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
465 stars 246 forks source link

Ability to Dump Application's Database #2360

Closed qiarie closed 1 month ago

qiarie commented 6 months ago

Is your feature request related to a problem? Please describe.

We have experienced sync issues due to malformed resources, caused by some references not properly set such as missing the resource type before the reference. Resources with such issues fail to sync since the referenced resources are not found on the server.

Identifying the cause of the failing sync has proven hard, especially when we are unable to reproduce the issue on our staging environment.

Describe the solution you'd like

To make troubleshooting possible for cases that are hard to reproduce, we would like a copy of the application's database to be downloadable to device storage for further investigations.

The dumped database file should be encrypted with a password that is defined by the app calling the database download SDK API.

Describe alternatives you've considered

Additional context

Add any other context or screenshots about the feature request here.

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.

dubdabasoduba commented 6 months ago

@jingtang10 please feel free to review the PR On OpenSRP. I think we want to move that kind of functionality to the SDK

qiarie commented 2 months ago

@jingtang10 We would like to revisit this issue and have the feature in the SDK. Please review the issue and share your thoughts.

santosh-pingle commented 2 months ago

Can you please discuss this issue in today's developer call? @Simon Njoroge @Aditya Khajuria @Madhuram Jajoo

MJ1998 commented 2 months ago

We are happy to add this ability. Along with this there should also be a way for application to modify data before dump - so a plugin which application can implement and register.

Can you tell us how you are doing this in the PR linked above. Would you work on this @qiarie ? Thanks.

MJ1998 commented 2 months ago

@qiarie We also wanted to understand the use-case more. Questions are around difference between staging and prod environment - and the possibility of replicating the scenario to troubleshoot the sync issue in prod environment ? For example, one could upload all the logs to troubleshoot, no ?

qiarie commented 2 months ago

Hello @MJ1998.

We are happy to add this ability. Along with this there should also be a way for application to modify data before dump - so a plugin which application can implement and register.

This is noted. Do you mind giving more information on there should also be a way for application to modify data before dump - so a plugin which application can implement and register.

Can you tell us how you are doing this in the PR linked above. Would you work on this @qiarie ? Thanks.

I will check with my team and share an update

qiarie commented 2 months ago

@MJ1998

@qiarie We also wanted to understand the use-case more. Questions are around difference between staging and prod environment - and the possibility of replicating the scenario to troubleshoot the sync issue in prod environment ? For example, one could upload all the logs to troubleshoot, no ?

In our current use case and implementation, a user is able to initiate a raw database download to the file system.

For debug versions, the database is unencrypted and is saved as is to the file system. For release versions, the app's database is encrypted. An empty database file is created. The encrypted database is read and its contents copied to the empty DB file.

In both cases, the database is zipped and a ZIP password set.

MJ1998 commented 1 month ago

After internal discussions and careful evaluation, we've decided not to implement the database dump feature at this time. This decision aligns with our core principle of maintaining a secure, encrypted database environment. Additionally, we believe this feature may become less relevant as our sync capabilities mature.