Basics of JavaScript

Basic Code

Symbol Meaning
== equals
!= not equals
|| or
&& and
> greater than
>= greater than or equal to
< less than
<= less than or equal to
() brackets control order of execution
. a period indicates a property of something
Case JavaScript is case-sensitive (i.e. capitalization matters!)

Answer Variable

Any item that's been completed by a patient has 2 useful properties:

  1. Response value ("r")
  2. Point value ("p")

Example: myPainScale, a numeric scale with point values from 0-5.

myPainScale.r
Returns the value associated with the patient's choice (always in standard language, i.e. English)
myPainScale.p
Returns the point value as a number

Script Variables

Variable Description Example Expressions
pt The ScriptPatient object with age, sex, etc.
pt.isMale() && pt.getAge() >= 55

Refer to "ScriptPatient Functions" for more details about more "pt." expressions.

daysSinceLastCompleted The number of day since the patient last complete this form
daysSinceLastCompleted > 365
firstTime Whether or not the patient has ever completed this form
firstTime
lastCompletedTag A string “remembered” by the form last time it was completed
lastCompletedTag.indexOf('myString') != -1

ScriptUtil Functions

ScriptUtil provides miscellaneous functions that allow you to simplify your scripts and support special use-cases. ScriptUtil is bound to all script session contexts, so you can use these functions in tablet rules or within eForms (show if, make note if, etc.).

Please refer to "ScriptUtil Functions" for examples of common ScriptUtil functions.

Have more questions? Submit a request