2839 |
20 Oct 14 |
olle |
var RetractionProtocol = function() |
2839 |
20 Oct 14 |
olle |
2 |
{ |
2839 |
20 Oct 14 |
olle |
var rp = {}; |
2839 |
20 Oct 14 |
olle |
var debug = 0; |
6731 |
05 May 22 |
nicklas |
var showLabelColumn = false; |
2839 |
20 Oct 14 |
olle |
6 |
|
2839 |
20 Oct 14 |
olle |
// Page initialization |
2839 |
20 Oct 14 |
olle |
rp.initPage = function() |
2839 |
20 Oct 14 |
olle |
9 |
{ |
2839 |
20 Oct 14 |
olle |
Buttons.addClickHandler('print-button', Wizard.goPrint); |
3323 |
11 May 15 |
nicklas |
var url = '../Retraction.servlet?ID='+App.getSessionId(); |
2839 |
20 Oct 14 |
olle |
url += '&cmd=GetProtocolInfo'; |
5639 |
03 Oct 19 |
nicklas |
url += '&caseName=' + encodeURIComponent(Data.get('page-data', 'casename')); |
5639 |
03 Oct 19 |
nicklas |
url += '&patientId=' + encodeURIComponent(Data.get('page-data', 'patient-id')); |
2839 |
20 Oct 14 |
olle |
Wizard.showLoadingAnimation('Creating protocol...'); |
2839 |
20 Oct 14 |
olle |
Wizard.asyncJsonRequest(url, rp.initializeProtocol); |
2839 |
20 Oct 14 |
olle |
17 |
} |
2839 |
20 Oct 14 |
olle |
18 |
|
2839 |
20 Oct 14 |
olle |
rp.initializeProtocol = function(response) |
2839 |
20 Oct 14 |
olle |
20 |
{ |
2839 |
20 Oct 14 |
olle |
var patientInfo = response.patient; |
2839 |
20 Oct 14 |
olle |
22 |
|
5639 |
03 Oct 19 |
nicklas |
// Patient and case info |
4312 |
18 Jan 17 |
nicklas |
var patientName = patientInfo ? patientInfo.name : 'No patient information is registered for this case.'; |
5639 |
03 Oct 19 |
nicklas |
Doc.element('patient').innerHTML = Strings.encodeTags(patientName); |
5639 |
03 Oct 19 |
nicklas |
Doc.element('allcases').innerHTML = Strings.encodeTags(response.allCaseNames.join(', ')); |
2839 |
20 Oct 14 |
olle |
27 |
|
2839 |
20 Oct 14 |
olle |
// Item data |
5639 |
03 Oct 19 |
nicklas |
var html = ''; |
5639 |
03 Oct 19 |
nicklas |
html += rp.tableRowsForItems('Specimen', response.specimen); |
5639 |
03 Oct 19 |
nicklas |
html += rp.tableRowsForItems('Lysate', response.lysate); |
5639 |
03 Oct 19 |
nicklas |
html += rp.tableRowsForItems('RNA', response.rna); |
5639 |
03 Oct 19 |
nicklas |
html += rp.tableRowsForItems('DNA', response.dna); |
5639 |
03 Oct 19 |
nicklas |
html += rp.tableRowsForItems('FlowThrough', response.flowThrough); |
5639 |
03 Oct 19 |
nicklas |
html += rp.tableRowsForItems('BloodDNA', response.bloodDna); |
5639 |
03 Oct 19 |
nicklas |
Doc.element('itemList').innerHTML = html; |
5639 |
03 Oct 19 |
nicklas |
37 |
|
6731 |
05 May 22 |
nicklas |
if (showLabelColumn) |
6731 |
05 May 22 |
nicklas |
39 |
{ |
6731 |
05 May 22 |
nicklas |
Doc.removeClass('itemTable', 'nolabels'); |
6731 |
05 May 22 |
nicklas |
Doc.show('protocol-footer'); |
6731 |
05 May 22 |
nicklas |
42 |
} |
6731 |
05 May 22 |
nicklas |
43 |
|
2839 |
20 Oct 14 |
olle |
Doc.show('all-protocol'); |
2839 |
20 Oct 14 |
olle |
45 |
} |
2839 |
20 Oct 14 |
olle |
46 |
|
5639 |
03 Oct 19 |
nicklas |
rp.tableRowsForItems = function(itemType, items) |
2839 |
20 Oct 14 |
olle |
48 |
{ |
5639 |
03 Oct 19 |
nicklas |
if (!items || items.length == 0) return ''; |
2839 |
20 Oct 14 |
olle |
// Table item row |
2839 |
20 Oct 14 |
olle |
var html = ''; |
5639 |
03 Oct 19 |
nicklas |
for (var itemNo = 0; itemNo < items.length; itemNo++) |
2839 |
20 Oct 14 |
olle |
53 |
{ |
5639 |
03 Oct 19 |
nicklas |
var item = items[itemNo]; |
5642 |
04 Oct 19 |
nicklas |
var isDestroyed = item.RetractStatus == 'Destroyed'; |
6731 |
05 May 22 |
nicklas |
if (item.label) showLabelColumn = true; |
5639 |
03 Oct 19 |
nicklas |
57 |
|
5642 |
04 Oct 19 |
nicklas |
html += '<tr class="'+(isDestroyed ? 'destroyed' : '')+'">'; |
5639 |
03 Oct 19 |
nicklas |
html += '<td>'+itemType+'</td>'; |
5639 |
03 Oct 19 |
nicklas |
html += '<td>'+Strings.encodeTags(item.name)+'</td>'; |
6731 |
05 May 22 |
nicklas |
html += '<td class="label">'+Strings.encodeTags(item.label)+'</td>'; |
5639 |
03 Oct 19 |
nicklas |
html += '<td>'+rp.asBoxPosition(item.bioWell)+'</td>'; |
5639 |
03 Oct 19 |
nicklas |
html += '<td>'+rp.asFreezerLocation(item.bioWell)+'</td>'; |
5642 |
04 Oct 19 |
nicklas |
if (isDestroyed) |
5642 |
04 Oct 19 |
nicklas |
65 |
{ |
5642 |
04 Oct 19 |
nicklas |
html += '<td>Already destroyed</td>'; |
5642 |
04 Oct 19 |
nicklas |
67 |
} |
5642 |
04 Oct 19 |
nicklas |
else |
5642 |
04 Oct 19 |
nicklas |
69 |
{ |
5642 |
04 Oct 19 |
nicklas |
html += '<td><div class="colorbox"></div>Destroyed</td>'; |
5642 |
04 Oct 19 |
nicklas |
71 |
} |
5639 |
03 Oct 19 |
nicklas |
html += '</tr>'; |
2839 |
20 Oct 14 |
olle |
73 |
} |
5639 |
03 Oct 19 |
nicklas |
return html; |
2839 |
20 Oct 14 |
olle |
75 |
} |
2839 |
20 Oct 14 |
olle |
76 |
|
2839 |
20 Oct 14 |
olle |
// A biowell as plate name |
5639 |
03 Oct 19 |
nicklas |
rp.asBoxPosition = function(well) |
2839 |
20 Oct 14 |
olle |
79 |
{ |
2839 |
20 Oct 14 |
olle |
if (!well) return ''; |
2839 |
20 Oct 14 |
olle |
var plate = well.bioPlate; |
5639 |
03 Oct 19 |
nicklas |
return Strings.encodeTags(plate.name + ' ' + well.location); |
2839 |
20 Oct 14 |
olle |
83 |
} |
2839 |
20 Oct 14 |
olle |
84 |
|
2839 |
20 Oct 14 |
olle |
// A biowell as the location |
5639 |
03 Oct 19 |
nicklas |
rp.asFreezerLocation = function(well) |
2839 |
20 Oct 14 |
olle |
87 |
{ |
5639 |
03 Oct 19 |
nicklas |
if (!well) return '<i>- unknown -</i>'; |
5639 |
03 Oct 19 |
nicklas |
var storage = well.bioPlate.storage; |
5639 |
03 Oct 19 |
nicklas |
if (!storage) return '<i>- unknown -</i>'; |
5639 |
03 Oct 19 |
nicklas |
91 |
|
5639 |
03 Oct 19 |
nicklas |
var location = []; |
5639 |
03 Oct 19 |
nicklas |
if (storage.name) location[location.length] = storage.name; |
5639 |
03 Oct 19 |
nicklas |
if (storage.section) location[location.length] = 'Section ' +storage.section; |
5639 |
03 Oct 19 |
nicklas |
if (storage.tray) location[location.length] = 'Tray ' +storage.tray; |
5639 |
03 Oct 19 |
nicklas |
if (storage.position) location[location.length] = 'Position ' +storage.position; |
5639 |
03 Oct 19 |
nicklas |
97 |
|
5639 |
03 Oct 19 |
nicklas |
return location.join(', '); |
2839 |
20 Oct 14 |
olle |
99 |
} |
2839 |
20 Oct 14 |
olle |
100 |
|
2839 |
20 Oct 14 |
olle |
return rp; |
2839 |
20 Oct 14 |
olle |
102 |
}(); |
2839 |
20 Oct 14 |
olle |
103 |
|
2839 |
20 Oct 14 |
olle |
Doc.onLoad(RetractionProtocol.initPage); |
2839 |
20 Oct 14 |
olle |
105 |
|