2.46 Resource Subscription 订阅型resource - Content 详情

工作组:FHIR Infrastructure 成熟度: 3 试用安全级别: Business 隔间: Not linked to any defined compartments

The subscription resource is used to define a push-based subscription from a server to another system. Once a subscription is registered with the server, the server checks every resource that is created or updated, and if the resource matches the given criteria, it sends a message on the defined "channel" so that another system can take an appropriate action. 订阅型resource用于描述从一个服务端到另一个服务端的消息推送。当订阅型resource在fhir服务端进行了注册了后,fhir服务端将会检查在订阅型resource中描述的资源在进行新增或修改且这些资源满足预设的条件时,fhir服务端将会发送消息到对应的“频道”上,订阅这些消息的服务端根据这些消息作自身的业务操作。

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. 当订阅型resource生成后,任何资源(订阅型resource中描述的)的生成或修改满足条件(根据订阅资源中描述)时将会触发发送消息到预设的频道上。这些条件可以是跟在rest api的基础url后的搜索字符串。 注意这些搜索字符串是对应于该资源的新值。这样的设计带来的直接后果就是当资源被删除或者资源被修改后,这些资源将不满足设定(发消息)的条件。

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 rest api回调方式: 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 通过post请求注册订阅型resource。当post的消息体中有整个资源时,那么url将被服务端认为是服务的基地址。
  • websocket websocket方式: A PING message is sent to the designated URI ping消息被发送到指定的url
  • email/sms emai及短信方式: A notification is sent to the nominated email address or SMS number 发送消息到指定的email地址或短信号码
  • message 一般信息: The resource is sent to the application identified in the URI as a message 直接通过一个urimessage将消息体发送到其他服务端。

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. 订阅型resource必须是处理激活状态的。服务端只会在收到resource时才会向一个特定的channel发送消息。 当订阅型resource被删除时,将不会发送消息到channel上。

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. 对于使用订阅方式,用restful api对bundleshistory operation进行轮询一样可以达到目的。 这种方式要求客户端和被轮询的服务端较高即服务端不会有更新或删除的问题(最好只有查询);

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 ). 当使用订阅型resource时,相对于其他场景发布和分发是分开的,此时的fhir服务端同时具有信息发布和分发的作用。 具体实施起来,订阅和被订阅者一般是分开的,可以选择任何一种发布/订阅结构。 (参考 FHIRCast , 或者更一般地,参考 W3C Pub/Sub ).

Structure

NameFlagsCard.TypeDescription & Constraintsdoco
.. Subscription ΣTUDomainResourceServer push subscription criteria
Elements defined in Ancestors: id, meta, implicitRules, language, text, contained, extension, modifierExtension
... status ?!Σ1..1coderequested | active | error | off
SubscriptionStatus (Required)
... 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
... criteria Σ1..1stringRule for server push
... error Σ0..1stringLatest error note
... channel Σ1..1BackboneElementThe channel on which to report matches to the criteria
.... type Σ1..1coderest-hook | websocket | email | sms | message
SubscriptionChannelType (Required)
.... endpoint Σ0..1urlWhere the channel points to
.... payload Σ0..1codeMIME type to send, or omit for no payload
MimeType (Required)
.... header Σ0..*stringUsage depends on the channel type

doco Documentation for this format

UML Diagram (Legend)

Subscription (DomainResource)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! »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]The rules that the server should use to determine when to generate notifications for this subscriptioncriteria : string [1..1]A record of the last error that occurred when the server processed a notificationerror : string [0..1]ChannelThe type of channel to send notifications ontype : code [1..1] « The type of method used to execute a subscription. (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! »Additional headers / information to send as part of the notificationheader : string [0..*]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 -->
 <status value="[code]"/><!-- 1..1 requested | active | error | off -->
 <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 -->
 <criteria value="[string]"/><!-- 1..1 Rule for server push -->
 <error value="[string]"/><!-- 0..1 Latest error note -->
 <channel>  <!-- 1..1 The channel on which to report matches to the criteria -->
  <type value="[code]"/><!-- 1..1 rest-hook | websocket | email | sms | message -->
  <endpoint value="[url]"/><!-- 0..1 Where the channel points to -->
  <payload value="[code]"/><!-- 0..1 MIME type to send, or omit for no payload -->
  <header value="[string]"/><!-- 0..* Usage depends on the channel type -->
 </channel>
</Subscription>

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.status [ code ]; # 1..1 requested | active | error | off
  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.criteria [ string ]; # 1..1 Rule for server push
  fhir:Subscription.error [ string ]; # 0..1 Latest error note
  fhir:Subscription.channel [ # 1..1 The channel on which to report matches to the criteria
    fhir:Subscription.channel.type [ code ]; # 1..1 rest-hook | websocket | email | sms | message
    fhir:Subscription.channel.endpoint [ url ]; # 0..1 Where the channel points to
    fhir:Subscription.channel.payload [ code ]; # 0..1 MIME type to send, or omit for no payload
    fhir:Subscription.channel.header [ string ], ... ; # 0..* Usage depends on the channel type
  ];
]

Changes since R3

Subscription
Subscription.status
  • Change value set from http://hl7.org/fhir/ValueSet/subscription-status to http://hl7.org/fhir/ValueSet/subscription-status|4.0.0
Subscription.channel.type
  • Change value set from http://hl7.org/fhir/ValueSet/subscription-channel-type to http://hl7.org/fhir/ValueSet/subscription-channel-type|4.0.0
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|4.0.0 (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.)

Structure

NameFlagsCard.TypeDescription & Constraintsdoco
.. Subscription ΣTUDomainResourceServer push subscription criteria服务端进行推送时的条件
Elements defined in Ancestors上级定义的元素: id, meta, implicitRules, language, text, contained, extension, modifierExtension
... status ?!Σ1..1coderequested | active | error | off
SubscriptionStatus (Required)
... contact Σ0..*ContactPointContact details for source (e.g. troubleshooting)联系方式相关
... end Σ0..1instantWhen to automatically delete the subscription 什么时候自动删除订阅型resource
... reason Σ1..1stringDescription of why this subscription was created 描述订阅型resource生成的原因
... criteria Σ1..1stringRule for server push推送消息的条件
... error Σ0..1stringLatest error note 最近错误的原因
... channel Σ1..1BackboneElementThe channel on which to report matches to the criteria满足条件的的channel
.... type Σ1..1coderest-hook | websocket | email | sms | message
SubscriptionChannelType (Required)
.... endpoint Σ0..1urlWhere the channel points to channel的接入点
.... payload Σ0..1codeMIME type to send, or omit for no payload 消息体的格式类型,当没有消息体时可以忽略
MimeType (Required)
.... header Σ0..*stringUsage depends on the channel type 根据不同的channel类型,用法不同

doco Documentation for this format

UML Diagram (Legend)

Subscription (DomainResource)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! »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]The rules that the server should use to determine when to generate notifications for this subscriptioncriteria : string [1..1]A record of the last error that occurred when the server processed a notificationerror : string [0..1]ChannelThe type of channel to send notifications ontype : code [1..1] « The type of method used to execute a subscription. (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! »Additional headers / information to send as part of the notificationheader : string [0..*]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 -->
 <status value="[code]"/><!-- 1..1 requested | active | error | off -->
 <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 -->
 <criteria value="[string]"/><!-- 1..1 Rule for server push -->
 <error value="[string]"/><!-- 0..1 Latest error note -->
 <channel>  <!-- 1..1 The channel on which to report matches to the criteria -->
  <type value="[code]"/><!-- 1..1 rest-hook | websocket | email | sms | message -->
  <endpoint value="[url]"/><!-- 0..1 Where the channel points to -->
  <payload value="[code]"/><!-- 0..1 MIME type to send, or omit for no payload -->
  <header value="[string]"/><!-- 0..* Usage depends on the channel type -->
 </channel>
</Subscription>

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.status [ code ]; # 1..1 requested | active | error | off
  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.criteria [ string ]; # 1..1 Rule for server push
  fhir:Subscription.error [ string ]; # 0..1 Latest error note
  fhir:Subscription.channel [ # 1..1 The channel on which to report matches to the criteria
    fhir:Subscription.channel.type [ code ]; # 1..1 rest-hook | websocket | email | sms | message
    fhir:Subscription.channel.endpoint [ url ]; # 0..1 Where the channel points to
    fhir:Subscription.channel.payload [ code ]; # 0..1 MIME type to send, or omit for no payload
    fhir:Subscription.channel.header [ string ], ... ; # 0..* Usage depends on the channel type
  ];
]

Changes since Release 3

Subscription
Subscription.status
  • Change value set from http://hl7.org/fhir/ValueSet/subscription-status to http://hl7.org/fhir/ValueSet/subscription-status|4.0.0
Subscription.channel.type
  • Change value set from http://hl7.org/fhir/ValueSet/subscription-channel-type to http://hl7.org/fhir/ValueSet/subscription-channel-type|4.0.0
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|4.0.0 (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 alternate definitions: 参看 资料和扩展 和其他定义方式: Master Definition XML + JSON, XML Schema/Schematron + JSON Schema, ShEx (for Turtle) + see the extensions & the dependency analysis

PathDefinitionTypeReference
Subscription.status The status of a subscription.订阅的状态RequiredSubscriptionStatus
Subscription.channel.type The type of method used to execute a subscription.在推送时会用到的方法的类型RequiredSubscriptionChannelType
Subscription.channel.payload The mime type of an attachment. Any valid mime type is allowed.附件类型。任何有效的多媒体类型。RequiredMime Types

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. 在下述的提到的channel,在推送数据过程中都会暴露关于被推送端和推送端的关系相关的信息,当一个完整的resource时,涉及到的信息可能会比较敏感或本身就是受法律保护。推送端必须保证每个channel都 对安全因素方面进行了处理。订阅型resource(具体的定义)是没有处理安全相关的因素,因为假设推送端已经通过配置进行处理了。比如说,推送端会维持一个可以接受rest方式生成/修改resource进行推送的白名单

Emails should generally be secured using some technique such as emails的数据安全可以通过此种技术处理 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. 订阅的实质就是在推送服务端生成订阅型resource.当订阅型resource根据客户端的请求生成时,订阅型resource的status应该被设置为"requested"。 当客户端通过post方式生成订阅型resource时,客户端将会转换地址头并保存订阅型resource的逻辑id以备下次使用。

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. 当推送端收到订阅型resource请求时应该检查它是否准备好接受或处理订阅型resource。如果其准备好了,将会将订阅型resource的状态设置为active,接下来会和其他的resource一样 执行create方法。若未就续会返回一个错误结果 OperationOutcome而不会执行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). 当推送服务端激活订阅时,它将设置状态 到“active”(注意:推送服务端在其需要接受resource时,可以这样) )

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. 通过授权的客户端可以使用搜索和/或查看历史操作 查看服务端上当前处于"active"状态的订阅。 当不再需要在被推送消息时,客户端可以删除 推送服务端的订阅resource。

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. 推送服务端可以通过固定次数的重试发送通知或 将推送过程中的错误记录到自己的警报日志。如果推送失败,则 应将订阅型resource的状态设置为“error”。如果推送通知成功,应更新 状态为“active“。如果推送通知始终失败 推送服务端可以选择将订阅型resource的状态设置为“off”,然后 停止尝试推送通知。

If a subscription nominates a fixed end date, the server automatically deletes it at the specified time. 订阅型resource定义了某个固定日期时,推送端将会在设置的日期自动删除此订阅型resource.

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: 当推送端需要追踪是否已为特定资源(或资源版本)发送通知可以查看审计resource AuditEvent。例如:

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. 上述查询会返回Patient的code为103的审计resource AuditEvent。 目前为止没有一种方式可以分清比如说是这些审计resource AuditEvent来自于哪个发送了通知的推送子系统(当是集群时)。 以后的版本会处理此种问题,与此同时,推送服务端可以实现当完成通知时生成审计resource AuditEvent,可以在返回给客户端的信息中加入与推送子系统相应的身份信息。

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. 另外,fhir服务端推送通知并得到响应时比如发送email时,可能会生成 Communication资源(实现与否看实际情况)。

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

This returns a list of communications sent by a subscription. TODO: search on payload.... 上述查询会返回已经发送通知后的communication resource资源的列表。待完成:通过消息体查询。

This uses an empty POST message to alert the subscriber that new results are available - POST to [base]/Subscription: rest-hook在未指定payload时,通过post消息提醒被推送端新的结果生成了。- 通过post生成订阅型resource:[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. 当一个资源生成或修改满足条件时,那么服务端会发起一个空消息体的post请求到指定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. 当被推送端收到一个post请求,它将其作为一个查询请求,并在查询的参数后加上&_since=:last(last是代表被推送端收到请求的时间)通过此种方式,被推送端可以得到所有相关的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. 由于缺少消息内容,资源中的数据只有通过REST API才可用,此种方式使得授权和验证更加健壮。推送端提交给被推送端的额外信息必须放在header中。

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. 另外,推送端也可以将整个resource发送到指定的url。在一个医疗相关的生态系统中通过定义路由时,这种方式是可行的。

{
  "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. 这要求推送端提交一个匹配到的resource的json格式的副本通过使用service base为基地址的Update operation(这里是put请求)的请求到指定的被推送端。为了执行此操作,推送端必须了解对于被推送端的的验证方式。验证的方式可以在提交订阅型resource时指定,当然,通过设置白名单的方式也可以。

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. 生成订阅资源一样可以通过FHIR REST API完成。当然通知方式不是使用REST方式。的确,有些被通送端不太方便对外暴露一个HTTP接入点来接收通知。举例来说,一个纯粹的webapp客户端或者移动app希望 不是通过轮询的方式或history查询的方式来获取数据。这时可以通过websocket方式来推送数据。

A client can declare its intention to listen via Web Sockets: 被推送端可以通过以下方式指定通过websocket方式。

{
  "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: 订阅者会初始一个websocket连接到推送端,url通过fhir推送端的Capability描述得到(以后可以通过subscriptions/webSocketUrl获取(待完成)) 可以通过简单的格式来推送通知:

  • Client connects a secure Web Socket to the server's webSocketUrl (see websocket extension in the server's CapabilityStatement). 客户端连接到推送端暴露的websocket url(参见 websocket extension in the server's CapabilityStatement)
  • Client authenticates to server using a server-specified Web socket protocol (e.g. OAuth bearer token presentation). 根据推送端的实际情况,客户端的验证用相应的协议(如oauth验证等)
  • Client sends a bind :id message over the socket (using the logical id of the subscription). For example, the client might issue: bind 123). 客户端发送一个bind:通过socket发送id信息(id为订阅型resource的id)比如说客户端会发送:bind 123
  • Server responds with a "bound :id" message to acknowledge. 推送端会以"bound :id"的消息格式回复以表示收到了。
  • Server sends a "ping :id" message to notify the client each time a new result is available 推送端每次发送一个“ping:id”的消息去通知客户端有新消息。

A client can register for its user to receive notifications by email: 客户端订阅型resource为其用户注册通过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. 推送端当有匹配的resource时将会发送消息。email的消息体可能为空或者是指向这个匹配到的资源的查询链接。 推送端要发送的email的内容要谨慎对待。Subscription.channel.header决定了email的内容。 这个email的发送要考虑到一些安全因素,当直接发送给用户email时,要考虑到相关地区的规则。

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. 注意:短信在容量上有限制,故channel.payload将被忽略(特别是当没有内容被发送时).接收者可能是一个人,但不绝对。对应于容量,大多数推送端基于安全考虑,都不会通过短信的方式来发送通知,也不会 发送未加密的email.

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. 多媒体类型为text/plai且带上展示内容的方法对email和短信是有用的。这种规定在以后可能会提供一些其础层面的支持。

A client can register for its user to receive notifications by messaging: 客户可以通过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. 对于每个匹配到的resource,推送端将会将消息发送到指定的接入点。大多数推送端都会要求在允许这种订阅型resource之前,自己在白名单中。

STU Note: stu版本注意: The details of the message - mainly the event code - are still to be resolved during the trial use period. 消息的详情--主要是event code -在使用时必须先解析。

Feedback is welcome here 欢迎到此反馈 这里 .

Search parameters for this resource. The common parameters also apply. See Searching for more information about searching in REST, messaging, and services. 这个资源的查询参数。通用参数也可以使用。参见查询更多关于REST,messaging,services的查询。

Name 名称Type 类型Description 描述Expression表达式In Common相同点
contacttokenContact details for the subscription 订阅的联系详情Subscription.contact
criteriastringThe search rules used to determine when to send a notification确定发送通知的时间的搜索规则Subscription.criteria
payloadtokenThe mime-type of the notification payload 内容的类型Subscription.channel.payload
statustokenThe current state of the subscription 订阅型resource目前的状态Subscription.status
typetokenThe type of channel for the sent notifications 已发送通知的方式类型Subscription.channel.type
urluriThe uri that will receive the notifications 接收通知的uriSubscription.channel.endpoint