

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

# AWS HealthScribe
<a name="health-scribe"></a>

 AWS HealthScribe 是一種符合 HIPAA 資格的機器學習 (ML) 功能，結合了語音辨識和生成式 AI，可轉錄患者與臨床醫生對話並產生easy-to-review的臨床備註。 AWS HealthScribe 可協助醫療保健軟體供應商建置臨床應用程式，以減少文件負擔並改善諮詢體驗。此服務會自動提供豐富的對話文字記錄、識別發言者角色、分類對話、擷取醫學術語，並產生初步臨床備註。 AWS HealthScribe 結合這些功能，無需整合和最佳化個別 AI 服務，讓您加速實作。

常用案例：
+ **縮短文件時間** — 讓臨床醫生能夠使用 AI 生成式的臨床筆記快速完成臨床文件，這些筆記方便在您的應用程式中檢閱、調整和完成。
+ **提高醫療抄寫員效率** — 為醫療抄寫員提供 AI 生成式的文字記錄和臨床筆記以及諮詢音訊，以加快文件的準備時間。
+ **有效率的患者門診回憶** — 建立體驗，讓使用者可以在您的應用程式中快速回憶對話的重點。

**重要**  
 AWS HealthScribe 產生的結果很概率，可能不一定會因為各種因素而準確， 包括音訊品質、 背景雜訊、 發言者清晰度、 醫學術語的複雜性、 內容特定的語言細微差別、 和[機器學習和生成式 AI 的性質](https://aws.amazon.com/machine-learning/responsible-ai/policy/)。 AWS HealthScribe 旨在用於臨床醫生和醫學骨架的輔助角色。 AWS HealthScribe 輸出應僅用於患者護理案例， 包括 但不限於 做為電子運作狀態記錄的一部分， 經過訓練的醫療專業人員審核後，醫療判斷的準確性和實施。 AWS HealthScribe 輸出不能取代專業醫療建議， 診斷、 或處理方式 和 並非旨在修復、 處理、 緩解、 防止、 或診斷任何疾病或健康狀況。

**Topics**
+ [安全](#health-scribe-security-overview)
+ [服務可用性](#health-scribe-availability)
+ [技術需求](#health-scribe-tech-requirements-overview)
+ [支援的醫療專科](#health-scribe-specialties)
+ [工作流程](#health-scribe-workflows)
+ [AWS HealthScribe 文字記錄檔案](health-scribe-transcript.md)
+ [AWS HealthScribe 臨床文件檔案](health-scribe-insights.md)
+ [AWS HealthScribe 轉錄任務](health-scribe-job.md)
+ [AWS HealthScribe 串流](health-scribe-streaming.md)
+ [for AWS HealthScribe 靜態資料加密](health-scribe-encryption.md)

## 安全
<a name="health-scribe-security-overview"></a>

AWS HealthScribe 在共同的責任模型下運作，因此 AWS 負責保護執行 AWS HealthScribe 的基礎設施，而且您負責管理您的資料。若要了解詳細資訊，請參閱 [ 共同責任模型](https://aws.amazon.com/compliance/shared-responsibility-model/)。

 根據預設， AWS HealthScribe 提供靜態加密，以保護使用 Amazon S3受管金鑰的敏感客戶資料。當您建立 AWS HealthScribe 轉錄任務或啟動串流時，您可以指定客戶受管金鑰。這會新增第二層加密。如需詳細資訊，請參閱[for AWS HealthScribe 靜態資料加密](health-scribe-encryption.md)。

## 服務可用性
<a name="health-scribe-availability"></a>

AWS HealthScribe 在美國東部 （維吉尼亞北部） 區域提供。

## 技術需求
<a name="health-scribe-tech-requirements-overview"></a>
+ **支援的語言：**美式英文 (en-US)
+ **建議的音訊格式：**無失真音訊 （例如 FLAC 或 WAV)
+ **編碼：**PCM 16 位元
+ **取樣率：**16，000 Hz 或更高

## 支援的醫療專科
<a name="health-scribe-specialties"></a>

AWS HealthScribe 目前支援下列專業：
+ 敏感免疫學
+ 心臟科
+ 皮膚病學
+ 神經內科
+ 消化道病學
+ 血液/腫瘤學
+ 感染性疾病
+ Nephrology
+ 神經病學
+ OBGYN
+ 腫瘤學
+ 眼科學
+ 骨科
+ 耳鼻喉科
+ 痛苦醫學
+ 小兒科
+ 初級護理
+ 精神科
+ 肺病學
+ 風濕病學
+ 外科
+ 泌尿外科

## 工作流程
<a name="health-scribe-workflows"></a>

 AWS HealthScribe 工作流程包括轉錄任務和串流。在您執行轉錄任務或完成串流後， AWS HealthScribe 會產生轉錄檔案，並提供每個對話回合的turn-by-turn轉錄輸出和洞見。此外，還會產生臨床文件檔案，其中包含摘要和證據連結。如需更多資訊，請參閱[AWS HealthScribe 文字記錄檔案](health-scribe-transcript.md)及[AWS HealthScribe 臨床文件檔案](health-scribe-insights.md)。
+ **轉錄任務** – 透過轉錄任務， AWS HealthScribe 會分析來自 Amazon S3 儲存貯體的已完成醫療諮詢媒體檔案。以下是 AWS HealthScribe 轉錄任務特定的 API 操作。
  + [StartMedicalScribeJob](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartMedicalScribeJob.html)
  + [ListMedicalScribeJobs](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_ListMedicalScribeJobs.html)
  + [GetMedicalScribeJob](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_GetMedicalScribeJob.html)
  + [DeleteMedicalScribeJob](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_DeleteMedicalScribeJob.html)

  如需詳細資訊，包括程式碼範例，請參閱 [AWS HealthScribe 轉錄任務](health-scribe-job.md)。
+ **串流** – AWS HealthScribe 串流是一種以 HTTP2 為基礎的即時雙向服務，在一個頻道上接受音訊串流，並在另一個頻道上提供音訊轉錄。

  

   以下是 AWS HealthScribe 串流特定的 API 操作：
  + [StartMedicalScribeStream](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartMedicalScribeStream.html)
  + [GetMedicalScribeStream](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_GetMedicalScribeStream.html)

  如需詳細資訊，包括程式碼範例，請參閱 [AWS HealthScribe 串流](health-scribe-streaming.md)。

# AWS HealthScribe 文字記錄檔案
<a name="health-scribe-transcript"></a>

在文字記錄檔案中，除了具有單字層級時間戳記的標準turn-by-turn轉錄輸出之外， AWS HealthScribe 還為您提供：
+ **參與者角色偵測**，因此您可以區分對話記錄中的患者語臨床醫生。
+ **文字記錄分段**，根據其臨床相關性 (例如閒聊、主觀、客觀等)，進行文字記錄對話分類。這可以用來顯示文字記錄的特定部分。
+ **臨床實體**，其中包括結構化資訊，例如藥物、醫療條件和對話中提到的治療方法。

此外，還為每個對話回合提供以下見解：
+ **參與者角色** — 每個參與者都被標記為臨床醫生或患者。如果對話在每個類別中有多個參與者，則會為每個參與者指定編號。例如：`CLINICIAN_0`、`CLINICIAN_1` 和 `PATIENT_0`、`PATIENT_1`。
+ **區段** — 每個對話回合都會根據所識別的內容，指定給四個可能的區段之一。
  + **主觀** — 病患提供其健康問題的資訊。
  + **客觀** — 臨床醫師透過身體檢查、實驗室檢驗、影像或診斷測試觀察到的資訊。
  + **評估和計劃** — 與醫師的評估和治療計劃相關的資訊。
  + **造訪流程管理** — 與閒聊或轉換相關的資訊。
+ **洞見** — 擷取存在於對話中的臨床相關實體 (`ClinicalEntity`)。 AWS HealthScribe 會偵測 [Amazon Comprehend Medical ](https://aws.amazon.com//comprehend/medical)支援的所有臨床實體。

如需轉錄任務的文字記錄範例，請參閱 中的文字記錄輸出[轉錄任務輸出範例](starting-health-scribe-job.md#health-scribe-output-example)。如需來自串流的文字記錄範例，請參閱 中的文字記錄輸出[串流轉錄輸出範例](health-scribe-streaming-setting-up.md#health-scribe-streaming-output-example)。

# AWS HealthScribe 臨床文件檔案
<a name="health-scribe-insights"></a>

AWS HealthScribe 可以使用下列其中一個範本進行臨床備註摘要。預設值為 `HISTORY_AND_PHYSICAL`。
+ HISTORY\$1AND\$1PHYSICAL：提供臨床文件重要章節的摘要。區段的範例包括主投訴、目前疾病歷史記錄、系統審查、過去醫療歷史記錄、評估和計劃。
+ GIRPP：根據患者朝向目標的進度提供摘要。區段的範例包括目標、介入、回應、進度和計劃。
+ BIRP：專注於病患的行為模式和回應。區段的範例包括行為、介入、回應和計劃。
+ SIRP：強調治療的情況內容。區段的範例包括情況、介入、回應和計劃。
+ DAP：提供臨床文件的簡化格式。區段的範例包括資料、評估和計劃。
+ BH\$1SOAP：以行為狀態為重心的文件格式。區段的範例包括主觀、目標、評估和計畫。
+ PH\$1SOAP：以身體運作狀態為重心的文件格式。區段的範例包括主觀、目標、評估和計畫。

若要指定要使用的範本，請執行下列動作：
+  對於轉錄任務，指定要在 [StartMedicalScribeJob](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartMedicalScribeJob.html) API 操作`NoteTemplate`之 的 [ClinicalNoteGenerationSettings](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_ClinicalNoteGenerationSettings.html) `Settings` 的 中使用的範本。
+  對於串流，您可以指定要在 [MedicalScribeConfigurationEvent](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_MedicalScribeConfigurationEvent.html) `NoteTemplate`之 的 [ClinicalNoteGenerationSettings](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_ClinicalNoteGenerationSettings.html) `PostStreamAnalyticsSettings` 的 中使用的範本。

## Medical Scribe 內容
<a name="health-scribe-contextual-information"></a>

`MedicalScribeContext` 物件包含內容資訊，用於自訂具有患者特定詳細資訊的臨床備註產生。

`MedicalScribeContext` 物件包含下列元件：
+ **PatientContext** - 包含用於自訂臨床備註產生的病患特定資訊。其中包含：
  + **代名詞** - 您想要提供的患者偏好代名詞，做為產生臨床備註的內容。在產生的臨床輸出中參照病患時，會使用這些代名詞。

如需如何設定醫療轉錄內容的資訊，請參閱 [MedicalScribeContext](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_MedicalScribeContext.html)。

**Topics**
+ [Medical Scribe 內容](#health-scribe-contextual-information)
+ [HISTORY\$1AND\$1PHYSICAL 範本區段](#health-scribe-history-physical-insights)
+ [GIRPP 範本區段](#health-scribe-GIRPP-insights)
+ [BIRP 範本區段](#health-scribe-BIRP-insights)
+ [SIRP 範本區段](#health-scribe-SIRP-insights)
+ [DAP 範本區段](#health-scribe-DAP-insights)
+ [BH\$1SOAP 範本區段](#health-scribe-BH-SOAP-insights)
+ [PH\$1SOAP 範本區段](#health-scribe-PH-SOAP-insights)

## HISTORY\$1AND\$1PHYSICAL 範本區段
<a name="health-scribe-history-physical-insights"></a>

HISTORY\$1AND\$1PHYSICAL 洞見範本包含下列區段。


| 區段 | Description | 
| --- | --- | 
|  主訴  |  病患造訪臨床醫生原因的簡短描述。  | 
|  目前病史  |  提供患者疾病資訊的備註事項，包括參考嚴重程度、發病、症狀的時間、目前的治療和受影響的不為。  | 
|  系統性回顧  |  病患對全身不同系統回報的症狀評估。  | 
|  過去病史  |  詳述病患過去的醫療情形、手術及治療。  | 
|  評估  |  供有關臨床醫生對患者健康評估的資訊的備註事項。  | 
|  計劃  |  參考任何醫療、生活方式調整和進一步預約的注意事項。  | 
|  PHYSICAL\$1EXAMINATION  |  記錄臨床醫生對患者身體系統和生命體徵進行理學檢查的結果。  | 
|  PAST\$1FAMILY\$1HISTORY  |  有關在患者系列中執行之運作狀態的資訊。  | 
|  PAST\$1SOCIAL\$1HISTORY  |  有關患者社交生活、習慣、職業和影響健康的環境因素的詳細資訊。  | 
|  DIAGNOSTIC\$1TESTING  |  實驗室測試、影像研究和其他診斷程序的結果和解釋。  | 

中出現的每個句子都`Summary`包含 `EvidenceLinks` ，可在摘要的文字記錄中提供`SegmentId`相關對話的 。這有助於使用者驗證應用程式中摘要的準確性。如同可解釋性，為 AI 產生的洞見提供可追蹤性和透明度，與負責任的 AI 原則一致。將這些參考與摘要備註一起提供給臨床醫生或醫學人員，有助於培養信任，並鼓勵在臨床環境中安全地使用 AI。

如需轉錄任務臨床文件檔案的範例，請參閱 中的臨床文件檔案範例[轉錄任務輸出範例](starting-health-scribe-job.md#health-scribe-output-example)。如需來自串流之臨床文件檔案的範例，請參閱 中的臨床文件檔案範例[串流轉錄輸出範例](health-scribe-streaming-setting-up.md#health-scribe-streaming-output-example)。

## GIRPP 範本區段
<a name="health-scribe-GIRPP-insights"></a>

GIRPP 洞見範本包含下列各節。


| 區段 | Description | 
| --- | --- | 
|  目標  |  需要透過處理解決的已識別問題、挑戰或行為。  | 
|  介入  |  臨床醫生用來協助患者解決已識別目標的特定處理、方法或技術。  | 
|  回應  |  患者如何回應介入，包括他們的參與程度、反應和意見回饋。  | 
|  進度  |  臨床醫生對朝治療目標移動的評估，包括觀察患者改善或障礙。  | 
|  計畫  |  接下來的處理步驟，包括未來的介入、家庭作業指派和推薦。  | 

## BIRP 範本區段
<a name="health-scribe-BIRP-insights"></a>

BIRP 洞見範本包含下列各節。


| 區段 | Description | 
| --- | --- | 
|  Behavior (行為)  |  患者呈現的問題及其對治療的反應。  | 
|  介入  |  臨床醫生用來協助患者解決已識別目標的特定處理、方法或技術。  | 
|  回應  |  患者如何回應介入，包括他們的參與程度、反應和意見回饋。  | 
|  計畫  |  接下來的處理步驟，包括未來的介入、家庭作業指派和推薦。  | 

## SIRP 範本區段
<a name="health-scribe-SIRP-insights"></a>

SIRP 洞見範本包含下列各節。


| 區段 | Description | 
| --- | --- | 
|  情形  |  患者提出的問題及其尋求治療的目標。  | 
|  介入  |  臨床醫生用來協助患者解決已識別目標的特定處理、方法或技術。  | 
|  回應  |  患者如何回應介入，包括他們的參與程度、反應和意見回饋。  | 
|  計畫  |  接下來的處理步驟，包括未來的介入、家庭作業指派和推薦。  | 

## DAP 範本區段
<a name="health-scribe-DAP-insights"></a>

DAP 洞見範本包含下列區段。


| 區段 | Description | 
| --- | --- | 
|  資料  |  病患尋求治療的原因和有關病患的資訊。  | 
|  評估  |  臨床醫生對患者情況的診斷。  | 
|  計畫  |  接下來的處理步驟，包括未來的介入、家庭作業指派和推薦。  | 

## BH\$1SOAP 範本區段
<a name="health-scribe-BH-SOAP-insights"></a>

BH\$1SOAP 洞見範本包含下列區段。


| 區段 | Description | 
| --- | --- | 
|  主觀  |  用戶端的處理目標及其體驗，以及現有和過去的問題。  | 
|  目標  |  有關用戶端的資料和事實。  | 
|  評估  |  臨床醫生對患者情況的診斷。  | 
|  計畫  |  接下來的處理步驟，包括未來的介入、家庭作業指派和推薦。  | 

## PH\$1SOAP 範本區段
<a name="health-scribe-PH-SOAP-insights"></a>

PH\$1SOAP 洞察範本包含下列區段。


| 區段 | Description | 
| --- | --- | 
|  主觀  |  用戶端的處理目標及其體驗，以及現有和過去的問題。  | 
|  目標  |  有關用戶端的資料和事實。  | 
|  評估  |  臨床醫生對患者情況的診斷。  | 
|  計畫  |  接下來的處理步驟，包括未來的介入、家庭作業指派和推薦。  | 

# AWS HealthScribe 轉錄任務
<a name="health-scribe-job"></a>

An AWS HealthScribe 轉錄任務會處理來自 Amazon S3 儲存貯體的媒體檔案。處理媒體檔案時，它會轉錄患者與臨床醫師的對話，並分析醫療諮詢以產生兩個 JSON 輸出檔案：[文字](https://docs.aws.amazon.com/transcribe/latest/dg/health-scribe-job.html#health-scribe-output-example)記錄檔案和[臨床文件](https://docs.aws.amazon.com/transcribe/latest/dg/health-scribe-job.html#health-scribe-output-example)檔案。

以下是 AWS HealthScribe 轉錄任務特有的 API 操作：
+ [StartMedicalScribeJob](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartMedicalScribeJob.html)
+ [ListMedicalScribeJobs](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_ListMedicalScribeJobs.html)
+ [GetMedicalScribeJob](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_GetMedicalScribeJob.html)
+ [DeleteMedicalScribeJob](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_DeleteMedicalScribeJob.html)

# 啟動 AWS HealthScribe 轉錄任務
<a name="starting-health-scribe-job"></a>

您可以使用 CLI 或 AWS SDKs啟動 AWS HealthScribe AWS 任務。

## AWS CLI
<a name="health-scribe-cli-batch"></a>

 此範例使用 [start-medical-scribe-job](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/transcribe/start-medical-scribe-job.html) 指令。如需詳細資訊，請參閱 [StartMedicalScribeJob](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartMedicalScribeJob.html)。

```
aws transcribe start-medical-scribe-job \
--region us-west-2 \
--medical-scribe-job-name my-first-medical-scribe-job \
--media MediaFileUri=s3://amzn-s3-demo-bucket/my-input-files/my-media-file.flac \
--output-bucket-name amzn-s3-demo-bucket \
--DataAccessRoleArn=arn:aws:iam::111122223333:role/ExampleRole \
--settings ShowSpeakerLabels=false,ChannelIdentification=true \
--channel-definitions ChannelId=0,ParticipantRole=CLINICIAN ChannelId=1,ParticipantRole=PATIENT
```

這是使用 [start-medical-scribe-job](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/transcribe/start-medical-scribe-job.html) 指令的另一個範例，以及帶其他設定的請求內文。

```
aws transcribe start-medical-scribe-job \
--region us-west-2 \
--cli-input-json file://filepath/my-first-medical-scribe-job.json
```

檔案 `my-first-medical-scribe-job.json` 包含以下請求內文。

```
{
  "MedicalScribeJobName": "my-first-medical-scribe-job",  
  "Media": {
    "MediaFileUri": "s3://amzn-s3-demo-bucket/my-input-files/my-media-file.flac"
   },
  "OutputBucketName": "amzn-s3-demo-bucket", 
  "DataAccessRoleArn": "arn:aws:iam::111122223333:role/ExampleRole",
  "Settings": {
    "ShowSpeakerLabels": false,
    "ChannelIdentification": true
  },
  "ChannelDefinitions": [
    {
      "ChannelId": 0,
      "ParticipantRole":"CLINICIAN"
    }, {
      "ChannelId": 1,
      "ParticipantRole":"PATIENT"
    }
  ]
}
```

## 適用於 Python (Boto3) 的 AWS SDK
<a name="health-scribe-python-batch"></a>

 下列範例使用 適用於 Python (Boto3) 的 AWS SDK 提出 [start\$1Medical\$1scribe\$1job](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/transcribe/client/start_medical_scribe_job.html) 請求。如需詳細資訊，請參閱 [StartMedicalScribeJob](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartMedicalScribeJob.html)。

```
from __future__ import print_functionimport timeimport boto3
transcribe = boto3.client('transcribe', 'us-west-2')
job_name = "my-first-medical-scribe-job"
job_uri = "s3://amzn-s3-demo-bucket/my-input-files/my-media-file.flac"
transcribe.start_medical_scribe_job(
    MedicalScribeJobName = job_name,
    Media = {
      'MediaFileUri': job_uri
    },
    OutputBucketName = 'amzn-s3-demo-bucket',
    DataAccessRoleArn = 'arn:aws:iam::111122223333:role/ExampleRole',
    Settings = {
      'ShowSpeakerLabels': false,
      'ChannelIdentification': true
    },
    ChannelDefinitions = [
      {
        'ChannelId': 0, 
        'ParticipantRole': 'CLINICIAN'
      }, {
        'ChannelId': 1, 
        'ParticipantRole': 'PATIENT'
      }
    ]
)
while True:
    status = transcribe.get_medical_scribe_job(MedicalScribeJobName = job_name)
    if status['MedicalScribeJob']['MedicalScribeJobStatus'] in ['COMPLETED', 'FAILED']:
        break
    print("Not ready yet...")
    time.sleep(5)    
print(status)
```

**注意**  
 AWS 管理主控台目前不支援 AWS HealthScribe 任務。

## 轉錄任務輸出範例
<a name="health-scribe-output-example"></a>

除了文字記錄之外，`StartMedicalScribeJob` 請求還會產生獨立的臨床文件檔案。這兩個檔案都是 JSON 格式，並存放在您在請求中指定的輸出位置。下列是每個輸出類型的範例：

### 範例文字記錄輸出
<a name="health-scribe-transcript-output"></a>

 An AWS HealthScribe 轉錄檔案 （來自`StartMedicalScribeJob`請求） 的格式如下：

```
{
  "Conversation": {
    "ConversationId": "sampleConversationUUID",
    "JobName": "sampleJobName",
    "JobType": "ASYNC",
    "LanguageCode": "en-US",
    "ClinicalInsights": [
      {
        "Attributes": [],
        "Category": "MEDICAL_CONDITION",
        "InsightId": "insightUUID1",
        "InsightType": "ClinicalEntity",
        "Spans": [
          {
            "BeginCharacterOffset": 12,
            "Content": "pain",
            "EndCharacterOffset": 15,
            "SegmentId": "uuid1"
          }
        ],
        "Type": "DX_NAME"
      },
      {
        "Attributes": [],
        "Category": "TEST_TREATMENT_PROCEDURE",
        "InsightId": "insightUUID2",
        "InsightType": "ClinicalEntity",
        "Spans": [
          {
            "BeginCharacterOffset": 4,
            "Content": "mammogram",
            "EndCharacterOffset": 12,
            "SegmentId": "uuid2"
          }
        ],
        "Type": "TEST_NAME"
      },
      {
        "Attributes": [],
        "Category": "TEST_TREATMENT_PROCEDURE",
        "InsightId": "insightUUID3",
        "InsightType": "ClinicalEntity",
        "Spans": [
          {
            "BeginCharacterOffset": 15,
            "Content": "pap smear",
            "EndCharacterOffset": 23,
            "SegmentId": "uuid3"
          }
        ],
        "Type": "TEST_NAME"
      },
      {
        "Attributes": [],
        "Category": "MEDICATION",
        "InsightId": "insightUUID4",
        "InsightType": "ClinicalEntity",
        "Spans": [
          {
            "BeginCharacterOffset": 28,
            "Content": "phentermine",
            "EndCharacterOffset": 38,
            "SegmentId": "uuid4"
          }
        ],
        "Type": "GENERIC_NAME"
      },
      {
        "Attributes": [
          {
            "AttributeId": "attributeUUID1",
            "Spans": [
              {
                "BeginCharacterOffset": 38,
                "Content": "high",
                "EndCharacterOffset": 41,
                "SegmentId": "uuid5"
              }
            ],
            "Type": "TEST_VALUE"
          }
        ],
        "Category": "TEST_TREATMENT_PROCEDURE",
        "InsightId": "insightUUID5",
        "InsightType": "ClinicalEntity",
        "Spans": [
          {
            "BeginCharacterOffset": 14,
            "Content": "weight",
            "EndCharacterOffset": 19,
            "SegmentId": "uuid6"
          }
        ],
        "Type": "TEST_NAME"
      },
      {
        "Attributes": [],
        "Category": "ANATOMY",
        "InsightId": "insightUUID6",
        "InsightType": "ClinicalEntity",
        "Spans": [
          {
            "BeginCharacterOffset": 60,
            "Content": "heart",
            "EndCharacterOffset": 64,
            "SegmentId": "uuid7"
          }
        ],
        "Type": "SYSTEM_ORGAN_SITE"
      }
    ],
    "TranscriptItems": [
      {
        "Alternatives": [
          {
            "Confidence": 0.7925,
            "Content": "Okay"
          }
        ],
        "BeginAudioTime": 0.16,
        "EndAudioTime": 0.6,
        "Type": "PRONUNCIATION"
      },
      {
        "Alternatives": [
          {
            "Confidence": 0,
            "Content": "."
          }
        ],
        "BeginAudioTime": 0.17,
        "EndAudioTime": 0.9,
        "Type": "PUNCTUATION"
      },
      {
        "Alternatives": [
          {
            "Confidence": 1,
            "Content": "Good"
          }
        ],
        "BeginAudioTime": 0.61,
        "EndAudioTime": 0.92,
        "Type": "PRONUNCIATION"
      },
      {
        "Alternatives": [
          {
            "Confidence": 1,
            "Content": "afternoon"
          }
        ],
        "BeginAudioTime": 0.92,
        "EndAudioTime": 1.54,
        "Type": "PRONUNCIATION"
      },
      {
        "Alternatives": [
          {
            "Confidence": 0,
            "Content": "."
          }
        ],
        "BeginAudioTime": 0,
        "EndAudioTime": 0,
        "Type": "PUNCTUATION"
      },
      {
        "Alternatives": [
          {
            "Confidence": 0.9924,
            "Content": "You"
          }
        ],
        "BeginAudioTime": 1.55,
        "EndAudioTime": 1.88,
        "Type": "PRONUNCIATION"
      },
      {
        "Alternatives": [
          {
            "Confidence": 1,
            "Content": "lost"
          }
        ],
        "BeginAudioTime": 1.88,
        "EndAudioTime": 2.19,
        "Type": "PRONUNCIATION"
      },
      {
        "Alternatives": [
          {
            "Confidence": 1,
            "Content": "one"
          }
        ],
        "BeginAudioTime": 2.19,
        "EndAudioTime": 2.4,
        "Type": "PRONUNCIATION"
      },
      {
        "Alternatives": [
          {
            "Confidence": 1,
            "Content": "lb"
          }
        ],
        "BeginAudioTime": 2.4,
        "EndAudioTime": 2.97,
        "Type": "PRONUNCIATION"
      }
    ],
    "TranscriptSegments": [
      {
        "BeginAudioTime": 0.16,
        "Content": "Okay.",
        "EndAudioTime": 0.6,
        "ParticipantDetails": {
          "ParticipantRole": "CLINICIAN_0"
        },
        "SectionDetails": {
          "SectionName": "SUBJECTIVE"
        },
        "SegmentId": "uuid1"
      },
      {
        "BeginAudioTime": 0.61,
        "Content": "Good afternoon.",
        "EndAudioTime": 1.54,
        "ParticipantDetails": {
          "ParticipantRole": "CLINICIAN_0"
        },
        "SectionDetails": {
          "SectionName": "OTHER"
        },
        "SegmentId": "uuid2"
      },
      {
        "BeginAudioTime": 1.55,
        "Content": "You lost one lb.",
        "EndAudioTime": 2.97,
        "ParticipantDetails": {
          "ParticipantRole": "CLINICIAN_0"
        },
        "SectionDetails": {
          "SectionName": "SUBJECTIVE"
        },
        "SegmentId": "uuid3"
      },
      {
        "BeginAudioTime": 2.98,
        "Content": "Yeah, I think it, uh, do you feel more energy?",
        "EndAudioTime": 6.95,
        "ParticipantDetails": {
          "ParticipantRole": "CLINICIAN_0"
        },
        "SectionDetails": {
          "SectionName": "SUBJECTIVE"
        },
        "SegmentId": "uuid5"
      },
      {
        "BeginAudioTime": 6.96,
        "Content": "Yes.",
        "EndAudioTime": 7.88,
        "ParticipantDetails": {
          "ParticipantRole": "CLINICIAN_0"
        },
        "SectionDetails": {
          "SectionName": "SUBJECTIVE"
        },
        "SegmentId": "uuid6"
      },
      {
        "BeginAudioTime": 7.89,
        "Content": "Uh, how about craving for the carbohydrate or sugar or fat or anything?",
        "EndAudioTime": 17.93,
        "ParticipantDetails": {
          "ParticipantRole": "CLINICIAN_0"
        },
        "SectionDetails": {
          "SectionName": "SUBJECTIVE"
        },
        "SegmentId": "uuid7"
      }
    ]
  }
}
```

這是使用 [start-medical-scribe-job](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/transcribe/start-medical-conversation-intelligence-job.html) 指令的另一個範例，以及帶其他設定的請求內文。

```
aws transcribe start-medical-scribe-job \
--region us-west-2 \
--cli-input-json file://filepath/my-first-medical-scribe-job.json
```

檔案 `my-first-medical-scribe-job.json` 包含以下請求內文。

```
{
  "MedicalScribeJobName": "my-first-medical-scribe-job",  
  "Media": {
    "MediaFileUri": "s3://amzn-s3-demo-bucket/my-input-files/my-media-file.flac"
   },
  "OutputBucketName": "amzn-s3-demo-bucket", 
  "DataAccessRoleArn": "arn:aws:iam::111122223333:role/ExampleRole",
  "Settings": {
    "ShowSpeakerLabels": false,
    "ChannelIdentification": true
  },
  "ChannelDefinitions": [
    {
      "ChannelId": 0,
      "ParticipantRole":"CLINICIAN"
    }, {
      "ChannelId": 1,
      "ParticipantRole":"PATIENT"
    }
  ]
}
```

### 臨床文件輸出範例
<a name="health-scribe-insights-output"></a>

 文件見解檔案 (來自 `StartMedicalScribeJob` 要求) 具有下列格式：

```
{
  "ClinicalDocumentation": {
    "Sections": [
      {
        "SectionName": "CHIEF_COMPLAINT",
        "Summary": [
          {
            "EvidenceLinks": [
              {
                "SegmentId": "uuid1"
              },
              {
                "SegmentId": "uuid2"
              },
              {
                "SegmentId": "uuid3"
              },
              {
                "SegmentId": "uuid4"
              },
              {
                "SegmentId": "uuid5"
              },
              {
                "SegmentId": "uuid6"
              }
            ],
            "SummarizedSegment": "Weight loss."
          }
        ]
      },
      {
        "SectionName": "HISTORY_OF_PRESENT_ILLNESS",
        "Summary": [
          {
            "EvidenceLinks": [
              {
                "SegmentId": "uuid7"
              },
              {
                "SegmentId": "uuid8"
              },
              {
                "SegmentId": "uuid9"
              },
              {
                "SegmentId": "uuid10"
              }
            ],
            "SummarizedSegment": "The patient is seen today for a follow-up of weight loss."
          },
          {
            "EvidenceLinks": [
              {
                "SegmentId": "uuid11"
              },
              {
                "SegmentId": "uuid12"
              },
              {
                "SegmentId": "uuid13"
              }
            ],
            "SummarizedSegment": "They report feeling more energy and craving carbohydrates, sugar, and fat."
          },
          {
            "EvidenceLinks": [
              {
                "SegmentId": "uuid14"
              },
              {
                "SegmentId": "uuid15"
              },
              {
                "SegmentId": "uuid16"
              }
            ],
            "SummarizedSegment": "The patient is up to date on their mammogram and pap smear."
          },
          {
            "EvidenceLinks": [
              {
                "SegmentId": "uuid17"
              },
              {
                "SegmentId": "uuid18"
              },
              {
                "SegmentId": "uuid19"
              },
              {
                "SegmentId": "uuid20"
              }
            ],
            "SummarizedSegment": "The patient is taking phentermine and would like to continue."
          }
        ]
      },
      {
        "SectionName": "REVIEW_OF_SYSTEMS",
        "Summary": [
          {
            "EvidenceLinks": [
              {
                "SegmentId": "uuid21"
              },
              {
                "SegmentId": "uuid22"
              }
            ],
            "SummarizedSegment": "Patient reports intermittent headaches, occasional chest pains but denies any recent fevers or chills."
          },
          {
            "EvidenceLinks": [
              {
                "SegmentId": "uuid23"
              },
              {
                "SegmentId": "uuid24"
              }
            ],
            "SummarizedSegment": "No recent changes in vision, hearing, or any respiratory complaints."
          }
        ]
      },
      {
        "SectionName": "PAST_MEDICAL_HISTORY",
        "Summary": [
          {
            "EvidenceLinks": [
              {
                "SegmentId": "uuid25"
              },
              {
                "SegmentId": "uuid26"
              }
            ],
            "SummarizedSegment": "Patient has a history of hypertension and was diagnosed with Type II diabetes 5 years ago."
          },
          {
            "EvidenceLinks": [
              {
                "SegmentId": "uuid27"
              },
              {
                "SegmentId": "uuid28"
              }
            ],
            "SummarizedSegment": "Underwent an appendectomy in the early '90s and had a fracture in the left arm during childhood."
          }
        ]
      },
      {
        "SectionName": "ASSESSMENT",
        "Summary": [
          {
            "EvidenceLinks": [
              {
                "SegmentId": "uuid29"
              },
              {
                "SegmentId": "uuid30"
              }
            ],
            "SummarizedSegment": "Weight loss"
          }
        ]
      },
      {
        "SectionName": "PLAN",
        "Summary": [
          {
            "EvidenceLinks": [
              {
                "SegmentId": "uuid31"
              },
              {
                "SegmentId": "uuid32"
              },
              {
                "SegmentId": "uuid33"
              },
              {
                "SegmentId": "uuid34"
              }
            ],
            "SummarizedSegment": "For the condition of Weight loss: The patient was given a 30-day supply of phentermine and was advised to follow up in 30 days."
          }
        ]
      }
    ]
  }
}
```

# AWS HealthScribe 串流
<a name="health-scribe-streaming"></a>

透過 AWS HealthScribe 串流，您可以即時轉錄醫療對話。 AWS HealthScribe 串流是一種以 HTTP2 為基礎的即時雙向服務，在一個頻道上接受音訊串流，並在另一個頻道上提供音訊轉錄。串流完成後， AWS HealthScribe 會分析串流內容，並產生文字記錄 JSON 檔案和臨床備註 JSON 檔案。

 若要開始串流，請使用 [StartMedicalScribeStream](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartMedicalScribeStream.html) API 操作。此 API 會啟動 HTTP2 型雙向頻道，讓您用來串流音訊事件。

當您啟動串流時，請先在 中指定串流組態`MedicalScribeConfigurationEvent`。此事件包括頻道定義、加密設定和串流後分析設定，例如彙總文字記錄和產生臨床備註的輸出組態。

開始串流音訊後，您可以管理串流，如下所示：
+  完成後，若要使用串流後分析開始處理結果，請傳送`MedicalScribeSessionControlEvent`具有 `Type` 的 `END_OF_SESSION`， AWS HealthScribe 會開始分析。
+ 若要暫停串流，請完成輸入串流，而不傳送 `MedicalScribeSessionControlEvent`。
+ 若要繼續暫停的串流，請使用 `StartMedicalScribeStream` API 操作並指定相同的 `SessionId`。這是您最初啟動串流`SessionId`時使用的 。

**Topics**
+ [準則和要求](#health-scribe-streaming-requirements)
+ [ResourceAccessRoleArn 角色許可](#health-scribe-data-access-role)
+ [Starting AWS HealthScribe 串流轉錄](health-scribe-streaming-setting-up.md)

## 準則和要求
<a name="health-scribe-streaming-requirements"></a>

以下是 AWS HealthScribe 串流的指導方針和要求：
+ 傳送音訊事件之前，您必須先在 中指定串流組態`[MedicalScribeConfigurationEvent](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_MedicalScribeConfigurationEvent.html)`。
+ 若要執行串流後分析， `ResourceAccessRoleArn`中的 `MedicalScribeConfigurationEvent` 必須具有正確的許可。如需詳細資訊，請參閱[ResourceAccessRoleArn 角色許可](#health-scribe-data-access-role)。
+ 您可以在初始串流建立後 5 小時內繼續工作階段任意次數。
+ 您可以跨所有串流請求，透過工作階段串流最多 2 小時的音訊。
+ 根據預設， AWS HealthScribe 提供靜態加密，以保護使用 Amazon S3受管金鑰的敏感客戶資料。當您啟動串流時，您可以為第二層加密指定 AWS KMS 金鑰。您的 `ResourceAccessRoleArn` 必須具有使用 AWS KMS 金鑰的許可。如需詳細資訊，請參閱[for AWS HealthScribe 靜態資料加密](health-scribe-encryption.md)。
+ 您可以使用 AWS HealthScribe 串流搭配 AWS SDKs，不包括適用於 Python (Boto3) 的 SDK 和適用於 PHP 的 SDK。
+ 如果在結束串流後發生`LimitExceededException`例外狀況，您可以重新啟動工作階段，但仍會產生串流後分析。若要重新啟動串流，請使用 [StartMedicalScribeStream](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartMedicalScribeStream.html) API，並使用相同的 `SessionID`。然後傳送`MedicalScribeSessionControlEvent`具有 `Type`的 `END_OF_SESSION`， AWS HealthScribe 會開始分析。

## ResourceAccessRoleArn 角色許可
<a name="health-scribe-data-access-role"></a>

若要執行串流後分析， `ResourceAccessRoleArn`中的 `MedicalScribeConfigurationEvent` 必須能夠存取您的 Amazon S3 輸出儲存貯體，而且如果您提供它，則必須能夠存取您的 AWS KMS 金鑰。此外，角色的信任政策必須授予`transcribe.streaming.amazonaws.com`服務擔任角色的許可。

以下是授予 Amazon S3 儲存貯體許可和 AWS KMS 金鑰許可的 IAM 政策範例。如需詳細資訊，請參閱[for AWS HealthScribe 靜態資料加密](health-scribe-encryption.md)。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Action": [
                "s3:PutObject"
            ],
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-bucket",
                "arn:aws:s3:::amzn-s3-demo-bucket/*"
            ],
            "Effect": "Allow"
        },
        {
            "Action": [
                "kms:DescribeKey",
                "kms:Decrypt",
                "kms:Encrypt",
                "kms:GenerateDataKey*"
            ],
            "Resource": "arn:aws:kms:us-west-2:123456789012:key/1234abcd-12ab-34cd-56ef-123456SAMPLE",
            "Effect": "Allow"
        }
    ]
}
```

------

信任政策範例如下。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": [
                    "transcribe.streaming.amazonaws.com"
                ]
            },
            "Action": "sts:AssumeRole"
        }
    ]
}
```

------

# Starting AWS HealthScribe 串流轉錄
<a name="health-scribe-streaming-setting-up"></a>

下列程式碼範例示範如何使用 AWS SDKs 設定 AWS HealthScribe 串流轉錄。

**Topics**
+ [適用於 Java 2.x 的 SDK](#health-scribe-java-stream)
+ [串流轉錄輸出範例](#health-scribe-streaming-output-example)

## 適用於 Java 2.x 的 SDK
<a name="health-scribe-java-stream"></a>

 下列範例使用適用於 Java 的 SDK 2.x 來設定串流並提出 [StartMedicalScribeStream](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartMedicalScribeStream.html) 請求。

```
package org.example;

import io.reactivex.rxjava3.core.BackpressureStrategy;
import io.reactivex.rxjava3.core.Flowable;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
import software.amazon.awssdk.core.SdkBytes;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.transcribestreaming.TranscribeStreamingAsyncClient;
import software.amazon.awssdk.services.transcribestreaming.model.ClinicalNoteGenerationSettings;
import software.amazon.awssdk.services.transcribestreaming.model.LanguageCode;
import software.amazon.awssdk.services.transcribestreaming.model.MediaEncoding;

import software.amazon.awssdk.services.transcribestreaming.model.MedicalScribeInputStream;
import software.amazon.awssdk.services.transcribestreaming.model.MedicalScribePostStreamAnalyticsSettings;
import software.amazon.awssdk.services.transcribestreaming.model.MedicalScribeSessionControlEventType;
import software.amazon.awssdk.services.transcribestreaming.model.MedicalScribeTranscriptEvent;
import software.amazon.awssdk.services.transcribestreaming.model.MedicalScribeTranscriptSegment;
import software.amazon.awssdk.services.transcribestreaming.model.StartMedicalScribeStreamRequest;
import software.amazon.awssdk.services.transcribestreaming.model.StartMedicalScribeStreamResponseHandler;
import software.amazon.awssdk.services.transcribestreaming.model.medicalscribeinputstream.DefaultConfigurationEvent;

import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient;

import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.TargetDataLine;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.concurrent.CompletableFuture;


public class HealthScribeStreamingDemoApp {
    private static final int CHUNK_SIZE_IN_BYTES = 6400;
    private static final int SAMPLE_RATE = 16000;
    private static final Region REGION = Region.US_EAST_1;
    private static final String sessionId = "1234abcd-12ab-34cd-56ef-123456SAMPLE";
    private static final String bucketName = "amzn-s3-demo-bucket";
    private static final String resourceAccessRoleArn = "arn:aws:iam::123456789012:role/resource-access-role";
    private static TranscribeStreamingAsyncClient client;

    public static void main(String args[]) {

        client = TranscribeStreamingAsyncClient.builder()
                .credentialsProvider(getCredentials())
                .httpClientBuilder(NettyNioAsyncHttpClient.builder())
                .region(REGION)
                .build();
        try {
            StartMedicalScribeStreamRequest request = StartMedicalScribeStreamRequest.builder()
                    .languageCode(LanguageCode.EN_US.toString())
                    .mediaSampleRateHertz(SAMPLE_RATE)
                    .mediaEncoding(MediaEncoding.PCM.toString())
                    .sessionId(sessionId)
                    .build();

            MedicalScribeInputStream endSessionEvent = MedicalScribeInputStream.sessionControlEventBuilder()
                    .type(MedicalScribeSessionControlEventType.END_OF_SESSION)
                    .build();

            CompletableFuture<Void> result = client.startMedicalScribeStream(
                    request,
                    new AudioStreamPublisher(getStreamFromMic(), getConfigurationEvent(),endSessionEvent),
                    getMedicalScribeResponseHandler());
            result.get();
            client.close();
        } catch (Exception e) {
            System.err.println("Error occurred: " + e.getMessage());
            e.printStackTrace();
        }
    }

    private static AudioInputStream getStreamFromMic() throws LineUnavailableException {
        // Signed PCM AudioFormat with 16kHz, 16 bit sample size, mono
        AudioFormat format = new AudioFormat(SAMPLE_RATE, 16, 1, true, false);
        DataLine.Info info = new DataLine.Info(TargetDataLine.class, format);

        if (!AudioSystem.isLineSupported(info)) {
            System.out.println("Line not supported");
            throw new LineUnavailableException("The audio system microphone line is not supported.");
        }
        TargetDataLine line = (TargetDataLine) AudioSystem.getLine(info);
        int bufferSize = (CHUNK_SIZE_IN_BYTES / format.getFrameSize()) * format.getFrameSize();
        line.open(format);
        line.start();

        // Create a wrapper class that can be closed when Enter is pressed
        AudioInputStream audioStream = new AudioInputStream(line);

        // Start a thread to monitor for Enter key
        System.out.println("Recording... Press Enter to stop");
        Thread monitorThread = new Thread(() -> {
            try {
                System.in.read();
                line.stop();
                line.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        });
        monitorThread.setDaemon(true);  // Set as daemon thread so it doesn't prevent JVM shutdown
        monitorThread.start();

        return new AudioInputStream(
            new BufferedInputStream(new AudioInputStream(line)),
            format,
            AudioSystem.NOT_SPECIFIED
        );
    }

    private static AwsCredentialsProvider getCredentials() {
        return DefaultCredentialsProvider.create();
    }

    private static StartMedicalScribeStreamResponseHandler getMedicalScribeResponseHandler() {

        return StartMedicalScribeStreamResponseHandler.builder()
            .onResponse(r -> {
                System.out.println("Received Initial response");
            })
            .onError(Throwable::printStackTrace)
            .onComplete(() -> {
                System.out.println("=== All records streamed successfully ===");
            })
            .subscriber(event -> {
                if (event instanceof MedicalScribeTranscriptEvent) {
                    MedicalScribeTranscriptSegment segment = ((MedicalScribeTranscriptEvent) event).transcriptSegment();
                    if (segment != null && segment.content() != null && !segment.content().isEmpty()) {
                        System.out.println(segment.content());
                    }
                }
            })
            .build();
    }

    private static DefaultConfigurationEvent getConfigurationEvent() {
        MedicalScribePostStreamAnalyticsSettings postStreamSettings = MedicalScribePostStreamAnalyticsSettings
                .builder()
                .clinicalNoteGenerationSettings(
                        ClinicalNoteGenerationSettings.builder()
                                .outputBucketName(bucketName)
                                .build()
                )
                .build();
        return (DefaultConfigurationEvent) MedicalScribeInputStream.configurationEventBuilder()
                .resourceAccessRoleArn(resourceAccessRoleArn)
                .postStreamAnalyticsSettings(postStreamSettings)
                .build();
    }

    private static class AudioStreamPublisher implements Publisher<MedicalScribeInputStream> {
        private final InputStream audioInputStream;
        private final MedicalScribeInputStream configEvent;
        private final MedicalScribeInputStream endSessionEvent;

        private AudioStreamPublisher(AudioInputStream audioInputStream,
                                     MedicalScribeInputStream configEvent,
                                     MedicalScribeInputStream endSessionEvent) {
            this.audioInputStream = audioInputStream;
            this.configEvent = configEvent;
            this.endSessionEvent = endSessionEvent;
        }

        @Override
        public void subscribe(Subscriber<? super MedicalScribeInputStream> subscriber) {
            createAudioFlowable()
                    .doOnComplete(() -> {
                        try {
                            audioInputStream.close();
                        } catch (IOException e) {
                            throw new UncheckedIOException(e);
                        }
                    })
                    .subscribe(subscriber);
        }

        private Flowable<MedicalScribeInputStream> createAudioFlowable() {
            // Start with config event
            Flowable<MedicalScribeInputStream> configFlow = Flowable.just(configEvent);

            // Create audio chunk flowable
            Flowable<MedicalScribeInputStream> audioFlow = Flowable.create(emitter -> {
                byte[] buffer = new byte[CHUNK_SIZE_IN_BYTES];
                int bytesRead;

                try {
                    while (!emitter.isCancelled() && (bytesRead = audioInputStream.read(buffer)) > 0) {
                        byte[] audioData = bytesRead < buffer.length
                                ? Arrays.copyOfRange(buffer, 0, bytesRead)
                                : buffer;

                        MedicalScribeInputStream audioEvent = MedicalScribeInputStream.audioEventBuilder()
                                .audioChunk(SdkBytes.fromByteArray(audioData))
                                .build();

                        emitter.onNext(audioEvent);
                    }
                    emitter.onComplete();
                } catch (IOException e) {
                    emitter.onError(e);
                }
            }, BackpressureStrategy.BUFFER);

            // End with session end event
            Flowable<MedicalScribeInputStream> endFlow = Flowable.just(endSessionEvent);

            // Concatenate all flows
            return Flowable.concat(configFlow, audioFlow, endFlow);
        }
    }
}
```

## 串流轉錄輸出範例
<a name="health-scribe-streaming-output-example"></a>

 串流完成後， AWS HealthScribe 會分析串流內容，並產生文字記錄 JSON 檔案和臨床備註 JSON 檔案。下列是每個輸出類型的範例：

### 範例文字記錄輸出
<a name="health-scribe-streaming-transcript-output"></a>

 以下是來自串流工作階段的 a AWS HealthScribe 文字記錄檔案範例。

```
{
    "Conversation": {
        "ClinicalInsights": [{
            "Attributes": [],
            "Category": "MEDICAL_CONDITION",
            "InsightId": "insightUUID1",
            "InsightType": "ClinicalEntity",
            "Spans": [{
                "BeginCharacterOffset": 12,
                "Content": "pain",
                "EndCharacterOffset": 15,
                "SegmentId": "uuid1"
            }],
            "Type": "DX_NAME"
        }, {
            "Attributes": [],
            "Category": "TEST_TREATMENT_PROCEDURE",
            "InsightId": "insightUUID2",
            "InsightType": "ClinicalEntity",
            "Spans": [{
                "BeginCharacterOffset": 4,
                "Content": "mammogram",
                "EndCharacterOffset": 12,
                "SegmentId": "uuid2"
            }],
            "Type": "TEST_NAME"
        }, {
            "Attributes": [],
            "Category": "TEST_TREATMENT_PROCEDURE",
            "InsightId": "insightUUID3",
            "InsightType": "ClinicalEntity",
            "Spans": [{
                "BeginCharacterOffset": 15,
                "Content": "pap smear",
                "EndCharacterOffset": 23,
                "SegmentId": "uuid3"
            }],
            "Type": "TEST_NAME"
        }, {
            "Attributes": [],
            "Category": "MEDICATION",
            "InsightId": "insightUUID4",
            "InsightType": "ClinicalEntity",
            "Spans": [{
                "BeginCharacterOffset": 28,
                "Content": "phentermine",
                "EndCharacterOffset": 38,
                "SegmentId": "uuid4"
            }],
            "Type": "GENERIC_NAME"
        }, {
            "Attributes": [{
                "AttributeId": "attributeUUID1",
                "Spans": [{
                    "BeginCharacterOffset": 38,
                    "Content": "high",
                    "EndCharacterOffset": 41,
                    "SegmentId": "uuid5"
                }],
                "Type": "TEST_VALUE"
            }],
            "Category": "TEST_TREATMENT_PROCEDURE",
            "InsightId": "insightUUID5",
            "InsightType": "ClinicalEntity",
            "Spans": [{
                "BeginCharacterOffset": 14,
                "Content": "weight",
                "EndCharacterOffset": 19,
                "SegmentId": "uuid6"
            }],
            "Type": "TEST_NAME"
        }, {
            "Attributes": [],
            "Category": "ANATOMY",
            "InsightId": "insightUUID6",
            "InsightType": "ClinicalEntity",
            "Spans": [{
                "BeginCharacterOffset": 60,
                "Content": "heart",
                "EndCharacterOffset": 64,
                "SegmentId": "uuid7"
            }],
            "Type": "SYSTEM_ORGAN_SITE"
        }],
        "ConversationId": "sampleConversationUUID",
        "LanguageCode": "en-US",
        "SessionId": "sampleSessionUUID",
        "TranscriptItems": [{
            "Alternatives": [{
                "Confidence": 0.7925,
                "Content": "Okay"
            }],
            "BeginAudioTime": 0.16,
            "EndAudioTime": 0.6,
            "Type": "PRONUNCIATION"
        },
        {
            "Alternatives": [{
                "Confidence": 0,
                "Content": "."
            }],
            "BeginAudioTime": 0,
            "EndAudioTime": 0,
            "Type": "PUNCTUATION"
        },
        {
            "Alternatives": [{
                "Confidence": 1,
                "Content": "Good"
            }],
            "BeginAudioTime": 0.61,
            "EndAudioTime": 0.92,
            "Type": "PRONUNCIATION"
        },
        {
            "Alternatives": [{
                "Confidence": 1,
                "Content": "afternoon"
            }],
            "BeginAudioTime": 0.92,
            "EndAudioTime": 1.54,
            "Type": "PRONUNCIATION"
        },
        {
            "Alternatives": [{
                "Confidence": 0,
                "Content": "."
            }],
            "BeginAudioTime": 0,
            "EndAudioTime": 0,
            "Type": "PUNCTUATION"
        },
        {
            "Alternatives": [{
                "Confidence": 0.9924,
                "Content": "You"
            }],
            "BeginAudioTime": 1.55,
            "EndAudioTime": 1.88,
            "Type": "PRONUNCIATION"
        },
        {
            "Alternatives": [{
                "Confidence": 1,
                "Content": "lost"
            }],
            "BeginAudioTime": 1.88,
            "EndAudioTime": 2.19,
            "Type": "PRONUNCIATION"
        },
        {
            "Alternatives": [{
                "Confidence": 1,
                "Content": "one"
            }],
            "BeginAudioTime": 2.19,
            "EndAudioTime": 2.4,
            "Type": "PRONUNCIATION"
        },
        {
            "Alternatives": [{
                "Confidence": 1,
                "Content": "lb"
            }],
            "BeginAudioTime": 2.4,
            "EndAudioTime": 2.97,
            "Type": "PRONUNCIATION"
        }
        ],
        "TranscriptSegments": [{
            "BeginAudioTime": 0.16,
            "Content": "Okay.",
            "EndAudioTime": 0.6,
            "ParticipantDetails": {
                "ParticipantRole": "CLINICIAN_0"
            },
            "SectionDetails": {
                "SectionName": "SUBJECTIVE"
            },
            "SegmentId": "uuid1"
        }, {
            "BeginAudioTime": 0.61,
            "Content": "Good afternoon.",
            "EndAudioTime": 1.54,
            "ParticipantDetails": {
                "ParticipantRole": "CLINICIAN_0"
            },
            "SectionDetails": {
                "SectionName": "OTHER"
            },
            "SegmentId": "uuid2"
        }, {
            "BeginAudioTime": 1.55,
            "Content": "You lost one lb.",
            "EndAudioTime": 2.97,
            "ParticipantDetails": {
                "ParticipantRole": "CLINICIAN_0"
            },
            "SectionDetails": {
                "SectionName": "SUBJECTIVE"
            },
            "SegmentId": "uuid3"
        }, {
            "BeginAudioTime": 2.98,
            "Content": "Yeah, I think it, uh, do you feel more energy?",
            "EndAudioTime": 6.95,
            "ParticipantDetails": {
                "ParticipantRole": "CLINICIAN_0"
            },
            "SectionDetails": {
                "SectionName": "SUBJECTIVE"
            },
            "SegmentId": "uuid4"
        }, {
            "BeginAudioTime": 6.96,
            "Content": "Yes.",
            "EndAudioTime": 7.88,
            "ParticipantDetails": {
                "ParticipantRole": "CLINICIAN_0"
            },
            "SectionDetails": {
                "SectionName": "SUBJECTIVE"
            },
            "SegmentId": "uuid5"
        }, {
            "BeginAudioTime": 7.89,
            "Content": "Uh, how about craving for the carbohydrate or sugar or fat or anything?",
            "EndAudioTime": 17.93,
            "ParticipantDetails": {
                "ParticipantRole": "CLINICIAN_0"
            },
            "SectionDetails": {
                "SectionName": "SUBJECTIVE"
            },
            "SegmentId": "uuid6"
        }]
    }
}
```

### 範例臨床文件輸出
<a name="health-scribe-streaming-insights-output"></a>

 以下是來自串流工作階段的 a AWS HealthScribe 臨床文件洞察檔案範例。

```
{
  "ClinicalDocumentation": {
    "Sections": [
      {
        "SectionName": "CHIEF_COMPLAINT",
        "Summary": [
          {
            "EvidenceLinks": [
              {
                "SegmentId": "uuid1"
              },
              {
                "SegmentId": "uuid2"
              },
              {
                "SegmentId": "uuid3"
              },
              {
                "SegmentId": "uuid4"
              },
              {
                "SegmentId": "uuid5"
              },
              {
                "SegmentId": "uuid6"
              }
            ],
            "SummarizedSegment": "Weight loss."
          }
        ]
      },
      {
        "SectionName": "HISTORY_OF_PRESENT_ILLNESS",
        "Summary": [
          {
            "EvidenceLinks": [
              {
                "SegmentId": "uuid7"
              },
              {
                "SegmentId": "uuid8"
              },
              {
                "SegmentId": "uuid9"
              },
              {
                "SegmentId": "uuid10"
              }
            ],
            "SummarizedSegment": "The patient is seen today for a follow-up of weight loss."
          },
          {
            "EvidenceLinks": [
              {
                "SegmentId": "uuid11"
              },
              {
                "SegmentId": "uuid12"
              },
              {
                "SegmentId": "uuid13"
              }
            ],
            "SummarizedSegment": "They report feeling more energy and craving carbohydrates, sugar, and fat."
          },
          {
            "EvidenceLinks": [
              {
                "SegmentId": "uuid14"
              },
              {
                "SegmentId": "uuid15"
              },
              {
                "SegmentId": "uuid16"
              }
            ],
            "SummarizedSegment": "The patient is up to date on their mammogram and pap smear."
          },
          {
            "EvidenceLinks": [
              {
                "SegmentId": "uuid17"
              },
              {
                "SegmentId": "uuid18"
              },
              {
                "SegmentId": "uuid19"
              },
              {
                "SegmentId": "uuid20"
              }
            ],
            "SummarizedSegment": "The patient is taking phentermine and would like to continue."
          }
        ]
      },
      {
        "SectionName": "REVIEW_OF_SYSTEMS",
        "Summary": [
          {
            "EvidenceLinks": [
              {
                "SegmentId": "uuid21"
              },
              {
                "SegmentId": "uuid22"
              }
            ],
            "SummarizedSegment": "Patient reports intermittent headaches, occasional chest pains but denies any recent fevers or chills."
          },
          {
            "EvidenceLinks": [
              {
                "SegmentId": "uuid23"
              },
              {
                "SegmentId": "uuid24"
              }
            ],
            "SummarizedSegment": "No recent changes in vision, hearing, or any respiratory complaints."
          }
        ]
      },
      {
        "SectionName": "PAST_MEDICAL_HISTORY",
        "Summary": [
          {
            "EvidenceLinks": [
              {
                "SegmentId": "uuid25"
              },
              {
                "SegmentId": "uuid26"
              }
            ],
            "SummarizedSegment": "Patient has a history of hypertension and was diagnosed with Type II diabetes 5 years ago."
          },
          {
            "EvidenceLinks": [
              {
                "SegmentId": "uuid27"
              },
              {
                "SegmentId": "uuid28"
              }
            ],
            "SummarizedSegment": "Underwent an appendectomy in the early '90s and had a fracture in the left arm during childhood."
          }
        ]
      },
      {
        "SectionName": "ASSESSMENT",
        "Summary": [
          {
            "EvidenceLinks": [
              {
                "SegmentId": "uuid29"
              },
              {
                "SegmentId": "uuid30"
              }
            ],
            "SummarizedSegment": "Weight loss"
          }
        ]
      },
      {
        "SectionName": "PLAN",
        "Summary": [
          {
            "EvidenceLinks": [
              {
                "SegmentId": "uuid31"
              },
              {
                "SegmentId": "uuid32"
              },
              {
                "SegmentId": "uuid33"
              },
              {
                "SegmentId": "uuid34"
              }
            ],
            "SummarizedSegment": "For the condition of Weight loss: The patient was given a 30-day supply of phentermine and was advised to follow up in 30 days."
          }
        ]
      }
    ],
    "SessionId": "sampleSessionUUID"
  }
}
```

# for AWS HealthScribe 靜態資料加密
<a name="health-scribe-encryption"></a>

根據預設， AWS HealthScribe 提供靜態加密，以保護使用 AWS HealthScribe 受管 AWS Key Management Service (AWS KMS) 金鑰的敏感客戶資料。依預設加密靜態資料，有助於降低保護敏感資料所涉及的營運開銷和複雜性。此外，它還可讓您建置符合嚴格加密合規和法規要求的安全應用程式。當您建立 AWS HealthScribe 轉錄任務或啟動串流時，您可以指定客戶受管金鑰。這會新增第二層加密。
+ **AWS HealthScribe 受管 AWS KMS 金鑰** — AWS HealthScribe 預設會使用 AWS HealthScribe 受管 AWS Key Management Service (AWS KMS) 金鑰自動加密中繼檔案。您無法停用此加密層，或選擇替代加密類型。您無法檢視、管理或使用金鑰，或稽核其使用方式。不過，您不需要採取任何動作或變更任何程式，即可保護加密您資料的金鑰。
+ **客戶受管金鑰** — AWS HealthScribe 支援使用您建立、擁有和管理的對稱客戶受管金鑰，以透過現有的 AWS 擁有的加密新增第二層加密。您可以完全控制此層加密，因此能執行以下任務：
  + 建立和維護金鑰政策
  + 建立和維護 IAM 政策和授予
  + 啟用和停用金鑰政策
  + 輪換金鑰密碼編譯資料
  + 新增 標籤
  + 建立金鑰別名
  + 安排金鑰供刪除

  如需詳細資訊，請參閱《 AWS Key Management Service 開發人員指南》中的[客戶受管金鑰](https://docs.aws.amazon.com//kms/latest/developerguide/concepts.html#customer-cmk)。

**注意**  
AWS HealthScribe 會使用擁有 AWS的金鑰自動啟用靜態加密，免費保護個人身分識別資料。不過，使用客戶受管金鑰會產生 AWS KMS 費用。如需定價的詳細資訊，請參閱 [AWS Key Management Service 定價](https://aws.amazon.com//kms/pricing/)。  
 如需詳細資訊 AWS KMS，請參閱[什麼是 AWS Key Management Service](https://docs.aws.amazon.com//kms/latest/developerguide/overview.html) 。

**Topics**
+ [建立客戶受管金鑰](health-scribe-encryption-customer.md)
+ [指定 AWS HealthScribe 的客戶受管金鑰](#health-scribe-encryption-managed)
+ [AWS KMS 加密內容](#health-scribe-encryption-context)
+ [監控 AWS HealthScribe 的加密金鑰](#hscribe-monitoring-keys)

# 建立客戶受管金鑰
<a name="health-scribe-encryption-customer"></a>

 您可以使用 AWS 管理主控台或 AWS KMS APIs 來建立對稱客戶受管金鑰。若要建立對稱客戶受管金鑰，請遵循《 AWS Key Management Service 開發人員指南》中的[建立對稱客戶受管金鑰](https://docs.aws.amazon.com//kms/latest/developerguide/create-keys.html#create-symmetric-cmk)的步驟。

金鑰政策會控制客戶受管金鑰的存取權限。每個客戶受管金鑰都必須只有一個金鑰政策，其中包含決定誰可以使用金鑰及其使用方式的陳述式。在建立客戶受管金鑰時，可以指定金鑰政策。如需詳細資訊，請參閱《 AWS Key Management Service 開發人員指南》中的[管理對客戶受管金鑰的存取](https://docs.aws.amazon.com//kms/latest/developerguide/control-access-overview.html#managing-access)。

## AWS KMS AWS HealthScribe 的關鍵政策
<a name="health-scribe-key-policies"></a>

 如果您在與 [StartMedicalScribeJob](https://docs.aws.amazon.com//transcribe/latest/APIReference/API_StartMedicalScribeJob.html) 或 `ResourceAccessRole` [StartMedicalScribeStream](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartMedicalScribeStream.html) 請求`DataAccessRole`中指定為 IAM 的角色相同的帳戶中使用金鑰，則不需要更新金鑰政策。若要在與 DataAccessRole （用於轉錄任務） 或 ResourceAccessRole （用於串流） 不同的帳戶中使用客戶受管金鑰，您必須信任金鑰政策中的個別角色，才能執行下列動作：
+ [https://docs.aws.amazon.com//kms/latest/APIReference/API_Encrypt.html](https://docs.aws.amazon.com//kms/latest/APIReference/API_Encrypt.html)：允許使用客戶受管金鑰進行加密
+ [https://docs.aws.amazon.com//kms/latest/APIReference/API_Decrypt.html](https://docs.aws.amazon.com//kms/latest/APIReference/API_Decrypt.html)：允許使用客戶受管金鑰進行解密
+ [https://docs.aws.amazon.com//kms/latest/APIReference/API_DescribeKey.html](https://docs.aws.amazon.com//kms/latest/APIReference/API_DescribeKey.html) — 提供客戶受管金鑰詳細資訊，以允許 AWS HealthScribe 驗證金鑰

以下是可用來授予 ResourceAccessRole 跨帳戶許可的金鑰政策範例，以使用客戶受管金鑰進行 AWS HealthScribe 串流。若要將此政策用於轉錄任務，請更新 `Principal` 以使用 DataAccessRole ARN，並移除或修改加密內容。

------
#### [ JSON ]

****  

```
{
   "Version":"2012-10-17",		 	 	 
   "Statement":[
      {  
         "Sid": "AllowAccessForKeyAdministrators", 
         "Effect": "Allow", 
         "Principal": {
            "AWS": "arn:aws:iam::111122223333:root" 
         }, 
         "Action": [
           "kms:*" 
         ], 
         "Resource": "*"
      },
      {
         "Sid": "AllowAccessToResourceAccessRoleForMedicalScribe",
         "Effect": "Allow",
         "Principal": {
            "AWS": "arn:aws:iam::111122223333:role/ResourceAccessRole"
         },
         "Action": [
            "kms:Encrypt",
            "kms:Decrypt",
            "kms:GenerateDataKey*"
         ],
         "Resource": "*",
         "Condition": {
            "StringEquals": {
                "kms:EncryptionContext:aws:us-east-1:transcribe:medical-scribe:session-id": "1234abcd-12ab-34cd-56ef-123456SAMPLE"
            }
         }
      },
      {
         "Sid": "AllowAccessToResourceAccessRoleForDescribeKey",
         "Effect": "Allow",
         "Principal": {
             "AWS": "arn:aws:iam::111122223333:role/ResourceAccessRole"
         },
         "Action": "kms:DescribeKey",
         "Resource": "*"
     }
   ]
}
```

------

## 存取角色的 IAM 政策許可
<a name="health-scribe-key-data-access-role"></a>

 連接至 DataAccessRole 或 ResourceAccessRole 的 IAM 政策必須授予執行必要 AWS KMS 動作的許可，無論客戶受管金鑰和角色是否位於相同或不同的帳戶中。此外，角色的信任政策必須授予 AWS HealthScribe 擔任角色的許可。

下列 IAM 政策範例顯示如何授予 AWS HealthScribe 串流的 ResourceAccessRole 許可。若要將此政策用於轉錄任務，請將 取代`transcribe.streaming.amazonaws.com`為 ，`transcribe.amazonaws.com`並移除或修改加密內容。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "kms:Encrypt",
                "kms:Decrypt",
                "kms:GenerateDataKey*"
            ],
            "Resource": "arn:aws:kms:us-west-2:111122223333:key/KMS-Example-KeyId",
            "Condition": {
                "StringEquals": {
                    "kms:ViaService": "transcribe.streaming.amazonaws.com",
                    "kms:EncryptionContext:aws:us-east-1:transcribe:medical-scribe:session-id": "1234abcd-12ab-34cd-56ef-123456SAMPLE"
                }
            }
        },
        {
            "Effect": "Allow",
            "Action": [
                "kms:DescribeKey"
            ],
            "Resource": "arn:aws:kms:us-west-2:111122223333:key/KMS-Example-KeyId",
            "Condition": {
                "StringEquals": {
                    "kms:ViaService": "transcribe.streaming.amazonaws.com"
                }
            }
        }
    ]
}
```

------

以下是 ResourceAccessRole 的信任政策範例。對於 DataAccessRole，將 取代`transcribe.streaming.amazonaws.com`為 `transcribe.amazonaws.com`。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "transcribe.streaming.amazonaws.com"
            },
            "Action": "sts:AssumeRole",
            "Condition": {
                "StringEquals": {
                    "aws:SourceAccount": "111122223333"
                },
                "ArnLike": {
                    "aws:SourceArn": "arn:aws:transcribe:us-west-2:111122223333:*"
                }
            }
        }
    ]
}
```

------

 如需在[政策中指定許可](https://docs.aws.amazon.com//kms/latest/developerguide/control-access-overview.html#overview-policy-elements)或對[金鑰存取進行疑難排解](https://docs.aws.amazon.com//kms/latest/developerguide/policy-evaluation.html#example-no-iam)的詳細資訊，請參閱 AWS Key Management Service 開發人員指南。

## 指定 AWS HealthScribe 的客戶受管金鑰
<a name="health-scribe-encryption-managed"></a>

 您可以將客戶受管金鑰指定為轉錄任務或串流的第二層加密。
+ 對於轉錄任務，您可以在 [StartMedicalScribeJob](https://docs.aws.amazon.com//transcribe/latest/APIReference/API_StartMedicalScribeJob.html) API 操作的 [OutputEncryptionKMSKeyId](https://docs.aws.amazon.com//transcribe/latest/APIReference/API_StartMedicalScribeJob.html#transcribe-StartMedicalScribeJob-request-OutputEncryptionKMSKeyId) 中指定金鑰。
+ 對於串流，您可以在 MedicalScribeConfigurationEvent 的 [MedicalScribeEncryptionSettings](https://docs.aws.amazon.com//transcribe/latest/APIReference/API_streaming_MedicalScribeEncryptionSettings.html) 中指定 金鑰。 [MedicalScribeConfigurationEvent](https://docs.aws.amazon.com//transcribe/latest/APIReference/API_streaming_MedicalScribeConfigurationEvent.html) 

## AWS KMS 加密內容
<a name="health-scribe-encryption-context"></a>

 AWS KMS 加密內容是純文字、非私密金鑰：值對的映射。此映射代表額外的已驗證資料，稱為加密內容對，可為您的資料提供多一層的安全性。 AWS HealthScribe 需要對稱加密金鑰，才能將 AWS HealthScribe 輸出加密到客戶指定的 Amazon S3 儲存貯體。若要了解詳細資訊，請參閱 [AWS KMS中的非對稱金鑰](https://docs.aws.amazon.com//kms/latest/developerguide/symmetric-asymmetric.html)。

 建立加密內容對時，*請勿*包含敏感資訊。加密內容不是秘密，它在 CloudTrail 日誌中以純文字顯示 （因此您可以使用它來識別和分類密碼編譯操作）。加密內容對可以包含特殊字元，例如底線 (`_`)、破折號 (`-`)、斜線 (`/`、`\`) 和冒號 (`:`)。

**提示**  
 將加密內容對中的值與要加密的資料建立關聯會很實用。雖然不是必要的舉動，但我們建議您使用與加密內容相關的非敏感中繼資料，例如檔案名稱、標頭值或未加密的資料庫欄位。  
 若要搭配 API 使用輸出加密，請在 [StartMedicalScribeJob](https://docs.aws.amazon.com//transcribe/latest/APIReference/API_StartMedicalScribeJob.html) 操作中設定 [KMSEncryptionContext](https://docs.aws.amazon.com//transcribe/latest/APIReference/API_StartMedicalScribeJob.html#transcribe-StartMedicalScribeJob-request-KMSEncryptionContext) 參數。為了提供輸出加密操作的加密內容，[OutputEncryptionKMSKeyId](https://docs.aws.amazon.com//transcribe/latest/APIReference/API_StartMedicalScribeJob.html#transcribe-StartMedicalScribeJob-request-OutputEncryptionKMSKeyId) 參數必須參考對稱 AWS KMS 金鑰 ID。  
對於串流，您可以在 [MedicalScribeConfigurationEvent](https://docs.aws.amazon.com//transcribe/latest/APIReference/API_streaming_MedicalScribeConfigurationEvent.html) `KmsEncryptionContext`的 MedicalScribeEncryptionSettings 中指定 的鍵值對。 [MedicalScribeEncryptionSettings](https://docs.aws.amazon.com//transcribe/latest/APIReference/API_streaming_MedicalScribeEncryptionSettings.html)   
 您可以使用 [AWS KMS 條件金鑰](https://docs.aws.amazon.com//kms/latest/developerguide/policy-conditions.html#conditions-kms)搭配 IAM 政策，根據[密碼編譯操作](https://docs.aws.amazon.com//kms/latest/developerguide/concepts.html#cryptographic-operations)請求中使用的加密內容來控制對對稱加密 AWS KMS 金鑰的存取。如需加密內容政策範例，請參閱 [AWS KMS 加密內容政策](https://docs.aws.amazon.com//transcribe/latest/dg/security_iam_id-based-policy-examples.html#kms-context-policy)。  
 加密內容是選用項目，但建議使用。如需詳細資訊，請參閱[加密內容](https://docs.aws.amazon.com//kms/latest/developerguide/concepts.html#encrypt_context)。

### AWS HealthScribe 加密內容
<a name="hscribe-context-details"></a>

AWS HealthScribe 在所有 AWS Key Management Service 密碼編譯操作中使用相同的加密內容。加密內容是字串對字串的映射，可以自訂為您想要的任何項目。

```
"encryptionContext": {
   "ECKey": "ECValue"
   ...
}
```

對於 AWS HealthScribe 串流，以下是服務產生的預設加密內容。它會將此內容套用到您提供的任何加密內容上。

```
"encryptionContext": {
  "aws:<region>:transcribe:medical-scribe:session-id": "1234abcd-12ab-34cd-56ef-123456SAMPLE"
}
```

對於 AWS HealthScribe 轉錄任務，以下是服務產生的預設加密內容。它會將此內容套用到您提供的任何加密內容上。

```
"encryptionContext": {
  "aws:<region>:transcribe:medical-scribe:job-name": "<job-name>",
  "aws:<region>:transcribe:medical-scribe:start-time-epoch-ms": "<job-start-time>"
}
```

如果您不提供任何加密內容，則所有 AWS KMS 密碼編譯操作只會使用服務產生的加密內容。

**使用加密內容監控 AWS HealthScribe **

當您使用對稱客戶受管金鑰來加密靜態 in AWS HealthScribe 中的資料時，您也可以使用稽核記錄和日誌中的加密內容來識別客戶受管金鑰的使用方式。加密內容也會出現在 AWS CloudTrail 或 CloudWatch Logs 產生的日誌中。

**使用加密內容控制對客戶受管金鑰的存取**

 您也可以在金鑰政策和 IAM 政策中，使用加密內容來控制對對稱客戶受管金鑰的存取。

 以下是授予特定加密內容之客戶受管金鑰存取權的金鑰政策陳述式範例。此政策陳述式中的 條件要求 KMS 金鑰使用具有指定加密內容的加密內容限制條件。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "AllowAccessToResourceAccessRoleForMedicalScribe",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::111122223333:role/ResourceAccessRole"
            },
            "Action": [
                "kms:Encrypt",
                "kms:Decrypt",
                "kms:GenerateDataKey*"
            ],
            "Resource": "arn:aws:kms:us-west-2:111122223333:key/KMS-Example-KeyId",
            "Condition": {
                "StringEquals": {
                    "kms:EncryptionContext:aws:us-east-1:transcribe:medical-scribe:session-id": "1234abcd-12ab-34cd-56ef-123456SAMPLE",
                    "kms:EncryptionContext:ECKey": "ECValue"
                }
            }
        },
        {
            "Sid": "AllowAccessToResourceAccessRoleForDescribeKey",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::111122223333:role/ResourceAccessRole"
            },
            "Action": "kms:DescribeKey",
            "Resource": "arn:aws:kms:us-west-2:111122223333:key/KMS-Example-KeyId"
        }
    ]
}
```

------

## 監控 AWS HealthScribe 的加密金鑰
<a name="hscribe-monitoring-keys"></a>

當您搭配 AWS HealthScribe 使用 AWS Key Management Service 客戶受管金鑰時，您可以使用 AWS CloudTrail 或 CloudWatch 日誌來追蹤 AWS HealthScribe 傳送的請求 AWS KMS。

下列範例是 CloudTrail Encrypt 和 Decrypt 事件，您可以使用這些事件來監控 AWS HealthScribe 如何使用您的客戶受管金鑰。

**加密**

```
{
   "eventVersion":"1.09",
   "userIdentity":{
      "type":"AssumedRole",
      "principalId":"AROAIGDTESTANDEXAMPLE:Sampleuser01",
      "arn":"arn:aws:sts::123456789012:assumed-role/Admin/Sampleuser01",
      "accountId":"123456789012",
      "accessKeyId":"AKIAIOSFODNN7EXAMPLE3",
      "sessionContext":{
         "sessionIssuer":{
            "type":"Role",
            "principalId":"AROAIGDTESTANDEXAMPLE:Sampleuser01",
            "arn":"arn:aws:sts::123456789012:assumed-role/Admin/Sampleuser01",
            "accountId":"123456789012",
            "userName":"Admin"
         },
         "attributes":{
            "creationDate":"2024-08-16T01:10:05Z",
            "mfaAuthenticated":"false"
         }
      },
      "invokedBy":"transcribe.streaming.amazonaws.com"
   },
   "eventTime":"2024-08-16T01:10:05Z",
   "eventSource":"kms.amazonaws.com",
   "eventName":"Encrypt",
   "awsRegion":"us-east-1",
   "sourceIPAddress":"transcribe.streaming.amazonaws.com",
   "userAgent":"transcribe.streaming.amazonaws.com",
   "requestParameters":{
      "encryptionContext":{
         "aws:us-east-1:transcribe:medical-scribe:session-id":"1234abcd-12ab-34cd-56ef-123456SAMPLE"
      },
      "encryptionAlgorithm":"SYMMETRIC_DEFAULT",
      "keyId":"1234abcd-12ab-34cd-56ef-1234567890ab"
   },
   "responseElements":null,
   "requestID":"cbe0ac33-8cca-49e5-9bb5-dc2b8dfcb389",
   "eventID":"1b9fedde-aa96-48cc-9dd9-a2cce2964b3c",
   "readOnly":true,
   "resources":[
      {
         "accountId":"123456789012",
         "type":"AWS::KMS::Key",
         "ARN":"arn:aws:kms:us-west-2:123456789012:key/1234abcd-12ab-34cd-56ef-123456SAMPLE"
      }
   ],
   "eventType":"AwsApiCall",
   "managementEvent":true,
   "recipientAccountId":"123456789012",
   "eventCategory":"Management"
}
```

**解密**

```
{
   "eventVersion":"1.09",
   "userIdentity":{
      "type":"AssumedRole",
      "principalId":"AROAIGDTESTANDEXAMPLE:Sampleuser01",
      "arn":"arn:aws:sts::123456789012:assumed-role/Admin/Sampleuser01",
      "accountId":"123456789012",
      "accessKeyId":"AKIAIOSFODNN7EXAMPLE3",
      "sessionContext":{
         "sessionIssuer":{
            "type":"Role",
            "principalId":"AROAIGDTESTANDEXAMPLE:Sampleuser01",
            "arn":"arn:aws:sts::123456789012:assumed-role/Admin/Sampleuser01",
            "accountId":"123456789012",
            "userName":"Admin"
         },
         "attributes":{
            "creationDate":"2024-08-16T20:47:04Z",
            "mfaAuthenticated":"false"
         }
      },
      "invokedBy":"transcribe.streaming.amazonaws.com"
   },
   "eventTime":"2024-08-16T20:47:04Z",
   "eventSource":"kms.amazonaws.com",
   "eventName":"Decrypt",
   "awsRegion":"us-east-1",
   "sourceIPAddress":"transcribe.streaming.amazonaws.com",
   "userAgent":"transcribe.streaming.amazonaws.com",
   "requestParameters":{
      "keyId":"mrk-de27f019178f4fbf86512ab03ba860be",
      "encryptionAlgorithm":"SYMMETRIC_DEFAULT",
      "encryptionContext":{
         "aws:us-east-1:transcribe:medical-scribe:session-id":"1234abcd-12ab-34cd-56ef-123456SAMPLE"
      }
   },
   "responseElements":null,
   "requestID":"8b7fb865-48be-4e03-ac3d-e7bee3ba30a1",
   "eventID":"68b7a263-d410-4701-9e2b-20c196628966",
   "readOnly":true,
   "resources":[
      {
         "accountId":"123456789012",
         "type":"AWS::KMS::Key",
         "ARN":"arn:aws:kms:us-west-2:123456789012:key/1234abcd-12ab-34cd-56ef-123456SAMPLE"
      }
   ],
   "eventType":"AwsApiCall",
   "managementEvent":true,
   "recipientAccountId":"123456789012",
   "eventCategory":"Management"
}
```