delete method

Future<bool> delete({
  1. Resource? resource,
  2. R4ResourceType? resourceType,
  3. String? id,
  4. bool finder(
    1. Map<String, dynamic>
    )?,
  5. String? pw,
})

Delete specific resource

Implementation

Future<bool> delete({
  Resource? resource,
  R4ResourceType? resourceType,
  String? id,
  bool Function(Map<String, dynamic>)? finder,
  String? pw,
}) async {
  if (resource != null &&
      resource.resourceType != null &&
      resource.fhirId != null) {
    return _deleteById(
      resourceType: resource.resourceType!,
      id: resource.fhirId!,
      pw: pw,
    );
  } else if (resourceType != null && id != null) {
    return _deleteById(
      resourceType: resourceType,
      id: id,
      pw: pw,
    );
  } else if (resourceType != null && finder != null) {
    return _deleteFromDb(
      resourceType: resourceType,
      finder: finder,
      pw: pw,
    );
  } else {
    throw const FormatException('Must have either: '
        '\n1) a resource with a resourceType'
        '\n2) a resourceType and an Id'
        '\n3) a resourceType, a specific field, and the value of interest');
  }
}