Administering Address Templates

This is a feature in OpenMRS 1.9+

It is possible to configure the fields that appear in the UI and their names, the text box sizes as well as the order they appear in. The configuration instructions on this page tell how to do it.

Managing Address Templates

To get to the address configuration page in OpenMRS you can go to Administration (or System Administration --> Advanced Administration in the Reference Application) --> Manage Address Template.

Templates/Examples

Some example OpenMRS address templates are provided here. You can copy a preferred Address Template from this page and paste into the "Manage Address Template" text box. Feel free to customize to your liking as seen in the screenshot above.

Customizing Templates

You can also build your own templates.

First according to your need, select some address attribute from the table below,

Attribute type

XML Snippet

Attribute type

XML Snippet

address1

<property name="address1" value="Location.address1"/>

address2

<property name="address2" value="Location.address2"/>

address3

<property name="address3" value="Location.neighborhood"/>

address4

<property name="address4" value="Location.division"/>

address5

<property name="address5" value="Location.sublocation"/>

address6

<property name="address6" value="Location.location"/>

cityVillage

<property name="cityVillage" value="Location.cityVillage"/>

countyDistrict

<property name="countyDistrict" value="Location.district"/>

stateProvince

<property name="stateProvince" value="Location.stateProvince"/>

country

<property name="country" value="Location.country"/>

latitude

<property name="latitude" value="Location.latitude"/>

longitude

<property name="longitude" value="Location.longitude"/>

postalCode

<property name="postalCode" value="Location.postalCode"/>

startDate

<property name="startDate" value="PersonAddress.startDate"/>

endDate

<property name="endDate" value="personAddress.endDate"/>

Add these attributes XML in the following format,

<nameMappings class="properties"> <property name="postalCode" value="Location.postalCode"/> <property name="longitude" value="Location.longitude"/> ... others </nameMappings>

Now define the character size for each of the attribute you selected. This is the visible width, in characters, of the input element.
name = Attribute name
value = Number of characters
E.g.

<sizeMappings class="properties"> <property name="postalCode" value="10"/> <property name="longitude" value="10"/> ... others </sizeMappings>

Next, design the layout for your Address Template.
This defines the relative positions of the address attributes to one another

E.g.

<lineByLineFormat> <string>address1</string> <string>address2</string> <string>cityVillage stateProvince country postalCode</string> <string>latitude longitude</string> <string>startDate endDate</string> </lineByLineFormat>

(Optional) You can add default values to the attributes as below,
E.g.

(Optional) You can define which fields are required (since Platform 2.0)

 

(Optional) You can define regular expressions to validate input, and also help the user by giving input suggestions

E.g.
  Regular expressions for validation;

Input suggestions;  These can be used to display an example format that an element should look like.

Finally bundle all the above XMLs as shown below,

For further clarification please go through the samples below,

General Address Template

Address Template for Kenya

Address Template for Lesotho

Address Template for Malawi

Address Template for Rwanda

Address Template for Spain

Address Template for Tanzania

Address Template for USA

 

Address Template for Chile

 

Address Template for Nepal

 

Address Template for Haiti

Snippet

Related pages