execute method

  1. @override
List execute(
  1. List results,
  2. Map<String, dynamic> passed
)
override

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 returnList =
      IterationContext.withIterationContext((iterationContext) {
    final iterationResult = [];
    results.forEachIndexed((i, element) {
      iterationContext.indexValue = i;
      iterationContext.thisValue = element;
      final newResult = value.execute([element], passed);
      if (newResult.isNotEmpty) {
        if (!(newResult.length == 1 && newResult.first == false)) {
          iterationResult.add(element);
        }
      }
    });
    return iterationResult;
  }, passed);

  return [returnList.isNotEmpty];
}