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.length == 1 && after.first is IdentifierParser
      ? [(after.first as IdentifierParser).value]
      : after.execute(results.toList(), passed);

  return executedBefore.isEmpty ||
          executedBefore.length != 1 ||
          executedAfter.isEmpty ||
          executedAfter.length != 1
      ? throw FhirPathEvaluationException(
          'the "is" operation requires two operands, this was '
          'passed the following\n'
          'Operand1: $executedBefore\n'
          'Operand2: $executedAfter',
          collection: results)
      : (passed.isVersion(FhirVersion.r4)
                  ? r4.resourceTypeFromStringMap.keys
                      .contains(executedAfter.first)
                  : passed.isVersion(FhirVersion.r5)
                      ? r5.resourceTypeFromStringMap.keys
                          .contains(executedAfter.first)
                      : passed.isVersion(FhirVersion.dstu2)
                          ? dstu2.resourceTypeFromStringMap.keys
                              .contains(executedAfter.first)
                          : stu3.resourceTypeFromStringMap.keys
                              .contains(executedAfter.first)) &&
              executedBefore.first is Map &&
              executedBefore.first['resourceType'] == executedAfter.first
          ? [true]
          : executedAfter.first == 'String'
              ? [executedBefore.first is String]
              : executedAfter.first == 'Boolean'
                  ? [
                      executedBefore.first is bool ||
                          executedBefore.first is FhirBoolean
                    ]
                  : executedAfter.first == 'Integer'
                      ? [
                          (executedBefore.first is int ||
                                  executedBefore.first is FhirInteger) &&

                              /// This is because of transpilation to javascript
                              !executedBefore.first.toString().contains('.')
                        ]
                      : executedAfter.first == 'Decimal'
                          ? [
                              (executedBefore.first is double ||
                                      executedBefore.first is FhirDecimal) &&

                                  /// This is because of transpilation to javascript
                                  executedBefore.first
                                      .toString()
                                      .contains('.')
                            ]
                          : executedAfter.first == 'Date'
                              ? [executedBefore.first is FhirDate]
                              : executedAfter.first == 'DateTime'
                                  ? [
                                      executedBefore.first is DateTime ||
                                          executedBefore.first is FhirDateTime
                                    ]
                                  : executedAfter.first == 'Time'
                                      ? [executedBefore.first is FhirTime]
                                      : executedAfter.first == 'Quantity'
                                          ? [isQuantity(executedBefore.first)]
                                          : [false];
}