use of org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemOperator in project org.hl7.fhir.core by hapifhir.
the class EnableWhenEvaluator method evaluateCondition.
protected EnableWhenResult evaluateCondition(QuestionnaireItemEnableWhenComponent enableCondition, QuestionnaireItemComponent qitem, QStack qstack) {
List<Element> answerItems = findQuestionAnswers(qstack, qitem, enableCondition);
QuestionnaireItemOperator operator = enableCondition.getOperator();
if (operator == QuestionnaireItemOperator.EXISTS) {
DataType answer = enableCondition.getAnswer();
if (!(answer instanceof BooleanType)) {
throw new UnprocessableEntityException("Exists-operator requires answerBoolean");
}
return new EnableWhenResult(((BooleanType) answer).booleanValue() != answerItems.isEmpty(), enableCondition);
}
boolean result = false;
for (Element answer : answerItems) {
result = result || evaluateAnswer(answer, enableCondition.getAnswer(), enableCondition.getOperator());
}
return new EnableWhenResult(result, enableCondition);
}
Aggregations