use of org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemEnableWhenComponent in project org.hl7.fhir.core by hapifhir.
the class EnableWhenEvaluator method isQuestionEnabled.
/**
* the stack contains a set of QR items that represent the tree of the QR being validated, each tagged with the definition of the item from the Q for the QR being validated
* <p>
* the itembeing validated is in the context of the stack. For root items, the stack is empty.
* <p>
* The context Questionnaire and QuestionnaireResponse are always available
*/
public boolean isQuestionEnabled(ValidatorHostContext hostContext, QuestionnaireItemComponent qitem, QStack qstack, FHIRPathEngine engine) {
if (hasExpressionExtension(qitem)) {
String expr = getExpression(qitem);
ExpressionNode node = engine.parse(expr);
return engine.evaluateToBoolean(hostContext, qstack.a, qstack.a, qstack.a, node);
}
if (!qitem.hasEnableWhen()) {
return true;
}
List<EnableWhenResult> evaluationResults = new ArrayList<>();
for (QuestionnaireItemEnableWhenComponent enableCondition : qitem.getEnableWhen()) {
evaluationResults.add(evaluateCondition(enableCondition, qitem, qstack));
}
return checkConditionResults(evaluationResults, qitem);
}
Aggregations