

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

# 在支持 Smart 的数据存储上发出 FHIR REST HealthLake API 请求
<a name="reference-smart-on-fhir-request-example"></a>

你可以在支持 FHIR 的数据存储上的 SMART 上发出 FH HealthLake IR REST API 请求。以下示例显示了来自客户端应用程序的请求，授权标头中包含 JWT，以及 Lambda 应如何解码响应。在客户端应用程序请求获得授权和身份验证后，它必须收到来自授权服务器的持有者令牌。在支持 FHIR 的 SMART 数据存储上发送 FH HealthLake IR REST API 请求时，请在授权标头中使用不记名令牌。

```
GET https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/Patient/[ID]
Authorization: Bearer auth-server-provided-bearer-token
```

由于在授权标头中找到了不记名令牌且未检测到 AWS IAM 身份，因此会 HealthLake 调用在创建启用 SMART on FHIR 的数据存储时指定的 Lambda 函数。 HealthLake 当您的 Lambda 函数成功解码令牌后，将向发送以下示例响应。 HealthLake

```
{
  "authPayload": {
    "iss": "https://authorization-server-endpoint/oauth2/token", # The issuer identifier of the authorization server
    "aud": "https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/", # Required, data store endpoint
    "iat": 1677115637,  # Identifies the time at which the token was issued
    "nbf": 1677115637,  # Required, the earliest time the JWT would be valid
    "exp": 1997877061,  # Required, the time at which the JWT is no longer valid
    "isAuthorized": "true",  # Required, boolean indicating the request has been authorized
    "uid": "100101",  # Unique identifier returned by the auth server
    "scope": "system/*.*" # Required, the scope of the request
  },
  "iamRoleARN": "iam-role-arn" #Required, IAM role to complete the request
}
```