Written by Technical Team | Last updated 20.11.2026 | 24 minute read
Polling a FHIR server every few seconds to discover whether a patient record has changed is straightforward to implement, but difficult to operate efficiently at scale. A clinical application monitoring 10,000 patient records at 30-second intervals could generate 28.8 million requests per day, even when very little clinical information has changed. Most requests return unchanged resources, while updates occurring between polling intervals remain undetected until the next request.
HL7 FHIR R5 provides a more efficient approach through topic-based Subscriptions. Instead of repeatedly querying for changes, a subscribing application registers its interest in particular clinical events. The FHIR server evaluates changes against defined criteria and actively sends notifications when matching events occur.
The engineering work involves considerably more than replacing HTTP GET requests with webhooks. A production implementation must detect relevant changes accurately, manage subscription lifecycles, deliver notifications reliably, recover from interruptions and ensure that clinical information is only disclosed to authorised consumers.
FHIR R5 introduces three resources that form the foundation of this mechanism: SubscriptionTopic, Subscription and SubscriptionStatus. Together, they separate the definition of a clinical event from the applications interested in receiving it and the transport used to deliver notifications.
A topic-based subscription system has two principal components: a FHIR server capable of detecting clinical events and a subscribing application capable of receiving and processing notifications.
The server exposes one or more SubscriptionTopic definitions describing the events it can detect. A subscriber selects a topic, supplies any permitted filtering criteria and establishes a Subscription that specifies how notifications should be delivered.
Consider a hospital integration where an application needs to respond whenever a laboratory result becomes final.
Without subscriptions, the application might repeatedly execute a query such as:
GET /fhir/Observation?status=final
&_lastUpdated=ge2026-11-20T10:00:00Z
Although the query limits the returned data, it still requires repeated search execution. The client must manage pagination, overlapping time windows, clock differences and duplicate results. Depending on the server’s indexing and query implementation, these searches can also create substantial database load.
With FHIR R5 Subscriptions, the server monitors the relevant resource changes and delivers notifications when an Observation satisfies the configured event criteria.
The architecture becomes:
Clinical Application
|
| Create Subscription
v
FHIR Server
|
| Resource created or updated
v
Event Evaluation
|
| Match SubscriptionTopic
| Apply Subscription filters
v
Notification Queue
|
| HTTPS POST
v
Subscriber Endpoint
|
| Validate and persist
v
Application Processing
This is a conceptual implementation rather than a prescribed internal FHIR architecture. The standard defines the externally observable subscription behaviour, not how a server must build its event detection and delivery infrastructure.
A server might evaluate events within its resource persistence layer, consume database change events or integrate with an existing messaging platform such as Apache Kafka or RabbitMQ.
The choice affects latency, transaction consistency, recoverability and the ability to scale event processing independently of the FHIR REST API.
A SubscriptionTopic describes which activity should generate a notification. It can identify resource interactions, changes to resource state or explicitly defined events.
For example, a topic intended to detect newly finalised laboratory results might monitor changes to Observation resources.
The topic can use resourceTrigger to specify the applicable resource type and interactions. More precise conditions can be expressed using FHIR search criteria or FHIRPath expressions.
A useful implementation must distinguish between an Observation that is already final and an Observation that has just transitioned to final.
A filter that simply checks Observation.status = final could produce repeated notifications whenever an already-final Observation is subsequently updated. That might be correct for a topic describing changes to final results, but not for a topic describing the transition to a final result.
R5 provides access to previous and current resource states when evaluating applicable resource triggers. A FHIRPath expression can therefore identify a transition by comparing %previous and %current, provided the server supports the relevant evaluation capability.
For example, the following expresses the central transition condition:
%current.status = 'final'
and
%previous.status != 'final'
A production topic must also specify the intended behaviour for resource creation, where no previous version exists. It should explicitly handle corrections, deletions and resources entering an erroneous state rather than assuming every update represents a new clinical event.
These details belong in the event definition. They should not be left for every subscribing application to interpret independently.
A Subscription associates an application with a topic, optional filters and a delivery channel.
The following simplified R5 example requests notifications about Observation events from a laboratory-results topic:
{
"resourceType": "Subscription",
"status": "requested",
"topic": "https://fhir.example.nhs.uk/SubscriptionTopic/lab-results",
"reason": "Receive laboratory result notifications",
"channelType": {
"system": "http://terminology.hl7.org/CodeSystem/subscription-channel-type",
"code": "rest-hook"
},
"endpoint": "https://integration.example.org/fhir/notifications",
"contentType": "application/fhir+json",
"content": "id-only",
"heartbeatPeriod": 300,
"timeout": 30
}
The topic URL is a canonical identifier for a topic supported by the server. It is not necessarily the REST endpoint used to retrieve the corresponding SubscriptionTopic resource.
The channelType specifies REST-hook delivery, meaning the server will send an HTTP POST to the configured endpoint when a relevant event occurs.
The content setting determines how much resource information is included in the notification. In this example, id-only means the subscriber receives references to affected resources and can retrieve their contents through the normal FHIR API.
The subscriber creates the resource using the appropriate FHIR REST interaction:
POST /fhir/Subscription
Content-Type: application/fhir+json
The server validates the request and returns the accepted subscription representation or an appropriate error. The subscriber should retain the server-assigned Subscription identifier and inspect the returned resource, since the server may reject unsupported options or accept a modified configuration.
Creation does not necessarily mean the subscription is active. For REST-hook subscriptions, R5 defines a handshake procedure to verify that the receiving endpoint can accept notifications before the server moves the subscription from requested to active.
FHIR R5 supports several notification channels, including REST-hook, WebSocket, email and FHIR messaging. Additional channel types can be defined by implementation guides.
For server-to-server clinical integrations, REST-hook delivery is often the most straightforward choice. It uses conventional HTTPS infrastructure, works with API gateways and load balancers, and supports established authentication and monitoring patterns.
WebSockets are useful when the subscriber cannot expose an inbound HTTP endpoint, such as a browser-based application or a mobile client. They require additional connection management and reconnection handling.
A subscription notification is represented as a FHIR Bundle with its type set to subscription-notification.
The first Bundle entry contains a SubscriptionStatus resource describing the notification. Subsequent entries depend on the requested payload level.
R5 defines several notification types, including:
For ordinary event delivery, the Bundle contains the subscription reference and event metadata, including event numbers for best-effort delivery.
A simplified notification might look like this:
{
"resourceType": "Bundle",
"type": "subscription-notification",
"timestamp": "2026-11-20T10:15:30Z",
"entry": [
{
"resource": {
"resourceType": "SubscriptionStatus",
"status": "active",
"type": "event-notification",
"eventsSinceSubscriptionStart": "42",
"subscription": {
"reference": "Subscription/123"
},
"notificationEvent": [
{
"eventNumber": "42",
"timestamp": "2026-11-20T10:15:29Z",
"focus": {
"reference": "Observation/98765"
}
}
]
}
}
]
}
The integer64 event-number fields are represented as strings in this JSON example, following R5 JSON serialisation conventions for that datatype.
In an id-only notification, the subscriber receives references to the focus resources without requiring their full contents in the Bundle. The receiving application can then retrieve the corresponding Observation:
GET /fhir/Observation/98765
Authorization: Bearer <access_token>
Accept: application/fhir+json
The application must authenticate independently to the FHIR API. Possession of a notification does not automatically grant permission to access the referenced resource.
There is also a temporal consideration. A resource retrieved after receiving a notification may have changed again.
For example, a laboratory result might be marked final at 10:15:29, triggering an event. At 10:15:31, the result could be corrected. If the subscriber retrieves the resource at 10:15:35, it may receive the corrected version rather than the version that originally triggered the event.
This behaviour is acceptable when the subscribing application only needs the latest known clinical state. It is unsuitable when the application must reconstruct an exact sequence of historical transitions.
Where historical state is required, the integration needs an explicit versioning strategy. This may involve retrieving a particular resource version, retaining event-time snapshots or using a server-supported event replay mechanism. FHIR resource history must not be assumed to be available indefinitely.
FHIR R5 defines three payload levels: empty, id-only and full-resource.
An empty payload contains the SubscriptionStatus notification metadata without identifying the affected resources. The subscriber must use other mechanisms to discover the changes. This can reduce disclosure, but it may require additional queries and is therefore less suitable for workflows intended to avoid repeated searches entirely.
An id-only payload includes references to the resources associated with the event. For many NHS integrations, this is a practical default because the notification can remain relatively small while resource access continues through the FHIR server’s established authorisation controls.
A full-resource payload includes the affected resources within the notification Bundle.
This can reduce subsequent API requests and is useful when an integration needs the clinical information immediately. However, it increases notification size, creates additional information-governance obligations and requires careful management of data retained in queues, logs and diagnostic tooling.
It also changes the handling of event-time consistency. A full-resource notification can carry the resource representation associated with the event, whereas an id-only notification normally leads the subscriber to retrieve the resource’s current state.
The correct payload choice depends on whether the consumer needs notification of a change, the latest state of a resource or the state that existed when the change occurred.
A REST-hook receiver should perform minimal synchronous work.
The endpoint must accept a FHIR notification Bundle, validate the message sufficiently to reject malformed or unauthorised requests, persist the notification durably and return an HTTP success response.
Clinical workflow processing should happen asynchronously after durable acceptance.
A suitable implementation has the following structure:
HTTPS Endpoint
|
v
Authentication
|
v
FHIR Bundle Validation
|
v
Subscription Validation
|
v
Durable Inbox / Queue
|
v
HTTP 200 Response
|
v
Background Worker
|
v
Resource Retrieval
|
v
Clinical Processing
The sequence matters. Returning HTTP 200 before durably recording the notification creates a loss window: a process crash after acknowledgement can discard the event while the sending server considers delivery successful.
Conversely, performing clinical processing inside the HTTP request can produce avoidable timeouts and unnecessary retransmissions.
A durable inbox table or message queue separates acceptance from processing. The receiver can acknowledge the POST after the event has been committed to storage, then allow one or more workers to process it.
For an id-only subscription, workers retrieve the referenced resources, validate the expected resource type and apply the application’s business rules.
These workers must be able to process events more than once without creating duplicate clinical actions. A duplicated notification should not generate a second referral, repeat a clinical alert or create another entry in a downstream record.
A unique processing key can be constructed using the source FHIR server, subscription identity and event number. This distinguishes events from different subscriptions, even where their numeric sequences overlap.
Resource identifiers alone are insufficient for deduplication because the same Observation or Encounter may legitimately generate multiple events.
FHIR R5 Subscriptions define a standard notification mechanism, but the core REST-hook channel does not guarantee that every event will reach its destination.
A server can successfully commit a resource change while the subscriber endpoint is temporarily unavailable. Network timeouts can occur after a notification has been accepted but before the sender receives its HTTP response. A subscriber can restart during an active notification stream.
These are ordinary distributed-system failure conditions, not exceptional cases.
For organisations implementing their own FHIR server or event infrastructure, event generation should be closely coupled to resource persistence.
A common failure occurs when a server updates a clinical resource in one transaction and publishes an event in a separate operation. If the process crashes between those operations, the resource is updated but no notification is generated.
The transactional outbox pattern addresses this problem.
Within the same database transaction, the application writes the updated FHIR resource and an outbox record describing the corresponding event. A separate publisher reads committed outbox records, evaluates or dispatches events and records delivery progress.
Database Transaction
|
+-- Update Observation
|
+-- Insert Outbox Event
|
+-- Commit
|
v
Outbox Publisher
|
v
Topic Evaluation
|
v
Delivery Queue
|
v
Subscriber Endpoint
Because the clinical update and outbox record are committed atomically, a process failure cannot leave one committed without the other.
The publisher may still deliver an event more than once, particularly when it crashes after sending a notification but before recording successful delivery. That is why idempotent processing remains necessary.
Where a database change-data-capture system is used instead of an application-managed outbox, the implementation must preserve sufficient transaction ordering and previous-state information to evaluate topic triggers accurately.
Some subscription topics depend on changes rather than absolute values. An event detector that only sees the latest resource state cannot always determine whether an Observation has just become final or was already final before an unrelated update.
FHIR R5 provides event numbering to help subscribers detect delivery gaps.
For best-effort channels, the SubscriptionStatus.notificationEvent.eventNumber identifies an event within the subscription’s monotonically increasing event sequence.
The eventsSinceSubscriptionStart field indicates the total number of events in that sequence, including the current event.
Suppose a subscriber receives events numbered 104, 105 and 107.
The absence of event 106 suggests a delivery gap. The application should record this condition and initiate recovery rather than silently advancing its processing position.
However, gaps must be assessed against batching and out-of-order delivery. A notification can contain several events, and concurrent delivery workers may cause later notifications to arrive before earlier ones.
The receiving application should therefore track event numbers over a window, retain a set of processed numbers and advance its contiguous checkpoint only when every preceding event has been accounted for.
For example, receiving event 107 before 106 should not automatically trigger an irreversible failure. The subscriber can allow a bounded period for delayed delivery before starting recovery.
FHIR R5 defines the optional $events operation for retrieving events associated with a subscription.
A server that supports the operation may permit clients to request historical events beginning at a specified event number:
GET /fhir/Subscription/123/$events
?eventsSinceNumber=106
This returns a notification Bundle containing the available matching events. It is a targeted recovery mechanism rather than routine polling for changes.
Support for $events is optional, and servers may impose limits on how long events remain available. Integration contracts should document retention periods, replay limits and the behaviour when a requested event can no longer be retrieved.
If event replay is unavailable, the subscriber needs a reconciliation strategy. That may involve querying resources modified since a previously established checkpoint and comparing the results with locally recorded state.
Such reconciliation should use overlapping time windows or another reliable cursor mechanism to avoid losing changes at timestamp boundaries. Pagination, concurrent modifications and resource deletion also need explicit treatment.
The goal is to avoid continuous polling during normal operation, not to eliminate every read operation required for recovery.
Event numbers provide a sequence within a subscription, but they do not establish a universal ordering of clinical changes across an entire healthcare system.
Two subscriptions may report related changes to Patient and Encounter resources with no globally consistent ordering.
Even within one subscription, processing workers can complete tasks in a different order from notification delivery.
An integration that depends on ordering should make that requirement explicit. It can serialise processing by subscription, patient identifier or another suitable partition key.
Partitioning by patient allows independent patient workflows to proceed concurrently while preserving local ordering for events belonging to the same patient.
The application should also distinguish events from resulting state. Multiple Observation notifications might be coalesced into a single refresh of the latest patient result set, provided the consuming workflow does not require every intermediate transition.
By contrast, an audit-oriented integration may need to retain every event even if successive events refer to the same resource.
For clinical workflows, idempotency must cover the business action, not just the notification record. Recording that event 106 has been processed is insufficient if the downstream clinical write succeeds but the local acknowledgement transaction fails.
A robust workflow uses transactional processing where possible, or a durable action ledger and idempotent downstream operations where transactions cannot span the systems involved.
FHIR Subscriptions introduce an outbound communication path from the clinical data provider to the subscribing application. That path requires security controls separate from those used for ordinary FHIR API requests.
A subscriber ordinarily authenticates when creating a Subscription. However, the server also needs to verify that the subscriber is entitled to receive notifications for the selected topic and any requested filters.
A user authorised to read a particular patient’s Observations should not automatically be able to create a subscription covering every Observation in an organisation.
Subscription authorisation must consider the topic, scope, patient population, receiving endpoint and information included in the notification.
Permissions should also be reassessed when notifications are sent. A subscription can remain active after the credentials used to create it have expired, and the underlying access permissions may change.
A system that only checks access when the subscription is created risks continuing to disclose information after the subscriber’s authority has been withdrawn.
REST-hook subscriptions require particular attention because the FHIR server sends requests to a subscriber-supplied endpoint.
Without restrictions, an attacker might attempt to register a Subscription pointing to an internal service, cloud metadata endpoint or unauthorised external destination.
This creates a server-side request forgery risk.
Production implementations should restrict endpoint registration to approved destinations and validate destination addresses. They should also control redirects, DNS resolution and outbound network routing to prevent a previously approved endpoint from being used to reach an unauthorised internal service.
HTTPS should be mandatory for clinical notifications. Where supported, mutual TLS can authenticate both parties at the transport layer.
Alternatively, the receiver might validate a sender-specific credential or cryptographic signature. Authentication details depend on the integration agreement and must be supported by the sending implementation.
FHIR R5 allows subscription parameters to specify HTTP headers for REST-hook delivery, but static credentials embedded in subscription configurations introduce lifecycle and exposure risks. Credential rotation, secret storage and the handling of diagnostic logs must be designed deliberately.
The notification receiver should never assume that an incoming FHIR Bundle is trustworthy simply because its structure is valid.
The endpoint should verify the sending system, identify the subscription and reject unexpected topics or resource references. If the notification contains an absolute resource URL, the subscriber should ensure it belongs to an approved FHIR server before attempting retrieval.
Otherwise, a forged notification could cause the subscriber to make authenticated requests to an attacker-controlled destination or consume resources outside its intended scope.
Care is also required when logging notifications. Full-resource payloads may contain sensitive clinical information, and even resource identifiers can disclose patient or workflow context when combined with other data.
Operational logs should normally record subscription identifiers, event numbers, delivery outcomes and correlation identifiers without retaining unnecessary clinical content.
Subscriptions are operational resources requiring ongoing management.
An active subscription can become invalid because an endpoint has moved, an organisation’s authorisation has changed or the FHIR server no longer supports the configured topic.
R5 provides subscription states including requested, active, error and off. Applications should monitor these states rather than assuming successful creation guarantees continued notification delivery.
For REST-hook subscriptions, the initial handshake is an important part of activation. The server sends a handshake notification to the configured endpoint, and successful acceptance allows the subscription to become active.
If the handshake fails, the subscription enters an error state under the R5 REST-hook workflow. An integration must diagnose the cause and restore the subscription rather than treating the initial creation response as sufficient.
Heartbeat notifications provide another operational signal.
A subscription with a configured heartbeat period can receive heartbeat messages even when no clinical events are occurring. The subscriber can use these messages to detect delivery-path failures.
A missing heartbeat is evidence of a possible problem, but it does not identify the precise cause. The fault might involve the sender, outbound networking, load balancer, receiver or subscription state.
The $status operation provides a way to query subscription status where supported. This is useful for diagnostics and recovery, although it should not replace endpoint monitoring.
For larger deployments, a subscription registry should track the relationship between application services and the subscriptions on which they depend.
It should record the FHIR server, canonical topic, accepted filters, endpoint, subscription identifier, expected heartbeat period and operational owner.
This becomes particularly valuable when an NHS trust replaces an EPR, migrates an integration platform or changes the infrastructure hosting its FHIR services.
Many existing healthcare platforms expose FHIR R4 or R4B rather than native R5 interfaces.
FHIR R5 Subscriptions are therefore not automatically available simply because a platform provides a FHIR API.
Earlier FHIR releases used different subscription structures and capabilities. HL7’s Subscriptions R5 Backport Implementation Guide provides a mechanism for supporting topic-based subscription behaviour on R4 and R4B systems.
A backported implementation should be treated as a distinct interoperability profile, not as an R5 endpoint with a different version number.
Subscription resource representations, extensions, supported operations and notification profiles differ. A client must generate requests appropriate to the server’s declared FHIR version and implementation guide.
Before designing an integration, inspect the server’s CapabilityStatement, implementation-guide declarations and published topic catalogue. Confirm support for the required subscription interactions, channels, filters, payload levels and recovery operations.
A server may support ordinary FHIR resource reads and writes without supporting topic-based subscriptions at all.
Within NHS environments, the wider integration architecture also matters. Events may originate from EPR systems, laboratory systems or departmental applications and reach the FHIR server through HL7 v2 interfaces or an integration engine.
A FHIR Subscription can only report events that the server can detect. If an upstream system delays publishing a laboratory result, or an integration engine batches changes before updating the FHIR repository, the subscription cannot eliminate that upstream latency.
The point at which an event becomes visible must therefore be established during integration design.
A notification about an Observation being created in a downstream FHIR repository is not necessarily equivalent to the moment the originating laboratory system authorised the result.
A subscription service should be designed around expected clinical event volumes rather than the number of registered subscriptions alone.
Consider a hospital FHIR platform maintaining 50,000 active subscriptions.
If every resource update is evaluated independently against every subscription, the server can create substantial unnecessary processing overhead.
A scalable implementation first determines which topics could be affected by a resource change. It then evaluates the relevant topic triggers and applies subscriber-specific filters only to subscriptions associated with those topics.
Indexes can partition subscriptions by topic, resource type, patient reference, organisation or other supported filter parameters.
The effectiveness of this strategy depends on the filtering model. Equality checks on indexed identifiers are generally cheaper to evaluate than arbitrary FHIRPath expressions requiring access to multiple resources.
Complex topic criteria may require previously persisted resource versions, joins to related resources or additional derived indexes.
Topic definitions should therefore be reviewed for computational cost as well as clinical correctness.
Notification delivery should normally be decoupled from the clinical write transaction.
A bounded queue or event broker allows resource updates to complete without waiting for external subscriber endpoints.
However, queues introduce their own operational requirements.
A slow subscriber can accumulate a backlog. If the sender creates notifications faster than the receiving endpoint can accept them, the system needs a defined policy for queue limits, retries, expiry and escalation.
Repeatedly retrying every failed request immediately is usually counterproductive. It increases traffic to an already unhealthy service and may worsen the original failure.
A retry policy should use bounded exponential backoff with jitter, distinguish transient failures from permanent configuration errors and provide a dead-letter mechanism for messages requiring intervention.
HTTP 429 and 5xx responses typically warrant consideration for retry, while persistent authentication failures or malformed payload errors require a different response.
The precise retry policy is not dictated by the core R5 REST-hook specification and should be agreed between the participating systems.
For high-volume integrations, notification batching can reduce HTTP overhead. A single notification Bundle may represent several events, allowing the receiver to amortise connection and validation costs.
Batching must not obscure event numbers or allow processing failures affecting one event to silently discard the others.
The receiver should persist individual event identities, even when several arrive in the same Bundle.
End-to-end event latency should be measured from the clinical resource change to the point at which the receiving application has completed the required processing.
Measuring only HTTP delivery time is insufficient.
Useful timestamps include the resource commit time, event detection time, queue insertion time, delivery attempt time, receiver acceptance time and downstream processing completion time.
From these timestamps, engineers can distinguish database event-detection delays from delivery backlogs and slow consumer processing.
Metrics should include notification delivery success rates, queue depth, retry counts, age of the oldest outstanding event, subscriber processing latency, event-number gaps and time since the last heartbeat.
Percentile latency is more informative than averages. A system may process most events within one second while a smaller proportion remain delayed for several minutes because of queue contention or endpoint failures.
Dashboards should expose these delays by FHIR server, subscription topic and subscriber endpoint.
Clinical workflows may also need separate service-level objectives. A notification updating a non-urgent analytics dataset does not necessarily require the same latency or recovery target as one supporting an operational clinical workflow.
The most valuable tests exercise resource-state transitions rather than merely proving that an HTTP POST can be delivered.
For an Observation-finalisation topic, tests should cover creation of a preliminary result, transition to final, corrections after finalisation, duplicate updates and deletion or entry-in-error scenarios.
The expected notification count must be explicitly defined for each case.
For example, an implementation that promises notification only when an Observation first becomes final should not emit another event because a later update changes an unrelated metadata field.
The test suite should also cover concurrent updates. Two application instances might update the same clinical resource within a short interval. Event detection must operate against committed changes and avoid reporting transitions that occurred only in failed transactions.
Delivery testing should include deliberate failures:
Load testing should reproduce realistic event distributions rather than uniform random traffic.
Hospital activity frequently occurs in bursts: morning pathology processing, ward rounds, admission peaks and bulk changes following integration recovery can generate highly uneven volumes.
A representative test should include these bursts, multiple active topics, slow subscribers and temporary downstream outages.
It should also measure the impact on ordinary FHIR API performance. Subscription processing must not cause unacceptable latency for clinical applications retrieving or updating patient records.
For organisations operating several interconnected clinical systems, a staged rollout is preferable to immediately enabling every topic.
One approach is to begin with a single low-risk event type, validate its semantics against source-system activity, test recovery and observability, and then extend the implementation to higher-volume or more clinically significant events.
The final production design should have an explicitly documented delivery contract: what constitutes an event, when it is generated, how it is numbered, whether it can be replayed, what happens during an outage and which component owns recovery when the event stream becomes incomplete.
FHIR R5 standardises the subscription resources, topic definitions and notification structures needed to implement this model. Achieving reliable event-driven integration still depends on the underlying persistence, message delivery, identity management and operational controls.
A well-engineered implementation allows subscribing applications to react to clinical changes without continuously querying for them, while preserving the ability to detect missing notifications, reconstruct the required clinical state and recover safely when systems fail.
Is your team looking for help with HL7 FHIR Subscriptions and HL7 FHIR R5? Click the button below.
Get in touch