Re-assign clients with pre-used ZEIR IDs on apps using opensrp-client-child library

There have been issues in the recent past where clients are not syncing to the server due to holding used ZEIR IDs. This article gives a way forward and explains the fix that was made. The issue affects opensrp-client-child for versions below v0.9.0-SNAPSHOT. Clients with already-assigned ZEIR IDs are not synced but are marked as synced. This can easily lead to data-loss should the user clear the app data or uninstall the app.

 Instructions

  1. Ensure that in your dependencies you have opensrp-client-core v5.0.10-SNAPSHOT or later

  2. In the scheduleJobsImmediately() method of your LoginInteractor ( extending BaseLoginInteractor), schedule the cleanup service to run periodically upon login. Checkout this example in the GIZ Malawi app https://github.com/opensrp/opensrp-client-giz-malawi/blob/master/opensrp-giz-malawi/src/main/java/org/smartregister/giz/interactor/LoginInteractor.java#L79 . This service should re-assign IDs to local clients found with duplicate IDs. The service only handles IDs labelled as F_ZEIR_ID, M_ZEIR_ID, ZEIR_ID and zeir_id. If you application uses any ID label, then you should request for help to include this ID label in the query. The service uses the following events Birth Registration and New Woman Registration when reprocessing these clients. In case the app’s registration events are named differently, pass this to the service similar to this

  3. Fix the bug causing the duplicate ID assignment by updating your opensrp-client-child to v0.10.0-SNAPSHOT or later

How it works

  • The service checks if there are any clients that share the same ZEIR IDs.

  • If such clients exists it then obtains new ids from the unique_id's table (or fetches new ones if they have been exhausted) and applies them to the affected clients.

  • Finally it marks these clients as Unsynced. This is so that they can be synced to the server in the next sync cycle or if the user manually clicks on sync.