Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

Some recommended OpenMRS address templates are provided here;
Please copy past your preferred Address Template to the "Address Template xml" textbox in the /admin/locations/addressTemplate.form

...

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 according to your country.

First according to your need, select some address attribute form the Table bellow:from the table below,

Attribute type

xml

XML Snippet

address1

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

address2

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

address3

<property name="address3" value="Location.

address3

neighborhood"/>

address4

<property name="address4" value="Location.

address4

division"/>

address5

<property name="address5" value="Location.

address5

sublocation"/>

address6

<property name="address6" value="Location.

address6

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 atribut sets attributes XML in the XML as followsfollowing format,

Code Block
languagexml

	<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
Name = attribute This is the visible width, in characters, of the input element.
name = Attribute name
value = Number of charecterscharacters
E.g.

Code Block
languagexml

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

Next, design the layout of for your Address Template.
This defines the top to bottom and left to right order relative positions of the address attributes to one another

E.g.

Code Block
languagexml

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

(OPtionalOptional) You can add default values for to the attribute attributes as bellowbelow,
E.g.

Code Block
languagexml

     <elementDefaults class="properties">
  <elementDefaults>             <property name="country" value="Kenya"/>
            ...
        </elementDefaults>

(OPtionalOptional) You can define Reguler expressions to validate input, and also help the user by giving input sugessionsE.g.
Reguler expressions to validation;which fields are required (since Platform 2.0)

Code Block
languagexml
<requiredElements>
        <elementRegex>    <string>address1</string>
        <property name="longitude" value="^(\\d{1,3}\\s)\\d\\d.(\\d{2,3})\\s*$"/>
   ...
          <property name="latitude</requiredElements>

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

E.g.
  Regular expressions for validation;

Code Block
languagexml
<elementRegex class="properties">
            <property name="longitude" value="^(\\d{1,3}\\s)\d\d\\d.(\\d{2,3})\\s*$"/>
            ...
        <property name="latitude" value="^(\d{1,3}\\s)\d\d\.(\d{2,3})\s*$"/>
            ...
        </elementRegex>

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

Code Block
languagexml

 <elementRegexFormats class="properties">
      <elementRegexFormats>             <property name=<property name="longitude" value="123 45.000"/>
            <property name="latitude" value="123 45.000"/>
            ...
        </elementRegexFormats>

Fianly you can Finally bundle all in one xml asthe above XMLs as shown below,

Code Block
languagexml

   <org.openmrs.layout.web.address.AddressTemplate>
   <addressTemplate>             <nameMappings class="properties">
                <property name="postalCode" value="Location.postalCode"/>
	        ...
            </nameMappings>
            <sizeMappings class="properties">
                <property name="postalCode" value="10"/>
                ...
            </sizeMappings>
            <lineByLineFormat>
                <string>address1</string>
                <string>address2</string>
                ...
            </lineByLineFormat>
            ...
            ...
        </addressTemplate>org.openmrs.layout.web.address.AddressTemplate>

For further clarification please go through the samples bellowbelow,

Anchor
General
General

General Address Template
Code Block
controlstrue
languagexml
titleGeneral Address Template
    <addressTemplate><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>
    </addressTemplate>org.openmrs.layout.web.address.AddressTemplate>

Anchor
Kenya
Kenya

Address Template for Kenya
Code Block
controlstrue
languagexml
titleAddress Template for Kenya
<org.openmrs.layout.web.address.AddressTemplate>
   <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*$"/>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>

Anchor
Lesotho
Lesotho

Address Template for Lesotho
Code Block
languagexml
<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>

Anchor
Malawi
Malawi

Address Template for Malawi
Code Block
languagexml
<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>

Anchor
Rwanda
Rwanda

Address Template for Rwanda
Code Block
languagexml
<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</elementRegex>string>
        <elementRegexFormats class="properties"></lineByLineFormat>
    </org.openmrs.layout.web.address.AddressTemplate>

Anchor
Spain
Spain

Address Template for Spain
Code Block
languagexml
<org.openmrs.layout.web.address.AddressTemplate>
        <property<nameMappings nameclass="longitude" value="123 45.000"/properties">
            <property name="latitudeaddress2" value="123 45Location.000address2"/>
        </elementRegexFormats>    <property name="stateProvince" value="Location.stateProvince"/>
  <lineByLineFormat>          <property   <string>address1</string>name="address1" value="Location.address1"/>
            <string>address2</string>
            <string>address3 cityVillage</string>
            <string>address5 address6</string><property name="longitude" value="Location.longitude"/>
            <property <string>address4 countyDistrict</string>name="postalCode" value="Location.postalCode"/>
            <string>stateProvince postalCode</string><property name="cityVillage" value="Location.cityVillage"/>
            <property <string>latitude longitude</string>name="country" value="Location.country"/>
            <string>country</string>
        </lineByLineFormat><property name="latitude" value="Location.latitude"/>
    </addressTemplate>

...

Code Block
controlstrue
languagexml
titleAddress Template for Lesotho
    <addressTemplate></nameMappings>
        <nameMappings<sizeMappings class="properties">
            <property name="countyDistrictaddress2" value="Location.district40"/>
            <property name="cityVillagestateProvince" value="Location.village10"/>
          </nameMappings>   <property name="address1" value="40"/>
            <sizeMappings class<property name="longitude" value="properties10"/>
            <property name="countyDistrictpostalCode" value="4010"/>
            <property name="cityVillage" value="4010"/>
        </sizeMappings>    <property     <elementDefaults classname="country" value="properties10"/>
            <property name="countrylatitude" value="Lesotho10"/>
        </elementDefaults>sizeMappings>
        <lineByLineFormat>
            <string>countyDistrict<<string>address1</string>
            <string>cityVillage<<string>address2</string>
    
   </lineByLineFormat>     </addressTemplate>

...

Code Block
controlstrue
languagexml
titleAddress Template for Malawi
    <addressTemplate>
        <nameMappings class="properties">     <string>cityVillage stateProvince country postalCode</string>
    <property  name="address3" value="Location.neighborhood"/>     <string>latitude longitude</string>
      <property name="stateProvince" value="Location.district"/>
   </lineByLineFormat>
    </org.openmrs.layout.web.address.AddressTemplate>

Anchor
Tanzania
Tanzania

Address Template for Tanzania
Code Block
languagexml
<org.openmrs.layout.web.address.AddressTemplate>
        <nameMappings <property nameclass="address1" value="Location.address1"/properties">
            <property name="countyDistrictaddress6" value="Location.traditionalAuthorityregion"/>
            <property name="cityVillageaddress5" value="Location.villageward"/>
       
</nameMappings>         <sizeMappings class="properties">             <property name="address3countyDistrict" value="20Location.district"/>
            <property name="stateProvincecityVillage" value="20Location.villageStreet"/>
        </nameMappings>
    <property name="address1" value="40"/    <sizeMappings class="properties">
            <property name="countyDistrictaddress6" value="2014"/>
            <property name="cityVillageaddress5" value="2022"/>
        </sizeMappings>    <property     <elementDefaults classname="countyDistrict" value="properties17"/>
            <property name="countrycityVillage" value="Malawi50"/>
        </elementDefaults>sizeMappings>
        <lineByLineFormat>
            <string>address1<<string>cityVillage</string>
            <string>address3<<string>address5</string>

           <string>cityVillage</string>             <string>countyDistrict</string>
            <string>stateProvince<<string>address6</string>
        </lineByLineFormat>
    </addressTemplate>org.openmrs.layout.web.address.AddressTemplate>

Anchor
RwandaRwandaUSA
USA

Address Template for USA
Code Block
controlstrue
languagexml
titleAddress Template for Rwanda
    <addressTemplate><org.openmrs.layout.web.address.AddressTemplate>
        <nameMappings class="properties">
            <property name="address3address2" value="Location.celladdress2"/>
            <property name="stateProvince" value="Location.provincestate"/>
            <property name="address1" value="Location.rwandanNeighborhoodaddress1"/>
            <property name="countyDistrictpostalCode" value="Location.districtzipCode"/>
            <property name="cityVillage" value="Location.sectorcity"/>
        </nameMappings>
        <sizeMappings class="properties">
            <property name="address3address2" value="4050"/>
            <property name="stateProvince" value="402"/>
            <property name="address1" value="4050"/>
            <property name="countyDistrictpostalCode" value="4010"/>
            <property name="cityVillage" value="4020"/>
        </sizeMappings>
        <elementDefaults class="properties">
            <property name="country" value="RwandaUSA"/>
        </elementDefaults>
        <lineByLineFormat>
            <string>stateProvince<<string>address1</string>
            <string>countyDistrict<<string>address2</string>
            <string>cityVillage</string><string>cityVillage             <string>address3<stateProvince postalCode</string>
            <string>address1</string></lineByLineFormat>
        </lineByLineFormat>
    </addressTemplate>

...

Code Block
controlstrue
languagexml
titleAddress Template for Spain
    <addressTemplate>
  </org.openmrs.layout.web.address.AddressTemplate>

Anchor
Chile
Chile

Address Template for Chile
Code Block
languagehtml/xml
<org.openmrs.layout.web.address.AddressTemplate>
         <nameMappings class="properties">
            <property name="address2address3" value="Location.address2address3"/>
            <property name="stateProvinceaddress2" value="Location.stateProvinceaddress2"/>
            <property name="address1stateProvince" value="Location.address1state"/>
            <property name="longitudeaddress1" value="Location.longitudeaddress1"/>
            <property name="postalCode" value="Location.postalCodezipCode"/>
            <property name="cityVillage" value="Location.cityVillagecity"/>
			<property name="countyDistrict" value="Location.district"/>
	 	</nameMappings>
        <property<sizeMappings nameclass="country" value="Location.country"/properties">
            <property name="latitudeaddress3" value="Location.latitude10"/>
        </nameMappings>    <property     <sizeMappings classname="address2" value="properties10"/>
            <property name="address2stateProvince" value="402"/>
            <property name="stateProvinceaddress1" value="1050"/>
            <property name="address1postalCode" value="4010"/>
            <property name="longitudecityVillage" value="1020"/>
            <property name="postalCodecountyDistrict" value="1020"/>
        </sizeMappings>
    <property name="cityVillage" value="10"/    <elementDefaults class="properties">
            <property name="country" value="10Chile"/>
        </elementDefaults>
        <lineByLineFormat>
			<string>address1 address2 address3</string>
			<string>cityVillage countyDistrict <property name="latitude" value="10"/>stateProvince country postalCode</string>
        </sizeMappings>lineByLineFormat>
    </org.openmrs.layout.web.address.AddressTemplate>

Anchor
Nepal
Nepal

Address Template for Nepal
Code Block
languagexml
<org.openmrs.layout.web.address.AddressTemplate>
    <lineByLineFormat>
<nameMappings class="properties">
      <property name="address3"    <string>address1</string>
value="Ward Number"/><!--Ward Number-->
      <property     <string>address2</string>
            <string>cityVillage stateProvince country postalCode</string>
    name="address4" value="Tole"/><!--Tole-->
	  <property name="address5" value="Landmark"/><!--Landmarks-->
      <property name="startDate" value="PersonAddress.startDate"/>
      <property <string>latitude longitude</string>name="country" value="Location.country"/>
      <property  </lineByLineFormat>
    </addressTemplate>

...

Code Block
controlstrue
languagexml
titleAddress Template for Tanzania
    <addressTemplate>name="endDate" value="personAddress.endDate"/>
      <property    <nameMappings class="properties"name="countyDistrict" value="Location.district"/><!--District-->
      <property name="cityVillage" value="VDC/Municipality"/><!--VDC/Municipality-->
      <property name="address6stateProvince" value="Location.regionZone"/>
    </nameMappings>
    <sizeMappings class="properties">
      <property name="address5address3" value="Location.ward40"/>
     
      <property name="countyDistrictaddress4" value="Location.district40"/>
       	     <property name="cityVillageaddress5" value="Location.villageStreet40"/>
      <property  </nameMappings>name="startDate" value="10"/>
      <property  <sizeMappings classname="country" value="properties10"/>
    
       <property name="address6endDate" value="1410"/>
            <property name="address5countyDistrict" value="2240"/>
            <property name="countyDistrictcityVillage" value="1740"/>
     
      <property name="cityVillagestateProvince" value="5040"/>
        </sizeMappings>
	<elementDefaults class="properties">
      <lineByLineFormat><property name="country"            <string>cityVillage</string>value="Nepal"/>
	</elementDefaults>
    <lineByLineFormat>
      <string>stateProvince <string>address5<countyDistrict</string>
	  <string>cityVillage address3</string>
	        <string>countyDistrict<<string>address4 address5</string>
            <string>address6<<string>country</string>
        </lineByLineFormat>
    </addressTemplate></org.openmrs.layout.web.address.AddressTemplate>

Anchor
USAUSAHaiti
Haiti

Address Template for Haiti
Code Block
controlstrue
languagexml
titleAddress Template for USA
<org.openmrs.layout.web.address.AddressTemplate>
   <addressTemplate>         <nameMappings class="properties">
  
         <property name="address2" value="Location.address2Ri / Nimewo Kay"/>
            <property name="stateProvinceaddress1" value="Location.stateLokalite"/>
            <property name="address1country" value="Location.address1Peyi"/>
    
       <property name="postalCodestateProvince" value="Location.zipCodeDepatman"/>
    
       <property name="cityVillage" value="Location.cityKomin"/>
        </nameMappings>
        <sizeMappings class="properties"<property name="countyDistrict" value="Seksyon Riral"/>
     </nameMappings>
     <sizeMappings <property nameclass="address2" value="50"/>
properties">
           <property name="stateProvinceaddress2" value="240"/>
  
         <property name="address1" value="5040"/>
            <property name="postalCodecountry" value="1040"/>
    
       <property name="cityVillagestateProvince" value="2040"/>
        </sizeMappings>
        <elementDefaults class="properties">
    <property name="cityVillage" value="40"/>
       <property name="countrycountyDistrict" value="USA40"/>
        </elementDefaults>sizeMappings>
     <lineByLineFormat>
  <lineByLineFormat>     <string>country</string>
       <string>address1<<string>stateProvince</string>
       <string>cityVillage</string>
       <string>address2<<string>countyDistrict</string>
       <string>address1</string>
    <string>cityVillage  stateProvince postalCode<<string>address2</string>
        </lineByLineFormat>

   </addressTemplate>org.openmrs.layout.web.address.AddressTemplate>

Snippet