Fixed bug: https://sourceforge.net/p/openemr/bugs/416/
[openemr.git] / interface / reports / cqm.php
blobd739edf456c3c5295280f8d5dd828dd925189edd
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'>
419 <?php if ($rule_filter == "amc") { //only show this when displaying old reports. Not available option for new reports ?>
420 <option value='amc' selected>
421 <?php echo xlt('All Automated Measure Calculations (AMC)'); ?></option>
422 <?php } ?>
424 <option value='amc_2011' <?php if ($rule_filter == "amc_2011") echo "selected"; ?>>
425 <?php echo xlt('2011 Automated Measure Calculations (AMC)'); ?></option>
426 <option value='amc_2014_stage1' <?php if ($rule_filter == "amc_2014_stage1") echo "selected"; ?>>
427 <?php echo xlt('2014 Automated Measure Calculations (AMC) - Stage I'); ?></option>
428 <option value='amc_2014_stage2' <?php if ($rule_filter == "amc_2014_stage2") echo "selected"; ?>>
429 <?php echo xlt('2014 Automated Measure Calculations (AMC) - Stage II'); ?></option>
430 </select>
431 </td>
432 </tr>
433 <?php } ?>
435 <?php if ($type_report == "standard") { ?>
436 <tr>
437 <td class='label'>
438 <?php echo xlt('Rule Set'); ?>:
439 </td>
440 <td>
441 <select <?php echo $dis_text; ?> id='form_rule_filter' name='form_rule_filter'>
442 <option value='passive_alert' <?php if ($rule_filter == "passive_alert") echo "selected"; ?>>
443 <?php echo xlt('Passive Alert Rules'); ?></option>
444 <option value='active_alert' <?php if ($rule_filter == "active_alert") echo "selected"; ?>>
445 <?php echo xlt('Active Alert Rules'); ?></option>
446 <option value='patient_reminder' <?php if ($rule_filter == "patient_reminder") echo "selected"; ?>>
447 <?php echo xlt('Patient Reminder Rules'); ?></option>
448 </select>
449 </td>
450 </tr>
451 <?php } ?>
453 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
454 <input type='hidden' id='form_plan_filter' name='form_plan_filter' value=''>
455 <?php } else { ?>
456 <tr>
457 <td class='label'>
458 <?php echo htmlspecialchars( xl('Plan Set'), ENT_NOQUOTES); ?>:
459 </td>
460 <td>
461 <select <?php echo $dis_text; ?> id='form_plan_filter' name='form_plan_filter'>
462 <option value=''>-- <?php echo htmlspecialchars( xl('Ignore'), ENT_NOQUOTES); ?> --</option>
463 <?php if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) { ?>
464 <option value='cqm' <?php if ($plan_filter == "cqm") echo "selected"; ?>>
465 <?php echo htmlspecialchars( xl('All Official Clinical Quality Measures (CQM) Measure Groups'), ENT_NOQUOTES); ?></option>
466 <option value='cqm_2011' <?php if ($plan_filter == "cqm_2011") echo "selected"; ?>>
467 <?php echo htmlspecialchars( xl('2011 Official Clinical Quality Measures (CQM) Measure Groups'), ENT_NOQUOTES); ?></option>
468 <option value='cqm_2014' <?php if ($plan_filter == "cqm_2014") echo "selected"; ?>>
469 <?php echo htmlspecialchars( xl('2014 Official Clinical Quality Measures (CQM) Measure Groups'), ENT_NOQUOTES); ?></option>
470 <?php } ?>
471 <?php if ($type_report == "standard") { ?>
472 <option value='normal' <?php if ($plan_filter == "normal") echo "selected"; ?>>
473 <?php echo htmlspecialchars( xl('Active Plans'), ENT_NOQUOTES); ?></option>
474 <?php } ?>
475 </td>
476 </tr>
477 <?php } ?>
479 <tr>
480 <td class='label'>
481 <?php echo htmlspecialchars( xl('Provider'), ENT_NOQUOTES); ?>:
482 </td>
483 <td>
484 <?php
486 // Build a drop-down list of providers.
489 $query = "SELECT id, lname, fname FROM users WHERE ".
490 "authorized = 1 $provider_facility_filter ORDER BY lname, fname"; //(CHEMED) facility filter
492 $ures = sqlStatement($query);
494 echo " <select " . $dis_text . " id='form_provider' name='form_provider'>\n";
495 echo " <option value=''>-- " . htmlspecialchars( xl('All (Cumulative)'), ENT_NOQUOTES) . " --\n";
497 echo " <option value='collate_outer'";
498 if ($provider == 'collate_outer') echo " selected";
499 echo ">-- " . htmlspecialchars( xl('All (Collated Format A)'), ENT_NOQUOTES) . " --\n";
501 echo " <option value='collate_inner'";
502 if ($provider == 'collate_inner') echo " selected";
503 echo ">-- " . htmlspecialchars( xl('All (Collated Format B)'), ENT_NOQUOTES) . " --\n";
505 while ($urow = sqlFetchArray($ures)) {
506 $provid = $urow['id'];
507 echo " <option value='".htmlspecialchars( $provid, ENT_QUOTES)."'";
508 if ($provid == $provider) echo " selected";
509 echo ">" . htmlspecialchars( $urow['lname'] . ", " . $urow['fname'], ENT_NOQUOTES) . "\n";
512 echo " </select>\n";
515 </td>
516 </tr>
518 <tr>
519 <td class='label'>
520 <?php echo htmlspecialchars( xl('Provider Relationship'), ENT_NOQUOTES); ?>:
521 </td>
522 <td>
523 <?php
525 // Build a drop-down list of of patient provider relationships.
527 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";
528 echo " <option value='primary'";
529 if ($pat_prov_rel == 'primary') echo " selected";
530 echo ">" . xlt('Primary') . "\n";
531 echo " <option value='encounter'";
532 if ($pat_prov_rel == 'encounter') echo " selected";
533 echo ">" . xlt('Encounter') . "\n";
534 echo " </select>\n";
536 </td>
537 </tr>
539 <?php if (($type_report == "amc") || ($type_report == "amc_2011") || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2")) { ?>
540 <tr>
541 <td>
542 <?php echo htmlspecialchars( xl('Number labs'), ENT_NOQUOTES); ?>:<br>
543 (<?php echo htmlspecialchars( xl('Non-electronic'), ENT_NOQUOTES); ?>)
544 </td>
545 <td>
546 <input <?php echo $dis_text; ?> type="text" id="labs_manual_entry" name="labs_manual_entry" value="<?php echo htmlspecialchars($labs_manual,ENT_QUOTES); ?>">
547 </td>
548 </tr>
549 <?php } ?>
551 </table>
553 </div>
555 </td>
556 <td align='left' valign='middle' height="100%">
557 <table style='border-left:1px solid; width:100%; height:100%' >
558 <tr>
559 <td scope="row">
561 <div style='margin-left:15px'>
563 <?php if (empty($report_id)) { ?>
564 <a id='submit_button' href='#' class='css_button' onclick='runReport();'>
565 <span>
566 <?php echo htmlspecialchars( xl('Submit'), ENT_NOQUOTES); ?>
567 </span>
568 </a>
569 <span id='status_span'></span>
570 <div id='processing' style='margin:10px;display:none;'><img src='../pic/ajax-loader.gif'/></div>
571 <?php if ($type_report == "cqm") { ?>
572 <a id='xmla_button' href='#' class='css_button' onclick='return GenXml("false")'>
573 <span>
574 <?php echo htmlspecialchars( xl('Generate PQRI report (Method A) - 2011'), ENT_NOQUOTES); ?>
575 </span>
576 </a>
577 <a id='xmlb_button' href='#' class='css_button' onclick='return GenXml("true")'>
578 <span>
579 <?php echo htmlspecialchars( xl('Generate PQRI report (Method E) - 2011'), ENT_NOQUOTES); ?>
580 </span>
581 </a>
582 <?php } ?>
583 <?php } ?>
585 <?php if (!empty($report_id)) { ?>
586 <a href='#' class='css_button' id='printbutton'>
587 <span>
588 <?php echo htmlspecialchars( xl('Print'), ENT_NOQUOTES); ?>
589 </span>
590 </a>
591 <?php if ($type_report == "cqm_2014") { ?>
592 <a href="#" id="genQRDA" class='css_button' onclick='return downloadQRDA()'>
593 <span>
594 <?php echo htmlspecialchars( xl('Generate QRDA I – 2014'), ENT_NOQUOTES); ?>
595 </span>
596 </a>
597 <a href="#" id="xmlc_button" class='css_button' onclick='return GenXml("QRDA")'>
598 <span>
599 <?php echo htmlspecialchars( xl('Generate QRDA III - 2014'), ENT_NOQUOTES); ?>
600 </span>
601 </a>
602 <?php } ?>
604 <?php if ($back_link == "list") { ?>
605 <a href='report_results.php' class='css_button' onclick='top.restoreSession()'><span><?php echo xlt("Return To Report Results"); ?></span></a>
606 <?php } else { ?>
607 <a href='#' class='css_button' onclick='top.restoreSession(); $("#theform").submit();'><span><?php echo xlt("Start Another Report"); ?></span></a>
608 <?php } ?>
609 <?php } ?>
610 </div>
611 </td>
612 </tr>
613 </table>
614 </td>
615 </tr>
616 </table>
618 </div> <!-- end of search parameters -->
620 <br>
622 <?php
623 if (!empty($report_id)) {
627 <div id="report_results">
628 <table>
630 <thead>
631 <th>
632 <?php echo htmlspecialchars( xl('Title'), ENT_NOQUOTES); ?>
633 </th>
635 <th>
636 <?php echo htmlspecialchars( xl('Total Patients'), ENT_NOQUOTES); ?>
637 </th>
639 <th>
640 <?php if ($type_report == "amc") { ?>
641 <?php echo htmlspecialchars( xl('Denominator'), ENT_NOQUOTES); ?></a>
642 <?php } else { ?>
643 <?php echo htmlspecialchars( xl('Applicable Patients') .' (' . xl('Denominator') . ')', ENT_NOQUOTES); ?></a>
644 <?php } ?>
645 </th>
647 <?php if ($type_report != "amc") { ?>
648 <th>
649 <?php echo htmlspecialchars( xl('Excluded Patients'), ENT_NOQUOTES); ?></a>
650 </th>
651 <?php } ?>
653 <th>
654 <?php if ($type_report == "amc") { ?>
655 <?php echo htmlspecialchars( xl('Numerator'), ENT_NOQUOTES); ?></a>
656 <?php } else { ?>
657 <?php echo htmlspecialchars( xl('Passed Patients') . ' (' . xl('Numerator') . ')', ENT_NOQUOTES); ?></a>
658 <?php } ?>
659 </th>
661 <th>
662 <?php if ($type_report == "amc") { ?>
663 <?php echo htmlspecialchars( xl('Failed'), ENT_NOQUOTES); ?></a>
664 <?php } else { ?>
665 <?php echo htmlspecialchars( xl('Failed Patients'), ENT_NOQUOTES); ?></a>
666 <?php } ?>
667 </th>
669 <th>
670 <?php echo htmlspecialchars( xl('Performance Percentage'), ENT_NOQUOTES); ?></a>
671 </th>
673 </thead>
674 <tbody> <!-- added for better print-ability -->
675 <?php
677 $firstProviderFlag = TRUE;
678 $firstPlanFlag = TRUE;
679 $existProvider = FALSE;
680 foreach ($dataSheet as $row) {
684 <tr bgcolor='<?php echo $bgcolor ?>'>
686 <?php
687 if (isset($row['is_main']) || isset($row['is_sub'])) {
688 echo "<td class='detail'>";
689 if (isset($row['is_main'])) {
691 // is_sub is a special case of is_main whereas total patients, denominator, and excluded patients are taken
692 // from is_main prior to it. So, need to store denominator patients from is_main for subsequent is_sub
693 // to calculate the number of patients that failed.
694 // Note that exlusion in the standard rules is not the same as in the cqm/amd and should not be in calculation
695 // as is in the cqm/amc rules.
696 $main_pass_filter = $row['pass_filter'];
698 echo "<b>".generate_display_field(array('data_type'=>'1','list_id'=>'clinical_rules'),$row['id'])."</b>";
700 $tempCqmAmcString = "";
701 if (($type_report == "cqm") || ($type_report == "cqm_2011") || ($type_report == "cqm_2014")) {
702 if (!empty($row['cqm_pqri_code'])) {
703 $tempCqmAmcString .= " " . htmlspecialchars( xl('PQRI') . ":" . $row['cqm_pqri_code'], ENT_NOQUOTES) . " ";
705 if (!empty($row['cqm_nqf_code'])) {
706 $tempCqmAmcString .= " " . htmlspecialchars( xl('NQF') . ":" . $row['cqm_nqf_code'], ENT_NOQUOTES) . " ";
709 if ($type_report == "amc") {
710 if (!empty($row['amc_code'])) {
711 $tempCqmAmcString .= " " . htmlspecialchars( xl('AMC-2011') . ":" . $row['amc_code'], ENT_NOQUOTES) . " ";
713 if (!empty($row['amc_code_2014'])) {
714 $tempCqmAmcString .= " " . htmlspecialchars( xl('AMC-2014') . ":" . $row['amc_code_2014'], ENT_NOQUOTES) . " ";
717 if ($type_report == "amc_2011") {
718 if (!empty($row['amc_code'])) {
719 $tempCqmAmcString .= " " . htmlspecialchars( xl('AMC-2011') . ":" . $row['amc_code'], ENT_NOQUOTES) . " ";
722 if ( ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2") ) {
723 if (!empty($row['amc_code_2014'])) {
724 $tempCqmAmcString .= " " . htmlspecialchars( xl('AMC-2014') . ":" . $row['amc_code_2014'], ENT_NOQUOTES) . " ";
728 if (!empty($tempCqmAmcString)) {
729 echo "(".$tempCqmAmcString.")";
732 if ( !(empty($row['concatenated_label'])) ) {
733 echo ", " . htmlspecialchars( xl( $row['concatenated_label'] ), ENT_NOQUOTES) . " ";
737 else { // isset($row['is_sub'])
738 echo generate_display_field(array('data_type'=>'1','list_id'=>'rule_action_category'),$row['action_category']);
739 echo ": " . generate_display_field(array('data_type'=>'1','list_id'=>'rule_action'),$row['action_item']);
741 echo "</td>";
742 echo "<td align='center'>" . $row['total_patients'] . "</td>";
744 if ( isset($row['itemized_test_id']) && ($row['pass_filter'] > 0) ) {
745 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>";
747 else {
748 echo "<td align='center'>" . $row['pass_filter'] . "</td>";
751 if ($type_report != "amc") {
752 // Note that amc will likely support in excluded items in the future for MU2
753 if ( ($type_report != "standard") && isset($row['itemized_test_id']) && ($row['excluded'] > 0) ) {
754 // Note standard reporting exluded is different than cqm/amc and will not support itemization
755 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>";
757 else {
758 echo "<td align='center'>" . $row['excluded'] . "</td>";
762 if ( isset($row['itemized_test_id']) && ($row['pass_target'] > 0) ) {
763 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>";
765 else {
766 echo "<td align='center'>" . $row['pass_target'] . "</td>";
769 $failed_items = 0;
770 if (isset($row['is_main'])) {
771 if ($type_report == "standard") {
772 // Excluded is not part of denominator in standard rules so do not use in calculation
773 $failed_items = $row['pass_filter'] - $row['pass_target'];
775 else {
776 $failed_items = $row['pass_filter'] - $row['pass_target'] - $row['excluded'];
779 else { // isset($row['is_sub'])
780 // Excluded is not part of denominator in standard rules so do not use in calculation
781 $failed_items = $main_pass_filter - $row['pass_target'];
783 if ( isset($row['itemized_test_id']) && ($failed_items > 0) ) {
784 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>";
786 else {
787 echo "<td align='center'>" . $failed_items . "</td>";
790 echo "<td align='center'>" . $row['percentage'] . "</td>";
792 else if (isset($row['is_provider'])) {
793 // Display the provider information
794 if (!$firstProviderFlag && $_POST['form_provider'] == 'collate_outer') {
795 echo "<tr><td>&nbsp</td></tr>";
797 echo "<td class='detail' align='center'><b>";
798 echo htmlspecialchars( xl("Provider").": " . $row['prov_lname'] . "," . $row['prov_fname'], ENT_NOQUOTES);
799 if (!empty($row['npi']) || !empty($row['federaltaxid'])) {
800 echo " (";
801 if (!empty($row['npi'])) {
802 echo " " . htmlspecialchars( xl('NPI') . ":" . $row['npi'], ENT_NOQUOTES) . " ";
804 if (!empty($row['federaltaxid'])) {
805 echo " " . htmlspecialchars( xl('TID') . ":" . $row['federaltaxid'], ENT_NOQUOTES) . " ";
807 echo ")";
809 echo "</b></td>";
810 $firstProviderFlag = FALSE;
811 $existProvider = TRUE;
813 else { // isset($row['is_plan'])
814 if (!$firstPlanFlag && $_POST['form_provider'] != 'collate_outer') {
815 echo "<tr><td>&nbsp</td></tr>";
817 echo "<td class='detail' align='center'><b>";
818 echo htmlspecialchars( xl("Plan"), ENT_NOQUOTES) . ": ";
819 echo generate_display_field(array('data_type'=>'1','list_id'=>'clinical_plans'),$row['id']);
820 if (!empty($row['cqm_measure_group'])) {
821 echo " (". htmlspecialchars( xl('Measure Group Code') . ": " . $row['cqm_measure_group'], ENT_NOQUOTES) . ")";
823 echo "</b></td>";
824 $firstPlanFlag = FALSE;
827 </tr>
829 <?php
832 </tbody>
833 </table>
834 </div> <!-- end of search results -->
835 <?php } else { ?>
836 <div id="instructions_text" class='text'>
837 <?php echo htmlspecialchars( xl('Please input search criteria above, and click Submit to start report.'), ENT_NOQUOTES); ?>
838 </div>
839 <?php } ?>
841 <input type='hidden' name='form_new_report_id' id='form_new_report_id' value=''/>
843 </form>
845 </body>
847 <!-- stuff for the popup calendar -->
848 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
849 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
850 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
851 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
852 <script language="Javascript">
853 <?php if ($type_report == "amc" || ($type_report == "amc_2014_stage1") || ($type_report == "amc_2014_stage2") ) { ?>
854 Calendar.setup({inputField:"form_begin_date", ifFormat:"%Y-%m-%d %H:%M:%S", button:"img_begin_date", showsTime:'true'});
855 <?php } ?>
856 Calendar.setup({inputField:"form_target_date", ifFormat:"%Y-%m-%d %H:%M:%S", button:"img_target_date", showsTime:'true'});
857 </script>
859 </html>