Hello 👋
How can I configure FhirInstanceValidator so that a validation of a QuestionnaireResponse can be performed against a base Questionnaire that is passed as an object, instead of trying to get the Questionnaire by resolving the questionnaire url that is present in QuestionnaireResponse?
Currently, HAPI is trying to fetch the resource using http when encountering a URI, but I would like to fetch the resource from a database instead.
Here is my code below:
My question is: how can I configure FhirInstanceValidator so that the questionnaire can be fetched from memory/db, and not from an a rest endpoint
@JsonCreator
public FhirQuestionnaireDataReportContent(JsonNode response, JsonNode questionnaire) {
//instantiate the context
FhirContext ctx = FhirContext.forR4();
final IParser iParser = ctx.newJsonParser();
iParser.setParserErrorHandler(new StrictErrorHandler());
// the resource that I want to validate is the response, and I have the questionnaire that the response is based on
this.response = iParser.parseResource(QuestionnaireResponse.class, JsonUtil.toJSONString(response));
this.questionnaire = iParser.parseResource(Questionnaire.class, JsonUtil.toJSONString(questionnaire));
// Create a validator
FhirValidator validator = ctx.newValidator();
// Create a validation support chain
ValidationSupportChain validationSupportChain = new ValidationSupportChain(
new DefaultProfileValidationSupport(ctx),
new InMemoryTerminologyServerValidationSupport(ctx),
new CommonCodeSystemsTerminologyService(ctx)
);
FhirInstanceValidator instanceValidator = new FhirInstanceValidator(validationSupportChain);
//Question: How can I configure the instanceValidator to make the resourceFetcher to use the questionnaire object that I have?
validator.registerValidatorModule(instanceValidator);
instanceValidator.setAnyExtensionsAllowed(true);
ValidationResult result = validator.validateWithResult(this.response);
if (result.isSuccessful()) {
System.out.println("Success!");
} else {
System.out.println("Failed with " + result.getMessages().size() + " errors");
for (SingleValidationMessage next : result.getMessages()) {
System.out.println("* " + next);
}
}
}
--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/2f5dae63-b6cc-46f8-984c-fb4c6e6e8ef5n%40googlegroups.com.