

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

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

您可以使用 `GET` 請求來搜尋 HealthLake 資料存放區。使用 時`GET`，HealthLake 支援提供搜尋參數做為 URL 的一部分，但不支援做為請求內文的一部分。如需詳細資訊，請參閱[HealthLake 的 FHIR R4 搜尋參數](reference-fhir-search-parameters.md)。

**Important (重要)**  
對於涉及個人身分識別資訊 (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. 決定要搜尋的 FHIR 資源類型，並收集相關聯的`id`值。如需詳細資訊，請參閱[資源類型](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 Signature 第 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 ]

   [https://docs.aws.amazon.com/healthlake/latest/APIReference/API_IdentityProviderConfiguration.html](https://docs.aws.amazon.com/healthlake/latest/APIReference/API_IdentityProviderConfiguration.html) 資料類型的 FHIR 上的 SMART 授權範例。

   ```
   {
       "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. 選擇 **Run query** (執行查詢)。

------

## 範例：使用 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)資源類型中的 元素。使用下列範例，使用 [birthDate](https://hl7.org/fhir/R4/patient-definitions.html#Patient.birthDate) 元素和`eq`[搜尋比較器](reference-fhir-search-parameters.md#search-comparators)對[https://hl7.org/fhir/R4/patient.html](https://hl7.org/fhir/R4/patient.html)資源類型提出`GET`以 為基礎的搜尋請求，以搜尋 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 ]

下列範例示範如何針對具有鏈球菌診斷的 `Patient`() 和也獲開立 amoxicillin 的人員，在[https://hl7.org/fhir/R4/documentreference.html](https://hl7.org/fhir/R4/documentreference.html)資源類型上建立`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
```

------