Sidebar

How can i convert an HL7 Message format to XML format?

0 votes
2.8K views
asked Mar 13, 2019 by melusi-m-9548 (230 points)
If I have this HL7 message

and I want its format to be XLM. How can I do it?

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

Output should be XML

e.g

<HL7Message>
     <MSH>
            <MSH.1>|</MSH.1> <MSH.2>^~\&amp;</MSH.2> <MSH.3><HD.1>LAB</HD.1></MSH.3> <MSH.4><HD.1>767543</HD.1></MSH.4> <MSH.5><HD.1>ADT</HD.1></MSH.5> <MSH.6><HD.1>767543</HD.1></MSH.6> <MSH.7>19900314130405</MSH.7> <MSH.9> <CM_MSG_TYPE.1>ADT</CM_MSG_TYPE.1> <CM_MSG_TYPE.2>A04</CM_MSG_TYPE.2> </MSH.9> <MSH.10>XX3657</MSH.10> <MSH.11><PT.1>P</PT.1></MSH.11> <MSH.12><VID.1>2.3.1</VID.1></MSH.12>
</MSH> <EVN>
<EVN.1>A01</EVN.1> <EVN.2>19980327101314</EVN.2> <EVN.3>19980327095000</EVN.3> <EVN.4>I</EVN.4> <EVN.6>19980327095000</EVN.6>
</EVN> <PID>
<PID.1>1</PID.1> <PID.3.LST> <PID.3><CX.1>123456789ABCDEF</CX.1></PID.3>

</Hl7Message>

2 Answers

0 votes
answered Mar 13, 2019 by michael-h-5027 (14,350 points)
0 votes
Your comments or suggestions for Knowledge Base - Qvera:

Thankx Michael-h-5027. But my intention is to convert the whole message to XML. Each node and segment be on its own tag. Like on Mirth Connect I will make this clear.

 

input

 

MSH|^~\&|HIS||XXX|XXX|202342271553||ADT^A51^ADT_|19811410|P|2.4|||AL|NE| EVN|A51|201902271552||vf||201902271552| PID|1|5t5t3472156|KZ00076010^^^^PI~4542435313087^^^^HC~P0-201607085-0000006488^^^^XX~P00072156^^^^eer|P0-20143585-0435345488|Yeni^Thdfve^Mrbfess^^Mrs^^L||1943537|F||BL|ttN House 5210^P.O. Umlazi Township,Durban^Umlazi^Kwazulu-Natal^4031||031-907-6101^PRN^HOME||ENG|W|NONE||4353450413087||HIM|

 

 

Transformed Data:

<HL7Message>

       <MSH>

               <MSH.1>|</MSH.1>

                 <MSH.2>^~\&amp;</MSH.2> <MSH.3> <MSH.3.1>XXX</MSH.3.1> </MSH.3> <MSH.4/> <MSH.5> <MSH.5.1>XXX</MSH.5.1> </MSH.5> <MSH.6> <MSH.6.1>XXX</MSH.6.1> </MSH.6> <MSH.7> <MSH.7.1>201902271553</MSH.7.1> </MSH.7> <MSH.8/> <MSH.9> <MSH.9.1>ADT</MSH.9.1> <MSH.9.2>A51</MSH.9.2> <MSH.9.3>ADT_</MSH.9.3> </MSH.9> <MSH.10> <MSH.10.1>23432423</MSH.10.1> </MSH.10> <MSH.11> <MSH.11.1>P</MSH.11.1> </MSH.11> <MSH.12> <MSH.12.1>2.4</MSH.12.1> </MSH.12> <MSH.13/> <MSH.14/> <MSH.15> <MSH.15.1>AL</MSH.15.1> </MSH.15> <MSH.16> <MSH.16.1>NE</MSH.16.1> </MSH.16> <MSH.17/> </MSH> <EVN> <EVN.1> <EVN.1.1>A31</EVN.1.1> </EVN.1> <EVN.2> <EVN.2.1>5365364656</EVN.2.1> </EVN.2> <EVN.3/> <EVN.4> <EVN.4.1>EdMpi</EVN.4.1> </EVN.4> <EVN.5/> <EVN.6> <EVN.6.1>436346</EVN.6.1> </EVN.6> <EVN.7/> </EVN> <PID> <PID.1> <PID.1.1>1</PID.1.1> </PID.1> <PID.2> <PID.2.1>P3453654656</PID.2.1> </PID.2> <PID.3> <PID.3.1>KZ346456010</PID.3.1> <PID.3.2/> <PID.3.3/> <PID.3.4/> <PID.3.5>PI</PID.3.5> </PID.3> <PID.3> <PID.3.1>346546346346</PID.3.1> <PID.3.2/> <PID.3.3/> <PID.3.4/> <PID.3.5>HC</PID.3.5> </PID.3> <PID.3> <PID.3.1>P0-4364565640004565466488</PID.3.1> <PID.3.2/> <PID.3.3/> <PID.3.4/> <PID.3.5>XX</PID.3.5> </PID.3> <PID.3> <PID.3.1>P3456656</PID.3.1> <PID.3.2/> <PID.3.3/> <PID.3.4/> <PID.3.5>XXX</PID.3.5> </PID.3> <PID.4> <PID.4.1>P0-2045685-464564</PID.4.1> </PID.4> <PID.5> <PID.5.1>Yeni</PID.5.1> <PID.5.2>Th4564e</PID.5.2> <PID.5.3>Mag43646ss</PID.5.3> <PID.5.4/> <PID.5.5>M436</PID.5.5> <PID.5.6/> <PID.5.7>L</PID.5.7> </PID.5> <PID.6/> <PID.7> <PID.7.1>1943463457</PID.7.1> </PID.7> <PID.8> <PID.8.1>F</PID.8.1> </PID.8> <PID.9/> <PID.10> <PID.10.1>sdfL</PID.10.1> </PID.10> <PID.11> <PID.11.1>fbfgbN fgb43f0</PID.11.1> <PID.11.2>PdDgfburdan</PID.11.2> <PID.11.3>Umlazi</PID.11.3> <PID.11.4>dfgdg-dfg</PID.11.4> <PID.11.5>453</PID.11.5> </PID.11> <PID.12/> <PID.13> <PID.13.1>0324235431</PID.13.1> <PID.13.2>2342</PID.13.2> <PID.13.3>fbdf</PID.13.3> </PID.13> <PID.14/> <PID.15> <PID.15.1>dfg</PID.15.1> </PID.15> <PID.16> <PID.16.1>W</PID.16.1> </PID.16> <PID.17> <PID.17.1>NONE</PID.17.1> </PID.17> <PID.18/> <PID.19> <PID.19.1>dfgfdg</PID.19.1> </PID.19> <PID.20/> <PID.21> <PID.21.1>HIM</PID.21.1> </PID.21> <PID.22/> </PID> </HL7Message> something like this

 
answered Mar 13, 2019 by melusi-m-9548 (230 points)
...