use of com.google.api.services.healthcare.v1.model.FhirStore in project beam by apache.
the class HttpHealthcareApiClient method importFhirResource.
@Override
public Operation importFhirResource(String fhirStore, String gcsSourcePath, @Nullable String contentStructure) throws IOException {
GoogleCloudHealthcareV1FhirGcsSource gcsSrc = new GoogleCloudHealthcareV1FhirGcsSource();
gcsSrc.setUri(gcsSourcePath);
ImportResourcesRequest importRequest = new ImportResourcesRequest();
importRequest.setGcsSource(gcsSrc).setContentStructure(contentStructure);
return client.projects().locations().datasets().fhirStores().healthcareImport(fhirStore, importRequest).execute();
}
use of com.google.api.services.healthcare.v1.model.FhirStore in project beam by apache.
the class HttpHealthcareApiClient method searchFhirResource.
@Override
public HttpBody searchFhirResource(String fhirStore, String resourceType, @Nullable Map<String, Object> parameters, String pageToken) throws IOException {
SearchResourcesRequest request = new SearchResourcesRequest().setResourceType(resourceType);
Search search = client.projects().locations().datasets().fhirStores().fhir().search(fhirStore, request);
if (parameters != null && !parameters.isEmpty()) {
parameters.forEach(search::set);
}
if (pageToken != null && !pageToken.isEmpty()) {
search.set("_page_token", URLDecoder.decode(pageToken, "UTF-8"));
}
return search.execute();
}
use of com.google.api.services.healthcare.v1.model.FhirStore in project beam by apache.
the class HttpHealthcareApiClient method executeFhirBundle.
@Override
public HttpBody executeFhirBundle(String fhirStore, String bundle) throws IOException, HealthcareHttpException {
if (httpClient == null || client == null) {
initClient();
}
credentials.refreshIfExpired();
StringEntity requestEntity = new StringEntity(bundle, ContentType.APPLICATION_JSON);
URI uri;
try {
uri = new URIBuilder(client.getRootUrl() + "v1/" + fhirStore + "/fhir").build();
} catch (URISyntaxException e) {
LOG.error("URL error when making executeBundle request to FHIR API. " + e.getMessage());
throw new IllegalArgumentException(e);
}
HttpUriRequest request = RequestBuilder.post().setUri(uri).setEntity(requestEntity).addHeader("Authorization", "Bearer " + credentials.getAccessToken().getTokenValue()).addHeader("User-Agent", USER_AGENT).addHeader("Content-Type", FHIRSTORE_HEADER_CONTENT_TYPE).addHeader("Accept-Charset", FHIRSTORE_HEADER_ACCEPT_CHARSET).addHeader("Accept", FHIRSTORE_HEADER_ACCEPT).build();
HttpResponse response = httpClient.execute(request);
HttpEntity responseEntity = response.getEntity();
String content = EntityUtils.toString(responseEntity);
// Check 2XX code.
int statusCode = response.getStatusLine().getStatusCode();
if (!(statusCode / 100 == 2)) {
throw HealthcareHttpException.of(statusCode, content);
}
HttpBody responseModel = new HttpBody();
responseModel.setData(content);
return responseModel;
}
use of com.google.api.services.healthcare.v1.model.FhirStore in project java-docs-samples by GoogleCloudPlatform.
the class FhirStoreList method fhirStoreList.
public static void fhirStoreList(String datasetName) throws IOException {
// String datasetName =
// String.format(DATASET_NAME, "your-project-id", "your-region-id", "your-dataset-id");
// Initialize the client, which will be used to interact with the service.
CloudHealthcare client = createClient();
// Results are paginated, so multiple queries may be required.
String pageToken = null;
List<FhirStore> stores = new ArrayList<>();
do {
// Create request and configure any parameters.
FhirStores.List request = client.projects().locations().datasets().fhirStores().list(datasetName).setPageSize(// Specify pageSize up to 1000
100).setPageToken(pageToken);
// Execute response and collect results.
ListFhirStoresResponse response = request.execute();
stores.addAll(response.getFhirStores());
// Update the page token for the next request.
pageToken = response.getNextPageToken();
} while (pageToken != null);
// Print results.
System.out.printf("Retrieved %s Fhir stores: \n", stores.size());
for (FhirStore data : stores) {
System.out.println("\t" + data.toPrettyString());
}
}
use of com.google.api.services.healthcare.v1.model.FhirStore in project java-docs-samples by GoogleCloudPlatform.
the class FhirStorePatch method fhirStorePatch.
public static void fhirStorePatch(String fhirStoreName, String pubsubTopic) throws IOException {
// String fhirStoreName =
// String.format(
// FHIR_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-fhir-id");
// String pubsubTopic = "projects/your-project-id/topics/your-pubsub-topic";
// Initialize the client, which will be used to interact with the service.
CloudHealthcare client = createClient();
// Fetch the initial state of the FHIR store.
FhirStores.Get getRequest = client.projects().locations().datasets().fhirStores().get(fhirStoreName);
FhirStore store = getRequest.execute();
// Update the FhirStore fields as needed as needed. For a full list of FhirStore fields, see:
// https://cloud.google.com/healthcare/docs/reference/rest/v1/projects.locations.datasets.fhirStores#FhirStore
store.setNotificationConfig(new NotificationConfig().setPubsubTopic(pubsubTopic));
// Create request and configure any parameters.
FhirStores.Patch request = client.projects().locations().datasets().fhirStores().patch(fhirStoreName, store).setUpdateMask("notificationConfig");
// Execute the request and process the results.
store = request.execute();
System.out.println("Fhir store patched: \n" + store.toPrettyString());
}
Aggregations