Does MedPlum/FHIR Support Cascade Deletes
# support
m
I'm wondering if there is any concept similar to Cascade Delete in FHIR/Medplum. For example, I create a
Patient
with
id=123
and then an
Encounter.subject
that contains a
Reference
to
Patient123
. Now, if I delete
Patient123
, is there any setting/config that would ensure that the
Encounter
would also be removed automatically along with any other objects that reference? Potential Use Cases: - Removing duplicate Patient - Cleaning up Test Data I've considered the below as a possible solution: -
Subscription
to listen on
Patient
delete and go delete all
Resources
with a
Reference
to the deleted
Patient
Any thoughts, resources, or further questions would be greatly appreciated!
r
Hi @mr_andy_p ! We don't have cascading delete functionality per-se, but we have a few options for you: * You can use the Patient compartment (https://www.medplum.com/docs/access/access-policies#compartments) to find all resources that refer to aptient. * You can then use the DELETE REST call to make a soft delete * OR you can use the expunge call to make a hard delete (if you are self hosting) https://www.medplum.com/docs/fhir-datastore/deleting-data#expunge-operation
m
Thanks for the speedy response, @rahul1 ! I'll review and share these options with my team and reach out if there are any additional questions.
135 Views