Date comparison - dynamic query
Compare two date questions that do not have time elements and display a dynamic query if the dates are not as expected.
Rule description: the date of the Informed Consent is Signed must be on or before the date entered in the Visit Date field for the Screening or Baseline visit.
Rule expression
//to meet the rule description criteria onstdt-compdt should be a negative value or zero (<=0)
if(dateDiffInDays(icdat,vstdt)<=0)
{
return true;
}
else
{
setQueryMessage("Date Informed Consent signed "+getDateDMYFormat(icdat,false)+" must be on or before the Visit date "+getDateDMYFormat(vstdt,false) +" .Please correct or clarify.");
return false; //Query message set dynamically. System sends query when return false condition is met
}
Query message: Date Informed Consent was signed {infconstdt} must be on or before the Visit date {visitdate}. Please correct or clarify.
Definitions
- icdat
-
Corrsponds to the Date of Informed Consent from the rule description.
- vstdt
-
Corresponds to the Visit date from the rule description.
- <=
-
Less Than or Equalt To operator. Update operator based on the rule description.
- dateDiffInDays( )
-
Calculates difference between date1 and date2 (date1-date2) in days, in this case icdat - vstdt.
- setQueryMessage( )
-
Specify dynamic query text passed in as a parameter.
- getDateDMYFormat( )
-
Use the getDateDMYFormat helper function to return a date (including partial dates) in DD-MON-YYYY format.
Return value
Usage tips
Always use the relevant date helper function to compare dates rather than comparing the variables directly using comparison operators.
Verification steps
- Using a subject for testing, go to the given visit and form
containing the date items to compare, in this example the date of
informed consent <
icdat
> and visit date <vstdt
>. - Update the form items
icdat
andvstdt
as in the following table and verify the result is as listed:icdat
vstdt
Result 10-May-2021 Null
No query 10-May-2021 10-May-2021 No query 11-May-2021 10-May-2021 Query. Verify correct date values are populated in the Query Text.
09-May-2021 10-May-2021 No query 09-Jun-2021 10-May-2021 Query. Verify correct date values are populated in the Query Text.
11-Apr-2021 10-May-2021 No query Null
10-May-2021 No query 12-May-2021 10-May-2021 Query. Verify correct date values are populated in the Query Text.
12-May-2021 14-May-2021 No query
Note:
Repeat the above steps if the form is present in multiple visits.
Other examples
Example 4-20 Date of Study Discontinuation must be >= Date Informed Consent signed
if(dateDiffInDays(studycompdt,infdt)>=0)
{
return true;
}
else
{
setQueryMessage("Date of Study Discontinuation "+getDateDMYFormat(studycompdt,false)+" is less than Informed Consent date "+getDateDMYFormat(infdt,false)+". Please correct or clarify.");
return false;
}
Query message: Date of Study Discontinuation {discontdate} is less than Informed Consent date {infdt}. Please correct or clarify.
Example 4-21 Date of Infusion must be equal to visit date of respective visits
if(dateDiffInDays(infudt, visdt)==0)
{
return true;
}
else
{
setQueryMessage("Date of Infusion "+getDateDMYFormat(infudt,false)+" is prior to or greater than visit date "+getDateDMYFormat(visdt,false)+". Please correct or clarify.");
return false;
}
Query message: Date of Infusion {infusiondt} is prior to or greater than visit date {visitdate}. Please correct or clarify.
Example 4-22 Start date of hypoglyceamic episode must be >= Date of randomization
Note:
Hypoglycaemic episode is date question with time elements.if(dateDiffInDays(hypodt, randdt)>=0)
{
return true;
}
else
{
setQueryMessage("Start date "+getDateDMYFormat(hypodt,false)+" is prior to date of randomisation "+getDateDMYFormat(randdt,false)+". Please correct.");
return false;
}
Query message: Start date is prior to date of randomization ({RandDate}). Please correct.
Parent topic: Dates with Dynamic Query Text