Reconciles Epic Willow medication orders, cabinet dispenses, and inventory with automated dispensing cabinets over HL7v2, so the profiled cabinet, the MAR, and on-hand counts agree at the point of service.
Tags: healthcare, epic, hl7v2, connected-devices, interoperability, api-led, event-driven, system-api
Automated Dispensing System
Objective: Automated dispensing cabinets and Epic Willow drift apart the moment they stop talking: a nurse pulls a med the cabinet still lists on a discontinued order, on-hand counts diverge from Willow's records, and pharmacy chases paper discrepancy reports at shift end. The goal is a bidirectional bridge where Willow's active medication profile is pushed to each cabinet, every dispense and return posts back against the correct order and encounter, and inventory reconciles continuously. Done looks like: the cabinet only offers meds on active orders, every withdrawal lands on the right MAR line, overrides are flagged, and unmatched dispenses queue for review instead of silently vanishing. This accelerator packages the Automated Dispensing System Epic Data Sharing Playbook as a MuleSoft-anchored solution plan.
What's Getting Built
- Cabinet (System API) — terminates the Willow and vendor MLLP feeds and maps orders to the cabinet formulary and profile format ·
MLLP LISTEN RDE^O11 / RXE, MLLP LISTEN RAS^O17 / RRD, MLLP LISTEN ADT A01/A02/A03, vendor inventory event feed, ACK/NAK
- Reconciliation (Process API) — matches dispenses to open order lines, drives the ledger, and posts profiles and dispenses to Willow through Bridges ·
match dispense to open order line, push RDE^O11 order profile to cabinet, post dispense to Willow via Bridges, reconcile on-hand vs posted dispenses
- Order to Dispense Ledger (Reconciliation database) — open order lines and dispense matches held for idempotency and continuous reconciliation ·
upsert dispense keyed on MSH-10 control ID, look up open order lines by patient and med, record match confidence
- Discrepancy DLQ (Anypoint MQ queue) — holds unmatched dispenses, unmapped formulary items, and unit-conversion failures with raw HL7 for pharmacy review and replay ·
publish discrepancy with raw HL7 + correlation ID, one-click replay against original control ID
- Epic Willow via Bridges (target) — receives the pushed order profile and posted dispenses, and serves read-side reconciliation to the MAR ·
RDE^O11 order profile out, RAS dispense post + ACK/NAK, FHIR R4 MedicationDispense / MedicationRequest read
Prerequisites
- Epic Willow licensed with Bridges configured for outbound pharmacy order (RDE/RXE) and inbound dispense/inventory interfaces over MLLP
- ADC vendor (Pyxis, Omnicell, or BD) interface engine reachable over MLLP or a documented REST/dispense API, with a test cabinet in a non-production pharmacy area
- Agreed HL7v2 profile version (2.5.1 recommended) and message set: RDE^O11/RXE for order profile, RAS/RRD dispense, plus vendor inventory event feed
- Master files aligned: Willow ERX/medication IDs, NDC, and the cabinet formulary mapped in a shared crosswalk
- Anypoint Platform with CloudHub 2.0 or RTF, a database for the order-to-dispense reconciliation ledger, and Anypoint MQ for the discrepancy DLQ
- Patient and encounter context feed (ADT A01/A02/A03) so dispenses attribute to the correct admission and location
1. Epic interfaces and standards
This accelerator implements the Automated Dispensing System Epic Data Sharing Playbook. Register the connecting app on Epic on FHIR and confirm the customer has the relevant Epic modules licensed before building.
- Willow Inpatient pharmacy medication profile and MAR
- HL7v2 RDE^O11 / RXE outbound order profile to the cabinet
- HL7v2 RAS^O17 / RRD dispense and return messages inbound
- HL7v2 ADT A01/A02/A03 for patient, encounter, and location context
- Bridges HL7v2 interface engine over MLLP with ACK/NAK
- Epic FHIR R4 MedicationRequest and MedicationDispense for read-side reconciliation
Architecture
2. Business requirements
- Only meds on an active Willow order may be offered for profiled withdrawal; discontinued and held orders must disappear from the cabinet within the agreed SLA.
- Every dispense, return, and waste event posts back to Willow against the originating order, encounter, and location, and reaches the MAR.
- Override withdrawals are permitted where clinically configured but must be flagged, attributed, and reconciled against a later order.
- On-hand counts in the cabinet and dispense records in Willow reconcile continuously, not just at shift change.
- A dispense that cannot be matched to an order is never dropped; it is queued for pharmacy review with full context.
3. Order profile push and dispense capture
- Consume Willow RDE^O11 / RXE order events at the Cabinet System API over MLLP, transform with DataWeave to the vendor order-profile format, and ACK only after the cabinet confirms load.
- Map RXO/RXE dosing, NDC, and Willow ERX medication ID to the cabinet formulary via the shared crosswalk; reject unmapped meds to the DLQ rather than guessing.
- Ingest RAS^O17 / RRD dispense and return messages, normalize withdrawal quantity to dispensable units, and stamp a correlation ID tying the event to the order.
- Carry ADT-derived encounter and bed location on every dispense so Willow attributes it to the current admission, not a stale one.
- Distinguish profiled pulls, overrides, returns, and waste as separate event types so downstream reconciliation and reporting stay unambiguous.
4. Matching, normalization, and reconciliation
- Match each dispense to an open order line in the ledger by patient, medication, and time window; record match confidence and route low-confidence matches to review.
- Normalize units at the boundary: Willow ordering units, cabinet package units, and NDC package size must resolve to a common dispensable-unit basis before quantities are compared.
- Reconcile expected-versus-actual on-hand from the vendor inventory event feed against posted dispenses, and open a discrepancy when the delta exceeds tolerance.
- Treat an override with no matching order as a first-class exception: attribute it, alert pharmacy, and hold it open until a covering order arrives or it is resolved manually.
- Idempotency-key every inbound dispense on message control ID so a redelivered RAS after an MLLP hiccup does not double-post to the MAR.
5. Orchestration and error handling
- Split the flow into a thin Cabinet System API for protocol and vendor mapping and a Reconciliation Process API for matching, ledger, and Willow posting, so vendor swaps do not touch clinical logic.
- Post dispenses to Willow through Bridges and confirm the ACK; on NAK, retain the event in the ledger as unposted and retry with backoff rather than silently dropping.
- Route unmatched dispenses, unmapped formulary items, and unit-conversion failures to a discrepancy dead-letter queue with the raw HL7 message and correlation ID attached.
- Support one-click replay from the DLQ once a crosswalk gap or late order is fixed, replaying against the original message control ID to preserve idempotency.
- Alert on the absence of an expected dispense feed from a cabinet, which is the failure mode a throughput dashboard misses when a single cabinet goes dark.
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 cabinet-facing MLLP listeners to the pharmacy VLAN and mutually authenticate the vendor interface engine; a dispensing feed is a controlled-substance chain-of-custody record.
- Preserve dispenser and witness identity from the cabinet event end to end so controlled-substance diversion analytics in Willow and Cogito stay attributable.
- Do not persist raw dispense messages containing PHI in the DLQ beyond the reconciliation retention window; tokenize patient identifiers in operational logs and dashboards.
- Segregate override and waste events with tighter access controls, since these are the primary signals reviewed in diversion investigations.
Sample payload — RAS O17 profiled dispense from cabinet, inbound to the System API
MSH|^~and&|PYXIS|PHARM|WILLOW|EPIC|20260820143210||RAS^O17^RAS_O17|MSGCTL0098231|P|2.5.1
PID|1||E1000472^^^EPIC^MRN||DOE^JANE^A||19540212|F
PV1|1|I|4WEST^441^01^MAIN||||1447382^SMITH^ROBERT^MD|||MED
ORC|RE|ORD778120^EPIC|DISP0098231^PYXIS||CM||||20260820143210
RXA|0|1|20260820143210|20260820143210|00093-0058-01^METOPROLOL TARTRATE 25 MG TAB^NDC|1|TAB^tablet||||4WEST^CAB03^BIN14|||||OVERRIDE=N
RXR|PO^oral
Testing and validation
- Replay a captured RDE order-profile stream against a test cabinet and confirm only active orders appear and discontinued orders drop within SLA.
- Send matched, override, return, and waste RAS events and assert each posts to the correct MAR line with the right event type and location.
- Inject an unmapped NDC and confirm it lands in the discrepancy DLQ with the raw message, not a silent drop or a wrong-med post.
- Redeliver an identical RAS message control ID and verify idempotency prevents a duplicate MAR post.
- Force a unit mismatch of each versus package and confirm the conversion guard fails safely to review rather than posting a wrong quantity.
- Kill a cabinet feed mid-test and confirm the missing-feed alert fires within the expected interval.
Phased rollout
Phase 1 — Connect
- Stand up the Cabinet System API MLLP listeners and confirm bidirectional ACK/NAK with the vendor test cabinet and the Willow non-production Bridges channel.
- Load the medication crosswalk and validate NDC, ERX ID, and formulary alignment against a sample of high-volume meds.
Phase 2 — Map and test
- Build and unit-test DataWeave maps for RDE order profile, RAS dispense, and inventory events with unit normalization and idempotency keys.
- Run the full reconciliation ledger against replayed production-shaped traffic and tune match windows and discrepancy tolerances with pharmacy.
Phase 3 — Production
- Go live on one nursing unit and one cabinet, with pharmacy monitoring the DLQ and discrepancy dashboard daily before expanding.
- Roll out unit by unit, comparing automated reconciliation against the legacy end-of-shift discrepancy report until the manual process is retired.
Success metrics
- Percent of dispenses auto-matched to an order without manual review
- Order-profile propagation latency from Willow discontinuation to cabinet removal
- Count and aging of open discrepancies and unmatched overrides
- Inventory reconciliation delta between cabinet on-hand and Willow dispense records
- Missing-feed alert mean time to detect per cabinet
Troubleshooting
- Dispenses land in the DLQ as unmatched despite an active order — Likely cause: The match window is tighter than the real gap between order signing and cabinet withdrawal, or ADT location on the dispense is stale. Fix: Widen the match time window, add a fallback match on patient plus medication, and confirm the ADT A02 transfer feed is current before attributing location.
- MAR shows a duplicated withdrawal for one physical pull — Likely cause: An MLLP redelivery replayed a RAS the cabinet had already sent and idempotency was keyed on the wrong field. Fix: Key idempotency on MSH-10 message control ID plus cabinet dispense ID, and deduplicate in the ledger before posting to Willow.
- A med stays available on the cabinet after the order is discontinued — Likely cause: The RDE discontinuation event was NAKed or the crosswalk lacks the current medication mapping. Fix: Inspect the Bridges NAK reason, repair the crosswalk entry, and replay the order-profile event from the DLQ against the original control ID.
- Quantities post to the MAR that do not match what was pulled — Likely cause: Cabinet package units were treated as ordering units with no NDC package-size conversion. Fix: Enforce the unit-normalization guard so package, each, and ordering units resolve to a common dispensable basis, and fail unconvertible events to review.
Deliverable: A deployable Anypoint project: a Willow-facing pharmacy System API, a dispense-reconciliation Process API, HL7v2 listeners and MLLP/REST connectors for the ADC vendor, DataWeave maps for RDE/RAS/RXE and inventory events, a discrepancy dead-letter queue with replay, plus dashboards, alerts, and a runbook covering cabinet outages and override reconciliation.