2794 |
13 Oct 14 |
nicklas |
var Histology = function() |
2794 |
13 Oct 14 |
nicklas |
2 |
{ |
2794 |
13 Oct 14 |
nicklas |
var histology = {}; |
2853 |
23 Oct 14 |
nicklas |
var debug = 0; |
2794 |
13 Oct 14 |
nicklas |
5 |
|
2794 |
13 Oct 14 |
nicklas |
var paraffinBlock; |
2794 |
13 Oct 14 |
nicklas |
var wells = ['idx.0.0', 'idx.1.0', 'idx.1.1', 'idx.2.0', 'idx.2.1']; |
2794 |
13 Oct 14 |
nicklas |
var wellIsValid = []; |
6646 |
17 Mar 22 |
nicklas |
var usedWells = []; |
2794 |
13 Oct 14 |
nicklas |
var numHEGlassIsValid = true; |
3119 |
06 Feb 15 |
nicklas |
var existingNumberOfHEGlass = 0; |
2794 |
13 Oct 14 |
nicklas |
var glassBoxIsValid = []; |
2794 |
13 Oct 14 |
nicklas |
13 |
|
2794 |
13 Oct 14 |
nicklas |
// Page initialization |
2794 |
13 Oct 14 |
nicklas |
histology.initPage = function() |
2794 |
13 Oct 14 |
nicklas |
16 |
{ |
2794 |
13 Oct 14 |
nicklas |
// Step 1 |
2794 |
13 Oct 14 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', histology.validateStep1); |
2794 |
13 Oct 14 |
nicklas |
Buttons.addClickHandler('btnSelectParaffinBlock', histology.selectParaffinBlock); |
2794 |
13 Oct 14 |
nicklas |
Events.addEventHandler('plates', 'base-selected', histology.onParaffinBlockSelected); |
2794 |
13 Oct 14 |
nicklas |
21 |
|
2794 |
13 Oct 14 |
nicklas |
// Step 2 |
2794 |
13 Oct 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', histology.initializeStep2); |
2794 |
13 Oct 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-validate', histology.validateStep2); |
2794 |
13 Oct 14 |
nicklas |
Events.addEventHandler('stainDate', 'blur', Wizard.validateDate); |
2794 |
13 Oct 14 |
nicklas |
Events.addEventHandler('numberOfHEGlass', 'keypress', Events.integerOnly); |
2794 |
13 Oct 14 |
nicklas |
Events.addEventHandler('numberOfHEGlass', 'change', histology.checkNumHEGlass); |
2794 |
13 Oct 14 |
nicklas |
28 |
|
2794 |
13 Oct 14 |
nicklas |
for (var i = 0; i < wells.length; i++) |
2794 |
13 Oct 14 |
nicklas |
30 |
{ |
2794 |
13 Oct 14 |
nicklas |
var w = wells[i]; |
2794 |
13 Oct 14 |
nicklas |
wellIsValid[w] = false; |
2794 |
13 Oct 14 |
nicklas |
Events.addEventHandler(w, 'keypress', Events.integerOnly); |
2794 |
13 Oct 14 |
nicklas |
Events.addEventHandler(w, 'blur', histology.checkIndexValue); |
2794 |
13 Oct 14 |
nicklas |
35 |
} |
2794 |
13 Oct 14 |
nicklas |
36 |
|
2794 |
13 Oct 14 |
nicklas |
// Step 3 |
2794 |
13 Oct 14 |
nicklas |
Events.addEventHandler('step-3', 'wizard-initialize', histology.initializeStep3); |
2794 |
13 Oct 14 |
nicklas |
Events.addEventHandler('step-3', 'wizard-validate', histology.validateStep3); |
2794 |
13 Oct 14 |
nicklas |
40 |
|
2794 |
13 Oct 14 |
nicklas |
// Navigation |
2794 |
13 Oct 14 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
2794 |
13 Oct 14 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
2794 |
13 Oct 14 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
2794 |
13 Oct 14 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
2794 |
13 Oct 14 |
nicklas |
46 |
|
2794 |
13 Oct 14 |
nicklas |
// Final registration |
2794 |
13 Oct 14 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', histology.submit); |
2794 |
13 Oct 14 |
nicklas |
49 |
|
2794 |
13 Oct 14 |
nicklas |
var url = '../Histology.servlet?ID='+App.getSessionId(); |
2794 |
13 Oct 14 |
nicklas |
url += '&cmd=GetParaffinBlocks'; |
2794 |
13 Oct 14 |
nicklas |
Wizard.showLoadingAnimation('Loading paraffin blocks...'); |
2794 |
13 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, histology.paraffinBlocksLoaded); |
2794 |
13 Oct 14 |
nicklas |
54 |
} |
2794 |
13 Oct 14 |
nicklas |
55 |
|
2794 |
13 Oct 14 |
nicklas |
histology.paraffinBlocksLoaded = function(response) |
2794 |
13 Oct 14 |
nicklas |
57 |
{ |
2794 |
13 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2794 |
13 Oct 14 |
nicklas |
59 |
|
2794 |
13 Oct 14 |
nicklas |
var plates = response.plates; |
2794 |
13 Oct 14 |
nicklas |
61 |
|
2794 |
13 Oct 14 |
nicklas |
var plateList = frm.plates; |
2794 |
13 Oct 14 |
nicklas |
if (plates.length > 0) |
2794 |
13 Oct 14 |
nicklas |
64 |
{ |
2794 |
13 Oct 14 |
nicklas |
for (var i=0; i < plates.length; i++) |
2794 |
13 Oct 14 |
nicklas |
66 |
{ |
2794 |
13 Oct 14 |
nicklas |
var plate = plates[i]; |
2794 |
13 Oct 14 |
nicklas |
var option = new Option(plate.name, plate.id); |
2794 |
13 Oct 14 |
nicklas |
option.plate = plate; |
2794 |
13 Oct 14 |
nicklas |
plateList.options[plateList.length] = option; |
2794 |
13 Oct 14 |
nicklas |
71 |
} |
2794 |
13 Oct 14 |
nicklas |
72 |
} |
2794 |
13 Oct 14 |
nicklas |
else |
2794 |
13 Oct 14 |
nicklas |
74 |
{ |
2794 |
13 Oct 14 |
nicklas |
Wizard.setInputStatus('plates', 'invalid', 'No paraffin blocks could be found.'); |
2794 |
13 Oct 14 |
nicklas |
76 |
} |
2794 |
13 Oct 14 |
nicklas |
77 |
|
2794 |
13 Oct 14 |
nicklas |
Doc.show('gonext'); |
2794 |
13 Oct 14 |
nicklas |
Doc.show('step-1'); |
2794 |
13 Oct 14 |
nicklas |
80 |
} |
2794 |
13 Oct 14 |
nicklas |
81 |
|
2794 |
13 Oct 14 |
nicklas |
82 |
|
2794 |
13 Oct 14 |
nicklas |
histology.selectParaffinBlock = function() |
2794 |
13 Oct 14 |
nicklas |
84 |
{ |
2794 |
13 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2794 |
13 Oct 14 |
nicklas |
if (frm.plates.disabled) return; |
2794 |
13 Oct 14 |
nicklas |
87 |
|
2794 |
13 Oct 14 |
nicklas |
var url = '&resetTemporary=1'; |
2794 |
13 Oct 14 |
nicklas |
url += '&tmpfilter:STRING:bioPlateType.name=FFPE+block'; |
2794 |
13 Oct 14 |
nicklas |
url += '&tmpfilter:INT:freeWells=1'; |
2794 |
13 Oct 14 |
nicklas |
Dialogs.selectItem('BIOPLATE', 'plates', 1, url); |
2794 |
13 Oct 14 |
nicklas |
92 |
} |
2794 |
13 Oct 14 |
nicklas |
93 |
|
2794 |
13 Oct 14 |
nicklas |
histology.onParaffinBlockSelected = function(event) |
2794 |
13 Oct 14 |
nicklas |
95 |
{ |
2794 |
13 Oct 14 |
nicklas |
var pb = event.detail; |
2794 |
13 Oct 14 |
nicklas |
Wizard.setInputStatus('plates'); |
2794 |
13 Oct 14 |
nicklas |
98 |
|
2794 |
13 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2794 |
13 Oct 14 |
nicklas |
var plates = frm.plates; |
2794 |
13 Oct 14 |
nicklas |
for (var i = 0; i < plates.length; i++) |
2794 |
13 Oct 14 |
nicklas |
102 |
{ |
2794 |
13 Oct 14 |
nicklas |
if (plates[i].value == pb.id) |
2794 |
13 Oct 14 |
nicklas |
104 |
{ |
2794 |
13 Oct 14 |
nicklas |
plates[i].selected = true; |
2794 |
13 Oct 14 |
nicklas |
return; |
2794 |
13 Oct 14 |
nicklas |
107 |
} |
2794 |
13 Oct 14 |
nicklas |
108 |
} |
2794 |
13 Oct 14 |
nicklas |
109 |
|
2794 |
13 Oct 14 |
nicklas |
var option = new Option(pb.name, pb.id, true, true); |
2794 |
13 Oct 14 |
nicklas |
plates[plates.length] = option; |
2794 |
13 Oct 14 |
nicklas |
112 |
} |
2794 |
13 Oct 14 |
nicklas |
113 |
|
2794 |
13 Oct 14 |
nicklas |
histology.validateStep1 = function(event) |
2794 |
13 Oct 14 |
nicklas |
115 |
{ |
2794 |
13 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2794 |
13 Oct 14 |
nicklas |
117 |
|
2794 |
13 Oct 14 |
nicklas |
if (frm.plates.selectedIndex == -1) |
2794 |
13 Oct 14 |
nicklas |
119 |
{ |
2794 |
13 Oct 14 |
nicklas |
Wizard.setInputStatus('plates', 'invalid', 'No paraffin block selected.'); |
2794 |
13 Oct 14 |
nicklas |
event.preventDefault(); |
2794 |
13 Oct 14 |
nicklas |
122 |
} |
2794 |
13 Oct 14 |
nicklas |
123 |
} |
2794 |
13 Oct 14 |
nicklas |
124 |
|
2794 |
13 Oct 14 |
nicklas |
histology.initializeStep2 = function() |
2794 |
13 Oct 14 |
nicklas |
126 |
{ |
2794 |
13 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2794 |
13 Oct 14 |
nicklas |
128 |
|
2794 |
13 Oct 14 |
nicklas |
Reggie.loadProtocols('STAINING_PROTOCOL', 'stainingProtocol'); |
2794 |
13 Oct 14 |
nicklas |
130 |
|
2794 |
13 Oct 14 |
nicklas |
var url = '../Histology.servlet?ID='+App.getSessionId(); |
2794 |
13 Oct 14 |
nicklas |
url += '&cmd=GetParaffinBlockInfo&bioPlateId='+frm.plates.value; |
2794 |
13 Oct 14 |
nicklas |
Wizard.showLoadingAnimation('Loading paraffin block information...'); |
2794 |
13 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, histology.paraffinBlockInfoLoaded); |
2794 |
13 Oct 14 |
nicklas |
135 |
} |
2794 |
13 Oct 14 |
nicklas |
136 |
|
2794 |
13 Oct 14 |
nicklas |
histology.paraffinBlockInfoLoaded = function(response) |
2794 |
13 Oct 14 |
nicklas |
138 |
{ |
2794 |
13 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2794 |
13 Oct 14 |
nicklas |
140 |
|
2794 |
13 Oct 14 |
nicklas |
paraffinBlock = response.paraffinBlock; |
2794 |
13 Oct 14 |
nicklas |
142 |
|
2794 |
13 Oct 14 |
nicklas |
var heGlass = paraffinBlock.heGlass; |
2794 |
13 Oct 14 |
nicklas |
var wellMap = [1, 0, 3, 2, 5, 4]; // Map well on Paraffin block to well on HEglass |
2794 |
13 Oct 14 |
nicklas |
145 |
|
2794 |
13 Oct 14 |
nicklas |
Doc.element('blockName').innerHTML = Strings.encodeTags(paraffinBlock.name); |
2794 |
13 Oct 14 |
nicklas |
frm.comment.value = paraffinBlock.comment; |
2794 |
13 Oct 14 |
nicklas |
148 |
|
2794 |
13 Oct 14 |
nicklas |
if (heGlass) |
2794 |
13 Oct 14 |
nicklas |
150 |
{ |
2794 |
13 Oct 14 |
nicklas |
frm.numberOfHEGlass.value = heGlass.length; |
2794 |
13 Oct 14 |
nicklas |
existingNumberOfHEGlass = heGlass.length; |
2794 |
13 Oct 14 |
nicklas |
153 |
} |
3119 |
06 Feb 15 |
nicklas |
else |
3119 |
06 Feb 15 |
nicklas |
155 |
{ |
3119 |
06 Feb 15 |
nicklas |
existingNumberOfHEGlass = 0; |
3119 |
06 Feb 15 |
nicklas |
157 |
} |
2794 |
13 Oct 14 |
nicklas |
158 |
|
2794 |
13 Oct 14 |
nicklas |
var numWells = 0; |
2794 |
13 Oct 14 |
nicklas |
for (var i = 0; i < paraffinBlock.bioWells.length; i++) |
2794 |
13 Oct 14 |
nicklas |
161 |
{ |
2794 |
13 Oct 14 |
nicklas |
var well = paraffinBlock.bioWells[i]; |
2794 |
13 Oct 14 |
nicklas |
var div = Doc.element('his.' + well.row + '.' + well.column); |
2794 |
13 Oct 14 |
nicklas |
if (div && well.bioMaterial) |
2794 |
13 Oct 14 |
nicklas |
165 |
{ |
2794 |
13 Oct 14 |
nicklas |
div.innerHTML = Strings.encodeTags(well.bioMaterial.name); |
6646 |
17 Mar 22 |
nicklas |
Doc.show('input.' + well.row + '.' + well.column); |
6646 |
17 Mar 22 |
nicklas |
usedWells[usedWells.length] = 'idx.' + well.row + '.' + well.column; |
2794 |
13 Oct 14 |
nicklas |
169 |
|
2794 |
13 Oct 14 |
nicklas |
if (heGlass) |
2794 |
13 Oct 14 |
nicklas |
171 |
{ |
2794 |
13 Oct 14 |
nicklas |
Doc.element('existingGlass').innerHTML = '<img src="../images/info.png">There are ' + heGlass.length + ' HE glass plates already registered for this paraffin block.'; |
2794 |
13 Oct 14 |
nicklas |
Doc.show('existingGlass'); |
2794 |
13 Oct 14 |
nicklas |
174 |
|
2794 |
13 Oct 14 |
nicklas |
// Try to find the current "GoodStain" annotation on a child biomaterial |
2794 |
13 Oct 14 |
nicklas |
var goodStain = 0; |
2794 |
13 Oct 14 |
nicklas |
for (var j = 0; j < heGlass.length; j++) |
2794 |
13 Oct 14 |
nicklas |
178 |
{ |
2794 |
13 Oct 14 |
nicklas |
var heWell = heGlass[j].bioWells[wellMap[i]]; |
2794 |
13 Oct 14 |
nicklas |
if (heWell.bioMaterial && heWell.bioMaterial.GoodStain) |
2794 |
13 Oct 14 |
nicklas |
181 |
{ |
2794 |
13 Oct 14 |
nicklas |
goodStain = j+1; |
2794 |
13 Oct 14 |
nicklas |
break; |
2794 |
13 Oct 14 |
nicklas |
184 |
} |
2794 |
13 Oct 14 |
nicklas |
185 |
} |
2794 |
13 Oct 14 |
nicklas |
var field = 'idx.'+well.row + '.' + well.column; |
2794 |
13 Oct 14 |
nicklas |
frm[field].value = goodStain; |
2794 |
13 Oct 14 |
nicklas |
histology.checkIndexValue(field); |
2794 |
13 Oct 14 |
nicklas |
189 |
} |
2794 |
13 Oct 14 |
nicklas |
frm['comment.'+well.row+'.'+well.column].value = well.bioMaterial.comment; |
2794 |
13 Oct 14 |
nicklas |
numWells++; |
2794 |
13 Oct 14 |
nicklas |
192 |
} |
2794 |
13 Oct 14 |
nicklas |
193 |
} |
2794 |
13 Oct 14 |
nicklas |
194 |
|
6646 |
17 Mar 22 |
nicklas |
if (numWells == 0) |
2794 |
13 Oct 14 |
nicklas |
196 |
{ |
6646 |
17 Mar 22 |
nicklas |
Wizard.setFatalError('There are no histology items on this paraffin block.'); |
2794 |
13 Oct 14 |
nicklas |
return; |
2794 |
13 Oct 14 |
nicklas |
199 |
} |
6646 |
17 Mar 22 |
nicklas |
else if (numWells < 5) |
6646 |
17 Mar 22 |
nicklas |
201 |
{ |
6646 |
17 Mar 22 |
nicklas |
var emptyLocations = numWells==4 ? '1 empty location' : (5-numWells)+' empty locations'; |
6646 |
17 Mar 22 |
nicklas |
Wizard.showGoNextConfirmation(false, 'There is '+emptyLocations+' on this paraffin block.'); |
6646 |
17 Mar 22 |
nicklas |
204 |
} |
2794 |
13 Oct 14 |
nicklas |
205 |
|
2794 |
13 Oct 14 |
nicklas |
Wizard.setCurrentStep(2); |
2794 |
13 Oct 14 |
nicklas |
Doc.show('gonext'); |
2794 |
13 Oct 14 |
nicklas |
Doc.show('gocancel'); |
2794 |
13 Oct 14 |
nicklas |
frm.stainDate.focus(); |
2794 |
13 Oct 14 |
nicklas |
210 |
} |
2794 |
13 Oct 14 |
nicklas |
211 |
|
2794 |
13 Oct 14 |
nicklas |
histology.checkNumHEGlass = function() |
2794 |
13 Oct 14 |
nicklas |
213 |
{ |
2794 |
13 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2794 |
13 Oct 14 |
nicklas |
numHEGlassIsValid = false; |
2794 |
13 Oct 14 |
nicklas |
216 |
|
2794 |
13 Oct 14 |
nicklas |
var numHEGlass = parseInt(frm.numberOfHEGlass.value, 10) || 0; |
2794 |
13 Oct 14 |
nicklas |
var limit = Math.max(1, existingNumberOfHEGlass); |
2794 |
13 Oct 14 |
nicklas |
if (numHEGlass < limit) |
2794 |
13 Oct 14 |
nicklas |
220 |
{ |
2794 |
13 Oct 14 |
nicklas |
Wizard.setInputStatus('numberOfHEGlass', 'invalid', 'Must be a value >= ' + limit); |
2794 |
13 Oct 14 |
nicklas |
return; |
2794 |
13 Oct 14 |
nicklas |
223 |
} |
2794 |
13 Oct 14 |
nicklas |
224 |
|
2794 |
13 Oct 14 |
nicklas |
Wizard.setInputStatus('numberOfHEGlass', 'valid'); |
2794 |
13 Oct 14 |
nicklas |
numHEGlassIsValid = true; |
2794 |
13 Oct 14 |
nicklas |
227 |
|
6646 |
17 Mar 22 |
nicklas |
for (var i = 0; i < usedWells.length; i++) |
2794 |
13 Oct 14 |
nicklas |
229 |
{ |
6646 |
17 Mar 22 |
nicklas |
histology.checkIndexValue(usedWells[i]); |
2794 |
13 Oct 14 |
nicklas |
231 |
} |
2794 |
13 Oct 14 |
nicklas |
232 |
|
2794 |
13 Oct 14 |
nicklas |
233 |
} |
2794 |
13 Oct 14 |
nicklas |
234 |
|
2794 |
13 Oct 14 |
nicklas |
235 |
|
2794 |
13 Oct 14 |
nicklas |
histology.checkIndexValue = function(field) |
2794 |
13 Oct 14 |
nicklas |
237 |
{ |
2794 |
13 Oct 14 |
nicklas |
// Can be called with either a ID or an Event object |
2794 |
13 Oct 14 |
nicklas |
if (field.currentTarget) field = field.currentTarget.id; |
2794 |
13 Oct 14 |
nicklas |
240 |
|
2794 |
13 Oct 14 |
nicklas |
wellIsValid[field] = false; |
2794 |
13 Oct 14 |
nicklas |
242 |
|
2794 |
13 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2794 |
13 Oct 14 |
nicklas |
var numHEGlass = parseInt(frm.numberOfHEGlass.value, 10) || 1; |
2794 |
13 Oct 14 |
nicklas |
var indexValue = parseInt(frm[field].value, 10); |
2794 |
13 Oct 14 |
nicklas |
246 |
|
2794 |
13 Oct 14 |
nicklas |
if (isNaN(indexValue) || indexValue < 0 || indexValue > numHEGlass) |
2794 |
13 Oct 14 |
nicklas |
248 |
{ |
2794 |
13 Oct 14 |
nicklas |
Wizard.setInputStatus(field, 'invalid'); |
2794 |
13 Oct 14 |
nicklas |
Wizard.setInputStatus('index', '', 'Must be between 1–'+numHEGlass + ' (or 0 if no good stain)'); |
2794 |
13 Oct 14 |
nicklas |
return; |
2794 |
13 Oct 14 |
nicklas |
252 |
} |
2794 |
13 Oct 14 |
nicklas |
253 |
|
2794 |
13 Oct 14 |
nicklas |
wellIsValid[field] = true; |
2794 |
13 Oct 14 |
nicklas |
if (indexValue == 0) |
2794 |
13 Oct 14 |
nicklas |
256 |
{ |
2794 |
13 Oct 14 |
nicklas |
Wizard.setInputStatus(field, 'flag', 'No good stain! Sample will be flagged and saved to Flagged Histology list.'); |
2794 |
13 Oct 14 |
nicklas |
258 |
} |
2794 |
13 Oct 14 |
nicklas |
else |
2794 |
13 Oct 14 |
nicklas |
260 |
{ |
2794 |
13 Oct 14 |
nicklas |
Wizard.setInputStatus(field, 'valid'); |
2794 |
13 Oct 14 |
nicklas |
262 |
} |
2794 |
13 Oct 14 |
nicklas |
263 |
|
2794 |
13 Oct 14 |
nicklas |
Wizard.setInputStatus('index'); |
2794 |
13 Oct 14 |
nicklas |
265 |
} |
2794 |
13 Oct 14 |
nicklas |
266 |
|
2794 |
13 Oct 14 |
nicklas |
267 |
|
2794 |
13 Oct 14 |
nicklas |
histology.validateStep2 = function(event) |
2794 |
13 Oct 14 |
nicklas |
269 |
{ |
2794 |
13 Oct 14 |
nicklas |
var valid = Wizard.isValid('stainDate'); |
2794 |
13 Oct 14 |
nicklas |
valid &= numHEGlassIsValid; |
2794 |
13 Oct 14 |
nicklas |
272 |
|
6646 |
17 Mar 22 |
nicklas |
for (var i = 0; i < usedWells.length; i++) |
2794 |
13 Oct 14 |
nicklas |
274 |
{ |
6646 |
17 Mar 22 |
nicklas |
var w = usedWells[i] |
2794 |
13 Oct 14 |
nicklas |
if (!wellIsValid[w]) |
2794 |
13 Oct 14 |
nicklas |
277 |
{ |
2794 |
13 Oct 14 |
nicklas |
Wizard.setInputStatus(w, 'invalid'); |
2794 |
13 Oct 14 |
nicklas |
valid = false; |
2794 |
13 Oct 14 |
nicklas |
280 |
} |
2794 |
13 Oct 14 |
nicklas |
281 |
} |
2794 |
13 Oct 14 |
nicklas |
if (!valid) event.preventDefault(); |
2794 |
13 Oct 14 |
nicklas |
283 |
} |
2794 |
13 Oct 14 |
nicklas |
284 |
|
2794 |
13 Oct 14 |
nicklas |
histology.initializeStep3 = function() |
2794 |
13 Oct 14 |
nicklas |
286 |
{ |
2794 |
13 Oct 14 |
nicklas |
var url = '../Histology.servlet?ID='+App.getSessionId(); |
2794 |
13 Oct 14 |
nicklas |
url += '&cmd=FindLastUsedHeGlassPosition'; |
2794 |
13 Oct 14 |
nicklas |
Wizard.showLoadingAnimation('Loading HE glass information...'); |
2794 |
13 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, histology.heGlassInfoLoaded); |
2794 |
13 Oct 14 |
nicklas |
291 |
} |
2794 |
13 Oct 14 |
nicklas |
292 |
|
2794 |
13 Oct 14 |
nicklas |
histology.heGlassInfoLoaded = function(response) |
2794 |
13 Oct 14 |
nicklas |
294 |
{ |
2794 |
13 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2794 |
13 Oct 14 |
nicklas |
296 |
|
2794 |
13 Oct 14 |
nicklas |
var numHEGlass = parseInt(frm.numberOfHEGlass.value, 10); |
3125 |
09 Feb 15 |
nicklas |
298 |
|
3125 |
09 Feb 15 |
nicklas |
// Set flag for slides with at least one good stain item |
3125 |
09 Feb 15 |
nicklas |
var hasGoodStain = []; |
6646 |
17 Mar 22 |
nicklas |
for (var i = 0; i < usedWells.length; i++) |
3125 |
09 Feb 15 |
nicklas |
302 |
{ |
6646 |
17 Mar 22 |
nicklas |
var w = usedWells[i]; |
3125 |
09 Feb 15 |
nicklas |
var glassNo = parseInt(frm[w].value, 10) - 1; |
3125 |
09 Feb 15 |
nicklas |
hasGoodStain[glassNo] = true; |
3125 |
09 Feb 15 |
nicklas |
306 |
} |
6646 |
17 Mar 22 |
nicklas |
307 |
|
2794 |
13 Oct 14 |
nicklas |
var lastHeGlassPosition = response; |
3121 |
06 Feb 15 |
nicklas |
var ihcValues = response.ihc; |
2794 |
13 Oct 14 |
nicklas |
310 |
|
3121 |
06 Feb 15 |
nicklas |
var ihcOptions = '<option></option>'; |
3121 |
06 Feb 15 |
nicklas |
for (var i = 0; i < ihcValues.length; i++) |
3121 |
06 Feb 15 |
nicklas |
313 |
{ |
3121 |
06 Feb 15 |
nicklas |
var v = Strings.encodeTags(ihcValues[i]); |
3121 |
06 Feb 15 |
nicklas |
ihcOptions += '<option value="' + v + '">'+v+'</option>'; |
3121 |
06 Feb 15 |
nicklas |
316 |
} |
3121 |
06 Feb 15 |
nicklas |
317 |
|
2794 |
13 Oct 14 |
nicklas |
var html = '<table id="glassTable">'; |
2794 |
13 Oct 14 |
nicklas |
html += '<thead>'; |
2794 |
13 Oct 14 |
nicklas |
// First header row |
2794 |
13 Oct 14 |
nicklas |
html += '<tr>'; |
2794 |
13 Oct 14 |
nicklas |
html += '<th style="width: 10em;">HE glass</th>'; |
2794 |
13 Oct 14 |
nicklas |
html += '<th style="width: 8em;">Storage box</th>'; |
2794 |
13 Oct 14 |
nicklas |
html += '<th style="width: 8em;">Position</th>'; |
3126 |
10 Feb 15 |
nicklas |
html += '<th style="width: 8em;">IHC¹</th>'; |
2794 |
13 Oct 14 |
nicklas |
html += '<th style="width: 30em;">Comment</th>'; |
2794 |
13 Oct 14 |
nicklas |
html += '<th style="width: 20px;"> </th>'; |
2794 |
13 Oct 14 |
nicklas |
html += '</tr>'; |
2794 |
13 Oct 14 |
nicklas |
html += '</thead>'; |
2794 |
13 Oct 14 |
nicklas |
html += '<tbody>'; |
2794 |
13 Oct 14 |
nicklas |
331 |
|
2794 |
13 Oct 14 |
nicklas |
var glassNamePrefix = paraffinBlock.name.replace('PB', 'HE'); |
2794 |
13 Oct 14 |
nicklas |
var heGlass = paraffinBlock.heGlass; |
2794 |
13 Oct 14 |
nicklas |
for (var glassNo = 0; glassNo < numHEGlass; glassNo++) |
2794 |
13 Oct 14 |
nicklas |
335 |
{ |
2794 |
13 Oct 14 |
nicklas |
var heSlide; |
2794 |
13 Oct 14 |
nicklas |
if (heGlass && heGlass[glassNo]) |
2794 |
13 Oct 14 |
nicklas |
338 |
{ |
2794 |
13 Oct 14 |
nicklas |
heSlide = heGlass[glassNo]; |
2794 |
13 Oct 14 |
nicklas |
340 |
} |
2794 |
13 Oct 14 |
nicklas |
else |
2794 |
13 Oct 14 |
nicklas |
342 |
{ |
3125 |
09 Feb 15 |
nicklas |
heSlide = {}; |
2794 |
13 Oct 14 |
nicklas |
heSlide.name = glassNamePrefix + '.' + (glassNo+1); |
2794 |
13 Oct 14 |
nicklas |
345 |
} |
2794 |
13 Oct 14 |
nicklas |
if (!heSlide.position) |
2794 |
13 Oct 14 |
nicklas |
347 |
{ |
2794 |
13 Oct 14 |
nicklas |
if (lastHeGlassPosition && lastHeGlassPosition.position) |
2794 |
13 Oct 14 |
nicklas |
349 |
{ |
2794 |
13 Oct 14 |
nicklas |
heSlide.position = ++lastHeGlassPosition.position; |
2794 |
13 Oct 14 |
nicklas |
if (heSlide.position > 100) |
2794 |
13 Oct 14 |
nicklas |
352 |
{ |
2794 |
13 Oct 14 |
nicklas |
heSlide.position = 1; |
2794 |
13 Oct 14 |
nicklas |
lastHeGlassPosition.position = 1; |
2794 |
13 Oct 14 |
nicklas |
lastHeGlassPosition.storageBox++; |
2794 |
13 Oct 14 |
nicklas |
356 |
} |
2794 |
13 Oct 14 |
nicklas |
heSlide.storageBox = lastHeGlassPosition.storageBox; |
2794 |
13 Oct 14 |
nicklas |
358 |
} |
2794 |
13 Oct 14 |
nicklas |
else |
2794 |
13 Oct 14 |
nicklas |
360 |
{ |
2794 |
13 Oct 14 |
nicklas |
heSlide.position = ''; |
2794 |
13 Oct 14 |
nicklas |
heSlide.storageBox = ''; |
2794 |
13 Oct 14 |
nicklas |
363 |
} |
2794 |
13 Oct 14 |
nicklas |
364 |
} |
2794 |
13 Oct 14 |
nicklas |
365 |
|
2794 |
13 Oct 14 |
nicklas |
html += '<tr>'; |
2794 |
13 Oct 14 |
nicklas |
html += '<td>' + Strings.encodeTags(heSlide.name) + '</td>'; |
3121 |
06 Feb 15 |
nicklas |
html += '<td><input type="text" class="required" name="glassBox.'+glassNo+'" id="glassBox.'+glassNo+'" value="'+heSlide.storageBox+'" style="width: 5em;"></td>'; |
3121 |
06 Feb 15 |
nicklas |
html += '<td><input type="text" class="required" name="position.'+glassNo+'" id="position.'+glassNo+'" value="'+heSlide.position+'" style="width: 5em;"></td>'; |
3125 |
09 Feb 15 |
nicklas |
html += '<td>'; |
3125 |
09 Feb 15 |
nicklas |
if (!hasGoodStain[glassNo] || heSlide.IHC) |
3125 |
09 Feb 15 |
nicklas |
372 |
{ |
3125 |
09 Feb 15 |
nicklas |
html += '<select name="ihc.'+glassNo+'" id="ihc.'+glassNo+'" style="width: 5em;">'+ihcOptions+'</select>'; |
3125 |
09 Feb 15 |
nicklas |
374 |
} |
3125 |
09 Feb 15 |
nicklas |
html += '</td>'; |
2794 |
13 Oct 14 |
nicklas |
html += '<td><input type="text" name="comment.'+glassNo+'"id="comment.'+glassNo+'" style="width: 95%;"></td>'; |
2794 |
13 Oct 14 |
nicklas |
html += '<td class="status" id="glassBox.'+glassNo+'.status"></td>'; |
2794 |
13 Oct 14 |
nicklas |
html += '</tr>'; |
2794 |
13 Oct 14 |
nicklas |
379 |
|
2794 |
13 Oct 14 |
nicklas |
380 |
} |
2794 |
13 Oct 14 |
nicklas |
html += '</tbody>'; |
2794 |
13 Oct 14 |
nicklas |
html += '</table>'; |
2794 |
13 Oct 14 |
nicklas |
383 |
|
2794 |
13 Oct 14 |
nicklas |
Doc.element('glassBoxInput').innerHTML = html; |
2794 |
13 Oct 14 |
nicklas |
385 |
|
2794 |
13 Oct 14 |
nicklas |
for (var glassNo = 0; glassNo < numHEGlass; glassNo++) |
2794 |
13 Oct 14 |
nicklas |
387 |
{ |
2794 |
13 Oct 14 |
nicklas |
if (heGlass && heGlass[glassNo]) |
2794 |
13 Oct 14 |
nicklas |
389 |
{ |
2794 |
13 Oct 14 |
nicklas |
frm['comment.'+glassNo].value = heGlass[glassNo].comment; |
3125 |
09 Feb 15 |
nicklas |
if (frm['ihc.'+glassNo]) |
3125 |
09 Feb 15 |
nicklas |
392 |
{ |
3125 |
09 Feb 15 |
nicklas |
Forms.selectListOption(frm['ihc.'+glassNo], heGlass[glassNo].IHC); |
3125 |
09 Feb 15 |
nicklas |
394 |
} |
2794 |
13 Oct 14 |
nicklas |
395 |
} |
2794 |
13 Oct 14 |
nicklas |
396 |
|
2794 |
13 Oct 14 |
nicklas |
Events.addEventHandler('glassBox.'+glassNo, 'keypress', Wizard.focusOnEnter, {'next-focus': 'position.'+glassNo}); |
2794 |
13 Oct 14 |
nicklas |
Events.addEventHandler('position.'+glassNo, 'keypress', Wizard.focusOnEnter, {'next-focus': 'comment.'+glassNo}); |
2794 |
13 Oct 14 |
nicklas |
Events.addEventHandler('comment.'+glassNo, 'keypress', Wizard.focusOnEnter, {'next-focus': 'glassBox.'+(glassNo+1)}); |
2794 |
13 Oct 14 |
nicklas |
400 |
|
2794 |
13 Oct 14 |
nicklas |
Events.addEventHandler('glassBox.'+glassNo, 'keypress', Events.integerOnly); |
2794 |
13 Oct 14 |
nicklas |
Events.addEventHandler('position.'+glassNo, 'keypress', Events.integerOnly); |
2794 |
13 Oct 14 |
nicklas |
403 |
|
2794 |
13 Oct 14 |
nicklas |
Events.addEventHandler('glassBox.'+glassNo, 'change', histology.glassBoxOnChange, {'index': glassNo}); |
2794 |
13 Oct 14 |
nicklas |
Events.addEventHandler('position.'+glassNo, 'change', histology.glassBoxOnChange, {'index': glassNo}); |
2794 |
13 Oct 14 |
nicklas |
Events.sendChangeEvent('glassBox.'+glassNo); |
2794 |
13 Oct 14 |
nicklas |
407 |
} |
2794 |
13 Oct 14 |
nicklas |
408 |
|
2794 |
13 Oct 14 |
nicklas |
Wizard.setCurrentStep(3); |
2794 |
13 Oct 14 |
nicklas |
Doc.show('goregister'); |
2794 |
13 Oct 14 |
nicklas |
Doc.show('gocancel'); |
2794 |
13 Oct 14 |
nicklas |
frm['glassBox.0'].focus(); |
2794 |
13 Oct 14 |
nicklas |
413 |
} |
2794 |
13 Oct 14 |
nicklas |
414 |
|
2794 |
13 Oct 14 |
nicklas |
histology.glassBoxOnChange = function(event) |
2794 |
13 Oct 14 |
nicklas |
416 |
{ |
2794 |
13 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2794 |
13 Oct 14 |
nicklas |
var glassNo = Data.int(event.currentTarget, 'index'); |
2794 |
13 Oct 14 |
nicklas |
419 |
|
2794 |
13 Oct 14 |
nicklas |
glassBoxIsValid[glassNo] = false; |
2794 |
13 Oct 14 |
nicklas |
421 |
|
2794 |
13 Oct 14 |
nicklas |
if (frm['glassBox.'+glassNo].value == '') |
2794 |
13 Oct 14 |
nicklas |
423 |
{ |
2794 |
13 Oct 14 |
nicklas |
Wizard.setInputStatus('glassBox.'+glassNo, 'invalid', 'Missing storage box'); |
2794 |
13 Oct 14 |
nicklas |
return; |
2794 |
13 Oct 14 |
nicklas |
426 |
} |
2794 |
13 Oct 14 |
nicklas |
if (frm['position.'+glassNo].value == '') |
2794 |
13 Oct 14 |
nicklas |
428 |
{ |
2794 |
13 Oct 14 |
nicklas |
Wizard.setInputStatus('glassBox.'+glassNo, 'invalid', 'Missing position'); |
2794 |
13 Oct 14 |
nicklas |
return; |
2794 |
13 Oct 14 |
nicklas |
431 |
} |
2794 |
13 Oct 14 |
nicklas |
432 |
|
2794 |
13 Oct 14 |
nicklas |
glassBoxIsValid[glassNo] = true; |
3119 |
06 Feb 15 |
nicklas |
Wizard.setInputStatus('glassBox.'+glassNo, paraffinBlock.heGlass && paraffinBlock.heGlass[glassNo] ? 'valid' : 'new'); |
2794 |
13 Oct 14 |
nicklas |
435 |
} |
2794 |
13 Oct 14 |
nicklas |
436 |
|
2794 |
13 Oct 14 |
nicklas |
histology.validateStep3 = function(event) |
2794 |
13 Oct 14 |
nicklas |
438 |
{ |
2794 |
13 Oct 14 |
nicklas |
var valid = true; |
2794 |
13 Oct 14 |
nicklas |
for (var glassNo = 0; glassNo < glassBoxIsValid.length; glassNo++) |
2794 |
13 Oct 14 |
nicklas |
441 |
{ |
2794 |
13 Oct 14 |
nicklas |
valid &= glassBoxIsValid[glassNo]; |
2794 |
13 Oct 14 |
nicklas |
443 |
} |
2794 |
13 Oct 14 |
nicklas |
444 |
|
2794 |
13 Oct 14 |
nicklas |
if (!valid) event.preventDefault(); |
2794 |
13 Oct 14 |
nicklas |
446 |
} |
2794 |
13 Oct 14 |
nicklas |
447 |
|
2794 |
13 Oct 14 |
nicklas |
histology.submit = function() |
2794 |
13 Oct 14 |
nicklas |
449 |
{ |
2794 |
13 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2794 |
13 Oct 14 |
nicklas |
451 |
|
2794 |
13 Oct 14 |
nicklas |
for (var i = 0; i < paraffinBlock.bioWells.length; i++) |
2794 |
13 Oct 14 |
nicklas |
453 |
{ |
2794 |
13 Oct 14 |
nicklas |
var well = paraffinBlock.bioWells[i]; |
2794 |
13 Oct 14 |
nicklas |
var field = 'idx.'+ well.row + '.' + well.column; |
6646 |
17 Mar 22 |
nicklas |
if (well.bioMaterial && frm[field]) |
2794 |
13 Oct 14 |
nicklas |
457 |
{ |
2794 |
13 Oct 14 |
nicklas |
well.GoodStain = parseInt(frm[field].value, 10); |
2794 |
13 Oct 14 |
nicklas |
well.bioMaterial.comment = frm['comment.'+well.row+'.'+well.column].value; |
2794 |
13 Oct 14 |
nicklas |
460 |
} |
2794 |
13 Oct 14 |
nicklas |
461 |
} |
2794 |
13 Oct 14 |
nicklas |
462 |
|
2794 |
13 Oct 14 |
nicklas |
if (!paraffinBlock.heGlass) |
2794 |
13 Oct 14 |
nicklas |
464 |
{ |
2794 |
13 Oct 14 |
nicklas |
paraffinBlock.heGlass = []; |
2794 |
13 Oct 14 |
nicklas |
466 |
} |
2794 |
13 Oct 14 |
nicklas |
467 |
|
2794 |
13 Oct 14 |
nicklas |
var glassNo = 0; |
2794 |
13 Oct 14 |
nicklas |
while (frm['glassBox.'+glassNo]) |
2794 |
13 Oct 14 |
nicklas |
470 |
{ |
2794 |
13 Oct 14 |
nicklas |
if (paraffinBlock.heGlass.length <= glassNo) |
2794 |
13 Oct 14 |
nicklas |
472 |
{ |
2794 |
13 Oct 14 |
nicklas |
paraffinBlock.heGlass[glassNo] = {}; |
2794 |
13 Oct 14 |
nicklas |
474 |
} |
2794 |
13 Oct 14 |
nicklas |
var heGlass = paraffinBlock.heGlass[glassNo]; |
2794 |
13 Oct 14 |
nicklas |
heGlass.storageBox = frm['glassBox.'+glassNo].value; |
2794 |
13 Oct 14 |
nicklas |
heGlass.position = frm['position.'+glassNo].value; |
3125 |
09 Feb 15 |
nicklas |
if (frm['ihc.'+glassNo]) |
3125 |
09 Feb 15 |
nicklas |
479 |
{ |
3125 |
09 Feb 15 |
nicklas |
heGlass.IHC = frm['ihc.'+glassNo].value; |
3125 |
09 Feb 15 |
nicklas |
481 |
} |
2794 |
13 Oct 14 |
nicklas |
heGlass.comment = frm['comment.'+glassNo].value; |
2794 |
13 Oct 14 |
nicklas |
glassNo++; |
2794 |
13 Oct 14 |
nicklas |
484 |
} |
2794 |
13 Oct 14 |
nicklas |
485 |
|
2794 |
13 Oct 14 |
nicklas |
var submitInfo = {}; |
2794 |
13 Oct 14 |
nicklas |
paraffinBlock.stainDate = frm.stainDate.value; |
2794 |
13 Oct 14 |
nicklas |
paraffinBlock.protocolId = parseInt(frm.stainingProtocol.value, 10); |
2794 |
13 Oct 14 |
nicklas |
paraffinBlock.comment = frm.comment.value; |
2794 |
13 Oct 14 |
nicklas |
submitInfo.paraffinBlock = paraffinBlock; |
2794 |
13 Oct 14 |
nicklas |
491 |
|
2794 |
13 Oct 14 |
nicklas |
var url = '../Histology.servlet?ID='+App.getSessionId(); |
2794 |
13 Oct 14 |
nicklas |
url += '&cmd=RegisterHEGlass'; |
2794 |
13 Oct 14 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
2794 |
13 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, histology.submissionResults, 'POST', JSON.stringify(submitInfo)); |
2794 |
13 Oct 14 |
nicklas |
496 |
} |
2794 |
13 Oct 14 |
nicklas |
497 |
|
2794 |
13 Oct 14 |
nicklas |
histology.submissionResults = function(response) |
2794 |
13 Oct 14 |
nicklas |
499 |
{ |
2794 |
13 Oct 14 |
nicklas |
Wizard.showFinalMessage(response.messages); |
2794 |
13 Oct 14 |
nicklas |
Doc.show('gorestart'); |
2794 |
13 Oct 14 |
nicklas |
502 |
} |
2794 |
13 Oct 14 |
nicklas |
503 |
|
2794 |
13 Oct 14 |
nicklas |
return histology; |
2794 |
13 Oct 14 |
nicklas |
505 |
}(); |
2794 |
13 Oct 14 |
nicklas |
506 |
|
2794 |
13 Oct 14 |
nicklas |
Doc.onLoad(Histology.initPage); |
2794 |
13 Oct 14 |
nicklas |
508 |
|