Default values for patient address (country) during registration

Is there a way to pre-populate/set a default value for newly registered patient at an address field? E.g. the vast majority of the patients will come from Sierra Leone, only once in a while another country needs to be selected. Therefore it would save data entry time, if Sierra Leone could be preselected (we also use the address hierarchy)

In OpenMRS admin UI, you can go to “Manage Locations”. Open one of you Login Locations. Here you can add default values for address Hierarchy in State/Province field.

Bahmni registration will pick up these values by default if the user logs in using this Location.

Cool. Didn’t know about this features. But it doesn’t seem to work for me.

I only need the first level to be preset, but whatever I try to specify there is not picked up in Bahmni. But I also have changed the address hierarchy structure to match our needs (Country -> State/Province -> Address 2 -> City/Village -> Address), so maybe that’s part of the problem?!?

How do you suggest for me to debug this?

Sorry, I missed one important step. Please take a look at https://bahmni.atlassian.net/wiki/display/BAH/Registration+Page

There is a section called “Pre-fill Address details based on login location”. That should solve your issue.

I did that and I sill can not see the default. So far I’ve specified a default value (Country) through OpenMRS for the Registration location. And then I’ve the added the block below to the app.json.

        "addressHierarchy": {
            "showAddressFieldsTopDown": true,
            "freeTextAddressFields": ["address1"]
        },
        "prepopulateFields" : ["Country"],

I feel like I miss something, but don’t know what and where. Any ideas?

I am not sure why it is not happening. Can you please post you config file somewhere.

As an example, you can also take a look at:

Yes. You can find the app.json here:

Mostly I want to pre-select the first level (from top) of the configured address hierarchy; Country in our case. And I’ve specified the default value in OpenMRS under Manage locations for the login location.

I am not able to figure out the real issue here.

Code to autopopulate address fields is in “CreatePatientController” (https://github.com/Bhamni/openmrs-module-bahmniapps/blob/master/ui/app/registration/controllers/createPatientController.js)

Try to debug “prepopulateFields()” method. This might give you some pointers on why this is not working.

Christian,

On this page (/module/addresshierarchy/admin/manageAddressHierarchy.form), can you share a screenshot?

Thanks, Mike