Bahmni Connect: how to setup the LocationBasedSyncStrategy?

Hi guys!

Trying to set up Bahmni Connect with Location based sync strategy.

But I get the following error: [Please give address for this login location in openmrs]

My login location is Subcenter 1 (BAM) and I have set an address to it:

login screen

Any idea what additional steps I forgot to perform?

Thanks @shashikanth for the explanation during the call yesterday.

Could you reply to this post and explain what you explained to me yesterday? (I haven’t found any documentation about this so let’s at least write that down here.)

We will then need to update the wiki as well.

Hi All,

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.

If the user_generated_id column is null, then a script can be written to generate these IDs based on the above logic.

1 Like

@shashikanth, another problem I encounter is when I map the Login location with higher level address hierarchy (higher than “'District”) loading the Bahmni Connect page stops working:

1/ Set the login location with a Country + Province + District value:

Then Connect loads just fine:

2/ Set the login location with Country + Province only values:

Then the page freezes:

Any idea of what could happen here?

Thanks @shruthipitta for spending the time to debug this with me :+1: .

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.


Thanks for the excellent explanation.