Current Build

Переводит команда Health Samurai . Приглашаем поучаствовать в русификации стандарта FHIR: GitHub , Email.

2.47 Ресурс Subscription - Назначение

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

Ресурс Subscription (Подписка) используется для определения подписки на основе метода push с сервера в другую систему. После регистрации подписки на сервере, сервер проверяет каждый ресурс, который создается или обновляется, и если ресурс соответствует заданным критериям, то он посылает сообщение в определенный "канал", чтобы другая система могла выполнить надлежащее действие.

Once a subscription is created, any newly created or updated resources that meet the criteria in the resource cause a notification to be sent using the provided channel. The criteria are Search strings that have the same interpretation as if they were appended to the base URL and submitted using the REST API. Note that the search criteria are applied to the new value of the resource. The consequence of this is that there is no notification when a resource is deleted, or when a resource is updated so that it no longer meets the criteria.

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 post is made to the URL identified in the Subscription resource. If the subscription requests that the whole resource is included, the URL is interpreted as the service base
  • 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 ).

Структура

ИмяФлагиКард.ТипОписание и ограниченияdoco
.. Subscription ΣTUDomainResourceServer push subscription criteria
Элементы, определённые в прародителе: id, meta, implicitRules, language, text, contained, extension, modifierExtension
... status ?!Σ1..1coderequested | active | error | off
SubscriptionStatus (Required)
... contact Σ0..*ContactPointКонтактные данные источника (например для устранения неполадок)
... end Σ0..1instantКогда следует автоматически удалить подписку
... reason Σ1..1stringОписание, для чего была создана данная подписка
... criteria Σ1..1stringRule for server push
... error Σ0..1stringПоследнее сообщение об ошибке
... channel Σ1..1BackboneElementКанал, по которому сообщается о соответствии критериям
.... type Σ1..1coderest-hook | websocket | email | sms | message
SubscriptionChannelType (Required)
.... endpoint Σ0..1urlКуда указывает этот канал
.... payload Σ0..1codeMIME type to send, or omit for no payload
MimeType (Required)
.... header Σ0..*stringПрименение зависит от типа канала

doco Документация по этому формату

UML-диаграмма (Legend)

Subscription (DomainResource)Статус подписки, который помечает состояние сервера для управления подпиской (this element modifies the meaning of other elements)status : code [1..1] « Статус подписки. (Strength=Required)SubscriptionStatus! »Контактные данные человека, с которым можно контактировать по поводу подписки. В основном применяется для устранения неполадок системным администраторомcontact : ContactPoint [0..*]Время, когда сервер должен отключить подпискуend : instant [0..1]Описание, для чего задана эта подпискаreason : string [1..1]Правила, которые использует сервер для определения, когда ему следует создавать оповещения для данной подпискиcriteria : string [1..1]Запись о самой последней ошибке, которая произошла, когда сервер обрабатывал оповещениеerror : string [0..1]ChannelТип канала для отправки оповещенийtype : code [1..1] « Тип метода, используемого для осуществления подписки. (Strength=Required)SubscriptionChannelType! »The url that describes the actual end-point to send messages toendpoint : url [0..1]The mime type to send the payload in - either application/fhir+xml, or application/fhir+json. If the payload is not present, then there is no payload in the notification, just a notification. The mime type "text/plain" may also be used for Email and SMS subscriptionspayload : code [0..1] « The mime type of an attachment. Any valid mime type is allowed. (Strength=Required)Mime Types! »Дополнительные заголовки / информация для отправки в рамках оповещенияheader : string [0..*]Сведения о том, куда отправлять оповещения при получении ресурсов, соответствующих заданным критериямchannel[1..1]

Turtle-шаблон

@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.status [ code ]; # 1..1 requested | active | error | off
  fhir:Subscription.contact [ ContactPoint ], ... ; # 0..* Контактные данные источника (например для устранения неполадок)
  fhir:Subscription.end [ instant ]; # 0..1 Когда следует автоматически удалить подписку
  fhir:Subscription.reason [ string ]; # 1..1 Описание, для чего была создана данная подписка
  fhir:Subscription.criteria [ string ]; # 1..1 Rule for server push
  fhir:Subscription.error [ string ]; # 0..1 Последнее сообщение об ошибке
  fhir:Subscription.channel [ # 1..1 Канал, по которому сообщается о соответствии критериям
    fhir:Subscription.channel.type [ code ]; # 1..1 rest-hook | websocket | email | sms | message
    fhir:Subscription.channel.endpoint [ url ]; # 0..1 Куда указывает этот канал
    fhir:Subscription.channel.payload [ code ]; # 0..1 MIME type to send, or omit for no payload
    fhir:Subscription.channel.header [ string ], ... ; # 0..* Применение зависит от типа канала
  ];
]

Changes since R3

Subscription
Subscription.channel.endpoint
  • Type changed from uri to url
Subscription.channel.payload
  • Type changed from string to code
  • Add Binding http://hl7.org/fhir/ValueSet/mimetypes (required)
Subscription.tag
  • 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.)

Структура

ИмяФлагиКард.ТипОписание и ограниченияdoco
.. Subscription ΣTUDomainResourceServer push subscription criteria
Элементы, определённые в прародителе: id, meta, implicitRules, language, text, contained, extension, modifierExtension
... status ?!Σ1..1coderequested | active | error | off
SubscriptionStatus (Required)
... contact Σ0..*ContactPointКонтактные данные источника (например для устранения неполадок)
... end Σ0..1instantКогда следует автоматически удалить подписку
... reason Σ1..1stringОписание, для чего была создана данная подписка
... criteria Σ1..1stringRule for server push
... error Σ0..1stringПоследнее сообщение об ошибке
... channel Σ1..1BackboneElementКанал, по которому сообщается о соответствии критериям
.... type Σ1..1coderest-hook | websocket | email | sms | message
SubscriptionChannelType (Required)
.... endpoint Σ0..1urlКуда указывает этот канал
.... payload Σ0..1codeMIME type to send, or omit for no payload
MimeType (Required)
.... header Σ0..*stringПрименение зависит от типа канала

doco Документация по этому формату

UML-диаграмма (Legend)

Subscription (DomainResource)Статус подписки, который помечает состояние сервера для управления подпиской (this element modifies the meaning of other elements)status : code [1..1] « Статус подписки. (Strength=Required)SubscriptionStatus! »Контактные данные человека, с которым можно контактировать по поводу подписки. В основном применяется для устранения неполадок системным администраторомcontact : ContactPoint [0..*]Время, когда сервер должен отключить подпискуend : instant [0..1]Описание, для чего задана эта подпискаreason : string [1..1]Правила, которые использует сервер для определения, когда ему следует создавать оповещения для данной подпискиcriteria : string [1..1]Запись о самой последней ошибке, которая произошла, когда сервер обрабатывал оповещениеerror : string [0..1]ChannelТип канала для отправки оповещенийtype : code [1..1] « Тип метода, используемого для осуществления подписки. (Strength=Required)SubscriptionChannelType! »The url that describes the actual end-point to send messages toendpoint : url [0..1]The mime type to send the payload in - either application/fhir+xml, or application/fhir+json. If the payload is not present, then there is no payload in the notification, just a notification. The mime type "text/plain" may also be used for Email and SMS subscriptionspayload : code [0..1] « The mime type of an attachment. Any valid mime type is allowed. (Strength=Required)Mime Types! »Дополнительные заголовки / информация для отправки в рамках оповещенияheader : string [0..*]Сведения о том, куда отправлять оповещения при получении ресурсов, соответствующих заданным критериямchannel[1..1]

Turtle-шаблон

@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.status [ code ]; # 1..1 requested | active | error | off
  fhir:Subscription.contact [ ContactPoint ], ... ; # 0..* Контактные данные источника (например для устранения неполадок)
  fhir:Subscription.end [ instant ]; # 0..1 Когда следует автоматически удалить подписку
  fhir:Subscription.reason [ string ]; # 1..1 Описание, для чего была создана данная подписка
  fhir:Subscription.criteria [ string ]; # 1..1 Rule for server push
  fhir:Subscription.error [ string ]; # 0..1 Последнее сообщение об ошибке
  fhir:Subscription.channel [ # 1..1 Канал, по которому сообщается о соответствии критериям
    fhir:Subscription.channel.type [ code ]; # 1..1 rest-hook | websocket | email | sms | message
    fhir:Subscription.channel.endpoint [ url ]; # 0..1 Куда указывает этот канал
    fhir:Subscription.channel.payload [ code ]; # 0..1 MIME type to send, or omit for no payload
    fhir:Subscription.channel.header [ string ], ... ; # 0..* Применение зависит от типа канала
  ];
]

Changes since Release 3

Subscription
Subscription.channel.endpoint
  • Type changed from uri to url
Subscription.channel.payload
  • Type changed from string to code
  • Add Binding http://hl7.org/fhir/ValueSet/mimetypes (required)
Subscription.tag
  • 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 Альтернативные определения: Основное определение XML + JSON, XML Schema/Schematron + JSON Schema, ShEx (for Turtle) + see the extensions & the Анализ зависимостей

PathОписаниеТипСсылка
Subscription.status Статус подписки.RequiredSubscriptionStatus
Subscription.channel.type Тип метода, используемого для осуществления подписки.RequiredSubscriptionChannelType
Subscription.channel.payload The mime type of an attachment. Any valid mime type is allowed.RequiredMime Types

3

Executing each of the channels documented below 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 Direct .

A subscription is defined by creating the Subscription resource on the server. When the subscription is created by the client, it sets the status to "requested". After POSTing the subscription, 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 active, and then 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 can 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 again. If a subscription fails consistently a server may choose set the subscription status to off and stop trying to send notifications.

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

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.

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

This uses an empty POST message to alert the subscriber that new results are available - POST to [base]/Subscription:

{
  "resourceType": "Subscription",
  "criteria": "Observation?name=http://loinc.org|1975-2&_format=json",
  "channel": {
    "type": "rest-hook",
    "endpoint": "https://biliwatch.com/customers/mount-auburn-miu/on-result",
    "header": "Authorization: Bearer secret-token-abc-123"
  }
}

When a resource is created or updated that meets the criteria, the server sends a POST request with no body to the nominated URL.

When the subscriber receives a POST to https://biliwatch.com/customers/mount-auburn-miu/on-result, it re-issues the criteria as a query to the server, appending &_since=:last (where :last is replaced by the time at which the client last checked). In this way it can fetch all new relevant Observations.

Since payload is missing, the data in the resources is only available through the REST API, which helps consolidate authorization and authentication logic. The server must append the headers, if any are given, to the POST request that it makes to the client.

Alternatively, the server can be asked to send the entire resource to a nominated FHIR end-point. This is usually appropriate for defining routing rules within a managed eco-system such as a healthcare institution.

{
  "channel": {
    "type": "rest-hook",
    "endpoint": "https://internal.acme.com/research/saturn",
    "payload": "application/fhir+json"
  }
}

This requests that a server forward a copy of any matching resource in JSON format to the nominated server as an Update operation using the nominated URL as the service base. In order to execute this channel, the server must 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": "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

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

{
  "channel": {
    "type": "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": "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.

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

{
  "channel": {
    "type": "message",
    "endpoint": "http://ehr.example.org/fhir/$process-message"
  }
}

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.

STU Note: The details of the message - mainly the event code - are still to be resolved during the trial use period.

Feedback is welcome here .

Параметры поиска для этого ресурса. Также к нему применяются общие параметры. Более подробную информацию о поиске в REST, обмене сообщениями и сервисах см. в разделе Поиск.

ИмяТипОпределениеВыражениеIn Common
add-tagtokenA tag to be added to the resource matching the criteria
contacttokenContact details for the subscriptionSubscription.contact
criteriastringThe search rules used to determine when to send a notificationSubscription.criteria
payloadtokenThe mime-type of the notification payloadSubscription.channel.payload
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