isPrimitive function

bool isPrimitive(
  1. String oldType,
  2. Map<String, dynamic> oldValue
)

Implementation

bool isPrimitive(String oldType, Map<String, dynamic> oldValue) {
  final int keyLength = oldValue.keys.length;
  final bool containsId =
      oldValue.keys.contains('id') || oldValue.keys.contains('@id');
  final bool containsValue =
      oldValue.keys.contains('value') || oldValue.keys.contains('@value');
  final bool containsExtension = oldValue.keys.contains('extension') ||
      oldValue.keys.contains('@extension');
  if (<String>[
    'String',
    'Base64Binary',
    'Boolean',
    'Canonical',
    'Code',
    'Date',
    'FhirDateTime',
    'Decimal',
    'Id',
    'Instant',
    'Integer',
    'Integer64',
    'Markdown',
    'Oid',
    'PositiveInt',
    'Time',
    'UnsignedInt',
    'FhirUri',
    'FhirUrl',
    'Uuid',
  ].contains(oldType)) {
    if (keyLength == 1 && (containsValue || containsId || containsExtension)) {
      return true;
    } else if (keyLength == 2 &&
        ((containsValue && containsId) ||
            (containsValue && containsExtension) ||
            (containsExtension && containsId))) {
      return true;
    } else if (keyLength == 3 &&
        containsValue &&
        containsId &&
        containsExtension) {
      return true;
    } else {
      return false;
    }
  } else {
    return false;
  }
}