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 executedBefore = before.execute(results.toList(), passed);
  final executedAfter = after.execute(results.toList(), passed);

  if (executedBefore.isEmpty) {
    return (executedAfter.isEmpty) ? [] : [false];
  }

  if (executedBefore.length > 1) {
    throw FhirPathEvaluationException(
        "The 'in' operator is expecting a single item on its left side. Found $executedBefore",
        operation: 'in',
        collection: results);
  }

  final leftItem = executedBefore.first.toString();
  return [
    executedAfter.firstWhere((rightItem) => rightItem.toString() == leftItem,
            orElse: () => null) !=
        null
  ];
}