

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 使用生成临床文档 `$document`
<a name="reference-fhir-operations-document"></a>

AWS HealthLake 现在支持组合资源的`$document`操作，使您能够通过将组合及其所有引用资源捆绑到一个统一的包中来生成完整的临床文档。此操作对于需要满足以下要求的医疗保健应用程序至关重要：
+ 创建标准化临床文档
+ 交换完整的患者记录
+ 存储全面的临床文档
+ 生成包含所有相关背景的报告

## 用法
<a name="document-usage"></a>

可以使用 GET 和 POST 方法在组合资源上调用该`$document`操作：

**支持的操作**  


```
GET/POST [base]/Composition/[id]/$document
```

## 支持的参数
<a name="document-parameters"></a>

HealthLake 支持以下 FHIR `$document` 参数：


| 参数 | Type | 必需 | 默认值 | 说明 | 
| --- | --- | --- | --- | --- | 
| persist | 布尔值 | 否 | false | 表示服务器是否应存储生成的文档包的布尔值 | 

## 示例
<a name="document-examples"></a>

**获取请求**  


```
GET [base]/Composition/180f219f-97a8-486d-99d9-ed631fe4fc57/$document?persist=true
```

**带参数的 POST 请求**  


```
POST [base]/Composition/180f219f-97a8-486d-99d9-ed631fe4fc57/$document
Content-Type: application/fhir+json

{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "persist",
      "valueBoolean": true
    }
  ]
}
```

**示例响应**  
该操作返回一个 “文档” 类型的 Bundle 资源，其中包含构图和所有引用的资源：

```
{
  "resourceType": "Bundle",
  "id": "180f219f-97a8-486d-99d9-ed631fe4fc57",
  "type": "document",
  "identifier": {
    "system": "urn:ietf:rfc:3986",
    "value": "urn:uuid:0c3151bd-1cbf-4d64-b04d-cd9187a4c6e0"
  },
  "timestamp": "2024-06-21T15:30:00Z",
  "entry": [
    {
      "fullUrl": "http://example.org/fhir/Composition/180f219f-97a8-486d-99d9-ed631fe4fc57",
      "resource": {
        "resourceType": "Composition",
        "id": "180f219f-97a8-486d-99d9-ed631fe4fc57",
        "status": "final",
        "type": {
          "coding": [
            {
              "system": "http://loinc.org",
              "code": "34133-9",
              "display": "Summary of Episode Note"
            }
          ]
        },
        "subject": {
          "reference": "Patient/example"
        },
        "section": [
          {
            "title": "Allergies",
            "entry": [
              {
                "reference": "AllergyIntolerance/123"
              }
            ]
          }
        ]
      }
    },
    {
      "fullUrl": "http://example.org/fhir/Patient/example",
      "resource": {
        "resourceType": "Patient",
        "id": "example",
        "name": [
          {
            "family": "Smith",
            "given": ["John"]
          }
        ]
      }
    },
    {
      "fullUrl": "http://example.org/fhir/AllergyIntolerance/123",
      "resource": {
        "resourceType": "AllergyIntolerance",
        "id": "123",
        "patient": {
          "reference": "Patient/example"
        },
        "code": {
          "coding": [
            {
              "system": "http://snomed.info/sct",
              "code": "418689008",
              "display": "Allergy to penicillin"
            }
          ]
        }
      }
    }
  ]
}
```

## 行为
<a name="document-behavior"></a>

该`$document`操作：

1. 将指定的合成资源作为文档的基础

1. 识别并检索组合直接引用的所有资源

1. 将构图和所有引用的资源打包成一个 “文档” 类型的捆绑包

1. 当 persist 参数设置为 true 时，将生成的文档包存储在数据存储中

1. 识别和检索合成间接引用的资源，以生成全面的文档

该`$document`操作目前支持按以下格式检索资源引用：

1. 

   ```
   GET https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/Resource/id
   ```

1. 资源/ID

合成资源中不支持的资源引用将从生成的文档中过滤掉。

## 错误处理
<a name="document-error-handling"></a>

该操作处理以下错误情况：
+ 400 错误请求：`$document`操作无效（请求不一致），或者如果在 persist 设置为 true 时由于筛选出引用而导致生成的文档未通过 FHIR 验证
+ 404 未找到：未找到合成资源

有关`$document`操作规范的更多信息，请参阅 [FHIR R4 组合`$document`文档](https://www.hl7.org/fhir/R4/composition-operation-document.html)。