2740 |
06 Oct 14 |
nicklas |
var Partition = function() |
2740 |
06 Oct 14 |
nicklas |
2 |
{ |
2740 |
06 Oct 14 |
nicklas |
var partition = {}; |
2853 |
23 Oct 14 |
nicklas |
var debug = 0; |
2740 |
06 Oct 14 |
nicklas |
5 |
|
3153 |
27 Feb 15 |
nicklas |
var selectionIsValid = false; |
2740 |
06 Oct 14 |
nicklas |
var selectedSpecimen; |
6721 |
03 May 22 |
nicklas |
var tubeLabelAnnotationType; |
2740 |
06 Oct 14 |
nicklas |
9 |
|
2740 |
06 Oct 14 |
nicklas |
var spWeightsAreValid = []; |
2740 |
06 Oct 14 |
nicklas |
var apWeightsAreValid = []; |
2740 |
06 Oct 14 |
nicklas |
var hisWeightsAreValid = []; |
2740 |
06 Oct 14 |
nicklas |
var nofPiecesAreValid = []; |
2740 |
06 Oct 14 |
nicklas |
14 |
|
2740 |
06 Oct 14 |
nicklas |
var APPEARANCE_OPTIONS = ['', 'HOMOGENEOUS', 'HETEROGENEOUS']; |
2740 |
06 Oct 14 |
nicklas |
var FAT_OPTIONS = [0, 20, 40, 60, 80, 100]; |
2740 |
06 Oct 14 |
nicklas |
17 |
|
2740 |
06 Oct 14 |
nicklas |
// Page initialization |
2740 |
06 Oct 14 |
nicklas |
partition.initPage = function() |
2740 |
06 Oct 14 |
nicklas |
20 |
{ |
2740 |
06 Oct 14 |
nicklas |
// Step 1 |
2740 |
06 Oct 14 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', partition.validateStep1); |
3153 |
27 Feb 15 |
nicklas |
Events.addEventHandler('specimentubes', 'change', partition.checkSelection); |
3153 |
27 Feb 15 |
nicklas |
Events.addEventHandler('reextraction', 'change', partition.checkSelection); |
3145 |
25 Feb 15 |
nicklas |
Buttons.addClickHandler('goprint', partition.printPickList); |
2740 |
06 Oct 14 |
nicklas |
26 |
|
2740 |
06 Oct 14 |
nicklas |
// Step 2 |
2740 |
06 Oct 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', partition.initializeStep2); |
2740 |
06 Oct 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-validate', partition.validateStep2); |
2740 |
06 Oct 14 |
nicklas |
Events.addEventHandler('partitionDate', 'change', Wizard.validateDate); |
5299 |
14 Feb 19 |
nicklas |
Buttons.addClickHandler('downloadLabelsCsv', partition.downloadLabelFile); |
5299 |
14 Feb 19 |
nicklas |
Buttons.addClickHandler('downloadLabelsXlsx', partition.downloadLabelFile); |
2740 |
06 Oct 14 |
nicklas |
33 |
|
2740 |
06 Oct 14 |
nicklas |
// Navigation |
2740 |
06 Oct 14 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
2740 |
06 Oct 14 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
2740 |
06 Oct 14 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
3149 |
26 Feb 15 |
nicklas |
Buttons.addClickHandler('goregister', partition.verifyPositionsForReextraction); |
2740 |
06 Oct 14 |
nicklas |
39 |
|
2740 |
06 Oct 14 |
nicklas |
// Final registration |
2740 |
06 Oct 14 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', partition.submit); |
2740 |
06 Oct 14 |
nicklas |
42 |
|
2740 |
06 Oct 14 |
nicklas |
var url = '../PartitionRegistration.servlet?ID='+App.getSessionId(); |
2740 |
06 Oct 14 |
nicklas |
url += '&cmd=GetSpecimenTubes'; |
2740 |
06 Oct 14 |
nicklas |
Wizard.showLoadingAnimation('Loading specimen tubes...'); |
2740 |
06 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, partition.specimenTubesLoaded); |
2740 |
06 Oct 14 |
nicklas |
47 |
} |
2740 |
06 Oct 14 |
nicklas |
48 |
|
2740 |
06 Oct 14 |
nicklas |
partition.specimenTubesLoaded = function(response) |
2740 |
06 Oct 14 |
nicklas |
50 |
{ |
2740 |
06 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2740 |
06 Oct 14 |
nicklas |
52 |
|
6721 |
03 May 22 |
nicklas |
tubeLabelAnnotationType = response.TubeLabelAnnotationType; |
2740 |
06 Oct 14 |
nicklas |
var specimenTubes = response.specimenTubes; |
2740 |
06 Oct 14 |
nicklas |
if (specimenTubes.length > 0) |
2740 |
06 Oct 14 |
nicklas |
56 |
{ |
5346 |
03 Apr 19 |
nicklas |
specimenTubes.sort(partition.sortByPosition(false)); // Sort tubes, paused last |
2740 |
06 Oct 14 |
nicklas |
for (var i = 0; i < specimenTubes.length; i++) |
2740 |
06 Oct 14 |
nicklas |
59 |
{ |
2740 |
06 Oct 14 |
nicklas |
var specimen = specimenTubes[i]; |
3738 |
11 Feb 16 |
nicklas |
var isYellow = specimen.YellowLabel != null; |
3145 |
25 Feb 15 |
nicklas |
specimen.reprocess = specimen.AutoProcessing == 'ReProcess'; |
5335 |
28 Mar 19 |
nicklas |
specimen.firstExtraction = !specimen.originalQuantity; |
5335 |
28 Mar 19 |
nicklas |
specimen.paused = specimen.reprocess && specimen.firstExtraction; |
2740 |
06 Oct 14 |
nicklas |
var storeInfo = partition.getStoredInfo(specimen.id); |
4583 |
21 Sep 17 |
nicklas |
var option = new Option(specimen.name, specimen.id, false, storeInfo ? true : false); |
2740 |
06 Oct 14 |
nicklas |
option.specimenTube = specimen; |
3738 |
11 Feb 16 |
nicklas |
if (isYellow) option.className = 'yellow'; |
3145 |
25 Feb 15 |
nicklas |
if (specimen.reprocess) |
3145 |
25 Feb 15 |
nicklas |
70 |
{ |
5782 |
11 Dec 19 |
nicklas |
option.text += ' - ' + (specimen.bioWell != null ? specimen.bioWell.bioPlate.name + ' ' + specimen.bioWell.location : 'no box'); |
5346 |
03 Apr 19 |
nicklas |
frm.reextraction[frm.reextraction.length] = option; |
3145 |
25 Feb 15 |
nicklas |
73 |
} |
3145 |
25 Feb 15 |
nicklas |
else |
3145 |
25 Feb 15 |
nicklas |
75 |
{ |
3145 |
25 Feb 15 |
nicklas |
frm.specimentubes[frm.specimentubes.length] = option; |
3145 |
25 Feb 15 |
nicklas |
77 |
} |
3145 |
25 Feb 15 |
nicklas |
if (storeInfo) option.text += ' [*]'; |
2740 |
06 Oct 14 |
nicklas |
79 |
} |
3145 |
25 Feb 15 |
nicklas |
if (frm.specimentubes.length == 0) Doc.hide('regularFlowRow'); |
3153 |
27 Feb 15 |
nicklas |
if (frm.reextraction.length > 0) Doc.show('reExtractionRow'); |
3153 |
27 Feb 15 |
nicklas |
partition.checkSelection(); |
2740 |
06 Oct 14 |
nicklas |
83 |
} |
2740 |
06 Oct 14 |
nicklas |
else |
2740 |
06 Oct 14 |
nicklas |
85 |
{ |
2740 |
06 Oct 14 |
nicklas |
Wizard.setFatalError('No specimen available for partitioning'); |
2740 |
06 Oct 14 |
nicklas |
return; |
2740 |
06 Oct 14 |
nicklas |
88 |
} |
2740 |
06 Oct 14 |
nicklas |
89 |
|
2740 |
06 Oct 14 |
nicklas |
Doc.show('step-1'); |
2740 |
06 Oct 14 |
nicklas |
Doc.show('gonext'); |
2740 |
06 Oct 14 |
nicklas |
92 |
} |
2740 |
06 Oct 14 |
nicklas |
93 |
|
3153 |
27 Feb 15 |
nicklas |
partition.checkSelection = function() |
3145 |
25 Feb 15 |
nicklas |
95 |
{ |
3145 |
25 Feb 15 |
nicklas |
var frm = document.forms['reggie']; |
3153 |
27 Feb 15 |
nicklas |
var numSpecimen = 0; |
3153 |
27 Feb 15 |
nicklas |
var numReextration = 0; |
3739 |
11 Feb 16 |
nicklas |
var numUnselectedYellow = 0; |
3153 |
27 Feb 15 |
nicklas |
selectionIsValid = false; |
3153 |
27 Feb 15 |
nicklas |
Wizard.setInputStatus('specimentubes'); |
3153 |
27 Feb 15 |
nicklas |
Wizard.setInputStatus('reextraction'); |
3153 |
27 Feb 15 |
nicklas |
103 |
|
3153 |
27 Feb 15 |
nicklas |
for (var i = 0; i < frm.specimentubes.length; i++) |
3153 |
27 Feb 15 |
nicklas |
105 |
{ |
3739 |
11 Feb 16 |
nicklas |
var specimen = frm.specimentubes[i].specimenTube; |
3739 |
11 Feb 16 |
nicklas |
if (frm.specimentubes[i].selected) |
3739 |
11 Feb 16 |
nicklas |
108 |
{ |
3739 |
11 Feb 16 |
nicklas |
numSpecimen++; |
3739 |
11 Feb 16 |
nicklas |
110 |
} |
3739 |
11 Feb 16 |
nicklas |
else if (specimen.YellowLabel != null) |
3739 |
11 Feb 16 |
nicklas |
112 |
{ |
3739 |
11 Feb 16 |
nicklas |
numUnselectedYellow++; |
3739 |
11 Feb 16 |
nicklas |
114 |
} |
3153 |
27 Feb 15 |
nicklas |
115 |
} |
3145 |
25 Feb 15 |
nicklas |
for (var i = 0; i < frm.reextraction.length; i++) |
3145 |
25 Feb 15 |
nicklas |
117 |
{ |
3739 |
11 Feb 16 |
nicklas |
var specimen = frm.reextraction[i].specimenTube; |
3739 |
11 Feb 16 |
nicklas |
if (frm.reextraction[i].selected) |
3739 |
11 Feb 16 |
nicklas |
120 |
{ |
3739 |
11 Feb 16 |
nicklas |
numReextration++; |
3739 |
11 Feb 16 |
nicklas |
122 |
} |
3739 |
11 Feb 16 |
nicklas |
else if (specimen.YellowLabel != null) |
3739 |
11 Feb 16 |
nicklas |
124 |
{ |
3739 |
11 Feb 16 |
nicklas |
numUnselectedYellow++; |
3739 |
11 Feb 16 |
nicklas |
126 |
} |
3145 |
25 Feb 15 |
nicklas |
127 |
} |
3145 |
25 Feb 15 |
nicklas |
128 |
|
3153 |
27 Feb 15 |
nicklas |
if (numReextration == 0 && numSpecimen == 0) |
3145 |
25 Feb 15 |
nicklas |
130 |
{ |
3153 |
27 Feb 15 |
nicklas |
Wizard.setInputStatus('specimentubes', 'invalid', 'At least one specimen tube must be selected'); |
3153 |
27 Feb 15 |
nicklas |
Wizard.setInputStatus('reextraction', 'invalid', 'At least one specimen tube must be selected'); |
3153 |
27 Feb 15 |
nicklas |
return; |
3153 |
27 Feb 15 |
nicklas |
134 |
} |
3153 |
27 Feb 15 |
nicklas |
135 |
|
3153 |
27 Feb 15 |
nicklas |
selectionIsValid = true; |
3739 |
11 Feb 16 |
nicklas |
if (numUnselectedYellow > 0) |
3153 |
27 Feb 15 |
nicklas |
138 |
{ |
3739 |
11 Feb 16 |
nicklas |
Wizard.setInputStatus('specimentubes', 'warning', 'Not all YellowLabel specimen are selected'); |
3739 |
11 Feb 16 |
nicklas |
140 |
} |
3739 |
11 Feb 16 |
nicklas |
else if (numSpecimen > 0) |
3739 |
11 Feb 16 |
nicklas |
142 |
{ |
3153 |
27 Feb 15 |
nicklas |
Wizard.setInputStatus('specimentubes', 'valid'); |
3153 |
27 Feb 15 |
nicklas |
144 |
} |
3153 |
27 Feb 15 |
nicklas |
145 |
|
3153 |
27 Feb 15 |
nicklas |
if (numReextration > 0) |
3153 |
27 Feb 15 |
nicklas |
147 |
{ |
3145 |
25 Feb 15 |
nicklas |
Doc.show('goprint'); |
3145 |
25 Feb 15 |
nicklas |
Wizard.showGoNextConfirmation(true, 'Print the pick list protocol before continuing with the registration!'); |
3153 |
27 Feb 15 |
nicklas |
150 |
|
3153 |
27 Feb 15 |
nicklas |
if (numSpecimen != frm.specimentubes.length) |
3153 |
27 Feb 15 |
nicklas |
152 |
{ |
3153 |
27 Feb 15 |
nicklas |
var msg = 'Selecting specimen tubes for re-extraction without selecting all regular specimen may result in non-consecutive positioning in storage boxes'; |
3153 |
27 Feb 15 |
nicklas |
Wizard.setInputStatus('reextraction', 'warning', msg); |
3153 |
27 Feb 15 |
nicklas |
Wizard.setInputStatus('specimentubes', 'warning', msg); |
3153 |
27 Feb 15 |
nicklas |
156 |
} |
3153 |
27 Feb 15 |
nicklas |
else |
3153 |
27 Feb 15 |
nicklas |
158 |
{ |
3153 |
27 Feb 15 |
nicklas |
Wizard.setInputStatus('reextraction', 'valid'); |
3153 |
27 Feb 15 |
nicklas |
160 |
} |
3145 |
25 Feb 15 |
nicklas |
161 |
} |
3145 |
25 Feb 15 |
nicklas |
else |
3145 |
25 Feb 15 |
nicklas |
163 |
{ |
3145 |
25 Feb 15 |
nicklas |
Doc.hide('goprint'); |
3145 |
25 Feb 15 |
nicklas |
Wizard.hideGoNextConfirmation(); |
3145 |
25 Feb 15 |
nicklas |
166 |
} |
3145 |
25 Feb 15 |
nicklas |
167 |
} |
3145 |
25 Feb 15 |
nicklas |
168 |
|
3145 |
25 Feb 15 |
nicklas |
partition.printPickList = function() |
3145 |
25 Feb 15 |
nicklas |
170 |
{ |
3145 |
25 Feb 15 |
nicklas |
var frm = document.forms['reggie']; |
3145 |
25 Feb 15 |
nicklas |
var selected = []; |
3145 |
25 Feb 15 |
nicklas |
for (var i = 0; i < frm.reextraction.length; i++) |
3145 |
25 Feb 15 |
nicklas |
174 |
{ |
3145 |
25 Feb 15 |
nicklas |
if (frm.reextraction[i].selected) |
3145 |
25 Feb 15 |
nicklas |
176 |
{ |
5346 |
03 Apr 19 |
nicklas |
selected[selected.length] = frm.reextraction[i].specimenTube; |
3145 |
25 Feb 15 |
nicklas |
178 |
} |
3145 |
25 Feb 15 |
nicklas |
179 |
} |
5346 |
03 Apr 19 |
nicklas |
// Re-sort so that paused specime are first (to match the order on the partition protocol) |
5346 |
03 Apr 19 |
nicklas |
selected.sort(partition.sortByPosition(true)); |
3145 |
25 Feb 15 |
nicklas |
182 |
|
3145 |
25 Feb 15 |
nicklas |
var url = 'reextract_picklist.jsp?ID='+App.getSessionId(); |
5346 |
03 Apr 19 |
nicklas |
url += '&specimen='+selected.map(function(s){return s.id}).join(','); |
6721 |
03 May 22 |
nicklas |
url += '&tubeLabelAnnotationType='+tubeLabelAnnotationType; |
3145 |
25 Feb 15 |
nicklas |
window.open(url, '_blank'); |
3145 |
25 Feb 15 |
nicklas |
Wizard.hideGoNextConfirmation(); |
3145 |
25 Feb 15 |
nicklas |
188 |
} |
3145 |
25 Feb 15 |
nicklas |
189 |
|
2740 |
06 Oct 14 |
nicklas |
partition.validateStep1 = function(event) |
2740 |
06 Oct 14 |
nicklas |
191 |
{ |
3153 |
27 Feb 15 |
nicklas |
if (!selectionIsValid) |
2740 |
06 Oct 14 |
nicklas |
193 |
{ |
3153 |
27 Feb 15 |
nicklas |
event.preventDefault(); |
2740 |
06 Oct 14 |
nicklas |
195 |
} |
2740 |
06 Oct 14 |
nicklas |
196 |
} |
2740 |
06 Oct 14 |
nicklas |
197 |
|
2740 |
06 Oct 14 |
nicklas |
198 |
|
2740 |
06 Oct 14 |
nicklas |
partition.initializeStep2 = function() |
2740 |
06 Oct 14 |
nicklas |
200 |
{ |
2740 |
06 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2740 |
06 Oct 14 |
nicklas |
202 |
|
2740 |
06 Oct 14 |
nicklas |
selectedSpecimen = []; |
2740 |
06 Oct 14 |
nicklas |
for (var i = 0; i < frm.specimentubes.length; i++) |
2740 |
06 Oct 14 |
nicklas |
205 |
{ |
2740 |
06 Oct 14 |
nicklas |
if (frm.specimentubes[i].selected) |
2740 |
06 Oct 14 |
nicklas |
207 |
{ |
2740 |
06 Oct 14 |
nicklas |
selectedSpecimen[selectedSpecimen.length] = frm.specimentubes[i].specimenTube; |
2740 |
06 Oct 14 |
nicklas |
209 |
} |
2740 |
06 Oct 14 |
nicklas |
210 |
} |
3149 |
26 Feb 15 |
nicklas |
211 |
|
3149 |
26 Feb 15 |
nicklas |
var numReextraction = 0; |
3145 |
25 Feb 15 |
nicklas |
for (var i = 0; i < frm.reextraction.length; i++) |
3145 |
25 Feb 15 |
nicklas |
214 |
{ |
3145 |
25 Feb 15 |
nicklas |
if (frm.reextraction[i].selected) |
3145 |
25 Feb 15 |
nicklas |
216 |
{ |
3145 |
25 Feb 15 |
nicklas |
selectedSpecimen[selectedSpecimen.length] = frm.reextraction[i].specimenTube; |
3149 |
26 Feb 15 |
nicklas |
numReextraction++; |
3145 |
25 Feb 15 |
nicklas |
219 |
} |
3145 |
25 Feb 15 |
nicklas |
220 |
} |
5346 |
03 Apr 19 |
nicklas |
selectedSpecimen.sort(partition.sortByPosition(true)); // Sort tubes, paused between regular and other re-processing tubes |
3149 |
26 Feb 15 |
nicklas |
222 |
|
3149 |
26 Feb 15 |
nicklas |
if (numReextraction > 0) |
3149 |
26 Feb 15 |
nicklas |
224 |
{ |
3149 |
26 Feb 15 |
nicklas |
var url = '../SpecimenTubeRegistration.servlet?ID='+App.getSessionId(); |
3149 |
26 Feb 15 |
nicklas |
url += '&cmd=FindStoragePositions'; |
3149 |
26 Feb 15 |
nicklas |
url += '&nofTubes='+numReextraction; |
2740 |
06 Oct 14 |
nicklas |
228 |
|
3149 |
26 Feb 15 |
nicklas |
Wizard.showLoadingAnimation('Looking for empty box positions...'); |
3149 |
26 Feb 15 |
nicklas |
Wizard.asyncJsonRequest(url, partition.storagePositionsLoaded); |
3149 |
26 Feb 15 |
nicklas |
231 |
} |
3149 |
26 Feb 15 |
nicklas |
else |
3149 |
26 Feb 15 |
nicklas |
233 |
{ |
3149 |
26 Feb 15 |
nicklas |
partition.buildPartitionTable(); |
3149 |
26 Feb 15 |
nicklas |
235 |
} |
3149 |
26 Feb 15 |
nicklas |
236 |
} |
3149 |
26 Feb 15 |
nicklas |
237 |
|
3149 |
26 Feb 15 |
nicklas |
238 |
|
3149 |
26 Feb 15 |
nicklas |
partition.storagePositionsLoaded = function(response) |
3149 |
26 Feb 15 |
nicklas |
240 |
{ |
3149 |
26 Feb 15 |
nicklas |
var wells = response.wells; |
3149 |
26 Feb 15 |
nicklas |
if (wells.length < response.nofTubes) |
3149 |
26 Feb 15 |
nicklas |
243 |
{ |
3149 |
26 Feb 15 |
nicklas |
var msg = 'Could not find enough free positions in storage box for re-extracted specimen.'; |
3149 |
26 Feb 15 |
nicklas |
msg += ' Wanted ' + response.nofTubes + ', but found ' + wells.length + '.'; |
3149 |
26 Feb 15 |
nicklas |
if (wells.length > 0) |
3149 |
26 Feb 15 |
nicklas |
247 |
{ |
3149 |
26 Feb 15 |
nicklas |
var last = wells[wells.length-1]; |
3149 |
26 Feb 15 |
nicklas |
msg += ' Last free: ' + Strings.encodeTags(last.bioPlate.name+' ['+last.location+']'); |
3149 |
26 Feb 15 |
nicklas |
250 |
} |
3149 |
26 Feb 15 |
nicklas |
Wizard.setFatalError(msg); |
3149 |
26 Feb 15 |
nicklas |
return; |
3149 |
26 Feb 15 |
nicklas |
253 |
} |
3149 |
26 Feb 15 |
nicklas |
254 |
|
3149 |
26 Feb 15 |
nicklas |
var wellNo = 0; |
3149 |
26 Feb 15 |
nicklas |
for (var i = 0; i < selectedSpecimen.length; i++) |
3149 |
26 Feb 15 |
nicklas |
257 |
{ |
3149 |
26 Feb 15 |
nicklas |
var specimen = selectedSpecimen[i]; |
3149 |
26 Feb 15 |
nicklas |
if (specimen.reprocess) |
3149 |
26 Feb 15 |
nicklas |
260 |
{ |
3149 |
26 Feb 15 |
nicklas |
specimen.newBioWell = wells[wellNo]; |
3149 |
26 Feb 15 |
nicklas |
wellNo++; |
3149 |
26 Feb 15 |
nicklas |
263 |
} |
3149 |
26 Feb 15 |
nicklas |
264 |
} |
3149 |
26 Feb 15 |
nicklas |
partition.buildPartitionTable(); |
3149 |
26 Feb 15 |
nicklas |
266 |
} |
3149 |
26 Feb 15 |
nicklas |
267 |
|
3149 |
26 Feb 15 |
nicklas |
partition.buildPartitionTable = function() |
3149 |
26 Feb 15 |
nicklas |
269 |
{ |
3149 |
26 Feb 15 |
nicklas |
var frm = document.forms['reggie']; |
2740 |
06 Oct 14 |
nicklas |
var html = '<table id="weightsTable" class="step-form">'; |
5335 |
28 Mar 19 |
nicklas |
if (selectedSpecimen[0].firstExtraction) |
3145 |
25 Feb 15 |
nicklas |
273 |
{ |
3145 |
25 Feb 15 |
nicklas |
html += '<thead class="bg-filled-100" style="border-top-width: 2px; border-bottom-width: 2px;">'; |
3145 |
25 Feb 15 |
nicklas |
// First header row |
3145 |
25 Feb 15 |
nicklas |
html += '<tr>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<th>Specimen</th>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<th class="dottedleft">Bloody</th>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<th>Appearance</th>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<th>Fat</th>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<th>Coloured</th>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<th>NofPieces</th>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<th>ApWeight</th>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<th>Mult¹</th>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<th>HisWeight</th>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<th>SpWeight</th>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<th></th>'; |
3145 |
25 Feb 15 |
nicklas |
html += '</tr>'; |
3145 |
25 Feb 15 |
nicklas |
// Second header row |
3145 |
25 Feb 15 |
nicklas |
html += '<tr>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<td>Storage box</td>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<td class="dottedleft"></td>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<td></td>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<td>%</td>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<td></td>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<td></td>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<td>(mg)</td>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<td></td>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<td>(mg)</td>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<td>(mg)</td>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<th></th>'; |
3145 |
25 Feb 15 |
nicklas |
html += '</tr>'; |
3145 |
25 Feb 15 |
nicklas |
html += '</thead>'; |
3145 |
25 Feb 15 |
nicklas |
304 |
} |
2740 |
06 Oct 14 |
nicklas |
html += '<tbody>'; |
2740 |
06 Oct 14 |
nicklas |
306 |
|
2740 |
06 Oct 14 |
nicklas |
var appearance = partition.buildOptionsHtml(APPEARANCE_OPTIONS); |
2740 |
06 Oct 14 |
nicklas |
var fat = partition.buildOptionsHtml(FAT_OPTIONS); |
3145 |
25 Feb 15 |
nicklas |
309 |
|
3145 |
25 Feb 15 |
nicklas |
var firstReprocess = true; |
5335 |
28 Mar 19 |
nicklas |
var firstPaused = true; |
2740 |
06 Oct 14 |
nicklas |
for (var i = 0; i < selectedSpecimen.length; i++) |
2740 |
06 Oct 14 |
nicklas |
313 |
{ |
3145 |
25 Feb 15 |
nicklas |
var specimen = selectedSpecimen[i]; |
3738 |
11 Feb 16 |
nicklas |
var isYellow = specimen.YellowLabel != null; |
3738 |
11 Feb 16 |
nicklas |
316 |
|
2740 |
06 Oct 14 |
nicklas |
spWeightsAreValid[i] = false; |
2740 |
06 Oct 14 |
nicklas |
apWeightsAreValid[i] = false; |
5335 |
28 Mar 19 |
nicklas |
hisWeightsAreValid[i] = !specimen.firstExtraction; |
5335 |
28 Mar 19 |
nicklas |
nofPiecesAreValid[i] = !specimen.firstExtraction; |
5335 |
28 Mar 19 |
nicklas |
if (specimen.paused && firstPaused) |
3145 |
25 Feb 15 |
nicklas |
322 |
{ |
5335 |
28 Mar 19 |
nicklas |
html += '<tr style="border-top-width: 2px;">'; |
5782 |
11 Dec 19 |
nicklas |
html += '<th class="bg-filled-100">Paused specimen & external</th>'; |
5335 |
28 Mar 19 |
nicklas |
html += '<th colspan="11" class="dottedleft"></th>'; |
5335 |
28 Mar 19 |
nicklas |
html += '</tr>'; |
5335 |
28 Mar 19 |
nicklas |
// Second header row |
5335 |
28 Mar 19 |
nicklas |
html += '<tr>'; |
5335 |
28 Mar 19 |
nicklas |
html += '<td class="bg-filled-100" style="border-bottom-width: 1px;">Old box <b>›</b> New box</td>'; |
6079 |
24 Nov 20 |
nicklas |
html += '<td colspan="10" class="dottedleft"></td>'; |
5335 |
28 Mar 19 |
nicklas |
html += '</tr>'; |
5335 |
28 Mar 19 |
nicklas |
firstPaused = false; |
5335 |
28 Mar 19 |
nicklas |
333 |
} |
5335 |
28 Mar 19 |
nicklas |
334 |
|
5335 |
28 Mar 19 |
nicklas |
if (!specimen.firstExtraction && firstReprocess) |
5335 |
28 Mar 19 |
nicklas |
336 |
{ |
3146 |
25 Feb 15 |
nicklas |
Doc.show('includeAllHisLabelsLbl', 'inline'); |
3145 |
25 Feb 15 |
nicklas |
html += '<tr class="bg-filled-100" style="border-top-width: 2px;">'; |
3145 |
25 Feb 15 |
nicklas |
html += '<th>Re-extraction</th>'; |
6079 |
24 Nov 20 |
nicklas |
html += '<th colspan="3" class="dottedleft">OperatorPartitionComment</th>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<th>Weight</th>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<th>NofPieces</th>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<th>ApWeight</th>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<th>Mult¹</th>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<th>HisWeight</th>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<th>SpWeight</th>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<th></th>'; |
3145 |
25 Feb 15 |
nicklas |
html += '</tr>'; |
3145 |
25 Feb 15 |
nicklas |
// Second header row |
3145 |
25 Feb 15 |
nicklas |
html += '<tr class="bg-filled-100" style="border-bottom-width: 2px;">'; |
3145 |
25 Feb 15 |
nicklas |
html += '<td>Old box <b>›</b> New box</td>'; |
6079 |
24 Nov 20 |
nicklas |
html += '<td colspan="3" class="dottedleft"></td>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<td>(mg)</td>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<td></td>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<td>(mg)</td>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<td></td>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<td>(mg)</td>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<td>(mg)</td>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<th></th>'; |
3145 |
25 Feb 15 |
nicklas |
html += '</tr>'; |
3145 |
25 Feb 15 |
nicklas |
firstReprocess = false; |
3145 |
25 Feb 15 |
nicklas |
362 |
} |
6721 |
03 May 22 |
nicklas |
var prefix = isYellow ? '<img src="../images/yellow-label.png">' : ''; |
6721 |
03 May 22 |
nicklas |
if (specimen.label) |
6721 |
03 May 22 |
nicklas |
365 |
{ |
6721 |
03 May 22 |
nicklas |
prefix += Strings.encodeTags(specimen.label) + ' › '; |
6721 |
03 May 22 |
nicklas |
367 |
} |
3738 |
11 Feb 16 |
nicklas |
html += '<tr class="highlight'+(isYellow ? ' yellow-specimen' : '')+'">'; |
6721 |
03 May 22 |
nicklas |
html += '<td class="prompt if-yellow">'+prefix+Strings.encodeTags(specimen.name)+'</td>'; |
3151 |
26 Feb 15 |
nicklas |
var nextFocusAfterApWeight; |
3145 |
25 Feb 15 |
nicklas |
var nextFocusAfterSpWeight; |
5335 |
28 Mar 19 |
nicklas |
if (!specimen.firstExtraction) |
3145 |
25 Feb 15 |
nicklas |
373 |
{ |
6079 |
24 Nov 20 |
nicklas |
html += '<td class="dottedleft" colspan="3" style="text-align: left;">'+Strings.encodeTags(specimen.OperatorPartitionComment)+'</td>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<td>'+Reggie.formatNumber(specimen.remainingQuantity/1000, '', 1)+'</td>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<td>'+specimen.NofPieces+'</td>'; |
3151 |
26 Feb 15 |
nicklas |
nextFocusAfterApWeight = 'spWeight.'+i; |
3151 |
26 Feb 15 |
nicklas |
nextFocusAfterSpWeight = 'apWeight.'+(i+1); |
3145 |
25 Feb 15 |
nicklas |
379 |
} |
3145 |
25 Feb 15 |
nicklas |
else |
3145 |
25 Feb 15 |
nicklas |
381 |
{ |
3145 |
25 Feb 15 |
nicklas |
html += '<td class="dottedleft"><input type="checkbox" name="bloody.'+i+'" id="bloody.'+i+'" data-next-focus="appearance.'+i+'" /></td>'; |
6079 |
24 Nov 20 |
nicklas |
html += '<td><select name="appearance.'+i+'" id="appearance.'+i+'" data-next-focus="fat.'+i+'">'+appearance+'</select></td>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<td><select name="fat.'+i+'" id="fat.'+i+'" data-next-focus="coloured.'+i+'">'+fat+'</select></td>'; |
3145 |
25 Feb 15 |
nicklas |
html += '<td><input type="checkbox" name="coloured.'+i+'" id="coloured.'+i+'" data-next-focus="nofPieces.'+i+'" /></td>' |
3145 |
25 Feb 15 |
nicklas |
html += '<td><input type="text" class="required" name="nofPieces.'+i+'" id="nofPieces.'+i+'" data-next-focus="apWeight.'+i+'" style="width: 2em;" maxlength="2" /></td>'; |
3151 |
26 Feb 15 |
nicklas |
nextFocusAfterApWeight = 'hisWeight.'+i; |
3151 |
26 Feb 15 |
nicklas |
nextFocusAfterSpWeight = 'bloody.'+(i+1); |
3145 |
25 Feb 15 |
nicklas |
389 |
} |
3151 |
26 Feb 15 |
nicklas |
html += '<td><input type="text" class="required" name="apWeight.'+i+'" id="apWeight.'+i+'" data-next-focus="'+nextFocusAfterApWeight+'" style="width: 4em;" maxlength="5" /></td>'; |
2740 |
06 Oct 14 |
nicklas |
html += '<td><input type="checkbox" name="multPieces.'+i+'" id="multPieces.'+i+'" data-next-focus="hisWeight.'+i+'" /></td>' |
2740 |
06 Oct 14 |
nicklas |
html += '<td><input type="text" class="required" name="hisWeight.'+i+'" id="hisWeight.'+i+'" data-next-focus="spWeight.'+i+'" style="width: 4em;" maxlength="5" /></td>'; |
3151 |
26 Feb 15 |
nicklas |
html += '<td><input type="text" class="required" name="spWeight.'+i+'" id="spWeight.'+i+'" data-next-focus="'+nextFocusAfterSpWeight+'" style="width: 4em;" maxlength="5" /></td>'; |
2740 |
06 Oct 14 |
nicklas |
html += '<td class="status" id="specimen.'+i+'.status"></td>'; |
2740 |
06 Oct 14 |
nicklas |
html += '</tr>'; |
2740 |
06 Oct 14 |
nicklas |
396 |
|
3738 |
11 Feb 16 |
nicklas |
html += '<tr class="'+(isYellow ? ' yellow-specimen' : '')+'" style="border-bottom-width: 1px; border-bottom-style: dotted;">'; |
3738 |
11 Feb 16 |
nicklas |
html += '<td class="if-yellow">'; |
2740 |
06 Oct 14 |
nicklas |
// Only show box information if there is something show. |
5782 |
11 Dec 19 |
nicklas |
if (specimen.bioWell || specimen.newBioWell) |
2740 |
06 Oct 14 |
nicklas |
401 |
{ |
3145 |
25 Feb 15 |
nicklas |
if (specimen.reprocess) |
3145 |
25 Feb 15 |
nicklas |
403 |
{ |
3151 |
26 Feb 15 |
nicklas |
html += '<span class="old-location">'+partition.toLocation(specimen.bioWell)+'</span>'; |
3149 |
26 Feb 15 |
nicklas |
html += ' <b>›</b> '; |
3151 |
26 Feb 15 |
nicklas |
html += '<span class="new-location" id="newlocation.'+i+'">'+partition.toLocation(specimen.newBioWell)+'</span>'; |
3145 |
25 Feb 15 |
nicklas |
407 |
} |
3149 |
26 Feb 15 |
nicklas |
else |
3149 |
26 Feb 15 |
nicklas |
409 |
{ |
3151 |
26 Feb 15 |
nicklas |
html += partition.toLocation(specimen.bioWell); |
3149 |
26 Feb 15 |
nicklas |
411 |
} |
2740 |
06 Oct 14 |
nicklas |
412 |
} |
2740 |
06 Oct 14 |
nicklas |
html += '</td>'; |
6079 |
24 Nov 20 |
nicklas |
html += '<td colspan="10" class="help dottedleft"><span class="message" id="specimen.'+i+'.message"></span><span id="specimen.'+i+'.help"> </span></td>'; |
2740 |
06 Oct 14 |
nicklas |
html += '</tr>'; |
2740 |
06 Oct 14 |
nicklas |
416 |
} |
2740 |
06 Oct 14 |
nicklas |
html += '</tbody>'; |
2740 |
06 Oct 14 |
nicklas |
html += '</table>'; |
2740 |
06 Oct 14 |
nicklas |
Doc.element('weightInputs').innerHTML = html; |
2740 |
06 Oct 14 |
nicklas |
420 |
|
2740 |
06 Oct 14 |
nicklas |
// Attach event handlers, restore from local storage, etc. |
2740 |
06 Oct 14 |
nicklas |
isRestoringFromLocalStorage = true; |
2740 |
06 Oct 14 |
nicklas |
for (var i = 0; i < selectedSpecimen.length; i++) |
2740 |
06 Oct 14 |
nicklas |
424 |
{ |
3145 |
25 Feb 15 |
nicklas |
var specimen = selectedSpecimen[i]; |
3145 |
25 Feb 15 |
nicklas |
426 |
|
5335 |
28 Mar 19 |
nicklas |
if (specimen.reprocess && !specimen.firstExtraction) frm['hisWeight.'+i].value = '0'; |
3145 |
25 Feb 15 |
nicklas |
428 |
|
6079 |
24 Nov 20 |
nicklas |
var elements = ['bloody.'+i, 'appearance.'+i, 'fat.'+i, 'coloured.'+i, 'nofPieces.'+i, 'apWeight.'+i, 'multPieces.'+i, 'hisWeight.'+i, 'spWeight.'+i]; |
2740 |
06 Oct 14 |
nicklas |
partition.addEventHandlers(elements, 'focus', partition.onFocusElement); |
2740 |
06 Oct 14 |
nicklas |
partition.addEventHandlers(elements, 'blur', partition.onFocusElement); |
2740 |
06 Oct 14 |
nicklas |
partition.addEventHandlers(elements, 'keypress', Wizard.focusOnEnter); |
2740 |
06 Oct 14 |
nicklas |
partition.addEventHandlers(elements, 'change', partition.saveToLocalStorage); |
2740 |
06 Oct 14 |
nicklas |
434 |
|
2740 |
06 Oct 14 |
nicklas |
Events.addEventHandler('nofPieces.'+i, 'keypress', Events.integerOnly); |
2740 |
06 Oct 14 |
nicklas |
Events.addEventHandler('nofPieces.'+i, 'change', partition.nofPiecesOnChange); |
2740 |
06 Oct 14 |
nicklas |
Events.addEventHandler('apWeight.'+i, 'keypress', Events.numberOnly); |
2740 |
06 Oct 14 |
nicklas |
Events.addEventHandler('apWeight.'+i, 'change', partition.apWeightOnChange); |
2740 |
06 Oct 14 |
nicklas |
Events.addEventHandler('hisWeight.'+i, 'keypress', Events.numberOnly); |
2740 |
06 Oct 14 |
nicklas |
Events.addEventHandler('hisWeight.'+i, 'change', partition.hisWeightOnChange); |
2740 |
06 Oct 14 |
nicklas |
Events.addEventHandler('spWeight.'+i, 'keypress', Events.numberOnly); |
2740 |
06 Oct 14 |
nicklas |
Events.addEventHandler('spWeight.'+i, 'change', partition.spWeightOnChange); |
2740 |
06 Oct 14 |
nicklas |
443 |
|
3145 |
25 Feb 15 |
nicklas |
444 |
|
2740 |
06 Oct 14 |
nicklas |
var storeInfo = partition.getStoredInfo(specimen.id); |
2740 |
06 Oct 14 |
nicklas |
if (storeInfo) |
2740 |
06 Oct 14 |
nicklas |
447 |
{ |
5335 |
28 Mar 19 |
nicklas |
if (specimen.firstExtraction) |
3145 |
25 Feb 15 |
nicklas |
449 |
{ |
3145 |
25 Feb 15 |
nicklas |
frm['bloody.'+i].checked = storeInfo.bloody; |
3145 |
25 Feb 15 |
nicklas |
Forms.selectListOption(frm['appearance.'+i], storeInfo.appearance); |
3145 |
25 Feb 15 |
nicklas |
Forms.selectListOption(frm['fat.'+i], storeInfo.fat); |
3145 |
25 Feb 15 |
nicklas |
frm['coloured.'+i].checked = storeInfo.coloured; |
3145 |
25 Feb 15 |
nicklas |
frm['nofPieces.'+i].value = storeInfo.nofPieces; |
3145 |
25 Feb 15 |
nicklas |
455 |
} |
3145 |
25 Feb 15 |
nicklas |
456 |
|
2740 |
06 Oct 14 |
nicklas |
frm['spWeight.'+i].value = storeInfo.spWeight; |
2740 |
06 Oct 14 |
nicklas |
frm['hisWeight.'+i].value = storeInfo.hisWeight; |
2740 |
06 Oct 14 |
nicklas |
frm['apWeight.'+i].value = storeInfo.apWeight; |
2740 |
06 Oct 14 |
nicklas |
frm['multPieces.'+i].checked = storeInfo.multPieces; |
2740 |
06 Oct 14 |
nicklas |
461 |
|
2740 |
06 Oct 14 |
nicklas |
Events.sendChangeEvent('spWeight.'+i); |
2740 |
06 Oct 14 |
nicklas |
Events.sendChangeEvent('hisWeight.'+i); |
2740 |
06 Oct 14 |
nicklas |
Events.sendChangeEvent('apWeight.'+i); |
5335 |
28 Mar 19 |
nicklas |
if (specimen.firstExtraction) |
3145 |
25 Feb 15 |
nicklas |
466 |
{ |
3145 |
25 Feb 15 |
nicklas |
Events.sendChangeEvent('nofPieces.'+i); |
3145 |
25 Feb 15 |
nicklas |
468 |
} |
2740 |
06 Oct 14 |
nicklas |
469 |
} |
2740 |
06 Oct 14 |
nicklas |
470 |
} |
2740 |
06 Oct 14 |
nicklas |
471 |
|
2740 |
06 Oct 14 |
nicklas |
isRestoringFromLocalStorage = false; |
2740 |
06 Oct 14 |
nicklas |
473 |
|
2740 |
06 Oct 14 |
nicklas |
Wizard.setCurrentStep(2); |
2740 |
06 Oct 14 |
nicklas |
frm.partitionDate.focus(); |
2740 |
06 Oct 14 |
nicklas |
frm.partitionDate.select(); |
2740 |
06 Oct 14 |
nicklas |
477 |
|
2740 |
06 Oct 14 |
nicklas |
Doc.show('goregister'); |
2740 |
06 Oct 14 |
nicklas |
Doc.show('gocancel'); |
2745 |
07 Oct 14 |
nicklas |
Wizard.keepSessionAlive(); |
2740 |
06 Oct 14 |
nicklas |
481 |
} |
2740 |
06 Oct 14 |
nicklas |
482 |
|
2740 |
06 Oct 14 |
nicklas |
partition.addEventHandlers = function(elements, eventName, handler) |
2740 |
06 Oct 14 |
nicklas |
484 |
{ |
2740 |
06 Oct 14 |
nicklas |
for (var i = 0; i < elements.length; i++) |
2740 |
06 Oct 14 |
nicklas |
486 |
{ |
2740 |
06 Oct 14 |
nicklas |
Events.addEventHandler(elements[i], eventName, handler); |
2740 |
06 Oct 14 |
nicklas |
488 |
} |
2740 |
06 Oct 14 |
nicklas |
489 |
} |
2740 |
06 Oct 14 |
nicklas |
490 |
|
5346 |
03 Apr 19 |
nicklas |
491 |
/** |
5346 |
03 Apr 19 |
nicklas |
Sort specimen tubes. Regular processing (AutoProcessing=null) tubes are |
5346 |
03 Apr 19 |
nicklas |
always sorted first. Then, we can either sort paused specimen tubes before |
5346 |
03 Apr 19 |
nicklas |
re-processing or after. |
5346 |
03 Apr 19 |
nicklas |
495 |
*/ |
5346 |
03 Apr 19 |
nicklas |
partition.sortByPosition = function(pausedFirst) |
2740 |
06 Oct 14 |
nicklas |
497 |
{ |
5346 |
03 Apr 19 |
nicklas |
498 |
|
5346 |
03 Apr 19 |
nicklas |
return function(t1, t2) |
3145 |
25 Feb 15 |
nicklas |
500 |
{ |
5346 |
03 Apr 19 |
nicklas |
if (t1.AutoProcessing != t2.AutoProcessing) |
5346 |
03 Apr 19 |
nicklas |
502 |
{ |
5346 |
03 Apr 19 |
nicklas |
// Re-extraction items are sorted last (eg. AutoProcessing=ReProcess) |
5346 |
03 Apr 19 |
nicklas |
return t1.AutoProcessing == null ? -1 : 1; |
5346 |
03 Apr 19 |
nicklas |
505 |
} |
5782 |
11 Dec 19 |
nicklas |
506 |
|
5782 |
11 Dec 19 |
nicklas |
if (t1.paused != t2.paused) |
5782 |
11 Dec 19 |
nicklas |
508 |
{ |
5782 |
11 Dec 19 |
nicklas |
return t1.paused == pausedFirst ? -1 : 1; |
5782 |
11 Dec 19 |
nicklas |
510 |
} |
5782 |
11 Dec 19 |
nicklas |
511 |
|
5782 |
11 Dec 19 |
nicklas |
if (t1.bioWell == null || t2.bioWell == null) |
5782 |
11 Dec 19 |
nicklas |
513 |
{ |
5782 |
11 Dec 19 |
nicklas |
// Tubes without a box position are sorted last, in name order |
5782 |
11 Dec 19 |
nicklas |
if (t1.bioWell != null) return -1; |
5782 |
11 Dec 19 |
nicklas |
if (t2.bioWell != null) return 1; |
5782 |
11 Dec 19 |
nicklas |
return t1.name < t2.name ? -1 : 1; |
5782 |
11 Dec 19 |
nicklas |
518 |
} |
5782 |
11 Dec 19 |
nicklas |
519 |
|
5346 |
03 Apr 19 |
nicklas |
var well1 = t1.bioWell; |
5346 |
03 Apr 19 |
nicklas |
var box1 = well1.bioPlate.name; |
5346 |
03 Apr 19 |
nicklas |
var well2 = t2.bioWell; |
5346 |
03 Apr 19 |
nicklas |
var box2 = well2.bioPlate.name; |
5346 |
03 Apr 19 |
nicklas |
if (box1 == box2) |
5346 |
03 Apr 19 |
nicklas |
525 |
{ |
5346 |
03 Apr 19 |
nicklas |
return well1.row == well2.row ? well1.column - well2.column : well1.row - well2.row; |
5346 |
03 Apr 19 |
nicklas |
527 |
} |
5346 |
03 Apr 19 |
nicklas |
else |
5346 |
03 Apr 19 |
nicklas |
529 |
{ |
5346 |
03 Apr 19 |
nicklas |
return box1 < box2 ? -1 : 1; |
5346 |
03 Apr 19 |
nicklas |
531 |
} |
3145 |
25 Feb 15 |
nicklas |
532 |
} |
2740 |
06 Oct 14 |
nicklas |
533 |
} |
2740 |
06 Oct 14 |
nicklas |
534 |
|
3151 |
26 Feb 15 |
nicklas |
partition.toLocation = function(well) |
3151 |
26 Feb 15 |
nicklas |
536 |
{ |
5782 |
11 Dec 19 |
nicklas |
return well ? Strings.encodeTags(well.bioPlate.name+' ['+well.location+']') : 'Unknown box'; |
3151 |
26 Feb 15 |
nicklas |
538 |
} |
3151 |
26 Feb 15 |
nicklas |
539 |
|
2740 |
06 Oct 14 |
nicklas |
partition.buildOptionsHtml = function(a) |
2740 |
06 Oct 14 |
nicklas |
541 |
{ |
2740 |
06 Oct 14 |
nicklas |
var html = ''; |
2740 |
06 Oct 14 |
nicklas |
for (var i = 0; i < a.length; i++) |
2740 |
06 Oct 14 |
nicklas |
544 |
{ |
2740 |
06 Oct 14 |
nicklas |
html += '<option value="'+a[i]+'">'+a[i]+'</option>'; |
2740 |
06 Oct 14 |
nicklas |
546 |
} |
2740 |
06 Oct 14 |
nicklas |
return html; |
2740 |
06 Oct 14 |
nicklas |
548 |
} |
2740 |
06 Oct 14 |
nicklas |
549 |
|
5299 |
14 Feb 19 |
nicklas |
partition.downloadLabelFile = function(event) |
2740 |
06 Oct 14 |
nicklas |
551 |
{ |
5299 |
14 Feb 19 |
nicklas |
var format = Data.get(event.currentTarget, 'format'); |
3146 |
25 Feb 15 |
nicklas |
var ids = []; |
2740 |
06 Oct 14 |
nicklas |
for (var i = 0; i < selectedSpecimen.length; i++) |
2740 |
06 Oct 14 |
nicklas |
555 |
{ |
3146 |
25 Feb 15 |
nicklas |
ids[ids.length] = selectedSpecimen[i].id; |
2740 |
06 Oct 14 |
nicklas |
557 |
} |
5299 |
14 Feb 19 |
nicklas |
558 |
|
5299 |
14 Feb 19 |
nicklas |
var url = '../PartitionRegistration.servlet?ID='+App.getSessionId(); |
5299 |
14 Feb 19 |
nicklas |
url += '&cmd=GetLabelFile'; |
3146 |
25 Feb 15 |
nicklas |
url += '&specimen='+ids.join(','); |
5813 |
22 Jan 20 |
nicklas |
url += '&includeHisLabels='+(Doc.element('includeHisLabels').checked ? 1 : 0); |
3146 |
25 Feb 15 |
nicklas |
url += '&includeAllHisLabels='+(Doc.element('includeAllHisLabels').checked ? 1 : 0); |
5299 |
14 Feb 19 |
nicklas |
url += '&format='+encodeURIComponent(format); |
3146 |
25 Feb 15 |
nicklas |
565 |
|
2740 |
06 Oct 14 |
nicklas |
window.open(url); |
2740 |
06 Oct 14 |
nicklas |
567 |
} |
2740 |
06 Oct 14 |
nicklas |
568 |
|
2740 |
06 Oct 14 |
nicklas |
partition.onFocusElement = function(event) |
2740 |
06 Oct 14 |
nicklas |
570 |
{ |
2740 |
06 Oct 14 |
nicklas |
var target = event.currentTarget; |
2740 |
06 Oct 14 |
nicklas |
var dotI = target.id.indexOf('.'); |
2740 |
06 Oct 14 |
nicklas |
var col = target.id.substr(0, dotI); |
2740 |
06 Oct 14 |
nicklas |
var index = target.id.substr(dotI+1); |
2740 |
06 Oct 14 |
nicklas |
575 |
|
2740 |
06 Oct 14 |
nicklas |
var msg = ' '; |
2740 |
06 Oct 14 |
nicklas |
if (event.type == 'focus') |
2740 |
06 Oct 14 |
nicklas |
578 |
{ |
2740 |
06 Oct 14 |
nicklas |
if (col == 'bloody') |
2740 |
06 Oct 14 |
nicklas |
580 |
{ |
2740 |
06 Oct 14 |
nicklas |
msg = 'Check this if the partition is bloody. Unchecked is default.'; |
2740 |
06 Oct 14 |
nicklas |
582 |
} |
2740 |
06 Oct 14 |
nicklas |
else if (col == 'appearance') |
2740 |
06 Oct 14 |
nicklas |
584 |
{ |
2740 |
06 Oct 14 |
nicklas |
msg = 'Select appearance. Empty is default.'; |
2740 |
06 Oct 14 |
nicklas |
586 |
} |
2740 |
06 Oct 14 |
nicklas |
else if (col == 'fat') |
2740 |
06 Oct 14 |
nicklas |
588 |
{ |
2740 |
06 Oct 14 |
nicklas |
msg = 'Select percentage of fat. \'0\' is default.'; |
2740 |
06 Oct 14 |
nicklas |
590 |
} |
2740 |
06 Oct 14 |
nicklas |
else if (col == 'coloured') |
2740 |
06 Oct 14 |
nicklas |
592 |
{ |
2740 |
06 Oct 14 |
nicklas |
msg = 'Check this if the partition is coloured. Unchecked is default.'; |
2740 |
06 Oct 14 |
nicklas |
594 |
} |
2740 |
06 Oct 14 |
nicklas |
else if (col == 'nofPieces') |
2740 |
06 Oct 14 |
nicklas |
596 |
{ |
2740 |
06 Oct 14 |
nicklas |
msg = 'Number of pieces in this partition.'; |
2740 |
06 Oct 14 |
nicklas |
598 |
} |
2740 |
06 Oct 14 |
nicklas |
else if (col == 'apWeight') |
2740 |
06 Oct 14 |
nicklas |
600 |
{ |
2740 |
06 Oct 14 |
nicklas |
msg = 'Ap weight in [mg].'; |
2740 |
06 Oct 14 |
nicklas |
602 |
} |
2740 |
06 Oct 14 |
nicklas |
else if (col == 'hisWeight') |
2740 |
06 Oct 14 |
nicklas |
604 |
{ |
2740 |
06 Oct 14 |
nicklas |
msg = 'His weight in [mg].'; |
2740 |
06 Oct 14 |
nicklas |
606 |
} |
2740 |
06 Oct 14 |
nicklas |
else if (col == 'spWeight') |
2740 |
06 Oct 14 |
nicklas |
608 |
{ |
2740 |
06 Oct 14 |
nicklas |
msg = 'Sp weight in [mg].'; |
2740 |
06 Oct 14 |
nicklas |
610 |
} |
2740 |
06 Oct 14 |
nicklas |
else if (col == 'multPieces') |
2740 |
06 Oct 14 |
nicklas |
612 |
{ |
2740 |
06 Oct 14 |
nicklas |
msg = 'Check the box if multiple specimen pieces are sampled for the AllPrep piece.'; |
2740 |
06 Oct 14 |
nicklas |
614 |
} |
2745 |
07 Oct 14 |
nicklas |
// So we get an error icon for empty required fields |
2745 |
07 Oct 14 |
nicklas |
if (target.value == '') Events.sendChangeEvent(event.target); |
2740 |
06 Oct 14 |
nicklas |
617 |
} |
2740 |
06 Oct 14 |
nicklas |
Doc.element('specimen.'+index+'.help').innerHTML = msg; |
2740 |
06 Oct 14 |
nicklas |
619 |
} |
2740 |
06 Oct 14 |
nicklas |
620 |
|
2740 |
06 Oct 14 |
nicklas |
partition.nofPiecesOnChange = function(event) |
2740 |
06 Oct 14 |
nicklas |
622 |
{ |
2740 |
06 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2740 |
06 Oct 14 |
nicklas |
var target = event.currentTarget; |
2740 |
06 Oct 14 |
nicklas |
var dotI = target.id.indexOf('.'); |
2740 |
06 Oct 14 |
nicklas |
var index = parseInt(target.id.substr(dotI+1)); |
2740 |
06 Oct 14 |
nicklas |
627 |
|
2740 |
06 Oct 14 |
nicklas |
var nofPieces = parseInt(target.value); |
2740 |
06 Oct 14 |
nicklas |
if (nofPieces > 0) |
2740 |
06 Oct 14 |
nicklas |
630 |
{ |
2740 |
06 Oct 14 |
nicklas |
nofPiecesAreValid[index] = true; |
2740 |
06 Oct 14 |
nicklas |
if (nofPieces == 1) |
2740 |
06 Oct 14 |
nicklas |
633 |
{ |
2740 |
06 Oct 14 |
nicklas |
frm['multPieces.'+index].disabled = true; |
2740 |
06 Oct 14 |
nicklas |
frm['multPieces.'+index].checked = false; |
2740 |
06 Oct 14 |
nicklas |
636 |
} |
2740 |
06 Oct 14 |
nicklas |
else |
2740 |
06 Oct 14 |
nicklas |
638 |
{ |
2740 |
06 Oct 14 |
nicklas |
frm['multPieces.'+index].disabled = false; |
2740 |
06 Oct 14 |
nicklas |
640 |
} |
2740 |
06 Oct 14 |
nicklas |
641 |
} |
2740 |
06 Oct 14 |
nicklas |
else |
2740 |
06 Oct 14 |
nicklas |
643 |
{ |
2740 |
06 Oct 14 |
nicklas |
nofPiecesAreValid[index] = false; |
2740 |
06 Oct 14 |
nicklas |
645 |
} |
2745 |
07 Oct 14 |
nicklas |
partition.updateInputStatus(index); |
2740 |
06 Oct 14 |
nicklas |
647 |
} |
2740 |
06 Oct 14 |
nicklas |
648 |
|
2740 |
06 Oct 14 |
nicklas |
partition.apWeightOnChange = function(event) |
2740 |
06 Oct 14 |
nicklas |
650 |
{ |
2740 |
06 Oct 14 |
nicklas |
var target = event.currentTarget; |
2740 |
06 Oct 14 |
nicklas |
var dotI = target.id.indexOf('.'); |
2740 |
06 Oct 14 |
nicklas |
var index = parseInt(target.id.substr(dotI+1)); |
2740 |
06 Oct 14 |
nicklas |
654 |
|
2740 |
06 Oct 14 |
nicklas |
var apWeight = parseFloat(target.value); |
2745 |
07 Oct 14 |
nicklas |
apWeightsAreValid[index] = apWeight >= 0; |
2745 |
07 Oct 14 |
nicklas |
partition.updateInputStatus(index); |
2740 |
06 Oct 14 |
nicklas |
658 |
} |
2740 |
06 Oct 14 |
nicklas |
659 |
|
2740 |
06 Oct 14 |
nicklas |
partition.spWeightOnChange = function(event) |
2740 |
06 Oct 14 |
nicklas |
661 |
{ |
2740 |
06 Oct 14 |
nicklas |
var target = event.currentTarget; |
2740 |
06 Oct 14 |
nicklas |
var dotI = target.id.indexOf('.'); |
2740 |
06 Oct 14 |
nicklas |
var index = parseInt(target.id.substr(dotI+1)); |
2740 |
06 Oct 14 |
nicklas |
665 |
|
2740 |
06 Oct 14 |
nicklas |
var spWeight = parseFloat(target.value); |
2745 |
07 Oct 14 |
nicklas |
spWeightsAreValid[index] = spWeight >= 0; |
2745 |
07 Oct 14 |
nicklas |
partition.updateInputStatus(index); |
2740 |
06 Oct 14 |
nicklas |
669 |
} |
2740 |
06 Oct 14 |
nicklas |
670 |
|
2740 |
06 Oct 14 |
nicklas |
partition.hisWeightOnChange = function(event) |
2740 |
06 Oct 14 |
nicklas |
672 |
{ |
2740 |
06 Oct 14 |
nicklas |
var target = event.currentTarget; |
2740 |
06 Oct 14 |
nicklas |
var dotI = target.id.indexOf('.'); |
2740 |
06 Oct 14 |
nicklas |
var index = parseInt(target.id.substr(dotI+1)); |
2740 |
06 Oct 14 |
nicklas |
676 |
|
2740 |
06 Oct 14 |
nicklas |
var hisWeight = parseFloat(target.value); |
2745 |
07 Oct 14 |
nicklas |
hisWeightsAreValid[index] = hisWeight >= 0; |
2745 |
07 Oct 14 |
nicklas |
partition.updateInputStatus(index); |
2740 |
06 Oct 14 |
nicklas |
680 |
} |
2740 |
06 Oct 14 |
nicklas |
681 |
|
2740 |
06 Oct 14 |
nicklas |
partition.updateInputStatus = function(index) |
2740 |
06 Oct 14 |
nicklas |
683 |
{ |
2740 |
06 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2740 |
06 Oct 14 |
nicklas |
685 |
|
2745 |
07 Oct 14 |
nicklas |
if (!nofPiecesAreValid[index]) |
2740 |
06 Oct 14 |
nicklas |
687 |
{ |
2745 |
07 Oct 14 |
nicklas |
Wizard.setInputStatus('specimen.'+index, 'invalid', 'NofPieces is invalid.'); |
2745 |
07 Oct 14 |
nicklas |
689 |
} |
2745 |
07 Oct 14 |
nicklas |
else if (!apWeightsAreValid[index]) |
2745 |
07 Oct 14 |
nicklas |
691 |
{ |
2745 |
07 Oct 14 |
nicklas |
Wizard.setInputStatus('specimen.'+index, 'invalid', 'APWeight is invalid.'); |
2745 |
07 Oct 14 |
nicklas |
693 |
} |
2745 |
07 Oct 14 |
nicklas |
else if (!hisWeightsAreValid[index]) |
2745 |
07 Oct 14 |
nicklas |
695 |
{ |
2745 |
07 Oct 14 |
nicklas |
Wizard.setInputStatus('specimen.'+index, 'invalid', 'HisWeight is invalid.'); |
2745 |
07 Oct 14 |
nicklas |
697 |
} |
2745 |
07 Oct 14 |
nicklas |
else if (!spWeightsAreValid[index]) |
2745 |
07 Oct 14 |
nicklas |
699 |
{ |
2745 |
07 Oct 14 |
nicklas |
Wizard.setInputStatus('specimen.'+index, 'invalid', 'SpWeight is invalid.'); |
2745 |
07 Oct 14 |
nicklas |
701 |
} |
2745 |
07 Oct 14 |
nicklas |
else |
2745 |
07 Oct 14 |
nicklas |
703 |
{ |
3145 |
25 Feb 15 |
nicklas |
var specimen = selectedSpecimen[index]; |
2740 |
06 Oct 14 |
nicklas |
var spWeightValue = parseFloat(frm.elements['spWeight.'+index].value); |
2740 |
06 Oct 14 |
nicklas |
var apWeightValue = parseFloat(frm.elements['apWeight.'+index].value); |
2740 |
06 Oct 14 |
nicklas |
var hisWeightValue = parseFloat(frm.elements['hisWeight.'+index].value); |
3147 |
25 Feb 15 |
nicklas |
var sumOfWeights = apWeightValue + hisWeightValue + spWeightValue; |
3147 |
25 Feb 15 |
nicklas |
709 |
|
2740 |
06 Oct 14 |
nicklas |
if (apWeightValue == 0) |
2740 |
06 Oct 14 |
nicklas |
711 |
{ |
2740 |
06 Oct 14 |
nicklas |
Wizard.setInputStatus('specimen.'+index, 'warning', 'No Lysate item will be created!'); |
2740 |
06 Oct 14 |
nicklas |
713 |
} |
5335 |
28 Mar 19 |
nicklas |
else if (hisWeightValue == 0 && specimen.firstExtraction) |
2740 |
06 Oct 14 |
nicklas |
715 |
{ |
2740 |
06 Oct 14 |
nicklas |
Wizard.setInputStatus('specimen.'+index, 'warning', 'No Histology item will be created!'); |
2740 |
06 Oct 14 |
nicklas |
717 |
} |
3147 |
25 Feb 15 |
nicklas |
else |
2740 |
06 Oct 14 |
nicklas |
719 |
{ |
5335 |
28 Mar 19 |
nicklas |
var weightDiff = specimen.firstExtraction ? 0 : sumOfWeights-specimen.remainingQuantity/1000; |
3147 |
25 Feb 15 |
nicklas |
if (Math.abs(weightDiff) > 2) |
3147 |
25 Feb 15 |
nicklas |
722 |
{ |
3147 |
25 Feb 15 |
nicklas |
Wizard.setInputStatus('specimen.'+index, 'warning', 'Sum of weights ' + sumOfWeights + (weightDiff > 0 ? ' > ' : ' < ') + Reggie.formatNumber(specimen.remainingQuantity/1000, '', 1)); |
3147 |
25 Feb 15 |
nicklas |
724 |
} |
3147 |
25 Feb 15 |
nicklas |
else |
3147 |
25 Feb 15 |
nicklas |
726 |
{ |
3147 |
25 Feb 15 |
nicklas |
Wizard.setInputStatus('specimen.'+index, 'valid'); |
3147 |
25 Feb 15 |
nicklas |
728 |
} |
2740 |
06 Oct 14 |
nicklas |
729 |
} |
2740 |
06 Oct 14 |
nicklas |
730 |
} |
2740 |
06 Oct 14 |
nicklas |
731 |
} |
2740 |
06 Oct 14 |
nicklas |
732 |
|
2740 |
06 Oct 14 |
nicklas |
partition.validateStep2 = function(event) |
2740 |
06 Oct 14 |
nicklas |
734 |
{ |
2740 |
06 Oct 14 |
nicklas |
var valid = true; |
2740 |
06 Oct 14 |
nicklas |
valid &= Wizard.isValid('partitionDate'); |
2740 |
06 Oct 14 |
nicklas |
737 |
|
2740 |
06 Oct 14 |
nicklas |
if (valid) |
2740 |
06 Oct 14 |
nicklas |
739 |
{ |
2740 |
06 Oct 14 |
nicklas |
for (var i = 0; i < selectedSpecimen.length; i++) |
2740 |
06 Oct 14 |
nicklas |
741 |
{ |
2740 |
06 Oct 14 |
nicklas |
valid &= spWeightsAreValid[i]; |
2740 |
06 Oct 14 |
nicklas |
valid &= apWeightsAreValid[i]; |
2740 |
06 Oct 14 |
nicklas |
valid &= hisWeightsAreValid[i]; |
2740 |
06 Oct 14 |
nicklas |
valid &= nofPiecesAreValid[i]; |
2740 |
06 Oct 14 |
nicklas |
if (!valid) |
2740 |
06 Oct 14 |
nicklas |
747 |
{ |
2740 |
06 Oct 14 |
nicklas |
Wizard.setInputStatus('specimen.'+i, 'invalid'); |
2740 |
06 Oct 14 |
nicklas |
break; |
2740 |
06 Oct 14 |
nicklas |
750 |
} |
2740 |
06 Oct 14 |
nicklas |
751 |
} |
2740 |
06 Oct 14 |
nicklas |
752 |
} |
2740 |
06 Oct 14 |
nicklas |
753 |
|
2740 |
06 Oct 14 |
nicklas |
if (!valid) event.preventDefault(); |
2740 |
06 Oct 14 |
nicklas |
755 |
} |
2740 |
06 Oct 14 |
nicklas |
756 |
|
3149 |
26 Feb 15 |
nicklas |
757 |
/* |
3149 |
26 Feb 15 |
nicklas |
Linked to the 'Register' buttons since we want to check if |
3149 |
26 Feb 15 |
nicklas |
the generated positions for re-extracted specimen tubes are |
3149 |
26 Feb 15 |
nicklas |
still valid. We simply make the same request as we made when |
3149 |
26 Feb 15 |
nicklas |
creating the partition table. See also |
3149 |
26 Feb 15 |
nicklas |
partition.storagePositionsLoadedForVerification() |
3149 |
26 Feb 15 |
nicklas |
763 |
*/ |
3149 |
26 Feb 15 |
nicklas |
partition.verifyPositionsForReextraction = function() |
3149 |
26 Feb 15 |
nicklas |
765 |
{ |
3149 |
26 Feb 15 |
nicklas |
Wizard.hideGoNextConfirmation(); |
3149 |
26 Feb 15 |
nicklas |
var numReextraction = 0; |
3149 |
26 Feb 15 |
nicklas |
for (var i = 0; i < selectedSpecimen.length; i++) |
3149 |
26 Feb 15 |
nicklas |
769 |
{ |
3149 |
26 Feb 15 |
nicklas |
if (selectedSpecimen[i].reprocess) numReextraction++ |
3149 |
26 Feb 15 |
nicklas |
771 |
} |
3149 |
26 Feb 15 |
nicklas |
772 |
|
3149 |
26 Feb 15 |
nicklas |
if (numReextraction > 0) |
3149 |
26 Feb 15 |
nicklas |
774 |
{ |
3149 |
26 Feb 15 |
nicklas |
var url = '../SpecimenTubeRegistration.servlet?ID='+App.getSessionId(); |
3149 |
26 Feb 15 |
nicklas |
url += '&cmd=FindStoragePositions'; |
3149 |
26 Feb 15 |
nicklas |
url += '&nofTubes='+numReextraction; |
3149 |
26 Feb 15 |
nicklas |
778 |
|
3149 |
26 Feb 15 |
nicklas |
Wizard.showLoadingAnimation('Verifying empty box positions...'); |
3149 |
26 Feb 15 |
nicklas |
Wizard.asyncJsonRequest(url, partition.storagePositionsLoadedForVerification); |
3149 |
26 Feb 15 |
nicklas |
781 |
} |
3149 |
26 Feb 15 |
nicklas |
else |
3149 |
26 Feb 15 |
nicklas |
783 |
{ |
3149 |
26 Feb 15 |
nicklas |
Wizard.goRegister(); |
3149 |
26 Feb 15 |
nicklas |
785 |
} |
3149 |
26 Feb 15 |
nicklas |
786 |
} |
2740 |
06 Oct 14 |
nicklas |
787 |
|
3149 |
26 Feb 15 |
nicklas |
788 |
/** |
3149 |
26 Feb 15 |
nicklas |
Verify that the second request for storage positions return the same positions as the |
3149 |
26 Feb 15 |
nicklas |
first request (when creating the partition table). If they match we simple continue |
3149 |
26 Feb 15 |
nicklas |
with registration by calling Wizard.goRegister(), otherwise we update the specimen |
3149 |
26 Feb 15 |
nicklas |
with new positions and display a notification that must be verified before registration |
3149 |
26 Feb 15 |
nicklas |
can continue. |
3149 |
26 Feb 15 |
nicklas |
794 |
*/ |
3149 |
26 Feb 15 |
nicklas |
partition.storagePositionsLoadedForVerification = function(response) |
3149 |
26 Feb 15 |
nicklas |
796 |
{ |
3149 |
26 Feb 15 |
nicklas |
var wells = response.wells; |
3149 |
26 Feb 15 |
nicklas |
if (wells.length < response.nofTubes) |
3149 |
26 Feb 15 |
nicklas |
799 |
{ |
3149 |
26 Feb 15 |
nicklas |
var msg = 'Could not find enough free positions in storage box for re-extracted specimen.'; |
3149 |
26 Feb 15 |
nicklas |
msg += ' Wanted ' + response.nofTubes + ', but found ' + wells.length + '.'; |
3149 |
26 Feb 15 |
nicklas |
if (wells.length > 0) |
3149 |
26 Feb 15 |
nicklas |
803 |
{ |
3149 |
26 Feb 15 |
nicklas |
var last = wells[wells.length-1]; |
3149 |
26 Feb 15 |
nicklas |
msg += ' Last free: ' + Strings.encodeTags(last.bioPlate.name+' ['+last.location+']'); |
3149 |
26 Feb 15 |
nicklas |
806 |
} |
3149 |
26 Feb 15 |
nicklas |
Wizard.setFatalError(msg); |
3149 |
26 Feb 15 |
nicklas |
return; |
3149 |
26 Feb 15 |
nicklas |
809 |
} |
3149 |
26 Feb 15 |
nicklas |
810 |
|
3149 |
26 Feb 15 |
nicklas |
var wellNo = 0; |
3149 |
26 Feb 15 |
nicklas |
var hasModified = false; |
3149 |
26 Feb 15 |
nicklas |
for (var i = 0; i < selectedSpecimen.length; i++) |
3149 |
26 Feb 15 |
nicklas |
814 |
{ |
3149 |
26 Feb 15 |
nicklas |
var specimen = selectedSpecimen[i]; |
3149 |
26 Feb 15 |
nicklas |
if (specimen.reprocess) |
3149 |
26 Feb 15 |
nicklas |
817 |
{ |
3149 |
26 Feb 15 |
nicklas |
var w = wells[wellNo]; |
3149 |
26 Feb 15 |
nicklas |
wellNo++; |
3149 |
26 Feb 15 |
nicklas |
if (specimen.newBioWell.id != w.id) |
3149 |
26 Feb 15 |
nicklas |
821 |
{ |
3149 |
26 Feb 15 |
nicklas |
hasModified = true; |
3149 |
26 Feb 15 |
nicklas |
specimen.newBioWell = w; |
3151 |
26 Feb 15 |
nicklas |
Doc.element('newlocation.'+i).innerHTML = partition.toLocation(w); |
5933 |
08 May 20 |
nicklas |
Doc.addClass('newlocation.'+i, 'updated-location'); |
3149 |
26 Feb 15 |
nicklas |
826 |
} |
3149 |
26 Feb 15 |
nicklas |
827 |
} |
3149 |
26 Feb 15 |
nicklas |
828 |
} |
3149 |
26 Feb 15 |
nicklas |
829 |
|
3149 |
26 Feb 15 |
nicklas |
if (hasModified) |
3149 |
26 Feb 15 |
nicklas |
831 |
{ |
3149 |
26 Feb 15 |
nicklas |
Wizard.showGoNextConfirmation(true, 'Positions for re-extraction specimen has been updated. Confirm new positions before registration!'); |
3149 |
26 Feb 15 |
nicklas |
833 |
} |
3149 |
26 Feb 15 |
nicklas |
else |
3149 |
26 Feb 15 |
nicklas |
835 |
{ |
3149 |
26 Feb 15 |
nicklas |
Wizard.goRegister(); |
3149 |
26 Feb 15 |
nicklas |
837 |
} |
3149 |
26 Feb 15 |
nicklas |
838 |
} |
3149 |
26 Feb 15 |
nicklas |
839 |
|
3149 |
26 Feb 15 |
nicklas |
840 |
|
2740 |
06 Oct 14 |
nicklas |
partition.submit = function() |
2740 |
06 Oct 14 |
nicklas |
842 |
{ |
2740 |
06 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2740 |
06 Oct 14 |
nicklas |
844 |
|
2740 |
06 Oct 14 |
nicklas |
var submitInfo = {}; |
2740 |
06 Oct 14 |
nicklas |
submitInfo.partitionDate = frm.partitionDate.value; |
2740 |
06 Oct 14 |
nicklas |
847 |
|
2740 |
06 Oct 14 |
nicklas |
var specimens = []; |
2740 |
06 Oct 14 |
nicklas |
for (var i = 0; i < selectedSpecimen.length; i++) |
2740 |
06 Oct 14 |
nicklas |
850 |
{ |
2740 |
06 Oct 14 |
nicklas |
var specimen = selectedSpecimen[i]; |
2740 |
06 Oct 14 |
nicklas |
852 |
|
2740 |
06 Oct 14 |
nicklas |
specimen.spWeight = parseFloat(frm['spWeight.'+i].value) || null; |
2740 |
06 Oct 14 |
nicklas |
specimen.apWeight = parseFloat(frm['apWeight.'+i].value) || null; |
2740 |
06 Oct 14 |
nicklas |
specimen.hisWeight = parseFloat(frm['hisWeight.'+i].value) || null; |
2740 |
06 Oct 14 |
nicklas |
specimen.multPieces = frm['multPieces.'+i].checked; |
2740 |
06 Oct 14 |
nicklas |
857 |
|
5335 |
28 Mar 19 |
nicklas |
if (specimen.firstExtraction) |
3149 |
26 Feb 15 |
nicklas |
859 |
{ |
3149 |
26 Feb 15 |
nicklas |
specimen.nofPieces = parseInt(frm['nofPieces.'+i].value); |
3149 |
26 Feb 15 |
nicklas |
// Generate partition comment string |
3149 |
26 Feb 15 |
nicklas |
var comment = []; |
3149 |
26 Feb 15 |
nicklas |
if (frm['bloody.'+i].checked) comment[comment.length] = 'BLOODY'; |
3149 |
26 Feb 15 |
nicklas |
if (frm['appearance.'+i].selectedIndex > 0) comment[comment.length] = frm['appearance.'+i].value; |
3149 |
26 Feb 15 |
nicklas |
if (frm['fat.'+i].selectedIndex > 0) comment[comment.length] = 'FAT'+frm['fat.'+i].value+'%'; |
3149 |
26 Feb 15 |
nicklas |
if (frm['coloured.'+i].checked) comment[comment.length] = 'COLOURED'; |
3149 |
26 Feb 15 |
nicklas |
specimen.operatorPartitionComment = comment.length > 0 ? comment.join(';') : null; |
3149 |
26 Feb 15 |
nicklas |
868 |
} |
3149 |
26 Feb 15 |
nicklas |
869 |
|
2740 |
06 Oct 14 |
nicklas |
specimens[i] = specimen; |
2740 |
06 Oct 14 |
nicklas |
871 |
} |
2740 |
06 Oct 14 |
nicklas |
submitInfo.specimens = specimens; |
2740 |
06 Oct 14 |
nicklas |
873 |
|
2740 |
06 Oct 14 |
nicklas |
var url = '../PartitionRegistration.servlet?ID='+App.getSessionId(); |
2740 |
06 Oct 14 |
nicklas |
url += '&cmd=CreatePartitions'; |
2740 |
06 Oct 14 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
2740 |
06 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, partition.submissionResults, 'POST', JSON.stringify(submitInfo)); |
2740 |
06 Oct 14 |
nicklas |
878 |
} |
2740 |
06 Oct 14 |
nicklas |
879 |
|
2740 |
06 Oct 14 |
nicklas |
partition.submissionResults = function(response) |
2740 |
06 Oct 14 |
nicklas |
881 |
{ |
2740 |
06 Oct 14 |
nicklas |
for (var i = 0; i < response.partitioned.length; i++) |
2740 |
06 Oct 14 |
nicklas |
883 |
{ |
2740 |
06 Oct 14 |
nicklas |
partition.removeFromLocalStorage(response.partitioned[i]); |
2740 |
06 Oct 14 |
nicklas |
885 |
} |
2740 |
06 Oct 14 |
nicklas |
886 |
|
2740 |
06 Oct 14 |
nicklas |
Wizard.showFinalMessage(response.messages); |
2740 |
06 Oct 14 |
nicklas |
Doc.show('gorestart'); |
2740 |
06 Oct 14 |
nicklas |
889 |
} |
2740 |
06 Oct 14 |
nicklas |
890 |
|
2740 |
06 Oct 14 |
nicklas |
891 |
|
2740 |
06 Oct 14 |
nicklas |
892 |
/** |
2740 |
06 Oct 14 |
nicklas |
Save as much information as possible about the partitioned |
2740 |
06 Oct 14 |
nicklas |
specimen tube. The information is stored in the localStorage() |
2740 |
06 Oct 14 |
nicklas |
under the key 'reggie.specimen.<id>.partitionInfo' where |
2740 |
06 Oct 14 |
nicklas |
<id> is the ID of the specimen tube. |
2740 |
06 Oct 14 |
nicklas |
897 |
*/ |
2740 |
06 Oct 14 |
nicklas |
partition.saveToLocalStorage = function(event) |
2740 |
06 Oct 14 |
nicklas |
899 |
{ |
2740 |
06 Oct 14 |
nicklas |
if (!isRestoringFromLocalStorage) |
2740 |
06 Oct 14 |
nicklas |
901 |
{ |
2740 |
06 Oct 14 |
nicklas |
var target = event.currentTarget; |
2740 |
06 Oct 14 |
nicklas |
var dotI = target.id.indexOf('.'); |
2740 |
06 Oct 14 |
nicklas |
var index = parseInt(target.id.substr(dotI+1)); |
2740 |
06 Oct 14 |
nicklas |
905 |
|
2740 |
06 Oct 14 |
nicklas |
var specimen = selectedSpecimen[index]; |
2740 |
06 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2740 |
06 Oct 14 |
nicklas |
908 |
|
2740 |
06 Oct 14 |
nicklas |
var info = {}; |
2740 |
06 Oct 14 |
nicklas |
info.id = specimen.id; |
5335 |
28 Mar 19 |
nicklas |
if (specimen.firstExtraction) |
3145 |
25 Feb 15 |
nicklas |
912 |
{ |
3145 |
25 Feb 15 |
nicklas |
info.bloody = frm['bloody.'+index].checked; |
3145 |
25 Feb 15 |
nicklas |
info.appearance = frm['appearance.'+index].value; |
3145 |
25 Feb 15 |
nicklas |
info.fat = frm['fat.'+index].value; |
3145 |
25 Feb 15 |
nicklas |
info.coloured = frm['coloured.'+index].checked; |
3145 |
25 Feb 15 |
nicklas |
info.nofPieces = frm['nofPieces.'+index].value; |
3145 |
25 Feb 15 |
nicklas |
918 |
} |
2740 |
06 Oct 14 |
nicklas |
info.spWeight = frm['spWeight.'+index].value; |
2740 |
06 Oct 14 |
nicklas |
info.hisWeight = frm['hisWeight.'+index].value; |
2740 |
06 Oct 14 |
nicklas |
info.apWeight = frm['apWeight.'+index].value; |
2740 |
06 Oct 14 |
nicklas |
info.multPieces = frm['multPieces.'+index].checked; |
2740 |
06 Oct 14 |
nicklas |
App.setLocal('reggie.specimen.' + specimen.id + '.partitionInfo', JSON.stringify(info)); |
2740 |
06 Oct 14 |
nicklas |
if (debug) |
2740 |
06 Oct 14 |
nicklas |
925 |
{ |
2740 |
06 Oct 14 |
nicklas |
App.debug(index + ': ' + App.getLocal('reggie.specimen.' + specimen.id + '.partitionInfo')); |
2740 |
06 Oct 14 |
nicklas |
927 |
} |
2740 |
06 Oct 14 |
nicklas |
928 |
} |
2740 |
06 Oct 14 |
nicklas |
929 |
} |
2740 |
06 Oct 14 |
nicklas |
930 |
|
2740 |
06 Oct 14 |
nicklas |
partition.removeFromLocalStorage = function(specimenId) |
2740 |
06 Oct 14 |
nicklas |
932 |
{ |
2740 |
06 Oct 14 |
nicklas |
App.removeLocal('reggie.specimen.' + specimenId + '.partitionInfo'); |
2740 |
06 Oct 14 |
nicklas |
934 |
} |
2740 |
06 Oct 14 |
nicklas |
935 |
|
2740 |
06 Oct 14 |
nicklas |
partition.getStoredInfo = function(specimenId) |
2740 |
06 Oct 14 |
nicklas |
937 |
{ |
2740 |
06 Oct 14 |
nicklas |
try |
2740 |
06 Oct 14 |
nicklas |
939 |
{ |
2740 |
06 Oct 14 |
nicklas |
var stored = App.getLocal('reggie.specimen.' + specimenId + '.partitionInfo'); |
2740 |
06 Oct 14 |
nicklas |
if (debug) App.debug(stored); |
2740 |
06 Oct 14 |
nicklas |
return stored ? JSON.parse(stored) : null; |
2740 |
06 Oct 14 |
nicklas |
943 |
} |
2740 |
06 Oct 14 |
nicklas |
catch (e) |
2740 |
06 Oct 14 |
nicklas |
945 |
{ |
2740 |
06 Oct 14 |
nicklas |
App.debug('Could not load stored information for tube ' + specimenId + ': ' + e); |
2740 |
06 Oct 14 |
nicklas |
947 |
} |
2740 |
06 Oct 14 |
nicklas |
948 |
} |
2740 |
06 Oct 14 |
nicklas |
949 |
|
2740 |
06 Oct 14 |
nicklas |
950 |
|
2740 |
06 Oct 14 |
nicklas |
return partition; |
2740 |
06 Oct 14 |
nicklas |
952 |
}(); |
2740 |
06 Oct 14 |
nicklas |
953 |
|
2740 |
06 Oct 14 |
nicklas |
Doc.onLoad(Partition.initPage); |
2740 |
06 Oct 14 |
nicklas |
955 |
|