Changeset 1379


Ignore:
Timestamp:
Jun 27, 2011, 3:58:52 PM (12 years ago)
Author:
Martin Svensson
Message:

References #317. Added a section to fill in information for each individual specimen tube in a case. Also began to build the finishing create-process, which will create or update the items BASE

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

Legend:

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

    r1375 r1379  
    3030var nofDeliveredTubesIsValid = true;
    3131var nofTubesIsValid = false;
     32var lateralityIsValid = false;
    3233var debug = false;
    3334var currentStep = 1;
    3435
    3536var caseInfo = null;
    36 var specimenTubeInfo = null;
     37var boxInfo = null;
    3738
    3839function init()
     
    4243}
    4344
    44 function goNext(manual)
     45function goNext()
    4546{
    4647  setInnerHTML('gonext.message', '');
    4748  if (currentStep == 1)
    48   {
    49     if(step1IsValid())
    50     {
    51       gotoStep2();
    52     }
    53   }
    54   if (currentStep == 2)
    55   {
    56     gotoStep3();
    57   }
     49  {   
     50    gotoStep2();
     51  }
     52  else if (currentStep == 2)
     53  {
     54    if (step2IsValid()) gotoStep3();
     55  }
     56}
     57
     58function step2IsValid()
     59{
     60  var frm = document.forms['reggie'];
     61  if (!nofTubesIsValid) frm.nofTubes.focus();
     62  else if (lateralityIsValid) return true;
    5863}
    5964
     
    6166{
    6267  var frm = document.forms['reggie'];
    63   frm.caseName.disabled = true;
    64   currentStep = 2;
     68  var caseName = frm.caseName.value;
     69  if (caseName == '')
     70  {
     71    setInputStatus('case', 'Missing', 'invalid');
     72    return;
     73  }
     74  setInputStatus('case', '', 'valid');
     75 
     76  getCaseInfo();
     77 
    6578  var hasSpecimen = caseInfo.specimen && caseInfo.specimen.length > 0;
    6679  var hasLeftSpecimen = false;
     
    7487  var thisPad = null;
    7588
     89  frm.caseName.disabled = true;
     90   
    7691  Main.show('gocancel');
    7792  Main.show('caseSection');
    78 
     93 
     94  frm.nofTubes.focus();
     95  currentStep = 2;
     96     
     97  // Load annotations from the actual case
     98  if (hasSpecimen)
     99  {
     100    frm.nofTubes.value = thisNumberOfTubes;
     101    frm.nofTubes.disabled = true;
     102    frm.arrivalDate.focus();
     103    for (var i=0; i < caseInfo.specimen.length; i++)
     104    {
     105      var specimen = caseInfo.specimen[i];       
     106      if (specimen.pad && !thisPad)
     107      {         
     108        thisPad = specimen.pad;
     109      }
     110      if(specimen.arrivalDate && !thisArrivalDate)
     111      {
     112        thisArrivalDate = specimen.arrivalDate;
     113      }
     114      if (specimen.nofTubes && !thisNumberOfTubes)
     115      {
     116        thisNumberOfTubes = specimen.nofTubes;
     117      }
     118      if (specimen.samplingDate && !thisCaseSamplingDate)
     119      {
     120        thisCaseSamplingDate = specimen.samplingDate;         
     121      }
     122      if (specimen.rnaLaterDate && !thisCaseRNALaterDate)
     123      {
     124        thisCaseRNALaterDate = specimen.rnaLaterDate;
     125      }
     126      if (specimen.laterality && !thisCaseLaterality)
     127      {
     128        if (specimen.laterality == 'LEFT') hasLeftSpecimen = true;
     129        if (specimen.laterality == 'RIGHT') hasRightSpecimen = true;
     130        thisCaseLaterality = specimen.laterality;
     131      }
     132      else if(!thisCaseLaterality)
     133      {
     134        hasUnknownSpecimen = true;       
     135      }
     136    }
     137    // If the number of tubes not is set - use the current number of specimen tubes.
     138    if (!thisNumberOfTubes) thisNumberOfTubes = caseInfo.specimen.length;
     139         
     140    // Check that all specimen tubes have the same laterality
     141    var numLateralities = 0;
     142    if (hasLeftSpecimen) numLateralities++;
     143    if (hasRightSpecimen) numLateralities++;
     144    if (hasUnknownSpecimen) numLateralities++;     
     145    if (numLateralities > 1)
     146    {
     147      setInputStatus('laterality', 'Specimen tubes with different laterality', 'warning');
     148      thisCaseLaterality = null;
     149      Forms.checkRadio(frm.laterality, thisCaseLaterality);       
     150    }     
     151    Forms.checkRadio(frm.laterality, thisCaseLaterality);
     152    lateralityOnChange();
     153   
     154    if (thisPad != null)
     155    {
     156      frm.pad.value = thisPad;
     157      padOnChange();
     158    }
     159    if (thisArrivalDate != null)
     160    {
     161      frm.arrivalDate.value = thisArrivalDate;
     162    }
     163    if (thisNumberOfTubes != null)
     164    {
     165      frm.nofTubes.value = thisNumberOfTubes;
     166      nofTubesOnChange();
     167    }
     168    if (thisCaseSamplingDate != null)
     169    {
     170      frm.samplingDate.value = thisCaseSamplingDate.substring(0, 8);
     171      frm.samplingTime.value = thisCaseSamplingDate.substring(9, 13);
     172      samplingDateTimeOnChange();
     173    }
     174    if (thisCaseRNALaterDate != null)
     175    {
     176      frm.rnaLaterDate.value = thisCaseRNALaterDate.substring(0, 8);
     177      frm.rnaLaterTime.value = thisCaseRNALaterDate.substring(9, 13);
     178      rnaLaterDateTimeOnChange();
     179    }
     180  }
     181
     182  var hasLeftCase = false;
     183  var hasRightCase = false;
     184  var hasUnknownCase = false;
    79185  if (caseInfo.id)
    80186  {
    81187    setInnerHTML('step2.title', 'Update Case Information');
    82     if (caseInfo.pad)
     188    if (caseInfo.pad && !thisPad)     
    83189    {     
    84       frm.pad.value = caseInfo.pad;
     190      thisPad = caseInfo.pad;     
    85191    }
    86192    if (caseInfo.laterality)
    87193    {
    88       if(caseInfo.laterality == 'LEFT') hasLeftSpecimen = true;
    89       if(caseInfo.laterality == 'RIGHT') hasRightSpecimen = true;
    90       thisCaseLaterality = caseInfo.laterality;
    91       Forms.checkRadio(frm.laterality, thisCaseLaterality);
     194      var lateralityInput = '';
     195      lateralityInput += '<input type="radio" name="laterality" value="LEFT" ';
     196      if (caseInfo.laterality == 'LEFT') lateralityInput += 'checked';
     197      lateralityInput += ' onChange="lateralityOnChange()">LEFT';
     198      lateralityInput += '<br>';
     199      lateralityInput += '<input type="radio" name="laterality" value="RIGHT" ';
     200      if (caseInfo.laterality == 'RIGHT') lateralityInput += 'checked';
     201      lateralityInput += ' onChange="lateralityOnChange()">RIGHT';
     202      setInnerHTML('laterality.input', lateralityInput);
    92203      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       }
    174204    }
    175205  }
     
    193223  frm.rnaLaterTime.disabled = true;
    194224  frm.samplingTime.disabled = true;
    195   frm.pathNote.disabled = true; 
     225  frm.pathNote.disabled = true;
    196226 
    197227  for (var i=0;i<nofTubes;i++)
    198228  {
    199229    var specimen = null;
     230    var boxValue = '';
     231    var rowValue = '';
     232    var columnValue = '';
    200233    if (caseInfo.specimen && caseInfo.specimen.length>0 && i<caseInfo.specimen.length)
    201234    {
    202235      specimen = caseInfo.specimen[i];
     236      boxValue = specimen.box;
     237      rowValue = specimen.row;
     238      columnValue = specimen.column;
    203239    }
    204240    inputTubeHtml += '<tr>';
     
    209245    inputTubeHtml += '<tr>';
    210246    inputTubeHtml += '<td class="subprompt">Box</td>';
    211     inputTubeHtml += '<td class="input"><input type="text" name='+box+' value="" size="12" maxlength="10"></td>';
     247    inputTubeHtml += '<td class="input"><input type="text" name='+box+' value="' + boxValue + '" size="18" maxlength="12" onBlur="boxOnChange('+i+')"></td>';
    212248    inputTubeHtml += '<td class="status" id="'+box+'.status"></td>';
    213249    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>';
     250    inputTubeHtml += '</tr>';       
    215251
    216252    var row = 'row'+i;
     
    218254    inputTubeHtml += '<tr>';
    219255    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">';
     256    inputTubeHtml += '<td class="input"><input type="text" name='+row+' value="' + rowValue + '" size="3" maxlength="3"';
     257    inputTubeHtml += boxValue != '' ? '' : ' disabled';
     258    inputTubeHtml += ' onBlur="wellOnChange('+i+')">';
     259    inputTubeHtml += '&nbsp;Column<input type="text" name='+column+' value="'+ columnValue + '" size="3" maxlength="3"';
     260    inputTubeHtml += boxValue != '' ? '' : ' disabled';
     261    inputTubeHtml += ' onBlur="wellOnChange('+i+')">';
    222262    inputTubeHtml += '</td>';
    223263    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>';   
     264    inputTubeHtml += '<td class="help"><span id="rowColumn'+i+'.message" class="message" style="display: none;"></span></td>';   
    225265    inputTubeHtml += '</tr>';
    226266   
     
    252292    inputTubeHtml += '<tr>';
    253293    inputTubeHtml += '<td class="subprompt">Operator comment</td>';
    254     inputTubeHtml += '<td class="input"><input type="text" name='+deliveryComment+' value="" size="12" maxlength="10"></td>';
     294    inputTubeHtml += '<td class="input"><textarea rows="3" cols="30" name='+deliveryComment+' value=""></textarea></td>';
    255295    inputTubeHtml += '<td class="status" id="'+deliveryComment+'.status"></td>';
    256296    inputTubeHtml += '<td class="help"><span id="'+deliveryComment+'.message" class="message" style="display: none;"></span>Operator delivery comment</td>';   
    257297    inputTubeHtml += '</tr>';
    258298  }
    259 
    260299  setInnerHTML('tubeInputs', inputTubeHtml);
    261   Main.show('tubeSection');
     300  boxInfo = Array();
     301  currentStep = 3;
     302  Main.show('tubeSection');
    262303  Main.hide('gonext');
    263   Main.show('gocreate');
    264  
     304  Main.show('gocreate'); 
     305  frm.box0.focus();
    265306}
    266307
     
    300341}
    301342
     343function boxOnChange(tubeIndex)
     344{
     345  var frm = document.forms['reggie'];
     346  var boxName = 'box'+tubeIndex;
     347  var rowName = 'row'+tubeIndex;
     348  var columnName = 'column'+tubeIndex; 
     349  var boxValue = frm.elements[boxName].value;
     350 
     351  if (frm.elements[boxName].value == '')
     352  {
     353    frm.elements[rowName].disabled = true;
     354    frm.elements[rowName].value = '';
     355    frm.elements[columnName].disabled = true;
     356    frm.elements[columnName].value = '';
     357    frm.elements['his'+tubeIndex].focus();
     358    setInputStatus(boxName, '', ''); 
     359    setInputStatus('rowColumn'+tubeIndex, '', '');       
     360    return false;
     361  }
     362   
     363  var request = Ajax.getXmlHttpRequest();
     364  var url = 'SpecimenTubeRegistration.servlet?ID=<%=ID%>&cmd=GetBoxInfo';
     365  url += '&boxName=' + boxValue; 
     366  request.open("GET", url, false);
     367  request.send(null);
     368
     369  if (debug) Main.debug(request.responseText);
     370
     371  var response = JSON.parse(request.responseText);
     372  if (response.status != 'ok')
     373  {
     374    setFatalError(response.message);
     375    return false;
     376  }
     377  if (!response.boxInfo)
     378  {
     379    setInputStatus(boxName, response.message, 'invalid');
     380    frm.elements[rowName].value = '';
     381    frm.elements[columnName].value = '';
     382    frm.elements[rowName].disabled = true;
     383    frm.elements[columnName].disabled = true;
     384    return false;
     385  }   
     386  else
     387  {
     388    boxInfo[tubeIndex] = response.boxInfo; 
     389    frm.elements[rowName].disabled = false;
     390    frm.elements[columnName].disabled = false;
     391    frm.elements[rowName].value = '';
     392    setInputStatus('rowColumn'+tubeIndex,'Row[A-'+response.rows+'], Columns[1-'+response.columns+']','');   
     393    frm.elements[columnName].disabled = '';
     394    setInputStatus(boxName, '', 'valid');   
     395    frm.elements[rowName].focus();   
     396  }   
     397}
     398
     399function wellOnChange(tubeIndex)
     400{
     401  var frm = document.forms['reggie'];
     402  var boxName = 'box'+tubeIndex;
     403  var rowName = 'row'+tubeIndex;
     404  var columnName = 'column'+tubeIndex;
     405  var rowValue = frm.elements[rowName].value;
     406  var columnValue = frm.elements[columnName].value
     407  var boxValue = frm.elements[boxName].value;
     408  var nofTubes = frm.nofTubes.value;
     409 
     410  if (boxValue != '' &&
     411      (rowValue == '' || columnValue == ''))
     412  {
     413    setInputStatus('rowColumn'+tubeIndex, 'Row or column cannot be empty when the box is specified.', 'invalid');
     414    return false;
     415  }
     416 
     417  var request = Ajax.getXmlHttpRequest();
     418  var url = 'SpecimenTubeRegistration.servlet?ID=<%=ID%>&cmd=ValidateWell';
     419  url += '&boxId=' + boxInfo[tubeIndex]; 
     420  url += '&row=' + rowValue;
     421  url += '&column=' + columnValue;
     422  request.open("GET", url, false);
     423  request.send(null);
     424
     425  if (debug) Main.debug(request.responseText);
     426
     427  var response = JSON.parse(request.responseText);
     428  if (response.status != 'ok')
     429  {
     430    setFatalError(response.message);
     431    return false;
     432  }
     433  if (response.message)
     434  {
     435    setInputStatus('rowColumn'+tubeIndex, response.message, 'invalid')
     436    return false;
     437  }
     438  for (var i=0;i<nofTubes;i++)
     439  {
     440    if (i != tubeIndex && frm.elements['box'+i].value == boxValue)
     441    {
     442      if (rowValue == frm.elements['row'+i].value &&
     443          columnValue == frm.elements['column'+i].value)
     444      {
     445        setInputStatus('rowColumn'+tubeIndex, 'The row and column are already used once in this wizard','invalid');       
     446        return false;
     447      }
     448    }
     449  }
     450  setInputStatus('rowColumn'+tubeIndex, '', 'valid');
     451}
     452
    302453function rnaLaterDateTimeOnChange()
    303454{
     
    372523}
    373524
    374 function nofTubesOnBlur()
     525function nofTubesOnChange()
    375526{
    376527  var frm = document.forms['reggie'];
     
    382533    return;
    383534  }
    384   setInputStatus('nofTubes','', 'valid');
    385 }
    386 
    387 function caseNameOnBlur()
    388 {
    389   var frm = document.forms['reggie'];
    390   var caseName = frm.caseName.value;
    391   if (caseName == '')
    392   {
    393     setInputStatus('case', 'Missing', 'invalid');
    394     return;
    395   }
    396   setInputStatus('case', '', 'valid');
    397   caseIsValid = true;
    398 
    399   getCaseInfo();
     535  setInputStatus('nofTubes','', 'valid');
     536  nofTubesIsValid = true;
    400537}
    401538
     
    428565    return;
    429566  }
     567  setInputStatus('laterality', '', 'valid');
     568  lateralityIsValid = true;
    430569  var laterality = selectedLaterality.value; 
     570 
    431571  // No specimen tubes?
    432572  if (!caseInfo.specimen || caseInfo.specimen.length == 0) return;
     
    447587      return;
    448588    }
     589  }
     590}
     591
     592function step3IsValid()
     593{
     594  return false;
     595}
     596
     597function goCreate()
     598{
     599  if (!step3IsValid()) return;
     600
     601  Main.hide('gocancel');
     602  Main.hide('gocreate');
     603  var frm = document.forms['reggie'];
     604
     605  caseInfo.laterality = Forms.getCheckedRadio(frm.laterality).value;
     606  caseInfo.pad = frm.pad.value;
     607  caseInfo.samplingDate = Main.trimString(frm.samplingDate.value + ' ' + frm.samplingTime.value);
     608  caseInfo.rnaLaterDate = Main.trimString(frm.rnaLaterDate.value + ' ' + frm.rnaLaterTime.value);
     609  caseInfo.pathNote = frm.pathNote.value;
     610
     611  var nofTubes = frm.nofTubes.value;
     612  for (var i=0; i<nofTubes; i++)
     613  {
     614    var specimenTube = new Object();   
     615    if (caseInfo.specimen[i]) specimenTube = caseInfo.specimen[i];
     616    specimenTube.name = caseInfo.name+'.'+i;
     617
     618    caseInfo.specimen[i] = specimenTube;
     619  }
     620
     621  var submitInfo = new Object();
     622  submitInfo.caseInfo = caseInfo;
     623
     624  if (debug) Main.debug(JSON.stringify(submitInfo));
     625 
     626  var request = Ajax.getXmlHttpRequest();
     627  var url = 'SpecimenTubeRegistration.servlet?ID=<%=ID%>&cmd=';
     628  url += 'CreateSpecimenTubes';
     629  request.open("POST", url, false);
     630  request.setRequestHeader("Content-Type", "application/json");
     631  request.send(JSON.stringify(submitInfo));
     632
     633  if (debug) Main.debug(request.responseText);
     634
     635  var response = JSON.parse(request.responseText);
     636  if (response.status != 'ok')
     637  {
     638    setFatalError(response.message);
     639    return false;
    449640  }
    450641}
     
    468659    return false;
    469660  }
    470 
    471661  caseInfo = response.caseInfo;
    472   if (caseInfo)
    473   {
    474     gotoStep2();
    475   }
    476 }
    477 
     662}
    478663</script>
    479664
     
    511696        <td class="prompt">Case name</td>
    512697        <td class="input"><input type="text" name="caseName"
    513           size="18" maxlength="12" onblur="caseNameOnBlur()"></td>
     698          size="18" maxlength="12" onkeypress="doOnTabOrEnter(event, goNext)"></td>
    514699        <td class="status" id="case.status"></td>
    515700        <td class="help"><span id="case.message" class="message" style="display: none;"></span>The case (barcode) associated with this specimen tube.</td>
     
    533718      <td class="prompt">Number of tubes</td>
    534719      <td class="input"><input type="text" name="nofTubes"
    535         value="" size="12" maxlength="10" onblur="nofTubesOnBlur()"></td>
     720        value="" size="12" maxlength="10" onblur='nofTubesOnChange()'></td>
    536721      <td class="status" id="nofTubes.status"></td>
    537722      <td class="help"><span id="nofTubes.message" class="message" style="display:none"></span>Number of tubes in this case.</td>
     
    575760        <input type="radio" name="laterality" value="LEFT" onclick="lateralityOnChange()">LEFT<br>
    576761        <input type="radio" name="laterality" value="RIGHT" onclick="lateralityOnChange()">RIGHT<br>
    577         <input type="radio" name="laterality" value="" onclick="lateralityOnChange()"><i>unknown</i>
     762        <input type="radio" name="laterality" value="" checked onclick="lateralityOnChange()"><i>unknown</i>
    578763      </td>
    579764      <td class="status" id="laterality.status"></td>
     
    582767    <tr>
    583768      <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>
     769      <td class="input" id="pathNote.input"><textarea rows="3" cols="30"
     770        name="pathNote" value="" onkeypress="doOnTabOrEnter(event, goNext)"></textarea></td>
    585771      <td class="status" id="pathNote.status"></td>
    586772      <td class="help"><span id="pathNote.message" class="message" style="display: none;"></span></td>
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/Reggie.java

    r1378 r1379  
    9191  */
    9292  public static final String ANNOTATION_PAD_CASE = "PADcase";
     93 
     94  /**
     95    The name of the "PathNote" annotation type,
     96    used for samples (Case). It is a string annotation type.
     97  */
     98  public static final String ANNOTATION_PATH_NOTE = "PathNote";
    9399
    94100  /**
     
    135141  */
    136142  public static final String GROUP_PATIENT_CURATOR = "PatientCurator";
     143
     144  /**
     145    The name of the "OperatorComment" annotation type, used
     146    for samples (Specimen tube). It is a String annotation type.
     147  */
     148  public static final String ANNOTATION_OPERATOR_COMMENT = "OperatorComment";
    137149 
    138150  /**
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/SpecimenTube.java

    r1372 r1379  
    44import java.util.List;
    55
     6import org.json.simple.JSONObject;
     7
     8import net.sf.basedb.core.BioPlate;
     9import net.sf.basedb.core.BioWell;
    610import net.sf.basedb.core.DbControl;
    711import net.sf.basedb.core.Include;
     
    6367    List<SpecimenTube> tubes = new ArrayList<SpecimenTube>();
    6468    for (Sample s : specimenQuery.list(dc))
    65     {
     69    {   
    6670      tubes.add(new SpecimenTube(s));
    6771    }
     
    9397  }
    9498 
     99  private final String box;
     100  private final Integer row;
     101  private final Integer column;
     102 
    95103  private SpecimenTube(Sample sample)
    96104  {
    97105    super(sample);
    98   }
     106    if (sample.getBioWell() != null)
     107    {
     108      BioWell well = sample.getBioWell();
     109      box = well.getPlate().getName();
     110      row = well.getRow();
     111      column = well.getColumn();
     112    }
     113    else
     114    {
     115      box = null;
     116      row = null;
     117      column = null;
     118    }
     119  }
     120 
    99121 
    100122  /**
     
    106128  }
    107129
     130  /**
     131    Get the box where this specimen tube is located 
     132   */
     133  public String getBox()
     134  {
     135    return this.box;
     136  }
     137
     138  /**
     139    Get the row index in the box, where this specimen tube can be found.
     140  */
     141  public Integer getRow()
     142  {
     143    return row;
     144  }
     145
     146  /**
     147    Get the column index in the box, where this specimen tube can be found.
     148  */
     149  public Integer getColumn()
     150  {
     151    return column;
     152  }
    108153 
     154  @SuppressWarnings("unchecked")
     155  @Override
     156  protected void initJSON(JSONObject json)
     157  {
     158    json.put("box", box);
     159    json.put("row", row);
     160    json.put("column", column);
     161  }
    109162}
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/InstallServlet.java

    r1375 r1379  
    129129        jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_NOF_DELIVERED_TUBES, Item.SAMPLE, Type.INT, 1,
    130130            null, effectiveOptions, createIfMissing));
     131        jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_OPERATOR_COMMENT, Item.SAMPLE, Type.STRING, 1,
     132            null, effectiveOptions, createIfMissing));
     133        jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_PATH_NOTE, Item.SAMPLE, Type.STRING, 1,
     134            null, effectiveOptions, createIfMissing));
    131135       
    132136        json.put("checks", jsonChecks);
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/SpecimenTubeServlet.java

    r1375 r1379  
    1111import javax.servlet.http.HttpServletResponse;
    1212
    13 import net.sf.basedb.core.AnnotationSet;
    1413import net.sf.basedb.core.AnnotationType;
    1514import net.sf.basedb.core.Application;
     15import net.sf.basedb.core.BioPlate;
     16import net.sf.basedb.core.BioWell;
    1617import net.sf.basedb.core.DbControl;
     18import net.sf.basedb.core.InvalidDataException;
    1719import net.sf.basedb.core.Item;
     20import net.sf.basedb.core.ItemQuery;
    1821import net.sf.basedb.core.Sample;
    1922import net.sf.basedb.core.SessionControl;
     23import net.sf.basedb.core.Type;
     24import net.sf.basedb.core.query.Expression;
     25import net.sf.basedb.core.query.Expressions;
     26import net.sf.basedb.core.query.Hql;
     27import net.sf.basedb.core.query.Restrictions;
    2028import net.sf.basedb.reggie.Reggie;
    2129import net.sf.basedb.reggie.converter.DateToStringConverter;
     
    2533import net.sf.basedb.util.Values;
    2634import net.sf.basedb.util.error.ThrowableUtil;
     35import net.sf.basedb.util.formatter.WellCoordinateFormatter;
    2736
    2837import org.json.simple.JSONArray;
     
    95104          AnnotationType arrivalDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_ARRIVAL_DATE, true);
    96105          AnnotationType nofDeliveredTubesType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_NOF_DELIVERED_TUBES, true);
     106          AnnotationType operatorCommentType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_OPERATOR_COMMENT, true);
    97107         
    98108          DateToStringConverter dateTimeConverter = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd HHmm"));
     
    106116            tube.loadAnnotations("arrivalDate", arrivalDateType, dateConverter);
    107117            tube.loadAnnotations("nofTubes", nofDeliveredTubesType, null);
     118            tube.loadAnnotations("operatorComment", operatorCommentType, null);
    108119           
    109120            jsonTubes.add(tube.asJSONObject());
     
    113124       
    114125        json.put("caseInfo", jsonCase);
     126      }
     127      else if ("GetBoxInfo".equals(cmd))
     128      {
     129        dc = sc.newDbControl();
     130       
     131        String boxName = req.getParameter("boxName");
     132        ItemQuery<BioPlate> boxQuery = BioPlate.getQuery();
     133        boxQuery.restrict(Restrictions.eq(Hql.property("name"), Expressions.string(boxName)));
     134        List<BioPlate> boxes = boxQuery.list(dc);
     135       
     136        if (boxes.size() == 0)
     137        {
     138          json.put("message", "Box does not exist.");         
     139        }
     140        else if (boxes.size() > 1)
     141        {
     142          json.put("message", "More then one box were found.");
     143        }
     144        else
     145        {         
     146          WellCoordinateFormatter wcfRow = new WellCoordinateFormatter(true);
     147         
     148          json.put("boxInfo", boxes.get(0).getId());
     149          json.put("rows", wcfRow.format(boxes.get(0).getRows()-1));
     150          json.put("columns", boxes.get(0).getColumns());
     151        }
     152       
     153      }
     154      else if ("ValidateWell".equals(cmd))
     155      {
     156        dc = sc.newDbControl();
     157       
     158        int boxId = Integer.parseInt(req.getParameter("boxId"));
     159        BioPlate plate = BioPlate.getById(dc, boxId);
     160       
     161        WellCoordinateFormatter wcfRow = new WellCoordinateFormatter(true);       
     162        String rowString = req.getParameter("row");
     163        int rowNumber = wcfRow.parseString(rowString);
     164               
     165        Integer columnIndex = Integer.parseInt(req.getParameter("column")) - 1;
     166        WellCoordinateFormatter wcfColumn = new WellCoordinateFormatter(false);
     167       
     168        String msg = null;
     169        if (rowNumber < 1 || rowNumber > plate.getRows())
     170        {
     171          msg = "The row must be between "+ wcfRow.format(0) +" and " + wcfRow.format(plate.getRows()-1);
     172        }
     173        else if (columnIndex < 0 || columnIndex > plate.getColumns())
     174        {
     175          msg = "The column must be between " +  1 + " and " + plate.getColumns();
     176        }
     177        else if (!plate.getBioWell(rowNumber-1, columnIndex).isEmpty())
     178        {
     179          msg = "Specified row:column("+rowString+":"+wcfColumn.format(columnIndex)+") is already taken.";
     180        }
     181        json.put("message", msg);       
    115182      }
    116183    }
     
    144211   
    145212    JSONArray jsonMessages = new JSONArray();
    146    
    147213    final SessionControl sc = Application.getSessionControl(ID, req.getRemoteAddr());
    148214    DbControl dc = null;
     
    150216    try
    151217    {
    152       if ("CreateSpecimenTube".equals(cmd))
    153       {
    154        
     218      if ("CreateSpecimenTubes".equals(cmd))
     219      {
     220        dc = sc.newDbControl();
     221       
     222        JSONObject jsonReq = (JSONObject)new JSONParser().parse(req.getReader());       
     223        JSONObject jsonCase = (JSONObject)jsonReq.get("caseInfo");
     224        Number caseId = (Number)jsonCase.get("id");
     225        Sample theCase = null;
     226       
     227        if (caseId != null)
     228        {
     229          theCase = Sample.getById(dc, caseId.intValue());
     230        }
     231        else
     232        {
     233          theCase = Sample.getNew(dc);
     234          theCase.setName((String)jsonCase.get("name"));
     235         
     236          dc.saveItem(theCase);
     237        }
     238         
     239        String laterality = Values.getStringOrNull((String)jsonCase.get("laterality"));
     240        String padCase = Values.getStringOrNull((String)jsonCase.get("pad"));
     241        String pathNote = Values.getStringOrNull((String)jsonCase.get("pathNote"));
     242        StringToDateConverter dateTimeConverter = new StringToDateConverter(new SimpleDateFormat("yyyyMMdd HHmm"));
     243        StringToDateConverter dateConverter = new StringToDateConverter(new SimpleDateFormat("yyyyMMdd"));       
     244        Date samplingDate = dateTimeConverter.convert((String)jsonCase.get("samplingDate"));
     245        Date rnaLaterDate = dateTimeConverter.convert((String)jsonCase.get("rnaLaterDate"));
     246        Date arrivalDate = dateConverter.convert((String)jsonCase.get("arrivalDate"));
     247       
     248        AnnotationType padCaseType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PAD_CASE, true);
     249        AnnotationType lateralityType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_LATERALITY, true);
     250//        AnnotationType pathNoteType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PATH_NOTE, true);
     251        AnnotationType samplingDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_SAMPLING_DATETIME, true);
     252        AnnotationType rnaLaterDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_RNALATER_DATETIME, true);
     253        AnnotationType arrivalDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_ARRIVAL_DATE, true);
     254       
     255        Reggie.setAnnotationValue(theCase, lateralityType, laterality);
     256        Reggie.setAnnotationValue(theCase, arrivalDateType, arrivalDate);
     257//        Reggie.setAnnotationValue(theCase, pathNoteType, pathNote);
     258       
     259        if (padCase != null) Reggie.appendAnnotationValueIfUnique(theCase, padCaseType, padCase);
    155260       
    156261        dc.commit();
Note: See TracChangeset for help on using the changeset viewer.