4089 |
08 Sep 16 |
nicklas |
var LysateReExtract = function() |
4089 |
08 Sep 16 |
nicklas |
2 |
{ |
4089 |
08 Sep 16 |
nicklas |
var extract = {}; |
4089 |
08 Sep 16 |
nicklas |
var debug = 0; |
4089 |
08 Sep 16 |
nicklas |
5 |
|
4089 |
08 Sep 16 |
nicklas |
var lysatesIsValid = false; |
4089 |
08 Sep 16 |
nicklas |
var selectedLysates; |
4089 |
08 Sep 16 |
nicklas |
8 |
|
4089 |
08 Sep 16 |
nicklas |
// Page initialization |
4089 |
08 Sep 16 |
nicklas |
extract.initPage = function() |
4089 |
08 Sep 16 |
nicklas |
11 |
{ |
4089 |
08 Sep 16 |
nicklas |
// Step 1 |
4089 |
08 Sep 16 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', extract.validateStep1); |
4089 |
08 Sep 16 |
nicklas |
14 |
|
4089 |
08 Sep 16 |
nicklas |
// Step 2 |
4089 |
08 Sep 16 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', extract.initializeStep2); |
4089 |
08 Sep 16 |
nicklas |
17 |
|
4089 |
08 Sep 16 |
nicklas |
// Navigation |
4089 |
08 Sep 16 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
4089 |
08 Sep 16 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
4089 |
08 Sep 16 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
4089 |
08 Sep 16 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
4089 |
08 Sep 16 |
nicklas |
Buttons.addClickHandler('goprint', extract.printPickList); |
4089 |
08 Sep 16 |
nicklas |
24 |
|
4089 |
08 Sep 16 |
nicklas |
// Final registration |
4092 |
09 Sep 16 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', extract.submit); |
4089 |
08 Sep 16 |
nicklas |
27 |
|
4089 |
08 Sep 16 |
nicklas |
var url = '../Extraction.servlet?ID='+App.getSessionId(); |
4089 |
08 Sep 16 |
nicklas |
url += '&cmd=GetLysatesForPicking'; |
4089 |
08 Sep 16 |
nicklas |
Wizard.showLoadingAnimation('Loading Lysates selected for re-extraction...'); |
4089 |
08 Sep 16 |
nicklas |
Wizard.asyncJsonRequest(url, extract.initializeStep1); |
4089 |
08 Sep 16 |
nicklas |
32 |
} |
4089 |
08 Sep 16 |
nicklas |
33 |
|
4089 |
08 Sep 16 |
nicklas |
extract.initializeStep1 = function(response) |
4089 |
08 Sep 16 |
nicklas |
35 |
{ |
4089 |
08 Sep 16 |
nicklas |
var frm = document.forms['reggie']; |
4089 |
08 Sep 16 |
nicklas |
var lysates = response.lysates; |
4089 |
08 Sep 16 |
nicklas |
38 |
|
4089 |
08 Sep 16 |
nicklas |
var lysateList = frm.lysates; |
4089 |
08 Sep 16 |
nicklas |
if (lysates.length > 0) |
4089 |
08 Sep 16 |
nicklas |
41 |
{ |
4089 |
08 Sep 16 |
nicklas |
for (var i=0; i < lysates.length; i++) |
4089 |
08 Sep 16 |
nicklas |
43 |
{ |
4089 |
08 Sep 16 |
nicklas |
var lysate = lysates[i]; |
4089 |
08 Sep 16 |
nicklas |
var isYellow = lysate.specimen.YellowLabel != null; |
4089 |
08 Sep 16 |
nicklas |
var name = (i+1) + ': ' + Strings.encodeTags(lysate.name); |
4089 |
08 Sep 16 |
nicklas |
if (lysate.bioWell) |
4089 |
08 Sep 16 |
nicklas |
48 |
{ |
4089 |
08 Sep 16 |
nicklas |
name += ' -- ' + Strings.encodeTags(lysate.bioWell.bioPlate.name + ' (' + lysate.bioWell.location+')'); |
4089 |
08 Sep 16 |
nicklas |
50 |
} |
4089 |
08 Sep 16 |
nicklas |
51 |
|
4089 |
08 Sep 16 |
nicklas |
var option = new Option(name, lysate.id, true, true); |
4089 |
08 Sep 16 |
nicklas |
if (isYellow) option.className = 'yellow'; |
4089 |
08 Sep 16 |
nicklas |
option.lysate = lysate; |
4089 |
08 Sep 16 |
nicklas |
lysateList.options[lysateList.length] = option; |
4089 |
08 Sep 16 |
nicklas |
56 |
} |
4089 |
08 Sep 16 |
nicklas |
57 |
} |
4089 |
08 Sep 16 |
nicklas |
else |
4089 |
08 Sep 16 |
nicklas |
59 |
{ |
4089 |
08 Sep 16 |
nicklas |
Wizard.setFatalError('No Lysates available for re-extraction.'); |
4089 |
08 Sep 16 |
nicklas |
return; |
4089 |
08 Sep 16 |
nicklas |
62 |
} |
4089 |
08 Sep 16 |
nicklas |
63 |
|
4089 |
08 Sep 16 |
nicklas |
Doc.show('step-1'); |
4089 |
08 Sep 16 |
nicklas |
Doc.show('gonext'); |
4089 |
08 Sep 16 |
nicklas |
66 |
} |
4089 |
08 Sep 16 |
nicklas |
67 |
|
4089 |
08 Sep 16 |
nicklas |
extract.printPickList = function() |
4089 |
08 Sep 16 |
nicklas |
69 |
{ |
4089 |
08 Sep 16 |
nicklas |
var frm = document.forms['reggie']; |
4089 |
08 Sep 16 |
nicklas |
var selected = []; |
4089 |
08 Sep 16 |
nicklas |
for (var i = 0; i < frm.lysates.length; i++) |
4089 |
08 Sep 16 |
nicklas |
73 |
{ |
4089 |
08 Sep 16 |
nicklas |
if (frm.lysates[i].selected) |
4089 |
08 Sep 16 |
nicklas |
75 |
{ |
4089 |
08 Sep 16 |
nicklas |
selected[selected.length] = frm.lysates[i].value; |
4089 |
08 Sep 16 |
nicklas |
77 |
} |
4089 |
08 Sep 16 |
nicklas |
78 |
} |
4089 |
08 Sep 16 |
nicklas |
79 |
|
4089 |
08 Sep 16 |
nicklas |
var url = 'lysate_picklist.jsp?ID='+App.getSessionId(); |
4089 |
08 Sep 16 |
nicklas |
url += '&lysates='+selected.join(','); |
4089 |
08 Sep 16 |
nicklas |
window.open(url, '_blank'); |
4089 |
08 Sep 16 |
nicklas |
Wizard.hideGoNextConfirmation(); |
4089 |
08 Sep 16 |
nicklas |
84 |
} |
4089 |
08 Sep 16 |
nicklas |
85 |
|
4089 |
08 Sep 16 |
nicklas |
extract.validateStep1 = function(event) |
4089 |
08 Sep 16 |
nicklas |
87 |
{ |
4089 |
08 Sep 16 |
nicklas |
var frm = document.forms['reggie']; |
4089 |
08 Sep 16 |
nicklas |
var lysateList = frm.lysates; |
4089 |
08 Sep 16 |
nicklas |
90 |
|
4089 |
08 Sep 16 |
nicklas |
selectedLysates = []; |
4089 |
08 Sep 16 |
nicklas |
for (var i=0; i < lysateList.length; i++) |
4089 |
08 Sep 16 |
nicklas |
93 |
{ |
4089 |
08 Sep 16 |
nicklas |
if (lysateList[i].selected) |
4089 |
08 Sep 16 |
nicklas |
95 |
{ |
4089 |
08 Sep 16 |
nicklas |
selectedLysates[selectedLysates.length] = lysateList[i].lysate; |
4089 |
08 Sep 16 |
nicklas |
97 |
} |
4089 |
08 Sep 16 |
nicklas |
98 |
} |
4089 |
08 Sep 16 |
nicklas |
99 |
|
4089 |
08 Sep 16 |
nicklas |
if (selectedLysates.length == 0) |
4089 |
08 Sep 16 |
nicklas |
101 |
{ |
4089 |
08 Sep 16 |
nicklas |
Wizard.setInputStatus('lysates', 'invalid', 'Not selected', 'invalid'); |
4089 |
08 Sep 16 |
nicklas |
event.preventDefault(); |
4089 |
08 Sep 16 |
nicklas |
104 |
} |
4089 |
08 Sep 16 |
nicklas |
else |
4089 |
08 Sep 16 |
nicklas |
106 |
{ |
4089 |
08 Sep 16 |
nicklas |
Wizard.setInputStatus('lysates', 'valid'); |
4089 |
08 Sep 16 |
nicklas |
108 |
} |
4089 |
08 Sep 16 |
nicklas |
109 |
} |
4089 |
08 Sep 16 |
nicklas |
110 |
|
4089 |
08 Sep 16 |
nicklas |
extract.initializeStep2 = function() |
4089 |
08 Sep 16 |
nicklas |
112 |
{ |
4089 |
08 Sep 16 |
nicklas |
113 |
|
4089 |
08 Sep 16 |
nicklas |
var url = '../Extraction.servlet?ID='+App.getSessionId(); |
4089 |
08 Sep 16 |
nicklas |
url += '&cmd=GetNewLysateBoxPositions&numLysates='+selectedLysates.length; |
4089 |
08 Sep 16 |
nicklas |
Wizard.showLoadingAnimation('Finding new box positions for lysates...'); |
4089 |
08 Sep 16 |
nicklas |
Wizard.asyncJsonRequest(url, extract.newBoxPositionsLoaded); |
4089 |
08 Sep 16 |
nicklas |
118 |
|
4089 |
08 Sep 16 |
nicklas |
119 |
} |
4089 |
08 Sep 16 |
nicklas |
120 |
|
4089 |
08 Sep 16 |
nicklas |
extract.newBoxPositionsLoaded = function(response) |
4089 |
08 Sep 16 |
nicklas |
122 |
{ |
4089 |
08 Sep 16 |
nicklas |
var newWells = response.wells; |
4089 |
08 Sep 16 |
nicklas |
if (newWells.length < selectedLysates.length) |
4089 |
08 Sep 16 |
nicklas |
125 |
{ |
4089 |
08 Sep 16 |
nicklas |
var msg; |
4089 |
08 Sep 16 |
nicklas |
if (!response.lastExtraLys) |
4089 |
08 Sep 16 |
nicklas |
128 |
{ |
4089 |
08 Sep 16 |
nicklas |
msg = 'Could not find any extra storage boxes for'; |
4089 |
08 Sep 16 |
nicklas |
msg += ' Lysate, RNA, DNA and FlowThrough.'; |
4089 |
08 Sep 16 |
nicklas |
msg += ' Please prepare and register extra storage boxes before using this wizard.'; |
4089 |
08 Sep 16 |
nicklas |
132 |
} |
4089 |
08 Sep 16 |
nicklas |
else |
4089 |
08 Sep 16 |
nicklas |
134 |
{ |
4089 |
08 Sep 16 |
nicklas |
var msg = 'Could not find any empty space in <i>' + Strings.encodeTags(response.lastExtraLys) + '</i>'; |
4089 |
08 Sep 16 |
nicklas |
msg += ' and related storage boxes for Lysate, RNA, DNA and FlowThrough.'; |
4089 |
08 Sep 16 |
nicklas |
msg += ' Please prepare and register extra storage boxes before using this wizard.'; |
4089 |
08 Sep 16 |
nicklas |
138 |
} |
4089 |
08 Sep 16 |
nicklas |
Wizard.setFatalError(msg); |
4089 |
08 Sep 16 |
nicklas |
return; |
4089 |
08 Sep 16 |
nicklas |
141 |
} |
4089 |
08 Sep 16 |
nicklas |
142 |
|
6722 |
04 May 22 |
nicklas |
var html = ''; |
4089 |
08 Sep 16 |
nicklas |
var homeUrl = Data.get('page-data', 'home-url'); |
4089 |
08 Sep 16 |
nicklas |
var yellowImg = '<img src="'+homeUrl+'/images/yellow-label.png">'; |
6722 |
04 May 22 |
nicklas |
var numWithLabel = 0; |
4089 |
08 Sep 16 |
nicklas |
for (var i=0; i < selectedLysates.length; i++) |
4089 |
08 Sep 16 |
nicklas |
148 |
{ |
4089 |
08 Sep 16 |
nicklas |
var lysate = selectedLysates[i]; |
4089 |
08 Sep 16 |
nicklas |
var well = lysate.bioWell; |
4089 |
08 Sep 16 |
nicklas |
var plate = well.bioPlate; |
4089 |
08 Sep 16 |
nicklas |
var storage = plate.storage; |
4089 |
08 Sep 16 |
nicklas |
var isYellow = lysate.specimen && lysate.specimen.YellowLabel != null; |
4089 |
08 Sep 16 |
nicklas |
var newWell = newWells[i]; |
4092 |
09 Sep 16 |
nicklas |
lysate.newWell = newWell; |
6722 |
04 May 22 |
nicklas |
if (lysate.label) numWithLabel++; |
4089 |
08 Sep 16 |
nicklas |
157 |
|
6722 |
04 May 22 |
nicklas |
var freezerLocation = []; |
6722 |
04 May 22 |
nicklas |
if (storage) |
6722 |
04 May 22 |
nicklas |
160 |
{ |
6722 |
04 May 22 |
nicklas |
if (storage.section) freezerLocation[freezerLocation.length] = 'Section '+storage.section; |
6722 |
04 May 22 |
nicklas |
if (storage.tray) freezerLocation[freezerLocation.length] = 'Tray '+storage.tray; |
6722 |
04 May 22 |
nicklas |
if (storage.position) freezerLocation[freezerLocation.length] = 'Position '+storage.position; |
6722 |
04 May 22 |
nicklas |
164 |
} |
4089 |
08 Sep 16 |
nicklas |
165 |
|
4089 |
08 Sep 16 |
nicklas |
var img = isYellow ? yellowImg : ''; |
4089 |
08 Sep 16 |
nicklas |
html += '<tr class="highlight'+(isYellow ? ' yellow-specimen' : '')+'">'; |
4089 |
08 Sep 16 |
nicklas |
html += '<td class="lysate if-yellow">'+img+Strings.encodeTags(lysate.name)+'</td>'; |
6722 |
04 May 22 |
nicklas |
html += '<td class="label">'+Strings.encodeTags(lysate.label)+'</td>'; |
6722 |
04 May 22 |
nicklas |
html += '<td class="location">'; |
6722 |
04 May 22 |
nicklas |
if (storage) |
6722 |
04 May 22 |
nicklas |
172 |
{ |
6722 |
04 May 22 |
nicklas |
html += Strings.encodeTags(storage.name)+'<br>'+Strings.encodeTags(freezerLocation.join(', ')); |
6722 |
04 May 22 |
nicklas |
174 |
} |
6722 |
04 May 22 |
nicklas |
html += '</td>'; |
4089 |
08 Sep 16 |
nicklas |
html += '<td class="box">'+Strings.encodeTags(plate.name+' '+well.location)+'</td>'; |
4089 |
08 Sep 16 |
nicklas |
html += '<td class="newbox">'+Strings.encodeTags(newWell.bioPlate.name+' '+newWell.location)+'</td>'; |
4089 |
08 Sep 16 |
nicklas |
html += '<td class="remain">'+ Numbers.formatNumber(lysate.remainingQuantity, 0, 'µl') + '</td>'; |
4089 |
08 Sep 16 |
nicklas |
html += '<td class="remarks"></td>'; |
4089 |
08 Sep 16 |
nicklas |
html += '</tr>' |
4089 |
08 Sep 16 |
nicklas |
181 |
} |
4089 |
08 Sep 16 |
nicklas |
182 |
|
4089 |
08 Sep 16 |
nicklas |
Doc.element('lysateList').innerHTML = html; |
6722 |
04 May 22 |
nicklas |
if (numWithLabel > 0) |
6722 |
04 May 22 |
nicklas |
185 |
{ |
6722 |
04 May 22 |
nicklas |
Doc.removeClass('protocol-table', 'nolabels'); |
6722 |
04 May 22 |
nicklas |
187 |
} |
4089 |
08 Sep 16 |
nicklas |
188 |
|
4089 |
08 Sep 16 |
nicklas |
Wizard.setCurrentStep(2); |
4089 |
08 Sep 16 |
nicklas |
Doc.show('goregister'); |
4089 |
08 Sep 16 |
nicklas |
Doc.show('goprint'); |
4089 |
08 Sep 16 |
nicklas |
Doc.show('gocancel'); |
4092 |
09 Sep 16 |
nicklas |
Wizard.showGoNextConfirmation(true, 'Print the lab protocol before continuing with the registration!'); |
4089 |
08 Sep 16 |
nicklas |
194 |
} |
4089 |
08 Sep 16 |
nicklas |
195 |
|
4089 |
08 Sep 16 |
nicklas |
extract.printPickList = function() |
4089 |
08 Sep 16 |
nicklas |
197 |
{ |
4089 |
08 Sep 16 |
nicklas |
Wizard.hideGoNextConfirmation(); |
4089 |
08 Sep 16 |
nicklas |
Doc.removeClass('goregister', 'disabled'); |
4089 |
08 Sep 16 |
nicklas |
var reportName = 'Pick-list protocol for lysate re-extraction'; |
4089 |
08 Sep 16 |
nicklas |
var printNote = '<b>Note!</b> For better printing set page orientation to <i>portrait</i>.'; |
4089 |
08 Sep 16 |
nicklas |
Reggie.openPrintWindow('full-protocol', reportName, 'portrait', printNote, '../', 'lysate_picklist.css'); |
4089 |
08 Sep 16 |
nicklas |
203 |
} |
4089 |
08 Sep 16 |
nicklas |
204 |
|
4092 |
09 Sep 16 |
nicklas |
extract.submit = function() |
4092 |
09 Sep 16 |
nicklas |
206 |
{ |
4092 |
09 Sep 16 |
nicklas |
var submitInfo = {}; |
4092 |
09 Sep 16 |
nicklas |
var lysates = []; |
4092 |
09 Sep 16 |
nicklas |
for (var i = 0; i < selectedLysates.length; i++) |
4092 |
09 Sep 16 |
nicklas |
210 |
{ |
4092 |
09 Sep 16 |
nicklas |
var lysate = selectedLysates[i]; |
4092 |
09 Sep 16 |
nicklas |
lysates[i] = { 'id': lysate.id, 'newWell': lysate.newWell.id }; |
4092 |
09 Sep 16 |
nicklas |
213 |
} |
4092 |
09 Sep 16 |
nicklas |
submitInfo.lysates = lysates; |
4092 |
09 Sep 16 |
nicklas |
215 |
|
4092 |
09 Sep 16 |
nicklas |
var url = '../Extraction.servlet?ID='+App.getSessionId(); |
4092 |
09 Sep 16 |
nicklas |
url += '&cmd=RegisterLysatesPickedForReextraction'; |
4092 |
09 Sep 16 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
4092 |
09 Sep 16 |
nicklas |
Wizard.asyncJsonRequest(url, extract.submissionResults, 'POST', JSON.stringify(submitInfo)); |
4092 |
09 Sep 16 |
nicklas |
220 |
} |
4092 |
09 Sep 16 |
nicklas |
221 |
|
4092 |
09 Sep 16 |
nicklas |
extract.submissionResults = function(response) |
4092 |
09 Sep 16 |
nicklas |
223 |
{ |
4092 |
09 Sep 16 |
nicklas |
Wizard.showFinalMessage(response.messages); |
4092 |
09 Sep 16 |
nicklas |
Doc.show('gorestart'); |
4092 |
09 Sep 16 |
nicklas |
226 |
} |
4092 |
09 Sep 16 |
nicklas |
227 |
|
4089 |
08 Sep 16 |
nicklas |
return extract; |
4089 |
08 Sep 16 |
nicklas |
229 |
}(); |
4089 |
08 Sep 16 |
nicklas |
230 |
|
4089 |
08 Sep 16 |
nicklas |
Doc.onLoad(LysateReExtract.initPage); |
4089 |
08 Sep 16 |
nicklas |
232 |
|