source: extensions/net.sf.basedb.reggie/trunk/resources/sampleproc/specimentube.jsp @ 2576

Last change on this file since 2576 was 2576, checked in by Nicklas Nordborg, 8 years ago

Fixes #618: Specimen tube item is registered with incorrect name

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 29.6 KB
Line 
1<%@ page
2  pageEncoding="UTF-8"
3  session="false"
4  import="net.sf.basedb.core.User"
5  import="net.sf.basedb.core.BioPlate"
6  import="net.sf.basedb.core.DbControl" 
7  import="net.sf.basedb.core.Item"
8  import="net.sf.basedb.core.ItemContext"
9  import="net.sf.basedb.core.SessionControl"
10  import="net.sf.basedb.core.Application"
11  import="net.sf.basedb.clients.web.Base" 
12  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
13  import="net.sf.basedb.util.Values"
14  import="java.util.List"
15%>
16<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
17<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
18<%
19final SessionControl sc = Base.getExistingSessionControl(request, true);
20final String ID = sc.getId();
21final float scale = Base.getScale(sc);
22final String home = ExtensionsControl.getHomeUrl("net.sf.basedb.reggie");
23DbControl dc = null;
24try
25{
26  dc = sc.newDbControl();
27  final User user = User.getById(dc, sc.getLoggedInUserId());
28%>
29<base:page type="default" >
30<base:head scripts="ajax.js" styles="path.css">
31  <link rel="stylesheet" type="text/css" href="../css/reggie.css">
32  <script language="JavaScript" src="../reggie.js" type="text/javascript" charset="UTF-8"></script>
33 
34 
35<script language="JavaScript">
36var caseIsValid = false;
37var arrivalDateIsValid = true;
38var nofTubesIsValid = false;
39var lateralityIsValid = true;
40var boxesAreValid = null;
41var wellsAreValidValid = null;
42var specimenTypeIsValid = false;
43var samplingDateIsValid = true;
44var rnaLaterDateIsValid = true;
45var biopsyTypeIsValid = true;
46var debug = false;
47var currentStep = 1;
48var usedBox = '';
49var restartTimer;
50
51var caseInfo = null;
52var boxInfo = null;
53
54function init()
55{
56  var frm = document.forms['reggie'];
57  frm.caseName.focus();
58}
59
60function goNextAuto()
61{
62  goNext(false);
63}
64
65function goNext(manual)
66{
67  setInnerHTML('gonext.message', '');
68  if (currentStep == 1)
69  {   
70    gotoStep2();
71  }
72  else if (currentStep == 2)
73  {
74    if (step2IsValid()) gotoStep3();
75  }
76}
77
78function step2IsValid()
79{
80  var frm = document.forms['reggie'];
81  if (!nofTubesIsValid)
82  {
83    frm.nofTubes.focus();
84    return false;
85  }
86  if (!arrivalDateIsValid)
87  {
88    frm.arrivalDate.focus();
89    return false;
90  }
91  if (!samplingDateIsValid)
92  {
93    frm.samplingDate.focus();
94    return false;
95  }
96  if (!rnaLaterDateIsValid)
97  {
98    frm.rnaLaterDate.focus();
99    return false;
100  }
101  if (!lateralityIsValid) return false;
102  if (!biopsyTypeIsValid) return false;
103  return true;
104}
105
106function gotoStep2()
107{
108  var frm = document.forms['reggie'];
109  var caseName = frm.caseName.value.toUpperCase();
110  if (caseName == '')
111  {
112    setInputStatus('case', 'Missing', 'invalid');
113    return;
114  }
115  if (!isValidCaseName(caseName, true))  // Allow 'C' suffix to be used
116  {
117    setInputStatus('case', 'Only 7-digits name + optional \'C\' is allowed.', 'invalid');
118    frm.caseName.focus();
119    return;
120  }
121  frm.caseName.value = caseName;
122  setInputStatus('case', '', 'valid');
123 
124  getCaseInfo();
125 
126  frm.caseName.disabled = true;
127  if (caseInfo != null)
128  {
129    Main.show('gocancel');
130    Main.show('caseSection');
131  }
132 
133  var currentTime = new Date();
134  var currentYear = currentTime.getFullYear().toString();
135  var currentMonth = (currentTime.getMonth()+1).toString();
136  currentMonth = currentMonth.length < 2 ? '0'+currentMonth : currentMonth;
137  var currentDate = currentTime.getDate().toString();
138  currentDate = currentDate.length < 2 ? '0'+currentDate : currentDate;
139 
140  var dateString = currentYear + currentMonth + currentDate;
141 
142  frm.arrivalDate.value = dateString;
143   
144  frm.nofTubes.focus();
145  frm.nofTubes.setSelectionRange(0,1);
146 
147  // Select 'Laterality' if we have that information since before
148  if (caseInfo.laterality)
149  {
150    Forms.checkRadio(frm.laterality, caseInfo.laterality);
151    lateralityOnChange();
152   
153    if (caseInfo.laterality == 'LEFT') Main.hide('lateralityRight');
154    if (caseInfo.laterality == 'RIGHT') Main.hide('lateralityLeft');
155    Main.hide('lateralityUnknown');
156    document.getElementById('lateralityFromCase').innerHTML = '(From existing case: ' + caseInfo.name + ')';
157    Main.show('lateralityFromCase');
158  }
159 
160 
161  // Select 'SpecimenCoreBiopsy' if case name has 'C' suffix
162  var caseName = frm.caseName.value;
163  if (caseName.length > 7 && caseName.substring(7, 8) == 'C')
164  {
165    Forms.selectListOption(frm.biopsyType, 'SpecimenCoreBiopsy');
166    biopsyTypeOnClick();
167  }
168
169  currentStep = 2;   
170}
171
172function gotoStep3()
173{
174  var frm = document.forms['reggie'];
175  var inputTubeHtml = '';
176  var nofTubes = parseInt(frm.nofTubes.value);
177  boxInfo = new Array(nofTubes);
178 
179  var freeWells = findStoragePositions(nofTubes);
180 
181  frm.arrivalDate.disabled = true;
182  frm.nofTubes.disabled = true;
183  for (var i=0;i<frm.laterality.length;i++)
184  {
185    frm.laterality[i].disabled = true;
186  }
187  frm.rnaLaterDate.disabled = true;
188  frm.samplingDate.disabled = true;
189  frm.rnaLaterTime.disabled = true;
190  frm.samplingTime.disabled = true;
191  frm.otherPathNote.disabled = true;
192  frm.specimenType.disabled = true;
193  frm.biopsyType.disabled = true;
194 
195  boxesAreValid = new Array(nofTubes);
196  wellsAreValid = new Array(nofTubes);
197 
198  for (var i=0;i<nofTubes;i++)
199  {
200    var specimen = null;
201   
202    var freeWell = freeWells.length > i ? freeWells[i] : null;
203    var boxValue = freeWell == null ? '' : freeWell.bioPlate.name;
204    var rowValue = freeWell == null ? '' : WELL_ALPHA[freeWell.row];
205    var columnValue = freeWell == null ? '' : freeWell.column+1;
206    boxInfo[i] = freeWell == null ? '' : freeWell.bioPlate.id;
207    boxesAreValid[i] = freeWell != null;
208    wellsAreValid[i] = freeWell != null;
209    var spWeightValue = '';
210    var hisWeightValue = '';
211    var allPrepWeightValue = '';
212   
213    inputTubeHtml += '<tr>';
214    inputTubeHtml += '<td class="prompt">Specimen Tube '+caseInfo.originalName+'.'+(i+caseInfo.specimenFirstIndex)+'</td>';
215    inputTubeHtml += '</tr>';
216
217    var box = 'box'+i; 
218    var row = 'row'+i;
219    var column = 'column'+i;
220    var operatorComment = 'operatorComment'+i;
221    inputTubeHtml += '<tr>';
222    inputTubeHtml += '<td class="subprompt">Box</td>';
223    inputTubeHtml += '<td class="input">';
224    inputTubeHtml += '<input type="text" onkeypress="focusOnEnter(event, \''+row+'\')" name='+box+' value="' + boxValue + '" size="12" maxlength="12" onKeyUp="boxOnKeyUp('+i+')" onBlur="boxOnChange('+i+')"></td>';
225    inputTubeHtml += '<td class="status ' + (boxesAreValid[i] ? 'valid' : '') + '" id="'+box+'.status"></td>';
226    inputTubeHtml += '<td class="help"><span id="'+box+'.message" class="message" style="display: none;"></span>Box-number where the specimen tube is located in.</td>';   
227    inputTubeHtml += '</tr>';       
228   
229    inputTubeHtml += '<tr>';
230    inputTubeHtml += '<td class="subprompt">Row</td>';
231    inputTubeHtml += '<td class="input"><input style="text-transform:uppercase;" type="text"  onkeypress="focusOnEnter(event, \''+column+'\')" name='+row+' value="' + rowValue + '" size="3" maxlength="2" ';
232    inputTubeHtml += ' onBlur="wellOnChange('+i+')">';
233    inputTubeHtml += '&nbsp;Column<input type="text" onkeypress="focusOnEnter(event, \''+operatorComment+'\');  return true || Numbers.integerOnly(event);" name='+column+' value="'+ columnValue + '" size="3" maxlength="3" ';
234    inputTubeHtml += ' onBlur="wellOnChange('+i+')">';
235    inputTubeHtml += '</td>';
236    inputTubeHtml += '<td class="status ' + (wellsAreValid[i] ? 'valid' : '') + '" id="rowColumn'+i+'.status"></td>';
237    inputTubeHtml += '<td class="help"><span id="rowColumn'+i+'.message" class="message" style="display: none;"></span></td>';   
238    inputTubeHtml += '</tr>';
239
240    var doOnTab = i==(nofTubes-1) ? 'doOnTab(event, goCreate)' : '';
241    inputTubeHtml += '<tr>';
242    inputTubeHtml += '<td class="subprompt">Operator delivery comment</td>';
243    inputTubeHtml += '<td class="input"><textarea rows="3" cols="30" name='+operatorComment+' value="" onkeypress="'+doOnTab+'"></textarea></td>';
244    inputTubeHtml += '<td class="status" id="'+operatorComment+'.status"></td>';
245    inputTubeHtml += '<td class="help"><span id="'+operatorComment+'.message" class="message" style="display: none;"></span>Operator delivery comment</td>';   
246    inputTubeHtml += '</tr>';
247  }
248  setInnerHTML('tubeInputs', inputTubeHtml); 
249  currentStep = 3;
250  Main.show('tubeSection');
251  Main.hide('gonext'); 
252
253  Main.show('gocreate'); 
254
255  var textLength = frm.box0.value.length;
256  frm.box0.focus();
257  frm.box0.setSelectionRange(textLength,textLength);
258 
259}
260
261function findStoragePositions(nofTubes)
262{
263  var frm = document.forms['reggie'];
264 
265  var request = Ajax.getXmlHttpRequest();
266  try
267  {
268    showLoadingAnimation('Loading Lysate extracts...');
269    var url = '../SpecimenTubeRegistration.servlet?ID=<%=ID%>&cmd=FindStoragePositions'; 
270    url += '&nofTubes='+nofTubes;
271    request.open("GET", url, false); 
272    request.send(null);
273  }
274  finally
275  {
276    hideLoadingAnimation();
277  }
278 
279  if (debug) Main.debug(request.responseText);
280  var response = JSON.parse(request.responseText); 
281  if (response.status != 'ok')
282  {
283    setFatalError(response.message);
284    return false;
285  }
286  return response.wells;
287}
288
289
290function samplingDateTimeOnChange()
291{
292  var frm = document.forms['reggie'];
293  var todaysDate = new Date();
294  samplingDateIsValid = false;
295  setInputStatus('samplingDate', '', '');
296 
297  var samplingDate = frm.samplingDate.value;
298  var samplingTime = frm.samplingTime.value;
299 
300  if (samplingDate != '' || samplingTime != '')
301  {
302    // Auto-fill the date if it's only given with 4(MMdd) or 6(yyMMdd) digits.
303    samplingDate = autoFillDate(samplingDate);
304    frm.samplingDate.value = samplingDate;
305
306    samplingTime = autoFillTime(samplingTime);
307    frm.samplingTime.value = samplingTime;
308   
309    if (!Dates.isDate(samplingDate, 'yyyyMMdd'))
310    {
311      setInputStatus('samplingDate', 'Not a valid date', 'invalid');
312      return;
313    }   
314    if (todaysDate < new Date(samplingDate.substring(0,4),new Number(samplingDate.substring(4,6)-1), samplingDate.substring(6)) )
315    {
316      setInputStatus('samplingDate', 'Future date is not valid', 'invalid');
317      return;
318    }
319    if (frm.rnaLaterDate.value == '') frm.rnaLaterDate.value = samplingDate;
320   
321    if (!Dates.isDate(samplingDate + ' ' + samplingTime, 'yyyyMMdd HHmm'))
322    {
323      if (samplingDate != '') setInputStatus('samplingDate', 'Not a valid time (if time unknown, also leave date field blank)', 'invalid');
324      return;
325    }
326    setInputStatus('samplingDate', '', 'valid');
327  }
328  samplingDateIsValid = true;
329  rnaLaterDateTimeOnChange();
330}
331
332function boxOnKeyUp(tubeIndex)
333{
334  var frm = document.forms['reggie'];
335  var boxName = 'box'+tubeIndex;
336  var boxValue = frm.elements[boxName].value;
337  if (boxValue.length>0 && boxValue.substring(0,2) != 'Sp')
338  {
339    boxValue = 'Sp'+boxValue;
340  }
341  frm.elements[boxName].value = boxValue;
342}
343
344function boxOnChange(tubeIndex)
345{
346  var frm = document.forms['reggie'];
347  var boxName = 'box'+tubeIndex;
348  var boxValue = frm.elements[boxName].value;
349 
350  boxValue = boxValue.substring(2);
351  while (boxValue.length > 0 && boxValue.length < 3)
352  {   
353    boxValue = '0'+boxValue;
354  }
355  if (boxValue.length > 0)
356  {
357    boxValue = 'Sp'+boxValue;
358  }
359  frm.elements[boxName].value = boxValue;
360   
361  var request = Ajax.getXmlHttpRequest();
362  var url = '../SpecimenTubeRegistration.servlet?ID=<%=ID%>&cmd=GetBoxInfo';
363  url += '&boxName=' + boxValue;
364  request.open("GET", url, false);
365  request.send(null);
366
367  if (debug) Main.debug(request.responseText);
368
369  var response = JSON.parse(request.responseText);
370  if (response.status != 'ok')
371  {
372    boxesAreValid[tubeIndex] = false;   
373    setFatalError(response.message);
374    return false;
375  }
376  if (!response.boxInfo)
377  {
378    boxesAreValid[tubeIndex] = false;
379    setInputStatus(boxName, response.message, 'invalid');
380    return false;
381  }   
382  else
383  {
384    setInputStatus('rowColumn'+tubeIndex,'Row[A-'+response.rows+'], Columns[1-'+response.columns+']','');
385    boxesAreValid[tubeIndex] = true;
386    boxInfo[tubeIndex] = response.boxInfo; 
387   
388    if (tubeIndex==0)
389    {
390      usedBox = boxValue;     
391    }
392   
393    if (usedBox != boxValue)
394    {     
395      setInputStatus(boxName, 'More then one box is used','warning');
396      return;
397    }
398    setInputStatus('rowColumn'+tubeIndex,'Row[A-'+response.rows+'], Columns[1-'+response.columns+']','');
399    if (response.message && "Warning:" == response.message.substring(0,8))
400    {
401      setInputStatus(boxName, response.message.substring(8), 'warning');
402    }
403    else
404    {
405      setInputStatus(boxName, '', 'valid');
406    }
407  }   
408}
409
410function wellOnChange(tubeIndex)
411{
412  var frm = document.forms['reggie'];
413  var boxName = 'box'+tubeIndex;
414  var rowName = 'row'+tubeIndex;
415  var columnName = 'column'+tubeIndex;
416  var rowValue = frm.elements[rowName].value;
417  var columnValue = frm.elements[columnName].value
418  var boxValue = frm.elements[boxName].value;
419  var nofTubes = frm.nofTubes.value;
420 
421  wellsAreValid[tubeIndex] = false;
422 
423  if (boxValue != '' && 
424      (rowValue == '' || columnValue == ''))
425  {
426    setInputStatus('rowColumn'+tubeIndex, 'Row or column cannot be empty when the box is specified.', 'invalid');
427    return false;
428  }
429 
430  if (boxInfo[tubeIndex] == null)
431  {
432    boxOnChange(tubeIndex);
433    if (boxInfo[tubeIndex] == null) return;
434  }
435 
436  var request = Ajax.getXmlHttpRequest();
437  var url = '../SpecimenTubeRegistration.servlet?ID=<%=ID%>&cmd=ValidateWell';
438  url += '&boxId=' + boxInfo[tubeIndex]; 
439  url += '&row=' + rowValue;
440  url += '&column=' + columnValue;
441  request.open("GET", url, false);
442  request.send(null);
443
444  if (debug) Main.debug(request.responseText);
445
446  var response = JSON.parse(request.responseText);
447  if (response.status != 'ok')
448  {
449    setInputStatus('rowColumn'+tubeIndex, response.message, 'invalid');
450    return false;
451  }
452  if (response.message)
453  {
454    if (response.message.length>8 && response.message.substring(0,8) == "Warning:")
455    {
456      setInputStatus('rowColumn'+tubeIndex, response.message.substring(8), 'warning');
457    }
458    else
459    {
460      setInputStatus('rowColumn'+tubeIndex, response.message, 'invalid')
461      return false;
462    }   
463  }
464  for (var i=0;i<nofTubes;i++)
465  {   
466    if (i != tubeIndex && frm.elements['box'+i].value == boxValue)
467    {
468      if (rowValue == frm.elements['row'+i].value && 
469          columnValue == frm.elements['column'+i].value)
470      {
471        setInputStatus('rowColumn'+tubeIndex, 'The row and column are already used once in this wizard','invalid');       
472        return false;
473      }
474    }
475  }
476  wellsAreValid[tubeIndex] = true;
477  setInputStatus('rowColumn'+tubeIndex, '', 'valid');
478}
479
480function rnaLaterDateTimeOnChange()
481{
482  var frm = document.forms['reggie'];
483  var todaysDate = new Date();
484  rnaLaterDateIsValid = false;
485  setInputStatus('rnaLaterDate', '', '');
486 
487  var rnaLaterDate = frm.rnaLaterDate.value;
488  var rnaLaterTime = frm.rnaLaterTime.value;
489  var rnaLaterTimestamp;
490 
491  if (rnaLaterDate != '' || rnaLaterTime != '')
492  {
493    // Auto-fill the date if it's not given in yyyyMMdd
494    rnaLaterDate = autoFillDate(rnaLaterDate);
495    frm.rnaLaterDate.value = rnaLaterDate;
496
497    rnaLaterTime = autoFillTime(rnaLaterTime);
498    frm.rnaLaterTime.value = rnaLaterTime;
499   
500    if (!Dates.isDate(rnaLaterDate, 'yyyyMMdd'))
501    {
502      setInputStatus('rnaLaterDate', 'Not a valid date', 'invalid');
503      return;
504    }
505    if (todaysDate < new Date(rnaLaterDate.substring(0,4),new Number(rnaLaterDate.substring(4,6)-1), rnaLaterDate.substring(6)) )
506    {
507      setInputStatus('rnaLaterDate', 'Future date is not valid', 'invalid');
508      return;
509    }
510    rnaLaterTimestamp = Dates.parseString(rnaLaterDate + ' ' + rnaLaterTime, 'yyyyMMdd HHmm');
511    if (rnaLaterTimestamp == null)
512    {
513      if (rnaLaterDate != '') setInputStatus('rnaLaterDate', 'Not a valid time (if time unknown, also leave date field blank)', 'invalid');
514      return;
515    }
516    if (samplingDateIsValid && rnaLaterTimestamp)
517    {
518      var samplingTimestamp = Dates.parseString(frm.samplingDate.value + ' ' + frm.samplingTime.value, 'yyyyMMdd Hmm');     
519      if (samplingTimestamp)
520      {
521        if (rnaLaterTimestamp.getDate() != samplingTimestamp.getDate())
522        {
523          setInputStatus('rnaLaterDate', 'Sampling and RNA later dates are different', 'invalid');
524          return;
525        }
526        if (rnaLaterTimestamp.getTime() < samplingTimestamp.getTime())
527        {
528          setInputStatus('rnaLaterDate', 'RNA later time must be later than Sampling time','invalid');
529          return;
530        }
531      }
532     
533    }
534    setInputStatus('rnaLaterDate', '', 'valid');
535  }
536   
537  rnaLaterDateIsValid = true;
538}
539
540function arrivalDateOnBlur()
541{
542  var frm = document.forms['reggie'];
543  var arrivalDate = frm.arrivalDate.value;
544  var todaysDate = new Date();
545  arrivalDateIsValid = false;
546
547  setInputStatus('arrivalDate', '', '');
548
549  if (arrivalDate != '')
550  {
551    arrivalDate = autoFillDate(arrivalDate);
552    frm.arrivalDate.value = arrivalDate;
553
554    if (!Dates.isDate(arrivalDate, 'yyyyMMdd'))
555    {
556      setInputStatus('arrivalDate', 'Not a valid date', 'invalid');
557      return;
558    }
559    if (todaysDate < new Date(arrivalDate.substring(0,4), new Number(arrivalDate.substring(4,6))-1, arrivalDate.substring(6)))
560    {
561      setInputStatus('arrivalDate', 'Future dates are not valid','invalid');
562      return; 
563    }
564    setInputStatus('arrivalDate', '', 'valid');
565  }
566  else
567  {
568    setInputStatus('arrivalDate', 'Missing', 'warning');
569  } 
570  arrivalDateIsValid = true;
571}
572
573function nofTubesOnChange()
574{
575  var frm = document.forms['reggie'];
576  var nofTubes = frm.nofTubes.value;
577
578  if (nofTubes == '')
579  {
580    setInputStatus('nofTubes', 'Missing', 'invalid');
581    return;
582  }
583  if (nofTubes < '1')
584  {
585    setInputStatus('nofTubes', 'Must be at least 1', 'invalid');
586    return;   
587  }
588  setInputStatus('nofTubes','', 'valid');
589  nofTubesIsValid = true; 
590}
591
592
593function lateralityOnChange()
594{ 
595  lateralityIsValid = false;
596 
597  // Check selected laterality against specimen tubes
598  var frm = document.forms['reggie'];
599  var selectedLaterality = Forms.getCheckedRadio(frm.laterality);
600 
601  // No laterality/case selected
602  if (selectedLaterality == null) 
603  {
604    setInputStatus('laterality', 'Not selected', 'invalid');
605    return;
606  }
607 
608  lateralityIsValid = true;
609
610  if (caseInfo.laterality && caseInfo.laterality != selectedLaterality.value)
611  {
612    setInputStatus('laterality', 'Not same laterality as existing case/specimen', 'warning'); 
613    return;
614  }
615 
616  setInputStatus('laterality', '', 'valid');
617}
618
619function specimenTypeOnClick()
620{
621  var frm = document.forms['reggie'];
622  var selectedSpecimenType = frm.specimenType.value;
623 
624  specimenTypeIsValid = true;
625  var specimenType = null;
626  if (selectedSpecimenType != "")
627  {
628    specimenType = selectedSpecimenType;
629  }
630  setInputStatus('specimenType', '', 'valid');
631}
632
633function biopsyTypeOnClick()
634{
635  var frm = document.forms['reggie'];
636  var selectedBiopsyType = frm.biopsyType.value;
637  biopsyTypeIsValid = false;
638 
639  // Check 'SpecimenCoreBiopsy' if case name has 'C' suffix
640  var caseName = frm.caseName.value;
641  if (caseName.length > 7 && caseName.substring(7, 8) == 'C' && selectedBiopsyType != 'SpecimenCoreBiopsy')
642  {
643    setInputStatus('biopsyType', 'Case name with \'C\' suffix is always SpecimenCoreBiopsy', 'invalid');
644    return;
645  }
646 
647  biopsyTypeIsValid = true;
648  setInputStatus('biopsyType', '', 'valid');
649}
650
651function step3IsValid()
652{
653  var step3IsValid = false;
654  var i=0;
655  var bioWellsAreValid = true;
656  while (i<boxesAreValid.length && bioWellsAreValid)
657  {
658    if (!boxesAreValid[i] || !wellsAreValid[i])
659    {
660      bioWellsAreValid = false;
661    }
662    i++;
663  }
664  step3IsValid = bioWellsAreValid; 
665  return step3IsValid;
666}
667
668function goCreate()
669{
670  if (!step3IsValid()) return;
671
672  Main.hide('gocancel');
673  Main.hide('gocreate');
674  Main.hide('goupdate');
675  var frm = document.forms['reggie'];
676 
677  caseInfo.laterality = Forms.getCheckedRadio(frm.laterality).value;
678  caseInfo.samplingDate = Main.trimString(frm.samplingDate.value + ' ' + frm.samplingTime.value);
679  caseInfo.rnaLaterDate = Main.trimString(frm.rnaLaterDate.value + ' ' + frm.rnaLaterTime.value);
680  caseInfo.otherPathNote = frm.otherPathNote.value;
681  caseInfo.arrivalDate = Main.trimString(frm.arrivalDate.value);
682 
683  var nofTubes = frm.nofTubes.value;
684  caseInfo.specimen = new Array(nofTubes);
685  for (var i=0; i<nofTubes; i++)
686  {
687    var specimenTube = new Object();
688    specimenTube.name = caseInfo.originalName+'.'+(i+caseInfo.specimenFirstIndex);
689
690    frm.elements['box'+i].disabled = true;
691    frm.elements['row'+i].disabled = true;
692    frm.elements['column'+i].disabled = true;
693    frm.elements['operatorComment'+i].disabled = true;
694   
695    if (boxInfo[i] != '') specimenTube.boxId = boxInfo[i];
696    if (frm.elements['row'+i].value != '') specimenTube.row = frm.elements['row'+i].value;
697    if (frm.elements['column'+i].value != '') specimenTube.column = frm.elements['column'+i].value;
698    if (frm.elements['operatorComment'+i].value != '') specimenTube.operatorComment = frm.elements['operatorComment'+i].value;
699    if (frm.specimenType.value != '') specimenTube.specimenType = frm.specimenType.value;
700    if (frm.biopsyType.value != '') specimenTube.biopsyType = frm.biopsyType.value;
701   
702    caseInfo.specimen[i] = specimenTube;
703  }
704
705  var submitInfo = new Object();
706  submitInfo.caseInfo = caseInfo;
707
708  if (debug) Main.debug(JSON.stringify(submitInfo));
709 
710  var request = Ajax.getXmlHttpRequest();
711  var url = '../SpecimenTubeRegistration.servlet?ID=<%=ID%>&cmd=';
712  url += 'CreateSpecimenTubes';
713  request.open("POST", url, false);
714  request.setRequestHeader("Content-Type", "application/json");
715  request.send(JSON.stringify(submitInfo));
716
717  if (debug) Main.debug(request.responseText);
718
719  var response = JSON.parse(request.responseText);
720  if (response.status != 'ok')
721  {
722    setFatalError(response.message);
723    return false;
724  }
725
726  var msg = '<ul>';
727  for (var i = 0; i < response.messages.length; i++)
728  {
729    msg += '<li>' + response.messages[i];
730  }
731  msg += '</ul>';
732  msg += '<p></p>';
733  msg += '<div id=restartSection><i>Wizard will restart automatically...</i></div>';
734  setInnerHTML('done', msg);
735  Main.show('done');
736  Main.show('gostop');
737  restartTimer = setTimeout(function() { goRestart(true); },2000);
738}
739
740function getCaseInfo()
741{
742  var frm = document.forms['reggie'];
743  var caseName = frm.caseName.value;
744  var request = Ajax.getXmlHttpRequest();
745  var url = '../SpecimenTubeRegistration.servlet?ID=<%=ID%>&cmd=GetCaseInfo';
746  url += '&caseName=' + caseName;
747  request.open("GET", url, false);
748  request.send(null);
749
750  if (debug) Main.debug(request.responseText);
751
752  var response = JSON.parse(request.responseText);
753  if (response.status != 'ok')
754  {
755    setFatalError(response.message);
756    return false;
757  }
758  caseInfo = response.caseInfo;
759}
760
761function goStop()
762{
763  clearTimeout(restartTimer);
764  Main.hide('restartSection');
765  Main.hide('gostop');
766  Main.show('gorestart');
767}
768</script>
769
770</base:head>
771<base:body onload="init()">
772
773  <p:path><p:pathelement 
774    title="Reggie" href="<%="../index.jsp?ID="+ID%>" 
775    /><p:pathelement title="Specimen tube registration" 
776    /></p:path>
777 
778  <div class="content">
779  <%
780  if (sc.getActiveProjectId() == 0)
781  {
782    %>
783    <div class="messagecontainer note" style="width: 950px; margin-left: 20px; margin-bottom: 20px; margin-right: 0px; font-weight: bold; color: #cc0000;">
784      No project has been selected. You may proceed with the registration but
785      created items will not be shared.
786    </div>
787    <%
788  }
789  %>
790
791  <form name="reggie" onsubmit="return false;">
792 
793  <!-- 1. Case name-->
794  <table border="0" cellspacing="0" cellpadding="0" class="stepform">
795  <tr>
796    <td rowspan="3" class="stepno">1</td>
797    <td class="steptitle">Enter Case Name</td>
798  </tr>
799  <tr>
800    <td class="stepfields">
801      <table border="0" cellspacing="0" cellpadding="0" width="100%">
802      <tr valign="top">
803        <td class="prompt">Case name</td>
804        <td class="input"><input type="text" name="caseName" 
805          size="18" maxlength="12" onkeypress="doOnTabOrEnter(event, goNextAuto)"></td>
806        <td class="status" id="case.status"></td>
807        <td class="help"><span id="case.message" class="message" style="display: none;"></span>The 7-digit case (barcode) associated with this specimen tube.</td>
808      </tr>
809      </table>
810    </td>
811  </tr>
812  </table>
813 
814  <div id="caseSection" style="display: none;">
815  <p></p>
816  <table border="0" cellspacing="0" cellpadding="0" class="stepform">
817  <tr>
818    <td rowspan="2" class="stepno">2</td>
819    <td id="step2.title" class="steptitle">Enter Case information</td>
820  </tr>
821  <tr>
822    <td class="stepfields">
823    <table border="0" cellspacing="0" cellpadding="0" width="100%">
824    <tr>
825      <td class="prompt">Number of tubes</td>
826      <td class="input"><input type="text" name="nofTubes"
827        onkeypress="focusOnEnter(event, 'arrivalDate'); return Numbers.integerOnly(event);" value="1" size="12" maxlength="10" onblur='nofTubesOnChange()'></td>
828      <td class="status" id="nofTubes.status"></td>
829      <td class="help"><span id="nofTubes.message" class="message" style="display:none"></span>Number of tubes in this case.</td>
830    </tr>
831    <tr valign="top">
832      <td class="prompt">Arrival date</td>
833      <td class="input"><input type="text" name="arrivalDate"
834        onkeypress="focusOnEnter(event, 'samplingDate')" value="" size="12" maxlength="10" onblur="arrivalDateOnBlur()"></td>
835      <td class="status" id="arrivalDate.status"></td>
836      <td class="help"><span id="arrivalDate.message" class="message" style="display:none"></span>Date when the specimen tubes arrived(YYYYMMDD or MMDD).</td>
837    </tr>
838    <tr id="samplingDateSection" valign="top">
839      <td class="prompt">Sampling date</td>
840      <td class="input"><input type="text" name="samplingDate" value="" size="12" maxlength="10" 
841          onkeypress="focusOnEnter(event, 'samplingTime')" onblur="samplingDateTimeOnChange()">
842        Time <input type="text" name="samplingTime" value="" size="6" maxlength="4" 
843          onkeypress="focusOnEnter(event, 'rnaLaterDate')" onblur="samplingDateTimeOnChange()"></td>
844      <td class="status" id="samplingDate.status"></td>
845      <td class="help"><span id="samplingDate.message" class="message" style="display: none;"></span>Date+time of surgical removal (YYYYMMDD, HHMM or MMDD, HMM)</td>
846    </tr>
847    <tr id="rnaLaterDateSection" valign="top">
848      <td class="prompt">RNA Later date</td>
849      <td class="input"><input type="text" name="rnaLaterDate" value="" size="12" maxlength="10"
850          onkeypress="focusOnEnter(event, 'rnaLaterTime')" onblur="rnaLaterDateTimeOnChange()">
851        Time <input type="text" name="rnaLaterTime" value="" size="6" maxlength="4"
852          onkeypress="focusOnEnter(event, 'specimenType')" onblur="rnaLaterDateTimeOnChange()"></td>
853      <td class="status" id="rnaLaterDate.status"></td>
854      <td class="help"><span id="rnaLaterDate.message" class="message" style="display: none;"></span>Date+time of pathology handling (YYYYMMDD, HHMM or MMDD, HMM)</td>
855    </tr>
856    <tr>
857      <td class="prompt" id="laterality.prompt">Laterality</td>
858      <td class="input" id="laterality.input">
859        <label id="lateralityLeft"><input type="radio" name="laterality" value="LEFT" onclick="lateralityOnChange()">LEFT<br></label>
860        <label id="lateralityRight"><input type="radio" name="laterality" value="RIGHT" onclick="lateralityOnChange()">RIGHT<br></label>
861        <label id="lateralityUnknown"><input type="radio" name="laterality" value="" checked onclick="lateralityOnChange()"><i>unknown</label></i>
862        <span id="lateralityFromCase" style="display: none; font-style: italic;">(From existing case)</span>
863      </td>
864      <td class="status" id="laterality.status"></td>
865      <td class="help"><span id="laterality.message" class="message" style="display: none;"></span></td>
866    </tr>
867    <tr>
868      <td class="prompt" id="specimenType.prompt">Specimen type</td>
869      <td class="input" id="specimenType.input">
870        <select onkeypress="focusOnEnter(event, 'biopsyType')" 
871          name="specimenType" onChange="specimenTypeOnClick()"
872        >
873          <option selected value="" >unknown
874          <option value="Primary">Primary
875          <option value="LymphnodeRegional">LymphnodeRegional         
876          <option value="MetastasisDistant">MetastasisDistant
877          <option value="RecurrenceLocal">RecurrenceLocal
878          <option value="RecurrenceRegional">RecurrenceRegional         
879        </select>
880      </td>
881      <td class="status" id="specimenType.status"></td>
882      <td class="help"><span id="specimenType.message" class="message" style="display: none;"></span></td>
883    </tr>
884    <tr>
885      <td class="prompt" id="biopsyType.prompt">Biopsy type</td>
886      <td class="input" id="biopsyType.input">
887        <select onkeypress="focusOnEnter(event, 'otherPathNote')" 
888          name="biopsyType" onChange="biopsyTypeOnClick()"
889        >
890          <option selected value="" >unknown
891          <option value="SpecimenSurgery">SpecimenSurgery
892          <option value="SpecimenCoreBiopsy">SpecimenCoreBiopsy
893          <option value="SpecimenFineNeedleAspiration" >SpecimenFineNeedleAspiration
894        </select>
895      </td>
896      <td class="status" id="biopsyType.status"></td>
897      <td class="help"><span id="biopsyType.message" class="message" style="display: none;"></span></td>
898    </tr>
899   
900    <tr>
901      <td class="prompt" id="otherPathNote.prompt">Other path note</td>
902      <td class="input" id="otherPathNote.input"><textarea rows="3" cols="30" 
903        name="otherPathNote" value="" onkeypress="doOnTab(event, goNextAuto)"></textarea></td>
904      <td class="status" id="otherPathNote.status"></td>
905      <td class="help"><span id="otherPathNote.message" class="message" style="display: none;"></span></td>
906    </tr>
907    </table>
908    </td>
909     
910  </tr>
911  </table>
912  </div>
913 
914  <div id="tubeSection" style="display:none;">
915  <p></p>
916  <table border="0" cellspacing="0" cellpadding="0" class="stepform">
917  <tr>
918    <td rowspan="2" class="stepno">3</td>
919    <td class="steptitle">Enter tube information</td>   
920  </tr>
921  <tr>
922    <td class="stepfields">
923      <table id="tubeInputs" border="0" cellspacing="0" cellpadding="0" width="100%">
924      </table>
925    </td>
926  </tr>
927  </table>
928  </div> 
929   
930  <div class="messagecontainer error" id="errorMessage" style="display: none; width: 950px; margin-left: 20px; margin-bottom: 0px;"></div>
931 
932  <div id="done" class="success" style="display: none; width: 950px; margin-left: 20px; margin-top: 20px;"></div>
933 
934  <table style="margin-left: 20px; margin-top: 10px;" class="navigation">
935    <tr>
936      <td><base:button id="gocancel" title="Cancel" onclick="goRestart(false)" style="display: none;"/></td>
937      <td><base:button id="gonext" title="Next" image="<%=home+"/images/gonext.png"%>" onclick="goNext(true)"/></td>
938      <td><base:button id="gocreate" title="Create" image="<%=home+"/images/gonext.png"%>" onclick="goCreate()" style="display: none;"/></td>
939      <td><base:button id="goupdate" title="Update" image="<%=home+"/images/gonext.png"%>" onclick="goCreate()" style="display: none;"/></td>     
940      <td><base:button id="gorestart" title="Restart" image="<%=home+"/images/goback.png"%>" onclick="goRestart(true)" style="display: none;"/></td>
941      <td><base:button id="gostop" title="Stop" image="cancel.png" onclick="goStop()" style="display:none;"/></td>
942      <td id="gonext.message" class="message"></td>
943    </tr>
944  </table>
945  </form>
946  </div>
947 
948</base:body>
949</base:page>
950<%
951}
952finally
953{
954  if (dc != null) dc.close();
955}
956%>
Note: See TracBrowser for help on using the repository browser.