...
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.Image Removed
...
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 |
---|
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,
...
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.
...
Code Block |
---|
|
<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.
Code Block |
---|
|
<elementDefaults class="properties">
<property name="country" value="Kenya"/>
...
</elementDefaults>
|
(Optional) You can define which fields are required (since Platform 2.0)
Code Block |
---|
|
<requiredElements>
<string>address1</string>
...
</requiredElements>
|
(Optional) You can define regular expressions to validate input, and also help the user by giving input suggestions
...
Code Block |
---|
|
<elementRegex class="properties">
<property name="longitude" value="^(\d{1,3}\s)\d\d\.(\d{2,3})\s*$"/>
<property name="latitude" value="^(\d{1,3}\\s)\d\d\.(\d{2,3})\s*$"/>
...
</elementRegex>
|
Input suggestions;
Input suggestions; These can be used to display an example format that an element should look like.
Code Block |
---|
|
<elementRegexFormats class="properties">
<property name="longitude" value="123 45.000"/>
<property name="latitude" value="123 45.000"/>
...
</elementRegexFormats>
|
...
For further clarification please go through the samples below,
General Address Template
Code Block |
---|
controls | true |
---|
language | xml | title | General Address Template |
---|
|
<org.openmrs.layout.web.address.AddressTemplate>
<nameMappings class="properties">
<property name="postalCode" value="Location.postalCode"/>
<property name="longitude" value="Location.longitude"/>
<property name="address2" value="Location.address2"/>
<property name="address1" value="Location.address1"/>
<property name="startDate" value="PersonAddress.startDate"/>
<property name="country" value="Location.country"/>
<property name="endDate" value="personAddress.endDate"/>
<property name="stateProvince" value="Location.stateProvince"/>
<property name="latitude" value="Location.latitude"/>
<property name="cityVillage" value="Location.cityVillage"/>
</nameMappings>
<sizeMappings class="properties">
<property name="postalCode" value="10"/>
<property name="longitude" value="10"/>
<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="latitude" value="10"/>
<property name="cityVillage" value="10"/>
</sizeMappings>
<lineByLineFormat>
<string>address1</string>
<string>address2</string>
<string>cityVillage stateProvince country postalCode</string>
<string>latitude longitude</string>
<string>startDate endDate</string>
</lineByLineFormat>
</org.openmrs.layout.web.address.AddressTemplate> |
Address Template for Kenya
Code Block |
---|
controls | true |
---|
language | xml | title | Address Template for Kenya |
---|
|
<org.openmrs.layout.web.address.AddressTemplate>
<nameMappings class="properties">
<property name="postalCode" value="Location.postalCode"/>
<property name="longitude" value="Location.longitude"/>
<property name="address3" value="Location.estateNearestCentre"/>
<property name="address2" value="Location.sectionHomestead"/>
<property name="address1" value="Location.address1"/>
<property name="country" value="Location.country"/>
<property name="stateProvince" value="Location.province"/>
<property name="latitude" value="Location.latitude"/>
<property name="address6" value="Location.location"/>
<property name="address5" value="Location.sublocation"/>
<property name="cityVillage" value="Location.townVillage"/>
<property name="countyDistrict" value="Location.district"/>
<property name="address4" value="Location.division"/>
</nameMappings>
<sizeMappings class="properties">
<property name="postalCode" value="6"/>
<property name="longitude" value="10"/>
<property name="address3" value="24"/>
<property name="address2" value="55"/>
<property name="address1" value="55"/>
<property name="country" value="10"/>
<property name="townshipDivision" value="24"/>
<property name="stateProvince" value="24"/>
<property name="subregion" value="24"/>
<property name="latitude" value="10"/>
<property name="region" value="24"/>
<property name="cityVillage" value="24"/>
<property name="countyDistrict" value="24"/>
</sizeMappings>
<elementDefaults class="properties">
<property name="country" value="Kenya"/>
</elementDefaults>
<elementRegex class="properties">
<property name="longitude" value="^(\\d{1,3}\\s)\\d\\d.(\\d{2,3})\\s*$"/>
<property name="latitude" value="^(\\d{1,3}\\s)\\d\\d.(\\d{2,3})\\s*$"/>
</elementRegex>
<elementRegexFormats class="properties">
<property name="longitude" value="123 45.000"/>
<property name="latitude" value="123 45.000"/>
</elementRegexFormats>
<lineByLineFormat>
<string>address1</string>
<string>address2</string>
<string>address3 cityVillage</string>
<string>address5 address6</string>
<string>address4 countyDistrict</string>
<string>stateProvince postalCode</string>
<string>latitude longitude</string>
<string>country</string>
</lineByLineFormat>
</org.openmrs.layout.web.address.AddressTemplate> |
Address Template for Lesotho
Code Block |
---|
controls | true |
---|
language | xml | title | Address Template for Lesotho |
---|
|
<org.openmrs.layout.web.address.AddressTemplate>
<nameMappings class="properties">
<property name="countyDistrict" value="Location.district"/>
<property name="cityVillage" value="Location.village"/>
</nameMappings>
<sizeMappings class="properties">
<property name="countyDistrict" value="40"/>
<property name="cityVillage" value="40"/>
</sizeMappings>
<elementDefaults class="properties">
<property name="country" value="Lesotho"/>
</elementDefaults>
<lineByLineFormat>
<string>countyDistrict</string>
<string>cityVillage</string>
</lineByLineFormat>
</org.openmrs.layout.web.address.AddressTemplate> |
...
Address Template for Malawi
Code Block |
---|
language | xml | title | Address Template for Malawi |
---|
|
<org.openmrs.layout.web.address.AddressTemplate>
<nameMappings class="properties">
<property name="address3" value="Location.neighborhood"/>
<property name="stateProvince" value="Location.district"/>
<property name="address1" value="Location.address1"/>
<property name="countyDistrict" value="Location.traditionalAuthority"/>
<property name="cityVillage" value="Location.village"/>
</nameMappings>
<sizeMappings class="properties">
<property name="address3" value="20"/>
<property name="stateProvince" value="20"/>
<property name="address1" value="40"/>
<property name="countyDistrict" value="20"/>
<property name="cityVillage" value="20"/>
</sizeMappings>
<elementDefaults class="properties">
<property name="country" value="Malawi"/>
</elementDefaults>
<lineByLineFormat>
<string>address1</string>
<string>address3</string>
<string>cityVillage</string>
<string>countyDistrict</string>
<string>stateProvince</string>
</lineByLineFormat>
</org.openmrs.layout.web.address.AddressTemplate> |
Address Template for Rwanda
Code Block |
---|
controls | true |
---|
language | xml |
---|
title | Address Template for Rwandalanguage | xml |
---|
|
<org.openmrs.layout.web.address.AddressTemplate>
<nameMappings class="properties">
<property name="address3" value="Location.cell"/>
<property name="stateProvince" value="Location.province"/>
<property name="address1" value="Location.rwandanNeighborhood"/>
<property name="countyDistrict" value="Location.district"/>
<property name="cityVillage" value="Location.sector"/>
</nameMappings>
<sizeMappings class="properties">
<property name="address3" value="40"/>
<property name="stateProvince" value="40"/>
<property name="address1" value="40"/>
<property name="countyDistrict" value="40"/>
<property name="cityVillage" value="40"/>
</sizeMappings>
<elementDefaults class="properties">
<property name="country" value="Rwanda"/>
</elementDefaults>
<lineByLineFormat>
<string>stateProvince</string>
<string>countyDistrict</string>
<string>cityVillage</string>
<string>address3</string>
<string>address1</string>
</lineByLineFormat>
</org.openmrs.layout.web.address.AddressTemplate> |
Address Template for Spain
Code Block |
controls |
---|
true | language | xml | title | Address Template for Spain |
---|
|
<org.openmrs.layout.web.address.AddressTemplate>
<nameMappings class="properties">
<property name="address2" value="Location.address2"/>
<property name="stateProvince" value="Location.stateProvince"/>
<property name="address1" value="Location.address1"/>
<property name="longitude" value="Location.longitude"/>
<property name="postalCode" value="Location.postalCode"/>
<property name="cityVillage" value="Location.cityVillage"/>
<property name="country" value="Location.country"/>
<property name="latitude" value="Location.latitude"/>
</nameMappings>
<sizeMappings class="properties">
<property name="address2" value="40"/>
<property name="stateProvince" value="10"/>
<property name="address1" value="40"/>
<property name="longitude" value="10"/>
<property name="postalCode" value="10"/>
<property name="cityVillage" value="10"/>
<property name="country" value="10"/>
<property name="latitude" value="10"/>
</sizeMappings>
<lineByLineFormat>
<string>address1</string>
<string>address2</string>
<string>cityVillage stateProvince country postalCode</string>
<string>latitude longitude</string>
</lineByLineFormat>
</org.openmrs.layout.web.address.AddressTemplate> |
Address Template for Tanzania
Code Block |
---|
controls | true |
---|
language | xml | title | Address Template for Tanzania |
---|
|
<org.openmrs.layout.web.address.AddressTemplate>
<nameMappings class="properties">
<property name="address6" value="Location.region"/>
<property name="address5" value="Location.ward"/>
<property name="countyDistrict" value="Location.district"/>
<property name="cityVillage" value="Location.villageStreet"/>
</nameMappings>
<sizeMappings class="properties">
<property name="address6" value="14"/>
<property name="address5" value="22"/>
<property name="countyDistrict" value="17"/>
<property name="cityVillage" value="50"/>
</sizeMappings>
<lineByLineFormat>
<string>cityVillage</string>
<string>address5</string>
<string>countyDistrict</string>
<string>address6</string>
</lineByLineFormat>
</org.openmrs.layout.web.address.AddressTemplate> |
Address Template for USA
Code Block |
---|
controls | true |
---|
language | xml | title | Address Template for USA |
---|
|
<org.openmrs.layout.web.address.AddressTemplate>
<nameMappings class="properties">
<property name="address2" value="Location.address2"/>
<property name="stateProvince" value="Location.state"/>
<property name="address1" value="Location.address1"/>
<property name="postalCode" value="Location.zipCode"/>
<property name="cityVillage" value="Location.city"/>
</nameMappings>
<sizeMappings class="properties">
<property name="address2" value="50"/>
<property name="stateProvince" value="2"/>
<property name="address1" value="50"/>
<property name="postalCode" value="10"/>
<property name="cityVillage" value="20"/>
</sizeMappings>
<elementDefaults class="properties">
<property name="country" value="USA"/>
</elementDefaults>
<lineByLineFormat>
<string>address1</string>
<string>address2</string>
<string>cityVillage stateProvince postalCode</string>
</lineByLineFormat>
</org.openmrs.layout.web.address.AddressTemplate> |
Address Template for Chile
Code Block |
---|
controls | true |
---|
language | html/xml | title | Address Template for Chile |
---|
|
<org.openmrs.layout.web.address.AddressTemplate>
<nameMappings class="properties">
<property name="address3" value="Location.address3"/>
<property name="address2" value="Location.address2"/>
<property name="stateProvince" value="Location.state"/>
<property name="address1" value="Location.address1"/>
<property name="postalCode" value="Location.zipCode"/>
<property name="cityVillage" value="Location.city"/>
<property name="countyDistrict" value="Location.district"/>
</nameMappings>
<sizeMappings class="properties">
<property name="address3" value="10"/>
<property name="address2" value="10"/>
<property name="stateProvince" value="2"/>
<property name="address1" value="50"/>
<property name="postalCode" value="10"/>
<property name="cityVillage" value="20"/>
<property name="countyDistrict" value="20"/>
</sizeMappings>
<elementDefaults class="properties">
<property name="country" value="Chile"/>
</elementDefaults>
<lineByLineFormat>
<string>address1 address2 address3</string>
<string>cityVillage countyDistrict stateProvince country postalCode</string>
</lineByLineFormat>
</org.openmrs.layout.web.address.AddressTemplate> |
Address Template for Nepal
Code Block |
---|
language | xml | title | Address Template for Nepal |
---|
|
<org.openmrs.layout.web.address.AddressTemplate>
<nameMappings class="properties">
<property name="address3" value="Ward Number"/><!--Ward Number-->
<property name="address4" value="Tole"/><!--Tole-->
<property name="address5" value="Landmark"/><!--Landmarks-->
<property name="startDate" value="PersonAddress.startDate"/>
<property name="country" value="Location.country"/>
<property name="endDate" value="personAddress.endDate"/>
<property name="countyDistrict" value="Location.district"/><!--District-->
<property name="cityVillage" value="VDC/Municipality"/><!--VDC/Municipality-->
<property name="stateProvince" value="Zone"/>
</nameMappings>
<sizeMappings class="properties">
<property name="address3" value="40"/>
<property name="address4" value="40"/>
<property name="address5" value="40"/>
<property name="startDate" value="10"/>
<property name="country" value="10"/>
<property name="endDate" value="10"/>
<property name="countyDistrict" value="40"/>
<property name="cityVillage" value="40"/>
<property name="stateProvince" value="40"/>
</sizeMappings>
<elementDefaults class="properties">
<property name="country" value="Nepal"/>
</elementDefaults>
<lineByLineFormat>
<string>stateProvince countyDistrict</string>
<string>cityVillage address3</string>
<string>address4 address5</string>
<string>country</string>
</lineByLineFormat>
</org.openmrs.layout.web.address.AddressTemplate> |
Address Template for Haiti
Code Block |
---|
language | xml | title | Address Template for Haiti |
---|
|
<org.openmrs.layout.web.address.AddressTemplate>
<nameMappings class="properties">
<property name="address2" value="Ri / Nimewo Kay"/>
<property name="address1" value="Lokalite"/>
<property name="country" value="Peyi"/>
<property name="stateProvince" value="Depatman"/>
<property name="cityVillage" value="Komin"/>
<property name="countyDistrict" value="Seksyon Riral"/>
</nameMappings>
<sizeMappings class="properties">
<property name="address2" value="40"/>
<property name="address1" value="40"/>
<property name="country" value="40"/>
<property name="stateProvince" value="40"/>
<property name="cityVillage" value="40"/>
<property name="countyDistrict" value="40"/>
</sizeMappings>
<lineByLineFormat>
<string>country</string>
<string>stateProvince</string>
<string>cityVillage</string>
<string>countyDistrict</string>
<string>address1</string>
<string>address2</string>
</lineByLineFormat>
</org.openmrs.layout.web.address.AddressTemplate> |
Snippet