Support for optional logging of print actions.
[openemr.git] / interface / reports / cqm.php
blobe5f6a42ede93010ed675c4b6517f0c6e3d4c7e2b
1 <?php
2 // Copyright (C) 2010 Brady Miller <brady@sparmy.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 //SANITIZE ALL ESCAPES
10 $sanitize_all_escapes=true;
13 //STOP FAKE REGISTER GLOBALS
14 $fake_register_globals=false;
17 require_once("../globals.php");
18 require_once("../../library/patient.inc");
19 require_once("$srcdir/formatting.inc.php");
20 require_once "$srcdir/options.inc.php";
21 require_once "$srcdir/formdata.inc.php";
22 require_once "$srcdir/clinical_rules.php";
23 require_once "$srcdir/report_database.inc";
25 // This is only pertinent for users of php versions less than 5.2
26 // (ie. this wrapper is only loaded when php version is less than
27 // 5.2; otherwise the native php json functions are used)
28 require_once "$srcdir/jsonwrapper/jsonwrapper.php";
30 // See if showing an old report or creating a new report
31 $report_id = (isset($_GET['report_id'])) ? trim($_GET['report_id']) : "";
33 // Collect the back variable, if pertinent
34 $back_link = (isset($_GET['back'])) ? trim($_GET['back']) : "";
36 // If showing an old report, then collect information
37 if (!empty($report_id)) {
38 $report_view = collectReportDatabase($report_id);
39 $date_report = $report_view['date_report'];
40 $type_report = $report_view['type'];
42 $type_report = (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2") ||
43 ($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) ? $type_report : "standard";
44 $rule_filter = $report_view['type'];
46 if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) {
47 $begin_date = $report_view['date_begin'];
48 $labs_manual = $report_view['labs_manual'];
50 $target_date = $report_view['date_target'];
51 $plan_filter = $report_view['plan'];
52 $organize_method = $report_view['organize_mode'];
53 $provider = $report_view['provider'];
54 $pat_prov_rel = $report_view['pat_prov_rel'];
55 $dataSheet = json_decode($report_view['data'],TRUE);
57 else {
58 // Collect report type parameter (standard, amc, cqm)
59 // Note that need to convert amc_2011 and amc_2014 to amc and cqm_2011 and cqm_2014 to cqm
60 // to simplify for when submitting for a new report.
61 $type_report = (isset($_GET['type'])) ? trim($_GET['type']) : "standard";
63 if ( ($type_report == "cqm_2011") || ($type_report == "cqm_2014") ) {
64 $type_report = "cqm";
66 if ( ($type_report == "amc_2011") || ($type_report == "amc_2014") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2") ) {
67 $type_report = "amc";
69 // Collect form parameters (set defaults if empty)
70 if ($type_report == "amc") {
71 $begin_date = (isset($_POST['form_begin_date'])) ? trim($_POST['form_begin_date']) : "";
72 $labs_manual = (isset($_POST['labs_manual_entry'])) ? trim($_POST['labs_manual_entry']) : "0";
74 $target_date = (isset($_POST['form_target_date'])) ? trim($_POST['form_target_date']) : date('Y-m-d H:i:s');
75 $rule_filter = (isset($_POST['form_rule_filter'])) ? trim($_POST['form_rule_filter']) : "";
76 $plan_filter = (isset($_POST['form_plan_filter'])) ? trim($_POST['form_plan_filter']) : "";
77 $organize_method = (empty($plan_filter)) ? "default" : "plans";
78 $provider = trim($_POST['form_provider']);
79 $pat_prov_rel = (empty($_POST['form_pat_prov_rel'])) ? "primary" : trim($_POST['form_pat_prov_rel']);
83 <html>
85 <head>
86 <?php html_header_show();?>
88 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
90 <?php if ($type_report == "standard") { ?>
91 <title><?php echo xlt('Standard Measures'); ?></title>
92 <?php } ?>
94 <?php if ($type_report == "cqm") { ?>
95 <title><?php echo xlt('Clinical Quality Measures (CQM)'); ?></title>
96 <?php } ?>
97 <?php if ($type_report == "cqm_2011") { ?>
98 <title><?php echo xlt('Clinical Quality Measures (CQM) - 2011'); ?></title>
99 <?php } ?>
100 <?php if ($type_report == "cqm_2014") { ?>
101 <title><?php echo xlt('Clinical Quality Measures (CQM) - 2014'); ?></title>
102 <?php } ?>
104 <?php if ($type_report == "amc") { ?>
105 <title><?php echo xlt('Automated Measure Calculations (AMC)'); ?></title>
106 <?php } ?>
107 <?php if ($type_report == "amc_2011") { ?>
108 <title><?php echo xlt('Automated Measure Calculations (AMC) - 2011'); ?></title>
109 <?php } ?>
110 <?php if ($type_report == "amc_2014_stage1") { ?>
111 <title><?php echo xlt('Automated Measure Calculations (AMC) - 2014 Stage I'); ?></title>
112 <?php } ?>
113 <?php if ($type_report == "amc_2014_stage2") { ?>
114 <title><?php echo xlt('Automated Measure Calculations (AMC) - 2014 Stage II'); ?></title>
115 <?php } ?>
117 <script type="text/javascript" src="../../library/overlib_mini.js"></script>
118 <script type="text/javascript" src="../../library/textformat.js"></script>
119 <script type="text/javascript" src="../../library/dialog.js"></script>
120 <script type="text/javascript" src="../../library/js/jquery.1.3.2.js"></script>
122 <script LANGUAGE="JavaScript">
124 var mypcc = '<?php echo text($GLOBALS['phone_country_code']) ?>';
126 $(document).ready(function() {
127 var win = top.printLogSetup ? top : opener.top;
128 win.printLogSetup(document.getElementById('printbutton'));
131 function runReport() {
133 // Validate first
134 if (!(validateForm())) {
135 alert("<?php echo xls("Rule Set and Plan Set selections are not consistent. Please fix and Submit again."); ?>");
136 return false;
139 // Showing processing wheel
140 $("#processing").show();
142 // hide Submit buttons
143 $("#submit_button").hide();
144 $("#xmla_button").hide();
145 $("#xmlb_button").hide();
146 $("#xmlc_button").hide();
147 $("#print_button").hide();
148 $("#genQRDA").hide();
150 // hide instructions
151 $("#instructions_text").hide();
153 // Collect an id string via an ajax request
154 top.restoreSession();
155 $.get("../../library/ajax/collect_new_report_id.php",
156 function(data){
157 // Set the report id in page form
158 $("#form_new_report_id").attr("value",data);
160 // Start collection status checks
161 collectStatus($("#form_new_report_id").val());
163 // Run the report
164 top.restoreSession();
165 $.post("../../library/ajax/execute_cdr_report.php",
166 {provider: $("#form_provider").val(),
167 type: $("#form_rule_filter").val(),
168 date_target: $("#form_target_date").val(),
169 date_begin: $("#form_begin_date").val(),
170 plan: $("#form_plan_filter").val(),
171 labs: $("#labs_manual_entry").val(),
172 pat_prov_rel: $("#form_pat_prov_rel").val(),
173 execute_report_id: $("#form_new_report_id").val()
178 function collectStatus(report_id) {
179 // Collect the status string via an ajax request and place in DOM at timed intervals
180 top.restoreSession();
181 // Do not send the skip_timeout_reset parameter, so don't close window before report is done.
182 $.post("../../library/ajax/status_report.php",
183 {status_report_id: report_id},
184 function(data){
185 if (data == "PENDING") {
186 // Place the pending string in the DOM
187 $('#status_span').replaceWith("<span id='status_span'><?php echo xlt("Preparing To Run Report"); ?></span>");
189 else if (data == "COMPLETE") {
190 // Go into the results page
191 top.restoreSession();
192 link_report = "cqm.php?report_id="+report_id;
193 window.open(link_report,'_self',false);
194 //$("#processing").hide();
195 //$('#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>");
197 else {
198 // Place the string in the DOM
199 $('#status_span').replaceWith("<span id='status_span'>"+data+"</span>");
202 // run status check every 10 seconds
203 var repeater = setTimeout("collectStatus("+report_id+")", 10000);
206 function GenXml(sNested) {
207 top.restoreSession();
208 //QRDA Category III Export
209 if(sNested == "QRDA"){
210 var form_rule_filter = theform.form_rule_filter.value
211 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);?>";
212 }else{
213 var sLoc = '../../custom/export_registry_xml.php?&target_date=' + theform.form_target_date.value + '&nested=' + sNested;
215 dlgopen(sLoc, '_blank', 600, 500);
216 return false;
219 //QRDA I - 2014 Download
220 function downloadQRDA() {
221 top.restoreSession();
222 var reportID = '<?php echo attr($report_id); ?>';
223 var provider = $("#form_provider").val();
224 sLoc = '../../custom/download_qrda.php?&report_id=' + reportID + '&provider_id=' + provider;
225 dlgopen(sLoc, '_blank', 600, 500);
228 function validateForm() {
229 <?php if ( (empty($report_id)) && ($type_report == "cqm") ) { ?>
230 // If this is a cqm and plan set not set to ignore, then need to ensure consistent with the rules set
231 if ($("#form_plan_filter").val() != '') {
232 if ($("#form_rule_filter").val() == $("#form_plan_filter").val()) {
233 return true;
234 } else {
235 return false;
238 else {
239 return true;
241 <?php } else { ?>
242 return true;
243 <?php } ?>
246 function Form_Validate() {
247 <?php if ( (empty($report_id)) && (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) ){ ?>
248 var d = document.forms[0];
249 FromDate = d.form_begin_date.value;
250 ToDate = d.form_target_date.value;
251 if ( (FromDate.length > 0) && (ToDate.length > 0) ) {
252 if (FromDate > ToDate){
253 alert("<?php echo xls('End date must be later than Begin date!'); ?>");
254 return false;
257 <?php } ?>
259 //For Results are in Gray Background & disabling anchor links
260 <?php if($report_id != ""){?>
261 $("#report_results").css("opacity", '0.4');
262 $("#report_results").css("filter", 'alpha(opacity=40)');
263 $("a").removeAttr("href");
264 <?php }?>
266 $("#form_refresh").attr("value","true");
267 runReport();
268 return true;
271 </script>
273 <style type="text/css">
275 /* specifically include & exclude from printing */
276 @media print {
277 #report_parameters {
278 visibility: hidden;
279 display: none;
281 #report_parameters_daterange {
282 visibility: visible;
283 display: inline;
285 #report_results table {
286 margin-top: 0px;
290 /* specifically exclude some from the screen */
291 @media screen {
292 #report_parameters_daterange {
293 visibility: hidden;
294 display: none;
298 </style>
299 </head>
301 <body class="body_top">
303 <!-- Required for the popup date selectors -->
304 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
306 <span class='title'><?php echo xlt('Report'); ?> -
308 <?php if ($type_report == "standard") { ?>
309 <?php echo xlt('Standard Measures'); ?>
310 <?php } ?>
312 <?php if ($type_report == "cqm") { ?>
313 <?php echo xlt('Clinical Quality Measures (CQM)'); ?>
314 <?php } ?>
315 <?php if ($type_report == "cqm_2011") { ?>
316 <?php echo xlt('Clinical Quality Measures (CQM) - 2011'); ?>
317 <?php } ?>
318 <?php if ($type_report == "cqm_2014") { ?>
319 <?php echo xlt('Clinical Quality Measures (CQM) - 2014'); ?>
320 <?php } ?>
322 <?php if ($type_report == "amc") { ?>
323 <?php echo xlt('Automated Measure Calculations (AMC)'); ?>
324 <?php } ?>
325 <?php if ($type_report == "amc_2011") { ?>
326 <?php echo xlt('Automated Measure Calculations (AMC) - 2011'); ?>
327 <?php } ?>
328 <?php if ($type_report == "amc_2014_stage1") { ?>
329 <?php echo xlt('Automated Measure Calculations (AMC) - 2014 Stage I'); ?>
330 <?php } ?>
331 <?php if ($type_report == "amc_2014_stage2") { ?>
332 <?php echo xlt('Automated Measure Calculations (AMC) - 2014 Stage II'); ?>
333 <?php } ?>
335 <?php if (!empty($report_id)) { ?>
336 <?php echo " - " . xlt('Date of Report') . ": " . text($date_report);
337 //prepare to disable form elements
338 $dis_text = " disabled='disabled' ";
340 <?php } ?>
341 </span>
343 <form method='post' name='theform' id='theform' action='cqm.php?type=<?php echo attr($type_report) ;?>' onsubmit='return validateForm()'>
345 <div id="report_parameters">
346 <?php
347 $widthDyn = "470px";
348 if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) $widthDyn = "410px";
350 <table>
351 <tr>
352 <td scope="row" width='<?php echo $widthDyn;?>'>
353 <div style='float:left'>
355 <table class='text'>
357 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
358 <tr>
359 <td class='label'>
360 <?php echo htmlspecialchars( xl('Begin Date'), ENT_NOQUOTES); ?>:
361 </td>
362 <td>
363 <input <?php echo $dis_text; ?> type='text' name='form_begin_date' id="form_begin_date" size='20' value='<?php echo htmlspecialchars( $begin_date, ENT_QUOTES); ?>'
364 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title='<?php echo htmlspecialchars( xl('yyyy-mm-dd hh:mm:ss'), ENT_QUOTES); ?>'>
365 <?php if (empty($report_id)) { ?>
366 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
367 id='img_begin_date' border='0' alt='[?]' style='cursor:pointer'
368 title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>'>
369 <?php } ?>
370 </td>
371 </tr>
372 <?php } ?>
374 <tr>
375 <td class='label'>
376 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
377 <?php echo htmlspecialchars( xl('End Date'), ENT_NOQUOTES); ?>:
378 <?php } else { ?>
379 <?php echo htmlspecialchars( xl('Target Date'), ENT_NOQUOTES); ?>:
380 <?php } ?>
381 </td>
382 <td>
383 <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); ?>'
384 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title='<?php echo htmlspecialchars( xl('yyyy-mm-dd hh:mm:ss'), ENT_QUOTES); ?>'>
385 <?php if (empty($report_id)) { ?>
386 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
387 id='img_target_date' border='0' alt='[?]' style='cursor:pointer'
388 title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>'>
389 <?php } ?>
390 </td>
391 </tr>
393 <?php if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) { ?>
394 <tr>
395 <td class='label'>
396 <?php echo xlt('Rule Set'); ?>:
397 </td>
398 <td>
399 <select <?php echo $dis_text; ?> id='form_rule_filter' name='form_rule_filter'>
400 <option value='cqm' <?php if ($rule_filter == "cqm") echo "selected"; ?>>
401 <?php echo xlt('All Clinical Quality Measures (CQM)'); ?></option>
402 <option value='cqm_2011' <?php if ($rule_filter == "cqm_2011") echo "selected"; ?>>
403 <?php echo xlt('2011 Clinical Quality Measures (CQM)'); ?></option>
404 <option value='cqm_2014' <?php if ($rule_filter == "cqm_2014") echo "selected"; ?>>
405 <?php echo xlt('2014 Clinical Quality Measures (CQM)'); ?></option>
406 </select>
407 </td>
408 </tr>
409 <?php } ?>
411 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
412 <tr>
413 <td class='label'>
414 <?php echo xlt('Rule Set'); ?>:
415 </td>
416 <td>
417 <select <?php echo $dis_text; ?> id='form_rule_filter' name='form_rule_filter'>
418 <option value='amc' <?php if ($rule_filter == "amc") echo "selected"; ?>>
419 <?php echo xlt('All Automated Measure Calculations (AMC)'); ?></option>
420 <option value='amc_2011' <?php if ($rule_filter == "amc_2011") echo "selected"; ?>>
421 <?php echo xlt('2011 Automated Measure Calculations (AMC)'); ?></option>
422 <option value='amc_2014_stage1' <?php if ($rule_filter == "amc_2014_stage1") echo "selected"; ?>>
423 <?php echo xlt('2014 Automated Measure Calculations (AMC) - Stage I'); ?></option>
424 <option value='amc_2014_stage2' <?php if ($rule_filter == "amc_2014_stage2") echo "selected"; ?>>
425 <?php echo xlt('2014 Automated Measure Calculations (AMC) - Stage II'); ?></option>
426 </select>
427 </td>
428 </tr>
429 <?php } ?>
431 <?php if ($type_report == "standard") { ?>
432 <tr>
433 <td class='label'>
434 <?php echo xlt('Rule Set'); ?>:
435 </td>
436 <td>
437 <select <?php echo $dis_text; ?> id='form_rule_filter' name='form_rule_filter'>
438 <option value='passive_alert' <?php if ($rule_filter == "passive_alert") echo "selected"; ?>>
439 <?php echo xlt('Passive Alert Rules'); ?></option>
440 <option value='active_alert' <?php if ($rule_filter == "active_alert") echo "selected"; ?>>
441 <?php echo xlt('Active Alert Rules'); ?></option>
442 <option value='patient_reminder' <?php if ($rule_filter == "patient_reminder") echo "selected"; ?>>
443 <?php echo xlt('Patient Reminder Rules'); ?></option>
444 </select>
445 </td>
446 </tr>
447 <?php } ?>
449 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
450 <input type='hidden' id='form_plan_filter' name='form_plan_filter' value=''>
451 <?php } else { ?>
452 <tr>
453 <td class='label'>
454 <?php echo htmlspecialchars( xl('Plan Set'), ENT_NOQUOTES); ?>:
455 </td>
456 <td>
457 <select <?php echo $dis_text; ?> id='form_plan_filter' name='form_plan_filter'>
458 <option value=''>-- <?php echo htmlspecialchars( xl('Ignore'), ENT_NOQUOTES); ?> --</option>
459 <?php if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) { ?>
460 <option value='cqm' <?php if ($plan_filter == "cqm") echo "selected"; ?>>
461 <?php echo htmlspecialchars( xl('All Official Clinical Quality Measures (CQM) Measure Groups'), ENT_NOQUOTES); ?></option>
462 <option value='cqm_2011' <?php if ($plan_filter == "cqm_2011") echo "selected"; ?>>
463 <?php echo htmlspecialchars( xl('2011 Official Clinical Quality Measures (CQM) Measure Groups'), ENT_NOQUOTES); ?></option>
464 <option value='cqm_2014' <?php if ($plan_filter == "cqm_2014") echo "selected"; ?>>
465 <?php echo htmlspecialchars( xl('2014 Official Clinical Quality Measures (CQM) Measure Groups'), ENT_NOQUOTES); ?></option>
466 <?php } ?>
467 <?php if ($type_report == "standard") { ?>
468 <option value='normal' <?php if ($plan_filter == "normal") echo "selected"; ?>>
469 <?php echo htmlspecialchars( xl('Active Plans'), ENT_NOQUOTES); ?></option>
470 <?php } ?>
471 </td>
472 </tr>
473 <?php } ?>
475 <tr>
476 <td class='label'>
477 <?php echo htmlspecialchars( xl('Provider'), ENT_NOQUOTES); ?>:
478 </td>
479 <td>
480 <?php
482 // Build a drop-down list of providers.
485 $query = "SELECT id, lname, fname FROM users WHERE ".
486 "authorized = 1 $provider_facility_filter ORDER BY lname, fname"; //(CHEMED) facility filter
488 $ures = sqlStatement($query);
490 echo " <select " . $dis_text . " id='form_provider' name='form_provider'>\n";
491 echo " <option value=''>-- " . htmlspecialchars( xl('All (Cumulative)'), ENT_NOQUOTES) . " --\n";
493 echo " <option value='collate_outer'";
494 if ($provider == 'collate_outer') echo " selected";
495 echo ">-- " . htmlspecialchars( xl('All (Collated Format A)'), ENT_NOQUOTES) . " --\n";
497 echo " <option value='collate_inner'";
498 if ($provider == 'collate_inner') echo " selected";
499 echo ">-- " . htmlspecialchars( xl('All (Collated Format B)'), ENT_NOQUOTES) . " --\n";
501 while ($urow = sqlFetchArray($ures)) {
502 $provid = $urow['id'];
503 echo " <option value='".htmlspecialchars( $provid, ENT_QUOTES)."'";
504 if ($provid == $provider) echo " selected";
505 echo ">" . htmlspecialchars( $urow['lname'] . ", " . $urow['fname'], ENT_NOQUOTES) . "\n";
508 echo " </select>\n";
511 </td>
512 </tr>
514 <tr>
515 <td class='label'>
516 <?php echo htmlspecialchars( xl('Provider Relationship'), ENT_NOQUOTES); ?>:
517 </td>
518 <td>
519 <?php
521 // Build a drop-down list of of patient provider relationships.
523 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";
524 echo " <option value='primary'";
525 if ($pat_prov_rel == 'primary') echo " selected";
526 echo ">" . xlt('Primary') . "\n";
527 echo " <option value='encounter'";
528 if ($pat_prov_rel == 'encounter') echo " selected";
529 echo ">" . xlt('Encounter') . "\n";
530 echo " </select>\n";
532 </td>
533 </tr>
535 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
536 <tr>
537 <td>
538 <?php echo htmlspecialchars( xl('Number labs'), ENT_NOQUOTES); ?>:<br>
539 (<?php echo htmlspecialchars( xl('Non-electronic'), ENT_NOQUOTES); ?>)
540 </td>
541 <td>
542 <input <?php echo $dis_text; ?> type="text" id="labs_manual_entry" name="labs_manual_entry" value="<?php echo htmlspecialchars($labs_manual,ENT_QUOTES); ?>">
543 </td>
544 </tr>
545 <?php } ?>
547 </table>
549 </div>
551 </td>
552 <td align='left' valign='middle' height="100%">
553 <table style='border-left:1px solid; width:100%; height:100%' >
554 <tr>
555 <td scope="row">
557 <div style='margin-left:15px'>
559 <?php if (empty($report_id)) { ?>
560 <a id='submit_button' href='#' class='css_button' onclick='runReport();'>
561 <span>
562 <?php echo htmlspecialchars( xl('Submit'), ENT_NOQUOTES); ?>
563 </span>
564 </a>
565 <span id='status_span'></span>
566 <div id='processing' style='margin:10px;display:none;'><img src='../pic/ajax-loader.gif'/></div>
567 <?php if ($type_report == "cqm") { ?>
568 <a id='xmla_button' href='#' class='css_button' onclick='return GenXml("false")'>
569 <span>
570 <?php echo htmlspecialchars( xl('Generate PQRI report (Method A) - 2011'), ENT_NOQUOTES); ?>
571 </span>
572 </a>
573 <a id='xmlb_button' href='#' class='css_button' onclick='return GenXml("true")'>
574 <span>
575 <?php echo htmlspecialchars( xl('Generate PQRI report (Method E) - 2011'), ENT_NOQUOTES); ?>
576 </span>
577 </a>
578 <?php } ?>
579 <?php } ?>
581 <?php if (!empty($report_id)) { ?>
582 <a href='#' class='css_button' id='printbutton'>
583 <span>
584 <?php echo htmlspecialchars( xl('Print'), ENT_NOQUOTES); ?>
585 </span>
586 </a>
587 <?php if ($type_report == "cqm_2014") { ?>
588 <a href="#" id="genQRDA" class='css_button' onclick='return downloadQRDA()'>
589 <span>
590 <?php echo htmlspecialchars( xl('Generate QRDA I – 2014'), ENT_NOQUOTES); ?>
591 </span>
592 </a>
593 <a href="#" id="xmlc_button" class='css_button' onclick='return GenXml("QRDA")'>
594 <span>
595 <?php echo htmlspecialchars( xl('Generate QRDA III - 2014'), ENT_NOQUOTES); ?>
596 </span>
597 </a>
598 <?php } ?>
600 <?php if ($back_link == "list") { ?>
601 <a href='report_results.php' class='css_button' onclick='top.restoreSession()'><span><?php echo xlt("Return To Report Results"); ?></span></a>
602 <?php } else { ?>
603 <a href='#' class='css_button' onclick='top.restoreSession(); $("#theform").submit();'><span><?php echo xlt("Start Another Report"); ?></span></a>
604 <?php } ?>
605 <?php } ?>
606 </div>
607 </td>
608 </tr>
609 </table>
610 </td>
611 </tr>
612 </table>
614 </div> <!-- end of search parameters -->
616 <br>
618 <?php
619 if (!empty($report_id)) {
623 <div id="report_results">
624 <table>
626 <thead>
627 <th>
628 <?php echo htmlspecialchars( xl('Title'), ENT_NOQUOTES); ?>
629 </th>
631 <th>
632 <?php echo htmlspecialchars( xl('Total Patients'), ENT_NOQUOTES); ?>
633 </th>
635 <th>
636 <?php if ($type_report == "amc") { ?>
637 <?php echo htmlspecialchars( xl('Denominator'), ENT_NOQUOTES); ?></a>
638 <?php } else { ?>
639 <?php echo htmlspecialchars( xl('Applicable Patients') .' (' . xl('Denominator') . ')', ENT_NOQUOTES); ?></a>
640 <?php } ?>
641 </th>
643 <?php if ($type_report != "amc") { ?>
644 <th>
645 <?php echo htmlspecialchars( xl('Excluded Patients'), ENT_NOQUOTES); ?></a>
646 </th>
647 <?php } ?>
649 <th>
650 <?php if ($type_report == "amc") { ?>
651 <?php echo htmlspecialchars( xl('Numerator'), ENT_NOQUOTES); ?></a>
652 <?php } else { ?>
653 <?php echo htmlspecialchars( xl('Passed Patients') . ' (' . xl('Numerator') . ')', ENT_NOQUOTES); ?></a>
654 <?php } ?>
655 </th>
657 <th>
658 <?php if ($type_report == "amc") { ?>
659 <?php echo htmlspecialchars( xl('Failed'), ENT_NOQUOTES); ?></a>
660 <?php } else { ?>
661 <?php echo htmlspecialchars( xl('Failed Patients'), ENT_NOQUOTES); ?></a>
662 <?php } ?>
663 </th>
665 <th>
666 <?php echo htmlspecialchars( xl('Performance Percentage'), ENT_NOQUOTES); ?></a>
667 </th>
669 </thead>
670 <tbody> <!-- added for better print-ability -->
671 <?php
673 $firstProviderFlag = TRUE;
674 $firstPlanFlag = TRUE;
675 $existProvider = FALSE;
676 foreach ($dataSheet as $row) {
680 <tr bgcolor='<?php echo $bgcolor ?>'>
682 <?php
683 if (isset($row['is_main']) || isset($row['is_sub'])) {
684 echo "<td class='detail'>";
685 if (isset($row['is_main'])) {
687 // is_sub is a special case of is_main whereas total patients, denominator, and excluded patients are taken
688 // from is_main prior to it. So, need to store denominator patients from is_main for subsequent is_sub
689 // to calculate the number of patients that failed.
690 // Note that exlusion in the standard rules is not the same as in the cqm/amd and should not be in calculation
691 // as is in the cqm/amc rules.
692 $main_pass_filter = $row['pass_filter'];
694 echo "<b>".generate_display_field(array('data_type'=>'1','list_id'=>'clinical_rules'),$row['id'])."</b>";
696 $tempCqmAmcString = "";
697 if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) {
698 if (!empty($row['cqm_pqri_code'])) {
699 $tempCqmAmcString .= " " . htmlspecialchars( xl('PQRI') . ":" . $row['cqm_pqri_code'], ENT_NOQUOTES) . " ";
701 if (!empty($row['cqm_nqf_code'])) {
702 $tempCqmAmcString .= " " . htmlspecialchars( xl('NQF') . ":" . $row['cqm_nqf_code'], ENT_NOQUOTES) . " ";
705 if ($type_report == "amc") {
706 if (!empty($row['amc_code'])) {
707 $tempCqmAmcString .= " " . htmlspecialchars( xl('AMC-2011') . ":" . $row['amc_code'], ENT_NOQUOTES) . " ";
709 if (!empty($row['amc_code_2014'])) {
710 $tempCqmAmcString .= " " . htmlspecialchars( xl('AMC-2014') . ":" . $row['amc_code_2014'], ENT_NOQUOTES) . " ";
713 if ($type_report == "amc_2011") {
714 if (!empty($row['amc_code'])) {
715 $tempCqmAmcString .= " " . htmlspecialchars( xl('AMC-2011') . ":" . $row['amc_code'], ENT_NOQUOTES) . " ";
718 if ( ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2") ) {
719 if (!empty($row['amc_code_2014'])) {
720 $tempCqmAmcString .= " " . htmlspecialchars( xl('AMC-2014') . ":" . $row['amc_code_2014'], ENT_NOQUOTES) . " ";
724 if (!empty($tempCqmAmcString)) {
725 echo "(".$tempCqmAmcString.")";
728 if ( !(empty($row['concatenated_label'])) ) {
729 echo ", " . htmlspecialchars( xl( $row['concatenated_label'] ), ENT_NOQUOTES) . " ";
733 else { // isset($row['is_sub'])
734 echo generate_display_field(array('data_type'=>'1','list_id'=>'rule_action_category'),$row['action_category']);
735 echo ": " . generate_display_field(array('data_type'=>'1','list_id'=>'rule_action'),$row['action_item']);
737 echo "</td>";
738 echo "<td align='center'>" . $row['total_patients'] . "</td>";
740 if ( isset($row['itemized_test_id']) && ($row['pass_filter'] > 0) ) {
741 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>";
743 else {
744 echo "<td align='center'>" . $row['pass_filter'] . "</td>";
747 if ($type_report != "amc") {
748 // Note that amc will likely support in excluded items in the future for MU2
749 if ( ($type_report != "standard") && isset($row['itemized_test_id']) && ($row['excluded'] > 0) ) {
750 // Note standard reporting exluded is different than cqm/amc and will not support itemization
751 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>";
753 else {
754 echo "<td align='center'>" . $row['excluded'] . "</td>";
758 if ( isset($row['itemized_test_id']) && ($row['pass_target'] > 0) ) {
759 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>";
761 else {
762 echo "<td align='center'>" . $row['pass_target'] . "</td>";
765 $failed_items = 0;
766 if (isset($row['is_main'])) {
767 if ($type_report == "standard") {
768 // Excluded is not part of denominator in standard rules so do not use in calculation
769 $failed_items = $row['pass_filter'] - $row['pass_target'];
771 else {
772 $failed_items = $row['pass_filter'] - $row['pass_target'] - $row['excluded'];
775 else { // isset($row['is_sub'])
776 // Excluded is not part of denominator in standard rules so do not use in calculation
777 $failed_items = $main_pass_filter - $row['pass_target'];
779 if ( isset($row['itemized_test_id']) && ($failed_items > 0) ) {
780 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>";
782 else {
783 echo "<td align='center'>" . $failed_items . "</td>";
786 echo "<td align='center'>" . $row['percentage'] . "</td>";
788 else if (isset($row['is_provider'])) {
789 // Display the provider information
790 if (!$firstProviderFlag && $_POST['form_provider'] == 'collate_outer') {
791 echo "<tr><td>&nbsp</td></tr>";
793 echo "<td class='detail' align='center'><b>";
794 echo htmlspecialchars( xl("Provider").": " . $row['prov_lname'] . "," . $row['prov_fname'], ENT_NOQUOTES);
795 if (!empty($row['npi']) || !empty($row['federaltaxid'])) {
796 echo " (";
797 if (!empty($row['npi'])) {
798 echo " " . htmlspecialchars( xl('NPI') . ":" . $row['npi'], ENT_NOQUOTES) . " ";
800 if (!empty($row['federaltaxid'])) {
801 echo " " . htmlspecialchars( xl('TID') . ":" . $row['federaltaxid'], ENT_NOQUOTES) . " ";
803 echo ")";
805 echo "</b></td>";
806 $firstProviderFlag = FALSE;
807 $existProvider = TRUE;
809 else { // isset($row['is_plan'])
810 if (!$firstPlanFlag && $_POST['form_provider'] != 'collate_outer') {
811 echo "<tr><td>&nbsp</td></tr>";
813 echo "<td class='detail' align='center'><b>";
814 echo htmlspecialchars( xl("Plan"), ENT_NOQUOTES) . ": ";
815 echo generate_display_field(array('data_type'=>'1','list_id'=>'clinical_plans'),$row['id']);
816 if (!empty($row['cqm_measure_group'])) {
817 echo " (". htmlspecialchars( xl('Measure Group Code') . ": " . $row['cqm_measure_group'], ENT_NOQUOTES) . ")";
819 echo "</b></td>";
820 $firstPlanFlag = FALSE;
823 </tr>
825 <?php
828 </tbody>
829 </table>
830 </div> <!-- end of search results -->
831 <?php } else { ?>
832 <div id="instructions_text" class='text'>
833 <?php echo htmlspecialchars( xl('Please input search criteria above, and click Submit to start report.'), ENT_NOQUOTES); ?>
834 </div>
835 <?php } ?>
837 <input type='hidden' name='form_new_report_id' id='form_new_report_id' value=''/>
839 </form>
841 </body>
843 <!-- stuff for the popup calendar -->
844 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
845 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
846 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
847 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
848 <script language="Javascript">
849 <?php if ($type_report == "amc" || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2") ) { ?>
850 Calendar.setup({inputField:"form_begin_date", ifFormat:"%Y-%m-%d %H:%M:%S", button:"img_begin_date", showsTime:'true'});
851 <?php } ?>
852 Calendar.setup({inputField:"form_target_date", ifFormat:"%Y-%m-%d %H:%M:%S", button:"img_target_date", showsTime:'true'});
853 </script>
855 </html>