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();
}
use of com.google.api.services.healthcare.v1.model.Hl7V2Store in project beam by apache.
the class HttpHealthcareApiClient method ingestHL7v2Message.
@Override
public IngestMessageResponse ingestHL7v2Message(String hl7v2Store, Message msg) throws IOException {
IngestMessageRequest ingestMessageRequest = new IngestMessageRequest();
ingestMessageRequest.setMessage(msg);
return client.projects().locations().datasets().hl7V2Stores().messages().ingest(hl7v2Store, ingestMessageRequest).execute();
}
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);
}
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);
}
Aggregations