The scenario when analyzing and checking the HL7 message immediately works as expected:
HapiContext hapiContext = new DefaultHapiContext(); PipeParser parser = hapiContext.getPipeParser(); Message message = parser.parse("MSH|^~\\&|MedSeries|CAISI_1-2|PLS|3910|200903230934||ADT^A31^ADT_A05|75535037-1237815294895|P^T|2.5\r" + "EVN|A31|200903230934345345345345345\r" + "PID|1||29^^CAISI_1-2^PI~\"\"||Test300^Leticia^^^^^L||19770202|M||||||||||||||||||||||");
Exception (this is a valid behavior):
Exception in thread "main" ca.uhn.hl7v2.model.DataTypeException: ca.uhn.hl7v2.validation.ValidationException: Validation failed: Primitive value '200903230934345345345345345' requires to be empty or a HL7 datetime string at EVN-2(0)
But when I try to parse the HL7 message first and then check - the check method returns true and no exceptions are thrown:
HapiContext hapiContext = new DefaultHapiContext(); hapiContext.setValidationContext((ValidationContext) ValidationContextFactory.noValidation()); PipeParser parser = hapiContext.getPipeParser(); Message message = parser.parse("MSH|^~\\&|MedSeries|CAISI_1-2|PLS|3910|200903230934||ADT^A31^ADT_A05|75535037-1237815294895|P^T|2.5\r" + "EVN|A31|200903230934345345345345345\r" + "PID|1||29^^CAISI_1-2^PI~\"\"||Test300^Leticia^^^^^L||19770202|M||||||||||||||||||||||"); hapiContext.setValidationRuleBuilder(new DefaultValidationBuilder()); System.out.println(hapiContext.getMessageValidator().validate(message));
I need this to generate confirmation messages in case the verification is not performed using the message.generateACK () method.
Yuriy source share