Hello,
On this way, I have found the following two methods.
1) isErrorForUnknownProfiles() from class FhirInstanceValidator
2) addProfile(String theProfileUri) from class ValidationOptions
But I do not know exactly how best to use these methods for my purpose mentioned above. Or is there another better solution that I do not know yet?
Here is the code snippet where I am trying to build the logic right now:
public ValidationResult validateResource(IBaseResource resource) throws IOException {
FhirContext hapiFhirContext = pegFhirContext.getHapiFhirContext();
CachingValidationSupport validationSupport = pegFhirContext.getConfig().getValidationSupport(hapiFhirContext);
FhirInstanceValidator module = new FhirInstanceValidator(validationSupport);
module.setErrorForUnknownProfiles(true);
ValidationOptions options = new ValidationOptions();
options.addProfile("https://gematik.de/fhir/isik/v2/Basismodul/StructureDefinition/ISiKPatient");
FhirValidator validator = hapiFhirContext.newValidator();
validator.registerValidatorModule(module);
return validator.validateWithResult(resource, options);
}
I would like to know if anyone could help me with this.
Thanks in advance!
Best regards,
Armin Shafiee