Need to Validate HL7 V2 ADT_A01 version 3 message against a Conformance XML Profile for the same version
I have a Java program that validates the message against the XML, but I am getting a few errors. I cannot proceed further without solving them.
public static void main(String[] args) throws Exception {
try {
// Load the conformance profile
ProfileParser ourProfileParser = new ProfileParser(false);
RuntimeProfile ourConformanceProfile = ourProfileParser.
parseClasspath("A01_v23.xml");
//Read a test non-conformant HL7 from file. See my GitHub page for this file
String message = readHl7FileDataAsString("C:\\Jai\\ADT\\ADT_A01_v2.5_Conformance_XML\\A01_v23.txt");
PipeParser parser=new PipeParser();
System.out.println("parser configuration "+parser.getParserConfiguration().toString());
//parse the HL7 message from the file data
Message msg = parser.parse(message);
// Validate the HL7 message using the sample HL7 conformance profile I have provided. See my GitHub page for the XML file
HL7Exception[] errors = new DefaultValidator().validate(msg, ourConformanceProfile.getMessage());
// Display all the validation errors that are generated.
System.out.println("The following validation errors were found during message validation:");
for (HL7Exception hl7Exception : errors) {
System.out.println(hl7Exception);
}
} catch (Exception e) {
e.printStackTrace();
}
}
Input message is:
MSH|^~\&|NSI^UID^D|A^B^C|RID^UID^h|hm|201907071123||ADT^A01^ADT_A01|MSGA01023|P|2.3
EVN|A01|201907071153|201908081153|02|11|20190708105155
PID|||HO2^^^A^MR||Ada^Pal^Kin^Jr^Mr||196101011153|M|Aam^Pau^Kin^Jr^Mr^MA^Ali^AL|Bl|St^^Blr^Ka^56^Ind^Off|91|^Off^Ph^^91^80^123^567^PHo|^91^Ph^d^91^^080^767^P1|Eng^Hin|M|Hin|124|SSN503|DL3|I|For|Bir|Y|2|C||91|201801012022|Y
PV1||I|6N^01^B23^ICU||||010^ATT^AON^A|018^ATT^AAR^A|||||||||014^END^RON^A|S|100|A|||||||||||||||||ISH^200701102300||GL|||||201907071153|201907080500
Console Output:
The following validation errors were found during message validation:
ca.uhn.hl7v2.conf.check.ProfileNotFollowedException: The type Field Separator has length 3 which exceeds max of 1 at MSH-1(0)
ca.uhn.hl7v2.conf.check.ProfileNotFollowedException: The type Encoding Characters has length 12 which exceeds max of 4 at MSH-2(0)
ca.uhn.hl7v2.conf.check.ProfileNotFollowedException: The type Message Type has length 15 which exceeds max of 9 at MSH-9(0)