google / android-fhir

The Android FHIR SDK is a set of Kotlin libraries for building offline-capable, mobile-first healthcare applications using the HL7® FHIR® standard on Android.
https://google.github.io/android-fhir/
Apache License 2.0
458 stars 238 forks source link

Fix case when we purge a resource with forcePurge and related resource in LocalChange #2510

Closed ndegwamartin closed 1 month ago

ndegwamartin commented 1 month ago

This is a follow up on the ticket here - https://github.com/google/android-fhir/pull/2462#pullrequestreview-1979937455

Is your feature request related to a problem? Please describe. With the above implementation, what happens in case we purge a resource with forcePurge set to true but there is some resource reference in another LocalChange - referential integrity broken e.g. when application does a purge of Patient(s) with given id(s) but not Observation(s) for that patient.

We can either:-

Support reference resource recursive purging with another flag. Throw an exception when there are references which were not purged ?

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context More context here : https://github.com/google/android-fhir/pull/2462

Would you like to work on the issue? Please state if this issue should be assigned to you or who you think could help to solve this issue.

MJ1998 commented 1 month ago

Thanks for raising this Martin, I discussed this internally today, it seems this was considered before and we wanted to keep the purge API straight forward and simple depending on the developer to ensure correct purging.

We provide the include & revInclude search APIs to get all referenced resources for a resource. Developer can use it and then provide the ids to the purge API - this will ensure all referenced resources are also purged.

Closing this.