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) {
  // Returns true if the input collection contains a single value which is a FHIR primitive,...
  if (results.length != 1) {
    return [false];
  }

  final element = results.first;

  if (element == null) {
    return [false];
  }

  // ...and it has a primitive value
  // (e.g. as opposed to not having a value and just having extensions).

  if (element is Map<String, dynamic>) {
    // element is a Map, most likely an answer. Introspect further...
    return [
      element.entries.any((mapEntry) =>
          mapEntry.key.startsWith('value') && mapEntry.value != null)
    ];
  } else {
    // element is a Dart primitive
    return [true];
  }
}