Changeset 1359


Ignore:
Timestamp:
May 13, 2011, 10:44:34 AM (11 years ago)
Author:
Martin Svensson
Message:

Fixes #316 Add support for 'YYYYMMDD' date format in the 'Consent form registration wizard'. Support for short-input formats 'YYMMDD' and 'MMDD' are also added. The changes also apply to the Personal information registration wizard.

Location:
extensions/net.sf.basedb.reggie/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/resources/consentform.jsp

    r1354 r1359  
    134134    // This wizard will only allow 'Yes' option on the consent form
    135135    enableConsentOption('consent.yes', true);
    136     setInputStatus('consent', 'This case is already exists.', 'valid');
     136    setInputStatus('consent', 'This case already exists.', 'valid');
    137137    Main.showInline('morehelp.yes');
    138138    Main.show('gocancel');
     
    254254  else
    255255  {
    256     if (!Dates.isDate(consentDate, 'yyyy-MM-dd'))
     256    // Auto-fill the date if it's only given with 4(MMdd) or 6(yyMMdd) digits.   
     257    consentDate = autoFillDate(consentDate);
     258    frm.consentDate.value = consentDate;
     259 
     260    if (!Dates.isDate(consentDate, 'yyyyMMdd'))
    257261    {
    258262      setInputStatus('consentDate', 'Not a valid date', 'invalid');
     
    353357        <td class="status" id="consentDate.status"></td>
    354358        <td class="help">
    355           <span id="consentDate.message" class="message" style="display: none;"></span>(YYYY-MM-DD)
     359          <span id="consentDate.message" class="message" style="display: none;"></span>(YYYYMMDD or MMDD)
    356360        </td>
    357361      </tr>
  • extensions/net.sf.basedb.reggie/trunk/resources/persinfo.jsp

    r1342 r1359  
    304304  if (samplingDate != '' || samplingTime != '')
    305305  {
    306     if (!Dates.isDate(samplingDate, 'yyyy-MM-dd'))
     306    // Auto-fill the date if it's only given with 4(MMdd) or 6(yyMMdd) digits.
     307    samplingDate = autoFillDate(samplingDate);
     308    frm.samplingDate.value = samplingDate;
     309
     310    samplingTime = autoFillTime(samplingTime);
     311    frm.samplingTime.value = samplingTime;
     312   
     313    if (!Dates.isDate(samplingDate, 'yyyyMMdd'))
    307314    {
    308315      setInputStatus('samplingDate', 'Not a valid date', 'invalid');
     
    311318    if (frm.rnaLaterDate.value == '') frm.rnaLaterDate.value = samplingDate;
    312319   
    313     if (!Dates.isDate(samplingDate + ' ' + samplingTime, 'yyyy-MM-dd HH:mm'))
     320    if (!Dates.isDate(samplingDate + ' ' + samplingTime, 'yyyyMMdd HHmm'))
    314321    {
    315322      if (samplingDate != '') setInputStatus('samplingDate', 'Not a valid time', 'invalid');
     
    333340  if (rnaLaterDate != '' || rnaLaterTime != '')
    334341  {
    335     if (!Dates.isDate(rnaLaterDate, 'yyyy-MM-dd'))
     342    // Auto-fill the date if it's only given with 4(MMdd) or 6(yyMMdd) digits.
     343    rnaLaterDate = autoFillDate(rnaLaterDate);
     344    frm.rnaLaterDate.value = rnaLaterDate;
     345
     346    rnaLaterTime = autoFillTime(rnaLaterTime);
     347    frm.rnaLaterTime.value = rnaLaterTime;
     348   
     349    if (!Dates.isDate(rnaLaterDate, 'yyyyMMdd'))
    336350    {
    337351      setInputStatus('rnaLaterDate', 'Not a valid date', 'invalid');
    338352      return;
    339353    }
    340     rnaLaterTimestamp = Dates.parseString(rnaLaterDate + ' ' + rnaLaterTime, 'yyyy-MM-dd HH:mm');
     354    rnaLaterTimestamp = Dates.parseString(rnaLaterDate + ' ' + rnaLaterTime, 'yyyyMMdd HHmm');
    341355    if (rnaLaterTimestamp == null)
    342356    {
     
    351365  if (samplingDateIsValid && rnaLaterTimestamp)
    352366  {
    353     var samplingTimestamp = Dates.parseString(frm.samplingDate.value + ' ' + frm.samplingTime.value, 'yyyy-MM-dd HH:mm');
     367    var samplingTimestamp = Dates.parseString(frm.samplingDate.value + ' ' + frm.samplingTime.value, 'yyyyMMdd Hmm');
    354368    if (samplingTimestamp && rnaLaterTimestamp.getDate() != samplingTimestamp.getDate())
    355369    {
     
    526540    if (thisCaseSamplingDate != null)
    527541    {
    528       frm.samplingDate.value = thisCaseSamplingDate.substring(0, 10);
    529       frm.samplingTime.value = thisCaseSamplingDate.substring(11, 16);
     542      frm.samplingDate.value = thisCaseSamplingDate.substring(0, 8);
     543      frm.samplingTime.value = thisCaseSamplingDate.substring(9, 13);
    530544      samplingDateTimeOnChange();
    531545    }
    532546    if (thisCaseRNALaterDate != null)
    533547    {
    534       frm.rnaLaterDate.value = thisCaseRNALaterDate.substring(0, 10);
    535       frm.rnaLaterTime.value = thisCaseRNALaterDate.substring(11, 16);
     548      frm.rnaLaterDate.value = thisCaseRNALaterDate.substring(0, 8);
     549      frm.rnaLaterTime.value = thisCaseRNALaterDate.substring(9, 13);
    536550      rnaLaterDateTimeOnChange();
    537551    }
     
    936950            onkeypress="focusOnEnter(event, 'rnaLaterDate')" onblur="samplingDateTimeOnChange()"></td>
    937951        <td class="status" id="samplingDate.status"></td>
    938         <td class="help"><span id="samplingDate.message" class="message" style="display: none;"></span>Date+time of surgical removal (YYYY-MM-DD, HH:MM)</td>
     952        <td class="help"><span id="samplingDate.message" class="message" style="display: none;"></span>Date+time of surgical removal (YYYYMMDD, HHMM)</td>
    939953      </tr>
    940954      <tr id="rnaLaterDateSection" valign="top">
     
    945959            onblur="rnaLaterDateTimeOnChange()"></td>
    946960        <td class="status" id="rnaLaterDate.status"></td>
    947         <td class="help"><span id="rnaLaterDate.message" class="message" style="display: none;"></span>Date+time of pathology handling (YYYY-MM-DD, HH:MM)</td>
     961        <td class="help"><span id="rnaLaterDate.message" class="message" style="display: none;"></span>Date+time of pathology handling (YYYYMMDD, HHMM)</td>
    948962      </tr>
    949963      <tr id="reasonIfNoSpecimenSection" valign="top">
  • extensions/net.sf.basedb.reggie/trunk/resources/reggie.js

    r1342 r1359  
    133133  location.href = location.href;
    134134}
     135
     136/**
     137  Autofill a date-string.
     138  The supplemented date-string will have the format yyyyMMdd when it's returned.
     139  If the short-date in format MMdd is larger the current date, the year before will be used.
     140 
     141  @param shortDate Date in format 'MMdd' or in 'yyMMdd'
     142*/
     143function autoFillDate(shortDate)
     144{
     145  var fullDateString = shortDate;
     146 
     147  var currentDate = new Date();
     148  var currentYear = currentDate.getFullYear();
     149  if (shortDate.length == 4 && Dates.isDate(shortDate, 'MMdd'))
     150  {
     151    var month = parseInt(shortDate.substring(0,2));
     152    var date = parseInt(shortDate.substring(2));
     153    if ((month > (currentDate.getMonth()+1))  ||
     154        ( (month == (currentDate.getMonth()+1)) && (date > currentDate.getDate())) )
     155    {
     156      currentYear--;
     157    }
     158    fullDateString = currentYear+shortDate;
     159  }
     160  else if (shortDate.length == 6 && Dates.isDate(shortDate, 'yyMMdd'))
     161  {
     162    var year = parseInt(shortDate.substring(0,2));   
     163    fullDateString = ((2000+year)>currentYear ? "19" : "20") + fullDateString;
     164  }
     165  return fullDateString; 
     166}
     167
     168function autoFillTime(shortTime)
     169{
     170 
     171  var fullTimeString = shortTime;
     172  if (shortTime.length==3)
     173  {
     174    fullTimeString = "0"+shortTime;
     175  }
     176  return fullTimeString;
     177}
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/ConsentFormServlet.java

    r1354 r1359  
    7979          // ... case annotations
    8080          theCase.loadAnnotations(dc, "consent", Reggie.ANNOTATION_CONSENT, null);
    81           DateToStringConverter dateConverter = new DateToStringConverter(new SimpleDateFormat("yyyy-MM-dd"));
     81          DateToStringConverter dateConverter = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd"));
    8282          theCase.loadAnnotations(dc, "consentDate", Reggie.ANNOTATION_CONSENT_DATE, dateConverter);
    8383         
     
    151151        Number caseId = (Number)jsonCase.get("id");
    152152        String consent = Values.getStringOrNull((String)jsonCase.get("consent"));
    153         StringToDateConverter dateConverter = new StringToDateConverter(new SimpleDateFormat("yyyy-MM-dd"));
     153        StringToDateConverter dateConverter = new StringToDateConverter(new SimpleDateFormat("yyyyMMdd"));
    154154        Date consentDate = dateConverter.convert((String)jsonCase.get("consentDate"));
    155155        AnnotationType consentType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_CONSENT, true);
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PersonalRegistrationServlet.java

    r1341 r1359  
    129129          AnnotationType samplingDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_SAMPLING_DATETIME, true);
    130130          AnnotationType rnaLaterDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_RNALATER_DATETIME, true);
    131           DateToStringConverter dateConverter = new DateToStringConverter(new SimpleDateFormat("yyyy-MM-dd HH:mm"));
     131          DateToStringConverter dateConverter = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd HHmm"));
    132132          for (SpecimenTube tube : specimenTubes)
    133133          {
     
    351351          AnnotationType rnaLaterType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_RNALATER_DATETIME, true);
    352352         
    353           StringToDateConverter dateConverter = new StringToDateConverter(new SimpleDateFormat("yyyy-MM-dd HH:mm"));
     353          StringToDateConverter dateConverter = new StringToDateConverter(new SimpleDateFormat("yyyyMMdd HHmm"));
    354354          Date samplingDate = dateConverter.convert((String)jsonCase.get("samplingDate"));
    355355          Date rnaLaterDate = dateConverter.convert((String)jsonCase.get("rnaLaterDate"));
     
    422422          AnnotationType rnaLaterType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_RNALATER_DATETIME, true);
    423423         
    424           StringToDateConverter dateConverter = new StringToDateConverter(new SimpleDateFormat("yyyy-MM-dd HH:mm"));
     424          StringToDateConverter dateConverter = new StringToDateConverter(new SimpleDateFormat("yyyyMMdd HHmm"));
    425425          Date samplingDate = dateConverter.convert((String)jsonCase.get("samplingDate"));
    426426          Date rnaLaterDate = dateConverter.convert((String)jsonCase.get("rnaLaterDate"));
Note: See TracChangeset for help on using the changeset viewer.