Release 4B Snapshot #1

This page is part of the FHIR Specification v4.3.0-snapshot1: R4B Snapshot to support the Jan 2022 Connectathon. About the R4B version of FHIR. The current officially released version is 4.3.0. For a full list of available versions, see the Directory of published versions . Page versions: R5 R4B

2.47 Resource SubscriptionStatus - Content

FHIR Infrastructure Work GroupMaturity Level: 0 DraftSecurity Category: Business Compartments: Not linked to any defined compartments

The SubscriptionStatus resource describes the state of a Subscription during notifications.

This document contains information about the SubscriptionStatus resource and details specific to options in it. It is defined as part of the Pub/Sub (Publish / Subscribe) model of Subscriptions.

The SubscriptionStatus resource is used to convey information about the current state of a Subscription. Information contained within a SubscriptionStatus falls into three categories:

  • Information to identify the relevant Subscription (e.g., a reference to a Subscription, SubscriptionTopic)
  • Information about the current state of the Subscription (e.g., Subscription status, number of events the Subscription has generated)
  • Information about a current notification (e.g., notification type, number of events in this notification)

The SubscriptionStatus resource is used in the Subscriptions Framework. This resource is designed only to be used to convey state information about a subscription during various operations, for example included with notifications or as the result of a status request.

No resources refer to this resource directly.

This resource does not implement any patterns.

Structure

NameFlagsCard.TypeDescription & Constraintsdoco
.. SubscriptionStatus DDomainResourceStatus information about a Subscription provided during event notification
Elements defined in Ancestors: id, meta, implicitRules, language, text, contained, extension, modifierExtension
... status Σ0..1coderequested | active | error | off | entered-in-error
SubscriptionStatus (Required)
... type ?!Σ1..1codehandshake | heartbeat | event-notification | query-status | query-event
SubscriptionNotificationType (Required)
... eventsSinceSubscriptionStart Σ0..1stringEvents since the Subscription was created
... notificationEvent 0..*BackboneElementDetailed information about any events relevant to this notification
.... eventNumber 1..1stringEvent number
.... timestamp 0..1instantThe instant this event occurred
.... focus 0..1Reference(Any)The focus of this event
.... additionalContext 0..*Reference(Any)Additional context for this event
... subscription Σ1..1Reference(Subscription)Reference to the Subscription responsible for this notification
... topic Σ0..1canonical(SubscriptionTopic)Reference to the SubscriptionTopic this notification relates to
... error Σ0..*CodeableConceptList of errors on the subscription
Subscription Error Codes (Example)

doco Documentation for this format

UML Diagram (Legend)

SubscriptionStatus (DomainResource)The status of the subscription, which marks the server state for managing the subscriptionstatus : code [0..1] « null (Strength=Required)SubscriptionStatus! »The type of event being conveyed with this notificaiton (this element modifies the meaning of other elements)type : code [1..1] « null (Strength=Required)SubscriptionNotificationType! »The total number of actual events which have been generated since the Subscription was created (inclusive of this notification) - regardless of how many have been successfully communicated. This number is NOT incremented for handshake and heartbeat notificationseventsSinceSubscriptionStart : string [0..1]The total number of actual events represented within this notification. For handshake and heartbeat notifications, this will be zero or not present. For event-notifications, this number may be one or more, depending on server batchingeventsInNotification : integer [0..1]The reference to the Subscription which generated this notificationsubscription : Reference [1..1] « Subscription »The reference to the SubscriptionTopic for the Subscription which generated this notificationtopic : canonical [0..1] « SubscriptionTopic »A record of errors that occurred when the server processed a notificationerror : CodeableConcept [0..*] « null (Strength=Example)SubscriptionErrorCodes?? »NotificationEventThe sequential number of this event in this subscription context. Note that this value is a 64-bit integer value, encoded as a stringeventNumber : string [1..1]The actual time this event occured on the servertimestamp : instant [0..1]The focus of this event. While this will usually be a reference to the focus resource of the event, it MAY contain a reference to a non-FHIR objectfocus : Reference [0..1] « Any »Additional context information for this event. Generally, this will contain references to additional resources included with the event (e.g., the Patient relevant to an Encounter), however it MAY refer to non-FHIR objectsadditionalContext : Reference [0..*] « Any »Detailed information about events relevant to this subscription notificationnotificationEvent[0..*]

Turtle Template

@prefix fhir: <http://hl7.org/fhir/> .doco


[ a fhir:SubscriptionStatus;
  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:SubscriptionStatus.status [ code ]; # 0..1 requested | active | error | off | entered-in-error
  fhir:SubscriptionStatus.type [ code ]; # 1..1 handshake | heartbeat | event-notification | query-status | query-event
  fhir:SubscriptionStatus.eventsSinceSubscriptionStart [ string ]; # 0..1 Events since the Subscription was created
  fhir:SubscriptionStatus.eventsInNotification [ integer ]; # 0..1 The number of actual notifications represented by this bundle
  fhir:SubscriptionStatus.notificationEvent [ # 0..* Detailed information about any events relevant to this notification
    fhir:SubscriptionStatus.notificationEvent.eventNumber [ string ]; # 1..1 Event number
    fhir:SubscriptionStatus.notificationEvent.timestamp [ instant ]; # 0..1 The instant this event occurred
    fhir:SubscriptionStatus.notificationEvent.focus [ Reference(Any) ]; # 0..1 The focus of this event
    fhir:SubscriptionStatus.notificationEvent.additionalContext [ Reference(Any) ], ... ; # 0..* Additional context for this event
  ], ...;
  fhir:SubscriptionStatus.subscription [ Reference(Subscription) ]; # 1..1 Reference to the Subscription responsible for this notification
  fhir:SubscriptionStatus.topic [ canonical(SubscriptionTopic) ]; # 0..1 Reference to the SubscriptionTopic this notification relates to
  fhir:SubscriptionStatus.error [ CodeableConcept ], ... ; # 0..* List of errors on the subscription
]

Changes since R3

This resource did not exist in Release 2

This analysis is available as XML or JSON.

Structure

NameFlagsCard.TypeDescription & Constraintsdoco
.. SubscriptionStatus DDomainResourceStatus information about a Subscription provided during event notification
Elements defined in Ancestors: id, meta, implicitRules, language, text, contained, extension, modifierExtension
... status Σ0..1coderequested | active | error | off | entered-in-error
SubscriptionStatus (Required)
... type ?!Σ1..1codehandshake | heartbeat | event-notification | query-status | query-event
SubscriptionNotificationType (Required)
... eventsSinceSubscriptionStart Σ0..1stringEvents since the Subscription was created
... notificationEvent 0..*BackboneElementDetailed information about any events relevant to this notification
.... eventNumber 1..1stringEvent number
.... timestamp 0..1instantThe instant this event occurred
.... focus 0..1Reference(Any)The focus of this event
.... additionalContext 0..*Reference(Any)Additional context for this event
... subscription Σ1..1Reference(Subscription)Reference to the Subscription responsible for this notification
... topic Σ0..1canonical(SubscriptionTopic)Reference to the SubscriptionTopic this notification relates to
... error Σ0..*CodeableConceptList of errors on the subscription
Subscription Error Codes (Example)

doco Documentation for this format

UML Diagram (Legend)

SubscriptionStatus (DomainResource)The status of the subscription, which marks the server state for managing the subscriptionstatus : code [0..1] « null (Strength=Required)SubscriptionStatus! »The type of event being conveyed with this notificaiton (this element modifies the meaning of other elements)type : code [1..1] « null (Strength=Required)SubscriptionNotificationType! »The total number of actual events which have been generated since the Subscription was created (inclusive of this notification) - regardless of how many have been successfully communicated. This number is NOT incremented for handshake and heartbeat notificationseventsSinceSubscriptionStart : string [0..1]The total number of actual events represented within this notification. For handshake and heartbeat notifications, this will be zero or not present. For event-notifications, this number may be one or more, depending on server batchingeventsInNotification : integer [0..1]The reference to the Subscription which generated this notificationsubscription : Reference [1..1] « Subscription »The reference to the SubscriptionTopic for the Subscription which generated this notificationtopic : canonical [0..1] « SubscriptionTopic »A record of errors that occurred when the server processed a notificationerror : CodeableConcept [0..*] « null (Strength=Example)SubscriptionErrorCodes?? »NotificationEventThe sequential number of this event in this subscription context. Note that this value is a 64-bit integer value, encoded as a stringeventNumber : string [1..1]The actual time this event occured on the servertimestamp : instant [0..1]The focus of this event. While this will usually be a reference to the focus resource of the event, it MAY contain a reference to a non-FHIR objectfocus : Reference [0..1] « Any »Additional context information for this event. Generally, this will contain references to additional resources included with the event (e.g., the Patient relevant to an Encounter), however it MAY refer to non-FHIR objectsadditionalContext : Reference [0..*] « Any »Detailed information about events relevant to this subscription notificationnotificationEvent[0..*]

Turtle Template

@prefix fhir: <http://hl7.org/fhir/> .doco


[ a fhir:SubscriptionStatus;
  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:SubscriptionStatus.status [ code ]; # 0..1 requested | active | error | off | entered-in-error
  fhir:SubscriptionStatus.type [ code ]; # 1..1 handshake | heartbeat | event-notification | query-status | query-event
  fhir:SubscriptionStatus.eventsSinceSubscriptionStart [ string ]; # 0..1 Events since the Subscription was created
  fhir:SubscriptionStatus.eventsInNotification [ integer ]; # 0..1 The number of actual notifications represented by this bundle
  fhir:SubscriptionStatus.notificationEvent [ # 0..* Detailed information about any events relevant to this notification
    fhir:SubscriptionStatus.notificationEvent.eventNumber [ string ]; # 1..1 Event number
    fhir:SubscriptionStatus.notificationEvent.timestamp [ instant ]; # 0..1 The instant this event occurred
    fhir:SubscriptionStatus.notificationEvent.focus [ Reference(Any) ]; # 0..1 The focus of this event
    fhir:SubscriptionStatus.notificationEvent.additionalContext [ Reference(Any) ], ... ; # 0..* Additional context for this event
  ], ...;
  fhir:SubscriptionStatus.subscription [ Reference(Subscription) ]; # 1..1 Reference to the Subscription responsible for this notification
  fhir:SubscriptionStatus.topic [ canonical(SubscriptionTopic) ]; # 0..1 Reference to the SubscriptionTopic this notification relates to
  fhir:SubscriptionStatus.error [ CodeableConcept ], ... ; # 0..* List of errors on the subscription
]

Changes since Release 3

This resource did not exist in Release 2

This analysis is available as XML or JSON.

 

See the Profiles & Extensions and the alternate definitions: Master Definition XML + JSON, XML Schema/Schematron + JSON Schema, ShEx (for Turtle) + see the extensions & the dependency analysis

PathDefinitionTypeReference
SubscriptionStatus.status RequiredSubscriptionStatus
SubscriptionStatus.type RequiredSubscriptionNotificationType
SubscriptionStatus.error ExampleSubscriptionErrorCodes

This resource is used to communicate information about a Subscription and the events represented by a notification bundle. The process of sending a notification (e.g., a notification this status is included with) can change the status of that subscription. Servers SHALL populate elements with the most recent information at the time of generation (e.g., when a notification is created) and receivers SHOULD be aware that this information may not be current at the time a notification is processed (e.g., a subscription was active but has subsequently moved to an error state).

Subscription notifications MAY contain PHI. Applications are responsible for following FHIR security guidance and compliance with relevant security requirements (e.g., corporate policy, government regulation, etc.). Hinting for the allowed amount of PHI is available in the relevant Subscription resource, via the channel and payload information.

Since Subscription Topic definitions contain human-readable descriptions and definitions, the purpose of a topic may be understood by viewing the resource. Given that canonical links to topics are intended to be resolvable and/or searchable (e.g., indexed in a registry), it is assumed that anyone with a link to a topic also knows what that topic is about. Thus, topics MAY be considered PHI and SHOULD be reviewed before inclusion in a notification.

Hinting about when a canonical topic URL may be included with a notification can be derived from a subscription's payload level. E.g.:

  • empty: SHOULD NOT be present
  • id-only: MAY be present
  • full-resource: SHOULD be present

This specification describes five distinct outbound notification types: Event, Handshake, Heartbeat, Query Status, and Query Event. For each, the notification body is a subscription-notification Bundle with a SubscriptionStatus resource used to convey Subscription and notification details.

The primary notification bundle type is a notification about an event.

ElementOptionalityNotes
SubscriptionStatus.statusRecommendedCurrent status of the relevant subscription (e.g., active).
SubscriptionStatus.typeRequiredSHALL be event-notification
SubscriptionStatus.eventsSinceSubscriptionStartRecommendedServers SHOULD include this value when sending event notifications in order to allow clients to detect missing events.
This value is inclusive of this notification (e.g., the first event notification sent would include one (1) in this element).
SubscriptionStatus.eventsInNotificationRecommendedServers SHOULD include this value when sending event notifications to ease client processing.
SubscriptionStatus.notificationEventSpecialIn general, filling out the eventNumber and timestamp is recommended. Links contained in the focus and additionalContext elements contain resource IDs and should mirror the payload level used in the subscription:
  • empty: SHOULD NOT be present
  • id-only: SHOULD be present
  • full-resource: SHOULD be present
SubscriptionStatus.topicOptionalSee Content and PHI.

When a connection to an Endpoint is established or re-established, a server MAY send a Handshake notification to the endpoint.

The client expectations upon receipt of a Handshake notification differ for each channel type (e.g., for the rest-hook channel type, a client endpoint responds to event notifications with standard HTTP response codes).

ElementOptionalityNotes
SubscriptionStatus.statusRecommendedCurrent status of the relevant subscription (e.g., active).
SubscriptionStatus.typeRequiredSHALL be handshake
SubscriptionStatus.eventsSinceSubscriptionStartOptionalFor a new Subscription, if this value is present it SHALL be zero (0).
A sender MAY send a handshake with a non-zero number of events, for example as process for re-establishing communication after an error state.
Note: this value SHALL NOT be incremented by sending a handshake notification.
SubscriptionStatus.eventsInNotificationOptionalIf present, this value SHALL be zero (0).
SubscriptionStatus.notificationEventProhibitedA handshake notification SHALL NOT contain any event information.
SubscriptionStatus.topicOptionalSee Content and PHI.

The client is not expected to take any special action in receipt of a Handshake notification beyond the channel-specific requirement for receiving an event notification.

Servers MAY periodically send notifications across a channel to ensure that the connection is still alive and valid (e.g., in accordance with a client's requested heartbeat interval). A heartbeat notification is an empty subscription-notification Bundle sent without incrementing the subscription event count.

A client SHOULD use a hearbeat notification to verify that no events have been missed (if possible). However, a client is not required to take any action in receipt of a heartbeat beyond the channel-specific requirement for receiving an event notification (e.g., accepting the notification bundle with an HTTP 200).

ElementOptionalityNotes
SubscriptionStatus.statusRecommendedCurrent status of the relevant subscription (e.g., active).
SubscriptionStatus.typeRequiredSHALL be heartbeat
SubscriptionStatus.eventsSinceSubscriptionStartRecommendedThe presence of this value allows clients to detect missing notifications.
Note: this value SHALL NOT be incremented by sending a heartbeat notification.
SubscriptionStatus.eventsInNotificationOptionalIf present, this value SHALL be zero (0).
SubscriptionStatus.notificationEventProhibitedA heartbeat notification SHALL NOT contain any event information.
SubscriptionStatus.topicOptionalSee Content and PHI.

Clients can ask a server at any time for the current status of a Subscription via the $status operation.

Since the $status operation is part of the FHIR REST API, the guidance below assumes that a user has been authenticated and is allowed access to all relevant resources.

ElementOptionalityNotes
SubscriptionStatus.statusRequiredCurrent status of the relevant subscription (e.g., active).
SubscriptionStatus.typeRequiredSHALL be query-status
SubscriptionStatus.eventsSinceSubscriptionStartRequiredThis value is required for clients to know if there are missing notifications.
Note: this value SHALL NOT be incremented by sending a query-status notification.
SubscriptionStatus.eventsInNotificationOptionalIf present, this value SHALL be zero (0).
SubscriptionStatus.notificationEventProhibitedA query-status notification SHALL NOT contain any event information.
SubscriptionStatus.topicRecommendedSee Content and PHI, but note that guidance will vary since there is an active user session.

Some servers may allow clients to ask for events which have already occurred. Notification bundles returned by such operations or queries should use the query-event type.

ElementOptionalityNotes
SubscriptionStatus.statusRecommendedCurrent status of the relevant subscription (e.g., active).
SubscriptionStatus.typeRequiredSHALL be query-event
SubscriptionStatus.eventsSinceSubscriptionStartRecommendedThis value is allows clients to know if they are missing notifications.
Note: this value SHALL NOT be incremented by sending a query-event bundle.
SubscriptionStatus.eventsInNotificationRequiredThe number of events actually returned by this operation request.
SubscriptionStatus.notificationEventRecommendedA query-event notification SHOULD contain as much event information as possible, to simplify client processing.
SubscriptionStatus.topicRecommendedSee Content and PHI, but note that guidance will vary since there is an active user session.

If a server encounters errors while sending a notification, 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 of the subscription to error. If the error would be useful to a client (e.g., notification failed because the destination SSL certificate expired), servers SHOULD track errors and provide details to the client. If a notification retry attempt 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.

One role of the SubscriptionStatus resource is to aid clients (subscribers) in error detection. Included are two classes of errors and how they can be found. Please note that this is not intended to serve as a comprehensive list of errors and their resolutions.

There are several mechanisms available to subscribers in order to understand the current state of notification delivery. Below are some example error scenarios with details about how a subscriber can detect the problem state.

The diagram below shows how a subscriber can use the SubscriptionStatus.eventsSinceSubscriptionStart element on received notifications to determine that an event has been missed.

Diagram of missing event workflow

In the above sequence, the subscriber tracks the eventsSinceSubscriptionStart of each received notification (per Subscription). When the subscriber received event 23, the subscriber was aware that the last notification it received was a single notification for event 21. The subscriber then waited an amount of time to ensure that event 22 was indeed missing (and not, for example, still being processed) and started a recovery process. The recovery process itself will vary by subscriber, but should be a well-understood method for recovering in the event of errors.

The diagram below show how a subscriber can use the Subscription.heartbeatPeriod to determine errors which prevent notifications from reaching the endpoint.

Diagram of heartbeat-detection workflow

In the above sequence, the subscriber is aware that the heartbeatPeriod has elapsed for a subscription without receiving any notifications. The subscriber then asks the server for the $status of the subscription, and seeing an error, begins a recovery process. As in the previous scenario, the recovery process itself will vary by subscriber, but should be a well-understood method for recovering in the event of errors.