Please join your peers on either March 26 (8pm GMT) or March 28 (8am GMT) to watch as user extraordinaire and forum legend @"lindsay.stevens" demonstrates OpenClinica Insight.

See preview and register at https://openclinica.com/insight-webinar

Insight makes it easy to ask questions of ALL of your clinical and operational data and visualize answers via interactive reports and dashboards. The idea is simple, but the results are powerful: ask your questions, choose your visualizations, then return often for updated, interactive results that link you to all of the underlying data.

regular expression with year field

Dear Developers,
I have some issue about regular expression, I would be grateful if the enrollment date(date type) can have some validation rule.
E.g. Year <2050.

Many thanks and best wishes,
Padd

Comments

  • GerbenRienkGerbenRienk Posts: 772 ✭✭✭
    Hi Padd,

    Yes, this is possible. You can use a regular expression and this will be validated before the check is fired that the entered characters must form a date.
    So the main part of your regexp must be the year: days and months will be validated by OpenClinica.
    Fill in column V (VALIDATION):
    regexp: /\d\d\-\w\w\w\-(19\d\d|20[0-4]\d)/
    and in column W (VALIDATION_ERROR_MESSAGE)
    Please give a date before 2050.

    If this is not exactly what you want, use http://regexpal.com/ to find out how to get just that.
    Hope this helps,

    Gerben Rienk
    http://www.trialdatasolutions.com

    Van: [email protected] [mailto:[email protected]] Namens Thatsanun Ngernseng
    Verzonden: woensdag 5 september 2012 9:59
    Aan: [email protected]
    Onderwerp: [Developers] regular expression with year field

    Dear Developers,
    I have some issue about regular expression, I would be grateful if the enrollment date(date type) can have some validation rule.
    E.g. Year <2050.

    Many thanks and best wishes,
    Padd
  • Hi Gerben Rienk,
    Thanks, it worked.

    Padd
    Sent: Tuesday, September 11, 2012 1:55 AM
    To: [email protected]
    Subject: Re: [Developers] regular expression with year field

    Hi Padd,

    Yes, this is possible. You can use a regular expression and this will be validated before the check is fired that the entered characters must form a date.
    So the main part of your regexp must be the year: days and months will be validated by OpenClinica.
    Fill in column V (VALIDATION):
    regexp: /\d\d\-\w\w\w\-(19\d\d|20[0-4]\d)/
    and in column W (VALIDATION_ERROR_MESSAGE)
    Please give a date before 2050.

    If this is not exactly what you want, use http://regexpal.com/ to find out how to get just that.
    Hope this helps,

    Gerben Rienk
    http://www.trialdatasolutions.com

    Van: [email protected] [mailto:[email protected]] Namens Thatsanun Ngernseng
    Verzonden: woensdag 5 september 2012 9:59
    Aan: [email protected]
    Onderwerp: [Developers] regular expression with year field

    Dear Developers,
    I have some issue about regular expression, I would be grateful if the enrollment date(date type) can have some validation rule.
    E.g. Year <2050.

    Many thanks and best wishes,
    Padd
  • JohannaRnstJohannaRnst Posts: 1
    Hello,

    Thanks for the explanation given above. Unfortunately, it seems like my OpenClinica does not like the regex function. I tested it and after implementing the validation (I literally copy-pasted from this thread), I cannot enter any dates without receiving an error message. Would you be able to help with this issue?

    Many thanks and best wishes!

    Hanna
  • GerbenRienkGerbenRienk Posts: 772 ✭✭✭
    Hi Hanna,
    That's strange. I uploaded an example: can you please look for differences with your situation?
    Kind regards,
    Gerben Rienk
  • haenselhaensel Posts: 570 ✭✭
    Hi Hanna

    Is the field type ST or DATE? Using Regex with DATE fields might not work but I didn't tested it on my own.

    Regards,
    Christian
This discussion has been closed.