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

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 43 Next »

Reference for writing HTML for the Html Form Entry Module

Tag Reference

<code>

See <translations>

<encounterDate>

Data entry widget for recording encounter date. Along with encounterLocation and encounterProvider, encounterDate should be present on every HTML form.

Attributes

  • default: Specifies default value for encounterDate widget.
    • OPTIONAL
    • Example: <encounterDate default="today"/>
    • Value: "today", "now", or ?????
    • Default: None
  • showTime: The showTime attribute determines if the encounterDate widget is date-only or date and time.
    • OPTIONAL
    • Example: <encounterDate showTime="true"/>
    • Value: "true" or "false"
    • Default: False - Widget is date-only

Example Usage

<encounterDate/>                   <!-- an initially-blank date widget -->
<encounterDate default="today"/>   <!-- a date widget pre-filled with today's date -->
<encounterDate showTime="true"/>   <!-- a date and time widget -->
<encounterDate showTime="true" default="now"/>   <!-- a date and time widget defaulting to the time on the server -->

<encounterLocation>

Data entry widget for recording location of the encounter. Along with encounterDate and encounterProvider, encounterLocation should be present on every HTML form.

Attributes

  • default: Sets default value for the widget.
    • OPTIONAL
    • Example: <encounterLocation default="2"/>
    • Value: Location ID, Location UUID, or Location Name
    • Default: None
  • order: Determines which locations appear in the list, and specifies the order in which they appear.
    • OPTIONAL
    • Example: <encounterLocation order="2,7,4"/>
    • Value: Comma separated list of Location IDs, Location UUIDs, or Location Names
    • Default: All locations in alphabetical order

Example Usage

<encounterLocation/>                                    <!-- a list of all locations, sorted alphabetically by name -->
<encounterLocation default="2"/>                        <!-- a list of all locations, sorted alphabetically by name, with location 2 selected by default -->
<encounterLocation order="2,7,4"/>                      <!-- a list of the specified locations, by id -->
<encounterLocation order="Rwinkwavu,Kirehe,Mulindi"/>   <!-- a list of the specified locations, by name -->

<encounterProvider>

Data entry widget for recording provider for the encounter. Along with encounterDate and encounterLocation, encounterProvider should be present on every HTML form.

Attributes

  • default: Sets default value for the widget.
    • OPTIONAL
    • Example: <encounterProvider default="djaz"/>
    • Value: username, Person IDs, or Person UUID
    • Default: None
  • role: Filters the list of persons to only those users with the specified role
    • OPTIONAL
    • Example: <encounterProvider role="Provider"/>
    • Value: Any valid role
    • Default: Provider
  • persons:  Determines which persons appear in the list, and specifies the order in which they appear.
    • OPTIONAL
    • As of version 1.6.8
    • Example: <encounterLocation persons="1,2,4"/>
    • Value: Comma separated list of usernames, Person IDs, or Person UUIDs

Example Usage

<encounterProvider/>                   <!-- a list of all users -->
<encounterProvider default="djaz"/>    <!-- a list of all users, with the user whose username is djaz selected -->
<encounterProvider default="6"/>       <!-- a list of all users, with the user whose userId is 6 selected -->
<encounterProvider role="Provider"/>   <!-- a list of those users with the Provider role -->
<encounterProvider persons="username1,username2"/>   <!-- a list of those 2 Persons who are users with usernames username1 and username2 -->

<enrollInProgram>

Enrolls a patient in a program when the form is submitted. This only happens when the form is first entered--nothing happens when the form is edited or deleted.

Specifics about this enrollment behavior:

  • If the patient is already in the program on that date, nothing changes
  • If the patient is registered in the program after that date, then the patient's enrollment date will be moved back to the date of this encounter
  • Otherwise, the patient is enrolled as requested

Attributes

  • programId: ID of the program in which the patient is to be enrolled.
    • REQUIRED
    • Example: <enrollInProgram programId="1"/>
    • Value: Any valid program ID or program UUID.
    • Default: None.

<excludeIf>

A tag that optionally exclude all its content based on evaluating a logic token or a velocity expression. This tag has to only contain either a logic test or a velocity test.

Attributes

  • logicTest A logic expression represents a logic test.
    • OPTIONAL
    • Example: <excludeIf logicTest="GENDER = F"/> - A logic test to see if the patient's gender is female
  • velocityTest A velocity expression represents a velocity test.
    • OPTIONAL
    • Example: <excludeIf velocityTest=""$patient.gender" == "F" "/> - A velocity test to see if the patient's gender is female.

Example Usage

   <htmlform>
     <table border="0" width="100%">
        <tr><td><includeIf logicTest="GENDER = F">This shows a logic test for a woman</includeIf> </td></tr>
        <tr><td><includeIf velocityTest=""$patient.gender" == "F" ">This shows a velocity test for a woman</includeIf> </td></tr>
        <tr><td><excludeIf logicTest="GENDER = F">This won't show for a logic test for a woman</excludeIf> </td></tr>
        <tr><td><excludeIf velocityTest=""$patient.gender" == "F" ">This won't show for a velocity test for a woman</excludeIf> </td></tr>
     </table>
   </htmlform>

<htmlform>

Top-level tag that defines a form. A form must be wrapped in an htmlform tag.

<includeIf>

See <excludeIf>

<lookup>

Allows you to evaluation of velocity expressions. See the Velocity Users Guide for more documentation.

The variables you have access to in the velocity context are:

  • patient: the patient object you're entering the form for
  • locale: the authenticated user's locale
  • patientIdentifiers: Map<String, List<String>> of identifierType.name -> all identifiers of that type
  • personAttributes: Map<String, Object> of personAttributeType.name -> the (hydrated) current attribute value
    • since HTML Form Entry 1.7 the name has any single quotes removed, so "Mother's Name" will become "Mothers Name"
  • relationshipList: List<Relationship> of all relationships that the subject of the form belongs to
  • relationshipMap: Map<String, List<Person>> of either RelationshipType.aIsToB or RelationshipType.bIsToA -> all persons with that relationship to the subject
  • form: the HtmlForm currently in use
  • encounter: the Encounter currently being viewed/edited. (only set in view/edit mode)

Additionally (since 1.7.0) there are some functions available to you that allow you to access existing patient data:

  • fn.logic(String logicExpression)
    • evaluates a logic expression, and returns an org.openmrs.logic.Result
    • since 1.7.0
    • Example
      Latest BMI: <lookup expression="fn.logic('BMI')"/> <!-- requires that you have a BMI rule registered -->
      
  • fn.allObs(Integer conceptId)
    • returns all the patient's observations for the given concept id, as a List<Obs>
    • since 1.7.0
    • Example
      Past CD4 results: <lookup complexExpression="#foreach($cd4 in $fn.allObs(5497)) $cd4.valueNumeric #end"/>
      
  • fn.latestObs(Integer conceptId)
    • returns the patient's most recent observation for the given concept id (most recent ever and not in relation to this encounter's date)
    • since 1.7.0
    • Example
      Last Weight: <lookup expression="fn.latestObs(5089)"/>
      
      Last BMI: <lookup complexExpression="#set( $wt = $fn.latestObs(5089) ) #set( $ht = $fn.latestObs(5090) ) #set( $bmi = $wt / ($ht * $ht) ) $!{bmi}"/>
      
  • fn.earliestObs(Integer conceptId)
    • returns the patient's earliest observation for the given concept id
    • since 1.7.0
    • Example
      First Weight: <lookup expression="fn.earliestObs(5089)"/>
      

Attributes

  • complexExpression
    • OPTIONAL
    • Example: <lookup complexExpression="#foreach( $addr in $patient.addresses ) $!addr.cityVillage <br/> #end"/>
    • Value: Valid complex velocity expression
    • Default: None
  • class
    • OPTIONAL
    • Example: <lookup class="value" ... />
    • Value: Valid velocity class
    • Default: None
  • expression
    • OPTIONAL
    • Example: <lookup expression="patient.personName"/>
    • Value: Valid velocity expression
    • Default: None

Example Usage

<lookup expression="patient.personName"/> this will translate to the velocity expression $\!{patient.personName}
<lookup expression="patient.getPatientIdentifier(5)"/> this will get the patient's first identifier with Identifier Type Id of 5
<lookup complexExpression="#foreach( $addr in $patient.addresses ) $\!addr.cityVillage <br/> #end"/>
<lookup class="value" .../>   this will produce <span>result of expression</span>

<macros>

Define macros at the top of the file (e.g. for things like colors).

Example Usage

<htmlform>
    <macros>
        lightgrey=#e0e0e0
        lightblue=#e0e0ff
        darkblue=#4444ff
    </macros>
    <div style="background-color: $lightblue">This is a pleasant light blue color</div>
</htmlform>

<obs>

Generates an obs data entry widget. Depending on the datatype of the concept you specify, you get different obs.value widgets, and you use different attributes to control them.

Data Types

Numeric

By default, displays a small text box that auto-checks that entries are between absoluteMinimum and absoluteMaximum for the concept, and checks on precise also. You can also specify a constrained list of answers, as radio button or checkboxes. (Since 1.6.1) Example:

<!-- free text box (constrained to legal numbers) -->
<obs conceptId="5497" labelText="Most recent CD4:" dateLabel="Date of test:"/>

<!-- constrained to None, 1-6, and 7-8 -->
<obs conceptId="123" labelText="Education" answers="0,6,8" answerLabels="None,1-6,7-8" style="radio"/>
<obs conceptId="123" labelText="Education" answers="0,6,8" answerLabels="None,1-6,7-8" style="dropdown"/>

You can also specify answerCodes instead of answerLabels to reference answer labels by codes in messages.properties or in the translation mappings in the form itself.

Boolean

Various widget styles can be used to input Boolean values:

style="checkbox"                 A checkbox that when checked creates a TRUE obs, and when unchecked does nothing
style="checkbox" value="false"   A checkbox that when checked creates a FALSE obs, and when unchecked does nothing
style="no_yes"                   Radio buttons for no and yes. You may click on a selected radio button to unselect it.
style="yes_no"                   Like above but reverse order
style="no_yes_dropdown"          Dropdown list with blank, no, and yes options.
style="yes_no_dropdown"          Like above but reverse order

<!-- Localization -->
<obs style="no_yes" noLabel="Non" yesLabel="Oui"/>

Text

By default, displays a normal text input box.

size="5" means a text field with the specified size
style="textarea" means a textarea
rows="10" number of rows in the textarea (implies style="textarea")
cols="80" number of columns in the textarea (implies style="textarea")
answers="comma,separated,legal,answers"
answerLabels="Display,For,Legal,Answers"
answerCodes=Allows you to reference labels by a messages.properties codes or a codes in the translation mappings defined in the form.
style="location" provides a drop-down list of Locations.

Date

Renders a date picker widget. Note that dates are not allowed to be in the future, unless attribute allowFutureDates="true".

Coded

Renders a drop-down with all possible coded answered. Set style="radio" to display a radio set of options in lieu of a drop-down. Set style = "autocomplete" to display a autocomplete widget. Note autocomplete has to work with either an answerClasses attribute or an answerConceptId attribute.

Examples:
<obs conceptId="1234" answerConceptId="123" labelText="The question:" answerLabel="The answer"/>
Renders as: The question: [ ]The answer
If checked creates an obs with conceptId=1234 and valueCoded=123

<obs conceptId="1234"/>
Renders as a dropdown of all possible answer specified for concept 1234 in the dictionary

<obs conceptId="1234" answerConceptIds="123,7,912" answerLabels="Malaria,Tuberculosis,Diabetes"/>
Renders as a dropdown of the specified answers with the specified labels.

<obs conceptId="1296" answerClasses="Drug"/>
Renders as a dropdown all Concepts with ConceptClass = "Drug", ordered by Concept Name

<obs conceptId="1296" answerClasses="Drug" style="autocomplete"/>
Renders as a autocomplete widget with ConceptClass = "Drug", ordered by Concept Name

You can also specify answerCode instead of answerLabel to reference an answer label by a code in messages.properties or in the translation mappings in the form itself.

Attributes

  • allowFutureDates: When set to true allows obsDatetime to be in the future. (Has no effect on valueDatetime.)
    • OPTIONAL
    • Example: <obs conceptId="5096" dateLabel="Date measured:" allowFutureDates="true" />
    • Value: "true" or "false"
    • Default: False - Only past dates are allowed by default.
  • answerCodes: Allows you to reference labels by a messages.properties codes or a codes in the translation mappings defined in the form.
    • OPTIONAL
    • Example: ???
    • Value ??
    • Default: ?????
  • answerClasses: Renders as a dropdown all Concepts with specified ConceptClass, ordered by Concept Name
    • OPTIONAL
    • Example: <obs conceptId="1296" answerClasses="Drug"/>
    • Value: Valid ConceptClass
    • Default: None
  • answerConceptId: Concept reference corresponding to the coded answer for the question. Frequently used with checkboxes.
    • OPTIONAL
    • Examples:
      • <obs conceptId="3509" answerConceptId="2070" answerLabel="l'hôpital" style="checkbox" />
      • <obs conceptId="3509" answerConceptId="XYZ:HT" answerLabel="l'hôpital" style="checkbox" />
      • <obs conceptId="3509" answerConceptId="0cbe2ed3-cd5f-4f46-9459-26127c9265ab" answerLabel="l'hôpital" style="checkbox" />
    • Value: A valid Concept Integer ID, Concept Mapping, or Concept uuid.
    • Default: None
  • answerConceptIds: Concept references corresponding to the coded answers for the question. Used with radio buttons and dropdowns.
    • OPTIONAL
    • Examples:
      • <obs conceptId="1319" labelText="Toiture/Roofing: " answerConceptIds="1320,1321,1316" answerLabels="tole,tache,beton"/>
      • <obs conceptId="1319" labelText="Toiture/Roofing: " answerConceptIds="XYZ:HT,ABC:QQ,QWE:TR" answerLabels="tole,tache,beton"/>
      • <obs conceptId="1319" labelText="Toiture/Roofing: " answerConceptIds="5ecb88f3-cd5f-4f46-9459-26127c9265ab,74e3ded1-cd4f-4f4b-9459-26127c9265ab,0cbe2ed3-cd5f-4f46-9459-26127c9265ab" answerLabels="tole,tache,beton"/>
      • <obs conceptId="1319" labelText="Toiture/Roofing: " answerConceptIds="1320,ABC:QQ,0cbe2ed3-cd5f-4f46-9459-26127c9265ab" answerLabels="tole,tache,beton"/>
    • Value: Quoted, comma separated list of valid Concept Integer IDs, Concept Mappings, or Concept uuid's.
    • Default: None
  • answerLabel: Sets the text to display after the object. Used with checkboxes.
    • OPTIONAL
    • Example: <obs conceptId="3509" answerConceptId="2070" answerLabel="l'hôpital" style="checkbox" />
    • Value: Any quoted string
    • Default: None
  • answerLabels: Sets the text to display after the objects. Used with radio buttons or dropdowns.
    • OPTIONAL
    • Example: <obs conceptId="3201" labelText="" answerConceptIds="1065,1066" style="radio" answerLabels="oui,non" />
    • Value: Comma separated list.
    • Default: None
  • answers: Values to be stored as the answer for a radio button or dropdown. NOT used when answers are concepts - see answerConceptIds in that case
    • OPTIONAL
    • Example: <obs conceptId="123" labelText="Education" answers="0,6,8" answerLabels="None,1-6,7-8" style="radio"/>
    • Value: Comma-separated list
    • Default: None
  • cols: Number of columns in the textarea (implies style="textarea").
    • OPTIONAL
    • Example: <obs conceptId="3221" rows="7" cols="60" />
    • Value: Positive integer.
    • Default: None
  • conceptId: Integer ID, Concept Mapping, or Concept uuid of the concept to which the obs widget is linked. The datatype of this concept drives the behavior of the widget.
    • REQUIRED
    • Examples:<obs conceptId="6135" /><obs conceptId="XYZ:HT" /><obs conceptId="0cbe2ed3-cd5f-4f46-9459-26127c9265ab" />
    • Value: Valid Concept Integer ID, Concept Mapping, or Concept uuid.
    • Default: None
  • dateLabel: Text to display after the obs.value widget and before the obs.datetime widget. Specifying this implies showDate="true".
    • OPTIONAL
    • Example: <obs conceptId="5497" labelText="Most recent CD4:" dateLabel="Date of test:"/>
    • Value: Any quoted string
    • Default: None
  • id: label that you can use to refer to this obs in javascript on the page
    • OPTIONAL
    • Example: <obs conceptId="5089" id="weight"/><obs conceptId="5090" id="height"/> <script>var bmi = getValue('weight.value') / Math.pow(getValue('height.value'), 2);</script>
    • Value: string
    • Default: None
    • Since 1.6.8
  • labelCode: Allows you to reference a label by a messages.properties code or a code in the translation mappings defined in the form.
    • OPTIONAL
    • Example: <obs conceptId="1234" labelCode="night_sweats"/>
    • Value: If referencing a translation mapping, the value for the labelCode attribute must be a valid name as defined within the <code> tag.
    • Default: None
  • labelNameTag: "default" will delegate to Concept.getBestName(Context.getLocale()). Currently that's the only legal tag.
    • OPTIONAL
    • Example: ?????
    • Value: "default"
    • Default: None
  • labelText: Sets the label that goes before the widget.
    • OPTIONAL
    • Example: <obs conceptId="3355" labelText="cause de décès:" />
    • Value: Any quoted string
    • Default: None
  • noLabel: Defines the label for the "no" option for all styles with a "no" parameter. Commonly used to change label from "No" to "non"
    • OPTIONAL
    • Example: <obs conceptId="6689" style="yes_no" noLabel="non" yesLabel="oui" />
    • Value: Any quoted string.
    • Default: "No"
  • required: Sets this field as a required field
    • OPTIONAL
    • Example: <obs conceptId="3453" required="true" />
    • Value: True or false
    • Default: False
  • rows: Number of rows in the textarea (implies style="textarea")
    • OPTIONAL
    • Example: <obs conceptId="3221" rows="7" cols="60" />
    • Value: Positive Integer
    • Default: None
  • showDate: Sets whether or not to show a date widget to set the obs.datetime for this obs
    • OPTIONAL
    • Example: <obs conceptId="3232" showDate="true" />
    • Value: True or false
    • Default: False
  • size: Specifies the size of a text field.
    • OPTIONAL
    • Example: <obs conceptId="2216" labelText="Résultats: " size="80" />
    • Value: Positive integer
    • Default:?
  • style: Specifies the type of input element (radio, checkbox, dropdown, yes/no, etc.) that displays on the form.
    • OPTIONAL
    • Example: <obs conceptId="6689" style="yes_no" noLabel="non" yesLabel="oui" />
    • Value: "radio", "checkbox", "dropdown", "yes_no", "no_yes", "yes_no_dropdown", "no_yes_dropdown", "textarea", "autocomplete"
    • Default: Driven by datatype of associated concept.
  • value: When set to "false", a checked checkbox signifies a value of false for the concept. It inverts the normal relationship where a checked checkbox signifies "true".
    • OPTIONAL
    • Example: <obs conceptId="2146" style="checkbox" value="false" />
    • Value: True or false
    • Default: True
  • yesLabel: Defines the label for the "yes" option for all styles with a "yes" parameter. Commonly used to change label from "Yes" to "Oui"
    • OPTIONAL
    • Example: <obs conceptId="6689" style="yes_no" noLabel="non" yesLabel="oui" />
    • Value: Any quoted string.
    • Default: "Yes"
  • conceptIds:  It is possible to create an obs tag where you're choosing the 'question' for a predefined answerConceptId.  This attribute can't be used in the same obs tag as the usual 'conceptId' attribute, and for the moment requires an answerConceptId.  Here is an example of valid usage of this attribute:
<obs conceptIds="1441,3017,2474" answerConceptId="656" labelText="ISONIAZID"/>
Renders as a dropdown list of drug sensitivity results for the drug isoniazid. 
The resulting obs has, for example,'WEAKLY POSITIVE' for the concept, and Isoniazid as the conceptAnswer.

Related Tags

<obsgroup>

Used to create an obs group. You are required to specify a groupingConceptId. Nested obs groups are now supported.

Attributes

  • groupingConceptId: ID of the associated concept
    • REQUIRED
    • Examples:
      • <obsgroup groupingConceptId="2214">
      • <obsgroup groupingConceptId="XYZ:HT">
      • <obsgroup groupingConceptId="0cbe2ed3-cd5f-4f46-9459-26127c9265ab">
    • Value: Any valid concept integer ID, concept mapping pair, or concept uuid.
    • Default: None

Related Tags

Example Usage

<obsgroup groupingConceptId="1234">
    <obs conceptId="1234" answerConceptId="123" answerLabel="Other"/>
    <obs conceptId="987" labelText="specify:"/>
</obsgroup>

You can wrap an obsgroup tag anywhere in the html, generally speaking, as long as it is still a well-formed xml document.

This is okay:
    <table>
        <tr>
            <obsgroup groupingConceptId="1234">
                <td><obs conceptId="5089" labelText="Weight:"/></td>
                <td><obs conceptId="5090" labelText="Height:"/></td>
            </obsgroup>
        </tr>
    </table>

This will break:
    <obsgroup groupingConceptId="1234">
        <table>
            <tr>
                <td><obs conceptId="5089" labelText="Weight:"/></td>
                <td><obs conceptId="5090" labelText="Height:"/></td>
            </obsgroup>
        </tr>
    </table>

<render>

See <repeat>

<repeat>

Repeatedly renders code that is contained within template tags. Facilitates future code maintenance. Repeats can be nested inside of other tags. A repeat can contain only 2 top level tags: template and render.

Related Tags

<template>

  • The code contained in the <template> tags is repeated for each <render> tag.

<render>

  • Used within a repeat tag to render code. Within the render tag you can also specify attributes that can be used as keys during substitution.

Example Usage

<repeat>
    <template>
        <obsgroup groupingConceptId="1295">
            <tr>
                <td><obs conceptId="1297" answerConceptId="{concept}" answerLabel="{effect}" labelText=""/></td>
                <td><obs conceptId="3063"/></td>
                <td><obs conceptId="1300"/></td>
                <td><obs conceptId="1643"/></td>
            </tr>
        </obsgroup>
    </template>
    <render concept="6355" effect="Nausées/vomissements"/>
    <render concept="16" effect="Diarrhée"/>
    <render concept="80" effect="Arthralgie"/>
    <render concept="877" effect="Etourdissements et/ou vertiges"/>
</repeat>

<section>

The <section> tag lets you break your form, and corresponding form schema, into sections.

Attributes

  • headerCode: Allows you specify the header label using a code that references message.properties or the translation mappings in the form itself.
    • OPTIONAL
    • Example: ???
    • Value: ????
    • Default: None.
  • headerLabel: The label to use in the section header.
    • OPTIONAL
    • Example: <section headerLabel="1. Information démographique">
    • Value: Any quoted string
    • Default: None.
  • headerStyle: Allows you to override the default style for the section header.
    • OPTIONAL
    • Value: Valid CSS style attributes
    • Default: None
  • sectionStyle: Allows you to override the default style for the section.
    • OPTIONAL
    • Value: Valid CSS style attributes
    • Default: None

<submit>

You need to put a submit tag at the bottom of your form, or else your users will be very disappointed in you. Label, Code, Style attributes analogous to a section tag can be applied.

Attributes

  • submitLabel: Allows you to set the text of the submit button.
    • OPTIONAL
    • Value: Any String
    • Default: Messages from message.properties for htmlformentry.enterFormButton or htmlformentry.saveChangesButton depending on if form new form is being saved or existing form is being edited, respectively.
    • Since: 1.7.2
  • submitCode: Allows you to set the text of the submit button using an htmlformentry translation code
    • OPTIONAL
    • Value: reference to a translation code
    • Default: None
    • Since: 1.7.2
  • submitStyle: Allows you to set the style class for the submit button.  This attribute gets written into the rendered submit tag as class="<<submitStyle Value>>".
    • OPTIONAL
    • Value: Valid CSS style attributes
    • Default: submitButton CSS style is referenced by default; if none is defined in the style section, no style will be applied 
    • since: 1.7.2

Example

Simplest example using defaults

<htmlform>
    ...stuff goes here...
    <submit/>
</htmlform>

Example of applying custom Class to a translated label

<htmlform>
<style>
    .customSubmit { font-weight: bold; }
</style>
<translations defaultLocale="en">
    <code name="submit_text">
        <variant locale="en" value="Close Flowsheet"/>
        <variant locale="fr" value="Not sure how to say it in French"/>
    </code>
</translations>
    ...stuff goes here...
    <submit submitStyle="customSubmit" submitCode="submit_text" />
</htmlform>

<template>

See <repeat>

<translations>

Defines translation mappings at the top of the file which can be accessed by specialized coded attributes in other tags.

Attributes

  • defaultLocale: Allows you to specify the default variant value.
    • OPTIONAL
    • Example: <translations defaultLocale="en">
    • Value: Any quoted string.
    • Default: None.

Related Tags

<code>

Used to define a code to assign variant values to.

Attributes
  • name: Name of the variant
    • REQUIRED
    • Example: <code name="night_sweats">
    • Value: Any quoted string.
    • Default: None

<variant>

Used to identify the value for a code as determined by the locale.

Attributes
  • locale: ????
    • REQUIRED
    • Example: <variant locale="en" value="night sweats"/>
    • Value: A valid two letter locale value. E.g. "ar", "en", "es", "fr"
    • Default: None
  • value: The value to be assigned to the code.
    • REQUIRED
    • Example: <variant locale="en" value="night sweats"/>
    • Value: Any quoted string.
    • Default: None

Example Usage

<translations defaultLocale="en">
    <code name="night_sweats">
        <variant locale="en" value="night sweats"/>
        <variant locale="fr" value="sueurs nocturnes"/>
    </code>
</translations>

And then in the body of the form:

<obs conceptId="1234" labelCode="night_sweats"/>

<variant>

See <translations>

Javascript function reference

Javascript overview

You've always been allowed to write Javascript in an HTML form but since version 1.6.8 we provide some built-in Javascript helper functionality.

  • Any time you specify an 'id' attribute on an obs tag (for example: <obs id="weight" .../>) you have access to the displayed fields (in this example: weight.value, weight.date, weight.error, and weight.accessionNumber)

getField(idAndProperty)

Used to get a JQuery handle to a field, so you can attach event listeners to it.

  • argument: idAndProperty the field you want to get (for example "weight.value")
  • returns: a JQuery selector for the field you requested
  • since: 1.6.8
    Example:
    getField('weight.value').change(function() {
        window.alert('Weight is now ' + getValue('weight.value'))
    });
    

getValue(idAndProperty)

Gets the value of a field.

  • argument: idAndProperty the field you want to get (for example "weight.value")
  • returns: the value of the specified field
  • since: 1.6.8
    Example:
    window.alert('You entered ' + getValue('weight.value') + 'kg as the weight');
    

setValue(idAndProperty)

Sets the value of a field

  • argument: idAndProperty the field you want to set the value of (for example "weight.value")
  • value: the value you want to set
  • since: 1.6.8
    Example:
    setValue('weight.value', 74);
    setValue('scheduledVisit.value', true);
    setValue('howTravelClinic.value', 456); // 456 is a concept id that's a legal answer to this question
    

Other Examples and Tips

Example HTML Forms

Linking to Pages

To make it seem like your html form has multiple pages, it would be best to put links to allow the user to jump down to the next page:

<a href="#page1">1</a>
Jump to Page: <b>1</b> \| <a href="#page2">2</a> \| <a href="#page3">3</a>
...
...
<hr/>
<a name="page2"></a>
Jump to Page: <a href="#page1">1</a> \| <b>2</b> \| <a href="#page3">3</a>
...
...
<hr/>
<a name="page3"></a>
Jump to Page: <a href="#page1">1</a> \| <a href="#page2">2</a> \| <b>3</b>
...

Features in Version 1.7

New features include access to past observations, as well as the logic service, from the lookup tag.

An example for first encounter location using logic:

<lookup expression="fn.logic('first  encounterLocation')"/>

Or you could calculate the patient's BMI without using logic: (I know this is ugly. Blame the velocity templating language.)

Previous BMI:

<lookup complexExpression="#set( $wt = $fn.latestObs(5089)  ) #set( $ht = $fn.latestObs(5090) ) #set( $bmi = $wt / ($ht * $ht) )  $\!{bmi}" />

Create your own custom tag and handler

It is possible to register your own tag and handler with htmlformentry from another module.  For an example of this, see the htmlformflowsheet module.

  • No labels