The DefaultValidator for HAPI throws a ValidationException.
When a single hl7 v2.3.1 message having multiple/different IDs for OBX-2 field (i.e. datatype used for OBX-5 value field) is validated against the conformance profile, where the datatype for OBX-5 is mentioned as "VARIES", throws the ValidationException.
e.g.
May 21, 2015 9:16:22 AM xxx.xxxx.xxxx.xxxx.xxxx.validation.ValidatorWithConformanceProfile validate SEVERE: ValidationException - HL7 datatype NM doesn't match profile datatype VARIES at OBX-5 May 21, 2015 9:16:22 AM xxx.xxxx.xxxx.xxxx.xxxx.validation.ValidatorWithConformanceProfile validate SEVERE: ValidationException - HL7 datatype ST doesn't match profile datatype VARIES at OBX-5
Expected Behaviour:
The datatype "VARIES" in OBX-5 of Conformance Profile should acts as place-holder (as per HAPI api documentation) for the a datatype being resolved at runtime to a specific datatype present in OBX-2 field of the hl7 v2.3.1 message.
As a workaround, you can subclass ca.uhn.hl7v2.conf.check.DefaultValidator and overwrite the checkDataType(String, Type, List<HL7Exception>) method to do something like:
Finally, an instance of your implementation must be returned by HapiContext#getConformanceValidator()