Stream: hapi
Topic: getting wrong result from FhirInstanceValidator while val...
Aditya (May 02 2019 at 15:40):
I am trying to use FhirInstanceValidator with following configuration :
compile group: 'ca.uhn.hapi.fhir', name: 'hapi-fhir-base', version: '2.5' compile group: 'ca.uhn.hapi.fhir', name: 'hapi-fhir-structures-dstu3', version: '2.5' compile group:'ca.uhn.hapi.fhir', name:'hapi-fhir-validation', version:'3.7.0' compile group:'ca.uhn.hapi.fhir', name:'hapi-fhir-validation-resources-dstu3', version:'3.7.0'
However, I get result as true (ideally it should be false as Observation.status is mandatory) after executing following :
FhirContext ctx = FhirContext.forDstu3(); // Create a FhirInstanceValidator and register it to a validator FhirValidator validator = ctx.newValidator(); FhirInstanceValidator instanceValidator = new FhirInstanceValidator(); validator.registerValidatorModule(instanceValidator); Observation obs = new Observation(); obs.getCode().addCoding().setSystem("http://loinc.org").setCode("12345-6"); obs.setValue(new StringType("This is a value")); // Validate ValidationResult result = validator.validateWithResult(obs);
I am getting following in logs :
Unable to load resource: /org/hl7/fhir/instance/model/dstu3/profile/profiles-resources.xml
It seems that the org.hl7.fhir.dstu3.hapi.validation.DefaultProfileValidationSupport.java has following code :
loadStructureDefinitions(theContext, structureDefinitions, "/org/hl7/fhir/instance/model/dstu3/profile/profiles-resources.xml"); loadStructureDefinitions(theContext, structureDefinitions, "/org/hl7/fhir/instance/model/dstu3/profile/profiles-types.xml"); loadStructureDefinitions(theContext, structureDefinitions, "/org/hl7/fhir/instance/model/dstu3/profile/profiles-others.xml");
In the above code, the path to profile xml contains "/instance" and the word "dstu3" after word "model" however, the actual profiles in jar - hapi-fhir-validation-resources-dstu3-3.0.0.jar are at location
/org/hl7/fhir/dstu3/model/profile/profiles-resources.xml
Is this a bug in HAPI ?
James Agnew (May 05 2019 at 16:32):
HAPI is definitely not designed to work with different versions of the library on your classparth. You should replace the 2.5
with 3.7.0
for all dependencies.
Last updated: Apr 12 2022 at 19:14 UTC