use of com.google.api.services.healthcare.v1.model.Dataset in project java-docs-samples by GoogleCloudPlatform.
the class FhirStoreImport method fhirStoreImport.
public static void fhirStoreImport(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 should be imported from.
GoogleCloudHealthcareV1FhirGcsSource gcsSource = new GoogleCloudHealthcareV1FhirGcsSource().setUri(gcsUri);
ImportResourcesRequest importRequest = new ImportResourcesRequest().setGcsSource(gcsSource);
// Create request and configure any parameters.
FhirStores.CloudHealthcareImport request = client.projects().locations().datasets().fhirStores().healthcareImport(fhirStoreName, 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("FHIR store import complete: " + operation.getResponse());
} catch (Exception ex) {
System.out.printf("Error during request execution: %s", ex.toString());
ex.printStackTrace(System.out);
}
}
use of com.google.api.services.healthcare.v1.model.Dataset in project java-docs-samples by GoogleCloudPlatform.
the class FhirResourceCreate method fhirResourceCreate.
public static void fhirResourceCreate(String fhirStoreName, String resourceType) throws IOException, URISyntaxException {
// String fhirStoreName =
// String.format(
// FHIR_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-fhir-id");
// String resourceType = "Patient";
// 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/fhir/%s", client.getRootUrl(), fhirStoreName, resourceType);
URIBuilder uriBuilder = new URIBuilder(uri).setParameter("access_token", getAccessToken());
StringEntity requestEntity = new StringEntity("{\"resourceType\": \"" + resourceType + "\", \"language\": \"en\"}");
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_CREATED) {
System.err.print(String.format("Exception creating FHIR resource: %s\n", response.getStatusLine().toString()));
responseEntity.writeTo(System.err);
throw new RuntimeException();
}
System.out.print("FHIR resource created: ");
responseEntity.writeTo(System.out);
}
use of com.google.api.services.healthcare.v1.model.Dataset in project java-docs-samples by GoogleCloudPlatform.
the class FhirResourceDeletePurge method fhirResourceDeletePurge.
public static void fhirResourceDeletePurge(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/$purge", client.getRootUrl(), resourceName);
URIBuilder uriBuilder = new URIBuilder(uri).setParameter("access_token", getAccessToken());
HttpUriRequest request = RequestBuilder.delete().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) {
String errorMessage = String.format("Exception purging FHIR resource: %s\n", response.getStatusLine().toString());
System.err.print(errorMessage);
responseEntity.writeTo(System.err);
throw new RuntimeException(errorMessage);
}
System.out.println("FHIR resource history purged (excluding current version).");
responseEntity.writeTo(System.out);
}
use of com.google.api.services.healthcare.v1.model.Dataset in project java-docs-samples by GoogleCloudPlatform.
the class FhirResourceGetHistory method fhirResourceGetHistory.
public static void fhirResourceGetHistory(String resourceName, String versionId) throws IOException, URISyntaxException {
// String resourceName =
// String.format(
// FHIR_NAME, "project-id", "region-id", "dataset-id", "store-id", "resource-type",
// "resource-id");
// String versionId = "version-uuid"
// 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/%s", client.getRootUrl(), resourceName, versionId);
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 retrieved from version: ");
responseEntity.writeTo(System.out);
}
use of com.google.api.services.healthcare.v1.model.Dataset in project java-docs-samples by GoogleCloudPlatform.
the class FhirResourceGetPatientEverything method fhirResourceGetPatientEverything.
public static void fhirResourceGetPatientEverything(String resourceName) throws IOException, URISyntaxException {
// String resourceName =
// String.format(
// FHIR_NAME, "project-id", "region-id", "dataset-id", "store-id", "patient-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/$everything", client.getRootUrl(), resourceName);
URIBuilder uriBuilder = new URIBuilder(uri).setParameter("access_token", getAccessToken());
HttpUriRequest request = RequestBuilder.get(uriBuilder.build()).addHeader("Content-Type", "application/json-patch+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 getting patient everythingresource: %s\n", response.getStatusLine().toString()));
responseEntity.writeTo(System.err);
throw new RuntimeException();
}
System.out.println("Patient compartment results: ");
responseEntity.writeTo(System.out);
}
Aggregations