Stream high-volume Epic or Cerner ADT over HL7v2 into Salesforce Health Cloud in minutes, not hours — filtered at the interface engine, ordered per patient on an Anypoint MQ FIFO queue, and batched to stay inside Salesforce limits.
Efficient Patient 360: Optimized EHR to Salesforce Health Cloud via HL7v2
Objective: Keep Salesforce Health Cloud current with every patient registration, update, transfer, discharge, and merge from the EHR's HL7v2 ADT feed — at health-system volume (a million or more ADT messages a day) with minutes of lag, not hours. Per-patient ordering comes from an Anypoint MQ FIFO queue grouped on the MRN, so the app scales out with normal replicas instead of throttling everything through a single worker. Noise is filtered at the interface engine before it ever reaches Mule. This is a Health Cloud sync for engagement, contact-center, and care-coordination teams — not an enterprise data platform.
What's Getting Built
- ADT Receiver (Experience API) — MLLP listener that validates, filters on the event allow-list, ACKs, and publishes to the FIFO queue with the MRN as the Message Group ID ·
MLLP LISTEN ADT^A01/A02/A03/A04/A08/A40, ACK AA (including filtered messages), PUBLISH groupId = PID-3
- ADT FIFO queue (Anypoint MQ) — FIFO queue that guarantees order within each patient's message group while different patients drain in parallel ·
PUBLISH (Message Group ID = MRN), CONSUME polling, AUTO ack, DLQ after max deliveries
- Patient Sync (Process API) — Polling consumer that maps ADT to the canonical patient model, applies merges and cancels, and batches upserts to Health Cloud ·
CONSUME ADT FIFO queue, MAP PID / PV1 / MRG to canonical, BATCH upsert by MRN
- Salesforce Health Cloud (System API) — System API that upserts person accounts and encounters keyed on the EHR MRN external ID ·
UPSERT Account (external ID = MRN), UPSERT ClinicalEncounter, Bulk / Composite batch
- Epic / Cerner EHR (target) — Source EHR and interface engine publishing ADT over HL7v2 MLLP ·
MLLP ADT feed, Interface-engine route filter (MSH-9.2, PV1-2, PV1-3)
- Dead-letter queue (Anypoint MQ) — DLQ that receives messages past the max-delivery count, raises an alert, and holds the raw payload for manual review and replay ·
ALERT on first DLQ message, GET for review, REPUBLISH to FIFO queue
Prerequisites
- Anypoint Platform org with CloudHub 2.0 (or Runtime Fabric) and Anypoint MQ entitlement for FIFO queues.
- MuleSoft Accelerator for Healthcare Patient 360 HL7v2 assets imported from Exchange.
- Interface-engine access (Epic Bridges, Rhapsody, Cloverleaf, or equivalent) to define the outbound ADT route and its filter.
- Salesforce Health Cloud org with a connected app for the System API and enough daily API allocation for the projected batched volume.
Choose your path
- Anypoint MQ FIFO grouped by MRN (recommended) — Choose for most programs. The broker enforces per-patient order, a failure only blocks that patient's group, and you scale by adding replicas — no custom partitioning code.
- MRN-partitioned lanes — Choose when Anypoint MQ FIFO isn't available. Hash the MRN (for example, its last one or two digits) into 10–100 lanes, each a VM queue with its own single-threaded Process and System API pair. Order holds per lane, and a failure stops only that lane.
EHR vendor notes
Epic
- HL7v2: Receive ADT over an Epic Bridges outbound MLLP interface — use the receiving application and facility IDs assigned in your connection spec.
- Filter in Bridges first: restrict the outbound route to the event allow-list and, if needed, to in-scope facilities (PV1-3) and patient classes (PV1-2).
- Strip or suppress communication-preference segments from ADT — Epic can carry hundreds of preference settings per patient, which bloats every message and multiplies API calls. Sync consent only, or route preferences through a warehouse or Data Cloud.
- Epic's FHIR Patient create is limited; if you add FHIR later, keep HL7v2 ADT as the source for registration and merge events.
Cerner (Oracle Health)
- HL7v2: Outbound ADT over MLLP on Millennium tenant-specific ports with the correct sending and receiving entities.
- Apply the same event allow-list and facility filter in the Millennium interface definition or your interface engine before the feed reaches Mule.
- Cerner location and provider registries differ from Epic — validate facility codes in PV1-3 against your Millennium source of truth.
Architecture
1. Business requirements
- Reflect patient registration, demographic updates, transfers, discharges, and merges in Health Cloud within minutes at peak volume.
- Never apply a patient's events out of order (for example, a discharge before its admit, or an update after a merge).
- Isolate failures so one bad message blocks only its own patient, never the whole feed.
- Stay inside Salesforce API limits and avoid row-lock contention on shared parent records.
- Meet HIPAA minimum-necessary and audit requirements for every read and write.
2. Why the single-worker design falls behind
The common first design runs the consumer with maxConcurrency="1" so messages are processed strictly in order. It works in test and then collapses in production: at roughly a million ADT messages a day, one worker making synchronous Salesforce calls builds a backlog of 10–16 hours. Global ordering is the wrong goal — ordering only matters within a patient. Make the broker enforce per-patient order and let everything else run in parallel.
3. Reduce volume at the source
Filter as far upstream as possible: in the interface engine (Epic Bridges, Rhapsody, Cloverleaf) first, otherwise in the Mule MLLP receiver before publishing to Anypoint MQ.
- Event allow-list on MSH-9.2: keep
A01 (admit), A04 (register), A03 (discharge), A08 (update), A02 (transfer), and A40 (merge). Drop events Health Cloud doesn't need, such as A28, A31, and A60.
- Optional scope filters: limit to in-scope facilities on PV1-3 and patient classes on PV1-2 (for example, inpatient and emergency only for a first phase).
- Guardrail — keep the cancels and merges: for any event you keep, also keep its cancel (
A11 cancels A01/A04, A12 cancels A02, A13 cancels A03) and keep A40 merges. Dropping these leaves Health Cloud with admissions that never happened and duplicate patients.
- Guardrail — always ACK: return
AA for filtered messages too. A missing or negative ACK makes the EHR retry and can stall the whole outbound queue.
- Result: less volume per message group, fewer row locks in Salesforce, and faster draining.
4. Ordered, scalable processing with Anypoint MQ FIFO
- Use a FIFO queue, not a standard queue. Standard queues don't guarantee order.
- Message Group ID = MRN. In the receiver, set the group ID from PID-3 with DataWeave on the Publish operation (for example,
messageGroupId: payload.PID."PID-03"[0]."CX-01"). Anypoint MQ allows 10 in-flight messages per group and places no limit on the number of groups, so thousands of patients drain concurrently while each patient stays in order.
- Use polling mode, not prefetch. Prefetch is the subscriber default and pulls messages ahead into a local buffer, which breaks ordering. Configure the subscriber for polling.
- Use AUTO acknowledgement, not IMMEDIATE. IMMEDIATE acks on receipt, so a failure mid-flow loses the message and lets the next one for that patient through. AUTO acks only after the flow completes successfully.
- Set
acknowledgementTimeout longer than worst-case processing time (including Salesforce retries). If it expires first, the broker redelivers and you process the same event twice, possibly out of order.
- Configure a DLQ on the FIFO queue with a max-delivery count (for example, 5), an alert on the first DLQ message, and a manual review process to fix and republish.
- Then remove
maxConcurrency="1" and the single worker. Ordering now comes from the broker, so scale replicas normally on CloudHub 2.0 based on queue depth and lag.
5. Writing to Health Cloud efficiently
- Batch writes. Collect upserts into Composite or Bulk API batches and tune batch size and flush frequency against your lag target and API allocation; per-message synchronous calls are the main source of rate-limit errors.
- Avoid row locks. Sort batches by parent record and keep a single patient's records in one batch; concurrent updates under the same parent account cause
UNABLE_TO_LOCK_ROW.
- Key on one MRN. When all facilities run on a single EHR instance, key the person account directly on the EHR MRN external ID. This avoids a separate MPI link-and-unlink layer and the extra calls each merge would otherwise trigger.
- Handle merges deliberately. An
A40 re-parents encounters and related records from the old MRN to the surviving one; merge workflows generate many more calls than an update, so measure them separately when sizing.
- Only sync what's approved. Bring in only the fields compliance has signed off on; don't sync communication preferences raw.
6. Data mapping
- Map PID-3 (MRN) to the Health Cloud external ID for idempotent upserts; map MRG-1 to the retired MRN on merges.
- Normalize names, addresses, and phone numbers before writing.
- Handle null and unknown HL7 values (
"" vs empty) explicitly rather than overwriting good data with blanks.
- Version code-set tables (facility, patient class, provider) separately from flow logic so updates don't require redeploys.
7. Error handling and operations
- MLLP connection resilience: enable TCP keep-alive and reconnect with backoff on the listener so an interface-engine restart doesn't require restarting the Mule app. Where the engine supports it, HTTP(S) delivery is an alternative to raw MLLP.
- Retry transient Salesforce failures with bounded exponential backoff, within the acknowledgement timeout.
- Monitor queue depth, oldest-message age per queue, DLQ count, and EHR-event-to-Health-Cloud lag; alert when lag exceeds target.
- Use idempotency on MSH-10 so EHR retries and broker redeliveries don't create duplicate writes.
8. Security and visibility
- Encrypt PHI in transit with TLS or mutual TLS on the MLLP and Salesforce legs; optionally add AES-256 payload encryption on queued messages.
- Encrypt PHI at rest and audit-log every access to and modification of patient data.
- Enforce minimum-necessary access for integration operators and support users.
- Restrict sensitive records (for example, patients flagged as employees) behind a break-the-glass process in Health Cloud, with every access audit-logged.
For additional HIPAA controls, API policies, and reference security patterns, see the MuleSoft Accelerator for Healthcare on Anypoint Exchange.
Sample payload — HL7v2 ADT^A08 (patient update)
MSH|^~\&|SENDING_APP|SENDING_FAC|RECEIVER|RECEIVER_FAC|20260101120000||ADT^A08|MSG00001|P|2.5
EVN|A08|20260101120000
PID|1||MRN12345^^^EPIC^MR||DOE^JANE^M||19850315|F|||123 MAIN ST^^ANYTOWN^CA^90210
PV1|1|I|{facility}^101^01||||1234567890^SMITH^JOHN^A^^^NPI
Testing and validation
- Send an A28 and confirm it's filtered, returns AA, and never reaches the queue.
- Send A01, A08, A03 for one MRN in quick succession with several replicas running; confirm Health Cloud applies them in order.
- Interleave messages for many MRNs and confirm they drain in parallel while each MRN stays ordered.
- Force a Salesforce failure for one MRN; confirm only that group pauses, the message lands in the DLQ after the max-delivery count, the alert fires, and other patients keep flowing.
- Send an A40 merge followed by an update to the surviving MRN; confirm related records re-parent and no duplicate account remains.
- Restart the interface engine and confirm the MLLP listener reconnects without restarting the Mule app.
- Replay a production-sized day of de-identified ADT and confirm peak lag stays within target.
Phased rollout
Phase 1 — Connect
- Import the HL7v2 Patient 360 template; create the FIFO queue and DLQ; configure the MLLP listener and Health Cloud connected app in a non-production environment with TLS and audit logging.
- Define the event allow-list and facility filter in the interface engine, mirroring it in the receiver as a safety net.
Phase 2 — Map and test
- Map one facility's ADT demographics and encounters, including merges and cancels.
- Load-test at projected peak volume and tune replica count, batch size, flush interval, and acknowledgement timeout.
Phase 3 — Production
- Expand facilities and patient classes on a defined schedule while watching lag, DLQ volume, and API usage.
- Hand off the DLQ review runbook, alert routing, and HIPAA audit evidence to operations before cutover.
Success metrics
- EHR-event-to-Health-Cloud lag ≤ 5 minutes at the 95th percentile during peak hours.
- Zero out-of-order updates for the same MRN.
- DLQ messages reviewed and resolved within one business day.
- Salesforce API usage stays under 70% of the daily allocation at peak; no sustained UNABLE_TO_LOCK_ROW errors.
- Zero duplicate Health Cloud records for the same EHR MRN after go-live.
Configuration checklist
Before first sandbox deploy, complete the shared Healthcare integration configuration checklist — secure property keys, TLS, OAuth, and credential naming conventions are documented once for all Exchange use cases.
9. Implementation starting point
Build from the accelerator assets on Anypoint Exchange rather than an empty project:
Download the MuleSoft Accelerator for Healthcare Patient 360 assets from Exchange and start from the HL7v2 implementation template.
Split the template into an MLLP receiver that filters, ACKs, and publishes to an Anypoint MQ FIFO queue with messageGroupId set to the MRN, and a Process API that consumes in polling mode with AUTO acknowledgement.
Configure the DLQ, max-delivery count, and alert, then remove maxConcurrency="1" and scale replicas on CloudHub 2.0.
Replace per-message Salesforce calls with batched upserts keyed on the MRN external ID. Keep the accelerator's API-led layering — Experience, Process, and System APIs — intact.
Troubleshooting
- Backlog grows to hours during the day — Likely cause: a single worker (
maxConcurrency="1") or per-message synchronous Salesforce calls. Fix: Move to a FIFO queue grouped on the MRN, scale replicas, and batch upserts.
- Updates for one patient apply out of order — Likely cause: prefetch mode, IMMEDIATE acknowledgement, a standard queue, or an acknowledgement timeout shorter than processing time. Fix: Use a FIFO queue, polling mode, AUTO acknowledgement, and an acknowledgement timeout above worst-case processing time.
- EHR outbound queue stalls — Likely cause: filtered or failed messages aren't ACKed, so the EHR keeps retrying. Fix: Return AA for filtered messages and ACK only after the message is safely published to Anypoint MQ.
- UNABLE_TO_LOCK_ROW or REQUEST_LIMIT_EXCEEDED from Salesforce — Likely cause: concurrent writes under the same parent record or too many individual API calls. Fix: Group a patient's records in one batch, sort batches by parent, and tune batch size and frequency.
- MLLP listener stops receiving after an interface-engine restart — Likely cause: stale TCP connection without keep-alive or reconnect. Fix: Enable keep-alive and reconnect with backoff on the listener, or switch to HTTP(S) delivery if the engine supports it.
- Messages are very large and API volume spikes — Likely cause: communication-preference segments carried on every ADT. Fix: Suppress them in the interface engine and sync consent only, or route preferences through a warehouse or Data Cloud.
Deliverable: A horizontally scalable Mule application that streams filtered HL7v2 ADT from Epic or Cerner through an Anypoint MQ FIFO queue grouped by MRN into Salesforce Health Cloud, with per-patient ordering, batched writes, and a monitored dead-letter queue.