Bahmni Connect when setup with Location based sync strategy will not work by default unless, there are unique IDs for each address hierarchy entry in the OpenMRS database.
By Unique IDs I mean, in the address_hierarchy_entry table, each entry should have a user_generated_id column filled. This setup will not work if the user_generated_id column is null for the address entries. Based on the loggedIn location, this unique ID will be used as a filter to sync the patient data to the connect device.
Usually, the IDs are more like a PINCODE format. For example, based on the above image, the following can be the unique IDs for the address entries.
Thanks @shruthipitta for spending the time to debug this with me .
We have found that the problem is likely coming from the fact that too many calls are made when the address set on the Login location is a high level in the address hierarchy.
Indeed, there is as many calls made as there is filter values (ie, address entries):
In my use case, there is only one possible login location named ‘Health Center’ because the clinic is a mobile clinic and provides care across 3 provinces. So I would have to set the level to the highest one, “country”. That is 16,459 address entries.
This means that in the code below, promises will contain 16,459 promises.
And as many HTTP calls will be made. This seems to freeze the Chrome window.
If one sets a lower address level to the Login location, such as a District or Village, the number of child entries is much smaller and all works. For instance, with few trials I can say that around 500~700 entries max, the page works and loads fine.
Conclusion: I believe the LocationBasedSyncStrategy was not created to load such a big number of entries and may just not fit for me here.
I am thinking I should create a “AllPatientsSyncStrategy” instead to simply retrieve all patients.