cqframework / clinical-reasoning

CQF Clinical Reasoning on FHIR for Java
https://www.cqframework.org/clinical-reasoning/
Apache License 2.0
33 stars 24 forks source link

$extract disregards definitions in Questionnaire when applying definition based extraction #482

Open simoneOnFhir opened 1 week ago

simoneOnFhir commented 1 week ago

Definition based extraction works only if the definitions are present in the QuestionnaireResponse

I can put absolute nonsense into Questionnaire.item.definition, or nothing, but the extraction results remain the same. Even if I remove QuestionnaireResponse.questionnaire or point it to an nonexisting URL, extraction will be performed without error, if the definitions are present in the QuestionnaireResponse.

If I remove all definitions from QuestionanireResponse, I get "HAPI-0389: Failed to call access method: java.lang.NullPointerException: Cannot invoke \"String.contains(java.lang.CharSequence)\" because \"definition\" is null", regardless of whether definitions are present in the referenced Questionnaire or not.

If I remove the reference to the questionnaire or reference a non-existing questionnaire, and no definitions are present in the QuestionnaireResponse, I get "HAPI-0389: Failed to call access method: java.lang.IllegalArgumentException: Unable to retrieve Questionnaire code map for Observation based extraction"

To me it looks like Observation based extraction relies on the annotations in Questionnaire but Definition based Extraction relies on the annotations in QuestionnaireResponse.

IMO $extract should always use the annotations from Questionnaire as first line and only use definitions from QuestionnaireResponse as a fallback, if no Questionnaire is referenced or the referenced Questionnaire cannot be found (AND produce a warning in the latter case).

see also: https://chat.fhir.org/#narrow/stream/179167-hapi/topic/SDC-Extraction.20capabilities.20in.20HAPI.20Starter

simoneOnFhir commented 1 week ago

https://chat.fhir.org/#narrow/stream/179255-questionnaire/topic/definition.20in.20Questionnaire.20vs.2E.20QuestionnaireResponse for clarification in SDC Spec