Previous Topic

Next Topic

Book Contents

Book Index

Constraint rules

Constraint rules

Characteristic

Description

Definition

A constraint rule checks whether data is valid.

Note: There is no real difference between a calculation rule and a constraint rule. Each offers different starting points in the Rule Wizard; the options on the Actions tab change depending on the rule type that you select.

Study objects that can have constraint rules

  • Study designs
  • Study elements
  • Study events
  • Forms
  • Items

Programming experience necessary

Creating a constraint rule is comparable to writing formulas in the Microsoft Excel spreadsheet software.

What to define

You must define:

  • When to evaluate the rule.
  • The rule expression.

    For calculation and constraint rules, you can use the following to define the rule expression:

    • Study objects and their rule model properties.
    • Functions. If you use a function, you define values for its parameters using numeric values, values of study objects and their rule model properties, constants, and data mapping study objects and their rule model properties.
    • Constants.
    • Data mapping study objects and their rule model properties.
  • The action to take after the rule executes.

Example

(without a function)

A constraint rule determines if a calculated BMI value is below the expected value of 30. You create the rule on the form that contains the weight and height items.

You provide the following information to create the rule:

  • When to evaluate the rule—On form submission.
  • The rule expression—To create the rule expression, which calculates body mass index, either drag the weight and height items from the Data tab to the Expression workspace, or type the expression.
  • The action to take after the rule executes—You specify the constraint in the action. When the BMI is below 30, an email is sent.

The following information appears in the Rule Summary section:

evaluate on Form Submission

 value = this.weight / (this.height)*(this.height)
 when value < 30
     send email: Subject has reached target BMI.
You could create the rule with a function, as described in the next example, or with a rule template.

Example

(with a function)

A constraint rule uses a function (_CalculateBMI) and determines if a calculated BMI value is below the expected value of 30. You create the rule on the form that contains the weight and height items.

A programmer creates the function, and a non-programmer provides the following information to create the rule:

  • When to evaluate the rule—On form submission.
  • The rule expression—After you drag the function to the Expression workspace, the Invoke Function dialog box appears, and you can provide values for the parameters. In this case, you provide the weight and height items as parameters.
  • The action to take after the rule executes—When the BMI is below 30, an email is sent.

The following information appears in the Rule Summary section:

 evaluate on Form Submission
 value = _CalculateBMI(this.height.value, this.weight.value)
 when value < 30
     send email: Subject has reached target BMI.

You could create the rule without a function, as described in the previous example, or with a rule template. For more information, see Intrinsic rules.

Copyright © 2013 Oracle and/or its affiliates. All rights reserved.