execute method
The iterable, nested function that evaluates the entire FHIRPath expression one object at a time
Implementation
@override
List execute(List results, Map<String, dynamic> passed) {
final finalTotal =
IterationContext.withIterationContext((iterationContext) {
List<dynamic> currentTotal = [];
late FhirPathParser expression;
late dynamic initialValue;
if (value.value.first is CommaParser) {
initialValue = (value.value.first as CommaParser)
.after
.execute(results.toList(), passed);
expression = (value.value.first as CommaParser).before;
} else {
initialValue = [];
expression = value;
}
iterationContext.totalValue = initialValue as List;
results.forEachIndexed((i, r) {
iterationContext.indexValue = i;
iterationContext.thisValue = r;
iterationContext.totalValue = expression.execute([r], passed);
currentTotal = iterationContext.totalValue;
});
return currentTotal;
}, passed);
return finalTotal;
}