Retrieve a treating patient's records from external organizations over TEFCA and Carequality, normalize the returned C-CDA and IPS documents to FHIR R4, and feed reconciliation candidates into Epic so clinicians accept external problems, meds, and allergies into the chart rather than re-charting them.
External Health Records for Patient Treatment
Objective: A patient arrives for treatment with a history living in other health systems, and today that history is faxed, re-keyed, or missed, causing duplicate labs, missed allergies, and med errors. Done looks like this: at the point of care a query fans out across TEFCA and Carequality partners under the treatment purpose of use, matching C-CDA and IPS documents return, they normalize to FHIR R4, and discrete problems, meds, and allergies surface in Epic as reconciliation candidates the clinician accepts, declines, or merges. Success means external history is present before the visit ends, provenance is on every element, and nothing is written silently. This accelerator packages the External Health Records for Patient Treatment Epic Data Sharing Playbook as a MuleSoft-anchored solution plan.
What's Getting Built
- External Records Retrieval (Experience API) — called by Hyperdrive with patient context and a correlation ID, returns a partial result envelope marking slow partners still-pending, and writes reconciled data back to Epic via Bridges ·
POST /patients/{id}/external-records, GET /patients/{id}/external-records/status
- Normalize & Reconcile (Process API) — parses C-CDA R2.1 and IPS to FHIR R4, normalizes to SNOMED/RxNorm/LOINC, deduplicates against the local record, and emits reconciliation candidates with FHIR Provenance ·
POST /normalize, POST /reconcile
- Network Exchange (System API) — runs XCPD patient discovery then XCA cross-community query and retrieve, fanning out concurrently to TEFCA QHIN and Carequality partners with per-partner timeouts ·
POST /xcpd/discover, POST /xca/query, POST /xca/retrieve
- External Documents (Object Store) — retrieved C-CDA/IPS documents and their FHIR projection persisted keyed by correlation ID for audit and re-reconciliation ·
PUT /{correlationId}, GET /{correlationId}
- Unparseable C-CDA (Dead-letter queue) — captures unparseable or schema-invalid documents with the raw payload and partner HCID for triage and replay ·
PUBLISH dlq, REPLAY dlq
- Epic Care Everywhere Reconciliation (target) — receives external problems, meds, and allergies as candidates a clinician accepts, declines, or merges ·
POST /reconciliation-candidates
Prerequisites
- Epic connected to a QHIN and to Carequality with valid trust-bundle certificates and a registered home community ID (HCID) for XCA transactions
- Care Everywhere and external record reconciliation configured in Epic so incoming discrete data lands in the reconciliation workqueue rather than direct-writing the chart
- Anypoint Platform with an environment holding the QHIN client credentials, mTLS keystore, and trust bundle for participant endpoints
- A master directory or QHIN-provided endpoint catalog resolving trading-partner HCIDs to XCPD, XCA query, and XCA retrieve endpoints
- Documented treatment purpose-of-use policy and consent handling for each network (TEFCA XCA, Carequality)
- Epic patient demographics available to seed XCPD discovery (name, DOB, sex, address, identifiers)
1. Epic interfaces and standards
This accelerator implements the External Health Records for Patient Treatment Epic Data Sharing Playbook. Register the connecting app on Epic on FHIR and confirm the customer has the relevant Epic modules licensed before building.
- Care Everywhere and External Record Reconciliation (Hyperdrive clinician workflow)
- Bridges HL7v2 for optional discrete write-back and document routing
- FHIR R4: Patient, DocumentReference, Bundle document, AllergyIntolerance, MedicationStatement, Condition, Provenance
- IHE profiles XCPD patient discovery and XCA cross-community query and retrieve
- C-CDA R2.1 Continuity of Care Document and HL7 International Patient Summary (IPS)
Architecture
2. Business requirements
- Fire discovery under the treatment purpose of use only, and stamp every outbound request with that assertion so partners can enforce their own policy.
- Return external history before the encounter closes, not overnight; a summary that arrives after discharge is a summary nobody reads.
- Never auto-commit external data to the chart; produce reconciliation candidates a clinician accepts, declines, or merges.
- Preserve source attribution on every problem, med, and allergy so a clinician can see which organization asserted it and when.
- Deduplicate against the local record before surfacing a candidate, or the clinician drowns in fifteen copies of the same lisinopril.
3. Patient discovery and document exchange (System API)
- Run XCPD patient discovery first, sending Epic demographics to resolve a partner-side patient identifier before any document query.
- Treat XCPD as probabilistic: capture the returned match confidence and carry it forward; do not query documents on a weak demographic match.
- Issue XCA cross-community query to list DocumentReference entries, then XCA retrieve only the documents you actually need, keyed by document unique ID and repository ID.
- Fan out across trading partners concurrently with a per-partner timeout, because one slow QHIN participant must not stall the whole result set.
- Handle SAML assertion signing and mTLS at the connector layer; a request missing the purpose-of-use assertion is rejected by the partner, not by you.
4. Normalization and reconciliation (Process API)
- Parse C-CDA R2.1 and IPS documents in DataWeave into FHIR R4 Condition, MedicationStatement, and AllergyIntolerance resources with a shared internal shape.
- Normalize coded data to standard terminologies: SNOMED CT for problems, RxNorm for meds, and map lab observations to LOINC where present.
- Attach a FHIR Provenance resource to each candidate recording source organization HCID, document ID, and retrieval timestamp.
- Compute duplicate suppression by comparing code plus clinical status against the local record, so resolved and inactive items do not resurface as new.
- Emit reconciliation candidates to Epic through Care Everywhere reconciliation, letting the clinician make the final accept or merge decision.
5. Orchestration and delivery
- Drive the flow from an Experience API the Hyperdrive workflow calls with a patient context and correlation ID that threads through every downstream log.
- Return a partial result envelope: surface documents that arrived within the SLA and mark slow partners as still-pending rather than failing the whole call.
- Cache resolved partner endpoints and XCPD identifiers per patient for the encounter duration to avoid re-discovering on every document fetch.
- Persist retrieved documents and their FHIR projection in an object store keyed by correlation ID for audit and re-reconciliation.
- Separate query concurrency limits per network so Carequality throttling does not starve TEFCA retrieval and vice versa.
6. Error handling and operations
- Route unparseable or schema-invalid C-CDA to a dead-letter queue with the raw payload and partner HCID attached for triage, never silently drop it.
- Alert on the absence of expected responses: a partner that returns zero documents for a patient who should have history is the failure mode dashboards miss.
- Retry XCA retrieve with backoff on transient transport faults, but treat a SAML or policy rejection as terminal and surface it to operations, not to the clinician.
- Track XCPD match rate per partner over time; a sudden drop usually means a demographic mapping or trust-bundle regression, not sick patients.
- Redact PHI from logs and keep only correlation IDs, HCIDs, and status codes at INFO level, with full payloads gated behind a break-glass audit store.
7. Security and compliance
- Encrypt PHI in transit and at rest.
- Audit-log every access to and modification of patient data, and carry a correlation ID end to end.
- Enforce minimum-necessary access for integration operators and support users.
- Sign every outbound XCPD and XCA request with a SAML assertion carrying the treatment purpose of use, requesting provider, and organization, and reject responses whose policy assertions do not match the request.
- Terminate mutual TLS against the current TEFCA and Carequality trust bundles and fail closed if a partner certificate is not in the bundle or has been revoked.
- Enforce consent handling per network before querying, honoring opt-out flags a partner returns rather than assuming blanket treatment access.
- Store retrieved external documents encrypted at rest on a retention clock, since they are copies of another organization's record held under a treatment justification.
Sample payload — XCA-retrieved C-CDA normalized to a FHIR R4 AllergyIntolerance reconciliation candidate with provenance
{
"resourceType": "AllergyIntolerance",
"id": "ext-allergy-88213",
"clinicalStatus": {
"coding": [{"system": "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical", "code": "active"}]
},
"verificationStatus": {
"coding": [{"system": "http://terminology.hl7.org/CodeSystem/allergyintolerance-verification", "code": "confirmed"}]
},
"type": "allergy",
"category": ["medication"],
"criticality": "high",
"code": {
"coding": [{"system": "http://www.nlm.nih.gov/research/umls/rxnorm", "code": "7980", "display": "Penicillin G"}]
},
"patient": {"reference": "Patient/local-4471"},
"reaction": [{
"manifestation": [{"coding": [{"system": "http://snomed.info/sct", "code": "247472004", "display": "Hives"}]}],
"severity": "severe"
}],
"meta": {"source": "urn:oid:2.16.840.1.113883.3.9999.4471"}
}
Testing and validation
- Unit-test DataWeave C-CDA and IPS parsers against Epic-exported and non-Epic partner samples, since real-world C-CDA varies wildly in how sections are populated.
- Assert XCPD requests carry the treatment purpose-of-use assertion and reject flows where it is missing before any document query fires.
- Simulate a slow and a failing partner concurrently and confirm the Experience API returns a partial result with correct pending and error markers.
- Verify duplicate suppression against a local record fixture so an already-charted medication does not surface as a new candidate.
- Confirm every emitted candidate carries a Provenance resource with source HCID, document ID, and retrieval timestamp.
- Run MUnit coverage over the dead-letter path with a malformed C-CDA to prove the raw payload and partner HCID are preserved for triage.
Phased rollout
Phase 1 — Connect
- Register the home community ID and load TEFCA and Carequality trust bundles, then complete mTLS and SAML handshake tests against a QHIN test endpoint.
- Validate XCPD patient discovery end to end against a sandbox partner and confirm match confidence is captured.
Phase 2 — Map and test
- Build and unit-test C-CDA and IPS to FHIR R4 mappings against a corpus of partner document samples across multiple EHR vendors.
- Wire the reconciliation candidate output into an Epic non-production environment and confirm items land in the reconciliation workqueue, not the live chart.
Phase 3 — Production
- Enable for a single service line under the treatment purpose of use with clinician acceptance required, and monitor XCPD match rate and time-to-first-document.
- Expand trading-partner coverage and concurrency limits per network once dead-letter volume and reconciliation accept rates are stable.
Success metrics
- Time from Experience API call to first external document surfaced, tracked at the encounter level
- XCPD patient-match rate per trading partner and network
- Percentage of reconciliation candidates accepted, declined, or merged by clinicians
- Dead-letter volume of unparseable C-CDA documents per partner over time
- Duplicate-suppression rate: candidates filtered before reaching the clinician
Troubleshooting
- XCA document query returns zero documents for a patient who clearly has external history. — Likely cause: XCPD returned a weak or no demographic match, so no partner-side patient identifier was resolved to query against. Fix: Inspect the XCPD match confidence in the correlation log, enrich the outbound demographics (address, prior names, identifiers), and re-run discovery before querying documents.
- Retrieved C-CDA documents land in the dead-letter queue instead of producing candidates. — Likely cause: The partner's C-CDA populates sections in a structurally valid but non-conforming way the DataWeave parser did not anticipate. Fix: Pull the raw payload from the DLQ, add a mapping case for the partner's section layout, and add the sample to the parser test corpus.
- Partner rejects the request with a policy or authorization fault. — Likely cause: The SAML assertion is missing or misstates the treatment purpose of use or requesting-organization identifiers. Fix: Verify the assertion signing chain and confirm the purpose-of-use and organization claims match the partner's expected values, then retry; do not surface the error to the clinician.
- The same medication appears repeatedly as a new reconciliation candidate on every visit. — Likely cause: Duplicate suppression compares raw text rather than normalized RxNorm code plus clinical status against the local record. Fix: Normalize to RxNorm before comparison and include clinical status so resolved and already-charted items are suppressed.
Deliverable: A deployable Anypoint project: a Carequality/TEFCA System API that runs XCPD patient discovery and XCA query/retrieve, a Process API that maps C-CDA and IPS to FHIR R4 and computes clinical reconciliation candidates, and an Experience API that writes reconciled data back to Epic via Bridges, with DataWeave mappings, error-handling flows, dead-letter queues, and MUnit tests.