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