Dropdown for Address Hierarchy

Hello there! I was wondering whether there was a way (guide or tutorial would be helpful) to create a dropdown for the Address Hierarchy. For example: you pick a country and then you get a dropdown with all the states. @cristian @rafanetow

Hi @mmatamoros

You just need to import your address hierarchy entries and map the address fields to the entries levels.
See ‘Address Hierarchy’ on Bahmni wiki.
As for the address fields themselves, they are configured through the address template, see ‘Administering Address Templates’ on OpenMRS wiki.

Additionally you can also refer to the ‘Address Hierarchy Module’ OpenMRS wiki page, for more information.

Finally, as from Address Hierarchy 2.11.0 (which is about to be released, see from here), it will be possible to just let the module load the address configuration (including address hierarchy entries) upon starting.
This is an example of such a configuration. You can ignore the .properties files, the example configuration I’m pointing you to is also supporting i18n, that’s why they are there.

Two files are in fact needed:

  1. addresshierarchy.csv
    That’s the one containing all the entries.
  2. addressConfiguration.xml
    That’s the one defining the address template and mapping the entries levels.
1 Like

Hello @mksd

I helped a lot what you put in this template guide: https://wiki.openmrs.org/display/docs/Administering+Address+Templates#AdministeringAddressTemplates-Spain and stayed like this: https://pastebin.com/dNC4vEWq and my Heirarchy address :

but I have the following problems: 1) There are fields 5 fields that do not allow me to save:

What should I change in my template to allow me to save them?

  1. maybe it still is not really like adding a drop down since I did a test and it was always added to the 5 element with entries and all appear as text

Also did you see this: ‘Configure Address Hierarchy’?

Ans also you should not map - I believe - the fields from the address template that have no address hierarchy entries. So IMO you should delete mappings 6 to 11.

Hi @mksd I succeeded thank you very much :blush: I read the links of his comment well and these were the results: this is my template:https://pastebin.com/sCxnyVC4 and I uploaded my csv for the Address Heirarychy with success. The only thing that I could not was that my countries and cities appeared as dropdown. Address Hierarchy working (Honduras): 1)

image 2)

image 3)


Great that you could move forward with this and that the wiki could be of help!

Do you mean that you couldn’t get the ‘País’ dropdown to list the countries?

Yes, is it possible to do dropdown in version 0.89 of openmrs?

I haven’t looked so I am not sure. Obviously there are (at least) two possibilities as to why this does not work:

  1. The Address Hierarchy module itself does not allow multiple choices for the highest address hierarchy level (which is always the country level).
  2. Bahmni Apps does not produce a dropdown widget for the address field at the highest level.

Is this something you could investigate?

@rafanetow I can confirm that Address Hierarchy allows multiple choices for the highest level, you should start by looking into the way the addresses are mapped in the Address Template, then into the widget config (which may be a Bahmni) issue

1 Like

Thanks for confirming this @ssmusoke! Good to know as I had never tried that specific configuration, and I was doubting that those guys at PIH would have overlooked the multi-country use case :wink:

@rafanetow if you could confirm that the issue lies in Bahmni this will definitely be worth a JIRA ticket.

Yes, @ssmusoke beat me to it, but, unless a bug was introduced at some point, the module should allow multiple choices at the highest level.

I can not find in bahmni where I could do a dropdown in my template or with some kind of configuraicon from the openmrs UI @mksd …This is my template https://pastebin.com/sCxnyVC4 @ssmusoke

Hi @rafanetow,

I looked a little bit and the country address field (or the top level address field for that matter) is not handled differently than the others in Bahmni Apps.
How do you experience that the autocomplete is not working for the country address field? For instance if you start typing “Hond”, does it suggest “Honduras”?

This screenshot of yours above suggests that 0 countries were imported, which would explain what you are experiencing of course. Can we see the import CSV file somewhere?