Changeset 1375


Ignore:
Timestamp:
Jun 14, 2011, 4:12:05 PM (10 years ago)
Author:
Martin Svensson
Message:

References #317. Some changes to the registration wizard. The fields that are common for all tubes, are gathered in a separate wizard-step.

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

Legend:

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

    r1372 r1375  
    2727<script language="JavaScript">
    2828var caseIsValid = false;
    29 var tubeNumberIsValid = false;
    3029var arrivalDateIsValid = false;
    3130var nofDeliveredTubesIsValid = true;
     
    3433var currentStep = 1;
    3534
     35var caseInfo = null;
    3636var specimenTubeInfo = null;
    3737
     
    4040  var frm = document.forms['reggie'];
    4141  frm.caseName.focus();
     42}
     43
     44function goNext(manual)
     45{
     46  setInnerHTML('gonext.message', '');
     47  if (currentStep == 1)
     48  {
     49    if(step1IsValid())
     50    {
     51      gotoStep2();
     52    }
     53  }
     54  if (currentStep == 2)
     55  {
     56    gotoStep3();
     57  }
     58}
     59
     60function gotoStep2()
     61{
     62  var frm = document.forms['reggie'];
     63  frm.caseName.disabled = true;
     64  currentStep = 2;
     65  var hasSpecimen = caseInfo.specimen && caseInfo.specimen.length > 0;
     66  var hasLeftSpecimen = false;
     67  var hasRightSpecimen = false;
     68  var hasUnknownSpecimen = false;
     69  var thisArrivalDate = null;
     70  var thisNumberOfTubes = null;
     71  var thisCaseSamplingDate = null;
     72  var thisCaseRNALaterDate = null;
     73  var thisCaseLaterality = null;
     74  var thisPad = null;
     75
     76  Main.show('gocancel');
     77  Main.show('caseSection');
     78
     79  if (caseInfo.id)
     80  {
     81    setInnerHTML('step2.title', 'Update Case Information');
     82    if (caseInfo.pad)
     83    {     
     84      frm.pad.value = caseInfo.pad;
     85    }
     86    if (caseInfo.laterality)
     87    {
     88      if(caseInfo.laterality == 'LEFT') hasLeftSpecimen = true;
     89      if(caseInfo.laterality == 'RIGHT') hasRightSpecimen = true;
     90      thisCaseLaterality = caseInfo.laterality;
     91      Forms.checkRadio(frm.laterality, thisCaseLaterality);
     92      lateralityOnChange();
     93    }
     94    // Load annotations from the actual case
     95    if (hasSpecimen)
     96    {
     97      frm.nofTubes.value = thisNumberOfTubes;
     98      frm.nofTubes.disabled = true;
     99      for (var i=0; i < caseInfo.specimen.length; i++)
     100      {
     101        var specimen = caseInfo.specimen[i];       
     102        if (specimen.pad && !thisPad)
     103        {         
     104          thisPad = specimen.pad;
     105        }
     106        if(specimen.arrivalDate && !thisArrivalDate)
     107        {
     108          thisArrivalDate = specimen.arrivalDate;
     109        }
     110        if (specimen.nofTubes && !thisNumberOfTubes)
     111        {
     112          thisNumberOfTubes = specimen.nofTubes;
     113        }
     114        if (specimen.samplingDate && !thisCaseSamplingDate)
     115        {
     116          thisCaseSamplingDate = specimen.samplingDate;         
     117        }
     118        if (specimen.rnaLaterDate && !thisCaseRNALaterDate)
     119        {
     120          thisCaseRNALaterDate = specimen.rnaLaterDate;
     121        }
     122        if (specimen.laterality)
     123        {
     124          if (specimen.laterality == 'LEFT') hasLeftSpecimen = true;
     125          if (specimen.laterality == 'RIGHT') hasRightSpecimen = true;
     126          if (!thisCaseLaterality) thisCaseLaterality = specimen.laterality;
     127        }
     128        else
     129        {
     130          hasUnknownSpecimen = true;       
     131        }
     132      }
     133      // If the number of tubes not is set - use the current number of specimen tubes.
     134      if (!thisNumberOfTubes) thisNumberOfTubes = caseInfo.specimen.length;
     135      frm.nofTubes.value = thisNumberOfTubes;
     136      // Check that all specimen tubes have the same laterality
     137      var numLateralities = 0;
     138      if (hasLeftSpecimen) numLateralities++;
     139      if (hasRightSpecimen) numLateralities++;
     140      if (hasUnknownSpecimen) numLateralities++;     
     141      if (numLateralities > 1)
     142      {
     143        setInputStatus('laterality', 'Specimen tubes with different laterality', 'warning');
     144        thisCaseLaterality = null;
     145        Forms.checkRadio(frm.laterality, thisCaseLaterality);       
     146      }     
     147      Forms.checkRadio(frm.laterality, thisCaseLaterality);
     148      lateralityOnChange();
     149     
     150      if (thisPad != null)
     151      {
     152        frm.pad.value = thisPad;
     153      }
     154      if (thisArrivalDate != null)
     155      {
     156        frm.arrivalDate.value = thisArrivalDate;
     157      }
     158      if (thisNumberOfTubes != null)
     159      {
     160        frm.nofTubes.value = thisNumberOfTubes;
     161      }
     162      if (thisCaseSamplingDate != null)
     163      {
     164        frm.samplingDate.value = thisCaseSamplingDate.substring(0, 8);
     165        frm.samplingTime.value = thisCaseSamplingDate.substring(9, 13);
     166        samplingDateTimeOnChange();
     167      }
     168      if (thisCaseRNALaterDate != null)
     169      {
     170        frm.rnaLaterDate.value = thisCaseRNALaterDate.substring(0, 8);
     171        frm.rnaLaterTime.value = thisCaseRNALaterDate.substring(9, 13);
     172        rnaLaterDateTimeOnChange();
     173      }
     174    }
     175  }
     176}
     177
     178function gotoStep3()
     179{
     180  var frm = document.forms['reggie'];
     181  var inputTubeHtml = '';
     182  var nofTubes = frm.nofTubes.value;
     183
     184  frm.arrivalDate.disabled = true;
     185  frm.nofTubes.disabled = true;
     186  frm.pad.disabled = true;
     187  for (var i=0;i<frm.laterality.length;i++)
     188  {
     189    frm.laterality[i].disabled = true;
     190  }
     191  frm.rnaLaterDate.disabled = true;
     192  frm.samplingDate.disabled = true;
     193  frm.rnaLaterTime.disabled = true;
     194  frm.samplingTime.disabled = true;
     195  frm.pathNote.disabled = true;
     196 
     197  for (var i=0;i<nofTubes;i++)
     198  {
     199    var specimen = null;
     200    if (caseInfo.specimen && caseInfo.specimen.length>0 && i<caseInfo.specimen.length)
     201    {
     202      specimen = caseInfo.specimen[i];
     203    }
     204    inputTubeHtml += '<tr>';
     205    inputTubeHtml += '<td class="prompt">Specimen Tube '+caseInfo.name+'.'+(i+1)+'</td>';
     206    inputTubeHtml += '</tr>';
     207
     208    var box = 'box'+i;
     209    inputTubeHtml += '<tr>';
     210    inputTubeHtml += '<td class="subprompt">Box</td>';
     211    inputTubeHtml += '<td class="input"><input type="text" name='+box+' value="" size="12" maxlength="10"></td>';
     212    inputTubeHtml += '<td class="status" id="'+box+'.status"></td>';
     213    inputTubeHtml += '<td class="help"><span id="'+box+'.message" class="message" style="display: none;"></span>Box the specimen tube is located in.</td>';   
     214    inputTubeHtml += '</tr>';
     215
     216    var row = 'row'+i;
     217    var column = 'column'+i;
     218    inputTubeHtml += '<tr>';
     219    inputTubeHtml += '<td class="subprompt">Row</td>';
     220    inputTubeHtml += '<td class="input"><input type="text" name='+row+' value="" size="3" maxlength="3">';
     221    inputTubeHtml += '&nbsp;Column<input type="text" name='+column+' value="" size="3" maxlength="3">';
     222    inputTubeHtml += '</td>';
     223    inputTubeHtml += '<td class="status" id="rowColumn'+i+'.status"></td>';
     224    inputTubeHtml += '<td class="help"><span id="rowColumn'+i+'.message" class="message" style="display: none;"></span>Row and column the specimen tube is located at.</td>';   
     225    inputTubeHtml += '</tr>';
     226   
     227    var his = 'his'+i;   
     228    inputTubeHtml += '<tr>';
     229    inputTubeHtml += '<td class="subprompt">His</td>';
     230    inputTubeHtml += '<td class="input"><input type="text" name='+his+' value="" size="12" maxlength="10"></td>';
     231    inputTubeHtml += '<td class="status" id="his.status"></td>';
     232    inputTubeHtml += '<td class="help"><span id="'+his+'.message" class="message" style="display: none;"></span>[µg]</td>';   
     233    inputTubeHtml += '</tr>';
     234
     235    var allPrep = 'allPrep' + i;
     236    inputTubeHtml += '<tr>';
     237    inputTubeHtml += '<td class="subprompt">Allprep</td>';
     238    inputTubeHtml += '<td class="input"><input type="text" name='+allPrep+' value="" size="12" maxlength="10"></td>';
     239    inputTubeHtml += '<td class="status" id="'+allPrep+'.status"></td>';
     240    inputTubeHtml += '<td class="help"><span id="'+allPrep+'.message" class="message" style="display: none;"></span>[µg]</td>';   
     241    inputTubeHtml += '</tr>';
     242
     243    var backupWeight = 'backupWeight'+i;
     244    inputTubeHtml += '<tr>';
     245    inputTubeHtml += '<td class="subprompt">Backup weight</td>';
     246    inputTubeHtml += '<td class="input"><input type="text" name='+backupWeight+' value="" size="12" maxlength="10"></td>';
     247    inputTubeHtml += '<td class="status" id="'+backupWeight+'.status"></td>';
     248    inputTubeHtml += '<td class="help"><span id="'+backupWeight+'.message" class="message" style="display: none;"></span>[µg]</td>';   
     249    inputTubeHtml += '</tr>';
     250
     251    var deliveryComment = 'deliveryComment'+i;
     252    inputTubeHtml += '<tr>';
     253    inputTubeHtml += '<td class="subprompt">Operator comment</td>';
     254    inputTubeHtml += '<td class="input"><input type="text" name='+deliveryComment+' value="" size="12" maxlength="10"></td>';
     255    inputTubeHtml += '<td class="status" id="'+deliveryComment+'.status"></td>';
     256    inputTubeHtml += '<td class="help"><span id="'+deliveryComment+'.message" class="message" style="display: none;"></span>Operator delivery comment</td>';   
     257    inputTubeHtml += '</tr>';
     258  }
     259
     260  setInnerHTML('tubeInputs', inputTubeHtml);
     261  Main.show('tubeSection');
     262  Main.hide('gonext');
     263  Main.show('gocreate');
     264 
     265}
     266
     267function samplingDateTimeOnChange()
     268{
     269  var frm = document.forms['reggie'];
     270  samplingDateIsValid = false;
     271  setInputStatus('samplingDate', '', '');
     272 
     273  var samplingDate = frm.samplingDate.value;
     274  var samplingTime = frm.samplingTime.value;
     275 
     276  if (samplingDate != '' || samplingTime != '')
     277  {
     278    // Auto-fill the date if it's only given with 4(MMdd) or 6(yyMMdd) digits.
     279    samplingDate = autoFillDate(samplingDate);
     280    frm.samplingDate.value = samplingDate;
     281
     282    samplingTime = autoFillTime(samplingTime);
     283    frm.samplingTime.value = samplingTime;
     284   
     285    if (!Dates.isDate(samplingDate, 'yyyyMMdd'))
     286    {
     287      setInputStatus('samplingDate', 'Not a valid date', 'invalid');
     288      return;
     289    }
     290    if (frm.rnaLaterDate.value == '') frm.rnaLaterDate.value = samplingDate;
     291   
     292    if (!Dates.isDate(samplingDate + ' ' + samplingTime, 'yyyyMMdd HHmm'))
     293    {
     294      if (samplingDate != '') setInputStatus('samplingDate', 'Not a valid time', 'invalid');
     295      return;
     296    }
     297    setInputStatus('samplingDate', '', 'valid');
     298  }
     299  samplingDateIsValid = true;
     300}
     301
     302function rnaLaterDateTimeOnChange()
     303{
     304  var frm = document.forms['reggie'];
     305  rnaLaterDateIsValid = false;
     306  setInputStatus('rnaLaterDate', '', '');
     307 
     308  var rnaLaterDate = frm.rnaLaterDate.value;
     309  var rnaLaterTime = frm.rnaLaterTime.value;
     310  var rnaLaterTimestamp;
     311 
     312  if (rnaLaterDate != '' || rnaLaterTime != '')
     313  {
     314    // Auto-fill the date if it's only given with 4(MMdd) or 6(yyMMdd) digits.
     315    rnaLaterDate = autoFillDate(rnaLaterDate);
     316    frm.rnaLaterDate.value = rnaLaterDate;
     317
     318    rnaLaterTime = autoFillTime(rnaLaterTime);
     319    frm.rnaLaterTime.value = rnaLaterTime;
     320   
     321    if (!Dates.isDate(rnaLaterDate, 'yyyyMMdd'))
     322    {
     323      setInputStatus('rnaLaterDate', 'Not a valid date', 'invalid');
     324      return;
     325    }
     326    rnaLaterTimestamp = Dates.parseString(rnaLaterDate + ' ' + rnaLaterTime, 'yyyyMMdd HHmm');
     327    if (rnaLaterTimestamp == null)
     328    {
     329      if (rnaLaterDate != '') setInputStatus('rnaLaterDate', 'Not a valid time', 'invalid');
     330      return;
     331    }
     332    setInputStatus('rnaLaterDate', '', 'valid');
     333  }
     334   
     335  rnaLaterDateIsValid = true;
     336
     337  if (samplingDateIsValid && rnaLaterTimestamp)
     338  {
     339    var samplingTimestamp = Dates.parseString(frm.samplingDate.value + ' ' + frm.samplingTime.value, 'yyyyMMdd Hmm');
     340    if (samplingTimestamp && rnaLaterTimestamp.getDate() != samplingTimestamp.getDate())
     341    {
     342      setInputStatus('rnaLaterDate', 'Sampling and RNA later dates are different', 'warning');
     343    }
     344  }
     345}
     346
     347function arrivalDateOnBlur()
     348{
     349  var frm = document.forms['reggie'];
     350  var arrivalDate = frm.arrivalDate.value;
     351  arrivalDateIsValid = false;
     352
     353  setInputStatus('arrivalDate', '', '');
     354
     355  if (arrivalDate != '')
     356  {
     357    arrivalDate = autoFillDate(arrivalDate);
     358    frm.arrivalDate.value = arrivalDate;
     359
     360    if (!Dates.isDate(arrivalDate, 'yyyyMMdd'))
     361    {
     362      setInputStatus('arrivalDate', 'Not a valid date', 'invalid');
     363      return;
     364    }
     365    setInputStatus('arrivalDate', '', 'valid');
     366    arrivalDateIsValid = true;   
     367  }
     368  else
     369  {
     370    setInputStatus('arrivalDate', 'Missing', 'warning');
     371  }
     372}
     373
     374function nofTubesOnBlur()
     375{
     376  var frm = document.forms['reggie'];
     377  var nofTubes = frm.nofTubes.value;
     378
     379  if (nofTubes == '')
     380  {
     381    setInputStatus('nofTubes', 'Missing', 'invalid');
     382    return;
     383  }
     384  setInputStatus('nofTubes','', 'valid');
    42385}
    43386
     
    53396  setInputStatus('case', '', 'valid');
    54397  caseIsValid = true;
    55 }
    56 
    57 function tubeNumberOnBlur()
    58 {
    59   var frm = document.forms['reggie'];
    60   var tubeNumber = frm.tubeNumber.value;
    61   if (tubeNumber == '')
    62   {
    63     setInputStatus('tnr', 'Missing', 'invalid');
     398
     399  getCaseInfo();
     400}
     401
     402function padOnChange()
     403{
     404  var frm = document.forms['reggie'];
     405  var PAD = frm.pad.value;
     406  if (PAD == '')
     407  {
     408    setInputStatus('pad', 'Missing', 'warning');
    64409    return;
    65410  }
    66   setInputStatus('tnr', '', 'valid');
    67   tubeNumberIsValid = true;
    68 }
    69 
    70 function goNext(manual)
    71 {
    72   setInnerHTML('gonext.message', '');
    73   if (currentStep == 1)
    74   {
    75     if(step1IsValid())
    76     {
    77       gotoStep2();
    78     }
    79   }
    80 }
    81 
    82 function step2IsValid()
    83 {
    84   var isValid = arrivalDateIsValid && nofDeliveredTubesIsValid;
    85   return isValid;
    86 }
    87 
    88 function step1IsValid()
    89 {
    90   return caseIsValid && tubeNumberIsValid;
    91 }
    92 
    93 function gotoStep2()
    94 {
    95   var frm = document.forms['reggie'];
     411  frm.pad.value = PAD.replace(/\+/, '-');
     412  setInputStatus('pad', '', 'valid');
     413}
     414
     415function lateralityOnChange()
     416{
     417  lateralityIsValid = false;
     418  var updateMode = caseInfo.id;
     419 
     420  // Check selected laterality against specimen tubes
     421  var frm = document.forms['reggie'];
     422  var selectedLaterality = Forms.getCheckedRadio(frm.laterality);
     423 
     424  // No laterality/case selected
     425  if (selectedLaterality == null)
     426  {
     427    setInputStatus('laterality', 'Not selected', 'invalid');
     428    return;
     429  }
     430  var laterality = selectedLaterality.value; 
     431  // No specimen tubes?
     432  if (!caseInfo.specimen || caseInfo.specimen.length == 0) return;
     433 
     434  for (var i = 0; i < caseInfo.specimen.length; i++)
     435  {
     436    var specimen = caseInfo.specimen[i];
     437    if (specimen.laterality != laterality)
     438    {
     439      if (specimen.laterality == null || updateMode)
     440      {
     441        setInputStatus('laterality', 'Specimen tubes are updated to: ' + laterality, 'valid')
     442      }
     443      else
     444      {
     445        setInputStatus('laterality', 'Not same laterality as specimen tubes', 'warning');
     446      }
     447      return;
     448    }
     449  }
     450}
     451
     452function getCaseInfo()
     453{
     454  var frm = document.forms['reggie'];
    96455  var caseName = frm.caseName.value;
    97   var tubeNumber = frm.tubeNumber.value;
    98456  var request = Ajax.getXmlHttpRequest();
    99   var url = 'SpecimenTubeRegistration.servlet?ID=<%=ID%>&cmd=GetSpecimenTubeInfo';
     457  var url = 'SpecimenTubeRegistration.servlet?ID=<%=ID%>&cmd=GetCaseInfo';
    100458  url += '&caseName=' + caseName;
    101   url += '&specimenTubeNumber=' + tubeNumber;
    102459  request.open("GET", url, false);
    103460  request.send(null);
     
    111468    return false;
    112469  }
    113  
    114   // Get sample information from the AJAX response
    115   specimenTubeInfo = response.specimenTubeInfo;
    116 
    117   Main.show('gocancel');
    118   if (!specimenTubeInfo.id)
    119   {
    120     Main.show('newSpecimenTubeSection');
    121     frm.arrivalDate.focus();
    122   }
    123 
    124   currentStep == 2;
    125   Main.hide('gonext');
    126   Main.show('gocreate');
    127 }
    128 
    129 function arrivalDateOnChange()
    130 {
    131   var frm = document.forms['reggie'];
    132   arrivalDateIsValid = false;
    133   setInputStatus('arrivalDate', '', '');
    134 
    135   var arrivalDate = frm.arrivalDate.value;
    136 
    137   if (arrivalDate != '')
    138   {
    139     arrivalDate = autoFillDate(arrivalDate);
    140     frm.arrivalDate.value = arrivalDate;
    141 
    142     if (!Dates.isDate(arrivalDate, 'yyyyMMdd'))
    143     {
    144       setInputStatus('arrivalDate', 'Not a valid date', 'invalid');
    145       return;
    146     }
    147     setInputStatus('arrivalDate', '', 'valid');
    148     arrivalDateIsValid = true;
    149   }
    150 }
    151 
    152 function nofDeliveredTubesOnKeyup()
    153 {
    154   var frm = document.forms['reggie'];
    155   var nofTubes = frm.nofDeliveredTubes.value;
    156   if (nofTubes != '')
    157   {
    158     if (isNaN(nofTubes))
    159     {
    160       setInputStatus('nofDeliveredTubes', 'Must be a number', 'invalid');
    161       nofDeliveredTubesIsValid = false;
    162       return;
    163     }
    164     setInputStatus('nofDeliveredTubes', '', 'valid');
    165     nofDeliveredTubesIsValid = true;
    166   }
    167 }
    168 
    169 function goCreate()
    170 {
    171   if (!step2IsValid()) return;
    172   Main.hide('gocreate');
    173   Main.hide('gocancel');
    174   var frm = document.forms['reggie'];
    175 
    176   specimenTubeInfo.name = frm.caseName.value + '.' + frm.tubeNumber.value;
    177   specimenTubeInfo.arrivalDate = frm.arrivalDate.value;
    178   specimenTubeInfo.nofDeliveredTubes = frm.nofDeliveredTubes.value;
    179 
    180   if (debug) Main.debug(JSON.stringify(specimentTubeInfo));
    181 
    182   var request = Ajax.getXmlHttpRequest();
    183   var url = 'SpecimenTubeRegistration.servlet?ID=<%=ID%>&cmd=';
    184   url += 'CreateSpecimenTube';
    185   request.open("POST", url, false);
    186   request.setRequestHeader("Content-Type", "application/json");
    187   request.send(JSON.stringify(specimenTubeInfo));
    188 
    189   if (debug) Main.debug(request.responseText);
    190 
    191   var response = JSON.parse(request.reponseText);
    192   if(response.status != 'ok')
    193   {
    194     setFatalError(response.message);
    195     return false;
    196   }
    197 
    198   var msg = '<ul>';
    199   for (var i=0; i < resposne.messages.length; i++)
    200   {
    201     msg +='<li>' + reponse.messages[i];
    202   }
    203   msg += '</ul>';
    204   setInnerHTML('done', msg);
    205   Main.show('done');
    206   Main.show('gorestart');
     470
     471  caseInfo = response.caseInfo;
     472  if (caseInfo)
     473  {
     474    gotoStep2();
     475  }
    207476}
    208477
     
    230499  <form name="reggie" onsubmit="return false;">
    231500 
    232   <!-- 1. Case and tube number-->
     501  <!-- 1. Case name-->
    233502  <table border="0" cellspacing="0" cellpadding="0" class="stepform">
    234503  <tr>
    235504    <td rowspan="3" class="stepno">1</td>
    236     <td class="steptitle">Enter Case Name and tube number</td>
     505    <td class="steptitle">Enter Case Name</td>
    237506  </tr>
    238507  <tr>
     
    242511        <td class="prompt">Case name</td>
    243512        <td class="input"><input type="text" name="caseName"
    244           size="18" maxlength="12" onblur="caseNameOnBlur()" onkeypress="focusOnEnter(event, 'tubeNumber')"></td>
     513          size="18" maxlength="12" onblur="caseNameOnBlur()"></td>
    245514        <td class="status" id="case.status"></td>
    246515        <td class="help"><span id="case.message" class="message" style="display: none;"></span>The case (barcode) associated with this specimen tube.</td>
    247       </tr>
    248       <tr>
    249         <td class="prompt">Tube number</td>
    250         <td class="input"><input type="text" name="tubeNumber"
    251           size="18" maxlength="12" onblur="tubeNumberOnBlur()" onkeypress="doOnTabOrEnter(event, goNext)"></td>
    252         <td class="status" id="tnr.status"></td>
    253         <td class="help"><span id="tnr.message" class="message" style="display: none;"></span>The number associated with this specimen tube.</td>
    254516      </tr>
    255517      </table>
     
    257519  </tr>
    258520  </table>
    259   <div id="newSpecimenTubeSection" style="display:none;">
    260   <p>
     521 
     522  <div id="caseSection" style="display: none;">
     523  <p></p>
    261524  <table border="0" cellspacing="0" cellpadding="0" class="stepform">
    262525  <tr>
    263526    <td rowspan="2" class="stepno">2</td>
    264     <td class="steptitle">New specimen tube: Enter specimen information</td>
     527    <td id="step2.title" class="steptitle">Enter Case information</td>
    265528  </tr>
    266529  <tr>
    267530    <td class="stepfields">
    268       <table border="0" cellspacing="0" cellpadding="0" width="100%">
    269       <tr>
    270         <td class="prompt">Arrival date</td>
    271         <td class="input"><input type="text" name="arrivalDate"
    272           value="" size="18" maxlength="12" onblur="arrivalDateOnChange()"
    273           onkeypress="focusOnEnter(event, 'arrivalDate')"></td>
    274         <td class="status" id="arrivalDate.status"></td>
    275         <td class="help"><span id="arrivalDate.message" class="message" style="display: none;"></span>Date(YYYYMMDD) when this specimen tube arrived.</td>
    276       </tr>
    277       <tr>
    278         <td class="prompt">Number of delivered tubes</td>
    279         <td class="input"><input type="text" name="nofDeliveredTubes"
    280           value="" size="18" maxlength="12" onkeyup="nofDeliveredTubesOnKeyup()"
    281           onkeypress="focusOnEnter(event, 'nofDeliveredTubes')"></td>
    282         <td class="status" id="nofDeliveredTubes.status"></td>
    283         <td class="help"><span id="nofDeliveredTubes.message" class="message" style="display: none;"></span>Number of speciment tubes that were delivered.</td>
    284       </tr>
     531    <table border="0" cellspacing="0" cellpadding="0" width="100%">
     532    <tr>
     533      <td class="prompt">Number of tubes</td>
     534      <td class="input"><input type="text" name="nofTubes"
     535        value="" size="12" maxlength="10" onblur="nofTubesOnBlur()"></td>
     536      <td class="status" id="nofTubes.status"></td>
     537      <td class="help"><span id="nofTubes.message" class="message" style="display:none"></span>Number of tubes in this case.</td>
     538    </tr>
     539    <tr valign="top">
     540      <td class="prompt">Arrival date</td>
     541      <td class="input"><input type="text" name="arrivalDate"
     542        value="" size="12" maxlength="10" onblur="arrivalDateOnBlur()"></td>
     543      <td class="status" id="arrivalDate.status"></td>
     544      <td class="help"><span id="arrivalDate.message" class="message" style="display:none"></span>Date when the specimen tubes arrived(YYYYMMDD or MMDD).</td>
     545    </tr>
     546    <tr>
     547      <td class="prompt">PAD</td>
     548      <td class="input"><input type="text" name="pad"
     549        value="" size="12" maxlength="10"
     550        onblur="padOnChange()"></td>
     551      <td class="status" id="pad.status"></td>
     552      <td class="help"><span id="pad.message" class="message" style="display: none;"></span></td>
     553    </tr>
     554    <tr id="samplingDateSection" valign="top">
     555      <td class="prompt">Sampling date</td>
     556      <td class="input"><input type="text" name="samplingDate" value="" size="12" maxlength="10"
     557          onkeypress="focusOnEnter(event, 'samplingTime')" onblur="samplingDateTimeOnChange()">
     558        Time <input type="text" name="samplingTime" value="" size="6" maxlength="4"
     559          onkeypress="focusOnEnter(event, 'rnaLaterDate')" onblur="samplingDateTimeOnChange()"></td>
     560      <td class="status" id="samplingDate.status"></td>
     561      <td class="help"><span id="samplingDate.message" class="message" style="display: none;"></span>Date+time of surgical removal (YYYYMMDD, HHMM)</td>
     562    </tr>
     563    <tr id="rnaLaterDateSection" valign="top">
     564      <td class="prompt">RNA Later date</td>
     565      <td class="input"><input type="text" name="rnaLaterDate" value="" size="12" maxlength="10"
     566          onkeypress="focusOnEnter(event, 'rnaLaterTime')" onblur="rnaLaterDateTimeOnChange()">
     567        Time <input type="text" name="rnaLaterTime" value="" size="6" maxlength="4"
     568          onblur="rnaLaterDateTimeOnChange()"></td>
     569      <td class="status" id="rnaLaterDate.status"></td>
     570      <td class="help"><span id="rnaLaterDate.message" class="message" style="display: none;"></span>Date+time of pathology handling (YYYYMMDD, HHMM)</td>
     571    </tr>
     572    <tr>
     573      <td class="prompt" id="laterality.prompt">Laterality</td>
     574      <td class="input" id="laterality.input">
     575        <input type="radio" name="laterality" value="LEFT" onclick="lateralityOnChange()">LEFT<br>
     576        <input type="radio" name="laterality" value="RIGHT" onclick="lateralityOnChange()">RIGHT<br>
     577        <input type="radio" name="laterality" value="" onclick="lateralityOnChange()"><i>unknown</i>
     578      </td>
     579      <td class="status" id="laterality.status"></td>
     580      <td class="help"><span id="laterality.message" class="message" style="display: none;"></span></td>
     581    </tr>
     582    <tr>
     583      <td class="prompt" id="pathNote.prompt">Path note</td>
     584      <td class="input" id="pathNote.input"><textarea rows="3" cols="30" name="pathNote" value=""></textarea></td>
     585      <td class="status" id="pathNote.status"></td>
     586      <td class="help"><span id="pathNote.message" class="message" style="display: none;"></span></td>
     587    </tr>
     588    </table>
     589    </td>
     590     
     591  </tr>
     592  </table>
     593  </div>
     594 
     595  <div id="tubeSection" style="display:none;">
     596  <p></p>
     597  <table border="0" cellspacing="0" cellpadding="0" class="stepform">
     598  <tr>
     599    <td rowspan="2" class="stepno">3</td>
     600    <td class="steptitle">Enter tube information</td>   
     601  </tr>
     602  <tr>
     603    <td class="stepfields">
     604      <table id="tubeInputs" border="0" cellspacing="0" cellpadding="0" width="100%">
    285605      </table>
    286606    </td>
     
    288608  </table>
    289609  </div>
     610   
     611  <div class="error" id="errorMessage" style="display: none; width: 800px; margin-left: 20px; margin-bottom: 0px;"></div>
     612 
     613  <div id="done" class="success" style="display: none; width: 800px; margin-left: 20px; margin-top: 20px;"></div>
    290614 
    291615  <table style="margin-left: 20px; margin-top: 10px;" class="navigation">
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/InstallServlet.java

    r1372 r1375  
    127127        jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_ARRIVAL_DATE, Item.SAMPLE, Type.DATE, 1,
    128128            null, effectiveOptions, createIfMissing));
    129         jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_NOF_DELIVERED_TUBES, Item.SAMPLE, Type.STRING, 1,
     129        jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_NOF_DELIVERED_TUBES, Item.SAMPLE, Type.INT, 1,
    130130            null, effectiveOptions, createIfMissing));
    131131       
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/SpecimenTubeServlet.java

    r1372 r1375  
    22
    33import java.io.IOException;
     4import java.text.SimpleDateFormat;
     5import java.util.Date;
     6import java.util.List;
    47
    58import javax.servlet.ServletException;
     
    811import javax.servlet.http.HttpServletResponse;
    912
     13import net.sf.basedb.core.AnnotationSet;
     14import net.sf.basedb.core.AnnotationType;
    1015import net.sf.basedb.core.Application;
    1116import net.sf.basedb.core.DbControl;
     17import net.sf.basedb.core.Item;
     18import net.sf.basedb.core.Sample;
    1219import net.sf.basedb.core.SessionControl;
     20import net.sf.basedb.reggie.Reggie;
     21import net.sf.basedb.reggie.converter.DateToStringConverter;
     22import net.sf.basedb.reggie.converter.StringToDateConverter;
     23import net.sf.basedb.reggie.dao.Case;
    1324import net.sf.basedb.reggie.dao.SpecimenTube;
     25import net.sf.basedb.util.Values;
    1426import net.sf.basedb.util.error.ThrowableUtil;
    1527
     28import org.json.simple.JSONArray;
    1629import org.json.simple.JSONObject;
     30import org.json.simple.parser.JSONParser;
    1731
    1832
     
    4458    try
    4559    {
    46       if ("GetSpecimenTubeInfo".equals(cmd))
     60      if ("GetCaseInfo".equals(cmd))
    4761      {
    4862        dc = sc.newDbControl();
    49         JSONObject jsonTube = null;
    5063       
    5164        String caseName = req.getParameter("caseName");
    52         String tubeNumber = req.getParameter("tubeNumber");
    53         String tubeName = caseName + "." + tubeNumber;
     65        Case theCase = Case.findByName(dc, caseName);
     66        List<SpecimenTube> specimenTubes = null;
     67        JSONObject jsonCase = null;
    5468       
    55         jsonTube = new JSONObject();
    56        
    57         SpecimenTube tube = SpecimenTube.findByTubeName(dc, tubeName);       
    58         if (tube != null)
     69        if (theCase == null)
    5970        {
    60           jsonTube = tube.asJSONObject();
     71          specimenTubes = SpecimenTube.findByCaseName(dc, caseName);
     72          jsonCase = new JSONObject();
     73          jsonCase.put("name", caseName);
    6174        }
    6275        else
    6376        {
    64           jsonTube.put("name", tubeName);
     77          // Load specimen tubes for the case
     78          specimenTubes = SpecimenTube.findByCase(dc, theCase, true);
     79         
     80          // Load case annotations
     81          theCase.loadAnnotations(dc, "laterality", Reggie.ANNOTATION_LATERALITY, null);
     82          theCase.loadAnnotations(dc, "pad", Reggie.ANNOTATION_PAD_CASE, null);
     83          theCase.loadAnnotations(dc, "reasonIfNoSpeciment", Reggie.ANNOTATION_REASON_IF_NO_SPECIMEN, null);
     84         
     85          jsonCase = theCase.asJSONObject();
    6586        }
    66         json.put("specimenTubeInfo", jsonTube);
     87       
     88        JSONArray jsonTubes = new JSONArray();
     89        if (specimenTubes.size() > 0)
     90        {
     91          AnnotationType padType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PAD, true);
     92          AnnotationType laterlityType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_LATERALITY, true);
     93          AnnotationType samplingDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_SAMPLING_DATETIME, true);
     94          AnnotationType rnaLaterDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_RNALATER_DATETIME, true);
     95          AnnotationType arrivalDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_ARRIVAL_DATE, true);
     96          AnnotationType nofDeliveredTubesType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_NOF_DELIVERED_TUBES, true);
     97         
     98          DateToStringConverter dateTimeConverter = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd HHmm"));
     99          DateToStringConverter dateConverter = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd"));
     100          for (SpecimenTube tube : specimenTubes)
     101          {
     102            tube.loadAnnotations("pad", padType, null);
     103            tube.loadAnnotations("laterality", laterlityType, null);
     104            tube.loadAnnotations("samplingDate", samplingDateType, dateTimeConverter);
     105            tube.loadAnnotations("rnaLaterDate", rnaLaterDateType, dateTimeConverter);
     106            tube.loadAnnotations("arrivalDate", arrivalDateType, dateConverter);
     107            tube.loadAnnotations("nofTubes", nofDeliveredTubesType, null);
     108           
     109            jsonTubes.add(tube.asJSONObject());
     110          }
     111        }
     112        jsonCase.put("specimen", jsonTubes);
     113       
     114        json.put("caseInfo", jsonCase);
    67115      }
    68116    }
     
    87135    throws ServletException, IOException
    88136  {
     137    String ID = req.getParameter("ID");
     138    String cmd = req.getParameter("cmd");
     139    resp.setContentType("application/json");
     140    resp.setCharacterEncoding("UTF-8");
    89141   
     142    JSONObject json = new JSONObject();
     143    json.put("status", "ok");
     144   
     145    JSONArray jsonMessages = new JSONArray();
     146   
     147    final SessionControl sc = Application.getSessionControl(ID, req.getRemoteAddr());
     148    DbControl dc = null;
     149   
     150    try
     151    {
     152      if ("CreateSpecimenTube".equals(cmd))
     153      {
     154       
     155       
     156        dc.commit();
     157        json.put("messages", jsonMessages);
     158      }     
     159    }
     160    catch (Throwable t)
     161    {
     162      t.printStackTrace();
     163      json.clear();
     164      json.put("status", "error");
     165      json.put("message", t.getMessage());
     166      json.put("stacktrace", ThrowableUtil.stackTraceToString(t));
     167    }
     168    finally
     169    {
     170      if (dc != null) dc.close();
     171      json.writeJSONString(resp.getWriter());
     172    }
    90173  }
    91174}
Note: See TracChangeset for help on using the changeset viewer.