2 // Copyright (C) 2010 Brady Miller <brady@sparmy.com>
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.
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";
24 //Remove time limit, since script can take many minutes
27 // Collect report type parameter (standard, amc, or cqm)
28 $type_report = (isset($_GET['type'])) ?
trim($_GET['type']) : "standard";
30 // Collect form parameters (set defaults if empty)
31 if ($type_report == "amc") {
32 $begin_date = (isset($_POST['form_begin_date'])) ?
trim($_POST['form_begin_date']) : "";
33 $labs_manual = (isset($_POST['labs_manual_entry'])) ?
trim($_POST['labs_manual_entry']) : "0";
35 $target_date = (isset($_POST['form_target_date'])) ?
trim($_POST['form_target_date']) : date('Y-m-d H:i:s');
36 $rule_filter = (isset($_POST['form_rule_filter'])) ?
trim($_POST['form_rule_filter']) : "";
37 $plan_filter = (isset($_POST['form_plan_filter'])) ?
trim($_POST['form_plan_filter']) : "";
38 $organize_method = (empty($plan_filter)) ?
"default" : "plans";
39 $provider = trim($_POST['form_provider']);
46 <?php
html_header_show();?
>
48 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
50 <?php
if ($type_report == "standard") { ?
>
51 <title
><?php
echo htmlspecialchars( xl('Standard Measures'), ENT_NOQUOTES
); ?
></title
>
53 <?php
if ($type_report == "cqm") { ?
>
54 <title
><?php
echo htmlspecialchars( xl('Clinical Quality Measures (CQM)'), ENT_NOQUOTES
); ?
></title
>
56 <?php
if ($type_report == "amc") { ?
>
57 <title
><?php
echo htmlspecialchars( xl('Automated Measure Calculations (AMC)'), ENT_NOQUOTES
); ?
></title
>
60 <script type
="text/javascript" src
="../../library/overlib_mini.js"></script
>
61 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
62 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
63 <script type
="text/javascript" src
="../../library/js/jquery.1.3.2.js"></script
>
65 <script LANGUAGE
="JavaScript">
67 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
69 function refreshme() {
72 document
.forms
[0].submit();
75 function GenXml(sNested
) {
77 var sLoc
= '../../custom/export_registry_xml.php?&target_date=' + theform
.form_target_date
.value +
'&nested=' + sNested
;
78 dlgopen(sLoc
, '_blank', 600, 500);
84 <style type
="text/css">
86 /* specifically include & exclude from printing */
92 #report_parameters_daterange {
96 #report_results table {
101 /* specifically exclude some from the screen */
103 #report_parameters_daterange {
112 <body
class="body_top">
114 <!-- Required
for the popup date selectors
-->
115 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
117 <span
class='title'><?php
echo htmlspecialchars( xl('Report'), ENT_NOQUOTES
); ?
> -
119 <?php
if ($type_report == "standard") { ?
>
120 <?php
echo htmlspecialchars( xl('Standard Measures'), ENT_NOQUOTES
); ?
></span
>
122 <?php
if ($type_report == "cqm") { ?
>
123 <?php
echo htmlspecialchars( xl('Clinical Quality Measures (CQM)'), ENT_NOQUOTES
); ?
></span
>
125 <?php
if ($type_report == "amc") { ?
>
126 <?php
echo htmlspecialchars( xl('Automated Measure Calculations (AMC)'), ENT_NOQUOTES
); ?
></span
>
130 <form method
='post' name
='theform' id
='theform' action
='cqm.php?type=<?php echo htmlspecialchars($type_report,ENT_QUOTES) ;?>' onsubmit
='return top.restoreSession()'>
132 <div id
="report_parameters">
137 <div style
='float:left'>
141 <?php
if ($type_report == "amc") { ?
>
144 <?php
echo htmlspecialchars( xl('Begin Date'), ENT_NOQUOTES
); ?
>:
147 <input type
='text' name
='form_begin_date' id
="form_begin_date" size
='20' value
='<?php echo htmlspecialchars( $begin_date, ENT_QUOTES); ?>'
148 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='<?php echo htmlspecialchars( xl('yyyy
-mm
-dd hh
:mm
:ss
'), ENT_QUOTES); ?>'>
149 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
150 id
='img_begin_date' border
='0' alt
='[?]' style
='cursor:pointer'
151 title
='<?php echo htmlspecialchars( xl('Click here to choose a date
'), ENT_QUOTES); ?>'>
158 <?php
if ($type_report == "amc") { ?
>
159 <?php
echo htmlspecialchars( xl('End Date'), ENT_NOQUOTES
); ?
>:
161 <?php
echo htmlspecialchars( xl('Target Date'), ENT_NOQUOTES
); ?
>:
165 <input type
='text' name
='form_target_date' id
="form_target_date" size
='20' value
='<?php echo htmlspecialchars( $target_date, ENT_QUOTES); ?>'
166 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='<?php echo htmlspecialchars( xl('yyyy
-mm
-dd hh
:mm
:ss
'), ENT_QUOTES); ?>'>
167 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
168 id
='img_target_date' border
='0' alt
='[?]' style
='cursor:pointer'
169 title
='<?php echo htmlspecialchars( xl('Click here to choose a date
'), ENT_QUOTES); ?>'>
173 <?php
if ($type_report == "cqm") { ?
>
174 <input type
='hidden' name
='form_rule_filter' value
='cqm'>
176 <?php
if ($type_report == "amc") { ?
>
177 <input type
='hidden' name
='form_rule_filter' value
='amc'>
179 <?php
if ($type_report == "standard") { ?
>
182 <?php
echo htmlspecialchars( xl('Rule Set'), ENT_NOQUOTES
); ?
>:
185 <select name
='form_rule_filter'>
186 <option value
='passive_alert' <?php
if ($rule_filter == "passive_alert") echo "selected"; ?
>>
187 <?php
echo htmlspecialchars( xl('Passive Alert Rules'), ENT_NOQUOTES
); ?
></option
>
188 <option value
='active_alert' <?php
if ($rule_filter == "active_alert") echo "selected"; ?
>>
189 <?php
echo htmlspecialchars( xl('Active Alert Rules'), ENT_NOQUOTES
); ?
></option
>
190 <option value
='patient_reminder' <?php
if ($rule_filter == "patient_reminder") echo "selected"; ?
>>
191 <?php
echo htmlspecialchars( xl('Patient Reminder Rules'), ENT_NOQUOTES
); ?
></option
>
197 <?php
if ($type_report == "amc") { ?
>
198 <input type
='hidden' name
='form_plan_filter' value
=''>
202 <?php
echo htmlspecialchars( xl('Plan Set'), ENT_NOQUOTES
); ?
>:
205 <select name
='form_plan_filter'>
206 <option value
=''>-- <?php
echo htmlspecialchars( xl('Ignore'), ENT_NOQUOTES
); ?
> --</option
>
207 <?php
if ($type_report == "cqm") { ?
>
208 <option value
='cqm' <?php
if ($plan_filter == "cqm") echo "selected"; ?
>>
209 <?php
echo htmlspecialchars( xl('Official Clinical Quality Measures (CQM) Measure Groups'), ENT_NOQUOTES
); ?
></option
>
211 <?php
if ($type_report == "standard") { ?
>
212 <option value
='normal' <?php
if ($plan_filter == "normal") echo "selected"; ?
>>
213 <?php
echo htmlspecialchars( xl('Active Plans'), ENT_NOQUOTES
); ?
></option
>
221 <?php
echo htmlspecialchars( xl('Provider'), ENT_NOQUOTES
); ?
>:
226 // Build a drop-down list of providers.
229 $query = "SELECT id, lname, fname FROM users WHERE ".
230 "authorized = 1 $provider_facility_filter ORDER BY lname, fname"; //(CHEMED) facility filter
232 $ures = sqlStatement($query);
234 echo " <select name='form_provider'>\n";
235 echo " <option value=''>-- " . htmlspecialchars( xl('All (Cumulative)'), ENT_NOQUOTES
) . " --\n";
237 echo " <option value='collate_outer'";
238 if ($_POST['form_provider'] == 'collate_outer') echo " selected";
239 echo ">-- " . htmlspecialchars( xl('All (Collated Format A)'), ENT_NOQUOTES
) . " --\n";
241 echo " <option value='collate_inner'";
242 if ($_POST['form_provider'] == 'collate_inner') echo " selected";
243 echo ">-- " . htmlspecialchars( xl('All (Collated Format B)'), ENT_NOQUOTES
) . " --\n";
245 while ($urow = sqlFetchArray($ures)) {
246 $provid = $urow['id'];
247 echo " <option value='".htmlspecialchars( $provid, ENT_QUOTES
)."'";
248 if ($provid == $_POST['form_provider']) echo " selected";
249 echo ">" . htmlspecialchars( $urow['lname'] . ", " . $urow['fname'], ENT_NOQUOTES
) . "\n";
258 <?php
if ($type_report == "amc") { ?
>
261 <?php
echo htmlspecialchars( xl('Number labs'), ENT_NOQUOTES
); ?
>:<br
>
262 (<?php
echo htmlspecialchars( xl('Non-electronic'), ENT_NOQUOTES
); ?
>)
265 <input type
="text" name
="labs_manual_entry" value
="<?php echo htmlspecialchars($labs_manual,ENT_QUOTES); ?>">
275 <td align
='left' valign
='middle' height
="100%">
276 <table style
='border-left:1px solid; width:100%; height:100%' >
279 <div style
='margin-left:15px'>
280 <a href
='#' class='css_button' onclick
='$("#form_refresh").attr("value","true"); top.restoreSession(); $("#theform").submit();'>
282 <?php
echo htmlspecialchars( xl('Submit'), ENT_NOQUOTES
); ?
>
285 <?php
if ($type_report == "cqm") { ?
>
286 <a href
='#' class='css_button' onclick
='return GenXml("false")'>
288 <?php
echo htmlspecialchars( xl('Generate PQRI report (Method A)'), ENT_NOQUOTES
); ?
>
291 <a href
='#' class='css_button' onclick
='return GenXml("true")'>
293 <?php
echo htmlspecialchars( xl('Generate PQRI report (Method E)'), ENT_NOQUOTES
); ?
>
297 <?php
if ($_POST['form_refresh']) { ?
>
298 <a href
='#' class='css_button' onclick
='window.print()'>
300 <?php
echo htmlspecialchars( xl('Print'), ENT_NOQUOTES
); ?
>
312 </div
> <!-- end of search parameters
-->
317 if ($_POST['form_refresh']) {
321 <div id
="report_results">
326 <?php
echo htmlspecialchars( xl('Title'), ENT_NOQUOTES
); ?
>
330 <?php
echo htmlspecialchars( xl('Total Patients'), ENT_NOQUOTES
); ?
>
334 <?php
if ($type_report == "amc") { ?
>
335 <?php
echo htmlspecialchars( xl('Denominator'), ENT_NOQUOTES
); ?
></a
>
337 <?php
echo htmlspecialchars( xl('Applicable Patients') .' (' . xl('Denominator') . ')', ENT_NOQUOTES
); ?
></a
>
341 <?php
if ($type_report != "amc") { ?
>
343 <?php
echo htmlspecialchars( xl('Excluded Patients'), ENT_NOQUOTES
); ?
></a
>
348 <?php
if ($type_report == "amc") { ?
>
349 <?php
echo htmlspecialchars( xl('Numerator'), ENT_NOQUOTES
); ?
></a
>
351 <?php
echo htmlspecialchars( xl('Passed Patients') . ' (' . xl('Numerator') . ')', ENT_NOQUOTES
); ?
></a
>
356 <?php
echo htmlspecialchars( xl('Performance Percentage'), ENT_NOQUOTES
); ?
></a
>
360 <tbody
> <!-- added
for better
print-ability
-->
363 if ($type_report == "amc") {
365 // need to make $target_date an array with two elements ('dateBegin' and 'dateTarget')
366 // need to to send a manual data entry option (number of labs)
367 $array_date = array();
368 $array_date['dateBegin'] = $begin_date;
369 $array_date['dateTarget'] = $target_date;
370 $options = array('labs_manual'=>$labs_manual);
371 $dataSheet = test_rules_clinic($provider,$rule_filter,$array_date,"report",'',$plan_filter,$organize_method,$options);
374 $dataSheet = test_rules_clinic($provider,$rule_filter,$target_date,"report",'',$plan_filter,$organize_method);
377 $firstProviderFlag = TRUE;
378 $firstPlanFlag = TRUE;
379 $existProvider = FALSE;
380 foreach ($dataSheet as $row) {
384 <tr bgcolor
='<?php echo $bgcolor ?>'>
387 if (isset($row['is_main']) ||
isset($row['is_sub'])) {
388 echo "<td class='detail'>";
389 if (isset($row['is_main'])) {
390 echo "<b>".generate_display_field(array('data_type'=>'1','list_id'=>'clinical_rules'),$row['id'])."</b>";
391 if (!empty($row['cqm_pqri_code']) ||
!empty($row['cqm_nqf_code']) ||
!empty($row['amc_code'])) {
393 if (!empty($row['cqm_pqri_code'])) {
394 echo " " . htmlspecialchars( xl('PQRI') . ":" . $row['cqm_pqri_code'], ENT_NOQUOTES
) . " ";
396 if (!empty($row['cqm_nqf_code'])) {
397 echo " " . htmlspecialchars( xl('NQF') . ":" . $row['cqm_nqf_code'], ENT_NOQUOTES
) . " ";
399 if (!empty($row['amc_code'])) {
400 echo " " . htmlspecialchars( xl('AMC') . ":" . $row['amc_code'], ENT_NOQUOTES
) . " ";
405 if ( !(empty($row['concatenated_label'])) ) {
406 echo ", " . htmlspecialchars( xl( $row['concatenated_label'] ), ENT_NOQUOTES
) . " ";
410 else { // isset($row['is_sub'])
411 echo generate_display_field(array('data_type'=>'1','list_id'=>'rule_action_category'),$row['action_category']);
412 echo ": " . generate_display_field(array('data_type'=>'1','list_id'=>'rule_action'),$row['action_item']);
415 echo "<td align='center'>" . $row['total_patients'] . "</td>";
416 echo "<td align='center'>" . $row['pass_filter'] . "</td>";
417 if ($type_report != "amc") {
418 echo "<td align='center'>" . $row['excluded'] . "</td>";
420 echo "<td align='center'>" . $row['pass_target'] . "</td>";
421 echo "<td align='center'>" . $row['percentage'] . "</td>";
423 else if (isset($row['is_provider'])) {
424 // Display the provider information
425 if (!$firstProviderFlag && $_POST['form_provider'] == 'collate_outer') {
426 echo "<tr><td> </td></tr>";
428 echo "<td class='detail' align='center'><b>";
429 echo htmlspecialchars( xl("Provider").": " . $row['prov_lname'] . "," . $row['prov_fname'], ENT_NOQUOTES
);
430 if (!empty($row['npi']) ||
!empty($row['federaltaxid'])) {
432 if (!empty($row['npi'])) {
433 echo " " . htmlspecialchars( xl('NPI') . ":" . $row['npi'], ENT_NOQUOTES
) . " ";
435 if (!empty($row['federaltaxid'])) {
436 echo " " . htmlspecialchars( xl('TID') . ":" . $row['federaltaxid'], ENT_NOQUOTES
) . " ";
441 $firstProviderFlag = FALSE;
442 $existProvider = TRUE;
444 else { // isset($row['is_plan'])
445 if (!$firstPlanFlag && $_POST['form_provider'] != 'collate_outer') {
446 echo "<tr><td> </td></tr>";
448 echo "<td class='detail' align='center'><b>";
449 echo htmlspecialchars( xl("Plan"), ENT_NOQUOTES
) . ": ";
450 echo generate_display_field(array('data_type'=>'1','list_id'=>'clinical_plans'),$row['id']);
451 if (!empty($row['cqm_measure_group'])) {
452 echo " (". htmlspecialchars( xl('Measure Group Code') . ": " . $row['cqm_measure_group'], ENT_NOQUOTES
) . ")";
455 $firstPlanFlag = FALSE;
465 </div
> <!-- end of search results
-->
468 <?php
echo htmlspecialchars( xl('Please input search criteria above, and click Submit to view results.'), ENT_NOQUOTES
); ?
>
472 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
478 <!-- stuff
for the popup calendar
-->
479 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
480 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
481 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
482 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
483 <script language
="Javascript">
484 <?php
if ($type_report == "amc") { ?
>
485 Calendar
.setup({inputField
:"form_begin_date", ifFormat
:"%Y-%m-%d %H:%M:%S", button
:"img_begin_date", showsTime
:'true'});
487 Calendar
.setup({inputField
:"form_target_date", ifFormat
:"%Y-%m-%d %H:%M:%S", button
:"img_target_date", showsTime
:'true'});