Date comparison within range: Days before

Check if one date is within a number of days prior to another date (inclusive) and raise a query if the date is outside of this window.

Rule description: the Date of Measurement must be 1 to 28 days prior (inclusive) to the Day 1 visit start date.

Rule expression

//to meet the rule description criteria DOV-MEASDT should be between 1 and 28 (inclusive)
//so greater than or equal to 1 (>=1) AND less than or equal 28 (<=28)
if(dateDiffInDays(DOV,MEASDT)<=28 && dateDiffInDays(DOV, MEASDT)>=1)
{
return true;
}
else
{
return false;                    //System sends query when return false condition is met
}

Query message: Date of Measurement at Screening visit was not taken within -28 to -1 days prior to Day 1. Please verify the dates.

Definitions

DOV

Corresponds to Day 1 Visit Start date from the rule description.

MEASDT

Corresponds to Date of Measurement from the rule description.

<=, >=

Less Than or Equal To and Greater Than or Equal To operators. Update operator based on the rule description.

dateDiffInDays

Calculates difference between date1 (DOV) and date2 (MEASDT) (date1-date2) in days.

Return value

Boolean

Returns either true or false. System raises query when return false condition is met.

Usage tips

Always use the relevant date helper function to compare dates rather than comparing the variables directly using comparison operators.

Verification steps

  1. Using a subject for testing, go to the given visit and form containing the date items to compare, in this example the Day 1 visit start date <DOV> and date of measurement <MEASDT>.
  2. Update the form items DOV and MEASDT as in the following table and verify the result is as listed:
    DOV MEASDT Result
    Null 10-May-2021 No query
    10-May-2021 10-May-2021 Query
    11-May-2021 10-May-2021 No query
    09-May-2021 10-May-2021 Query
    12-Apr-2022 10-May-2021 Query
    12-Apr-2022 11-Apr-2021 No query
    12-Apr-2022 12-Apr-2022 Query
    12-Apr-2022 14-Mar-2021 Query
    12-Apr-2022 15-Mar-2021 No query
    13-Apr-2021 15-Mar-2022 Query
    13-Apr-2022 Null No query

Note:

Repeat the above steps if the form is present in multiple visits.