Search in sources :

Example 1 with DicomStores

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

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

the class DicomWebSearchStudies method dicomWebSearchStudies.

public static void dicomWebSearchStudies(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();
    DicomStores.SearchForStudies request = client.projects().locations().datasets().dicomStores().searchForStudies(dicomStoreName, "studies").set("PatientName", "Sally Zhang");
    // Execute the request and process the results.
    HttpResponse response = request.executeUnparsed();
    System.out.println("Studies 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 3 with DicomStores

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

the class DicomStoreGetIamPolicy method dicomStoreGetIamPolicy.

public static void dicomStoreGetIamPolicy(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.GetIamPolicy request = client.projects().locations().datasets().dicomStores().getIamPolicy(dicomStoreName);
    // Execute the request and process the results.
    Policy policy = request.execute();
    System.out.println("DICOM store IAMPolicy retrieved: \n" + policy.toPrettyString());
}
Also used : Policy(com.google.api.services.healthcare.v1.model.Policy) DicomStores(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare)

Example 4 with DicomStores

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

the class DicomStoreList method dicomStoreList.

public static void dicomStoreList(String datasetName) throws IOException {
    // String datasetName =
    // String.format(DATASET_NAME, "your-project-id", "your-region-id", "your-dataset-id");
    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();
    // Results are paginated, so multiple queries may be required.
    String pageToken = null;
    List<DicomStore> stores = new ArrayList<>();
    do {
        // Create request and configure any parameters.
        DicomStores.List request = client.projects().locations().datasets().dicomStores().list(datasetName).setPageSize(// Specify pageSize up to 1000
        100).setPageToken(pageToken);
        // Execute response and collect results.
        ListDicomStoresResponse response = request.execute();
        stores.addAll(response.getDicomStores());
        // Update the page token for the next request.
        pageToken = response.getNextPageToken();
    } while (pageToken != null);
    // Print results.
    System.out.printf("Retrieved %s DICOM stores: \n", stores.size());
    for (DicomStore data : stores) {
        System.out.println("\t" + data.toPrettyString());
    }
}
Also used : ListDicomStoresResponse(com.google.api.services.healthcare.v1.model.ListDicomStoresResponse) DicomStore(com.google.api.services.healthcare.v1.model.DicomStore) DicomStores(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores) ArrayList(java.util.ArrayList) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare)

Example 5 with DicomStores

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

the class DicomStoreImport method dicomStoreImport.

public static void dicomStoreImport(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 should be imported from.
    GoogleCloudHealthcareV1DicomGcsSource gcsSource = new GoogleCloudHealthcareV1DicomGcsSource().setUri(gcsUri);
    ImportDicomDataRequest importRequest = new ImportDicomDataRequest().setGcsSource(gcsSource);
    // Create request and configure any parameters.
    DicomStores.CloudHealthcareImport request = client.projects().locations().datasets().dicomStores().healthcareImport(dicomStoreName, importRequest);
    // 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 import complete." + operation.getResponse());
    } catch (Exception ex) {
        System.out.printf("Error during request execution: %s", ex.toString());
        ex.printStackTrace(System.out);
    }
}
Also used : GoogleCloudHealthcareV1DicomGcsSource(com.google.api.services.healthcare.v1.model.GoogleCloudHealthcareV1DicomGcsSource) DicomStores(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare) ImportDicomDataRequest(com.google.api.services.healthcare.v1.model.ImportDicomDataRequest) Operation(com.google.api.services.healthcare.v1.model.Operation) IOException(java.io.IOException)

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