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

October 18th, 2006 by Dave Shaver

4 Votes | Average: 4.5 out of 54 Votes | Average: 4.5 out of 54 Votes | Average: 4.5 out of 54 Votes | Average: 4.5 out of 54 Votes | Average: 4.5 out of 5 (4 votes, average: 4.5 out of 5)

Loading ... Loading ...

Posted in HL7 Messaging

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.
Last 5 posts by Dave Shaver
4 Responses to “How Do I Send a Binary File Inside of an HL7 Message?”
  1. Sending Images or Formatted Documents via HL7 Messaging - NeoTool Healthcare IT Blog says:

    […] Enter the HL7 2.X Encapsulated Data (ED) type. In a prior post, I described how the magic ED data type inside an HL7 ORU message allows me to move a binary file between systems. […]

  2. PDF Attachment in HL7 Message says:

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

  3. Sending text documents or reports via an HL7 interface says:

    […] applications support moving rich text documents via either an ED or RP data type. This means that the sender can deliver a PDF, Word document, RTF document, HTML […]

  4. Eugene Shifrin says:

    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?

Leave a Reply

Discover the NeoTool Healthcare Integration Solution for Your Market.