

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

# 使用 GET 搜索 FHIR 资源
<a name="searching-fhir-resources-get"></a>

您可以使用`GET`请求来搜索 HealthLake 数据存储。使用时`GET`， HealthLake 支持将搜索参数作为网址的一部分提供，但不支持作为请求正文的一部分。有关更多信息，请参阅 [FHIR R4 的搜索参数为 HealthLake](reference-fhir-search-parameters.md)。

**重要提示**  
对于涉及个人身份信息 (PII) 或受保护的健康信息 (PHI) 的搜索，安全最佳实践要求使用`POST`请求，因为 PII 和 PHI 是作为请求正文的一部分添加的，并在传输过程中进行加密。有关更多信息，请参阅 [使用 POST 搜索 FHIR 资源](searching-fhir-resources-post.md)。

以下过程之后是用于`GET`搜索 HealthLake 数据存储的示例。

**使用搜索 HealthLake 数据存储 `GET`**  


1. 收集 HealthLake `region`和`datastoreId`价值。有关更多信息，请参阅 [获取数据存储属性](managing-data-stores-describe.md)。

1. 确定要搜索和收集关联`id`值的 FHIR 资源类型。有关更多信息，请参阅 [资源类型](reference-fhir-resource-types.md)。

1. 使用收集的 HealthLake`region`和值为请求构造一个 URL `datastoreId`。还应包括 FHIR `Resource` 类型和支持的[搜索参数](reference-fhir-search-parameters.md)。要查看以下示例中的整个 URL 路径，请滚动到 “**复制**” 按钮。

   ```
   GET https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/Resource{?[parameters]{&_format=[mime-type]}}
   ```

1. 使用[AWS 签名版本 4](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv.html) 或 FHIR 授权的 SMART 发送`GET`请求。以下`curl`示例返回 HealthLake 数据存储中的`Patient`资源总数。要查看整个示例，请滚动到 “复**制**” 按钮。

------
#### [ SigV4 ]

   Sigv4 授权

   ```
   curl --request GET \
     'https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/Patient?_total=accurate' \   
     --aws-sigv4 'aws:amz:region:healthlake' \
     --user "$AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY" \
     --header "x-amz-security-token:$AWS_SESSION_TOKEN" \                          
     --header 'Accept: application/json'
   ```

------
#### [ SMART on FHIR ]

   SMART on FHIR [https://docs.aws.amazon.com/healthlake/latest/APIReference/API_IdentityProviderConfiguration.html](https://docs.aws.amazon.com/healthlake/latest/APIReference/API_IdentityProviderConfiguration.html)数据类型的授权示例。

   ```
   {
       "AuthorizationStrategy": "SMART_ON_FHIR",
       "FineGrainedAuthorizationEnabled": true,
       "IdpLambdaArn": "arn:aws:lambda:your-region:your-account-id:function:your-lambda-name",
       "Metadata": "{\"issuer\":\"https://ehr.example.com\", \"jwks_uri\":\"https://ehr.example.com/.well-known/jwks.json\",\"authorization_endpoint\":\"https://ehr.example.com/auth/authorize\",\"token_endpoint\":\"https://ehr.token.com/auth/token\",\"token_endpoint_auth_methods_supported\":[\"client_secret_basic\",\"foo\"],\"grant_types_supported\":[\"client_credential\",\"foo\"],\"registration_endpoint\":\"https://ehr.example.com/auth/register\",\"scopes_supported\":[\"openId\",\"profile\",\"launch\"],\"response_types_supported\":[\"code\"],\"management_endpoint\":\"https://ehr.example.com/user/manage\",\"introspection_endpoint\":\"https://ehr.example.com/user/introspect\",\"revocation_endpoint\":\"https://ehr.example.com/user/revoke\",\"code_challenge_methods_supported\":[\"S256\"],\"capabilities\":[\"launch-ehr\",\"sso-openid-connect\",\"client-public\",\"permission-v2\"]}"
   }
   ```

   调用者可以在授权 lambda 中分配权限。有关更多信息，请参阅 [OAuth 2.0 瞄准镜](reference-smart-on-fhir-oauth-scopes.md)。

------
#### [ AWS Console ]

**注意**  
 HealthLake 控制台仅支持 SigV4 授权。通过 AWS CLI 和 AWS SDKs支持 FHIR 上的 SMART 授权。

   1. 登录 HealthLake控制台上的 “[运行查询](https://console.aws.amazon.com/healthlake/home#/crud)” 页面。

   2. 在 **“查询设置”** 部分下，进行以下选择。
   + **数据存储 ID**-选择数据存储 ID 以生成查询字符串。
   + **查询类型**-选择`Search with GET`。
   + **资源类型**-选择要搜索的 FHIR [资源类型](reference-fhir-resource-types.md)。
   + **搜索参数**-选择[搜索参数](reference-fhir-search-parameters.md)或搜索参数组合，将查询重点放在特定的记录上。

   3. 选择**运行查询**。

------

## 示例：使用 GET 进行搜索
<a name="searching-fhir-resources-get-examples"></a>

以下选项卡提供了使用搜索特定 FHIR 资源类型的示例。`GET`这些示例说明了如何在请求中指定搜索参数 URLs。

**注意**  
 HealthLake 控制台仅支持 SigV4 授权。通过 AWS CLI 和 AWS SDKs支持 FHIR 上的 SMART 授权。  
HealthLake 支持 FHIR R4 搜索参数的子集。有关更多信息，请参阅 [搜索参数](reference-fhir-search-parameters.md)。

------
#### [ Patient (age) ]

尽管年龄不是在 FHIR 中定义的资源类型，但它被捕获为[https://hl7.org/fhir/R4/patient.html](https://hl7.org/fhir/R4/patient.html)资源类型中的一个元素。使用以下示例对[https://hl7.org/fhir/R4/patient.html](https://hl7.org/fhir/R4/patient.html)资源类型提出`GET`基于搜索的请求，使用 B [irthD](https://hl7.org/fhir/R4/patient-definitions.html#Patient.birthDate) ate 元素和`eq`[搜索比较器](reference-fhir-search-parameters.md#search-comparators)来搜索 1997 年出生的个人。

```
GET https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/Patient?birthdate=eq1997
```

------
#### [ Condition ]

使用以下示例对[https://hl7.org/fhir/R4/condition.html](https://hl7.org/fhir/R4/condition.html)资源类型发出`GET`请求。搜索会在您的 HealthLake 数据存储中查找包含 SNOMED 医疗代码的条件`72892002`，该代码转换为。`Normal pregnancy`

```
GET https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/Condition?code=72892002
```

------
#### [ DocumentationReference ]

以下示例说明如何根据[https://hl7.org/fhir/R4/documentreference.html](https://hl7.org/fhir/R4/documentreference.html)资源类型为诊断为`Patient`链球菌且同时服用阿莫西林处方的人创建`GET`请求。

```
GET https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/DocumentReference?_lastUpdated=le2021-12-19&infer-icd10cm-entity-text-concept-score;=streptococcal|0.6&infer-rxnorm-entity-text-concept-score=Amoxicillin|0.8
```

------
#### [ Location ]

使用以下示例对[https://hl7.org/fhir/R4/location.html](https://hl7.org/fhir/R4/location.html)资源类型发出`GET`请求。以下搜索将在您的 HealthLake 数据存储中查找地址中包含城市名称波士顿的位置。

```
GET https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/Location?address=boston
```

------
#### [ Observation ]

使用以下示例对[https://hl7.org/fhir/R4/observation.html](https://hl7.org/fhir/R4/observation.html)资源类型发出`GET`基于搜索的请求。此搜索使用`value-concept`[搜索参数](reference-fhir-search-parameters.md)来查找医疗代码`266919005`，该代码转换为。`Never smoker`

```
GET https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/Observation?value-concept=266919005
```

------