Health Standards

Healthcare & Technology Resources

  • Blog
  • Podcasts
  • #HITsm Chat
  • About
  • Authors

How Do I Send a Binary File Inside of an HL7 Message?

October 18, 2006 By Dave Shaver 12 Comments

HL7 messaging insights. HL7 2.X has one primary message used for moving “results” from a producer to a consumer:  The ORU^R01 “unsolicited result” message. A lab system is an example producer (creating lab results) while an electronic medical record (EMR) system is an example consumer (storing/displaying the lab result).

The contents of the ORU message are “wide open” and everything from vital signs to dictated documents can be sent via this single HL7 message. To allow one message structure to carry such a mixture of data, the ORU message encodes the pieces of the result being sent in an OBX segment.

Here is an subset of an example result message for a Urinalysis:

MSH|^~\&|X|Y|LIS|TEST9999|199807311532||ORU^R01|3738|P|2.2
PID|107|21613…
ORC|RE|8642753…
OBR|1|8642753100117|21079900680|003038^URINALYSIS, ROUTINE^L|…
OBX|1|NM|013060^Specific Gravity^L||1.010||1.005-1.030|||N|F|…
OBX|2|CE|013045^Urine-Color^L||Y^Yellow^L||Y|||N|F|…
OBX|3|ST|013052^Appearance^L||Hazy||Clear|A||N|F|…

The key here is that the lab result is sending three types of data and each is keyed in the OBX-2 field telling what type of data is being sent in that given OBX. Thus, a NM indicates a numeric value for Specific Gravity, a CE indicates coded value for Urine color, and a ST is a string value for the urine appearance.

This same message can be used to send “lines of text” in a transcribed clinical document setting:

MSH|^~\&|PSCRIBE||RDHL701||20021021070646||ORU^R01|20021021070646|P|2.3
PID|||12345||Bob^Joe|…
PV1||I|IQ^363^07||…
OBR|1|P123|F123|502^CHEST XRAY^L|…
OBX|3|TX|502^CHEST XRAY^L|1|Portable chest 8:05 p.m.||||||F
OBX|4|TX|502^CHEST XRAY^L|1|||||||F
OBX|5|TX|502^CHEST XRAY^L|1|Swan-Ganz check||||||F
OBX|6|TX|502^CHEST XRAY^L|1|Comparison prior same day||||||F
OBX|7|TX|502^CHEST XRAY^L|1|||||||F
OBX|8|TX|502^CHEST XRAY^L|1|Swan tip projects over what is likely a proximal branch of the right||||||F
OBX|9|TX|502^CHEST XRAY^L|1|lower lobe pulmonary artery. Basilar air space disease. No definite||||||F
…

If you want to include a binary object as part of the ORU, HL7 uses the ORU message with an ED (encapsulated data) data type in an OBX-5. The type of encoded of object is sent along with a base-64 encoded version of that object.

Here is an example of sending the same radiology report as a Word document packaged/embedded inside of an HL7 message looks like this:

MSH|^~\&|PSCRIBE||RDHL701||20021021070646||ORU^R01|20021021070646|P|2.3
PID|||12345||Bob^Joe|…
PV1||I|IQ^363^07||…
OBR|1|P123|F123|502^CHEST XRAY^L|…
OBX|1|ED|502^CHEST XRAY^L||Word^TEXT^^Base64^JVBERi0xLjMKJeTjz9IKNSAwI… (many more bytes!)

In training class, I stress that it is not difficult to encode a binary object into HL7 messaging. The critical problem is that both ends of the connection must support all three of these items:

  1. the ED data type,
  2. the document type being sent, and
  3. have a method of getting that document all the way to the user’s screen.
The following two tabs change content below.
  • Bio
  • Latest Posts
My Twitter profileMy LinkedIn profile

Dave Shaver

Dave Shaver is the CTO for Corepoint Health. Dave has more than 20 years experience in training, consulting, and software development. He’s deeply involved in the HL7 standards community, including co-chair of HL7 Infrastructure and Messaging committee and co-chair of the HL7 FHIR Governance Board.
My Twitter profileMy LinkedIn profile

Latest posts by Dave Shaver (see all)

  • HL7 ADT Q&A with Dave Shaver - July 2, 2014
  • Health Standards Community Membership Archetypes: Who uses HL7? - August 6, 2013
  • Note from the Field: Meditech 6.0 HL7 Integration - September 6, 2011

Filed Under: HL7 Messaging

  • Pingback: Sending Images or Formatted Documents via HL7 Messaging - NeoTool Healthcare IT Blog()

  • Pingback: PDF Attachment in HL7 Message()

  • Pingback: Sending text documents or reports via an HL7 interface()

  • Eugene Shifrin

    Please advise me what kind of document formats HIS is most likely to understand? Word? PDF?

    Is it more likely to accept document through RP or ED?

    Can you send me or put here some sample message and specification of the system that knows to accept and display such documents?

  • Yves Lejeune

    Hello,
    I think there is a typo error in the OBX-5 value: it should be “^Word^TEXT^Base64^…” rather than “Word^TEXT^^Base64^…”.
    Best regards,
    Yves.

  • Yves Lejeune

    Sorry for my invalid comment, I was puzzled by the missing subtype value. In case other ones make the same mistake as me: “WORD” is used as “Application ID” (probably only valid for this example), then “TEXT” is one of the Type of Data listed in HL7 table 0191. Then the Subtype is unspecified: this coud be a local deployment rule, or the list of Subtypes of could be extended to explicitely enable a “MSWord” Subtype.

  • Pingback: Embedding or Sending a CCR Document Inside an HL7 2.X Message | HL7 Standards()

  • Pingback: Sending Text Documents or Reports via an HL7 Interface | HL7 Standards()

  • Jefy Dominic

    Can we insert patient photo in HL7 messages?

  • Dave Shaver

    Jefy: Yes, you may attach a patient photo to an HL7 message. As is discussed in this posting among others, the key question is not “Can you put it in?” but rather “Can your trading partner recognize it, extract it, and put it somewhere useful in their application.”

  • Jason Hamm

    Is there a size limit for the attachment that is being embedded into the HL7 file?  If there is, can you split and attachment up into more than one field and recreate it on the other end?  

  • Pingback: Confluence: SW Maintenance()

HL7 FHIR Resources

HL7 FHIR Resources

Connect

  • 
  • 
  • 
  • 
Tweets by @HealthStandards

#HITSM Chat

[#HITsm chat 11.18.16] Celebrate Passing the #HITsm Torch

November 15, 2016

Moderated by Chad Johnson, @OchoTex, HealthStandards.com Editor and Corepoint Health Senior Marketing Manager. November 18th will be the last #HITsm chat under @HealthStandards. Celebrate ‘Passing the #HITsm torch’ to @techguy @HealthcareScene.

Passing the #HITsm torch

November 10, 2016

The first #HITsm tweet chat was held almost six years ago on Jan 10, 2011. Since that time, we have hosted approximately 280 #HITsm chats. While some of you may have participated in that very first chat (only 15 actually participated), I’m proud to say that the chats and the community have continued to grow […]

View More #HITSM Chat >

Podcasts

‘Hactivist’ Fred Trotter on the Cancer Moonshot, open source data in healthcare, and more

August 3, 2016

Artificial intelligence is a topic that isn’t going away in the health IT and medical community. One reason it’s come as far as it has is thanks to open sourcing, or shared data. Today’s guest, Fred Trotter, has a lot to say about the Vice President’s Cancer Moonshot initiative – which he was recognized for […]

Sue Schade on gender equality, CIO challenges, and value-based healthcare

July 27, 2016

View More Podcasts >

Copyright © 2021 Health Standards. All Rights Reserved.