4

I'm looking for a HL7 parser that would parse v2.7 messages. I have tried Hapi but it has support only upto v2.6.

Can you anyone please provide any suggestions in parsing v2.7 messages?

Infinite Recursion
  • 6,315
  • 28
  • 36
  • 51

3 Answers3

6

Additionally to allowing unknown versions (like nradov pointed out), you need to inject the right model class factory, e.g. GenericModelClassFactory, into the parser or you might end up with an exception:

ca.uhn.hl7v2.HL7Exception: No map found for version null. Only the following are available: [V22, V25, V21, V23, V24]

So the complete solution is

  1. use the GenericModelClassFactory
  2. allow unknown versions

and it looks like this:

final ModelClassFactory modelClassFactory = new GenericModelClassFactory();
final PipeParser parser = new PipeParser(modelClassFactory);
parser.getParserConfiguration()
      .setAllowUnknownVersions(true);

final Message message = parser.parse(message);
Amadán
  • 663
  • 5
  • 15
1

Like nradov said, you can use HAPI to parse V2.7. But you'll need to call this to prevent the "2.7 is not recognized" Exception:

parser.getParserConfiguration().setAllowUnknownVersions(true);
0

You can still use HAPI to parse HL7 V2.7. It just doesn't have convenient methods to easily access the new fields that were added after V2.6.

Nick Radov
  • 404
  • 2
  • 7
  • By using HAPI I have the follwing exception: ca.uhn.hl7v2.HL7Exception: The HL7 version 2.7 is not recognized at ca.uhn.hl7v2.parser.Parser.assertVersionExists(Parser.java:527) at ca.uhn.hl7v2.parser.Parser.parse(Parser.java:208) at ca.uhn.hl7v2.parser.PipeParser.parse(PipeParser.java:1018) So, how to manage that – user1321939 Aug 12 '14 at 07:46