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) {
if (results.isEmpty) {
return [];
} else {
/// if there's more than 1 item in context, throw exception
if (results.length > 1) {
throw _conversionException('.convertsToQuantity()', results);
}
/// otherwise if the first item is a Quantity already, a num or a
/// bool, this is considered true
else if ((results.first is ValidatedQuantity &&
(results.first as ValidatedQuantity).isValid()) ||
results.first is num ||
results.first is bool) {
return [true];
} else if (results.first is String &&
ValidatedQuantity.fromString(results.first).isValid()) {
return [true];
}
/// Otherwise it's definitely false
else {
return [false];
}
}
}