Scope :

To parse the incoming HL7V2.X message and write it to PDF.

Pre-requisite:

  • MirthConnect : 3.4.1.8057 (latest version)

Channel setup :

  1. Create a New channel name it as your wish Here I have named HL7V2 to PDF
  2. Click on Set Data Types button set the source connector inbound to HL7V2.x
  3. Outbound and Destination 1 to Raw
     – that’s it the channel setup is done for it.

Source Transformer :

  • Go to the source transformer and right click to create a new step
  • Name the step as HL7V2 to PDF
  • Select the drop-down of  the step that you have created and select Javascript

Code : 

//MSH Data
var sender = msg[‘MSH’][‘MSH.3’][‘MSH.3.1’].toString();
var receiver = msg[‘MSH’][‘MSH.5’][‘MSH.5.1’].toString();
var messageType = msg[‘MSH’][‘MSH.9’][‘MSH.9.1’].toString();
var messageEvent = msg[‘MSH’][‘MSH.9’][‘MSH.9.2’].toString();
var uniqueId = msg[‘MSH’][‘MSH.10’][‘MSH.10.1’].toString();
channelMap.put(“sender”,sender);
channelMap.put(“receiver”,receiver);
channelMap.put(“messageType”,messageType);
channelMap.put(“messageEvent”,messageEvent);
channelMap.put(“uniqueId”,uniqueId);
//PID Data
var patientName = msg[‘PID’][‘PID.5’][‘PID.5.1’].toString()+” “+msg[‘PID’][‘PID.5’][‘PID.5.2’].toString();
channelMap.put(“patientName”,patientName);
//OBX data
var obxLen = msg[‘OBX’].length();
for(obx=0;obx<obxLen;obx++)
{
var obxSetId = msg[‘OBX’][obx][‘OBX.3’][‘OBX.3.1’].toString();
logger.info(obxSetId)
channelMap.put(“setId”,obxSetId);
}

Destination :

  1. Select Document Writer as the destination setup
  2. Provide the directory to be written and the file name to be generated.

HTML Template : 

Design an HTML template with the following code below:

<html>

HL7 Message Patient Details


//quotes added to remove wordpress html way

<hr></hr>
<br></br>

${patientName}

//quotes added to remove wordpress html way
<ol>
<li><u>Sending Facility</u> : ${sender}</li>
<li><u>Receiving Facility</u> : ${receiver}</li>
<li><u>Message Type </u> : ${messageType}</li>
<li><u>Message Event </u> : ${messageEvent}</li>
<li><u>Control-Id </u> : ${uniqueId}</li>
<hr></hr>
${setId}
</ol>
<br>
</br>

</html>

Destination Configuration :

destination-pdf

Sample data for Source :

use the sample data provided here to pass it on to mirth

pdf-writer

 

 

Leave a Comment