use of com.google.api.services.healthcare.v1.model.Dataset in project java-docs-samples by GoogleCloudPlatform.
the class HL7v2MessageIngest method hl7v2MessageIngest.
public static void hl7v2MessageIngest(String hl7v2StoreName, String filePath) throws IOException {
// String hl7v2StoreName =
// String.format(
// HL7v2_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-hl7v2-id");
// Initialize the client, which will be used to interact with the service.
CloudHealthcare client = createClient();
// Load the data from file and format it into an ingest request.
List<String> lines = Files.readAllLines(Paths.get(filePath), Charset.defaultCharset());
String data = String.join("\n", lines);
Message message = new Message().setData(data);
IngestMessageRequest ingestRequest = new IngestMessageRequest().setMessage(message);
// Create request and configure any parameters.
Messages.Ingest request = client.projects().locations().datasets().hl7V2Stores().messages().ingest(hl7v2StoreName, ingestRequest);
// Execute the request and process the results.
IngestMessageResponse response = request.execute();
System.out.println("HL7v2 message ingested: " + response.toPrettyString());
}
use of com.google.api.services.healthcare.v1.model.Dataset in project java-docs-samples by GoogleCloudPlatform.
the class HL7v2MessagePatch method hl7v2MessagePatch.
public static void hl7v2MessagePatch(String hl7v2MessageName) throws IOException {
// String hl7v2MessageName =
// String.format(
// MESSAGE_NAME, "project-id", "region-id", "dataset-id", "hl7v2-id", "message-id");
// Initialize the client, which will be used to interact with the service.
CloudHealthcare client = createClient();
// Fetch the initial state of the message.
Messages.Get getRequest = client.projects().locations().datasets().hl7V2Stores().messages().get(hl7v2MessageName);
Message message = getRequest.execute();
// Update the Message fields as needed as needed. For a full list of Message fields, see:
// https://cloud.google.com/healthcare/docs/reference/rest/v1/projects.locations.datasets.hl7V2Stores.messages
Map<String, String> labels = new HashMap<>();
labels.put("key1", "value1");
labels.put("key2", "value2");
message.setLabels(labels);
// Create request and configure any parameters.
Messages.Patch request = client.projects().locations().datasets().hl7V2Stores().messages().patch(hl7v2MessageName, message).setUpdateMask("labels");
// Execute the request and process the results.
message = request.execute();
System.out.println("HL7v2 message patched: \n" + message.toPrettyString());
}
use of com.google.api.services.healthcare.v1.model.Dataset 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());
}
use of com.google.api.services.healthcare.v1.model.Dataset in project java-docs-samples by GoogleCloudPlatform.
the class HL7v2MessageCreate method hl7v2MessageCreate.
public static void hl7v2MessageCreate(String hl7v2StoreName, String messageId, String filePath) throws IOException {
// String hl7v2StoreName =
// String.format(
// HL7v2_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-hl7v2-id");
// String messageId = "your-message-id";
// String filePath = "path/to/file.txt";
// Initialize the client, which will be used to interact with the service.
CloudHealthcare client = createClient();
// Load the data from file representing the message.
List<String> lines = Files.readAllLines(Paths.get(filePath), Charset.defaultCharset());
String data = String.join("\n", lines);
Message message = new Message().setData(data).setName(messageId);
CreateMessageRequest createRequest = new CreateMessageRequest().setMessage(message);
// Create request and configure any parameters.
Messages.Create request = client.projects().locations().datasets().hl7V2Stores().messages().create(hl7v2StoreName, createRequest);
// Execute the request and process the results.
Message response = request.execute();
System.out.println("HL7v2 message created: " + response.toPrettyString());
}
use of com.google.api.services.healthcare.v1.model.Dataset in project java-docs-samples by GoogleCloudPlatform.
the class FhirStoreExecuteBundle method fhirStoreExecuteBundle.
public static void fhirStoreExecuteBundle(String fhirStoreName, String data) throws IOException, URISyntaxException {
// String fhirStoreName =
// String.format(
// FHIR_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-fhir-id");
// String data = "{\"resourceType\": \"Bundle\",\"type\": \"batch\",\"entry\": []}"
// Initialize the client, which will be used to interact with the service.
CloudHealthcare client = createClient();
HttpClient httpClient = HttpClients.createDefault();
String baseUri = String.format("%sv1/%s/fhir", client.getRootUrl(), fhirStoreName);
URIBuilder uriBuilder = new URIBuilder(baseUri).setParameter("access_token", getAccessToken());
StringEntity requestEntity = new StringEntity(data);
HttpUriRequest request = RequestBuilder.post().setUri(uriBuilder.build()).setEntity(requestEntity).addHeader("Content-Type", "application/fhir+json").addHeader("Accept-Charset", "utf-8").addHeader("Accept", "application/fhir+json; charset=utf-8").build();
// Execute the request and process the results.
HttpResponse response = httpClient.execute(request);
HttpEntity responseEntity = response.getEntity();
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
System.err.print(String.format("Exception executing FHIR bundle: %s\n", response.getStatusLine().toString()));
responseEntity.writeTo(System.err);
throw new RuntimeException();
}
System.out.print("FHIR bundle executed: ");
responseEntity.writeTo(System.out);
}
Aggregations