Computations

To edit a computation, click the Edit button on the item’s design surface card.

Neutral Specification vs Native Code

At the top of the computation editor is a toggle labeled Use Native Code. When using native code, custom Blaise code can be specified and will be included in the RULES section of the generated Blaise survey.

Description

The Description tab lets you specify basic metadata about the computation.

Name

A short name used to refer to the computation.

Label

A label used to denote the computation in documentation.

Description

A description of what the computation performs.

Inputs

The Inputs tab lets you specify what values are necessary to perform the computation.

To add an input:

  1. Click the plus button.

  2. The Select an Input dialog is displayed

  3. Choose an item from the survey to use as an input to the computation.

  4. The input will now be available as a token on the Code tab.

Outputs

The Outputs tab lets you specify what fields are made available after the computation.

To add an output:

  1. Click the plus button.

  2. Enter a name for the output.

  3. Choose the scope of the output (Field, Local, or AuxField).

  4. Choose the type of the output (text, numeric, code, date/time).

  5. If the output is a code type, either choose an existing code list or create a new code list to define which code list defines the type.

Expression

The Expression tab lets you build computations, step by step.

  1. Before building an expression, make sure you have specified the inputs and outputs, as described above.

  2. On the left side of the window is a list of assignment steps. Click the plus button to add a new step.

  3. Choose the field to calculate.

  4. Choose a function. See Functions for Computation Assignments for details on available functions.

  5. Specify values for each function parameter.

Function parameters can be filled in two ways.

Literal

Literal values are specified by typing the text, number, date, or time in provided entry field.

Symbol Reference

Symbol references are specified by choosing an available input or output.

Code

When using native Blaise computations, the Expression tab is hidden, and a Code tab is available.

The Code tab lets you specify Blaise code that will be included in the RULES section.

Input and output tokens are displayed above the code entry box. These should be surrounded by double curly braced. For example, to refer to the fields named dogYears and dogAge, code like the following can be used.

{{dogYears}} := {{dogAge}} * 7

When generating Blaise code, Blaise Colectica Questionnaires will replace the terms with the appropriate field names. This allows custom Blaise code to be re-used across instruments, even when the fields used as input to the computation may have different names in different instruments.