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);
}
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());
}
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();
}
}
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();
}
}
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.");
}
Aggregations