Search in sources :

Example 1 with FhirStore

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();
}
Also used : ImportResourcesRequest(com.google.api.services.healthcare.v1.model.ImportResourcesRequest) GoogleCloudHealthcareV1FhirGcsSource(com.google.api.services.healthcare.v1.model.GoogleCloudHealthcareV1FhirGcsSource)

Example 2 with FhirStore

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();
}
Also used : Search(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.FhirStores.Fhir.Search) SearchResourcesRequest(com.google.api.services.healthcare.v1.model.SearchResourcesRequest)

Example 3 with FhirStore

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;
}
Also used : HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) StringEntity(org.apache.http.entity.StringEntity) HttpEntity(org.apache.http.HttpEntity) HttpResponse(org.apache.http.HttpResponse) HttpBody(com.google.api.services.healthcare.v1.model.HttpBody) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 4 with FhirStore

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());
    }
}
Also used : FhirStores(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.FhirStores) ArrayList(java.util.ArrayList) FhirStore(com.google.api.services.healthcare.v1.model.FhirStore) ListFhirStoresResponse(com.google.api.services.healthcare.v1.model.ListFhirStoresResponse) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare)

Example 5 with FhirStore

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());
}
Also used : FhirStores(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.FhirStores) NotificationConfig(com.google.api.services.healthcare.v1.model.NotificationConfig) FhirStore(com.google.api.services.healthcare.v1.model.FhirStore) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare)

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