I need to read an HL7, pipe-delimited message into a custom Java structure that represents the message structure. I need to do all this without using any message type, event type, or version specific methods or classes, because I need this code to work no matter what kind of HL7 message is read. I don't want to write a reader for every different message and event type. I need to get all the segments and subfields. I have looked at HAPI a lot to see if it has a prebuilt solution for this problem, but I have found nothing.
Is there anyway to extend a HAPI class or iterate over the underlying message structure that HAPI creates from a parser to solve this problem?
Also, any good resources on HAPI would be appreciated.
Have a look at the HL7X library for Java. This library offers you to transform any HL7 to an XML. It does not depend on MessageType, EventType nor version (big difference to HAPI).
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>^~\&</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>
Then you can get your Information from the String based XML or you parse it with any XMLDocument builder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With