5339 |
29 Mar 19 |
nicklas |
var StorePaused = function() |
5339 |
29 Mar 19 |
nicklas |
2 |
{ |
5339 |
29 Mar 19 |
nicklas |
var store = {}; |
5339 |
29 Mar 19 |
nicklas |
var debug = 0; |
5339 |
29 Mar 19 |
nicklas |
5 |
|
5339 |
29 Mar 19 |
nicklas |
var specimenTubes; |
5339 |
29 Mar 19 |
nicklas |
7 |
|
5339 |
29 Mar 19 |
nicklas |
// Page initialization |
5339 |
29 Mar 19 |
nicklas |
store.initPage = function() |
5339 |
29 Mar 19 |
nicklas |
10 |
{ |
5339 |
29 Mar 19 |
nicklas |
// Step 1 |
5339 |
29 Mar 19 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', store.validateStep1); |
5339 |
29 Mar 19 |
nicklas |
Buttons.addClickHandler('downloadLabelsCsv', store.downloadLabels); |
5339 |
29 Mar 19 |
nicklas |
Buttons.addClickHandler('downloadLabelsXlsx', store.downloadLabels); |
5339 |
29 Mar 19 |
nicklas |
15 |
|
5339 |
29 Mar 19 |
nicklas |
// Navigation |
5339 |
29 Mar 19 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
5339 |
29 Mar 19 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
5339 |
29 Mar 19 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
5339 |
29 Mar 19 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
5339 |
29 Mar 19 |
nicklas |
Buttons.addClickHandler('goprint', store.printPickList); |
5339 |
29 Mar 19 |
nicklas |
22 |
|
5339 |
29 Mar 19 |
nicklas |
// Final registration |
5339 |
29 Mar 19 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', store.submit); |
5339 |
29 Mar 19 |
nicklas |
25 |
|
5339 |
29 Mar 19 |
nicklas |
var url = '../SpecimenTubeRegistration.servlet?ID='+App.getSessionId(); |
5339 |
29 Mar 19 |
nicklas |
url += '&cmd=GetSpecimenTubesToStore'; |
5339 |
29 Mar 19 |
nicklas |
Wizard.showLoadingAnimation('Loading specimen tube information...'); |
5339 |
29 Mar 19 |
nicklas |
Wizard.asyncJsonRequest(url, store.initializeStep1); |
5339 |
29 Mar 19 |
nicklas |
30 |
} |
5339 |
29 Mar 19 |
nicklas |
31 |
|
5339 |
29 Mar 19 |
nicklas |
store.initializeStep1 = function(response) |
5339 |
29 Mar 19 |
nicklas |
33 |
{ |
5339 |
29 Mar 19 |
nicklas |
specimenTubes = response.specimenTubes; |
5339 |
29 Mar 19 |
nicklas |
35 |
|
5339 |
29 Mar 19 |
nicklas |
if (!specimenTubes || specimenTubes.length == 0) |
5339 |
29 Mar 19 |
nicklas |
37 |
{ |
5339 |
29 Mar 19 |
nicklas |
Wizard.setFatalError('No specimen tubes available for storing.'); |
5339 |
29 Mar 19 |
nicklas |
return; |
5339 |
29 Mar 19 |
nicklas |
40 |
} |
5339 |
29 Mar 19 |
nicklas |
41 |
|
5339 |
29 Mar 19 |
nicklas |
var html = '<table id="specimenTable">'; |
5339 |
29 Mar 19 |
nicklas |
html += '<thead class="bg-filled-100">'; |
5339 |
29 Mar 19 |
nicklas |
// First header row |
5339 |
29 Mar 19 |
nicklas |
html += '<tr>'; |
5339 |
29 Mar 19 |
nicklas |
html += '<th>Specimen</th>'; |
5339 |
29 Mar 19 |
nicklas |
html += '<th>Arrival date</th>'; |
5339 |
29 Mar 19 |
nicklas |
html += '<th>Storage box</th>'; |
5339 |
29 Mar 19 |
nicklas |
html += '<th>Freezer</th>'; |
5339 |
29 Mar 19 |
nicklas |
html += '<th>Remark</th>'; |
5339 |
29 Mar 19 |
nicklas |
html += '</tr>'; |
5339 |
29 Mar 19 |
nicklas |
html += '</thead>'; |
5339 |
29 Mar 19 |
nicklas |
html += '<tbody>'; |
5339 |
29 Mar 19 |
nicklas |
54 |
|
5339 |
29 Mar 19 |
nicklas |
var homeUrl = Data.get('page-data', 'home-url'); |
5339 |
29 Mar 19 |
nicklas |
var yellowImg = '<img src="'+homeUrl+'/images/yellow-label.png">'; |
5339 |
29 Mar 19 |
nicklas |
for (var i=0; i < specimenTubes.length; i++) |
5339 |
29 Mar 19 |
nicklas |
58 |
{ |
5339 |
29 Mar 19 |
nicklas |
var specimen = specimenTubes[i]; |
5339 |
29 Mar 19 |
nicklas |
var well = specimen.bioWell; |
5339 |
29 Mar 19 |
nicklas |
var plate = well.bioPlate; |
5339 |
29 Mar 19 |
nicklas |
var storage = plate.storage; |
5339 |
29 Mar 19 |
nicklas |
var isYellow = specimen.specimen && specimen.specimen.YellowLabel != null; |
5339 |
29 Mar 19 |
nicklas |
64 |
|
5339 |
29 Mar 19 |
nicklas |
var freezerLocation = []; |
5339 |
29 Mar 19 |
nicklas |
if (storage.section) freezerLocation[freezerLocation.length] = 'Section ' + storage.section; |
5339 |
29 Mar 19 |
nicklas |
if (storage.tray) freezerLocation[freezerLocation.length] = 'Tray ' + storage.tray; |
5339 |
29 Mar 19 |
nicklas |
if (storage.position) freezerLocation[freezerLocation.length] = 'Position ' + storage.position; |
5339 |
29 Mar 19 |
nicklas |
69 |
|
5339 |
29 Mar 19 |
nicklas |
70 |
|
5339 |
29 Mar 19 |
nicklas |
var img = isYellow ? yellowImg : ''; |
5339 |
29 Mar 19 |
nicklas |
html += '<tr class="highlight'+(isYellow ? ' yellow-specimen' : '')+'">'; |
5339 |
29 Mar 19 |
nicklas |
html += '<td class="specimen if-yellow">'+img+Strings.encodeTags(specimen.name)+'</td>'; |
5339 |
29 Mar 19 |
nicklas |
html += '<td class="arrivaldate">'+Reggie.reformatDate(specimen.ArrivalDate)+'</td>'; |
5339 |
29 Mar 19 |
nicklas |
html += '<td class="box">'+Strings.encodeTags(plate.name+' '+well.location)+'</td>'; |
5339 |
29 Mar 19 |
nicklas |
html += '<td class="location">'+Strings.encodeTags(storage.name)+'<br>'+Strings.encodeTags(freezerLocation.join(', '))+'</td>'; |
5339 |
29 Mar 19 |
nicklas |
html += '<td class="remarks"></td>'; |
5339 |
29 Mar 19 |
nicklas |
html += '</tr>' |
5339 |
29 Mar 19 |
nicklas |
79 |
} |
5339 |
29 Mar 19 |
nicklas |
html += '</tbody>'; |
5339 |
29 Mar 19 |
nicklas |
html += '</table>'; |
5339 |
29 Mar 19 |
nicklas |
82 |
|
5339 |
29 Mar 19 |
nicklas |
Doc.element('specimenList').innerHTML = html; |
5339 |
29 Mar 19 |
nicklas |
84 |
|
5339 |
29 Mar 19 |
nicklas |
Doc.show('step-1'); |
5339 |
29 Mar 19 |
nicklas |
Doc.show('goregister'); |
5339 |
29 Mar 19 |
nicklas |
Doc.show('goprint'); |
5339 |
29 Mar 19 |
nicklas |
Wizard.showGoNextConfirmation(true, 'If needed, print the protocol before registering!'); |
5339 |
29 Mar 19 |
nicklas |
89 |
} |
5339 |
29 Mar 19 |
nicklas |
90 |
|
5339 |
29 Mar 19 |
nicklas |
91 |
|
5339 |
29 Mar 19 |
nicklas |
store.downloadLabels = function(event) |
5339 |
29 Mar 19 |
nicklas |
93 |
{ |
5339 |
29 Mar 19 |
nicklas |
var format = Data.get(event.currentTarget, 'format'); |
5339 |
29 Mar 19 |
nicklas |
var specimen = []; |
5339 |
29 Mar 19 |
nicklas |
for (var i = 0; i < specimenTubes.length; i++) |
5339 |
29 Mar 19 |
nicklas |
97 |
{ |
5339 |
29 Mar 19 |
nicklas |
specimen[specimen.length] = specimenTubes[i].id; |
5339 |
29 Mar 19 |
nicklas |
99 |
} |
5339 |
29 Mar 19 |
nicklas |
100 |
|
5339 |
29 Mar 19 |
nicklas |
var url = '../SpecimenTubeRegistration.servlet?ID='+App.getSessionId(); |
5339 |
29 Mar 19 |
nicklas |
url += '&cmd=GetSpecimenTubeLabels'; |
5339 |
29 Mar 19 |
nicklas |
url += '&specimen=' + encodeURIComponent(specimen.join(',')); |
5339 |
29 Mar 19 |
nicklas |
url += '&format='+encodeURIComponent(format); |
5339 |
29 Mar 19 |
nicklas |
window.open(url); |
5339 |
29 Mar 19 |
nicklas |
106 |
} |
5339 |
29 Mar 19 |
nicklas |
107 |
|
5339 |
29 Mar 19 |
nicklas |
108 |
|
5339 |
29 Mar 19 |
nicklas |
store.printPickList = function() |
5339 |
29 Mar 19 |
nicklas |
110 |
{ |
5339 |
29 Mar 19 |
nicklas |
Wizard.hideGoNextConfirmation(); |
5339 |
29 Mar 19 |
nicklas |
Doc.removeClass('goregister', 'disabled'); |
5339 |
29 Mar 19 |
nicklas |
var reportName = 'Pick-list protocol for lysate re-extraction'; |
5339 |
29 Mar 19 |
nicklas |
var printNote = '<b>Note!</b> For better printing set page orientation to <i>portrait</i>.'; |
5339 |
29 Mar 19 |
nicklas |
Reggie.openPrintWindow('full-protocol', reportName, 'portrait', printNote, '../', 'store_paused.css'); |
5339 |
29 Mar 19 |
nicklas |
116 |
} |
5339 |
29 Mar 19 |
nicklas |
117 |
|
5339 |
29 Mar 19 |
nicklas |
store.submit = function() |
5339 |
29 Mar 19 |
nicklas |
119 |
{ |
5339 |
29 Mar 19 |
nicklas |
var specimen = []; |
5339 |
29 Mar 19 |
nicklas |
for (var i = 0; i < specimenTubes.length; i++) |
5339 |
29 Mar 19 |
nicklas |
122 |
{ |
5339 |
29 Mar 19 |
nicklas |
specimen[specimen.length] = specimenTubes[i].id; |
5339 |
29 Mar 19 |
nicklas |
124 |
} |
5339 |
29 Mar 19 |
nicklas |
125 |
|
5339 |
29 Mar 19 |
nicklas |
var submitInfo = {}; |
5339 |
29 Mar 19 |
nicklas |
submitInfo.specimen = specimen; |
5339 |
29 Mar 19 |
nicklas |
128 |
|
5339 |
29 Mar 19 |
nicklas |
var url = '../SpecimenTubeRegistration.servlet?ID='+App.getSessionId(); |
5339 |
29 Mar 19 |
nicklas |
url += '&cmd=RegisterPausedSpecimen'; |
5339 |
29 Mar 19 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
5339 |
29 Mar 19 |
nicklas |
Wizard.asyncJsonRequest(url, store.submissionResults, 'POST', JSON.stringify(submitInfo)); |
5339 |
29 Mar 19 |
nicklas |
133 |
} |
5339 |
29 Mar 19 |
nicklas |
134 |
|
5339 |
29 Mar 19 |
nicklas |
store.submissionResults = function(response) |
5339 |
29 Mar 19 |
nicklas |
136 |
{ |
5339 |
29 Mar 19 |
nicklas |
Wizard.showFinalMessage(response.messages); |
5339 |
29 Mar 19 |
nicklas |
Doc.show('gorestart'); |
5339 |
29 Mar 19 |
nicklas |
139 |
} |
5339 |
29 Mar 19 |
nicklas |
140 |
|
5339 |
29 Mar 19 |
nicklas |
return store; |
5339 |
29 Mar 19 |
nicklas |
142 |
}(); |
5339 |
29 Mar 19 |
nicklas |
143 |
|
5339 |
29 Mar 19 |
nicklas |
Doc.onLoad(StorePaused.initPage); |
5339 |
29 Mar 19 |
nicklas |
145 |
|