Versions Compared

Key

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

...

Customizing Templates

You can also build your own templates.

...

Add these attributes XML in the following 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 name
value = Number of characters
E.g.

Code Block
languagexml

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

...

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>

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

Code Block
languagexml

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

...

E.g.
  Regular expressions for validation;

Code Block
languagexml

<elementRegex>
            <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;

Code Block
languagexml

<elementRegexFormats>
            <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
languagexml

<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>

...

Code Block
controlstrue
languagexml
titleAddress 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>

Anchor
USA
USA

Code Block
controlstrue
languagexml
titleAddress Template for USA
<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.address3"/>
            <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"/>
            <property name="countyDistrict" value="Location.district"/>
        </nameMappings>
        <sizeMappings class="properties">
            <property name="postalCode" value="10"/>
            <property name="longitude" value="10"/>
            <property name="address3" value="10"/>
			<property name="address2" value="10"/>
            <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 address2 address3</string>
            <string>cityVillage countyDistrict stateProvince country postalCode</string>
            <string>latitude longitude</string>
            <string>startDate endDate</string>
        </lineByLineFormat>
    </org.openmrs.layout.web.address.AddressTemplate>

Anchor
Chile
Chile

Code Block
controlstrue
languagexml
titleAddress 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>

...