

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

# STOW-RS を使用したインスタンスの保存
<a name="dicomweb-storing"></a>

AWS HealthImaging は、データをインポートするための [https://www.dicomstandard.org/using/dicomweb/store-stow-rs](https://www.dicomstandard.org/using/dicomweb/store-stow-rs) APIs の表現を提供します。これらの APIs を使用して、DICOM データを HealthImaging データストアに同期的に保存します。

次の表は、データのインポートに使用できる DICOMweb STOW-RS APIs の HealthImaging 表現を示しています。


**DICOMweb STOW-RS APIs の HealthImaging 表現**  

| 名前 | 説明 | 
| --- | --- | 
| StoreDICOM | HealthImaging データストアに 1 つ以上のインスタンスを保存します。 | 
| StoreDICOMStudy | 指定された治験インスタンス UID に対応する 1 つ以上のインスタンスを HealthImaging データストアに保存します。 | 

`StoreDICOM` および `StoreDICOMStudy`アクションでインポートされたデータは、非同期[インポートジョブ](https://docs.aws.amazon.com/healthimaging/latest/devguide/understanding-import-jobs.html)と同じロジックを使用して、新しいプライマリイメージセットとして編成されるか、既存のプライマリイメージセットに追加されます。新しくインポートされた DICOM P10 データのメタデータ要素が既存のプライマリ[イメージセット](https://docs.aws.amazon.com/healthimaging/latest/devguide/getting-started-concepts.html#concept-image-set)と競合する場合、新しいデータは非プライマリ[イメージセット](https://docs.aws.amazon.com/healthimaging/latest/devguide/getting-started-concepts.html#concept-image-set)に追加されます。

**注記**  
これらのアクションは、リクエストごとに最大 1GB の DICOM データのアップロードをサポートします。
API レスポンスは、DICOMweb STOW-RS 標準に準拠した JSON 形式になります。

**StoreDICOM リクエストを開始するには**  


1. AWS リージョン、HealthImaging `datastoreId`、DICOM P10 ファイル名を収集します。

1. フォームのリクエストの URL を作成します。 `https://dicom-medical-imaging.region.amazonaws.com/datastore/datastore-id/studies`

1. などの任意のコマンドを使用して、DICOM P10 ファイルの内容の長さを決定します`$(stat -f %z $FILENAME)`。

1. リクエストを準備して送信します。 は、[AWS 署名バージョン 4 ](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv.html)の署名プロトコルで HTTP POST リクエスト`StoreDICOM`を使用します。

 

**Example 例 1: `StoreDICOM`アクションを使用して DICOM P10 ファイルを保存するには**  

```
curl -X POST -v \
  'https://dicom-medical-imaging.us-east-1.amazonaws.com/datastore/d9a2a515ab294163a2d2f4069eed584c/studies' \
  --aws-sigv4 "aws:amz:$AWS_REGION:medical-imaging" \
  --user "$AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY" \
  --header "x-amz-security-token:$AWS_SESSION_TOKEN" \
  --header "x-amz-content-sha256: STREAMING-AWS4-HMAC-SHA256-PAYLOAD" \
  --header "x-amz-decoded-content-length: $CONTENT_LENGTH" \
  --header 'Accept: application/dicom+json' \
  --header "Content-Type: application/dicom" \
  --upload-file $FILENAME
```

**Example 例 2: `StoreDICOMStudy`アクションを使用して DICOM P10 ファイルを保存するには**  
StoreDICOM と StoreDICOMStudy の唯一の違いは、治験インスタンス UID が StoreDICOMStudy のパラメータとして渡され、アップロードされたインスタンスが指定された治験のメンバーであることです。  

```
curl -X POST -v \
  'https://dicom-medical-imaging.us-east-1.amazonaws.com/datastore/d9a2a515ab294163a2d2f4069eed584c/studies/1.3.6.1.4.1.5962.1.2.4.20040826285059.5457' \
  --aws-sigv4 "aws:amz:$AWS_REGION:medical-imaging" \
  --user "$AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY" \
  --header "x-amz-security-token:$AWS_SESSION_TOKEN" \
  --header "x-amz-content-sha256: STREAMING-AWS4-HMAC-SHA256-PAYLOAD" \
  --header "x-amz-decoded-content-length: $CONTENT_LENGTH" \
  --header 'Accept: application/dicom+json' \
  --header "Content-Type: application/dicom" \
  --upload-file $FILENAME
```

**Example 例 3: マルチパート HTTP ペイロードで DICOM P10 ファイルを保存するには**  
1 つのマルチパートアップロードアクションで複数の P10 ファイルをアップロードできます。次のシェルコマンドは、2 つの P10 ファイルを含むマルチパートペイロードをアセンブルし、 `StoreDICOM`アクションでアップロードする方法を示しています。  

```
#!/bin/sh
FILENAME=multipart.payload
BOUNDARY=2a8a02b9-0ed3-c8a7-7ebd-232427531940
boundary_str="--$BOUNDARY\r\n"
mp_header="${boundary_str}Content-Type: application/dicom\r\n\r\n"

##Encapsulate the binary DICOM file 1.
printf '%b' "$mp_header" > $FILENAME
cat file1.dcm >> $FILENAME

##Encapsulate the binary DICOM file 2 (note the additional CRLF before the part header).
printf '%b' "\r\n$mp_header" >> $FILENAME
cat file2.dcm >> $FILENAME

## Add the closing boundary.
printf '%b' "\r\n--$BOUNDARY--" >> $FILENAME

## Obain the payload size in bytes.
multipart_payload_size=$(stat -f%z "$FILENAME")

# Execute CURL POST request with AWS SIGv4
curl -X POST -v \
  'https://iad-dicom.external-healthlake-imaging.ai.aws.dev/datastore/b5f34e91ca734b39a54ac11ea42416cf/studies' \
  --aws-sigv4 "aws:amz:us-east-1:medical-imaging" \
  --user "AKIAIOSFODNN7EXAMPLE:wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" \
  --header "x-amz-content-sha256: STREAMING-AWS4-HMAC-SHA256-PAYLOAD" \
  --header "x-amz-decoded-content-length: ${multipart_payload_size}" \
  --header 'Accept: application/dicom+json' \
  --header "Content-Type: multipart/related; type=\"application/dicom\"; boundary=\"${BOUNDARY}\"" \
  --data-binary "@$FILENAME"

# Delete the payload file
rm $FILENAME
```