Sidebar

How can I handle a Base64 PDF embedded within an Hl7 result file (in the OBX Segment)

0 votes
22.4K views
asked Oct 2, 2014 by matt-w-2627 (3,220 points)

I'm receiving an HL7 lab results file, from a well known national laboratory.

In the last OBX segment, they base64 encoded an entire PDF of the results

related to an answer for: What is base64 encoding?
commented Oct 2, 2014 by matt-w-2627 (3,220 points)
Yes, that is a test message with fake patient data

1 Answer

+1 vote
 
Best answer

Since the entire PDF is encoded within that segment, we need to 1) extract and decode that segment, and 2) write the contents out to a file.

In my example, the OBX segment may NOT always be the last segment. So I am using an XPath to provide the node where OBX-5.4 equals the string 'Base64' which always precedes the Base64 encoded PDF.

//get the encoded OBX5 where the type is Base64
var obx5Decoded = qie.base64DecodeToBytes(message.getNode('OBX[@5.4=Base64]-5.5'));

// create new message with PDF as the content
message = qie.createTextMessage(obx5Decoded);

Finally, in my outbound node, I output to a folder with a filename equivalent to MSH-10 of the source message (with PDF as the extension)

D:\Processed\{s:MSH-10}.pdf

answered Oct 2, 2014 by matt-w-2627 (3,220 points)
selected Oct 2, 2014 by rich-c-2789
...