Unable to validate codes in resources using profile

I have added Patient resource and profile.
When I try to add gender for patient it shows the following error:

“The value provided (‘male’) is not in the value set http://hl7.org/fhir/ValueSet/administrative-gender|4.0.1 (http://hl7.org.fhir/ValueSet/administrative-gender, and a code is required from this value set) (error message = Unknown code [male] in sysytem[(none)]”

I have tried similar thing for Observation resource giving same error for status.

how are you running the validation?

I am using hapi libraries.
With which for each resource that I have defined I have added @Validate operation.

I am adding custom profile using PrePopulatedValidationSupport.

Code snippet:

ValidationSupport supportChain = new ValidationSupport();

supportChain.addValidationSupport(new PrePopulatedSupport(structureDefinitions, valueSets, codeSystems));
supportChai .addValidationSupport(new DefaultSupport);
FhirInstanceValidator instanceValidator = new FhirInstanceValidator ();
validator.registerValidatorModule(instanceValidator);
instanceValidator.setValidatonSupport(supportChain);
ValidationResult result = validator.validateWithResult(input);
validator.validateWithResult(valueSet);

=> The structuredefinitions i.e. the profile is added as a json file that contains valueSet’s url.

It looks like you’re not loading the whole core package - the validator assumes that the entire core package for the relevant version is always in scope

When you say core package what exactly needs to be added? Because we have added all required hapi 4.1.0 libraries and haven’t added scope attribute for any dependency.
Could you please verify the dependency added by us from the attachment, and tell us if anything else needs to be added or modified?

@grahamegrieve could you review the comment…just in case you missed it

I did miss it - the package I am referring to is no a maven/java dependency, it’s the NPM package that contains the core definitions - hl7.fhir.r[x].core.

Hi again @grahamegrieve,
Could you please help me out with the steps to add this core package to our java code to be used. Also, how do I bring this package to use.

Well, it turns out you can’t. This will be addressed in the next version of HAPI

Hi @ShruJ, did you find a solution for this issue? I am getting the same error when trying validate my classes using Hapi-FHIR libraries version 5.2.0.

Thanks in advance
Elano