use of com.google.api.services.healthcare.v1.model.Dataset in project java-docs-samples by GoogleCloudPlatform.
the class FhirResourceGet method fhirResourceGet.
public static void fhirResourceGet(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", client.getRootUrl(), resourceName);
URIBuilder uriBuilder = new URIBuilder(uri).setParameter("access_token", getAccessToken());
HttpUriRequest request = RequestBuilder.get().setUri(uriBuilder.build()).build();
// Execute the request and process the results.
HttpResponse response = httpClient.execute(request);
HttpEntity responseEntity = response.getEntity();
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
String errorMessage = String.format("Exception retrieving FHIR resource: %s\n", response.getStatusLine().toString());
System.err.print(errorMessage);
responseEntity.writeTo(System.err);
throw new RuntimeException(errorMessage);
}
System.out.println("FHIR resource retrieved: ");
responseEntity.writeTo(System.out);
}
use of com.google.api.services.healthcare.v1.model.Dataset 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());
}
use of com.google.api.services.healthcare.v1.model.Dataset in project java-docs-samples by GoogleCloudPlatform.
the class FhirStoreCreate method fhirStoreCreate.
public static void fhirStoreCreate(String datasetName, String fhirStoreId) throws IOException {
// String datasetName =
// String.format(DATASET_NAME, "your-project-id", "your-region-id", "your-dataset-id");
// String fhirStoreId = "your-fhir-id"
// Initialize the client, which will be used to interact with the service.
CloudHealthcare client = createClient();
// Configure the FhirStore to be created.
Map<String, String> labels = new HashMap<String, String>();
labels.put("key1", "value1");
labels.put("key2", "value2");
String version = "STU3";
FhirStore content = new FhirStore().setLabels(labels).setVersion(version);
// Create request and configure any parameters.
FhirStores.Create request = client.projects().locations().datasets().fhirStores().create(datasetName, content).setFhirStoreId(fhirStoreId);
// Execute the request and process the results.
FhirStore response = request.execute();
System.out.println("FHIR store created: " + response.toPrettyString());
}
use of com.google.api.services.healthcare.v1.model.Dataset in project java-docs-samples by GoogleCloudPlatform.
the class FhirStoreExecuteBundle method fhirStoreExecuteBundle.
public static void fhirStoreExecuteBundle(String fhirStoreName, String data) throws IOException, URISyntaxException {
// String fhirStoreName =
// String.format(
// FHIR_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-fhir-id");
// String data = "{\"resourceType\": \"Bundle\",\"type\": \"batch\",\"entry\": []}"
// Initialize the client, which will be used to interact with the service.
CloudHealthcare client = createClient();
HttpClient httpClient = HttpClients.createDefault();
String baseUri = String.format("%sv1/%s/fhir", client.getRootUrl(), fhirStoreName);
URIBuilder uriBuilder = new URIBuilder(baseUri).setParameter("access_token", getAccessToken());
StringEntity requestEntity = new StringEntity(data);
HttpUriRequest request = RequestBuilder.post().setUri(uriBuilder.build()).setEntity(requestEntity).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 executing FHIR bundle: %s\n", response.getStatusLine().toString()));
responseEntity.writeTo(System.err);
throw new RuntimeException();
}
System.out.print("FHIR bundle executed: ");
responseEntity.writeTo(System.out);
}
use of com.google.api.services.healthcare.v1.model.Dataset in project java-docs-samples by GoogleCloudPlatform.
the class FhirStoreExport method fhirStoreExport.
public static void fhirStoreExport(String fhirStoreName, String gcsUri) throws IOException {
// String fhirStoreName =
// String.format(
// FHIR_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-fhir-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 will be exported too.
GoogleCloudHealthcareV1FhirGcsDestination gcsDestination = new GoogleCloudHealthcareV1FhirGcsDestination().setUriPrefix(gcsUri);
ExportResourcesRequest exportRequest = new ExportResourcesRequest().setGcsDestination(gcsDestination);
// Create request and configure any parameters.
FhirStores.Export request = client.projects().locations().datasets().fhirStores().export(fhirStoreName, exportRequest);
// 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("Fhir store export complete." + operation.getResponse());
} catch (Exception ex) {
System.out.printf("Error during request execution: %s", ex.toString());
ex.printStackTrace(System.out);
}
}
Aggregations