Search in sources :

Example 1 with Studies

use of com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores.Studies in project beam by apache.

the class HttpHealthcareApiClient method uploadToDicomStore.

@Override
public Empty uploadToDicomStore(String webPath, String filePath) throws IOException, URISyntaxException {
    byte[] dcmFile = Files.readAllBytes(Paths.get(filePath));
    ByteArrayEntity requestEntity = new ByteArrayEntity(dcmFile);
    String uri = String.format("%sv1/%s/dicomWeb/studies", client.getRootUrl(), webPath);
    URIBuilder uriBuilder = new URIBuilder(uri).setParameter("access_token", credentials.getAccessToken().getTokenValue());
    HttpUriRequest request = RequestBuilder.post(uriBuilder.build()).setEntity(requestEntity).addHeader("Content-Type", "application/dicom").build();
    httpClient.execute(request);
    return new Empty();
}
Also used : HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) Empty(com.google.api.services.healthcare.v1.model.Empty) ByteArrayEntity(org.apache.http.entity.ByteArrayEntity) URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 2 with Studies

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

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

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

the class DicomWebDeleteStudy method dicomWebDeleteStudy.

public static void dicomWebDeleteStudy(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.Delete request = client.projects().locations().datasets().dicomStores().studies().delete(dicomStoreName, "studies/" + studyId);
    // Execute the request and process the results.
    request.execute();
    System.out.println("DICOM study deleted.");
}
Also used : Studies(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores.Studies) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare)

Example 5 with Studies

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

Aggregations

CloudHealthcare (com.google.api.services.healthcare.v1.CloudHealthcare)6 HttpResponse (com.google.api.client.http.HttpResponse)4 File (java.io.File)4 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 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)2 URIBuilder (org.apache.http.client.utils.URIBuilder)2 ByteArrayEntity (org.apache.http.entity.ByteArrayEntity)2 DicomStores (com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores)1 Empty (com.google.api.services.healthcare.v1.model.Empty)1 HttpEntity (org.apache.http.HttpEntity)1 HttpResponse (org.apache.http.HttpResponse)1 HttpClient (org.apache.http.client.HttpClient)1