Skip to content
Healthcare SoftwareEngineering

Architecture

Healthcare Event-Driven Architecture That Survives Real Message Traffic

Clinical systems already speak in events: admissions, transfers, orders, results, discharges. We design the brokers, contracts, and consumers that let those events flow reliably, including when they arrive twice, late, or in the wrong order.

Event-driven architecture: overview

Healthcare was event-driven long before the term existed. An HL7 v2 ADT feed is a stream of facts about patient movement, and an ORU feed is a stream of results. The problem is that traditional point-to-point interfaces bake routing, transformation, and business logic into one place, usually an interface engine channel nobody wants to touch. A modern event-driven architecture separates those concerns: producers publish facts once, a durable log keeps them, and any number of consumers react independently.

The difficult parts are not the broker. They are ordering, duplication, and meaning. An A08 patient update can arrive before the A01 admission it modifies. A FHIR Subscription can redeliver a notification after a timeout, or quietly stop firing after the server marks the endpoint as errored. A merge (A40) changes which patient every earlier event belonged to. We design for these cases explicitly: partition keys that preserve per-patient order, idempotent consumers keyed by message control ID or resource version, parking lots for early arrivals, and reconciliation jobs that catch silent gaps.

Events are not free, and they are not right for every interaction. A clinician waiting for a medication interaction check needs a synchronous answer, not an eventually consistent projection. We use events where decoupling and replay add value, such as feeding analytics, notifications, care-gap engines, and downstream products, and keep request-response where a human is waiting. Choosing between them per interaction is the architecture.

Engineering challenges in event-driven architecture

  • 01Out-of-order clinical messages

    An update arrives before the create, a cancel before the order, a result before the specimen is registered. Consumers that assume order either reject valid data or apply changes to the wrong state.

  • 02Duplicates from at-least-once delivery

    Brokers, interface engines, and FHIR Subscriptions all redeliver on timeout. Without idempotency, a duplicate ORU can create two result entries or send a patient two identical notifications.

  • 03Silent subscription failures

    A FHIR Subscription moves to an error state or a TCP listener stops accepting connections, and nothing alerts. Downstream systems simply stop receiving updates until someone notices missing data.

  • 04Event schemas without contracts

    Producers add, rename, or reinterpret fields without notice. Consumers break in production, or worse, keep running with a field now meaning something different.

  • 05PHI scattered across topics

    Fat events copied into many topics, retained for months, and replicated to analytics clusters multiply where PHI lives and complicate access control, retention, and breach scope.

Technical capabilities

What our event-driven architecture work covers

  • Event modeling and contracts

    We define domain events such as PatientAdmitted or ResultFinalized with clear semantics, schemas in Avro, Protobuf, or JSON Schema, and compatibility rules enforced by a registry. Each event has a documented owner and a list of known consumers.

  • Ordering by design

    Partition keys are chosen so all events for a patient or encounter land on the same partition in order. Where producers cannot guarantee order, consumers use sequence numbers, timestamps from the source, or resource versions to apply changes correctly.

  • Idempotent consumers

    Every consumer records processed message IDs, such as MSH-10 control IDs or FHIR resource version IDs, in the same transaction as its state change. Redelivery becomes a no-op rather than a duplicate clinical record.

  • Outbox-based publishing

    Services publish events through a transactional outbox, with change data capture or a polling relay forwarding them to the broker. Database state and published events cannot diverge.

  • CQRS read models

    For read-heavy views such as census boards or patient timelines, we build projections from the event stream into stores optimized for the query. Writes stay in the transactional model; reads scale independently and can be rebuilt by replay.

  • Dead-letter, parking, and replay

    Poison messages go to dead-letter topics with the failure reason, early arrivals wait in a parking store until their prerequisite appears, and operators can replay a time window after a fix. Each path has dashboards and alert thresholds.

  • Gap detection and reconciliation

    Heartbeats, expected-volume alerts, and periodic reconciliation against the source of truth catch the feed that silently stops. A census mismatch at 6 a.m. is better than a missed discharge at noon.

Software architecture

Reference architecture for event-driven architecture

Sources publish into a durable log through adapters; consumers subscribe independently and own their own state, with dedicated paths for failures and replay.

  1. Sources
    • EHR HL7 v2 feeds
    • FHIR Subscriptions
    • Device gateways
    • Internal service outboxes
  2. Ingestion
    • MLLP and HTTP adapters
    • Validation and enrichment
    • Canonical event mapping
    • Schema registry
  3. Event backbone
    • Partitioned log
    • Retention policies
    • Dead-letter topics
    • Replay tooling
  4. Consumers
    • Clinical notifications
    • CQRS projections
    • Analytics sink
    • Workflow engines
  5. Control
    • Lag and volume monitors
    • Reconciliation jobs
    • Access policies per topic
    • Audit stream
Illustrative layering; actual architecture is decided per engagement and documented in decision records.

Technology stack for event-driven architecture

Brokers and logs
Apache KafkaConfluent CloudAmazon MSKAzure Event HubsGoogle Pub/Sub
Queues
Amazon SQS / SNSAzure Service BusRabbitMQ
Integration
Mirth ConnectRhapsodyApache CamelHAPI HL7v2
Schemas
Confluent Schema RegistryApicurioAvroProtobufCloudEvents
Processing
Kafka StreamsApache FlinkDebeziumTemporal

Security & compliance

Security and compliance considerations for event-driven architecture

What regulations require

  • 45 CFR 164.312(c)(1) requires policies and procedures to protect ePHI from improper alteration or destruction; duplicate or misordered event processing that corrupts clinical records falls squarely within that integrity standard.
  • The minimum necessary standard (45 CFR 164.502(b)) requires limiting uses and disclosures of PHI to what is needed for the purpose, which argues against broadcasting full clinical payloads to every subscriber.
  • Audit controls under 45 CFR 164.312(b) apply to brokers and consumers that store or process ePHI, including retained event logs.

Recommended engineering practices

  • Thin events carrying identifiers and change type, with consumers fetching detail through authorized APIs when they need it.
  • Topic-level access control lists mapped to service identities, reviewed like database grants.
  • Retention set per topic based on replay needs, with PHI topics on the shortest retention that still supports recovery.
  • Encryption in transit between producers, brokers, and consumers, and encryption at rest for broker storage.
  • Field-level encryption or tokenization for sensitive elements such as SSNs or 42 CFR Part 2 data that must traverse shared topics.

Regulatory summaries are educational, not legal advice. HIPAA compliance is an organizational program; software can support safeguards but cannot by itself make an organization compliant. Systems that handle PHI need their own risk analysis, vendor evaluation, and Business Associate Agreements before deployment.

Integration capabilities

Integrations we engineer for event-driven architecture

  • HL7 v2 ADT (A01, A03, A04, A08, A40) feeds
  • HL7 v2 ORM/OML orders and ORU results
  • FHIR R4 Subscriptions and R5 topic-based subscriptions
  • SIU scheduling messages
  • Device and RPM telemetry gateways
  • Data warehouses and lakehouses
  • Clinical notification and paging systems
  • Workflow and care management engines

Engineering methodology

How we approach event-driven architecture

  1. 1

    Inventory existing feeds

    We document every interface, message type, volume, and consumer, including the undocumented ones found in interface engine channels.

  2. 2

    Model domain events

    With clinical and integration staff we define canonical events, their semantics, ordering keys, and which systems are authoritative for each.

  3. 3

    Build the backbone and paved consumer

    Broker, registry, outbox relay, and a consumer template with idempotency, dead-lettering, and tracing are built and load-tested.

  4. 4

    Migrate feeds incrementally

    Point-to-point interfaces move onto the backbone one at a time, running in parallel with reconciliation before the old route is retired.

  5. 5

    Operate with gap detection

    Volume baselines, lag alerts, and daily reconciliation reports go live with each migrated feed, along with replay runbooks.

Business use cases

Where event-driven architecture delivers value

  • Real-time bed and census board

    ADT events feed a CQRS projection that powers a live census view, rebuilt from the log if the read store is lost.

  • Result notification to patients

    Finalized results trigger patient notifications after release-delay rules apply, with idempotency preventing duplicate messages on redelivery.

  • Fan-out to new products

    A digital health company adds a care-gap service by subscribing to existing encounter and result events, without changing producers.

  • Retiring point-to-point interfaces

    Dozens of duplicated ADT feeds to ancillary systems are replaced by one canonical stream with per-consumer filtering.

Technical comparison

Integration styles for clinical data flows
ConcernPoint-to-point interfacesMessage queueEvent log (streaming)
Adding a consumerNew interface per consumerNew queue or subscriptionNew consumer group; producer unchanged
OrderingPer connectionUsually per queue, limitedPer partition key, such as patient ID
Replay after a bugRarely possibleLost once acknowledgedRe-read from retained offset
Duplicate handlingEngine-specificConsumer must be idempotentConsumer must be idempotent
PHI footprintSpread across channelsTransientRetained; needs retention policy
Best fitOne-off legacy feedsTask distribution, commandsClinical facts many systems need

Typical deliverables

What a event-driven architecture engagement produces

  • Interface and event inventory with owners and volumes
  • Event catalog with schemas, semantics, and ordering keys
  • Broker and schema registry configuration as code
  • Consumer template with idempotency, dead-lettering, and tracing
  • Parking and replay tooling with runbooks
  • Lag, volume, and gap-detection dashboards and alerts
  • Topic access and retention policy

Event consumer readiness checklist

  • Idempotency key defined and stored in the same transaction as state changes
  • Behavior defined for out-of-order and early-arriving events
  • Patient merge and unmerge events handled
  • Dead-letter topic with alerting and an owner
  • Replay tested from a past offset in a non-production environment
  • Consumer lag and expected-volume alerts configured
  • Schema compatibility checked in CI

Cost and timeline factors

What shapes event-driven architecture cost and timeline

  • Number and diversity of source feeds and message types
  • Ordering and latency requirements per consumer
  • Amount of business logic currently embedded in interface engine channels
  • Managed versus self-operated broker
  • Replay and retention requirements
  • Number of consumers to migrate off point-to-point routes

Typical timeline

Standing up the backbone with a first migrated feed typically takes several weeks to a quarter. Migrating a hospital's full interface portfolio onto events is a multi-quarter effort sequenced by risk and dependency.

Read the cost guide

Event-driven architecture FAQs

How do you handle an HL7 A08 that arrives before the A01?

The consumer should not reject it or apply it blindly. Common approaches are parking the update until the admission arrives, creating a provisional encounter that the later A01 completes, or using source timestamps and sequence numbers to apply changes in the right order. The choice depends on the downstream system, but the behavior must be designed, tested, and monitored, with a timeout that escalates parked messages that never resolve.

What does idempotency mean for healthcare events?

It means processing the same message more than once has the same effect as processing it once. Consumers store a unique key, such as the HL7 MSH-10 message control ID or a FHIR resource version, in the same transaction as their state change, and skip messages already recorded. Because most brokers and interface engines deliver at least once, idempotency is what prevents duplicate results, orders, or patient notifications.

When should we use CQRS in a healthcare system?

Use CQRS when read and write needs differ sharply, such as a patient timeline or census board that must aggregate many sources quickly while writes remain transactional. Avoid it for simple CRUD screens, where it adds eventual consistency and extra moving parts for little benefit. Read models in CQRS should be rebuildable from the event log, which also helps recovery.

Do events replace FHIR APIs?

No. Events tell systems that something changed; APIs let them read current state and act with proper authorization. A common pattern is a thin event announcing a new or updated resource, followed by an authorized FHIR read for the details. That keeps PHI out of broadly shared topics and lets access control stay at the API layer.

How do you detect a FHIR Subscription that stops firing?

Monitor the subscription's status on the server, track expected event volume by hour and day of week, and alert when volume drops well below baseline. R5 and the R4 Subscriptions Backport define heartbeat notifications and event counts that make gaps detectable. A periodic reconciliation query against the source catches anything the volume check misses.

Discuss your healthcare engineering project

Tell us about the system, the integrations it depends on, and the constraints you are working within. A senior engineer will review it and reply with questions, not a sales script.