Sample data-entry rules that use methods
Example 1
Example 1 - Data entry rules that use methods
Characteristic |
Description |
Description |
Use a math method to round the result of the existing rule, rulCalcBMI, to two decimal places. |
Scope |
Baseline event |
Study structure |
|
Rule summary |
evaluate on Form Submission
value = Math.Round(_CalculateBMI(this.frmDemographics.itmHeight.Value,this.frmVitals.itmWeight.Value),2)
always set this.frmVitals.itmBMI.Value = value
Note: The solution above is the simplest solution, but not the best, as it does not clear the BMI field if Height or Weight are subsequently cleared, and it will cause an ISE if Height is 0.0. A better solution follows. evaluate on Form Submission
value = !this.frmDemographics.itmHeight.Empty && !this.frmVitals.itmWeight.Empty ? (this.frmDemographics.itmHeight.Value != 0 ? 1: (!this.frmVitals.itmBMI.Empty ? 2 : 3)) : (!this.frmVitals.itmBMI.Empty ? 2 : 3)
when value == 1 set this.frmVitals.itmBMI.Value = Math.Round(_CalculateBMI(this.frmDemographics.itmHeight.Value,this.frmVitals.itmWeight.Value),2)
when value == 2 set this.frmVitals.itmBMI.Empty = true |
Example 2
Example 2 - Data entry rules that use methods
Characteristic |
Description |
Description |
Create a rule named rulTabsDispensed that checks that the sum of tablets dispensed is greater than zero and less than 500. The sum of tablets should use 0 as a replacement value. If false, fire a query. |
Scope |
Dispensing Record section |
Study structure |
|
Rule summary |
evaluate on Form Submission
value = (this.itmTabNum.itmonemg.GetValue(0) + this.itmTabNum.itmtwomg.GetValue(0)) > 0 && (this.itmTabNum.itmonemg.GetValue(0) + this.itmTabNum.itmthreemg.GetValue(0) + this.itmTabNum.itmtwomg.GetValue(0)) < 500
when value is false issue query on this.itmTabNum: The total number of tablets dispensed {TabsDisp} is not within the expected range. Please clarify or correct. |