Search in sources :

Example 1 with ImportDicomDataRequest

use of com.google.api.services.healthcare.v1.model.ImportDicomDataRequest 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)1 DicomStores (com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores)1 GoogleCloudHealthcareV1DicomGcsSource (com.google.api.services.healthcare.v1.model.GoogleCloudHealthcareV1DicomGcsSource)1 ImportDicomDataRequest (com.google.api.services.healthcare.v1.model.ImportDicomDataRequest)1 Operation (com.google.api.services.healthcare.v1.model.Operation)1 IOException (java.io.IOException)1