This page describes how to export HL7v2 messages to Pub/Sub using the projects.locations.datasets.hl7V2Stores.export
method.
You can export HL7v2 messages to Pub/Sub for downstream processing.
Suppose you have a Dataflow pipeline that transforms HL7v2 messages
when new messages are ingested into an HL7v2 store. The pipeline reads from a
Pub/Sub subscription and waits for notifications of new HL7v2
messages. When you import HL7v2 messages into an HL7v2 store using the hl7V2Stores.import
method, the method doesn't send Pub/Sub notifications
.
To trigger the pipeline, import the HL7v2 messages and then use the hl7v2Stores.export
method to export them to Pub/Sub.
Before you begin
Enable the Pub/Sub API
In the Google Cloud console, enable the Pub/Sub API:
Configure Pub/Sub permissions
To export messages from an HL7v2 store to Pub/Sub, you must add
the pubsub.publisher
role to your project's Cloud Healthcare Service Agent service account
.
See DICOM, FHIR, and HL7v2 store Pub/Sub permissions
for steps to add the required role.
Create a Pub/Sub topic
To create a topic, see Create a topic .
Individual data stores can have their own Pub/Sub topic, or multiple data stores can share the same topic.
Use the following format when specifying the Pub/Sub topic:
projects/ PROJECT_ID /topics/ TOPIC_NAME
PROJECT_ID
is your Google Cloud project ID and TOPIC_NAME
is the name of the Pub/Sub topic.
Export HL7v2 messages to Pub/Sub
Export a subset of HL7v2 messages using a filter
You can use the following fields in your filter criteria:
You can specify the following filter parameters as your filter criteria in the filter
field. To learn the filter
syntax and construct queries, see Query strings
.
-
message_type: from the MSH.9.1 field. For example,NOT message_type = "ADT". -
send_date: theYYYY-MM-DDdate the message was sent from the MSH.7 segment, specified in the time zone of the dataset. For example,send_date < "2017-01-02". -
send_time: the timestamp when the message was sent. This parameter is from the MSH.7 segment of the message. This parameter uses the RFC 3339 time format for comparisons. For example,send_time < "2017-01-02T00:00:00-05:00". -
create_time: the timestamp when the message was created in the Cloud Healthcare API, using the RFC 3339 time format for comparisons. For example:create_time < "2017-01-02T00:00:00-05:00". -
send_facility: the care center that the message came from, from the MSH.4 segment. For example,send_facility = "ABC".
The following samples show how to specify a filter to only export HL7v2 messages
of type ADT
.
View exported HL7v2 messages in Pub/Sub
To view the exported HL7v2 messages in Pub/Sub,
run the gcloud pubsub subscriptions pull
command. The command uses the --format=json
flag to return the output as JSON instead of the default YAML.
gcloud pubsub subscriptions pull --auto-ack projects/ PROJECT_ID /subscriptions/ PUBSUB_SUBSCRIPTION \ --format = json
-
PROJECT_IDis the ID of your Google Cloud project -
PUBSUB_SUBSCRIPTIONis the subscription attached to the Pub/Sub topic where you exported HL7v2 messages
The output is the following:
[ { "ackId": " ACK_ID ", "message": { "attributes": { "msgType": "TYPE" }, "data": " DATA ", "messageId": "8076570784126536", "publishTime": " YYYY-MM-DDTHH:MM:SS+ZZ:ZZ " } } ]

