This page is part of the FHIR Specification (v4.6.0: R5 Draft Ballot - see ballot notes). The current version which supercedes this version is 5.0.0. For a full list of available versions, see the Directory of published versions . Page versions: R5 R4B R4 R3 R2
FHIR Infrastructure Work Group | Maturity Level: 2 | Trial Use | Security Category: Business | Compartments: Not linked to any defined compartments |
The subscription resource describes a particular client's request to be notified about a SubscriptionTopic.
This document contains information about the Subscription
resource and details specific to options in it. See Subscriptions for general information about using Subscriptions in FHIR.
The Subscription
resource is used to establish proactive event notifications from a FHIR server to another system. Subscribers request event notifications within a predefined SubscriptionTopic that the server supports, and can further refine their notifications by supplying filters. Each SubscriptionTopic
resource defines a set of allowed filters (SubscriptionTopic.canFilterBy
), which a subscriber refer to within a Subscription
resource (Subscription.filterBy
). Once a subscription is created, any event matching a specified SubscriptionTopic that meets the filtering criteria will cause a notification to be sent using the provided channel. Notifications are Bundle resources, of type subscription-notification
.
Subscriptions are active resources; a server can only accept a subscription if it will execute the specified channel for any resources subsequently received. The subscription is no longer active once it is deleted from the server.
By adjusting Subscription.content
, subscribers can request event notifications that include full resource content; or just the ID of the triggering resource; or an empty notification body.
Several channels are defined in the core specification:
Subscription.endpoint
URL (e.g., https://...
)Subscription.endpoint
email URI (e.g., mailto:...
)Subscription.endpoint
URIAdditional channel types can be defined by external implementation guides. See below for further discussion of the various channels.
The Subscription
resource is used in the Subscriptions Framework. Information about the Boundaries and Relationships both within the Subscriptions Framework and to other areas of the FHIR specification can be found here.
This resource is referenced by SubscriptionStatus.
This resource does not implement any patterns.
Structure
Name | Flags | Card. | Type | Description & Constraints |
---|---|---|---|---|
Subscription | TU | DomainResource | Notification about a SubscriptionTopic Elements defined in Ancestors: id, meta, implicitRules, language, text, contained, extension, modifierExtension | |
identifier | Σ | 0..* | Identifier | Additional identifiers (business identifier) |
name | Σ | 0..1 | string | Human readable name for this subscription |
status | ?!Σ | 1..1 | code | requested | active | error | off | entered-in-error Subscription State (Required) |
topic | Σ | 1..1 | canonical(SubscriptionTopic) | Reference to the subscription topic being subscribed to |
contact | Σ | 0..* | ContactPoint | Contact details for source (e.g. troubleshooting) |
end | Σ | 0..1 | instant | When to automatically delete the subscription |
reason | Σ | 0..1 | string | Description of why this subscription was created |
filterBy | Σ | 0..* | BackboneElement | Criteria for narrowing the subscription topic stream |
resourceType | Σ | 0..1 | uri | Allowed Data type or Resource (reference to definition) for this Subscription FHIRDefinedType (Extensible) |
searchParamName | Σ | 1..1 | string | Filter label defined in SubscriptionTopic |
searchModifier | Σ | 0..1 | code | = | eq | ne | gt | lt | ge | le | sa | eb | ap | above | below | in | not-in | of-type Subscription Search Modifier (Required) |
value | Σ | 1..1 | string | Literal value or resource path |
channelType | Σ | 1..1 | Coding | Channel type for notifications Subscription Channel Type (Extensible) |
endpoint | Σ | 0..1 | url | Where the channel points to |
header | Σ | 0..* | string | Usage depends on the channel type |
heartbeatPeriod | Σ | 0..1 | unsignedInt | Interval in seconds to send 'heartbeat' notification |
timeout | Σ | 0..1 | unsignedInt | Timeout in seconds to attempt notification delivery |
contentType | Σ | 0..1 | code | MIME type to send, or omit for no payload MimeType (Required) |
content | Σ | 0..1 | code | empty | id-only | full-resource SubscriptionPayloadContent (Required) |
notificationUrlLocation | Σ | 0..1 | code | none | full-url | request-response | all SubscriptionUrlLocation (Required) |
maxCount | Σ | 0..1 | positiveInt | Maximum number of triggering resources included in notification bundles |
Documentation for this format |
UML Diagram (Legend)
XML Template
<Subscription xmlns="http://hl7.org/fhir"> <!-- from Resource: id, meta, implicitRules, and language --> <!-- from DomainResource: text, contained, extension, and modifierExtension --> <identifier><!-- 0..* Identifier Additional identifiers (business identifier) --></identifier> <name value="[string]"/><!-- 0..1 Human readable name for this subscription --> <status value="[code]"/><!-- 1..1 requested | active | error | off | entered-in-error --> <topic><!-- 1..1 canonical(SubscriptionTopic) Reference to the subscription topic being subscribed to --></topic> <contact><!-- 0..* ContactPoint Contact details for source (e.g. troubleshooting) --></contact> <end value="[instant]"/><!-- 0..1 When to automatically delete the subscription --> <reason value="[string]"/><!-- 0..1 Description of why this subscription was created --> <filterBy> <!-- 0..* Criteria for narrowing the subscription topic stream --> <resourceType value="[uri]"/><!-- 0..1 Allowed Data type or Resource (reference to definition) for this Subscription --> <searchParamName value="[string]"/><!-- 1..1 Filter label defined in SubscriptionTopic --> <searchModifier value="[code]"/><!-- 0..1 = | eq | ne | gt | lt | ge | le | sa | eb | ap | above | below | in | not-in | of-type --> <value value="[string]"/><!-- 1..1 Literal value or resource path --> </filterBy> <channelType><!-- 1..1 Coding Channel type for notifications --></channelType> <endpoint value="[url]"/><!-- 0..1 Where the channel points to --> <header value="[string]"/><!-- 0..* Usage depends on the channel type --> <heartbeatPeriod value="[unsignedInt]"/><!-- 0..1 Interval in seconds to send 'heartbeat' notification --> <timeout value="[unsignedInt]"/><!-- 0..1 Timeout in seconds to attempt notification delivery --> <contentType value="[code]"/><!-- 0..1 MIME type to send, or omit for no payload --> <content value="[code]"/><!-- 0..1 empty | id-only | full-resource --> <notificationUrlLocation value="[code]"/><!-- 0..1 none | full-url | request-response | all --> <maxCount value="[positiveInt]"/><!-- 0..1 Maximum number of triggering resources included in notification bundles --> </Subscription>
JSON Template
{ "resourceType" : "Subscription", // from Resource: id, meta, implicitRules, and language // from DomainResource: text, contained, extension, and modifierExtension "identifier" : [{ Identifier }], // Additional identifiers (business identifier) "name" : "<string>", // Human readable name for this subscription "status" : "<code>", // R! requested | active | error | off | entered-in-error "topic" : { canonical(SubscriptionTopic) }, // R! Reference to the subscription topic being subscribed to "contact" : [{ ContactPoint }], // Contact details for source (e.g. troubleshooting) "end" : "<instant>", // When to automatically delete the subscription "reason" : "<string>", // Description of why this subscription was created "filterBy" : [{ // Criteria for narrowing the subscription topic stream "resourceType" : "<uri>", // Allowed Data type or Resource (reference to definition) for this Subscription "searchParamName" : "<string>", // R! Filter label defined in SubscriptionTopic "searchModifier" : "<code>", // = | eq | ne | gt | lt | ge | le | sa | eb | ap | above | below | in | not-in | of-type "value" : "<string>" // R! Literal value or resource path }], "channelType" : { Coding }, // R! Channel type for notifications "endpoint" : "<url>", // Where the channel points to "header" : ["<string>"], // Usage depends on the channel type "heartbeatPeriod" : "<unsignedInt>", // Interval in seconds to send 'heartbeat' notification "timeout" : "<unsignedInt>", // Timeout in seconds to attempt notification delivery "contentType" : "<code>", // MIME type to send, or omit for no payload "content" : "<code>", // empty | id-only | full-resource "notificationUrlLocation" : "<code>", // none | full-url | request-response | all "maxCount" : "<positiveInt>" // Maximum number of triggering resources included in notification bundles }
Turtle Template
@prefix fhir: <http://hl7.org/fhir/> . [ a fhir:Subscription; fhir:nodeRole fhir:treeRoot; # if this is the parser root # from Resource: .id, .meta, .implicitRules, and .language # from DomainResource: .text, .contained, .extension, and .modifierExtension fhir:Subscription.identifier [ Identifier ], ... ; # 0..* Additional identifiers (business identifier) fhir:Subscription.name [ string ]; # 0..1 Human readable name for this subscription fhir:Subscription.status [ code ]; # 1..1 requested | active | error | off | entered-in-error fhir:Subscription.topic [ canonical(SubscriptionTopic) ]; # 1..1 Reference to the subscription topic being subscribed to fhir:Subscription.contact [ ContactPoint ], ... ; # 0..* Contact details for source (e.g. troubleshooting) fhir:Subscription.end [ instant ]; # 0..1 When to automatically delete the subscription fhir:Subscription.reason [ string ]; # 0..1 Description of why this subscription was created fhir:Subscription.filterBy [ # 0..* Criteria for narrowing the subscription topic stream fhir:Subscription.filterBy.resourceType [ uri ]; # 0..1 Allowed Data type or Resource (reference to definition) for this Subscription fhir:Subscription.filterBy.searchParamName [ string ]; # 1..1 Filter label defined in SubscriptionTopic fhir:Subscription.filterBy.searchModifier [ code ]; # 0..1 = | eq | ne | gt | lt | ge | le | sa | eb | ap | above | below | in | not-in | of-type fhir:Subscription.filterBy.value [ string ]; # 1..1 Literal value or resource path ], ...; fhir:Subscription.channelType [ Coding ]; # 1..1 Channel type for notifications fhir:Subscription.endpoint [ url ]; # 0..1 Where the channel points to fhir:Subscription.header [ string ], ... ; # 0..* Usage depends on the channel type fhir:Subscription.heartbeatPeriod [ unsignedInt ]; # 0..1 Interval in seconds to send 'heartbeat' notification fhir:Subscription.timeout [ unsignedInt ]; # 0..1 Timeout in seconds to attempt notification delivery fhir:Subscription.contentType [ code ]; # 0..1 MIME type to send, or omit for no payload fhir:Subscription.content [ code ]; # 0..1 empty | id-only | full-resource fhir:Subscription.notificationUrlLocation [ code ]; # 0..1 none | full-url | request-response | all fhir:Subscription.maxCount [ positiveInt ]; # 0..1 Maximum number of triggering resources included in notification bundles ]
Changes since R3
Subscription | |
Subscription.identifier |
|
Subscription.name |
|
Subscription.status |
|
Subscription.topic |
|
Subscription.reason |
|
Subscription.filterBy |
|
Subscription.filterBy.resourceType |
|
Subscription.filterBy.searchParamName |
|
Subscription.filterBy.searchModifier |
|
Subscription.filterBy.value |
|
Subscription.channelType |
|
Subscription.endpoint |
|
Subscription.header |
|
Subscription.heartbeatPeriod |
|
Subscription.timeout |
|
Subscription.contentType |
|
Subscription.content |
|
Subscription.notificationUrlLocation |
|
Subscription.maxCount |
|
Subscription.criteria |
|
Subscription.error |
|
Subscription.channel |
|
See the Full Difference for further information
This analysis is available as XML or JSON.
See R3 <--> R4 Conversion Maps (status = 2 tests that all execute ok. 2 fail round-trip testing and all r3 resources are valid.)
Structure
Name | Flags | Card. | Type | Description & Constraints |
---|---|---|---|---|
Subscription | TU | DomainResource | Notification about a SubscriptionTopic Elements defined in Ancestors: id, meta, implicitRules, language, text, contained, extension, modifierExtension | |
identifier | Σ | 0..* | Identifier | Additional identifiers (business identifier) |
name | Σ | 0..1 | string | Human readable name for this subscription |
status | ?!Σ | 1..1 | code | requested | active | error | off | entered-in-error Subscription State (Required) |
topic | Σ | 1..1 | canonical(SubscriptionTopic) | Reference to the subscription topic being subscribed to |
contact | Σ | 0..* | ContactPoint | Contact details for source (e.g. troubleshooting) |
end | Σ | 0..1 | instant | When to automatically delete the subscription |
reason | Σ | 0..1 | string | Description of why this subscription was created |
filterBy | Σ | 0..* | BackboneElement | Criteria for narrowing the subscription topic stream |
resourceType | Σ | 0..1 | uri | Allowed Data type or Resource (reference to definition) for this Subscription FHIRDefinedType (Extensible) |
searchParamName | Σ | 1..1 | string | Filter label defined in SubscriptionTopic |
searchModifier | Σ | 0..1 | code | = | eq | ne | gt | lt | ge | le | sa | eb | ap | above | below | in | not-in | of-type Subscription Search Modifier (Required) |
value | Σ | 1..1 | string | Literal value or resource path |
channelType | Σ | 1..1 | Coding | Channel type for notifications Subscription Channel Type (Extensible) |
endpoint | Σ | 0..1 | url | Where the channel points to |
header | Σ | 0..* | string | Usage depends on the channel type |
heartbeatPeriod | Σ | 0..1 | unsignedInt | Interval in seconds to send 'heartbeat' notification |
timeout | Σ | 0..1 | unsignedInt | Timeout in seconds to attempt notification delivery |
contentType | Σ | 0..1 | code | MIME type to send, or omit for no payload MimeType (Required) |
content | Σ | 0..1 | code | empty | id-only | full-resource SubscriptionPayloadContent (Required) |
notificationUrlLocation | Σ | 0..1 | code | none | full-url | request-response | all SubscriptionUrlLocation (Required) |
maxCount | Σ | 0..1 | positiveInt | Maximum number of triggering resources included in notification bundles |
Documentation for this format |
XML Template
<Subscription xmlns="http://hl7.org/fhir"> <!-- from Resource: id, meta, implicitRules, and language --> <!-- from DomainResource: text, contained, extension, and modifierExtension --> <identifier><!-- 0..* Identifier Additional identifiers (business identifier) --></identifier> <name value="[string]"/><!-- 0..1 Human readable name for this subscription --> <status value="[code]"/><!-- 1..1 requested | active | error | off | entered-in-error --> <topic><!-- 1..1 canonical(SubscriptionTopic) Reference to the subscription topic being subscribed to --></topic> <contact><!-- 0..* ContactPoint Contact details for source (e.g. troubleshooting) --></contact> <end value="[instant]"/><!-- 0..1 When to automatically delete the subscription --> <reason value="[string]"/><!-- 0..1 Description of why this subscription was created --> <filterBy> <!-- 0..* Criteria for narrowing the subscription topic stream --> <resourceType value="[uri]"/><!-- 0..1 Allowed Data type or Resource (reference to definition) for this Subscription --> <searchParamName value="[string]"/><!-- 1..1 Filter label defined in SubscriptionTopic --> <searchModifier value="[code]"/><!-- 0..1 = | eq | ne | gt | lt | ge | le | sa | eb | ap | above | below | in | not-in | of-type --> <value value="[string]"/><!-- 1..1 Literal value or resource path --> </filterBy> <channelType><!-- 1..1 Coding Channel type for notifications --></channelType> <endpoint value="[url]"/><!-- 0..1 Where the channel points to --> <header value="[string]"/><!-- 0..* Usage depends on the channel type --> <heartbeatPeriod value="[unsignedInt]"/><!-- 0..1 Interval in seconds to send 'heartbeat' notification --> <timeout value="[unsignedInt]"/><!-- 0..1 Timeout in seconds to attempt notification delivery --> <contentType value="[code]"/><!-- 0..1 MIME type to send, or omit for no payload --> <content value="[code]"/><!-- 0..1 empty | id-only | full-resource --> <notificationUrlLocation value="[code]"/><!-- 0..1 none | full-url | request-response | all --> <maxCount value="[positiveInt]"/><!-- 0..1 Maximum number of triggering resources included in notification bundles --> </Subscription>
JSON Template
{ "resourceType" : "Subscription", // from Resource: id, meta, implicitRules, and language // from DomainResource: text, contained, extension, and modifierExtension "identifier" : [{ Identifier }], // Additional identifiers (business identifier) "name" : "<string>", // Human readable name for this subscription "status" : "<code>", // R! requested | active | error | off | entered-in-error "topic" : { canonical(SubscriptionTopic) }, // R! Reference to the subscription topic being subscribed to "contact" : [{ ContactPoint }], // Contact details for source (e.g. troubleshooting) "end" : "<instant>", // When to automatically delete the subscription "reason" : "<string>", // Description of why this subscription was created "filterBy" : [{ // Criteria for narrowing the subscription topic stream "resourceType" : "<uri>", // Allowed Data type or Resource (reference to definition) for this Subscription "searchParamName" : "<string>", // R! Filter label defined in SubscriptionTopic "searchModifier" : "<code>", // = | eq | ne | gt | lt | ge | le | sa | eb | ap | above | below | in | not-in | of-type "value" : "<string>" // R! Literal value or resource path }], "channelType" : { Coding }, // R! Channel type for notifications "endpoint" : "<url>", // Where the channel points to "header" : ["<string>"], // Usage depends on the channel type "heartbeatPeriod" : "<unsignedInt>", // Interval in seconds to send 'heartbeat' notification "timeout" : "<unsignedInt>", // Timeout in seconds to attempt notification delivery "contentType" : "<code>", // MIME type to send, or omit for no payload "content" : "<code>", // empty | id-only | full-resource "notificationUrlLocation" : "<code>", // none | full-url | request-response | all "maxCount" : "<positiveInt>" // Maximum number of triggering resources included in notification bundles }
Turtle Template
@prefix fhir: <http://hl7.org/fhir/> . [ a fhir:Subscription; fhir:nodeRole fhir:treeRoot; # if this is the parser root # from Resource: .id, .meta, .implicitRules, and .language # from DomainResource: .text, .contained, .extension, and .modifierExtension fhir:Subscription.identifier [ Identifier ], ... ; # 0..* Additional identifiers (business identifier) fhir:Subscription.name [ string ]; # 0..1 Human readable name for this subscription fhir:Subscription.status [ code ]; # 1..1 requested | active | error | off | entered-in-error fhir:Subscription.topic [ canonical(SubscriptionTopic) ]; # 1..1 Reference to the subscription topic being subscribed to fhir:Subscription.contact [ ContactPoint ], ... ; # 0..* Contact details for source (e.g. troubleshooting) fhir:Subscription.end [ instant ]; # 0..1 When to automatically delete the subscription fhir:Subscription.reason [ string ]; # 0..1 Description of why this subscription was created fhir:Subscription.filterBy [ # 0..* Criteria for narrowing the subscription topic stream fhir:Subscription.filterBy.resourceType [ uri ]; # 0..1 Allowed Data type or Resource (reference to definition) for this Subscription fhir:Subscription.filterBy.searchParamName [ string ]; # 1..1 Filter label defined in SubscriptionTopic fhir:Subscription.filterBy.searchModifier [ code ]; # 0..1 = | eq | ne | gt | lt | ge | le | sa | eb | ap | above | below | in | not-in | of-type fhir:Subscription.filterBy.value [ string ]; # 1..1 Literal value or resource path ], ...; fhir:Subscription.channelType [ Coding ]; # 1..1 Channel type for notifications fhir:Subscription.endpoint [ url ]; # 0..1 Where the channel points to fhir:Subscription.header [ string ], ... ; # 0..* Usage depends on the channel type fhir:Subscription.heartbeatPeriod [ unsignedInt ]; # 0..1 Interval in seconds to send 'heartbeat' notification fhir:Subscription.timeout [ unsignedInt ]; # 0..1 Timeout in seconds to attempt notification delivery fhir:Subscription.contentType [ code ]; # 0..1 MIME type to send, or omit for no payload fhir:Subscription.content [ code ]; # 0..1 empty | id-only | full-resource fhir:Subscription.notificationUrlLocation [ code ]; # 0..1 none | full-url | request-response | all fhir:Subscription.maxCount [ positiveInt ]; # 0..1 Maximum number of triggering resources included in notification bundles ]
Changes since Release 3
Subscription | |
Subscription.identifier |
|
Subscription.name |
|
Subscription.status |
|
Subscription.topic |
|
Subscription.reason |
|
Subscription.filterBy |
|
Subscription.filterBy.resourceType |
|
Subscription.filterBy.searchParamName |
|
Subscription.filterBy.searchModifier |
|
Subscription.filterBy.value |
|
Subscription.channelType |
|
Subscription.endpoint |
|
Subscription.header |
|
Subscription.heartbeatPeriod |
|
Subscription.timeout |
|
Subscription.contentType |
|
Subscription.content |
|
Subscription.notificationUrlLocation |
|
Subscription.maxCount |
|
Subscription.criteria |
|
Subscription.error |
|
Subscription.channel |
|
See the Full Difference for further information
This analysis is available as XML or JSON.
See R3 <--> R4 Conversion Maps (status = 2 tests that all execute ok. 2 fail round-trip testing and all r3 resources are valid.)
See the Profiles & Extensions and the alternate definitions: Master Definition XML + JSON, XML Schema/Schematron + JSON Schema, ShEx (for Turtle) + see the extensions, the spreadsheet version & the dependency analysis a
Path | Definition | Type | Reference |
---|---|---|---|
Subscription.status | Required | SubscriptionState | |
Subscription.filterBy.resourceType | Extensible | FHIRDefinedType | |
Subscription.filterBy.searchModifier | Required | SubscriptionSearchModifier | |
Subscription.channelType | Extensible | SubscriptionChannelType | |
Subscription.contentType | The mime type of an attachment. Any valid mime type is allowed. | Required | Mime Types |
Subscription.content | Required | SubscriptionPayloadContent | |
Subscription.notificationUrlLocation | Required | SubscriptionUrlLocation |
Trial-Use Note:
TODO
Updates to "Managing Subscriptions and Errors"
- Discuss error codes (Extensible Codeable Concept)
- Define basic error codes here
- Need to discuss eventCount and error detection (insert appropriate examples/workflows)
Updates to "Tracking Subscription Notifications" SHOULD define what the AuditEvent looks like
Applications are responsible for following FHIR security guidance. Some recommendations specific to subscriptions are provided on the Subscriptions Framework page.
There are three options available when specifying the contents of a Notification: empty
, id-only
, and full-resource
. These options change the level of detail conveyed in the notification Bundle
.
When deciding which payload type to request, systems SHOULD consider both ease of processing and security of PHI. To mitigate the risk of information leakage, systems SHOULD use the minimum level of detail consistent with the use case. In practice, id-only
provides a good balance between security and performance for many real-world scenarios.
If a server will not honor a payload type (e.g., will not send full-resource
over HTTP), it SHOULD reject the Subscription request, but the server MAY accept the subscription with modificaitons.
An example notification with an empty
payload can be found here.
With the content type of empty
, all information about the resources involved in triggering the notification is only available via channels other than the Subscription itself (e.g., the REST API). This mitigates many security concerns by both removing most PHI from the notification and allows servers to consolidate authorization and authentication logic. When the subscriber receives a notification of this type, it may query the server to fetch all the relevant resources based on the SubscriptionTopic
and applicable filters. The client might include a _since=
query parameter, supplying its last query timestamp to retrieve only the most recent resources. For example, if the notification is for a topic about patient admission, the subscriber will generally query for recent Encounters
for a patient or group of patients, then fetch them as needed.
When the content type is empty
, notification bundles SHALL not contain Bundle.entry
elements other than the SubscriptionStatus
for the notification.
An example notification with an id-only
payload can be found here.
With the content type of id-only
, the resources involved in triggering the notification are only available through other channels (e.g., REST API), but notifications include URLs which can be used to access those resources. This allows servers to consolidate authorization and authentication logic, while removing the need for expensive queries by subscribers. When a subscriber receives a notification of this type, it may directly fetch all the relevant resources using the supplied resource ids. For example, the if the notification is for a topic about patient admission, the subscriber may fetch the Encounter(s)
for a patient or group of patients.
When the content type is id-only
, notification bundles SHALL contain, in addition to the SubscriptionStatus
, at least one Bundle.entry
for each resource relevant to the notification. For example, a notification for a topic based on Encounter
SHALL include a reference to the Encounter
and MAY include additional resources deemed relevant (e.g., the linked Patient
).
Each Bundle.entry
for id-only
notification SHALL contain a relevant resource URL in the fullUrl
, request
, and/or response
elements. The Subscription's notificationUrlLocation
element describes the behavior which should be used.
An example notification with a full-resource
payload can be found here.
With the content type of full-resource
, the resources involved in triggering the notification are included in the notification bundle. When a subscriber receives a notification of this type, resources are already present in the bundle, though the subscriber may need to fetch additional resources from the server. For example, the if the notification is for a topic about patient admission, the subscriber may require related Observation
resources.
When the content type is full-resource
, notification bundles SHALL contain, in addition to the SubscriptionStatus
, at least one Bundle.entry
for each resource relevant to the notification. For example, a notification for a topic based on Encounter
SHALL include an Encounter
and MAY include additional resources deemed relevant (e.g., the relevant Patient
).
In most scenarios, each Bundle.entry
for a full-resource
notification SHALL contain a relevant resource in the resource
element. In some scenarios, it is not possible to include the resource, in which case entry.request
and/or entry.response
are required. For example, in the case of a notification about a deleted resource, the server may no longer have access to the resource. In this case, information in the entry.response
is critical for a subscriber to process the notification (e.g., the etag
).
When a Subscription is created for a REST Hook channel type, the server SHALL set initial status to requested
, pending verification of the nominated endpoint URL. After a successful handshake notification has been sent and accepted, the server SHALL update the status to active
. Any errors in the initial handshake SHALL result in the status being changed to error
.
To receive notifications via HTTP/S POST, a client should request a subscription with the channel type (Subscription.channelType
) of rest-hook
(from the subscription-channel-type Code System) and set the endpoint (Subscription.endpoint
) to the appropriate client URL. Note that this URL must be accessible by the hosting server.
To convey an event notification, the server POSTs a Bundle to the client's nominated endpoint URL per the format requests in the Subscription. The content-type of the POST SHALL match the contentType (channel.contentType
) requested during creation of the Subscription. Each Subscription.header
value SHALL be conveyed as an HTTP request header.
An example workflow for establishing a rest-hook
subscription is included below.
Subscription
with the channelType
set to rest-hook
.
requested
.
handshake
notification.
heartbeat
at any time.
event-notificaiton
at any time.
HTTP is neither a secure nor an encrypted channel. It is strongly recommended that production implementations refuse requests to send notifications to URLs using the HTTP protocol (use HTTPS instead).
HTTP does not provide endpoint verification. It is strongly recommended that implementations refuse requests to send notifications to URLs using the HTTP protocol (use HTTPS instead).
While the primary interface for FHIR servers is the FHIR REST API, notifications need not occur via REST. Indeed, some subscribers may be unable to expose an outward-facing HTTP server to receive triggered notifications. For example, a pure client-side Web app or mobile app may want to subscribe to a data feed without polling using the /history operation. This can be accomplished using a websocket notification channel.
A client can declare its intention to receive notifications via Web Sockets by requesting a subscription with the channel type (Subscription.channelType
) of websocket
(from the subscription-channel-type Code System).
An example workflow for receiving notifications via websockets is shown below:
Subscription
with the channelType
set to websocket
.
token
and an expiration
.
bind-with-token
message via websockets, with the token provided by the server. Note: this operation can be repeated concurrently for multiple subscriptions, and serially for continued operation over a single websocket connection.
handshake
messages via websockets (one per Subscription included in the token). Note: some servers may additionally send one or more event-notification
messages at this time (e.g., all messages since last connected, last 'n' messages, etc.). Clients are expected to handle either flow.
heartbeat
message via websockets at any time.
event-notification
message via websockets at any time.
Note: all notifications sent from the server SHALL be in the format specified by the Subscription
it is for (e.g., contentType
and content
fields).
Trial-Use Note: The Websocket channel type needs more testing and feedback to ensure all requirements are met before finalizing the specification.
WebSocket security poses several challenges specific to the channel. When implementing websockets for notifications, please keep in mind the following list of some areas of concern:
While the primary interface for FHIR servers is the FHIR REST API, notifications need not occur via REST. Indeed, some subscribers may be unable to maintain an outward-facing HTTP server to receive triggered notifications. For example, a public health organization may want to be notified of outbreaks of various illnesses. This can be accomplished using an email notification channel.
A client can declare its intention to receive notifications via Email by requesting a subscription with the channel type (Subscription.channelType
) of email
(from the subscription-channel-type Code System) and setting the endpoint (Subscription.endpoint
) to the appropriate email URI (e.g., mailto:public_health_notifications@example.org
).
The server will send a new message each time a notification should be sent (e.g., per event or per batch). The server will create a message based on the values present in the Subscription.contentType
and Subscription.content
fields. If a server cannot honor the requested combination, the server should reject the Subscription request rather than send unexpected email messages.
The email channel sets two guidelines about content:
Due to these guidelines, the Subscription.contentType
refers to the content of the body of the message. Attachment type information can be appended as a MIME parameter, for example:
text/plain
: a plain-text body with no attachmenttext/html
: an HTML body with no attachmenttext/plain;attach=application/fhir+json
: a plain-text body with a FHIR JSON bundle attachedtext/html;attach=application/fhir+xml
: an HTML body with a FHIR XML bundle attached
The Subscription.content
field SHALL be applied to any attachments, and MAY be applied to body contents (depending on server implementation). However, a server must not include a body which exceeds the specified content level. For example, a server may choose to always include a standard message in the body of the message containing no PHI and vary the attachment, but cannot include PHI in the body of an email when the content is set to empty
.
An example workflow using the email
channel type is included below.
Subscription
with the channelType
set to email
.
requested
or active
.
handshake
notification. If the subscription was set to requested
, it should be updated to active
after successfully sending the email (pending additional steps such as user confirmation, etc.).
heartbeat
at any time.
event-notificaiton
at any time.
Email (SMTP) is not a secure channel. Implementers must ensure that any messages containing PHI have been secured according to their policy requirements (e.g., use of a system such as Direct ).
There are times when it is desireable to use Subscriptions as a communication channel between FHIR servers. This can be accomplished using a Subscription
with the channel type of message
.
To receive notifications via messaging, a client should request a subscription with the channel type (Subscription.channelType
) of message
and set the endpoint (Subscription.endpoint
) to the destination FHIR server base URL. Note that this URL must be accessible by the hosting server.
The FHIR server hosting the subscription (server) will send FHIR messages to the destination FHIR server (endpoint) as needed. These messages will, as the contents of the message, have a fully-formed subscription-notification
Bundle. An example message can be found here.
An example workflow using the message
channel type is included below.
Subscription
with the channelType
set to message
.
requested
.
handshake
notification.
heartbeat
at any time.
event-notificaiton
at any time.
Trial-Use Note: The Messaging channel type needs more testing and feedback to ensure all requirements are met before finalizing the specification.
Servers MAY require that the end-point is white-listed prior to allowing these kinds of subscriptions. Additionally, servers MAY impose authorization/authentication requirements for server to server communication (e.g., certificate pinning, etc.).
Defining a new channel type requires clear communication to implementers of both clients and servers around requirements and expectations. Below are some areas which should be considered when creating a channel. Anyone defining a channel type is encouraged to publish their definition at registry.fhir.org .
Trial-Use Note: Warning: This section is still in early drafting.
At a minimum, the following items should be defined:
Subscription.channelType
(e.g., 'secure-mq' isntead of 'channel0012')Subscription.endpoint
(e.g., URI, etc.)Subscription.header
field values (e.g., REST-hook defines as Auth headers included in a POST)Subscription.contentType
(e.g., email defines this as the email body, with allowable attachments.)
The subscription resource is authored by the client with an initial status of requested
. A new subscription is created on the server using the RESTful create or update interaction. After a successful transaction, the client parses the Location header and saves the new Subscription's logical id for use in subsequent operations.
When the server receives a subscription, it SHOULD check that it is prepared to accept/process the subscription. If it is, it sets the subscription to requested
and process it like a normal create. If it isn't, it SHOULD return an error with an OperationOutcome instead of processing the create
.
The criteria are subject to the same limitations as the client that created it, such as access to patient compartments etc. Note that the subscription MAY remain active after the client access tokens expire.
Once the server has activated the subscription, it sets the status to active
(note: the server may do this as it accepts the resource if it wants).
An appropriately authorized client can use search and/or history operations to see what subscriptions are currently active on the server. Once the subscription is no longer desired, the client deletes the subscription from the server.
The server may retry the notification a fixed number of times and/or refer errors to its own alert logs. If the notification fails, the server SHOULD set the status to error
and mark the error in the resource. If the notification succeeds, the server SHOULD update the status to active
and may remove any error codes. If a subscription fails consistently a server may choose set the subscription status to off
and stop trying to send notifications.
Errors a server wishes to make accessible to clients are stored in Subscription.error
. Servers should provide a mechanism for clearing errors (e.g., when resetting a Subscription.status
back to requested
after an error). Since Subscription.error
represents server errors, a server SHOULD NOT allow clients to add errors.
Search parameters for this resource. The common parameters also apply. See Searching for more information about searching in REST, messaging, and services.
Name | Type | Description | Expression | In Common |
contact | token | Contact details for the subscription | Subscription.contact | |
identifier | token | A subscription identifier | Subscription.identifier | |
payload | token | The mime-type of the notification payload | ||
status N | token | The current state of the subscription | Subscription.status | |
type | token | The type of channel for the sent notifications | ||
url | uri | The uri that will receive the notifications |