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 executedAfter = after.execute(results.toList(), passed);
if (executedAfter.isEmpty) {
return [];
}
if (executedAfter.length != 1) {
throw FhirPathInvalidExpressionException(
'Unary negate needs to be applied on a single item. Found instead: $executedAfter');
}
if (executedAfter.first is num) {
return [-(executedAfter.first as num)];
}
if (executedAfter.first is ValidatedQuantity) {
return [(executedAfter.first as ValidatedQuantity) * -1];
} else {
throw FhirPathInvalidExpressionException(
'Unary negate needs to be followed by an integer, a decimal, or a quantity. Found instead: ${executedAfter.first}');
}
}