CDR module work on the CQM report requirements:
[openemr.git] / interface / reports / cqm.php
bloba6365b3a440df6a76fbf5316d8736a2f53529663
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 // This report shows upcoming appointments with filtering and
10 // sorting by patient, practitioner, appointment type, and date.
12 //SANITIZE ALL ESCAPES
13 $sanitize_all_escapes=true;
16 //STOP FAKE REGISTER GLOBALS
17 $fake_register_globals=false;
20 require_once("../globals.php");
21 require_once("../../library/patient.inc");
22 require_once("$srcdir/formatting.inc.php");
23 require_once "$srcdir/options.inc.php";
24 require_once "$srcdir/formdata.inc.php";
25 require_once "$srcdir/clinical_rules.php";
27 // Collect parameters (set defaults if empty)
28 $target_date = (isset($_POST['form_target_date'])) ? trim($_POST['form_target_date']) : date('Y-m-d H:i:s');
29 $rule_filter = (isset($_POST['form_rule_filter'])) ? trim($_POST['form_rule_filter']) : "";
30 $plan_filter = (isset($_POST['form_plan_filter'])) ? trim($_POST['form_plan_filter']) : "";
31 $organize_method = (empty($plan_filter)) ? "default" : "plans";
32 $provider = trim($_POST['form_provider']);
36 <html>
38 <head>
39 <?php html_header_show();?>
41 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
43 <title><?php echo htmlspecialchars( xl('Clinical Quality Measures'), ENT_NOQUOTES); ?></title>
45 <script type="text/javascript" src="../../library/overlib_mini.js"></script>
46 <script type="text/javascript" src="../../library/textformat.js"></script>
47 <script type="text/javascript" src="../../library/dialog.js"></script>
48 <script type="text/javascript" src="../../library/js/jquery.1.3.2.js"></script>
50 <script LANGUAGE="JavaScript">
52 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
54 function refreshme() {
55 // location.reload();
56 document.forms[0].submit();
59 </script>
61 <style type="text/css">
63 /* specifically include & exclude from printing */
64 @media print {
65 #report_parameters {
66 visibility: hidden;
67 display: none;
69 #report_parameters_daterange {
70 visibility: visible;
71 display: inline;
73 #report_results table {
74 margin-top: 0px;
78 /* specifically exclude some from the screen */
79 @media screen {
80 #report_parameters_daterange {
81 visibility: hidden;
82 display: none;
86 </style>
87 </head>
89 <body class="body_top">
91 <!-- Required for the popup date selectors -->
92 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
94 <span class='title'><?php echo htmlspecialchars( xl('Report'), ENT_NOQUOTES); ?> -
95 <?php echo htmlspecialchars( xl('Clinical Quality Measures'), ENT_NOQUOTES); ?></span>
97 <form method='post' name='theform' id='theform' action='cqm.php'>
99 <div id="report_parameters">
101 <table>
102 <tr>
103 <td width='470px'>
104 <div style='float:left'>
106 <table class='text'>
107 <tr>
108 <td class='label'>
109 <?php xl('Target Date','e'); ?>:
110 </td>
111 <td>
112 <input type='text' name='form_target_date' id="form_target_date" size='20' value='<?php echo htmlspecialchars( $target_date, ENT_QUOTES); ?>'
113 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title='<?php echo htmlspecialchars( xl('yyyy-mm-dd hh:mm:ss'), ENT_QUOTES); ?>'>
114 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
115 id='img_target_date' border='0' alt='[?]' style='cursor:pointer'
116 title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>'>
117 </td>
118 </tr>
119 <tr>
120 <td class='label'>
121 <?php echo htmlspecialchars( xl('Rule Set'), ENT_NOQUOTES); ?>:
122 </td>
123 <td>
124 <select name='form_rule_filter'>
125 <option value=''>-- <?php echo htmlspecialchars( xl('Show All'), ENT_NOQUOTES); ?> --</option>
126 <option value='cqm' <?php if ($rule_filter == "cqm") echo "selected"; ?>>
127 <?php echo htmlspecialchars( xl('Official Clinical Quality Measures (CQM) Rules'), ENT_NOQUOTES); ?></option>
128 <option value='amc' <?php if ($rule_filter == "amc") echo "selected"; ?>>
129 <?php echo htmlspecialchars( xl('Official Automated Measure Calculation Rules'), ENT_NOQUOTES); ?></option>
130 <option value='passive_alert' <?php if ($rule_filter == "passive_alert") echo "selected"; ?>>
131 <?php echo htmlspecialchars( xl('Passive Alert Rules'), ENT_NOQUOTES); ?></option>
132 <option value='active_alert' <?php if ($rule_filter == "active_alert") echo "selected"; ?>>
133 <?php echo htmlspecialchars( xl('Active Alert Rules'), ENT_NOQUOTES); ?></option>
134 <option value='patient_reminder' <?php if ($rule_filter == "patient_reminder") echo "selected"; ?>>
135 <?php echo htmlspecialchars( xl('Patient Reminder Rules'), ENT_NOQUOTES); ?></option>
136 </td>
137 </tr>
138 <tr>
139 <td class='label'>
140 <?php echo htmlspecialchars( xl('Plan Set'), ENT_NOQUOTES); ?>:
141 </td>
142 <td>
143 <select name='form_plan_filter'>
144 <option value=''>-- <?php echo htmlspecialchars( xl('Show All'), ENT_NOQUOTES); ?> --</option>
145 <option value='cqm' <?php if ($plan_filter == "cqm") echo "selected"; ?>>
146 <?php echo htmlspecialchars( xl('Official Clinical Quality Measures (CQM) Measure Groups'), ENT_NOQUOTES); ?></option>
147 <option value='normal' <?php if ($plan_filter == "normal") echo "selected"; ?>>
148 <?php echo htmlspecialchars( xl('Active Plans'), ENT_NOQUOTES); ?></option>
149 </td>
150 </tr>
151 <tr>
152 <td class='label'>
153 <?php echo htmlspecialchars( xl('Provider'), ENT_NOQUOTES); ?>:
154 </td>
155 <td>
156 <?php
158 // Build a drop-down list of providers.
161 $query = "SELECT id, lname, fname FROM users WHERE ".
162 "authorized = 1 $provider_facility_filter ORDER BY lname, fname"; //(CHEMED) facility filter
164 $ures = sqlStatement($query);
166 echo " <select name='form_provider'>\n";
167 echo " <option value=''>-- " . htmlspecialchars( xl('All (Cumulative)'), ENT_NOQUOTES) . " --\n";
169 echo " <option value='collate'";
170 if ($_POST['form_provider'] == 'collate') echo " selected";
171 echo ">-- " . htmlspecialchars( xl('All (Collated)'), ENT_NOQUOTES) . " --\n";
173 while ($urow = sqlFetchArray($ures)) {
174 $provid = $urow['id'];
175 echo " <option value='".htmlspecialchars( $provid, ENT_QUOTES)."'";
176 if ($provid == $_POST['form_provider']) echo " selected";
177 echo ">" . htmlspecialchars( $urow['lname'] . ", " . $urow['fname'], ENT_NOQUOTES) . "\n";
180 echo " </select>\n";
183 </td>
184 </tr>
185 </table>
187 </div>
189 </td>
190 <td align='left' valign='middle' height="100%">
191 <table style='border-left:1px solid; width:100%; height:100%' >
192 <tr>
193 <td>
194 <div style='margin-left:15px'>
195 <a href='#' class='css_button' onclick='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
196 <span>
197 <?php echo htmlspecialchars( xl('Submit'), ENT_NOQUOTES); ?>
198 </span>
199 </a>
201 <?php if ($_POST['form_refresh']) { ?>
202 <a href='#' class='css_button' onclick='window.print()'>
203 <span>
204 <?php echo htmlspecialchars( xl('Print'), ENT_NOQUOTES); ?>
205 </span>
206 </a>
207 <?php } ?>
208 </div>
209 </td>
210 </tr>
211 </table>
212 </td>
213 </tr>
214 </table>
216 </div> <!-- end of search parameters -->
218 <br>
220 <?php
221 if ($_POST['form_refresh']) {
225 <div id="report_results">
226 <table>
228 <thead>
229 <th>
230 <?php echo htmlspecialchars( xl('Title'), ENT_NOQUOTES); ?>
231 </th>
233 <th>
234 <?php echo htmlspecialchars( xl('Total Patients'), ENT_NOQUOTES); ?>
235 </th>
237 <th>
238 <?php echo htmlspecialchars( xl('Applicable Patients'), ENT_NOQUOTES); ?></a>
239 </th>
241 <th>
242 <?php echo htmlspecialchars( xl('Excluded Patients'), ENT_NOQUOTES); ?></a>
243 </th>
245 <th>
246 <?php echo htmlspecialchars( xl('Passed Patients'), ENT_NOQUOTES); ?></a>
247 </th>
249 <th>
250 <?php echo htmlspecialchars( xl('Performance Percentage'), ENT_NOQUOTES); ?></a>
251 </th>
253 </thead>
254 <tbody> <!-- added for better print-ability -->
255 <?php
257 //collect the results
258 $dataSheet = test_rules_clinic($provider,$rule_filter,$target_date,"report",'',$plan_filter,$organize_method);
260 $firstProviderFlag = TRUE;
261 $firstPlanFlag = TRUE;
262 $existProvider = FALSE;
263 foreach ($dataSheet as $row) {
267 <tr bgcolor='<?php echo $bgcolor ?>'>
269 <?php
270 if (isset($row['is_main']) || isset($row['is_sub'])) {
271 echo "<td class='detail'>";
272 if (isset($row['is_main'])) {
273 echo "<b>".generate_display_field(array('data_type'=>'1','list_id'=>'clinical_rules'),$row['id'])."</b>";
274 if (!empty($row['cqm_pqri_code']) || !empty($row['cqm_nqf_code']) || !empty($row['amc_code'])) {
275 echo " (";
276 if (!empty($row['cqm_pqri_code'])) {
277 echo " " . htmlspecialchars( xl('PQRI') . ":" . $row['cqm_pqri_code'], ENT_NOQUOTES) . " ";
279 if (!empty($row['cqm_nqf_code'])) {
280 echo " " . htmlspecialchars( xl('NQF') . ":" . $row['cqm_nqf_code'], ENT_NOQUOTES) . " ";
282 if (!empty($row['amc_code'])) {
283 echo " " . htmlspecialchars( xl('AMC') . ":" . $row['amc_code'], ENT_NOQUOTES) . " ";
285 echo ")";
288 else { // isset($row['is_sub'])
289 echo generate_display_field(array('data_type'=>'1','list_id'=>'rule_action_category'),$row['action_category']);
290 echo ": " . generate_display_field(array('data_type'=>'1','list_id'=>'rule_action'),$row['action_item']);
292 echo "</td>";
293 echo "<td align='center'>" . $row['total_patients'] . "</td>";
294 echo "<td align='center'>" . $row['pass_filter'] . "</td>";
295 echo "<td align='center'>" . $row['excluded'] . "</td>";
296 echo "<td align='center'>" . $row['pass_target'] . "</td>";
297 echo "<td align='center'>" . $row['percentage'] . "</td>";
299 else if (isset($row['is_provider'])) {
300 // Display the provider information
301 if (!$firstProviderFlag) {
302 echo "<tr><td>&nbsp</td></tr>";
304 echo "<td class='detail' align='center'><b>";
305 echo htmlspecialchars( xl("Provider").": " . $row['prov_lname'] . "," . $row['prov_fname'], ENT_NOQUOTES);
306 if (!empty($row['npi']) || !empty($row['federaltaxid'])) {
307 echo " (";
308 if (!empty($row['npi'])) {
309 echo " " . htmlspecialchars( xl('NPI') . ":" . $row['npi'], ENT_NOQUOTES) . " ";
311 if (!empty($row['federaltaxid'])) {
312 echo " " . htmlspecialchars( xl('TID') . ":" . $row['federaltaxid'], ENT_NOQUOTES) . " ";
314 echo ")";
316 echo "</b></td>";
317 $firstProviderFlag = FALSE;
318 $existProvider = TRUE;
320 else { // isset($row['is_plan'])
321 if (!$firstPlanFlag && !$existProvider) {
322 echo "<tr><td>&nbsp</td></tr>";
324 echo "<td class='detail' align='center'><b>";
325 echo htmlspecialchars( xl("Plan"), ENT_NOQUOTES) . ": ";
326 echo generate_display_field(array('data_type'=>'1','list_id'=>'clinical_plans'),$row['id']);
327 if (!empty($row['cqm_measure_group'])) {
328 echo " (". htmlspecialchars( xl('Measure Group Code') . ": " . $row['cqm_measure_group'], ENT_NOQUOTES) . ")";
330 echo "</b></td>";
331 $firstPlanFlag = FALSE;
334 </tr>
336 <?php
339 </tbody>
340 </table>
341 </div> <!-- end of search results -->
342 <?php } else { ?>
343 <div class='text'>
344 <?php echo htmlspecialchars( xl('Please input search criteria above, and click Submit to view results.'), ENT_NOQUOTES); ?>
345 </div>
346 <?php } ?>
348 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
350 </form>
352 </body>
354 <!-- stuff for the popup calendar -->
355 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
356 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
357 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
358 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
359 <script language="Javascript">
360 Calendar.setup({inputField:"form_target_date", ifFormat:"%Y-%m-%d %H:%M:%S", button:"img_target_date", showsTime:'true'});
361 </script>
363 </html>