opensrp/opensrp-client-reveal

Some Plans not appearing even after sync is complete on Thai

Closed this issue · 4 comments

@Rkareko
APK: V5.3.26
user raitests

steps
-install the app
-sync data
-click on an OA and select
-try to select a plan
-observe how some plans are showing "Downloading of plans in progress please wait"
this happens both when:
-All data is synced and still have internet on
-You have fully synced the data and downloaded ALL the offline maps and internet is off

see below screenshot.
image

note that this is affecting even older APK versions. eg v5.3.25

@madrinekariuki @samkanga This message is usually displayed when a location does not have plans that have a status = active and plan end date is in the past. Should we update the message to be more descriptive?

@samkanga cc @LZRS After initial investigations the likely cause of this is that team assignments in Thailand are set to be valid even after all the plans are retired or complete. The OAs displayed on the hierarchy on the app are determined by the active team assignments for that user. Since the team assignment is active but user has no active plans the OA is displayed on the app location hierarchy but no active plans are detected and thus an error is displayed.

Why do team assignments persist even after all plans are complete / retired ?
Thailand requires the ability to view even complete plans on the Web UI. The Web UI fetches plans from the opensrp server using the fetchPlansForUser endpoint.
The process is as follows : -

  1. Fetch all teams the user is assigned to. The practitioner role table contains a mapping of users to teams
  2. Fetch team assignments using the organization ids from step 1. The team assignments are filtered by
  • From date is less than or equal to current date
  • To date is either null or is greater than the current date
  • Belong to the teams provided
  1. Extract the list of plans from the team assignments and return them
    This work around will be affected by the changes introduced to expire all team assignments when plan status changes to Retired or Completed update to the opensrp server.
LZRS commented

@samkanga @Rkareko The reason why some of the operational areas are shown on the app location hierarchy, when they do not have plans, is because they do have 'active' plans but the 'effectivePeriod' end date is in the past. The server does not check on the 'effectivePeriod' end date
An example
https://servermhealth.ddc.moph.go.th/opensrp/rest/plans/f456c725-29f0-5c77-8c57-930abaa5273a

{
  "identifier": "f456c725-29f0-5c77-8c57-930abaa5273a",
  "version": "1",
  "name": "-เมืองทอง(Site)-2-2021-06-30",
  "title": " เมืองทอง(Site)-2 2021-06-30_MigrationII",
  "status": "active",
  "date": "2021-06-30",
  "effectivePeriod": {
    "start": "2021-06-30",
    "end": "2021-07-20"
  }
} 

for operational area 49a51216-eb8b-458e-988a-09c7d7119cee

tested this on:
v5.3.26-rc3

users:
test77/Amani123
raitest/raitest

steps:
-install the app
-sync data on the app
-check to see the listed OAs
-count the number of OAs in the plans.
-check in the database or through this endpoint to check the OAs with active plans for that user.
-confirm the number of active plans from the query tallys with the one you got on the app.
-also try downloading offlne maps and after tey download turn off the internet and try accessing all the plans to confirm that you are not getting the error "download in progress"
-repeat the process with another user to confirm this.