new datepicker in encounter
[openemr.git] / interface / reports / cqm.php
blob0578e5b1f68bda09ae0eede511d96132dfb6d751
1 <?php
2 /**
4 * Copyright (C) 2010-2017 Brady Miller <brady@sparmy.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@sparmy.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/formatting.inc.php");
33 require_once "$srcdir/options.inc.php";
34 require_once "$srcdir/clinical_rules.php";
35 require_once "$srcdir/report_database.inc";
37 // See if showing an old report or creating a new report
38 $report_id = (isset($_GET['report_id'])) ? trim($_GET['report_id']) : "";
40 // Collect the back variable, if pertinent
41 $back_link = (isset($_GET['back'])) ? trim($_GET['back']) : "";
43 // If showing an old report, then collect information
44 if (!empty($report_id)) {
45 $report_view = collectReportDatabase($report_id);
46 $date_report = $report_view['date_report'];
47 $type_report = $report_view['type'];
49 $type_report = (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2") ||
50 ($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) ? $type_report : "standard";
51 $rule_filter = $report_view['type'];
53 if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) {
54 $begin_date = $report_view['date_begin'];
55 $labs_manual = $report_view['labs_manual'];
57 $target_date = $report_view['date_target'];
58 $plan_filter = $report_view['plan'];
59 $organize_method = $report_view['organize_mode'];
60 $provider = $report_view['provider'];
61 $pat_prov_rel = $report_view['pat_prov_rel'];
62 $dataSheet = json_decode($report_view['data'],TRUE);
64 else {
65 // Collect report type parameter (standard, amc, cqm)
66 // Note that need to convert amc_2011 and amc_2014 to amc and cqm_2011 and cqm_2014 to cqm
67 // to simplify for when submitting for a new report.
68 $type_report = (isset($_GET['type'])) ? trim($_GET['type']) : "standard";
70 if ( ($type_report == "cqm_2011") || ($type_report == "cqm_2014") ) {
71 $type_report = "cqm";
73 if ( ($type_report == "amc_2011") || ($type_report == "amc_2014") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2") ) {
74 $type_report = "amc";
76 // Collect form parameters (set defaults if empty)
77 if ($type_report == "amc") {
78 $begin_date = (isset($_POST['form_begin_date'])) ? trim($_POST['form_begin_date']) : "";
79 $labs_manual = (isset($_POST['labs_manual_entry'])) ? trim($_POST['labs_manual_entry']) : "0";
81 $target_date = (isset($_POST['form_target_date'])) ? trim($_POST['form_target_date']) : date('Y-m-d H:i:s');
82 $rule_filter = (isset($_POST['form_rule_filter'])) ? trim($_POST['form_rule_filter']) : "";
83 $plan_filter = (isset($_POST['form_plan_filter'])) ? trim($_POST['form_plan_filter']) : "";
84 $organize_method = (empty($plan_filter)) ? "default" : "plans";
85 $provider = trim($_POST['form_provider']);
86 $pat_prov_rel = (empty($_POST['form_pat_prov_rel'])) ? "primary" : trim($_POST['form_pat_prov_rel']);
90 <html>
92 <head>
93 <?php html_header_show();?>
95 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
96 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
98 <?php if ($type_report == "standard") { ?>
99 <title><?php echo xlt('Standard Measures'); ?></title>
100 <?php } ?>
102 <?php if ($type_report == "cqm") { ?>
103 <title><?php echo xlt('Clinical Quality Measures (CQM)'); ?></title>
104 <?php } ?>
105 <?php if ($type_report == "cqm_2011") { ?>
106 <title><?php echo xlt('Clinical Quality Measures (CQM) - 2011'); ?></title>
107 <?php } ?>
108 <?php if ($type_report == "cqm_2014") { ?>
109 <title><?php echo xlt('Clinical Quality Measures (CQM) - 2014'); ?></title>
110 <?php } ?>
112 <?php if ($type_report == "amc") { ?>
113 <title><?php echo xlt('Automated Measure Calculations (AMC)'); ?></title>
114 <?php } ?>
115 <?php if ($type_report == "amc_2011") { ?>
116 <title><?php echo xlt('Automated Measure Calculations (AMC) - 2011'); ?></title>
117 <?php } ?>
118 <?php if ($type_report == "amc_2014_stage1") { ?>
119 <title><?php echo xlt('Automated Measure Calculations (AMC) - 2014 Stage I'); ?></title>
120 <?php } ?>
121 <?php if ($type_report == "amc_2014_stage2") { ?>
122 <title><?php echo xlt('Automated Measure Calculations (AMC) - 2014 Stage II'); ?></title>
123 <?php } ?>
125 <script type="text/javascript" src="../../library/overlib_mini.js"></script>
126 <script type="text/javascript" src="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
127 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
128 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script>
129 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script>
131 <script LANGUAGE="JavaScript">
133 var mypcc = '<?php echo text($GLOBALS['phone_country_code']) ?>';
135 $(document).ready(function() {
136 var win = top.printLogSetup ? top : opener.top;
137 win.printLogSetup(document.getElementById('printbutton'));
139 $('.datepicker').datetimepicker({
140 <?php $datetimepicker_timepicker = true; ?>
141 <?php $datetimepicker_formatInput = false; ?>
142 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
143 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
147 function runReport() {
149 // Validate first
150 if (!(validateForm())) {
151 alert("<?php echo xls("Rule Set and Plan Set selections are not consistent. Please fix and Submit again."); ?>");
152 return false;
155 // Showing processing wheel
156 $("#processing").show();
158 // hide Submit buttons
159 $("#submit_button").hide();
160 $("#xmla_button").hide();
161 $("#xmlb_button").hide();
162 $("#xmlc_button").hide();
163 $("#print_button").hide();
164 $("#genQRDA").hide();
166 // hide instructions
167 $("#instructions_text").hide();
169 // Collect an id string via an ajax request
170 top.restoreSession();
171 $.get("../../library/ajax/collect_new_report_id.php",
172 function(data){
173 // Set the report id in page form
174 $("#form_new_report_id").attr("value",data);
176 // Start collection status checks
177 collectStatus($("#form_new_report_id").val());
179 // Run the report
180 top.restoreSession();
181 $.post("../../library/ajax/execute_cdr_report.php",
182 {provider: $("#form_provider").val(),
183 type: $("#form_rule_filter").val(),
184 date_target: $("#form_target_date").val(),
185 date_begin: $("#form_begin_date").val(),
186 plan: $("#form_plan_filter").val(),
187 labs: $("#labs_manual_entry").val(),
188 pat_prov_rel: $("#form_pat_prov_rel").val(),
189 execute_report_id: $("#form_new_report_id").val()
194 function collectStatus(report_id) {
195 // Collect the status string via an ajax request and place in DOM at timed intervals
196 top.restoreSession();
197 // Do not send the skip_timeout_reset parameter, so don't close window before report is done.
198 $.post("../../library/ajax/status_report.php",
199 {status_report_id: report_id},
200 function(data){
201 if (data == "PENDING") {
202 // Place the pending string in the DOM
203 $('#status_span').replaceWith("<span id='status_span'><?php echo xlt("Preparing To Run Report"); ?></span>");
205 else if (data == "COMPLETE") {
206 // Go into the results page
207 top.restoreSession();
208 link_report = "cqm.php?report_id="+report_id;
209 window.open(link_report,'_self',false);
210 //$("#processing").hide();
211 //$('#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>");
213 else {
214 // Place the string in the DOM
215 $('#status_span').replaceWith("<span id='status_span'>"+data+"</span>");
218 // run status check every 10 seconds
219 var repeater = setTimeout("collectStatus("+report_id+")", 10000);
222 function GenXml(sNested) {
223 top.restoreSession();
224 //QRDA Category III Export
225 if(sNested == "QRDA"){
226 var form_rule_filter = theform.form_rule_filter.value
227 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);?>";
228 }else{
229 var sLoc = '../../custom/export_registry_xml.php?&target_date=' + theform.form_target_date.value + '&nested=' + sNested;
231 dlgopen(sLoc, '_blank', 600, 500);
232 return false;
235 //QRDA I - 2014 Download
236 function downloadQRDA() {
237 top.restoreSession();
238 var reportID = '<?php echo attr($report_id); ?>';
239 var provider = $("#form_provider").val();
240 sLoc = '../../custom/download_qrda.php?&report_id=' + reportID + '&provider_id=' + provider;
241 dlgopen(sLoc, '_blank', 600, 500);
244 function validateForm() {
245 <?php if ( (empty($report_id)) && ($type_report == "cqm") ) { ?>
246 // If this is a cqm and plan set not set to ignore, then need to ensure consistent with the rules set
247 if ($("#form_plan_filter").val() != '') {
248 if ($("#form_rule_filter").val() == $("#form_plan_filter").val()) {
249 return true;
250 } else {
251 return false;
254 else {
255 return true;
257 <?php } else { ?>
258 return true;
259 <?php } ?>
262 function Form_Validate() {
263 <?php if ( (empty($report_id)) && (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) ){ ?>
264 var d = document.forms[0];
265 FromDate = d.form_begin_date.value;
266 ToDate = d.form_target_date.value;
267 if ( (FromDate.length > 0) && (ToDate.length > 0) ) {
268 if (FromDate > ToDate){
269 alert("<?php echo xls('End date must be later than Begin date!'); ?>");
270 return false;
273 <?php } ?>
275 //For Results are in Gray Background & disabling anchor links
276 <?php if($report_id != ""){?>
277 $("#report_results").css("opacity", '0.4');
278 $("#report_results").css("filter", 'alpha(opacity=40)');
279 $("a").removeAttr("href");
280 <?php }?>
282 $("#form_refresh").attr("value","true");
283 runReport();
284 return true;
287 </script>
289 <style type="text/css">
291 /* specifically include & exclude from printing */
292 @media print {
293 #report_parameters {
294 visibility: hidden;
295 display: none;
297 #report_parameters_daterange {
298 visibility: visible;
299 display: inline;
301 #report_results table {
302 margin-top: 0px;
306 /* specifically exclude some from the screen */
307 @media screen {
308 #report_parameters_daterange {
309 visibility: hidden;
310 display: none;
314 </style>
315 </head>
317 <body class="body_top">
319 <!-- Required for the popup date selectors -->
320 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
322 <span class='title'><?php echo xlt('Report'); ?> -
324 <?php if ($type_report == "standard") { ?>
325 <?php echo xlt('Standard Measures'); ?>
326 <?php } ?>
328 <?php if ($type_report == "cqm") { ?>
329 <?php echo xlt('Clinical Quality Measures (CQM)'); ?>
330 <?php } ?>
331 <?php if ($type_report == "cqm_2011") { ?>
332 <?php echo xlt('Clinical Quality Measures (CQM) - 2011'); ?>
333 <?php } ?>
334 <?php if ($type_report == "cqm_2014") { ?>
335 <?php echo xlt('Clinical Quality Measures (CQM) - 2014'); ?>
336 <?php } ?>
338 <?php if ($type_report == "amc") { ?>
339 <?php echo xlt('Automated Measure Calculations (AMC)'); ?>
340 <?php } ?>
341 <?php if ($type_report == "amc_2011") { ?>
342 <?php echo xlt('Automated Measure Calculations (AMC) - 2011'); ?>
343 <?php } ?>
344 <?php if ($type_report == "amc_2014_stage1") { ?>
345 <?php echo xlt('Automated Measure Calculations (AMC) - 2014 Stage I'); ?>
346 <?php } ?>
347 <?php if ($type_report == "amc_2014_stage2") { ?>
348 <?php echo xlt('Automated Measure Calculations (AMC) - 2014 Stage II'); ?>
349 <?php } ?>
351 <?php if (!empty($report_id)) { ?>
352 <?php echo " - " . xlt('Date of Report') . ": " . text($date_report);
353 //prepare to disable form elements
354 $dis_text = " disabled='disabled' ";
356 <?php } ?>
357 </span>
359 <form method='post' name='theform' id='theform' action='cqm.php?type=<?php echo attr($type_report) ;?>' onsubmit='return validateForm()'>
361 <div id="report_parameters">
362 <?php
363 $widthDyn = "470px";
364 if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) $widthDyn = "410px";
366 <table>
367 <tr>
368 <td scope="row" width='<?php echo $widthDyn;?>'>
369 <div style='float:left'>
371 <table class='text'>
373 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
374 <tr>
375 <td class='label'>
376 <?php echo htmlspecialchars( xl('Begin Date'), ENT_NOQUOTES); ?>:
377 </td>
378 <td>
379 <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); ?>'
380 class='datepicker'
381 title='<?php echo htmlspecialchars( xl('yyyy-mm-dd hh:mm:ss'), ENT_QUOTES); ?>'>
382 <?php if (empty($report_id)) { ?>
383 <?php } ?>
384 </td>
385 </tr>
386 <?php } ?>
388 <tr>
389 <td class='label'>
390 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
391 <?php echo htmlspecialchars( xl('End Date'), ENT_NOQUOTES); ?>:
392 <?php } else { ?>
393 <?php echo htmlspecialchars( xl('Target Date'), ENT_NOQUOTES); ?>:
394 <?php } ?>
395 </td>
396 <td>
397 <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); ?>'
398 class='datepicker'
399 title='<?php echo htmlspecialchars( xl('yyyy-mm-dd hh:mm:ss'), ENT_QUOTES); ?>'>
400 <?php if (empty($report_id)) { ?>
401 <?php } ?>
402 </td>
403 </tr>
405 <?php if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) { ?>
406 <tr>
407 <td class='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'>
412 <option value='cqm' <?php if ($rule_filter == "cqm") echo "selected"; ?>>
413 <?php echo xlt('All Clinical Quality Measures (CQM)'); ?></option>
414 <option value='cqm_2011' <?php if ($rule_filter == "cqm_2011") echo "selected"; ?>>
415 <?php echo xlt('2011 Clinical Quality Measures (CQM)'); ?></option>
416 <option value='cqm_2014' <?php if ($rule_filter == "cqm_2014") echo "selected"; ?>>
417 <?php echo xlt('2014 Clinical Quality Measures (CQM)'); ?></option>
418 </select>
419 </td>
420 </tr>
421 <?php } ?>
423 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
424 <tr>
425 <td class='label'>
426 <?php echo xlt('Rule Set'); ?>:
427 </td>
428 <td>
429 <select <?php echo $dis_text; ?> id='form_rule_filter' name='form_rule_filter'>
431 <?php if ($rule_filter == "amc") { //only show this when displaying old reports. Not available option for new reports ?>
432 <option value='amc' selected>
433 <?php echo xlt('All Automated Measure Calculations (AMC)'); ?></option>
434 <?php } ?>
436 <option value='amc_2011' <?php if ($rule_filter == "amc_2011") echo "selected"; ?>>
437 <?php echo xlt('2011 Automated Measure Calculations (AMC)'); ?></option>
438 <option value='amc_2014_stage1' <?php if ($rule_filter == "amc_2014_stage1") echo "selected"; ?>>
439 <?php echo xlt('2014 Automated Measure Calculations (AMC) - Stage I'); ?></option>
440 <option value='amc_2014_stage2' <?php if ($rule_filter == "amc_2014_stage2") echo "selected"; ?>>
441 <?php echo xlt('2014 Automated Measure Calculations (AMC) - Stage II'); ?></option>
442 </select>
443 </td>
444 </tr>
445 <?php } ?>
447 <?php if ($type_report == "standard") { ?>
448 <tr>
449 <td class='label'>
450 <?php echo xlt('Rule Set'); ?>:
451 </td>
452 <td>
453 <select <?php echo $dis_text; ?> id='form_rule_filter' name='form_rule_filter'>
454 <option value='passive_alert' <?php if ($rule_filter == "passive_alert") echo "selected"; ?>>
455 <?php echo xlt('Passive Alert Rules'); ?></option>
456 <option value='active_alert' <?php if ($rule_filter == "active_alert") echo "selected"; ?>>
457 <?php echo xlt('Active Alert Rules'); ?></option>
458 <option value='patient_reminder' <?php if ($rule_filter == "patient_reminder") echo "selected"; ?>>
459 <?php echo xlt('Patient Reminder Rules'); ?></option>
460 </select>
461 </td>
462 </tr>
463 <?php } ?>
465 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
466 <input type='hidden' id='form_plan_filter' name='form_plan_filter' value=''>
467 <?php } else { ?>
468 <tr>
469 <td class='label'>
470 <?php echo htmlspecialchars( xl('Plan Set'), ENT_NOQUOTES); ?>:
471 </td>
472 <td>
473 <select <?php echo $dis_text; ?> id='form_plan_filter' name='form_plan_filter'>
474 <option value=''>-- <?php echo htmlspecialchars( xl('Ignore'), ENT_NOQUOTES); ?> --</option>
475 <?php if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) { ?>
476 <option value='cqm' <?php if ($plan_filter == "cqm") echo "selected"; ?>>
477 <?php echo htmlspecialchars( xl('All Official Clinical Quality Measures (CQM) Measure Groups'), ENT_NOQUOTES); ?></option>
478 <option value='cqm_2011' <?php if ($plan_filter == "cqm_2011") echo "selected"; ?>>
479 <?php echo htmlspecialchars( xl('2011 Official Clinical Quality Measures (CQM) Measure Groups'), ENT_NOQUOTES); ?></option>
480 <option value='cqm_2014' <?php if ($plan_filter == "cqm_2014") echo "selected"; ?>>
481 <?php echo htmlspecialchars( xl('2014 Official Clinical Quality Measures (CQM) Measure Groups'), ENT_NOQUOTES); ?></option>
482 <?php } ?>
483 <?php if ($type_report == "standard") { ?>
484 <option value='normal' <?php if ($plan_filter == "normal") echo "selected"; ?>>
485 <?php echo htmlspecialchars( xl('Active Plans'), ENT_NOQUOTES); ?></option>
486 <?php } ?>
487 </td>
488 </tr>
489 <?php } ?>
491 <tr>
492 <td class='label'>
493 <?php echo htmlspecialchars( xl('Provider'), ENT_NOQUOTES); ?>:
494 </td>
495 <td>
496 <?php
498 // Build a drop-down list of providers.
501 $query = "SELECT id, lname, fname FROM users WHERE ".
502 "authorized = 1 $provider_facility_filter ORDER BY lname, fname"; //(CHEMED) facility filter
504 $ures = sqlStatement($query);
506 echo " <select " . $dis_text . " id='form_provider' name='form_provider'>\n";
507 echo " <option value=''>-- " . htmlspecialchars( xl('All (Cumulative)'), ENT_NOQUOTES) . " --\n";
509 echo " <option value='collate_outer'";
510 if ($provider == 'collate_outer') echo " selected";
511 echo ">-- " . htmlspecialchars( xl('All (Collated Format A)'), ENT_NOQUOTES) . " --\n";
513 echo " <option value='collate_inner'";
514 if ($provider == 'collate_inner') echo " selected";
515 echo ">-- " . htmlspecialchars( xl('All (Collated Format B)'), ENT_NOQUOTES) . " --\n";
517 while ($urow = sqlFetchArray($ures)) {
518 $provid = $urow['id'];
519 echo " <option value='".htmlspecialchars( $provid, ENT_QUOTES)."'";
520 if ($provid == $provider) echo " selected";
521 echo ">" . htmlspecialchars( $urow['lname'] . ", " . $urow['fname'], ENT_NOQUOTES) . "\n";
524 echo " </select>\n";
527 </td>
528 </tr>
530 <tr>
531 <td class='label'>
532 <?php echo htmlspecialchars( xl('Provider Relationship'), ENT_NOQUOTES); ?>:
533 </td>
534 <td>
535 <?php
537 // Build a drop-down list of of patient provider relationships.
539 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";
540 echo " <option value='primary'";
541 if ($pat_prov_rel == 'primary') echo " selected";
542 echo ">" . xlt('Primary') . "\n";
543 echo " <option value='encounter'";
544 if ($pat_prov_rel == 'encounter') echo " selected";
545 echo ">" . xlt('Encounter') . "\n";
546 echo " </select>\n";
548 </td>
549 </tr>
551 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
552 <tr>
553 <td>
554 <?php echo htmlspecialchars( xl('Number labs'), ENT_NOQUOTES); ?>:<br>
555 (<?php echo htmlspecialchars( xl('Non-electronic'), ENT_NOQUOTES); ?>)
556 </td>
557 <td>
558 <input <?php echo $dis_text; ?> type="text" id="labs_manual_entry" name="labs_manual_entry" value="<?php echo htmlspecialchars($labs_manual,ENT_QUOTES); ?>">
559 </td>
560 </tr>
561 <?php } ?>
563 </table>
565 </div>
567 </td>
568 <td align='left' valign='middle' height="100%">
569 <table style='border-left:1px solid; width:100%; height:100%' >
570 <tr>
571 <td scope="row">
573 <div style='margin-left:15px'>
575 <?php if (empty($report_id)) { ?>
576 <a id='submit_button' href='#' class='css_button' onclick='runReport();'>
577 <span>
578 <?php echo htmlspecialchars( xl('Submit'), ENT_NOQUOTES); ?>
579 </span>
580 </a>
581 <span id='status_span'></span>
582 <div id='processing' style='margin:10px;display:none;'><img src='../pic/ajax-loader.gif'/></div>
583 <?php if ($type_report == "cqm") { ?>
584 <a id='xmla_button' href='#' class='css_button' onclick='return GenXml("false")'>
585 <span>
586 <?php echo htmlspecialchars( xl('Generate PQRI report (Method A) - 2011'), ENT_NOQUOTES); ?>
587 </span>
588 </a>
589 <a id='xmlb_button' href='#' class='css_button' onclick='return GenXml("true")'>
590 <span>
591 <?php echo htmlspecialchars( xl('Generate PQRI report (Method E) - 2011'), ENT_NOQUOTES); ?>
592 </span>
593 </a>
594 <?php } ?>
595 <?php } ?>
597 <?php if (!empty($report_id)) { ?>
598 <a href='#' class='css_button' id='printbutton'>
599 <span>
600 <?php echo htmlspecialchars( xl('Print'), ENT_NOQUOTES); ?>
601 </span>
602 </a>
603 <?php if ($type_report == "cqm_2014") { ?>
604 <a href="#" id="genQRDA" class='css_button' onclick='return downloadQRDA()'>
605 <span>
606 <?php echo htmlspecialchars( xl('Generate QRDA I – 2014'), ENT_NOQUOTES); ?>
607 </span>
608 </a>
609 <a href="#" id="xmlc_button" class='css_button' onclick='return GenXml("QRDA")'>
610 <span>
611 <?php echo htmlspecialchars( xl('Generate QRDA III - 2014'), ENT_NOQUOTES); ?>
612 </span>
613 </a>
614 <?php } ?>
616 <?php if ($back_link == "list") { ?>
617 <a href='report_results.php' class='css_button' onclick='top.restoreSession()'><span><?php echo xlt("Return To Report Results"); ?></span></a>
618 <?php } else { ?>
619 <a href='#' class='css_button' onclick='top.restoreSession(); $("#theform").submit();'><span><?php echo xlt("Start Another Report"); ?></span></a>
620 <?php } ?>
621 <?php } ?>
622 </div>
623 </td>
624 </tr>
625 </table>
626 </td>
627 </tr>
628 </table>
630 </div> <!-- end of search parameters -->
632 <br>
634 <?php
635 if (!empty($report_id)) {
639 <div id="report_results">
640 <table>
642 <thead>
643 <th>
644 <?php echo htmlspecialchars( xl('Title'), ENT_NOQUOTES); ?>
645 </th>
647 <th>
648 <?php
649 if($type_report == 'cqm' || $type_report == 'cqm_2011' || $type_report == 'cqm_2014')
650 echo htmlspecialchars( xl('Initial Patient Population'), ENT_NOQUOTES);
651 else
652 echo htmlspecialchars( xl('Total Patients'), ENT_NOQUOTES);
654 </th>
656 <th>
657 <?php if ($type_report == "amc") { ?>
658 <?php echo htmlspecialchars( xl('Denominator'), ENT_NOQUOTES); ?></a>
659 <?php } else { ?>
660 <?php echo htmlspecialchars( xl('Applicable Patients') .' (' . xl('Denominator') . ')', ENT_NOQUOTES); ?></a>
661 <?php } ?>
662 </th>
664 <?php if ($type_report != "amc") { ?>
665 <th>
666 <?php echo htmlspecialchars( xl('Denominator Exclusion'), ENT_NOQUOTES); ?></a>
667 </th>
668 <?php }?>
669 <?php if($type_report == 'cqm' || $type_report == 'cqm_2011' || $type_report == 'cqm_2014') {?>
670 <th>
671 <?php echo htmlspecialchars( xl('Denominator Exception'), ENT_NOQUOTES); ?></a>
672 </th>
673 <?php } ?>
675 <th>
676 <?php if ($type_report == "amc") { ?>
677 <?php echo htmlspecialchars( xl('Numerator'), ENT_NOQUOTES); ?></a>
678 <?php } else { ?>
679 <?php echo htmlspecialchars( xl('Passed Patients') . ' (' . xl('Numerator') . ')', ENT_NOQUOTES); ?></a>
680 <?php } ?>
681 </th>
683 <th>
684 <?php if ($type_report == "amc") { ?>
685 <?php echo htmlspecialchars( xl('Failed'), ENT_NOQUOTES); ?></a>
686 <?php } else { ?>
687 <?php echo htmlspecialchars( xl('Failed Patients'), ENT_NOQUOTES); ?></a>
688 <?php } ?>
689 </th>
691 <th>
692 <?php echo htmlspecialchars( xl('Performance Percentage'), ENT_NOQUOTES); ?></a>
693 </th>
695 </thead>
696 <tbody> <!-- added for better print-ability -->
697 <?php
699 $firstProviderFlag = TRUE;
700 $firstPlanFlag = TRUE;
701 $existProvider = FALSE;
702 foreach ($dataSheet as $row) {
706 <tr bgcolor='<?php echo $bgcolor ?>'>
708 <?php
709 if (isset($row['is_main']) || isset($row['is_sub'])) {
710 echo "<td class='detail'>";
711 if (isset($row['is_main'])) {
713 // is_sub is a special case of is_main whereas total patients, denominator, and excluded patients are taken
714 // from is_main prior to it. So, need to store denominator patients from is_main for subsequent is_sub
715 // to calculate the number of patients that failed.
716 // Note that exlusion in the standard rules is not the same as in the cqm/amd and should not be in calculation
717 // as is in the cqm/amc rules.
718 $main_pass_filter = $row['pass_filter'];
720 echo "<b>".generate_display_field(array('data_type'=>'1','list_id'=>'clinical_rules'),$row['id'])."</b>";
722 $tempCqmAmcString = "";
723 if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) {
724 if (!empty($row['cqm_pqri_code'])) {
725 $tempCqmAmcString .= " " . htmlspecialchars( xl('PQRI') . ":" . $row['cqm_pqri_code'], ENT_NOQUOTES) . " ";
727 if (!empty($row['cqm_nqf_code'])) {
728 $tempCqmAmcString .= " " . htmlspecialchars( xl('NQF') . ":" . $row['cqm_nqf_code'], ENT_NOQUOTES) . " ";
731 if ($type_report == "amc") {
732 if (!empty($row['amc_code'])) {
733 $tempCqmAmcString .= " " . htmlspecialchars( xl('AMC-2011') . ":" . $row['amc_code'], ENT_NOQUOTES) . " ";
735 if (!empty($row['amc_code_2014'])) {
736 $tempCqmAmcString .= " " . htmlspecialchars( xl('AMC-2014') . ":" . $row['amc_code_2014'], ENT_NOQUOTES) . " ";
739 if ($type_report == "amc_2011") {
740 if (!empty($row['amc_code'])) {
741 $tempCqmAmcString .= " " . htmlspecialchars( xl('AMC-2011') . ":" . $row['amc_code'], ENT_NOQUOTES) . " ";
744 if ( ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2") ) {
745 if (!empty($row['amc_code_2014'])) {
746 $tempCqmAmcString .= " " . htmlspecialchars( xl('AMC-2014') . ":" . $row['amc_code_2014'], ENT_NOQUOTES) . " ";
750 if (!empty($tempCqmAmcString)) {
751 echo "(".$tempCqmAmcString.")";
754 if ( !(empty($row['concatenated_label'])) ) {
755 echo ", " . htmlspecialchars( xl( $row['concatenated_label'] ), ENT_NOQUOTES) . " ";
759 else { // isset($row['is_sub'])
760 echo generate_display_field(array('data_type'=>'1','list_id'=>'rule_action_category'),$row['action_category']);
761 echo ": " . generate_display_field(array('data_type'=>'1','list_id'=>'rule_action'),$row['action_item']);
763 echo "</td>";
765 if($type_report == 'cqm' || $type_report == 'cqm_2011' || $type_report == 'cqm_2014')
766 echo "<td align='center'>" . $row['initial_population'] . "</td>";
767 else
768 echo "<td align='center'>" . $row['total_patients'] . "</td>";
770 if ( isset($row['itemized_test_id']) && ($row['pass_filter'] > 0) ) {
771 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>";
773 else {
774 echo "<td align='center'>" . $row['pass_filter'] . "</td>";
777 if ($type_report != "amc") {
778 // Note that amc will likely support in excluded items in the future for MU2
779 if ( ($type_report != "standard") && isset($row['itemized_test_id']) && ($row['excluded'] > 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=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>";
783 else {
784 echo "<td align='center'>" . $row['excluded'] . "</td>";
788 if($type_report == 'cqm' || $type_report == 'cqm_2011' || $type_report == 'cqm_2014'){
789 // Note that amc will likely support in exception items in the future for MU2
790 if ( isset($row['itemized_test_id']) && ($row['exception'] > 0) ) {
791 // Note standard reporting exluded is different than cqm/amc and will not support itemization
792 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>";
794 else {
795 echo "<td align='center'>" . $row['exception'] . "</td>";
799 if ( isset($row['itemized_test_id']) && ($row['pass_target'] > 0) ) {
800 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>";
802 else {
803 echo "<td align='center'>" . $row['pass_target'] . "</td>";
806 $failed_items = 0;
807 if (isset($row['is_main'])) {
808 if ($type_report == "standard") {
809 // Excluded is not part of denominator in standard rules so do not use in calculation
810 $failed_items = $row['pass_filter'] - $row['pass_target'];
812 else {
813 $failed_items = $row['pass_filter'] - $row['pass_target'] - $row['excluded'];
816 else { // isset($row['is_sub'])
817 // Excluded is not part of denominator in standard rules so do not use in calculation
818 $failed_items = $main_pass_filter - $row['pass_target'];
820 if ( isset($row['itemized_test_id']) && ($failed_items > 0) ) {
821 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>";
823 else {
824 echo "<td align='center'>" . $failed_items . "</td>";
827 echo "<td align='center'>" . $row['percentage'] . "</td>";
829 else if (isset($row['is_provider'])) {
830 // Display the provider information
831 if (!$firstProviderFlag && $_POST['form_provider'] == 'collate_outer') {
832 echo "<tr><td>&nbsp</td></tr>";
834 echo "<td class='detail' align='center'><b>";
835 echo htmlspecialchars( xl("Provider").": " . $row['prov_lname'] . "," . $row['prov_fname'], ENT_NOQUOTES);
836 if (!empty($row['npi']) || !empty($row['federaltaxid'])) {
837 echo " (";
838 if (!empty($row['npi'])) {
839 echo " " . htmlspecialchars( xl('NPI') . ":" . $row['npi'], ENT_NOQUOTES) . " ";
841 if (!empty($row['federaltaxid'])) {
842 echo " " . htmlspecialchars( xl('TID') . ":" . $row['federaltaxid'], ENT_NOQUOTES) . " ";
844 echo ")";
846 echo "</b></td>";
847 $firstProviderFlag = FALSE;
848 $existProvider = TRUE;
850 else { // isset($row['is_plan'])
851 if (!$firstPlanFlag && $_POST['form_provider'] != 'collate_outer') {
852 echo "<tr><td>&nbsp</td></tr>";
854 echo "<td class='detail' align='center'><b>";
855 echo htmlspecialchars( xl("Plan"), ENT_NOQUOTES) . ": ";
856 echo generate_display_field(array('data_type'=>'1','list_id'=>'clinical_plans'),$row['id']);
857 if (!empty($row['cqm_measure_group'])) {
858 echo " (". htmlspecialchars( xl('Measure Group Code') . ": " . $row['cqm_measure_group'], ENT_NOQUOTES) . ")";
860 echo "</b></td>";
861 $firstPlanFlag = FALSE;
864 </tr>
866 <?php
869 </tbody>
870 </table>
871 </div> <!-- end of search results -->
872 <?php } else { ?>
873 <div id="instructions_text" class='text'>
874 <?php echo htmlspecialchars( xl('Please input search criteria above, and click Submit to start report.'), ENT_NOQUOTES); ?>
875 </div>
876 <?php } ?>
878 <input type='hidden' name='form_new_report_id' id='form_new_report_id' value=''/>
880 </form>
882 </body>
884 </html>