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

Version 1 Next »

Overview

This page has advanced features that require a knowledge of JavaScript. 

 

Details

In expressions (created by using Expression dialog or using <%= %> syntax in the template) the following short-hand is allowed to reference variable values:

<%= #code %> - results in the variable's value or blank if the value is null.

<%= #code1 + #code2 %> - if the values are numeric, will result in the two numbers being added together, otherwise the two values will be concatenated together.

 

In expressions, script, or script blocks

#code.displayValue.toString() displays:

  1. The variable's value, or
  2. Blank if the value is null or defined as a missing value

 

#code.value.toString() displays:

  1. the variable's value (even if the value is defined as missing) or
  2. blank if the value is null.

 

#code.displayValue.value displays:

  1. Numeric variables:  returns a number
  2. Date variables:  returns a date
  3. All other variables:  returns a string representation of the value
  4. Missing values or null:  returns null

 

#code.value.value displays:

  1. Numeric variables:  returns a number
  2. Date variables:  returns a date
  3.  All other variables:  returns a string representation of the value
  4. Missing values:  returns the missing value
  5. Null:  returns null

 

#code.value.value - if the value is for a numeric variable, the result is a number; if the value is for a date variable, the result is a date; otherwise the result is a string representation of the value. If the value is null, the result is null. Note, values defined as missing are returned (i.e., they are not returned as null).

 

#code.displayValue.name - returns the picklist display name associated with the variable's value. If the value is null or defined as a missing value, empty string is returned.

#code.value.name - returns the picklist display name associated with the variable's value even if the value is defined as missing. If the value is null, empty string is returned.

 

Detailed explanation

 

#code - refers to an object with the following properties: variableId, definition, displayValue, value.

1) variableId: Integer key of the variable (used as input to some methods on the Encounters collection).

2) definition: an object that has properties and method:

                a) name: variable name.

                b) description: variable description.

3) displayValue and value return an object with the following properties. The object returned for displayValue treats values defined as missing as being null.

                a) name: picklist display name associated with the variable or empty string if null.

                b) value: the variable's value as the variable's type. Thus, numeric values are returned as number or NaN if null; date values are returned as Date objects or null; and other other data is returned as a string. If the value is null, null is returned so statement like "if (#code == null)" will be true if the value is null.

                c) IsNull: returns true if the value is null.

                d) toString(): returns a string representation of the value or empty string.

 

 

Examples

Output a variable value:

<% Output.Write( #code.displayValue.toString() );

 

Output a variable value even if it is defined as missing:

<% Output.Write( #code.value.toString() );

 

Output a sum of two numeric variables:

<% Output.Write( #code1.displayValue.value == null || #code2.displayValue.value == null ? '' : #code1.displayValue.value + #code2.displayValue.value ) %>

  • No labels