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 other = value.execute(results.toList(), passed);
  final inBag = [...results];

  // Eliminate duplicates in input
  final outBag = [];
  for (final item in inBag) {
    if (outBag.indexWhere((otherItem) =>
            const DeepCollectionEquality().equals(item, otherItem)) ==
        -1) {
      outBag.add(item);
    }
  }

  // Intersect
  outBag.removeWhere((e) =>
      other.indexWhere(
          (element) => const DeepCollectionEquality().equals(e, element)) ==
      -1);

  return outBag;
}