Retrieving HL7v2 messages in bulk

This page shows how to get HL7v2 messages in bulk in the Cloud Healthcare API.

Overview

You can bulk read messages from an HL7v2 store using the BatchGet method. This method retrieves up to 100 messages with a single call.

Getting HL7v2 messages in bulk

The following samples show how to get the contents of HL7v2 messages in bulk.

For more information, see projects.locations.datasets.hl7V2Stores.messages.batchGet.

curl

To get HL7v2 messages in bulk, make a GET request and specify the following information:

  • The name of the parent dataset
  • The name of the HL7v2 store
  • An access token
  • The query parameter names with the names of the HL7v2 messages you want to retrieve. For each names value, enter the fully qualified path to the message in the format: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID

The following sample shows a GET request using curl.

curl -X GET \
      -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
      "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID
      /locations/LOCATION/datasets/DATASET_ID
      /hl7V2Stores/HL7V2_STORE_ID/messages:batchGet?names=MESSAGE_NAME_1&names=MESSAGE_NAME_2&names=
      MESSAGE_NAME_3&view=FULL"

If the request is successful, the server returns the response in JSON format:

{
  "messages" : [
    {
      "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID"
    }
  ]
}

PowerShell

To get HL7v2 messages in bulk, make a GET request and specify the following information:

  • The name of the parent dataset
  • The name of the HL7v2 store
  • An access token
  • The query parameter names with the names of the HL7v2 messages you want to retrieve. For each names value, enter the fully qualified path to the message in the format: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID

The following sample shows a GET request using Windows PowerShell.

$cred = gcloud auth application-default print-access-token
$headers = @{ Authorization = "Bearer $cred" }

Invoke-WebRequest `
  -Method Get `
  -Headers $headers `
  -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages:batchGet?names=MESSAGE_NAME_1&names=MESSAGE_NAME_2&names=MESSAGE_NAME_3&view=FULL" | Select-Object -Expand Content

If the request is successful, the server returns the response in JSON format:

{
  "messages" : [
    {
      "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID"
    }
  ]
}

See also