This page explains how to ingest, create, label, list, view, and delete HL7v2 messages. HL7v2 messages are used to transmit clinical data between systems. An HL7v2 message might contain information about an observation result, a prescription to send to a pharmacy, a financial transaction, or other clinical events.
Overview of creating and ingesting HL7v2 messages
Use either of the following methods to store an HL7v2 message in the Cloud Healthcare API:
When you use messages.ingest
, the method generates a response containing
one of the following:
- An HL7v2 acknowledgement (
ACK
) message when successful - A negative acknowledgement (
NACK
) message when there is an error
The ACK
and NACK
messages are used for replying to HL7v2 interface systems
that expect these acknowledgements.
Message ingestion and creation with an MLLP adapter
HL7v2 messages are delivered between care systems and the Cloud Healthcare API using the minimal lower layer protocol (MLLP). For more information, see MLLP and the Google Cloud Platform MLLP adapter. For instructions on how to configure an MLLP adapter to communicate securely with the Cloud Healthcare API, see Transmitting HL7v2 messages over TCP/IP connections.
Ingesting HL7v2 messages
After the Cloud Healthcare API ingests the message from a care system, the
Cloud Healthcare API generates a response containing an hl7ack
field
which contains a base64-encoded HL7v2 message with the following
characteristics:
- The message type is
ACK
. - The sending facility and the receiving facility are reversed, and the sending application and receiving application are reversed.
- The send time of the message is the current time and a new control ID is generated.
- The
MSH-9.1
field's value defines the message type. - The
MSA.1
field's value defines a response type. AnAA
response type indicatesApplication Accept
, meaning that the message was validated and successfully ingested. - The
MSA.2
value contains the original message's control ID.
The following samples show how to ingest an HL7v2 message using the
projects.locations.datasets.hl7V2Stores.messages.ingest
method.
curl
To ingest an HL7v2 message, make a POST
request and specify the following
information:
- The name and location of the parent dataset
- The name of the HL7v2 store
- A
Message
The following sample shows a POST
request using curl
and a sample JSON file
called
hl7v2-sample.json
.
curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ --data-binary @hl7v2-sample.json \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages:ingest"
The following sample response shows the hl7Ack
and message details.
{ "hl7Ack": "TVNIfF5+XCZ8QXxBfEF8U0VORF9GQUNJTElUWXwyMDIwMDIxNDIxMjAwNXx8QUNLfDFmMmQ1MjQzLTFhOWEtNGE4My05ZmI5LWNlNTIzMTVmZjk2M3xUfDAuMA1NU0F8QUF8MjAxODAxMDEwMDAwMDA=", "message": { "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID", "data": "TVNIfF5+XCZ8QXxTRU5EX0ZBQ0lMSVRZfEF8QXwyMDE4MDEwMTAwMDAwMHx8VFlQRV5BfDIwMTgwMTAxMDAwMDAwfFR8MC4wfHx8QUF8fDAwfEFTQ0lJDUVWTnxBMDB8MjAxODAxMDEwNDAwMDANUElEfHwxNAExMTFeXl5eTVJOfDExMTExMTExXl5eXk1STn4xMTExMTExMTExXl5eXk9SR05NQlI=", "sendFacility": "SEND_FACILITY", "sendTime": "2018-01-01T00:00:00Z", "messageType": "TYPE", "createTime": "CREATE_TIME", "patientIds": [ { "value": "14\u0001111", "type": "MRN" }, { "value": "11111111", "type": "MRN" }, { "value": "1111111111", "type": "ORGNMBR" } ] } }
PowerShell
To ingest an HL7v2 message, make a POST
request and specify the following
information:
- The name and location of the parent dataset
- The name of the HL7v2 store
- A
Message
The following sample shows a POST
request using PowerShell and a
sample JSON file called
hl7v2-sample.json
.
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Post ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -InFile hl7v2-sample.json ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages:ingest" | Select-Object -Expand Content
The following sample response shows the hl7Ack
and message details.
{ "hl7Ack": "TVNIfF5+XCZ8QXxBfEF8U0VORF9GQUNJTElUWXwyMDIwMDIxNDIxMjAwNXx8QUNLfDFmMmQ1MjQzLTFhOWEtNGE4My05ZmI5LWNlNTIzMTVmZjk2M3xUfDAuMA1NU0F8QUF8MjAxODAxMDEwMDAwMDA=", "message": { "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID", "data": "TVNIfF5+XCZ8QXxTRU5EX0ZBQ0lMSVRZfEF8QXwyMDE4MDEwMTAwMDAwMHx8VFlQRV5BfDIwMTgwMTAxMDAwMDAwfFR8MC4wfHx8QUF8fDAwfEFTQ0lJDUVWTnxBMDB8MjAxODAxMDEwNDAwMDANUElEfHwxNAExMTFeXl5eTVJOfDExMTExMTExXl5eXk1STn4xMTExMTExMTExXl5eXk9SR05NQlI=", "sendFacility": "SEND_FACILITY", "sendTime": "2018-01-01T00:00:00Z", "messageType": "TYPE", "createTime": "CREATE_TIME", "patientIds": [ { "value": "14\u0001111", "type": "MRN" }, { "value": "11111111", "type": "MRN" }, { "value": "1111111111", "type": "ORGNMBR" } ] } }
Go
Java
Node.js
Python
Creating HL7v2 messages
The following samples show how to create an HL7v2 message using the
projects.locations.datasets.hl7V2Stores.messages.create
method.
REST
To create an HL7v2 message, use the projects.locations.datasets.hl7V2Stores.messages.create
method.
If you need an HL7v2 message file to use with the sample commands, you can
download the
hl7v2-sample.json
JSON file.
Before using any of the request data, make the following replacements:
- PROJECT_ID: the ID of your Google Cloud project
- LOCATION: the dataset location
- DATASET_ID: the HL7v2 store's parent dataset
- HL7V2_STORE_ID: the HL7v2 store ID
- HL7V2_MESSAGE_FILE: the path to a JSON-formatted file containing an HL7v2 message on your local machine
To send your request, choose one of these options:
curl
Execute the following command:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
--data-binary @HL7V2_MESSAGE_FILE \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages"
PowerShell
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-InFile HL7V2_MESSAGE_FILE `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages" | Select-Object -Expand Content
APIs Explorer
Open the method reference page. The APIs Explorer panel opens on the right side of the page. You can interact with this tool to send requests. Complete any required fields and click Execute.
hl7v2-sample.json
JSON file:
Go
Java
Node.js
Python
HL7v2 message segment separators and encoding
The default segment separator in HL7v2 is a carriage return (\r
). Most text
editors use newline (\n
) characters as segment separators. This produces HL7v2
messages that can't be ingested into the Cloud Healthcare API using the
default configuration. To permit an HL7v2 store to ingest messages that use
newline characters as segment separators, see
Setting the segment terminator.
To convert the newline characters in a file to carriage returns, run the following command in a Linux shell:
sed -z 's/\n/\r/g' INPUT_FILENAME > OUTPUT_FILENAME
The ingest and create methods expect HL7v2 messages to be base64 encoded strings. To convert a string to base64 encoding, run the following command in a Linux shell:
openssl base64 -A -in ./INPUT_FILENAME -out ./OUTPUT_FILENAME
Setting the segment terminator
When creating or ingesting data, the
HL7v2 message format
requires that segments are terminated using the return
character, \r
. You can configure an HL7v2 store to accept HL7v2 messages
with a non-standard terminator, such as \n
.
Consider the following HL7v2 message that uses the default \r
as the segment
terminator. This message is accepted by default when you create an HL7v2 store.
MSH|^~\\&|FROM_APP|FROM_FACILITY|TO_APP|TO_FACILITY|20150503223000||ADT^A01|20150503223000|P|2.5|\r EVN|A01|20110613083617|\r PID|1||21004053^^^^MRN||SULLY^BRIAN||19611209|M|||123 MAIN ST^^MOUNTAIN SPRINGS^CO^80439|\r PV1||I|H73 RM1^1^^HIGHWAY 73 CLINIC||||5148^MARY QUINN|||||||||Y||||||||||||||||||||||||||||20150503223000|\r
The following message is identical to the previous message, except that
it uses \n
as the segment terminator:
MSH|^~\\&|FROM_APP|FROM_FACILITY|TO_APP|TO_FACILITY|20150503223000||ADT^A01|20150503223000|P|2.5|\n EVN|A01|20110613083617|\n PID|1||21004053^^^^MRN||SULLY^BRIAN||19611209|M|||123 MAIN ST^^MOUNTAIN SPRINGS^CO^80439|\n PV1||I|H73 RM1^1^^HIGHWAY 73 CLINIC||||5148^MARY QUINN|||||||||Y||||||||||||||||||||||||||||20150503223000|\n
To store the message with the non-standard terminator, configure the
ParserConfig
object in the HL7v2 store and set the segmentTerminator
field to the
base64-encoding of \n
.
The following samples show how to configure segmentTerminator
in
ParserConfig
when you
create an HL7v2 store.
If you have an existing HL7v2 store, you can
edit it
to provide the ParserConfig
body. After setting the segment terminator, you
can create or ingest
the message.
curl
To create an HL7v2 store with the segment terminator set to \n
, make a
POST
request and specify the following information:
- The name and location of the parent dataset
- The name of the HL7v2 store
- A
parserConfig
object with thesegmentTerminator
set toCg==
(the base64-encoding of\n
)
The following sample shows a POST
request using curl
.
curl -X POST \ --data "{ 'parserConfig': { 'segmentTerminator': 'Cg==' } }" \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores?hl7V2StoreId=HL7V2_STORE_ID"
If the request is successful, the server returns the response in JSON format:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID", "parserConfig": { "segmentTerminator": "Cg==" } }
PowerShell
To create an HL7v2 store with the segment terminator set to \n
, make a
POST
request and specify the following information:
- The name and location of the parent dataset
- The name of the HL7v2 store
- A
parserConfig
object with thesegmentTerminator
set toCg==
(the base64-encoding of\n
)
The following sample shows a POST
request using PowerShell.
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Post ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -Body "{ 'parserConfig': { 'segmentTerminator': 'Cg==' } } ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores?hl7V2StoreId=HL7V2_STORE_ID" | Select-Object -Expand Content
If the request is successful, the server returns the response in JSON format:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID", "parserConfig": { "segmentTerminator": "Cg==" } }
Using a null segment header
An HL7v2 message without a
message header segment (MSH)
has a null segment header. Typically, an HL7v2 message contains a MSH that
defines metadata such as the message's source, intent, purpose, and destination.
The MSH enables you to search and filter messages. However, you can store
messages that don't contain an MSH by configuring the
ParserConfig
object in the HL7v2 store and set the allowNullHeader
field to true
.
The folllowing sample message contains a Patient Identification (PID) segment, but no MSH:
PID|1||21004053^^^^MRN||SULLY^BRIAN||19611209|M|||123 MAIN ST^^MOUNTAIN SPRINGS^CO^80439
The following samples show how to configure allowNullHeader
in ParserConfig
when you
create an HL7v2 store.
If you have an existing HL7v2 store, you can
edit it
and provide the ParserConfig
body. After setting allowNullHeader
to true
,
you can create or ingest messages with null segment headers.
curl
To create an HL7v2 store and store messages that don't contain an MSH, make a
POST
request and specify the following information:
- The name and location of the parent dataset
- The name of the HL7v2 store
- A
parserConfig
object withallowNullHeader
set totrue
The following sample shows a POST
request using curl
.
curl -X POST \ --data "{ 'parserConfig': { 'allowNullHeader': true } }" \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores?hl7V2StoreId=HL7V2_STORE_ID"
If the request is successful, the server returns the response in JSON format:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID", "parserConfig": { "allowNullHeader": true } }
PowerShell
To create an HL7v2 store and store messages that don't contain an MSH, make a
POST
request and specify the following information:
- The name and location of the parent dataset
- The name of the HL7v2 store
- A
parserConfig
object withallowNullHeader
set totrue
The following sample shows a POST
request using PowerShell.
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Post ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -Body "{ 'parserConfig': { 'nullTerminator': true } } ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores?hl7V2StoreId=HL7V2_STORE_ID" | Select-Object -Expand Content
If the request is successful, the server returns the response in JSON format:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID", "parserConfig": { "allowNullHeader": true } }
Labeling an HL7v2 message
You can add one or more key-value labels to a message. A use case for labels is adding status labels to a message so that an application can query messages by status.
The following samples show how to add labels to an HL7v2 message using the
projects.locations.datasets.hl7V2Stores.messages.patch
method.
curl
To add labels to an HL7v2 message, make a PATCH
request and specify the
following information:
- The name and location of the parent dataset
- The name of the HL7v2 store
- The message ID
- The label data to update
- An update mask
The following sample shows a PATCH
request using curl
.
curl -X PATCH \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ --data "{ 'labels': { 'KEY' : 'VALUE' } }" "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID?updateMask=labels"
If the request is successful, the server returns the response in JSON format:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID", "data": "DATA", "sendFacility": "SEND_FACILITY", "sendTime": "2018-01-01T00:00:00Z", "messageType": "TYPE", "createTime": "CREATE_TIME", "patientIds": [ { "value": "VALUE_1", "type": "TYPE_1" }, { "value": "VALUE_2", "type": "TYPE_2" } ], "labels": { "KEY": "VALUE" } }
PowerShell
To add labels to an HL7v2 message, make a PATCH
request and specify the
following information:
- The name and location of the parent dataset
- The name of the HL7v2 store
- The message ID
- The label data to update
- An update mask
The following sample shows a PATCH
request using PowerShell.
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Patch ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -Body "{ 'labels': { 'KEY': 'VALUE' } }" ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID?updateMask=labels" | Select-Object -Expand Content
If the request is successful, the server returns the response in JSON format:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID", "data": "DATA", "sendFacility": "SEND_FACILITY", "sendTime": "2018-01-01T00:00:00Z", "messageType": "TYPE", "createTime": "CREATE_TIME", "patientIds": [ { "value": "VALUE_1", "type": "TYPE_1" }, { "value": "VALUE_2", "type": "TYPE_2" } ], "labels": { "KEY": "VALUE" } }
Go
Java
Node.js
Python
Getting HL7v2 message contents
The following samples show how to get the contents of an HL7v2 message using the
projects.locations.datasets.hl7V2Stores.messages.get
method. To determine the parts of the message to get, supply the view
query
parameter with one of the following options:
BASIC
: Include only thename
field.RAW_ONLY
: Include all the message fields except theparsedData
field.PARSED_ONLY
: Include all the message fields except thedata
field.FULL
: Include all the message fields. This is the default.
The following samples show how to get the contents of an HL7v2 message using the
FULL
, RAW_ONLY
, and PARSED_ONLY
views.
Using the FULL
view
You don't need to explicitly set the FULL
view, as FULL
is the default
value. However, in the following curl
and PowerShell samples, the
FULL
view is added as a query parameter for completeness.
curl
To get the contents of an HL7v2 message using the FULL
view, make a GET
request and specify the following information:
- The name and location of the parent dataset
- The name of the HL7v2 store
- The message ID
FULL
as theview
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/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID?view=FULL"
If the request is successful, the server returns the response in JSON format:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID", "data": "DATA", "sendFacility": "SEND_FACILITY", "sendTime": "2018-01-01T00:00:00Z", "messageType": "TYPE", "createTime": "CREATE_TIME", "patientIds": [ { "value": "VALUE_1", "type": "TYPE_1" }, { "value": "VALUE_2", "type": "TYPE_2" }, { "value": "VALUE_3", "type": "TYPE_3" } ], "parsedData": { "segments": [ { ""segmentId": "SEGMENT_ID_1", "fields": { FIELDS_1 } }, { "segmentId": "SEGMENT_ID_2", "fields": { FIELDS_2 } }, { "segmentId": "SEGMENT_ID_3", "fields": { FIELDS_3 } } ] } }
PowerShell
To get the contents of an HL7v2 message using the FULL
view, make a GET
request and specify the following information:
- The name and location of the parent dataset
- The name of the HL7v2 store
- The message ID
FULL
as theview
The following sample shows a GET
request using PowerShell.
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Get ` -Headers $headers ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID?view=FULL" | Select-Object -Expand Content
If the request is successful, the server returns the response in JSON format:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID", "data": "DATA", "sendFacility": "SEND_FACILITY", "sendTime": "2018-01-01T00:00:00Z", "messageType": "TYPE", "createTime": "CREATE_TIME", "patientIds": [ { "value": "VALUE_1", "type": "TYPE_1" }, { "value": "VALUE_2", "type": "TYPE_2" }, { "value": "VALUE_3", "type": "TYPE_3" } ], "parsedData": { "segments": [ { ""segmentId": "SEGMENT_ID_1", "fields": { FIELDS_1 } }, { "segmentId": "SEGMENT_ID_2", "fields": { FIELDS_2 } }, { "segmentId": "SEGMENT_ID_3", "fields": { FIELDS_3 } } ] } }
Go
Java
Node.js
Python
Using the RAW_ONLY
view
The following samples show how to get the contents of an HL7v2 message using
the RAW_ONLY
view, which includes all of the message fields except for
parsedData
.
curl
To get the contents of an HL7v2 message using the RAW_ONLY
view, make a
GET
request and specify the following information:
- The name and location of the parent dataset
- The name of the HL7v2 store
- The message ID
RAW_ONLY
as the view
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/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID?view=RAW_ONLY"
If the request is successful, the server returns the response in JSON format:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID", "data": "DATA", "sendFacility": "SEND_FACILITY", "sendTime": "2018-01-01T00:00:00Z", "messageType": "TYPE", "createTime": "CREATE_TIME", "patientIds": [ { "value": "VALUE_1", "type": "TYPE_1" }, { "value": "VALUE_2", "type": "TYPE_2" }, { "value": "VALUE_3", "type": "TYPE_3" } ] }
PowerShell
To get the contents of an HL7v2 message using the RAW_ONLY
view, make a
GET
request and specify the following information:
- The name and location of the parent dataset
- The name of the HL7v2 store
- The message ID
RAW_ONLY
as the view
The following sample shows a GET
request using PowerShell.
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Get ` -Headers $headers ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID?view=RAW_ONLY" | Select-Object -Expand Content
If the request is successful, the server returns the response in JSON format:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID", "data": "DATA", "sendFacility": "SEND_FACILITY", "sendTime": "2018-01-01T00:00:00Z", "messageType": "TYPE", "createTime": "CREATE_TIME", "patientIds": [ { "value": "VALUE_1", "type": "TYPE_1" }, { "value": "VALUE_2", "type": "TYPE_2" }, { "value": "VALUE_3", "type": "TYPE_3" } ] }
Using the PARSED_ONLY
view
The following samples show how to get the contents of an HL7v2 message using
the PARSED_ONLY
view, which includes all of the message fields except for
data
.
curl
To get the contents of an HL7v2 message using the PARSED_ONLY
view, make a
GET
request and specify the following information:
- The name and location of the parent dataset
- The name of the HL7v2 store
- The message ID
PARSED_ONLY
as the view
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/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID?view=PARSED_ONLY"
If the request is successful, the server returns the response in JSON format:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID", "sendFacility": "SEND_FACILITY", "sendTime": "2018-01-01T00:00:00Z", "messageType": "TYPE", "createTime": "CREATE_TIME", "patientIds": [ { "value": "VALUE_1", "type": "TYPE_1" }, { "value": "VALUE_2", "type": "TYPE_2" }, { "value": "VALUE_3", "type": "TYPE_3" } ], "parsedData": { "segments": [ { "segmentId": "SEGMENT_ID_1", "fields": { FIELDS_1 } }, { "segmentId": "SEGMENT_ID_2", "fields": { FIELDS_2 } }, { "segmentId": "SEGMENT_ID_3", "fields": { FIELDS_3 } } ] } }
PowerShell
To get the contents of an HL7v2 message using the PARSED_ONLY
view, make a
GET
request and specify the following information:
- The name and location of the parent dataset
- The name of the HL7v2 store
- The message ID
PARSED_ONLY
as the view
The following sample shows a GET
request using PowerShell.
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Get ` -Headers $headers ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID?view=PARSED_ONLY" | Select-Object -Expand Content
If the request is successful, the server returns the response in JSON format:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID", "sendFacility": "SEND_FACILITY", "sendTime": "2018-01-01T00:00:00Z", "messageType": "TYPE", "createTime": "CREATE_TIME", "patientIds": [ { "value": "VALUE_1", "type": "TYPE_1" }, { "value": "VALUE_2", "type": "TYPE_2" }, { "value": "VALUE_3", "type": "TYPE_3" } ], "parsedData": { "segments": [ { "segmentId": "SEGMENT_ID_1", "fields": { FIELDS_1 } }, { "segmentId": "SEGMENT_ID_2", "fields": { FIELDS_2 } }, { "segmentId": "SEGMENT_ID_3", "fields": { FIELDS_3 } } ] } }
Using the BASIC
view
The following samples show how to get the contents of an HL7v2 message using
the BASIC
view, which includes only the name
field.
curl
To get the contents of an HL7v2 message using the BASIC
view, make a
GET
request and specify the following information:
- The name and location of the parent dataset
- The name of the HL7v2 store
- The message ID
BASIC
as the view
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/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID?view=BASIC"
If the request is successful, the server returns the response in JSON format:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID" }
PowerShell
To get the contents of an HL7v2 message using the BASIC
view, make a
GET
request and specify the following information:
- The name and location of the parent dataset
- The name of the HL7v2 store
- The message ID
BASIC
as the view
The following sample shows a GET
request using PowerShell.
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Get ` -Headers $headers ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID?view=BASIC" | Select-Object -Expand Content
If the request is successful, the server returns the response in JSON format:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID" }
Listing HL7v2 messages
The following samples show how to list the messages in an HL7v2 store using the
method. To determine the information about each message to include in the list,
specify the view
query parameter with one of the following options:
BASIC
: Include only thename
field. This is the default.RAW_ONLY
: Include all the message fields except theparsedData
field.PARSED_ONLY
: Include all the message fields except thedata
field.FULL
: Include all the message fields.
curl
To list the messages in an HL7v2 store, make a GET
request and specify the
following information:
- The name and location of the parent dataset
- The name of the HL7v2 store
- The
view
, one ofBASIC
,RAW_ONLY
,PARSED_ONLY
, orFULL
, or omit to use the default ofBASIC
The following sample shows a GET
request using curl
. The request specifies
?view=FULL
to include all the message fields.
curl -X GET \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages?view=FULL"
If the request is successful, the server returns a 200 OK
HTTP status code and
an array of messages named hl7_v2_messages
. The following sample response is
truncated.
{ "hl7_v2_messages": [ { "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID", "data": "DATA", "sendFacility": "SEND_FACILITY", "sendTime": "SEND_TIME", "messageType": "MESSAGE_TYPE", "createTime": "CREATE_TIME", ... }, ... ] }
PowerShell
To list the messages in an HL7v2 store, make a GET
request and specify the
following information:
- The name and location of the parent dataset
- The name of the HL7v2 store
- The
view
, one ofBASIC
,RAW_ONLY
,PARSED_ONLY
, orFULL
, or omit to use the default ofBASIC
The following sample shows a GET
request using PowerShell. The request
specifies ?view=FULL
to include all the message fields.
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Get ` -Headers $headers ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages?view=FULL" | Select-Object -Expand Content
If the request is successful, the server returns the response in JSON format. The sample response is truncated.
{ "hl7_v2_messages": [ { "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID", "data": "DATA", "sendFacility": "SEND_FACILITY", "sendTime": "SEND_TIME", "messageType": "MESSAGE_TYPE", "createTime": "CREATE_TIME", ... }, ... ] }
Go
Java
Node.js
Python
Deleting an HL7v2 message
The following samples show how to delete an HL7v2 message using the
projects.locations.datasets.hl7V2Stores.messages.delete
method.
curl
To delete an HL7v2 message, make a DELETE
request and specify the
following information:
- The name and location of the parent dataset
- The name of the HL7v2 store
- The HL7v2 message ID
The following sample shows a DELETE
request using curl
.
curl -X DELETE \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID"
If the request is successful, the server returns the empty body response in JSON format:
{}
PowerShell
To delete an HL7v2 message, make a DELETE
request and specify the
following information:
- The name and location of the parent dataset
- The name of the HL7v2 store
- The HL7v2 message ID
The following sample shows a DELETE
request using PowerShell.
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Delete ` -Headers $headers ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID" | Select-Object -Expand Content
If the request is successful, the server returns the empty response body in JSON format:
{}