Search in sources :

Example 26 with Datasets

use of com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets 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);
    }
}
Also used : FhirStores(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.FhirStores) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare) ExportResourcesRequest(com.google.api.services.healthcare.v1.model.ExportResourcesRequest) Operation(com.google.api.services.healthcare.v1.model.Operation) GoogleCloudHealthcareV1FhirGcsDestination(com.google.api.services.healthcare.v1.model.GoogleCloudHealthcareV1FhirGcsDestination) IOException(java.io.IOException)

Example 27 with Datasets

use of com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets in project beam by apache.

the class HttpHealthcareApiClient method getEarliestHL7v2SendTime.

@Override
public Instant getEarliestHL7v2SendTime(String hl7v2Store, @Nullable String filter) throws IOException {
    ListMessagesResponse response = client.projects().locations().datasets().hl7V2Stores().messages().list(hl7v2Store).setFilter(filter).set("view", // needed to retrieve the value for sendtime
    "full").setOrderBy(// default order is ascending
    "sendTime").setPageSize(// Only interested in the earliest sendTime
    1).execute();
    if (response.isEmpty()) {
        throw new IllegalArgumentException(String.format("Could not find earliest send time. The filter %s  matched no results on " + "HL7v2 Store: %s", filter, hl7v2Store));
    }
    String sendTime = response.getHl7V2Messages().get(0).getSendTime();
    if (Strings.isNullOrEmpty(sendTime)) {
        LOG.warn(String.format("Earliest message in %s has null or empty sendTime defaulting to Epoch.", hl7v2Store));
        return Instant.ofEpochMilli(0);
    }
    // https://cloud.google.com/healthcare/docs/reference/rest/v1/projects.locations.datasets.hl7V2Stores.messages#Message
    return Instant.parse(sendTime);
}
Also used : ListMessagesResponse(com.google.api.services.healthcare.v1.model.ListMessagesResponse)

Example 28 with Datasets

use of com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets in project beam by apache.

the class HttpHealthcareApiClient method getLatestHL7v2SendTime.

@Override
public Instant getLatestHL7v2SendTime(String hl7v2Store, @Nullable String filter) throws IOException {
    ListMessagesResponse response = client.projects().locations().datasets().hl7V2Stores().messages().list(hl7v2Store).setFilter(filter).set("view", // needed to retrieve the value for sendTime
    "full").setOrderBy("sendTime desc").setPageSize(// Only interested in the earliest sendTime
    1).execute();
    if (response.isEmpty()) {
        throw new IllegalArgumentException(String.format("Could not find latest send time. The filter %s  matched no results on " + "HL7v2 Store: %s", filter, hl7v2Store));
    }
    String sendTime = response.getHl7V2Messages().get(0).getSendTime();
    if (Strings.isNullOrEmpty(sendTime)) {
        LOG.warn(String.format("Latest message in %s has null or empty sendTime defaulting to now.", hl7v2Store));
        return Instant.now();
    }
    // https://cloud.google.com/healthcare/docs/reference/rest/v1/projects.locations.datasets.hl7V2Stores.messages#Message
    return Instant.parse(sendTime);
}
Also used : ListMessagesResponse(com.google.api.services.healthcare.v1.model.ListMessagesResponse)

Example 29 with Datasets

use of com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets in project beam by apache.

the class HttpHealthcareApiClient method createHL7v2Message.

@Override
public Message createHL7v2Message(String hl7v2Store, Message msg) throws IOException {
    CreateMessageRequest createMessageRequest = new CreateMessageRequest();
    createMessageRequest.setMessage(msg);
    return client.projects().locations().datasets().hl7V2Stores().messages().create(hl7v2Store, createMessageRequest).execute();
}
Also used : CreateMessageRequest(com.google.api.services.healthcare.v1.model.CreateMessageRequest)

Example 30 with Datasets

use of com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets in project beam by apache.

the class HttpHealthcareApiClient method listAllFhirStores.

@Override
public List<FhirStore> listAllFhirStores(String dataset) throws IOException {
    ArrayList<FhirStore> fhirStores = new ArrayList<>();
    String pageToken = "";
    do {
        ListFhirStoresResponse resp = client.projects().locations().datasets().fhirStores().list(dataset).setPageToken(pageToken).execute();
        for (FhirStore fs : resp.getFhirStores()) {
            fhirStores.add(fs);
        }
        if (resp.getNextPageToken() == null) {
            break;
        }
        pageToken = resp.getNextPageToken();
    } while (!pageToken.equals(""));
    return fhirStores;
}
Also used : ArrayList(java.util.ArrayList) FhirStore(com.google.api.services.healthcare.v1.model.FhirStore) ListFhirStoresResponse(com.google.api.services.healthcare.v1.model.ListFhirStoresResponse)

Aggregations

CloudHealthcare (com.google.api.services.healthcare.v1.CloudHealthcare)47 DicomStores (com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores)11 FhirStores (com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.FhirStores)9 Datasets (com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets)8 Policy (com.google.api.services.healthcare.v1.model.Policy)8 Hl7V2Stores (com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.Hl7V2Stores)7 FhirStore (com.google.api.services.healthcare.v1.model.FhirStore)6 Message (com.google.api.services.healthcare.v1.model.Message)6 Operation (com.google.api.services.healthcare.v1.model.Operation)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 HttpResponse (com.google.api.client.http.HttpResponse)5 Messages (com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.Hl7V2Stores.Messages)5 DicomStore (com.google.api.services.healthcare.v1.model.DicomStore)5 Binding (com.google.api.services.healthcare.v1.model.Binding)4 Dataset (com.google.api.services.healthcare.v1.model.Dataset)4 Hl7V2Store (com.google.api.services.healthcare.v1.model.Hl7V2Store)4 NotificationConfig (com.google.api.services.healthcare.v1.model.NotificationConfig)4 SetIamPolicyRequest (com.google.api.services.healthcare.v1.model.SetIamPolicyRequest)4 HashMap (java.util.HashMap)4