Gunakan CopyImageSet dengan AWS SDKatau CLI - AWS HealthImaging

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

Gunakan CopyImageSet dengan AWS SDKatau CLI

Contoh kode berikut menunjukkan cara menggunakanCopyImageSet.

CLI
AWS CLI

Contoh 1: Untuk menyalin set gambar tanpa tujuan.

copy-image-setContoh berikut membuat salinan duplikat dari gambar yang ditetapkan tanpa tujuan.

aws medical-imaging copy-image-set \ --datastore-id 12345678901234567890123456789012 \ --source-image-set-id ea92b0d8838c72a3f25d00d13616f87e \ --copy-image-set-information '{"sourceImageSet": {"latestVersionId": "1" } }'

Output:

{ "destinationImageSetProperties": { "latestVersionId": "2", "imageSetWorkflowStatus": "COPYING", "updatedAt": 1680042357.432, "imageSetId": "b9a06fef182a5f992842f77f8e0868e5", "imageSetState": "LOCKED", "createdAt": 1680042357.432 }, "sourceImageSetProperties": { "latestVersionId": "1", "imageSetWorkflowStatus": "COPYING_WITH_READ_ONLY_ACCESS", "updatedAt": 1680042357.432, "imageSetId": "ea92b0d8838c72a3f25d00d13616f87e", "imageSetState": "LOCKED", "createdAt": 1680027126.436 }, "datastoreId": "12345678901234567890123456789012" }

Contoh 2: Untuk menyalin gambar yang ditetapkan dengan tujuan.

copy-image-setContoh berikut membuat salinan duplikat dari gambar yang ditetapkan dengan tujuan.

aws medical-imaging copy-image-set \ --datastore-id 12345678901234567890123456789012 \ --source-image-set-id ea92b0d8838c72a3f25d00d13616f87e \ --copy-image-set-information '{"sourceImageSet": {"latestVersionId": "1" }, "destinationImageSet": { "imageSetId": "b9a06fef182a5f992842f77f8e0868e5", "latestVersionId": "1"} }'

Output:

{ "destinationImageSetProperties": { "latestVersionId": "2", "imageSetWorkflowStatus": "COPYING", "updatedAt": 1680042505.135, "imageSetId": "b9a06fef182a5f992842f77f8e0868e5", "imageSetState": "LOCKED", "createdAt": 1680042357.432 }, "sourceImageSetProperties": { "latestVersionId": "1", "imageSetWorkflowStatus": "COPYING_WITH_READ_ONLY_ACCESS", "updatedAt": 1680042505.135, "imageSetId": "ea92b0d8838c72a3f25d00d13616f87e", "imageSetState": "LOCKED", "createdAt": 1680027126.436 }, "datastoreId": "12345678901234567890123456789012" }

Contoh 3: Untuk menyalin subset instance dari gambar sumber yang disetel ke kumpulan gambar tujuan.

copy-image-setContoh berikut menyalin satu DICOM contoh dari gambar sumber yang disetel ke set gambar tujuan. Parameter gaya disediakan untuk mengesampingkan inkonsistensi dalam atribut tingkat Pasien, Studi, dan Seri.

aws medical-imaging copy-image-set \ --datastore-id 12345678901234567890123456789012 \ --source-image-set-id ea92b0d8838c72a3f25d00d13616f87e \ --copy-image-set-information '{"sourceImageSet": {"latestVersionId": "1","DICOMCopies": {"copiableAttributes": "{\"SchemaVersion\":\"1.1\",\"Study\":{\"Series\":{\"1.3.6.1.4.1.5962.99.1.3673257865.2104868982.1369432891697.3666.0\":{\"Instances\":{\"1.3.6.1.4.1.5962.99.1.3673257865.2104868982.1369432891697.3669.0\":{}}}}}}"}},"destinationImageSet": {"imageSetId": "b9eb50d8ee682eb9fcf4acbf92f62bb7","latestVersionId": "1"}}' \ --force

Output:

{ "destinationImageSetProperties": { "latestVersionId": "2", "imageSetWorkflowStatus": "COPYING", "updatedAt": 1680042505.135, "imageSetId": "b9eb50d8ee682eb9fcf4acbf92f62bb7", "imageSetState": "LOCKED", "createdAt": 1680042357.432 }, "sourceImageSetProperties": { "latestVersionId": "1", "imageSetWorkflowStatus": "COPYING_WITH_READ_ONLY_ACCESS", "updatedAt": 1680042505.135, "imageSetId": "ea92b0d8838c72a3f25d00d13616f87e", "imageSetState": "LOCKED", "createdAt": 1680027126.436 }, "datastoreId": "12345678901234567890123456789012" }

Untuk informasi selengkapnya, lihat Menyalin set gambar di AWS HealthImaging Panduan Pengembang.

  • Untuk API detailnya, lihat CopyImageSetdi AWS CLI Referensi Perintah.

Java
SDKuntuk Java 2.x
/** * Copy an AWS HealthImaging image set. * * @param medicalImagingClient - The AWS HealthImaging client object. * @param datastoreId - The datastore ID. * @param imageSetId - The image set ID. * @param latestVersionId - The version ID. * @param destinationImageSetId - The optional destination image set ID, ignored if null. * @param destinationVersionId - The optional destination version ID, ignored if null. * @param force - The force flag. * @param subsets - The optional subsets to copy, ignored if null. * @return - The image set ID of the copy. * @throws MedicalImagingException - Base exception for all service exceptions thrown by AWS HealthImaging. */ public static String copyMedicalImageSet(MedicalImagingClient medicalImagingClient, String datastoreId, String imageSetId, String latestVersionId, String destinationImageSetId, String destinationVersionId, boolean force, Vector<String> subsets) { try { CopySourceImageSetInformation.Builder copySourceImageSetInformation = CopySourceImageSetInformation.builder() .latestVersionId(latestVersionId); // Optionally copy a subset of image instances. if (subsets != null) { String subsetInstanceToCopy = getCopiableAttributesJSON(imageSetId, subsets); copySourceImageSetInformation.dicomCopies(MetadataCopies.builder() .copiableAttributes(subsetInstanceToCopy) .build()); } CopyImageSetInformation.Builder copyImageSetBuilder = CopyImageSetInformation.builder() .sourceImageSet(copySourceImageSetInformation.build()); // Optionally designate a destination image set. if (destinationImageSetId != null) { copyImageSetBuilder = copyImageSetBuilder.destinationImageSet(CopyDestinationImageSet.builder() .imageSetId(destinationImageSetId) .latestVersionId(destinationVersionId) .build()); } CopyImageSetRequest copyImageSetRequest = CopyImageSetRequest.builder() .datastoreId(datastoreId) .sourceImageSetId(imageSetId) .copyImageSetInformation(copyImageSetBuilder.build()) .force(force) .build(); CopyImageSetResponse response = medicalImagingClient.copyImageSet(copyImageSetRequest); return response.destinationImageSetProperties().imageSetId(); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); throw e; } }

Fungsi utilitas untuk membuat atribut yang dapat disalin.

/** * Create a JSON string of copiable image instances. * * @param imageSetId - The image set ID. * @param subsets - The subsets to copy. * @return A JSON string of copiable image instances. */ private static String getCopiableAttributesJSON(String imageSetId, Vector<String> subsets) { StringBuilder subsetInstanceToCopy = new StringBuilder( """ { "SchemaVersion": 1.1, "Study": { "Series": { " """ ); subsetInstanceToCopy.append(imageSetId); subsetInstanceToCopy.append( """ ": { "Instances": { """ ); for (String subset : subsets) { subsetInstanceToCopy.append('"' + subset + "\": {},"); } subsetInstanceToCopy.deleteCharAt(subsetInstanceToCopy.length() - 1); subsetInstanceToCopy.append(""" } } } } } """); return subsetInstanceToCopy.toString(); }
  • Untuk API detailnya, lihat CopyImageSetdi AWS SDK for Java 2.x APIReferensi.

catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di AWS Repositori Contoh Kode.

JavaScript
SDKuntuk JavaScript (v3)

Fungsi utilitas untuk menyalin set gambar.

import {CopyImageSetCommand} from "@aws-sdk/client-medical-imaging"; import {medicalImagingClient} from "../libs/medicalImagingClient.js"; /** * @param {string} datastoreId - The ID of the data store. * @param {string} imageSetId - The source image set ID. * @param {string} sourceVersionId - The source version ID. * @param {string} destinationImageSetId - The optional ID of the destination image set. * @param {string} destinationVersionId - The optional version ID of the destination image set. * @param {boolean} force - Force the copy action. * @param {[string]} copySubsets - A subset of instance IDs to copy. */ export const copyImageSet = async ( datastoreId = "xxxxxxxxxxx", imageSetId = "xxxxxxxxxxxx", sourceVersionId = "1", destinationImageSetId = "", destinationVersionId = "", force = false, copySubsets = [] ) => { try { const params = { datastoreId: datastoreId, sourceImageSetId: imageSetId, copyImageSetInformation: { sourceImageSet: {latestVersionId: sourceVersionId}, }, force: force }; if (destinationImageSetId !== "" && destinationVersionId !== "") { params.copyImageSetInformation.destinationImageSet = { imageSetId: destinationImageSetId, latestVersionId: destinationVersionId, }; } if (copySubsets.length > 0) { let copySubsetsJson; copySubsetsJson = { SchemaVersion: 1.1, Study: { Series: { imageSetId: { Instances: {} } } } }; for (let i = 0; i < copySubsets.length; i++) { copySubsetsJson.Study.Series.imageSetId.Instances[ copySubsets[i] ] = {}; } params.copyImageSetInformation.dicomCopies = copySubsetsJson; } const response = await medicalImagingClient.send( new CopyImageSetCommand(params) ); console.log(response); // { // '$metadata': { // httpStatusCode: 200, // requestId: 'd9b219ce-cc48-4a44-a5b2-c5c3068f1ee8', // extendedRequestId: undefined, // cfId: undefined, // attempts: 1, // totalRetryDelay: 0 // }, // datastoreId: 'xxxxxxxxxxxxxx', // destinationImageSetProperties: { // createdAt: 2023-09-27T19:46:21.824Z, // imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxxx:datastore/xxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxxxxx', // imageSetId: 'xxxxxxxxxxxxxxx', // imageSetState: 'LOCKED', // imageSetWorkflowStatus: 'COPYING', // latestVersionId: '1', // updatedAt: 2023-09-27T19:46:21.824Z // }, // sourceImageSetProperties: { // createdAt: 2023-09-22T14:49:26.427Z, // imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxxx:datastore/xxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxx', // imageSetId: 'xxxxxxxxxxxxxxxx', // imageSetState: 'LOCKED', // imageSetWorkflowStatus: 'COPYING_WITH_READ_ONLY_ACCESS', // latestVersionId: '4', // updatedAt: 2023-09-27T19:46:21.824Z // } // } return response; } catch (err) { console.error(err); } };

Salin set gambar tanpa tujuan.

await copyImageSet( "12345678901234567890123456789012", "12345678901234567890123456789012", "1" );

Salin set gambar dengan tujuan.

await copyImageSet( "12345678901234567890123456789012", "12345678901234567890123456789012", "1", "12345678901234567890123456789012", "1", false, );

Salin subset dari kumpulan gambar dengan tujuan dan paksa salinannya.

await copyImageSet( "12345678901234567890123456789012", "12345678901234567890123456789012", "1", "12345678901234567890123456789012", "1", true, ["12345678901234567890123456789012", "11223344556677889900112233445566"] );
  • Untuk API detailnya, lihat CopyImageSetdi AWS SDK for JavaScript APIReferensi.

catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di AWS Repositori Contoh Kode.

Python
SDKuntuk Python (Boto3)

Fungsi utilitas untuk menyalin set gambar.

class MedicalImagingWrapper: def __init__(self, health_imaging_client): self.health_imaging_client = health_imaging_client def copy_image_set( self, datastore_id, image_set_id, version_id, destination_image_set_id=None, destination_version_id=None, force=False, subsets=[], ): """ Copy an image set. :param datastore_id: The ID of the data store. :param image_set_id: The ID of the image set. :param version_id: The ID of the image set version. :param destination_image_set_id: The ID of the optional destination image set. :param destination_version_id: The ID of the optional destination image set version. :param force: Force the copy. :param subsets: The optional subsets to copy. For example: ["12345678901234567890123456789012"]. :return: The copied image set ID. """ try: copy_image_set_information = { "sourceImageSet": {"latestVersionId": version_id} } if destination_image_set_id and destination_version_id: copy_image_set_information["destinationImageSet"] = { "imageSetId": destination_image_set_id, "latestVersionId": destination_version_id, } if len(subsets) > 0: copySubsetsJson = { "SchemaVersion": "1.1", "Study": {"Series": {"imageSetId": {"Instances": {}}}}, } for subset in subsets: copySubsetsJson["Study"]["Series"]["imageSetId"]["Instances"][ subset ] = {} copy_image_set_information["sourceImageSet"]["DICOMCopies"] = { "copiableAttributes": json.dumps(copySubsetsJson) } copy_results = self.health_imaging_client.copy_image_set( datastoreId=datastore_id, sourceImageSetId=image_set_id, copyImageSetInformation=copy_image_set_information, force=force, ) except ClientError as err: logger.error( "Couldn't copy image set. Here's why: %s: %s", err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise else: return copy_results["destinationImageSetProperties"]["imageSetId"]

Salin set gambar tanpa tujuan.

copy_image_set_information = { "sourceImageSet": {"latestVersionId": version_id} } copy_results = self.health_imaging_client.copy_image_set( datastoreId=datastore_id, sourceImageSetId=image_set_id, copyImageSetInformation=copy_image_set_information, force=force, )

Salin set gambar dengan tujuan.

copy_image_set_information = { "sourceImageSet": {"latestVersionId": version_id} } if destination_image_set_id and destination_version_id: copy_image_set_information["destinationImageSet"] = { "imageSetId": destination_image_set_id, "latestVersionId": destination_version_id, } copy_results = self.health_imaging_client.copy_image_set( datastoreId=datastore_id, sourceImageSetId=image_set_id, copyImageSetInformation=copy_image_set_information, force=force, )

Salin subset dari kumpulan gambar.

copy_image_set_information = { "sourceImageSet": {"latestVersionId": version_id} } if len(subsets) > 0: copySubsetsJson = { "SchemaVersion": "1.1", "Study": {"Series": {"imageSetId": {"Instances": {}}}}, } for subset in subsets: copySubsetsJson["Study"]["Series"]["imageSetId"]["Instances"][ subset ] = {} copy_image_set_information["sourceImageSet"]["DICOMCopies"] = { "copiableAttributes": json.dumps(copySubsetsJson) } copy_results = self.health_imaging_client.copy_image_set( datastoreId=datastore_id, sourceImageSetId=image_set_id, copyImageSetInformation=copy_image_set_information, force=force, )

Kode berikut membuat instance objek. MedicalImagingWrapper

client = boto3.client("medical-imaging") medical_imaging_wrapper = MedicalImagingWrapper(client)
  • Untuk API detailnya, lihat CopyImageSetdi AWS SDKuntuk Python (Boto3) Referensi. API

catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di AWS Repositori Contoh Kode.

Untuk daftar lengkap AWS SDKpanduan pengembang dan contoh kode, lihatMenggunakan HealthImaging dengan AWS SDK. Topik ini juga mencakup informasi tentang memulai dan detail tentang SDK versi sebelumnya.