isPrimitive function
Implementation
bool isPrimitive(String oldType, Map<String, dynamic> oldValue) {
final int keyLength = oldValue.keys.length;
// print(oldValue.keys);
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',
'FhirId',
'Id',
'Instant',
'Integer',
'Integer64',
'Markdown',
'Oid',
'PositiveInt',
'Time',
'UnsignedInt',
'FhirUri',
'FhirUrl',
'Uuid',
'FhirBase64Binary',
'FhirBoolean',
'FhirCanonical',
'FhirCode',
'FhirDate',
'FhirDecimal',
'FhirInstant',
'FhirInteger',
'FhirInteger64',
'FhirMarkdown',
'FhirOid',
'FhirPositiveInt',
'FhirTime',
'FhirUnsignedInt',
'FhirUuid',
].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;
}
}