Email change of a developer (#503)
[openemr.git] / interface / reports / cqm.php
blob73abee3f7c322562b312b011688725971da0a891
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
22 //SANITIZE ALL ESCAPES
23 $sanitize_all_escapes=true;
26 //STOP FAKE REGISTER GLOBALS
27 $fake_register_globals=false;
30 require_once("../globals.php");
31 require_once("../../library/patient.inc");
32 require_once "$srcdir/options.inc.php";
33 require_once "$srcdir/clinical_rules.php";
34 require_once "$srcdir/report_database.inc";
36 // See if showing an old report or creating a new report
37 $report_id = (isset($_GET['report_id'])) ? trim($_GET['report_id']) : "";
39 // Collect the back variable, if pertinent
40 $back_link = (isset($_GET['back'])) ? trim($_GET['back']) : "";
42 // If showing an old report, then collect information
43 if (!empty($report_id)) {
44 $report_view = collectReportDatabase($report_id);
45 $date_report = $report_view['date_report'];
46 $type_report = $report_view['type'];
48 $type_report = (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2") ||
49 ($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) ? $type_report : "standard";
50 $rule_filter = $report_view['type'];
52 if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) {
53 $begin_date = $report_view['date_begin'];
54 $labs_manual = $report_view['labs_manual'];
56 $target_date = $report_view['date_target'];
57 $plan_filter = $report_view['plan'];
58 $organize_method = $report_view['organize_mode'];
59 $provider = $report_view['provider'];
60 $pat_prov_rel = $report_view['pat_prov_rel'];
61 $dataSheet = json_decode($report_view['data'],TRUE);
63 else {
64 // Collect report type parameter (standard, amc, cqm)
65 // Note that need to convert amc_2011 and amc_2014 to amc and cqm_2011 and cqm_2014 to cqm
66 // to simplify for when submitting for a new report.
67 $type_report = (isset($_GET['type'])) ? trim($_GET['type']) : "standard";
69 if ( ($type_report == "cqm_2011") || ($type_report == "cqm_2014") ) {
70 $type_report = "cqm";
72 if ( ($type_report == "amc_2011") || ($type_report == "amc_2014") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2") ) {
73 $type_report = "amc";
75 // Collect form parameters (set defaults if empty)
76 if ($type_report == "amc") {
77 $begin_date = (isset($_POST['form_begin_date'])) ? trim($_POST['form_begin_date']) : "";
78 $labs_manual = (isset($_POST['labs_manual_entry'])) ? trim($_POST['labs_manual_entry']) : "0";
80 $target_date = (isset($_POST['form_target_date'])) ? trim($_POST['form_target_date']) : date('Y-m-d H:i:s');
81 $rule_filter = (isset($_POST['form_rule_filter'])) ? trim($_POST['form_rule_filter']) : "";
82 $plan_filter = (isset($_POST['form_plan_filter'])) ? trim($_POST['form_plan_filter']) : "";
83 $organize_method = (empty($plan_filter)) ? "default" : "plans";
84 $provider = trim($_POST['form_provider']);
85 $pat_prov_rel = (empty($_POST['form_pat_prov_rel'])) ? "primary" : trim($_POST['form_pat_prov_rel']);
89 <html>
91 <head>
92 <?php html_header_show();?>
94 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
95 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
97 <?php if ($type_report == "standard") { ?>
98 <title><?php echo xlt('Standard Measures'); ?></title>
99 <?php } ?>
101 <?php if ($type_report == "cqm") { ?>
102 <title><?php echo xlt('Clinical Quality Measures (CQM)'); ?></title>
103 <?php } ?>
104 <?php if ($type_report == "cqm_2011") { ?>
105 <title><?php echo xlt('Clinical Quality Measures (CQM) - 2011'); ?></title>
106 <?php } ?>
107 <?php if ($type_report == "cqm_2014") { ?>
108 <title><?php echo xlt('Clinical Quality Measures (CQM) - 2014'); ?></title>
109 <?php } ?>
111 <?php if ($type_report == "amc") { ?>
112 <title><?php echo xlt('Automated Measure Calculations (AMC)'); ?></title>
113 <?php } ?>
114 <?php if ($type_report == "amc_2011") { ?>
115 <title><?php echo xlt('Automated Measure Calculations (AMC) - 2011'); ?></title>
116 <?php } ?>
117 <?php if ($type_report == "amc_2014_stage1") { ?>
118 <title><?php echo xlt('Automated Measure Calculations (AMC) - 2014 Stage I'); ?></title>
119 <?php } ?>
120 <?php if ($type_report == "amc_2014_stage2") { ?>
121 <title><?php echo xlt('Automated Measure Calculations (AMC) - 2014 Stage II'); ?></title>
122 <?php } ?>
124 <script type="text/javascript" src="../../library/overlib_mini.js"></script>
125 <script type="text/javascript" src="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
126 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
127 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script>
128 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script>
130 <script LANGUAGE="JavaScript">
132 var mypcc = '<?php echo text($GLOBALS['phone_country_code']) ?>';
134 $(document).ready(function() {
135 var win = top.printLogSetup ? top : opener.top;
136 win.printLogSetup(document.getElementById('printbutton'));
138 $('.datepicker').datetimepicker({
139 <?php $datetimepicker_timepicker = true; ?>
140 <?php $datetimepicker_formatInput = false; ?>
141 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
142 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
146 function runReport() {
148 // Validate first
149 if (!(validateForm())) {
150 alert("<?php echo xls("Rule Set and Plan Set selections are not consistent. Please fix and Submit again."); ?>");
151 return false;
154 // Showing processing wheel
155 $("#processing").show();
157 // hide Submit buttons
158 $("#submit_button").hide();
159 $("#xmla_button").hide();
160 $("#xmlb_button").hide();
161 $("#xmlc_button").hide();
162 $("#print_button").hide();
163 $("#genQRDA").hide();
165 // hide instructions
166 $("#instructions_text").hide();
168 // Collect an id string via an ajax request
169 top.restoreSession();
170 $.get("../../library/ajax/collect_new_report_id.php",
171 function(data){
172 // Set the report id in page form
173 $("#form_new_report_id").attr("value",data);
175 // Start collection status checks
176 collectStatus($("#form_new_report_id").val());
178 // Run the report
179 top.restoreSession();
180 $.post("../../library/ajax/execute_cdr_report.php",
181 {provider: $("#form_provider").val(),
182 type: $("#form_rule_filter").val(),
183 date_target: $("#form_target_date").val(),
184 date_begin: $("#form_begin_date").val(),
185 plan: $("#form_plan_filter").val(),
186 labs: $("#labs_manual_entry").val(),
187 pat_prov_rel: $("#form_pat_prov_rel").val(),
188 execute_report_id: $("#form_new_report_id").val()
193 function collectStatus(report_id) {
194 // Collect the status string via an ajax request and place in DOM at timed intervals
195 top.restoreSession();
196 // Do not send the skip_timeout_reset parameter, so don't close window before report is done.
197 $.post("../../library/ajax/status_report.php",
198 {status_report_id: report_id},
199 function(data){
200 if (data == "PENDING") {
201 // Place the pending string in the DOM
202 $('#status_span').replaceWith("<span id='status_span'><?php echo xlt("Preparing To Run Report"); ?></span>");
204 else if (data == "COMPLETE") {
205 // Go into the results page
206 top.restoreSession();
207 link_report = "cqm.php?report_id="+report_id;
208 window.open(link_report,'_self',false);
209 //$("#processing").hide();
210 //$('#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>");
212 else {
213 // Place the string in the DOM
214 $('#status_span').replaceWith("<span id='status_span'>"+data+"</span>");
217 // run status check every 10 seconds
218 var repeater = setTimeout("collectStatus("+report_id+")", 10000);
221 function GenXml(sNested) {
222 top.restoreSession();
223 //QRDA Category III Export
224 if(sNested == "QRDA"){
225 var form_rule_filter = theform.form_rule_filter.value
226 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);?>";
227 }else{
228 var sLoc = '../../custom/export_registry_xml.php?&target_date=' + theform.form_target_date.value + '&nested=' + sNested;
230 dlgopen(sLoc, '_blank', 600, 500);
231 return false;
234 //QRDA I - 2014 Download
235 function downloadQRDA() {
236 top.restoreSession();
237 var reportID = '<?php echo attr($report_id); ?>';
238 var provider = $("#form_provider").val();
239 sLoc = '../../custom/download_qrda.php?&report_id=' + reportID + '&provider_id=' + provider;
240 dlgopen(sLoc, '_blank', 600, 500);
243 function validateForm() {
244 <?php if ( (empty($report_id)) && ($type_report == "cqm") ) { ?>
245 // If this is a cqm and plan set not set to ignore, then need to ensure consistent with the rules set
246 if ($("#form_plan_filter").val() != '') {
247 if ($("#form_rule_filter").val() == $("#form_plan_filter").val()) {
248 return true;
249 } else {
250 return false;
253 else {
254 return true;
256 <?php } else { ?>
257 return true;
258 <?php } ?>
261 function Form_Validate() {
262 <?php if ( (empty($report_id)) && (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) ){ ?>
263 var d = document.forms[0];
264 FromDate = d.form_begin_date.value;
265 ToDate = d.form_target_date.value;
266 if ( (FromDate.length > 0) && (ToDate.length > 0) ) {
267 if (FromDate > ToDate){
268 alert("<?php echo xls('End date must be later than Begin date!'); ?>");
269 return false;
272 <?php } ?>
274 //For Results are in Gray Background & disabling anchor links
275 <?php if($report_id != ""){?>
276 $("#report_results").css("opacity", '0.4');
277 $("#report_results").css("filter", 'alpha(opacity=40)');
278 $("a").removeAttr("href");
279 <?php }?>
281 $("#form_refresh").attr("value","true");
282 runReport();
283 return true;
286 </script>
288 <style type="text/css">
290 /* specifically include & exclude from printing */
291 @media print {
292 #report_parameters {
293 visibility: hidden;
294 display: none;
296 #report_parameters_daterange {
297 visibility: visible;
298 display: inline;
300 #report_results table {
301 margin-top: 0px;
305 /* specifically exclude some from the screen */
306 @media screen {
307 #report_parameters_daterange {
308 visibility: hidden;
309 display: none;
313 </style>
314 </head>
316 <body class="body_top">
318 <!-- Required for the popup date selectors -->
319 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
321 <span class='title'><?php echo xlt('Report'); ?> -
323 <?php if ($type_report == "standard") { ?>
324 <?php echo xlt('Standard Measures'); ?>
325 <?php } ?>
327 <?php if ($type_report == "cqm") { ?>
328 <?php echo xlt('Clinical Quality Measures (CQM)'); ?>
329 <?php } ?>
330 <?php if ($type_report == "cqm_2011") { ?>
331 <?php echo xlt('Clinical Quality Measures (CQM) - 2011'); ?>
332 <?php } ?>
333 <?php if ($type_report == "cqm_2014") { ?>
334 <?php echo xlt('Clinical Quality Measures (CQM) - 2014'); ?>
335 <?php } ?>
337 <?php if ($type_report == "amc") { ?>
338 <?php echo xlt('Automated Measure Calculations (AMC)'); ?>
339 <?php } ?>
340 <?php if ($type_report == "amc_2011") { ?>
341 <?php echo xlt('Automated Measure Calculations (AMC) - 2011'); ?>
342 <?php } ?>
343 <?php if ($type_report == "amc_2014_stage1") { ?>
344 <?php echo xlt('Automated Measure Calculations (AMC) - 2014 Stage I'); ?>
345 <?php } ?>
346 <?php if ($type_report == "amc_2014_stage2") { ?>
347 <?php echo xlt('Automated Measure Calculations (AMC) - 2014 Stage II'); ?>
348 <?php } ?>
350 <?php if (!empty($report_id)) { ?>
351 <?php echo " - " . xlt('Date of Report') . ": " . text($date_report);
352 //prepare to disable form elements
353 $dis_text = " disabled='disabled' ";
355 <?php } ?>
356 </span>
358 <form method='post' name='theform' id='theform' action='cqm.php?type=<?php echo attr($type_report) ;?>' onsubmit='return validateForm()'>
360 <div id="report_parameters">
361 <?php
362 $widthDyn = "470px";
363 if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) $widthDyn = "410px";
365 <table>
366 <tr>
367 <td scope="row" width='<?php echo $widthDyn;?>'>
368 <div style='float:left'>
370 <table class='text'>
372 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
373 <tr>
374 <td class='label'>
375 <?php echo htmlspecialchars( xl('Begin Date'), ENT_NOQUOTES); ?>:
376 </td>
377 <td>
378 <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); ?>'
379 class='datepicker'
380 title='<?php echo htmlspecialchars( xl('yyyy-mm-dd hh:mm:ss'), ENT_QUOTES); ?>'>
381 <?php if (empty($report_id)) { ?>
382 <?php } ?>
383 </td>
384 </tr>
385 <?php } ?>
387 <tr>
388 <td class='label'>
389 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
390 <?php echo htmlspecialchars( xl('End Date'), ENT_NOQUOTES); ?>:
391 <?php } else { ?>
392 <?php echo htmlspecialchars( xl('Target Date'), ENT_NOQUOTES); ?>:
393 <?php } ?>
394 </td>
395 <td>
396 <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); ?>'
397 class='datepicker'
398 title='<?php echo htmlspecialchars( xl('yyyy-mm-dd hh:mm:ss'), ENT_QUOTES); ?>'>
399 <?php if (empty($report_id)) { ?>
400 <?php } ?>
401 </td>
402 </tr>
404 <?php if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) { ?>
405 <tr>
406 <td class='label'>
407 <?php echo xlt('Rule Set'); ?>:
408 </td>
409 <td>
410 <select <?php echo $dis_text; ?> id='form_rule_filter' name='form_rule_filter'>
411 <option value='cqm' <?php if ($rule_filter == "cqm") echo "selected"; ?>>
412 <?php echo xlt('All Clinical Quality Measures (CQM)'); ?></option>
413 <option value='cqm_2011' <?php if ($rule_filter == "cqm_2011") echo "selected"; ?>>
414 <?php echo xlt('2011 Clinical Quality Measures (CQM)'); ?></option>
415 <option value='cqm_2014' <?php if ($rule_filter == "cqm_2014") echo "selected"; ?>>
416 <?php echo xlt('2014 Clinical Quality Measures (CQM)'); ?></option>
417 </select>
418 </td>
419 </tr>
420 <?php } ?>
422 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
423 <tr>
424 <td class='label'>
425 <?php echo xlt('Rule Set'); ?>:
426 </td>
427 <td>
428 <select <?php echo $dis_text; ?> id='form_rule_filter' name='form_rule_filter'>
430 <?php if ($rule_filter == "amc") { //only show this when displaying old reports. Not available option for new reports ?>
431 <option value='amc' selected>
432 <?php echo xlt('All Automated Measure Calculations (AMC)'); ?></option>
433 <?php } ?>
435 <option value='amc_2011' <?php if ($rule_filter == "amc_2011") echo "selected"; ?>>
436 <?php echo xlt('2011 Automated Measure Calculations (AMC)'); ?></option>
437 <option value='amc_2014_stage1' <?php if ($rule_filter == "amc_2014_stage1") echo "selected"; ?>>
438 <?php echo xlt('2014 Automated Measure Calculations (AMC) - Stage I'); ?></option>
439 <option value='amc_2014_stage2' <?php if ($rule_filter == "amc_2014_stage2") echo "selected"; ?>>
440 <?php echo xlt('2014 Automated Measure Calculations (AMC) - Stage II'); ?></option>
441 </select>
442 </td>
443 </tr>
444 <?php } ?>
446 <?php if ($type_report == "standard") { ?>
447 <tr>
448 <td class='label'>
449 <?php echo xlt('Rule Set'); ?>:
450 </td>
451 <td>
452 <select <?php echo $dis_text; ?> id='form_rule_filter' name='form_rule_filter'>
453 <option value='passive_alert' <?php if ($rule_filter == "passive_alert") echo "selected"; ?>>
454 <?php echo xlt('Passive Alert Rules'); ?></option>
455 <option value='active_alert' <?php if ($rule_filter == "active_alert") echo "selected"; ?>>
456 <?php echo xlt('Active Alert Rules'); ?></option>
457 <option value='patient_reminder' <?php if ($rule_filter == "patient_reminder") echo "selected"; ?>>
458 <?php echo xlt('Patient Reminder Rules'); ?></option>
459 </select>
460 </td>
461 </tr>
462 <?php } ?>
464 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
465 <input type='hidden' id='form_plan_filter' name='form_plan_filter' value=''>
466 <?php } else { ?>
467 <tr>
468 <td class='label'>
469 <?php echo htmlspecialchars( xl('Plan Set'), ENT_NOQUOTES); ?>:
470 </td>
471 <td>
472 <select <?php echo $dis_text; ?> id='form_plan_filter' name='form_plan_filter'>
473 <option value=''>-- <?php echo htmlspecialchars( xl('Ignore'), ENT_NOQUOTES); ?> --</option>
474 <?php if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) { ?>
475 <option value='cqm' <?php if ($plan_filter == "cqm") echo "selected"; ?>>
476 <?php echo htmlspecialchars( xl('All Official Clinical Quality Measures (CQM) Measure Groups'), ENT_NOQUOTES); ?></option>
477 <option value='cqm_2011' <?php if ($plan_filter == "cqm_2011") echo "selected"; ?>>
478 <?php echo htmlspecialchars( xl('2011 Official Clinical Quality Measures (CQM) Measure Groups'), ENT_NOQUOTES); ?></option>
479 <option value='cqm_2014' <?php if ($plan_filter == "cqm_2014") echo "selected"; ?>>
480 <?php echo htmlspecialchars( xl('2014 Official Clinical Quality Measures (CQM) Measure Groups'), ENT_NOQUOTES); ?></option>
481 <?php } ?>
482 <?php if ($type_report == "standard") { ?>
483 <option value='normal' <?php if ($plan_filter == "normal") echo "selected"; ?>>
484 <?php echo htmlspecialchars( xl('Active Plans'), ENT_NOQUOTES); ?></option>
485 <?php } ?>
486 </td>
487 </tr>
488 <?php } ?>
490 <tr>
491 <td class='label'>
492 <?php echo htmlspecialchars( xl('Provider'), ENT_NOQUOTES); ?>:
493 </td>
494 <td>
495 <?php
497 // Build a drop-down list of providers.
500 $query = "SELECT id, lname, fname FROM users WHERE ".
501 "authorized = 1 $provider_facility_filter ORDER BY lname, fname"; //(CHEMED) facility filter
503 $ures = sqlStatement($query);
505 echo " <select " . $dis_text . " id='form_provider' name='form_provider'>\n";
506 echo " <option value=''>-- " . htmlspecialchars( xl('All (Cumulative)'), ENT_NOQUOTES) . " --\n";
508 echo " <option value='collate_outer'";
509 if ($provider == 'collate_outer') echo " selected";
510 echo ">-- " . htmlspecialchars( xl('All (Collated Format A)'), ENT_NOQUOTES) . " --\n";
512 echo " <option value='collate_inner'";
513 if ($provider == 'collate_inner') echo " selected";
514 echo ">-- " . htmlspecialchars( xl('All (Collated Format B)'), ENT_NOQUOTES) . " --\n";
516 while ($urow = sqlFetchArray($ures)) {
517 $provid = $urow['id'];
518 echo " <option value='".htmlspecialchars( $provid, ENT_QUOTES)."'";
519 if ($provid == $provider) echo " selected";
520 echo ">" . htmlspecialchars( $urow['lname'] . ", " . $urow['fname'], ENT_NOQUOTES) . "\n";
523 echo " </select>\n";
526 </td>
527 </tr>
529 <tr>
530 <td class='label'>
531 <?php echo htmlspecialchars( xl('Provider Relationship'), ENT_NOQUOTES); ?>:
532 </td>
533 <td>
534 <?php
536 // Build a drop-down list of of patient provider relationships.
538 echo " <select ". $dis_text ." id='form_pat_prov_rel' name='form_pat_prov_rel' 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";
539 echo " <option value='primary'";
540 if ($pat_prov_rel == 'primary') echo " selected";
541 echo ">" . xlt('Primary') . "\n";
542 echo " <option value='encounter'";
543 if ($pat_prov_rel == 'encounter') echo " selected";
544 echo ">" . xlt('Encounter') . "\n";
545 echo " </select>\n";
547 </td>
548 </tr>
550 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
551 <tr>
552 <td>
553 <?php echo htmlspecialchars( xl('Number labs'), ENT_NOQUOTES); ?>:<br>
554 (<?php echo htmlspecialchars( xl('Non-electronic'), ENT_NOQUOTES); ?>)
555 </td>
556 <td>
557 <input <?php echo $dis_text; ?> type="text" id="labs_manual_entry" name="labs_manual_entry" value="<?php echo htmlspecialchars($labs_manual,ENT_QUOTES); ?>">
558 </td>
559 </tr>
560 <?php } ?>
562 </table>
564 </div>
566 </td>
567 <td align='left' valign='middle' height="100%">
568 <table style='border-left:1px solid; width:100%; height:100%' >
569 <tr>
570 <td scope="row">
572 <div style='margin-left:15px'>
574 <?php if (empty($report_id)) { ?>
575 <a id='submit_button' href='#' class='css_button' onclick='runReport();'>
576 <span>
577 <?php echo htmlspecialchars( xl('Submit'), ENT_NOQUOTES); ?>
578 </span>
579 </a>
580 <span id='status_span'></span>
581 <div id='processing' style='margin:10px;display:none;'><img src='../pic/ajax-loader.gif'/></div>
582 <?php if ($type_report == "cqm") { ?>
583 <a id='xmla_button' href='#' class='css_button' onclick='return GenXml("false")'>
584 <span>
585 <?php echo htmlspecialchars( xl('Generate PQRI report (Method A) - 2011'), ENT_NOQUOTES); ?>
586 </span>
587 </a>
588 <a id='xmlb_button' href='#' class='css_button' onclick='return GenXml("true")'>
589 <span>
590 <?php echo htmlspecialchars( xl('Generate PQRI report (Method E) - 2011'), ENT_NOQUOTES); ?>
591 </span>
592 </a>
593 <?php } ?>
594 <?php } ?>
596 <?php if (!empty($report_id)) { ?>
597 <a href='#' class='css_button' id='printbutton'>
598 <span>
599 <?php echo htmlspecialchars( xl('Print'), ENT_NOQUOTES); ?>
600 </span>
601 </a>
602 <?php if ($type_report == "cqm_2014") { ?>
603 <a href="#" id="genQRDA" class='css_button' onclick='return downloadQRDA()'>
604 <span>
605 <?php echo htmlspecialchars( xl('Generate QRDA I – 2014'), ENT_NOQUOTES); ?>
606 </span>
607 </a>
608 <a href="#" id="xmlc_button" class='css_button' onclick='return GenXml("QRDA")'>
609 <span>
610 <?php echo htmlspecialchars( xl('Generate QRDA III - 2014'), ENT_NOQUOTES); ?>
611 </span>
612 </a>
613 <?php } ?>
615 <?php if ($back_link == "list") { ?>
616 <a href='report_results.php' class='css_button' onclick='top.restoreSession()'><span><?php echo xlt("Return To Report Results"); ?></span></a>
617 <?php } else { ?>
618 <a href='#' class='css_button' onclick='top.restoreSession(); $("#theform").submit();'><span><?php echo xlt("Start Another Report"); ?></span></a>
619 <?php } ?>
620 <?php } ?>
621 </div>
622 </td>
623 </tr>
624 </table>
625 </td>
626 </tr>
627 </table>
629 </div> <!-- end of search parameters -->
631 <br>
633 <?php
634 if (!empty($report_id)) {
638 <div id="report_results">
639 <table>
641 <thead>
642 <th>
643 <?php echo htmlspecialchars( xl('Title'), ENT_NOQUOTES); ?>
644 </th>
646 <th>
647 <?php
648 if($type_report == 'cqm' || $type_report == 'cqm_2011' || $type_report == 'cqm_2014')
649 echo htmlspecialchars( xl('Initial Patient Population'), ENT_NOQUOTES);
650 else
651 echo htmlspecialchars( xl('Total Patients'), ENT_NOQUOTES);
653 </th>
655 <th>
656 <?php if ($type_report == "amc") { ?>
657 <?php echo htmlspecialchars( xl('Denominator'), ENT_NOQUOTES); ?></a>
658 <?php } else { ?>
659 <?php echo htmlspecialchars( xl('Applicable Patients') .' (' . xl('Denominator') . ')', ENT_NOQUOTES); ?></a>
660 <?php } ?>
661 </th>
663 <?php if ($type_report != "amc") { ?>
664 <th>
665 <?php echo htmlspecialchars( xl('Denominator Exclusion'), ENT_NOQUOTES); ?></a>
666 </th>
667 <?php }?>
668 <?php if($type_report == 'cqm' || $type_report == 'cqm_2011' || $type_report == 'cqm_2014') {?>
669 <th>
670 <?php echo htmlspecialchars( xl('Denominator Exception'), ENT_NOQUOTES); ?></a>
671 </th>
672 <?php } ?>
674 <th>
675 <?php if ($type_report == "amc") { ?>
676 <?php echo htmlspecialchars( xl('Numerator'), ENT_NOQUOTES); ?></a>
677 <?php } else { ?>
678 <?php echo htmlspecialchars( xl('Passed Patients') . ' (' . xl('Numerator') . ')', ENT_NOQUOTES); ?></a>
679 <?php } ?>
680 </th>
682 <th>
683 <?php if ($type_report == "amc") { ?>
684 <?php echo htmlspecialchars( xl('Failed'), ENT_NOQUOTES); ?></a>
685 <?php } else { ?>
686 <?php echo htmlspecialchars( xl('Failed Patients'), ENT_NOQUOTES); ?></a>
687 <?php } ?>
688 </th>
690 <th>
691 <?php echo htmlspecialchars( xl('Performance Percentage'), ENT_NOQUOTES); ?></a>
692 </th>
694 </thead>
695 <tbody> <!-- added for better print-ability -->
696 <?php
698 $firstProviderFlag = TRUE;
699 $firstPlanFlag = TRUE;
700 $existProvider = FALSE;
701 foreach ($dataSheet as $row) {
705 <tr bgcolor='<?php echo $bgcolor ?>'>
707 <?php
708 if (isset($row['is_main']) || isset($row['is_sub'])) {
709 echo "<td class='detail'>";
710 if (isset($row['is_main'])) {
712 // is_sub is a special case of is_main whereas total patients, denominator, and excluded patients are taken
713 // from is_main prior to it. So, need to store denominator patients from is_main for subsequent is_sub
714 // to calculate the number of patients that failed.
715 // Note that exlusion in the standard rules is not the same as in the cqm/amd and should not be in calculation
716 // as is in the cqm/amc rules.
717 $main_pass_filter = $row['pass_filter'];
719 echo "<b>".generate_display_field(array('data_type'=>'1','list_id'=>'clinical_rules'),$row['id'])."</b>";
721 $tempCqmAmcString = "";
722 if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) {
723 if (!empty($row['cqm_pqri_code'])) {
724 $tempCqmAmcString .= " " . htmlspecialchars( xl('PQRI') . ":" . $row['cqm_pqri_code'], ENT_NOQUOTES) . " ";
726 if (!empty($row['cqm_nqf_code'])) {
727 $tempCqmAmcString .= " " . htmlspecialchars( xl('NQF') . ":" . $row['cqm_nqf_code'], ENT_NOQUOTES) . " ";
730 if ($type_report == "amc") {
731 if (!empty($row['amc_code'])) {
732 $tempCqmAmcString .= " " . htmlspecialchars( xl('AMC-2011') . ":" . $row['amc_code'], ENT_NOQUOTES) . " ";
734 if (!empty($row['amc_code_2014'])) {
735 $tempCqmAmcString .= " " . htmlspecialchars( xl('AMC-2014') . ":" . $row['amc_code_2014'], ENT_NOQUOTES) . " ";
738 if ($type_report == "amc_2011") {
739 if (!empty($row['amc_code'])) {
740 $tempCqmAmcString .= " " . htmlspecialchars( xl('AMC-2011') . ":" . $row['amc_code'], ENT_NOQUOTES) . " ";
743 if ( ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2") ) {
744 if (!empty($row['amc_code_2014'])) {
745 $tempCqmAmcString .= " " . htmlspecialchars( xl('AMC-2014') . ":" . $row['amc_code_2014'], ENT_NOQUOTES) . " ";
749 if (!empty($tempCqmAmcString)) {
750 echo "(".$tempCqmAmcString.")";
753 if ( !(empty($row['concatenated_label'])) ) {
754 echo ", " . htmlspecialchars( xl( $row['concatenated_label'] ), ENT_NOQUOTES) . " ";
758 else { // isset($row['is_sub'])
759 echo generate_display_field(array('data_type'=>'1','list_id'=>'rule_action_category'),$row['action_category']);
760 echo ": " . generate_display_field(array('data_type'=>'1','list_id'=>'rule_action'),$row['action_item']);
762 echo "</td>";
764 if($type_report == 'cqm' || $type_report == 'cqm_2011' || $type_report == 'cqm_2014')
765 echo "<td align='center'>" . $row['initial_population'] . "</td>";
766 else
767 echo "<td align='center'>" . $row['total_patients'] . "</td>";
769 if ( isset($row['itemized_test_id']) && ($row['pass_filter'] > 0) ) {
770 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>";
772 else {
773 echo "<td align='center'>" . $row['pass_filter'] . "</td>";
776 if ($type_report != "amc") {
777 // Note that amc will likely support in excluded items in the future for MU2
778 if ( ($type_report != "standard") && isset($row['itemized_test_id']) && ($row['excluded'] > 0) ) {
779 // Note standard reporting exluded is different than cqm/amc and will not support itemization
780 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>";
782 else {
783 echo "<td align='center'>" . $row['excluded'] . "</td>";
787 if($type_report == 'cqm' || $type_report == 'cqm_2011' || $type_report == 'cqm_2014'){
788 // Note that amc will likely support in exception items in the future for MU2
789 if ( isset($row['itemized_test_id']) && ($row['exception'] > 0) ) {
790 // Note standard reporting exluded is different than cqm/amc and will not support itemization
791 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>";
793 else {
794 echo "<td align='center'>" . $row['exception'] . "</td>";
798 if ( isset($row['itemized_test_id']) && ($row['pass_target'] > 0) ) {
799 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>";
801 else {
802 echo "<td align='center'>" . $row['pass_target'] . "</td>";
805 $failed_items = 0;
806 if (isset($row['is_main'])) {
807 if ($type_report == "standard") {
808 // Excluded is not part of denominator in standard rules so do not use in calculation
809 $failed_items = $row['pass_filter'] - $row['pass_target'];
811 else {
812 $failed_items = $row['pass_filter'] - $row['pass_target'] - $row['excluded'];
815 else { // isset($row['is_sub'])
816 // Excluded is not part of denominator in standard rules so do not use in calculation
817 $failed_items = $main_pass_filter - $row['pass_target'];
819 if ( isset($row['itemized_test_id']) && ($failed_items > 0) ) {
820 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>";
822 else {
823 echo "<td align='center'>" . $failed_items . "</td>";
826 echo "<td align='center'>" . $row['percentage'] . "</td>";
828 else if (isset($row['is_provider'])) {
829 // Display the provider information
830 if (!$firstProviderFlag && $_POST['form_provider'] == 'collate_outer') {
831 echo "<tr><td>&nbsp</td></tr>";
833 echo "<td class='detail' align='center'><b>";
834 echo htmlspecialchars( xl("Provider").": " . $row['prov_lname'] . "," . $row['prov_fname'], ENT_NOQUOTES);
835 if (!empty($row['npi']) || !empty($row['federaltaxid'])) {
836 echo " (";
837 if (!empty($row['npi'])) {
838 echo " " . htmlspecialchars( xl('NPI') . ":" . $row['npi'], ENT_NOQUOTES) . " ";
840 if (!empty($row['federaltaxid'])) {
841 echo " " . htmlspecialchars( xl('TID') . ":" . $row['federaltaxid'], ENT_NOQUOTES) . " ";
843 echo ")";
845 echo "</b></td>";
846 $firstProviderFlag = FALSE;
847 $existProvider = TRUE;
849 else { // isset($row['is_plan'])
850 if (!$firstPlanFlag && $_POST['form_provider'] != 'collate_outer') {
851 echo "<tr><td>&nbsp</td></tr>";
853 echo "<td class='detail' align='center'><b>";
854 echo htmlspecialchars( xl("Plan"), ENT_NOQUOTES) . ": ";
855 echo generate_display_field(array('data_type'=>'1','list_id'=>'clinical_plans'),$row['id']);
856 if (!empty($row['cqm_measure_group'])) {
857 echo " (". htmlspecialchars( xl('Measure Group Code') . ": " . $row['cqm_measure_group'], ENT_NOQUOTES) . ")";
859 echo "</b></td>";
860 $firstPlanFlag = FALSE;
863 </tr>
865 <?php
868 </tbody>
869 </table>
870 </div> <!-- end of search results -->
871 <?php } else { ?>
872 <div id="instructions_text" class='text'>
873 <?php echo htmlspecialchars( xl('Please input search criteria above, and click Submit to start report.'), ENT_NOQUOTES); ?>
874 </div>
875 <?php } ?>
877 <input type='hidden' name='form_new_report_id' id='form_new_report_id' value=''/>
879 </form>
881 </body>
883 </html>