接口描述
用于在事务
Bundle 中执行删除操作。客户端可在同一个事务请求中提交多个删除条目,由服务端统一处理。在事务模式下,删除操作以整体方式执行,即如果其中任意一个删除条目失败,则整个事务回滚,其他删除也不会生效。输入参数
参数名称 | 类型 | 是否必填 | 说明 |
HTTP Method | String | 是 | 固定为 POST。 |
URL | String | 是 | Bundle 提交地址,通常为 [baseUrl]。 |
Authorization | String | 是 | 身份认证令牌,格式为 Bearer <AccessToken>,AccessToken 通过 调用方式 中的 GetAccessToken 接口获取(实例控制台场景可通过 GetWebAccessToken 接口获取)。 |
Content-Type | String | 否 | 请求体 MIME 类型,写入类请求通常为 application/fhir+json;未指定时服务端将根据请求内容自动推断。 |
Request Body | JSON Object | 是 | 包含删除条目的事务 Bundle。 |
请求体主要字段说明:
字段 | 类型 | 是否必填 | 说明 |
resourceType | String | 是 | 固定为 Bundle。 |
type | String | 否 | 处理模式。取值为 transaction(事务模式,所有条目作为一个原子事务执行,任一条目失败则整体回滚)或 batch(批处理模式,各条目独立执行,互不影响)。未指定时默认按 transaction 处理。 |
entry | Array | 是 | 删除条目列表。 |
entry[].request.method | String | 是 | 固定为 DELETE。 |
entry[].request.url | String | 是 | 待删除资源路径,格式为 [resourceType]/[id],例如 Patient/A0。 |
输出参数
接口调用成功后,返回 HTTP 状态码
200 OK,并在响应头中包含内容类型及请求追踪信息,响应体为 transaction-response 类型的结果 Bundle,包含各删除条目的执行状态。需要注意的是,每个删除条目的响应状态码为 204 No Content,而非整体响应的 200 OK。响应头示例说明:
参数名称 | 类型 | 说明 |
Status Code | Integer | 成功时返回 200 OK。 |
Location | String | Bundle 响应资源地址,格式为 [baseUrl]/Bundle/[bundleId]。 |
Content-Location | String | Bundle 响应资源当前版本地址。 |
Content-Type | String | 响应体 MIME 类型,通常为 application/fhir+json。 |
x-request-id | String | 请求追踪 ID。 |
响应体主要字段说明:
字段 | 类型 | 说明 |
resourceType | String | 返回资源类型,通常为 Bundle。 |
id | String | Bundle 资源的唯一标识。 |
type | String | 响应 Bundle 类型,事务模式返回 transaction-response,批处理模式返回 batch-response。 |
link | Array | 链接信息列表,包含与当前 Bundle 相关的导航链接。 |
link[].relation | String | 链接关系类型,如 self(指向当前请求地址)。 |
link[].url | String | 链接地址。 |
entry | Array | 各删除条目的执行结果。 |
entry[].response.status | String | 删除执行状态,成功时为 204 No Content。 |
entry[].response.location | String | 删除后资源版本位置。 |
entry[].response.etag | String | 资源版本标识。 |
entry[].response.outcome | Object | 操作结果详情,包含 OperationOutcome 资源,描述条目执行的具体结果信息。 |
示例
请求示例
POST /INSTANCE_ID/fhir HTTP/1.1Host: HOSTNAMEAuthorization: Bearer YOUR_ACCESS_TOKENContent-Type: application/fhir+json
{"resourceType": "Bundle","type": "transaction","entry": [{"request": {"method": "DELETE","url": "Patient/A0"}},{"request": {"method": "DELETE","url": "Patient/A1"}}]}
响应示例
HTTP/1.1 200 OKLocation: https://HOSTNAME/INSTANCE_ID/fhir/Bundle/<BUNDLE_ID>Content-Location: https://HOSTNAME/INSTANCE_ID/fhir/Bundle/<BUNDLE_ID>Content-Type: application/fhir+jsonx-request-id: <REQUEST_ID>
{"resourceType": "Bundle","id": "<BUNDLE_ID>","type": "transaction-response","link": [{"relation": "self","url": "https://HOSTNAME/INSTANCE_ID/fhir"}],"entry": [{"response": {"status": "204 No Content","location": "Patient/A0/_history/2","etag": "2","outcome": {"resourceType": "OperationOutcome","issue": [{"severity": "information","code": "informational","details": {"coding": [{"system": "https://hapifhir.io/fhir/CodeSystem/hapi-fhir-storage-response-code","code": "SUCCESSFUL_DELETE","display": "Delete succeeded."}]},"diagnostics": "Successfully deleted 1 resource(s). Took 87ms."}]}}},{"response": {"status": "204 No Content","location": "Patient/A1/_history/2","etag": "2","outcome": {"resourceType": "OperationOutcome","issue": [{"severity": "information","code": "informational","details": {"coding": [{"system": "https://hapifhir.io/fhir/CodeSystem/hapi-fhir-storage-response-code","code": "SUCCESSFUL_DELETE","display": "Delete succeeded."}]},"diagnostics": "Successfully deleted 1 resource(s). Took 87ms."}]}}}]}
错误码
错误码 | 说明 |
400 Bad Request | 删除条目格式错误,或资源路径非法 |
401 Unauthorized | 未认证,缺少有效身份凭证 |
403 Forbidden | 已认证但无执行删除操作的权限 |
404 Not Found | 条目中的目标资源不存在 |
409 Conflict | 某一删除条目失败导致事务回滚 |
500 Internal Server Error | 服务端内部处理异常 |