Changeset 1380 for extensions
- Timestamp:
- Aug 12, 2011, 2:57:39 PM (12 years ago)
- Location:
- extensions/net.sf.basedb.reggie/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.reggie/trunk/resources/specimentube.jsp
r1379 r1380 28 28 var caseIsValid = false; 29 29 var arrivalDateIsValid = false; 30 var partitionDateIsValid = false; 30 31 var nofDeliveredTubesIsValid = true; 31 32 var nofTubesIsValid = false; 32 33 var lateralityIsValid = false; 34 var boxesAreValid = null; 35 var wellsAreValidValid = null; 33 36 var debug = false; 34 37 var currentStep = 1; … … 36 39 var caseInfo = null; 37 40 var boxInfo = null; 41 var updateMode = null; 38 42 39 43 function init() … … 76 80 getCaseInfo(); 77 81 78 var hasSpecimen = caseInfo.specimen && caseInfo.specimen.length > 0; 82 var hasSpecimen = caseInfo.specimen && caseInfo.specimen.length > 0; 79 83 var hasLeftSpecimen = false; 80 84 var hasRightSpecimen = false; 81 85 var hasUnknownSpecimen = false; 82 86 var thisArrivalDate = null; 87 var thisPartitionDate = null; 83 88 var thisNumberOfTubes = null; 84 89 var thisCaseSamplingDate = null; 85 90 var thisCaseRNALaterDate = null; 86 91 var thisCaseLaterality = null; 87 var thisPad = null; 92 var thisCasePad = null; 93 var thisCasePathNote = null; 88 94 89 95 frm.caseName.disabled = true; … … 91 97 Main.show('gocancel'); 92 98 Main.show('caseSection'); 93 94 frm.nofTubes.focus(); 95 currentStep = 2; 96 99 100 var hasLeftCase = false; 101 var hasRightCase = false; 102 var hasUnknownCase = false; 103 97 104 // Load annotations from the actual case 105 thisCaseLaterality = caseInfo.laterality; 106 thisCasePathNote = caseInfo.pathNote; 107 thisCasePad = caseInfo.pad; 108 if (caseInfo.reasonIfNoSpecimen && caseInfo.reasonIfNoSpecimen.length>0) 109 { 110 setFatalError("There is a reason given why this case doesn't have specimen tubes. " + 111 "This wizard can't be used until that is corrected."); 112 } 113 114 //Adjust the step-title 115 if (caseInfo.id) 116 { 117 setInnerHTML('step2.title', 'Add Specimen tube Information'); 118 } 98 119 if (hasSpecimen) 99 120 { 121 setInnerHTML('step2.title', 'Update Case Information'); 122 updateMode = true; 100 123 frm.nofTubes.value = thisNumberOfTubes; 101 124 frm.nofTubes.disabled = true; 102 125 frm.arrivalDate.focus(); 126 127 // If the number of tubes not is set - use the current number of specimen tubes. 128 if (!thisNumberOfTubes) thisNumberOfTubes = caseInfo.specimen.length; 129 103 130 for (var i=0; i < caseInfo.specimen.length; i++) 104 131 { 105 132 var specimen = caseInfo.specimen[i]; 106 if (specimen.pad && !this Pad)133 if (specimen.pad && !thisCasePad) 107 134 { 108 thisPad = specimen.pad; 135 thisCasePad = specimen.pad; 136 } 137 if(specimen.arrivalDate && !thisArrivalDate) 138 { 139 thisArrivalDate = specimen.arrivalDate; 109 140 } 110 if(specimen. arrivalDate && !thisArrivalDate)111 { 112 this ArrivalDate = specimen.arrivalDate;141 if(specimen.partitionDate && !thisPartitionDate) 142 { 143 thisPartitionDate = specimen.partitionDate; 113 144 } 114 145 if (specimen.nofTubes && !thisNumberOfTubes) … … 124 155 thisCaseRNALaterDate = specimen.rnaLaterDate; 125 156 } 157 if (specimen.pathNote && !thisCasePathNote) 158 { 159 thisCasePathNote = specimen.pathNote; 160 } 126 161 if (specimen.laterality && !thisCaseLaterality) 127 162 { … … 132 167 else if(!thisCaseLaterality) 133 168 { 134 hasUnknownSpecimen = true; 169 hasUnknownSpecimen = true; 135 170 } 136 171 } 137 // If the number of tubes not is set - use the current number of specimen tubes. 138 if (!thisNumberOfTubes) thisNumberOfTubes = caseInfo.specimen.length; 139 172 140 173 // Check that all specimen tubes have the same laterality 141 174 var numLateralities = 0; … … 148 181 thisCaseLaterality = null; 149 182 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; 185 if (caseInfo.id) 186 { 187 setInnerHTML('step2.title', 'Update Case Information'); 188 if (caseInfo.pad && !thisPad) 189 { 190 thisPad = caseInfo.pad; 191 } 192 if (caseInfo.laterality) 193 { 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); 203 lateralityOnChange(); 204 } 183 } 184 } 185 if (thisCaseLaterality != null) 186 { 187 var lateralityInput = ''; 188 lateralityInput += '<input type="radio" name="laterality" value="LEFT" '; 189 if (thisCaseLaterality == 'LEFT') lateralityInput += 'checked'; 190 lateralityInput += ' onChange="lateralityOnChange()">LEFT'; 191 lateralityInput += '<br>'; 192 lateralityInput += '<input type="radio" name="laterality" value="RIGHT" '; 193 if (thisCaseLaterality == 'RIGHT') lateralityInput += 'checked'; 194 lateralityInput += ' onChange="lateralityOnChange()">RIGHT'; 195 setInnerHTML('laterality.input', lateralityInput); 196 } 197 lateralityOnChange(); 198 if (thisCasePad != null) 199 { 200 frm.pad.value = thisCasePad; 201 padOnChange(); 202 } 203 if (thisArrivalDate != null) 204 { 205 frm.arrivalDate.value = thisArrivalDate; 206 } 207 if (thisPartitionDate != null) 208 { 209 frm.partitionDate.value = thisPartitionDate; 210 } 211 if (thisNumberOfTubes != null) 212 { 213 frm.nofTubes.value = thisNumberOfTubes; 214 nofTubesOnChange(); 215 } 216 if (thisCaseSamplingDate != null) 217 { 218 frm.samplingDate.value = thisCaseSamplingDate.substring(0, 8); 219 frm.samplingTime.value = thisCaseSamplingDate.substring(9, 13); 220 samplingDateTimeOnChange(); 221 } 222 if (thisCaseRNALaterDate != null) 223 { 224 frm.rnaLaterDate.value = thisCaseRNALaterDate.substring(0, 8); 225 frm.rnaLaterTime.value = thisCaseRNALaterDate.substring(9, 13); 226 rnaLaterDateTimeOnChange(); 227 } 228 if (thisCasePathNote != null) 229 { 230 frm.pathNote.value = thisCasePathNote; 205 231 } 232 frm.nofTubes.focus(); 233 currentStep = 2; 206 234 } 207 235 … … 211 239 var inputTubeHtml = ''; 212 240 var nofTubes = frm.nofTubes.value; 213 241 boxInfo = Array(nofTubes); 242 214 243 frm.arrivalDate.disabled = true; 244 frm.partitionDate.disabled = true; 215 245 frm.nofTubes.disabled = true; 216 246 frm.pad.disabled = true; … … 225 255 frm.pathNote.disabled = true; 226 256 257 if (updateMode) 258 { 259 //setInnerHTML('step3.title', 'Update Tube Information'); 260 } 261 227 262 for (var i=0;i<nofTubes;i++) 228 263 { … … 231 266 var rowValue = ''; 232 267 var columnValue = ''; 268 var spWeightValue = ''; 269 var hisWeightValue = ''; 270 var allPrepWeightValue = ''; 271 272 boxInfo[i] = null; 233 273 if (caseInfo.specimen && caseInfo.specimen.length>0 && i<caseInfo.specimen.length) 234 274 { 235 275 specimen = caseInfo.specimen[i]; 236 boxValue = specimen.box; 237 rowValue = specimen.row; 238 columnValue = specimen.column; 276 boxValue = specimen.box == null ? '' : specimen.box; 277 rowValue = specimen.row == null ? '' : specimen.row; 278 columnValue = specimen.column == null ? '' : specimen.column; 279 spWeightValue = specimen.spWeight == null ? '' : specimen.spWeight; 280 hisWeightValue = specimen.hisWeight == null ? '' : specimen.hisWeight; 281 allPrepWeightValue = specimen.allPrepWeight == null ? '' : specimen.allPrepWeight; 239 282 } 240 283 inputTubeHtml += '<tr>'; … … 243 286 244 287 var box = 'box'+i; 288 var boxDisabled = boxValue == '' ? '' : 'disabled'; 245 289 inputTubeHtml += '<tr>'; 246 290 inputTubeHtml += '<td class="subprompt">Box</td>'; 247 inputTubeHtml += '<td class="input"><input type="text" name='+box+' value="' + boxValue + '" size="18" maxlength="12" onBlur="boxOnChange('+i+')"></td>';291 inputTubeHtml += '<td class="input"><input type="text" name='+box+' value="' + boxValue + '" '+ boxDisabled +' size="12" maxlength="12" onChange="boxOnChange('+i+')"></td>'; 248 292 inputTubeHtml += '<td class="status" id="'+box+'.status"></td>'; 249 293 inputTubeHtml += '<td class="help"><span id="'+box+'.message" class="message" style="display: none;"></span>Box the specimen tube is located in.</td>'; … … 252 296 var row = 'row'+i; 253 297 var column = 'column'+i; 298 var wellDisabled = rowValue != '' || boxValue == '' ? 'disabled' : ''; 254 299 inputTubeHtml += '<tr>'; 255 300 inputTubeHtml += '<td class="subprompt">Row</td>'; 256 inputTubeHtml += '<td class="input"><input type="text" name='+row+' value="' + rowValue + '" size="3" maxlength="3"'; 257 inputTubeHtml += boxValue != '' ? '' : ' disabled'; 301 inputTubeHtml += '<td class="input"><input style="text-transform:uppercase;" type="text" onKeyPress="" name='+row+' value="' + rowValue + '" size="3" maxlength="2" ' + wellDisabled; 258 302 inputTubeHtml += ' onBlur="wellOnChange('+i+')">'; 259 inputTubeHtml += ' Column<input type="text" name='+column+' value="'+ columnValue + '" size="3" maxlength="3"'; 260 inputTubeHtml += boxValue != '' ? '' : ' disabled'; 303 inputTubeHtml += ' Column<input type="text" name='+column+' value="'+ columnValue + '" size="3" maxlength="3" ' + wellDisabled; 261 304 inputTubeHtml += ' onBlur="wellOnChange('+i+')">'; 262 305 inputTubeHtml += '</td>'; … … 264 307 inputTubeHtml += '<td class="help"><span id="rowColumn'+i+'.message" class="message" style="display: none;"></span></td>'; 265 308 inputTubeHtml += '</tr>'; 309 310 var spWeight = 'spWeight'+i; 311 inputTubeHtml += '<tr>'; 312 inputTubeHtml += '<td class="subprompt">Sp weight</td>'; 313 inputTubeHtml += '<td class="input"><input type="text" name='+spWeight+' value="' + spWeightValue + '" size="12" maxlength="10"></td>'; 314 inputTubeHtml += '<td class="status" id="'+spWeight+'.status"></td>'; 315 inputTubeHtml += '<td class="help"><span id="'+spWeight+'.message" class="message" style="display: none;"></span>[mg]</td>'; 316 inputTubeHtml += '</tr>'; 317 318 var allPrep = 'allPrepWeight' + i; 319 inputTubeHtml += '<tr>'; 320 inputTubeHtml += '<td class="subprompt">Allprep weight</td>'; 321 inputTubeHtml += '<td class="input"><input type="text" name='+allPrep+' value="'+allPrepWeightValue+'" size="12" maxlength="10"></td>'; 322 inputTubeHtml += '<td class="status" id="'+allPrep+'.status"></td>'; 323 inputTubeHtml += '<td class="help"><span id="'+allPrep+'.message" class="message" style="display: none;"></span>[mg]</td>'; 324 inputTubeHtml += '</tr>'; 266 325 267 var his = 'his '+i;326 var his = 'hisWeight'+i; 268 327 inputTubeHtml += '<tr>'; 269 inputTubeHtml += '<td class="subprompt">His </td>';270 inputTubeHtml += '<td class="input"><input type="text" name='+his+' value=" " size="12" maxlength="10"></td>';328 inputTubeHtml += '<td class="subprompt">His weight</td>'; 329 inputTubeHtml += '<td class="input"><input type="text" name='+his+' value="'+hisWeightValue+'" size="12" maxlength="10"></td>'; 271 330 inputTubeHtml += '<td class="status" id="his.status"></td>'; 272 inputTubeHtml += '<td class="help"><span id="'+his+'.message" class="message" style="display: none;"></span>[µg]</td>'; 273 inputTubeHtml += '</tr>'; 274 275 var allPrep = 'allPrep' + i; 276 inputTubeHtml += '<tr>'; 277 inputTubeHtml += '<td class="subprompt">Allprep</td>'; 278 inputTubeHtml += '<td class="input"><input type="text" name='+allPrep+' value="" size="12" maxlength="10"></td>'; 279 inputTubeHtml += '<td class="status" id="'+allPrep+'.status"></td>'; 280 inputTubeHtml += '<td class="help"><span id="'+allPrep+'.message" class="message" style="display: none;"></span>[µg]</td>'; 281 inputTubeHtml += '</tr>'; 282 283 var backupWeight = 'backupWeight'+i; 284 inputTubeHtml += '<tr>'; 285 inputTubeHtml += '<td class="subprompt">Backup weight</td>'; 286 inputTubeHtml += '<td class="input"><input type="text" name='+backupWeight+' value="" size="12" maxlength="10"></td>'; 287 inputTubeHtml += '<td class="status" id="'+backupWeight+'.status"></td>'; 288 inputTubeHtml += '<td class="help"><span id="'+backupWeight+'.message" class="message" style="display: none;"></span>[µg]</td>'; 289 inputTubeHtml += '</tr>'; 290 291 var deliveryComment = 'deliveryComment'+i; 331 inputTubeHtml += '<td class="help"><span id="'+his+'.message" class="message" style="display: none;"></span>[mg]</td>'; 332 inputTubeHtml += '</tr>'; 333 334 var operatorComment = 'operatorComment'+i; 335 var doOnTab = i==(nofTubes-1) ? 'doOnTab(event, goCreate)' : ''; 292 336 inputTubeHtml += '<tr>'; 293 337 inputTubeHtml += '<td class="subprompt">Operator comment</td>'; 294 inputTubeHtml += '<td class="input"><textarea rows="3" cols="30" name='+ deliveryComment+' value=""></textarea></td>';295 inputTubeHtml += '<td class="status" id="'+ deliveryComment+'.status"></td>';296 inputTubeHtml += '<td class="help"><span id="'+ deliveryComment+'.message" class="message" style="display: none;"></span>Operator delivery comment</td>';338 inputTubeHtml += '<td class="input"><textarea rows="3" cols="30" name='+operatorComment+' value="" onkeypress="'+doOnTab+'"></textarea></td>'; 339 inputTubeHtml += '<td class="status" id="'+operatorComment+'.status"></td>'; 340 inputTubeHtml += '<td class="help"><span id="'+operatorComment+'.message" class="message" style="display: none;"></span>Operator delivery comment</td>'; 297 341 inputTubeHtml += '</tr>'; 298 342 } 299 setInnerHTML('tubeInputs', inputTubeHtml); 300 boxInfo = Array(); 343 setInnerHTML('tubeInputs', inputTubeHtml); 344 boxesAreValid = Array(nofTubes); 345 wellsAreValid = Array(nofTubes); 301 346 currentStep = 3; 302 347 Main.show('tubeSection'); 303 348 Main.hide('gonext'); 304 Main.show('gocreate'); 305 frm.box0.focus(); 349 350 if (updateMode) Main.show('goupdate'); 351 else Main.show('gocreate'); 352 353 if (frm.box0.value == '') frm.box0.focus(); 354 else frm.his0.focus(); 306 355 } 307 356 … … 348 397 var columnName = 'column'+tubeIndex; 349 398 var boxValue = frm.elements[boxName].value; 399 400 wellsAreValid[tubeIndex] = false; 350 401 351 402 if (frm.elements[boxName].value == '') 352 403 { 404 boxesAreValid[tubeIndex] = true; 405 wellsAreValid[tubeIndex] = true; 353 406 frm.elements[rowName].disabled = true; 354 407 frm.elements[rowName].value = ''; … … 372 425 if (response.status != 'ok') 373 426 { 427 boxesAreValid[tubeIndex] = false; 374 428 setFatalError(response.message); 375 429 return false; … … 377 431 if (!response.boxInfo) 378 432 { 379 setInputStatus(boxName, response.message, 'invalid'); 433 boxesAreValid[tubeIndex] = false; 434 setInputStatus(boxName, response.message, 'invalid'); 380 435 frm.elements[rowName].value = ''; 381 436 frm.elements[columnName].value = ''; … … 385 440 } 386 441 else 387 { 442 { 443 boxesAreValid[tubeIndex] = true; 388 444 boxInfo[tubeIndex] = response.boxInfo; 389 445 frm.elements[rowName].disabled = false; 390 446 frm.elements[columnName].disabled = false; 391 447 frm.elements[rowName].value = ''; 392 setInputStatus('rowColumn'+tubeIndex,'Row[A-'+response.rows+'], Columns[1-'+response.columns+']','');393 frm.elements[columnName].disabled = '';448 frm.elements[columnName].value = ''; 449 setInputStatus('rowColumn'+tubeIndex,'Row[A-'+response.rows+'], Columns[1-'+response.columns+']',''); 394 450 setInputStatus(boxName, '', 'valid'); 395 451 frm.elements[rowName].focus(); … … 411 467 (rowValue == '' || columnValue == '')) 412 468 { 469 wellsAreValid[tubeIndex] = false; 413 470 setInputStatus('rowColumn'+tubeIndex, 'Row or column cannot be empty when the box is specified.', 'invalid'); 414 471 return false; 415 } 472 } 416 473 417 474 var request = Ajax.getXmlHttpRequest(); … … 428 485 if (response.status != 'ok') 429 486 { 487 wellsAreValid[tubeIndex] = false; 430 488 setFatalError(response.message); 431 489 return false; … … 433 491 if (response.message) 434 492 { 493 wellsAreValid[tubeIndex] = false; 435 494 setInputStatus('rowColumn'+tubeIndex, response.message, 'invalid') 436 495 return false; … … 443 502 columnValue == frm.elements['column'+i].value) 444 503 { 504 wellsAreValid[tubeIndex] = false; 445 505 setInputStatus('rowColumn'+tubeIndex, 'The row and column are already used once in this wizard','invalid'); 446 506 return false; … … 448 508 } 449 509 } 510 wellsAreValid[tubeIndex] = true; 450 511 setInputStatus('rowColumn'+tubeIndex, '', 'valid'); 451 512 } … … 523 584 } 524 585 586 function partitionDateOnBlur() 587 { 588 var frm = document.forms['reggie']; 589 var partitionDate = frm.partitionDate.value; 590 partitionDateIsValid = false; 591 592 setInputStatus('partitionDate', '', ''); 593 594 if (partitionDate != '') 595 { 596 partitionDate = autoFillDate(partitionDate); 597 frm.partitionDate.value = partitionDate; 598 599 if (!Dates.isDate(partitionDate, 'yyyyMMdd')) 600 { 601 setInputStatus('partitionDate', 'Not a valid date', 'invalid'); 602 return; 603 } 604 setInputStatus('partitionDate', '', 'valid'); 605 partitionDateIsValid = true; 606 } 607 else 608 { 609 setInputStatus('partitionDate', 'Missing', 'warning'); 610 } 611 } 612 525 613 function nofTubesOnChange() 526 614 { … … 533 621 return; 534 622 } 623 if (nofTubes == '0') 624 { 625 setInputStatus('nofTubes', 'Must be at least 1', 'invalid'); 626 return; 627 } 535 628 setInputStatus('nofTubes','', 'valid'); 536 629 nofTubesIsValid = true; … … 552 645 function lateralityOnChange() 553 646 { 647 // No specimen tubes? 648 //if (!caseInfo.specimen || caseInfo.specimen.length == 0) return; 649 554 650 lateralityIsValid = false; 555 var updateMode = caseInfo.id;556 651 557 652 // Check selected laterality against specimen tubes … … 568 663 lateralityIsValid = true; 569 664 var laterality = selectedLaterality.value; 570 571 // No specimen tubes? 572 if (!caseInfo.specimen || caseInfo.specimen.length == 0) return; 665 if (laterality == '') 666 { 667 laterality = null; 668 } 573 669 574 670 for (var i = 0; i < caseInfo.specimen.length; i++) … … 577 673 if (specimen.laterality != laterality) 578 674 { 579 if (specimen.laterality == null || updateMode) 580 { 581 setInputStatus('laterality', 'Specimen tubes are updated to: ' + laterality, 'valid') 582 } 583 else 584 { 585 setInputStatus('laterality', 'Not same laterality as specimen tubes', 'warning'); 586 } 675 setInputStatus('laterality', 'Specimen tubes are updated to: ' + laterality, 'valid') 587 676 return; 588 677 } … … 591 680 592 681 function step3IsValid() 593 { 594 return false; 682 { 683 var step3IsValid = false; 684 var i=0; 685 var bioWellsAreValid = true; 686 687 while (i<boxesAreValid.length && bioWellsAreValid) 688 { 689 if (!boxesAreValid[i] || !wellsAreValid[i]) 690 { 691 bioWellsAreValid = false; 692 } 693 i++; 694 } 695 step3IsValid = bioWellsAreValid; 696 return step3IsValid; 595 697 } 596 698 … … 601 703 Main.hide('gocancel'); 602 704 Main.hide('gocreate'); 603 var frm = document.forms['reggie']; 705 Main.hide('goupdate'); 706 var frm = document.forms['reggie']; 707 604 708 605 709 caseInfo.laterality = Forms.getCheckedRadio(frm.laterality).value; … … 608 712 caseInfo.rnaLaterDate = Main.trimString(frm.rnaLaterDate.value + ' ' + frm.rnaLaterTime.value); 609 713 caseInfo.pathNote = frm.pathNote.value; 610 714 caseInfo.arrivalDate = Main.trimString(frm.arrivalDate.value); 715 caseInfo.partitionDate = Main.trimString(frm.partitionDate.value); 716 611 717 var nofTubes = frm.nofTubes.value; 612 718 for (var i=0; i<nofTubes; i++) 613 719 { 614 var specimenTube = new Object(); 720 var specimenTube = new Object(); 615 721 if (caseInfo.specimen[i]) specimenTube = caseInfo.specimen[i]; 616 specimenTube.name = caseInfo.name+'.'+i; 617 722 specimenTube.name = caseInfo.name+'.'+(1+i); 723 724 frm.elements['box'+i].disabled = true; 725 frm.elements['row'+i].disabled = true; 726 frm.elements['column'+i].disabled = true; 727 frm.elements['spWeight'+i].disabled = true; 728 frm.elements['allPrepWeight'+i].disabled = true; 729 frm.elements['hisWeight'+i].disabled = true; 730 frm.elements['operatorComment'+i].disabled = true; 731 732 if (boxInfo[i] != '') specimenTube.boxId = boxInfo[i]; 733 if (frm.elements['row'+i].value != '') specimenTube.row = frm.elements['row'+i].value; 734 if (frm.elements['column'+i].value != '') specimenTube.column = frm.elements['column'+i].value; 735 if (frm.elements['operatorComment'+i].value != '') specimenTube.operatorComment = frm.elements['operatorComment'+i].value; 736 737 if (frm.elements['spWeight'+i].value != '') specimenTube.spWeight = frm.elements['spWeight'+i].value; 738 if (frm.elements['allPrepWeight'+i].value != '') specimenTube.allPrepWeight = frm.elements['allPrepWeight'+i].value; 739 if (frm.elements['hisWeight'+i].value != '') specimenTube.hisWeight = frm.elements['hisWeight'+i].value; 740 618 741 caseInfo.specimen[i] = specimenTube; 619 742 } … … 626 749 var request = Ajax.getXmlHttpRequest(); 627 750 var url = 'SpecimenTubeRegistration.servlet?ID=<%=ID%>&cmd='; 628 url += 'CreateSpecimenTubes';751 url += updateMode ? 'UpdateSpecimenTubes' : 'CreateSpecimenTubes'; 629 752 request.open("POST", url, false); 630 753 request.setRequestHeader("Content-Type", "application/json"); … … 638 761 setFatalError(response.message); 639 762 return false; 640 } 763 } 764 765 var msg = '<ul>'; 766 for (var i = 0; i < response.messages.length; i++) 767 { 768 msg += '<li>' + response.messages[i]; 769 } 770 msg += '</ul>'; 771 setInnerHTML('done', msg); 772 Main.show('done'); 773 Main.show('gorestart'); 641 774 } 642 775 … … 728 861 <td class="status" id="arrivalDate.status"></td> 729 862 <td class="help"><span id="arrivalDate.message" class="message" style="display:none"></span>Date when the specimen tubes arrived(YYYYMMDD or MMDD).</td> 863 </tr> 864 <tr valign="top"> 865 <td class="prompt">Partition date</td> 866 <td class="input"><input type="text" name="partitionDate" 867 value="" size="12" maxlength="10" onblur="partitionDateOnBlur()"></td> 868 <td class="status" id="partitionDate.status"></td> 869 <td class="help"><span id="partitionDate.message" class="message" style="display:none"></span>Date when the specimen tubes were partitioned(YYYYMMDD or MMDD).</td> 730 870 </tr> 731 871 <tr> … … 768 908 <td class="prompt" id="pathNote.prompt">Path note</td> 769 909 <td class="input" id="pathNote.input"><textarea rows="3" cols="30" 770 name="pathNote" value="" onkeypress="doOnTab OrEnter(event, goNext)"></textarea></td>910 name="pathNote" value="" onkeypress="doOnTab(event, goNext)"></textarea></td> 771 911 <td class="status" id="pathNote.status"></td> 772 912 <td class="help"><span id="pathNote.message" class="message" style="display: none;"></span></td> … … 804 944 <td><base:button id="gonext" title="Next" image="gonext.gif" onclick="goNext(true)"/></td> 805 945 <td><base:button id="gocreate" title="Create" image="gonext.gif" onclick="goCreate()" style="display: none;"/></td> 946 <td><base:button id="goupdate" title="Update" image="gonext.gif" onclick="goCreate()" style="display: none;"/></td> 806 947 <td><base:button id="gorestart" title="Restart" image="goback.gif" onclick="goRestart(true)" style="display: none;"/></td> 807 948 <td id="gonext.message" class="message"></td> -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/Reggie.java
r1379 r1380 131 131 132 132 /** 133 The name of the "PartitionDate" annotation type, used 134 for samples (Specimen tube). It is a timestamp annotation. 135 */ 136 public static final String ANNOTATION_PARTITION_DATE = "PartitionDate"; 137 /** 133 138 The name of the "NofDeliveredTubes" annotation type, used 134 139 for samples (Specimen tube). It is an Integer annotation type. … … 147 152 */ 148 153 public static final String ANNOTATION_OPERATOR_COMMENT = "OperatorComment"; 154 155 /** 156 The name of the Sp-weight annotation type, use 157 for samples (Specimen tube). It is a Float annotation type. 158 */ 159 public static final String ANNOTATION_SP_WEIGTH = "SpWeight"; 160 161 /** 162 The name of the allPrep-weight annotation type, use 163 for samples (Specimen tube). It is a Float annotation type. 164 */ 165 public static final String ANNOTATION_ALLPREP_WEIGTH = "AllPrepWeight"; 166 167 /** 168 The name of the his-weight annotation type, use 169 for samples (Specimen tube). It is a Float annotation type. 170 */ 171 public static final String ANNOTATION_HIS_WEIGTH = "HisWeight"; 149 172 150 173 /** -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/SpecimenTube.java
r1379 r1380 18 18 import net.sf.basedb.core.query.Orders; 19 19 import net.sf.basedb.core.query.Restrictions; 20 import net.sf.basedb.util.formatter.WellCoordinateFormatter; 20 21 21 22 /** … … 98 99 99 100 private final String box; 100 private final Integerrow;101 private final Integercolumn;101 private final String row; 102 private final String column; 102 103 103 104 private SpecimenTube(Sample sample) … … 106 107 if (sample.getBioWell() != null) 107 108 { 109 WellCoordinateFormatter wcfRow = new WellCoordinateFormatter(true); 110 WellCoordinateFormatter wcfColumn = new WellCoordinateFormatter(false); 108 111 BioWell well = sample.getBioWell(); 109 112 box = well.getPlate().getName(); 110 row = w ell.getRow();111 column = w ell.getColumn();113 row = wcfRow.format(well.getRow()); 114 column = wcfColumn.format(well.getColumn()); 112 115 } 113 116 else … … 139 142 Get the row index in the box, where this specimen tube can be found. 140 143 */ 141 public IntegergetRow()144 public String getRow() 142 145 { 143 146 return row; … … 147 150 Get the column index in the box, where this specimen tube can be found. 148 151 */ 149 public IntegergetColumn()152 public String getColumn() 150 153 { 151 154 return column; -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/InstallServlet.java
r1379 r1380 127 127 jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_ARRIVAL_DATE, Item.SAMPLE, Type.DATE, 1, 128 128 null, effectiveOptions, createIfMissing)); 129 jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_PARTITION_DATE, Item.SAMPLE, Type.DATE, 1, 130 null, effectiveOptions, createIfMissing)); 129 131 jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_NOF_DELIVERED_TUBES, Item.SAMPLE, Type.INT, 1, 130 132 null, effectiveOptions, createIfMissing)); … … 133 135 jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_PATH_NOTE, Item.SAMPLE, Type.STRING, 1, 134 136 null, effectiveOptions, createIfMissing)); 137 jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_ALLPREP_WEIGTH, Item.SAMPLE, Type.FLOAT, 1, 138 null,effectiveOptions, createIfMissing)); 139 jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_SP_WEIGTH, Item.SAMPLE, Type.FLOAT, 1, 140 null,effectiveOptions, createIfMissing)); 141 jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_HIS_WEIGTH, Item.SAMPLE, Type.FLOAT, 1, 142 null,effectiveOptions, createIfMissing)); 135 143 136 144 json.put("checks", jsonChecks); -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/SpecimenTubeServlet.java
r1379 r1380 21 21 import net.sf.basedb.core.Sample; 22 22 import net.sf.basedb.core.SessionControl; 23 import net.sf.basedb.core.Type;24 import net.sf.basedb.core.query.Expression;25 23 import net.sf.basedb.core.query.Expressions; 26 24 import net.sf.basedb.core.query.Hql; … … 76 74 JSONObject jsonCase = null; 77 75 76 // Load specimen tubes for the case 77 specimenTubes = SpecimenTube.findByCaseName(dc, caseName); 78 78 if (theCase == null) 79 { 80 specimenTubes = SpecimenTube.findByCaseName(dc, caseName); 79 { 81 80 jsonCase = new JSONObject(); 82 81 jsonCase.put("name", caseName); 83 82 } 84 83 else 85 { 86 // Load specimen tubes for the case 87 specimenTubes = SpecimenTube.findByCase(dc, theCase, true); 88 89 // Load case annotations 84 { 90 85 theCase.loadAnnotations(dc, "laterality", Reggie.ANNOTATION_LATERALITY, null); 91 theCase.loadAnnotations(dc, "pad", Reggie.ANNOTATION_PAD_CASE, null); 92 theCase.loadAnnotations(dc, "reasonIfNoSpeciment", Reggie.ANNOTATION_REASON_IF_NO_SPECIMEN, null); 86 theCase.loadAnnotations(dc, "pad", Reggie.ANNOTATION_PAD_CASE, null); 87 theCase.loadAnnotations(dc, "reasonIfNoSpecimen", Reggie.ANNOTATION_REASON_IF_NO_SPECIMEN, null); 88 theCase.loadAnnotations(dc, "pathNote", Reggie.ANNOTATION_PATH_NOTE, null); 93 89 94 90 jsonCase = theCase.asJSONObject(); 91 95 92 } 96 93 97 94 JSONArray jsonTubes = new JSONArray(); 98 if (specimenTubes.size() > 0) 99 { 100 AnnotationType padType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PAD, true); 101 AnnotationType laterlityType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_LATERALITY, true); 102 AnnotationType samplingDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_SAMPLING_DATETIME, true); 103 AnnotationType rnaLaterDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_RNALATER_DATETIME, true); 104 AnnotationType arrivalDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_ARRIVAL_DATE, true); 105 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); 95 if (theCase != null && specimenTubes.size() == 0) 96 { 97 throw new InvalidDataException("The case (" + caseName + ") was found " + 98 "but has no tubes to update"); 99 } 100 101 AnnotationType padType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PAD, true); 102 AnnotationType laterlityType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_LATERALITY, true); 103 AnnotationType samplingDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_SAMPLING_DATETIME, true); 104 AnnotationType rnaLaterDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_RNALATER_DATETIME, true); 105 AnnotationType arrivalDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_ARRIVAL_DATE, true); 106 AnnotationType partitionDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PARTITION_DATE, true); 107 AnnotationType nofDeliveredTubesType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_NOF_DELIVERED_TUBES, true); 108 AnnotationType operatorCommentType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_OPERATOR_COMMENT, true); 109 AnnotationType pathNoteType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PATH_NOTE, true); 110 AnnotationType spWeightType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_SP_WEIGTH, true); 111 AnnotationType allPrepWeightType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_ALLPREP_WEIGTH, true); 112 AnnotationType hisWeightType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_HIS_WEIGTH, true); 113 114 DateToStringConverter dateTimeConverter = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd HHmm")); 115 DateToStringConverter dateConverter = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd")); 116 for (SpecimenTube tube : specimenTubes) 117 { 118 tube.loadAnnotations("pad", padType, null); 119 tube.loadAnnotations("laterality", laterlityType, null); 120 tube.loadAnnotations("samplingDate", samplingDateType, dateTimeConverter); 121 tube.loadAnnotations("rnaLaterDate", rnaLaterDateType, dateTimeConverter); 122 tube.loadAnnotations("arrivalDate", arrivalDateType, dateConverter); 123 tube.loadAnnotations("partitionDate", partitionDateType, dateConverter); 124 tube.loadAnnotations("nofTubes", nofDeliveredTubesType, null); 125 tube.loadAnnotations("operatorComment", operatorCommentType, null); 126 tube.loadAnnotations("pathNote", pathNoteType, null); 127 tube.loadAnnotations("allPrepWeight", allPrepWeightType, null); 128 tube.loadAnnotations("spWeight", spWeightType, null); 129 tube.loadAnnotations("hisWeight", hisWeightType, null); 107 130 108 DateToStringConverter dateTimeConverter = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd HHmm")); 109 DateToStringConverter dateConverter = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd")); 110 for (SpecimenTube tube : specimenTubes) 111 { 112 tube.loadAnnotations("pad", padType, null); 113 tube.loadAnnotations("laterality", laterlityType, null); 114 tube.loadAnnotations("samplingDate", samplingDateType, dateTimeConverter); 115 tube.loadAnnotations("rnaLaterDate", rnaLaterDateType, dateTimeConverter); 116 tube.loadAnnotations("arrivalDate", arrivalDateType, dateConverter); 117 tube.loadAnnotations("nofTubes", nofDeliveredTubesType, null); 118 tube.loadAnnotations("operatorComment", operatorCommentType, null); 119 120 jsonTubes.add(tube.asJSONObject()); 121 } 122 } 123 jsonCase.put("specimen", jsonTubes); 124 131 jsonTubes.add(tube.asJSONObject()); 132 } 133 jsonCase.put("specimen", jsonTubes); 125 134 json.put("caseInfo", jsonCase); 126 135 } … … 175 184 msg = "The column must be between " + 1 + " and " + plate.getColumns(); 176 185 } 177 else if (!plate.getBioWell(rowNumber-1, columnIndex).isEmpty() )186 else if (!plate.getBioWell(rowNumber-1, columnIndex).isEmpty() ) 178 187 { 179 188 msg = "Specified row:column("+rowString+":"+wcfColumn.format(columnIndex)+") is already taken."; … … 201 210 protected void doPost(HttpServletRequest req, HttpServletResponse resp) 202 211 throws ServletException, IOException 203 { 212 { 204 213 String ID = req.getParameter("ID"); 205 214 String cmd = req.getParameter("cmd"); … … 213 222 final SessionControl sc = Application.getSessionControl(ID, req.getRemoteAddr()); 214 223 DbControl dc = null; 215 224 216 225 try 217 226 { 218 if (" CreateSpecimenTubes".equals(cmd))227 if ("UpdateSpecimenTubes".equals(cmd)) 219 228 { 220 229 dc = sc.newDbControl(); 221 230 231 JSONObject jsonReq = (JSONObject) new JSONParser().parse(req.getReader()); 232 JSONObject jsonCase = (JSONObject)jsonReq.get("caseInfo"); 233 Sample theCase = null; 234 235 Number caseId = (Number)jsonCase.get("id"); 236 String laterality = Values.getStringOrNull((String)jsonCase.get("laterality")); 237 String padCase = Values.getStringOrNull((String)jsonCase.get("pad")); 238 String pathNote = Values.getStringOrNull((String)jsonCase.get("pathNote")); 239 StringToDateConverter dateTimeConverter = new StringToDateConverter(new SimpleDateFormat("yyyyMMdd HHmm")); 240 StringToDateConverter dateConverter = new StringToDateConverter(new SimpleDateFormat("yyyyMMdd")); 241 Date samplingDate = dateTimeConverter.convert((String)jsonCase.get("samplingDate")); 242 Date rnaLaterDate = dateTimeConverter.convert((String)jsonCase.get("rnaLaterDate")); 243 Date arrivalDate = dateConverter.convert((String)jsonCase.get("arrivalDate")); 244 Date partitionDate = dateConverter.convert((String)jsonCase.get("partitionDate")); 245 246 AnnotationType nofDeliveredTubesType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_NOF_DELIVERED_TUBES, true); 247 AnnotationType padType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PAD, true); 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 AnnotationType partitionDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PARTITION_DATE, true); 255 AnnotationType operatorCommentType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_OPERATOR_COMMENT, true); 256 AnnotationType spWeightType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_SP_WEIGTH, true); 257 AnnotationType allPrepWeightType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_ALLPREP_WEIGTH, true); 258 AnnotationType hisWeightType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_HIS_WEIGTH, true); 259 260 // Checking if it is an existing case or a new should be created. 261 if (caseId != null) 262 { 263 theCase = Sample.getById(dc, caseId.intValue()); 264 265 if (laterality != null) Reggie.setAnnotationValue(theCase, lateralityType, laterality); 266 if (arrivalDate != null) Reggie.setAnnotationValue(theCase, arrivalDateType, arrivalDate); 267 if (partitionDate != null) Reggie.setAnnotationValue(theCase, partitionDateType, partitionDate); 268 if (pathNote != null) Reggie.setAnnotationValue(theCase, pathNoteType, pathNote); 269 if (padCase != null) Reggie.appendAnnotationValueIfUnique(theCase, padCaseType, padCase); 270 } 271 272 JSONArray jsonSpecimen = (JSONArray)jsonCase.get("specimen"); 273 if (jsonSpecimen != null && jsonSpecimen.size() > 0) 274 { 275 int nofTubes = jsonSpecimen.size(); 276 for (int i=0; i < jsonSpecimen.size(); i++) 277 { 278 JSONObject jsonSpec = (JSONObject)jsonSpecimen.get(i); 279 Number specimenId = (Number)jsonSpec.get("id"); 280 Sample specimen = Sample.getById(dc, specimenId.intValue()); 281 282 float originalQuantity = 0; 283 Float spWeight = null; 284 Float allPrepWeight = null; 285 Float hisWeight = null; 286 if (jsonSpec.get("spWeight") != null && jsonSpec.get("spWeight") != "") 287 { 288 spWeight = Values.getFloat(((String)jsonSpec.get("spWeight"))); 289 } 290 if (jsonSpec.get("hisWeight") != null && jsonSpec.get("hisWeight") != "") 291 { 292 hisWeight = Values.getFloat((String)jsonSpec.get("hisWeight")); 293 } 294 if (jsonSpec.get("allPrepWeight") != null && jsonSpec.get("allPrepWeight") != "") 295 { 296 allPrepWeight = Values.getFloat((String)jsonSpec.get("allPrepWeight")); 297 } 298 String operatorComment = Values.getStringOrNull((String)jsonSpec.get("operatorComment")); 299 300 Reggie.setAnnotationValue(specimen, nofDeliveredTubesType, nofTubes); 301 if (arrivalDate != null) Reggie.setAnnotationValue(specimen, arrivalDateType, arrivalDate); 302 if (partitionDate != null) Reggie.setAnnotationValue(specimen, partitionDateType, partitionDate); 303 if (laterality != null) Reggie.setAnnotationValue(specimen, lateralityType, laterality); 304 if (samplingDate != null) Reggie.setAnnotationValue(specimen, samplingDateType, samplingDate); 305 if (rnaLaterDate != null) Reggie.setAnnotationValue(specimen, rnaLaterDateType, rnaLaterDate); 306 if (padCase != null) Reggie.setAnnotationValue(specimen, padType, padCase); 307 if (pathNote != null) Reggie.setAnnotationValue(specimen, pathNoteType, pathNote); 308 if (spWeight != null) 309 { 310 Reggie.setAnnotationValue(specimen, spWeightType, spWeight.floatValue()); 311 originalQuantity = originalQuantity + spWeight * 1000; 312 } 313 if (allPrepWeight != null) 314 { 315 Reggie.setAnnotationValue(specimen, allPrepWeightType, allPrepWeight.floatValue()); 316 originalQuantity = originalQuantity + allPrepWeight.floatValue() * 1000; 317 } 318 if (hisWeight != null) 319 { 320 Reggie.setAnnotationValue(specimen, hisWeightType, hisWeight.floatValue()); 321 originalQuantity = originalQuantity + hisWeight.floatValue() * 1000; 322 } 323 if (operatorComment != null) Reggie.setAnnotationValue(specimen, operatorCommentType, operatorComment); 324 if (originalQuantity > 0) specimen.setOriginalQuantity(originalQuantity); 325 326 jsonMessages.add("Specimen tube '" + specimen.getName() + "' updated successfully."); 327 } 328 } 329 dc.commit(); 330 json.put("messages", jsonMessages); 331 } 332 else if ("CreateSpecimenTubes".equals(cmd)) 333 { 334 dc = sc.newDbControl(); 335 222 336 JSONObject jsonReq = (JSONObject)new JSONParser().parse(req.getReader()); 223 337 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")); 338 339 String laterality = Values.getStringOrNull((String)jsonCase.get("laterality")); 240 340 String padCase = Values.getStringOrNull((String)jsonCase.get("pad")); 241 341 String pathNote = Values.getStringOrNull((String)jsonCase.get("pathNote")); … … 244 344 Date samplingDate = dateTimeConverter.convert((String)jsonCase.get("samplingDate")); 245 345 Date rnaLaterDate = dateTimeConverter.convert((String)jsonCase.get("rnaLaterDate")); 246 Date arrivalDate = dateConverter.convert((String)jsonCase.get("arrivalDate")); 247 346 Date arrivalDate = dateConverter.convert((String)jsonCase.get("arrivalDate")); 347 Date partitionDate = dateConverter.convert((String)jsonCase.get("partitionDate")); 348 349 AnnotationType nofDeliveredTubesType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_NOF_DELIVERED_TUBES, true); 350 AnnotationType padType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PAD, true); 248 351 AnnotationType padCaseType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PAD_CASE, true); 249 352 AnnotationType lateralityType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_LATERALITY, true); 250 //AnnotationType pathNoteType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PATH_NOTE, true);353 AnnotationType pathNoteType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PATH_NOTE, true); 251 354 AnnotationType samplingDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_SAMPLING_DATETIME, true); 252 355 AnnotationType rnaLaterDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_RNALATER_DATETIME, true); 253 356 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); 260 357 AnnotationType partitionDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PARTITION_DATE, true); 358 AnnotationType operatorCommentType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_OPERATOR_COMMENT, true); 359 AnnotationType spWeightType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_SP_WEIGTH, true); 360 AnnotationType allPrepWeightType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_ALLPREP_WEIGTH, true); 361 AnnotationType hisWeightType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_HIS_WEIGTH, true); 362 363 JSONArray jsonSpecimen = (JSONArray)jsonCase.get("specimen"); 364 365 if (jsonSpecimen != null && jsonSpecimen.size() > 0) 366 { 367 int nofTubes = jsonSpecimen.size(); 368 for (int i=0; i < jsonSpecimen.size(); i++) 369 { 370 JSONObject jsonSpec = (JSONObject)jsonSpecimen.get(i); 371 Sample specimen = Sample.getNew(dc); 372 specimen.setName((String)jsonSpec.get("name")); 373 dc.saveItem(specimen); 374 375 float originalQuantity = 0; 376 Float spWeight = null; 377 Float allPrepWeight = null; 378 Float hisWeight = null; 379 if (jsonSpec.get("spWeight") != null && jsonSpec.get("spWeight") != "") 380 { 381 spWeight = Values.getFloat(((String)jsonSpec.get("spWeight"))); 382 } 383 if (jsonSpec.get("hisWeight") != null && jsonSpec.get("hisWeight") != "") 384 { 385 hisWeight = Values.getFloat((String)jsonSpec.get("hisWeight")); 386 } 387 if (jsonSpec.get("allPrepWeight") != null && jsonSpec.get("allPrepWeight") != "") 388 { 389 allPrepWeight = Values.getFloat((String)jsonSpec.get("allPrepWeight")); 390 } 391 392 String operatorComment = Values.getStringOrNull((String)jsonSpec.get("operatorComment")); 393 394 Reggie.setAnnotationValue(specimen, nofDeliveredTubesType, nofTubes); 395 if (arrivalDate != null) Reggie.setAnnotationValue(specimen, arrivalDateType, arrivalDate); 396 if (partitionDate != null) Reggie.setAnnotationValue(specimen, partitionDateType, partitionDate); 397 if (laterality != null) Reggie.setAnnotationValue(specimen, lateralityType, laterality); 398 if (samplingDate != null) Reggie.setAnnotationValue(specimen, samplingDateType, samplingDate); 399 if (rnaLaterDate != null) Reggie.setAnnotationValue(specimen, rnaLaterDateType, rnaLaterDate); 400 if (padCase != null) Reggie.setAnnotationValue(specimen, padType, padCase); 401 if (pathNote != null) Reggie.setAnnotationValue(specimen, pathNoteType, pathNote); 402 403 if (spWeight != null) 404 { 405 System.out.println("sp: " + spWeight); 406 Reggie.setAnnotationValue(specimen, spWeightType, spWeight.floatValue()); 407 originalQuantity = originalQuantity + spWeight * 1000; 408 } 409 if (allPrepWeight != null) 410 { 411 Reggie.setAnnotationValue(specimen, allPrepWeightType, allPrepWeight.floatValue()); 412 originalQuantity = originalQuantity + allPrepWeight.floatValue() * 1000; 413 } 414 if (hisWeight != null) 415 { 416 Reggie.setAnnotationValue(specimen, hisWeightType, hisWeight.floatValue()); 417 originalQuantity = originalQuantity + hisWeight.floatValue() * 1000; 418 } 419 if (operatorComment != null) Reggie.setAnnotationValue(specimen, operatorCommentType, operatorComment); 420 if (originalQuantity > 0) specimen.setOriginalQuantity(originalQuantity); 421 422 // Set biowell if it is specified for this tube 423 Number boxId = (Number)jsonSpec.get("boxId"); 424 String rowString = (String)jsonSpec.get("row"); 425 String columnString = (String)jsonSpec.get("column"); 426 427 if (boxId != null && 428 rowString != null && columnString != null) 429 { 430 WellCoordinateFormatter wcfRow = new WellCoordinateFormatter(true); 431 Integer rowIndex = wcfRow.parseString(rowString)-1; 432 Integer columnIndex = Integer.parseInt(columnString)-1; 433 BioPlate plate = BioPlate.getById(dc, boxId.intValue()); 434 BioWell well = plate.getBioWell(rowIndex, columnIndex); 435 if (well != null) 436 { 437 specimen.setBioWell(well); 438 } 439 } 440 jsonMessages.add("Specimen tube '" + specimen.getName() + "' created successfully."); 441 } 442 } 443 261 444 dc.commit(); 262 445 json.put("messages", jsonMessages);
Note: See TracChangeset
for help on using the changeset viewer.