...
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,
xmlXML Snippet |
---|
address1 | <property name="address1" value="Location.address1"/> |
address2 | <property name="address2" value="Location.address2"/> |
address3 | <property name="address3" value="Location. |
address3neighborhood"/> |
address4 | <property name="address4" value="Location. |
address4division"/> |
address5 | <property name="address5" value="Location. |
address5sublocation"/> |
address6 | <property name="address6" value="Location. |
address6location"/> |
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 follows following format,
Code Block |
---|
language | xml |
---|
title | General Address Template |
---|
|
<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 |
---|
language | xml | title | General Address Template |
---|
|
<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 |
---|
language | xml | title | General Address Template |
---|
|
<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 |
---|
language | xml |
---|
title | General Address Template |
---|
|
<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 |
---|
language | xml |
---|
title | General Address Template |
---|
|
<requiredElements>
<elementRegex> <string>address1</string>
<property name="longitude" value="^(\ ...
</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 |
---|
|
<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>
|
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>
|
Finally bundle all the above XMLs as shown below,
Code Block |
---|
|
<org.openmrs.layout.web.address.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>
...
...
</org.openmrs.layout.web.address.AddressTemplate>
|
For further clarification please go through the samples below,
General Address Template
Code Block |
---|
|
<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 |
---|
|
<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="latitudepostalCode" value="^(\\d{1,3}\\s)\\d\\d.(\\d{2,3})\\s*$6"/>
...
<property name="longitude" value="10"/>
</elementRegex>
|
Input sugessions;
Code Block |
---|
language | xml |
---|
title | General Address Template |
---|
|
<elementRegexFormats><property name="address3" value="24"/>
<property name="longitudeaddress2" value="123 45.00055"/>
<property name="latitudeaddress1" value="123 45.00055"/>
...<property name="country" value="10"/>
<property </elementRegexFormats>
|
Fianly you can bundle all in one xml as
Code Block |
---|
language | xml |
---|
title | General Address Template |
---|
|
<addressTemplate>name="townshipDivision" value="24"/>
<property <nameMappings classname="stateProvince" value="properties24"/>
<property name="postalCodesubregion" value="Location.postalCode24"/>
... <property </nameMappings>name="latitude" value="10"/>
<property <sizeMappings classname="region" value="properties24"/>
<property name="postalCodecityVillage" value="1024"/>
...<property name="countyDistrict" value="24"/>
</sizeMappings>
<elementDefaults class="properties">
<lineByLineFormat> <property <string>address1</string>name="country" value="Kenya"/>
</elementDefaults>
<string>address2</string> <elementRegex class="properties">
... </lineByLineFormat><property name="longitude" value="^(\\d{1,3}\\s)\\d\\d.(\\d{2,3})\\s*$"/>
... <property ...
</addressTemplate>
|
Please reffer the sample for further clarication
...
Code Block |
---|
controls | true |
---|
language | xml |
---|
title | General Address Template |
---|
|
<addressTemplate>name="latitude" value="^(\\d{1,3}\\s)\\d\\d.(\\d{2,3})\\s*$"/>
</elementRegex>
<nameMappings class="properties"> <property name<elementRegexFormats class="postalCode" value="Location.postalCode"/properties">
<property name="longitude" value="Location123 45.longitude000"/>
<property name="address2latitude" value="Location123 45.address2000"/>
<property name="address1" value="Location.address1"/></elementRegexFormats>
<lineByLineFormat>
<property name="startDate" value="PersonAddress.startDate"/> <string>address1</string>
<property name="country" value="Location.country"/> <string>address2</string>
<property name="endDate" value="personAddress.endDate"/> <string>address3 cityVillage</string>
<property name="stateProvince" value="Location.stateProvince"/>
<string>address5 address6</string>
<property name="latitude" value="Location.latitude"/> <string>address4 countyDistrict</string>
<string>stateProvince postalCode</string>
<property name="cityVillage" value="Location.cityVillage"/> <string>latitude <longitude</nameMappings>string>
<sizeMappings class="properties">
<string>country</string>
</lineByLineFormat>
<property name="postalCode" value="10"/> </org.openmrs.layout.web.address.AddressTemplate> |
Address Template for Lesotho
Code Block |
---|
|
<org.openmrs.layout.web.address.AddressTemplate>
<property name="longitude" value="10"/<nameMappings class="properties">
<property name="address2countyDistrict" value="40Location.district"/>
<property name="address1cityVillage" value="40Location.village"/>
<property name="startDate" value="10"/></nameMappings>
<property name="country" value="10"/<sizeMappings class="properties">
<property name="endDatecountyDistrict" value="1040"/>
<property name="stateProvincecityVillage" value="1040"/>
</sizeMappings>
<property name="latitude" value<elementDefaults class="10properties"/>
<property name="cityVillagecountry" value="10Lesotho"/>
</sizeMappings>elementDefaults>
<lineByLineFormat>
<string>address1<<string>countyDistrict</string>
<string>address2<<string>cityVillage</string>
</lineByLineFormat>
<string>cityVillage stateProvince country postalCode</string>
</org.openmrs.layout.web.address.AddressTemplate> |
Address Template for Malawi
Code Block |
---|
|
<org.openmrs.layout.web.address.AddressTemplate>
<nameMappings class="properties">
<string>latitude longitude</string> <property <string>startDate endDate</string>name="address3" value="Location.neighborhood"/>
</lineByLineFormat> <property </addressTemplate> |
...
Code Block |
---|
controls | true |
---|
language | xml |
---|
title | Address Template for Kenya |
---|
|
name="stateProvince" value="Location.district"/>
<addressTemplate> <property <nameMappings classname="address1" value="propertiesLocation.address1"/>
<property name="postalCodecountyDistrict" value="Location.postalCodetraditionalAuthority"/>
<property name="longitudecityVillage" value="Location.longitudevillage"/>
</nameMappings>
<property name="address3" value="Location.estateNearestCentre"/ <sizeMappings class="properties">
<property name="address2address3" value="Location.sectionHomestead20"/>
<property name="address1stateProvince" value="Location.address120"/>
<property name="countryaddress1" value="Location.country40"/>
<property name="stateProvincecountyDistrict" value="Location.province20"/>
<property name="latitudecityVillage" value="Location.latitude20"/>
</sizeMappings>
<property name="address6" value="Location.location"/ <elementDefaults class="properties">
<property name="address5country" value="Location.sublocationMalawi"/>
</elementDefaults>
<property name="cityVillage" value="Location.townVillage"/> <lineByLineFormat>
<property name="countyDistrict" value="Location.district"/> <string>address1</string>
<string>address3</string>
<property name="address4" value="Location.division"/> </nameMappings><string>cityVillage</string>
<string>countyDistrict</string>
<sizeMappings class="properties"> <string>stateProvince</string>
<property name="postalCode" value="6"/> </lineByLineFormat>
</org.openmrs.layout.web.address.AddressTemplate> |
Address Template for Rwanda
Code Block |
---|
|
<org.openmrs.layout.web.address.AddressTemplate>
<property name="longitude" value<nameMappings class="10properties"/>
<property name="address3" value="24Location.cell"/>
<property name="address2stateProvince" value="55Location.province"/>
<property name="address1" value="55Location.rwandanNeighborhood"/>
<property name="countrycountyDistrict" value="10Location.district"/>
<property name="townshipDivisioncityVillage" value="24Location.sector"/>
</nameMappings>
<property name="stateProvince" value<sizeMappings class="24properties"/>
<property name="subregionaddress3" value="2440"/>
<property name="latitudestateProvince" value="1040"/>
<property name="regionaddress1" value="2440"/>
<property name="cityVillagecountyDistrict" value="2440"/>
<property name="countyDistrictcityVillage" value="2440"/>
</sizeMappings>
<elementDefaults class="properties">
<property name="country" value="KenyaRwanda"/>
</elementDefaults>
<elementRegex class="properties"><lineByLineFormat>
<property name="longitude" value="^(\\d{1,3}\\s)\\d\\d.(\\d{2,3})\\s*$"/><string>stateProvince</string>
<string>countyDistrict</string>
<string>cityVillage</string>
<property name="latitude" value="^(\\d{1,3}\\s)\\d\\d.(\\d{2,3})\\s*$"/> <string>address3</string>
<<string>address1</elementRegex>string>
<elementRegexFormats class="properties"></lineByLineFormat>
</org.openmrs.layout.web.address.AddressTemplate> |
Address Template for Spain
Code Block |
---|
|
<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 |
---|
controls | true |
---|
language | xml |
---|
title | Address 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 |
---|
controls | true |
---|
language | xml |
---|
title | Address 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> |
Address Template for Tanzania
Code Block |
---|
|
<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> |
Address Template for USA
Code Block |
---|
controls | true |
---|
language | xml |
---|
title | Address 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 |
---|
controls | true |
---|
language | xml |
---|
title | Address Template for Spain |
---|
|
<addressTemplate>
</org.openmrs.layout.web.address.AddressTemplate> |
Address Template for Chile
Code Block |
---|
|
<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> |
Address Template for Nepal
Code Block |
---|
|
<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 |
---|
controls | true |
---|
language | xml |
---|
title | Address 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> |
Address Template for Haiti
Code Block |
---|
controls | true |
---|
language | xml |
---|
title | Address 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