HealthImaging 用SDK于 Java 2.x 的示例 - Amazon SDK for Java 2.x
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

HealthImaging 用SDK于 Java 2.x 的示例

以下代码示例向您展示了如何使用with来执行操作和实现常见场景 HealthImaging。 Amazon SDK for Java 2.x

操作是大型程序的代码摘录,必须在上下文中运行。您可以通过操作了解如何调用单个服务函数,还可以通过函数相关场景的上下文查看操作。

场景是向您展示如何通过在一个服务中调用多个函数或与其他 Amazon Web Services 服务结合来完成特定任务的代码示例。

每个示例都包含一个指向完整源代码的链接,您可以在其中找到有关如何在上下文中设置和运行代码的说明。

操作

以下代码示例演示如何使用 CopyImageSet

SDK适用于 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; } }

用于创建可复制属性的实用函数。

/** * 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(); }
  • 有关API详细信息,请参阅 “Amazon SDK for Java 2.x API参考 CopyImageSet” 中的。

注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

以下代码示例演示如何使用 CreateDatastore

SDK适用于 Java 2.x
public static String createMedicalImageDatastore(MedicalImagingClient medicalImagingClient, String datastoreName) { try { CreateDatastoreRequest datastoreRequest = CreateDatastoreRequest.builder() .datastoreName(datastoreName) .build(); CreateDatastoreResponse response = medicalImagingClient.createDatastore(datastoreRequest); return response.datastoreId(); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } return ""; }
  • 有关API详细信息,请参阅 “Amazon SDK for Java 2.x API参考 CreateDatastore” 中的。

注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

以下代码示例演示如何使用 DeleteDatastore

SDK适用于 Java 2.x
public static void deleteMedicalImagingDatastore(MedicalImagingClient medicalImagingClient, String datastoreID) { try { DeleteDatastoreRequest datastoreRequest = DeleteDatastoreRequest.builder() .datastoreId(datastoreID) .build(); medicalImagingClient.deleteDatastore(datastoreRequest); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } }
  • 有关API详细信息,请参阅 “Amazon SDK for Java 2.x API参考 DeleteDatastore” 中的。

注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

以下代码示例演示如何使用 DeleteImageSet

SDK适用于 Java 2.x
public static void deleteMedicalImageSet(MedicalImagingClient medicalImagingClient, String datastoreId, String imagesetId) { try { DeleteImageSetRequest deleteImageSetRequest = DeleteImageSetRequest.builder() .datastoreId(datastoreId) .imageSetId(imagesetId) .build(); medicalImagingClient.deleteImageSet(deleteImageSetRequest); System.out.println("The image set was deleted."); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } }
  • 有关API详细信息,请参阅 “Amazon SDK for Java 2.x API参考 DeleteImageSet” 中的。

注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

以下代码示例演示如何使用 GetDICOMImportJob

SDK适用于 Java 2.x
public static DICOMImportJobProperties getDicomImportJob(MedicalImagingClient medicalImagingClient, String datastoreId, String jobId) { try { GetDicomImportJobRequest getDicomImportJobRequest = GetDicomImportJobRequest.builder() .datastoreId(datastoreId) .jobId(jobId) .build(); GetDicomImportJobResponse response = medicalImagingClient.getDICOMImportJob(getDicomImportJobRequest); return response.jobProperties(); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } return null; }
  • 有关API详细信息,请参阅《Amazon SDK for Java 2.x API参考资料》中的 G etDICOMImport Job

注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

以下代码示例演示如何使用 GetDatastore

SDK适用于 Java 2.x
public static DatastoreProperties getMedicalImageDatastore(MedicalImagingClient medicalImagingClient, String datastoreID) { try { GetDatastoreRequest datastoreRequest = GetDatastoreRequest.builder() .datastoreId(datastoreID) .build(); GetDatastoreResponse response = medicalImagingClient.getDatastore(datastoreRequest); return response.datastoreProperties(); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } return null; }
  • 有关API详细信息,请参阅 “Amazon SDK for Java 2.x API参考 GetDatastore” 中的。

注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

以下代码示例演示如何使用 GetImageFrame

SDK适用于 Java 2.x
public static void getMedicalImageSetFrame(MedicalImagingClient medicalImagingClient, String destinationPath, String datastoreId, String imagesetId, String imageFrameId) { try { GetImageFrameRequest getImageSetMetadataRequest = GetImageFrameRequest.builder() .datastoreId(datastoreId) .imageSetId(imagesetId) .imageFrameInformation(ImageFrameInformation.builder() .imageFrameId(imageFrameId) .build()) .build(); medicalImagingClient.getImageFrame(getImageSetMetadataRequest, FileSystems.getDefault().getPath(destinationPath)); System.out.println("Image frame downloaded to " + destinationPath); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } }
  • 有关API详细信息,请参阅 “Amazon SDK for Java 2.x API参考 GetImageFrame” 中的。

注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

以下代码示例演示如何使用 GetImageSet

SDK适用于 Java 2.x
public static GetImageSetResponse getMedicalImageSet(MedicalImagingClient medicalImagingClient, String datastoreId, String imagesetId, String versionId) { try { GetImageSetRequest.Builder getImageSetRequestBuilder = GetImageSetRequest.builder() .datastoreId(datastoreId) .imageSetId(imagesetId); if (versionId != null) { getImageSetRequestBuilder = getImageSetRequestBuilder.versionId(versionId); } return medicalImagingClient.getImageSet(getImageSetRequestBuilder.build()); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } return null; }
  • 有关API详细信息,请参阅 “Amazon SDK for Java 2.x API参考 GetImageSet” 中的。

注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

以下代码示例演示如何使用 GetImageSetMetadata

SDK适用于 Java 2.x
public static void getMedicalImageSetMetadata(MedicalImagingClient medicalImagingClient, String destinationPath, String datastoreId, String imagesetId, String versionId) { try { GetImageSetMetadataRequest.Builder getImageSetMetadataRequestBuilder = GetImageSetMetadataRequest.builder() .datastoreId(datastoreId) .imageSetId(imagesetId); if (versionId != null) { getImageSetMetadataRequestBuilder = getImageSetMetadataRequestBuilder.versionId(versionId); } medicalImagingClient.getImageSetMetadata(getImageSetMetadataRequestBuilder.build(), FileSystems.getDefault().getPath(destinationPath)); System.out.println("Metadata downloaded to " + destinationPath); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } }
  • 有关API详细信息,请参阅 “Amazon SDK for Java 2.x API参考 GetImageSetMetadata” 中的。

注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

以下代码示例演示如何使用 ListDICOMImportJobs

SDK适用于 Java 2.x
public static List<DICOMImportJobSummary> listDicomImportJobs(MedicalImagingClient medicalImagingClient, String datastoreId) { try { ListDicomImportJobsRequest listDicomImportJobsRequest = ListDicomImportJobsRequest.builder() .datastoreId(datastoreId) .build(); ListDicomImportJobsResponse response = medicalImagingClient.listDICOMImportJobs(listDicomImportJobsRequest); return response.jobSummaries(); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } return new ArrayList<>(); }
  • 有关API详细信息,请参阅Amazon SDK for Java 2.x API参考中的 L istDICOMImport Job s

注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

以下代码示例演示如何使用 ListDatastores

SDK适用于 Java 2.x
public static List<DatastoreSummary> listMedicalImagingDatastores(MedicalImagingClient medicalImagingClient) { try { ListDatastoresRequest datastoreRequest = ListDatastoresRequest.builder() .build(); ListDatastoresIterable responses = medicalImagingClient.listDatastoresPaginator(datastoreRequest); List<DatastoreSummary> datastoreSummaries = new ArrayList<>(); responses.stream().forEach(response -> datastoreSummaries.addAll(response.datastoreSummaries())); return datastoreSummaries; } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } return null; }
  • 有关API详细信息,请参阅 “Amazon SDK for Java 2.x API参考 ListDatastores” 中的。

注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

以下代码示例演示如何使用 ListImageSetVersions

SDK适用于 Java 2.x
public static List<ImageSetProperties> listMedicalImageSetVersions(MedicalImagingClient medicalImagingClient, String datastoreId, String imagesetId) { try { ListImageSetVersionsRequest getImageSetRequest = ListImageSetVersionsRequest.builder() .datastoreId(datastoreId) .imageSetId(imagesetId) .build(); ListImageSetVersionsIterable responses = medicalImagingClient .listImageSetVersionsPaginator(getImageSetRequest); List<ImageSetProperties> imageSetProperties = new ArrayList<>(); responses.stream().forEach(response -> imageSetProperties.addAll(response.imageSetPropertiesList())); return imageSetProperties; } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } return null; }
  • 有关API详细信息,请参阅 “Amazon SDK for Java 2.x API参考 ListImageSetVersions” 中的。

注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

以下代码示例演示如何使用 ListTagsForResource

SDK适用于 Java 2.x
public static ListTagsForResourceResponse listMedicalImagingResourceTags(MedicalImagingClient medicalImagingClient, String resourceArn) { try { ListTagsForResourceRequest listTagsForResourceRequest = ListTagsForResourceRequest.builder() .resourceArn(resourceArn) .build(); return medicalImagingClient.listTagsForResource(listTagsForResourceRequest); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } return null; }
  • 有关API详细信息,请参阅 “Amazon SDK for Java 2.x API参考 ListTagsForResource” 中的。

注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

以下代码示例演示如何使用 SearchImageSets

SDK适用于 Java 2.x

用于搜索映像集的实用程序函数。

public static List<ImageSetsMetadataSummary> searchMedicalImagingImageSets( MedicalImagingClient medicalImagingClient, String datastoreId, SearchCriteria searchCriteria) { try { SearchImageSetsRequest datastoreRequest = SearchImageSetsRequest.builder() .datastoreId(datastoreId) .searchCriteria(searchCriteria) .build(); SearchImageSetsIterable responses = medicalImagingClient .searchImageSetsPaginator(datastoreRequest); List<ImageSetsMetadataSummary> imageSetsMetadataSummaries = new ArrayList<>(); responses.stream().forEach(response -> imageSetsMetadataSummaries .addAll(response.imageSetsMetadataSummaries())); return imageSetsMetadataSummaries; } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } return null; }

用例 #1: EQUAL 运算符。

List<SearchFilter> searchFilters = Collections.singletonList(SearchFilter.builder() .operator(Operator.EQUAL) .values(SearchByAttributeValue.builder() .dicomPatientId(patientId) .build()) .build()); SearchCriteria searchCriteria = SearchCriteria.builder() .filters(searchFilters) .build(); List<ImageSetsMetadataSummary> imageSetsMetadataSummaries = searchMedicalImagingImageSets( medicalImagingClient, datastoreId, searchCriteria); if (imageSetsMetadataSummaries != null) { System.out.println("The image sets for patient " + patientId + " are:\n" + imageSetsMetadataSummaries); System.out.println(); }

用例 #2: BETWEEN 运算符使用DICOMStudyDate和DICOMStudyTime。

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); searchFilters = Collections.singletonList(SearchFilter.builder() .operator(Operator.BETWEEN) .values(SearchByAttributeValue.builder() .dicomStudyDateAndTime(DICOMStudyDateAndTime.builder() .dicomStudyDate("19990101") .dicomStudyTime("000000.000") .build()) .build(), SearchByAttributeValue.builder() .dicomStudyDateAndTime(DICOMStudyDateAndTime.builder() .dicomStudyDate((LocalDate.now() .format(formatter))) .dicomStudyTime("000000.000") .build()) .build()) .build()); searchCriteria = SearchCriteria.builder() .filters(searchFilters) .build(); imageSetsMetadataSummaries = searchMedicalImagingImageSets(medicalImagingClient, datastoreId, searchCriteria); if (imageSetsMetadataSummaries != null) { System.out.println( "The image sets searched with BETWEEN operator using DICOMStudyDate and DICOMStudyTime are:\n" + imageSetsMetadataSummaries); System.out.println(); }

用例 #3: BETWEEN 运算符使用createdAt。时间研究以前一直存在。

searchFilters = Collections.singletonList(SearchFilter.builder() .operator(Operator.BETWEEN) .values(SearchByAttributeValue.builder() .createdAt(Instant.parse("1985-04-12T23:20:50.52Z")) .build(), SearchByAttributeValue.builder() .createdAt(Instant.now()) .build()) .build()); searchCriteria = SearchCriteria.builder() .filters(searchFilters) .build(); imageSetsMetadataSummaries = searchMedicalImagingImageSets(medicalImagingClient, datastoreId, searchCriteria); if (imageSetsMetadataSummaries != null) { System.out.println("The image sets searched with BETWEEN operator using createdAt are:\n " + imageSetsMetadataSummaries); System.out.println(); }

用例 #4: 开启DICOMSeriesInstanceUID和开启EQUAL运算符 updatedAt 并BETWEEN按 updatedAt 字段ASC顺序对响应进行排序。

Instant startDate = Instant.parse("1985-04-12T23:20:50.52Z"); Instant endDate = Instant.now(); searchFilters = Arrays.asList( SearchFilter.builder() .operator(Operator.EQUAL) .values(SearchByAttributeValue.builder() .dicomSeriesInstanceUID(seriesInstanceUID) .build()) .build(), SearchFilter.builder() .operator(Operator.BETWEEN) .values( SearchByAttributeValue.builder().updatedAt(startDate).build(), SearchByAttributeValue.builder().updatedAt(endDate).build() ).build()); Sort sort = Sort.builder().sortOrder(SortOrder.ASC).sortField(SortField.UPDATED_AT).build(); searchCriteria = SearchCriteria.builder() .filters(searchFilters) .sort(sort) .build(); imageSetsMetadataSummaries = searchMedicalImagingImageSets(medicalImagingClient, datastoreId, searchCriteria); if (imageSetsMetadataSummaries != null) { System.out.println("The image sets searched with EQUAL operator on DICOMSeriesInstanceUID and BETWEEN on updatedAt and sort response\n" + "in ASC order on updatedAt field are:\n " + imageSetsMetadataSummaries); System.out.println(); }
  • 有关API详细信息,请参阅 “Amazon SDK for Java 2.x API参考 SearchImageSets” 中的。

注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

以下代码示例演示如何使用 StartDICOMImportJob

SDK适用于 Java 2.x
public static String startDicomImportJob(MedicalImagingClient medicalImagingClient, String jobName, String datastoreId, String dataAccessRoleArn, String inputS3Uri, String outputS3Uri) { try { StartDicomImportJobRequest startDicomImportJobRequest = StartDicomImportJobRequest.builder() .jobName(jobName) .datastoreId(datastoreId) .dataAccessRoleArn(dataAccessRoleArn) .inputS3Uri(inputS3Uri) .outputS3Uri(outputS3Uri) .build(); StartDicomImportJobResponse response = medicalImagingClient.startDICOMImportJob(startDicomImportJobRequest); return response.jobId(); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } return ""; }
  • 有关API详细信息,请参阅《Amazon SDK for Java 2.x API参考资料》中的 S tartDICOMImport Job

注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

以下代码示例演示如何使用 TagResource

SDK适用于 Java 2.x
public static void tagMedicalImagingResource(MedicalImagingClient medicalImagingClient, String resourceArn, Map<String, String> tags) { try { TagResourceRequest tagResourceRequest = TagResourceRequest.builder() .resourceArn(resourceArn) .tags(tags) .build(); medicalImagingClient.tagResource(tagResourceRequest); System.out.println("Tags have been added to the resource."); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } }
  • 有关API详细信息,请参阅 “Amazon SDK for Java 2.x API参考 TagResource” 中的。

注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

以下代码示例演示如何使用 UntagResource

SDK适用于 Java 2.x
public static void untagMedicalImagingResource(MedicalImagingClient medicalImagingClient, String resourceArn, Collection<String> tagKeys) { try { UntagResourceRequest untagResourceRequest = UntagResourceRequest.builder() .resourceArn(resourceArn) .tagKeys(tagKeys) .build(); medicalImagingClient.untagResource(untagResourceRequest); System.out.println("Tags have been removed from the resource."); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } }
  • 有关API详细信息,请参阅 “Amazon SDK for Java 2.x API参考 UntagResource” 中的。

注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

以下代码示例演示如何使用 UpdateImageSetMetadata

SDK适用于 Java 2.x
/** * Update the metadata of an AWS HealthImaging image set. * * @param medicalImagingClient - The AWS HealthImaging client object. * @param datastoreId - The datastore ID. * @param imageSetId - The image set ID. * @param versionId - The version ID. * @param metadataUpdates - A MetadataUpdates object containing the updates. * @param force - The force flag. * @throws MedicalImagingException - Base exception for all service exceptions thrown by AWS HealthImaging. */ public static void updateMedicalImageSetMetadata(MedicalImagingClient medicalImagingClient, String datastoreId, String imageSetId, String versionId, MetadataUpdates metadataUpdates, boolean force) { try { UpdateImageSetMetadataRequest updateImageSetMetadataRequest = UpdateImageSetMetadataRequest .builder() .datastoreId(datastoreId) .imageSetId(imageSetId) .latestVersionId(versionId) .updateImageSetMetadataUpdates(metadataUpdates) .force(force) .build(); UpdateImageSetMetadataResponse response = medicalImagingClient.updateImageSetMetadata(updateImageSetMetadataRequest); System.out.println("The image set metadata was updated" + response); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); throw e; } }

用例 #1: 插入或更新属性。

final String insertAttributes = """ { "SchemaVersion": 1.1, "Study": { "DICOM": { "StudyDescription": "CT CHEST" } } } """; MetadataUpdates metadataInsertUpdates = MetadataUpdates.builder() .dicomUpdates(DICOMUpdates.builder() .updatableAttributes(SdkBytes.fromByteBuffer( ByteBuffer.wrap(insertAttributes .getBytes(StandardCharsets.UTF_8)))) .build()) .build(); updateMedicalImageSetMetadata(medicalImagingClient, datastoreId, imagesetId, versionid, metadataInsertUpdates, force);

用例 #2: 移除属性。

final String removeAttributes = """ { "SchemaVersion": 1.1, "Study": { "DICOM": { "StudyDescription": "CT CHEST" } } } """; MetadataUpdates metadataRemoveUpdates = MetadataUpdates.builder() .dicomUpdates(DICOMUpdates.builder() .removableAttributes(SdkBytes.fromByteBuffer( ByteBuffer.wrap(removeAttributes .getBytes(StandardCharsets.UTF_8)))) .build()) .build(); updateMedicalImageSetMetadata(medicalImagingClient, datastoreId, imagesetId, versionid, metadataRemoveUpdates, force);

用例 #3: 移除实例。

final String removeInstance = """ { "SchemaVersion": 1.1, "Study": { "Series": { "1.1.1.1.1.1.12345.123456789012.123.12345678901234.1": { "Instances": { "1.1.1.1.1.1.12345.123456789012.123.12345678901234.1": {} } } } } } """; MetadataUpdates metadataRemoveUpdates = MetadataUpdates.builder() .dicomUpdates(DICOMUpdates.builder() .removableAttributes(SdkBytes.fromByteBuffer( ByteBuffer.wrap(removeInstance .getBytes(StandardCharsets.UTF_8)))) .build()) .build(); updateMedicalImageSetMetadata(medicalImagingClient, datastoreId, imagesetId, versionid, metadataRemoveUpdates, force);

用例 #4: 恢复到以前的版本。

// In this case, revert to previous version. String revertVersionId = Integer.toString(Integer.parseInt(versionid) - 1); MetadataUpdates metadataRemoveUpdates = MetadataUpdates.builder() .revertToVersionId(revertVersionId) .build(); updateMedicalImageSetMetadata(medicalImagingClient, datastoreId, imagesetId, versionid, metadataRemoveUpdates, force);
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

场景

以下代码示例显示了如何为 HealthImaging 数据存储添加标签。

SDK适用于 Java 2.x

标记数据存储。

final String datastoreArn = "arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012"; TagResource.tagMedicalImagingResource(medicalImagingClient, datastoreArn, ImmutableMap.of("Deployment", "Development"));

用于标记资源的实用程序函数。

public static void tagMedicalImagingResource(MedicalImagingClient medicalImagingClient, String resourceArn, Map<String, String> tags) { try { TagResourceRequest tagResourceRequest = TagResourceRequest.builder() .resourceArn(resourceArn) .tags(tags) .build(); medicalImagingClient.tagResource(tagResourceRequest); System.out.println("Tags have been added to the resource."); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } }

列出数据存储的标签。

final String datastoreArn = "arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012"; ListTagsForResourceResponse result = ListTagsForResource.listMedicalImagingResourceTags( medicalImagingClient, datastoreArn); if (result != null) { System.out.println("Tags for resource: " + result.tags()); }

用于列出资源标签的实用程序函数。

public static ListTagsForResourceResponse listMedicalImagingResourceTags(MedicalImagingClient medicalImagingClient, String resourceArn) { try { ListTagsForResourceRequest listTagsForResourceRequest = ListTagsForResourceRequest.builder() .resourceArn(resourceArn) .build(); return medicalImagingClient.listTagsForResource(listTagsForResourceRequest); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } return null; }

取消标记数据存储。

final String datastoreArn = "arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012"; UntagResource.untagMedicalImagingResource(medicalImagingClient, datastoreArn, Collections.singletonList("Deployment"));

用于取消标记资源的实用程序函数。

public static void untagMedicalImagingResource(MedicalImagingClient medicalImagingClient, String resourceArn, Collection<String> tagKeys) { try { UntagResourceRequest untagResourceRequest = UntagResourceRequest.builder() .resourceArn(resourceArn) .tagKeys(tagKeys) .build(); medicalImagingClient.untagResource(untagResourceRequest); System.out.println("Tags have been removed from the resource."); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } }
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

以下代码示例显示了如何为 HealthImaging 图像集添加标签。

SDK适用于 Java 2.x

标记映像集。

final String imageSetArn = "arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/12345678901234567890123456789012"; TagResource.tagMedicalImagingResource(medicalImagingClient, imageSetArn, ImmutableMap.of("Deployment", "Development"));

用于标记资源的实用程序函数。

public static void tagMedicalImagingResource(MedicalImagingClient medicalImagingClient, String resourceArn, Map<String, String> tags) { try { TagResourceRequest tagResourceRequest = TagResourceRequest.builder() .resourceArn(resourceArn) .tags(tags) .build(); medicalImagingClient.tagResource(tagResourceRequest); System.out.println("Tags have been added to the resource."); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } }

列出映像集的标签。

final String imageSetArn = "arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/12345678901234567890123456789012"; ListTagsForResourceResponse result = ListTagsForResource.listMedicalImagingResourceTags( medicalImagingClient, imageSetArn); if (result != null) { System.out.println("Tags for resource: " + result.tags()); }

用于列出资源标签的实用程序函数。

public static ListTagsForResourceResponse listMedicalImagingResourceTags(MedicalImagingClient medicalImagingClient, String resourceArn) { try { ListTagsForResourceRequest listTagsForResourceRequest = ListTagsForResourceRequest.builder() .resourceArn(resourceArn) .build(); return medicalImagingClient.listTagsForResource(listTagsForResourceRequest); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } return null; }

取消标记映像集。

final String imageSetArn = "arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/12345678901234567890123456789012"; UntagResource.untagMedicalImagingResource(medicalImagingClient, imageSetArn, Collections.singletonList("Deployment"));

用于取消标记资源的实用程序函数。

public static void untagMedicalImagingResource(MedicalImagingClient medicalImagingClient, String resourceArn, Collection<String> tagKeys) { try { UntagResourceRequest untagResourceRequest = UntagResourceRequest.builder() .resourceArn(resourceArn) .tagKeys(tagKeys) .build(); medicalImagingClient.untagResource(untagResourceRequest); System.out.println("Tags have been removed from the resource."); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } }
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。