

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

# `$operations` 適用於 HealthLake 的 FHIR R4
<a name="reference-fhir-operations"></a>

 FHIR \$1 操作 （也稱為「美元操作」) 是特殊的伺服器端函數，超出 FHIR `Read`規格中的標準 CRUD (`Create`、`Update`、、`Delete`) 操作。這些操作會以「\$1」字首識別，並啟用複雜處理、資料轉換和大量操作，這些操作在使用標準 REST API 呼叫時難以或效率不佳。\$1 操作可以在系統層級、資源類型層級或特定資源執行個體上叫用，提供與 FHIR 資料互動的彈性方式。 AWS HealthLake 支援多個 FHIR`$operations`。如需其他詳細資訊，請參閱以下每個個別頁面。

**Topics**
+ [HealthLake 的 FHIR R4 `$attribution-status`操作](reference-fhir-operations-attribution-status.md)
+ [使用 刪除資源類型 `$bulk-delete`](reference-fhir-operations-bulk-delete.md)
+ [`$bulk-member-match` HealthLake 的 操作](reference-fhir-operations-bulk-member-match.md)
+ [HealthLake 的 FHIR R4 `$confirm-attribution-list`操作](reference-fhir-operations-confirm-attribution-list.md)
+ [HealthLake 的 FHIR R4 `$davinci-data-export`操作](reference-fhir-operations-davinci-data-export.md)
+ [使用 產生臨床文件 `$document`](reference-fhir-operations-document.md)
+ [使用 永久移除資源 `$erase`](reference-fhir-operations-erase.md)
+ [使用 取得患者資料 `Patient/$everything`](reference-fhir-operations-everything.md)
+ [使用 擷取 ValueSet 程式碼 `$expand`](reference-fhir-operations-expand.md)
+ [使用 FHIR 匯出 HealthLake 資料 `$export`](reference-fhir-operations-export.md)
+ [HealthLake 的 FHIR `$inquire`操作](reference-fhir-operations-inquire.md)
+ [使用 擷取概念詳細資訊 `$lookup`](reference-fhir-operations-lookup.md)
+ [`$member-add` HealthLake 的 操作](reference-fhir-operations-member-add.md)
+ [`$member-match` HealthLake 的 操作](reference-fhir-operations-member-match.md)
+ [`$member-remove` HealthLake 的 操作](reference-fhir-operations-member-remove.md)
+ [使用 移除病患室資源 `$purge`](reference-fhir-operations-purge.md)
+ [HealthLake 的 FHIR `$questionnaire-package`操作](reference-fhir-operations-questionnaire-package.md)
+ [HealthLake 的 FHIR `$submit`操作](reference-fhir-operations-submit.md)
+ [使用 驗證 FHIR 資源 `$validate`](reference-fhir-operations-validate.md)

# HealthLake 的 FHIR R4 `$attribution-status`操作
<a name="reference-fhir-operations-attribution-status"></a>

擷取特定成員的屬性狀態，傳回包含與病患相關所有屬性資源的套件。此操作是 [FHIR 成員屬性 (ATR) 清單 IG 2.1.0 實作的一部分。](https://build.fhir.org/ig/HL7/davinci-atr/spec.html)

## Endpoint
<a name="attribution-status-endpoint"></a>

```
POST [base]/Group/[id]/$attribution-status
```

## 請求參數
<a name="attribution-status-parameters"></a>

操作接受下列選用參數：


| 參數 | 類型 | 說明 | 
| --- | --- | --- | 
| memberId | 識別符 | 請求其屬性狀態之成員的 MemberId  | 
| patientReference | 參考資料 | 生產者系統中病患資源的參考 | 

**注意**  
`patientReference` 可以提供 `memberId`或 ，或兩者都用於驗證目的。

## 請求範例
<a name="attribution-status-request-example"></a>

```
{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "memberId",
      "valueIdentifier": {
        "system": "http://example.org",
        "value": "MBR123456789"
      }
    },
    {
      "name": "patientReference",
      "valueReference": {
        "reference": "Patient/patient-123",
        "display": "John Doe"
      }
    }
  ]
}
```

## 回應
<a name="attribution-status-response"></a>

傳回包含與病患相關屬性資源的套件：


| 資源 | 基數 | Location | 
| --- | --- | --- | 
| 病患 | 1..1 | Group.member.entity | 
| 涵蓋範圍 | 0..1 | Group.member.extension：coverageReference | 
| Organization/Practitioner/PractitionerRole | 0..1 | Group.member.extension：attributedProvider | 
| 任何資源 | 0..1 | Group.member.extension：associatedData | 

### 回應範例
<a name="attribution-status-response-example"></a>

```
{
  "resourceType": "Bundle",
  "id": "bundle-response",
  "meta": {
    "lastUpdated": "2014-08-18T01:43:33Z"
  },
  "type": "collection",
  "entry": [
    {
      "fullUrl": "http://example.org/fhir/Patient/12423",
      "resource": {
        "resourceType": "Patient",
        "id": "12423",
        "meta": {
          "versionId": "1",
          "lastUpdated": "2014-08-18T01:43:31Z"
        },
        "active": true,
        "name": [
          {
            "use": "official",
            "family": "Chalmers",
            "given": ["Peter", "James"]
          }
        ],
        "gender": "male",
        "birthDate": "1974-12-25"
      }
    },
    {
      "fullUrl": "http://example.org/fhir/Coverage/123456",
      "resource": {
        "resourceType": "Coverage",
        "id": "1"
        // ... additional Coverage resource details
      }
    },
    {
      "fullUrl": "http://example.org/fhir/Organization/666666",
      "resource": {
        "resourceType": "Organization",
        "id": "2"
        // ... additional Organization resource details
      }
    }
  ]
}
```

## 錯誤處理
<a name="attribution-status-error-handling"></a>

操作會處理下列錯誤條件：


| 錯誤 | HTTP 狀態 | Description | 
| --- | --- | --- | 
| 無效的操作請求 | 400 | 不符合的請求參數或結構 | 
| 找不到群組資源 | 404 | 指定的群組 ID 不存在 | 
| 找不到病患資源 | 404 | 指定的病患參考不存在 | 

## 授權和安全性
<a name="attribution-status-authorization"></a>

SMART 範圍需求  
用戶端必須具有適當的權限，才能讀取群組資源和相關歸因資源  
標準 FHIR 授權機制適用於所有操作

# 使用 刪除資源類型 `$bulk-delete`
<a name="reference-fhir-operations-bulk-delete"></a>

AWS HealthLake 支援 `$bulk-delete`操作，可刪除資料存放區中特定類型的所有資源。當您需要：
+ 執行季節性稽核和清除
+ 大規模管理資料生命週期
+ 移除特定資源類型
+ 遵循資料保留政策

## Usage
<a name="bulk-delete-usage"></a>

您可以使用 POST 方法叫用 `$bulk-delete`操作：

```
POST [base]/[ResourceType]/$bulk-delete?isHardDelete=false&deleteAuditEvent=true
```

## Parameters
<a name="bulk-delete-parameters"></a>


| 參數 | Type | 必要 | 預設 | Description | 
| --- | --- | --- | --- | --- | 
| isHardDelete | 布林值 | 否 | false | 當為 true 時， 會從儲存體永久移除資源 | 
| deleteAuditEvent | 布林值 | 否 | true | 為 true 時， 會刪除相關聯的稽核事件 | 
| \$1since | string | 否 | 資料存放區建立時間 | 輸入時， 會根據資源的lastModified時間選取開始截止時間來尋找資源。無法與開始或結束搭配使用 | 
| start | string | 否 | 資料存放區建立時間 | 輸入時， 會根據資源的lastModified時間選取截止時間來尋找資源。可與 end 搭配使用 | 
| end | string | 否 | 任務提交時間 | 輸入時， 會根據資源的lastModified時間選取結束截止時間以尋找資源 | 

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

**範例請求**  


```
POST [base]/Observation/$bulk-delete?isHardDelete=false
```

**回應範例**  


```
{
      "jobId": "jobId",
      "jobStatus": "SUBMITTED"
    }
```

## 任務狀態
<a name="bulk-delete-job-status"></a>

若要檢查大量刪除任務的狀態：

```
GET [base]/$bulk-delete/[jobId]
```

操作會傳回任務狀態資訊：

```
{
      "datastoreId": "datastoreId",
      "jobId": "jobId",
      "status": "COMPLETED",
      "submittedTime": "2025-10-09T15:09:51.336Z"
    }
```

## Behavior (行為)
<a name="bulk-delete-behavior"></a>

`$bulk-delete` 操作：

1. 以非同步方式處理大量資源

1. 維護 ACID 交易的資料完整性

1. 提供具有資源刪除計數的任務狀態追蹤

1. 支援軟式和硬式刪除模式

1. 包括刪除活動的完整稽核記錄

1. 允許選擇性刪除歷史版本和稽核事件

## 稽核記錄
<a name="bulk-delete-audit-logging"></a>

`$bulk-delete` 操作會記錄為 StartFHIRBulkDeleteJob 和 DescribeFHIRBulkDeleteJob，其中包含詳細的操作資訊。

## 限制
<a name="bulk-delete-limitations"></a>
+ 當 `isHardDelete` 設為 true 時，硬刪除的資源不會出現在搜尋結果或`_history`查詢中。
+ 透過此操作刪除的資源在處理期間可能暫時無法存取
+ 僅根據歷史版本調整儲存計量 - deleteVersionHistory=false 不會調整資料存放區儲存

# `$bulk-member-match` HealthLake 的 操作
<a name="reference-fhir-operations-bulk-member-match"></a>

AWS HealthLake 支援非同步處理多個成員比對請求`$bulk-member-match`的操作。此操作可讓醫療保健組織在單一大量請求中使用人口統計和涵蓋範圍資訊，在不同的醫療保健系統中有效率地比對數百個成員的唯一識別符。此功能對於大規模payer-to-payer資料交換、成員轉換和 CMS 合規要求至關重要，並遵循 FHIR [規格](https://build.fhir.org/ig/HL7/davinci-epdx/OperationDefinition-BulkMemberMatch.html)。

**注意**  
`$bulk-member-match` 操作是以目前實驗性且可能會有所變更的基礎 FHIR 規格為基礎。隨著規格的演進，此 API 的行為和界面也會隨之更新。建議開發人員監控 AWS HealthLake 版本備註和相關的 FHIR 規格更新，以隨時掌握可能影響其整合的任何變更。

當您需要執行下列動作時，此操作特別有用：
+ 在開放註冊期間大規模處理成員比對
+ 促進付款人之間的大量成員轉換
+ 支援大規模 CMS 合規資料交換需求
+ 有效率地比對跨醫療保健網路的成員群組
+ 將 API 呼叫降至最低，並提高大量比對案例的操作效率

## Usage
<a name="bulk-member-match-usage"></a>

`$bulk-member-match` 操作是使用 POST 方法在群組資源上調用的非同步操作：

```
POST [base]/Group/$bulk-member-match
```

提交大量比對請求後，您可以使用下列方式輪詢任務狀態：

```
GET [base]/$bulk-member-match-status/{jobId}
```

## 支援的參數
<a name="bulk-member-match-parameters"></a>

HealthLake 支援下列 FHIR `$bulk-member-match` 參數：


| 參數 | Type | 必要 | Description | 
| --- | --- | --- | --- | 
| `MemberPatient` | 病患 | 是 | 包含要比對之成員人口統計資訊的患者資源。 | 
| `CoverageToMatch` | 涵蓋範圍 | 是 | 用於比對現有記錄的涵蓋資源。 | 
| `CoverageToLink` | 涵蓋範圍 | 否 | 比對程序期間要連結的覆蓋資源。 | 
| `Consent` | 同意 | 是 | 授權用途的同意資源也會儲存。這與*不需要*同意的個別`$member-match`操作不同。 | 

## 提交大量成員比對任務的 POST 請求
<a name="bulk-member-match-request-example"></a>

下列範例顯示提交大量成員比對任務的 POST 請求。每個成員都會包裝在`MemberBundle`參數中`MemberPatient`，其中包含必要的 `CoverageToMatch`、 和 `Consent` 資源，以及選用的 `CoverageToLink`。

```
POST [base]/Group/$bulk-member-match
Content-Type: application/fhir+json
{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "MemberBundle",
      "part": [
        {
          "name": "MemberPatient",
          "resource": {
            "resourceType": "Patient",
            "identifier": [
              {
                "system": "http://example.org/patient-id",
                "value": "patient-0"
              }
            ],
            "name": [
              {
                "family": "Smith",
                "given": ["James"]
              }
            ],
            "gender": "male",
            "birthDate": "1950-01-01"
          }
        },
        {
          "name": "CoverageToMatch",
          "resource": {
            "resourceType": "Coverage",
            "status": "active",
            "identifier": [
              {
                "system": "http://example.org/coverage-id",
                "value": "cov-0"
              }
            ],
            "subscriberId": "sub-0",
            "beneficiary": {
              "reference": "Patient/patient123"
            },
            "relationship": {
              "coding": [
                {
                  "system": "http://terminology.hl7.org/CodeSystem/subscriber-relationship",
                  "code": "self"
                }
              ]
            },
            "payor": [
              {
                "reference": "Organization/org123"
              }
            ]
          }
        },
        {
          "name": "Consent",
          "resource": {
            "resourceType": "Consent",
            "status": "active",
            "scope": {
              "coding": [
                {
                  "system": "http://terminology.hl7.org/CodeSystem/consentscope",
                  "code": "patient-privacy"
                }
              ]
            },
            "category": [
              {
                "coding": [
                  {
                    "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                    "code": "IDSCL"
                  }
                ]
              }
            ],
            "patient": {
              "reference": "Patient/patient123"
            },
            "performer": [
              {
                "reference": "Patient/patient123"
              }
            ],
            "sourceReference": {
              "reference": "http://example.org/DocumentReference/consent-source"
            },
            "policy": [
              {
                "uri": "http://hl7.org/fhir/us/davinci-hrex/StructureDefinition-hrex-consent.html#regular"
              }
            ],
            "provision": {
              "type": "permit",
              "period": {
                "start": "2024-01-01",
                "end": "2025-12-31"
              },
              "actor": [
                {
                  "role": {
                    "coding": [
                      {
                        "system": "http://terminology.hl7.org/CodeSystem/provenance-participant-type",
                        "code": "performer"
                      }
                    ]
                  },
                  "reference": {
                    "identifier": {
                      "system": "http://hl7.org/fhir/sid/us-npi",
                      "value": "9876543210"
                    },
                    "display": "Old Health Plan"
                  }
                },
                {
                  "role": {
                    "coding": [
                      {
                        "system": "http://terminology.hl7.org/CodeSystem/v3-ParticipationType",
                        "code": "IRCP"
                      }
                    ]
                  },
                  "reference": {
                    "identifier": {
                      "system": "http://hl7.org/fhir/sid/us-npi",
                      "value": "0123456789"
                    },
                    "display": "New Health Plan"
                  }
                }
              ],
              "action": [
                {
                  "coding": [
                    {
                      "system": "http://terminology.hl7.org/CodeSystem/consentaction",
                      "code": "disclose"
                    }
                  ]
                }
              ]
            }
          }
        },
        {
          "name": "CoverageToLink",
          "resource": {
            "resourceType": "Coverage",
            "status": "active",
            "identifier": [
              {
                "system": "http://example.org/coverage-link-id",
                "value": "cov-link-0"
              }
            ],
            "subscriberId": "new-sub-0",
            "beneficiary": {
              "reference": "Patient/patient123"
            },
            "relationship": {
              "coding": [
                {
                  "system": "http://terminology.hl7.org/CodeSystem/subscriber-relationship",
                  "code": "self"
                }
              ]
            },
            "payor": [
              {
                "identifier": {
                  "system": "http://hl7.org/fhir/sid/us-npi",
                  "value": "0123456789"
                },
                "display": "New Health Plan"
              }
            ]
          }
        }
      ]
    }
  ]
}
```

## 使用輸出完成任務回應
<a name="bulk-member-match-response-example"></a>

當任務完成時，回應會包含任務中繼資料和 FHIR 參數資源，其中包含分類相符結果的三個群組資源。

```
{
  "datastoreId": "datastoreId",
  "jobId": "jobId",
  "status": "COMPLETED",
  "submittedTime": "2026-03-20T18:45:26.321Z",
  "numberOfMembers": 3,
  "numberOfMembersProcessedSuccessfully": 3,
  "numberOfMembersWithCustomerError": 0,
  "numberOfMembersWithServerError": 0,
  "output": {
    "resourceType": "Parameters",
    "meta": {
      "profile": [
        "http://hl7.org/fhir/us/davinci-pdex/StructureDefinition/pdex-parameters-multi-member-match-bundle-out"
      ]
    },
    "parameter": [
      {
        "name": "MatchedMembers",
        "resource": {
          "resourceType": "Group",
          "id": "group1",
          "text": {
            "status": "generated",
            "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">Matched members group</div>"
          },
          "contained": [
            {
              "resourceType": "Patient",
              "id": "1",
              "identifier": [
                {
                  "system": "http://example.org/patient-id",
                  "value": "patient-0"
                }
              ],
              "name": [
                {
                  "family": "Smith",
                  "given": ["James"]
                }
              ],
              "gender": "male",
              "birthDate": "1950-01-01"
            }
          ],
          "type": "person",
          "actual": true,
          "code": {
            "coding": [
              {
                "system": "http://hl7.org/fhir/us/davinci-pdex/CodeSystem/PdexMultiMemberMatchResultCS",
                "code": "match",
                "display": "Matched"
              }
            ]
          },
          "quantity": 1,
          "member": [
            {
              "entity": {
                "extension": [
                  {
                    "url": "http://hl7.org/fhir/us/davinci-pdex/StructureDefinition/base-ext-match-parameters",
                    "valueReference": {
                      "reference": "#1"
                    }
                  }
                ],
                "reference": "Patient/patient123"
              }
            }
          ]
        }
      },
      {
        "name": "NonMatchedMembers",
        "resource": {
          "resourceType": "Group",
          "id": "Group2",
          "text": {
            "status": "generated",
            "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">Non-matched members group</div>"
          },
          "contained": [
            {
              "resourceType": "Patient",
              "id": "1",
              "identifier": [
                {
                  "system": "http://example.org/patient-id",
                  "value": "patient-501"
                }
              ],
              "name": [
                {
                  "family": "Carter",
                  "given": ["Emily"]
                }
              ],
              "gender": "female",
              "birthDate": "1985-06-15"
            }
          ],
          "type": "person",
          "actual": true,
          "code": {
            "coding": [
              {
                "system": "http://hl7.org/fhir/us/davinci-pdex/CodeSystem/PdexMultiMemberMatchResultCS",
                "code": "nomatch",
                "display": "Not Matched"
              }
            ]
          },
          "quantity": 1,
          "member": [
            {
              "entity": {
                "extension": [
                  {
                    "url": "http://hl7.org/fhir/us/davinci-pdex/StructureDefinition/base-ext-match-parameters",
                    "valueReference": {
                      "reference": "#1"
                    }
                  }
                ],
                "reference": "Patient/patient123"
              }
            }
          ]
        }
      },
      {
        "name": "ConsentConstrainedMembers",
        "resource": {
          "resourceType": "Group",
          "id": "group3",
          "text": {
            "status": "generated",
            "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">Consent constrained members group</div>"
          },
          "contained": [
            {
              "resourceType": "Patient",
              "id": "1",
              "identifier": [
                {
                  "system": "http://example.org/patient-id",
                  "value": "patient-502"
                }
              ],
              "name": [
                {
                  "family": "Nguyen",
                  "given": ["David"]
                }
              ],
              "gender": "male",
              "birthDate": "1972-11-22"
            }
          ],
          "type": "person",
          "actual": true,
          "code": {
            "coding": [
              {
                "system": "http://hl7.org/fhir/us/davinci-pdex/CodeSystem/PdexMultiMemberMatchResultCS",
                "code": "consentconstraint",
                "display": "Consent Constraint"
              }
            ]
          },
          "quantity": 1,
          "member": [
            {
              "entity": {
                "extension": [
                  {
                    "url": "http://hl7.org/fhir/us/davinci-pdex/StructureDefinition/base-ext-match-parameters",
                    "valueReference": {
                      "reference": "#1"
                    }
                  }
                ],
                "reference": "Patient/123"
              }
            }
          ]
        }
      }
    ]
  }
}
```

## 輸出群組資源
<a name="bulk-member-match-output-groups"></a>

已完成的任務會傳回包含三個群組資源的參數資源：

**MatchedMembers 群組**  
包含所有成功配對成員的患者參考，且未分類為同意限制條件。

`Group.quantity` 欄位包含其各自群組中的成員總數。

**NonMatchedMembers 群組**  
包含對找不到相符項目或已識別多個相符項目之成員的參考。

**ConsentConstrainedMembers 群組**  
包含所有成功配對成員的患者參考，其中同意限制會阻止資料共用。當下列兩種條件都存在時，同意資源會被視為受限：  
+ **政策 URI 結尾`#sensitive`**為 - 這是最清晰、最直接的訊號。提交付款人明確表示：「此成員的資料很敏感 — 請謹慎處理。」

  ```
  "policy": [{ "uri": "...hrex-consent.html#sensitive" }]
  ```
+ **最上層佈建類型為 `deny`** — 成員已廣泛拒絕資料共用。

  ```
  "provision": { "type": "deny" }
  ```

## 與 \$1davinci-data-export 整合
<a name="bulk-member-match-davinci-integration"></a>

傳回的 MatchedMembers 群組資源`$bulk-member-match`可以直接與 `$davinci-data-export`操作搭配使用，以擷取大量成員資料：

```
POST [base]/Group/{matched-group-id}/$davinci-data-export
GET [base]/Group/{matched-group-id}
```

此整合可讓您在初次大量識別相符成員的高效工作流程，然後使用產生的群組資源匯出其完整的運作狀態記錄。

## 效能特性
<a name="bulk-member-match-performance"></a>

`$bulk-member-match` 操作專為大量處理而設計，並以非同步方式執行：
+ **並行**：每個資料存放區最多 5 個並行操作。
+ **可擴展性**：每個請求最多可處理 500 個成員 (5 MB 承載限制）。
+ **平行操作**：與並行匯入、匯出或大量刪除操作相容。

## Authorization
<a name="bulk-member-match-authorization"></a>

API 在 FHIR 授權通訊協定上使用 SMART 搭配下列必要範圍：
+ `system/Patient.read` — 搜尋和比對患者資源時必填。
+ `system/Coverage.read` — 驗證涵蓋範圍資訊時需要。
+ `system/Group.write` — 建立結果群組資源時需要。
+ `system/Organization.read` — 有條件，如果涵蓋範圍參考組織則為必要。
+ `system/Practitioner.read` — 有條件，如果涵蓋範圍參考從業人員則為必要。
+ `system/PractitionerRole.read` — 有條件，如果涵蓋範圍參考從業人員角色則為必要。
+ `system/Consent.write` — 有條件，如果提供同意資源則為必要。

此操作也支援程式設計存取的 AWS IAM Signature 第 4 版 (SigV4) 授權。

## 錯誤處理
<a name="bulk-member-match-errors"></a>

操作會處理下列錯誤條件：
+ **400 錯誤的請求**：無效的請求格式、缺少必要的參數或承載超過大小限制 (500 個成員或 5 MB)。
+ **422 無法處理的實體**：在任務執行期間處理錯誤。
+ **個別成員錯誤**：當特定成員無法處理時，操作會繼續保留剩餘成員，並在 NonMatchedMembers 群組中包含錯誤詳細資訊，並具有適當的原因代碼。例如，`MemberBundle`缺少 `birthDate` 參數且具有患者 的 將傳回下列錯誤：

  ```
  "errors": [
    {
      "memberIndex": 1,
      "jsonBlob": {
        "resourceType": "OperationOutcome",
        "issue": [
          {
            "severity": "error",
            "code": "invalid",
            "diagnostics": "MemberPatient.birthDate is required"
          }
        ],
        "statusCode": 400
      }
    }
  ]
  ```

錯誤詳細資訊可透過狀態輪詢端點取得，包括：
+ `numberOfMembersWithCustomerError`：發生驗證或輸入錯誤的成員計數。
+ `numberOfMembersWithServerError`：發生伺服器端處理錯誤的成員計數。

## 相關的 操作
<a name="bulk-member-match-related"></a>
+ [`$member-match` HealthLake 的 操作](reference-fhir-operations-member-match.md) — 個別成員比對操作。
+ [HealthLake 的 FHIR R4 `$davinci-data-export`操作](reference-fhir-operations-davinci-data-export.md) — 使用群組資源大量匯出資料。
+ [`$operations` 適用於 HealthLake 的 FHIR R4](reference-fhir-operations.md) — 支援操作的完整清單。

# HealthLake 的 FHIR R4 `$confirm-attribution-list`操作
<a name="reference-fhir-operations-confirm-attribution-list"></a>

向生產者指出消費者不再需要對屬性清單進行變更。此操作會透過從清單中移除非作用中的成員、將狀態變更為「最終」，以及確認操作，來完成歸因清單。此操作是 [FHIR 成員屬性 (ATR) List IG 2.1.0 實作的一部分。](https://build.fhir.org/ig/HL7/davinci-atr/spec.html)

## Endpoint
<a name="confirm-attribution-list-endpoint"></a>

```
POST [base]/Group/[id]/$confirm-attribution-list
```

## 請求
<a name="confirm-attribution-list-request"></a>

不需要參數。

```
POST [base]/Group/[id]/$confirm-attribution-list
```

## 回應
<a name="confirm-attribution-list-response"></a>

傳回 HTTP 201 與確認訊息。

### 回應範例
<a name="confirm-attribution-list-response-example"></a>

```
HTTP Status Code: 201

{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "message",
      "valueString": "Accepted."
    }
  ]
}
```

## 確認後的群組狀態
<a name="confirm-attribution-list-group-status"></a>

確認成功後，群組資源的屬性清單狀態會設為「最終」：

```
{
  "resourceType": "Group",
  "id": "fullexample",
  "extension": [
    {
      "url": "http://hl7.org/fhir/us/davinci-atr/StructureDefinition/ext-attributionListStatus",
      "valueCode": "final"
    }
  ]
  // ... other Group properties
}
```

## 錯誤處理
<a name="confirm-attribution-list-error-handling"></a>

操作會處理下列錯誤條件：


| 錯誤 | HTTP 狀態 | Description | 
| --- | --- | --- | 
| 無效的操作請求 | 400 | 不符合的請求參數或結構 | 
| 找不到群組資源 | 404 | 指定的群組 ID 不存在 | 

## 授權和安全性
<a name="confirm-attribution-list-authorization"></a>

SMART 範圍需求  
用戶端必須具有適當的權限，才能讀取群組資源和相關歸因資源  
對於 `$confirm-attribution-list`，用戶端也必須具有寫入權限才能修改群組資源  
標準 FHIR 授權機制適用於所有操作

# HealthLake 的 FHIR R4 `$davinci-data-export`操作
<a name="reference-fhir-operations-davinci-data-export"></a>

`$davinci-data-export` 操作是一種非同步 FHIR 操作，可用來從中匯出醫療保健資料 AWS HealthLake。此操作支援多種匯出類型，包括成員屬性 (ATR)、PDex 提供者存取、Payer-to-Payer和成員存取 APIs。它是標準 FHIR `$export`操作的特殊版本，旨在符合 DaVinci 實作指南的要求。

## 主要功能
<a name="davinci-data-export-features"></a>
+ *非同步處理*：遵循標準 FHIR 非同步請求模式
+ *群組層級匯出*：匯出特定群組資源中成員的資料
+ *多種匯出類型*：支援 ATR （成員屬性）、PDex 提供者存取、Payer-to-Payer和成員存取 APIs
+ *全面的設定檔支援*：包括美國核心、CARIN 藍色按鈕和 PDex 設定檔
+ *彈性篩選*：支援依病患、資源類型和時間範圍進行篩選
+ *NDJSON 輸出*：以換行分隔 JSON 格式提供資料

## 操作端點
<a name="davinci-data-export-endpoint"></a>

```
GET [base]/Group/[id]/$davinci-data-export
POST [base]/Group/[id]/$davinci-data-export
```

## 請求參數
<a name="davinci-data-export-parameters"></a>


| 參數 | 基數 | Description | 
| --- | --- | --- | 
| patient | 0..\$1 | 要匯出其資料的特定成員。省略時，會匯出群組中的所有成員。 | 
| \$1type | 0..1 | 要匯出的以逗號分隔的 FHIR 資源類型清單。 | 
| \$1since | 0..1 | 僅包含在此日期和時間之後更新的資源。 | 
| \$1until | 0..1 | 僅包含在此日期和時間之前更新的資源。 | 
| exportType | 0..1 | 要執行的匯出類型。有效值：hl7.fhir.us.davinci-atr、hl7.fhir.us.davinci-pdex、hl7.fhir.us.davinci-pdex.p2p、hl7.fhir.us.davinci-pdex.member。預設：hl7.fhir.us.davinci-atr。 | 
| \$1includeEOB2xWoFinancial | 0..1 | 指定是否要在移除財務資料時包含 CARIN BB 2.x ExplanationOfBenefit 資源。預設：false。 | 

### 支援的資源類型
<a name="davinci-data-export-supported-resources"></a>

支援的資源類型取決於您指定的匯出類型。對於 ATR 匯出，支援下列資源類型：
+ `Group`
+ `Patient`
+ `Coverage`
+ `RelatedPerson`
+ `Practitioner`
+ `PractitionerRole`
+ `Organization`
+ `Location`

對於 PDex 匯出 (Provider Access、Payer-to-Payer 和 Member Access)，除了上述類型之外，還支援所有臨床和宣告資源類型。如需支援資源類型的完整清單，請參閱[美國核心實作指南 (STU 6.1)](https://hl7.org/fhir/us/core/STU6.1/)、[CARIN 藍色按鈕實作指南](https://hl7.org/fhir/us/carin-bb/)，以及 [Da Vinci 預先授權支援實作指南](https://hl7.org/fhir/us/davinci-pas/)。

## 匯出類型
<a name="davinci-data-export-types"></a>

`$davinci-data-export` 操作支援下列匯出類型。您可以使用 `exportType` 參數指定匯出類型。


| 匯出類型 | 用途 | 資料範圍 | 時間限制 | 
| --- | --- | --- | --- | 
| hl7.fhir.us.davinci-atr | 成員屬性清單 | 屬性相關資源 | 無 | 
| hl7.fhir.us.davinci-pdex | 提供者存取 API | 屬性患者的臨床和宣告資料 | 5 年 | 
| hl7.fhir.us.davinci-pdex.p2p | Payer-to-Payer交換 | 保險轉換的歷史成員資料 | 5 年 | 
| hl7.fhir.us.davinci-pdex.member | 成員存取 API | 成員自己的運作狀態資料 | 5 年 | 

**注意**  
對於 PDex 匯出，5 年時間限制不適用於 ATR 資源類型 (`Group`、`Patient`、`Coverage`、`RelatedPerson`、`Practitioner`、`PractitionerRole``Organization`、)`Location`。無論存留期為何，一律都會包含這些資源。

### ATR (hl7.fhir.us：//.davinci-atr)
<a name="davinci-data-export-type-atr"></a>

使用 ATR 匯出類型，您可以匯出成員屬性清單資料。使用此匯出類型來擷取群組內成員的屬性相關資源。如需詳細資訊，請參閱 [Da Vinci ATR 匯出操作](https://build.fhir.org/ig/HL7/davinci-atr/OperationDefinition-davinci-data-export.html)。

支援的資源類型  
`Group`, `Patient`, `Coverage`, `RelatedPerson`, `Practitioner`, `PractitionerRole`, `Organization`, `Location`

時間篩選  
不會套用時間篩選。無論日期為何，都會匯出所有相符的資源。

### PDex 匯出類型
<a name="davinci-data-export-type-pdex"></a>

所有 PDex 匯出類型共用相同的支援設定檔和篩選邏輯。如需詳細資訊，請參閱 [Da Vinci PDex 提供者存取 API](https://build.fhir.org/ig/HL7/davinci-epdx/provider-access-api.html)。支援下列設定檔：
+ 美國核心 3.1.1、6.1.0 和 7.0.0
+ PDex 事前授權 （不支援成員存取）
+ CARIN BB 2.x 基礎描述檔：住院機構、門診機構、專業NonClinician、口頭、藥學

提供者存取 (`hl7.fhir.us.davinci-pdex`)  
讓網路內提供者擷取歸因患者的患者資料。

Payer-to-Payer(`hl7.fhir.us.davinci-pdex.p2p`)  
當患者變更保險時，啟用付款人之間的資料交換。

成員存取 (`hl7.fhir.us.davinci-pdex.member`)  
可讓成員存取自己的運作狀態資料。此匯出類型可能包含宣告資源中的財務資料。

## 設定檔支援和包含邏輯
<a name="davinci-data-export-profile-support"></a>

對於 PDex 匯出， `$davinci-data-export`操作會使用 `meta.profile`元素中的設定檔宣告來決定匯出中要包含哪些資源。

### ExplanationOfBenefit 資源處理
<a name="davinci-data-export-carin-handling"></a>

`ExplanationOfBenefit` (EOB) 資源會根據其`meta.profile`宣告從 PDex 匯出中包含或排除：
+ 匯出會排除具有 CARIN BB 1.x 設定檔的 ExplanationOfBenefit 資源。
+ 匯出會排除未設定 ExplanationOfBenefit 資源。 `meta.profile`
+ 一律包含具有 CARIN BB 2.x Basis 描述檔的 ExplanationOfBenefit 資源。
+ 根據預設，會排除具有包含財務資料的 CARIN BB 2.x 設定檔的 ExplanationOfBenefit 資源。設定 `_includeEOB2xWoFinancial=true` 時，它們會包含在財務資料分割中，並將資源轉換為對應的基礎設定檔。
+ 一律包含具有 PDex 預先授權設定檔的 ExplanationOfBenefit 資源。

### 財務資料轉換
<a name="davinci-data-export-financial-transformation"></a>

當您設定 時`_includeEOB2xWoFinancial=true`，此操作會移除財務資料，將 [CARIN BB 2.x](https://hl7.org/fhir/us/carin-bb/) ExplanationOfBenefit 資源轉換為其對應的 Basis 設定檔。例如，`C4BB ExplanationOfBenefit Oral`資源會轉換為 `C4BB ExplanationOfBenefit Oral Basis`，這會根據 FHIR 規格從記錄分割財務資料。

下列財務資料元素會在轉換期間移除：
+ `total` 元素上的所有切片
+ 具有`amounttype`配量的所有`adjudication`元素
+ 包含金額資訊的所有`item.adjudication`元素

此操作也會在轉換期間更新設定檔中繼資料：
+ `meta.profile` 已更新為 Basis 設定檔正式 URL
+ 版本已更新為 CARIN BB 2.x Basis 版本
+ 不會修改資料存放區中的現有資源
+ 匯出的資源不會保留回資料存放區

### 設定檔偵測規則
<a name="davinci-data-export-profile-detection"></a>

操作使用下列規則來偵測和驗證設定檔：
+ 版本偵測是以`meta.profile`正式 URLs為基礎
+ 如果任何宣告的設定檔符合匯出條件，則會包含資源
+ 設定檔驗證會在匯出處理期間進行

## PDex 匯出的五年時間篩選
<a name="davinci-data-export-temporal-filtering"></a>

對於所有 PDex 匯出類型，HealthLake 會根據資源上次更新的時間套用 5 年的時間篩選條件。暫時篩選條件適用於下列核心屬性資源類型以外的所有資源，無論使用期限為何，一律會匯出這些資源：
+ `Patient`
+ `Coverage`
+ `Organization`
+ `Practitioner`
+ `PractitionerRole`
+ `RelatedPerson`
+ `Location`
+ `Group`

這些管理和人口統計資源是豁免的，因為它們提供匯出資料的基本內容。ATR 匯出不受任何時間篩選的限制。

## 請求範例
<a name="davinci-data-export-examples"></a>

下列範例示範如何啟動不同匯出類型的匯出任務。

*ATR 匯出*

```
GET https://healthlake.{region}.amazonaws.com/datastore/{datastoreId}/r4/Group/example-group/$davinci-data-export?_type=Group,Patient,Coverage,Practitioner,Organization&exportType=hl7.fhir.us.davinci-atr

POST https://healthlake.{region}.amazonaws.com/datastore/{datastoreId}/r4/Group/example-group/$davinci-data-export?_type=Group,Patient,Coverage,Practitioner,Organization&exportType=hl7.fhir.us.davinci-atr
Content-Type: application/json

{
  "DataAccessRoleArn": "arn:aws:iam::444455556666:role/your-healthlake-service-role",
  "JobName": "attribution-export-job",
  "OutputDataConfig": {
    "S3Configuration": {
      "S3Uri": "s3://your-export-bucket/EXPORT-JOB",
      "KmsKeyId": "arn:aws:kms:region:444455556666:key/1234abcd-12ab-34cd-56ef-1234567890ab"
    }
  }
}
```

*使用 ExplanationOfBenefit 財務資料移除來匯出供應商存取*

```
GET https://healthlake.{region}.amazonaws.com/datastore/{datastoreId}/r4/Group/example-group/$davinci-data-export?_type=Patient,Observation,Condition,MedicationRequest,ExplanationOfBenefit&exportType=hl7.fhir.us.davinci-pdex&_includeEOB2xWoFinancial=true
```

*Payer-to-Payer匯出*

```
GET https://healthlake.{region}.amazonaws.com/datastore/{datastoreId}/r4/Group/example-group/$davinci-data-export?_type=Patient,Coverage,ExplanationOfBenefit,Condition,Procedure&exportType=hl7.fhir.us.davinci-pdex.p2p&_includeEOB2xWoFinancial=true
```

*特定病患的成員存取匯出*

```
GET https://healthlake.{region}.amazonaws.com/datastore/{datastoreId}/r4/Group/example-group/$davinci-data-export?_type=Patient,Observation,Condition,ExplanationOfBenefit,MedicationRequest&exportType=hl7.fhir.us.davinci-pdex.member&patient=Patient/example-patient-id
```

## 回應範例
<a name="davinci-data-export-sample-response"></a>

```
{
  "datastoreId": "eaee622d8406b41eb86c0f4741201ff9",
  "jobStatus": "SUBMITTED",
  "jobId": "48d7b91dae4a64d00d54b70862f33f61"
}
```

## 資源關係
<a name="davinci-data-export-resource-relationships"></a>

操作會根據其在成員屬性清單中的關係匯出資源：

```
Group (Attribution List)
├── Patient (Members)
├── Coverage → RelatedPerson (Subscribers)
├── Practitioner (Attributed Providers)
├── PractitionerRole → Location
└── Organization (Attributed Providers)
```

### 資源來源
<a name="davinci-data-export-resource-sources"></a>


| 資源 | 來源位置 | Description | 
| --- | --- | --- | 
| Patient | Group.member.entity | 屬於屬性清單成員的患者 | 
| Coverage | Group.member.extension:coverageReference | 導致病患成員資格的涵蓋範圍 | 
| Organization | Group.member.extension:attributedProvider | 患者所屬的組織 | 
| Practitioner | Group.member.extension:attributedProvider | 患者所屬的個別從業人員 | 
| PractitionerRole | Group.member.extension:attributedProvider | 患者所屬的從業人員角色 | 
| RelatedPerson | Coverage.subscriber | 涵蓋範圍的訂閱者 | 
| Location | PractitionerRole.location | 與從業人員角色相關聯的位置 | 
| Group | 輸入端點 | 屬性清單本身 | 

## 任務管理
<a name="davinci-data-export-job-management"></a>

檢查任務狀態  
`GET [base]/export/[job-id]`

取消任務  
`DELETE [base]/export/[job-id]`

### 任務生命週期
<a name="davinci-data-export-job-lifecycle"></a>
+ `SUBMITTED` - 已收到任務並排入佇列
+ `IN_PROGRESS` - 任務正在主動處理
+ `COMPLETED` - 任務成功完成，檔案可供下載
+ `FAILED` - 任務發生錯誤

## 輸出格式
<a name="davinci-data-export-output-format"></a>
+ *檔案格式*：NDJSON （換行分隔 JSON)
+ *檔案組織*：每個資源類型的個別檔案
+ *副檔名*：.ndjson
+ *位置*：指定的 S3 儲存貯體和路徑

## 錯誤處理
<a name="davinci-data-export-error-handling"></a>

針對下列情況， 操作會傳回 HTTP 400 錯誤請求與 OperationOutcome：

授權錯誤  
在 中指定的 IAM 角色`DataAccessRoleArn`沒有足夠的許可來執行匯出操作。如需所需 S3 和 KMS 許可的完整清單，請參閱[設定匯出任務的許可](getting-started-setting-up.md#setting-up-export-permissions)。

參數驗證錯誤  
+ `patient` 參數的格式不是 `Patient/id,Patient/id,...`
+ 一或多個病患參考無效或不屬於指定的群組
+ `exportType` 參數值不是支援的匯出類型
+ `_type` 參數包含指定匯出類型不支援的資源類型
+ `_type` 參數缺少`hl7.fhir.us.davinci-atr`匯出類型所需的資源類型 (`Group`、`Patient`、`Coverage`)
+ `_includeEOB2xWoFinancial` 參數值不是有效的布林值

資源驗證錯誤  
+ 指定的群組資源不存在於資料存放區中
+ 指定的群組資源沒有成員
+ 一或多個群組成員參考資料存放區中不存在的患者資源

## 安全性和授權
<a name="davinci-data-export-security"></a>
+ 適用標準 FHIR 授權機制
+ 資料存取角色必須具有 S3 和 KMS 操作所需的 IAM 許可。如需所需許可的完整清單，請參閱[設定匯出任務的許可](getting-started-setting-up.md#setting-up-export-permissions)。

## 最佳實務
<a name="davinci-data-export-best-practices"></a>
+ *資源類型選擇*：僅請求所需的資源類型，以將匯出大小和處理時間降至最低
+ 以*時間為基礎的篩選*：使用 `_since` 參數進行增量匯出
+ *病患篩選*：當您只需要特定成員的資料時，請使用 `patient` 參數
+ *任務監控*：定期檢查大型匯出的任務狀態
+ *錯誤處理*：針對失敗的任務實作適當的重試邏輯
+ *暫時篩選條件感知*：對於 PDex 匯出，請在選取資源類型時考慮 5 年暫時篩選條件
+ *財務資料移除*：當您需要沒有財務資訊的宣告資料`_includeEOB2xWoFinancial=true`時使用
+ *設定檔管理*：確保資源具有適當的設定檔宣告、在擷取之前針對目標設定檔進行驗證，並使用設定檔版本控制來控制匯出行為

## 限制
<a name="davinci-data-export-limitations"></a>
+ 參數中最多可指定 500 名病患 `patient` 
+ 匯出僅限於群組層級操作
+ 僅支援每個匯出類型的預先定義資源類型集
+ 輸出一律為 NDJSON 格式
+ PDex 匯出僅限於 5 年的臨床和宣告資料
+ 財務資料轉換僅適用於 CARIN BB 2.x ExplanationOfBenefit 設定檔

## 其他資源
<a name="davinci-data-export-additional-resources"></a>
+ [Da Vinci 成員屬性清單 IG](https://build.fhir.org/ig/HL7/davinci-atr/)
+ [Da Vinci 付款人資料交換 IG](https://hl7.org/fhir/us/davinci-pdex/)
+ [CARIN 消費者導向付款人資料交換 IG](https://build.fhir.org/ig/HL7/carin-bb/)
+ [美國核心實作指南](https://www.hl7.org/fhir/us/core/)
+ [FHIR 大量資料存取規格](https://hl7.org/fhir/uv/bulkdata/)

# 使用 產生臨床文件 `$document`
<a name="reference-fhir-operations-document"></a>

AWS HealthLake 現在支援合成資源的 `$document`操作，可讓您將合成與其所有參考的資源綁定到單一的整合套件中，以產生完整的臨床文件。此操作對於需要：
+ 建立標準化臨床文件
+ Exchange 完整患者記錄
+ 存放完整的臨床文件
+ 產生包含所有相關內容的報告

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

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

**受支援的 操作**  


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

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

HealthLake 支援下列 FHIR `$document` 參數：


| 參數 | Type | 必要 | 預設 | Description | 
| --- | --- | --- | --- | --- | 
| persist | 布林值 | 否 | false | 布林值，指出伺服器是否應存放產生的文件套件 | 

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

**GET 請求**  


```
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
    }
  ]
}
```

**回應範例**  
操作會傳回「文件」類型的套件資源，其中包含合成和所有參考的資源：

```
{
  "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"
            }
          ]
        }
      }
    }
  ]
}
```

## Behavior (行為)
<a name="document-behavior"></a>

`$document` 操作：

1. 將指定的合成資源做為文件的基礎

1. 識別和擷取合成直接參考的所有資源

1. 將合成和所有參考的資源封裝到類型為「文件」的套件中

1. 當持久性參數設定為 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`操作 （不符合的請求），或者如果產生的文件在持久性設定為 true 時因篩選掉的參考而失敗 FHIR 驗證
+ 找不到 404：找不到合成資源

如需 `$document`操作規格的詳細資訊，請參閱 [FHIR R4 合成`$document`](https://www.hl7.org/fhir/R4/composition-operation-document.html)文件。

# 使用 永久移除資源 `$erase`
<a name="reference-fhir-operations-erase"></a>

AWS HealthLake 支援 `$erase`操作，可永久刪除特定資源及其歷史版本。當您需要執行下列動作時，此操作特別有用：
+ 永久移除個別資源
+ 刪除特定版本歷史記錄
+ 管理個別資源生命週期
+ 符合特定資料移除要求

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

操作`$erase`可以在兩個層級叫用：

**資源執行個體層級**  


```
POST [base]/[ResourceType]/[ID]/$erase?deleteAuditEvent=true
```

**版本特定層級**  


```
POST [base]/[ResourceType]/[ID]/_history/[VersionID]/$erase
```

## Parameters
<a name="erase-parameters"></a>


| 參數 | Type | 必要 | 預設 | Description | 
| --- | --- | --- | --- | --- | 
| deleteAuditEvent | 布林值 | 否 | false | 為 true 時， 會刪除相關聯的稽核事件 | 

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

**範例請求**  


```
POST [base]/Patient/example-patient/$erase
```

**回應範例**  


```
{
      "jobId": "5df47e2f51ff3c731847678cb8cad48e",
      "jobStatus": "SUBMITTED"
    }
```

## 任務狀態
<a name="erase-job-status"></a>

若要檢查清除任務的狀態：

```
GET [base]/$erase/[jobId]
```

操作會傳回任務狀態資訊：

```
{
      "datastoreId": "36622996b1fcecb7e12ee2ee085308d3",
      "jobId": "5df47e2f51ff3c731847678cb8cad48e",
      "status": "COMPLETED",
      "submittedTime": "2025-10-30T16:39:24.160Z"
    }
```

## Behavior (行為)
<a name="erase-behavior"></a>

`$erase` 操作：

1. 非同步處理以確保資料完整性

1. 維護 ACID 交易

1. 提供任務狀態追蹤

1. 永久移除指定的資源及其版本

1. 包括刪除活動的完整稽核記錄

1. 支援選擇性刪除稽核事件

## 稽核記錄
<a name="erase-audit-logging"></a>

`$erase` 操作會以 DeleteResource 記錄使用者 ID、時間戳記和資源詳細資訊。

## 限制
<a name="erase-limitations"></a>
+ `$erased` 資源不會出現在搜尋結果或`_history`查詢中。
+ 正在清除的資源在處理期間可能暫時無法存取
+ 當資源永久移除時，儲存體計量會立即調整

# 使用 取得患者資料 `Patient/$everything`
<a name="reference-fhir-operations-everything"></a>

 `Patient/$everything` 操作用於查詢 FHIR `Patient` 資源，以及與該 相關的任何其他資源`Patient`。此操作可用來讓病患存取其整個記錄，或讓提供者執行與病患相關的大量資料下載。HealthLake `Patient/$everything` 支援特定病患 `id`。

`Patient/$everything` 是一種 FHIR REST API 操作，可以叫用，如以下範例所示。

------
#### [ GET request ]

```
GET https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/Patient/id/$everything
```

------

**注意**  
回應中的資源會依資源類型和資源 排序`id`。  
回應一律會填入 `Bundle.total`。

## `Patient/$everything` 參數
<a name="patient-everything-query-params"></a>

HealthLake 支援下列查詢參數


| 參數 | 詳細資訊 | 
| --- | --- | 
|  入門  |  取得指定開始日期之後的所有`Patient`資料。  | 
|  end  |  在指定的結束日期之前取得`Patient`所有資料。  | 
|  since  |  在指定日期之後更新`Patient`所有資料。  | 
|  \$1type  |  取得特定資源類型的`Patient`資料。  | 
|  \$1count  |  取得`Patient`資料並指定頁面大小。  | 

**Example - 取得指定開始日期之後的所有患者資料**  
`Patient/$everything` 可以使用`start`篩選條件僅查詢特定日期之後的資料。  

```
GET https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/Patient/id/$everything?start=2024-03-15T00:00:00.000Z
```

**Example - 在指定的結束日期之前取得`Patient`所有資料**  
病患 \$1所有項目都可以使用`end`篩選條件，只在特定日期之前查詢資料。  

```
GET https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/Patient/id/$everything?end=2024-03-15T00:00:00.000Z
```

**Example - 在指定日期之後更新`Patient`所有資料**  
`Patient/$everything` 可以使用`since`篩選條件，僅查詢特定日期之後更新的資料。  

```
GET https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/Patient/id/$everything?since=2024-03-15T00:00:00.000Z
```

**Example - 取得特定資源類型的`Patient`資料**  
病患 \$1所有項目都可以使用`_type`篩選條件來指定要包含在回應中的特定資源類型。您可以在逗號分隔清單中指定多種資源類型。  

```
GET https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/Patient/id/$everything?_type=Observation,Condition
```

**Example - 取得`Patient`資料並指定頁面大小**  
病患 \$1所有項目都可以使用 `_count`來設定頁面大小。  

```
GET https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/Patient/id/$everything?_count=15
```

## `Patient/$everything`  `start` 和 `end` 屬性
<a name="reference-patient-everything-start-end-attributes"></a>

HealthLake 支援 `Patient/ $everything``start`和 `end`查詢參數的下列資源屬性。


| 資源 | 資源元素 | 
| --- | --- | 
| 帳戶 | Account.servicePeriod.start | 
| AdverseEvent | AdverseEvent.date | 
| AllergyIntolerance | AllergyIntolerance.recordedDate | 
| 約定 | Appointment.start | 
| AppointmentResponse | AppointmentResponse.start | 
| AuditEvent | AuditEvent.period.start | 
| 基本 | Basic.created | 
| BodyStructure | NO\$1DATE | 
| CarePlan | CarePlan.period.start | 
| CareTeam | CareTeam.period.start | 
| ChargeItem | ChargeItem.occurrenceDateTime, ChargeItem.occurrencePeriod.start, ChargeItem.occurrenceTiming.event | 
| 取得 | Claim.billablePeriod.start | 
| ClaimResponse | ClaimResponse.created | 
| ClinicalImpression | ClinicalImpression.date | 
| Communication | Communication.sent | 
| CommunicationRequest | CommunicationRequest.occurrenceDateTime,CommCommunicationRequest.occurrencePeriod.start | 
| 合成 | Composition.date | 
| 條件 | Condition.recordedDate | 
| 同意 | consent.dateTime | 
| 涵蓋範圍 | Coverage.period.start | 
| CoverageEligibilityRequest | CoverageEligibilityRequest.created | 
| CoverageEligibilityResponse | CoverageEligibilityResponse.created | 
| DetectedIssue | DetectedIssue.identified | 
| DeviceRequest | DeviceRequest.authoredOn | 
| DeviceUseStatement | DeviceUseStatement.recordedOn | 
| DiagnosticReport | DiagnosticReport.effective | 
| DocumentManifest | DocumentManifest.created | 
| DocumentReference | DocumentReference.context.period.start | 
| 遇到 | Encounter.period.start | 
| EnrollmentRequest | EnrollmentRequest.created | 
| EpisodeOfCare | EpisodeOfCare.period.start | 
| ExplanationOfBenefit | ExplanationOfBenefit.billablePeriod.start | 
| FamilyMemberHistory | NO\$1DATE | 
| 旗標 | Flag.period.start | 
| 目標 | Goal.statusDate | 
| Group | NO\$1DATE | 
| ImagingStudy | ImagingStudy.started | 
| 預防 | Immunization.recorded | 
| ImmunizationEvaluation | ImmunizationEvaluation.date | 
| ImmunizationRecommendation | ImmunizationRecommendation.date | 
| 發票 | Invoice.date | 
| 清單 | List.date | 
| MeasureReport | MeasureReport.period.start | 
| 媒體 | 媒體。發行 | 
| MedicationAdministration | MedicationAdministration.effective | 
| MedicationDispense | MedicationDispense.whenPrepared | 
| MedicationRequest | MedicationRequest.authoredOn | 
| MedicationStatement | MedicationStatement.dateAsserted | 
| MolecularSequence | NO\$1DATE | 
| NutritionOrder | NutritionOrder.dateTime | 
| 觀察 | Observation.effective | 
| 病患 | NO\$1DATE | 
| 個人 | NO\$1DATE | 
| 程序 | Procedure.performed | 
| 證明 | Provenance.occurredPeriod.start,Provenance.occurredDateTime | 
| QuestionnaireResponse | QuestionnaireResponse.authored | 
| RelatedPerson | NO\$1DATE | 
| RequestGroup | RequestGroup.authoredOn | 
| ResearchSubject | ResearchSubject.period | 
| RiskAssessment | RiskAssessment.occurrenceDateTime,RiskAssessment.occurrencePeriod.start | 
| Schedule | Schedule.planningHorizon | 
| ServiceRequest | ServiceRequest.authoredOn | 
| 樣本 | 配置函式.receivedTime | 
| SupplyDelivery | SupplyDelivery.occurrenceDateTime, SupplyDelivery.occurrencePeriod.start, SupplyDelivery.occurrenceTiming.event | 
| SupplyRequest | SupplyRequest.authoredOn | 
| VisionPrescription | VisionPrescription.dateWritten | 

# 使用 擷取 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) 文件。

# 使用 FHIR 匯出 HealthLake 資料 `$export`
<a name="reference-fhir-operations-export"></a>

您可以使用 FHIR \$1export 操作，從 HealthLake 資料存放區大量匯出資料。HealthLake 支援`$export`使用 `POST`和 `GET`請求的 FHIR。若要使用 提出匯出請求`POST`，您必須擁有具有必要許可的 IAM 使用者、群組或角色、指定 `$export`做為請求的一部分，並在請求內文中包含所需的參數。

**注意**  
使用 FHIR 提出的所有 HealthLake 匯出請求`$export`都會以 `ndjson` 格式傳回，並匯出至 Amazon S3 儲存貯體，其中每個 Amazon S3 物件僅包含單一 FHIR 資源類型。  
您可以根據 AWS 帳戶服務配額將匯出請求排入佇列。如需詳細資訊，請參閱[Service Quotas](reference-healthlake-endpoints-quotas.md#reference-healthlake-quotas)。

HealthLake 支援下列三種類型的大量匯出端點請求。


**HealthLake 大量`$export`類型**  

| 匯出類型 | Description | 語法 | 
| --- | --- | --- | 
| 系統 | 從 HealthLake FHIR 伺服器匯出所有資料。 | `POST https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/$export`  | 
| 所有病患 | 匯出所有與病患相關的所有資料，包括與病患資源類型相關聯的資源類型。 | `POST https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/Patient/$export` `GET https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/Patient/$export` | 
| 病患群組 | 匯出與群組 ID 指定的一組患者相關的所有資料。 | `POST https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/Group/id/$export` `GET https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/Group/id/$export` | 

## 開始之前
<a name="export-rest-before-you-begin"></a>

符合下列要求，以使用 FHIR REST API for HealthLake 提出匯出請求。
+ 您必須設定具有提出匯出請求必要許可的使用者、群組或角色。如需詳細資訊，請參閱 [授權 `$export`請求](#export-rest-auth)。
+ 您必須已建立服務角色，授予 HealthLake 存取您要將資料匯出至其中的 Amazon S3 儲存貯體的權限。服務角色也必須指定 HealthLake 做為服務委託人。如需設定許可的詳細資訊，請參閱 [設定匯出任務的許可](getting-started-setting-up.md#setting-up-export-permissions)。

## 授權 `$export`請求
<a name="export-rest-auth"></a>

若要使用 FHIR REST API 提出成功的匯出請求，請使用 IAM 或 OAuth2.0. 您還必須擁有 服務角色。

**使用 IAM 授權請求**  
當您提出`$export`請求時，使用者、群組或角色必須在政策中包含 IAM 動作。如需詳細資訊，請參閱[設定匯出任務的許可](getting-started-setting-up.md#setting-up-export-permissions)。

**在 FHIR 上使用 SMART 授權請求 (OAuth 2.0)**  
當您在啟用 FHIR 的 HealthLake 資料存放區上對 SMART 提出`$export`請求時，您必須指派適當的範圍。如需詳細資訊，請參閱[HealthLake 的 FHIR 資源範圍上的 SMART](reference-smart-on-fhir-oauth-scopes.md#smart-on-fhir-scopes-rest)。

**注意**  
`$export` 具有`GET`請求的 FHIR 需要相同的身分驗證方法或承載字符 （在 FHIR 上使用 SMART 的情況下） 來請求匯出和擷取檔案。使用 FHIR `$export` 搭配 匯出的檔案`GET`可供下載 48 小時。

## 提出`$export`請求
<a name="export-rest-request"></a>

本節說明使用 FHIR REST API 提出匯出請求時必須採取的必要步驟。

為了避免 AWS 您的帳戶意外產生費用，我們建議您在不提供`$export`語法的情況下提出請求來測試您的`POST`請求。

若要提出請求，您必須執行下列動作：

1. 在支援端點的`POST`請求 URL `$export`中指定 。

1. 指定必要的標頭參數。

1. 指定定義必要參數的請求內文。

### 步驟 1：在支援[端點](reference-healthlake-endpoints-quotas.md#reference-healthlake-endpoints)的`POST`請求 URL `$export`中指定 。
<a name="export-rest-request-step-1"></a>

HealthLake 支援三種類型的大量匯出端點請求。若要提出大量匯出請求，您必須在三個支援的端點之一上提出`POST`以 為基礎的請求。下列範例示範要在請求 URL `$export`中指定何處。
+ `POST https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/$export`
+ `POST https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/Patient/$export`
+ `POST https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/Group/id/$export`

您可以在`POST`請求字串中使用下列支援的搜尋參數。

#### 支援的搜尋參數
<a name="export-rest-query-parameters"></a>

HealthLake 在大量匯出請求中支援下列搜尋修飾詞。

下列範例包含特殊字元，在提交請求之前必須先編碼。


| 名稱 | 是否為必要？ | Description | 範例 | 
| --- | --- | --- | --- | 
| \$1outputFormat | 否 | 要產生的請求大量資料檔案格式。接受的值為 application/fhir\$1ndjson、application/ndjson、ndjson。 |  | 
| \$1type | 否 | 您想要包含在匯出任務中的逗號分隔 FHIR 資源類型的字串。我們建議包含 ，\$1type因為匯出所有資源時，這可能會牽涉成本。 | &\$1type=MedicationStatement, Observation | 
| \$1since | 否 | 在日期時間戳記當天或之後修改的資源類型。如果資源類型沒有上次更新的時間，則會將其包含在回應中。 | &\$1since=2024-05-09T00%3A00%3A00Z | 
| \$1until | 否 | 在日期時間戳記當天或之前修改的資源類型。與 結合使用\$1since，以定義匯出的特定時間範圍。如果資源類型沒有上次更新的時間，它們將從您的回應中排除。 | &\$1until=2024-12-31T23%3A59%3A59Z | 

### 步驟 2：指定必要的標頭參數
<a name="export-rest-request-step-2"></a>

若要使用 FHIR REST API 提出匯出請求，您必須指定下列標頭參數。
+ Content-Type： `application/fhir+json`
+ 偏好： `respond-async`

接著，您必須在請求內文中指定必要的元素。

### 步驟 3：指定 定義必要參數的請求內文。
<a name="export-rest-request-step-3"></a>

匯出請求也需要 `JSON` 格式的內文。內文可以包含下列參數。


| 金錀 | 是否為必要？ | Description | Value | 
| --- | --- | --- | --- | 
| DataAccessRoleArn | 是 | HealthLake 服務角色的 ARN。使用的服務角色必須指定 HealthLake 做為服務委託人。 | arn:aws:iam::444455556666:role/your-healthlake-service-role | 
| JobName | 否 | 匯出請求的名稱。 | your-export-job-name | 
| S3Uri | 是 | OutputDataConfig 金鑰的一部分。要下載匯出資料之目的地儲存貯體的 S3 URI。 | s3://amzn-s3-demo-bucket/EXPORT-JOB/ | 
| KmsKeyId | 是 | OutputDataConfig 金鑰的一部分。用於保護 Amazon S3 儲存貯體之 AWS KMS 金鑰的 ARN。 | arn:aws:kms:region-of-bucket:123456789012:key/1234abcd-12ab-34cd-56ef-1234567890ab | 

**Example 使用 FHIR REST API 提出的匯出請求內文**  
若要使用 FHIR REST API 提出匯出請求，您必須指定內文，如下所示。  

```
{
  "DataAccessRoleArn": "arn:aws:iam::444455556666:role/your-healthlake-service-role",
  "JobName": "your-export-job",
  "OutputDataConfig": {
    "S3Configuration": {
      "S3Uri": "s3://amzn-s3-demo-bucket/EXPORT-JOB",
      "KmsKeyId": "arn:aws:kms:region-of-bucket:444455556666:key/1234abcd-12ab-34cd-56ef-1234567890ab"
    }
  }
}
```

當您的請求成功時，您將會收到下列回應。

*回應標頭*

```
content-location: https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/export/your-export-request-job-id
```

*回應內文*

```
{
  "datastoreId": "your-data-store-id",
  "jobStatus": "SUBMITTED",
  "jobId": "your-export-request-job-id"
}
```

## 管理您的匯出請求
<a name="export-rest-management"></a>

成功提出匯出請求後，您可以使用 管理請求`$export`，以描述目前匯出請求的狀態，以及`$export`取消目前的匯出請求。

當您使用 REST API 取消匯出請求時，您只需支付截至您提交取消請求之前匯出的部分資料的費用。

下列主題說明如何取得狀態或取消目前的匯出請求。

### 取消匯出請求
<a name="export-rest-management-describe"></a>

若要取消匯出請求，請提出`DELETE`請求並在請求 URL 中提供任務 ID。

```
DELETE https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/export/your-export-request-job-id
```

當您的請求成功時，您會收到以下內容。

```
{
  "exportJobProperties": {
    "jobId": "your-original-export-request-job-id",
    "jobStatus": "CANCEL_SUBMITTED",
    "datastoreId": "your-data-store-id"
  }
}
```

當您的請求不成功時，您會收到以下內容。

```
{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "error",
      "code": "not-supported",
      "diagnostics": "Interaction not supported."
    }
  ]
}
```

### 描述匯出請求
<a name="export-rest-management-describe"></a>

若要取得匯出請求的狀態，請使用 `export`和 提出`GET`請求`export-request-job-id`。

```
GET https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/export/your-export-request-id
```

JSON 回應將包含 `ExportJobProperties` 物件。它可能包含下列索引鍵：值對。


| 名稱 | 是否為必要？ | Description | Value | 
| --- | --- | --- | --- | 
| DataAccessRoleArn | 否 | HealthLake 服務角色的 ARN。使用的服務角色必須指定 HealthLake 做為服務委託人。 | arn:aws:iam::444455556666:role/your-healthlake-service-role | 
| SubmitTime | 否 | 匯出任務提交的日期。 | Apr 21, 2023 5:58:02 | 
| EndTime | 否 | 匯出任務完成的時間。 | Apr 21, 2023 6:00:08 PM | 
| JobName | 否 | 匯出請求的名稱。 | your-export-job-name | 
| JobStatus | 否 |  | 有效的值如下：<pre>SUBMITTED | IN_PROGRESS | COMPLETED_WITH_ERRORS | COMPLETED |<br />      FAILED</pre> | 
| S3Uri | 是 | [OutputDataConfig](https://docs.aws.amazon.com/healthlake/latest/APIReference/API_OutputDataConfig.html) 物件的一部分。要下載匯出資料之目的地儲存貯體的 Amazon S3 URI。 | s3://amzn-s3-demo-bucket/EXPORT-JOB/ | 
| KmsKeyId | 是 | [OutputDataConfig](https://docs.aws.amazon.com/healthlake/latest/APIReference/API_OutputDataConfig.html) 物件的一部分。用於保護 Amazon S3 儲存貯體之 AWS KMS 金鑰的 ARN。 | arn:aws:kms:region-of-bucket:123456789012:key/1234abcd-12ab-34cd-56ef-1234567890ab | 

**Example ：描述使用 FHIR REST API 提出之匯出請求的內文**  
成功時，您會收到下列 JSON 回應。  

```
{
  "exportJobProperties": {
    "jobId": "your-export-request-id",
    "JobName": "your-export-job",
    "jobStatus": "SUBMITTED",
    "submitTime": "Apr 21, 2023 5:58:02 PM",
    "endTime": "Apr 21, 2023 6:00:08 PM",
    "datastoreId": "your-data-store-id",
    "outputDataConfig": {
      "s3Configuration": {
        "S3Uri": "s3://amzn-s3-demo-bucket/EXPORT-JOB",
        "KmsKeyId": "arn:aws:kms:region-of-bucket:444455556666:key/1234abcd-12ab-34cd-56ef-1234567890ab""
      }
    },
    "DataAccessRoleArn": "arn:aws:iam::444455556666:role/your-healthlake-service-role",
  }
}
```

# HealthLake 的 FHIR `$inquire`操作
<a name="reference-fhir-operations-inquire"></a>

`$inquire` 操作可讓您檢查先前提交的預先授權請求的狀態。此操作實作 [Da Vinci 預先授權支援 (PAS) 實作指南](https://hl7.org/fhir/us/davinci-pas/)，提供標準化的 FHIR 工作流程來擷取目前的授權決策。

## 運作方式
<a name="inquire-how-it-works"></a>
+ **提交查詢**：您傳送 FHIR 套件，其中包含您要檢查的宣告和支援資訊
+ **搜尋**：HealthLake 會在您的資料存放區中搜尋對應的 ClaimResponse 
+ **擷取**：擷取最新的授權狀態
+ **回應**：您會收到目前授權狀態的立即回應 （佇列、核准、拒絕等）

**注意**  
`$inquire` 是**擷取現有授權狀態的唯讀操作**。它不會修改或更新資料存放區中的任何資源。

## API 端點
<a name="inquire-api-endpoint"></a>

```
POST /datastore/{datastoreId}/r4/Claim/$inquire  
Content-Type: application/fhir+json
```

## 請求結構
<a name="inquire-request-structure"></a>

### 套件需求
<a name="inquire-bundle-requirements"></a>

您的請求必須是具有下列項目的 FHIR 套件資源：
+ **Bundle.type**：必須為 `"collection"`
+ **Bundle.entry**：必須包含**一個**具有下列項目的宣告資源：
  + `use = "preauthorization"`
  + `status = "active"`
+ **參考資源**： 宣告參考的所有資源必須包含在套件中

**Query-by-Example**  
輸入套件中的資源做為搜尋範本。HealthLake 會使用提供的資訊來尋找對應的 ClaimResponse。

### 必要的資源
<a name="inquire-required-resources"></a>


| 資源 | 基數 | 設定檔 | Description | 
| --- | --- | --- | --- | 
| 宣告 | 1 | PAS 宣告查詢 | 您正在查詢的預先授權 | 
| 病患 | 1 | PAS 受益人病患 | 病患人口統計資訊 | 
| Organization （保險業者） | 1 | PAS 保險公司組織 | 保險公司 | 
| Organization （提供者） | 1 | PAS 請求組織 | 提交請求的醫療保健供應商 | 

### 重要搜尋條件
<a name="inquire-search-criteria"></a>

HealthLake 使用下列項目搜尋 ClaimResponse：
+ 來自宣告**的患者參考** 
+ 來自宣告的**保險業者參考** 
+ 來自宣告的**提供者參考** 
+ 從宣告**建立的日期** （做為時間篩選條件）

**僅限患者特定的查詢**  
所有查詢都必須繫結至特定病患。不允許沒有患者識別的全系統查詢。

## 範例請求
<a name="inquire-example-request"></a>

```
POST /datastore/example-datastore/r4/Claim/$inquire  
Content-Type: application/fhir+json  
Authorization: Bearer <your-token>  
  
{  
  "resourceType": "Bundle",  
  "id": "PASClaimInquiryBundleExample",  
  "meta": {  
    "profile": ["http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-pas-inquiry-request-bundle"]  
  },  
  "identifier": {  
    "system": "http://example.org/SUBMITTER_TRANSACTION_IDENTIFIER",  
    "value": "5269368"  
  },  
  "type": "collection",  
  "timestamp": "2005-05-02T14:30:00+05:00",  
  "entry": [  
    {  
      "fullUrl": "http://example.org/fhir/Claim/MedicalServicesAuthorizationExample",  
      "resource": {  
        "resourceType": "Claim",  
        "id": "MedicalServicesAuthorizationExample",  
        "meta": {  
          "profile": ["http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-claim-inquiry"]  
        },  
        "status": "active",  
        "type": {  
          "coding": [{  
            "system": "http://terminology.hl7.org/CodeSystem/claim-type",  
            "code": "professional"  
          }]  
        },  
        "use": "preauthorization",  
        "patient": {  
          "reference": "Patient/SubscriberExample"  
        },  
        "created": "2005-05-02T11:01:00+05:00",  
        "insurer": {  
          "reference": "Organization/InsurerExample"  
        },  
        "provider": {  
          "reference": "Organization/UMOExample"  
        }  
      }  
    },  
    {  
      "fullUrl": "http://example.org/fhir/Patient/SubscriberExample",  
      "resource": {  
        "resourceType": "Patient",  
        "id": "SubscriberExample",  
        "meta": {  
          "profile": ["http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-beneficiary"]  
        },  
        "name": [{  
          "family": "SMITH",  
          "given": ["JOE"]  
        }],  
        "gender": "male"  
      }  
    },  
    {  
      "fullUrl": "http://example.org/fhir/Organization/UMOExample",  
      "resource": {  
        "resourceType": "Organization",  
        "id": "UMOExample",  
        "meta": {  
          "profile": ["http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-requestor"]  
        },  
        "name": "Provider Organization"  
      }  
    },  
    {  
      "fullUrl": "http://example.org/fhir/Organization/InsurerExample",  
      "resource": {  
        "resourceType": "Organization",  
        "id": "InsurerExample",  
        "meta": {  
          "profile": ["http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-insurer"]  
        },  
        "name": "Insurance Company"  
      }  
    }  
  ]  
}
```

## 回應格式
<a name="inquire-response-format"></a>

### 成功回應 (200 OK)
<a name="inquire-success-response"></a>

您將會收到 PAS 查詢回應套件，其中包含：
+ 具有目前授權狀態的 **ClaimResponse**；如果符合搜尋條件，則為多個 **ClaimResponse** 
+ 請求中的所有原始資源 （已回呼）
+ 組合回應時的時間戳記

**可能的 ClaimResponse 結果**  



| 結果 | Description | 
| --- | --- | 
| queued | 授權請求仍在等待審核 | 
| complete | 已做出授權決策 （檢查disposition是否已核准/遭拒） | 
| error | 處理期間發生錯誤 | 
| partial | 已授予部分授權 | 

```
{  
  "resourceType": "Bundle",  
  "identifier": {  
        "system": "http://example.org/SUBMITTER_TRANSACTION_IDENTIFIER",  
        "value": "5269367"  
  },  
  "type": "collection",  
  "timestamp": "2005-05-02T14:30:15+05:00",  
  "entry": [  
    {  
      "fullUrl": "http://example.org/fhir/ClaimResponse/InquiryResponseExample",  
      "resource": {  
        "resourceType": "ClaimResponse",  
        "id": "InquiryResponseExample",  
        "meta": {  
          "profile": ["http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-claimresponse-inquiry"]  
        },  
        "status": "active",  
        "type": {  
          "coding": [{  
            "system": "http://terminology.hl7.org/CodeSystem/claim-type",  
            "code": "professional"  
          }]  
        },  
        "use": "preauthorization",  
        "patient": {  
          "reference": "Patient/SubscriberExample"  
        },  
        "created": "2005-05-02T11:05:00+05:00",  
        "insurer": {  
          "reference": "Organization/InsurerExample"  
        },  
        "request": {  
          "reference": "Claim/MedicalServicesAuthorizationExample"  
        },  
        "outcome": "complete",  
        "disposition": "Approved",  
        "preAuthRef": "AUTH12345"  
      }  
    },  
    {  
      "fullUrl": "http://example.org/fhir/Claim/MedicalServicesAuthorizationExample",  
      "resource": {  
        "resourceType": "Claim",  
        "id": "MedicalServicesAuthorizationExample",  
        "meta": {  
          "profile": ["http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-claim-inquiry"]  
        },  
        "status": "active",  
        "type": {  
          "coding": [{  
            "system": "http://terminology.hl7.org/CodeSystem/claim-type",  
            "code": "professional"  
          }]  
        },  
        "use": "preauthorization",  
        "patient": {  
          "reference": "Patient/SubscriberExample"  
        },  
        "created": "2005-05-02T11:01:00+05:00",  
        "insurer": {  
          "reference": "Organization/InsurerExample"  
        },  
        "provider": {  
          "reference": "Organization/UMOExample"  
        }  
      }  
    },  
    {  
      "fullUrl": "http://example.org/fhir/Patient/SubscriberExample",  
      "resource": {  
        "resourceType": "Patient",  
        "id": "SubscriberExample",  
        "meta": {  
          "profile": ["http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-beneficiary"]  
        },  
        "name": [{  
          "family": "SMITH",  
          "given": ["JOE"]  
        }],  
        "gender": "male"  
      }  
    },  
    {  
      "fullUrl": "http://example.org/fhir/Organization/UMOExample",  
      "resource": {  
        "resourceType": "Organization",  
        "id": "UMOExample",  
        "meta": {  
          "profile": ["http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-requestor"]  
        },  
        "name": "Provider Organization"  
      }  
    },  
    {  
      "fullUrl": "http://example.org/fhir/Organization/InsurerExample",  
      "resource": {  
        "resourceType": "Organization",  
        "id": "InsurerExample",  
        "meta": {  
          "profile": ["http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-insurer"]  
        },  
        "name": "Insurance Company"  
      }  
    }  
  ]  
}
```

## 錯誤回應
<a name="inquire-error-responses"></a>

### 400 錯誤的請求
<a name="inquire-400-error"></a>

當請求格式無效或驗證失敗時傳回。

```
{  
    "resourceType": "OperationOutcome",  
    "issue": [  
        {  
            "severity": "error",  
            "code": "required",  
            "diagnostics": "Reference 'Patient/SubscriberExample' at path 'patient' for 'CLAIM' resource not found(at Bundle.entry[0].resource)"  
        }  
    ]  
}
```

### 401 (未經授權)
<a name="inquire-401-error"></a>

當身分驗證憑證遺失或無效時傳回。

```
{  
    "resourceType": "OperationOutcome",  
    "issue": [  
        {  
            "severity": "error",  
            "code": "forbidden",  
            "diagnostics": "Invalid authorization header"  
        }  
    ]  
}
```

### 403 禁止
<a name="inquire-403-error"></a>

當已驗證的使用者缺少存取所請求資源的許可時傳回。

```
{  
    "resourceType": "OperationOutcome",  
    "issue": [  
        {  
            "severity": "error",  
            "code": "exception",  
            "diagnostics": "Insufficient SMART scope permissions."  
        }  
    ]  
}
```

### 400 當找不到時
<a name="inquire-400-none-found"></a>

查詢找不到相符的 ClaimResponse 時傳回。

```
{  
  "resourceType": "OperationOutcome",
  "issue": [{
    "severity": "error",
    "code": "not-found",
    "diagnostics": "Resource not found. No ClaimResponse found from the input Claim that matches the specified Claim properties patient, insurer, provider, and created(at Bundle.entry[0].resource)"
  }]
}
```

### 415 不支援的媒體類型
<a name="inquire-415-error"></a>

當 Content-Type 標頭不是 application/fhir\$1json 時傳回。

```
{  
  "resourceType": "OperationOutcome",  
  "issue": [{  
    "severity": "error",  
    "code": "value",  
    "diagnostics": "Incorrect MIME-type. Update request Content-Type header."  
  }]  
}
```

### 429 太多請求
<a name="inquire-429-error"></a>

超過速率限制時傳回。

```
{  
  "resourceType": "OperationOutcome",  
  "issue": [{  
    "severity": "error",  
    "code": "throttled",  
    "diagnostics": "Rate limit exceeded. Please retry after some time."  
  }]  
}
```

## 驗證規則
<a name="inquire-validation-rules"></a>

HealthLake 會對您的查詢執行全面的驗證：

### 套件驗證
<a name="inquire-bundle-validation"></a>
+ 必須符合 PAS 查詢請求套件描述檔
+ `Bundle.type` 必須 `"collection"`
+ 必須僅包含一個宣告資源
+ 套件中必須包含所有參考的資源

### 宣告驗證
<a name="inquire-claim-validation"></a>
+ 必須符合 PAS 宣告查詢設定檔
+ `Claim.use` 必須 `"preauthorization"`
+ `Claim.status` 必須 `"active"`
+ 必要欄位：`patient`、`insurer`、`provider`、 `created`

### 資源驗證
<a name="inquire-resource-validation"></a>
+ 所有資源必須符合其各自的 PAS 查詢設定檔
+ 必要的支援資源必須存在 （病患、保險公司組織、提供者組織）
+ 交互參考在套件中必須是有效且可解析的

## 效能規格
<a name="inquire-performance-specs"></a>


| 指標 | 規格 | 
| --- | --- | 
| 資源計數限制 | 每個套件 500 個資源 | 
| 套件大小限制 | 最多 5 MB | 

## 所需的許可
<a name="inquire-required-permissions"></a>

若要使用 `$inquire`操作，請確定您的 IAM 角色具有：
+ `healthlake:InquirePreAuthClaim` - 呼叫 操作

**FHIR 範圍上的 SMART**  
**所需範圍下限：**
+ **SMART v1**： `user/ClaimResponse.read`
+ **SMART v2**： `user/ClaimResponse.s`

## 重要實作備註
<a name="inquire-implementation-notes"></a>

### 搜尋行為
<a name="inquire-search-behavior"></a>

當您提交查詢時，HealthLake 會使用下列方式搜尋 ClaimResponse：
+ 來自輸入宣告**的患者參考** 
+ 來自輸入 Claim **的保險業者參考** 
+ 來自輸入宣告的**提供者參考** 
+ 從輸入宣告**建立日期** （做為時間篩選條件）

**多個相符項目**：如果多個 ClaimResponses 符合您的搜尋條件，則 HealthLake 會傳回所有相符結果。您應該使用最新的`ClaimResponse.created`時間戳記來識別最新狀態。

### 已更新宣告
<a name="inquire-updated-claims"></a>

如果您已提交相同預先授權的多個更新 （例如 Claim v1.1、v1.2、v1.3)，`$inquire`操作會根據提供的搜尋條件擷取與**最新版本**相關聯的 ClaimResponse。

### 唯讀操作
<a name="inquire-read-only"></a>

`$inquire` 操作：
+ **會**擷取現有的授權狀態
+ **會**傳回最新的 ClaimResponse
+ **不**修改或更新任何資源
+ **不**建立新資源
+ **不會**觸發新的授權處理

## 工作流程範例
<a name="inquire-workflow-example"></a>

**典型的預先授權查詢工作流程**  


```
1. Provider submits PA request  
   POST /Claim/$submit  
   → Returns ClaimResponse with outcome="queued"  
  
2. Payer reviews request (asynchronous)  
   → Updates ClaimResponse status internally  
  
3. Provider checks status  
   POST /Claim/$inquire  
   → Returns ClaimResponse with outcome="queued" (still pending)  
  
4. Provider checks status again later  
   POST /Claim/$inquire  
   → Returns ClaimResponse with outcome="complete", disposition="Approved"
```

## 相關的 操作
<a name="inquire-related-operations"></a>
+ `Claim/$submit` - 提交新的預先授權請求或更新現有的預先授權請求
+ `Patient/$everything` - 針對預先授權內容擷取完整的患者資料

# 使用 擷取概念詳細資訊 `$lookup`
<a name="reference-fhir-operations-lookup"></a>

AWS HealthLake 現在支援 CodeSystem 資源的 `$lookup`操作，可讓您透過提供程式碼等識別資訊，擷取程式碼系統中特定概念的詳細資訊。當您需要：
+ 擷取特定醫療代碼的詳細資訊
+ 驗證程式碼意義和屬性
+ 存取概念定義和關係
+ 使用準確的術語資料支援臨床決策

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

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

**受支援的 操作**  


```
GET [base]/CodeSystem/$lookup?system=http://snomed.info/sct&code=73211009&version=20230901
POST [base]/CodeSystem/$lookup
```

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

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


| 參數 | Type | 必要 | Description | 
| --- | --- | --- | --- | 
| code | code | 是 | 您要查詢的概念代碼 （例如 SNOMED CT 中的 "71620000") | 
| system | uri | 是 | 程式碼系統的正式 URL （例如 "[http://snomed.info/sct](http://snomed.info/sct)") | 
| version | string | 否 | 特定版本的程式碼系統 | 

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

**GET 請求**  


```
GET [base]/CodeSystem/$lookup?system=http://snomed.info/sct&code=71620000&version=2023-09
```

**POST 請求**  


```
POST [base]/CodeSystem/$lookup
Content-Type: application/fhir+json

{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "system",
      "valueUri": "http://snomed.info/sct"
    },
    {
      "name": "code",
      "valueCode": "71620000"
    },
    {
      "name": "version",
      "valueString": "2023-09"
    }
  ]
}
```

**回應範例**  
操作會傳回參數資源，其中包含概念詳細資訊：

```
{
    "resourceType": "Parameters",
    "parameter": [{
            "name": "name",
            "valueString": "SNOMED CT Fractures"
        },
        {
            "name": "version",
            "valueString": "2023-09"
        },
        {
            "name": "display",
            "valueString": "Fracture of femur"
        },
        {
            "name": "property",
            "part": [{
                    "name": "code",
                    "valueCode": "child"
                },
                {
                    "name": "value",
                    "valueCode": "263225007"
                },
                {
                    "name": "description",
                    "valueString": "Fracture of neck of femur"
                }
            ]
        },
        {
            "name": "property",
            "part": [{
                    "name": "code",
                    "valueCode": "child"
                },
                {
                    "name": "value",
                    "valueCode": "263227004"
                },
                {
                    "name": "description",
                    "valueString": "Fracture of shaft of femur"
                }
            ]
        }
    ]
}
```

## 回應參數
<a name="lookup-response-parameters"></a>

回應會在可用時包含下列參數：


| 參數 | 類型 | Description | 
| --- | --- | --- | 
| name | string | 程式碼系統的名稱 | 
| version | string | 程式碼系統的版本 | 
| display | string | 顯示概念的名稱 | 
| designation | BackboneElement | 此概念的其他表示法。 | 
| property | BackboneElement | 概念的其他屬性 （定義、關係等） | 

## Behavior (行為)
<a name="lookup-behavior"></a>

`$lookup` 操作：

1. 驗證所需的參數 (`code` 和 `system`)

1. 在存放在資料存放區的指定程式碼系統中搜尋概念

1. 傳回詳細的概念資訊，包括顯示名稱、指定項目和屬性。

1. 提供 `version` 參數時支援版本特定的查詢

1. 僅在明確存放在 HealthLake 資料存放區的程式碼系統上操作

## 錯誤處理
<a name="lookup-error-handling"></a>

操作會處理下列錯誤條件：
+ 400 錯誤的請求：無效的`$lookup`操作 （不符合的請求或缺少必要的參數）
+ 找不到 404：找不到程式碼系統，或在指定的程式碼系統中找不到程式碼

## 警告
<a name="lookup-caveats"></a>

在此版本中，不支援下列項目：
+ `$lookup` 透過呼叫外部術語伺服器進行 操作
+ `$lookup` CodeSystems 上的 操作由 HealthLake 管理，但未明確存放在資料存放區中

如需 `$lookup`操作規格的詳細資訊，請參閱 [FHIR R4 CodeSystem `$lookup`](https://www.hl7.org/fhir/R4/codesystem-operation-lookup.html) 文件。

# `$member-add` HealthLake 的 操作
<a name="reference-fhir-operations-member-add"></a>

FHIR `$member-add`操作會將成員 （病患） 新增至群組資源，特別是成員屬性清單。此操作是 DaVinci 成員屬性實作指南的一部分，並支援管理成員屬性的調校程序。

## 操作端點
<a name="member-add-endpoint"></a>

```
POST [base]/datastore/{datastoreId}/r4/Group/{groupId}/$member-add
Content-Type: application/json
```

## Parameters
<a name="member-add-parameters"></a>

操作接受具有下列參數組合的 FHIR 參數資源：

### 參數選項
<a name="member-add-parameter-options"></a>

您可以使用下列其中一個參數組合：

選項 1：成員 ID \$1 供應商 NPI  
`memberId` \$1 `providerNpi`  
`memberId` \$1 `providerNpi` \$1 `attributionPeriod`

選項 2：病患參考 \$1 提供者參考  
`patientReference` \$1 `providerReference`  
`patientReference` \$1 `providerReference` \$1 `attributionPeriod`

### 參數詳細資訊
<a name="member-add-parameter-details"></a>

memberId （選用）  
要新增至群組之成員的識別符。  
類型：Identifier  
系統：病患識別符系統  

```
{
  "name": "memberId",
  "valueIdentifier": {
    "system": "http://example.org/patient-id",
    "value": "patient-new"
  }
}
```

providerNpi （選用）  
屬性提供者的國家提供者識別符 (NPI)。  
類型：Identifier  
系統：https：//http://terminology.hl7.org/CodeSystem/NPI  

```
{
  "name": "providerNpi",
  "valueIdentifier": {
    "system": "http://terminology.hl7.org/CodeSystem/NPI",
    "value": "1234567890"
  }
}
```

patientReference （選用）  
要新增之病患資源的直接參考。  
類型：參考  

```
{
  "name": "patientReference",
  "valueReference": {
    "reference": "Patient/patient-123"
  }
}
```

providerReference （選用）  
直接參考提供者資源。  
類型：參考  

```
{
  "name": "providerReference",
  "valueReference": {
    "reference": "Practitioner/provider-456"
  }
}
```

attributionPeriod（選用）  
病患歸因於提供者的期間。  
類型：期間  

```
{
  "name": "attributionPeriod",
  "valuePeriod": {
    "start": "2024-07-15",
    "end": "2025-07-14"
  }
}
```

## 請求範例
<a name="member-add-examples"></a>

### 使用成員 ID 和提供者 NPI
<a name="member-add-example-id-npi"></a>

```
{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "memberId",
      "valueIdentifier": {
        "system": "http://example.org/patient-id",
        "value": "patient-new"
      }
    },
    {
      "name": "providerNpi",
      "valueIdentifier": {
        "system": "http://terminology.hl7.org/CodeSystem/NPI",
        "value": "1234567890"
      }
    },
    {
      "name": "attributionPeriod",
      "valuePeriod": {
        "start": "2024-07-15",
        "end": "2025-07-14"
      }
    }
  ]
}
```

### 使用病患和提供者參考
<a name="member-add-example-references"></a>

```
{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "patientReference",
      "valueReference": {
        "reference": "Patient/patient-123"
      }
    },
    {
      "name": "providerReference",
      "valueReference": {
        "reference": "Practitioner/provider-456"
      }
    },
    {
      "name": "attributionPeriod",
      "valuePeriod": {
        "start": "2024-07-15",
        "end": "2025-07-14"
      }
    }
  ]
}
```

## 回應格式
<a name="member-add-response"></a>

### 成功的新增回應
<a name="member-add-success-response"></a>

```
HTTP Status: 200 OK
Content-Type: application/fhir+json

{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "success",
      "code": "informational",
      "details": {
        "text": "Member Patient/patient-new successfully added to the Member Attribution List."
      }
    }
  ]
}
```

### 錯誤回應
<a name="member-add-error-responses"></a>

無效的請求語法  
HTTP 狀態：400 錯誤的請求  

```
{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "error",
      "code": "invalid",
      "details": {
        "text": "Invalid parameter combination provided"
      }
    }
  ]
}
```

找不到資源  
HTTP 狀態：找不到 404  

```
{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "error",
      "code": "not-found",
      "details": {
        "text": "Resource not found."
      }
    }
  ]
}
```

版本衝突  
HTTP 狀態：409 衝突  

```
{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "error",
      "code": "conflict",
      "details": {
        "text": "Resource version conflict detected"
      }
    }
  ]
}
```

無效的屬性狀態  
HTTP 狀態：422 無法處理的實體  

```
{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "error",
      "code": "business-rule",
      "details": {
        "text": "Cannot add member to Attribution List with status 'final'. Status must be 'draft' or 'open'."
      }
    }
  ]
}
```

## 業務規則
<a name="member-add-business-rules"></a>

屬性狀態驗證  
只有在群組的屬性狀態為：  
+ `draft`
+ `open`
當狀態為 時，不允許操作`final`。

防止重複成員  
系統會根據以下項目的唯一組合，防止新增重複的成員：  
+ 成員識別符
+ 付款人識別符
+ 涵蓋範圍識別符

涵蓋期間驗證  
提供 `attributionPeriod` 時，必須落在成員涵蓋期間的界限內。系統會：  
+ 搜尋成員的涵蓋範圍資源
+ 如果存在多個 ，請使用最新的涵蓋範圍 （最高 versionId)
+ 驗證歸因期間未超過涵蓋期間

參考驗證  
當同時為相同的資源 （病患或提供者） 提供 ID 和參考時，系統會驗證它們是否對應至相同的資源。  
當同時為相同的資源 （病患或提供者） 提供 ID 和 reference.identifier 欄位時，會擲回錯誤。

## 身分驗證與授權
<a name="member-add-auth"></a>

此操作需要對下列項目進行 FHIR 上的 SMART 授權：
+ 讀取許可 - 驗證患者、提供者和群組資源
+ 搜尋許可 - 依識別符尋找資源
+ 更新許可 - 修改群組資源

## 操作行為
<a name="member-add-behavior"></a>

資源更新  
+ 更新群組資源版本 ID
+ 在操作之前建立具有原始資源狀態的歷史記錄項目
+ 使用 新增成員資訊至 Group.member 陣列：
  + entity.reference 中的病患參考
  + 期間的屬性期間
  + 延伸欄位中的涵蓋範圍和提供者資訊

驗證步驟  
+ 參數驗證 - 確保有效的參數組合
+ 資源存在 - 驗證存在的患者、提供者和群組資源
+ 屬性狀態 - 確認群組狀態允許修改
+ 重複檢查 - 防止新增現有成員
+ 涵蓋範圍驗證 - 確保歸因期間在涵蓋範圍內

## 限制
<a name="member-add-limitations"></a>
+ 所有參考的資源都必須存在於相同的資料存放區中
+ 操作僅適用於成員屬性清單群組資源
+ 屬性期間必須在涵蓋範圍內
+ 無法修改具有「最終」狀態的群組

# `$member-match` HealthLake 的 操作
<a name="reference-fhir-operations-member-match"></a>

AWS HealthLake 現在支援 病患資源`$member-match`的操作，讓醫療保健組織能夠使用人口統計和涵蓋範圍資訊，在不同醫療保健系統中尋找成員的唯一識別符。此操作對於實現 CMS 合規和促進安全payer-to-payer資料交換，同時維護患者隱私至關重要。

當您需要：
+ 啟用組織之間的安全醫療保健資料交換
+ 維持不同系統的患者持續照護
+ 支援 CMS 合規要求
+ 促進跨醫療保健網路的準確成員識別

## Usage
<a name="member-match-usage"></a>

您可以使用 POST 方法，在病患資源上叫用 `$member-match`操作：

```
POST [base]/Patient/$member-match
```

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

HealthLake 支援下列 FHIR `$member-match` 參數：


| 參數 | Type | 必要 | 預設 | Description | 
| --- | --- | --- | --- | --- | 
| MemberPatient | 病患 | 是 | — | 包含要比對之成員人口統計資訊的患者資源 | 
| CoverageToMatch | 涵蓋範圍 | 是 | — | 將用於比對現有記錄的涵蓋資源 | 
| CoverageToLink | 涵蓋範圍 | 否 | — | 比對程序期間要連結的覆蓋資源 | 
| 同意 | 同意 | 否 | — | 授權用途的同意資源 | 

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

### 具有參數的 POST 請求
<a name="member-match-request-example"></a>

```
POST [base]/Patient/$member-match
Content-Type: application/fhir+json

{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "MemberPatient",
      "resource": {
        "resourceType": "Patient",
        "name": [
          {
            "family": "Jones",
            "given": ["Sarah"]
          }
        ],
        "gender": "female",
        "birthDate": "1985-05-15"
      }
    },
    {
      "name": "CoverageToMatch",
      "resource": {
        "resourceType": "Coverage",
        "status": "active",
        "beneficiary": {
          "reference": "Patient/1"
        },
        "relationship": {
          "coding": [
            {
              "system": "http://terminology.hl7.org/CodeSystem/subscriber-relationship",
              "code": "self",
              "display": "Self"
            }
          ]
        },
        "payor": [
          {
            "reference": "Organization/payer456"
          }
        ]
      }
    },
    {
      "name": "Consent",
      "resource": {
        "resourceType": "Consent",
        "status": "active",
        "scope": {
          "coding": [
            {
              "system": "http://terminology.hl7.org/CodeSystem/consentscope",
              "code": "patient-privacy"
            }
          ]
        },
        "category": [
          {
            "coding": [
              {
                "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                "code": "IDSCL"
              }
            ]
          }
        ],
        "patient": {
          "reference": "Patient/1"
        },
        "performer": [
          {
            "reference": "Patient/patient123"
          }
        ],
        "sourceReference": {
          "reference": "Document/someconsent"
        },
        "policy": [
          {
            "uri": "http://hl7.org/fhir/us/davinci-hrex/StructureDefinition-hrex-consent.html#regular"
          }
        ]
      }
    }
  ]
}
```

### 回應範例
<a name="member-match-response-example"></a>

操作會傳回參數資源，其中包含相符的結果：

```
{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "MemberIdentifier",
      "valueIdentifier": {
        "system": "http://hospital.org/medical-record-number",
        "value": "MRN-123456"
      }
    },
    {
      "name": "MemberId",
      "valueReference": {
        "reference": "Patient/patient123"
      }
    },
    {
      "name": "matchAlgorithm",
      "valueString": "DEMOGRAPHIC_MATCH"
    },
    {
      "name": "matchDetails",
      "valueString": "Demographic match: DOB + Name"
    },
    {
      "name": "matchedFields",
      "valueString": "given,birthdate,gender,family"
    }
  ]
}
```

## 回應參數
<a name="member-match-response-parameters"></a>

找到相符項目時，回應會包含下列參數：


| 參數 | 類型 | 說明 | 
| --- | --- | --- | 
| MemberIdentifier | 識別符 | 相符成員的唯一識別符 | 
| MemberId | 參考資料 | 患者資源的參考 | 
| matchAlgorithm | String | 使用的比對演算法類型 (EXACT\$1MATCH、STRONG\$1MATCH 或 DEMOGRAPHIC\$1MATCH) | 
| matchDetails | String | 比對程序的詳細資訊 | 
| matchedFields | String | 已成功相符的特定欄位清單 | 

## 相符演算法
<a name="member-match-algorithms"></a>

`$member-match` API 採用多層比對方法，以確保準確的成員識別：

EXACT\$1MATCH  
使用與 Coverage SubscriberId 結合的患者識別符  
為成員比對提供最高的可信度層級

STRONG\$1MATCH  
使用具有最低涵蓋範圍資訊的患者識別符  
不符合完全相符條件時，提供高可信度

DEMOGRAPHIC\$1MATCH  
依賴基本人口統計資訊  
當無法進行識別符型比對時使用

## Behavior (行為)
<a name="member-match-behavior"></a>

`$member-match` 操作：
+ 接受患者人口統計特性、涵蓋範圍詳細資訊和選用的同意資訊做為輸入
+ 傳回可用於後續互動的唯一成員識別符
+ 實作多層比對 （確切、強大、人口統計），以確保在不同醫療保健系統中正確識別成員
+ 儲存任何提供的同意資訊以供未來授權之用
+ 支援安全payer-to-payer資料交換，同時維護患者隱私權
+ 符合醫療資料交換的 CMS 要求

## Authorization
<a name="member-match-authorization"></a>

API 在 FHIR 授權通訊協定上使用 SMART 搭配下列必要範圍：
+ `system/Patient.read`
+ `system/Coverage.read`
+ `system/Organization.read` （有條件）
+ `system/Practitioner.read` （有條件）
+ `system/PractitionerRole.read` （有條件）
+ `system/Consent.write` （有條件）

## 錯誤處理
<a name="member-match-error-handling"></a>

操作會處理下列錯誤條件：
+ `400 Bad Request`：無效的`$member-match`操作 （不符合的請求或缺少必要的參數）
+ `422 Unprocessable Entity`：找不到相符項目或多個相符項目

# `$member-remove` HealthLake 的 操作
<a name="reference-fhir-operations-member-remove"></a>

`$member-remove` 操作可讓您從 FHIR 成員屬性清單 （群組資源） 中移除成員 AWS HealthLake。此操作是 DaVinci 成員屬性實作指南的一部分，並支援管理成員屬性的調校程序。

## 先決條件
<a name="member-remove-prerequisites"></a>
+ AWS HealthLake FHIR 資料存放區
+ HealthLake 操作的適當 IAM 許可
+ 草稿或開啟狀態的成員屬性清單 （群組資源）

## 操作詳細資訊
<a name="member-remove-endpoint"></a>

Endpoint  
`POST /Group/{id}/$member-remove`

內容類型  
`application/fhir+json`

## Parameters
<a name="member-remove-parameters"></a>

操作接受具有下列選用參數的 FHIR 參數資源：


| 參數 | 基數 | Type | 說明 | 
| --- | --- | --- | --- | 
| memberId | 0..1 | 識別符 | 要移除之成員的業務識別符 | 
| providerNpi | 0..1 | 識別符 | 屬性提供者的 NPI | 
| patientReference | 0..1 | 參考資料 | 直接參考 病患資源 | 
| providerReference | 0..1 | 參考資料 | 直接參考提供者資源 (Practitioner、PractitionerRole 或 Organization) | 
| coverageReference | 0..1 | 參考資料 | 涵蓋範圍資源的參考 | 

### 支援的參數組合
<a name="member-remove-parameter-combinations"></a>

支援下列參數組合：
+ `memberId` 僅限 - 移除指定成員的所有屬性
+ `memberId` \$1 `providerNpi` - 移除特定成員提供者組合的屬性
+ `patientReference` 僅限 - 移除指定病患的所有屬性
+ `patientReference` \$1 `providerReference` - 移除特定患者提供者組合的屬性
+ `patientReference` \$1 `providerReference` \$1 `coverageReference` - 根據病患、提供者和涵蓋範圍移除特定歸因

## 請求範例
<a name="member-remove-examples"></a>

```
{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "patientReference",
      "valueReference": {
        "reference": "Patient/12345"
      }
    },
    {
      "name": "providerReference",
      "valueReference": {
        "reference": "Practitioner/67890"
      }
    }
  ]
}
```

## 回應
<a name="member-remove-response"></a>

### 成功回應
<a name="member-remove-success-response"></a>

```
{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "result",
      "valueBoolean": true
    },
    {
      "name": "effectiveDate",
      "valueDate": "2024-06-30"
    },
    {
      "name": "status",
      "valueCode": "inactive"
    },
    {
      "name": "message",
      "valueString": "Member successfully removed from attribution list"
    }
  ]
}
```

## Behavior (行為)
<a name="member-remove-behavior"></a>

狀態需求  
操作僅適用於狀態為 `draft`或 的屬性清單 `open`  
`final` 狀態為 的清單將拒絕 422 錯誤的 操作

成員移除程序  
*草稿狀態清單*：成員標示為非作用中 (`inactive: true`)，且其`changeType`延伸項目已更新為 `changed`  
*開啟狀態清單*：類似草稿狀態的行為  
*最終狀態清單*：操作遭拒

驗證  
驗證參考以確保它們存在於 HealthLake 資料存放區中  
如果同時為相同的資源類型提供識別符和參考，它們必須對應至相同的資源  
根據支援的模式驗證參數組合

## 錯誤處理
<a name="member-remove-error-handling"></a>

### 常見錯誤回應
<a name="member-remove-common-errors"></a>

找不到資源 (404)  

```
{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "error",
      "code": "not-found",
      "details": {
        "text": "Patient with identifier 'http://example.org/fhir/identifiers|99999' not found in system"
      },
      "diagnostics": "Cannot remove member from attribution list. Verify patient identifier and try again.",
      "expression": ["memberId"]
    }
  ]
}
```

屬性清單最終狀態 (422)  

```
{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "error",
      "code": "business-rule",
      "details": {
        "coding": [
          {
            "system": "http://hl7.org/fhir/us/davinci-atr/CodeSystem/atr-error-codes",
            "code": "list-final",
            "display": "Attribution list is final and cannot be modified"
          }
        ]
      },
      "diagnostics": "Cannot modify attribution list with status 'final'. List modifications are not permitted after finalization.",
      "expression": ["Group.status"]
    }
  ]
}
```

無效操作 (400)  
當參數組合無效或格式不正確時傳回。

找到多個相符項目 (412)  
當提供的參數符合屬性清單中的多個成員時傳回。  

```
{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "error",
      "code": "processing",
      "diagnostics": "Multiple members found matching the criteria"
    }
  ]
}
```

## 最佳實務
<a name="member-remove-best-practices"></a>
+ *使用特定參數*：盡可能使用最特定的參數組合，以避免意外移除
+ *檢查清單狀態*：嘗試移除之前，請先驗證屬性清單狀態
+ *正常處理錯誤*：針對所有可能的錯誤條件實作適當的錯誤處理
+ *驗證參考*：確定所有參考的資源都存在，然後再提出請求

# 使用 移除病患室資源 `$purge`
<a name="reference-fhir-operations-purge"></a>

AWS HealthLake 支援 `$purge`操作，可永久刪除病患隔室內的所有資源。當您需要執行下列動作時，此操作特別有用：
+ 移除與病患相關聯的所有資料
+ 遵循病患資料移除請求
+ 管理病患資料生命週期
+ 執行全面的病患記錄清除

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

您可以在病患資源上叫用 `$purge`操作：

```
POST [base]/Patient/[ID]/$purge?deleteAuditEvent=true
```

## Parameters
<a name="purge-parameters"></a>


| 參數 | Type | 必要 | 預設 | Description | 
| --- | --- | --- | --- | --- | 
| deleteAuditEvent | 布林值 | 否 | false | 為 true 時， 會刪除相關聯的稽核事件 | 
| \$1since | string | 否 | 資料存放區建立時間 | 輸入時， 會根據其lastModified的時間選取開始截止時間以尋找資源。無法與開始或結束搭配使用 | 
| start | string | 否 | 資料存放區建立時間 | 輸入時， 會根據資源的lastModified時間選取截止時間來尋找資源。可與 end 搭配使用 | 
| end | string | 否 | 任務提交時間 | 輸入時， 會根據其lastModified的時間選取結束截止時間以尋找資源 | 

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

**範例請求**  


```
POST [base]/Patient/example-patient/$purge?deleteAuditEvent=true
```

**回應範例**  


```
{
  "resourceType": "OperationOutcome",
  "id": "purge-job",
  "issue": [
    {
      "severity": "information",
      "code": "informational",
      "diagnostics": "Purge job started successfully. Job ID: 12345678-1234-1234-1234-123456789012"
    }
  ]
}
```

## 任務狀態
<a name="purge-job-status"></a>

若要檢查清除任務的狀態：

```
GET [base]/$purge/[jobId]
```

操作會傳回任務狀態資訊：

```
{
      "datastoreId": "36622996b1fcecb7e12ee2ee085308d3",
      "jobId": "3dd1c7a5b6c0ef8c110f566eb87e2ef9",
      "status": "COMPLETED",
      "submittedTime": "2025-10-31T18:43:21.822Z"
    }
```

## Behavior (行為)
<a name="purge-behavior"></a>

`$purge` 操作：

1. 以非同步方式處理多個資源

1. 維護 ACID 交易的資料完整性

1. 提供具有資源刪除計數的任務狀態追蹤

1. 永久移除病患隔室中的所有資源

1. 包括刪除活動的完整稽核記錄

1. 支援選擇性刪除稽核事件

## 稽核記錄
<a name="purge-audit-logging"></a>

`$purge` 操作會記錄為 StartFHIRBulkDeleteJob 和 DescribeFHIRBulkDeleteJob，其中包含詳細的操作資訊。

## 限制
<a name="purge-limitations"></a>
+ 清除的資源不會出現在搜尋回應中
+ 正在清除的資源在處理期間可能暫時無法存取
+ 病患隔室中的所有資源都會永久移除

# HealthLake 的 FHIR `$questionnaire-package`操作
<a name="reference-fhir-operations-questionnaire-package"></a>

`$questionnaire-package` 操作會擷取完整的套件，其中包含 FHIR 問卷及其轉譯和處理問卷所需的所有相依性。此操作會實作 [Da Vinci 文件範本和規則 (DTR) 實作指南](https://hl7.org/fhir/us/davinci-dtr/OperationDefinition-questionnaire-package.html)，針對醫療工作流程中的文件需求啟用動態表單轉譯。

## 運作方式
<a name="questionnaire-package-how-it-works"></a>
+ **請求**：您傳送識別所需問卷的參數 （以及涵蓋範圍和順序內容）
+ **擷取**：HealthLake 會收集問卷和所有相依性 (ValueSets、CQL 程式庫等）
+ **套件**：所有資源都以標準化格式綁定在一起
+ **回應**：您收到準備轉譯和資料收集的完整套件

**使用案例**  

+ **預先授權文件**：收集預先授權請求所需的臨床資訊
+ **涵蓋範圍需求**：收集滿足付款人涵蓋範圍需求所需的文件
+ **臨床資料交換**：結構臨床資料以提交給付款人
+ **動態表單**：使用預先填入的患者資料和條件式邏輯轉譯問卷

## API 端點
<a name="questionnaire-package-api-endpoint"></a>

```
POST /datastore/{datastoreId}/r4/Questionnaire/$questionnaire-package  
Content-Type: application/fhir+json
```

## 請求參數
<a name="questionnaire-package-request-parameters"></a>

### 輸入參數
<a name="questionnaire-package-input-parameters"></a>

請求內文必須包含具有下列參數的 FHIR 參數資源：


| 參數 | Type | 基數 | Description | 
| --- | --- | --- | --- | 
| coverage | 涵蓋範圍 | 1..\$1 （必要） | 用於建立文件成員和涵蓋範圍的 （涵蓋範圍） 資源 | 
| questionnaire | 正式 | 0..\$1 | 要傳回之特定問卷的正式 URL (s) （可能包含版本） | 
| order | 資源 | 0..\$1 | 訂購資源 (DeviceRequest、ServiceRequest、MedicationRequest、Encounter、Appointment) 以建立內容 | 
| changedSince | dateTime | 0..1 | 如果存在，則只會傳回在此時間戳記之後變更的資源 | 

### 參數驗證規則
<a name="questionnaire-package-parameter-validation"></a>

**至少必須提供下列其中一項** （除了必要的 之外`coverage`)：
+ 一或多個`questionnaire`正式 URLs
+ 一或多個`order`資源

**有效的請求組合：**  

+ `coverage` \$1 `questionnaire`
+ `coverage` \$1 `order`
+ `coverage` \$1 `questionnaire` \$1 `order`

## 範例請求
<a name="questionnaire-package-example-request"></a>

```
POST /datastore/example-datastore/r4/Questionnaire/$questionnaire-package  
Content-Type: application/fhir+json  
Authorization: Bearer <your-token>  
  
{  
  "resourceType": "Parameters",  
  "parameter": [  
    {  
      "name": "coverage",  
      "resource": {  
        "resourceType": "Coverage",  
        "id": "example-coverage",  
        "status": "active",  
        "beneficiary": {  
          "reference": "Patient/example-patient"  
        },  
        "payor": [{  
          "reference": "Organization/example-payer"  
        }],  
        "class": [{  
          "type": {  
            "coding": [{  
              "system": "http://terminology.hl7.org/CodeSystem/coverage-class",  
              "code": "group"  
            }]  
          },  
          "value": "12345"  
        }]  
      }  
    },  
    {  
      "name": "questionnaire",  
      "valueCanonical": "http://example.org/fhir/Questionnaire/home-oxygen-therapy|2.0"  
    },  
    {  
      "name": "order",  
      "resource": {  
        "resourceType": "ServiceRequest",  
        "id": "example-service-request",  
        "status": "active",  
        "intent": "order",  
        "code": {  
          "coding": [{  
            "system": "http://www.ama-assn.org/go/cpt",  
            "code": "94660",  
            "display": "Continuous positive airway pressure ventilation (CPAP)"  
          }]  
        },  
        "subject": {  
          "reference": "Patient/example-patient"  
        }  
      }  
    },  
    {  
      "name": "changedSince",  
      "valueDateTime": "2024-01-01T00:00:00Z"  
    }  
  ]  
}
```

## 回應格式
<a name="questionnaire-package-response-format"></a>

### 成功回應 (200 OK)
<a name="questionnaire-package-success-response"></a>

操作會傳回包含一或多個**套件套件的** FHIR 參數資源。每個套件套件都包含：


| 項目類型 | 基數 | Description | 
| --- | --- | --- | 
| 問卷 | 1 | 要轉譯的問卷 | 
| QuestionnaireResponse | 0..1 | 預先填入或部分完成的回應 （如適用） | 
| Library (程式庫) | 0..\$1 | 包含預先填入和條件式邏輯的 CQL 程式庫 | 
| ValueSet | 0..\$1 | 擴展的 ValueSets （適用於 <40 個擴展的答案選項） | 

**Example 回應範例**  

```
{  
  "resourceType": "Parameters",  
  "parameter": [  
    {  
      "name": "PackageBundle",  
      "resource": {  
        "resourceType": "Bundle",  
        "id": "questionnaire-package-example",  
        "meta": {  
          "profile": ["http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/DTR-QPackageBundle"]  
        },  
        "type": "collection",  
        "timestamp": "2024-03-15T10:30:00Z",  
        "entry": [  
          {  
            "fullUrl": "http://example.org/fhir/Questionnaire/home-oxygen-therapy",  
            "resource": {  
              "resourceType": "Questionnaire",  
              "id": "home-oxygen-therapy",  
              "url": "http://example.org/fhir/Questionnaire/home-oxygen-therapy",  
              "version": "2.0",  
              "status": "active",  
              "title": "Home Oxygen Therapy Documentation",  
              "item": [  
                {  
                  "linkId": "1",  
                  "text": "Patient diagnosis",  
                  "type": "choice",  
                  "answerValueSet": "http://example.org/fhir/ValueSet/oxygen-diagnoses"  
                }  
              ]  
            }  
          },  
          {  
            "fullUrl": "http://example.org/fhir/Library/oxygen-prepopulation",  
            "resource": {  
              "resourceType": "Library",  
              "id": "oxygen-prepopulation",  
              "url": "http://example.org/fhir/Library/oxygen-prepopulation",  
              "version": "1.0",  
              "type": {  
                "coding": [{  
                  "system": "http://terminology.hl7.org/CodeSystem/library-type",  
                  "code": "logic-library"  
                }]  
              },  
              "content": [{  
                "contentType": "text/cql",  
                "data": "bGlicmFyeSBPeHlnZW5QcmVwb3B1bGF0aW9u..."  
              }]  
            }  
          },  
          {  
            "fullUrl": "http://example.org/fhir/ValueSet/oxygen-diagnoses",  
            "resource": {  
              "resourceType": "ValueSet",  
              "id": "oxygen-diagnoses",  
              "url": "http://example.org/fhir/ValueSet/oxygen-diagnoses",  
              "status": "active",  
              "expansion": {  
                "timestamp": "2024-03-15T10:30:00Z",  
                "contains": [  
                  {  
                    "system": "http://hl7.org/fhir/sid/icd-10",  
                    "code": "J44.0",  
                    "display": "COPD with acute lower respiratory infection"  
                  },  
                  {  
                    "system": "http://hl7.org/fhir/sid/icd-10",  
                    "code": "J96.01",  
                    "display": "Acute respiratory failure with hypoxia"  
                  }  
                ]  
              }  
            }  
          },  
          {  
            "fullUrl": "http://example.org/fhir/QuestionnaireResponse/example-prepopulated",  
            "resource": {  
              "resourceType": "QuestionnaireResponse",  
              "id": "example-prepopulated",  
              "questionnaire": "http://example.org/fhir/Questionnaire/home-oxygen-therapy|2.0",  
              "status": "in-progress",  
              "subject": {  
                "reference": "Patient/example-patient"  
              },  
              "basedOn": [{  
                "reference": "ServiceRequest/example-service-request"  
              }],  
              "item": [  
                {  
                  "linkId": "1",  
                  "text": "Patient diagnosis",  
                  "answer": [{  
                    "valueCoding": {  
                      "system": "http://hl7.org/fhir/sid/icd-10",  
                      "code": "J44.0",  
                      "display": "COPD with acute lower respiratory infection"  
                    }  
                  }]  
                }  
              ]  
            }  
          }  
        ]  
      }  
    },  
    {  
      "name": "Outcome",  
      "resource": {  
        "resourceType": "OperationOutcome",  
        "issue": [{  
          "severity": "information",  
          "code": "informational",  
          "details": {  
            "text": "Successfully retrieved questionnaire package"  
          }  
        }]  
      }  
    }  
  ]  
}
```

## 操作工作流程
<a name="questionnaire-package-operation-workflow"></a>

**HealthLake 如何處理您的請求**  
當您呼叫 時`$questionnaire-package`，HealthLake 會執行下列步驟：

1. **識別患者和付款人**：從您的 `coverage` 參數擷取患者和保險組織。

1. **尋找正確的問卷**：
   + **搭配 **`questionnaire`** 參數**：使用您提供的正式 URL
   + **使用 **`order`** 參數**：比對訂單代碼 (CPT/HCPCS/LOINC) 和付款人，以尋找適當的問卷

1. **收集相依性**：自動擷取轉譯問卷所需的一切：
   + **CQL 程式庫** - 預先填入和條件式問題的邏輯
   + **ValueSets** - 答案選項 （如果 <40 個選項，則自動展開）
   + **QuestionnaireResponse** - 任何現有的進行中或已完成的回應

1. **將所有內容一起封裝**：
   + 封裝所有資源 （每個資源僅包含一次）
   + 如果提供，則依`changedSince`時間戳記篩選
   + `Outcome` 如果遺失任何資源，將警告新增至

**結果**：準備進行轉譯的完整、獨立套件。

## 錯誤回應
<a name="questionnaire-package-error-responses"></a>

### 400 錯誤的請求
<a name="questionnaire-package-400-error"></a>

請求驗證失敗時傳回。

```
{  
  "resourceType": "OperationOutcome",  
  "issue": [{  
    "severity": "error",  
    "code": "required",  
    "details": {  
      "text": "At least one of 'questionnaire' or 'order' must be provided along with 'coverage'"  
    }  
  }]  
}
```

### 424 失敗相依性
<a name="questionnaire-package-424-error"></a>

當無法擷取相依資源時傳回。

```
{  
  "resourceType": "OperationOutcome",  
  "issue": [{  
    "severity": "warning",  
    "code": "not-found",  
    "details": {  
      "text": "Referenced Library 'http://example.org/fhir/Library/missing-library' could not be retrieved"  
    }  
  }]  
}
```

### 401 (未經授權)
<a name="questionnaire-package-401-error"></a>

當身分驗證憑證遺失或無效時傳回。

### 403 禁止
<a name="questionnaire-package-403-error"></a>

當已驗證的使用者缺少存取所請求資源的許可時傳回。

### 406 無法接受
<a name="questionnaire-package-406-error"></a>

當無法提供請求的內容類型時傳回。

### 409 衝突
<a name="questionnaire-package-409-error"></a>

發生版本或並行衝突時傳回。

### 410 Gone
<a name="questionnaire-package-410-error"></a>

當請求的資源永久刪除時傳回。

### 429 太多請求
<a name="questionnaire-package-429-error"></a>

超過速率限制時傳回。

### 500 內部伺服器錯誤
<a name="questionnaire-package-500-error"></a>

發生非預期的伺服器錯誤時傳回。

### 501 未實作
<a name="questionnaire-package-501-error"></a>

請求的操作尚未實作時傳回。

## 驗證規則
<a name="questionnaire-package-validation-rules"></a>

### 輸入驗證
<a name="questionnaire-package-input-validation"></a>
+ `coverage` 參數為**必要** (1..\$1 基數）
+ 至少`order`必須提供其中一個 `questionnaire`或
+ 所有涵蓋範圍資源都必須是有效的 FHIR 資源
+ 所有訂單資源必須是有效的 FHIR 資源
+ 正式 URLs 必須正確格式化
+ `changedSince` 必須是有效的 ISO 8601 dateTime

### QuestionnaireResponse驗證
<a name="questionnaire-package-response-validation"></a>
+ `status` 必須適當 (`in-progress`、`completed`、`amended`)
+ 結構必須符合參考的問卷
+ `basedOn` 必須參考有效的訂單資源
+ `subject` 必須參考有效的病患資源

### 資源重複資料刪除
<a name="questionnaire-package-resource-dedup"></a>
+ 每個資源只會在套件中出現一次
+ 例外狀況：可能同時包含相同資源的不同版本
+ 透過其正式 URL 和版本來識別資源

## 效能規格
<a name="questionnaire-package-performance-specs"></a>


| 指標 | 規格 | 
| --- | --- | 
| 資源計數限制 | 每個套件 500 個資源 | 
| 套件大小限制 | 最多 5 MB | 

## 所需的許可
<a name="questionnaire-package-required-permissions"></a>

若要使用 `$questionnaire-package`操作，請確定您的 IAM 角色具有：
+ `healthlake:QuestionnairePackage` - 呼叫 操作
+ `healthlake:ReadResource` - 擷取問卷和相依資源
+ `healthlake:SearchWithPost` - 搜尋 QuestionnaireResponse和相關資源

**FHIR 範圍上的 SMART**  
**所需範圍下限：**
+ **SMART v1**： `user/Questionnaire.read user/Library.read user/ValueSet.read user/QuestionnaireResponse.read`
+ **SMART v2**： `user/Questionnaire.rs user/Library.rs user/ValueSet.rs user/QuestionnaireResponse.rs`

## 重要實作備註
<a name="questionnaire-package-implementation-notes"></a>

### 資源擷取策略
<a name="questionnaire-package-retrieval-strategy"></a>

**問卷識別優先順序：**  

+ **正式 URL **（如果提供`questionnaire`參數） - 最高優先順序
+ **訂單分析** （如果提供 `order` 參數）：
  + 比對訂單代碼 (CPT、HCPCS、LOINC) 與付款人醫療政策
  + 使用涵蓋範圍付款人篩選付款人特定的問卷
  + 考慮其他內容的原因代碼

### 相依性解析
<a name="questionnaire-package-dependency-resolution"></a>

**CQL 程式庫：**  

+ 透過問卷資源上的`cqf-library`擴充功能擷取
+ 透過 `Library.relatedArtifact`類型以遞迴方式擷取相依程式庫 `depends-on`
+ 套件中包含所有程式庫相依性

**ValueSets：**  

+ 如果包含的概念少於 40 個，則自動擴展
+ 包含較大的 ValueSets，無需擴展
+ 包括問卷和程式庫資源中參考ValueSets 

### QuestionnaireResponse預先填入
<a name="questionnaire-package-prepopulation"></a>

下列情況下，操作可能會傳回具有預先填入資料的 QuestionnaireResponse：
+ 找到現有的進行中或已完成的回應
+ 關聯程式庫中的 CQL 邏輯可以從病患記錄擷取資料
+ 回應會連結到相關順序和涵蓋範圍

**QuestionnaireResponse的搜尋條件：**  



| 搜尋參數 | FHIR 路徑 | Description | 
| --- | --- | --- | 
| based-on | QuestionnaireResponse.basedOn | ServiceRequest 或 CarePlan 的連結 | 
| patient | QuestionnaireResponse.subject | 做為主體的患者 | 
| questionnaire | QuestionnaireResponse.questionnaire | 回答的問卷 | 

### 變更資源篩選
<a name="questionnaire-package-changed-filtering"></a>

提供 `changedSince` 參數時：
+ 僅包含指定時間戳記**後**修改的資源
+ 如果沒有變更任何資源， `200 OK` 會以空的套件傳回
+ 適用於增量更新和快取策略
+ 時間戳記比較使用資源`meta.lastUpdated`欄位

### 多個套件套件
<a name="questionnaire-package-multiple-bundles"></a>

下列情況下，操作可能會傳回**多個套件套件**：
+ 透過正式 URLs請求多個問卷
+ 多個訂單需要不同的問卷
+ 相同問卷的不同版本適用

每個套件套件都與所有必要的相依性獨立。

## 常用案例
<a name="questionnaire-package-common-use-cases"></a>

### 使用案例 1：預先授權文件
<a name="questionnaire-package-use-case-1"></a>

**案例**：提供者需要收集家庭供氧治療預先授權的文件。

```
{  
  "resourceType": "Parameters",  
  "parameter": [  
    {  
      "name": "coverage",  
      "resource": { /* Patient's insurance coverage */ }  
    },  
    {  
      "name": "order",  
      "resource": {  
        "resourceType": "ServiceRequest",  
        "code": {  
          "coding": [{  
            "system": "http://www.ama-assn.org/go/cpt",  
            "code": "94660"  
          }]  
        }  
      }  
    }  
  ]  
}
```

**結果**：傳回包含氧氣治療問卷的套件，預先填入來自 EHR 的患者生命值和診斷碼。

### 使用案例 2：擷取特定問卷版本
<a name="questionnaire-package-use-case-2"></a>

**案例**：供應商需要特定版本的問卷才能合規。

```
{  
  "resourceType": "Parameters",  
  "parameter": [  
    {  
      "name": "coverage",  
      "resource": { /* Coverage resource */ }  
    },  
    {  
      "name": "questionnaire",  
      "valueCanonical": "http://example.org/fhir/Questionnaire/dme-request|3.1.0"  
    }  
  ]  
}
```

**結果**：傳回含所有相依性的確切版本 3.1.0 的 DME 請求問卷。

### 使用案例 3：檢查更新
<a name="questionnaire-package-use-case-3"></a>

**案例**：供應商想要檢查自上次擷取以來是否有任何問卷資源已更新。

```
{  
  "resourceType": "Parameters",  
  "parameter": [  
    {  
      "name": "coverage",  
      "resource": { /* Coverage resource */ }  
    },  
    {  
      "name": "questionnaire",  
      "valueCanonical": "http://example.org/fhir/Questionnaire/medication-request"  
    },  
    {  
      "name": "changedSince",  
      "valueDateTime": "2024-03-01T00:00:00Z"  
    }  
  ]  
}
```

**結果**：僅傳回在 2024 年 3 月 1 日之後修改的資源，如果沒有變更，則傳回空白套件。

### 使用案例 4：多個訂單
<a name="questionnaire-package-use-case-4"></a>

**案例**：供應商提交多個可能需要不同問卷的服務請求。

```
{  
  "resourceType": "Parameters",  
  "parameter": [  
    {  
      "name": "coverage",  
      "resource": { /* Coverage resource */ }  
    },  
    {  
      "name": "order",  
      "resource": { /* ServiceRequest for imaging */ }  
    },  
    {  
      "name": "order",  
      "resource": { /* ServiceRequest for DME */ }  
    }  
  ]  
}
```

**結果**：傳回多個套件套件，每個適用的問卷各一個。

## 與其他 Da Vinci IGs整合
<a name="questionnaire-package-integration"></a>

### 涵蓋範圍需求探索 (CRD)
<a name="questionnaire-package-crd-integration"></a>

**工作流程整合：**  

+ 供應商在其 EHR 中訂購服務
+ CRD 勾點觸發，檢查涵蓋範圍需求
+ 付款人回應，指出需要文件
+ 供應商呼叫 `$questionnaire-package` 以擷取文件表單
+ 供應商完成問卷
+ 文件是透過 PAS 或 CDex 提交

### 預先授權支援 (PAS)
<a name="questionnaire-package-pas-integration"></a>

**工作流程整合：**  

+ 使用 `$questionnaire-package` 擷取文件需求
+ 使用所需的臨床資料完成 QuestionnaireResponse 
+ 使用 `Claim/$submit`搭配已完成的 QuestionnaireResponse提交預先授權
+ 使用 檢查狀態 `Claim/$inquire`

### 臨床資料交換 (CDex)
<a name="questionnaire-package-cdex-integration"></a>

**工作流程整合：**  

+ 付款人請求申請其他文件
+ 提供者使用 `$questionnaire-package` 擷取結構化資料收集表單
+ 供應商完成 QuestionnaireResponse
+ 文件會透過 CDex 連接工作流程提交給付款人

## 故障診斷指南
<a name="questionnaire-package-troubleshooting"></a>

### 問題：未傳回問卷
<a name="questionnaire-package-no-questionnaire"></a>

**可能的原因：**  

+ 正式 URL 不符合資料存放區中的任何問卷
+ 訂單代碼未對應至付款人醫療政策中的任何問卷
+ 涵蓋範圍付款人沒有相關聯的問卷

**解決方案：**  

+ 確認正式 URL 正確且問卷存在
+ 檢查訂單代碼 (CPT/HCPCS) 是否正確指定
+ 確認付款人組織已設定問卷

### 問題：套件中缺少相依性
<a name="questionnaire-package-missing-dependencies"></a>

**可能的原因：**  

+ 參考的程式庫或 ValueSet 不存在於資料存放區中
+ 程式庫參考已中斷或不正確
+ ValueSet 擴展失敗

**解決方案：**  

+ 檢查 `Outcome` 參數是否有資源遺失的相關警告
+ 驗證資料存放區中存在所有參考的資源
+ 確保 ValueSet URLs正確且可解決

### 問題：含 changedSince 的空套件
<a name="questionnaire-package-empty-package"></a>

**可能的原因：**  

+ 這是預期的行為 - 自指定的時間戳記以來未修改任何資源

**解決方案：**  

+ 使用套件的快取版本
+ 移除`changedSince`參數以擷取完整套件

### 問題：未預先填入 QuestionnaireResponse
<a name="questionnaire-package-not-prepopulated"></a>

**可能的原因：**  

+ 找不到現有的 QuestionnaireResponse 
+ CQL Library 邏輯無法擷取所需的資料
+ 病患資料遺失或不完整

**解決方案：**  

+ 這可能是預期的 - 並非所有問卷都有預先填入邏輯
+ 檢查資料存放區中是否存在病患資料
+ 檢閱 CQL Library 邏輯以了解資料擷取需求

## 最佳實務
<a name="questionnaire-package-best-practices"></a>

### 1. 搭配版本使用正式 URLs
<a name="questionnaire-package-bp-versions"></a>

請求特定問卷時，請務必指定版本編號：

```
{  
  "name": "questionnaire",  
  "valueCanonical": "http://example.org/fhir/Questionnaire/dme|2.1.0"  
}
```

**原因**：確保一致性，並防止更新問卷時的意外變更。

### 2. 利用 changedSince for Performance
<a name="questionnaire-package-bp-changed-since"></a>

對於經常存取的問卷，請使用 `changedSince` 將資料傳輸降至最低：

```
{  
  "name": "changedSince",  
  "valueDateTime": "2024-03-10T15:30:00Z"  
}
```

**原因**：僅擷取更新的資源，以減少延遲和頻寬使用量。

### 3. 包含完整涵蓋範圍資訊
<a name="questionnaire-package-bp-coverage"></a>

提供全面的涵蓋範圍詳細資訊，以確保正確的問卷選擇：

```
{  
  "name": "coverage",  
  "resource": {  
    "resourceType": "Coverage",  
    "beneficiary": { "reference": "Patient/123" },  
    "payor": [{ "reference": "Organization/payer-abc" }],  
    "class": [{ /* Group/plan information */ }]  
  }  
}
```

**原因**：協助 HealthLake 識別付款人特定的問卷和要求。

## 相關的 操作
<a name="questionnaire-package-related-operations"></a>
+ `Claim/$submit` - 提交包含已完成文件的預先授權請求
+ `Claim/$inquire` - 檢查提交的預先授權狀態
+ `ValueSet/$expand` - 展開用於答案選項的 ValueSets 

# HealthLake 的 FHIR `$submit`操作
<a name="reference-fhir-operations-submit"></a>

`$submit` 此操作可讓您以電子方式提交預先授權請求給付款人以進行核准。此操作實作 [Da Vinci 預先授權支援 (PAS) 實作指南](https://hl7.org/fhir/us/davinci-pas/)，為預先授權提交提供標準化的 FHIR 工作流程。

## 運作方式
<a name="submit-how-it-works"></a>
+ **提交**：您傳送 FHIR 套件，其中包含您的預先授權請求和支援的臨床資料
+ **驗證**：HealthLake 會根據 PAS 要求驗證提交
+ **持久**性：所有資源都存放在 HealthLake 資料存放區中
+ **回應**：您立即收到「佇列」狀態的回應
+ **程序**：由付款人非同步處理授權決策

## API 端點
<a name="submit-api-endpoint"></a>

```
POST /datastore/{datastoreId}/r4/Claim/$submit  
Content-Type: application/fhir+json
```

## 請求結構
<a name="submit-request-structure"></a>

### 套件需求
<a name="submit-bundle-requirements"></a>

您的請求必須是具有下列項目的 FHIR 套件資源：
+ **Bundle.type**：必須為 `"collection"`
+ **Bundle.entry**：必須包含**一個**具有 的宣告資源 `use = "preauthorization"`
+ **參考資源**： 宣告參考的所有資源必須包含在套件中

### 必要的資源
<a name="submit-required-resources"></a>


| 資源 | 基數 | 設定檔 | Description | 
| --- | --- | --- | --- | 
| 宣告 | 1 | PAS 宣告 | 預先授權請求 | 
| 病患 | 1 | PAS 病患 | 病患人口統計資訊 | 
| Organization （保險業者） | 1 | PAS Insurer | 保險公司 | 
| Organization （提供者） | 1 | PAS 請求者 | 提交請求的醫療保健供應商 | 
| 涵蓋範圍 | 1 個或多個 | PAS 涵蓋範圍 | 保險涵蓋範圍詳細資訊 | 

### 選用資源
<a name="submit-optional-resources"></a>


| 資源 | 基數 | 設定檔 | Description | 
| --- | --- | --- | --- | 
| 從業人員 | 0 或以上 | PAS 從業人員 | 醫療保健從業人員 | 
| PractitionerRole | 0 或以上 | PAS PractitionerRole | 從業人員角色 | 
| ServiceRequest | 0 或以上 | PAS ServiceRequest | 請求的醫療保健 | 
| DeviceRequest | 0 或以上 | PAS DeviceRequest | 請求的醫療設備 | 
| MedicationRequest | 0 或以上 | PAS MedicationRequest | 請求的藥品 | 
| DocumentReference | 0 或以上 | PAS DocumentReference | 支援臨床文件 | 

## 範例請求
<a name="submit-example-request"></a>

```
POST /datastore/example-datastore/r4/Claim/$submit  
Content-Type: application/fhir+json  
Authorization: Bearer <your-token>  
  
{  
  "resourceType" : "Bundle",  
  "id" : "MedicalServicesAuthorizationBundleExample",  
  "meta" : {  
    "profile" : ["http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-pas-request-bundle"]  
  },  
  "identifier" : {  
    "system" : "http://example.org/SUBMITTER_TRANSACTION_IDENTIFIER",  
    "value" : "5269367"  
  },  
  "type" : "collection",  
  "timestamp" : "2005-05-02T11:01:00+05:00",  
  "entry" : [{  
    "fullUrl" : "http://example.org/fhir/Claim/MedicalServicesAuthorizationExample",  
    "resource" : {  
      "resourceType" : "Claim",  
      "id" : "MedicalServicesAuthorizationExample",  
      "meta" : {  
        "profile" : ["http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-claim"]  
      },  
      "identifier" : [{  
        "system" : "http://example.org/PATIENT_EVENT_TRACE_NUMBER",  
        "value" : "111099"   
      }],  
      "status" : "active",  
      "type" : {  
        "coding" : [{  
          "system" : "http://terminology.hl7.org/CodeSystem/claim-type",  
          "code" : "professional"  
        }]  
      },  
      "use" : "preauthorization",  
      "patient" : {  
        "reference" : "Patient/SubscriberExample"  
      },  
      "created" : "2005-05-02T11:01:00+05:00",  
      "insurer" : {  
        "reference" : "Organization/InsurerExample"  
      },  
      "provider" : {  
        "reference" : "Organization/UMOExample"  
      },  
      "priority" : {  
        "coding" : [{  
          "system" : "http://terminology.hl7.org/CodeSystem/processpriority",  
          "code" : "normal"  
        }]  
      },  
      "insurance" : [{  
        "sequence" : 1,  
        "focal" : true,  
        "coverage" : {  
          "reference" : "Coverage/InsuranceExample"  
        }  
      }],  
      "item" : [{  
        "extension" : [{  
          "url" : "http://hl7.org/fhir/us/davinci-pas/StructureDefinition/extension-serviceItemRequestType",  
          "valueCodeableConcept" : {  
            "coding" : [{  
              "system" : "https://codesystem.x12.org/005010/1525",  
              "code" : "IN",  
              "display" : "Initial Medical Services Reservation"  
            }]  
          }  
        },  
        {  
          "url" : "http://hl7.org/fhir/us/davinci-pas/StructureDefinition/extension-certificationType",  
          "valueCodeableConcept" : {  
            "coding" : [{  
              "system" : "https://codesystem.x12.org/005010/1322",  
              "code" : "I",  
              "display" : "Initial"  
            }]  
          }  
        },  
        {  
          "url" : "http://hl7.org/fhir/us/davinci-pas/StructureDefinition/extension-authorizationNumber",  
          "valueString" : "1122344"  
        },  
        {  
          "url" : "http://hl7.org/fhir/us/davinci-pas/StructureDefinition/extension-administrationReferenceNumber",  
          "valueString" : "33441122"  
        }],  
        "sequence" : 1,  
        "category" : {  
          "coding" : [{  
            "system" : "https://codesystem.x12.org/005010/1365",  
            "code" : "1",  
            "display" : "Medical Care"  
          }]  
        },  
        "productOrService" : {  
          "coding" : [{  
            "system" : "http://www.cms.gov/Medicare/Coding/HCPCS​ReleaseCodeSets",  
            "code" : "99212",  
            "display" : "Established Office Visit"  
          }]  
        },  
        "servicedDate" : "2005-05-10",  
        "locationCodeableConcept" : {  
          "coding" : [{  
            "system" : "https://www.cms.gov/Medicare/Coding/place-of-service-codes/Place_of_Service_Code_Set",  
            "code" : "11"  
          }]  
        }  
      }]  
    }  
  },  
  {  
    "fullUrl" : "http://example.org/fhir/Organization/UMOExample",  
    "resource" : {  
      "resourceType" : "Organization",  
      "id" : "UMOExample",  
      "meta" : {  
        "profile" : ["http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-requestor"]  
      },  
      "identifier" : [{  
        "system" : "http://hl7.org/fhir/sid/us-npi",  
        "value" : "8189991234"  
      }],  
      "active" : true,  
      "type" : [{  
        "coding" : [{  
          "system" : "https://codesystem.x12.org/005010/98",  
          "code" : "X3"  
        }]  
      }],  
      "name" : "DR. JOE SMITH CORPORATION",  
      "address" : [{  
        "line" : ["111 1ST STREET"],  
        "city" : "SAN DIEGO",  
        "state" : "CA",  
        "postalCode" : "92101",  
        "country" : "US"  
      }]  
    }  
  },  
  {  
    "fullUrl" : "http://example.org/fhir/Organization/InsurerExample",  
    "resource" : {  
      "resourceType" : "Organization",  
      "id" : "InsurerExample",  
      "meta" : {  
        "profile" : ["http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-insurer"]  
      },  
      "identifier" : [{  
        "system" : "http://hl7.org/fhir/sid/us-npi",  
        "value" : "1234567893"  
      }],  
      "active" : true,  
      "type" : [{  
        "coding" : [{  
          "system" : "https://codesystem.x12.org/005010/98",  
          "code" : "PR"  
        }]  
      }],  
      "name" : "MARYLAND CAPITAL INSURANCE COMPANY"  
    }  
  },  
  {  
    "fullUrl" : "http://example.org/fhir/Coverage/InsuranceExample",  
    "resource" : {  
      "resourceType" : "Coverage",  
      "id" : "InsuranceExample",  
      "meta" : {  
        "profile" : ["http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-coverage"]  
      },  
      "status" : "active",  
      "subscriberId" : "1122334455",  
      "beneficiary" : {  
        "reference" : "Patient/SubscriberExample"  
      },  
      "relationship" : {  
        "coding" : [{  
          "system" : "http://terminology.hl7.org/CodeSystem/subscriber-relationship",  
          "code" : "self"  
        },  
        {  
          "system" : "https://codesystem.x12.org/005010/1069",  
          "code" : "18"  
        }]  
      },  
      "payor" : [{  
        "reference" : "Organization/InsurerExample"  
      }]  
    }  
  },  
  {  
    "fullUrl" : "http://example.org/fhir/Patient/SubscriberExample",  
    "resource" : {  
      "resourceType" : "Patient",  
      "id" : "SubscriberExample",  
      "meta" : {  
        "profile" : ["http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-subscriber"]  
      },  
      "extension" : [{  
        "url" : "http://hl7.org/fhir/us/davinci-pas/StructureDefinition/extension-militaryStatus",  
        "valueCodeableConcept" : {  
          "coding" : [{  
            "system" : "https://codesystem.x12.org/005010/584",  
            "code" : "RU"  
          }]  
        }  
      }],  
      "identifier" : [{  
        "type" : {  
          "coding" : [{  
            "system" : "http://terminology.hl7.org/CodeSystem/v2-0203",  
            "code" : "MB"  
          }]  
        },  
        "system" : "http://example.org/MIN",  
        "value" : "12345678901"  
      }],  
      "name" : [{  
        "family" : "SMITH",  
        "given" : ["JOE"]  
      }],  
      "gender" : "male"  
    }  
  }]  
}
```

## 回應格式
<a name="submit-response-format"></a>

### 成功回應 (200 OK)
<a name="submit-success-response"></a>

您將會收到 PAS 回應套件，其中包含：
+ 使用 `outcome: "queued"`和 的 **ClaimResponse** `status: "active"`
+ 請求中的所有原始資源
+ 確認接收的時間戳記

```
{  
  "resourceType" : "Bundle",  
  "identifier": {  
        "system": "http://example.org/SUBMITTER_TRANSACTION_IDENTIFIER",  
        "value": "5269367"  
  },  
  "type" : "collection",  
  "timestamp" : "2005-05-02T11:02:00+05:00",  
  "entry" : [{  
    "fullUrl" : "http://example.org/fhir/ClaimResponse/PractitionerRequestorPendingResponseExample",  
    "resource" : {  
      "resourceType" : "ClaimResponse",  
      "id" : "PractitionerRequestorPendingResponseExample",  
      "meta" : {  
        "profile" : ["http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-claimresponse"]  
      },  
      "identifier" : [{  
        "system" : "http://example.org/PATIENT_EVENT_TRACE_NUMBER",  
        "value" : "111099"  
      }],  
      "status" : "active",  
      "type" : {  
        "coding" : [{  
          "system" : "http://terminology.hl7.org/CodeSystem/claim-type",  
          "code" : "professional"  
        }]  
      },  
      "use" : "preauthorization",  
      "patient" : {  
        "reference" : "Patient/SubscriberExample"  
      },  
      "created" : "2005-05-02T11:02:00+05:00",  
      "insurer" : {  
        "reference" : "Organization/InsurerExample"  
      },  
      "requestor" : {  
        "reference" : "PractitionerRole/ReferralPractitionerRoleExample"  
      },  
      "request" : {  
        "reference" : "Claim/MedicalServicesAuthorizationExample"  
      },  
      "outcome" : "queued"  
    }  
  },  
  {  
    "fullUrl" : "http://example.org/fhir/Claim/MedicalServicesAuthorizationExample",  
    "resource" : {  
      "resourceType" : "Claim",  
      "id" : "MedicalServicesAuthorizationExample",  
      "meta" : {  
        "profile": [  
            "http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-claim",  
            "http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-claim|2.1.0"  
        ]  
      },  
      "identifier" : [{  
        "system" : "http://example.org/PATIENT_EVENT_TRACE_NUMBER",  
        "value" : "111099"  
        }  
      }],  
      "status" : "active",  
      "type" : {  
        "coding" : [{  
          "system" : "http://terminology.hl7.org/CodeSystem/claim-type",  
          "code" : "professional"  
        }]  
      },  
      "use" : "preauthorization",  
      "patient" : {  
        "reference" : "Patient/SubscriberExample"  
      },  
      "created" : "2005-05-02T11:01:00+05:00",  
      "insurer" : {  
        "reference" : "Organization/InsurerExample"  
      },  
      "provider" : {  
        "reference" : "Organization/UMOExample"  
      },  
      "priority" : {  
        "coding" : [{  
          "system" : "http://terminology.hl7.org/CodeSystem/processpriority",  
          "code" : "normal"  
        }]  
      },  
      "insurance" : [{  
        "sequence" : 1,  
        "focal" : true,  
        "coverage" : {  
          "reference" : "Coverage/InsuranceExample"  
        }  
      }],  
      "item" : [{  
        "extension" : [{  
          "url" : "http://hl7.org/fhir/us/davinci-pas/StructureDefinition/extension-serviceItemRequestType",  
          "valueCodeableConcept" : {  
            "coding" : [{  
              "system" : "https://codesystem.x12.org/005010/1525",  
              "code" : "IN",  
              "display" : "Initial Medical Services Reservation"  
            }]  
          }  
        },  
        {  
          "url" : "http://hl7.org/fhir/us/davinci-pas/StructureDefinition/extension-certificationType",  
          "valueCodeableConcept" : {  
            "coding" : [{  
              "system" : "https://codesystem.x12.org/005010/1322",  
              "code" : "I",  
              "display" : "Initial"  
            }]  
          }  
        },  
        {  
          "url" : "http://hl7.org/fhir/us/davinci-pas/StructureDefinition/extension-authorizationNumber",  
          "valueString" : "1122344"  
        },  
        {  
          "url" : "http://hl7.org/fhir/us/davinci-pas/StructureDefinition/extension-administrationReferenceNumber",  
          "valueString" : "33441122"  
        }],  
        "sequence" : 1,  
        "category" : {  
          "coding" : [{  
            "system" : "https://codesystem.x12.org/005010/1365",  
            "code" : "1",  
            "display" : "Medical Care"  
          }]  
        },  
        "productOrService" : {  
          "coding" : [{  
            "system" : "http://www.cms.gov/Medicare/Coding/HCPCS​ReleaseCodeSets",  
            "code" : "99212",  
            "display" : "Established Office Visit"  
          }]  
        },  
        "servicedDate" : "2005-05-10",  
        "locationCodeableConcept" : {  
          "coding" : [{  
            "system" : "https://www.cms.gov/Medicare/Coding/place-of-service-codes/Place_of_Service_Code_Set",  
            "code" : "11"  
          }]  
        }  
      }]  
    }  
  },  
  {  
    "fullUrl" : "http://example.org/fhir/Organization/UMOExample",  
    "resource" : {  
      "resourceType" : "Organization",  
      "id" : "UMOExample",  
      "meta" : {  
        "profile": [  
            "http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-requestor",  
            "http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-requestor|2.1.0"  
        ]  
      },  
      "identifier" : [{  
        "system" : "http://hl7.org/fhir/sid/us-npi",  
        "value" : "8189991234"  
      }],  
      "active" : true,  
      "type" : [{  
        "coding" : [{  
          "system" : "https://codesystem.x12.org/005010/98",  
          "code" : "X3"  
        }]  
      }],  
      "name" : "DR. JOE SMITH CORPORATION",  
      "address" : [{  
        "line" : ["111 1ST STREET"],  
        "city" : "SAN DIEGO",  
        "state" : "CA",  
        "postalCode" : "92101",  
        "country" : "US"  
      }]  
    }  
  },  
  {  
    "fullUrl" : "http://example.org/fhir/Organization/InsurerExample",  
    "resource" : {  
      "resourceType" : "Organization",  
      "id" : "InsurerExample",  
      "meta" : {  
           "profile": [  
                "http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-insurer",  
                "http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-insurer|2.1.0"  
            ]  
      },  
      "identifier" : [{  
        "system" : "http://hl7.org/fhir/sid/us-npi",  
        "value" : "1234567893"  
      }],  
      "active" : true,  
      "type" : [{  
        "coding" : [{  
          "system" : "https://codesystem.x12.org/005010/98",  
          "code" : "PR"  
        }]  
      }],  
      "name" : "MARYLAND CAPITAL INSURANCE COMPANY"  
    }  
  },  
  {  
    "fullUrl" : "http://example.org/fhir/Coverage/InsuranceExample",  
    "resource" : {  
      "resourceType" : "Coverage",  
      "id" : "InsuranceExample",  
      "meta": {  
            "profile": [  
                "http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-coverage",  
                "http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-coverage|2.1.0"  
            ]  
        },  
      "status" : "active",  
      "subscriberId" : "1122334455",  
      "beneficiary" : {  
        "reference" : "Patient/SubscriberExample"  
      },  
      "relationship" : {  
        "coding" : [{  
          "system" : "http://terminology.hl7.org/CodeSystem/subscriber-relationship",  
          "code" : "self"  
        },  
        {  
          "system" : "https://codesystem.x12.org/005010/1069",  
          "code" : "18"  
        }]  
      },  
      "payor" : [{  
        "reference" : "Organization/InsurerExample"  
      }]  
    }  
  },  
  {  
    "fullUrl" : "http://example.org/fhir/Patient/SubscriberExample",  
    "resource" : {  
      "resourceType" : "Patient",  
      "id" : "SubscriberExample",  
      "meta": {  
            "profile": [  
                "http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-subscriber",  
                "http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-beneficiary",  
                "http://hl7.org/fhir/us/davinci-pas/StructureDefinition/profile-beneficiary|2.1.0"  
            ]  
        },  
      "extension" : [{  
        "url" : "http://hl7.org/fhir/us/davinci-pas/StructureDefinition/extension-militaryStatus",  
        "valueCodeableConcept" : {  
          "coding" : [{  
            "system" : "https://codesystem.x12.org/005010/584",  
            "code" : "RU"  
          }]  
        }  
      }],  
      "identifier" : [{  
        "type" : {  
          "coding" : [{  
            "system" : "http://terminology.hl7.org/CodeSystem/v2-0203",  
            "code" : "MB"  
          }]  
        },  
        "system" : "http://example.org/MIN",  
        "value" : "12345678901"  
      }],  
      "name" : [{  
        "family" : "SMITH",  
        "given" : ["JOE"]  
      }],  
      "gender" : "male"  
    }  
  }]  
}
```

## 錯誤回應
<a name="submit-error-responses"></a>

### 400 錯誤的請求
<a name="submit-400-error"></a>

當請求格式無效或格式不正確時傳回。

```
{  
  "resourceType": "OperationOutcome",  
  "issue": [{  
    "severity": "error",  
    "code": "invalid",  
    "diagnostics": "The provided payload was invalid and could not be parsed correctly."  
  }]  
}
```

### 412 先決條件失敗
<a name="submit-412-error"></a>

已提交相同的預先授權請求時傳回 （偵測到重複提交）。

```
{  
  "resourceType": "OperationOutcome",  
  "issue": [{  
    "severity": "error",  
    "code": "processing",  
    "diagnostics": "PreAuth Claim already exists"  
  }]  
}
```

**冪等性**  
`$submit` 操作是等冪的。多次提交相同的請求不會建立重複的預先授權請求。反之，您會收到 412 錯誤，指示您使用 `$inquire`來檢查原始提交的狀態。

### 422 無法處理的實體
<a name="submit-422-error"></a>

FHIR 驗證失敗時傳回。

```
{  
  "resourceType": "OperationOutcome",  
  "issue": [{  
    "severity": "error",  
    "code": "required",  
    "diagnostics": "Bundle contains more than one preauthorization claim"  
  }]  
}
```

## 驗證規則
<a name="submit-validation-rules"></a>

HealthLake 會對您的提交執行全面的驗證：

### 套件驗證
<a name="submit-bundle-validation"></a>
+ 必須符合 PAS 請求套件描述檔
+ `Bundle.type` 必須 `"collection"`
+ 可以包含多個宣告資源
+ 不過， 必須包含一個具有預先授權使用的宣告資源
  + 此宣告資源必須是套件中的第一個項目
+ 套件中必須包含所有參考的資源

### 宣告驗證
<a name="submit-claim-validation"></a>
+ 必須符合 PAS 宣告描述檔
+ `Claim.use` 必須 `"preauthorization"`
+ 必要欄位：`patient`、`insurer`、`provider`、`created`、 `priority`
+ 業務識別符必須存在且有效

### 資源驗證
<a name="submit-resource-validation"></a>
+ 所有資源必須符合其各自的 PAS 設定檔
+ 必要的支援資源必須存在 （病患、涵蓋範圍、組織）
+ 交互參考在套件中必須是有效且可解析的

## 效能規格
<a name="submit-performance-specs"></a>


| 指標 | 規格 | 
| --- | --- | 
| 套件大小限制 | 最多 5 MB | 
| 資源計數限制 | 每個套件 500 個資源 | 

## 所需的許可
<a name="submit-required-permissions"></a>

若要使用 `$submit`操作，使用者可以在 FHIR 上使用 AWS Sigv4 或 SMART：
+ 確保您的 IAM 角色具有：`healthlake:SubmitPreAuthClaim`- 呼叫 操作

**FHIR 範圍上的 SMART**  
**所需範圍下限：**
+ **SMART v1**： `user/Claim.write & <all_resourceTypes_in_Bundle>.write`
+ **SMART v2**： `user/Claim.c & <all_resourceTypes_in_Bundle>.c or system/*.*`

## 重要實作備註
<a name="submit-implementation-notes"></a>

### 資源持久性
<a name="submit-resource-persistence"></a>
+ 所有套件項目都會保留為資料存放區中的個別 FHIR 資源
+ 客戶提供IDs 會在提供時保留
+ 維護版本歷史記錄以供稽核之用
+ 重複偵測可防止資源衝突

### 處理行為
<a name="submit-processing-behavior"></a>
+ 每個有效的提交只會產生一個 ClaimResponse `"queued"`結果
+ 無效提交會傳回 400 或 422 狀態碼，其中包含詳細的錯誤資訊
+ 系統錯誤會傳回適當的 5xx 狀態碼
+ 所有成功的提交都會傳回 200 狀態與待定的 ClaimResponse

### 套件需求
<a name="submit-bundle-requirements-impl"></a>
+ `Bundle.entry.fullUrl` 值必須是 REST URLs或`"urn:uuid:[guid]"`格式
+ 所有 GUIDs提交之間必須是唯一的 （相同資源執行個體除外）
+ 參考的資源必須存在於套件中或可解析

## 相關的 操作
<a name="submit-related-operations"></a>
+ `Claim/$inquire` - 查詢提交的預先授權請求的狀態
+ `Patient/$everything` - 針對預先授權內容擷取完整的患者資料

# 使用 驗證 FHIR 資源 `$validate`
<a name="reference-fhir-operations-validate"></a>

AWS HealthLake 現在支援 FHIR 資源`$validate`的操作，可讓您根據 FHIR 規格驗證資源，並檢查其是否符合指定的設定檔或基本資源定義，而無需執行任何儲存操作。當您需要：
+ 驗證 FHIR CMS 合規要求
+ 在生產環境中使用資源之前進行測試
+ 在使用者編輯臨床資料時提供即時驗證意見回饋
+ 減少無效的資料提交以建立和更新 APIs

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

您可以使用 POST 方法在 FHIR 資源上叫用 `$validate`操作：

**受支援的 操作**  


```
POST [base]/[type]/[id]/$validate
POST [base]/[type]/$validate
```

## 支援的承載
<a name="validate-payloads"></a>

**參數資源**  


HealthLake 支援下列 FHIR `$validate` 參數：


| 參數 | Type | 必要 | Description | 
| --- | --- | --- | --- | 
| resource | 資源 | 是 | 要驗證的資源 | 
| profile | 正式 | 否 | 要驗證之設定檔的正式 URL | 
| mode | code | 否 | 驗證模式： create或 update | 

**具有查詢參數的直接資源**  



| 參數 | Type | 必要 | Description | 
| --- | --- | --- | --- | 
| profile | 正式 | 否 | 要驗證之設定檔的正式 URL | 
| mode | code | 否 | 驗證模式： create或 update | 

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

**具有 ID 和參數承載之資源的 POST 請求**  


```
POST [base]/Patient/example-patient/$validate
Content-Type: application/fhir+json

{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "resource",
      "resource": {
        "resourceType": "Patient",
        "id": "example-patient",
        "name": [
          {
            "family": "Smith",
            "given": ["John"]
          }
        ],
        "gender": "male",
        "birthDate": "1990-01-01"
      }
    },
    {
      "name": "profile",
      "valueCanonical": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient"
    },
    {
      "name": "mode",
      "valueString": "create"
    }
  ]
}
```

**資源類型和參數承載的 POST 請求**  


```
POST [base]/Patient/$validate
Content-Type: application/fhir+json

{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "resource",
      "resource": {
        "resourceType": "Patient",
        "name": [
          {
            "family": "Doe",
            "given": ["Jane"]
          }
        ],
        "gender": "female",
        "birthDate": "1985-05-15"
      }
    },
    {
      "name": "profile",
      "valueCanonical": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient"
    },
    {
      "name": "mode",
      "valueString": "update"
    }
  ]
}
```

**具有 ID 和直接資源承載的資源 POST 請求**  


```
POST [base]/Patient/example-patient/$validate?profile=http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient&mode=create
Content-Type: application/fhir+json

{
    "resourceType": "Patient",
    "id": "example-patient",
    "name": [
        {
        "family": "Smith",
        "given": ["John"]
        }
    ],
    "gender": "male",
    "birthDate": "1990-01-01"
}
```

**資源類型和直接資源承載的 POST 請求**  


```
POST [base]/Patient/$validate?profile=http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient&mode=create
Content-Type: application/fhir+json

{
    "resourceType": "Patient",
    "id": "example-patient",
    "name": [
        {
        "family": "Smith",
        "given": ["John"]
        }
    ],
    "gender": "male",
    "birthDate": "1990-01-01"
}
```

**回應範例**  
操作會傳回具有驗證結果的 OperationOutcome 資源：

```
{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "information",
      "code": "informational",
      "diagnostics": "Validation successful"
    }
  ]
}
```

**驗證錯誤的回應範例**  


```
{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "error",
      "code": "required",
      "details": {
        "text": "Missing required element"
      },
      "diagnostics": "Patient.identifier is required by the US Core Patient profile",
      "location": [
        "Patient.identifier"
      ]
    },
    {
      "severity": "warning",
      "code": "code-invalid",
      "details": {
        "text": "Invalid code value"
      },
      "diagnostics": "The provided gender code is not from the required value set",
      "location": [
        "Patient.gender"
      ]
    }
  ]
}
```

## Behavior (行為)
<a name="validate-behavior"></a>

`$validate` 操作：

1. 根據 FHIR 規格和基本資源定義驗證資源

1. 提供 `profile` 參數時，檢查是否符合指定的設定檔

1. 根據指定的模式進行驗證 (`create` 或 `update`)

1. 傳回詳細的驗證結果，包括錯誤、警告和資訊性訊息

1. 不執行任何儲存操作 - 僅驗證

1. 在可執行驗證時傳回 HTTP 200 OK，無論是否發現驗證問題

## 驗證模式
<a name="validate-modes"></a>
+ **create**：將資源驗證為正在建立 （新資源）
+ **更新**：將資源驗證為正在更新 （現有資源）

## 錯誤處理
<a name="validate-error-handling"></a>

操作會傳回：
+ 200 OK：已成功執行驗證 （無論驗證結果為何）
+ 400 錯誤的請求：無效的請求格式或參數
+ 找不到 404：找不到資源類型或設定檔

如需 `$validate`操作規格的詳細資訊，請參閱 [FHIR R4 資源`$validate`](https://www.hl7.org/fhir/R4/operation-resource-validate.html)文件。