Delete data
FHIR delete
You can delete single resource using DELETE
FHIR API method. This method deletes the resource specified and create a history entry for the operation. The history entry created contains entire deleted resource.
Note that Aidbox does not enforce referential integrity for DELETE
method.
Example.
Request:
Response:
Transactional Delete
If you need to delete multiple resources, use FHIR Transaction with multiple DELETE
requests.
This operation groups multiple REST API operations in a transaction. If all DELETE
operations are successful, the transaction with DELETE
requests is equivalent to calling DELETE
multiple times.
Delete resource history
If you need to delete resource history, you need to execute SQL manually.
Example:
Or you can make a REST endpoint from SQL query using AidboxQuery.
Example:
And then run it with
Delete all resources and history
You can use truncate
PostgreSQL statement to delete everything from the specified table.
Example:
Similarly you can create an endpoint for this
And then run it with
Note that AidboxQuery with variable resourceType
can only be called with _query
parameter.
Delete resources in CI environment
In CI environments it is often desired to have same state at the beginning of each test suite. You can simply stop Aidbox, drop database, and start Aidbox again.
Use Aidbox project to set up fixtures. Note that you can use different Aidbox projects for each test suite (or different entrypoints).
Last updated