7 * @link http://www.open-emr.org
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2015 Ensoftek, Inc
11 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../interface/globals.php");
16 require_once "$srcdir/report_database.inc.php";
17 require_once("$srcdir/options.inc.php");
18 require_once("qrda_category1.inc.php");
20 use OpenEMR\Common\Csrf\CsrfUtils
;
21 use OpenEMR\Core\Header
;
23 if (!CsrfUtils
::verifyCsrfToken($_GET["csrf_token_form"])) {
24 CsrfUtils
::csrfNotVerified();
27 $report_id = (isset($_GET['report_id'])) ?
trim($_GET['report_id']) : "";
28 $provider_id = (isset($_GET['provider_id'])) ?
trim($_GET['provider_id']) : "";
30 $report_view = collectReportDatabase($report_id);
31 $dataSheet = json_decode($report_view['data'], true);
32 $type_report = $report_view['type'];
33 $type_report = (($type_report == "amc") ||
($type_report == "amc_2011") ||
($type_report == "amc_2014") ||
34 ($type_report == "cqm") ||
($type_report == "cqm_2011") ||
($type_report == "cqm_2014")) ?
$type_report : "standard";
40 <?php Header
::setupHeader(['common', 'opener']); ?
>
43 var reportID
= <?php
echo js_escape($report_id); ?
>;
44 var provider_id
= <?php
echo js_escape($provider_id);?
>;
45 var zipFileArray
= new Array();
46 var failureMessage
= "";
48 $
("#checkAll").on("change", function() {
49 var checked
= ( $
("#checkAll").prop("checked") ) ?
true : false;
50 $
("#thisForm input:checkbox").each(function() {
51 $
(this
).prop("checked", checked
);
56 function downloadSelected() {
57 zipFileArray
.length
= 0;
58 var criteriaArray
= new Array();
59 $
("#thisForm input:checkbox:checked").each(function() {
60 if ( $
(this
).attr("id") == "checkAll")
62 criteriaArray
.push($
(this
).attr("id"));
64 if ( criteriaArray
.length
== 0 ) {
65 alert(<?php
echo xlj('Please select at least one criteria to download');?
>);
68 for( var i
=0 ; i
< criteriaArray
.length
; i++
) {
69 var checkBoxCounterArray
= criteriaArray
[i
].split("check");
70 var ruleID
= $
("#text" + checkBoxCounterArray
[1]).val();
71 //console.log(ruleID);
72 var lastOne
= ( ( i +
1 ) == criteriaArray
.length
) ?
1 : 0;
73 downloadXML(checkBoxCounterArray
[1],lastOne
,ruleID
);
77 function downloadXML(counter
,lastOne
) {
78 $
("#download" + counter
).css("display","none");
79 $
("#spin" + counter
).css("display","inline");
82 url
: "ajax_download.php",
86 ruleID
: $
("#text" + counter
).val(),
87 provider_id
: provider_id
,
88 csrf_token_form
: <?php
echo js_escape(CsrfUtils
::collectCsrfToken()); ?
>
90 context
: document
.body
,
93 // Check if download is complete
94 var status
= data
.substr(0, 8);
95 if ( status
== "FAILURE:") {
96 data
= data
.substr(8);
98 failureMessage +
= data +
"\n";
100 zipFileArray
.push(data
);
101 $
("#checkmark" + counter
).css("display","inline");
103 $
("#download" + counter
).css("display","inline");
104 $
("#spin" + counter
).css("display","none");
105 if ( lastOne
== 1 ) {
106 if ( zipFileArray
.length
) {
107 var zipFiles
= zipFileArray
.join(",");
108 //console.log(zipFiles);
109 window
.location
= 'ajax_download.php?fileName=' +
encodeURIComponent(zipFiles
) +
'&csrf_token_form=' +
<?php
echo js_url(CsrfUtils
::collectCsrfToken()); ?
>;
110 zipFileArray
.length
= 0;
112 if ( failureMessage
) {
113 console
.log(failureMessage
);
114 alert(failureMessage
);
127 .downloadIcon
:hover
{
136 <body
class="body_top">
137 <form id
="thisForm" name
="thisForm">
140 <td
><span
class="title"><?php
echo xlt("Generate/Download QRDA I - 2014"); ?
> 
;</span
></td
>
142 <a
class="btn btn-primary multiDownload" href
="#" onclick
="downloadSelected();"><?php
echo xlt("Download"); ?
></a
>
143 <a
class="btn btn-secondary" href
="#" onclick
="closeMe();"><?php
echo xlt("Close"); ?
></a
>
148 <div id
="report_results" style
="width:95%">
149 <table
class="oemr_list text">
151 <th scope
="col" class="multiDownload">
152 <input type
="checkbox" name
="checkAll" id
="checkAll"/>
153 <div style
="display:none" id
=downloadAll
>
154 <img
class="downloadIcon" src
="<?php echo $GLOBALS['images_static_relative'];?>/downbtn.gif" onclick
=downloadAllXML(); />
156 <div style
="display:none" id
=spinAll
>;
157 <img src
="<?php echo $GLOBALS['webroot'];?>/interface/pic/ajax-loader.gif"/>
161 <?php
echo xlt('Title'); ?
>
165 <?php
echo xlt('Download'); ?
>
167 <th scope
="col"> 
; 
; 
;</th
>
172 foreach ($dataSheet as $row) {
173 if (isset($row['is_main']) ||
isset($row['is_sub'])) {
174 if (count($cqmCodes ??
[]) && in_array($row['cqm_nqf_code'], $cqmCodes)) {
179 $cqmCodes[] = $row['cqm_nqf_code'];
180 echo "<td class=multiDownload>";
181 echo "<input id=check" . attr($counter) . " type=checkbox />";
183 echo "<td class='detail'>";
184 if (isset($row['is_main'])) {
185 echo "<b>" . generate_display_field(array('data_type' => '1','list_id' => 'clinical_rules'), $row['id']) . "</b>";
186 $tempCqmAmcString = "";
187 if (($type_report == "cqm") ||
($type_report == "cqm_2011") ||
($type_report == "cqm_2014")) {
188 if (!empty($row['cqm_pqri_code'])) {
189 $tempCqmAmcString .= " " . xl('PQRI') . ":" . $row['cqm_pqri_code'] . " ";
192 if (!empty($row['cqm_nqf_code'])) {
193 $tempCqmAmcString .= " " . xl('NQF') . ":" . $row['cqm_nqf_code'] . " ";
197 if (!empty($tempCqmAmcString)) {
198 echo "(" . text($tempCqmAmcString) . ")";
201 echo generate_display_field(array('data_type' => '1','list_id' => 'rule_action_category'), $row['action_category']);
202 echo ": " . generate_display_field(array('data_type' => '1','list_id' => 'rule_action'), $row['action_item']);
205 echo "<input type=hidden id=text" . attr($counter) . " name=text" . attr($counter) . " value='" . attr($row['cqm_nqf_code']) . "'/>";
207 echo "<td align=center>";
208 echo "<div id=download" . attr($counter) . ">";
209 echo "<img class='downloadIcon' src='" . $GLOBALS['images_static_relative'] . "/downbtn.gif' onclick=downloadXML(" . attr_js($counter) . ",1); />";
211 echo "<div style='display:none' id=spin" . attr($counter) . ">";
212 echo "<img src='" . $GLOBALS['webroot'] . "/interface/pic/ajax-loader.gif'/>";
216 echo "<div style='display:none' id=checkmark" . attr($counter) . ">";
217 echo "<img src='" . $GLOBALS['images_static_relative'] . "/checkmark.png' />";