Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HL7 parser to parse v2.7 messages in java

Tags:

hl7

hl7-v2

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?

like image 293
user3293794 Avatar asked Mar 21 '23 00:03

user3293794


1 Answers

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);
like image 71
Amadán Avatar answered May 06 '23 23:05

Amadán