Search in sources :

Example 11 with FhirStore

use of com.google.api.services.healthcare.v1.model.FhirStore in project beam by apache.

the class FhirIOTestUtil method executeFhirBundles.

/**
 * Populate the test resources into the FHIR store and returns a list of resource IDs.
 */
static List<String> executeFhirBundles(HealthcareApiClient client, String fhirStore, List<String> bundles) throws IOException, HealthcareHttpException {
    List<String> resourceNames = new ArrayList<>();
    for (String bundle : bundles) {
        HttpBody resp = client.executeFhirBundle(fhirStore, bundle);
        JsonObject jsonResponse = JsonParser.parseString(resp.toString()).getAsJsonObject();
        for (JsonElement entry : jsonResponse.getAsJsonArray("entry")) {
            String location = entry.getAsJsonObject().getAsJsonObject("response").getAsJsonPrimitive("location").getAsString();
            String resourceName = location.substring(location.indexOf("project"), location.indexOf("/_history"));
            resourceNames.add(resourceName);
        }
    }
    return resourceNames;
}
Also used : JsonElement(com.google.gson.JsonElement) ArrayList(java.util.ArrayList) HttpBody(com.google.api.services.healthcare.v1.model.HttpBody) JsonObject(com.google.gson.JsonObject)

Aggregations

FhirStore (com.google.api.services.healthcare.v1.model.FhirStore)6 CloudHealthcare (com.google.api.services.healthcare.v1.CloudHealthcare)4 FhirStores (com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.FhirStores)4 ArrayList (java.util.ArrayList)3 HttpBody (com.google.api.services.healthcare.v1.model.HttpBody)2 ListFhirStoresResponse (com.google.api.services.healthcare.v1.model.ListFhirStoresResponse)2 NotificationConfig (com.google.api.services.healthcare.v1.model.NotificationConfig)2 Search (com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.FhirStores.Fhir.Search)1 ExportResourcesRequest (com.google.api.services.healthcare.v1.model.ExportResourcesRequest)1 GoogleCloudHealthcareV1FhirGcsDestination (com.google.api.services.healthcare.v1.model.GoogleCloudHealthcareV1FhirGcsDestination)1 GoogleCloudHealthcareV1FhirGcsSource (com.google.api.services.healthcare.v1.model.GoogleCloudHealthcareV1FhirGcsSource)1 ImportResourcesRequest (com.google.api.services.healthcare.v1.model.ImportResourcesRequest)1 SearchResourcesRequest (com.google.api.services.healthcare.v1.model.SearchResourcesRequest)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 HashMap (java.util.HashMap)1 HttpEntity (org.apache.http.HttpEntity)1 HttpResponse (org.apache.http.HttpResponse)1