EHR Quality-Governance Skill
Reusable entry instructions for generating normalized EHR quality-governance packets, referral coordination summaries, care transition packets, duplicate-review validations, and batch audits against a read-only FHIR-aligned REST API. These rules are distilled from five representative task archetypes (merge readiness, referral coordination, care transition, duplicate+ServiceRequest review, and batch audit) and are designed to transfer to any task expressed in the same prompt/payload idiom.
When to apply this skill
Activate this skill when a prompt:
- References an EHR quality-governance, referral, duplicate-chart merge, care-transition, or audit queue task.
- Points at a read-only REST API reachable at
<TASK_ENV_BASE_URL> (or a concrete base_url provided via environment_access.md).
- Asks for normalized JSON output conforming to an
answer_template.json payload.
- Mentions clinical entities: patients, conditions, medications, allergies, encounters, documents, immunizations, disclosures, providers, referrals, duplicates, ServiceRequests, ICD-10 codes, audit logs, or service codes.
Environment setup
- Read
environment_access.md for the base_url (default http://task-env:9015/) and the allowed endpoint list.
- All endpoints are read-only GET. No authentication, no write operations.
- Treat
<TASK_ENV_BASE_URL> in prompt text as a placeholder; substitute the base_url from environment_access.md.
- The complete endpoint catalog is documented in
api_reference.md (alongside this skill file).
Core operating rules
Rule 1 — Gather all evidence before deciding
For every task, fetch the full set of relevant resources before drawing conclusions. The standard evidence-gathering order:
- Primary entity — the patient(s), duplicate candidate(s), referral(s), or ServiceRequest named in the prompt.
- Active clinical lists — conditions, medications, allergies (all three, always, for every patient involved). Use the
/api/patients/{id}/conditions, /api/patients/{id}/medications, and /api/patients/{id}/allergies endpoints.
- Encounter history —
/api/patients/{id}/encounters. Filter for recency and relevance to the task's clinical domain.
- Documents —
/api/patients/{id}/documents. Assess document type, status (final vs preliminary vs cancelled), and date.
- Audit trail —
/api/audit-logs. Filter to entries referencing the patient(s) or task entities.
- Reference data — Providers (
/api/providers, /api/providers/{id}), ICD-10 codes (/api/icd10, /api/icd10/{code}), Service codes (/api/service-codes, /api/service-codes/{code}).
- Task-specific resources — duplicate candidates (
/api/duplicates/candidates, /api/duplicates/{id}), referrals (/api/referrals, /api/referrals/{id}), immunizations (/api/patients/{id}/immunizations), disclosures (/api/patients/{id}/disclosures), ServiceRequests (/api/patients/{id}/service-requests).
Rule 2 — Reconciling active clinical lists
When building clinical key unions across patients (merge packets) or for a single patient:
- Use the patient-specific active-list endpoints (
/api/patients/{id}/conditions, etc.) as the authoritative source over any preview or summary endpoint.
- Filter to active records only. Exclude records with statuses
inactive, resolved, entered-in-error, or equivalent.
- Extract the
normalized_key field from each active record.
- Deduplicate (union, not intersection) across patients for merge contexts.
- Sort alphabetically by
normalized_key unless the answer template explicitly states otherwise.
- Any record excluded because it is inactive, stale, or irrelevant must be reported in the
excluded_distractors or equivalent output section when the template provides one.
The entity model and key mapping conventions are documented in entity_model.md.
Rule 3 — Match, conflict, and identity signals
When comparing two patient records (duplicate candidates):
- Match signals are fields or normalized business signals that align between the records. Report them sorted alphabetically.
- Conflict signals are fields or normalized business signals that diverge.
- Demographic matches/conflicts are a finer-grained subset:
dob, given_name, phone, address, insurance, etc.
- Source identity signals from the duplicate-candidate endpoint response AND from directly comparing the full patient detail responses.
- If the duplicate-candidate endpoint provides its own signal list, augment it — do not replace it — with signals found from direct comparison.
Rule 4 — Evidence selection
- Documents: include only documents with
status: final (never preliminary or cancelled) that are relevant to the clinical question. Exclude internal-only document types (e.g., staff_message, admin_note) unless the task explicitly calls for them. Document the selection basis as identity_or_external_continuity_documents_only.
- Audit logs: include audit entries that reference the patients or task entities. Exclude system-internal entries with no clinical relevance.
- Encounters: select by recency AND clinical relevance to the task domain. A task about orthopedics should prefer orthopedic encounters; a task about cardiology should prefer cardiology encounters. When a count is specified (e.g., "four most relevant"), respect it exactly. Report excluded encounter IDs.
Rule 5 — Code validation (ICD-10, service codes)
For any task involving diagnosis codes or service codes:
- ICD-10 validation: Look up every diagnosis code against
/api/icd10/{code}. A code is valid if the ICD-10 directory returns a record for it; otherwise it is invalid / unknown_code.
- Chapter check: Extract the
chapter field from the ICD-10 lookup. Compare it to the expected chapter for the task's service line:
- Orthopedics →
Musculoskeletal
- Cardiology →
Circulatory
- Neurology →
Nervous
- etc.
A code from the wrong chapter is flagged
out_of_range_chapter.
- Narrative/laterality mismatch: Compare the diagnosis narrative text against the ICD-10 description and expected laterality terms from the directory. Flag
laterality_mismatch when the patient's condition mentions a side (left/right/bilateral) that conflicts with the code's description or when laterality is missing from a code that expects it. Flag narrative_mismatch when the narrative does not align with the code's clinical meaning.
- Service code validation: Look up service codes against
/api/service-codes/{code}. Flag as valid: false if the directory returns no match.
Rule 6 — Provider matching
When a task requires identifying a specialist or receiving provider:
- If a specific provider ID is given in the prompt or referral, fetch
/api/providers/{provider_id}.
- If no provider ID is given, search
/api/providers and filter by service_line matching the task's clinical domain.
- Extract:
provider_id, name, role, service_line, facility, phone, fax.
- For primary care providers: identify the PCP from the patient's encounter history or referral record.
Rule 7 — Packet readiness assessment
Every packet must conclude with a readiness determination:
ready (or ready_to_send, merge_ready): all required data is present, valid, and consistent. No blocking issues.
ready_with_review_note (or ready_with_risk_flags): data is sufficient to proceed but has flags that merit attention (e.g., risk flags on a care transition, conflict signals on a merge).
blocked (or hold_for_*, not_ready, needs_manual_review): one or more blocking issues prevent the packet from being sent. Enumerate the blocking issue codes.
- Blocking issues include: missing required documents, invalid diagnosis codes, incomplete allergy documentation, missing authorization, missing provider, disclosure not permitted, clinical mismatch.
Rule 8 — Output conventions
- Return JSON only. No narrative prose outside the JSON object.
- Dates: YYYY-MM-DD format.
- Arrays with set semantics: sort alphabetically by their primary sort key (typically the string value itself, or
normalized_key for clinical keys, or id for entity arrays) unless the answer template specifies a different ordering.
- Null vs. absent: When a field is structurally present in the template but has no value, use
null (not absent) for nullable fields. For arrays, use [] (empty array) when nothing qualifies.
- Enum values: use the exact string from the template's vocabulary. Never invent new enum values.
- Stable IDs: use the API-provided IDs verbatim. Never generate synthetic IDs.
- Task identification: when the template includes
task_id, set it to the exact value specified in the prompt or template (e.g., the train task identifier).
Rule 9 — Distractor and noise exclusion
- Inactive/resolved clinical records → exclude and report.
- Irrelevant document types → exclude and report.
- Audit entries unrelated to the task entities → exclude and report.
- Encounters outside the relevant time window or clinical domain → exclude and report.
- Stale immunizations or disclosures → exclude from the primary output but note any that were reviewed.
The exclusion reporting should mirror the template's structure: if the template has excluded_distractors, populate each category with the normalized keys or IDs of excluded items.
Rule 10 — Task-specific extraction patterns
Merge readiness (train_001 style):
- Source the duplicate candidate from
/api/duplicates/{candidate_id}.
- Fetch full patient records for both patient IDs.
- Build active clinical key unions across both patients' active list endpoints.
- Compare demographics for match/conflict signals.
- Identify the canonical target (the patient with more complete active data or the one explicitly tagged in the duplicate candidate).
- Collect document and audit evidence relevant to both patients.
Referral coordination (train_002 style):
- Source the referral from
/api/referrals/{referral_id}.
- Fetch the patient's active lists, encounters, documents.
- Validate the referral's diagnosis codes against ICD-10.
- Check allergy readiness: are allergies documented, non-conflicting, and complete?
- Identify the receiving provider from the referral or by service-line match.
- Assess authorization status.
- Construct the referral-letter field choices by matching clinical evidence to the template's enum options.
Care transition (train_003 style):
- Fetch patient detail, all three active clinical lists, encounters, immunizations, disclosures.
- Identify the recipient provider.
- Select exactly the N most relevant handoff encounters for the target service line, ordered newest to oldest.
- Extract the latest immunization.
- Find the applicable disclosure matching the recipient provider.
- Drive risk flags from active conditions and medications using the risk-flag evidence rules in
entity_model.md.
- Exclude stale encounters, inactive records, and unrelated distractors.
Duplicate review + ServiceRequest (train_004 style):
- Fetch the duplicate candidate and both patients.
- Determine duplicate status and merge decision independently from the candidate's own signals.
- Fetch the ServiceRequest and validate its service code, reason codes, and provider alignment.
- Assess SBAR coverage (Situation, Background, Assessment, Recommendation) from the available documentation and clinical evidence.
Batch audit (train_005 style):
- List all referrals in the batch via
/api/referrals (filter/search by batch ID).
- For each referral: validate its diagnosis code, check for laterality/narrative mismatches, check authorization status, check document completeness.
- Group duplicates (same patient, same clinical context, multiple referral rows).
- Detect insurance-patient anomalies (shared insurance across different patients, or same patient with separate clinical referrals).
- Assign Tier 1 (immediate: urgent coding or duplicate blockers), Tier 2 (short-term: routine coding/auth/document blockers), Tier 3 (administrative: document completion).
- Drive summary counts from the validated results, not from batch-level aggregates — every count must be traceable to individual referral rows.
Supporting files
api_reference.md — complete endpoint catalog with resource hierarchies and field notes.
entity_model.md — entity relationship map, normalized key conventions, risk-flag evidence rules, and enum vocabulary cross-reference.
1---2name: self-attempt-02-553description: EHR Quality-Governance Skill4---5# EHR Quality-Governance Skill67Reusable entry instructions for generating normalized EHR quality-governance packets, referral coordination summaries, care transition packets, duplicate-review validations, and batch audits against a read-only FHIR-aligned REST API. These rules are distilled from five representative task archetypes (merge readiness, referral coordination, care transition, duplicate+ServiceRequest review, and batch audit) and are designed to transfer to any task expressed in the same prompt/payload idiom.89## When to apply this skill1011Activate this skill when a prompt:1213- References an EHR quality-governance, referral, duplicate-chart merge, care-transition, or audit queue task.14- Points at a read-only REST API reachable at `<TASK_ENV_BASE_URL>` (or a concrete `base_url` provided via `environment_access.md`).15- Asks for normalized JSON output conforming to an `answer_template.json` payload.16- Mentions clinical entities: patients, conditions, medications, allergies, encounters, documents, immunizations, disclosures, providers, referrals, duplicates, ServiceRequests, ICD-10 codes, audit logs, or service codes.1718## Environment setup19201. Read `environment_access.md` for the `base_url` (default `http://task-env:9015/`) and the allowed endpoint list.212. All endpoints are **read-only GET**. No authentication, no write operations.223. Treat `<TASK_ENV_BASE_URL>` in prompt text as a placeholder; substitute the `base_url` from `environment_access.md`.234. The complete endpoint catalog is documented in `api_reference.md` (alongside this skill file).2425## Core operating rules2627### Rule 1 — Gather all evidence before deciding2829For every task, fetch the full set of relevant resources before drawing conclusions. The standard evidence-gathering order:30311. **Primary entity** — the patient(s), duplicate candidate(s), referral(s), or ServiceRequest named in the prompt.322. **Active clinical lists** — conditions, medications, allergies (all three, always, for every patient involved). Use the `/api/patients/{id}/conditions`, `/api/patients/{id}/medications`, and `/api/patients/{id}/allergies` endpoints.333. **Encounter history** — `/api/patients/{id}/encounters`. Filter for recency and relevance to the task's clinical domain.344. **Documents** — `/api/patients/{id}/documents`. Assess document type, status (`final` vs `preliminary` vs `cancelled`), and date.355. **Audit trail** — `/api/audit-logs`. Filter to entries referencing the patient(s) or task entities.366. **Reference data** — Providers (`/api/providers`, `/api/providers/{id}`), ICD-10 codes (`/api/icd10`, `/api/icd10/{code}`), Service codes (`/api/service-codes`, `/api/service-codes/{code}`).377. **Task-specific resources** — duplicate candidates (`/api/duplicates/candidates`, `/api/duplicates/{id}`), referrals (`/api/referrals`, `/api/referrals/{id}`), immunizations (`/api/patients/{id}/immunizations`), disclosures (`/api/patients/{id}/disclosures`), ServiceRequests (`/api/patients/{id}/service-requests`).3839### Rule 2 — Reconciling active clinical lists4041When building clinical key unions across patients (merge packets) or for a single patient:4243- Use the **patient-specific active-list endpoints** (`/api/patients/{id}/conditions`, etc.) as the authoritative source over any preview or summary endpoint.44- Filter to **active** records only. Exclude records with statuses `inactive`, `resolved`, `entered-in-error`, or equivalent.45- Extract the `normalized_key` field from each active record.46- Deduplicate (union, not intersection) across patients for merge contexts.47- **Sort alphabetically** by `normalized_key` unless the answer template explicitly states otherwise.48- Any record excluded because it is inactive, stale, or irrelevant must be reported in the `excluded_distractors` or equivalent output section when the template provides one.4950The entity model and key mapping conventions are documented in `entity_model.md`.5152### Rule 3 — Match, conflict, and identity signals5354When comparing two patient records (duplicate candidates):5556- **Match signals** are fields or normalized business signals that align between the records. Report them sorted alphabetically.57- **Conflict signals** are fields or normalized business signals that diverge.58- **Demographic matches/conflicts** are a finer-grained subset: `dob`, `given_name`, `phone`, `address`, `insurance`, etc.59- Source identity signals from the duplicate-candidate endpoint response AND from directly comparing the full patient detail responses.60- If the duplicate-candidate endpoint provides its own signal list, augment it — do not replace it — with signals found from direct comparison.6162### Rule 4 — Evidence selection6364- **Documents**: include only documents with `status: final` (never `preliminary` or `cancelled`) that are relevant to the clinical question. Exclude internal-only document types (e.g., `staff_message`, `admin_note`) unless the task explicitly calls for them. Document the selection basis as `identity_or_external_continuity_documents_only`.65- **Audit logs**: include audit entries that reference the patients or task entities. Exclude system-internal entries with no clinical relevance.66- **Encounters**: select by recency AND clinical relevance to the task domain. A task about orthopedics should prefer orthopedic encounters; a task about cardiology should prefer cardiology encounters. When a count is specified (e.g., "four most relevant"), respect it exactly. Report excluded encounter IDs.6768### Rule 5 — Code validation (ICD-10, service codes)6970For any task involving diagnosis codes or service codes:7172- **ICD-10 validation**: Look up every diagnosis code against `/api/icd10/{code}`. A code is `valid` if the ICD-10 directory returns a record for it; otherwise it is `invalid` / `unknown_code`.73- **Chapter check**: Extract the `chapter` field from the ICD-10 lookup. Compare it to the expected chapter for the task's service line:74 - Orthopedics → `Musculoskeletal`75 - Cardiology → `Circulatory`76 - Neurology → `Nervous`77 - etc.78 A code from the wrong chapter is flagged `out_of_range_chapter`.79- **Narrative/laterality mismatch**: Compare the diagnosis narrative text against the ICD-10 description and expected laterality terms from the directory. Flag `laterality_mismatch` when the patient's condition mentions a side (left/right/bilateral) that conflicts with the code's description or when laterality is missing from a code that expects it. Flag `narrative_mismatch` when the narrative does not align with the code's clinical meaning.80- **Service code validation**: Look up service codes against `/api/service-codes/{code}`. Flag as `valid: false` if the directory returns no match.8182### Rule 6 — Provider matching8384When a task requires identifying a specialist or receiving provider:85861. If a specific provider ID is given in the prompt or referral, fetch `/api/providers/{provider_id}`.872. If no provider ID is given, search `/api/providers` and filter by `service_line` matching the task's clinical domain.883. Extract: `provider_id`, `name`, `role`, `service_line`, `facility`, `phone`, `fax`.894. For primary care providers: identify the PCP from the patient's encounter history or referral record.9091### Rule 7 — Packet readiness assessment9293Every packet must conclude with a readiness determination:9495- **`ready`** (or `ready_to_send`, `merge_ready`): all required data is present, valid, and consistent. No blocking issues.96- **`ready_with_review_note`** (or `ready_with_risk_flags`): data is sufficient to proceed but has flags that merit attention (e.g., risk flags on a care transition, conflict signals on a merge).97- **`blocked`** (or `hold_for_*`, `not_ready`, `needs_manual_review`): one or more blocking issues prevent the packet from being sent. Enumerate the blocking issue codes.98- **Blocking issues** include: missing required documents, invalid diagnosis codes, incomplete allergy documentation, missing authorization, missing provider, disclosure not permitted, clinical mismatch.99100### Rule 8 — Output conventions101102- Return **JSON only**. No narrative prose outside the JSON object.103- **Dates**: YYYY-MM-DD format.104- **Arrays with set semantics**: sort alphabetically by their primary sort key (typically the string value itself, or `normalized_key` for clinical keys, or `id` for entity arrays) unless the answer template specifies a different ordering.105- **Null vs. absent**: When a field is structurally present in the template but has no value, use `null` (not absent) for nullable fields. For arrays, use `[]` (empty array) when nothing qualifies.106- **Enum values**: use the exact string from the template's vocabulary. Never invent new enum values.107- **Stable IDs**: use the API-provided IDs verbatim. Never generate synthetic IDs.108- **Task identification**: when the template includes `task_id`, set it to the exact value specified in the prompt or template (e.g., the train task identifier).109110### Rule 9 — Distractor and noise exclusion111112- Inactive/resolved clinical records → exclude and report.113- Irrelevant document types → exclude and report.114- Audit entries unrelated to the task entities → exclude and report.115- Encounters outside the relevant time window or clinical domain → exclude and report.116- Stale immunizations or disclosures → exclude from the primary output but note any that were reviewed.117118The exclusion reporting should mirror the template's structure: if the template has `excluded_distractors`, populate each category with the normalized keys or IDs of excluded items.119120### Rule 10 — Task-specific extraction patterns121122**Merge readiness (train_001 style):**123- Source the duplicate candidate from `/api/duplicates/{candidate_id}`.124- Fetch full patient records for both patient IDs.125- Build active clinical key unions across both patients' active list endpoints.126- Compare demographics for match/conflict signals.127- Identify the canonical target (the patient with more complete active data or the one explicitly tagged in the duplicate candidate).128- Collect document and audit evidence relevant to both patients.129130**Referral coordination (train_002 style):**131- Source the referral from `/api/referrals/{referral_id}`.132- Fetch the patient's active lists, encounters, documents.133- Validate the referral's diagnosis codes against ICD-10.134- Check allergy readiness: are allergies documented, non-conflicting, and complete?135- Identify the receiving provider from the referral or by service-line match.136- Assess authorization status.137- Construct the referral-letter field choices by matching clinical evidence to the template's enum options.138139**Care transition (train_003 style):**140- Fetch patient detail, all three active clinical lists, encounters, immunizations, disclosures.141- Identify the recipient provider.142- Select exactly the N most relevant handoff encounters for the target service line, ordered newest to oldest.143- Extract the latest immunization.144- Find the applicable disclosure matching the recipient provider.145- Drive risk flags from active conditions and medications using the risk-flag evidence rules in `entity_model.md`.146- Exclude stale encounters, inactive records, and unrelated distractors.147148**Duplicate review + ServiceRequest (train_004 style):**149- Fetch the duplicate candidate and both patients.150- Determine duplicate status and merge decision independently from the candidate's own signals.151- Fetch the ServiceRequest and validate its service code, reason codes, and provider alignment.152- Assess SBAR coverage (Situation, Background, Assessment, Recommendation) from the available documentation and clinical evidence.153154**Batch audit (train_005 style):**155- List all referrals in the batch via `/api/referrals` (filter/search by batch ID).156- For each referral: validate its diagnosis code, check for laterality/narrative mismatches, check authorization status, check document completeness.157- Group duplicates (same patient, same clinical context, multiple referral rows).158- Detect insurance-patient anomalies (shared insurance across different patients, or same patient with separate clinical referrals).159- Assign Tier 1 (immediate: urgent coding or duplicate blockers), Tier 2 (short-term: routine coding/auth/document blockers), Tier 3 (administrative: document completion).160- Drive summary counts from the validated results, not from batch-level aggregates — every count must be traceable to individual referral rows.161162## Supporting files163164- `api_reference.md` — complete endpoint catalog with resource hierarchies and field notes.165- `entity_model.md` — entity relationship map, normalized key conventions, risk-flag evidence rules, and enum vocabulary cross-reference.