Thursday 8 November 2018

Writing Base64 encoded HL7 data to a Binary file

It is common to have Base64 encode data in an OBX-5 field. The most common I've come across are PDF documents, but also .Doc, Docx and other Document formats are common, as are the many image formats - TIFF, PNG, JPG, and BMP.

HL7 Soup is now my go-to HL7 integration engine for binary formats as it's just so simple, while at the same time it's totally flexible.  Let me show you. 

Create a receiver workflow that receives an HL7 message and then writes it out to a file.

In the transformers of the “File Writer” activity, drag the OBX-5 into the transformers list to create a new variable.


Then back in the “File Writer” change the message template to write out the variable (delete the default message template, the right click in message template and insert variable).


Now Just change the message type of the file you want to write to binary and you’ll have a binary file.


And that is it done.  Writing out a binary file automatically decodes the value from base64.  No mucking about with code or anything fiddly like that.  

OK, but what if it wasn’t actually binary data, you just had base64 encoded text for instance?  Well, you also have the option to right click on the variable and tell it to base64 decode the value like so. 




There are lots of different types of encoding available too.  Depending on the Message Type you select, you get different options.  E.g. if I had written out an XML document then right-clicking on the variable would allow me to "XML Encode" the data which replaces the &'s & etc.

7 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. I know this might be a completely dumb question, but we had been using RS232 port for transmitting messages from laboratory analyzer to LIS over ASTM protocol, but would like to switch over to HL7. We are using Abbott Architect ci4100, which supports both, but I'm not sure on which port of the analyzer I must connect to, the lan port or the RS232 itself.
    Email: khanhudanurul@gmail.com

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. Hi Nurul
      If I've understood you correctly, then I think you should point it to the Lan port. I assume that Abbott will be using TCP to send the message, wrapped up in MLLP (or LLP)? Make sure that the receiver is listening on the machines IP address and not local host since you are coming externally. Alternatively, can you get the HL7 written to a file, as that can also be picked up and processed.

      Delete
  3. Hi Nurul
    If I've understood you correctly, then I think you should point it to the Lan port. I assume that Abbott will be using TCP to send the message, wrapped up in MLLP (or LLP)? Make sure that the receiver is listening on the machines IP address and not local host since you are coming externally. Alternatively, can you get the HL7 written to a file, as that can also be picked up and processed.

    ReplyDelete
  4. Thank you very much for your prompt response, will try that soon.

    ReplyDelete
  5. Buenas noches tengo una interfaz que realice con hapi de java y me trae en HL7 la respuesta de un analizador hematológico, pero en la parte de histogramas me trae una tira de caracteres la cual dice base64 pero me ha sido imposible convertir en imagen para presentarla en el reporte .. a continuación le dejó la tira de caracteres: ^Application^Octet-stream^Base64^gAAAAAAAAgAKABkAMgBPAG8AjACiALMAvgDEAMQAwAC4AK0AoQCTAIUAeABrAF8AVQBMAEQAPQA3ADEAKwAmACAAHAAYABUAEgAQAA4ADAALAAoACQAIAAgABwAGAAUABQAEAAQABAAEAAQAAwADAAMAAgACAAIAAgACAAIAAgACAAEAAQABAAEAAQACAAIAAwADAAMAAwADAAQABAAFAAYACAAJAAsADAAOABAAEwAXABwAIAAlACoALwA2AD4ARwBRAFwAZwB0AIEAkAChALMAxwDcAPIACQEfATUBSwFhAXsBmQG6AeABDwJNAqsCUgPJBAYI/gxIE+EYpxqnGVcW5BI=

    ReplyDelete