2604 |
27 Aug 14 |
nicklas |
var Xport = function() |
2604 |
27 Aug 14 |
nicklas |
2 |
{ |
2604 |
27 Aug 14 |
nicklas |
var xport = {}; |
2604 |
27 Aug 14 |
nicklas |
var previewTitle; |
2604 |
27 Aug 14 |
nicklas |
var previewList; |
2604 |
27 Aug 14 |
nicklas |
6 |
|
2604 |
27 Aug 14 |
nicklas |
xport.initPage = function() |
2604 |
27 Aug 14 |
nicklas |
8 |
{ |
2604 |
27 Aug 14 |
nicklas |
previewTitle = Doc.element('previewTitle'); |
2604 |
27 Aug 14 |
nicklas |
previewList = Doc.element('previewList'); |
2604 |
27 Aug 14 |
nicklas |
11 |
|
2604 |
27 Aug 14 |
nicklas |
Buttons.addClickHandler('goexport', xport.goExport); |
2604 |
27 Aug 14 |
nicklas |
Buttons.addClickHandler('gopreview', xport.goPreview); |
2604 |
27 Aug 14 |
nicklas |
14 |
|
2604 |
27 Aug 14 |
nicklas |
Doc.show('step-1'); |
2604 |
27 Aug 14 |
nicklas |
Doc.show('gopreview'); |
2604 |
27 Aug 14 |
nicklas |
Doc.show('goexport'); |
2604 |
27 Aug 14 |
nicklas |
18 |
} |
2604 |
27 Aug 14 |
nicklas |
19 |
|
2604 |
27 Aug 14 |
nicklas |
xport.goPreview = function() |
2604 |
27 Aug 14 |
nicklas |
21 |
{ |
2604 |
27 Aug 14 |
nicklas |
xport.doExport(true); |
2604 |
27 Aug 14 |
nicklas |
23 |
} |
2604 |
27 Aug 14 |
nicklas |
24 |
|
2604 |
27 Aug 14 |
nicklas |
xport.goExport = function() |
2604 |
27 Aug 14 |
nicklas |
26 |
{ |
2604 |
27 Aug 14 |
nicklas |
xport.doExport(false); |
2604 |
27 Aug 14 |
nicklas |
28 |
} |
2604 |
27 Aug 14 |
nicklas |
29 |
|
2604 |
27 Aug 14 |
nicklas |
xport.doExport = function(preview) |
2604 |
27 Aug 14 |
nicklas |
31 |
{ |
2604 |
27 Aug 14 |
nicklas |
var url = '../Export.servlet?ID='+App.getSessionId(); |
2604 |
27 Aug 14 |
nicklas |
url += '&cmd=ExportMissingConsentDataSampleList'; |
3914 |
02 May 16 |
nicklas |
url += '&progressbar=export-missing-consent-progress'; |
2604 |
27 Aug 14 |
nicklas |
35 |
|
3914 |
02 May 16 |
nicklas |
Wizard.showLoadingAnimation('Working...', 'export-missing-consent-progress'); |
3914 |
02 May 16 |
nicklas |
Doc.hide('navigation'); |
3914 |
02 May 16 |
nicklas |
Doc.hide('previewWrapper'); |
3914 |
02 May 16 |
nicklas |
39 |
|
2604 |
27 Aug 14 |
nicklas |
if (preview) |
2604 |
27 Aug 14 |
nicklas |
41 |
{ |
2604 |
27 Aug 14 |
nicklas |
url += '&preview=1'; |
2604 |
27 Aug 14 |
nicklas |
Wizard.asyncJsonRequest(url, xport.onPreviewLoaded); |
2604 |
27 Aug 14 |
nicklas |
44 |
} |
2604 |
27 Aug 14 |
nicklas |
else |
2604 |
27 Aug 14 |
nicklas |
46 |
{ |
2604 |
27 Aug 14 |
nicklas |
window.location = url; |
2604 |
27 Aug 14 |
nicklas |
48 |
} |
2604 |
27 Aug 14 |
nicklas |
49 |
} |
2604 |
27 Aug 14 |
nicklas |
50 |
|
2604 |
27 Aug 14 |
nicklas |
xport.onPreviewLoaded = function(response) |
2604 |
27 Aug 14 |
nicklas |
52 |
{ |
2604 |
27 Aug 14 |
nicklas |
Doc.show('navigation'); |
2604 |
27 Aug 14 |
nicklas |
54 |
|
2604 |
27 Aug 14 |
nicklas |
var allLines = response.split('\n'); |
2604 |
27 Aug 14 |
nicklas |
var numCases = allLines.length - 2; // First line is a header line |
2604 |
27 Aug 14 |
nicklas |
57 |
|
2604 |
27 Aug 14 |
nicklas |
var html = '<tr><th>'+allLines[0].replace(/\t/g, '</th><th>')+'</th></tr>'; |
2604 |
27 Aug 14 |
nicklas |
// Check last column for the 'Consent' value |
2604 |
27 Aug 14 |
nicklas |
var numConsentWithoutDate = 0; |
2604 |
27 Aug 14 |
nicklas |
var numMissingConsent = 0; |
2604 |
27 Aug 14 |
nicklas |
var numYesConsent = 0; |
2604 |
27 Aug 14 |
nicklas |
var numNoConsent = 0; |
2604 |
27 Aug 14 |
nicklas |
var numNotAskedConsent = 0; |
2604 |
27 Aug 14 |
nicklas |
for (var i = 1 ; i <= numCases; i++) |
2604 |
27 Aug 14 |
nicklas |
66 |
{ |
2604 |
27 Aug 14 |
nicklas |
var line = allLines[i]; |
2604 |
27 Aug 14 |
nicklas |
var cols = line.split(/\t/); |
2604 |
27 Aug 14 |
nicklas |
var consent = cols[cols.length-1]; |
2604 |
27 Aug 14 |
nicklas |
var rowClass = ''; |
2604 |
27 Aug 14 |
nicklas |
if (consent == null || consent == 'null') |
2604 |
27 Aug 14 |
nicklas |
72 |
{ |
2604 |
27 Aug 14 |
nicklas |
rowClass = 'consent-warning'; |
2604 |
27 Aug 14 |
nicklas |
numMissingConsent++; |
2604 |
27 Aug 14 |
nicklas |
75 |
} |
2604 |
27 Aug 14 |
nicklas |
else if (consent == 'Yes') |
2604 |
27 Aug 14 |
nicklas |
77 |
{ |
2604 |
27 Aug 14 |
nicklas |
numYesConsent++; |
2604 |
27 Aug 14 |
nicklas |
79 |
} |
2604 |
27 Aug 14 |
nicklas |
else if (consent == 'No') |
2604 |
27 Aug 14 |
nicklas |
81 |
{ |
2604 |
27 Aug 14 |
nicklas |
numNoConsent++; |
2604 |
27 Aug 14 |
nicklas |
83 |
} |
2604 |
27 Aug 14 |
nicklas |
else if (consent == 'Not asked') |
2604 |
27 Aug 14 |
nicklas |
85 |
{ |
2604 |
27 Aug 14 |
nicklas |
numNotAskedConsent++; |
2604 |
27 Aug 14 |
nicklas |
87 |
} |
2604 |
27 Aug 14 |
nicklas |
html += '<tr class="'+rowClass+'"><td>'+cols.join('</td><td>')+'</td></tr>'; |
2604 |
27 Aug 14 |
nicklas |
89 |
} |
2604 |
27 Aug 14 |
nicklas |
numConsentWithoutDate = numCases - numMissingConsent; |
2604 |
27 Aug 14 |
nicklas |
91 |
|
2604 |
27 Aug 14 |
nicklas |
previewTitle.innerHTML = numCases + ' Samples = ' + numConsentWithoutDate + ' unknown date (' + numYesConsent + ' Yes, ' + numNoConsent + ' No, ' + numNotAskedConsent + ' Not asked) + ' + numMissingConsent + ' missing consent'; |
2604 |
27 Aug 14 |
nicklas |
previewList.innerHTML = '<table>'+html+'</table>'; |
2604 |
27 Aug 14 |
nicklas |
Doc.show('previewWrapper'); |
2604 |
27 Aug 14 |
nicklas |
95 |
} |
2604 |
27 Aug 14 |
nicklas |
96 |
|
2604 |
27 Aug 14 |
nicklas |
return xport; |
2604 |
27 Aug 14 |
nicklas |
98 |
}(); |
2604 |
27 Aug 14 |
nicklas |
99 |
|
2604 |
27 Aug 14 |
nicklas |
Doc.onLoad(Xport.initPage); |
2604 |
27 Aug 14 |
nicklas |
101 |
|