Blog

    A Mental Model for Healthcare Integrations: Events, Documents and Queries

    By GauravNovember 26, 20269 mins read
    On this page

    Healthcare integration discussions often start with standards: should this be HL7 v2 or FHIR, an API or a file? Those questions matter, but they come second. The first question is what kind of exchange the two systems need, and teams that skip it build a query where an event was needed, or a feed where a snapshot would do.

    This post gives a small mental model that fits almost every integration: three exchange shapes, events, documents and queries, plus two choices, push or pull and synchronous or asynchronous. It shows when each fits, how they combine and how to choose for a new connection.

    What is a mental model for healthcare integrations?

    Planning connections between clinical systems?

    Our system integration service designs and builds the interfaces between EHRs, apps and partners.

    A mental model for healthcare integrations is a short set of questions that describes any exchange before a standard is chosen: is it an event, a document or a query, who starts it, and does the sender wait for an answer? Agnotic Technologies uses it to design interfaces that match how the data is actually used.

    Once the shape is clear, the standard and the transport usually follow from what the other system supports.

    Why do integrations need a shared model?

    Integrations need a shared model because clinicians, product owners and engineers describe the same need in different words. A request to get the patient's medications could mean a feed of every change, a snapshot at discharge or a lookup when a nurse opens a screen.

    Each of those is a different integration, with different failure modes and costs. Naming the shape early stops a team from building the wrong one well.

    What are the three exchange shapes?

    The three shapes are events, which say something happened; documents, which hand over a complete, signed snapshot; and queries, which ask the source for current data when it is needed.

    Three healthcare exchange shapes compared: events that announce a change, documents that hand over a signed snapshot, and queries that ask the source for current data, with an example, who starts each and what the receiver must handle

    HL7 FHIR R4 defines several ways to exchange data: a RESTful client and server API with create, read, update, delete and search, messaging that routes messages from system to system, and documents in which the content is wrapped by a Composition that keeps its context and a fixed presentation.

    HL7 v2 maps onto the same shapes: an admission message is an event, a transcribed report can travel as a document, and some interfaces support queries.

    When should you use events?

    Use events when the receiver needs to know that something happened soon after it happens, such as an admission, a discharge, a new result or a cancelled appointment. The sender pushes a notice and moves on.

    In HL7 FHIR R4, the Subscription resource defines a push-based subscription: once registered, the server checks every created or updated resource against the criteria and sends a message on the defined channel when one matches.

    Events suit work that is triggered by change: alerts, worklists and keeping a copy of data up to date. The receiver must handle duplicates, events that arrive out of order and events it missed while it was down.

    When should you use documents?

    Use documents when the receiver needs a complete record of a moment that will not change afterwards, such as a discharge summary, a referral letter or a signed report. The document carries its author, date and context with it.

    Documents suit handoffs between organizations and anything a clinician must read as a whole. They are poor at keeping data current, because a corrected document replaces the old one rather than updating a field.

    When should you use queries?

    Use queries when the receiver needs the latest data at the moment a person or process asks for it, such as current medications when a pharmacist opens a review or eligibility when a visit is booked.

    Queries keep the source as the single truth and avoid storing copies. Their cost is dependence: if the source is slow or down, the screen waits or fails, so plan a timeout and a clear message.

    Push versus pull

    Push means the system with the data starts the exchange; pull means the system that needs it asks. Events and most document deliveries are pushed, while queries are pulled.

    Pull is simpler to secure and reason about, since the receiver controls timing. Push gets data to the receiver sooner but needs an endpoint that is always available and a way to replay what was missed.

    Should the exchange be synchronous or asynchronous?

    Make it synchronous when a person is waiting and the answer changes what they do next, and asynchronous when the work can finish later. A query behind a screen is usually synchronous, while event and document delivery are usually asynchronous.

    Asynchronous exchange needs acknowledgments, retries and a dead letter queue for messages that never succeed. Synchronous exchange needs timeouts and a fallback for when the other side does not answer.

    Combining the shapes

    Many reliable integrations combine shapes. A common pairing is notify then query: an event carries only an identifier, and the receiver queries the source for the full, current data.

    Another pairing is event plus document: a discharge event triggers delivery of the discharge summary. Combining shapes lets each part do what it is good at, instead of stretching one shape to cover everything.

    Security for each shape

    Each shape puts the security work in a different place. A query needs the caller authenticated and limited to the data it may see, often through OAuth scopes when the caller is a SMART on FHIR app.

    Pushed events and documents need the receiving endpoint protected, the sender verified and the content limited to what the receiver is allowed to hold. For every shape, log who sent or asked for what and when, so any disclosure can be traced later.

    How do you choose for a new integration?

    Choose by answering a few questions about how the receiver uses the data, before discussing standards.

    • Timing: does the receiver need to know when something happens, or only what is true when it asks?
    • Completeness: does it need a signed snapshot to read as a whole, or individual data elements?
    • Initiative: which side can start the exchange, given firewalls and vendor limits?
    • Waiting: is a person waiting for the answer?
    • Failure: what should happen if the other system is down for an hour?

    What goes wrong when the shape is wrong?

    A mismatched shape usually works in testing and fails under real use. These patterns recur.

    • Polling for events: a query run every few minutes to detect changes, loading the source and still arriving late.
    • Copies treated as truth: a feed of events stored and queried later, without handling missed or corrected events.
    • Documents used as data: fields pulled from documents to keep a record current.
    • Synchronous chains: a screen waiting on several systems in a row.
    • No replay: pushed events lost while the receiver was down.

    A worked example: a care management application

    A care management application needs to know when its patients are admitted, to read their discharge summaries and to show current medications during calls. The team first wrote these as three plain needs, not as interface requests.

    Admissions became events from the hospital's ADT feed, discharge summaries arrived as documents triggered by the discharge event, and medications became a query to the EHR's FHIR API when a care manager opened the call screen.

    Each part was tested for its own failure: missed events, corrected documents and a slow query.

    Who owns what?

    Each integration needs a business owner for the need and a technical owner for the shape and its failures.

    • Product or clinical owner: what the receiver needs and how quickly.
    • Integration lead: the shape, standard and transport.
    • Source system team: what it can send or answer, and its limits.
    • Operations: monitoring, replays and incident response.

    How do you test each shape?

    Test each shape against the failures that belong to it, not only the happy path.

    • Events: duplicates, out-of-order arrival and a receiver restart with replay.
    • Documents: a corrected document replacing an earlier one.
    • Queries: slow responses, timeouts and the message the user sees.
    • All: monitoring that shows when the exchange stopped.

    What are mental model healthcare integrations best practices?

    Name the shape before the standard, write each need in the receiver's words, prefer pull unless timing demands push, and combine shapes where one alone would be stretched.

    Design for each shape's failure from the start: replays for events, replacements for documents and timeouts for queries. Record the chosen shape and the reason in the interface catalog, so later changes keep it.

    How Agnotic can help

    Agnotic designs and builds healthcare integrations from the need outward: naming the exchange shape, choosing standards such as HL7 v2 and FHIR, and building feeds, document delivery and queries with the monitoring and replay each one needs.

    Plan your next integration with Agnotic

    Our interoperability work covers EHR, partner and device connections designed around how data is used.

    Related reading on Agnotic

    Integration platforms, FHIR exchange and HL7 v2.

    Sources

    Frequently Asked Questions

    Events that announce a change, documents that hand over a complete snapshot, and queries that ask for current data when needed.

    Talk to an engineer about your project

    Describe one integration you are planning. We will name its shape and the failures it must handle.

    Go deeper

    Services and solutions on this topic