Calculation fields can be used to validate visit dates. In the example below, inclusion occurred on Sept 1, 2020. For the purposes of this example, there is 7+/-2 day washout.
Calculate the Time Between Visits
This calculation finds the difference in days between Inclusion and Baseline.
Since the is a 2-day window, if the baseline occurred less than 5 days or more than 9 days after inclusion, a message will appear.
var incl = moment('{inc_date}', 'DD-MM-YYYY');
var baseline = moment('{bl_v_dt}', 'DD-MM-YYYY');
var diff = baseline.diff(incl, 'days');
if(diff < 5 || diff > 9){
"This visit requires a deviation!"
} else {
'ok';
}
Your output in the data entry view will be the following:
Once you have constructed your calculations, you can automate queries for visit compliance by following these steps, or you can opt to create a validation message. If you opt to automate queries, you will need to edit the output of your calculation:
"This visit requires a deviation!" or "ok" would be 1 or 0, respectively.