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 executedValue = value.execute(results.toList(), passed);
return results.isEmpty
? []
: results.length > 1
? throw _requiresList('.substring()', results)
: (results.first is! String)
? throw _requiresString('.substring()', results)
: executedValue.isNotEmpty &&
executedValue.first is int &&
(((executedValue.first as int) >=
(results.first as String).length) ||
(executedValue.first as int) < 0)
? []
: executedValue.length == 1 && executedValue.first is int
? [
results.first
.toString()
.substring(executedValue.first as int)
]
: executedValue.length == 2 &&
executedValue.first is int &&
executedValue.last is int
? [
results.first.toString().substring(
executedValue.first as int,
((executedValue.first as int) +
(executedValue.last as int)) >
results.first.toString().length
? results.first.toString().length
: ((executedValue.first as int) +
(executedValue.last as int)),
)
]
: throw FhirPathEvaluationException(
'The function .substring() was not provided the '
' proper parameters.',
operation: '.substring()',
collection: results,
arguments: executedValue);
}