

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

# 使用 擷取 ValueSet 程式碼 `$expand`
<a name="reference-fhir-operations-expand"></a>

AWS HealthLake 現在支援您以客戶身分擷取的 ValueSets (ValueSet) `$expand`操作，可讓您擷取包含在這些 ValueSet 資源中的代碼完整清單。當您需要：
+ 擷取所有可能的程式碼以進行驗證
+ 在使用者介面中顯示可用的選項
+ 在特定術語內容中執行全面的程式碼查詢

## Usage
<a name="expand-usage"></a>

您可以使用 GET 和 POST 方法在 ValueSet 資源上叫用 `$expand`操作：

**受支援的 操作**  


```
GET/POST [base]/ValueSet/[id]/$expand
GET [base]/ValueSet/$expand?url=http://example.com
POST [base]/ValueSet/$expand
```

## 支援的參數
<a name="expand-parameters"></a>

HealthLake 支援 FHIR R4 `$expand` 參數的子集：


| 參數 | Type | 必要 | Description | 
| --- | --- | --- | --- | 
| url | uri | 否 | 要展開之 ValueSet 的正式 URL | 
| id | id | 否 | 要展開的 ValueSet 資源 ID （適用於 GET 或 POST 操作） | 
| filter | string | 否 | 篩選程式碼擴展結果 | 
| count | integer | 否 | 要傳回的代碼數量 | 
| offset | integer | 否 | 傳回前要略過的相符代碼數量。在篩選後套用，且僅適用於相符的代碼，不適用於原始 ValueSet 的完整、未篩選內容 | 

## 範例
<a name="expand-examples"></a>

**依 ID 的 GET 請求**  


```
GET [base]/ValueSet/example-valueset/$expand
```

**使用篩選條件依 URL 提出 GET 請求**  


```
GET [base]/ValueSet/$expand?url=http://example.com/ValueSet/my-valueset&filter=male&count=5
```

**含參數的 POST 請求 （依 ID)**  


```
POST [base]/ValueSet/example-valueset/$expand
Content-Type: application/fhir+json

{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "count",
      "valueInteger": 10
    },
    {
      "name": "filter",
      "valueString": "admin"
    }
  ]
}
```

**含參數的 POST 請求 （依 URL)**  


```
POST [base]/ValueSet/$expand
Content-Type: application/fhir+json

{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "url",
      "valueUri": "http://hl7.org/fhir/ValueSet/administrative-gender"
    },
    {
      "name": "count",
      "valueInteger": 10
    }
  ]
}
```

**回應範例**  
操作會傳回具有 `expansion`元素的 ValueSet 資源，其中包含展開的程式碼：

```
{
  "resourceType": "ValueSet",
  "id": "administrative-gender",
  "status": "active",
  "expansion": {
    "identifier": "urn:uuid:12345678-1234-1234-1234-123456789abc",
    "timestamp": "2024-01-15T10:30:00Z",
    "total": 4,
    "parameter": [
      {
        "name": "count",
        "valueInteger": 10
      }
    ],
    "contains": [
      {
        "system": "http://hl7.org/fhir/administrative-gender",
        "code": "male",
        "display": "Male"
      },
      {
        "system": "http://hl7.org/fhir/administrative-gender",
        "code": "female",
        "display": "Female"
      },
      {
        "system": "http://hl7.org/fhir/administrative-gender",
        "code": "other",
        "display": "Other"
      },
      {
        "system": "http://hl7.org/fhir/administrative-gender",
        "code": "unknown",
        "display": "Unknown"
      }
    ]
  }
}
```

回應包括：
+ expansion.total：展開 ValueSet 中的程式碼總數
+ expansion.contains：展開的程式碼陣列及其系統、程式碼和顯示值
+ expansion.parameter：擴展請求中使用的參數

如需 `$expand`操作規格的詳細資訊，請參閱 [FHIR R4 ValueSet `$expand`](https://build.fhir.org/valueset-operation-expand.html) 文件。