Easiest way to clean up a FHIR database?
Hi, what is the easiest way to clear all the tables which store FHIR data? The most straitforward approach is to get a list of tables using the information_schema.tables view, then execute dynamic SQL with the "delete from" clause, but perhaps some helper class has already been written for this purpose?
Comments
Great question. We routinely need to do this in our internal testing. To clean out your repo, use the following commands at the IRIS terminal:
Set strategy = ##class(HS.FHIRServer.API.InteractionsStrategy).GetStrategyForEndpoint(appKey)
Set options("deleteDataOnly") = 1
Do strategy.Delete(.options)
The FHIR Server config page should have your app key.
Good luck.
Great answer! And yes, I badly need that for testing!
For those who wants to purge it regularly on a test environment, you can use this task definition based on this method. .png)
is it possible to delete all resources of a specific type?
If this is for testing I'd suggest to use iris docker container with FHIR db inside. So just container relaunch will do the thing.
The use of docker obviously simplifies the solution to the problem and completely meets the need.
However, sometimes our customers don't use docker, even in their dev/test or staging environments.