Summary

This article describes how to allow for the creation of variables and calculations that can then be referenced anywhere that the expression language is used using the formulas worksheet.

Table of Contents


The Formulas worksheet allows for the creation of variables and calculations that can then be referenced anywhere that the expression language is used such as within dependencies, assignments and reports. This can be useful to leverage data without including it in an export as well as to perform a calculation once and then use it in multiple places. Unlike assignments, formulas are simply calculations that return a value.

Create a Basic Formula

  1. formulaId: Enter a unique name for the formula.
    • This formulaId must be unique across all Ids in the application including formIds, formTypeIds, questionIds and questionTypeIds.



Note: formulaId does not have a character limit, best practice is to make it less than 32 characters.


  1. Data Type: Enter one of the following to define the formula type and the data type that should be returned by the formula:
    • Date – has special math functionality (e.g., pop-up calendar for date, or time of day).
    • String – text (accepts any value)
    • Integer – denotes the need for whole numbers
    • Float – allows for decimal or integer values (more flexibility than an Integer)
    • Boolean – returns true or false based on the executed expression
  2. Expression Type: Enter ‘custom’ if a custom java class should be used. Enter ‘expression’ otherwise.
  3. Expression: If using a custom java file, enter the class name that should be executed for the formula. Otherwise, enter the expression that should be used to set a value to the formula.
  4. Repeat these steps for each formula.


Write Formula Expressions

Formula expressions can be written using the expression language. Additionally, you can specify when to use certain types of values.

Specify Data Values

To reference a data value for a question, add ‘.dataValue’ to the end of the question path.

Example: #studyTermination.visitDateTerm.dataValue

Specify Display Values

To reference a display value for a question, add ‘.displayValue’ to the end of the question path.

Example: #studyTermination.visitDateTerm.displayValue

Standard Custom Formulas

This section describes custom formulas that are globally available.

TodayTZ

TodayTZ returns the current time adjusted for the user’s time zone. As noted in step 4 below, TodayTZX can be used if TodayTZ was customized for a study prior to the release of 13.1.8.

Follow the steps described in this section to use this custom formula with Dependencies.

Note: TodayTZ can only be used with Dependencies.
For reconcile to work correctly: Only use TodayTZ on the question, whose value is compared.
Never use TodayTZ in order to check other questions (other means ‘not the question with the dependency’)
Note: @@today, @@currentDate, @@currentTime, and @@currentDateTime will evaluate based on the time zone set within the user profile of the active user. TodayTZ or TodayTZX can still be used and will still function as designed but is not the only solution for factoring in user time zone.


Formulas Worksheet

  1. formulaId: Enter a unique name for the formula.
    • This formulaId must be unique across all Ids in the application including formIds, formTypeIds, questionIds and questionTypeIds.
  2. Data Type: Enter ‘Date’
  3. Expression Type: Enter ‘custom’
  4. Expression: Enter:
    • ‘TodayTZ’ if the TodayTZ functionality has not been customized on the study or sponsor level
    • ‘TodayTZX’ if TodayTZ has been used and customized on the study or sponsor level prior to the DBP 13.1.8 release

Dependencies – Definition Worksheet

Create a dependency in the usual way, making sure to reference the formulaId created in the previous section when writing the dependency expression.

In the following example, the dependency ensures that the visit date is today or earlier. The alert fires if the date is in the future.



Need more help?

Please visit the Fountayn Contact Information page.