Search in sources :

Example 1 with Dataset

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());
}
Also used : Messages(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.Hl7V2Stores.Messages) Message(com.google.api.services.healthcare.v1.model.Message) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare) IngestMessageRequest(com.google.api.services.healthcare.v1.model.IngestMessageRequest) IngestMessageResponse(com.google.api.services.healthcare.v1.model.IngestMessageResponse)

Example 2 with Dataset

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());
}
Also used : Messages(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.Hl7V2Stores.Messages) Message(com.google.api.services.healthcare.v1.model.Message) HashMap(java.util.HashMap) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare)

Example 3 with Dataset

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());
}
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 4 with Dataset

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());
}
Also used : Messages(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.Hl7V2Stores.Messages) Message(com.google.api.services.healthcare.v1.model.Message) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare) CreateMessageRequest(com.google.api.services.healthcare.v1.model.CreateMessageRequest)

Example 5 with Dataset

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

Aggregations

CloudHealthcare (com.google.api.services.healthcare.v1.CloudHealthcare)59 HttpEntity (org.apache.http.HttpEntity)12 HttpResponse (org.apache.http.HttpResponse)12 HttpClient (org.apache.http.client.HttpClient)12 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)12 URIBuilder (org.apache.http.client.utils.URIBuilder)12 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 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 Message (com.google.api.services.healthcare.v1.model.Message)5 StringEntity (org.apache.http.entity.StringEntity)5