opensrp / fhircore

FHIR Core / OpenSRP 2 is a Kotlin application for delivering offline-capable, mobile-first healthcare project implementations from local community to national and international scale using FHIR and WHO Smart Guidelines on Android.
https://smartregister.org
Apache License 2.0
50 stars 39 forks source link

Sync and offline support #23

Closed f-odhiambo closed 2 years ago

f-odhiambo commented 3 years ago

Save questionnaire resource to SQLite DB and ensure it syncs to FHIR server

For ANC App

pld commented 3 years ago

From @fredhersch

Current approach: client constructs the query and sends to the HAPI restful end-point to perform an operation

Versus:

Does the SDK just point to an API end-point (passing in the authenticated user) that performs the operations server-side to determine what patients and resources the client should have access to?

The later makes sense to me because the server is what knows about permissions, and I believe that's what we're doing now.

@Andati @rkodev can you describe if this aligns w/what we're doing now?

CC @mberg

vincent-karuri commented 3 years ago

We need to coordinate with Google on this to flesh it out and figure out a strategy on sync. From this week's call, it seems like they would need our input.

f-odhiambo commented 3 years ago

Related to #42

ekigamba commented 3 years ago

Upload of new FHIR records and local modifications to the server

Download of FHIR records periodically

Next steps

rkodev commented 3 years ago

We can send a batch request by grouping by Resource Type and Request Type, the ordinality of the group can be determined combination of all POST requests = 0 and everything else = 1 + and the minimum change in the set of resources.

On the event downloads not exactly sure why the order will matter since the SDK seems not to care about the downloads, my understanding from the codebase looks like all data is saved regardless of the relationship and as long as sync is complete there will be Eventual Consistency.

On Sync : Option 4 We can implement a custom interceptor for Retrofit, this is assuming the sync params are simple might not need any changes to the SDK side

General comment: I think adding access control on the server-side instead of only relying on the client as we currently do in OpenSRP will great.

ekigamba commented 3 years ago

@rkodev I have updated the strategy based on your recommendations

vincent-karuri commented 3 years ago

@rkodev what do you mean by:

I think adding access control on the server-side instead of only relying on the client as we currently do in OpenSRP will great.

How does the client perform access control on OpenSRP?

rkodev commented 3 years ago

@vincent-karuri the older implementations of OpenSRP would return data without performing an authorization check to check whether the user requesting the data has access to the data. The server relied on OpenSRP clients to request only the data the client has access to i.e provide the filter parameters

f-odhiambo commented 3 years ago

Currently blocked by location mapping tasks

pld commented 2 years ago

what's remaining here?

ekigamba commented 2 years ago

Update


We probably want to change this issue into a discussion

fredhersch commented 2 years ago

Great to see the progress here.

Couple of questions:

  1. Are you planning to use the sync API to construct the queries to determine which resources to sync or will you be using a custom end-point that you will point the SDK too?
  2. What are the offline support updates required?
ekigamba commented 2 years ago
  1. @f-odhiambo @dubdabasoduba Can you help answer # 1 :arrow_up:
  2. Required offline updates - It seems this was fixed. I'd noticed that resources to be synced were not available on the resources table until synced to the server. This was probably fixed with the new engine update :smile: :+1:

I have updated my comment and updated the details also

f-odhiambo commented 2 years ago

@fredhersch @ekigamba Yes. This is what we want to achieve with the Single APK approach. We will also tie in Keycloack to facilitate Role-Based access control (RBAC). Also, we have the location hierarchy (Sync Location/Team) piece that will aid in unblocking this once done i.e. #188 & #189

Lastly, converting this to a discussion point