HL7中国发布订阅框架实施指南
2025.03.10 - release

HL7中国发布订阅框架实施指南 - Local Development build (v2025.03.10) built by the FHIR (HL7® FHIR® Standard) Build Tools. See the Directory of published versions

OperationDefinition: 取消订阅

官方URL: http://hl7.org.cn/fhir/pubsub/OperationDefinition/Subscription-Cancel 版本: 2025.03.10
Draft as of 2025-03-01 机读名称: PubsubSubscriptionCancel

Cancel操作可以取消订阅。

介绍

该操作是为了取消已经启用的订阅而设计的。

从业务设计上来说,一个已经启用的订阅不能被删除,也不能被修改。只能通过取消操作来从逻辑上禁用该订阅。

本操作就是将订阅中的状态标记为“off”来达到禁用该订阅的。

Generated Narrative: OperationDefinition Subscription-Cancel

URL: [base]/Subscription/[id]/$cancel

Parameters

UseNameScopeCardinalityTypeBindingDocumentation
OUTreturn1..1Resource

取消之后的订阅。

Notes:

示例

请求

通过使用PUT方法来发起取消订阅的操作:

PUT http://[ip]:[port]/[form]/Subscription/[id]/$cancel
[other headers]

无消息体。

响应

如果取消订阅成功,直接返回禁用状态的Subscription资源即可。

HTTP/1.1 200 OK
[other headers]

<?xml version="1.0" encoding="UTF-8"?>
<Subscription xmlns="http://hl7.org/fhir">
  <id value="BaseSubscriptionExample01"/>
  <meta>
    <profile value="http://hl7.org.cn/fhir-ig/pubsub/StructureDefinition/profile-base-subscription"/>
  </meta>
  <name value="表单填报完成就绪订阅"/>
  <status value="off"/>
  <topic value="http://hl7.org.cn/fhir/SubscriptionTopic/FormFilledReadyTopic"/>
  <channelType>
    <system value="http://terminology.hl7.org/CodeSystem/subscription-channel-type"/>
    <code value="rest-hook"/>
  </channelType>
  <endpoint value="http://localhost:8080/fhir/monitor/notify"/>
  <heartbeatPeriod value="30"/>
  <timeout value="10"/>
  <content value="full-resource"/>
  <maxCount value="3"/>
</Subscription>

如果在提取过程中发生错误,则应抛出异常:

HTTP/1.1 500 Internal Server Error
[other headers]

<?xml version="1.0" encoding="UTF-8"?>
<OperationOutcome xmlns="http://hl7.org/fhir">
  <id value="allok"/>
  <issue>
    <severity value="error"/>
    <code value="processing"/>
    <details>
      <coding>
        <system value="http://hl7.org.cn/fhir/CodeSystem/operationoutcome-codes-subscribe"/>
        <code value="SubscribeCancelFailedFault"/>
        <display value="订阅取消失败"/>
      </coding>
    </details>
    <diagnostics value="在取消过程中出现XX问题"/>
  </issue>
</OperationOutcome>