Expunge everything, but keep project around?
# support
y
Hi there. We're iterating on our data migration from our existing data store into our Medplum project. As we iterate, it would be helpful for us to essentially wipe all FHIR resources from within the project and re-run the migration to get a fresh clean instance to work from. I found there's an expunge everything endpoint, which almost suits our needs, except that it also wipes away the project itself. Is there a straightforward way to wipe everything in a project except for: - the project itself - clients - bots - subscriptions
r
Hu @yale_77214 , a couple points: 1. You can use the Expunge operation per-resource type: https://www.medplum.com/docs/fhir-datastore/deleting-data#expunge-operation. You would have to make 1 call per resource-type you want to handle 2. Because
$expunge
touches the database directly, this feature is only available to self-hosted customers. If you're using our hosted version, would encourage you just to use DELETE requests
If the concern is around needing too many delete requests to claer out the project, there's a few ideas we can discuss
y
Yes, given how many resources we are creating (even just from our UAT database), having one delete per resource is a lot
r
I understand. So the option currently available right now would be to create a Batch request of deletes. You can do this a couple different ways: 1. You can construct a bundle, as shown here: http://hl7.org/fhir/R4/http.html#transaction 2. You can use Medplum autobatching (needs documentation). If you set the
autobatchTime
constructor parameter to the
MedplumClient
, all REST operations within that time window will converted into a bundle transparently to the caller. E.g. setting it to
1000
will construct a bundle out all all rest operations constructed in 1 secord In the longer term, the FHIR spec allows for "Conditional Deletes" (http://hl7.org/fhir/R4/http.html#3.1.0.7.1) to delete a whole resoruce type at once, and this would be reasonable for us to support
y
Oh wow, I didn't know about autobatching. That's definitely good to know. Are there any bundle size constraints I should be aware of?
r
We haven't run into any constraints in the wild, but I'd say batches of 500-1000 are reasonable
The one caveat to autobatching - you'll have to wrap all your delete requests in a
Promise.all
y
Ok, great. We'll likely end up batching on our end as well (e.g. doing a Promise.all with 500 deletes, and then waiting out the time window and continuing to the next batch)
p
Hi, @rahul1 i am self hosting the server, i am trying to call expunge method from postman as http://localhost:8103/fhir/R4/Patient/46f7d58f-cecf-4881-8d0a-bbca9d51ce6f/$expunge?everything=true i have also send the authorization token of the logged in user in the admin panel, but i am getting unauthorize response. Also, is there any routes or page from where i can trigger this action from medplum admin panel?
159 Views