patient-data-integrity-check

Validates referential integrity and consistency of patient and provider data across Django models.

Updated May 11, 2026
One-click install
npx skills add https://github.com/thachrocky12345/local-agent-train-workstation --skill patient-data-integrity-check-thachrocky12345
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: patient-data-integrity-check
Source: https://github.com/thachrocky12345/local-agent-train-workstation/tree/main/.claude/skills/patient-data-integrity-check
Command: npx skills add https://github.com/thachrocky12345/local-agent-train-workstation --skill patient-data-integrity-check-thachrocky12345

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Healthcare databases accumulate orphaned records, mismatched user types, invalid credentials, and inconsistent scores after migrations, bulk imports, or seed data loading. This Skill systematically audits patient and provider data across all Django models to detect and optionally fix these integrity issues before they corrupt reports or break the UI. ## Core Features & Use Cases - Orphan Detection: Finds Clients, CareProviders, Appointments, Notes, UserResponses, and StripeUsers missing their required parent records, including string-based room_name links between Notes and Appointments. - Credential & NPI Validation: Runs Luhn checksum validation on NPI numbers and checks license, degree, and NPI year fields for expired, future, or inverted date ranges. - Business Rule Audits: Flags unlicensed providers with scheduled appointments, completed appointments without payment, risk screening score mismatches, and crisis-flagged responses lacking follow-up. - Use Case: After a data migration, run the check with --model all --verbose to get a full report of orphaned records and consistency violations, then rerun with --fix to apply safe remediations like deactivating orphans. ## Quick Start Ask the assistant to run a data integrity check across all patient and provider models and report any orphaned records or invalid credentials.

Frequently Asked Questions about patient-data-integrity-check

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I check for orphan records in a Django database?

Query each child model filtering for null foreign keys, such as Client.objects.filter(user__isnull=True), and compare user_type flags against actual profile records. This Skill provides ready-made ORM queries covering Users, Clients, CareProviders, Appointments, Notes, and StripeUsers.

How to validate an NPI number with the Luhn algorithm?

Prepend the prefix 80840 to the 10-digit NPI, then apply the standard Luhn checksum doubling every second digit from the right. The Skill includes a validate_npi function that also checks length, digit-only content, and the required leading 1 or 2.

Can this check fix data integrity issues automatically?

Yes, the generated management command supports a --fix flag that applies safe remediations such as deactivating orphan records and recalculating risk screening scores. Destructive changes are avoided; fixes are limited to reversible operations.

Why are Notes not linked to Appointments by foreign key?

The video_conferencing Notes model links to Appointments through a room_name CharField string match rather than a ForeignKey. Orphan detection for Notes therefore requires comparing room_name value sets instead of FK joins.

What are the limitations of this data integrity check?

The check requires direct database access via Django shell or a management command and an up-to-date migration state. It does not validate data against external systems like the NPI registry, and empty nullable M2M fields are treated as incomplete onboarding rather than errors.