2784 |
10 Oct 14 |
nicklas |
var Histology = function() |
2784 |
10 Oct 14 |
nicklas |
2 |
{ |
2784 |
10 Oct 14 |
nicklas |
var histology = {}; |
2853 |
23 Oct 14 |
nicklas |
var debug = 0; |
2784 |
10 Oct 14 |
nicklas |
5 |
|
2784 |
10 Oct 14 |
nicklas |
var nameIsValid = true; |
2784 |
10 Oct 14 |
nicklas |
var histologyIsValid = false; |
2784 |
10 Oct 14 |
nicklas |
var subtypeHistology = null; |
2784 |
10 Oct 14 |
nicklas |
9 |
|
2784 |
10 Oct 14 |
nicklas |
// Page initialization |
2784 |
10 Oct 14 |
nicklas |
histology.initPage = function() |
2784 |
10 Oct 14 |
nicklas |
12 |
{ |
2784 |
10 Oct 14 |
nicklas |
// Step 1 |
2784 |
10 Oct 14 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', histology.validateStep1); |
2784 |
10 Oct 14 |
nicklas |
Events.addEventHandler('name', 'change', histology.nameOnChange); |
2784 |
10 Oct 14 |
nicklas |
Events.addEventHandler('histology', 'change', histology.histologyOnChange); |
2784 |
10 Oct 14 |
nicklas |
Buttons.addClickHandler('btnSelectHistologyItems', histology.selectHistologyItems); |
2784 |
10 Oct 14 |
nicklas |
Events.addEventHandler('histology', 'base-selected', histology.onHistologySelected); |
2784 |
10 Oct 14 |
nicklas |
19 |
|
2784 |
10 Oct 14 |
nicklas |
// Navigation |
2784 |
10 Oct 14 |
nicklas |
Buttons.addClickHandler('gocancel', histology.cancelWizard); |
2784 |
10 Oct 14 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
2784 |
10 Oct 14 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
2784 |
10 Oct 14 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
2784 |
10 Oct 14 |
nicklas |
Buttons.addClickHandler('goprotocol', histology.showProtocol); |
2784 |
10 Oct 14 |
nicklas |
26 |
|
2784 |
10 Oct 14 |
nicklas |
// Final registration |
2784 |
10 Oct 14 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', histology.submit); |
2784 |
10 Oct 14 |
nicklas |
29 |
|
2784 |
10 Oct 14 |
nicklas |
var url = '../Histology.servlet?ID='+App.getSessionId(); |
2784 |
10 Oct 14 |
nicklas |
url += '&cmd=GetUnembeddedHistologyItems'; |
2784 |
10 Oct 14 |
nicklas |
Wizard.showLoadingAnimation('Loading unembedded histology items...'); |
2784 |
10 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, histology.histologyItemsLoaded); |
2784 |
10 Oct 14 |
nicklas |
34 |
} |
2784 |
10 Oct 14 |
nicklas |
35 |
|
2784 |
10 Oct 14 |
nicklas |
histology.histologyItemsLoaded = function(response) |
2784 |
10 Oct 14 |
nicklas |
37 |
{ |
2784 |
10 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2784 |
10 Oct 14 |
nicklas |
var items = response.histology; |
2784 |
10 Oct 14 |
nicklas |
40 |
|
2784 |
10 Oct 14 |
nicklas |
var histologyList = frm.histology; |
2784 |
10 Oct 14 |
nicklas |
if (items.length > 0) |
2784 |
10 Oct 14 |
nicklas |
43 |
{ |
2784 |
10 Oct 14 |
nicklas |
for (var i=0; i < items.length; i++) |
2784 |
10 Oct 14 |
nicklas |
45 |
{ |
2784 |
10 Oct 14 |
nicklas |
var his = items[i]; |
2784 |
10 Oct 14 |
nicklas |
var name = (i+1) + ': ' + his.name; |
2784 |
10 Oct 14 |
nicklas |
if (his.bioWell) |
2784 |
10 Oct 14 |
nicklas |
49 |
{ |
2784 |
10 Oct 14 |
nicklas |
name += ' -- ' + his.bioWell.bioPlate.name + ' (' + his.bioWell.location+')'; |
2784 |
10 Oct 14 |
nicklas |
51 |
} |
2784 |
10 Oct 14 |
nicklas |
var option = new Option(name, his.id); |
2784 |
10 Oct 14 |
nicklas |
option.histology = his; |
2784 |
10 Oct 14 |
nicklas |
histologyList.options[histologyList.length] = option; |
2784 |
10 Oct 14 |
nicklas |
55 |
} |
2784 |
10 Oct 14 |
nicklas |
histology.histologyOnChange(); |
2784 |
10 Oct 14 |
nicklas |
57 |
} |
2784 |
10 Oct 14 |
nicklas |
else |
2784 |
10 Oct 14 |
nicklas |
59 |
{ |
2784 |
10 Oct 14 |
nicklas |
Wizard.setInputStatus('histology', 'invalid', 'No Histology items available for processing.'); |
2784 |
10 Oct 14 |
nicklas |
61 |
} |
2784 |
10 Oct 14 |
nicklas |
62 |
|
2784 |
10 Oct 14 |
nicklas |
Doc.show('goregister'); |
2784 |
10 Oct 14 |
nicklas |
Doc.show('gocancel'); |
2784 |
10 Oct 14 |
nicklas |
Doc.show('step-1'); |
2784 |
10 Oct 14 |
nicklas |
66 |
} |
2784 |
10 Oct 14 |
nicklas |
67 |
|
2784 |
10 Oct 14 |
nicklas |
histology.nameOnChange = function() |
2784 |
10 Oct 14 |
nicklas |
69 |
{ |
2784 |
10 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2784 |
10 Oct 14 |
nicklas |
var name = frm.name.value; |
2784 |
10 Oct 14 |
nicklas |
72 |
|
2784 |
10 Oct 14 |
nicklas |
nameIsValid = false; |
2784 |
10 Oct 14 |
nicklas |
if (name == '') |
2784 |
10 Oct 14 |
nicklas |
75 |
{ |
2784 |
10 Oct 14 |
nicklas |
Wizard.setInputStatus('name', 'invalid', 'Missing'); |
2784 |
10 Oct 14 |
nicklas |
return; |
2784 |
10 Oct 14 |
nicklas |
78 |
} |
2784 |
10 Oct 14 |
nicklas |
Wizard.setInputStatus('name', 'valid'); |
2784 |
10 Oct 14 |
nicklas |
nameIsValid = true; |
2784 |
10 Oct 14 |
nicklas |
81 |
} |
2784 |
10 Oct 14 |
nicklas |
82 |
|
2784 |
10 Oct 14 |
nicklas |
histology.histologyOnChange = function() |
2784 |
10 Oct 14 |
nicklas |
84 |
{ |
2784 |
10 Oct 14 |
nicklas |
histologyIsValid = false; |
2784 |
10 Oct 14 |
nicklas |
86 |
|
2784 |
10 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2784 |
10 Oct 14 |
nicklas |
var histologyList = frm.histology; |
2784 |
10 Oct 14 |
nicklas |
89 |
|
2784 |
10 Oct 14 |
nicklas |
var numSelected = 0; |
2784 |
10 Oct 14 |
nicklas |
for (var i = 0; i < histologyList.length; i++) |
2784 |
10 Oct 14 |
nicklas |
92 |
{ |
2784 |
10 Oct 14 |
nicklas |
if (histologyList[i].selected) numSelected++; |
2784 |
10 Oct 14 |
nicklas |
94 |
} |
2784 |
10 Oct 14 |
nicklas |
95 |
|
2784 |
10 Oct 14 |
nicklas |
Doc.element('numSelected').innerHTML = numSelected + ' selected'; |
2784 |
10 Oct 14 |
nicklas |
97 |
|
2784 |
10 Oct 14 |
nicklas |
if (numSelected == 0 || numSelected % 5 != 0) |
2784 |
10 Oct 14 |
nicklas |
99 |
{ |
2784 |
10 Oct 14 |
nicklas |
Wizard.setInputStatus('histology', 'invalid', 'Must select items in blocks of 5.'); |
2784 |
10 Oct 14 |
nicklas |
return; |
2784 |
10 Oct 14 |
nicklas |
102 |
} |
2784 |
10 Oct 14 |
nicklas |
103 |
|
2784 |
10 Oct 14 |
nicklas |
histologyIsValid = true; |
2784 |
10 Oct 14 |
nicklas |
Wizard.setInputStatus('histology', 'valid'); |
2784 |
10 Oct 14 |
nicklas |
106 |
} |
2784 |
10 Oct 14 |
nicklas |
107 |
|
2784 |
10 Oct 14 |
nicklas |
histology.selectHistologyItems = function() |
2784 |
10 Oct 14 |
nicklas |
109 |
{ |
2784 |
10 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2784 |
10 Oct 14 |
nicklas |
if (frm.histology.disabled) return; |
2784 |
10 Oct 14 |
nicklas |
112 |
|
2784 |
10 Oct 14 |
nicklas |
if (subtypeHistology == null) |
2784 |
10 Oct 14 |
nicklas |
114 |
{ |
2784 |
10 Oct 14 |
nicklas |
subtypeHistology = Reggie.getSubtypeInfo('HISTOLOGY'); |
2784 |
10 Oct 14 |
nicklas |
116 |
} |
2784 |
10 Oct 14 |
nicklas |
117 |
|
2784 |
10 Oct 14 |
nicklas |
var url = '&resetTemporary=1'; |
2784 |
10 Oct 14 |
nicklas |
url += '&tmpfilter:INT:itemSubtype='+subtypeHistology.id; |
2784 |
10 Oct 14 |
nicklas |
url += '&tmpfilter:DATE:creationEvent.eventDate='+encodeURIComponent('='); |
2784 |
10 Oct 14 |
nicklas |
Dialogs.selectItem('SAMPLE', 'histology', 1, url); |
2784 |
10 Oct 14 |
nicklas |
122 |
} |
2784 |
10 Oct 14 |
nicklas |
123 |
|
2784 |
10 Oct 14 |
nicklas |
histology.onHistologySelected = function(event) |
2784 |
10 Oct 14 |
nicklas |
125 |
{ |
2784 |
10 Oct 14 |
nicklas |
var his = event.detail; |
2784 |
10 Oct 14 |
nicklas |
127 |
|
2784 |
10 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2784 |
10 Oct 14 |
nicklas |
var histologyList = frm.histology; |
2808 |
15 Oct 14 |
nicklas |
var isNew = true; |
2784 |
10 Oct 14 |
nicklas |
for (var i = 0; i < histologyList.length; i++) |
2784 |
10 Oct 14 |
nicklas |
132 |
{ |
2784 |
10 Oct 14 |
nicklas |
if (histologyList[i].value == his.id) |
2784 |
10 Oct 14 |
nicklas |
134 |
{ |
2784 |
10 Oct 14 |
nicklas |
histologyList[i].selected = true; |
2808 |
15 Oct 14 |
nicklas |
isNew = false; |
2784 |
10 Oct 14 |
nicklas |
137 |
} |
2784 |
10 Oct 14 |
nicklas |
138 |
} |
2784 |
10 Oct 14 |
nicklas |
139 |
|
2808 |
15 Oct 14 |
nicklas |
if (isNew) |
2808 |
15 Oct 14 |
nicklas |
141 |
{ |
2808 |
15 Oct 14 |
nicklas |
var option = new Option(his.name, his.id, true, true); |
2808 |
15 Oct 14 |
nicklas |
histologyList[histologyList.length] = option; |
2808 |
15 Oct 14 |
nicklas |
144 |
} |
2808 |
15 Oct 14 |
nicklas |
145 |
|
2808 |
15 Oct 14 |
nicklas |
if (event.detail.remaining == 0) |
2808 |
15 Oct 14 |
nicklas |
147 |
{ |
2808 |
15 Oct 14 |
nicklas |
histology.histologyOnChange(); |
2808 |
15 Oct 14 |
nicklas |
149 |
} |
2784 |
10 Oct 14 |
nicklas |
150 |
} |
2784 |
10 Oct 14 |
nicklas |
151 |
|
2784 |
10 Oct 14 |
nicklas |
histology.validateStep1 = function(event) |
2784 |
10 Oct 14 |
nicklas |
153 |
{ |
2784 |
10 Oct 14 |
nicklas |
var valid = nameIsValid; |
2784 |
10 Oct 14 |
nicklas |
valid &= histologyIsValid; |
2784 |
10 Oct 14 |
nicklas |
156 |
|
2784 |
10 Oct 14 |
nicklas |
if (!valid) event.preventDefault(); |
2784 |
10 Oct 14 |
nicklas |
158 |
} |
2784 |
10 Oct 14 |
nicklas |
159 |
|
2784 |
10 Oct 14 |
nicklas |
histology.submit = function() |
2784 |
10 Oct 14 |
nicklas |
161 |
{ |
2784 |
10 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2784 |
10 Oct 14 |
nicklas |
163 |
|
2784 |
10 Oct 14 |
nicklas |
var submitInfo = {}; |
2784 |
10 Oct 14 |
nicklas |
submitInfo.name = frm.name.value; |
2784 |
10 Oct 14 |
nicklas |
submitInfo.comments = frm.comments.value; |
2784 |
10 Oct 14 |
nicklas |
167 |
|
2784 |
10 Oct 14 |
nicklas |
var items = []; |
2784 |
10 Oct 14 |
nicklas |
for (var i = 0; i < frm.histology.length; i++) |
2784 |
10 Oct 14 |
nicklas |
170 |
{ |
2784 |
10 Oct 14 |
nicklas |
if (frm.histology[i].selected) |
2784 |
10 Oct 14 |
nicklas |
172 |
{ |
2784 |
10 Oct 14 |
nicklas |
items[items.length] = parseInt(frm.histology[i].value, 10); |
2784 |
10 Oct 14 |
nicklas |
174 |
} |
2784 |
10 Oct 14 |
nicklas |
175 |
} |
2784 |
10 Oct 14 |
nicklas |
176 |
|
2784 |
10 Oct 14 |
nicklas |
submitInfo.histology = items; |
2784 |
10 Oct 14 |
nicklas |
178 |
|
2784 |
10 Oct 14 |
nicklas |
var url = '../Histology.servlet?ID='+App.getSessionId(); |
2784 |
10 Oct 14 |
nicklas |
url += '&cmd=CreateWorkList'; |
2784 |
10 Oct 14 |
nicklas |
Wizard.showLoadingAnimation('Creating Histology work list...'); |
2784 |
10 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, histology.submissionResults, 'POST', JSON.stringify(submitInfo)); |
2784 |
10 Oct 14 |
nicklas |
183 |
} |
2784 |
10 Oct 14 |
nicklas |
184 |
|
2784 |
10 Oct 14 |
nicklas |
histology.submissionResults = function(response) |
2784 |
10 Oct 14 |
nicklas |
186 |
{ |
2784 |
10 Oct 14 |
nicklas |
Wizard.showFinalMessage(response.messages); |
2784 |
10 Oct 14 |
nicklas |
188 |
|
2784 |
10 Oct 14 |
nicklas |
Doc.show('gorestart'); |
2784 |
10 Oct 14 |
nicklas |
if (response.workList) |
2784 |
10 Oct 14 |
nicklas |
191 |
{ |
2784 |
10 Oct 14 |
nicklas |
var printFrm = document.forms['print']; |
2784 |
10 Oct 14 |
nicklas |
printFrm.workList.value = response.workList.id; |
2784 |
10 Oct 14 |
nicklas |
Doc.show('goprotocol'); |
2784 |
10 Oct 14 |
nicklas |
195 |
} |
2784 |
10 Oct 14 |
nicklas |
196 |
} |
2784 |
10 Oct 14 |
nicklas |
197 |
|
2784 |
10 Oct 14 |
nicklas |
histology.cancelWizard = function() |
2784 |
10 Oct 14 |
nicklas |
199 |
{ |
2784 |
10 Oct 14 |
nicklas |
location.href = 'histology_protocol.jsp?ID='+App.getSessionId(); |
2784 |
10 Oct 14 |
nicklas |
201 |
} |
2784 |
10 Oct 14 |
nicklas |
202 |
|
2784 |
10 Oct 14 |
nicklas |
histology.showProtocol = function() |
2784 |
10 Oct 14 |
nicklas |
204 |
{ |
2784 |
10 Oct 14 |
nicklas |
var printFrm = document.forms['print']; |
2784 |
10 Oct 14 |
nicklas |
printFrm.submit(); |
2784 |
10 Oct 14 |
nicklas |
207 |
} |
2784 |
10 Oct 14 |
nicklas |
208 |
|
2784 |
10 Oct 14 |
nicklas |
return histology; |
2784 |
10 Oct 14 |
nicklas |
210 |
}(); |
2784 |
10 Oct 14 |
nicklas |
211 |
|
2784 |
10 Oct 14 |
nicklas |
Doc.onLoad(Histology.initPage); |
2784 |
10 Oct 14 |
nicklas |
213 |
|