Stream: hapi
Topic: Custom Profile Validation R4 is not working correctly
Mukesh Sharma (Mar 12 2020 at 10:36):
Hi,
I am using PrePopulatedValidationSupport to validate a resource against a custom profile(USCore_PatientProfile).
Following is the code that I'm using to validate the input resource.
*FhirContext ctx = FhirContext.forR4();
FhirValidator validator = ctx.newValidator();
org.hl7.fhir.r4.hapi.validation.PrePopulatedValidationSupport prePopulatedSupport = new org.hl7.fhir.r4.hapi.validation.PrePopulatedValidationSupport(myStructureDefinitionsR4,myValueSetsR4,myCodeSystemsR4);
org.hl7.fhir.r4.hapi.ctx.DefaultProfileValidationSupport defaultSupport = new org.hl7.fhir.r4.hapi.ctx.DefaultProfileValidationSupport();
org.hl7.fhir.r4.hapi.validation.ValidationSupportChain validationSupportChain = new org.hl7.fhir.r4.hapi.validation.ValidationSupportChain(prePopulatedSupport,defaultSupport);
org.hl7.fhir.r4.hapi.validation.FhirInstanceValidator instanceValidator = new org.hl7.fhir.r4.hapi.validation.FhirInstanceValidator();
instanceValidator.setValidationSupport(validationSupportChain);
validator.registerValidatorModule(instanceValidator);
ValidationResult result = validator.validateWithResult((String) resource);*
I have populated myStructureDefinitionsR4 by parsing the structure definition from USCore_PatientProfile_STU3_V310_ballot. USCore_PatientProfile_STU3_V310_ballot.xml
The valuesets and codesystems are populated with FHIR valuesets and codesystems from org.hl7.fhir.r4.model.valueset in hapi-fhir-validation-resources-r4-4.1.0.jar.
Input provided to validate resource is from https://hl7.org/fhir/R4/patient-example.xml.html
Output received is attached :
Patient_CustomProfile_Validation_OO.xml
Please let me know where I'm going wrong. The Official FHIRValidator returns 'No issues found' but using the HAPI library classes I'm getting 19 issues. Please help.
Regards,
Mukesh
Last updated: Apr 12 2022 at 19:14 UTC