Search in sources :

Example 1 with Hl7V2Store

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

the class HL7v2IOWriteIT method createHL7v2tore.

@BeforeClass
public static void createHL7v2tore() throws IOException {
    String project = TestPipeline.testingPipelineOptions().as(HealthcareStoreTestPipelineOptions.class).getStoreProjectId();
    healthcareDataset = String.format(HEALTHCARE_DATASET_TEMPLATE, project);
    HealthcareApiClient client = new HttpHealthcareApiClient();
    Hl7V2Store store = client.createHL7v2Store(healthcareDataset, HL7V2_STORE_NAME);
    store.getParserConfig();
}
Also used : Hl7V2Store(com.google.api.services.healthcare.v1.model.Hl7V2Store) BeforeClass(org.junit.BeforeClass)

Example 2 with Hl7V2Store

use of com.google.api.services.healthcare.v1.model.Hl7V2Store in project java-docs-samples by GoogleCloudPlatform.

the class Hl7v2StorePatch method patchHl7v2Store.

public static void patchHl7v2Store(String hl7v2StoreName, String pubsubTopic) throws IOException {
    // String hl7v2StoreName =
    // String.format(
    // HL7v2_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-hl7v2-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 HL7v2 store.
    Hl7V2Stores.Get getRequest = client.projects().locations().datasets().hl7V2Stores().get(hl7v2StoreName);
    Hl7V2Store store = getRequest.execute();
    Hl7V2NotificationConfig notificationConfig = new Hl7V2NotificationConfig();
    notificationConfig.setPubsubTopic(pubsubTopic);
    List<Hl7V2NotificationConfig> notificationConfigs = new ArrayList<Hl7V2NotificationConfig>();
    notificationConfigs.add(notificationConfig);
    // Update the Hl7v2Store fields as needed as needed. For a full list of Hl7v2Store fields, see:
    // https://cloud.google.com/healthcare/docs/reference/rest/v1/projects.locations.datasets.hl7V2Store#Hl7v2Store
    store.setNotificationConfigs(notificationConfigs);
    // Create request and configure any parameters.
    Hl7V2Stores.Patch request = client.projects().locations().datasets().hl7V2Stores().patch(hl7v2StoreName, store).setUpdateMask("notificationConfigs");
    // Execute the request and process the results.
    store = request.execute();
    System.out.println("HL7v2 store patched: \n" + store.toPrettyString());
}
Also used : Hl7V2Stores(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.Hl7V2Stores) Hl7V2NotificationConfig(com.google.api.services.healthcare.v1.model.Hl7V2NotificationConfig) ArrayList(java.util.ArrayList) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare) Hl7V2Store(com.google.api.services.healthcare.v1.model.Hl7V2Store)

Example 3 with Hl7V2Store

use of com.google.api.services.healthcare.v1.model.Hl7V2Store 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 4 with Hl7V2Store

use of com.google.api.services.healthcare.v1.model.Hl7V2Store 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 5 with Hl7V2Store

use of com.google.api.services.healthcare.v1.model.Hl7V2Store 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)

Aggregations

Hl7V2Store (com.google.api.services.healthcare.v1.model.Hl7V2Store)5 CloudHealthcare (com.google.api.services.healthcare.v1.CloudHealthcare)4 Hl7V2Stores (com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.Hl7V2Stores)4 ListMessagesResponse (com.google.api.services.healthcare.v1.model.ListMessagesResponse)2 ArrayList (java.util.ArrayList)2 CreateMessageRequest (com.google.api.services.healthcare.v1.model.CreateMessageRequest)1 Hl7V2NotificationConfig (com.google.api.services.healthcare.v1.model.Hl7V2NotificationConfig)1 IngestMessageRequest (com.google.api.services.healthcare.v1.model.IngestMessageRequest)1 ListHl7V2StoresResponse (com.google.api.services.healthcare.v1.model.ListHl7V2StoresResponse)1 HashMap (java.util.HashMap)1 BeforeClass (org.junit.BeforeClass)1