Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Contact Us
  • Home
  • CDMS
  • Castor CDMS Calculations Manual
  • Calculations with date and time

Check if the last visit date matches the end of study date in EDC/CDMS

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • CDMS
    Castor CDMS Manual Castor CDMS Calculations Manual Frequently Asked Questions Articles for Data Managers Castor CDMS Compliance Release Documents
  • eConsent
    Castor eConsent Manual Castor eConsent Compliance Release Documents
  • SMS
    Castor SMS Manual Castor SMS Compliance Release Documents
  • Castor Connect
    Castor Connect Compliance Release Documents Castor Connect Manual Castor Connect - Participant Quick Start Guide
  • Helpdesk
    News Other Resources Castor products knowledge resources
  • Status page
  • Completing a Study
+ More

Table of Contents

Step by step

The calculation below allows to check all previous visit dates and compare the date of the last visit with the date of the end of the study. If the last visit date matches the end of study date, the calculation will output 'Yes', otherwise 'No'.

 

'##allowempty##';
'##setemptytozero##';
var screen = moment('{scr_date}', 'DD-MM-YYYY');
var visit_1 = '{v1_date}';
var visit_2 = '{v2_date}';
var visit_3 = '{v3_date}';
var visit_4 = '{v4_date}';
var visit_5 = '{v5_date}';
var end_study = moment('{eos_date}', 'DD-MM-YYYY');
var visit_dates = [screen, visit_1, visit_2, visit_3, visit_4, visit_5];
var i;
var last_date;
for (i = 0; i < visit_dates.length; i++) {
 if (visit_dates[i] != 0) {
 last_date = visit_dates[i];
 }
}
var last_visit_date = moment(last_date, 'DD-MM-YYYY');
if (end_study.isSame(last_visit_date)){
 "Yes.";
} else {
 "No.";
}

 

Check the calculation in the calculation field helper.

Step by step

  1. First, we will use the '##allowempty##' and '##setemptytozero##' tags to make sure that the dates which have not been completed are set to 0:
  2. Dates in Castor EDC are stored as strings. To make sure we can perform calculations with the dates,, we need to convert them to the date format. Here we are retrieving the screening ('{scr_date}') and the end of study dates ('{eos_date}') and converting them to the right format using the moment.js library. For the other dates, we simply assign them to the variables which can be used within our calculations. We do not perform the conversion yet, as we only need to check the date of the last performed visit.
  3. We create an array ('list') visit_dates and include the screening date and all the visit dates. Then we initialize a counter i and last_date variables. Using the counter variable in the for loop, allows us to find the date of the last visit from our array. This is done by checking each individual date. If a date is not equal to zero which is checked in the expression if (visit_dates[i] != 0), it means that the value was entered in Castor EDC. The date of the last visit is then saved in the last_date variable.
  4. Using the moment.js function, we convert the last visit date to the date format.
  5. Using is Same function, we can now check if the last visit date is the same as the end of the study date.
if (end_study.isSame(last_visit_date)){
 "Yes.";
} else {
 "No.";
}
var last_visit_date = moment(last_date, 'DD-MM-YYYY');
var visit_dates = [screen, visit_1, visit_2, visit_3, visit_4, visit_5];
var i;
var last_date;
for (i = 0; i < visit_dates.length; i++) {
 if (visit_dates[i] != 0) {
 last_date = visit_dates[i];
 }
}
var screen = moment('{scr_date}', 'DD-MM-YYYY');
var visit_1 = '{v1_date}';
var visit_2 = '{v2_date}';
var visit_3 = '{v3_date}';
var visit_4 = '{v4_date}';
var visit_5 = '{v5_date}';
var end_study = moment('{eos_date}', 'DD-MM-YYYY');
'##allowempty##';
'##setemptytozero##';
end date visit date

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Doing date (and time) calculations in EDC/CDMS: the basics
  • Add hours and minutes to a datetime field in EDC/CDMS
  • Check if year is in the future in EDC/CDMS
  • Adding hours or minutes to a time field in EDC/CDMS
ISO 27001
FDA - 21 CFR part 11
ICH GCP compliant
HIPAA compliant
CDISC
ISO 9001
gdpr compliant

Products & Industries

  • Electronic Data Capture (EDC)
  • ePRO
  • eConsent
  • Decentralized Clinical Trials (DCT)
  • Clinical Data Management
  • Medical Device & Diagnostics
  • Biotech & Pharma
  • CROs
  • Academic Research

Resources

  • Thought Leadership
  • Blog
  • Castor Academy
  • Knowledge Base

 

Company

  • About Us
  • Careers
  • News
  • Contact Support
  • Contact Us

Legal & Compliance

  • Terms of Use
  • Privacy & Cookie Statement
  • Responsible Disclosure Policy
  • Good Clinical Practice (GCP)
  • ISO Compliance Certificates
  • GDPR & HIPAA Compliance
  • Security Statement

© 2022, Castor. All Rights Reserved.

Follow us on social media


Knowledge Base Software powered by Helpjuice

Definition by Author

0
0
Expand