Thursday 28 March 2013

HL7 v2.x to FHIR using Iguana


HL7 v2.x is a widely accepted & deployed interoperability standard today. FHIR has started getting attention from people and all are looking forward to it. I think it will be good idea to showcase a transfromation from HL7 v2.x message to healthcare resource defined by FHIR.

I was looking for integration engine which can be used to demonstrate this transformation. iNTERFACEWARE helped me in this by providing free license of Iguana for research & development purpose. I would like to thank their CEO Eliot Muir for his help & support.
Iguana supports REST calls and would be great tool for interoperability using FHIR
In this article I will show how we can transform HL7 v2.x PID segment to FHIR Patient Resource using Iguana.

Following video will give you quick overview'


We will deploy a channel in Iguana with source as LLP Listener and destination as Translator.
LLP Listener will listen for incoming HL7 v2.x messages on a port specified. It will forward validated HL7 v2.x messages to Translator.
Translator will parse HL7 v2.x message and will apply a mapping logic to map fields in PID segment with corresponding elements of FHIR Patient Resource. This will generate xml formatted patient resource. Then translator will use net API to make HTTP PUT call to FHIR RESTful Test Server and upload the patient resource there.

Let’s understand the translator script:


This script parses incoming HL7 v2.x message, then calls MapData(Msg.PID) function and passes PID segment of HL7 v2.x message to it.
MapData() calls fhir module which has a template of xml formatted patient resource.
fhir module will return this template and then we can directly map each element of Patient Resource with corresponding fields of PID segment from HL7 v2.x message.
After mapping all the fields, MapData() returns a string with xml formatted Patient Resource generated from HL7 v2.x PID segment
Then we will use net API to call FHIR RESTful test server and upload this patient resource using HTTP PUT
Please note the URL declared at top, this is the URL of patient resource that we will be creating here. Our patient resource will be identified by id "@igu4" on FHIR Test Server

 require "node"  
 require "dateparse"  
 fhir = require 'fhir'  
 URL = 'http://hl7connect.healthintersections.com.au/svc/fhir/patient/@igu4'  
 function main(Data)  
   local Msg = hl7.parse{vmd='transform.vmd', data=Data}  
   local Patient = MapData(Msg.PID)  
   local R = net.http.put{url=URL,data=Patient, live=true}    
 end  
 function MapData(pid)  
    local T = fhir.Patient()  
   T.Patient.identifier.label.value = 'SSN'  
   T.Patient.identifier.id.value = pid[19]  
   T.Patient.identifier.system.value = 'http://hl7.org/fhir/sid/us-ssn'  
   T.Patient.details.name.family.value = pid[5][1][1]:S()  
   T.Patient.details.name.given.value = pid[5][1][2]:S()  
   T.Patient.details.telecom.system.value = fhir.systemCode.phone  
   T.Patient.details.telecom.value.value = pid[14]:S()  
   T.Patient.details.telecom.use.value = fhir.phoneCode.home  
   T.Patient.details.birthDate.value = pid[7]:D('yyyymmdd')  
   T.Patient.details.address.use.value = 'home'  
   T.Patient.details.address.line.value = pid[11][1][1]:S()  
   T.Patient.provider.type.value = 'Organization'  
   T.Patient.provider.url.value = '../organization/@hl7'  
   T.Patient.text.status.value = 'generated'  
   T.Patient.text.div[2] = 'Patient SSN :'.. pid[19]  
   return T:S()  
 end  

Here is the shared module "fhir" which defines the template for Patient Resource

 fhir = {}  
 function fhir.Patient()  
   return xml.parse{data=[[  
   <Patient xmlns="http://hl7.org/fhir">  
   <identifier>  
     <label value="#"></label><system value="#"></system><id value="#"></id>  
   </identifier>  
   <details>  
     <name>  
       <family value="#"></family>  
       <given value="#"></given>  
     </name>  
     <telecom><system value="#"></system><value value="#"></value><use value="#"></use></telecom>  
     <birthDate value="#"></birthDate>  
     <address><use value="#"></use><line value="#"></line></address>  
   </details>  
   <provider><type value="#"/><url value="#"/></provider>  
   <text><status value="#"></status><div xmlns="http://www.w3.org/1999/xhtml">#</div></text>  
 </Patient>  
   ]]}  
 end  
 local function code(T)  
   local Result = {}  
   for i=1,#T do  
    Result[T[i]]= T[i]  
   end  
   return Result  
 end  
 fhir.phoneCode = code{'home', 'phone', 'mobile', 'old', 'temp', 'work'}  
 fhir.systemCode = code{'email', 'phone', 'fax', 'url'}  
 return fhir  

It's time to test our implementation now...


  • Start this channel from Iguana Dashboard
  • Use HL7 Simulator to send HL7 v2.x messages to LLP Listener on specified port
  • Make Sure message processed without errors
  • Go to http://hl7connect.healthintersections.com.au/svc/fhir
  • Locate Patient Resource from list of resources and click on "Search" link
  • On Search Page locate "_id" field (first field) and enter "igu4" (remember our URL in translator script)
  • Click "Submit" or hit enter key
  • You should be able to see the patient resource uploaded by Iguana Script, please validate the values in elements.

Sample Immunization Records Blockchain using Hyperledger Composer

This is basic and sample Blockchain implementation of Immunization Records using Hyperledger Composer.  Source Code available at:  https...