Integrate pharmacy carousels and dispensing robots with Epic Willow Inventory so dispense orders become pick tasks and every pick, refill, and waste event reconciles back to Willow perpetual inventory with lot and expiration traceability.
Tags: healthcare, epic, connected-devices, hl7v2, event-driven, system-api, process-api, interoperability
Medication Carousels & Robots
Objective: Central-pharmacy carousels and dispensing robots hold most of a hospital's medication inventory, but only help if Willow knows what they contain and can drive them. Without integration, technicians double-key picks, perpetual inventory drifts from physical stock, and controlled-substance counts fail audit. Done looks like this: a verified dispense or cart-fill order in Willow becomes a pick task on the right device automatically; every pick, restock, return, and waste posts back as an adjustment against the correct NDC, lot, and expiration; and Willow reconciles to the physical count on a schedule with discrepancies flagged rather than silently absorbed. This accelerator packages the Medication Carousels & Robots Epic Data Sharing Playbook as a MuleSoft-anchored solution plan.
What's Getting Built
- Vendor Driver (System API) — speaks each carousel or robot's native contract for pick tasks and event confirmations ·
POST pick task, RECEIVE pick/refill/return/waste confirmation
- Willow Inventory (System API) — consumes RDS dispense orders over MLLP via Bridges, reads item master and stock levels, and posts inventory adjustments through Willow inventory web services ·
MLLP LISTEN RDS^O13, GET item master / stock level, POST inventory adjustment
- Dispense Orchestration (Process API) — validates mapping, dispatches picks, awaits confirmation, posts adjustments, and closes the loop ·
validate + map order, dispatch pick task, post adjustment
- Dead Letter Queue (Object Store) — holds unmapped items, out-of-stock picks, and device faults with raw payload and correlation ID for one-click replay ·
ENQUEUE unmatched, REPLAY
- Scheduled Recon Job (Scheduler) — pulls device on-hand and Willow stock levels and flags variance beyond per-item tolerance ·
SCHEDULER daily reconcile, GET device on-hand, GET Willow stock
Prerequisites
- Epic Willow Inventory live, with dispensing and cart-fill workflows configured and storage locations modeled for each device bay.
- Bridges interface engine access to publish and consume HL7v2 over MLLP, or Willow inventory web services enabled for the connecting app.
- Carousel and robot vendor middleware exposing an API, HL7v2 feed, or database drop for pick tasks and event confirmations.
- Anypoint Platform org with a deployment target reachable from the pharmacy VLAN where the devices sit.
- NDC-to-Willow item master crosswalk and per-device bin and canister to storage-location mapping agreed with pharmacy operations.
- Controlled-substance handling and witnessed-waste policy confirmed with the pharmacy DEA compliance owner.
1. Epic interfaces and standards
This accelerator implements the Medication Carousels & Robots 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 Inventory as the perpetual-inventory system of record
- HL7v2 RDS pharmacy dispense messages and inventory-adjustment segments over MLLP via Bridges
- Willow inventory web services for item master, storage location, and stock-level reads
- Hyperdrive pharmacy workqueues where technicians verify and route dispense orders
- NDC and lot and expiration identifiers carried on RXD-style segments
Architecture
2. Business requirements
- Turn every verified Willow dispense and cart-fill order into a device pick task without a technician re-keying the medication, quantity, or location.
- Post every device pick, restock, return, expiry pull, and waste back to Willow as an inventory adjustment against the correct NDC, lot, and expiration.
- Keep Willow perpetual inventory reconciled to physical device stock so counts survive audit rather than drifting.
- Support mixed fleets so a carousel line, a high-speed packaging robot, and a unit-dose robot can all hang off the same orchestration.
- Treat controlled substances as a first-class path with witnessed-waste capture, not an afterthought bolted onto general dispensing.
3. Ingestion and pick-task dispatch
- Consume Willow dispense and cart-fill orders as HL7v2 over MLLP through Bridges, or read them from Willow inventory web services where the site prefers request-response.
- Map each order line from the Willow item and storage location to the exact device, bin, or canister, and reject lines with no device mapping to the DLQ rather than guessing.
- Emit the pick task in the vendor's native contract via the Vendor Driver System API so the orchestration layer never speaks a proprietary dialect directly.
- Transform units of measure in DataWeave, since Willow may order in eaches while a carousel meters in packages or a robot in unit-dose blisters.
- Stamp a correlation ID on the pick task and carry it back on the confirmation so a pick is traceable order to canister to adjustment.
4. Event capture and inventory reconciliation
- Receive pick, refill, return, and waste confirmations from device middleware and normalize them to one internal event shape before mapping to Willow adjustments.
- Post inventory adjustments back to Willow keyed by NDC, lot, and expiration so the perpetual count and the physical canister agree at the lot level.
- Run a scheduled reconciliation that pulls device on-hand counts and Willow stock levels and flags any variance beyond a per-item tolerance for pharmacy review.
- Never auto-zero a discrepancy, because a silent correction hides shrinkage, miscalibration, and diversion, which is exactly what reconciliation exists to catch.
- Debounce and de-duplicate device events by correlation ID, because carousel middleware commonly re-sends confirmations on reconnect.
5. Orchestration and error handling
- Sequence the flow in the Dispense Orchestration Process API as validate mapping, dispatch pick, await confirmation, post adjustment, close the loop.
- Apply idempotent handling on both directions so a replayed order does not double-pick and a replayed confirmation does not double-adjust inventory.
- Route unmapped items, out-of-stock picks, and device faults to a dead-letter queue with the raw payload and correlation ID attached for one-click replay.
- Alert on the absence of an expected confirmation within an SLA window, since a pick task that never confirms is the failure mode dashboards miss most often.
- Fail a device offline cleanly by parking its orders for manual pull and re-releasing them automatically when the device returns.
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.
- Segment the pharmacy device VLAN and terminate MLLP inside it, exposing only the Process API northbound to Willow and never the raw vendor driver.
- Require witnessed-waste attestation on controlled-substance events and preserve the witness identity on the inventory adjustment for DEA traceability.
- Enforce lot and expiration integrity end to end so a recalled or expired lot pulled at the device reflects in Willow immediately, not at next reconciliation.
Sample payload — HL7v2 RDS dispense order becoming a carousel pick task
MSH|^~&|WILLOW|HOSP|MULE_ORCH|PHARM|20260820103015||RDS^O13|MSG00042|P|2.5.1
PID|1||MRN00891^^^HOSP^MR||DOE^JANE||19540212|F
ORC|RE|ORD778201|DISP556677|||||||||PHRM01^TECH^ALEX
RXD|1|00093-7146-01^METOPROLOL TARTRATE 50 MG TAB^NDC|20260820103015|30|TAB^tablet|CAROUSEL_A^BIN_0417|LOT^L24H882|20271130
ZPM|1|CAROUSEL_A|PICK|CORR-9f2c81a4-7bd0
Testing and validation
- Round-trip a dispense order to a pick task and confirm the pick posts a matching Willow adjustment at the correct lot.
- Force an unmapped NDC and confirm the line lands in the DLQ with correlation ID intact.
- Replay a duplicate confirmation and assert inventory is adjusted exactly once.
- Take a device offline mid-flow and confirm orders park then auto-release on return.
Phased rollout
Phase 1 — Connect
- Stand up the Vendor Driver System API against one device make in a lab or non-production carousel and confirm pick-task and confirmation contracts.
- Wire the Willow System API to Bridges in a test interface and echo dispense orders without dispatching to hardware.
Phase 2 — Map and test
- Load the NDC-to-item and bin-to-location crosswalk for one carousel line and run round-trip picks with reconciliation in test.
- Validate DataWeave unit-of-measure transforms across eaches, packages, and unit-dose forms with pharmacy sign-off.
Phase 3 — Production
- Go live on one high-volume carousel with reconciliation running daily and the DLQ monitored, then add the packaging and unit-dose robots.
- Enable controlled-substance flows only after witnessed-waste capture and DEA traceability are validated in production monitoring.
Success metrics
- Share of dispense orders auto-dispatched with zero technician re-keying.
- Inventory variance at reconciliation per device per day.
- Median order-to-confirmation time and count of pick tasks breaching SLA.
Troubleshooting
- Willow perpetual count drifts above physical device stock over a shift — Likely cause: Refill or return events are being dropped or de-duplicated too aggressively, so decrements post but increments do not. Fix: Check correlation-ID debounce windows and confirm every device event type maps to an adjustment, then replay missed increments from the DLQ.
- A dispense order never produces a pick and no error fires — Likely cause: The pick task dispatched but the device confirmation never arrived, and nothing watches for the missing event. Fix: Enable absence-of-event alerting on the confirmation SLA and park the order for manual pull until the device responds.
- Reconciliation flags the same item as short every run — Likely cause: The bin-to-storage-location mapping or unit-of-measure transform is wrong, so counts are compared in mismatched units. Fix: Re-verify the crosswalk row and DataWeave conversion for that item and reconcile once manually before re-enabling the job.
Deliverable: Three MuleSoft APIs — a Willow System API, a Dispense Orchestration Process API, and a per-vendor driver System API — that keep Willow Inventory and pharmacy automation in two-way sync: dispense orders become device pick tasks, and every pick, refill, return, and waste reconciles back to Willow at the NDC and lot level, with a DLQ and scheduled reconciliation.