Wiki Spaces

Documentation
Projects
Resources

Get Help from Others

Q&A: Ask OpenMRS
Discussion: OpenMRS Talk
Real-Time: IRC Chat | Slack

Documentation

Page tree
Skip to end of metadata
Go to start of metadata

There are certain name layouts that come with OpenMRS right now, they are: short (default), long, givenfamily, latinamerica and spain. 

You can modify the layout.name.format  setting  (formerly global property from platform 1.8 downwards) to one of those values or to the "codeName" of a new custom layout (instructions below) to see a different name layout.

Description of existing name layouts

These are the name layouts that come with OpenMRS. The following table shows which items are contained in each of them (they are ordered from shortest to longest).

 

codePrefixGiven NameMiddle NameFamily Name PrefixFamily NameFamily Name 2Family Name SuffixDegree 
givenfamily X  X   
short  XX X   
spain  X  XX  
latinamerica  XX X  
long 

Adding a new Name Layout

Name layouts are stored in the openmrs-servlet.xml file. You can find this file in tomcathome/webapps/openmrs/WEB-INF/lib/openmrs-web...jar/openmrs-servlet.xml .

In the <bean id="nameSupport" element, add <ref bean="nameTemplateCustomized" /> .

Now after the next </bean> tag, add:

<bean id="nameTemplateCustomized" class="org.openmrs.layout.web.name.NameTemplate">
	<property name="displayName"><value>My custom name layout format</value></property>
	<property name="codeName"><value>custom</value></property>
	<property name="nameMappings">
		<props>
			<prop key="prefix">PersonName.prefix</prop>
			<prop key="givenName">PersonName.givenName</prop>
			<prop key="middleName">PersonName.middleName</prop>
			<prop key="familyNamePrefix">PersonName.familyNamePrefix</prop>
			<prop key="familyName">PersonName.familyName</prop>
			<prop key="familyName2">PersonName.familyName2</prop>
			<prop key="familyNameSuffix">PersonName.familyNameSuffix</prop>
			<prop key="degree">PersonName.degree</prop>
	</props>
	</property>
	<property name="sizeMappings">
		<props>
			<prop key="prefix">5</prop>
			<prop key="givenName">30</prop>
			<prop key="middleName">30</prop>
			<prop key="familyNamePrefix">8</prop>
			<prop key="familyName">25</prop>
			<prop key="familyName2">25</prop>
			<prop key="familyNameSuffix">8</prop>
			<prop key="degree">5</prop>
		</props>
	</property>
	<property name="lineByLineFormat">
		<list>
			<value>prefix</value>
			<value>givenName</value>
			<value>middleName</value>
			<value>familyNamePrefix familyName familyName2 familyNameSuffix</value>
			<value>degree</value>
		</list>
	</property>
</bean>

Change the nameMappings, sizeMappings, and lineByLineFormat elements however you like.  Restart Tomcat to use the new name layout.

e.g. if you want to not show degree, you delete the lineByLineFormat line: <value>degree</value>

e.g. if you want to have a longer givenName, you modify <prop key="givenName">30</prop> to be <prop key="givenName">50</prop>

  • No labels