Search in sources :

Example 11 with DicomStores

use of com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores in project java-docs-samples by GoogleCloudPlatform.

the class DicomStoreExport method dicomStoreExport.

public static void dicomStoreExport(String dicomStoreName, String gcsUri) throws IOException {
    // String dicomStoreName =
    // String.format(
    // DICOM_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-dicom-id");
    // String gcsUri = "gs://your-bucket-id/path/to/destination/dir"
    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();
    // Configure where the store will be exported too.
    GoogleCloudHealthcareV1DicomGcsDestination gcsDestination = new GoogleCloudHealthcareV1DicomGcsDestination().setUriPrefix(gcsUri);
    ExportDicomDataRequest exportRequest = new ExportDicomDataRequest().setGcsDestination(gcsDestination);
    // Create request and configure any parameters.
    DicomStores.Export request = client.projects().locations().datasets().dicomStores().export(dicomStoreName, exportRequest);
    // Execute the request, wait for the operation to complete, and process the results.
    try {
        Operation operation = request.execute();
        while (operation.getDone() == null || !operation.getDone()) {
            // Update the status of the operation with another request.
            // Pause for 500ms between requests.
            Thread.sleep(500);
            operation = client.projects().locations().datasets().operations().get(operation.getName()).execute();
        }
        System.out.println("DICOM store export complete." + operation.getResponse());
    } catch (Exception ex) {
        System.out.printf("Error during request execution: %s", ex.toString());
        ex.printStackTrace(System.out);
    }
}
Also used : DicomStores(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare) GoogleCloudHealthcareV1DicomGcsDestination(com.google.api.services.healthcare.v1.model.GoogleCloudHealthcareV1DicomGcsDestination) Operation(com.google.api.services.healthcare.v1.model.Operation) ExportDicomDataRequest(com.google.api.services.healthcare.v1.model.ExportDicomDataRequest) IOException(java.io.IOException)

Example 12 with DicomStores

use of com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores in project java-docs-samples by GoogleCloudPlatform.

the class DicomWebSearchForInstances method dicomWebSearchForInstances.

public static void dicomWebSearchForInstances(String dicomStoreName) throws IOException {
    // String dicomStoreName =
    // String.format(
    // DICOM_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-dicom-id");
    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();
    // Create request and configure any parameters.
    DicomStores.SearchForInstances request = client.projects().locations().datasets().dicomStores().searchForInstances(dicomStoreName, "instances");
    // Execute the request and process the results.
    HttpResponse response = request.executeUnparsed();
    System.out.println("Dicom store instances found: \n" + response.toString());
}
Also used : DicomStores(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores) HttpResponse(com.google.api.client.http.HttpResponse) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare)

Example 13 with DicomStores

use of com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores in project java-docs-samples by GoogleCloudPlatform.

the class DicomStoreSetIamPolicy method dicomStoreSetIamPolicy.

public static void dicomStoreSetIamPolicy(String dicomStoreName) throws IOException {
    // String dicomStoreName =
    // String.format(
    // DICOM_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-dicom-id");
    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();
    // Configure the IAMPolicy to apply to the store.
    // For more information on understanding IAM roles, see the following:
    // https://cloud.google.com/iam/docs/understanding-roles
    Binding binding = new Binding().setRole("roles/healthcare.dicomStoreAdmin").setMembers(Arrays.asList("domain:google.com"));
    Policy policy = new Policy().setBindings(Arrays.asList(binding));
    SetIamPolicyRequest policyRequest = new SetIamPolicyRequest().setPolicy(policy);
    // Create request and configure any parameters.
    DicomStores.SetIamPolicy request = client.projects().locations().datasets().dicomStores().setIamPolicy(dicomStoreName, policyRequest);
    // Execute the request and process the results.
    Policy updatedPolicy = request.execute();
    System.out.println("DICOM policy has been updated: " + updatedPolicy.toPrettyString());
}
Also used : Binding(com.google.api.services.healthcare.v1.model.Binding) Policy(com.google.api.services.healthcare.v1.model.Policy) SetIamPolicyRequest(com.google.api.services.healthcare.v1.model.SetIamPolicyRequest) DicomStores(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare)

Example 14 with DicomStores

use of com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores in project java-docs-samples by GoogleCloudPlatform.

the class DicomWebRetrieveRendered method dicomWebRetrieveRendered.

public static void dicomWebRetrieveRendered(String dicomStoreName, String dicomWebPath) throws IOException {
    // String dicomStoreName =
    // String.format(
    // DICOM_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-dicom-id");
    // String dicomWebPath = String.format(DICOMWEB_PATH, "your-study-id", "your-series-id",
    // "your-instance-id");
    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();
    // Create request and configure any parameters.
    Instances.RetrieveRendered request = client.projects().locations().datasets().dicomStores().studies().series().instances().retrieveRendered(dicomStoreName, dicomWebPath);
    // Execute the request and process the results.
    HttpResponse response = request.executeUnparsed();
    String outputPath = "image.png";
    OutputStream outputStream = new FileOutputStream(new File(outputPath));
    try {
        response.download(outputStream);
        System.out.println("DICOM rendered PNG image written to file " + outputPath);
    } finally {
        outputStream.close();
    }
    if (!response.isSuccessStatusCode()) {
        System.err.print(String.format("Exception retrieving DICOM rendered image: %s\n", response.getStatusMessage()));
        throw new RuntimeException();
    }
}
Also used : Instances(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores.Studies.Series.Instances) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) HttpResponse(com.google.api.client.http.HttpResponse) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare) File(java.io.File)

Example 15 with DicomStores

use of com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores in project java-docs-samples by GoogleCloudPlatform.

the class DicomWebRetrieveStudy method dicomWebRetrieveStudy.

public static void dicomWebRetrieveStudy(String dicomStoreName, String studyId) throws IOException {
    // String dicomStoreName =
    // String.format(
    // DICOM_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-dicom-id");
    // String studyId = "your-study-id";
    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();
    // Create request and configure any parameters.
    Studies.RetrieveStudy request = client.projects().locations().datasets().dicomStores().studies().retrieveStudy(dicomStoreName, "studies/" + studyId);
    // Execute the request and process the results.
    HttpResponse response = request.executeUnparsed();
    // When specifying the output file, use an extension like ".multipart".
    // Then, parse the downloaded multipart file to get each individual
    // DICOM file.
    String outputPath = "study.multipart";
    OutputStream outputStream = new FileOutputStream(new File(outputPath));
    try {
        response.download(outputStream);
        System.out.println("DICOM study written to file " + outputPath);
    } finally {
        outputStream.close();
    }
    if (!response.isSuccessStatusCode()) {
        System.err.print(String.format("Exception retrieving DICOM study: %s\n", response.getStatusMessage()));
        throw new RuntimeException();
    }
}
Also used : Studies(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores.Studies) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) HttpResponse(com.google.api.client.http.HttpResponse) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare) File(java.io.File)

Aggregations

CloudHealthcare (com.google.api.services.healthcare.v1.CloudHealthcare)15 DicomStores (com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores)11 HttpResponse (com.google.api.client.http.HttpResponse)5 DicomStore (com.google.api.services.healthcare.v1.model.DicomStore)5 File (java.io.File)3 FileOutputStream (java.io.FileOutputStream)3 OutputStream (java.io.OutputStream)3 Studies (com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores.Studies)2 Instances (com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores.Studies.Series.Instances)2 NotificationConfig (com.google.api.services.healthcare.v1.model.NotificationConfig)2 Operation (com.google.api.services.healthcare.v1.model.Operation)2 Policy (com.google.api.services.healthcare.v1.model.Policy)2 IOException (java.io.IOException)2 Binding (com.google.api.services.healthcare.v1.model.Binding)1 ExportDicomDataRequest (com.google.api.services.healthcare.v1.model.ExportDicomDataRequest)1 GoogleCloudHealthcareV1DicomGcsDestination (com.google.api.services.healthcare.v1.model.GoogleCloudHealthcareV1DicomGcsDestination)1 GoogleCloudHealthcareV1DicomGcsSource (com.google.api.services.healthcare.v1.model.GoogleCloudHealthcareV1DicomGcsSource)1 ImportDicomDataRequest (com.google.api.services.healthcare.v1.model.ImportDicomDataRequest)1 ListDicomStoresResponse (com.google.api.services.healthcare.v1.model.ListDicomStoresResponse)1 SetIamPolicyRequest (com.google.api.services.healthcare.v1.model.SetIamPolicyRequest)1