Sidebar

How can I convert HL7 to JSON/FHIR format?

0 votes
6.1K views
asked Nov 15, 2018 by (240 points)
edited Nov 15, 2018 by gary-t-8719

What is the best approach to translate HL7 messages to JSON/FHIR data?

 

3 Answers

+1 vote

Included below is a link to download a sample QIE channel which shows the following three different ways to create a JSON message or a FHIR Resource from an HL7 message.

1. Creating a System Variable Template with Node Tags referencing the HL7 message for each field.

2. Creating an inline template with Node Tags referencing the HL7 message for each field.

3. Mapping each field from the HL7 message individually.

Please see other answers below for examples shown here vs the download.

https://www.qvera.com/kb/?qa=blob&qa_blobid=14673195438770178926

answered Nov 15, 2018 by gary-t-8719 (14,860 points)
+1 vote

In this answer I will give an example of creating each JSON data element individually.  For this example, we will use the following HL7 message:

MSH|^~\&|TEST|TEST000^E IM|EssexArchives|E IM|20120925173019||ADT^A04|1664213420006120|P|2.3.1|||NE|NE
EVN|A04|20120925173019
PID|1||661||Mouse^Minnie^S||19610301|F||B|6790 Oak St^^Plano^IL^60448^USA||^^^mmouse@mbc.com|(214) 669-0123 [123]||M|||237-12-9812|||N
PD1||||^Bailey^Todd^R^MD
NK1|1|""|E|3330 Keller Springs^^Carrollton^TX^75006|9725551212||||||||
NK1|1|Casey^Ben^G^MD|O|3790 W. First St^^Dallas^TX^75248|2146622000|2146621249|||||||Medical Clinic, PC
NK1|2|Bailey^William^R^MD|O|3790 West First Street^^Dallas^TX^75248|2145551211|2145551299|||||||Medical Clinic, PC
NK1|3|Pene^J^S^MD|O|123 Forget St^^Manchester^TX^75002|2145551212||||||||Medical Health Group
PV1|1|O|^^^E IM|||||^Pene^J^S
IN1|1||Aetna Life and Casualty|Aetna Life and Casualty|P O Box 1458^^Carrollton^TX^75006||(972) 662-1350||||||||P||S|||||||||||||||||||237129812
IN1|2||United Health Care  SLCity|United Health Care  SLCity|P O Box 30555^^Salt Lake City^UT^84130||(888) 267-3520||||||||S||S|||||||||||||||||||237129812

To set each node or data element of the JSON message we will use two functions. One is the source.getNode("MSH-3") function which is used to get data from the HL7 message. The second is to place that data into the JSON message using message.setNode('sendingApplication', value)
 

example code:
var value = source.getNode("MSH-3");
message.setNode("sendingApplication", value);

value = source.getNode("MSH-5");
message.setNode("receivingApplication", value);

value = source.getNode("MSH-7");
message.setNode("dateAndTime", value);

value = source.getNode("MSH-9");
message.setNode("messageType", value);

example output:
{
   "sendingApplication": "TEST",
   "receivingApplication": "EssexArchives",
   "dateAndTime": "20120925173019",
   "messageType": "ADT^A04"
}

answered Nov 15, 2018 by gary-t-8719 (14,860 points)
+1 vote

In this answer, I will give an example of using a template to create the new JSON message.  For this example, we will use the following HL7 message:

MSH|^~\&|TEST|TEST000^E IM|EssexArchives|E IM|20120925173019||ADT^A04|1664213420006120|P|2.3.1|||NE|NE
EVN|A04|20120925173019
PID|1||661||Mouse^Minnie^S||19610301|F||B|6790 Oak St^^Plano^IL^60448^USA||^^^mmouse@mbc.com|(214) 669-0123 [123]||M|||237-12-9812|||N
PD1||||^Bailey^Todd^R^MD
NK1|1|""|E|3330 Keller Springs^^Carrollton^TX^75006|9725551212||||||||
NK1|1|Casey^Ben^G^MD|O|3790 W. First St^^Dallas^TX^75248|2146622000|2146621249|||||||Medical Clinic, PC
NK1|2|Bailey^William^R^MD|O|3790 West First Street^^Dallas^TX^75248|2145551211|2145551299|||||||Medical Clinic, PC
NK1|3|Pene^J^S^MD|O|123 Forget St^^Manchester^TX^75002|2145551212||||||||Medical Health Group
PV1|1|O|^^^E IM|||||^Pene^J^S
IN1|1||Aetna Life and Casualty|Aetna Life and Casualty|P O Box 1458^^Carrollton^TX^75006||(972) 662-1350||||||||P||S|||||||||||||||||||237129812
IN1|2||United Health Care  SLCity|United Health Care  SLCity|P O Box 30555^^Salt Lake City^UT^84130||(888) 267-3520||||||||S||S|||||||||||||||||||237129812

Now we create a new system variable that will be our template.  Note in the template we are using node tags to identify the data that will be used in the template.  In this case, I named the variable 'patient'.

{
   "resourceType" : "Patient",
   "identifier" : "/*{PID-3}*/",
   "active" : null,
   "name" : "/*{PID-5.2}*/ /*{PID-5.3}*/ /*{PID-5.1}*/",
   "telecom" : "/*{PID-14}*/",
   "gender" : "/*{PID-8}*/",
   "birthDate" : "/*{PID-7}*/",
   "deceasedBoolean" : null,
   "deceasedDateTime" : null,
   "address" :{
      "resourceType" : "Address",
      "use" : "home",
      "type" : "physical",
      "text" : "/*{PID-11}*/",
      "line" : ["/*{PID-1.1}*/"],
      "city" : "/*{PID-11.3}*/",
      "district" : null,
      "state" : "/*{PID-11.4}*/",
      "postalCode" : "/*{PID-11.5}*/",
      "country" : "USA",
      "period" : null
   },
   "contact" : [{
      "relationship" : null,
      "name" : null,
      "telecom" :  {
         "resourceType" : "ContactPoint",
         "system" : "phone",
         "value" : "/*{PID-14}*/",
         "use" : "home",
         "rank" : "1"
      }
   }],
   "careProvider" : "/*{PD1-4}*/",
   "managingOrganization" : "South Side Clinic"
}

Now in my first mapping node, I will add the following code to load this template and have QIE convert the node tags in the template to the data from the message.

example code:
var value = qie.evaluateTemplate(qie.getVariable('patient'), null, null, true);
message.setNode('/', value);
message.formatJSON(3);

answered Nov 15, 2018 by gary-t-8719 (14,860 points)
...