Bidirectional order and result exchange between Epic Beaker and external reference laboratories over HL7v2, with a MuleSoft compendium-mapping layer that normalizes send-out test codes and reconciles results back to the originating Beaker order. Covers reflex tests, corrected results, and result-to-order matching failures.
Tags: healthcare, epic, hl7v2, loinc, interoperability, api-led, system-api, process-api
Reference Labs
Objective: Reference labs receive send-out orders and return results that must land on the correct Beaker order without manual reconciliation. The friction is real: each reference lab publishes its own test compendium and result codes, uses its own accession numbers, and returns reflex and corrected results that do not map cleanly to the placer order. Done looks like a Beaker outbound order (OML) reliably reaching the reference lab, and every inbound result (ORU) — including reflexes, corrections, and cancellations — matching back to its placer order automatically, with unmatched results routed to a human queue instead of silently dropped or filed to the wrong patient. This accelerator packages the Reference Labs Epic Data Sharing Playbook as a MuleSoft-anchored solution plan.
What's Getting Built
- Beaker HL7v2 (System API) — consumes Beaker outbound send-out orders from Bridges and returns the ORL placement acknowledgment ·
MLLP LISTEN OML^O21, MLLP SEND ORL^O22
- Order Result (Process API) — validates the placer order, resolves the compendium mapping, stamps a correlation ID, and hands the mapped order to the reference-lab gateway ·
CONSUME OML^O21, COMPENDIUM MAP, EMIT ORL^O22 on reject
- Reference Lab (System API) — sends the mapped send-out order to the reference lab over MLLP and listens for inbound results ·
MLLP SEND OML^O21, MLLP LISTEN ORU^R01
- Result Match (Process API) — matches inbound results to their placer order, handles reflex and corrected results, and files them back to Beaker through Bridges ·
CONSUME ORU^R01, MATCH filler-to-placer, MLLP SEND ORU^R01
- Reconciliation Queue (Object Store) — retains the raw HL7v2 of unmatched results for human reconciliation and replay by correlation ID ·
PUT /{correlationId}, GET /{correlationId}, DELETE /{correlationId}
- Master Order Index (System API) — persists per-order state keyed by correlation ID for end-to-end tracing across the exchange ·
PUT /order/{correlationId}, GET /order/{correlationId}
Prerequisites
- Epic Bridges interface engine configured with outbound OML and inbound ORU/ORR interfaces for the reference-lab connection, with placer/filler order-number conventions agreed.
- A reference-lab test compendium mapping each Beaker orderable to the lab's send-out code, container type, and expected result LOINC codes.
- Reference lab endpoint over MLLP/TCP or secure SFTP/HTTPS batch, with agreed HL7v2 version (typically 2.5.1) and acknowledgment mode.
- Anypoint Platform environment with MLLP or TCP connector, VM/Anypoint MQ for dead-letter queues, and Secrets Manager for credentials.
- LOINC and specimen/container reference data loaded for result normalization and unit-of-measure checks.
- Signed data-exchange agreement and test-facility routing table (which orders route to which reference lab).
1. Epic interfaces and standards
This accelerator implements the Reference Labs Epic Data Sharing Playbook. Register the connecting app on Epic on FHIR and confirm the customer has the relevant Epic modules licensed before building.
- Beaker (send-out lab orders and result filing)
- Bridges (HL7v2 OML, ORU, ORR, ORG interfaces)
- HL7v2 ORU-R01 and ORU-R30 result messages
- HL7v2 OML-O21 outbound order messages
- LOINC-coded OBX result observations
- Cogito (reference-lab turnaround-time and reconciliation analytics)
Architecture
2. Business requirements
- Route each Beaker send-out order to the correct reference lab based on orderable and performing-lab rules, not on free-text.
- Map every Beaker orderable to the reference lab's send-out code, specimen container, and expected result LOINC before transmission.
- Match every inbound result to its originating placer order using placer/filler order numbers, not patient demographics alone.
- Handle reflex results, corrected results (OBX result-status R to C), and order cancellations as first-class flows.
- Never drop an unmatched result: route it to a human reconciliation queue with the full original message retained.
3. Outbound order ingestion and mapping
- Consume OML-O21 from Bridges in the Beaker System API; validate ORC/OBR placer order number is present and unique.
- Look up the orderable in the compendium; reject with an ORL-O22 application error if no mapping exists rather than sending a guess.
- Transform to the reference lab's HL7v2 dialect with DataWeave, injecting send-out test code, container, and priority into OBR.
- Stamp a correlation ID onto ORC-2 placer number lineage so the later result can be reconciled deterministically.
- Emit an ORL-O22 acknowledgment back to Beaker on accepted transmission and on downstream MLLP NAK.
4. Result matching and normalization
- Match inbound ORU on filler-to-placer order number first, falling back to accession plus patient identifier only when configured.
- Normalize result OBX units and codes to the expected LOINC from the compendium; flag mismatches instead of overwriting.
- Detect reflex results (OBR without a matching placer order) and attach them to the parent order per the compendium reflex rule.
- Preserve result status transitions so corrected results (status C) supersede prior finals in Beaker rather than duplicating them.
- Convert lab-native abnormal flags and reference ranges into the OBX-8 and OBX-7 values Beaker expects.
5. Orchestration and operations
- Sequence multi-OBR panels so a partial result set does not file as a complete order in Beaker.
- Persist order state (sent, acknowledged, resulted, corrected, cancelled) keyed by correlation ID for end-to-end tracing.
- Alert on the absence of an expected result past the compendium turnaround time, the failure mode dashboards miss most often.
- Replay dead-lettered messages by correlation ID after a mapping or endpoint fix without re-triggering Beaker.
- Publish reconciliation and turnaround metrics to Cogito for per-lab performance monitoring.
6. 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.
- Restrict the reference-lab MLLP endpoint to allowlisted source IPs and mutual TLS; never accept results from unauthenticated senders.
- Validate that the patient and order identifiers on an inbound result belong to an order this platform actually sent, to prevent misfiled results.
- Retain the raw inbound HL7v2 for every unmatched result in an encrypted store for reconciliation and audit, not just the parsed fields.
- Segregate per-lab credentials and compendium data so one reference-lab connection cannot read or write another's routing.
Sample payload — Inbound ORU-R01 result from reference lab (HL7v2 2.5.1)
MSH|^~\&|REFLAB|QUESTDX|EPICBEAKER|HOSPITAL|20260820113000||ORU^R01^ORU_R01|MSG00042|P|2.5.1
PID|1||E1000234^^^EPIC^MR||DOE^JANE^A||19850214|F
ORC|RE|PLC784512^EPICBEAKER|FIL9930021^REFLAB
OBR|1|PLC784512^EPICBEAKER|FIL9930021^REFLAB|83036^Hemoglobin A1c^REFLAB|||20260819080000|||||||20260819093000|SER^Serum||||||20260820110000||CH|F
OBX|1|NM|4548-4^Hemoglobin A1c^LN||6.9|%|4.0-5.6|H|||F|||20260820110000
NTE|1||Corrected reference range per method update.
Testing and validation
- Send an OML with an orderable that has no compendium mapping; assert an ORL-O22 rejection and no MLLP transmission.
- Round-trip an order and matching ORU; assert the result files to the correct placer order in Beaker.
- Inject a reflex OBR with no direct placer order; assert it attaches to the parent order per the reflex rule.
- Send a corrected result (status C) after a final (status F); assert Beaker supersedes rather than duplicates.
- Send an ORU whose order numbers match no sent order; assert it lands in the reconciliation queue with raw message retained.
- Withhold an expected result past turnaround time; assert the missing-result alert fires.
Phased rollout
Phase 1 — Connect
- Establish MLLP/TLS connectivity and exchange test messages with the reference lab in a non-production environment.
- Stand up the Beaker and reference-lab System APIs and confirm OML consumption and ORR acknowledgment against Bridges.
Phase 2 — Map and test
- Load and validate the reference-lab compendium; run MUnit suites for mapping, matching, reflex, and corrected-result flows.
- Reconcile a batch of historical or synthetic orders end to end and confirm zero misfiled and zero silently dropped results.
Phase 3 — Production
- Cut over one low-volume orderable set first, monitoring the reconciliation queue and turnaround alerts daily.
- Expand to the full compendium once unmatched-result rate and manual reconciliation volume hold below agreed thresholds.
Success metrics
- Result-to-order auto-match rate (target above 98 percent).
- Unmatched results routed to the reconciliation queue per day and mean time to resolve.
- Median and 95th-percentile order-to-result turnaround time per reference lab.
- Corrected-result supersede accuracy (no duplicate finals in Beaker).
- Orders rejected for missing compendium mapping per week.
Troubleshooting
- Results consistently land in the reconciliation queue instead of matching. — Likely cause: The reference lab is not echoing the placer order number in ORC-2/OBR-2, or echoes it in a different field. Fix: Confirm the placer/filler number convention with the lab and adjust the matching DataWeave to read the field the lab actually populates.
- Beaker shows duplicate final results for the same test. — Likely cause: Corrected results (OBX-11 status C) are being filed as new observations instead of superseding the prior final. Fix: Preserve result-status transitions in the Process API and map status C to a supersede rather than an insert before filing to Bridges.
- An orderable transmits with the wrong send-out code and the lab runs the wrong test. — Likely cause: A stale or ambiguous compendium mapping resolved the Beaker orderable to an incorrect reference-lab code. Fix: Version the compendium, fail closed on ambiguous mappings, and require an explicit one-to-one orderable-to-send-out-code entry.
Deliverable: Anypoint blueprint with three System APIs (Beaker HL7v2, reference-lab gateway, master order index), an order/result Process API with a compendium-mapping layer and DataWeave OML-to-lab and ORU-to-Beaker transforms, a correlation-ID dead-letter queue with replay, plus MUnit suites and a Postman collection covering order placement, result matching, reflex, and corrected-result flows.