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 //To improve performance and not freeze the session when running this
25 // report, turn off session writing. Note that php session variables
26 // can not be modified after the line below. So, if need to do any php
27 // session work in the future, then will need to remove this line.
28 session_write_close();
30 //Remove time limit, since script can take many minutes
33 // Collect report type parameter (standard, amc, or cqm)
34 $type_report = (isset($_GET['type'])) ?
trim($_GET['type']) : "standard";
36 // Collect form parameters (set defaults if empty)
37 if ($type_report == "amc") {
38 $begin_date = (isset($_POST['form_begin_date'])) ?
trim($_POST['form_begin_date']) : "";
39 $labs_manual = (isset($_POST['labs_manual_entry'])) ?
trim($_POST['labs_manual_entry']) : "0";
41 $target_date = (isset($_POST['form_target_date'])) ?
trim($_POST['form_target_date']) : date('Y-m-d H:i:s');
42 $rule_filter = (isset($_POST['form_rule_filter'])) ?
trim($_POST['form_rule_filter']) : "";
43 $plan_filter = (isset($_POST['form_plan_filter'])) ?
trim($_POST['form_plan_filter']) : "";
44 $organize_method = (empty($plan_filter)) ?
"default" : "plans";
45 $provider = trim($_POST['form_provider']);
46 $pat_prov_rel = (empty($_POST['form_pat_prov_rel'])) ?
"primary" : trim($_POST['form_pat_prov_rel']);
52 <?php
html_header_show();?
>
54 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
56 <?php
if ($type_report == "standard") { ?
>
57 <title
><?php
echo htmlspecialchars( xl('Standard Measures'), ENT_NOQUOTES
); ?
></title
>
59 <?php
if ($type_report == "cqm") { ?
>
60 <title
><?php
echo htmlspecialchars( xl('Clinical Quality Measures (CQM)'), ENT_NOQUOTES
); ?
></title
>
62 <?php
if ($type_report == "amc") { ?
>
63 <title
><?php
echo htmlspecialchars( xl('Automated Measure Calculations (AMC)'), ENT_NOQUOTES
); ?
></title
>
66 <script type
="text/javascript" src
="../../library/overlib_mini.js"></script
>
67 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
68 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
69 <script type
="text/javascript" src
="../../library/js/jquery.1.3.2.js"></script
>
71 <script LANGUAGE
="JavaScript">
73 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
75 function refreshme() {
78 document
.forms
[0].submit();
81 function GenXml(sNested
) {
83 var sLoc
= '../../custom/export_registry_xml.php?&target_date=' + theform
.form_target_date
.value +
'&nested=' + sNested
;
84 dlgopen(sLoc
, '_blank', 600, 500);
90 <style type
="text/css">
92 /* specifically include & exclude from printing */
98 #report_parameters_daterange {
102 #report_results table {
107 /* specifically exclude some from the screen */
109 #report_parameters_daterange {
118 <body
class="body_top">
120 <!-- Required
for the popup date selectors
-->
121 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
123 <span
class='title'><?php
echo htmlspecialchars( xl('Report'), ENT_NOQUOTES
); ?
> -
125 <?php
if ($type_report == "standard") { ?
>
126 <?php
echo htmlspecialchars( xl('Standard Measures'), ENT_NOQUOTES
); ?
></span
>
128 <?php
if ($type_report == "cqm") { ?
>
129 <?php
echo htmlspecialchars( xl('Clinical Quality Measures (CQM)'), ENT_NOQUOTES
); ?
></span
>
131 <?php
if ($type_report == "amc") { ?
>
132 <?php
echo htmlspecialchars( xl('Automated Measure Calculations (AMC)'), ENT_NOQUOTES
); ?
></span
>
136 <form method
='post' name
='theform' id
='theform' action
='cqm.php?type=<?php echo htmlspecialchars($type_report,ENT_QUOTES) ;?>' onsubmit
='return top.restoreSession()'>
138 <div id
="report_parameters">
143 <div style
='float:left'>
147 <?php
if ($type_report == "amc") { ?
>
150 <?php
echo htmlspecialchars( xl('Begin Date'), ENT_NOQUOTES
); ?
>:
153 <input type
='text' name
='form_begin_date' id
="form_begin_date" size
='20' value
='<?php echo htmlspecialchars( $begin_date, ENT_QUOTES); ?>'
154 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='<?php echo htmlspecialchars( xl('yyyy
-mm
-dd hh
:mm
:ss
'), ENT_QUOTES); ?>'>
155 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
156 id
='img_begin_date' border
='0' alt
='[?]' style
='cursor:pointer'
157 title
='<?php echo htmlspecialchars( xl('Click here to choose a date
'), ENT_QUOTES); ?>'>
164 <?php
if ($type_report == "amc") { ?
>
165 <?php
echo htmlspecialchars( xl('End Date'), ENT_NOQUOTES
); ?
>:
167 <?php
echo htmlspecialchars( xl('Target Date'), ENT_NOQUOTES
); ?
>:
171 <input type
='text' name
='form_target_date' id
="form_target_date" size
='20' value
='<?php echo htmlspecialchars( $target_date, ENT_QUOTES); ?>'
172 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='<?php echo htmlspecialchars( xl('yyyy
-mm
-dd hh
:mm
:ss
'), ENT_QUOTES); ?>'>
173 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
174 id
='img_target_date' border
='0' alt
='[?]' style
='cursor:pointer'
175 title
='<?php echo htmlspecialchars( xl('Click here to choose a date
'), ENT_QUOTES); ?>'>
179 <?php
if ($type_report == "cqm") { ?
>
180 <input type
='hidden' name
='form_rule_filter' value
='cqm'>
182 <?php
if ($type_report == "amc") { ?
>
183 <input type
='hidden' name
='form_rule_filter' value
='amc'>
185 <?php
if ($type_report == "standard") { ?
>
188 <?php
echo htmlspecialchars( xl('Rule Set'), ENT_NOQUOTES
); ?
>:
191 <select name
='form_rule_filter'>
192 <option value
='passive_alert' <?php
if ($rule_filter == "passive_alert") echo "selected"; ?
>>
193 <?php
echo htmlspecialchars( xl('Passive Alert Rules'), ENT_NOQUOTES
); ?
></option
>
194 <option value
='active_alert' <?php
if ($rule_filter == "active_alert") echo "selected"; ?
>>
195 <?php
echo htmlspecialchars( xl('Active Alert Rules'), ENT_NOQUOTES
); ?
></option
>
196 <option value
='patient_reminder' <?php
if ($rule_filter == "patient_reminder") echo "selected"; ?
>>
197 <?php
echo htmlspecialchars( xl('Patient Reminder Rules'), ENT_NOQUOTES
); ?
></option
>
203 <?php
if ($type_report == "amc") { ?
>
204 <input type
='hidden' name
='form_plan_filter' value
=''>
208 <?php
echo htmlspecialchars( xl('Plan Set'), ENT_NOQUOTES
); ?
>:
211 <select name
='form_plan_filter'>
212 <option value
=''>-- <?php
echo htmlspecialchars( xl('Ignore'), ENT_NOQUOTES
); ?
> --</option
>
213 <?php
if ($type_report == "cqm") { ?
>
214 <option value
='cqm' <?php
if ($plan_filter == "cqm") echo "selected"; ?
>>
215 <?php
echo htmlspecialchars( xl('Official Clinical Quality Measures (CQM) Measure Groups'), ENT_NOQUOTES
); ?
></option
>
217 <?php
if ($type_report == "standard") { ?
>
218 <option value
='normal' <?php
if ($plan_filter == "normal") echo "selected"; ?
>>
219 <?php
echo htmlspecialchars( xl('Active Plans'), ENT_NOQUOTES
); ?
></option
>
227 <?php
echo htmlspecialchars( xl('Provider'), ENT_NOQUOTES
); ?
>:
232 // Build a drop-down list of providers.
235 $query = "SELECT id, lname, fname FROM users WHERE ".
236 "authorized = 1 $provider_facility_filter ORDER BY lname, fname"; //(CHEMED) facility filter
238 $ures = sqlStatement($query);
240 echo " <select name='form_provider'>\n";
241 echo " <option value=''>-- " . htmlspecialchars( xl('All (Cumulative)'), ENT_NOQUOTES
) . " --\n";
243 echo " <option value='collate_outer'";
244 if ($_POST['form_provider'] == 'collate_outer') echo " selected";
245 echo ">-- " . htmlspecialchars( xl('All (Collated Format A)'), ENT_NOQUOTES
) . " --\n";
247 echo " <option value='collate_inner'";
248 if ($_POST['form_provider'] == 'collate_inner') echo " selected";
249 echo ">-- " . htmlspecialchars( xl('All (Collated Format B)'), ENT_NOQUOTES
) . " --\n";
251 while ($urow = sqlFetchArray($ures)) {
252 $provid = $urow['id'];
253 echo " <option value='".htmlspecialchars( $provid, ENT_QUOTES
)."'";
254 if ($provid == $_POST['form_provider']) echo " selected";
255 echo ">" . htmlspecialchars( $urow['lname'] . ", " . $urow['fname'], ENT_NOQUOTES
) . "\n";
266 <?php
echo htmlspecialchars( xl('Provider Relationship'), ENT_NOQUOTES
); ?
>:
271 // Build a drop-down list of of patient provider relationships.
273 echo " <select 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";
274 echo " <option value='primary'";
275 if ($pat_prov_rel == 'primary') echo " selected";
276 echo ">" . xlt('Primary') . "\n";
277 echo " <option value='encounter'";
278 if ($pat_prov_rel == 'encounter') echo " selected";
279 echo ">" . xlt('Encounter') . "\n";
285 <?php
if ($type_report == "amc") { ?
>
288 <?php
echo htmlspecialchars( xl('Number labs'), ENT_NOQUOTES
); ?
>:<br
>
289 (<?php
echo htmlspecialchars( xl('Non-electronic'), ENT_NOQUOTES
); ?
>)
292 <input type
="text" name
="labs_manual_entry" value
="<?php echo htmlspecialchars($labs_manual,ENT_QUOTES); ?>">
302 <td align
='left' valign
='middle' height
="100%">
303 <table style
='border-left:1px solid; width:100%; height:100%' >
306 <div style
='margin-left:15px'>
307 <a href
='#' class='css_button' onclick
='$("#form_refresh").attr("value","true"); top.restoreSession(); $("#processing").show(); $("#theform").submit();'>
309 <?php
echo htmlspecialchars( xl('Submit'), ENT_NOQUOTES
); ?
>
312 <div id
='processing' style
='margin:10px;display:none;'><img src
='../pic/ajax-loader.gif'/></div
>
313 <?php
if ($type_report == "cqm") { ?
>
314 <a href
='#' class='css_button' onclick
='return GenXml("false")'>
316 <?php
echo htmlspecialchars( xl('Generate PQRI report (Method A)'), ENT_NOQUOTES
); ?
>
319 <a href
='#' class='css_button' onclick
='return GenXml("true")'>
321 <?php
echo htmlspecialchars( xl('Generate PQRI report (Method E)'), ENT_NOQUOTES
); ?
>
325 <?php
if ($_POST['form_refresh']) { ?
>
326 <a href
='#' class='css_button' onclick
='window.print()'>
328 <?php
echo htmlspecialchars( xl('Print'), ENT_NOQUOTES
); ?
>
340 </div
> <!-- end of search parameters
-->
345 if ($_POST['form_refresh']) {
349 <div id
="report_results">
354 <?php
echo htmlspecialchars( xl('Title'), ENT_NOQUOTES
); ?
>
358 <?php
echo htmlspecialchars( xl('Total Patients'), ENT_NOQUOTES
); ?
>
362 <?php
if ($type_report == "amc") { ?
>
363 <?php
echo htmlspecialchars( xl('Denominator'), ENT_NOQUOTES
); ?
></a
>
365 <?php
echo htmlspecialchars( xl('Applicable Patients') .' (' . xl('Denominator') . ')', ENT_NOQUOTES
); ?
></a
>
369 <?php
if ($type_report != "amc") { ?
>
371 <?php
echo htmlspecialchars( xl('Excluded Patients'), ENT_NOQUOTES
); ?
></a
>
376 <?php
if ($type_report == "amc") { ?
>
377 <?php
echo htmlspecialchars( xl('Numerator'), ENT_NOQUOTES
); ?
></a
>
379 <?php
echo htmlspecialchars( xl('Passed Patients') . ' (' . xl('Numerator') . ')', ENT_NOQUOTES
); ?
></a
>
384 <?php
echo htmlspecialchars( xl('Performance Percentage'), ENT_NOQUOTES
); ?
></a
>
388 <tbody
> <!-- added
for better
print-ability
-->
391 // Process report and collect results
393 $array_date = array();
394 if ($type_report == "amc") {
396 // need to make $target_date an array with two elements ('dateBegin' and 'dateTarget')
397 // need to send a manual data entry option (number of labs)
398 $array_date['dateBegin'] = $begin_date;
399 $array_date['dateTarget'] = $target_date;
400 $options = array('labs_manual'=>$labs_manual);
403 // For others, use the unmodified target date array and send an empty options array
404 $array_date = $target_date;
407 // Collect results (note using the batch method to decrease memory overhead and improve performance)
408 $dataSheet = test_rules_clinic_batch_method($provider,$rule_filter,$array_date,"report",$plan_filter,$organize_method,$options,$pat_prov_rel);
410 $firstProviderFlag = TRUE;
411 $firstPlanFlag = TRUE;
412 $existProvider = FALSE;
413 foreach ($dataSheet as $row) {
417 <tr bgcolor
='<?php echo $bgcolor ?>'>
420 if (isset($row['is_main']) ||
isset($row['is_sub'])) {
421 echo "<td class='detail'>";
422 if (isset($row['is_main'])) {
423 echo "<b>".generate_display_field(array('data_type'=>'1','list_id'=>'clinical_rules'),$row['id'])."</b>";
424 if (!empty($row['cqm_pqri_code']) ||
!empty($row['cqm_nqf_code']) ||
!empty($row['amc_code'])) {
426 if (!empty($row['cqm_pqri_code'])) {
427 echo " " . htmlspecialchars( xl('PQRI') . ":" . $row['cqm_pqri_code'], ENT_NOQUOTES
) . " ";
429 if (!empty($row['cqm_nqf_code'])) {
430 echo " " . htmlspecialchars( xl('NQF') . ":" . $row['cqm_nqf_code'], ENT_NOQUOTES
) . " ";
432 if (!empty($row['amc_code'])) {
433 echo " " . htmlspecialchars( xl('AMC') . ":" . $row['amc_code'], ENT_NOQUOTES
) . " ";
438 if ( !(empty($row['concatenated_label'])) ) {
439 echo ", " . htmlspecialchars( xl( $row['concatenated_label'] ), ENT_NOQUOTES
) . " ";
443 else { // isset($row['is_sub'])
444 echo generate_display_field(array('data_type'=>'1','list_id'=>'rule_action_category'),$row['action_category']);
445 echo ": " . generate_display_field(array('data_type'=>'1','list_id'=>'rule_action'),$row['action_item']);
448 echo "<td align='center'>" . $row['total_patients'] . "</td>";
449 echo "<td align='center'>" . $row['pass_filter'] . "</td>";
450 if ($type_report != "amc") {
451 echo "<td align='center'>" . $row['excluded'] . "</td>";
453 echo "<td align='center'>" . $row['pass_target'] . "</td>";
454 echo "<td align='center'>" . $row['percentage'] . "</td>";
456 else if (isset($row['is_provider'])) {
457 // Display the provider information
458 if (!$firstProviderFlag && $_POST['form_provider'] == 'collate_outer') {
459 echo "<tr><td> </td></tr>";
461 echo "<td class='detail' align='center'><b>";
462 echo htmlspecialchars( xl("Provider").": " . $row['prov_lname'] . "," . $row['prov_fname'], ENT_NOQUOTES
);
463 if (!empty($row['npi']) ||
!empty($row['federaltaxid'])) {
465 if (!empty($row['npi'])) {
466 echo " " . htmlspecialchars( xl('NPI') . ":" . $row['npi'], ENT_NOQUOTES
) . " ";
468 if (!empty($row['federaltaxid'])) {
469 echo " " . htmlspecialchars( xl('TID') . ":" . $row['federaltaxid'], ENT_NOQUOTES
) . " ";
474 $firstProviderFlag = FALSE;
475 $existProvider = TRUE;
477 else { // isset($row['is_plan'])
478 if (!$firstPlanFlag && $_POST['form_provider'] != 'collate_outer') {
479 echo "<tr><td> </td></tr>";
481 echo "<td class='detail' align='center'><b>";
482 echo htmlspecialchars( xl("Plan"), ENT_NOQUOTES
) . ": ";
483 echo generate_display_field(array('data_type'=>'1','list_id'=>'clinical_plans'),$row['id']);
484 if (!empty($row['cqm_measure_group'])) {
485 echo " (". htmlspecialchars( xl('Measure Group Code') . ": " . $row['cqm_measure_group'], ENT_NOQUOTES
) . ")";
488 $firstPlanFlag = FALSE;
498 </div
> <!-- end of search results
-->
501 <?php
echo htmlspecialchars( xl('Please input search criteria above, and click Submit to view results.'), ENT_NOQUOTES
); ?
>
505 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
511 <!-- stuff
for the popup calendar
-->
512 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
513 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
514 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
515 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
516 <script language
="Javascript">
517 <?php
if ($type_report == "amc") { ?
>
518 Calendar
.setup({inputField
:"form_begin_date", ifFormat
:"%Y-%m-%d %H:%M:%S", button
:"img_begin_date", showsTime
:'true'});
520 Calendar
.setup({inputField
:"form_target_date", ifFormat
:"%Y-%m-%d %H:%M:%S", button
:"img_target_date", showsTime
:'true'});