Invoking HAPI to use custom Conformance Profiles

vendredi 21 novembre 2014

Has anyone had any luck invoking the HAPI classes from within Mirth? I got this idea to take the NIST Validator Tool's conformance profile and use HAPI to create a testing channel that could speed up testing iterations. It seemed like a perfect idea! I even remembered to upload the vocabulary code sets.



So after some trial and error and studying the API, I was able to get the classes instantiated within a filter on Mirth (although conceivably it could be done anywhere; preprocessor or transformer) and the codesets uploaded and the NIST conformance profile imported. Problem is, I don't think HAPI parsed the Conformance Profile correctly. I tested with an ELR message that the NIST validator says "Valid" and my channel returned 1034 exceptions to the profile, most of which were for field exceeding the MaxLength of 0. Well a look at the profile and I can see that the MaxLength attributes are certainly not 0 but I tweak the conformance profile a bit and get all of those to go away. Leaving me with 325 exceptions or so...



So my thought is that I shouldn't have to "tweak" the NIST conformance profile but not doing so prevents HAPI from interpreting it correctly.



I am just curious to know if anyone has had any experience with this or any insight. This would be extremely helpful if I could get it to work as expected.



See below for my code and files if anyone wants to try to reproduce my results. I am currently developing in Mirth v2.2.2 but it should work for any version.



Thanks,


Code:



importPackage(Packages.ca.uhn.hl7v2.parser);

importPackage(Packages.ca.uhn.hl7v2.validation.impl);

importPackage(Packages.ca.uhn.hl7v2.validation.DefaultValidator);





// Load the profile from the classpath

var profileParser = new Packages.ca.uhn.hl7v2.conf.parser.ProfileParser(false);

var profile = new Packages.ca.uhn.hl7v2.conf.spec.RuntimeProfile();

profile = profileParser.parse(FileUtil.read('D:\\MU\\elr-profile-new.xml'));



var codeStores = new Packages.ca.uhn.hl7v2.conf.store.ProfileStoreFactory();

codeStores.addCodeStore(new Packages.ca.uhn.hl7v2.conf.store.ProfileCodeStore('D:\\MU\\EXTERNAL_VocabularyAnalysis.xml'));

codeStores.addCodeStore(new Packages.ca.uhn.hl7v2.conf.store.ProfileCodeStore('D:\\MU\\HL7_VocabularyAnalysis.xml'));

codeStores.addCodeStore(new Packages.ca.uhn.hl7v2.conf.store.ProfileCodeStore('D:\\MU\\ICD_VocabularyAnalysis.xml'));

codeStores.addCodeStore(new Packages.ca.uhn.hl7v2.conf.store.ProfileCodeStore('D:\\MU\\CDC_VocabularyAnalysis.xml'));



try{

var parsedMsg = (new PipeParser()).parse(messageObject.getRawData());

}catch (e){

var parsedMsg = "";

}

channelMap.put("Message",parsedMsg);

// Create a conformance validator, and validate

var validator = new Packages.ca.uhn.hl7v2.conf.check.DefaultValidator();

var exceptions = new Array();//

exceptions = validator.validate(parsedMsg, profile.getMessage());



channelMap.put("Validation errors: " + exceptions.join("\n"));



Note: the addition of the code stores didn't not make a difference to the numbers and types of exceptions so I won't include them.



Note: I had to zip the ELR conformance profile because it was too large for the forum's XML file size limits.




Attached Files





File Type: zip elr-profile.zip (47.6 KB)







Invoking HAPI to use custom Conformance Profiles

0 commentaires:

Enregistrer un commentaire