Sample calculation rules

Example 1

Characteristic Description

Description

Using the CalcAge function, create a rule named rulCalcAge that calculates a subject's age and populates the age field. Use the DOV from the visit containing the DEM form.

Scope

Baseline study event

Study structure

  • Baseline (study event)
    • frmDOV (form)
      • DOV (item)
    • Demog (form)
      • DOB (item)
      • AGE (item)

Rule summary

evaluate on Form Submission

value = !this.frmDOV.sctDOV.itmDOV.Empty &&
!this.frmDemographics.itmDOB.Empty ? 1
:(!this.frmDemographics.itmAGE.Empty ? 2:3)

when value == 1
    set this.frmDemographics.itmAGE.Value = _CalcAge(this.frmDemographics.itmDOB.Value, this.frmDOV.sctDOV.itmDOV.Value)

when value == 2
    set this.frmDemographics.itmAGE.Empty = true

Example 2

Characteristic Description

Description

Create a rule named rulBMIRangeCheck that checks that the BMI is between 18.5 and 30. Specify an action to issue a query if the BMI is out of range.

Scope

Baseline event

Study structure

  • Baseline (study event)
    • Vitals (form)
      • Weight (item)
      • BMI (item)
    • Demog (form)
      • HT (item)

Rule summary

evaluate on Form Submission

value = (this.Value >= Constants.BMIRange.BMILow)&&
(this.Value <= Constants.BMIRange.BMIHigh)

when value is false
    issue query on this: BMI {CalculatedBMI} is out of range. Please verify.