HL7v2 message upload failure

13 views
Skip to first unread message

Cogni Tinto

unread,
Jan 2, 2025, 8:10:55 AMJan 2
to GCP Healthcare Discuss
Hi All! Wish you all a Happy New Year 2025!

Can anyone let me know how to solve this -
Am trying to upload a  sample HL7v2 message to  HL7v2 store - 
Option 1 - Text format:
hl7_message2.txt file - 
MSH|^~\\&|EPIC|EPICADT|SMS|SMSADT|20060529135711||ADT^A04|0105291357|P|2.3\rEVN|A04|200605291357||\rPID|1||000000123^^^MRN||MYNAME2^MYNAME1||19710101|M|||123 MAIN ST^^ANYTOWN^ANYCOUNTRY^12345||(123)555-1212||(123)555-1212|||||123456789|987654^NC\rPV1|1|I|2000^2012^01||||004777^MYNAME3^MYNAME4^|003777^MYNAME5^MYNAME6^|008888^MY^NAME^|||SUR|||||19090999|||||||||||||||||||||||||200605291357

using the cURL - 
curl -X POST "https://healthcare.googleapis.com/v1/projects/<MYPROJ>/locations/<BEAT_ELON_TO_MARS_LOCATION>/datasets/<MYDATA>-dataset/hl7V2Stores/<MYDATA>-hl7-store/messages?messageId=testMessage" \
-H "Authorization: Bearer <MYTOKEN>" \
-H "Content-Type: application/json" \
-d @C:/projects/Utilities/hl7_message2.json

curl -v -X POST "https://healthcare.googleapis.com/v1/projects/ MYPROJ/locations/MARS!_ELONS_LATE/datasets/ MYDATA-dataset/hl7V2Stores/ MYDATA-hl7-store/messages?messageId=testMessage" \
-H "Authorization: Bearer  MYTOKEN" \
-H "Content-Type: application/hl7-v2" \
--data-binary @C:/projects/Utilities/hl7_message2.txt

Error Response -
 { "error": { "code": 400, "message": "Invalid JSON payload received. Unexpected token.\nMSH|^~\\&|EPIC|EPICAD\n^", "status": "INVALID_ARGUMENT" } }
  ======================
Option 2 - json format-
hl7_message2.json  -
{ "data": "MSH|^~\\&|EPIC|EPICADT|SMS|SMSADT|20060529135711||ADT^A04|0105291357|P|2.3\rEVN|A04|200605291357||\rPID|1||000000123^^^MRN||MYNAME2^MYNAME1||19710101|M|||123 MAIN ST^^ANYTOWN^ANYCOUNTRY^12345||(123)555-1212||(123)555-1212|||||123456789|987654^NC\rPV1|1|I|2000^2012^01||||004777^MYNAME3^MYNAME4^|003777^MYNAME5^MYNAME6^|008888^MY^NAME^|||SUR|||||19090999|||||||||||||||||||||||||200605291357", "labels": { "type": "ADT" } }

cURL request -
 curl -X POST https://healthcare.googleapis.com/v1/projects/<MYPROJ>/locations/<BEAT_ELON_TO_MARS_LOCATION>/datasets/<MYDATA>-dataset/hl7V2Stores/<MYDATA>-hl7-store/messages?messageId=testMessage" \
-H "Authorization: Bearer <MYTOKEN>" \   -H "Content-Type: application/json" -d @ C:/projects/Utilities/hl7_message2/hl7_message2.json   

Error -  { "error": { "code": 400, "message": "Invalid JSON payload received. Unknown name \"data\": Cannot find field.\nInvalid JSON payload received. Unknown name \"labels\": Cannot find field.", "status": "INVALID_ARGUMENT", "details": [ { "@type": "type.googleapis.com/google.rpc.BadRequest", "fieldViolations": [ { "description": "Invalid JSON payload received. Unknown name \"data\": Cannot find field." }, { "description": "Invalid JSON payload received. Unknown name \"labels\": Cannot find field." } ] } ] } }

Truc Le

unread,
Jan 2, 2025, 9:55:04 AMJan 2
to GCP Healthcare Discuss
Hello,

These are the errors that I could see:

1. Carriage return should be \r, not \n

2. The input file is supposed to be a message proto with base64 encoding of the data field.

Please refer to this guide on how to replace \n with \r and perform base64 encoding.

So the expected curl command is:

curl -X POST \
     -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     -H "Content-Type: application/json; charset=utf-8" \
     --data @message_file.txt \
     "https://healthcare.googleapis.com/v1/projects/${PROJECT?}/locations/${LOCATION?}/datasets/${DATASET?}/hl7V2Stores/${HL7_STORE?}/messages"

where message_file.txt has the following format:
{"message": {"data": "base64-encoding-of-the-raw-message"}}

Best,
Reply all
Reply to author
Forward
0 new messages