2774 |
09 Oct 14 |
nicklas |
var RnaQcAliquot = function() |
2774 |
09 Oct 14 |
nicklas |
2 |
{ |
2774 |
09 Oct 14 |
nicklas |
var rnaqc = {}; |
2774 |
09 Oct 14 |
nicklas |
4 |
|
3730 |
04 Feb 16 |
nicklas |
var HISENSE_LIMIT = 50.0; |
3545 |
16 Oct 15 |
nicklas |
var ALIQUOT_VOLUME_NORMAL = 2.0; |
3545 |
16 Oct 15 |
nicklas |
var ALIQUOT_VOLUME_HISENSE = 6.0; |
3550 |
19 Oct 15 |
nicklas |
var ALIQUOT_VOLUME_BA = 1.0; |
2774 |
09 Oct 14 |
nicklas |
9 |
|
2774 |
09 Oct 14 |
nicklas |
var selectedRna; |
2774 |
09 Oct 14 |
nicklas |
var selectedBioPlate; |
2774 |
09 Oct 14 |
nicklas |
var subtypeRna = null; |
2774 |
09 Oct 14 |
nicklas |
var bioPlateNameIsValid = false; |
3471 |
28 Aug 15 |
nicklas |
var bioPlateIsValid = false; |
2774 |
09 Oct 14 |
nicklas |
15 |
|
2774 |
09 Oct 14 |
nicklas |
var autoGoNext = 0; |
2808 |
15 Oct 14 |
nicklas |
var newRna = []; |
2774 |
09 Oct 14 |
nicklas |
18 |
|
2774 |
09 Oct 14 |
nicklas |
// Page initialization |
2774 |
09 Oct 14 |
nicklas |
rnaqc.initPage = function() |
2774 |
09 Oct 14 |
nicklas |
21 |
{ |
2774 |
09 Oct 14 |
nicklas |
// Step 1 |
2774 |
09 Oct 14 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', rnaqc.validateStep1); |
2774 |
09 Oct 14 |
nicklas |
Buttons.addClickHandler('btnSelectRna', rnaqc.selectRna); |
2774 |
09 Oct 14 |
nicklas |
Events.addEventHandler('rna', 'base-selected', rnaqc.onRnaSelected); |
2774 |
09 Oct 14 |
nicklas |
26 |
|
2774 |
09 Oct 14 |
nicklas |
// Step 2 |
2774 |
09 Oct 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', rnaqc.initializeStep2); |
2774 |
09 Oct 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-validate', rnaqc.validateStep2); |
2774 |
09 Oct 14 |
nicklas |
Events.addEventHandler('bioPlates', 'change', rnaqc.bioPlateOnChange); |
2774 |
09 Oct 14 |
nicklas |
Events.addEventHandler('CALIPER_RNAQC', 'click', rnaqc.bioPlateTypeOnChange); |
2774 |
09 Oct 14 |
nicklas |
Events.addEventHandler('BA_RNAQC', 'click', rnaqc.bioPlateTypeOnChange); |
2774 |
09 Oct 14 |
nicklas |
Events.addEventHandler('bioPlateName', 'change', rnaqc.bioPlateNameOnChange); |
2774 |
09 Oct 14 |
nicklas |
34 |
|
2774 |
09 Oct 14 |
nicklas |
// Step 3 |
2774 |
09 Oct 14 |
nicklas |
Events.addEventHandler('step-3', 'wizard-initialize', rnaqc.initializeStep3); |
2774 |
09 Oct 14 |
nicklas |
Events.addEventHandler('step-3', 'wizard-validate', rnaqc.validateStep3); |
2774 |
09 Oct 14 |
nicklas |
38 |
|
2774 |
09 Oct 14 |
nicklas |
// Navigation |
2774 |
09 Oct 14 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
2774 |
09 Oct 14 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
2774 |
09 Oct 14 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
2774 |
09 Oct 14 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
3544 |
15 Oct 15 |
nicklas |
Buttons.addClickHandler('goprint', rnaqc.printVersion); |
2774 |
09 Oct 14 |
nicklas |
45 |
|
2774 |
09 Oct 14 |
nicklas |
// Final registration |
2774 |
09 Oct 14 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', rnaqc.submit); |
2774 |
09 Oct 14 |
nicklas |
48 |
|
2774 |
09 Oct 14 |
nicklas |
var rna = Data.json('page-data', 'rna-id'); |
2774 |
09 Oct 14 |
nicklas |
if (rna.length > 0) |
2774 |
09 Oct 14 |
nicklas |
51 |
{ |
2774 |
09 Oct 14 |
nicklas |
Doc.show('step-1'); |
2774 |
09 Oct 14 |
nicklas |
autoGoNext = rna.length; |
2808 |
15 Oct 14 |
nicklas |
// Get more information about the selected rna |
2808 |
15 Oct 14 |
nicklas |
var url = '../RnaQc.servlet?ID='+App.getSessionId(); |
2808 |
15 Oct 14 |
nicklas |
url += '&cmd=GetRnaInfo&rnaIds=' + rna.join(','); |
2808 |
15 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, rnaqc.onRnaInfoLoaded); |
2774 |
09 Oct 14 |
nicklas |
58 |
} |
2774 |
09 Oct 14 |
nicklas |
else |
2774 |
09 Oct 14 |
nicklas |
60 |
{ |
2774 |
09 Oct 14 |
nicklas |
var url = '../RnaQc.servlet?ID='+App.getSessionId(); |
2774 |
09 Oct 14 |
nicklas |
url += '&cmd=GetRnaExtractsWithoutQc'; |
2774 |
09 Oct 14 |
nicklas |
Wizard.showLoadingAnimation('Loading RNA extracts...'); |
2774 |
09 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, rnaqc.onRnaLoaded); |
2774 |
09 Oct 14 |
nicklas |
65 |
} |
2774 |
09 Oct 14 |
nicklas |
66 |
} |
2774 |
09 Oct 14 |
nicklas |
67 |
|
2774 |
09 Oct 14 |
nicklas |
rnaqc.onRnaLoaded = function(response) |
2774 |
09 Oct 14 |
nicklas |
69 |
{ |
2774 |
09 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2774 |
09 Oct 14 |
nicklas |
var rnaExtracts = response.rnaExtracts; |
2774 |
09 Oct 14 |
nicklas |
72 |
|
2774 |
09 Oct 14 |
nicklas |
if (rnaExtracts.length > 0) |
2774 |
09 Oct 14 |
nicklas |
74 |
{ |
2774 |
09 Oct 14 |
nicklas |
for (var i=0; i < rnaExtracts.length; i++) |
2774 |
09 Oct 14 |
nicklas |
76 |
{ |
2774 |
09 Oct 14 |
nicklas |
var selected = i < 12; |
2774 |
09 Oct 14 |
nicklas |
var rna = rnaExtracts[i]; |
2774 |
09 Oct 14 |
nicklas |
rnaqc.addRnaOption(frm.rna, rna, selected); |
2774 |
09 Oct 14 |
nicklas |
80 |
} |
2774 |
09 Oct 14 |
nicklas |
81 |
} |
2774 |
09 Oct 14 |
nicklas |
else |
2774 |
09 Oct 14 |
nicklas |
83 |
{ |
2774 |
09 Oct 14 |
nicklas |
Wizard.setInputStatus('rna', 'invalid', 'No RNA available for quality control.'); |
2774 |
09 Oct 14 |
nicklas |
85 |
} |
2774 |
09 Oct 14 |
nicklas |
86 |
|
2774 |
09 Oct 14 |
nicklas |
Doc.show('step-1'); |
2774 |
09 Oct 14 |
nicklas |
Doc.show('gonext'); |
2774 |
09 Oct 14 |
nicklas |
89 |
} |
2774 |
09 Oct 14 |
nicklas |
90 |
|
2774 |
09 Oct 14 |
nicklas |
rnaqc.selectRna = function() |
2774 |
09 Oct 14 |
nicklas |
92 |
{ |
2774 |
09 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2774 |
09 Oct 14 |
nicklas |
if (frm.rna.disabled) return; |
2774 |
09 Oct 14 |
nicklas |
95 |
|
2774 |
09 Oct 14 |
nicklas |
if (subtypeRna == null) |
2774 |
09 Oct 14 |
nicklas |
97 |
{ |
2774 |
09 Oct 14 |
nicklas |
subtypeRna = Reggie.getSubtypeInfo('RNA'); |
2774 |
09 Oct 14 |
nicklas |
99 |
} |
2774 |
09 Oct 14 |
nicklas |
100 |
|
2808 |
15 Oct 14 |
nicklas |
newRna = []; |
2774 |
09 Oct 14 |
nicklas |
var url = '&resetTemporary=1'; |
2774 |
09 Oct 14 |
nicklas |
url += '&tmpfilter:INT:itemSubtype='+subtypeRna.id; |
2774 |
09 Oct 14 |
nicklas |
Dialogs.selectItem('EXTRACT', 'rna', 1, url); |
2774 |
09 Oct 14 |
nicklas |
105 |
} |
2774 |
09 Oct 14 |
nicklas |
106 |
|
2774 |
09 Oct 14 |
nicklas |
rnaqc.onRnaSelected = function(event) |
2774 |
09 Oct 14 |
nicklas |
108 |
{ |
2774 |
09 Oct 14 |
nicklas |
var rna = event.detail; |
2774 |
09 Oct 14 |
nicklas |
110 |
|
2774 |
09 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2774 |
09 Oct 14 |
nicklas |
var rnaList = frm.rna; |
2808 |
15 Oct 14 |
nicklas |
var isNew = true; |
2774 |
09 Oct 14 |
nicklas |
for (var i = 0; i < rnaList.length; i++) |
2774 |
09 Oct 14 |
nicklas |
115 |
{ |
2774 |
09 Oct 14 |
nicklas |
if (rnaList[i].value == rna.id) |
2774 |
09 Oct 14 |
nicklas |
117 |
{ |
2774 |
09 Oct 14 |
nicklas |
rnaList[i].selected = true; |
2808 |
15 Oct 14 |
nicklas |
isNew = false; |
2774 |
09 Oct 14 |
nicklas |
120 |
} |
2774 |
09 Oct 14 |
nicklas |
121 |
} |
2774 |
09 Oct 14 |
nicklas |
122 |
|
2808 |
15 Oct 14 |
nicklas |
if (isNew) newRna[newRna.length] = rna.id; |
2808 |
15 Oct 14 |
nicklas |
124 |
|
2808 |
15 Oct 14 |
nicklas |
if (event.detail.remaining == 0 && newRna.length > 0) |
2808 |
15 Oct 14 |
nicklas |
126 |
{ |
2808 |
15 Oct 14 |
nicklas |
// Get more information about the selected rna |
2808 |
15 Oct 14 |
nicklas |
var url = '../RnaQc.servlet?ID='+App.getSessionId(); |
2808 |
15 Oct 14 |
nicklas |
url += '&cmd=GetRnaInfo&rnaIds=' + newRna.join(','); |
2808 |
15 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, rnaqc.onRnaInfoLoaded); |
2808 |
15 Oct 14 |
nicklas |
131 |
} |
2774 |
09 Oct 14 |
nicklas |
132 |
} |
2774 |
09 Oct 14 |
nicklas |
133 |
|
2774 |
09 Oct 14 |
nicklas |
rnaqc.onRnaInfoLoaded = function(response) |
2774 |
09 Oct 14 |
nicklas |
135 |
{ |
2774 |
09 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2808 |
15 Oct 14 |
nicklas |
var rnaList = response.rna; |
2774 |
09 Oct 14 |
nicklas |
138 |
|
2808 |
15 Oct 14 |
nicklas |
for (var rnaNo = 0; rnaNo < rnaList.length; rnaNo++) |
2808 |
15 Oct 14 |
nicklas |
140 |
{ |
2808 |
15 Oct 14 |
nicklas |
var rna = rnaList[rnaNo]; |
2808 |
15 Oct 14 |
nicklas |
rnaqc.addRnaOption(frm.rna, rna, true); |
2808 |
15 Oct 14 |
nicklas |
143 |
} |
2774 |
09 Oct 14 |
nicklas |
144 |
|
2774 |
09 Oct 14 |
nicklas |
if (frm.rna.length == autoGoNext) |
2774 |
09 Oct 14 |
nicklas |
146 |
{ |
2774 |
09 Oct 14 |
nicklas |
Wizard.goNext(true); |
2774 |
09 Oct 14 |
nicklas |
148 |
} |
2774 |
09 Oct 14 |
nicklas |
149 |
} |
2774 |
09 Oct 14 |
nicklas |
150 |
|
2774 |
09 Oct 14 |
nicklas |
rnaqc.addRnaOption = function(list, rna, selected) |
2774 |
09 Oct 14 |
nicklas |
152 |
{ |
2774 |
09 Oct 14 |
nicklas |
var name = rna.name; |
2774 |
09 Oct 14 |
nicklas |
if (rna.bioWell) |
2774 |
09 Oct 14 |
nicklas |
155 |
{ |
2774 |
09 Oct 14 |
nicklas |
name += ' -- ' + rna.bioWell.bioPlate.name + ' (' + Reggie.wellToAlpha(rna.bioWell.row)+(rna.bioWell.column+1)+')'; |
2774 |
09 Oct 14 |
nicklas |
157 |
} |
2774 |
09 Oct 14 |
nicklas |
158 |
|
2774 |
09 Oct 14 |
nicklas |
var option = new Option(name, rna.id, selected, selected); |
3742 |
12 Feb 16 |
nicklas |
if (rna.specimen && rna.specimen.YellowLabel != null) option.className = 'yellow'; |
2774 |
09 Oct 14 |
nicklas |
option.rna = rna; |
2774 |
09 Oct 14 |
nicklas |
list[list.length] = option; |
2774 |
09 Oct 14 |
nicklas |
163 |
} |
2774 |
09 Oct 14 |
nicklas |
164 |
|
2774 |
09 Oct 14 |
nicklas |
rnaqc.validateStep1 = function(event) |
2774 |
09 Oct 14 |
nicklas |
166 |
{ |
2774 |
09 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2774 |
09 Oct 14 |
nicklas |
var rnaList = frm.rna; |
2774 |
09 Oct 14 |
nicklas |
169 |
|
2774 |
09 Oct 14 |
nicklas |
selectedRna = []; |
2774 |
09 Oct 14 |
nicklas |
for (var i=0; i < rnaList.length; i++) |
2774 |
09 Oct 14 |
nicklas |
172 |
{ |
2774 |
09 Oct 14 |
nicklas |
if (rnaList[i].selected) |
2774 |
09 Oct 14 |
nicklas |
174 |
{ |
2774 |
09 Oct 14 |
nicklas |
selectedRna[selectedRna.length] = rnaList[i].rna; |
2774 |
09 Oct 14 |
nicklas |
176 |
} |
2774 |
09 Oct 14 |
nicklas |
177 |
} |
2774 |
09 Oct 14 |
nicklas |
178 |
|
2774 |
09 Oct 14 |
nicklas |
if (selectedRna.length == 0) |
2774 |
09 Oct 14 |
nicklas |
180 |
{ |
2774 |
09 Oct 14 |
nicklas |
Wizard.setInputStatus('rna', 'invalid', 'Not selected', 'invalid'); |
2774 |
09 Oct 14 |
nicklas |
event.preventDefault(); |
2774 |
09 Oct 14 |
nicklas |
183 |
} |
2774 |
09 Oct 14 |
nicklas |
else |
2774 |
09 Oct 14 |
nicklas |
185 |
{ |
2774 |
09 Oct 14 |
nicklas |
Wizard.setInputStatus('rna', 'valid'); |
2774 |
09 Oct 14 |
nicklas |
187 |
} |
2774 |
09 Oct 14 |
nicklas |
188 |
} |
2774 |
09 Oct 14 |
nicklas |
189 |
|
2774 |
09 Oct 14 |
nicklas |
rnaqc.initializeStep2 = function() |
2774 |
09 Oct 14 |
nicklas |
191 |
{ |
2774 |
09 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2774 |
09 Oct 14 |
nicklas |
Wizard.setCurrentStep(2); |
2774 |
09 Oct 14 |
nicklas |
Doc.show('gonext'); |
3471 |
28 Aug 15 |
nicklas |
Doc.show('gocancel'); |
2774 |
09 Oct 14 |
nicklas |
196 |
|
2774 |
09 Oct 14 |
nicklas |
Reggie.loadProtocols('QUALITY_CONTROL', 'protocols'); |
2774 |
09 Oct 14 |
nicklas |
198 |
|
2774 |
09 Oct 14 |
nicklas |
var url = '../RnaQc.servlet?ID='+App.getSessionId(); |
2774 |
09 Oct 14 |
nicklas |
url += '&cmd=GetActiveRnaQcBioPlates&numFreeWells=' + selectedRna.length; |
2774 |
09 Oct 14 |
nicklas |
Doc.addClass('bioPlates', 'list-loading'); |
2774 |
09 Oct 14 |
nicklas |
frm.bioPlates[0] = new Option('loading...'); |
2774 |
09 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, rnaqc.bioPlatesLoaded); |
2774 |
09 Oct 14 |
nicklas |
204 |
} |
2774 |
09 Oct 14 |
nicklas |
205 |
|
2774 |
09 Oct 14 |
nicklas |
rnaqc.bioPlatesLoaded = function(response) |
2774 |
09 Oct 14 |
nicklas |
207 |
{ |
2774 |
09 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2774 |
09 Oct 14 |
nicklas |
frm.bioPlates.length = 0; |
2774 |
09 Oct 14 |
nicklas |
Doc.removeClass('bioPlates', 'list-loading'); |
2774 |
09 Oct 14 |
nicklas |
211 |
|
2774 |
09 Oct 14 |
nicklas |
var plates = response.plates; |
3471 |
28 Aug 15 |
nicklas |
var hasSelected = false; |
2774 |
09 Oct 14 |
nicklas |
for (var i = 0; i < plates.length; i++) |
2774 |
09 Oct 14 |
nicklas |
215 |
{ |
3471 |
28 Aug 15 |
nicklas |
var plate = plates[i]; |
3471 |
28 Aug 15 |
nicklas |
var selected = !hasSelected && plate.freeWells >= selectedRna.length; |
3471 |
28 Aug 15 |
nicklas |
hasSelected |= selected; |
4583 |
21 Sep 17 |
nicklas |
var option = new Option(plate.name + ' -- ' + plate.freeWells + ' free wells', plate.id, selected, selected); |
3471 |
28 Aug 15 |
nicklas |
option.plate = plate; |
3471 |
28 Aug 15 |
nicklas |
frm.bioPlates[frm.bioPlates.length] = option; |
2774 |
09 Oct 14 |
nicklas |
222 |
} |
4583 |
21 Sep 17 |
nicklas |
frm.bioPlates[frm.bioPlates.length] = new Option('- create new -', 0, false, !hasSelected); |
2774 |
09 Oct 14 |
nicklas |
224 |
|
2774 |
09 Oct 14 |
nicklas |
rnaqc.bioPlateOnChange(); |
2774 |
09 Oct 14 |
nicklas |
frm.bioPlates.focus(); |
2774 |
09 Oct 14 |
nicklas |
227 |
} |
2774 |
09 Oct 14 |
nicklas |
228 |
|
2774 |
09 Oct 14 |
nicklas |
// If the 'create new' option is selected we need to display that section |
2774 |
09 Oct 14 |
nicklas |
rnaqc.bioPlateOnChange = function() |
2774 |
09 Oct 14 |
nicklas |
231 |
{ |
2774 |
09 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2774 |
09 Oct 14 |
nicklas |
233 |
|
2774 |
09 Oct 14 |
nicklas |
var createNewSelected = parseInt(frm.bioPlates.value) == 0; |
2774 |
09 Oct 14 |
nicklas |
Doc.showHide('createNewBioPlateSection', createNewSelected); |
2774 |
09 Oct 14 |
nicklas |
236 |
|
3471 |
28 Aug 15 |
nicklas |
Wizard.setInputStatus('bioPlates'); |
3471 |
28 Aug 15 |
nicklas |
bioPlateIsValid = true; |
3471 |
28 Aug 15 |
nicklas |
239 |
|
2774 |
09 Oct 14 |
nicklas |
if (createNewSelected) |
2774 |
09 Oct 14 |
nicklas |
241 |
{ |
2774 |
09 Oct 14 |
nicklas |
if (frm.bioPlateName.value == '') |
2774 |
09 Oct 14 |
nicklas |
243 |
{ |
2774 |
09 Oct 14 |
nicklas |
rnaqc.bioPlateTypeOnChange(); |
2774 |
09 Oct 14 |
nicklas |
245 |
} |
2774 |
09 Oct 14 |
nicklas |
frm.bioPlateBarcode.focus(); |
2774 |
09 Oct 14 |
nicklas |
247 |
} |
3471 |
28 Aug 15 |
nicklas |
else |
3471 |
28 Aug 15 |
nicklas |
249 |
{ |
3471 |
28 Aug 15 |
nicklas |
var selected = frm.bioPlates[frm.bioPlates.selectedIndex].plate; |
3471 |
28 Aug 15 |
nicklas |
if (selected.freeWells < selectedRna.length) |
3471 |
28 Aug 15 |
nicklas |
252 |
{ |
3471 |
28 Aug 15 |
nicklas |
Wizard.setInputStatus('bioPlates', 'invalid', 'Not enough free wells'); |
3471 |
28 Aug 15 |
nicklas |
bioPlateIsValid = false; |
3471 |
28 Aug 15 |
nicklas |
255 |
} |
3471 |
28 Aug 15 |
nicklas |
256 |
} |
2774 |
09 Oct 14 |
nicklas |
257 |
} |
2774 |
09 Oct 14 |
nicklas |
258 |
|
2774 |
09 Oct 14 |
nicklas |
// We need to get the next auto-generated name for a new CaliperPlate or BAPlate |
2774 |
09 Oct 14 |
nicklas |
rnaqc.bioPlateTypeOnChange = function() |
2774 |
09 Oct 14 |
nicklas |
261 |
{ |
2774 |
09 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2774 |
09 Oct 14 |
nicklas |
var selectedType = Forms.getCheckedRadio(frm.bioPlateType); |
2774 |
09 Oct 14 |
nicklas |
if (selectedType.nextPlateName) |
2774 |
09 Oct 14 |
nicklas |
265 |
{ |
2774 |
09 Oct 14 |
nicklas |
rnaqc.onNextPlateNameGenerated(); |
2774 |
09 Oct 14 |
nicklas |
267 |
} |
2774 |
09 Oct 14 |
nicklas |
else |
2774 |
09 Oct 14 |
nicklas |
269 |
{ |
2774 |
09 Oct 14 |
nicklas |
var url = '../RnaQc.servlet?ID='+App.getSessionId(); |
2774 |
09 Oct 14 |
nicklas |
url += '&cmd=GetNextAutoGeneratedPlateName&bioPlateType=' + selectedType.value; |
2774 |
09 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, rnaqc.onNextPlateNameGenerated); |
2774 |
09 Oct 14 |
nicklas |
273 |
} |
2774 |
09 Oct 14 |
nicklas |
274 |
} |
2774 |
09 Oct 14 |
nicklas |
275 |
|
2774 |
09 Oct 14 |
nicklas |
rnaqc.onNextPlateNameGenerated = function(response) |
2774 |
09 Oct 14 |
nicklas |
277 |
{ |
2774 |
09 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2774 |
09 Oct 14 |
nicklas |
var selectedType = Forms.getCheckedRadio(frm.bioPlateType); |
2774 |
09 Oct 14 |
nicklas |
if (response) |
2774 |
09 Oct 14 |
nicklas |
281 |
{ |
2774 |
09 Oct 14 |
nicklas |
selectedType.nextPlateName = response.nextPlateName; |
2774 |
09 Oct 14 |
nicklas |
283 |
} |
2774 |
09 Oct 14 |
nicklas |
284 |
|
2774 |
09 Oct 14 |
nicklas |
frm.bioPlateName.value = selectedType.nextPlateName; |
2774 |
09 Oct 14 |
nicklas |
rnaqc.bioPlateNameOnChange(); |
2774 |
09 Oct 14 |
nicklas |
287 |
} |
2774 |
09 Oct 14 |
nicklas |
288 |
|
2774 |
09 Oct 14 |
nicklas |
rnaqc.bioPlateNameOnChange = function() |
2774 |
09 Oct 14 |
nicklas |
290 |
{ |
2774 |
09 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2774 |
09 Oct 14 |
nicklas |
292 |
|
2774 |
09 Oct 14 |
nicklas |
var bioPlateName = frm.bioPlateName.value; |
2774 |
09 Oct 14 |
nicklas |
bioPlateNameIsValid = false; |
2774 |
09 Oct 14 |
nicklas |
if (bioPlateName == '') |
2774 |
09 Oct 14 |
nicklas |
296 |
{ |
2774 |
09 Oct 14 |
nicklas |
Wizard.setInputStatus('bioPlateName', 'invalid', 'Missing'); |
2774 |
09 Oct 14 |
nicklas |
return; |
2774 |
09 Oct 14 |
nicklas |
299 |
} |
2774 |
09 Oct 14 |
nicklas |
300 |
|
2774 |
09 Oct 14 |
nicklas |
bioPlateNameIsValid = true; |
2774 |
09 Oct 14 |
nicklas |
if (bioPlateName.indexOf('CaliperPlate') != 0 && bioPlateName.indexOf('BAPlate') != 0) |
2774 |
09 Oct 14 |
nicklas |
303 |
{ |
2774 |
09 Oct 14 |
nicklas |
Wizard.setInputStatus('bioPlateName', 'warning', 'Should start with <i>CaliperPlate</code> or <i>BAPlate</i>.'); |
2774 |
09 Oct 14 |
nicklas |
return; |
2774 |
09 Oct 14 |
nicklas |
306 |
} |
2774 |
09 Oct 14 |
nicklas |
307 |
|
2774 |
09 Oct 14 |
nicklas |
Wizard.setInputStatus('bioPlateName', 'valid'); |
2774 |
09 Oct 14 |
nicklas |
309 |
} |
2774 |
09 Oct 14 |
nicklas |
310 |
|
2774 |
09 Oct 14 |
nicklas |
rnaqc.validateStep2 = function(event) |
2774 |
09 Oct 14 |
nicklas |
312 |
{ |
2774 |
09 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2774 |
09 Oct 14 |
nicklas |
var bioPlateId = parseInt(frm.bioPlates.value); |
3471 |
28 Aug 15 |
nicklas |
if (!bioPlateIsValid || (bioPlateId == 0 && !bioPlateNameIsValid)) |
2774 |
09 Oct 14 |
nicklas |
316 |
{ |
2774 |
09 Oct 14 |
nicklas |
event.preventDefault(); |
2774 |
09 Oct 14 |
nicklas |
318 |
} |
2774 |
09 Oct 14 |
nicklas |
319 |
} |
2774 |
09 Oct 14 |
nicklas |
320 |
|
2774 |
09 Oct 14 |
nicklas |
rnaqc.initializeStep3 = function() |
2774 |
09 Oct 14 |
nicklas |
322 |
{ |
2774 |
09 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2774 |
09 Oct 14 |
nicklas |
var bioPlateId = parseInt(frm.bioPlates.value); |
2774 |
09 Oct 14 |
nicklas |
325 |
|
2774 |
09 Oct 14 |
nicklas |
var url = '../RnaQc.servlet?ID='+App.getSessionId(); |
2774 |
09 Oct 14 |
nicklas |
url += '&cmd=GetFreeWellsInfo&bioPlateId='+bioPlateId; |
2774 |
09 Oct 14 |
nicklas |
if (bioPlateId == 0) |
2774 |
09 Oct 14 |
nicklas |
329 |
{ |
2774 |
09 Oct 14 |
nicklas |
url += '&bioPlateType=' + Forms.getCheckedRadio(frm.bioPlateType).value; |
2774 |
09 Oct 14 |
nicklas |
331 |
} |
3471 |
28 Aug 15 |
nicklas |
url += '&numAliquots='+selectedRna.length; |
2774 |
09 Oct 14 |
nicklas |
Wizard.showLoadingAnimation('Loading information about free wells...'); |
2774 |
09 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, rnaqc.freeWellsLoaded); |
2774 |
09 Oct 14 |
nicklas |
335 |
} |
2774 |
09 Oct 14 |
nicklas |
336 |
|
2774 |
09 Oct 14 |
nicklas |
rnaqc.freeWellsLoaded = function(response) |
2774 |
09 Oct 14 |
nicklas |
338 |
{ |
2774 |
09 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2774 |
09 Oct 14 |
nicklas |
340 |
|
2774 |
09 Oct 14 |
nicklas |
selectedBioPlate = response.bioPlate; |
2774 |
09 Oct 14 |
nicklas |
if (selectedBioPlate.id == 0) |
2774 |
09 Oct 14 |
nicklas |
343 |
{ |
2774 |
09 Oct 14 |
nicklas |
selectedBioPlate.name = frm.bioPlateName.value; |
2774 |
09 Oct 14 |
nicklas |
selectedBioPlate.barcode = frm.bioPlateBarcode.value; |
2774 |
09 Oct 14 |
nicklas |
346 |
} |
3550 |
19 Oct 15 |
nicklas |
var isCaliper = Doc.element('CALIPER_RNAQC').checked; |
2774 |
09 Oct 14 |
nicklas |
348 |
|
2774 |
09 Oct 14 |
nicklas |
var html = '<table id="rnaQcTable" class="step-form">'; |
3544 |
15 Oct 15 |
nicklas |
html += '<thead class="bg-filled-100">'; |
2774 |
09 Oct 14 |
nicklas |
// First header row |
2774 |
09 Oct 14 |
nicklas |
html += '<tr>'; |
2774 |
09 Oct 14 |
nicklas |
html += '<th>RNA QC</th>'; |
3612 |
20 Nov 15 |
nicklas |
html += '<th class="dottedleft">Storage</th>'; |
2774 |
09 Oct 14 |
nicklas |
html += '<th colspan="2" class="dottedleft">' + Strings.encodeTags(selectedBioPlate.name) + '</th>'; |
2774 |
09 Oct 14 |
nicklas |
html += '<th class="dottedleft">HiSense</th>'; |
3545 |
16 Oct 15 |
nicklas |
html += '<th>Volume</th>'; |
6219 |
20 Apr 21 |
nicklas |
html += '<th>Conc.</th>'; |
2774 |
09 Oct 14 |
nicklas |
html += '<th></th>'; |
3544 |
15 Oct 15 |
nicklas |
html += '<th class="dottedleft"></th>'; |
2774 |
09 Oct 14 |
nicklas |
html += '</tr>'; |
2774 |
09 Oct 14 |
nicklas |
// Second header row |
2774 |
09 Oct 14 |
nicklas |
html += '<tr>'; |
2774 |
09 Oct 14 |
nicklas |
html += '<th></th>'; |
3612 |
20 Nov 15 |
nicklas |
html += '<th class="dottedleft">box</th>'; |
3544 |
15 Oct 15 |
nicklas |
html += '<th class="dottedleft">Row</th>'; |
3544 |
15 Oct 15 |
nicklas |
html += '<th>Column</th>'; |
6219 |
20 Apr 21 |
nicklas |
html += '<th class="dottedleft">Conc. ‹ ' + HISENSE_LIMIT + '</th>'; |
3545 |
16 Oct 15 |
nicklas |
html += '<th>(µl)</th>'; |
3544 |
15 Oct 15 |
nicklas |
html += '<th>(ng/µl)</th>'; |
2774 |
09 Oct 14 |
nicklas |
html += '<th></th>'; |
3544 |
15 Oct 15 |
nicklas |
html += '<th class="dottedleft">Comments</th>'; |
2774 |
09 Oct 14 |
nicklas |
html += '</tr>'; |
3544 |
15 Oct 15 |
nicklas |
html += '</thead>'; |
3544 |
15 Oct 15 |
nicklas |
html += '<tbody>'; |
2774 |
09 Oct 14 |
nicklas |
376 |
|
3742 |
12 Feb 16 |
nicklas |
var homeUrl = Data.get('page-data', 'home-url'); |
3742 |
12 Feb 16 |
nicklas |
var yellowImg = '<img src="'+homeUrl+'/images/yellow-label.png">'; |
2774 |
09 Oct 14 |
nicklas |
for (var i=0; i < selectedRna.length; i++) |
2774 |
09 Oct 14 |
nicklas |
380 |
{ |
2774 |
09 Oct 14 |
nicklas |
var rna = selectedRna[i]; |
3742 |
12 Feb 16 |
nicklas |
var isYellow = rna.specimen && rna.specimen.YellowLabel != null; |
2774 |
09 Oct 14 |
nicklas |
rna.isValid = false; |
3545 |
16 Oct 15 |
nicklas |
rna.isValidVolume = true; |
2774 |
09 Oct 14 |
nicklas |
385 |
|
2774 |
09 Oct 14 |
nicklas |
var hiSenseChecked = ''; |
3550 |
19 Oct 15 |
nicklas |
var hiSenseDisabled = isCaliper ? '' : ' disabled'; |
6219 |
20 Apr 21 |
nicklas |
var conc = null; |
3550 |
19 Oct 15 |
nicklas |
var volume = isCaliper ? ALIQUOT_VOLUME_NORMAL : ALIQUOT_VOLUME_BA; |
6219 |
20 Apr 21 |
nicklas |
if (rna.conc) |
2774 |
09 Oct 14 |
nicklas |
391 |
{ |
6219 |
20 Apr 21 |
nicklas |
conc = rna.conc; |
6219 |
20 Apr 21 |
nicklas |
if (isCaliper && conc < HISENSE_LIMIT) |
2774 |
09 Oct 14 |
nicklas |
394 |
{ |
3550 |
19 Oct 15 |
nicklas |
hiSenseChecked = ' checked'; |
3545 |
16 Oct 15 |
nicklas |
volume = ALIQUOT_VOLUME_HISENSE; |
2774 |
09 Oct 14 |
nicklas |
397 |
} |
2774 |
09 Oct 14 |
nicklas |
398 |
} |
2774 |
09 Oct 14 |
nicklas |
399 |
|
3742 |
12 Feb 16 |
nicklas |
var img = isYellow ? yellowImg : ''; |
3742 |
12 Feb 16 |
nicklas |
html += '<tr class="highlight'+(isYellow ? ' yellow-specimen' : '')+'">'; |
3742 |
12 Feb 16 |
nicklas |
html += '<td class="rna if-yellow">'+img+Strings.encodeTags(rna.nextRnaQcName)+'</td>'; |
6219 |
20 Apr 21 |
nicklas |
html += '<td class="location dottedleft">'+(rna.bioWell?Strings.encodeTags(rna.bioWell.bioPlate.name + ' ' + rna.bioWell.location):'unknown')+'</td>'; |
2774 |
09 Oct 14 |
nicklas |
html += '<td class="dottedleft">'; |
3544 |
15 Oct 15 |
nicklas |
html += '<input name="row.'+i+'" id="row.'+i+'" type="text" class="required" style="width: 3em; text-transform:uppercase;" maxlength="2"></td>'; |
3544 |
15 Oct 15 |
nicklas |
html += '<td><input name="column.'+i+'" id="column.'+i+'" type="text" class="required" style="width: 3em;" maxlength="3"></td>'; |
3550 |
19 Oct 15 |
nicklas |
html += '<td class="dottedleft"><input name="hiSense.'+i+'" id="hiSense.'+i+'" type="checkbox" value="1" ' + hiSenseChecked + hiSenseDisabled +'></td>'; |
3545 |
16 Oct 15 |
nicklas |
html += '<td>'; |
3545 |
16 Oct 15 |
nicklas |
html += '<input name="volume.'+i+'" id="volume.'+i+'" type="text" class="required" style="width: 3em;" maxlength="3" value="'+volume+'">'; |
3545 |
16 Oct 15 |
nicklas |
html += '</td>'; |
6219 |
20 Apr 21 |
nicklas |
html += '<td class="conc">'; |
6219 |
20 Apr 21 |
nicklas |
if (conc) html += Reggie.formatNumber(conc); |
2774 |
09 Oct 14 |
nicklas |
html += '</td>'; |
2774 |
09 Oct 14 |
nicklas |
html += '<td class="status" id="well.'+i+'.status"></td>'; |
3544 |
15 Oct 15 |
nicklas |
html += '<td class="remarks help dottedleft"><span id="well.'+i+'.message" class="message"></span></td>'; |
3544 |
15 Oct 15 |
nicklas |
html += '</tr>'; |
2774 |
09 Oct 14 |
nicklas |
417 |
} |
3544 |
15 Oct 15 |
nicklas |
html += '</tbody>'; |
3544 |
15 Oct 15 |
nicklas |
html += '</table>'; |
2774 |
09 Oct 14 |
nicklas |
420 |
|
2774 |
09 Oct 14 |
nicklas |
Doc.element('rnaQc').innerHTML = html; |
2774 |
09 Oct 14 |
nicklas |
Wizard.setCurrentStep(3); |
2774 |
09 Oct 14 |
nicklas |
Doc.show('goregister'); |
3544 |
15 Oct 15 |
nicklas |
Doc.show('goprint'); |
3471 |
28 Aug 15 |
nicklas |
Doc.show('gocancel'); |
3544 |
15 Oct 15 |
nicklas |
Wizard.showGoNextConfirmation(true, 'Print the lab protocol before continuing with the registration!'); |
3471 |
28 Aug 15 |
nicklas |
427 |
|
2774 |
09 Oct 14 |
nicklas |
if (selectedRna.length > 12) Doc.addClass('step-3', 'auto-hide'); |
2774 |
09 Oct 14 |
nicklas |
Wizard.keepSessionAlive(); |
2774 |
09 Oct 14 |
nicklas |
430 |
|
2774 |
09 Oct 14 |
nicklas |
for (var i=0; i < selectedRna.length; i++) |
2774 |
09 Oct 14 |
nicklas |
432 |
{ |
2774 |
09 Oct 14 |
nicklas |
Events.addEventHandler('row.'+i, 'keypress', Wizard.focusOnEnter, { 'next-focus': 'column.'+i }); |
3545 |
16 Oct 15 |
nicklas |
Events.addEventHandler('column.'+i, 'keypress', Wizard.focusOnEnter, { 'next-focus': 'volume.'+i }); |
3545 |
16 Oct 15 |
nicklas |
Events.addEventHandler('volume.'+i, 'keypress', Wizard.focusOnEnter, { 'next-focus': 'row.'+(i+1) }); |
3545 |
16 Oct 15 |
nicklas |
Events.addEventHandler('volume.'+i, 'keypress', Numbers.numberOnly); |
2774 |
09 Oct 14 |
nicklas |
437 |
|
2774 |
09 Oct 14 |
nicklas |
Events.addEventHandler('row.'+i, 'focus', rnaqc.wellOnFocus); |
2774 |
09 Oct 14 |
nicklas |
Events.addEventHandler('row.'+i, 'change', rnaqc.wellOnChange, { 'index': i }); |
2774 |
09 Oct 14 |
nicklas |
Events.addEventHandler('column.'+i, 'change', rnaqc.wellOnChange, { 'index': i }); |
3545 |
16 Oct 15 |
nicklas |
Events.addEventHandler('volume.'+i, 'change', rnaqc.wellOnChange, { 'index': i }); |
3545 |
16 Oct 15 |
nicklas |
Events.addEventHandler('hiSense.'+i, 'click', rnaqc.hiSenseOnClick, { 'index': i }); |
2774 |
09 Oct 14 |
nicklas |
443 |
|
2774 |
09 Oct 14 |
nicklas |
rnaqc.suggestWell(i); |
2774 |
09 Oct 14 |
nicklas |
445 |
} |
2774 |
09 Oct 14 |
nicklas |
446 |
|
2774 |
09 Oct 14 |
nicklas |
frm['row.'+0].focus(); |
2774 |
09 Oct 14 |
nicklas |
448 |
} |
2774 |
09 Oct 14 |
nicklas |
449 |
|
2774 |
09 Oct 14 |
nicklas |
rnaqc.wellOnFocus = function(event) |
2774 |
09 Oct 14 |
nicklas |
451 |
{ |
2774 |
09 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2774 |
09 Oct 14 |
nicklas |
453 |
|
2774 |
09 Oct 14 |
nicklas |
var index = Data.int(event.currentTarget, 'index'); |
2774 |
09 Oct 14 |
nicklas |
var row = frm['row.'+index].value; |
2774 |
09 Oct 14 |
nicklas |
var column = frm['column.'+index].value; |
2774 |
09 Oct 14 |
nicklas |
457 |
|
2774 |
09 Oct 14 |
nicklas |
if (row == '' && column == '') |
2774 |
09 Oct 14 |
nicklas |
459 |
{ |
2774 |
09 Oct 14 |
nicklas |
rnaqc.suggestWell(index); |
2774 |
09 Oct 14 |
nicklas |
461 |
} |
2774 |
09 Oct 14 |
nicklas |
462 |
} |
2774 |
09 Oct 14 |
nicklas |
463 |
|
2774 |
09 Oct 14 |
nicklas |
rnaqc.suggestWell = function(index) |
2774 |
09 Oct 14 |
nicklas |
465 |
{ |
2774 |
09 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2774 |
09 Oct 14 |
nicklas |
if (frm['row.'+index].disabled) return; |
2774 |
09 Oct 14 |
nicklas |
468 |
|
2774 |
09 Oct 14 |
nicklas |
var bioWells = selectedBioPlate.bioWells; |
2774 |
09 Oct 14 |
nicklas |
470 |
|
2774 |
09 Oct 14 |
nicklas |
// First, map out the wells already used in the form |
2774 |
09 Oct 14 |
nicklas |
var used = []; |
2774 |
09 Oct 14 |
nicklas |
for (var i = 0; i < selectedRna.length; i++) |
2774 |
09 Oct 14 |
nicklas |
474 |
{ |
2774 |
09 Oct 14 |
nicklas |
var rna = selectedRna[i]; |
2774 |
09 Oct 14 |
nicklas |
if (rna.isValid) |
2774 |
09 Oct 14 |
nicklas |
477 |
{ |
2774 |
09 Oct 14 |
nicklas |
var row = frm['row.'+i].value.toUpperCase(); |
2774 |
09 Oct 14 |
nicklas |
var column = frm['column.'+i].value; |
2774 |
09 Oct 14 |
nicklas |
var key = row+column; |
2774 |
09 Oct 14 |
nicklas |
used[key] = true; |
2774 |
09 Oct 14 |
nicklas |
482 |
} |
2774 |
09 Oct 14 |
nicklas |
483 |
} |
2774 |
09 Oct 14 |
nicklas |
484 |
|
2774 |
09 Oct 14 |
nicklas |
// Find first unused well not followed by any used well |
2774 |
09 Oct 14 |
nicklas |
var lastUnused = -1; |
2774 |
09 Oct 14 |
nicklas |
for (var i = 0; i < bioWells.length; i++) |
2774 |
09 Oct 14 |
nicklas |
488 |
{ |
2774 |
09 Oct 14 |
nicklas |
var well = bioWells[i]; |
2774 |
09 Oct 14 |
nicklas |
var row = Reggie.wellToAlpha(well.row); |
2774 |
09 Oct 14 |
nicklas |
var column = well.column+1; |
2774 |
09 Oct 14 |
nicklas |
var isUsed = used[row+column]; |
2774 |
09 Oct 14 |
nicklas |
493 |
|
2774 |
09 Oct 14 |
nicklas |
if (well.canAdd && !isUsed && lastUnused == -1) |
2774 |
09 Oct 14 |
nicklas |
495 |
{ |
2774 |
09 Oct 14 |
nicklas |
lastUnused = i; |
2774 |
09 Oct 14 |
nicklas |
497 |
} |
2774 |
09 Oct 14 |
nicklas |
else if (!well.canAdd || isUsed) |
2774 |
09 Oct 14 |
nicklas |
499 |
{ |
2774 |
09 Oct 14 |
nicklas |
lastUnused = -1; |
2774 |
09 Oct 14 |
nicklas |
501 |
} |
2774 |
09 Oct 14 |
nicklas |
502 |
} |
2774 |
09 Oct 14 |
nicklas |
503 |
|
2774 |
09 Oct 14 |
nicklas |
if (lastUnused >= 0) |
2774 |
09 Oct 14 |
nicklas |
505 |
{ |
2774 |
09 Oct 14 |
nicklas |
var well = bioWells[lastUnused]; |
2774 |
09 Oct 14 |
nicklas |
frm['row.'+index].value = Reggie.wellToAlpha(well.row); |
2774 |
09 Oct 14 |
nicklas |
frm['column.'+index].value = well.column+1; |
2774 |
09 Oct 14 |
nicklas |
509 |
|
2774 |
09 Oct 14 |
nicklas |
Wizard.setInputStatus('well.'+index, 'valid'); |
2774 |
09 Oct 14 |
nicklas |
selectedRna[index].isValid = true; |
2774 |
09 Oct 14 |
nicklas |
512 |
} |
2774 |
09 Oct 14 |
nicklas |
513 |
} |
2774 |
09 Oct 14 |
nicklas |
514 |
|
2774 |
09 Oct 14 |
nicklas |
rnaqc.wellOnChange = function(event) |
2774 |
09 Oct 14 |
nicklas |
516 |
{ |
2774 |
09 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2774 |
09 Oct 14 |
nicklas |
518 |
|
2774 |
09 Oct 14 |
nicklas |
var index = Data.int(event.currentTarget, 'index'); |
2774 |
09 Oct 14 |
nicklas |
var row = frm['row.'+index].value; |
2774 |
09 Oct 14 |
nicklas |
var column = frm['column.'+index].value; |
3545 |
16 Oct 15 |
nicklas |
var volume = frm['volume.'+index].value; |
2774 |
09 Oct 14 |
nicklas |
523 |
|
2774 |
09 Oct 14 |
nicklas |
selectedRna[index].isValid = false; |
3545 |
16 Oct 15 |
nicklas |
selectedRna[index].isValidVolume = false; |
2774 |
09 Oct 14 |
nicklas |
526 |
|
2774 |
09 Oct 14 |
nicklas |
if (row == '' || column == '') |
2774 |
09 Oct 14 |
nicklas |
528 |
{ |
2774 |
09 Oct 14 |
nicklas |
Wizard.setInputStatus('well.'+index, 'invalid', 'Missing row or column'); |
2774 |
09 Oct 14 |
nicklas |
return; |
2774 |
09 Oct 14 |
nicklas |
531 |
} |
2774 |
09 Oct 14 |
nicklas |
532 |
|
3545 |
16 Oct 15 |
nicklas |
if (volume == '') |
3545 |
16 Oct 15 |
nicklas |
534 |
{ |
3545 |
16 Oct 15 |
nicklas |
Wizard.setInputStatus('well.'+index, 'invalid', 'Missing volume'); |
3545 |
16 Oct 15 |
nicklas |
return; |
3545 |
16 Oct 15 |
nicklas |
537 |
} |
3545 |
16 Oct 15 |
nicklas |
else if (parseFloat(volume) <= 0 || isNaN(parseFloat(volume))) |
3545 |
16 Oct 15 |
nicklas |
539 |
{ |
3545 |
16 Oct 15 |
nicklas |
Wizard.setInputStatus('well.'+index, 'invalid', 'Volume must be > 0'); |
3545 |
16 Oct 15 |
nicklas |
return; |
3545 |
16 Oct 15 |
nicklas |
542 |
} |
3545 |
16 Oct 15 |
nicklas |
selectedRna[index].isValidVolume = true; |
3545 |
16 Oct 15 |
nicklas |
544 |
|
2774 |
09 Oct 14 |
nicklas |
var rowC = Reggie.alphaToWell(row); |
2774 |
09 Oct 14 |
nicklas |
if (rowC < 0 || rowC >= selectedBioPlate.geometry.rows) |
2774 |
09 Oct 14 |
nicklas |
547 |
{ |
2774 |
09 Oct 14 |
nicklas |
setInputStatus('well.'+index, 'invalid', 'Row must be between A-' + Reggie.wellToAlpha(selectedBioPlate.geometry.rows-1)); |
2774 |
09 Oct 14 |
nicklas |
return; |
2774 |
09 Oct 14 |
nicklas |
550 |
} |
2774 |
09 Oct 14 |
nicklas |
551 |
|
2774 |
09 Oct 14 |
nicklas |
var colC = parseInt(column, 10)-1; |
2774 |
09 Oct 14 |
nicklas |
if (isNaN(colC) || colC < 0 || colC >= selectedBioPlate.geometry.columns) |
2774 |
09 Oct 14 |
nicklas |
554 |
{ |
2774 |
09 Oct 14 |
nicklas |
Wizard.setInputStatus('well.'+index, 'invalid', 'Column must be between 1-' + selectedBioPlate.geometry.columns); |
2774 |
09 Oct 14 |
nicklas |
return; |
2774 |
09 Oct 14 |
nicklas |
557 |
} |
2774 |
09 Oct 14 |
nicklas |
558 |
|
2774 |
09 Oct 14 |
nicklas |
// Find the selected well |
2774 |
09 Oct 14 |
nicklas |
var well = rnaqc.getWellByCoordinate(selectedBioPlate, rowC, colC); |
2774 |
09 Oct 14 |
nicklas |
561 |
|
2774 |
09 Oct 14 |
nicklas |
// Check that it is not already used |
2774 |
09 Oct 14 |
nicklas |
if (!well.canAdd) |
2774 |
09 Oct 14 |
nicklas |
564 |
{ |
2774 |
09 Oct 14 |
nicklas |
Wizard.setInputStatus('well.'+index, 'invalid', 'The selected well is already used'); |
2774 |
09 Oct 14 |
nicklas |
return; |
2774 |
09 Oct 14 |
nicklas |
567 |
} |
2774 |
09 Oct 14 |
nicklas |
568 |
|
2774 |
09 Oct 14 |
nicklas |
// Seems to be ok |
2774 |
09 Oct 14 |
nicklas |
Wizard.setInputStatus('well.'+index, 'valid'); |
2774 |
09 Oct 14 |
nicklas |
selectedRna[index].isValid = true; |
2774 |
09 Oct 14 |
nicklas |
572 |
|
2774 |
09 Oct 14 |
nicklas |
// The final check is a duplication check |
2774 |
09 Oct 14 |
nicklas |
rnaqc.duplicateWellCheck(); |
2774 |
09 Oct 14 |
nicklas |
575 |
} |
2774 |
09 Oct 14 |
nicklas |
576 |
|
2774 |
09 Oct 14 |
nicklas |
// Get a well from a plate given a coordinate. |
2774 |
09 Oct 14 |
nicklas |
rnaqc.getWellByCoordinate = function(bioPlate, row, col) |
2774 |
09 Oct 14 |
nicklas |
579 |
{ |
2774 |
09 Oct 14 |
nicklas |
for (var i = 0; i < bioPlate.bioWells.length; i++) |
2774 |
09 Oct 14 |
nicklas |
581 |
{ |
2774 |
09 Oct 14 |
nicklas |
var w = bioPlate.bioWells[i]; |
2774 |
09 Oct 14 |
nicklas |
if (w.row == row && w.column == col) |
2774 |
09 Oct 14 |
nicklas |
584 |
{ |
2774 |
09 Oct 14 |
nicklas |
return w; |
2774 |
09 Oct 14 |
nicklas |
586 |
} |
2774 |
09 Oct 14 |
nicklas |
587 |
} |
2774 |
09 Oct 14 |
nicklas |
return null; |
2774 |
09 Oct 14 |
nicklas |
589 |
} |
2774 |
09 Oct 14 |
nicklas |
590 |
|
2774 |
09 Oct 14 |
nicklas |
rnaqc.duplicateWellCheck = function() |
2774 |
09 Oct 14 |
nicklas |
592 |
{ |
2774 |
09 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2774 |
09 Oct 14 |
nicklas |
var used = []; |
2774 |
09 Oct 14 |
nicklas |
var index = []; |
2774 |
09 Oct 14 |
nicklas |
596 |
|
2774 |
09 Oct 14 |
nicklas |
for (var i = 0; i < selectedRna.length; i++) |
2774 |
09 Oct 14 |
nicklas |
598 |
{ |
2774 |
09 Oct 14 |
nicklas |
var rna = selectedRna[i]; |
2774 |
09 Oct 14 |
nicklas |
600 |
|
2774 |
09 Oct 14 |
nicklas |
if (rna.isValid) |
2774 |
09 Oct 14 |
nicklas |
602 |
{ |
2774 |
09 Oct 14 |
nicklas |
var row = frm['row.'+i].value.toUpperCase(); |
2774 |
09 Oct 14 |
nicklas |
var column = frm['column.'+i].value; |
2774 |
09 Oct 14 |
nicklas |
605 |
|
2774 |
09 Oct 14 |
nicklas |
var key = row+column; |
2774 |
09 Oct 14 |
nicklas |
var dupRna = used[key]; |
2774 |
09 Oct 14 |
nicklas |
if (dupRna) |
2774 |
09 Oct 14 |
nicklas |
609 |
{ |
2774 |
09 Oct 14 |
nicklas |
Wizard.setInputStatus('well.'+i, 'invalid', dupRna.nextRnaQcName + ' is using the same well'); |
2774 |
09 Oct 14 |
nicklas |
Wizard.setInputStatus('well.'+index[key], 'invalid', rna.nextRnaQcName + ' is using the same well'); |
2774 |
09 Oct 14 |
nicklas |
rna.isDuplicate = true; |
2774 |
09 Oct 14 |
nicklas |
dupRna.isDuplicate = true; |
2774 |
09 Oct 14 |
nicklas |
614 |
} |
2774 |
09 Oct 14 |
nicklas |
else |
2774 |
09 Oct 14 |
nicklas |
616 |
{ |
2774 |
09 Oct 14 |
nicklas |
rna.isDuplicate = false; |
2774 |
09 Oct 14 |
nicklas |
Wizard.setInputStatus('well.'+i, 'valid'); |
2774 |
09 Oct 14 |
nicklas |
619 |
} |
2774 |
09 Oct 14 |
nicklas |
used[key] = rna; |
2774 |
09 Oct 14 |
nicklas |
index[key] = i; |
2774 |
09 Oct 14 |
nicklas |
622 |
} |
2774 |
09 Oct 14 |
nicklas |
623 |
} |
2774 |
09 Oct 14 |
nicklas |
624 |
} |
2774 |
09 Oct 14 |
nicklas |
625 |
|
3545 |
16 Oct 15 |
nicklas |
rnaqc.hiSenseOnClick = function(event) |
3545 |
16 Oct 15 |
nicklas |
627 |
{ |
3545 |
16 Oct 15 |
nicklas |
var frm = document.forms['reggie']; |
3545 |
16 Oct 15 |
nicklas |
var index = Data.int(event.currentTarget, 'index'); |
3545 |
16 Oct 15 |
nicklas |
var hiSenseChecked = event.currentTarget.checked; |
3545 |
16 Oct 15 |
nicklas |
631 |
|
3545 |
16 Oct 15 |
nicklas |
var volume = parseFloat(frm['volume.'+index].value); |
3545 |
16 Oct 15 |
nicklas |
// Switch default volume when HiSense is toggled (unless the volume has been modified) |
3545 |
16 Oct 15 |
nicklas |
if (volume == (hiSenseChecked ? ALIQUOT_VOLUME_NORMAL : ALIQUOT_VOLUME_HISENSE)) |
3545 |
16 Oct 15 |
nicklas |
635 |
{ |
3545 |
16 Oct 15 |
nicklas |
frm['volume.'+index].value = hiSenseChecked ? ALIQUOT_VOLUME_HISENSE : ALIQUOT_VOLUME_NORMAL; |
3545 |
16 Oct 15 |
nicklas |
Events.sendChangeEvent(frm['volume.'+index]); |
3545 |
16 Oct 15 |
nicklas |
638 |
} |
3545 |
16 Oct 15 |
nicklas |
639 |
|
3545 |
16 Oct 15 |
nicklas |
640 |
} |
3544 |
15 Oct 15 |
nicklas |
641 |
|
3544 |
15 Oct 15 |
nicklas |
rnaqc.printVersion = function() |
3544 |
15 Oct 15 |
nicklas |
643 |
{ |
3544 |
15 Oct 15 |
nicklas |
Wizard.hideGoNextConfirmation(); |
3544 |
15 Oct 15 |
nicklas |
Doc.removeClass('gonext', 'disabled'); |
3544 |
15 Oct 15 |
nicklas |
var reportName = 'RNAQC Aliquot Protocol'; |
3544 |
15 Oct 15 |
nicklas |
var printNote = '<b>Note!</b> For better printing set page orientation to <i>portrait</i>.'; |
3544 |
15 Oct 15 |
nicklas |
Reggie.openPrintWindow('full-protocol', reportName, 'portrait', printNote, '../', 'rnaqc_aliquot.css'); |
3544 |
15 Oct 15 |
nicklas |
649 |
} |
3544 |
15 Oct 15 |
nicklas |
650 |
|
2774 |
09 Oct 14 |
nicklas |
rnaqc.validateStep3 = function(event) |
2774 |
09 Oct 14 |
nicklas |
652 |
{ |
2774 |
09 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2774 |
09 Oct 14 |
nicklas |
654 |
|
2774 |
09 Oct 14 |
nicklas |
// Check that no wells have an error or is duplicated |
2774 |
09 Oct 14 |
nicklas |
for (var i = 0; i < selectedRna.length; i++) |
2774 |
09 Oct 14 |
nicklas |
657 |
{ |
2774 |
09 Oct 14 |
nicklas |
var rna = selectedRna[i]; |
2774 |
09 Oct 14 |
nicklas |
if (!rna.isValid || rna.isDuplicate) |
2774 |
09 Oct 14 |
nicklas |
660 |
{ |
2774 |
09 Oct 14 |
nicklas |
event.preventDefault(); |
3545 |
16 Oct 15 |
nicklas |
// Focus on the 'row' or 'volume' field |
3545 |
16 Oct 15 |
nicklas |
frm[(rna.isValidVolume ? 'row.' : 'volume.')+i].focus(); |
2774 |
09 Oct 14 |
nicklas |
return; |
2774 |
09 Oct 14 |
nicklas |
665 |
} |
2774 |
09 Oct 14 |
nicklas |
666 |
} |
2774 |
09 Oct 14 |
nicklas |
667 |
} |
2774 |
09 Oct 14 |
nicklas |
668 |
|
2774 |
09 Oct 14 |
nicklas |
rnaqc.submit = function() |
2774 |
09 Oct 14 |
nicklas |
670 |
{ |
2774 |
09 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2774 |
09 Oct 14 |
nicklas |
672 |
|
2774 |
09 Oct 14 |
nicklas |
var submitInfo = {}; |
2774 |
09 Oct 14 |
nicklas |
selectedBioPlate.bioWells = null; |
2774 |
09 Oct 14 |
nicklas |
submitInfo.bioplate = selectedBioPlate; |
2774 |
09 Oct 14 |
nicklas |
676 |
|
2774 |
09 Oct 14 |
nicklas |
submitInfo.protocol = parseInt(frm.protocols.value, 10); |
2774 |
09 Oct 14 |
nicklas |
678 |
|
2774 |
09 Oct 14 |
nicklas |
var rnaQcExtracts = []; |
2774 |
09 Oct 14 |
nicklas |
for (var i=0; i < selectedRna.length; i++) |
2774 |
09 Oct 14 |
nicklas |
681 |
{ |
2774 |
09 Oct 14 |
nicklas |
var rnaQc = {}; |
2774 |
09 Oct 14 |
nicklas |
rnaQc.parentId = selectedRna[i].id; |
2774 |
09 Oct 14 |
nicklas |
rnaQc.name = selectedRna[i].nextRnaQcName; |
2774 |
09 Oct 14 |
nicklas |
rnaQc.row = frm['row.'+i].value; |
2774 |
09 Oct 14 |
nicklas |
rnaQc.column = frm['column.'+i].value; |
2774 |
09 Oct 14 |
nicklas |
rnaQc.QCHiSense = frm['hiSense.'+i].checked ? true : false; |
3545 |
16 Oct 15 |
nicklas |
rnaQc.volume = parseFloat(frm['volume.'+i].value); |
2774 |
09 Oct 14 |
nicklas |
rnaQcExtracts[rnaQcExtracts.length] = rnaQc; |
2774 |
09 Oct 14 |
nicklas |
690 |
} |
2774 |
09 Oct 14 |
nicklas |
submitInfo.rnaQcExtracts = rnaQcExtracts; |
2774 |
09 Oct 14 |
nicklas |
692 |
|
2774 |
09 Oct 14 |
nicklas |
var url = '../RnaQc.servlet?ID='+App.getSessionId(); |
2774 |
09 Oct 14 |
nicklas |
url += '&cmd=PlaceRnaQcAliquots'; |
2774 |
09 Oct 14 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
2774 |
09 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, rnaqc.submissionResults, 'POST', JSON.stringify(submitInfo)); |
2774 |
09 Oct 14 |
nicklas |
697 |
} |
2774 |
09 Oct 14 |
nicklas |
698 |
|
2774 |
09 Oct 14 |
nicklas |
rnaqc.submissionResults = function(response) |
2774 |
09 Oct 14 |
nicklas |
700 |
{ |
2774 |
09 Oct 14 |
nicklas |
Wizard.showFinalMessage(response.messages); |
2774 |
09 Oct 14 |
nicklas |
Doc.show('gorestart'); |
2774 |
09 Oct 14 |
nicklas |
703 |
} |
2774 |
09 Oct 14 |
nicklas |
704 |
|
2774 |
09 Oct 14 |
nicklas |
return rnaqc; |
2774 |
09 Oct 14 |
nicklas |
706 |
}(); |
2774 |
09 Oct 14 |
nicklas |
707 |
|
2774 |
09 Oct 14 |
nicklas |
Doc.onLoad(RnaQcAliquot.initPage); |
2774 |
09 Oct 14 |
nicklas |
709 |
|