Customize Address Hierarchy

Dears,

i am trying to customize Address hierarchy in registration Page in Bahmni as i understand from document ion i have Logged in Manage Address Template and edit template as below but after logging to address hierarchy map to map this fields to their labels the fields that i identified in manage address template not appeared

<org.openmrs.layout.address.AddressTemplate> address1 address2 countyDistrict city postalCode country startDate endDate </org.openmrs.layout.address.AddressTemplate>

here is configuration:

Does any one have clue how can i do that ?

thanks

Hi @ahmedkhalil, If you look at the OpenMRS Address Template WIKi, the address attributes needs to be picked up from the list given in the below table. Please change < property name=“city” value=“Location.city” /> to < property name=“cityVillage” value=“Location.cityVillage” / >

please check my first reply in the post you will see that i have already picked parameters from this table and change it from openmrs admin page and still not populated in List

Please change city to cityVillage. city is not present in OpenMRS given list.

ok but i don’t want to have village i need to have city

cityVillage is type of Attribute. So it can’t be changed. We can’t change it thats what is explained in openmrs documentation.

can i change alias of cityvillage to city ?

yes. Please use the below.

Please take a look at the examples given in OpenMRS WIKI. Its very clear that name denotes which attribute type it is and the value will be the label.

i have changed it as below but give me error in invalid

bahmni.docx (1.4 KB)

Hi @swathivarkala,

I’m facing similar problems with this, I have my Custom Address Hierarchy Template:

<org.openmrs.layout.address.AddressTemplate>
    <nameMappings class="properties">
      <property name="countyDistrict" value="Departamento.countyDistrict"/>
      <property name="longitude" value="Enteros o Decimales" />
      <property name="address2" value="NumCasa.address2"/>
      <property name="address3" value="Calle.address3"/>
      <property name="address6" value="Bloque.address6"/>
      <property name="address5" value="Dirección.address5"/>
      <property name="address4" value="Residencia.address4"/>
      <property name="startDate" value="PersonAddress.startDate"/>
      <property name="country" value="Pais.country"/>
      <property name="endDate" value="personAddress.endDate"/>
      <property name="stateProvince" value="Municipio.stateProvince"/>
      <property name="latitude" value="Enteros o Decimales" />
      <property name="cityVillage" value="Ciudad.cityVillage"/>
    </nameMappings>
    <sizeMappings class="properties">
      <property name="address2" value="40"/>
      <property name="address1" value="40"/>
      <property name="startDate" value="10"/>
      <property name="country" value="10"/>
      <property name="endDate" value="10"/>
      <property name="stateProvince" value="10"/>
      <property name="cityVillage" value="10"/>
    </sizeMappings>
    <elementRegex class="properties">
       <property name="longitude" value="^-?\d*\.?\d+$"/>
       <property name="latitude" value="^-?\d*\.?\d+$"/>
     </elementRegex>
    <elementDefaults class="properties">
         <property name="country" value="Honduras"/>
    </elementDefaults>
    <lineByLineFormat>
      <string>address1</string>
      <string>address4</string>
      <string>cityVillage stateProvince country countyDistrict</string>
      <string>latitude longitude</string>
      <string>startDate endDate</string>
    </lineByLineFormat>
  </org.openmrs.layout.address.AddressTemplate>  

As you notice I added a <elementRegex> Tag for Latitude/Longitude, but is not working i’m still able to add Text instead of just Numbers or Floats.

Any help?

I’m almost certain that this tag of the address template is not consumed by Bahmni. Long story short Bahmni obtains the address levels from the Address Hierarchy (AH) module. In turns AH consumes the address template to map address levels to address fields.

For the UI to impose a regex on certain address fields it would require to be handled by Bahmni Apps (as it is done with patient identifiers for example.) I am not sure if this is supported through the config for address fields.

@binduak, @shruthipitta @angshuonline, thoughts?

Hi @mksd, thanks for your reply. Yes you can impose a regex on Address Hierarchy fields using bahmni_config/apps/registration/attributesConditions.js

Steps I followed:

  1. Added an Address Hierarchy Templates where I use a field like this <property name="longitude" value="Numbers or Decimals" /> and <property name="latitude" value="Numbers o Decimals" />

  2. Inside bahmni_config/apps/registration/attributesConditions.js added:

     Bahmni.Registration.customValidator = {
      ...
       "address.latitude": {
         method: function (name, value, personAttributeDetails) {
           return value.match(/^-?\d*\.?\d+$/);
         },
         errorMessage: "REGISTRATION_ADDRESS_WORK_LATITUDE_TEXT_ERROR_KEY"
       },
       "address.longitude": {
         method: function (name, value, personAttributeDetails) {
           return value.match(/^-?\d*\.?\d+$/);
         },
         errorMessage: "REGISTRATION_ADDRESS_WORK_LATITUDE_TEXT_ERROR_KEY"
       }
      ...
     };
    

And that worked for me!

1 Like

Thanks for sharing @cristian!