Search in sources :

Example 51 with Dataset

use of com.google.api.services.healthcare.v1.model.Dataset in project java-docs-samples by GoogleCloudPlatform.

the class FhirResourceListHistory method fhirResourceListHistory.

public static void fhirResourceListHistory(String resourceName) throws IOException, URISyntaxException {
    // String resourceName =
    // String.format(
    // FHIR_NAME, "project-id", "region-id", "dataset-id", "store-id", "resource-type",
    // "resource-id");
    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();
    HttpClient httpClient = HttpClients.createDefault();
    String uri = String.format("%sv1/%s/_history", client.getRootUrl(), resourceName);
    URIBuilder uriBuilder = new URIBuilder(uri).setParameter("access_token", getAccessToken());
    HttpUriRequest request = RequestBuilder.get().setUri(uriBuilder.build()).addHeader("Content-Type", "application/fhir+json").addHeader("Accept-Charset", "utf-8").addHeader("Accept", "application/fhir+json; charset=utf-8").build();
    // Execute the request and process the results.
    HttpResponse response = httpClient.execute(request);
    HttpEntity responseEntity = response.getEntity();
    if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
        System.err.print(String.format("Exception retrieving FHIR history: %s\n", response.getStatusLine().toString()));
        responseEntity.writeTo(System.err);
        throw new RuntimeException();
    }
    System.out.println("FHIR resource history retrieved: ");
    responseEntity.writeTo(System.out);
}
Also used : HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) HttpEntity(org.apache.http.HttpEntity) HttpClient(org.apache.http.client.HttpClient) HttpResponse(org.apache.http.HttpResponse) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare) URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 52 with Dataset

use of com.google.api.services.healthcare.v1.model.Dataset 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 53 with Dataset

use of com.google.api.services.healthcare.v1.model.Dataset 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 54 with Dataset

use of com.google.api.services.healthcare.v1.model.Dataset 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)

Example 55 with Dataset

use of com.google.api.services.healthcare.v1.model.Dataset in project java-docs-samples by GoogleCloudPlatform.

the class HL7v2MessageDelete method hl7v2MessageDelete.

public static void hl7v2MessageDelete(String hl7v2MessageName) throws IOException {
    // String hl7v2MessageName =
    // String.format(
    // MESSAGE_NAME, "project-id", "region-id", "dataset-id", "hl7v2-id", "message-id");
    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();
    // Create request and configure any parameters.
    Messages.Delete request = client.projects().locations().datasets().hl7V2Stores().messages().delete(hl7v2MessageName);
    // Execute the request and process the results.
    request.execute();
    System.out.println("HL7v2 message deleted.");
}
Also used : Messages(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.Hl7V2Stores.Messages) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare)

Aggregations

CloudHealthcare (com.google.api.services.healthcare.v1.CloudHealthcare)57 DicomStores (com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores)11 HttpEntity (org.apache.http.HttpEntity)11 HttpResponse (org.apache.http.HttpResponse)11 HttpClient (org.apache.http.client.HttpClient)11 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)11 URIBuilder (org.apache.http.client.utils.URIBuilder)11 FhirStores (com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.FhirStores)9 Datasets (com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets)8 Policy (com.google.api.services.healthcare.v1.model.Policy)8 Hl7V2Stores (com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.Hl7V2Stores)7 FhirStore (com.google.api.services.healthcare.v1.model.FhirStore)6 Operation (com.google.api.services.healthcare.v1.model.Operation)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 HttpResponse (com.google.api.client.http.HttpResponse)5 Messages (com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.Hl7V2Stores.Messages)5 DicomStore (com.google.api.services.healthcare.v1.model.DicomStore)5 Message (com.google.api.services.healthcare.v1.model.Message)5 Binding (com.google.api.services.healthcare.v1.model.Binding)4