31 Dec 2018: Thank you to our knowledgeable and friendly forums users for another great year. We are aware of the uptick in spam accounts and are doing our best to ban these at first sight. Thank you for your patience!

Date Validation across CRF sections

Hello,

I am currently using OpenClinica Version 3.7 to build a study for clinical data collection,
My CRF template (excel workbook) has several sections for 1) Inclusion Criteria, 2) Demographics 3) Blood Test 4) Diagnostic Procedures etc.
I collect the "Date of Visit" data field in the Demographics section and also, "Date of Test", "Date of Procedure", "Date of prescription" data fields throughout all other sections of the CRF.

I would like to know if there is any way I can compare these date fields against the date of visit to validate that both dates are within 12 months of each other.
Further, the "Date of Visit" field is in the "DD-MMM-YYYY" format whereas, all other date fields are in the partial date; "MMM-YYYY" or "YYYY" format.

I am not sure how JavaScript/J query can be utilised to solve my issue.
Any and all advice/suggestions/help is appreciated.

Thank you!!

Best,
Neva

Comments

  • GerbenRienkGerbenRienk Posts: 799 ✭✭✭
    Hi Neva,
    Yes you can do this with javascripting and if you want could give you an example, but it is not what I would advice. If you want to allow partial dates, but at the same time want to compare these with "normal" dates, it is often better to use normal dates for all fields. In the "partial" dates you can set a regular expression to use only "01-" as the start of the and you can add instructions about this in the right-item-text. Then you can write normal validations checking the difference between the date of visit and the other dates.
    I hope this helps,
    Gerben Rienk
  • nevaeleangovannevaeleangovan Posts: 4
    Hi Gerben,

    This is excellent advice! I have already incorporated this into some of my date variables and this works very well.

    However, I do have other projects whereby there are over 40 date items to compare. I was wondering if I could take a look at your Javascript example to see if it could help me out as well?

    Many thanks for your input here, it has been very useful!

    Neva
  • GerbenRienkGerbenRienk Posts: 799 ✭✭✭
    Hi Neva,
    Please see attached CRF. It is based on http://www.trialdatasolutions.com/tds/howto/datediff.jsp but of course you must take into account the partial dates.
    This is done in
    function OCDateToJDate2(OCDate){
    // first we must check if we're dealing with a partial date
    if (OCDate.length == 8) {
    // only month and year were given, so add 15
    OCDate = "15-" + OCDate;
    }
    else{
    if (OCDate.length == 4){
    OCDate = "01-" + Calendar._SMN[6] + "-" + OCDate;
    }
    }
    etc.
    So if month and year were given we add "15" for the day. If only year is given we add "01-Jul" to the year.
    I hope this is what you're looking for.
    Gerben Rienk
Sign In or Register to comment.