

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 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 데이터 스토어에 인스턴스를 하나 이상 저장합니다. | 
| StoreDICOMStudy | 지정된 연구 인스턴스 UID에 해당하는 하나 이상의 인스턴스를 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 파일 저장**  
단일 멀티파트 업로드 작업으로 여러 P10 파일을 업로드할 수 있습니다. 다음 셸 명령은 두 개의 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
```