continued bug fixes (#1862)
[openemr.git] / interface / reports / cqm.php
blob2f278b93310fe28cf67d3ef545def81120e6e2bb
1 <?php
2 /**
3 * CDR reports.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @copyright Copyright (c) 2010-2017 Brady Miller <brady.g.miller@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 require_once("../globals.php");
14 require_once("../../library/patient.inc");
15 require_once "$srcdir/options.inc.php";
16 require_once "$srcdir/clinical_rules.php";
17 require_once "$srcdir/report_database.inc";
19 use OpenEMR\Core\Header;
21 // See if showing an old report or creating a new report
22 $report_id = (isset($_GET['report_id'])) ? trim($_GET['report_id']) : "";
24 // Collect the back variable, if pertinent
25 $back_link = (isset($_GET['back'])) ? trim($_GET['back']) : "";
27 // If showing an old report, then collect information
28 if (!empty($report_id)) {
29 $report_view = collectReportDatabase($report_id);
30 $date_report = $report_view['date_report'];
31 $type_report = $report_view['type'];
33 $type_report = (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2") ||
34 ($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) ? $type_report : "standard";
35 $rule_filter = $report_view['type'];
37 if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) {
38 $begin_date = $report_view['date_begin'];
39 $labs_manual = $report_view['labs_manual'];
42 $target_date = $report_view['date_target'];
43 $plan_filter = $report_view['plan'];
44 $organize_method = $report_view['organize_mode'];
45 $provider = $report_view['provider'];
46 $pat_prov_rel = $report_view['pat_prov_rel'];
47 $dataSheet = json_decode($report_view['data'], true);
48 } else {
49 // Collect report type parameter (standard, amc, cqm)
50 // Note that need to convert amc_2011 and amc_2014 to amc and cqm_2011 and cqm_2014 to cqm
51 // to simplify for when submitting for a new report.
52 $type_report = (isset($_GET['type'])) ? trim($_GET['type']) : "standard";
54 if (($type_report == "cqm_2011") || ($type_report == "cqm_2014")) {
55 $type_report = "cqm";
58 if (($type_report == "amc_2011") || ($type_report == "amc_2014") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) {
59 $type_report = "amc";
62 // Collect form parameters (set defaults if empty)
63 if ($type_report == "amc") {
64 $begin_date = (isset($_POST['form_begin_date'])) ? DateTimeToYYYYMMDDHHMMSS(trim($_POST['form_begin_date'])) : "";
65 $labs_manual = (isset($_POST['labs_manual_entry'])) ? trim($_POST['labs_manual_entry']) : "0";
68 $target_date = (isset($_POST['form_target_date'])) ? DateTimeToYYYYMMDDHHMMSS(trim($_POST['form_target_date'])) : date('Y-m-d H:i:s');
69 $rule_filter = (isset($_POST['form_rule_filter'])) ? trim($_POST['form_rule_filter']) : "";
70 $plan_filter = (isset($_POST['form_plan_filter'])) ? trim($_POST['form_plan_filter']) : "";
71 $organize_method = (empty($plan_filter)) ? "default" : "plans";
72 $provider = trim($_POST['form_provider']);
73 $pat_prov_rel = (empty($_POST['form_pat_prov_rel'])) ? "primary" : trim($_POST['form_pat_prov_rel']);
77 <html>
79 <head>
81 <?php if ($type_report == "standard") { ?>
82 <title><?php echo xlt('Standard Measures'); ?></title>
83 <?php } ?>
85 <?php if ($type_report == "cqm") { ?>
86 <title><?php echo xlt('Clinical Quality Measures (CQM)'); ?></title>
87 <?php } ?>
88 <?php if ($type_report == "cqm_2011") { ?>
89 <title><?php echo xlt('Clinical Quality Measures (CQM) - 2011'); ?></title>
90 <?php } ?>
91 <?php if ($type_report == "cqm_2014") { ?>
92 <title><?php echo xlt('Clinical Quality Measures (CQM) - 2014'); ?></title>
93 <?php } ?>
95 <?php if ($type_report == "amc") { ?>
96 <title><?php echo xlt('Automated Measure Calculations (AMC)'); ?></title>
97 <?php } ?>
98 <?php if ($type_report == "amc_2011") { ?>
99 <title><?php echo xlt('Automated Measure Calculations (AMC) - 2011'); ?></title>
100 <?php } ?>
101 <?php if ($type_report == "amc_2014_stage1") { ?>
102 <title><?php echo xlt('Automated Measure Calculations (AMC) - 2014 Stage I'); ?></title>
103 <?php } ?>
104 <?php if ($type_report == "amc_2014_stage2") { ?>
105 <title><?php echo xlt('Automated Measure Calculations (AMC) - 2014 Stage II'); ?></title>
106 <?php } ?>
108 <?php Header::setupHeader('datetime-picker'); ?>
110 <script LANGUAGE="JavaScript">
112 <?php require $GLOBALS['srcdir'] . "/formatting_DateToYYYYMMDD_js.js.php" ?>
114 var mypcc = '<?php echo text($GLOBALS['phone_country_code']) ?>';
116 $(document).ready(function() {
117 var win = top.printLogSetup ? top : opener.top;
118 win.printLogSetup(document.getElementById('printbutton'));
120 $('.datepicker').datetimepicker({
121 <?php $datetimepicker_timepicker = true; ?>
122 <?php $datetimepicker_showseconds = true; ?>
123 <?php $datetimepicker_formatInput = true; ?>
124 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
125 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
129 function runReport() {
131 // Validate first
132 if (!(validateForm())) {
133 alert("<?php echo xls("Rule Set and Plan Set selections are not consistent. Please fix and Submit again."); ?>");
134 return false;
137 // Showing processing wheel
138 $("#processing").show();
140 // hide Submit buttons
141 $("#submit_button").hide();
142 $("#xmla_button").hide();
143 $("#xmlb_button").hide();
144 $("#xmlc_button").hide();
145 $("#print_button").hide();
146 $("#genQRDA").hide();
148 // hide instructions
149 $("#instructions_text").hide();
151 // Collect an id string via an ajax request
152 top.restoreSession();
153 $.get("../../library/ajax/collect_new_report_id.php",
154 function(data){
155 // Set the report id in page form
156 $("#form_new_report_id").attr("value",data);
158 // Start collection status checks
159 collectStatus($("#form_new_report_id").val());
161 // Run the report
162 top.restoreSession();
163 $.post("../../library/ajax/execute_cdr_report.php",
164 {provider: $("#form_provider").val(),
165 type: $("#form_rule_filter").val(),
166 date_target: DateToYYYYMMDDHHMMSS_js($("#form_target_date").val()),
167 date_begin: DateToYYYYMMDDHHMMSS_js($("#form_begin_date").val()),
168 plan: $("#form_plan_filter").val(),
169 labs: $("#labs_manual_entry").val(),
170 pat_prov_rel: $("#form_pat_prov_rel").val(),
171 execute_report_id: $("#form_new_report_id").val()
176 function collectStatus(report_id) {
177 // Collect the status string via an ajax request and place in DOM at timed intervals
178 top.restoreSession();
179 // Do not send the skip_timeout_reset parameter, so don't close window before report is done.
180 $.post("../../library/ajax/status_report.php",
181 {status_report_id: report_id},
182 function(data){
183 if (data == "PENDING") {
184 // Place the pending string in the DOM
185 $('#status_span').replaceWith("<span id='status_span'><?php echo xlt("Preparing To Run Report"); ?></span>");
187 else if (data == "COMPLETE") {
188 // Go into the results page
189 top.restoreSession();
190 link_report = "cqm.php?report_id="+report_id;
191 window.open(link_report,'_self',false);
192 //$("#processing").hide();
193 //$('#status_span').replaceWith("<a id='view_button' href='cqm.php?report_id="+report_id+"' class='css_button' onclick='top.restoreSession()'><span><?php echo xlt('View Report'); ?></span></a>");
195 else {
196 // Place the string in the DOM
197 $('#status_span').replaceWith("<span id='status_span'>"+data+"</span>");
200 // run status check every 10 seconds
201 var repeater = setTimeout("collectStatus("+report_id+")", 10000);
204 function GenXml(sNested) {
205 top.restoreSession();
206 //QRDA Category III Export
207 if(sNested == "QRDA"){
208 var form_rule_filter = theform.form_rule_filter.value
209 var sLoc = '../../custom/export_qrda_xml.php?target_date=' + DateToYYYYMMDDHHMMSS_js(theform.form_target_date.value) + '&qrda_version=3&rule_filter=cqm_2014&form_provider='+theform.form_provider.value+"&report_id=<?php echo attr(urlencode($report_id)); ?>&csrf_token_form=<?php echo attr(urlencode(collectCsrfToken())); ?>";
210 }else{
211 var sLoc = '../../custom/export_registry_xml.php?&target_date=' + DateToYYYYMMDDHHMMSS_js(theform.form_target_date.value) + '&nested=' + sNested + "&csrf_token_form=<?php echo attr(urlencode(collectCsrfToken())); ?>";
213 dlgopen(sLoc, '_blank', 600, 500);
214 return false;
217 //QRDA I - 2014 Download
218 function downloadQRDA() {
219 top.restoreSession();
220 var reportID = '<?php echo attr($report_id); ?>';
221 var provider = $("#form_provider").val();
222 sLoc = '../../custom/download_qrda.php?&report_id=' + reportID + '&provider_id=' + provider;
223 dlgopen(sLoc, '_blank', 600, 500);
226 function validateForm() {
227 <?php if ((empty($report_id)) && ($type_report == "cqm")) { ?>
228 // If this is a cqm and plan set not set to ignore, then need to ensure consistent with the rules set
229 if ($("#form_plan_filter").val() != '') {
230 if ($("#form_rule_filter").val() == $("#form_plan_filter").val()) {
231 return true;
232 } else {
233 return false;
236 else {
237 return true;
239 <?php } else { ?>
240 return true;
241 <?php } ?>
244 function Form_Validate() {
245 <?php if ((empty($report_id)) && (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2"))) { ?>
246 var d = document.forms[0];
247 FromDate = DateToYYYYMMDDHHMMSS_js(d.form_begin_date.value);
248 ToDate = DateToYYYYMMDDHHMMSS_js(d.form_target_date.value);
249 if ( (FromDate.length > 0) && (ToDate.length > 0) ) {
250 if (FromDate > ToDate){
251 alert("<?php echo xls('End date must be later than Begin date!'); ?>");
252 return false;
255 <?php } ?>
257 //For Results are in Gray Background & disabling anchor links
258 <?php if ($report_id != "") {?>
259 $("#report_results").css("opacity", '0.4');
260 $("#report_results").css("filter", 'alpha(opacity=40)');
261 $("a").removeAttr("href");
262 <?php }?>
264 $("#form_refresh").attr("value","true");
265 runReport();
266 return true;
269 </script>
271 <style type="text/css">
273 /* specifically include & exclude from printing */
274 @media print {
275 #report_parameters {
276 visibility: hidden;
277 display: none;
279 #report_parameters_daterange {
280 visibility: visible;
281 display: inline;
283 #report_results table {
284 margin-top: 0px;
288 /* specifically exclude some from the screen */
289 @media screen {
290 #report_parameters_daterange {
291 visibility: hidden;
292 display: none;
296 </style>
297 </head>
299 <body class="body_top">
301 <!-- Required for the popup date selectors -->
302 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
304 <span class='title'><?php echo xlt('Report'); ?> -
306 <?php if ($type_report == "standard") { ?>
307 <?php echo xlt('Standard Measures'); ?>
308 <?php } ?>
310 <?php if ($type_report == "cqm") { ?>
311 <?php echo xlt('Clinical Quality Measures (CQM)'); ?>
312 <?php } ?>
313 <?php if ($type_report == "cqm_2011") { ?>
314 <?php echo xlt('Clinical Quality Measures (CQM) - 2011'); ?>
315 <?php } ?>
316 <?php if ($type_report == "cqm_2014") { ?>
317 <?php echo xlt('Clinical Quality Measures (CQM) - 2014'); ?>
318 <?php } ?>
320 <?php if ($type_report == "amc") { ?>
321 <?php echo xlt('Automated Measure Calculations (AMC)'); ?>
322 <?php } ?>
323 <?php if ($type_report == "amc_2011") { ?>
324 <?php echo xlt('Automated Measure Calculations (AMC) - 2011'); ?>
325 <?php } ?>
326 <?php if ($type_report == "amc_2014_stage1") { ?>
327 <?php echo xlt('Automated Measure Calculations (AMC) - 2014 Stage I'); ?>
328 <?php } ?>
329 <?php if ($type_report == "amc_2014_stage2") { ?>
330 <?php echo xlt('Automated Measure Calculations (AMC) - 2014 Stage II'); ?>
331 <?php } ?>
333 <?php if (!empty($report_id)) { ?>
334 <?php echo " - " . xlt('Date of Report') . ": " . text(oeFormatDateTime($date_report, "global", true));
335 //prepare to disable form elements
336 $dis_text = " disabled='disabled' ";
338 <?php } ?>
339 </span>
341 <form method='post' name='theform' id='theform' action='cqm.php?type=<?php echo attr($type_report) ;?>' onsubmit='return validateForm()'>
343 <div id="report_parameters">
344 <?php
345 $widthDyn = "470px";
346 if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) {
347 $widthDyn = "410px";
350 <table>
351 <tr>
352 <td scope="row" width='<?php echo $widthDyn;?>'>
353 <div style='float:left'>
355 <table class='text'>
357 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
358 <tr>
359 <td class='control-label'>
360 <?php echo xlt('Begin Date'); ?>:
361 </td>
362 <td>
363 <input <?php echo $dis_text; ?> type='text' name='form_begin_date' id="form_begin_date" size='20' value='<?php echo attr(oeFormatDateTime($begin_date, 0, true)); ?>'
364 class='datepicker form-control'>
365 <?php if (empty($report_id)) { ?>
366 <?php } ?>
367 </td>
368 </tr>
369 <?php } ?>
371 <tr>
372 <td class='control-label'>
373 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
374 <?php echo xlt('End Date'); ?>:
375 <?php } else { ?>
376 <?php echo xlt('Target Date'); ?>:
377 <?php } ?>
378 </td>
379 <td>
380 <input <?php echo $dis_text; ?> type='text' name='form_target_date' id="form_target_date" size='20' value='<?php echo attr(oeFormatDateTime($target_date, 0, true)); ?>'
381 class='datepicker form-control'>
382 <?php if (empty($report_id)) { ?>
383 <?php } ?>
384 </td>
385 </tr>
387 <?php if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) { ?>
388 <tr>
389 <td class='control-label'>
390 <?php echo xlt('Rule Set'); ?>:
391 </td>
392 <td>
393 <select <?php echo $dis_text; ?> id='form_rule_filter' name='form_rule_filter' class='form-control'>
394 <option value='cqm' <?php echo ($rule_filter == "cqm") ? "selected" : ""; ?>>
395 <?php echo xlt('All Clinical Quality Measures (CQM)'); ?></option>
396 <option value='cqm_2011' <?php echo ($rule_filter == "cqm_2011") ? "selected" : ""; ?>>
397 <?php echo xlt('2011 Clinical Quality Measures (CQM)'); ?></option>
398 <option value='cqm_2014' <?php echo ($rule_filter == "cqm_2014") ? "selected" : ""; ?>>
399 <?php echo xlt('2014 Clinical Quality Measures (CQM)'); ?></option>
400 </select>
401 </td>
402 </tr>
403 <?php } ?>
405 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
406 <tr>
407 <td class='control-label'>
408 <?php echo xlt('Rule Set'); ?>:
409 </td>
410 <td>
411 <select <?php echo $dis_text; ?> id='form_rule_filter' name='form_rule_filter' class='form-control'>
413 <?php if ($rule_filter == "amc") { //only show this when displaying old reports. Not available option for new reports ?>
414 <option value='amc' selected>
415 <?php echo xlt('All Automated Measure Calculations (AMC)'); ?></option>
416 <?php } ?>
418 <option value='amc_2011' <?php echo ($rule_filter == "amc_2011") ? "selected" : ""; ?>>
419 <?php echo xlt('2011 Automated Measure Calculations (AMC)'); ?></option>
420 <option value='amc_2014_stage1' <?php echo ($rule_filter == "amc_2014_stage1") ? "selected" : ""; ?>>
421 <?php echo xlt('2014 Automated Measure Calculations (AMC) - Stage I'); ?></option>
422 <option value='amc_2014_stage2' <?php echo ($rule_filter == "amc_2014_stage2") ? "selected" : ""; ?>>
423 <?php echo xlt('2014 Automated Measure Calculations (AMC) - Stage II'); ?></option>
424 </select>
425 </td>
426 </tr>
427 <?php } ?>
429 <?php if ($type_report == "standard") { ?>
430 <tr>
431 <td class='control-label'>
432 <?php echo xlt('Rule Set'); ?>:
433 </td>
434 <td>
435 <select <?php echo $dis_text; ?> id='form_rule_filter' name='form_rule_filter' class='form-control'>
436 <option value='passive_alert' <?php echo ($rule_filter == "passive_alert") ? "selected" : ""; ?>>
437 <?php echo xlt('Passive Alert Rules'); ?></option>
438 <option value='active_alert' <?php echo ($rule_filter == "active_alert") ? "selected" : ""; ?>>
439 <?php echo xlt('Active Alert Rules'); ?></option>
440 <option value='patient_reminder' <?php echo ($rule_filter == "patient_reminder") ? "selected" : ""; ?>>
441 <?php echo xlt('Patient Reminder Rules'); ?></option>
442 </select>
443 </td>
444 </tr>
445 <?php } ?>
447 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
448 <input type='hidden' id='form_plan_filter' name='form_plan_filter' value=''>
449 <?php } else { ?>
450 <tr>
451 <td class='control-label'>
452 <?php echo xlt('Plan Set'); ?>:
453 </td>
454 <td>
455 <select <?php echo $dis_text; ?> id='form_plan_filter' name='form_plan_filter' class='form-control'>
456 <option value=''>-- <?php echo xlt('Ignore'); ?> --</option>
457 <?php if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) { ?>
458 <option value='cqm' <?php echo ($plan_filter == "cqm") ? "selected" : ""; ?>>
459 <?php echo xlt('All Official Clinical Quality Measures (CQM) Measure Groups'); ?></option>
460 <option value='cqm_2011' <?php echo ($plan_filter == "cqm_2011") ? "selected" : ""; ?>>
461 <?php echo xlt('2011 Official Clinical Quality Measures (CQM) Measure Groups'); ?></option>
462 <option value='cqm_2014' <?php echo ($plan_filter == "cqm_2014") ? "selected" : ""; ?>>
463 <?php echo xlt('2014 Official Clinical Quality Measures (CQM) Measure Groups'); ?></option>
464 <?php } ?>
465 <?php if ($type_report == "standard") { ?>
466 <option value='normal' <?php echo ($plan_filter == "normal") ? "selected" : ""; ?>>
467 <?php echo xlt('Active Plans'); ?></option>
468 <?php } ?>
469 </td>
470 </tr>
471 <?php } ?>
473 <tr>
474 <td class='control-label'>
475 <?php echo xlt('Provider'); ?>:
476 </td>
477 <td>
478 <?php
480 // Build a drop-down list of providers.
483 $query = "SELECT id, lname, fname FROM users WHERE ".
484 "authorized = 1 $provider_facility_filter ORDER BY lname, fname"; //(CHEMED) facility filter
486 $ures = sqlStatement($query);
488 echo " <select " . $dis_text . " id='form_provider' name='form_provider' class='form-control'>\n";
489 echo " <option value=''>-- " . xlt('All (Cumulative)') . " --\n";
491 echo " <option value='collate_outer'";
492 if ($provider == 'collate_outer') {
493 echo " selected";
496 echo ">-- " . xlt('All (Collated Format A)') . " --\n";
498 echo " <option value='collate_inner'";
499 if ($provider == 'collate_inner') {
500 echo " selected";
503 echo ">-- " . xlt('All (Collated Format B)') . " --\n";
505 while ($urow = sqlFetchArray($ures)) {
506 $provid = $urow['id'];
507 echo " <option value='".attr($provid)."'";
508 if ($provid == $provider) {
509 echo " selected";
512 echo ">" . text($urow['lname'] . ", " . $urow['fname']) . "\n";
515 echo " </select>\n";
518 </td>
519 </tr>
521 <tr>
522 <td class='control-label'>
523 <?php echo xlt('Provider Relationship'); ?>:
524 </td>
525 <td>
526 <?php
528 // Build a drop-down list of of patient provider relationships.
530 echo " <select ". $dis_text ." id='form_pat_prov_rel' name='form_pat_prov_rel' class='form-control' title='" . xla('Only applicable if a provider or collated list was chosen above. PRIMARY only selects patients that the provider is the primary provider. ENCOUNTER selects all patients that the provider has seen.') . "'>\n";
531 echo " <option value='primary'";
532 if ($pat_prov_rel == 'primary') {
533 echo " selected";
536 echo ">" . xlt('Primary') . "\n";
537 echo " <option value='encounter'";
538 if ($pat_prov_rel == 'encounter') {
539 echo " selected";
542 echo ">" . xlt('Encounter') . "\n";
543 echo " </select>\n";
545 </td>
546 </tr>
548 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
549 <tr>
550 <td>
551 <?php echo xlt('Number labs'); ?>:<br>
552 (<?php echo xlt('Non-electronic'); ?>)
553 </td>
554 <td>
555 <input <?php echo $dis_text; ?> type="text" id="labs_manual_entry" name="labs_manual_entry" class='form-control' value="<?php echo attr($labs_manual); ?>">
556 </td>
557 </tr>
558 <?php } ?>
560 </table>
562 </div>
564 </td>
565 <td align='left' valign='middle' height="100%">
566 <table style='border-left:1px solid; width:100%; height:100%' >
567 <tr>
568 <td scope="row">
569 <div class="text-center">
570 <div class="btn-group" role="group">
571 <?php if (empty($report_id)) { ?>
572 <a href='#' id='submit_button' class='btn btn-default btn-save' onclick='runReport();'>
573 <?php echo xlt('Submit'); ?>
574 </a>
575 <span id='status_span'></span>
576 <div id='processing' style='margin:10px;display:none;'><img src='../pic/ajax-loader.gif'/></div>
577 <?php if ($type_report == "cqm") { ?>
578 <a href='#' id='xmla_button' class='btn btn-default btn-transmit' onclick='return GenXml("false")'>
579 <?php echo xlt('Generate PQRI report (Method A) - 2011'); ?>
580 </a>
581 <a href='#' id='xmlb_button' class='btn btn-default btn-transmit' onclick='return GenXml("true")'>
582 <?php echo xlt('Generate PQRI report (Method E) - 2011'); ?>
583 </a>
584 <?php } ?>
585 <?php } ?>
586 <?php if (!empty($report_id)) { ?>
587 <a href='#' class='btn btn-default btn-print' id='printbutton'>
588 <?php echo xlt('Print'); ?>
589 </a>
590 <?php if ($type_report == "cqm_2014") { ?>
591 <a href='#' id="genQRDA" class='btn btn-default btn-transmit' onclick='return downloadQRDA()'>
592 <?php echo xlt('Generate QRDA I – 2014'); ?>
593 </a>
594 <a href='#' id="xmlc_button" class='btn btn-default btn-transmit' onclick='return GenXml("QRDA")'>
595 <?php echo xlt('Generate QRDA III - 2014'); ?>
596 </a>
597 <?php } ?>
598 <?php if ($back_link == "list") { ?>
599 <a href='report_results.php' class='btn btn-default btn-transmit' onclick='top.restoreSession()'>
600 <?php echo xlt("Return To Report Results"); ?>
601 </a>
602 <?php } else { ?>
603 <a href='#' class='btn btn-default btn-transmit' onclick='top.restoreSession(); $("#theform").submit();'>
604 <?php echo xlt("Start Another Report"); ?>
605 </a>
606 <?php } ?>
607 <?php } ?>
608 </div>
609 </div>
610 </td>
611 </tr>
612 </table>
613 </td>
614 </tr>
615 </table>
617 </div> <!-- end of search parameters -->
619 <br>
621 <?php
622 if (!empty($report_id)) {
626 <div id="report_results">
627 <table>
629 <thead>
630 <th>
631 <?php echo xlt('Title'); ?>
632 </th>
634 <th>
635 <?php
636 if ($type_report == 'cqm' || $type_report == 'cqm_2011' || $type_report == 'cqm_2014') {
637 echo xlt('Initial Patient Population');
638 } else {
639 echo xlt('Total Patients');
642 </th>
644 <th>
645 <?php if ($type_report == "amc") { ?>
646 <?php echo xlt('Denominator'); ?></a>
647 <?php } else { ?>
648 <?php echo xlt('Applicable Patients') .' (' . xlt('Denominator') . ')'; ?></a>
649 <?php } ?>
650 </th>
652 <?php if ($type_report != "amc") { ?>
653 <th>
654 <?php echo xlt('Denominator Exclusion'); ?></a>
655 </th>
656 <?php }?>
657 <?php if ($type_report == 'cqm' || $type_report == 'cqm_2011' || $type_report == 'cqm_2014') {?>
658 <th>
659 <?php echo xlt('Denominator Exception'); ?></a>
660 </th>
661 <?php } ?>
663 <th>
664 <?php if ($type_report == "amc") { ?>
665 <?php echo xlt('Numerator'); ?></a>
666 <?php } else { ?>
667 <?php echo xlt('Passed Patients') . ' (' . xlt('Numerator') . ')'; ?></a>
668 <?php } ?>
669 </th>
671 <th>
672 <?php if ($type_report == "amc") { ?>
673 <?php echo xlt('Failed'); ?></a>
674 <?php } else { ?>
675 <?php echo xlt('Failed Patients'); ?></a>
676 <?php } ?>
677 </th>
679 <th>
680 <?php echo xlt('Performance Percentage'); ?></a>
681 </th>
683 </thead>
684 <tbody> <!-- added for better print-ability -->
685 <?php
687 $firstProviderFlag = true;
688 $firstPlanFlag = true;
689 $existProvider = false;
690 foreach ($dataSheet as $row) {
693 <tr bgcolor='<?php echo $bgcolor ?>'>
695 <?php
696 if (isset($row['is_main']) || isset($row['is_sub'])) {
697 echo "<td class='detail'>";
698 if (isset($row['is_main'])) {
699 // is_sub is a special case of is_main whereas total patients, denominator, and excluded patients are taken
700 // from is_main prior to it. So, need to store denominator patients from is_main for subsequent is_sub
701 // to calculate the number of patients that failed.
702 // Note that exlusion in the standard rules is not the same as in the cqm/amd and should not be in calculation
703 // as is in the cqm/amc rules.
704 $main_pass_filter = $row['pass_filter'];
706 echo "<b>".generate_display_field(array('data_type'=>'1','list_id'=>'clinical_rules'), $row['id'])."</b>";
708 $tempCqmAmcString = "";
709 if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) {
710 if (!empty($row['cqm_pqri_code'])) {
711 $tempCqmAmcString .= " " . xlt('PQRI') . ":" . text($row['cqm_pqri_code']) . " ";
714 if (!empty($row['cqm_nqf_code'])) {
715 $tempCqmAmcString .= " " . xlt('NQF') . ":" . text($row['cqm_nqf_code']) . " ";
719 if ($type_report == "amc") {
720 if (!empty($row['amc_code'])) {
721 $tempCqmAmcString .= " " . xlt('AMC-2011') . ":" . text($row['amc_code']) . " ";
724 if (!empty($row['amc_code_2014'])) {
725 $tempCqmAmcString .= " " . xlt('AMC-2014') . ":" . text($row['amc_code_2014']) . " ";
729 if ($type_report == "amc_2011") {
730 if (!empty($row['amc_code'])) {
731 $tempCqmAmcString .= " " . xlt('AMC-2011') . ":" . text($row['amc_code']) . " ";
735 if (($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) {
736 if (!empty($row['amc_code_2014'])) {
737 $tempCqmAmcString .= " " . xlt('AMC-2014') . ":" . text($row['amc_code_2014']) . " ";
741 if (!empty($tempCqmAmcString)) {
742 echo "(".$tempCqmAmcString.")";
745 if (!(empty($row['concatenated_label']))) {
746 echo ", " . xlt($row['concatenated_label']) . " ";
748 } else { // isset($row['is_sub'])
749 echo generate_display_field(array('data_type'=>'1','list_id'=>'rule_action_category'), $row['action_category']);
750 echo ": " . generate_display_field(array('data_type'=>'1','list_id'=>'rule_action'), $row['action_item']);
753 echo "</td>";
755 if ($type_report == 'cqm' || $type_report == 'cqm_2011' || $type_report == 'cqm_2014') {
756 echo "<td align='center'>" . text($row['initial_population']) . "</td>";
757 } else {
758 echo "<td align='center'>" . text($row['total_patients']) . "</td>";
761 if (isset($row['itemized_test_id']) && ($row['pass_filter'] > 0)) {
762 echo "<td align='center'><a href='../main/finder/patient_select.php?from_page=cdr_report&pass_id=all&report_id=".attr($report_id)."&itemized_test_id=".attr($row['itemized_test_id'])."&numerator_label=".urlencode(attr($row['numerator_label']))."' onclick='top.restoreSession()'>" . text($row['pass_filter']) . "</a></td>";
763 } else {
764 echo "<td align='center'>" . text($row['pass_filter']) . "</td>";
767 if ($type_report != "amc") {
768 // Note that amc will likely support in excluded items in the future for MU2
769 if (($type_report != "standard") && isset($row['itemized_test_id']) && ($row['excluded'] > 0)) {
770 // Note standard reporting exluded is different than cqm/amc and will not support itemization
771 echo "<td align='center'><a href='../main/finder/patient_select.php?from_page=cdr_report&pass_id=exclude&report_id=".attr($report_id)."&itemized_test_id=".attr($row['itemized_test_id'])."&numerator_label=".urlencode(attr($row['numerator_label']))."' onclick='top.restoreSession()'>" . text($row['excluded']) . "</a></td>";
772 } else {
773 echo "<td align='center'>" . text($row['excluded']) . "</td>";
777 if ($type_report == 'cqm' || $type_report == 'cqm_2011' || $type_report == 'cqm_2014') {
778 // Note that amc will likely support in exception items in the future for MU2
779 if (isset($row['itemized_test_id']) && ($row['exception'] > 0)) {
780 // Note standard reporting exluded is different than cqm/amc and will not support itemization
781 echo "<td align='center'><a href='../main/finder/patient_select.php?from_page=cdr_report&pass_id=exception&report_id=".attr($report_id)."&itemized_test_id=".attr($row['itemized_test_id'])."&numerator_label=".urlencode(attr($row['numerator_label']))."' onclick='top.restoreSession()'>" . text($row['exception']) . "</a></td>";
782 } else {
783 echo "<td align='center'>" . text($row['exception']) . "</td>";
787 if (isset($row['itemized_test_id']) && ($row['pass_target'] > 0)) {
788 echo "<td align='center'><a href='../main/finder/patient_select.php?from_page=cdr_report&pass_id=pass&report_id=".attr($report_id)."&itemized_test_id=".attr($row['itemized_test_id'])."&numerator_label=".urlencode(attr($row['numerator_label']))."' onclick='top.restoreSession()'>" . text($row['pass_target']) . "</a></td>";
789 } else {
790 echo "<td align='center'>" . text($row['pass_target']) . "</td>";
793 $failed_items = 0;
794 if (isset($row['is_main'])) {
795 if ($type_report == "standard") {
796 // Excluded is not part of denominator in standard rules so do not use in calculation
797 $failed_items = $row['pass_filter'] - $row['pass_target'];
798 } else {
799 $failed_items = $row['pass_filter'] - $row['pass_target'] - $row['excluded'];
801 } else { // isset($row['is_sub'])
802 // Excluded is not part of denominator in standard rules so do not use in calculation
803 $failed_items = $main_pass_filter - $row['pass_target'];
806 if (isset($row['itemized_test_id']) && ($failed_items > 0)) {
807 echo "<td align='center'><a href='../main/finder/patient_select.php?from_page=cdr_report&pass_id=fail&report_id=".attr($report_id)."&itemized_test_id=".attr($row['itemized_test_id'])."&numerator_label=".urlencode(attr($row['numerator_label']))."' onclick='top.restoreSession()'>" . text($failed_items) . "</a></td>";
808 } else {
809 echo "<td align='center'>" . text($failed_items) . "</td>";
812 echo "<td align='center'>" . text($row['percentage']) . "</td>";
813 } else if (isset($row['is_provider'])) {
814 // Display the provider information
815 if (!$firstProviderFlag && $_POST['form_provider'] == 'collate_outer') {
816 echo "<tr><td>&nbsp</td></tr>";
819 echo "<td class='detail' align='center'><b>";
820 echo xlt("Provider").": " . text($row['prov_lname']) . "," . text($row['prov_fname']);
821 if (!empty($row['npi']) || !empty($row['federaltaxid'])) {
822 echo " (";
823 if (!empty($row['npi'])) {
824 echo " " . xlt('NPI') . ":" . text($row['npi']) . " ";
827 if (!empty($row['federaltaxid'])) {
828 echo " " . xlt('TID') . ":" . text($row['federaltaxid']) . " ";
831 echo ")";
834 echo "</b></td>";
835 $firstProviderFlag = false;
836 $existProvider = true;
837 } else { // isset($row['is_plan'])
838 if (!$firstPlanFlag && $_POST['form_provider'] != 'collate_outer') {
839 echo "<tr><td>&nbsp</td></tr>";
842 echo "<td class='detail' align='center'><b>";
843 echo xlt("Plan") . ": ";
844 echo generate_display_field(array('data_type'=>'1','list_id'=>'clinical_plans'), $row['id']);
845 if (!empty($row['cqm_measure_group'])) {
846 echo " (". xlt('Measure Group Code') . ": " . text($row['cqm_measure_group']) . ")";
849 echo "</b></td>";
850 $firstPlanFlag = false;
853 </tr>
855 <?php
858 </tbody>
859 </table>
860 </div> <!-- end of search results -->
861 <?php } else { ?>
862 <div id="instructions_text" class='text'>
863 <?php echo xlt('Please input search criteria above, and click Submit to start report.'); ?>
864 </div>
865 <?php } ?>
867 <input type='hidden' name='form_new_report_id' id='form_new_report_id' value=''/>
869 </form>
871 </body>
873 </html>