Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality to allow for single/bulk delete or truncation of the DB #101

Closed
4 tasks
f-odhiambo opened this issue Jan 3, 2024 · 8 comments
Closed
4 tasks
Assignees

Comments

@f-odhiambo
Copy link
Contributor

f-odhiambo commented Jan 3, 2024

Need to delete dummy data from HAPI which includes dirty/dummy data while testing

  • Add ability to either delete by resources
{
  "resourceType": "Bundle",
  "type": "transaction",
  "entry": [
    {
      "request": {
        "method": "DELETE",
        "url": "Organization/1"
      }
    },
    {
      "request": {
        "method": "DELETE",
        "url": "Organization/2"
      }
    }
  ]
}
  • Mass Delete related Patient data via DELETE /Patient/123?_cascade=delete
  • Delete resource + history via $expunge operation
  • Delete all data on base
POST [base]/$expunge
Content-Type: application/fhir+json

{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "expungeEverything",
      "valueBoolean": true
    }
  ]
}

More here https://smilecdr.com/docs/fhir_repository/deleting_data.html

@lincmba lincmba self-assigned this Jan 5, 2024
@lincmba
Copy link
Contributor

lincmba commented Jan 10, 2024

I've conducted some research regarding the functionality:

  1. Conditional Deletes:
    It seems that conditional deletes with a match URL like /Patient?_id=1,2 result in an error due to matching multiple resources. To overcome this, it might be necessary to delete resources one by one.
    ref: https://hl7.org/fhir/http.html#cdelete

  2. Transactional Deletes:
    Transactional deletes, such as using a Bundle with DELETE methods, also encounter issues when a resource has references. Deleting references one by one might be necessary to successfully delete the target resource.
    ref: https://smilecdr.com/docs/fhir_repository/deleting_data.html#transactional-delete

  3. Expunge Operation:
    The expunge operation is not supported as of now, and attempting to use it results in a parsing error. It might be worth checking if future updates of the tooling will include support for this operation.
    ref: https://smilecdr.com/docs/fhir_repository/deleting_data.html#instance-level-expunge

  4. Cascading Deletes:
    Enabling allow_cascading_deletes and allow_multiple_delete at the JPA server settings seems to work for deleting multiple resources and all references at once. This means if a Patient of id 1 is referenced by another resource i.r Observation. When the patient is deleted, the referenced observation is deleted aswell.
    [DELETE] http://localhost:8888/fhir/Patient?_id=1,2&_cascade=delete
    ref: https://docs.oracle.com/en/industries/health-sciences/healthcare-data-repository/8.1.4/fhir-guide/deletes-and-referential-integrity.html#GUID-78537C7B-B9CC-466D-BFF4-8D75E785947C

I'll be implementing 4 as a solution to this

lincmba added a commit that referenced this issue Jan 10, 2024
lincmba added a commit that referenced this issue Jan 10, 2024
lincmba added a commit that referenced this issue Jan 10, 2024
@lincmba lincmba mentioned this issue Jan 10, 2024
2 tasks
@Wambere
Copy link
Contributor

Wambere commented Jan 11, 2024

@f-odhiambo @lincmba I'm probably missing some context here, but is there a reason we could not use this already existing cleaner ?

@f-odhiambo
Copy link
Contributor Author

Option 4 does not exist on the cleaner , so should we add this ad an enhancement there ?

@pld
Copy link
Member

pld commented Jan 11, 2024

since this already done in the PR, let's make sure the PR matches the cleaner functionality and remove the cleaner, I think we need to add expunge to the efsity version to match.

@lincmba you can update the PR to delete the cleaner, after adding the expunge functionality

@Wambere
Copy link
Contributor

Wambere commented Jan 16, 2024

@pld after some discussions with @ndegwamartin and @lincmba we think that it makes more sense to update the current cleaner and keep using it instead of deleting it, since it has the following functionality that does not exist here yet

  1. Takes in any parameter and value combination used to filter/find the resources you want to delete, while this takes in only IDs
  2. Able to expunge records after deleting
  3. Transaction requests - deleting in batches, while this deletes one at a time

We would need to add the cascade delete functionality to the cleaner though, creating a separate issue for that

@pld
Copy link
Member

pld commented Jan 17, 2024

Ah ok, so then we're remove the cleaning functionality from esfity? Or maybe better, merge that PR, so it's there and working, but at a doc string pointing to the cleaner tool?

@pld
Copy link
Member

pld commented Jan 17, 2024

Nevermind, just saw this comment, #101 (comment)

@Wambere
Copy link
Contributor

Wambere commented Jan 24, 2024

To be completed in #106

@Wambere Wambere closed this as completed Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants