Search in sources :

Example 1 with Instances

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

the class DicomWebRetrieveInstance method dicomWebRetrieveInstance.

public static void dicomWebRetrieveInstance(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.RetrieveInstance request = client.projects().locations().datasets().dicomStores().studies().series().instances().retrieveInstance(dicomStoreName, dicomWebPath);
    // Execute the request and process the results.
    HttpResponse response = request.executeUnparsed();
    String outputPath = "instance.dcm";
    OutputStream outputStream = new FileOutputStream(new File(outputPath));
    try {
        response.download(outputStream);
        System.out.println("DICOM instance written to file " + outputPath);
    } finally {
        outputStream.close();
    }
    if (!response.isSuccessStatusCode()) {
        System.err.print(String.format("Exception retrieving DICOM instance: %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 2 with Instances

use of com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores.Studies.Series.Instances 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 3 with Instances

use of com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores.Studies.Series.Instances 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)

Aggregations

HttpResponse (com.google.api.client.http.HttpResponse)3 CloudHealthcare (com.google.api.services.healthcare.v1.CloudHealthcare)3 Instances (com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores.Studies.Series.Instances)2 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 OutputStream (java.io.OutputStream)2 DicomStores (com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores)1