2374 |
23 Apr 14 |
nicklas |
var Xport = function() |
2374 |
23 Apr 14 |
nicklas |
2 |
{ |
2374 |
23 Apr 14 |
nicklas |
var xport = {}; |
2374 |
23 Apr 14 |
nicklas |
var previewTitle; |
2374 |
23 Apr 14 |
nicklas |
var previewList; |
2374 |
23 Apr 14 |
nicklas |
6 |
|
2374 |
23 Apr 14 |
nicklas |
xport.initPage = function() |
2374 |
23 Apr 14 |
nicklas |
8 |
{ |
2374 |
23 Apr 14 |
nicklas |
previewTitle = Doc.element('previewTitle'); |
2374 |
23 Apr 14 |
nicklas |
previewList = Doc.element('previewList'); |
2374 |
23 Apr 14 |
nicklas |
11 |
|
2374 |
23 Apr 14 |
nicklas |
Buttons.addClickHandler('goexport', xport.goExport); |
2374 |
23 Apr 14 |
nicklas |
Buttons.addClickHandler('gopreview', xport.goPreview); |
2603 |
27 Aug 14 |
nicklas |
14 |
|
2603 |
27 Aug 14 |
nicklas |
Doc.show('step-1'); |
2603 |
27 Aug 14 |
nicklas |
Doc.show('gopreview'); |
2603 |
27 Aug 14 |
nicklas |
Doc.show('goexport'); |
2374 |
23 Apr 14 |
nicklas |
18 |
} |
2374 |
23 Apr 14 |
nicklas |
19 |
|
2374 |
23 Apr 14 |
nicklas |
xport.goPreview = function() |
2374 |
23 Apr 14 |
nicklas |
21 |
{ |
2374 |
23 Apr 14 |
nicklas |
xport.doExport(true); |
2374 |
23 Apr 14 |
nicklas |
23 |
} |
2374 |
23 Apr 14 |
nicklas |
24 |
|
2374 |
23 Apr 14 |
nicklas |
xport.goExport = function() |
2374 |
23 Apr 14 |
nicklas |
26 |
{ |
2374 |
23 Apr 14 |
nicklas |
xport.doExport(false); |
2374 |
23 Apr 14 |
nicklas |
28 |
} |
2374 |
23 Apr 14 |
nicklas |
29 |
|
2374 |
23 Apr 14 |
nicklas |
xport.doExport = function(preview) |
2374 |
23 Apr 14 |
nicklas |
31 |
{ |
2374 |
23 Apr 14 |
nicklas |
var frm = document.forms['reggie']; |
2374 |
23 Apr 14 |
nicklas |
var url = '../Export.servlet?ID='+App.getSessionId(); |
2374 |
23 Apr 14 |
nicklas |
url += '&cmd=ExportMonthlyOpList'; |
2374 |
23 Apr 14 |
nicklas |
url += '&time=' + frm.time.value; |
2374 |
23 Apr 14 |
nicklas |
url += '&exportSubtype=0'; |
2374 |
23 Apr 14 |
nicklas |
url += '&exportPatientId=0'; |
2374 |
23 Apr 14 |
nicklas |
38 |
|
2374 |
23 Apr 14 |
nicklas |
if (preview) |
2374 |
23 Apr 14 |
nicklas |
40 |
{ |
2374 |
23 Apr 14 |
nicklas |
Doc.hide('previewWrapper'); |
2603 |
27 Aug 14 |
nicklas |
url += '&preview=1'; |
2374 |
23 Apr 14 |
nicklas |
43 |
|
2603 |
27 Aug 14 |
nicklas |
Wizard.showLoadingAnimation('Working...'); |
2603 |
27 Aug 14 |
nicklas |
Doc.hide('navigation'); |
2603 |
27 Aug 14 |
nicklas |
Wizard.asyncJsonRequest(url, xport.onPreviewLoaded); |
2374 |
23 Apr 14 |
nicklas |
47 |
} |
2374 |
23 Apr 14 |
nicklas |
else |
2374 |
23 Apr 14 |
nicklas |
49 |
{ |
2603 |
27 Aug 14 |
nicklas |
window.location = url; |
2374 |
23 Apr 14 |
nicklas |
51 |
} |
2374 |
23 Apr 14 |
nicklas |
52 |
} |
2374 |
23 Apr 14 |
nicklas |
53 |
|
2603 |
27 Aug 14 |
nicklas |
xport.onPreviewLoaded = function(response) |
2374 |
23 Apr 14 |
nicklas |
55 |
{ |
2603 |
27 Aug 14 |
nicklas |
Doc.show('navigation'); |
2374 |
23 Apr 14 |
nicklas |
var frm = document.forms['reggie']; |
2603 |
27 Aug 14 |
nicklas |
var allLines = response.split('\n'); |
2374 |
23 Apr 14 |
nicklas |
var numCases = allLines.length - 2; // First line is a header line |
2374 |
23 Apr 14 |
nicklas |
60 |
|
2374 |
23 Apr 14 |
nicklas |
var html = '<tr><th>'+allLines[0].replace(/\t/g, '</th><th>')+'</th></tr>'; |
2374 |
23 Apr 14 |
nicklas |
// Check last column for the 'Consent' value. All should be 'YES' for the export to be ok. |
2374 |
23 Apr 14 |
nicklas |
var numNoConsent = 0; |
2374 |
23 Apr 14 |
nicklas |
var numMissingConsent = 0; |
2374 |
23 Apr 14 |
nicklas |
for (var i = 1 ; i <= numCases; i++) |
2374 |
23 Apr 14 |
nicklas |
66 |
{ |
2374 |
23 Apr 14 |
nicklas |
var line = allLines[i]; |
2374 |
23 Apr 14 |
nicklas |
var cols = line.split(/\t/); |
2374 |
23 Apr 14 |
nicklas |
var consent = cols[cols.length-1]; |
2374 |
23 Apr 14 |
nicklas |
var rowClass = ''; |
2374 |
23 Apr 14 |
nicklas |
if (consent != 'YES') |
2374 |
23 Apr 14 |
nicklas |
72 |
{ |
2374 |
23 Apr 14 |
nicklas |
rowClass = 'consent-warning'; |
2374 |
23 Apr 14 |
nicklas |
if (consent == 'MISSING') |
2374 |
23 Apr 14 |
nicklas |
75 |
{ |
2374 |
23 Apr 14 |
nicklas |
numMissingConsent++; |
2374 |
23 Apr 14 |
nicklas |
77 |
} |
2374 |
23 Apr 14 |
nicklas |
else |
2374 |
23 Apr 14 |
nicklas |
79 |
{ |
2374 |
23 Apr 14 |
nicklas |
numNoConsent++; |
2374 |
23 Apr 14 |
nicklas |
81 |
} |
2374 |
23 Apr 14 |
nicklas |
82 |
} |
2374 |
23 Apr 14 |
nicklas |
html += '<tr class="'+rowClass+'"><td>'+cols.join('</td><td>')+'</td></tr>'; |
2374 |
23 Apr 14 |
nicklas |
84 |
} |
2374 |
23 Apr 14 |
nicklas |
85 |
|
2374 |
23 Apr 14 |
nicklas |
var previewWarning = Doc.element('previewWarning'); |
2374 |
23 Apr 14 |
nicklas |
if (numMissingConsent > 0 || numNoConsent > 0) |
2374 |
23 Apr 14 |
nicklas |
88 |
{ |
2374 |
23 Apr 14 |
nicklas |
var warning = '<img src="../images/warning.png" alt="!">'; |
2374 |
23 Apr 14 |
nicklas |
warning += ' Found ' + (numNoConsent+numMissingConsent) + ' case(s) with denied or missing consent!'; |
2374 |
23 Apr 14 |
nicklas |
previewWarning.innerHTML = warning; |
2374 |
23 Apr 14 |
nicklas |
92 |
} |
2374 |
23 Apr 14 |
nicklas |
else |
2374 |
23 Apr 14 |
nicklas |
94 |
{ |
2374 |
23 Apr 14 |
nicklas |
previewWarning.innerHTML = ''; |
2374 |
23 Apr 14 |
nicklas |
96 |
} |
2374 |
23 Apr 14 |
nicklas |
97 |
|
2374 |
23 Apr 14 |
nicklas |
previewTitle.innerHTML = 'Operation dates - ' + frm.time[frm.time.selectedIndex].text + ' (' + numCases + ')'; |
2374 |
23 Apr 14 |
nicklas |
previewList.innerHTML = '<table>'+html+'</table>'; |
2374 |
23 Apr 14 |
nicklas |
Doc.show('previewWrapper'); |
2374 |
23 Apr 14 |
nicklas |
101 |
} |
2374 |
23 Apr 14 |
nicklas |
102 |
|
2374 |
23 Apr 14 |
nicklas |
return xport; |
2374 |
23 Apr 14 |
nicklas |
104 |
}(); |
2374 |
23 Apr 14 |
nicklas |
105 |
|
2374 |
23 Apr 14 |
nicklas |
Doc.onLoad(Xport.initPage); |
2374 |
23 Apr 14 |
nicklas |
107 |
|