Versions Compared

Key

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

There are certain name layouts that come with OpenMRS right now, they are: short (default), long, givenfamily, latinamerica and spain.  These 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 .

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.

...

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

...

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:

...

/Overriding existing NameTemplate

  1. Add a new Global Property named "layout.name.template" if it already exists, update it's value to the your custom xml template: 

    Code Block
    <org.openmrs.layout.name.NameTemplate>
      <codeName>customXmlTemplate</codeName>
      <displayName>Custom Name Format</displayName>
      <nameMappings class="properties">
        <property name="prefix" value="PersonName.prefix"/>
        <property name="givenName" value="PersonName.givenName"/>
        <property name="familyName" value="PersonName.familyName"/>
      </nameMappings>
      <sizeMappings class="properties">
        <property name="prefix" value="5"/>
        <property name="givenName" value="30"/>
        <property name="familyName" value="25"/>
      </sizeMappings>
      <lineByLineFormat>
        <string>prefix</string>
        <string>givenName</string>
        <string>familyName</string>
      </lineByLineFormat>
      <requiredElements>
        <string>givenName</string>
        <string>familyName</string>
      </requiredElements>
    </org.openmrs.layout.name.NameTemplate> 


  2. Update the  layout.name.format  Global Property to the custom template's codeName so that it is chosen as the active template.
  3. Change the nameMappings, sizeMappings, and lineByLineFormat elements however you like.  Restart Tomcat to use the new name layout.


e.g. if you don't want to not show degreeprefix, you delete the lineByLineFormat line: <value>degree< <string>prefix</value>string>

e.g. if you want to have a longer givenName, you modify <prop keymodify <property name="givenName" >30</prop> to be <prop keyvalue="30"/> to be <property name="givenName" value="50">50</prop>>