source: extensions/net.sf.basedb.reggie/trunk/resources/partitionform.jsp @ 1638

Last change on this file since 1638 was 1638, checked in by Nicklas Nordborg, 10 years ago

Fixes #389: The partition wizard should not allow missing weights in some cases

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 26.0 KB
Line 
1<%@ page
2  pageEncoding="UTF-8"
3  session="false"
4  import="net.sf.basedb.core.User"
5  import="net.sf.basedb.core.DbControl"
6  import="net.sf.basedb.core.SessionControl"
7  import="net.sf.basedb.core.Application"
8  import="net.sf.basedb.clients.web.Base" 
9  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
10%>
11<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
12<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
13<%
14final SessionControl sc = Base.getExistingSessionControl(request, true);
15final String ID = sc.getId();
16final float scale = Base.getScale(sc);
17final String home = ExtensionsControl.getHomeUrl("net.sf.basedb.reggie");
18DbControl dc = null;
19try
20{
21  dc = sc.newDbControl();
22  final User user = User.getById(dc, sc.getLoggedInUserId());
23%>
24<base:page type="default" >
25<base:head scripts="ajax.js" styles="path.css">
26  <link rel="stylesheet" type="text/css" href="css/reggie.css">
27  <script language="JavaScript" src="reggie.js" type="text/javascript" charset="UTF-8"></script>
28 
29 
30<script language="JavaScript">
31var debug = false;
32var currentStep = 1;
33
34var specimenTubes = null;
35var selectedTubes = null;
36
37var partitionDateIsValid = false;
38
39var spWeightsAreValid;
40var apWeightsAreValid;
41var hisWeightsAreValid;
42var allWeightsAreValid;
43var nofPiecesAreValid;
44var isRestoringFromLocalStorage = false; // A flag to keep track of what is happening
45
46function init()
47{
48  var frm = document.forms['reggie'];
49  var selectList = frm.tubesSelect;
50  getSpecimenTubes();
51 
52  var specimenTubeOptions = '';
53  if (specimenTubes != null && specimenTubes.length > 0)
54  {
55    for (var i=0;i<specimenTubes.length;i++)
56    {
57      var tube = specimenTubes[i];
58      var storeInfo = getStoredInfo(tube.id);
59      selectList.options[selectList.length] = new Option(tube.name + (storeInfo ? ' [*]' : ''), tube.name, storeInfo ? true : false);
60    }
61  }
62  else
63  {
64    selectList.disabled = true;
65    Main.hide('gonext');   
66    setInputStatus('tubes','No tubes available for partition', 'invalid')
67  } 
68}
69
70function goNextAuto()
71{
72  goNext(false);
73}
74
75function goNext(manual)
76{
77  setInnerHTML('gonext.message', '');
78  if (currentStep == 1)
79  {   
80    gotoStep2();
81  }
82  else if (currentStep == 2)
83  {
84    partitionDateOnBlur();
85    if (step2IsValid()) gotoStep3();
86  }
87}
88
89function step2IsValid()
90{
91  return partitionDateIsValid;
92}
93
94function step3IsValid()
95{
96  for (var i=0; i<spWeightsAreValid.length; i++)
97  {
98   
99    if (spWeightsAreValid[i] == false ||
100        apWeightsAreValid[i] == false ||
101        hisWeightsAreValid[i] == false ||
102        nofPiecesAreValid[i] == false)
103    {
104      return false;
105    }
106    if (allWeightsAreValid[i] == false)
107    {
108      return false;
109    }
110  } 
111  return true;
112}
113
114function sortTubesByPosition(t1, t2)
115{
116  var box1 = t1.box;
117  var box2 = t2.box;
118  if (box1 < box2) return -1;
119  else if (box1>box2) return 1;
120  else
121  {
122    var row1 = t1.row;
123    var row2 = t2.row;
124    if (row1 < row2) return -1;
125    else if (row1>row2) return 1;
126    else
127    {
128      var col1 = t1.column;
129      var col2 = t2.column;
130      return col1 - col2;
131    }
132  }
133}
134
135function gotoStep2()
136{
137  var frm = document.forms['reggie'];
138  var selectList = frm.tubesSelect;
139  selectedTubes = new Array();
140  for (var i=0;i<selectList.length; i++)
141  {
142    if (selectList.options[i].selected)
143      selectedTubes.push(specimenTubes[i]);
144  }   
145  selectedTubes.sort(sortTubesByPosition);
146  if (selectedTubes.length == 0)
147  {
148    setInputStatus('tubes', 'Missing', 'invalid');
149    return;
150  }
151 
152  setInputStatus('tubes', '', 'valid');
153  // Change section
154  frm.tubesSelect.disabled = true;
155 
156  Main.show('partitionSection');
157  Main.show('gocancel');
158  var currentTime = new Date();
159  var currentYear = currentTime.getFullYear().toString();
160  var currentMonth = (currentTime.getMonth()+1).toString();
161  currentMonth = currentMonth.length < 2 ? '0'+currentMonth : currentMonth;
162  var currentDate = currentTime.getDate().toString();
163  currentDate = currentDate.length < 2 ? '0'+currentDate : currentDate;
164 
165  var dateString = currentYear + currentMonth + currentDate;
166 
167  frm.partitionDate.value = dateString;
168  frm.partitionDate.setSelectionRange(0,frm.partitionDate.value.length);
169  frm.partitionDate.focus();
170  currentStep = 2;
171}
172
173function gotoStep3()
174{
175  var frm = document.forms['reggie'];
176  frm.partitionDate.disabled = true; 
177 
178  var inputWeightHtml; 
179  if (selectedTubes.length > 0)
180  {
181    spWeightsAreValid = Array();
182    apWeightsAreValid = Array();
183    hisWeightsAreValid = Array();
184    nofPiecesAreValid = Array();
185    allWeightsAreValid = Array();
186   
187    for (var i=0;i<selectedTubes.length;i++)
188    {
189      spWeightsAreValid[i] = true;
190      apWeightsAreValid[i] = true;
191      hisWeightsAreValid[i] = true;
192      nofPiecesAreValid[i] = false;
193      allWeightsAreValid[i] = false;     
194    }
195   
196    inputWeightHtml = '<table border="0" cellspacing="0" cellpadding="0" width="100%">';
197    var spTitle = 'SpWeight<br>';
198    var apTitle = 'ApWeight<br>';
199    var hisTitle = 'HisWeight<br>';
200    var nofTitle = 'NofPieces<br>';
201    var appearanceTitle = 'Appearance<br>';
202    var necrosisTitle = 'Necrosis%<br>';
203    var fatTitle = 'Fat%<br>';
204    var colouredTitle = 'Coloured<br>';
205    var bloodyTitle = 'Bloody<br>';
206   
207    var appearanceOptions = '<option selected ></option>'; 
208    appearanceOptions += '<option value="HOMOGENEOUS">Homogeneous</option>';
209    appearanceOptions += '<option value="HETEROGENEOUS">Heterogeneous</option>';
210   
211    var necrosisOptions = '<option selected value="0">0</option>';
212    necrosisOptions += '<option value="5">5</option>';
213    necrosisOptions += '<option value="10">10</option>';
214    necrosisOptions += '<option value="15">15</option>';
215    necrosisOptions += '<option value="20">20</option>';
216    necrosisOptions += '<option value="30">30</option>';
217    necrosisOptions += '<option value="40">40</option>';
218    necrosisOptions += '<option value="60">60</option>';
219    necrosisOptions += '<option value="80">80</option>';
220    necrosisOptions += '<option value="100">100</option>';
221   
222    var fatOptions = '<option selected value=0>0</option>';
223    fatOptions += '<option value=20>20</option>';
224    fatOptions += '<option value=40>40</option>';
225    fatOptions += '<option value=60>60</option>';
226    fatOptions += '<option value=80>80</option>';
227    fatOptions += '<option value=100>100</option>';
228   
229    for (var i=0;i<selectedTubes.length; i++)
230    {
231      var tube = selectedTubes[i];
232      var nextStep = i<(selectedTubes.length-1) ? 'focusOnEnter(event, \'bloody'+(i+1)+'\')' : '';
233       
234      inputWeightHtml += '<tr>';
235      inputWeightHtml += '<td rowspan=2 class=prompt>'+tube.name;
236      // Only show box information if there is something show.     
237      if (tube.row != null && tube.column != null)
238      {
239        inputWeightHtml += ' ['+tube.box+'&nbsp;'+tube.row+tube.column+']';
240      }
241      inputWeightHtml += '</td>';
242     
243      inputWeightHtml += '<td style="width:400px;">';
244      inputWeightHtml += '<table style="width:100%"><tr>';     
245      inputWeightHtml += '<td>'+bloodyTitle+'<input type=checkbox onkeypress="checkOnNumber(event, this);focusOnEnter(event, \'appearance'+i+'\')" onchange="saveToLocalStorage('+i+')" onfocus="messageOnFocus(0,'+i+')" name=bloody'+i+' /></td>';
246      inputWeightHtml += '<td>'+appearanceTitle+'<select name=appearance'+i+' onfocus="messageOnFocus(1,'+i+')" onchange="saveToLocalStorage('+i+')" onkeypress="focusOnEnter(event, \'necrosis'+i+'\')">'+appearanceOptions+'</select></td>';
247      inputWeightHtml += '<td>'+necrosisTitle+'<select name=necrosis'+i+' onfocus="messageOnFocus(2,'+i+')" onchange="saveToLocalStorage('+i+')" onkeypress="focusOnEnter(event, \'fat'+i+'\')">'+necrosisOptions+'</select></td>';
248      inputWeightHtml += '<td>'+fatTitle+'<select name=fat'+i+' onfocus="messageOnFocus(3,'+i+')" onchange="saveToLocalStorage('+i+')" onkeypress="focusOnEnter(event, \'coloured'+i+'\')">'+fatOptions+'</select></td>';
249      inputWeightHtml += '<td>'+colouredTitle+'<input type=checkbox name=coloured'+i+' onfocus="messageOnFocus(4,'+i+')" onchange="saveToLocalStorage('+i+')" onkeypress="checkOnNumber(event, this);focusOnEnter(event, \'nofPieces'+i+'\')" /></td>'
250      inputWeightHtml += '<td>'+nofTitle+'<input name="nofPieces'+i+'" onfocus="messageOnFocus(5,'+i+')" onblur="nofPiecesOnChange('+i+')" onkeypress="focusOnEnter(event, \'spWeight'+i+'\');return isNumberKey(event)" size=2 /></td>';
251      inputWeightHtml += '<td>'+spTitle+'<input name="spWeight'+i+'" onfocus="messageOnFocus(6,'+i+')" onblur="spWeightOnChange('+i+')" onkeypress="focusOnEnter(event, \'hisWeight'+i+'\');return isNumberKey(event)" size=4 /></td>';
252      inputWeightHtml += '<td>'+hisTitle+'<input name="hisWeight'+i+'" onfocus="messageOnFocus(7,'+i+')" onblur="hisWeightOnChange('+i+')" onkeypress="focusOnEnter(event, \'apWeight'+i+'\');return isNumberKey(event)" size=4 /></td>';
253      inputWeightHtml += '<td>'+apTitle+'<input name="apWeight'+i+'" onfocus="messageOnFocus(8,'+i+')" onblur="apWeightOnChange('+i+')" onkeypress="'+nextStep+';return isNumberKey(event)" size=4 /></td>';     
254      inputWeightHtml += '</tr>';
255      inputWeightHtml += '</table>';
256      inputWeightHtml += '</td>';
257      inputWeightHtml += '<td rowspan=2 class="status" id="'+i+'.status"></td>';
258      inputWeightHtml += '</tr>';
259     
260      inputWeightHtml += '<tr>';
261      inputWeightHtml += '<td style="width:400px;" class="help"><span class="message" id="'+i+'.message"></span><span id="'+i+'.help"></span></td>';     
262      inputWeightHtml += '</tr>';     
263      inputWeightHtml += '<tr><td>&nbsp;</td></tr>';
264    }
265    inputWeightHtml += '</table>';
266    setInnerHTML('weightInputs', inputWeightHtml);
267   
268    // Restore saved information
269    isRestoringFromLocalStorage = true;
270    for (var i=0;i<selectedTubes.length; i++)
271    {
272      var tube = selectedTubes[i];
273      var storeInfo = getStoredInfo(tube.id);
274      if (storeInfo)
275      {
276        frm['bloody'+i].checked = storeInfo.bloody;
277        setSelectedValue(frm['appearance'+i], storeInfo.appearance);
278        setSelectedValue(frm['necrosis'+i], storeInfo.necrosis);
279        setSelectedValue(frm['fat'+i], storeInfo.fat);
280        frm['coloured'+i].checked = storeInfo.coloured;
281        frm['nofPieces'+i].value = storeInfo.nofPieces;
282        frm['spWeight'+i].value = storeInfo.spWeight;
283        frm['hisWeight'+i].value = storeInfo.hisWeight;
284        frm['apWeight'+i].value = storeInfo.apWeight;
285        nofPiecesOnChange(i);
286        spWeightOnChange(i);
287        hisWeightOnChange(i);
288        apWeightOnChange(i);
289      }
290    }
291    isRestoringFromLocalStorage = false;
292  }
293 
294 
295 
296  Main.show('weightSection');
297  Main.hide('gonext');
298  Main.show('gocreate');
299  frm.bloody0.focus();
300}
301
302function checkOnNumber(event, element)
303{
304  if (event.charCode == 48)
305  {
306    element.checked = false;
307  }
308  else if (event.charCode == 49)
309  {
310    element.checked = true;
311  }
312  return true;
313}
314
315function isNumberKey(evt)
316{
317  return true;
318  evt = (evt) ? evt : ((window.event) ? event : null);
319    if (evt) {
320       var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
321       if (elem) {
322           var charCode = (evt.charCode) ? evt.charCode : 
323               ((evt.which) ? evt.which : evt.keyCode);
324           if ((charCode < 32 ) || 
325               (charCode > 45 && charCode < 47) || 
326               (charCode > 47 && charCode < 58)) {
327               return true;
328           } else {
329               return false;
330           }
331       }
332    }
333}
334
335function messageOnFocus(order, tubeIndex)
336{ 
337  var helpMessage;
338  switch(order)
339  {
340    case 0:
341      helpMessage = 'Check this if the partition is bloody. Unchecked is default.';
342      break;
343    case 1:
344      helpMessage = 'Select appearance. Empty is default';
345      break;
346    case 2:
347      helpMessage = 'Select percentage of necrosis. \'0\' is default.';
348      break;
349    case 3:
350      helpMessage = 'Select percentage of fat. \'0\' is default.';
351      break;
352    case 4:
353      helpMessage = 'Check this if the partition is coloured. Unchecked is default.';
354      break;
355    case 5:
356      helpMessage = 'Number of pieces in this partition.';
357      break;
358    case 6:
359      helpMessage = 'Sp weight in [mg].';
360      break;
361    case 7:
362      helpMessage = 'His weight in [mg].';
363      break;
364    case 8:
365      helpMessage = 'Ap weight in [mg].';
366      break;
367    default:
368      helpMessage='&nbsp;';
369  }
370  for (var i=0;i<selectedTubes.length;i++)
371  {
372    if (i!=tubeIndex) setInnerHTML(i+'.help', '&nbsp;')
373  }
374  setInnerHTML(tubeIndex+'.help', helpMessage); 
375}
376
377
378
379/**
380  Save as much information as possible about the partitioned
381  specimen tube. The information is stored in the localStorage()
382  under the key 'reggie.specimen.<id>.partitionInfo' where
383  <id> is the ID of the specimen tube.
384*/
385function saveToLocalStorage(tubeIndex)
386{
387  if (window.localStorage && !isRestoringFromLocalStorage)
388  {
389    var tube = selectedTubes[tubeIndex];
390    var frm = document.forms['reggie'];
391    var storeInfo = new Object();
392    storeInfo.tubeId = tube.id;
393    storeInfo.bloody = frm['bloody'+tubeIndex].checked;
394    storeInfo.appearance = getSelectedValue(frm['appearance'+tubeIndex]);
395    storeInfo.necrosis = getSelectedValue(frm['necrosis'+tubeIndex]);
396    storeInfo.fat = getSelectedValue(frm['fat'+tubeIndex]);
397    storeInfo.coloured = frm['coloured'+tubeIndex].checked;
398    storeInfo.nofPieces = frm['nofPieces'+tubeIndex].value;
399    storeInfo.spWeight = frm['spWeight'+tubeIndex].value;
400    storeInfo.hisWeight = frm['hisWeight'+tubeIndex].value;
401    storeInfo.apWeight = frm['apWeight'+tubeIndex].value;
402    window.localStorage.setItem('reggie.specimen.' + tube.id + '.partitionInfo', JSON.stringify(storeInfo));
403    if (debug)
404    {
405      Main.debug(tubeIndex + ': ' + window.localStorage.getItem('reggie.specimen.' + tube.id + '.partitionInfo'));
406    }
407  }
408}
409
410function removeFromLocalStorage(tubeId)
411{
412  if (!window.localStorage) return;
413  if (debug) Main.debug('removeFromLocalStorage:' + tubeId);
414  window.localStorage.removeItem('reggie.specimen.' + tubeId + '.partitionInfo');
415}
416 
417function getStoredInfo(tubeId)
418{
419  if (!window.localStorage) return null;
420  try
421  {
422    var stored = window.localStorage.getItem('reggie.specimen.' + tubeId + '.partitionInfo');
423    if (debug) Main.debug(stored);
424    return stored ? JSON.parse(stored) : null;
425  }
426  catch (e)
427  {
428    Main.debug('Could not load stored information for tube ' + tubeId + ': ' + e);
429  }
430}
431
432function updateInputStatus(tubeIndex)
433{
434  saveToLocalStorage(tubeIndex);
435  var frm = document.forms['reggie'];
436  if(nofPiecesAreValid[tubeIndex] == false)
437  {
438    setInputStatus(tubeIndex, 'NofPieces is invalid.', 'invalid');
439    frm.elements['nofPieces'+tubeIndex].focus();
440    return ;
441  }
442  if (spWeightsAreValid[tubeIndex] == false)
443  {
444    setInputStatus(tubeIndex, 'SpWeight is invalid.','invalid');
445    return;
446  }
447  if(hisWeightsAreValid[tubeIndex] == false)
448  {
449    setInputStatus(tubeIndex, 'HisWeight is invalid.', 'invalid');
450    return;
451  }
452  if(apWeightsAreValid[tubeIndex] == false)
453  {
454    setInputStatus(tubeIndex, 'APWeight is invalid.', 'invalid');
455    return;
456  }
457 
458  var spWeightValue = frm.elements['spWeight'+tubeIndex].value;
459  var apWeightValue = frm.elements['apWeight'+tubeIndex].value;
460  var hisWeightValue = frm.elements['hisWeight'+tubeIndex].value;
461 
462  if (apWeightValue == '')
463  {
464    allWeightsAreValid[tubeIndex] = false;
465    setInputStatus(tubeIndex, 'No ApWeight is defined.', 'invalid');
466  }
467  else if (hisWeightValue == '' && spWeightValue != '')
468  {
469    allWeightsAreValid[tubeIndex] = false;
470    setInputStatus(tubeIndex, 'SpWeight is set but not HisWeight', 'invalid');
471   
472  }
473  else
474  {
475    allWeightsAreValid[tubeIndex] = true;
476    if (apWeightValue == '0')
477    {
478      setInputStatus(tubeIndex, 'No Lysate item will be created!', 'warning');
479    }
480    else if (hisWeightValue == '0')
481    {
482      setInputStatus(tubeIndex, 'No Histology item will be created!', 'warning');
483    }
484    else
485    {
486      setInputStatus(tubeIndex, '', 'valid');
487    }
488  }
489 
490}
491
492//Check the SpWeight value -- empty or >= 0 are ok.
493function spWeightOnChange(tubeIndex)
494{
495  var inputName = 'spWeight'+tubeIndex;
496  var frm = document.forms['reggie'];
497  var weightInput = frm.elements[inputName].value;
498  if (weightInput == '' || parseFloat(weightInput) >= 0)
499  {
500    spWeightsAreValid[tubeIndex] = true;
501  }
502  else
503  {
504    spWeightsAreValid[tubeIndex] = false;
505  }
506  updateInputStatus(tubeIndex);
507}
508
509// Check the ApWeight value -- empty or >= 0 are ok.
510function apWeightOnChange(tubeIndex)
511{
512  var inputName = 'apWeight'+tubeIndex;
513  var frm = document.forms['reggie'];
514  var weightInput = frm.elements[inputName].value;
515  if (weightInput == '' || parseFloat(weightInput) >= 0)
516  {
517    apWeightsAreValid[tubeIndex] = true;
518  }
519  else
520  {
521    apWeightsAreValid[tubeIndex] = false;
522  }
523  updateInputStatus(tubeIndex);
524}
525
526//Check the HisWeight value -- empty or >= 0 are ok.
527function hisWeightOnChange(tubeIndex)
528{
529  var inputName = 'hisWeight'+tubeIndex;
530  var frm = document.forms['reggie'];
531  var weightInput = frm.elements[inputName].value;
532  if (weightInput == '' || parseFloat(weightInput) >= 0)
533  {
534    hisWeightsAreValid[tubeIndex] = true;
535  }
536  else
537  {
538    hisWeightsAreValid[tubeIndex] = false;
539  }
540  updateInputStatus(tubeIndex);
541}
542
543function nofPiecesOnChange(tubeIndex)
544{
545  var inputName = 'nofPieces'+tubeIndex;
546  var frm = document.forms['reggie'];
547  var fieldInput = frm.elements[inputName].value;
548  if (fieldInput != '')
549  {
550    if (fieldInput < 0)
551    {
552      nofPiecesAreValid[tubeIndex] = false;
553      updateInputStatus(tubeIndex);
554      return;
555    } 
556    if (fieldInput == '0')
557    {
558      fieldInput = '';     
559      frm.elements[inputName].value = fieldInput;
560    }
561  } 
562  if (fieldInput == '')
563  {
564    nofPiecesAreValid[tubeIndex] = false;
565    updateInputStatus(tubeIndex);
566    return;
567  }
568  nofPiecesAreValid[tubeIndex] = true;
569  updateInputStatus(tubeIndex);
570}
571
572function partitionDateOnBlur()
573{
574  var frm = document.forms['reggie'];
575  var partitionDate = frm.partitionDate.value;
576  var todaysDate = new Date();
577  partitionDateIsValid = false;
578 
579  setInputStatus('partitionDate', '', '');
580 
581  if (partitionDate != '')
582  {
583    partitionDate = autoFillDate(partitionDate);
584    frm.partitionDate.value = partitionDate;
585   
586    if (!Dates.isDate(partitionDate, 'yyyyMMdd'))
587    {
588      setInputStatus('partitionDate', 'Not a valid date', 'invalid');
589      return;
590    }   
591    if (todaysDate < new Date(partitionDate.substring(0,4), new Number(partitionDate.substring(4,6)-1), partitionDate.substring(6)))
592    {
593      setInputStatus('partitionDate', 'Future dates are not valid','invalid');
594      return;
595    }
596    setInputStatus('partitionDate','','valid');   
597  }
598  else
599  {
600    setInputStatus('partitionDate', 'Missing', 'invalid');
601    return;
602  }
603  partitionDateIsValid = true;
604}
605
606function getSpecimenTubes()
607{
608  var frm = document.forms['reggie']; 
609 
610  var request = Ajax.getXmlHttpRequest();
611  var url = 'PartitionRegistration.servlet?ID=<%=ID%>&cmd=GetSpecimenTubes';   
612  request.open("GET", url, false); 
613  request.send(null);
614
615  if (debug) Main.debug(request.responseText); 
616  var response = JSON.parse(request.responseText); 
617  if (response.status != 'ok')
618  {
619    setFatalError(response.message);
620    return false;
621  } 
622  specimenTubes = response.tubeInfo.specimenTubes;
623}
624
625function goCreate()
626{
627  if (!step3IsValid()) return;
628 
629  Main.hide('gocancel');
630  Main.hide('gocreate');
631 
632  var frm = document.forms['reggie'];
633  var tubeInfo = new Object();
634 
635  var specimens = selectedTubes;
636  var nofTubes = specimens.length;
637  var partitionDateValue = frm.elements['partitionDate'].value;
638  tubeInfo.partitionDate = partitionDateValue;
639  for (var i=0; i<nofTubes; i++)
640  {
641    frm.elements['spWeight'+i].disabled = true;
642    frm.elements['apWeight'+i].disabled = true;
643    frm.elements['hisWeight'+i].disabled = true;
644    frm.elements['nofPieces'+i].disabled = true;
645    frm.elements['bloody'+i].disabled = true;
646    frm.elements['appearance'+i].disabled = true;
647    frm.elements['necrosis'+i].disabled = true;
648    frm.elements['fat'+i].disabled = true;
649    frm.elements['coloured'+i].disabled = true;
650       
651    var specimenTube = specimens[i];
652   
653    var spWeightValue = frm.elements['spWeight'+i].value; 
654    if (spWeightValue != '') specimenTube.spWeight = spWeightValue;
655    var apWeightValue = frm.elements['apWeight'+i].value;
656    if (apWeightValue != '') specimenTube.apWeight = apWeightValue;
657    var hisWeightValue = frm.elements['hisWeight'+i].value;
658    if (hisWeightValue != '') specimenTube.hisWeight = hisWeightValue;
659    var nofPiecesValue = frm.elements['nofPieces'+i].value;
660    if (nofPiecesValue != '') specimenTube.nofPieces = nofPiecesValue;
661   
662    var partitionComment = ''; 
663    var appearanceElement = frm.elements['appearance'+i];
664    var necrosisElement = frm.elements['necrosis'+i];
665    var fatElement = frm.elements['fat'+i];
666    var appearanceValue = appearanceElement.options[appearanceElement.selectedIndex].value;   
667    var necrosisValue = necrosisElement.options[necrosisElement.selectedIndex].value;
668    var fatValue = fatElement.options[fatElement.selectedIndex].value;
669   
670    // Generate partition comment string
671    if (frm.elements['bloody'+i].checked == true) partitionComment += 'BLOODY';
672    if (appearanceValue != '') partitionComment += (partitionComment.length>0 ? ';' : '') + appearanceValue;
673    if (necrosisValue != '0') partitionComment += (partitionComment.length>0 ? ';' : '') + 'NECROSIS'+necrosisValue+'%';
674    if (fatValue != '0') partitionComment += (partitionComment.length>0 ? ';' : '') + 'FAT'+fatValue+'%';
675    if (frm.elements['coloured'+i].checked == true) partitionComment += partitionComment.length>0 ? ';COLOURED' : 'COLOURED';
676   
677    specimenTube.operatorPartitionComment = partitionComment.length > 0 ? partitionComment : null;
678   
679    specimens[i] = specimenTube;   
680  }
681  tubeInfo.specimens = specimens;
682  var submitInfo = new Object();
683  submitInfo.tubeInfo = tubeInfo;
684 
685  if (debug) Main.debug(JSON.stringify(submitInfo));     
686  var request = Ajax.getXmlHttpRequest();
687  var url = 'PartitionRegistration.servlet?ID=<%=ID%>&cmd=CreatePartitions';
688  request.open("POST", url, false);
689  request.setRequestHeader("Content-Type", "application/json");
690  request.send(JSON.stringify(submitInfo));
691
692  if (debug) Main.debug(request.responseText);
693
694  var response = JSON.parse(request.responseText);
695  if (response.status != 'ok')
696  {
697    setFatalError(response.message);
698    return false;
699  }
700
701  var msg = '<ul>';
702  for (var i = 0; i < response.messages.length; i++)
703  {
704    msg += '<li>' + response.messages[i];
705  }
706  msg += '</ul>';
707  setInnerHTML('done', msg);
708 
709  for (var i = 0; i < response.partitioned.length; i++)
710  {
711    removeFromLocalStorage(response.partitioned[i]);
712  }
713 
714  Main.show('done');
715  Main.show('gorestart');
716}
717
718function downloadLabelFile()
719{ 
720  var downloadFileInput = 'PartitionRegistration.servlet?ID=<%=ID%>&cmd=GetLabelFile';
721  downloadFileInput += '&tubes=';
722  var separator = '';
723  for (i in selectedTubes)
724  {
725    downloadFileInput += separator + selectedTubes[i].name;
726    separator = ',';
727  } 
728  window.location = downloadFileInput;
729}
730</script>
731
732
733</base:head>
734<base:body onload="init()">
735
736  <p:path><p:pathelement 
737    title="Reggie" href="<%="index.jsp?ID="+ID%>" 
738    /><p:pathelement title="Partition registration" 
739    /></p:path>
740
741  <div class="content">
742  <%
743  if (sc.getActiveProjectId() == 0)
744  {
745    %>
746    <div class="messagecontainer note" style="width: 800px; margin-left: 20px; margin-bottom: 20px; margin-right: 0px; font-weight: bold; color: #cc0000;">
747      No project has been selected. You may proceed with the registration but
748      created items will not be shared.
749    </div>
750    <%
751  }
752  %>
753
754  <form name="reggie" onsubmit="return false;">
755 
756  <!-- 1. Case name-->
757  <table border="0" cellspacing="0" cellpadding="0" class="stepform">
758  <tr>
759    <td rowspan="3" class="stepno">1</td>
760    <td class="steptitle">Select specimen tubes</td>
761  </tr>
762  <tr>
763    <td class="stepfields">
764      <table border="0" cellspacing="0" cellpadding="0" width="100%">
765      <tr valign="top">
766        <td class="prompt">Specimen tubes</td>
767        <td class="input"><select style="width:50%" name="tubeSelect" id="tubesSelect" multiple="multiple" size="12" onkeypress='doOnTab(event, goNextAuto)'></select></td>
768        <td class="status" id="tubes.status"></td>
769        <td class="help"><span id="tubes.message" class="message" style="display: none;"></span>Select specimen tubes to include in the partition.<br>
770        * = There is unsaved partitioning information for this tube
771        </td>
772      </tr>
773      </table>
774    </td>
775  </tr>
776  </table>
777 
778  <!-- 2. General partition information -->
779  <div id="partitionSection" style="display: none;">
780    <p></p>
781    <table border="0" cellspacing="0" cellpadding="0" class="stepform">
782    <tr>
783      <td rowspan="2" class="stepno">2</td>
784      <td class="steptitle">General partition information</td>
785    </tr>
786    <tr>
787      <td class="stepfields">
788        <table border="0" cellspacing="0" cellpadding="0" width="100%">
789        <tr valign="top">
790          <td class="prompt">Partition date</td>
791          <td class="input"><input type="text" name="partitionDate" 
792             onkeypress="focusOnEnter(event, 'download')" size="12" maxlength="10" onBlur="partitionDateOnBlur()"></td>
793          <td class="status" id="partitionDate.status"></td>
794          <td class="help"><span id="partitionDate.message" class="message" style="display: none;"></span>The date when the partition was done.</td>
795        </tr>
796        <tr>
797          <td class="prompt">Download label file</td>
798          <td class="input" name="downloadfile.input" id="downloadfile.input">
799            <base:button id="downloadlabels" title="Download..." onclick="downloadLabelFile()" image="<%=home + "/images/download.png"%>" style="width:115px"/>
800          </td>
801          <td class="status" id="downloadfile.status"></td>
802          <td class="help"><span id="downloadfile.message" class="message" style="display:none;"></span>Download label file for the selected tubes.</td>
803        </tr>       
804        </table>
805      </td>
806    </tr>   
807    </table>
808  </div>
809 
810  <div id="weightSection" style="display:none;">
811    <p></p>
812    <table border="0" cellspacing="0" cellpadding="0" class="stepform">
813    <tr>
814      <td rowspan="2" class="stepno">3</td>
815      <td class="steptitle">Enter weight information</td>   
816    </tr>
817    <tr>
818      <td class="stepfields" id="weightInputs">
819       
820      </td>
821    </tr>
822    </table>
823  </div>
824   
825  <div class="messagecontainer error" id="errorMessage" style="display: none; width: 800px; margin-left: 20px; margin-bottom: 0px;"></div>
826 
827  <div id="done" class="success" style="display: none; width: 800px; margin-left: 20px; margin-top: 20px;"></div>
828 
829  <table style="margin-left: 20px; margin-top: 10px;" class="navigation">
830    <tr>
831      <td><base:button id="gocancel" title="Cancel" onclick="goRestart(false)" style="display: none;"/></td>
832      <td><base:button id="gonext" title="Next" image="<%=home+"/images/gonext.png"%>" onclick="goNext(true)"/></td>
833      <td><base:button id="gocreate" title="Create" image="<%=home+"/images/gonext.png"%>" onclick="goCreate()" style="display: none;"/></td>
834      <td><base:button id="goupdate" title="Update" image="<%=home+"/images/gonext.png"%>" onclick="goCreate()" style="display: none;"/></td>
835      <td><base:button id="gorestart" title="Restart" image="<%=home+"/images/goback.png"%>" onclick="goRestart(true)" style="display: none;"/></td>
836      <td id="gonext.message" class="message"></td>
837    </tr>
838  </table>
839  </form>
840  </div>
841 
842</base:body>
843</base:page>
844<%
845}
846finally
847{
848  if (dc != null) dc.close();
849}
850%>
Note: See TracBrowser for help on using the repository browser.