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?

3 Answers 3

7

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); 
Sign up to request clarification or add additional context in comments.

Comments

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); 

Comments

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.

1 Comment

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.