org.openmrs.util
Class FormUtil

java.lang.Object
  extended by org.openmrs.util.FormUtil

public class FormUtil
extends java.lang.Object

OpenMRS utilities related to forms.

See Also:
Form, FormField, Field, FieldType, FieldAnswer

Constructor Summary
FormUtil()
           
 
Method Summary
static java.lang.String conceptToString(Concept concept, ConceptName localizedName)
          Turn the given concept/concept-name pair into a string acceptable for hl7 and forms
static java.lang.String conceptToString(Concept concept, java.util.Locale locale)
          Turn the given concept into a string acceptable to for hl7 and forms
static java.lang.String dateToString()
           
static java.lang.String dateToString(java.util.Date date)
           
static java.lang.String drugToString(Drug drug)
          Turn the given drug into a string acceptable for hl7 and forms
static java.util.TreeMap<java.lang.Integer,java.util.TreeSet<FormField>> getFormStructure(Form form)
          Returns a sorted and structured map of FormFields for the given OpenMRS form.
static java.lang.String getFormUriWithoutExtension(Form form)
          Get a string somewhat unique to this form.
static java.lang.String getNewTag(java.lang.String s, java.util.Vector<java.lang.String> tagList)
          Generates a new, unique tag name for any given string
static java.lang.String getXmlToken(java.lang.String s)
          Converts a string into a valid XML token (tag name)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormUtil

public FormUtil()
Method Detail

getXmlToken

public static java.lang.String getXmlToken(java.lang.String s)
Converts a string into a valid XML token (tag name)

Parameters:
s - string to convert into XML token
Returns:
valid XML token based on s

getNewTag

public static java.lang.String getNewTag(java.lang.String s,
                                         java.util.Vector<java.lang.String> tagList)
Generates a new, unique tag name for any given string

Parameters:
s - string to convert into a unique XML tag
tagList - java.util.Vector containing all previously created tags. If the tagList is null, it will be initialized automatically
Returns:
unique XML tag name from given string (guaranteed not to duplicate any tag names already within tagList)

getFormStructure

public static java.util.TreeMap<java.lang.Integer,java.util.TreeSet<FormField>> getFormStructure(Form form)
Returns a sorted and structured map of FormFields for the given OpenMRS form. The root sections of the schema are stored under a key of zero (i.e., java.lang.Integer.valueOf(0)). All other entries represent sequences of children stored under the identifier (formField.getFormFieldId()) of their parent FormField. The form structure is sorted by the natural sorting order of the FormFields (as defined by the .equals() and .compareTo() methods).

Parameters:
form - form for which structure is requested
Returns:
sorted map of FormFields, where the top-level fields are under the key zero and all other leaves are stored under their parent FormField's id.

dateToString

public static java.lang.String dateToString()

dateToString

public static java.lang.String dateToString(java.util.Date date)

getFormUriWithoutExtension

public static java.lang.String getFormUriWithoutExtension(Form form)
Get a string somewhat unique to this form. Combines the form's id and version and build

Parameters:
form - Form to get the uri for
Returns:
String representing this form

conceptToString

public static java.lang.String conceptToString(Concept concept,
                                               java.util.Locale locale)
Turn the given concept into a string acceptable to for hl7 and forms

Parameters:
concept - Concept to convert to a string
locale - Locale to use for the concept name
Returns:
String representation of the given concept

conceptToString

public static java.lang.String conceptToString(Concept concept,
                                               ConceptName localizedName)
Turn the given concept/concept-name pair into a string acceptable for hl7 and forms

Parameters:
concept - Concept to convert to a string
localizedName - specific localized concept-name
Returns:
String representation of the given concept

drugToString

public static java.lang.String drugToString(Drug drug)
Turn the given drug into a string acceptable for hl7 and forms

Parameters:
drug - Drug to convert to a string
Returns:
String representation of the given drug

OpenMRS-1.7.x

Generated Apr 27 2012 10:06 PM. NOTE - these libraries are in active development and subject to change