save method
Saves a Resource
to the local Db, cipher
is optional (but after set,
it must always be used everytime), will update the FhirFhirFhirMeta fields
of the Resource
and adds an id if none is already given.
Implementation
Future<Resource> save({
Resource? resource,
String? pw,
}) async {
if (resource != null) {
if (resource.resourceType != null) {
return resource.fhirId == null
? await _insert(resource, pw)
: await exists(
resourceType: resource.resourceType!,
id: resource.fhirId!.value!,
pw: pw,
)
? await _update(resource, pw)
: await _insert(resource, pw);
} else {
throw const FormatException('ResourceType cannot be null');
}
} else {
throw const FormatException('Resource cannot be null');
}
}