

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# SDK と の開始方法 AWS CLI
<a name="data-transformation-getting-started-cli"></a>

## インストールと設定
<a name="data-transformation-getting-started-cli-install"></a>

インストールと設定の手順については、[「 のインストール AWS CLI](https://docs.aws.amazon.com/healthlake/latest/devguide/getting-started-setting-up.html#setting-up-install-cli)」を参照してください。

## ステップ 1: 変換プロファイルを作成する
<a name="data-transformation-getting-started-cli-step1"></a>

### AWS スタータープロファイルから開始 (CCDA のみ)
<a name="data-transformation-getting-started-cli-step1-starter"></a>

```
aws healthlake create-data-transformation-profile \
  --region us-west-2 \
  --source-format CCDA \
  --profile-name "My CCDA Profile" \
  --source '{"StarterProfile": {"StarterProfileName": "ccda-starter-kit-v1"}}'
```

### サンプルデータから開始 (CSV のみ)
<a name="data-transformation-getting-started-cli-step1-csv"></a>

プロファイルの作成:

```
aws healthlake create-data-transformation-profile \
  --region us-west-2 \
  --source-format CSV \
  --profile-name "Patient CSV Mapping" \
  --source '{"SampleData": {"S3Uri": "s3://my-bucket/samples/patient-data.csv"}}'
```

AI エージェントを実行して、最初の YAML マッピングを作成します。

エージェントと新しい会話を開始し、新しい会話 ID を取得します。API を再度呼び出します。今回は、前のレスポンスと実際のリクエストから ConversationId を渡します。CSV プロファイルの場合、エージェントは作成時に指定したサンプルファイルを分析し、YAML マッピングを生成します。

```
aws healthlake update-profile-with-agent \
  --region us-west-2 \
  --profile-id "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6" \
  --source-format CSV \
  --conversation-id "00154593-c867-4e4c-b870-25fb5237e54f" \
  --input-message '{"Body": "Generate a profile to convert my CSVs into FHIR.", "Type": "normal"}'
```

同じ ConversationId を使用して会話を続行し、マッピングを複数のターンにわたって絞り込みます (例：「RACE\_CD 列を FHIR 拡張機能にマッピングする」）。エージェントから変更の確認を求められた場合は、「Type」：「confirmation\_response」と応答します。

### ローカルマッピングから開始する
<a name="data-transformation-getting-started-cli-step1-raw"></a>

```
aws healthlake create-data-transformation-profile \
  --region us-west-2 \
  --source-format CCDA \
  --profile-name "CI/CD Profile" \
  --source '{"ProfileMapping": {"ProfileMapping": {"Resources/Patient.vm": "#set($patient = $input)..."}}}'
```

### 既存のプロファイルからクローンを作成する
<a name="data-transformation-getting-started-cli-step1-clone"></a>

```
aws healthlake create-data-transformation-profile \
  --region us-east-1 \
  --source-format CCDA \
  --profile-name test-profile-clone \
  --source '{"ExistingVersionedProfileId": {"ProfileId": "e41af4b891d6f9211b42b90435cf0cea", "Version": 0}}'
```

レスポンス:

```
{
    "ProfileId": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6",
    "Version": 0,
    "SourceFormat": "CCDA",
    "TargetFormat": "FHIR_R4",
    "ProfileName": "My CCDA Profile",
    "LastUpdatedAt": "2026-07-01T12:00:00Z"
}
```

プロファイルはドラフト状態 (バージョン 0) で作成されます。

## ステップ 2: AI エージェントでプロファイルをカスタマイズする (オプション)
<a name="data-transformation-getting-started-cli-step2"></a>

エージェントと新しい会話を開始し、新しい会話 ID を取得します。もう一度 API を呼び出し、今度は ConversationId を渡します。

```
aws healthlake update-profile-with-agent \
  --region us-west-2 \
  --profile-id "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6" \
  --source-format CCDA \
  --conversation-id "conv-a1b2c3d4-e5f6-7890" \
  --input-message '{"Body": "Add a mapping for Medication resources", "Type": "normal"}'
```

レスポンス:

```
{
    "chatOutput": {
        "body": "I can help you add a Medication resource mapping. Which CCDA section should I map from?",
        "type": "options",
        "optionsList": ["Medications Section", "Discharge Medications", "Immunizations"]
    },
    "conversationId": "conv-a1b2c3d4-e5f6-7890"
}
```

返された conversationId で会話を続行します。

```
aws healthlake update-profile-with-agent \
  --region us-west-2 \
  --profile-id "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6" \
  --source-format CCDA \
  --input-message '{"body": "Medications Section", "type": "confirmation_response"}' \
  --conversation-id "conv-a1b2c3d4-e5f6-7890"
```

## ステップ 3: 同期変換でテストする (オプション)
<a name="data-transformation-getting-started-cli-step3"></a>

同期変換エンドポイントは REST 専用です。公開する前に、サンプルドキュメントに対してプロファイルをテストします。

```
curl -X POST "https://datatransformation.healthlake.us-west-2.amazonaws.com/transform-data" \
  --aws-sigv4 "aws:amz:us-west-2:healthlake" \
  --user "${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}" \
  -H "x-amz-security-token: ${AWS_SESSION_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "ProfileId": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6",
    "InputData": {"CcdaInput": "<?xml version=\"1.0\"?><ClinicalDocument>...</ClinicalDocument>"},
    "DriftDetectionEnabled": true
  }'
```

レスポンス:

```
{
    "TransformedData": "{\"resourceType\":\"Bundle\",\"type\":\"collection\",\"entry\":[...]}",
    "DriftReport": "{\"coverageRate\":0.95,\"unmappedElements\":[...]}"
}
```
+ TransformedData: JSON エンコードされた FHIR バンドル文字列として変換された FHIR リソース。
+ DriftReport: DriftDetectionEnabled が true の場合にのみ表示されます。カバレッジ率とマッピングされていないソース要素を示す JSON エンコードされたドリフトレポート。

**注記**  
ProvenanceEnabled のデフォルトは true です。リクエストで「ProvenanceEnabledリソースが生成されます。

## ステップ 4: プロファイルを公開する
<a name="data-transformation-getting-started-cli-step4"></a>

```
aws healthlake publish-data-transformation-profile \
  --region us-west-2 \
  --profile-id "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6" \
  --source-format CCDA \
  --change-description "Initial release - Patient, Observation, Medication mappings"
```

公開すると、イミュータブルバージョン (v1) が作成されます。ドラフトは編集可能であり、一括ジョブは自動的に最新の公開バージョンを使用します。

## ステップ 5: データを FHIR に変換する
<a name="data-transformation-getting-started-cli-convert"></a>

データ変換エージェントには、ソースデータを FHIR R4 に変換する 3 つの方法があります。

### 1. 同期変換
<a name="data-transformation-getting-started-cli-sync"></a>

```
curl -X POST "https://datatransformation.healthlake.us-west-2.amazonaws.com/transform-data" \
  --aws-sigv4 "aws:amz:us-west-2:healthlake" \
  --user "${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}" \
  -H "x-amz-security-token: ${AWS_SESSION_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "ProfileId": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6",
    "InputData": {"CcdaInput": "<?xml version=\"1.0\"?><ClinicalDocument>...</ClinicalDocument>"},
    "DriftDetectionEnabled": true
  }'
```

### 2. Amazon S3 への一括変換ジョブを実行する
<a name="data-transformation-getting-started-cli-bulk-s3"></a>

```
aws healthlake start-data-transformation-job \
  --region us-west-2 \
  --profile-id "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6" \
  --input-data-config '{"S3Uri": "s3://my-source-bucket/ccda-files/", "SourceFormat": "CCDA"}' \
  --output-data-config '{"S3Configuration": {"S3Uri": "s3://my-output-bucket/fhir-output/", "KmsKeyId": "arn:aws:kms:us-west-2:123456789012:key/abcd1234"}}' \
  --data-access-role-arn "arn:aws:iam::123456789012:role/DTA-DataAccessRole" \
  --client-token "unique-token-$(date +%s)" \
  --job-name "cardiology-batch-july" \
  --drift-detection-enabled
```

ジョブをモニタリングします。

```
# Check status
aws healthlake describe-data-transformation-job \
  --region us-west-2 \
  --job-id "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6"

# List recent completed jobs
aws healthlake list-data-transformation-jobs \
  --region us-west-2 \
  --job-status COMPLETED \
  --submitted-after "2026-07-01T00:00:00Z"
```

### 3. 一括変換ジョブを実行して HealthLake データストアに取り込む
<a name="data-transformation-getting-started-cli-bulk-import"></a>

ソースファイルを変換し、生成された FHIR リソースを 1 つのステップで HealthLake データストアに直接ロードするには、変換プロファイルフィールドで既存の StartFHIRImportJob API を使用します。

```
aws healthlake start-fhir-import-job \
  --region us-west-2 \
  --datastore-id "your-datastore-id" \
  --input-data-config '{"S3Uri": "s3://my-source-bucket/ccda-files/"}' \
  --job-output-data-config '{"S3Configuration": {"S3Uri": "s3://my-output-bucket/import-output/", "KmsKeyId": "arn:aws:kms:us-west-2:123456789012:key/abcd1234"}}' \
  --data-access-role-arn "arn:aws:iam::123456789012:role/DTA-DataAccessRole" \
  --profile-id "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6" \
  --input-format "CCDA" \
  --drift-detection-enabled \
  --job-name "cardiology-import-july" \
  --client-token "import-$(date +%s)"
```

これにより、2 フェーズのジョブが開始されます。まず、サービスは公開されたプロファイルを使用してソースファイルを変換し、次に結果の FHIR リソースをデータストアに取り込みます。取り込みが完了すると、データは FHIR REST API を介してすぐにクエリできます。

ジョブをモニタリングします。

```
aws healthlake describe-fhir-import-job \
  --region us-west-2 \
  --datastore-id "your-datastore-id" \
  --job-id "returned-job-id"
```

**注記**  
データストアは ACTIVE 状態である必要があります。Provenance はデフォルトで有効になっています。データアクセスロールには、スタンドアロンジョブと同じ Amazon S3 と AWS KMS アクセス許可が必要です。