Current Build

2.46 Resource Subscription - Content

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

The subscription resource describes a particular client's request to be notified about a Topic.

The subscription resource is used to define a push-based transaction from a server to another system. A suscriber subscribes to one or more predefined Topics which the server supports. Subscribers typically receive only a subset of the total event notifications for a given topic by filtering on the content. The filtering criteria are defined by the Topic resource. Once a subscription is created, any topics that meet the filtering criteria cause a notification to be sent using the provided channel.

The server is able to send notifications without any information about the matching resource, or with the entire resource.

Several different types of channels are supported:

  • rest-hook: A notification is POSTed to the client nominated URL identified in the Subscription resource.
  • websocket: A PING message is sent to the designated URI
  • email/sms: A notification is sent to the nominated email address or SMS number
  • message: The resource is sent to the application identified in the URI as a message

See below for further discussion of the various channels. Note that sending the entire resource creates security concerns that must be managed by the server.

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.

As an alternative to subscriptions, the RESTful API describes a polling-based subscription method using bundles and the history operation. This method of polling allows for a much tighter relationship between the client and the server that doesn't involve missing updates and/or deletes.

When using the Subscription resource, the FHIR server combines the roles of publisher and information distributer. Other arrangements of the publish and subscribe pattern describe separate agents for the two roles. Implementers may implement the Subscription resource using an architecture with separate agents, or using any other pub/sub architectire (e.g. see FHIRCast , or, more generally, W3C Pub/Sub ).

No resources refer to this resource directly.

This resource does not implement any patterns.

Structure

NameFlagsCard.TypeDescription & Constraintsdoco
.. Subscription TUDomainResourceNotification about a Topic
Elements defined in Ancestors: id, meta, implicitRules, language, text, contained, extension, modifierExtension
... identifier Σ0..*IdentifierAdditional identifiers (business identifier)
... name Σ0..1stringHuman readable name for this subscription
... status ?!Σ1..1coderequested | active | error | off
SubscriptionStatus (Required)
... topic Σ1..1Reference(Topic)Reference to the topic being subscribed to
... contact Σ0..*ContactPointContact details for source (e.g. troubleshooting)
... end Σ0..1instantWhen to automatically delete the subscription
... reason Σ1..1stringDescription of why this subscription was created
... filterBy Σ0..*BackboneElementCriteria for narrowing the topic stream
.... name Σ1..1stringFilter label defined in Topic
.... matchType Σ0..1code= | in | not-in | above | below
SubscriptionFilterByMatchType (Required)
.... value Σ1..1stringLiteral value or resource path
... error Σ0..*CodeableConceptLatest error code or note
Subscription Error Codes (Example)
... eventCount Σ0..1unsignedIntNotification event counter
... channel Σ1..1BackboneElementThe channel on which to report matches to the criteria
.... type Σ1..1CodeableConceptrest-hook | websocket | email | sms | message
SubscriptionChannel Type Codes (Extensible)
.... endpoint Σ0..1urlWhere the channel points to
.... header Σ0..*stringUsage depends on the channel type
.... heartbeatPeriod Σ0..1unsignedIntInterval in seconds to send 'heartbeat' notification
.... payload Σ0..1BackboneElementPayload definition
..... contentType Σ0..1codeMIME type to send, or omit for no payload
MimeType (Required)
..... content Σ0..1codeempty | id-only | full-resource
SubscriptionPayloadContent (Required)

doco Documentation for this format

UML Diagram (Legend)

Subscription (DomainResource)A formal identifier that is used to identify this code system when it is represented in other formats, or referenced in a specification, model, design or an instanceidentifier : Identifier [0..*]A natural language name identifying the subscriptionname : string [0..1]The status of the subscription, which marks the server state for managing the subscription (this element modifies the meaning of other elements)status : code [1..1] « The status of a subscription. (Strength=Required)SubscriptionStatus! »The reference to the topic to be notified abouttopic : Reference [1..1] « Topic »Contact details for a human to contact about the subscription. The primary use of this for system administrator troubleshootingcontact : ContactPoint [0..*]The time for the server to turn the subscription offend : instant [0..1]A description of why this subscription is definedreason : string [1..1]A record of the last error that occurred when the server processed a notificationerror : CodeableConcept [0..*] « Codes to represent subscription error details. (Strength=Example)SubscriptionErrorCodes?? »A record of the number of events for which the server has attempted delivery on this subscription (i.e., the number of events that occurred while the subscription is in an "active" or "error" state -- not "requested" or "off"). Server Initializes to 0 for a new subscription. Repeated attempts at delivery of the *same* event notification do not increment this countereventCount : unsignedInt [0..1]FilterByThe filter label (=key) as defined in the `Topic.canFilterBy.name` elementname : string [1..1]The operator to apply to the filter value when determining matches (Search modifiers)matchType : code [0..1] « Operator to apply to filter label. (Strength=Required)SubscriptionFilterByMatchType! »The literal value or resource path as is legal in search - for example, "Patient/123" or "le1950"value : string [1..1]ChannelThe type of channel to send notifications ontype : CodeableConcept [1..1] « The type of method used to execute a subscription. (Strength=Extensible)SubscriptionChannelTypeCodes+ »The url that describes the actual end-point to send messages toendpoint : url [0..1]Additional headers / information to send as part of the notificationheader : string [0..*]If present, a 'hearbeat" notification (keepalive) is sent via this channel with an the interval period equal to this elements integer value in seconds. If not present, a heartbeat notification is not sentheartbeatPeriod : unsignedInt [0..1]PayloadThe mime type to send the payload in - either application/fhir+xml, or application/fhir+json. The mime type "text/plain" may also be used for Email and SMS subscriptionscontentType : code [0..1] « The mime type of an attachment. Any valid mime type is allowed. (Strength=Required)Mime Types! »How much of the resource content to deliver in the notification payload. The choices are an empty payload, only the resource id, or the full resource contentcontent : code [0..1] « Codes to represent how much resource content to send in the notification payload. (Strength=Required)SubscriptionPayloadContent! »The filter properties to be applied to narrow the topic stream. When multiple filters are applied, evaluates to true if all the conditions are met; otherwise it returns false. (i.e., logical AND)filterBy[0..*]The payload mimetype and content. If the payload is not present, then there is no payload in the notification, just a notificationpayload[0..1]Details where to send notifications when resources are received that meet the criteriachannel[1..1]

XML Template

<Subscription xmlns="http://hl7.org/fhir"> doco
 <!-- 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 -->
 <topic><!-- 1..1 Reference(Topic) Reference to the 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]"/><!-- 1..1 Description of why this subscription was created -->
 <filterBy>  <!-- 0..* Criteria for narrowing the topic stream -->
  <name value="[string]"/><!-- 1..1 Filter label defined in Topic -->
  <matchType value="[code]"/><!-- 0..1 = | in | not-in | above | below -->
  <value value="[string]"/><!-- 1..1 Literal value or resource path -->
 </filterBy>
 <error><!-- 0..* CodeableConcept Latest error code or note --></error>
 <eventCount value="[unsignedInt]"/><!-- 0..1 Notification event counter -->
 <channel>  <!-- 1..1 The channel on which to report matches to the criteria -->
  <type><!-- 1..1 CodeableConcept rest-hook | websocket | email | sms | message --></type>
  <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 -->
  <payload>  <!-- 0..1 Payload definition -->
   <contentType value="[code]"/><!-- 0..1 MIME type to send, or omit for no payload -->
   <content value="[code]"/><!-- 0..1 empty | id-only | full-resource -->
  </payload>
 </channel>
</Subscription>

JSON Template

{doco
  "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
  "topic" : { Reference(Topic) }, // R!  Reference to the topic being subscribed to
  "contact" : [{ ContactPoint }], // Contact details for source (e.g. troubleshooting)
  "end" : "<instant>", // When to automatically delete the subscription
  "reason" : "<string>", // R!  Description of why this subscription was created
  "filterBy" : [{ // Criteria for narrowing the topic stream
    "name" : "<string>", // R!  Filter label defined in Topic
    "matchType" : "<code>", // = | in | not-in | above | below
    "value" : "<string>" // R!  Literal value or resource path
  }],
  "error" : [{ CodeableConcept }], // Latest error code or note
  "eventCount" : "<unsignedInt>", // Notification event counter
  "channel" : { // R!  The channel on which to report matches to the criteria
    "type" : { CodeableConcept }, // R!  rest-hook | websocket | email | sms | message
    "endpoint" : "<url>", // Where the channel points to
    "header" : ["<string>"], // Usage depends on the channel type
    "heartbeatPeriod" : "<unsignedInt>", // Interval in seconds to send 'heartbeat' notification
    "payload" : { // Payload definition
      "contentType" : "<code>", // MIME type to send, or omit for no payload
      "content" : "<code>" // empty | id-only | full-resource
    }
  }
}

Turtle Template

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


[ 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
  fhir:Subscription.topic [ Reference(Topic) ]; # 1..1 Reference to the 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 ]; # 1..1 Description of why this subscription was created
  fhir:Subscription.filterBy [ # 0..* Criteria for narrowing the topic stream
    fhir:Subscription.filterBy.name [ string ]; # 1..1 Filter label defined in Topic
    fhir:Subscription.filterBy.matchType [ code ]; # 0..1 = | in | not-in | above | below
    fhir:Subscription.filterBy.value [ string ]; # 1..1 Literal value or resource path
  ], ...;
  fhir:Subscription.error [ CodeableConcept ], ... ; # 0..* Latest error code or note
  fhir:Subscription.eventCount [ unsignedInt ]; # 0..1 Notification event counter
  fhir:Subscription.channel [ # 1..1 The channel on which to report matches to the criteria
    fhir:Subscription.channel.type [ CodeableConcept ]; # 1..1 rest-hook | websocket | email | sms | message
    fhir:Subscription.channel.endpoint [ url ]; # 0..1 Where the channel points to
    fhir:Subscription.channel.header [ string ], ... ; # 0..* Usage depends on the channel type
    fhir:Subscription.channel.heartbeatPeriod [ unsignedInt ]; # 0..1 Interval in seconds to send 'heartbeat' notification
    fhir:Subscription.channel.payload [ # 0..1 Payload definition
      fhir:Subscription.channel.payload.contentType [ code ]; # 0..1 MIME type to send, or omit for no payload
      fhir:Subscription.channel.payload.content [ code ]; # 0..1 empty | id-only | full-resource
    ];
  ];
]

Changes since R3

Subscription
Subscription.identifier
  • Added Element
Subscription.name
  • Added Element
Subscription.status
  • Change value set from http://hl7.org/fhir/ValueSet/subscription-status|4.0.0 to http://hl7.org/fhir/ValueSet/subscription-status|4.1.0
Subscription.topic
  • Added Mandatory Element
Subscription.filterBy
  • Added Element
Subscription.filterBy.name
  • Added Mandatory Element
Subscription.filterBy.matchType
  • Added Element
Subscription.filterBy.value
  • Added Mandatory Element
Subscription.error
  • Max Cardinality changed from 1 to *
  • Type changed from string to CodeableConcept
Subscription.eventCount
  • Added Element
Subscription.channel.type
  • Type changed from code to CodeableConcept
  • Change binding strength from required to extensible
  • Change value set from http://hl7.org/fhir/ValueSet/subscription-channel-type|4.0.0 to http://hl7.org/fhir/ValueSet/subscription-channel-type
Subscription.channel.heartbeatPeriod
  • Added Element
Subscription.channel.payload
  • Type changed from code to BackboneElement
  • Remove Binding http://hl7.org/fhir/ValueSet/mimetypes|4.0.0 (required)
Subscription.channel.payload.contentType
  • Added Element
Subscription.channel.payload.content
  • Added Element
Subscription.criteria
  • deleted

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

NameFlagsCard.TypeDescription & Constraintsdoco
.. Subscription TUDomainResourceNotification about a Topic
Elements defined in Ancestors: id, meta, implicitRules, language, text, contained, extension, modifierExtension
... identifier Σ0..*IdentifierAdditional identifiers (business identifier)
... name Σ0..1stringHuman readable name for this subscription
... status ?!Σ1..1coderequested | active | error | off
SubscriptionStatus (Required)
... topic Σ1..1Reference(Topic)Reference to the topic being subscribed to
... contact Σ0..*ContactPointContact details for source (e.g. troubleshooting)
... end Σ0..1instantWhen to automatically delete the subscription
... reason Σ1..1stringDescription of why this subscription was created
... filterBy Σ0..*BackboneElementCriteria for narrowing the topic stream
.... name Σ1..1stringFilter label defined in Topic
.... matchType Σ0..1code= | in | not-in | above | below
SubscriptionFilterByMatchType (Required)
.... value Σ1..1stringLiteral value or resource path
... error Σ0..*CodeableConceptLatest error code or note
Subscription Error Codes (Example)
... eventCount Σ0..1unsignedIntNotification event counter
... channel Σ1..1BackboneElementThe channel on which to report matches to the criteria
.... type Σ1..1CodeableConceptrest-hook | websocket | email | sms | message
SubscriptionChannel Type Codes (Extensible)
.... endpoint Σ0..1urlWhere the channel points to
.... header Σ0..*stringUsage depends on the channel type
.... heartbeatPeriod Σ0..1unsignedIntInterval in seconds to send 'heartbeat' notification
.... payload Σ0..1BackboneElementPayload definition
..... contentType Σ0..1codeMIME type to send, or omit for no payload
MimeType (Required)
..... content Σ0..1codeempty | id-only | full-resource
SubscriptionPayloadContent (Required)

doco Documentation for this format

UML Diagram (Legend)

Subscription (DomainResource)A formal identifier that is used to identify this code system when it is represented in other formats, or referenced in a specification, model, design or an instanceidentifier : Identifier [0..*]A natural language name identifying the subscriptionname : string [0..1]The status of the subscription, which marks the server state for managing the subscription (this element modifies the meaning of other elements)status : code [1..1] « The status of a subscription. (Strength=Required)SubscriptionStatus! »The reference to the topic to be notified abouttopic : Reference [1..1] « Topic »Contact details for a human to contact about the subscription. The primary use of this for system administrator troubleshootingcontact : ContactPoint [0..*]The time for the server to turn the subscription offend : instant [0..1]A description of why this subscription is definedreason : string [1..1]A record of the last error that occurred when the server processed a notificationerror : CodeableConcept [0..*] « Codes to represent subscription error details. (Strength=Example)SubscriptionErrorCodes?? »A record of the number of events for which the server has attempted delivery on this subscription (i.e., the number of events that occurred while the subscription is in an "active" or "error" state -- not "requested" or "off"). Server Initializes to 0 for a new subscription. Repeated attempts at delivery of the *same* event notification do not increment this countereventCount : unsignedInt [0..1]FilterByThe filter label (=key) as defined in the `Topic.canFilterBy.name` elementname : string [1..1]The operator to apply to the filter value when determining matches (Search modifiers)matchType : code [0..1] « Operator to apply to filter label. (Strength=Required)SubscriptionFilterByMatchType! »The literal value or resource path as is legal in search - for example, "Patient/123" or "le1950"value : string [1..1]ChannelThe type of channel to send notifications ontype : CodeableConcept [1..1] « The type of method used to execute a subscription. (Strength=Extensible)SubscriptionChannelTypeCodes+ »The url that describes the actual end-point to send messages toendpoint : url [0..1]Additional headers / information to send as part of the notificationheader : string [0..*]If present, a 'hearbeat" notification (keepalive) is sent via this channel with an the interval period equal to this elements integer value in seconds. If not present, a heartbeat notification is not sentheartbeatPeriod : unsignedInt [0..1]PayloadThe mime type to send the payload in - either application/fhir+xml, or application/fhir+json. The mime type "text/plain" may also be used for Email and SMS subscriptionscontentType : code [0..1] « The mime type of an attachment. Any valid mime type is allowed. (Strength=Required)Mime Types! »How much of the resource content to deliver in the notification payload. The choices are an empty payload, only the resource id, or the full resource contentcontent : code [0..1] « Codes to represent how much resource content to send in the notification payload. (Strength=Required)SubscriptionPayloadContent! »The filter properties to be applied to narrow the topic stream. When multiple filters are applied, evaluates to true if all the conditions are met; otherwise it returns false. (i.e., logical AND)filterBy[0..*]The payload mimetype and content. If the payload is not present, then there is no payload in the notification, just a notificationpayload[0..1]Details where to send notifications when resources are received that meet the criteriachannel[1..1]

XML Template

<Subscription xmlns="http://hl7.org/fhir"> doco
 <!-- 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 -->
 <topic><!-- 1..1 Reference(Topic) Reference to the 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]"/><!-- 1..1 Description of why this subscription was created -->
 <filterBy>  <!-- 0..* Criteria for narrowing the topic stream -->
  <name value="[string]"/><!-- 1..1 Filter label defined in Topic -->
  <matchType value="[code]"/><!-- 0..1 = | in | not-in | above | below -->
  <value value="[string]"/><!-- 1..1 Literal value or resource path -->
 </filterBy>
 <error><!-- 0..* CodeableConcept Latest error code or note --></error>
 <eventCount value="[unsignedInt]"/><!-- 0..1 Notification event counter -->
 <channel>  <!-- 1..1 The channel on which to report matches to the criteria -->
  <type><!-- 1..1 CodeableConcept rest-hook | websocket | email | sms | message --></type>
  <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 -->
  <payload>  <!-- 0..1 Payload definition -->
   <contentType value="[code]"/><!-- 0..1 MIME type to send, or omit for no payload -->
   <content value="[code]"/><!-- 0..1 empty | id-only | full-resource -->
  </payload>
 </channel>
</Subscription>

JSON Template

{doco
  "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
  "topic" : { Reference(Topic) }, // R!  Reference to the topic being subscribed to
  "contact" : [{ ContactPoint }], // Contact details for source (e.g. troubleshooting)
  "end" : "<instant>", // When to automatically delete the subscription
  "reason" : "<string>", // R!  Description of why this subscription was created
  "filterBy" : [{ // Criteria for narrowing the topic stream
    "name" : "<string>", // R!  Filter label defined in Topic
    "matchType" : "<code>", // = | in | not-in | above | below
    "value" : "<string>" // R!  Literal value or resource path
  }],
  "error" : [{ CodeableConcept }], // Latest error code or note
  "eventCount" : "<unsignedInt>", // Notification event counter
  "channel" : { // R!  The channel on which to report matches to the criteria
    "type" : { CodeableConcept }, // R!  rest-hook | websocket | email | sms | message
    "endpoint" : "<url>", // Where the channel points to
    "header" : ["<string>"], // Usage depends on the channel type
    "heartbeatPeriod" : "<unsignedInt>", // Interval in seconds to send 'heartbeat' notification
    "payload" : { // Payload definition
      "contentType" : "<code>", // MIME type to send, or omit for no payload
      "content" : "<code>" // empty | id-only | full-resource
    }
  }
}

Turtle Template

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


[ 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
  fhir:Subscription.topic [ Reference(Topic) ]; # 1..1 Reference to the 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 ]; # 1..1 Description of why this subscription was created
  fhir:Subscription.filterBy [ # 0..* Criteria for narrowing the topic stream
    fhir:Subscription.filterBy.name [ string ]; # 1..1 Filter label defined in Topic
    fhir:Subscription.filterBy.matchType [ code ]; # 0..1 = | in | not-in | above | below
    fhir:Subscription.filterBy.value [ string ]; # 1..1 Literal value or resource path
  ], ...;
  fhir:Subscription.error [ CodeableConcept ], ... ; # 0..* Latest error code or note
  fhir:Subscription.eventCount [ unsignedInt ]; # 0..1 Notification event counter
  fhir:Subscription.channel [ # 1..1 The channel on which to report matches to the criteria
    fhir:Subscription.channel.type [ CodeableConcept ]; # 1..1 rest-hook | websocket | email | sms | message
    fhir:Subscription.channel.endpoint [ url ]; # 0..1 Where the channel points to
    fhir:Subscription.channel.header [ string ], ... ; # 0..* Usage depends on the channel type
    fhir:Subscription.channel.heartbeatPeriod [ unsignedInt ]; # 0..1 Interval in seconds to send 'heartbeat' notification
    fhir:Subscription.channel.payload [ # 0..1 Payload definition
      fhir:Subscription.channel.payload.contentType [ code ]; # 0..1 MIME type to send, or omit for no payload
      fhir:Subscription.channel.payload.content [ code ]; # 0..1 empty | id-only | full-resource
    ];
  ];
]

Changes since Release 3

Subscription
Subscription.identifier
  • Added Element
Subscription.name
  • Added Element
Subscription.status
  • Change value set from http://hl7.org/fhir/ValueSet/subscription-status|4.0.0 to http://hl7.org/fhir/ValueSet/subscription-status|4.1.0
Subscription.topic
  • Added Mandatory Element
Subscription.filterBy
  • Added Element
Subscription.filterBy.name
  • Added Mandatory Element
Subscription.filterBy.matchType
  • Added Element
Subscription.filterBy.value
  • Added Mandatory Element
Subscription.error
  • Max Cardinality changed from 1 to *
  • Type changed from string to CodeableConcept
Subscription.eventCount
  • Added Element
Subscription.channel.type
  • Type changed from code to CodeableConcept
  • Change binding strength from required to extensible
  • Change value set from http://hl7.org/fhir/ValueSet/subscription-channel-type|4.0.0 to http://hl7.org/fhir/ValueSet/subscription-channel-type
Subscription.channel.heartbeatPeriod
  • Added Element
Subscription.channel.payload
  • Type changed from code to BackboneElement
  • Remove Binding http://hl7.org/fhir/ValueSet/mimetypes|4.0.0 (required)
Subscription.channel.payload.contentType
  • Added Element
Subscription.channel.payload.content
  • Added Element
Subscription.criteria
  • deleted

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

PathDefinitionTypeReference
Subscription.status The status of a subscription.RequiredSubscriptionStatus
Subscription.filterBy.matchType Operator to apply to filter label.RequiredSubscriptionFilterByMatchType
Subscription.error Codes to represent subscription error details.ExampleSubscriptionErrorCodes
Subscription.channel.type The type of method used to execute a subscription.ExtensibleSubscriptionChannelTypeCodes
Subscription.channel.payload.contentType The mime type of an attachment. Any valid mime type is allowed.RequiredMime Types
Subscription.channel.payload.content Codes to represent how much resource content to send in the notification payload.RequiredSubscriptionPayloadContent

Trial-Use Note:

TODO

  1. 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)
  2. Updates to "Tracking Subscription Notifications" SHOULD define what the AuditEvent looks like

  3. Updates to "Channels" "REST Hook" `Replace “message” with “notification”

  4. Updates to "Channels" "WebSockets" Replace “message” with “notification”

  5. Updates to "Channels" "Email/SMS" ...

  6. Updates to "Channels" "Messaging" ...

The three types of notifications which a server is able to send to a client are the Event, Handshake and Heartbeat notification. All of the notification types are history Bundles with added extensions on the Bundle.meta element to define Subscription notification specific details.

TODO: In the following sections provide specific guidance for each channel types this including for REST Hooks + Web Sockets

The primary notification is a notification about an event.

The client expectations upon receipt of receipt of a Handshake notification are defined by each implementation.

When a connection to an Endpoint is established, the Server will send an empty History Bundle as a Handshake notification to the client.

The client is not expected to take any special action in receipt of a Handshake notification beyond the channel requirements.

Servers may periodically send notifications across a channel to ensure that the connection is still alive and valid. The Heartbeat notification is an empty History Bundle sent without incrementing the subscription event count.

The client is not expected to take any special action in receipt of a Heartbeat notification beyond the channel requirements.

  • The subscription-event-count extension is used to indicate the number of times a notification has been attempted on this Subscription PRIOR to this notification being sent.

    • In the case of a handshake, this count will always be zero (0).

    • In the case of a heartbeat notification, this count will be the same as the last notification and will not be incremented due to the heartbeat notification.

    • In the case of event notifications, the event count will be incremented by the number of notifications contained within this bundle (typically a single notification, though servers may choose to batch notifications within a short time interval).

  • The bundle-event-count extension represents the number of events ( event-notifications, notifications ??) within the Bundle. This is of particular interest in several ways:

    • Determining if a notification requires further processing (e.g., discarding handshake and heartbeat)

    • Determining the number of events in empty payload scenarios

    • Server batching (e.g., a server sending at max one notification per second)

    • In the case of a handshake, this count will always be zero (0).

  • The subscription-status extension is used to represent the Subscription status values at the time the notification is sent. Note that the status might change between the time the notification is sent and the time it is received/processed, and therefore this status recorded in the extension is not guaranteed to represent status of the Subscription at any time prior-to or after this notification is sent. The field is useful primarily as a hint to inform the client if the server has encountered errors in notifications immediately preceding this notification.

  • The subscription-topic-url extension references the Topic resource relevant to this notification. The URL is an absolute references to the resource on the server that generated the notification and NOT a reference its canonical URL.

  • The subscription-url extension references the Subscription resource which triggered this notification. The URL is an absolute references to the resource on the server that generated the notification.

There are three options available when specifying the contents of a Notification: empty, id-only, and full-resource. These options change the amount of information conveyed in the notification bundle itself.

When deciding which payload type to request, the client SHOULD consider both ease in processing and security of PHI. If any untrusted hosts are included in processing notifications, it is STRONGLY recommended to use an empty payload to protect confidential health information.

Examples:

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.

When the server processes an event meeting the specified criteria, the server POSTs an event notification to the client's nominated endpoint URL (i.e. to the Subscription.channel[type=rest-hook].endpoint) as shown in the following examples. The content-type of the POST SHALL match the contentType (Subscription.channel.payload.contentType) requested during creation of the Subscription. Note that the server SHALL append the headers, if any are given, to the POST request that it makes to the client.

This example uses an event notification with an empty payload to alert the subscriber that new results are available:

Request:

POST to [client endpoint]

Request Payload

{
    "resourceType": "Bundle",
    "id": "notification-empty",
    "meta": {
      "extension": [
        {
          "url": "http://hl7.org/fhir/StructureDefinition/subscription-event-count",
          "valueUnsignedInt": 1
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/bundle-event-count",
          "valueUnsignedInt": 1
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/subscription-status",
          "valueCode": "active"
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/subscription-topic-url",
          "valueUrl": "https://example.org/baseR4/Topic/admission"
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/subscription-url",
          "valueUrl": "https://example.org/Subscription/cb2dce51-a1f5-40b4-a98b-c934eae368e8"
        }
      ]
    },
    "type": "history",
    "timestamp": "2019-08-07T10:24:13.1882432-05:00"
  }

Since the content element is set to empty, the data in the resources is only available through the REST API which helps consolidate authorization and authentication logic. When the subscriber receives a POST to its nominated endpoint it may queries the server to fetch all the relevant resources based on the Topic. The parameter &_since=:last (where :last is replaced by the time at which the client last checked) may be appended to the query fetch the most recent resources. For example, in this example the topic is patient admission, and the subscriber may fetch the most recent Encounters for a patient or group of patients.

In this example, the event notification contains the only the ids for resource. This provide the subscriber with the id for fetching the data.

Request:

POST to [client endpoint]

Request Payload

{
    "resourceType": "Bundle",
    "id": "notification-id-only",
    "meta": {
      "extension": [
        {
          "url": "http://hl7.org/fhir/StructureDefinition/subscription-event-count",
          "valueUnsignedInt": 2
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/bundle-event-count",
          "valueUnsignedInt": 1
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/subscription-status",
          "valueCode": "active"
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/subscription-topic-url",
          "valueUrl": "https://example.org/baseR4/Topic/admission"
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/subscription-url",
          "valueUrl": "https://example.org/Subscription/cb2dce51-a1f5-40b4-a98b-c934eae368e8"
        }
      ]
    },
    "type": "history",
    "timestamp": "2019-08-07T10:24:13.1882432-05:00",
    "entry": [
      {
        "fullUrl": "https://example.org/baseR4/Encounter/2",
        "request": {
          "method": "PUT",
          "url": "Encounter/2"
        },
        "response": {
          "status": "201"
        }
      }
    ]
  }

Since the content element is set to id-only, like in the first scenario, the data in the resources is only available through the REST API which helps consolidate authorization and authentication logic. When the subscriber receives a POST to its nominated endpoint it may queries the server to fetch all the relevant resources using the supplied resource ids. For example, in this example the topic is patient admission, and the subscriber may fetch the Encounter(s) for a patient or group of patients.

In this example, the event notification contains the the entire resource. This is usually appropriate for defining routing rules within a managed eco-system such as a healthcare institution.

Request:

POST to [client endpoint]

Request Payload

{
    "resourceType": "Bundle",
    "id": "notification-full-resource",
    "meta": {
      "extension": [
        {
          "url": "http://hl7.org/fhir/StructureDefinition/subscription-event-count",
          "valueUnsignedInt": 3
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/bundle-event-count",
          "valueUnsignedInt": 1
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/subscription-status",
          "valueCode": "active"
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/subscription-topic-url",
          "valueUrl": "https://example.org/baseR4/Topic/admission"
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/subscription-url",
          "valueUrl": "https://example.org/Subscription/cb2dce51-a1f5-40b4-a98b-c934eae368e8"
        }
      ]
    },
    "type": "history",
    "timestamp": "2019-08-07T10:24:13.1882432-05:00",
    "entry": [
      {
        "fullUrl": "https://example.org/baseR4/Encounter/3",
        "resource": {
          "resourceType": "Encounter",
          "id": "3",
          "meta": {
            "versionId": "1",
            "lastUpdated": "2019-08-07T10:49:22Z"
          },
          "status": "in-progress",
          "class": {
            "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
            "code": "VR",
            "display": "virtual"
          },
          "subject": {
            "reference": "Patient/123"
          }
        },
        "request": {
          "method": "PUT",
          "url": "Encounter/3"
        },
        "response": {
          "status": "201"
        }
      }
    ]
  }

This requests that a server forward a copy of any matching resource in JSON format to the nominated server as an Update operation (i.e PUT) using the nominated URL as the service base. In order to execute this channel, the server SHALL know how to authenticate appropriately with the destination server. This can be done by the subscription resource providing an authentication header for the server to use, or alternatively, the server may be specifically configured to be able to use the nominated server.

Subscriptions are created exclusively via the FHIR REST API. But 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 listen via Web Sockets:

{
  "channel": {
  "type": {
    "coding": [
      {
        "system": "http://terminology.hl7.org/CodeSystem/subscription-channel-type",
        "code": "websocket"
        }
      ]
    }
  }
}

The subscriber would then initiate a Web Socket connection to the server, at a URL advertised in the FHIR server's Capability statement (subscriptions/webSocketUrl (todo)). A simple protocol is used to listen for notifications:

  • Client connects a secure Web Socket to the server's webSocketUrl (see websocket extension in the server's CapabilityStatement).
  • Client authenticates to server using a server-specified Web socket protocol (e.g. OAuth bearer token presentation).
  • Client sends a bind :id message over the socket (using the logical id of the subscription). For example, the client might issue: bind 123).
  • Server responds with a "bound :id" message to acknowledge.
  • Server sends a "ping :id" message to notify the client each time a new result is available

Trial-Use Note: Warning: The WebSocket channel type is being examined to provide functional parity with other channel types. In particular, the current system fails to address authentication and a desire for multiple subscriptions to be available to a single WebSocket connection. More work is required.

A client can register for its user to receive notifications by email:

{
     "channel":{
     "type": {
        "coding":[
           {
              "system":"http://terminology.hl7.org/CodeSystem/subscription-channel-type",
              "code":"email"
           }
        ]
     },
     "endpoint":"mailto:mt-auburn-results@direct.biliwatch.com",
     "header":"A new bilirubin result has arrived!"
  }
  }

The server would send a new message for each matching resource. The body of the email may be empty, or it may contain a reference to the search or the matching resource. It is at the discretion of the server as to how much information to provide. Subscription.channel.header sets the subject of the email. The email SHOULD be secured appropriately, such as using Direct, as specified by the rules of the applicable jurisdictions.

SMS works very similarly:

  {
     "channel":{
     "type": {
        "coding":[
           {
              "system":"http://terminology.hl7.org/CodeSystem/subscription-channel-type",
              "code":"sms"
           }
        ]
     },
     "endpoint":"tel:+1555-345-5555"
  }
  }

Note: SMS messages are extremely limited in size, so channel.payload will usually be omitted (signifying that no payload is to be sent). The recipient may be human, but this is not always the case. Irrespective of size, most servers will refuse to send payloads in SMS for security reasons, and may refuse to send emails unless encrypted.

A mime/type of text/plain can be useful for email and sms along with some extension describing how to convert resources to a text representation. This specification may provide supporting infrastructure for this in the future.

Trial-Use Note: Warning: The Email/SMS channel types are not yet defined in a highly standardized way, and may not be consistently support by servers. More work is required.

A client can register for its user to receive notifications by messaging:

  {
     "channel":{
     "type": {
        "coding":[
           {
              "system":"http://terminology.hl7.org/CodeSystem/subscription-channel-type",
              "code":"sms"
           }
        ]
     },
     "endpoint":"tel:+1555-345-5555"
  }
  }

For each matching resource, a server will send a message to the nominated end-point. Most servers will require that the end-point is white-listed prior to allowing these kinds of subscriptions.

Trial-Use Note: Warning: The Messaging channel type is not yet defined in a highly standardized way, and may not be consistently support by servers. More work is required.

Executing each of the channels documented in this specification involves the server sending a communication that will reveal information about the client and server relationship, and, if the entire resource is sent, administrative or clinical information that may be quite sensitive and/or protected under law. Servers are responsible for ensuring appropriate security is employed for each channel. The subscription resource does not address these concerns directly - it is assumed that these are administered by other configuration processes. For instance, a server might maintain a whitelist of acceptable servers for the rest-create/rest-update methods.

Emails SHOULD generally be secured using some technique such as Direc .

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 remains 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.

This search will return all the AuditEvent resources that are about Patient 103. At this time there is no deterministic way to tell say which of those AuditEvent resources come from the subscription sub-system that actually handles notifications. This is planned to be resolved in a future version of this specification. In the mean time, servers are encouraged to create AuditEvent records when performing notifications and document how clients can identify the relevant records when searching.

If a subscription nominates a fixed end date, the server automatically deletes it at the specified time.

Applications that wish to track whether notifications have been sent for particular resources (or versions of resources) can look at the AuditEvent resources. For example:

				GET [base]/AuditEvent?entity=Patient/103

			

In addition, servers might also create Communication resources for some of the notifications that are sent in response to a subscription, such as when sending emails.

				GET [base]/Communication?based-on=Subscription/103

			

This returns a list of communications sent by a subscription. TODO: search on payload....

Search parameters for this resource. The common parameters also apply. See Searching for more information about searching in REST, messaging, and services.

NameTypeDescriptionExpressionIn Common
contacttokenContact details for the subscriptionSubscription.contact
payloadtokenThe mime-type of the notification payloadSubscription.channel.payload.contentType
statustokenThe current state of the subscriptionSubscription.status
typetokenThe type of channel for the sent notificationsSubscription.channel.type
urluriThe uri that will receive the notificationsSubscription.channel.endpoint