HL7 version 2.7 parser using java except Hapi

2k Views Asked by At

Is there any good parser which can parser HL7 V2.7 message using Java except HAPI. My goal is to convert the message into a XML file.

2

There are 2 best solutions below

2
On

this http://www.dcm4che.org/confluence/display/ee2/Home open source Java software can receive various HL7 messages through the MLLP protocol, convert them to XML, run through XSLT transformer and then load them into database and serve to DICOM clients as needed. In order to do this in the code base there is the HL7->XML code. Just find it, copy/paste it and use it.

Once I knew where exactly this code is as I was troubleshooting message character set problem. At that time I have found that the HL7 parser is rather simple-minded and can understand only 1 character set provided in the configuration. It does not read/use character set (MSH-18, Table 0211, Grahame Grieve's encoding tips) provided in the messages neither does it support switching character sets during the message decoding (see chapter "Escape sequences supporting multiple character sets" in HL7 specification).

So I know the parser code is there. It is in Java. It produces XML inputs for the customer-specific XSLT transformation script. It should be quite easy to reuse.

You should be able to find it by yourself. Otherwise your question would turn out as plain finding a tool §4 is an off-topic :)

0
On

There is my own open source alternative called HL7X, which does work with any HL7v2 version. It converts your HL7 String into a XML String.

Example:

MSH|^~\&|||||20121116122025||ADT^A01|5730224|P|2.5||||||UNICODE UTF-8
EVN|A01|20130120151827
PID||0|123||Name^Firstname^^^^||193106170000|w
PV1||E|

Gets transformed to

<?xml version="1.0" encoding="UTF-8"?>
<HL7X>
<HL7X>
    <MSH>
        <MSH.1>^~\&amp;</MSH.1>
        <MSH.6>20121116122025</MSH.6>
        <MSH.8>
            <MSH.8.1>ADT</MSH.8.1>
            <MSH.8.2>A01</MSH.8.2>
        </MSH.8>
        <MSH.9>5730224</MSH.9>
        <MSH.10>P</MSH.10>
        <MSH.11>2.5</MSH.11>
        <MSH.17>UNICODE UTF-8</MSH.17>
    </MSH>
    <EVN>
        <EVN.1>A01</EVN.1>
        <EVN.2>20130120151827</EVN.2>
    </EVN>
    <PID>
        <PID.2>0</PID.2>
        <PID.3>123</PID.3>    
        <PID.5>
            <PID.5.1>Name</PID.5.1>
            <PID.5.2>Firstname</PID.5.2>
        </PID.5>
        <PID.7>193106170000</PID.7>
        <PID.8>F</PID.8>
    </PID>
    <PV1>
        <PV1.2>E</PV1.2>            
    </PV1>
</HL7X>