Some fixes in phpgacl to work with php 5.4
[openemr.git] / custom / download_qrda.php
blobf02b1afeb59724a36c2d6ebad5b18b8e11cfc6d4
1 <?php
2 /**
4 * QRDA Download
6 * Copyright (C) 2015 Ensoftek, Inc
8 * LICENSE: This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
19 * @package OpenEMR
20 * @author Ensoftek
21 * @link http://www.open-emr.org
25 $fake_register_globals=false;
26 $sanitize_all_escapes=true;
28 require_once("../interface/globals.php");
29 require_once "$srcdir/report_database.inc";
30 require_once("$srcdir/formatting.inc.php");
31 require_once ("$srcdir/options.inc.php");
32 require_once("$srcdir/sanitize.inc.php");
33 require_once("qrda_category1.inc");
35 $report_id = (isset($_GET['report_id'])) ? trim($_GET['report_id']) : "";
36 $provider_id = (isset($_GET['provider_id'])) ? trim($_GET['provider_id']) : "";
38 $report_view = collectReportDatabase($report_id);
39 $dataSheet = json_decode($report_view['data'],TRUE);
40 $type_report = $report_view['type'];
41 $type_report = (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014") ||
42 ($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) ? $type_report : "standard";
46 <html>
48 <head>
49 <?php html_header_show();?>
51 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
52 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js"></script>
53 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script>
54 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-1.4.3.min.js"></script>
55 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-ui-1.8.5.custom.min.js"></script>
56 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/common.js"></script>
57 <script language="JavaScript">
58 var reportID = '<?php echo attr($report_id); ?>';
59 var provider_id = '<?php echo attr($provider_id);?>';
60 var zipFileArray = new Array();
61 var failureMessage = "";
62 $(document).ready(function(){
63 $("#checkAll").change(function() {
64 var checked = ( $("#checkAll").attr("checked") ) ? true : false;
65 $("#thisForm input:checkbox").each(function() {
66 $(this).attr("checked", checked);
67 });
68 });
69 });
71 function downloadSelected() {
72 zipFileArray.length = 0;
73 var criteriaArray = new Array();
74 $("#thisForm input:checkbox:checked").each(function() {
75 if ( $(this).attr("id") == "checkAll")
76 return;
77 criteriaArray.push($(this).attr("id"));
78 });
79 if ( criteriaArray.length == 0 ) {
80 alert("<?php echo xls('Please select at least one criteria to download');?>");
81 return false;
83 for( var i=0 ; i < criteriaArray.length ; i++) {
84 var checkBoxCounterArray = criteriaArray[i].split("check");
85 var ruleID = $("#text" + checkBoxCounterArray[1]).val();
86 //console.log(ruleID);
87 var lastOne = ( ( i + 1 ) == criteriaArray.length ) ? 1 : 0;
88 downloadXML(checkBoxCounterArray[1],lastOne,ruleID);
92 function downloadXML(counter,lastOne) {
93 $("#download" + counter).css("display","none");
94 $("#spin" + counter).css("display","inline");
95 $.ajax({
96 type : "POST",
97 url: "ajax_download.php",
98 data : {
99 reportID: reportID,
100 counter: counter,
101 ruleID: $("#text" + counter).val(),
102 provider_id: provider_id
104 context: document.body,
105 success :
106 function(data){
107 // Check if download is complete
108 var status = data.substr(0, 8);
109 if ( status == "FAILURE:") {
110 data = data.substr(8);
111 //console.log(data);
112 failureMessage += data + "\n";
113 } else {
114 zipFileArray.push(data);
115 $("#checkmark" + counter).css("display","inline");
117 $("#download" + counter).css("display","inline");
118 $("#spin" + counter).css("display","none");
119 if ( lastOne == 1 ) {
120 if ( zipFileArray.length ) {
121 var zipFiles = zipFileArray.join(",");
122 //console.log(zipFiles);
123 window.location = 'ajax_download.php?fileName=' + zipFiles;
124 zipFileArray.length = 0;
126 if ( failureMessage ) {
127 console.log(failureMessage);
128 alert(failureMessage);
130 failureMessage = "";
136 function closeMe() {
137 window.close();
139 </script>
140 <style>
141 .downloadIcon:hover {
142 cursor: hand;
144 .multiDownload {
147 </style>
148 </head>
150 <body class="body_top">
151 <form id="thisForm" name="thisForm">
152 <table>
153 <tr>
154 <td><span class="title"><?php echo xlt("Generate/Download QRDA I - 2014"); ?>&nbsp;</span></td>
155 <td>
156 <a class="css_button multiDownload" href="#" onclick="downloadSelected();"><span><?php echo xlt("Download"); ?></span></a>
157 <a class="css_button" href="#" onclick="closeMe();"><span><?php echo xlt("Close"); ?></span></a>
158 </td>
159 </tr>
160 </table>
161 <br/>
162 <div id="report_results" style="width:95%">
163 <table class="oemr_list text">
164 <thead>
165 <th scope="col" class="multiDownload">
166 <input type="checkbox" name="checkAll" id="checkAll"/>
167 <div style="display:none" id=downloadAll>
168 <img class='downloadIcon' src='<?php echo $GLOBALS['webroot'];?>/images/downbtn.gif' onclick=downloadAllXML(); />
169 </div>
170 <div style='display:none' id=spinAll>;
171 <img src='<?php echo $GLOBALS['webroot'];?>/interface/pic/ajax-loader.gif'/>
172 </div>
173 </th>
174 <th scope="col">
175 <?php echo xlt('Title'); ?>
176 </th>
178 <th scope="col">
179 <?php echo xlt('Download'); ?>
180 </th>
181 <th scope="col">&nbsp;&nbsp;&nbsp;</th>
182 </thead>
183 <tbody>
184 <?php
185 $counter = 0;
186 foreach ($dataSheet as $row) {
187 if (isset($row['is_main']) || isset($row['is_sub'])) {
188 if ( count($cqmCodes) && in_array($row['cqm_nqf_code'],$cqmCodes) ) {
189 continue;
191 echo "<tr>";
192 $cqmCodes[] = $row['cqm_nqf_code'];
193 echo "<td class=multiDownload>";
194 echo "<input id=check" . attr($counter) . " type=checkbox />";
195 echo "</td>";
196 echo "<td class='detail'>";
197 if (isset($row['is_main'])) {
198 echo "<b>".generate_display_field(array('data_type'=>'1','list_id'=>'clinical_rules'),$row['id'])."</b>";
199 $tempCqmAmcString = "";
200 if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) {
201 if (!empty($row['cqm_pqri_code'])) {
202 $tempCqmAmcString .= " " . xl('PQRI') . ":" . $row['cqm_pqri_code'] . " ";
204 if (!empty($row['cqm_nqf_code'])) {
205 $tempCqmAmcString .= " " . xl('NQF') . ":" . $row['cqm_nqf_code'] . " ";
208 if (!empty($tempCqmAmcString)) {
209 echo "(".text($tempCqmAmcString).")";
211 } else {
212 echo generate_display_field(array('data_type'=>'1','list_id'=>'rule_action_category'),$row['action_category']);
213 echo ": " . generate_display_field(array('data_type'=>'1','list_id'=>'rule_action'),$row['action_item']);
215 echo "<input type=hidden id=text" . attr($counter) . " name=text" . attr($counter) . " value='" . attr($row['cqm_nqf_code']) . "'/>";
216 echo "</td>";
217 echo "<td align=center>";
218 echo "<div id=download" . attr($counter) . ">";
219 echo "<img class='downloadIcon' src='" . $GLOBALS['webroot'] . "/images/downbtn.gif' onclick=downloadXML(" . attr($counter) . ",1); />";
220 echo "</div>";
221 echo "<div style='display:none' id=spin" . attr($counter) . ">";
222 echo "<img src='" . $GLOBALS['webroot'] . "/interface/pic/ajax-loader.gif'/>";
223 echo "</div>";
224 echo "</td>";
225 echo "<td>";
226 echo "<div style='display:none' id=checkmark" . attr($counter) . ">";
227 echo "<img src='" . $GLOBALS['webroot'] . "/images/checkmark.png' />";
228 echo "</div>";
229 echo "</td>";
230 echo "</tr>";
231 $counter++;
233 } ?>
234 </tbody>
235 </table>
236 </div>
238 </form>
239 </body>
240 </html>