/
Customizing Address Layouts

Customizing Address Layouts

This page is outdated and no longer receives updates!

There are certain address layouts that come with OpenMRS right now, they are: general, kenya, lestho, malawi, rwanda, tanzania, usa . 

You can modify the layout.address.format  setting (formerly global property from platform 1.8 downwards) to one of those values or to the "codeName" of a new custom layout (instructions below) to see a different address/location layout on the new patient screen and location editor.

Adding a new address layout

Address layouts are stored in the openmrs-servlet.xml file.  You can find this file in tomcathome/webapps/openmrs/WEB-INF/lib/openmrs-web...jar/openmrs-servlet.xml .

In the <bean id="addressSupport" element, add <ref bean="addressTemplateCustomized" /> .

Now after the next </bean> tag, add:

<bean id="addressTemplateCustomized" class="org.openmrs.layout.web.address.AddressTemplate"> <property name="displayName"><value>My custom address layout format</value></property> <property name="codeName"><value>custom</value></property> <property name="country"><value>My Country Name</value></property> <property name="nameMappings"> <props> <prop key="postalCode">Location.postalCode</prop> <prop key="stateProvince">Location.stateProvince</prop> <prop key="cityVillage">Location.cityVillage</prop> <prop key="address1">Location.address1</prop> <prop key="address2">Location.address2</prop> <prop key="longitude">Location.longitude</prop> <prop key="latitude">Location.latitude</prop> <prop key="country">Location.country</prop> <prop key="countyDistrict">Location.district</prop> <prop key="neighborhoodCell">Location.cell</prop> <prop key="subregion">Location.sublocation</prop> <prop key="region">Location.location</prop> </props> </property> <property name="sizeMappings"> <props> <prop key="postalCode">10</prop> <prop key="stateProvince">10</prop> <prop key="cityVillage">10</prop> <prop key="address1">40</prop> <prop key="address2">40</prop> <prop key="longitude">10</prop> <prop key="latitude">10</prop> <prop key="country">10</prop> </props> </property> <property name="lineByLineFormat"> <list> <value>address1</value> <value>address2</value> <value>cityVillage stateProvince country postalCode</value> <value>latitude longitude</value> </list> </property> </bean>

Change the nameMappings, sizeMappings, and lineByLineFormat elements however you like.  Restart Tomcat to use the new address.

e.g. if you want to rename the "cityVillage" field, you change <prop key="cityVillage">Location.cityVillage</prop> to <prop key="cityVillage">Location.city</prop> or even to <prop key="cityVillage">What's your city:</prop>. (see messages.properties file for available translation elements)

e.g. if you want to not show latitude/longitude, you delete the lineByLineFormat line: <value>latitude longitude</value>

e.g. if you want to have a longer address1 line, you modify <prop key="address1">40</prop> to be <prop key="address1">80</prop>

These changes will be persisted across restarts, but will NOT be persisted across upgrades.  You will have to redo this every time you upgrade openmrs to a new version

Note: This functionality will change in OpenMRS 1.9+.  Please see the documentation on Address Templates.

Related content

Administering Address Templates
Administering Address Templates
More like this
Customizing Name Layouts
Customizing Name Layouts
More like this
3.x Address Hierarchy Widget
3.x Address Hierarchy Widget
More like this
Address hierarchy user guide (Prior version)
Address hierarchy user guide (Prior version)
More like this
Address Hierarchy Module
Address Hierarchy Module
More like this
Address Hierarchy Rwanda Module
Address Hierarchy Rwanda Module
More like this