Loading...
Download the "Convert HL7 to FHIR Patient - Example 1.xml" file from Downloads, and import the channel Convert HL7 to FHIR Patient - Example 1.xml
into your Mirth® Connect server.
This channel includes the "HL7 v2.x to FHIR Helper Functions" code template library. If you already have that library imported, you may see a dialog asking whether or not you want to overwrite the library. To overwrite the library and all of its code templates, click the "Overwrite: All" link in the top-right, and then click Import.
If you don't want to overwrite any libraries or code templates, click Cancel, then Yes when prompted to continue without importing. Then make sure the library is enabled for your newly imported channel:
Once you've imported the channel, go to the Source tab, and click Edit Transformer to view the source transformer. You will see quite a few Iterator steps with FHIR Resource Builders. These are dynamically creating the identifiers, names, telecoms, etc. that will go into the final Patient resource. For example, step 0-0 "Create Identifier" handles the creation of a single Identifier data type:
The parent Iterator step will loop through each PID-3 field, create a new Identifier for the field, and add it to an array. We use the name "identifiers" and store it as a local variable. That means that the variable "identifiers" will only be accessible in this transformer. This variable is used later on in step 9, "Create Patient":
In this example we're also storing the Patient object as a local variable, "patient". The final step calls a couple of helper methods in the code template library to consolidate and cleanup any properties in the Patient that were empty or non-valued.
msg = consolidate(cleanupFhirPatient(patient));
Check out the "HL7 v2.x to FHIR Helper Functions" library if you're wondering what exactly those code templates are doing.
Deploy the channel, and send a sample ADT message through it:
MSH|^~\&|ADT1|SHM|SHMADT|SHM|200812091126|SECURITY|ADT^A01^ADT_A01|MSG00001|P|2.5|
EVN|A01|200812091126||
PID|1|1001|1001^5^M11^ADT1^MR^SHM~123456789^^^USSSA^SS||OHALLAHAN^COLLEEN^^||19850704|F||2106-3|1200 N ELM STREET^^NEWPORT BEACH^CA^92660-1020^US^H|OC|(949) 555-1234|(949) 555-5678||S||PATID1001^2^M10^ADT1^AN^A|123456789|U1234567^CA|
NK1|1|O'HALLAHAN^BRITTANY^M|SIS^SISTER||||N^NEXT-OF-KIN
PV1|1|I|2000^2012^01||||001122^ZOIDBERG^JOHN^|||SUR||||1|A0|
If you look at the Source Encoded data or the Destination Raw data, you will see that it has been converted into a FHIR JSON resource!
{
"resourceType" : "Patient",
"identifier" : [
{
"type" : {
"text" : "MR"
},
"system" : "ADT1",
"value" : "1001"
},
{
"type" : {
"text" : "SS"
},
"system" : "USSSA",
"value" : "123456789"
}
],
"name" : [
{
"use" : "usual",
"family" : "OHALLAHAN",
"given" : [
"COLLEEN"
]
}
],
"telecom" : [
{
"system" : "phone",
"value" : "(949) 555-1234",
"use" : "home"
},
{
"system" : "phone",
"value" : "(949) 555-5678",
"use" : "work"
}
],
"gender" : "female",
"birthDate" : "1985-07-04",
"deceasedBoolean" : false,
"address" : [
{
"use" : "home",
"text" : "1200 N ELM STREET NEWPORT BEACH CA 92660-1020 US",
"line" : [
"1200 N ELM STREET"
],
"city" : "NEWPORT BEACH",
"state" : "CA",
"postalCode" : "92660-1020",
"country" : "US"
}
],
"maritalStatus" : {
"text" : "S"
},
"multipleBirthBoolean" : false,
"contact" : [
{
"relationship" : [
{
"id" : "SIS",
"text" : "SISTER"
},
{
"id" : "N",
"text" : "NEXT-OF-KIN"
}
],
"name" : {
"use" : "usual",
"family" : "O'HALLAHAN",
"given" : [
"BRITTANY",
"M"
]
},
"gender" : "unknown"
}
]
}