Committed football_injury_report.php for bug where Warning message is displayed when...
[openemr.git] / interface / reports / services_by_category.php
blobfa30d0f3ba2e87be232fc8c36caeee288d1c76df
1 <?php
2 // Copyright (C) 2008-2010 Rod Roark <rod@sunsetsystems.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 require_once("../globals.php");
10 require_once("../../custom/code_types.inc.php");
11 require_once("$srcdir/sql.inc");
12 require_once("$srcdir/formatting.inc.php");
14 // Format dollars for display.
16 function bucks($amount) {
17 if (empty($amount)) return '';
18 return oeFormatMoney($amount);
21 $filter = $_REQUEST['filter'] + 0;
22 $where = "c.active = 1";
23 if ($filter) $where .= " AND c.code_type = '$filter'";
24 if (empty($_REQUEST['include_uncat']))
25 $where .= " AND c.superbill != '' AND c.superbill != '0'";
27 <html>
28 <head>
29 <?php html_header_show(); ?>
30 <style type="text/css">
32 /* specifically include & exclude from printing */
33 @media print {
34 #report_parameters {
35 visibility: hidden;
36 display: none;
38 #report_parameters_daterange {
39 visibility: visible;
40 display: inline;
42 #report_results table {
43 margin-top: 0px;
47 /* specifically exclude some from the screen */
48 @media screen {
49 #report_parameters_daterange {
50 visibility: hidden;
51 display: none;
54 </style>
55 <title><?php xl('Services by Category','e'); ?></title>
56 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
58 <script type="text/javascript" src="../../library/js/jquery.1.3.2.js"></script>
60 </head>
62 <body class="body_top">
64 <span class='title'><?php xl('Report','e'); ?> - <?php xl('Services by Category','e'); ?></span>
66 <form method='post' action='services_by_category.php' name='theform' id='theform'>
68 <div id="report_parameters">
70 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
72 <table>
73 <tr>
74 <td width='280px'>
75 <div style='float:left'>
77 <table class='text'>
78 <tr>
79 <td>
80 <select name='filter'>
81 <option value='0'><?php xl('All','e'); ?></option>
82 <?php
83 foreach ($code_types as $key => $value) {
84 echo "<option value='" . $value['id'] . "'";
85 if ($value['id'] == $filter) echo " selected";
86 echo ">$key</option>\n";
89 </select>
90 </td>
91 <td>
92 <input type='checkbox' name='include_uncat' value='1'<?php if (!empty($_REQUEST['include_uncat'])) echo " checked"; ?> />
93 <?php xl('Include Uncategorized','e'); ?>
94 </td>
95 </tr>
96 </table>
98 </div>
100 </td>
101 <td align='left' valign='middle' height="100%">
102 <table style='border-left:1px solid; width:100%; height:100%' >
103 <tr>
104 <td>
105 <div style='margin-left:15px'>
106 <a href='#' class='css_button' onclick='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
107 <span>
108 <?php xl('Submit','e'); ?>
109 </span>
110 </a>
112 <?php if ($_POST['form_refresh']) { ?>
113 <a href='#' class='css_button' onclick='window.print()'>
114 <span>
115 <?php xl('Print','e'); ?>
116 </span>
117 </a>
118 <?php } ?>
119 </div>
120 </td>
121 </tr>
122 </table>
123 </td>
124 </tr>
125 </table>
126 </div> <!-- end of parameters -->
128 <div id="report_results">
129 <?php if ($_POST['form_submit']) { ?>
131 <table border='0' cellpadding='1' cellspacing='2' width='98%'>
132 <thead style='display:table-header-group'>
133 <tr bgcolor="#dddddd">
134 <th class='bold'><?php xl('Category' ,'e'); ?></th>
135 <th class='bold'><?php xl('Type' ,'e'); ?></th>
136 <th class='bold'><?php xl('Code' ,'e'); ?></th>
137 <th class='bold'><?php xl('Mod' ,'e'); ?></th>
138 <th class='bold'><?php xl('Units' ,'e'); ?></th>
139 <th class='bold'><?php xl('Description','e'); ?></th>
140 <?php if (related_codes_are_used()) { ?>
141 <th class='bold'><?php xl('Related' ,'e'); ?></th>
142 <?php } ?>
143 <?php
144 $pres = sqlStatement("SELECT title FROM list_options " .
145 "WHERE list_id = 'pricelevel' ORDER BY seq");
146 while ($prow = sqlFetchArray($pres)) {
147 // Added 5-09 by BM - Translate label if applicable
148 echo " <th class='bold' align='right' nowrap>" . xl_list_label($prow['title']) . "</th>\n";
151 </tr>
152 </thead>
153 <tbody>
154 <?php
155 $res = sqlStatement("SELECT c.*, lo.title FROM codes AS c " .
156 "LEFT OUTER JOIN list_options AS lo ON lo.list_id = 'superbill' " .
157 "AND lo.option_id = c.superbill " .
158 "WHERE $where ORDER BY lo.title, c.code_type, c.code, c.modifier");
160 $last_category = '';
161 $irow = 0;
162 while ($row = sqlFetchArray($res)) {
163 $category = $row['title'] ? $row['title'] : 'Uncategorized';
164 $disp_category = '&nbsp';
165 if ($category !== $last_category) {
166 $last_category = $category;
167 $disp_category = $category;
168 ++$irow;
170 foreach ($code_types as $key => $value) {
171 if ($value['id'] == $row['code_type']) {
172 break;
175 $bgcolor = (($irow & 1) ? "#ffdddd" : "#ddddff");
176 echo " <tr bgcolor='$bgcolor'>\n";
177 // Added 5-09 by BM - Translate label if applicable
178 echo " <td class='text'>" . xl_list_label($disp_category) . "</td>\n";
179 echo " <td class='text'>$key</td>\n";
180 echo " <td class='text'>" . $row['code'] . "</td>\n";
181 echo " <td class='text'>" . $row['modifier'] . "</td>\n";
182 echo " <td class='text'>" . $row['units'] . "</td>\n";
183 echo " <td class='text'>" . $row['code_text'] . "</td>\n";
185 if (related_codes_are_used()) {
186 // Show related codes.
187 echo " <td class='text'>";
188 $arel = explode(';', $row['related_code']);
189 foreach ($arel as $tmp) {
190 list($reltype, $relcode) = explode(':', $tmp);
191 $reltype = $code_types[$reltype]['id'];
192 $relrow = sqlQuery("SELECT code_text FROM codes WHERE " .
193 "code_type = '$reltype' AND code = '$relcode' LIMIT 1");
194 echo $relcode . ' ' . trim($relrow['code_text']) . '<br />';
196 echo "</td>\n";
199 $pres = sqlStatement("SELECT p.pr_price " .
200 "FROM list_options AS lo LEFT OUTER JOIN prices AS p ON " .
201 "p.pr_id = '" . $row['id'] . "' AND p.pr_selector = '' " .
202 "AND p.pr_level = lo.option_id " .
203 "WHERE list_id = 'pricelevel' ORDER BY lo.seq");
204 while ($prow = sqlFetchArray($pres)) {
205 echo " <td class='text' align='right'>" . bucks($prow['pr_price']) . "</td>\n";
207 echo " </tr>\n";
210 </tbody>
211 </table>
213 <?php } // end of submit logic ?>
214 </div>
216 </body>
217 </html>