ongoing internationalization of date widget
[openemr.git] / interface / reports / cqm.php
blob772f9e7a3bc171cd93139dde4db5dc79f357faa1
1 <?php
2 /**
4 * Copyright (C) 2010-2017 Brady Miller <brady.g.miller@gmail.com>
6 * LICENSE: This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
17 * @package OpenEMR
18 * @author Brady Miller <brady.g.miller@gmail.com>
19 * @link http://www.open-emr.org
23 use OpenEMR\Core\Header;
25 require_once("../globals.php");
26 require_once("../../library/patient.inc");
27 require_once "$srcdir/options.inc.php";
28 require_once "$srcdir/clinical_rules.php";
29 require_once "$srcdir/report_database.inc";
31 // See if showing an old report or creating a new report
32 $report_id = (isset($_GET['report_id'])) ? trim($_GET['report_id']) : "";
34 // Collect the back variable, if pertinent
35 $back_link = (isset($_GET['back'])) ? trim($_GET['back']) : "";
37 // If showing an old report, then collect information
38 if (!empty($report_id)) {
39 $report_view = collectReportDatabase($report_id);
40 $date_report = $report_view['date_report'];
41 $type_report = $report_view['type'];
43 $type_report = (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2") ||
44 ($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) ? $type_report : "standard";
45 $rule_filter = $report_view['type'];
47 if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) {
48 $begin_date = $report_view['date_begin'];
49 $labs_manual = $report_view['labs_manual'];
52 $target_date = $report_view['date_target'];
53 $plan_filter = $report_view['plan'];
54 $organize_method = $report_view['organize_mode'];
55 $provider = $report_view['provider'];
56 $pat_prov_rel = $report_view['pat_prov_rel'];
57 $dataSheet = json_decode($report_view['data'], true);
58 } else {
59 // Collect report type parameter (standard, amc, cqm)
60 // Note that need to convert amc_2011 and amc_2014 to amc and cqm_2011 and cqm_2014 to cqm
61 // to simplify for when submitting for a new report.
62 $type_report = (isset($_GET['type'])) ? trim($_GET['type']) : "standard";
64 if (($type_report == "cqm_2011") || ($type_report == "cqm_2014")) {
65 $type_report = "cqm";
68 if (($type_report == "amc_2011") || ($type_report == "amc_2014") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) {
69 $type_report = "amc";
72 // Collect form parameters (set defaults if empty)
73 if ($type_report == "amc") {
74 $begin_date = (isset($_POST['form_begin_date'])) ? trim($_POST['form_begin_date']) : "";
75 $labs_manual = (isset($_POST['labs_manual_entry'])) ? trim($_POST['labs_manual_entry']) : "0";
78 $target_date = (isset($_POST['form_target_date'])) ? trim($_POST['form_target_date']) : date('Y-m-d H:i:s');
79 $rule_filter = (isset($_POST['form_rule_filter'])) ? trim($_POST['form_rule_filter']) : "";
80 $plan_filter = (isset($_POST['form_plan_filter'])) ? trim($_POST['form_plan_filter']) : "";
81 $organize_method = (empty($plan_filter)) ? "default" : "plans";
82 $provider = trim($_POST['form_provider']);
83 $pat_prov_rel = (empty($_POST['form_pat_prov_rel'])) ? "primary" : trim($_POST['form_pat_prov_rel']);
87 <html>
89 <head>
91 <?php if ($type_report == "standard") { ?>
92 <title><?php echo xlt('Standard Measures'); ?></title>
93 <?php } ?>
95 <?php if ($type_report == "cqm") { ?>
96 <title><?php echo xlt('Clinical Quality Measures (CQM)'); ?></title>
97 <?php } ?>
98 <?php if ($type_report == "cqm_2011") { ?>
99 <title><?php echo xlt('Clinical Quality Measures (CQM) - 2011'); ?></title>
100 <?php } ?>
101 <?php if ($type_report == "cqm_2014") { ?>
102 <title><?php echo xlt('Clinical Quality Measures (CQM) - 2014'); ?></title>
103 <?php } ?>
105 <?php if ($type_report == "amc") { ?>
106 <title><?php echo xlt('Automated Measure Calculations (AMC)'); ?></title>
107 <?php } ?>
108 <?php if ($type_report == "amc_2011") { ?>
109 <title><?php echo xlt('Automated Measure Calculations (AMC) - 2011'); ?></title>
110 <?php } ?>
111 <?php if ($type_report == "amc_2014_stage1") { ?>
112 <title><?php echo xlt('Automated Measure Calculations (AMC) - 2014 Stage I'); ?></title>
113 <?php } ?>
114 <?php if ($type_report == "amc_2014_stage2") { ?>
115 <title><?php echo xlt('Automated Measure Calculations (AMC) - 2014 Stage II'); ?></title>
116 <?php } ?>
118 <?php Header::setupHeader('datetime-picker'); ?>
120 <script LANGUAGE="JavaScript">
122 var mypcc = '<?php echo text($GLOBALS['phone_country_code']) ?>';
124 $(document).ready(function() {
125 var win = top.printLogSetup ? top : opener.top;
126 win.printLogSetup(document.getElementById('printbutton'));
128 $('.datepicker').datetimepicker({
129 <?php $datetimepicker_timepicker = true; ?>
130 <?php $datetimepicker_showseconds = true; ?>
131 <?php $datetimepicker_formatInput = false; ?>
132 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
133 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
137 function runReport() {
139 // Validate first
140 if (!(validateForm())) {
141 alert("<?php echo xls("Rule Set and Plan Set selections are not consistent. Please fix and Submit again."); ?>");
142 return false;
145 // Showing processing wheel
146 $("#processing").show();
148 // hide Submit buttons
149 $("#submit_button").hide();
150 $("#xmla_button").hide();
151 $("#xmlb_button").hide();
152 $("#xmlc_button").hide();
153 $("#print_button").hide();
154 $("#genQRDA").hide();
156 // hide instructions
157 $("#instructions_text").hide();
159 // Collect an id string via an ajax request
160 top.restoreSession();
161 $.get("../../library/ajax/collect_new_report_id.php",
162 function(data){
163 // Set the report id in page form
164 $("#form_new_report_id").attr("value",data);
166 // Start collection status checks
167 collectStatus($("#form_new_report_id").val());
169 // Run the report
170 top.restoreSession();
171 $.post("../../library/ajax/execute_cdr_report.php",
172 {provider: $("#form_provider").val(),
173 type: $("#form_rule_filter").val(),
174 date_target: $("#form_target_date").val(),
175 date_begin: $("#form_begin_date").val(),
176 plan: $("#form_plan_filter").val(),
177 labs: $("#labs_manual_entry").val(),
178 pat_prov_rel: $("#form_pat_prov_rel").val(),
179 execute_report_id: $("#form_new_report_id").val()
184 function collectStatus(report_id) {
185 // Collect the status string via an ajax request and place in DOM at timed intervals
186 top.restoreSession();
187 // Do not send the skip_timeout_reset parameter, so don't close window before report is done.
188 $.post("../../library/ajax/status_report.php",
189 {status_report_id: report_id},
190 function(data){
191 if (data == "PENDING") {
192 // Place the pending string in the DOM
193 $('#status_span').replaceWith("<span id='status_span'><?php echo xlt("Preparing To Run Report"); ?></span>");
195 else if (data == "COMPLETE") {
196 // Go into the results page
197 top.restoreSession();
198 link_report = "cqm.php?report_id="+report_id;
199 window.open(link_report,'_self',false);
200 //$("#processing").hide();
201 //$('#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>");
203 else {
204 // Place the string in the DOM
205 $('#status_span').replaceWith("<span id='status_span'>"+data+"</span>");
208 // run status check every 10 seconds
209 var repeater = setTimeout("collectStatus("+report_id+")", 10000);
212 function GenXml(sNested) {
213 top.restoreSession();
214 //QRDA Category III Export
215 if(sNested == "QRDA"){
216 var form_rule_filter = theform.form_rule_filter.value
217 var sLoc = '../../custom/export_qrda_xml.php?target_date=' + theform.form_target_date.value + '&qrda_version=3&rule_filter=cqm_2014&form_provider='+theform.form_provider.value+"&report_id=<?php echo attr($report_id);?>";
218 }else{
219 var sLoc = '../../custom/export_registry_xml.php?&target_date=' + theform.form_target_date.value + '&nested=' + sNested;
221 dlgopen(sLoc, '_blank', 600, 500);
222 return false;
225 //QRDA I - 2014 Download
226 function downloadQRDA() {
227 top.restoreSession();
228 var reportID = '<?php echo attr($report_id); ?>';
229 var provider = $("#form_provider").val();
230 sLoc = '../../custom/download_qrda.php?&report_id=' + reportID + '&provider_id=' + provider;
231 dlgopen(sLoc, '_blank', 600, 500);
234 function validateForm() {
235 <?php if ((empty($report_id)) && ($type_report == "cqm")) { ?>
236 // If this is a cqm and plan set not set to ignore, then need to ensure consistent with the rules set
237 if ($("#form_plan_filter").val() != '') {
238 if ($("#form_rule_filter").val() == $("#form_plan_filter").val()) {
239 return true;
240 } else {
241 return false;
244 else {
245 return true;
247 <?php } else { ?>
248 return true;
249 <?php } ?>
252 function Form_Validate() {
253 <?php if ((empty($report_id)) && (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2"))) { ?>
254 var d = document.forms[0];
255 FromDate = d.form_begin_date.value;
256 ToDate = d.form_target_date.value;
257 if ( (FromDate.length > 0) && (ToDate.length > 0) ) {
258 if (FromDate > ToDate){
259 alert("<?php echo xls('End date must be later than Begin date!'); ?>");
260 return false;
263 <?php } ?>
265 //For Results are in Gray Background & disabling anchor links
266 <?php if ($report_id != "") {?>
267 $("#report_results").css("opacity", '0.4');
268 $("#report_results").css("filter", 'alpha(opacity=40)');
269 $("a").removeAttr("href");
270 <?php }?>
272 $("#form_refresh").attr("value","true");
273 runReport();
274 return true;
277 </script>
279 <style type="text/css">
281 /* specifically include & exclude from printing */
282 @media print {
283 #report_parameters {
284 visibility: hidden;
285 display: none;
287 #report_parameters_daterange {
288 visibility: visible;
289 display: inline;
291 #report_results table {
292 margin-top: 0px;
296 /* specifically exclude some from the screen */
297 @media screen {
298 #report_parameters_daterange {
299 visibility: hidden;
300 display: none;
304 </style>
305 </head>
307 <body class="body_top">
309 <!-- Required for the popup date selectors -->
310 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
312 <span class='title'><?php echo xlt('Report'); ?> -
314 <?php if ($type_report == "standard") { ?>
315 <?php echo xlt('Standard Measures'); ?>
316 <?php } ?>
318 <?php if ($type_report == "cqm") { ?>
319 <?php echo xlt('Clinical Quality Measures (CQM)'); ?>
320 <?php } ?>
321 <?php if ($type_report == "cqm_2011") { ?>
322 <?php echo xlt('Clinical Quality Measures (CQM) - 2011'); ?>
323 <?php } ?>
324 <?php if ($type_report == "cqm_2014") { ?>
325 <?php echo xlt('Clinical Quality Measures (CQM) - 2014'); ?>
326 <?php } ?>
328 <?php if ($type_report == "amc") { ?>
329 <?php echo xlt('Automated Measure Calculations (AMC)'); ?>
330 <?php } ?>
331 <?php if ($type_report == "amc_2011") { ?>
332 <?php echo xlt('Automated Measure Calculations (AMC) - 2011'); ?>
333 <?php } ?>
334 <?php if ($type_report == "amc_2014_stage1") { ?>
335 <?php echo xlt('Automated Measure Calculations (AMC) - 2014 Stage I'); ?>
336 <?php } ?>
337 <?php if ($type_report == "amc_2014_stage2") { ?>
338 <?php echo xlt('Automated Measure Calculations (AMC) - 2014 Stage II'); ?>
339 <?php } ?>
341 <?php if (!empty($report_id)) { ?>
342 <?php echo " - " . xlt('Date of Report') . ": " . text($date_report);
343 //prepare to disable form elements
344 $dis_text = " disabled='disabled' ";
346 <?php } ?>
347 </span>
349 <form method='post' name='theform' id='theform' action='cqm.php?type=<?php echo attr($type_report) ;?>' onsubmit='return validateForm()'>
351 <div id="report_parameters">
352 <?php
353 $widthDyn = "470px";
354 if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) {
355 $widthDyn = "410px";
358 <table>
359 <tr>
360 <td scope="row" width='<?php echo $widthDyn;?>'>
361 <div style='float:left'>
363 <table class='text'>
365 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
366 <tr>
367 <td class='control-label'>
368 <?php echo htmlspecialchars(xl('Begin Date'), ENT_NOQUOTES); ?>:
369 </td>
370 <td>
371 <input <?php echo $dis_text; ?> type='text' name='form_begin_date' id="form_begin_date" size='20' value='<?php echo htmlspecialchars($begin_date, ENT_QUOTES); ?>'
372 class='datepicker form-control'
373 title='<?php echo htmlspecialchars(xl('yyyy-mm-dd hh:mm:ss'), ENT_QUOTES); ?>'>
374 <?php if (empty($report_id)) { ?>
375 <?php } ?>
376 </td>
377 </tr>
378 <?php } ?>
380 <tr>
381 <td class='control-label'>
382 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
383 <?php echo htmlspecialchars(xl('End Date'), ENT_NOQUOTES); ?>:
384 <?php } else { ?>
385 <?php echo htmlspecialchars(xl('Target Date'), ENT_NOQUOTES); ?>:
386 <?php } ?>
387 </td>
388 <td>
389 <input <?php echo $dis_text; ?> type='text' name='form_target_date' id="form_target_date" size='20' value='<?php echo htmlspecialchars($target_date, ENT_QUOTES); ?>'
390 class='datepicker form-control'
391 title='<?php echo htmlspecialchars(xl('yyyy-mm-dd hh:mm:ss'), ENT_QUOTES); ?>'>
392 <?php if (empty($report_id)) { ?>
393 <?php } ?>
394 </td>
395 </tr>
397 <?php if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) { ?>
398 <tr>
399 <td class='control-label'>
400 <?php echo xlt('Rule Set'); ?>:
401 </td>
402 <td>
403 <select <?php echo $dis_text; ?> id='form_rule_filter' name='form_rule_filter' class='form-control'>
404 <option value='cqm' <?php if ($rule_filter == "cqm") {
405 echo "selected";
406 } ?>>
407 <?php echo xlt('All Clinical Quality Measures (CQM)'); ?></option>
408 <option value='cqm_2011' <?php if ($rule_filter == "cqm_2011") {
409 echo "selected";
410 } ?>>
411 <?php echo xlt('2011 Clinical Quality Measures (CQM)'); ?></option>
412 <option value='cqm_2014' <?php if ($rule_filter == "cqm_2014") {
413 echo "selected";
414 } ?>>
415 <?php echo xlt('2014 Clinical Quality Measures (CQM)'); ?></option>
416 </select>
417 </td>
418 </tr>
419 <?php } ?>
421 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
422 <tr>
423 <td class='control-label'>
424 <?php echo xlt('Rule Set'); ?>:
425 </td>
426 <td>
427 <select <?php echo $dis_text; ?> id='form_rule_filter' name='form_rule_filter' class='form-control'>
429 <?php if ($rule_filter == "amc") { //only show this when displaying old reports. Not available option for new reports ?>
430 <option value='amc' selected>
431 <?php echo xlt('All Automated Measure Calculations (AMC)'); ?></option>
432 <?php } ?>
434 <option value='amc_2011' <?php if ($rule_filter == "amc_2011") {
435 echo "selected";
436 } ?>>
437 <?php echo xlt('2011 Automated Measure Calculations (AMC)'); ?></option>
438 <option value='amc_2014_stage1' <?php if ($rule_filter == "amc_2014_stage1") {
439 echo "selected";
440 } ?>>
441 <?php echo xlt('2014 Automated Measure Calculations (AMC) - Stage I'); ?></option>
442 <option value='amc_2014_stage2' <?php if ($rule_filter == "amc_2014_stage2") {
443 echo "selected";
444 } ?>>
445 <?php echo xlt('2014 Automated Measure Calculations (AMC) - Stage II'); ?></option>
446 </select>
447 </td>
448 </tr>
449 <?php } ?>
451 <?php if ($type_report == "standard") { ?>
452 <tr>
453 <td class='control-label'>
454 <?php echo xlt('Rule Set'); ?>:
455 </td>
456 <td>
457 <select <?php echo $dis_text; ?> id='form_rule_filter' name='form_rule_filter' class='form-control'>
458 <option value='passive_alert' <?php if ($rule_filter == "passive_alert") {
459 echo "selected";
460 } ?>>
461 <?php echo xlt('Passive Alert Rules'); ?></option>
462 <option value='active_alert' <?php if ($rule_filter == "active_alert") {
463 echo "selected";
464 } ?>>
465 <?php echo xlt('Active Alert Rules'); ?></option>
466 <option value='patient_reminder' <?php if ($rule_filter == "patient_reminder") {
467 echo "selected";
468 } ?>>
469 <?php echo xlt('Patient Reminder Rules'); ?></option>
470 </select>
471 </td>
472 </tr>
473 <?php } ?>
475 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
476 <input type='hidden' id='form_plan_filter' name='form_plan_filter' value=''>
477 <?php } else { ?>
478 <tr>
479 <td class='control-label'>
480 <?php echo htmlspecialchars(xl('Plan Set'), ENT_NOQUOTES); ?>:
481 </td>
482 <td>
483 <select <?php echo $dis_text; ?> id='form_plan_filter' name='form_plan_filter' class='form-control'>
484 <option value=''>-- <?php echo htmlspecialchars(xl('Ignore'), ENT_NOQUOTES); ?> --</option>
485 <?php if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) { ?>
486 <option value='cqm' <?php if ($plan_filter == "cqm") {
487 echo "selected";
488 } ?>>
489 <?php echo htmlspecialchars(xl('All Official Clinical Quality Measures (CQM) Measure Groups'), ENT_NOQUOTES); ?></option>
490 <option value='cqm_2011' <?php if ($plan_filter == "cqm_2011") {
491 echo "selected";
492 } ?>>
493 <?php echo htmlspecialchars(xl('2011 Official Clinical Quality Measures (CQM) Measure Groups'), ENT_NOQUOTES); ?></option>
494 <option value='cqm_2014' <?php if ($plan_filter == "cqm_2014") {
495 echo "selected";
496 } ?>>
497 <?php echo htmlspecialchars(xl('2014 Official Clinical Quality Measures (CQM) Measure Groups'), ENT_NOQUOTES); ?></option>
498 <?php } ?>
499 <?php if ($type_report == "standard") { ?>
500 <option value='normal' <?php if ($plan_filter == "normal") {
501 echo "selected";
502 } ?>>
503 <?php echo htmlspecialchars(xl('Active Plans'), ENT_NOQUOTES); ?></option>
504 <?php } ?>
505 </td>
506 </tr>
507 <?php } ?>
509 <tr>
510 <td class='control-label'>
511 <?php echo htmlspecialchars(xl('Provider'), ENT_NOQUOTES); ?>:
512 </td>
513 <td>
514 <?php
516 // Build a drop-down list of providers.
519 $query = "SELECT id, lname, fname FROM users WHERE ".
520 "authorized = 1 $provider_facility_filter ORDER BY lname, fname"; //(CHEMED) facility filter
522 $ures = sqlStatement($query);
524 echo " <select " . $dis_text . " id='form_provider' name='form_provider' class='form-control'>\n";
525 echo " <option value=''>-- " . htmlspecialchars(xl('All (Cumulative)'), ENT_NOQUOTES) . " --\n";
527 echo " <option value='collate_outer'";
528 if ($provider == 'collate_outer') {
529 echo " selected";
532 echo ">-- " . htmlspecialchars(xl('All (Collated Format A)'), ENT_NOQUOTES) . " --\n";
534 echo " <option value='collate_inner'";
535 if ($provider == 'collate_inner') {
536 echo " selected";
539 echo ">-- " . htmlspecialchars(xl('All (Collated Format B)'), ENT_NOQUOTES) . " --\n";
541 while ($urow = sqlFetchArray($ures)) {
542 $provid = $urow['id'];
543 echo " <option value='".htmlspecialchars($provid, ENT_QUOTES)."'";
544 if ($provid == $provider) {
545 echo " selected";
548 echo ">" . htmlspecialchars($urow['lname'] . ", " . $urow['fname'], ENT_NOQUOTES) . "\n";
551 echo " </select>\n";
554 </td>
555 </tr>
557 <tr>
558 <td class='control-label'>
559 <?php echo htmlspecialchars(xl('Provider Relationship'), ENT_NOQUOTES); ?>:
560 </td>
561 <td>
562 <?php
564 // Build a drop-down list of of patient provider relationships.
566 echo " <select ". $dis_text ." id='form_pat_prov_rel' name='form_pat_prov_rel' class='form-control' title='" . xlt('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";
567 echo " <option value='primary'";
568 if ($pat_prov_rel == 'primary') {
569 echo " selected";
572 echo ">" . xlt('Primary') . "\n";
573 echo " <option value='encounter'";
574 if ($pat_prov_rel == 'encounter') {
575 echo " selected";
578 echo ">" . xlt('Encounter') . "\n";
579 echo " </select>\n";
581 </td>
582 </tr>
584 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
585 <tr>
586 <td>
587 <?php echo htmlspecialchars(xl('Number labs'), ENT_NOQUOTES); ?>:<br>
588 (<?php echo htmlspecialchars(xl('Non-electronic'), ENT_NOQUOTES); ?>)
589 </td>
590 <td>
591 <input <?php echo $dis_text; ?> type="text" id="labs_manual_entry" name="labs_manual_entry" class='form-control' value="<?php echo htmlspecialchars($labs_manual, ENT_QUOTES); ?>">
592 </td>
593 </tr>
594 <?php } ?>
596 </table>
598 </div>
600 </td>
601 <td align='left' valign='middle' height="100%">
602 <table style='border-left:1px solid; width:100%; height:100%' >
603 <tr>
604 <td scope="row">
605 <div class="text-center">
606 <div class="btn-group" role="group">
607 <?php if (empty($report_id)) { ?>
608 <a href='#' id='submit_button' class='btn btn-default btn-save' onclick='runReport();'>
609 <?php echo xlt('Submit'); ?>
610 </a>
611 <span id='status_span'></span>
612 <div id='processing' style='margin:10px;display:none;'><img src='../pic/ajax-loader.gif'/></div>
613 <?php if ($type_report == "cqm") { ?>
614 <a href='#' id='xmla_button' class='btn btn-default btn-transmit' onclick='return GenXml("false")'>
615 <?php echo xlt('Generate PQRI report (Method A) - 2011'); ?>
616 </a>
617 <a href='#' id='xmlb_button' class='btn btn-default btn-transmit' onclick='return GenXml("true")'>
618 <?php echo xlt('Generate PQRI report (Method E) - 2011'); ?>
619 </a>
620 <?php } ?>
621 <?php } ?>
622 <?php if (!empty($report_id)) { ?>
623 <a href='#' class='btn btn-default btn-print' id='printbutton'>
624 <?php echo xlt('Print'); ?>
625 </a>
626 <?php if ($type_report == "cqm_2014") { ?>
627 <a href='#' id="genQRDA" class='btn btn-default btn-transmit' onclick='return downloadQRDA()'>
628 <?php echo xlt('Generate QRDA I – 2014'); ?>
629 </a>
630 <a href='#' id="xmlc_button" class='btn btn-default btn-transmit' onclick='return GenXml("QRDA")'>
631 <?php echo xlt('Generate QRDA III - 2014'); ?>
632 </a>
633 <?php } ?>
634 <?php if ($back_link == "list") { ?>
635 <a href='report_results.php' class='btn btn-default btn-transmit' onclick='top.restoreSession()'>
636 <?php echo xlt("Return To Report Results"); ?>
637 </a>
638 <?php } else { ?>
639 <a href='#' class='btn btn-default btn-transmit' onclick='top.restoreSession(); $("#theform").submit();'>
640 <?php echo xlt("Start Another Report"); ?>
641 </a>
642 <?php } ?>
643 <?php } ?>
644 </div>
645 </div>
646 </td>
647 </tr>
648 </table>
649 </td>
650 </tr>
651 </table>
653 </div> <!-- end of search parameters -->
655 <br>
657 <?php
658 if (!empty($report_id)) {
662 <div id="report_results">
663 <table>
665 <thead>
666 <th>
667 <?php echo htmlspecialchars(xl('Title'), ENT_NOQUOTES); ?>
668 </th>
670 <th>
671 <?php
672 if ($type_report == 'cqm' || $type_report == 'cqm_2011' || $type_report == 'cqm_2014') {
673 echo htmlspecialchars(xl('Initial Patient Population'), ENT_NOQUOTES);
674 } else {
675 echo htmlspecialchars(xl('Total Patients'), ENT_NOQUOTES);
678 </th>
680 <th>
681 <?php if ($type_report == "amc") { ?>
682 <?php echo htmlspecialchars(xl('Denominator'), ENT_NOQUOTES); ?></a>
683 <?php } else { ?>
684 <?php echo htmlspecialchars(xl('Applicable Patients') .' (' . xl('Denominator') . ')', ENT_NOQUOTES); ?></a>
685 <?php } ?>
686 </th>
688 <?php if ($type_report != "amc") { ?>
689 <th>
690 <?php echo htmlspecialchars(xl('Denominator Exclusion'), ENT_NOQUOTES); ?></a>
691 </th>
692 <?php }?>
693 <?php if ($type_report == 'cqm' || $type_report == 'cqm_2011' || $type_report == 'cqm_2014') {?>
694 <th>
695 <?php echo htmlspecialchars(xl('Denominator Exception'), ENT_NOQUOTES); ?></a>
696 </th>
697 <?php } ?>
699 <th>
700 <?php if ($type_report == "amc") { ?>
701 <?php echo htmlspecialchars(xl('Numerator'), ENT_NOQUOTES); ?></a>
702 <?php } else { ?>
703 <?php echo htmlspecialchars(xl('Passed Patients') . ' (' . xl('Numerator') . ')', ENT_NOQUOTES); ?></a>
704 <?php } ?>
705 </th>
707 <th>
708 <?php if ($type_report == "amc") { ?>
709 <?php echo htmlspecialchars(xl('Failed'), ENT_NOQUOTES); ?></a>
710 <?php } else { ?>
711 <?php echo htmlspecialchars(xl('Failed Patients'), ENT_NOQUOTES); ?></a>
712 <?php } ?>
713 </th>
715 <th>
716 <?php echo htmlspecialchars(xl('Performance Percentage'), ENT_NOQUOTES); ?></a>
717 </th>
719 </thead>
720 <tbody> <!-- added for better print-ability -->
721 <?php
723 $firstProviderFlag = true;
724 $firstPlanFlag = true;
725 $existProvider = false;
726 foreach ($dataSheet as $row) {
729 <tr bgcolor='<?php echo $bgcolor ?>'>
731 <?php
732 if (isset($row['is_main']) || isset($row['is_sub'])) {
733 echo "<td class='detail'>";
734 if (isset($row['is_main'])) {
735 // is_sub is a special case of is_main whereas total patients, denominator, and excluded patients are taken
736 // from is_main prior to it. So, need to store denominator patients from is_main for subsequent is_sub
737 // to calculate the number of patients that failed.
738 // Note that exlusion in the standard rules is not the same as in the cqm/amd and should not be in calculation
739 // as is in the cqm/amc rules.
740 $main_pass_filter = $row['pass_filter'];
742 echo "<b>".generate_display_field(array('data_type'=>'1','list_id'=>'clinical_rules'), $row['id'])."</b>";
744 $tempCqmAmcString = "";
745 if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) {
746 if (!empty($row['cqm_pqri_code'])) {
747 $tempCqmAmcString .= " " . htmlspecialchars(xl('PQRI') . ":" . $row['cqm_pqri_code'], ENT_NOQUOTES) . " ";
750 if (!empty($row['cqm_nqf_code'])) {
751 $tempCqmAmcString .= " " . htmlspecialchars(xl('NQF') . ":" . $row['cqm_nqf_code'], ENT_NOQUOTES) . " ";
755 if ($type_report == "amc") {
756 if (!empty($row['amc_code'])) {
757 $tempCqmAmcString .= " " . htmlspecialchars(xl('AMC-2011') . ":" . $row['amc_code'], ENT_NOQUOTES) . " ";
760 if (!empty($row['amc_code_2014'])) {
761 $tempCqmAmcString .= " " . htmlspecialchars(xl('AMC-2014') . ":" . $row['amc_code_2014'], ENT_NOQUOTES) . " ";
765 if ($type_report == "amc_2011") {
766 if (!empty($row['amc_code'])) {
767 $tempCqmAmcString .= " " . htmlspecialchars(xl('AMC-2011') . ":" . $row['amc_code'], ENT_NOQUOTES) . " ";
771 if (($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) {
772 if (!empty($row['amc_code_2014'])) {
773 $tempCqmAmcString .= " " . htmlspecialchars(xl('AMC-2014') . ":" . $row['amc_code_2014'], ENT_NOQUOTES) . " ";
777 if (!empty($tempCqmAmcString)) {
778 echo "(".$tempCqmAmcString.")";
781 if (!(empty($row['concatenated_label']))) {
782 echo ", " . htmlspecialchars(xl($row['concatenated_label']), ENT_NOQUOTES) . " ";
784 } else { // isset($row['is_sub'])
785 echo generate_display_field(array('data_type'=>'1','list_id'=>'rule_action_category'), $row['action_category']);
786 echo ": " . generate_display_field(array('data_type'=>'1','list_id'=>'rule_action'), $row['action_item']);
789 echo "</td>";
791 if ($type_report == 'cqm' || $type_report == 'cqm_2011' || $type_report == 'cqm_2014') {
792 echo "<td align='center'>" . $row['initial_population'] . "</td>";
793 } else {
794 echo "<td align='center'>" . $row['total_patients'] . "</td>";
797 if (isset($row['itemized_test_id']) && ($row['pass_filter'] > 0)) {
798 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()'>" . $row['pass_filter'] . "</a></td>";
799 } else {
800 echo "<td align='center'>" . $row['pass_filter'] . "</td>";
803 if ($type_report != "amc") {
804 // Note that amc will likely support in excluded items in the future for MU2
805 if (($type_report != "standard") && isset($row['itemized_test_id']) && ($row['excluded'] > 0)) {
806 // Note standard reporting exluded is different than cqm/amc and will not support itemization
807 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()'>" . $row['excluded'] . "</a></td>";
808 } else {
809 echo "<td align='center'>" . $row['excluded'] . "</td>";
813 if ($type_report == 'cqm' || $type_report == 'cqm_2011' || $type_report == 'cqm_2014') {
814 // Note that amc will likely support in exception items in the future for MU2
815 if (isset($row['itemized_test_id']) && ($row['exception'] > 0)) {
816 // Note standard reporting exluded is different than cqm/amc and will not support itemization
817 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()'>" . $row['exception'] . "</a></td>";
818 } else {
819 echo "<td align='center'>" . $row['exception'] . "</td>";
823 if (isset($row['itemized_test_id']) && ($row['pass_target'] > 0)) {
824 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()'>" . $row['pass_target'] . "</a></td>";
825 } else {
826 echo "<td align='center'>" . $row['pass_target'] . "</td>";
829 $failed_items = 0;
830 if (isset($row['is_main'])) {
831 if ($type_report == "standard") {
832 // Excluded is not part of denominator in standard rules so do not use in calculation
833 $failed_items = $row['pass_filter'] - $row['pass_target'];
834 } else {
835 $failed_items = $row['pass_filter'] - $row['pass_target'] - $row['excluded'];
837 } else { // isset($row['is_sub'])
838 // Excluded is not part of denominator in standard rules so do not use in calculation
839 $failed_items = $main_pass_filter - $row['pass_target'];
842 if (isset($row['itemized_test_id']) && ($failed_items > 0)) {
843 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()'>" . $failed_items . "</a></td>";
844 } else {
845 echo "<td align='center'>" . $failed_items . "</td>";
848 echo "<td align='center'>" . $row['percentage'] . "</td>";
849 } else if (isset($row['is_provider'])) {
850 // Display the provider information
851 if (!$firstProviderFlag && $_POST['form_provider'] == 'collate_outer') {
852 echo "<tr><td>&nbsp</td></tr>";
855 echo "<td class='detail' align='center'><b>";
856 echo htmlspecialchars(xl("Provider").": " . $row['prov_lname'] . "," . $row['prov_fname'], ENT_NOQUOTES);
857 if (!empty($row['npi']) || !empty($row['federaltaxid'])) {
858 echo " (";
859 if (!empty($row['npi'])) {
860 echo " " . htmlspecialchars(xl('NPI') . ":" . $row['npi'], ENT_NOQUOTES) . " ";
863 if (!empty($row['federaltaxid'])) {
864 echo " " . htmlspecialchars(xl('TID') . ":" . $row['federaltaxid'], ENT_NOQUOTES) . " ";
867 echo ")";
870 echo "</b></td>";
871 $firstProviderFlag = false;
872 $existProvider = true;
873 } else { // isset($row['is_plan'])
874 if (!$firstPlanFlag && $_POST['form_provider'] != 'collate_outer') {
875 echo "<tr><td>&nbsp</td></tr>";
878 echo "<td class='detail' align='center'><b>";
879 echo htmlspecialchars(xl("Plan"), ENT_NOQUOTES) . ": ";
880 echo generate_display_field(array('data_type'=>'1','list_id'=>'clinical_plans'), $row['id']);
881 if (!empty($row['cqm_measure_group'])) {
882 echo " (". htmlspecialchars(xl('Measure Group Code') . ": " . $row['cqm_measure_group'], ENT_NOQUOTES) . ")";
885 echo "</b></td>";
886 $firstPlanFlag = false;
889 </tr>
891 <?php
894 </tbody>
895 </table>
896 </div> <!-- end of search results -->
897 <?php } else { ?>
898 <div id="instructions_text" class='text'>
899 <?php echo htmlspecialchars(xl('Please input search criteria above, and click Submit to start report.'), ENT_NOQUOTES); ?>
900 </div>
901 <?php } ?>
903 <input type='hidden' name='form_new_report_id' id='form_new_report_id' value=''/>
905 </form>
907 </body>
909 </html>