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

New API to support saving local only resources #2123

Open
ndegwamartin opened this issue Aug 10, 2023 · 3 comments · May be fixed by #2178
Open

New API to support saving local only resources #2123

ndegwamartin opened this issue Aug 10, 2023 · 3 comments · May be fixed by #2178
Assignees
Labels
P2 Medium priority issue type:enhancement New feature or request

Comments

@ndegwamartin
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
Sometimes we need to persist resources on the device's database without creating local changes to be synced to the server. Such resources may be downloaded from the server or perhaps generated by the client itself.

Currently the only way to persist a resource is to use the FhirEngine.create API method which flags the resources for sync.

Describe the solution you'd like
This could be solved by exposing the Database.insertRemote API via the FhirEngine API by adding the following interface and implementation.

//FhirEngine.kt
suspend fun createRemote(vararg resource: Resource)
//FhirEngineImpl.kt
  override suspend fun createRemote(vararg resource: Resource){
    return database.insertRemote(*resource)
  }

Describe alternatives you've considered
An alternative approach could be to enhance the current FhirEngine.create API and pass a flag to determine whether it should be marked for sync or is a local only resource.

//FhirEngine.kt
suspend fun create(val isLocalOnlyChange:Boolean = false, vararg resource: Resource): List<String>

Might be better to name the flag something like isSyncable or syncUp and set its default to true to avoid any confusion with the existing concept of local changes.

Additional context
N/A

Would you like to work on the issue?
Yes

ndegwamartin added a commit to opensrp/android-fhir that referenced this issue Aug 23, 2023
ndegwamartin added a commit to opensrp/android-fhir that referenced this issue Aug 23, 2023
ndegwamartin added a commit to opensrp/android-fhir that referenced this issue Aug 23, 2023
@ndegwamartin
Copy link
Collaborator Author

Appears in Kotlin an overriding function is not allowed to specify default values for its parameters. I will therefore make a PR with the original solution and we can iterate on that if need be.

ndegwamartin added a commit to opensrp/android-fhir that referenced this issue Sep 16, 2023
@ndegwamartin ndegwamartin linked a pull request Sep 16, 2023 that will close this issue
7 tasks
@fredhersch fredhersch added type:enhancement New feature or request P2 Medium priority issue labels Feb 7, 2024
@jingtang10
Copy link
Collaborator

what does it mean for a non-local only resource to depend on a local only resource? this shouldn't really work as we'd be potentially breaking data integrity on the server if the non-local only resource is uploaded to the server. to what extent is this a problem in our case and how should we handle it?

@jingtang10
Copy link
Collaborator

ping @ndegwamartin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Medium priority issue type:enhancement New feature or request
Projects
Status: PR under Review
Development

Successfully merging a pull request may close this issue.

3 participants