execute method Null safety

List execute(
  1. List results,
  2. Map<String, dynamic> passed
)
override

Implementation

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.ResourceUtils.resourceTypeFromStringMap.keys
                      .contains(executedAfter.first)
                  : passed.isVersion(FhirVersion.r5)
                      ? r5.ResourceUtils.resourceTypeFromStringMap.keys
                          .contains(executedAfter.first)
                      : passed.isVersion(FhirVersion.dstu2)
                          ? dstu2.ResourceUtils.resourceTypeFromStringMap.keys
                              .contains(executedAfter.first)
                          : stu3.ResourceUtils.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 Boolean
                    ]
                  : executedAfter.first == 'Integer'
                      ? [
                          executedBefore.first is int ||
                              executedBefore.first is Integer
                        ]
                      : executedAfter.first == 'Decimal'
                          ? [
                              executedBefore.first is double ||
                                  executedBefore.first is Decimal
                            ]
                          : executedAfter.first == 'Date'
                              ? [executedBefore.first is Date]
                              : executedAfter.first == 'Datetime'
                                  ? [
                                      executedBefore.first is DateTime ||
                                          executedBefore.first is FhirDateTime
                                    ]
                                  : executedAfter.first == 'Time'
                                      ? [executedBefore.first is Time]
                                      : executedAfter.first == 'Quantity'
                                          ? [
                                              executedBefore.first
                                                  is FhirPathQuantity
                                            ]
                                          : [false];
}