3 * Services by category report.
6 * @link http://www.open-emr.org
7 * @author Rod Roark <rod@sunsetsystems.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2008-2016 Rod Roark <rod@sunsetsystems.com>
10 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../globals.php");
16 require_once("../../custom/code_types.inc.php");
18 use OpenEMR\Core\Header
;
20 // Format dollars for display.
22 function bucks($amount)
28 return oeFormatMoney($amount);
33 <title
><?php
echo xlt('Services by Category'); ?
></title
>
35 <?php Header
::setupHeader(['datetime-picker', 'report-helper']); ?
>
37 <style type
="text/css">
38 /* specifically include & exclude from printing */
44 #report_parameters_daterange {
48 #report_results table {
53 /* specifically exclude some from the screen */
55 #report_parameters_daterange {
61 table
.mymaintable
, table
.mymaintable td
, table
.mymaintable th
{
62 border
: 1px solid
#aaaaaa;
63 border
-collapse
: collapse
;
65 table
.mymaintable td
, table
.mymaintable th
{
66 padding
: 1pt
4pt
1pt
4pt
;
70 <script language
="JavaScript">
72 $
(document
).ready(function() {
73 oeFixedHeaderSetup(document
.getElementById('mymaintable'));
74 var win
= top
.printLogSetup ? top
: opener
.top
;
75 win
.printLogSetup(document
.getElementById('printbutton'));
80 <body
class="body_top">
82 <span
class='title'><?php
echo xlt('Report'); ?
> - <?php
echo xlt('Services by Category'); ?
></span
>
84 <form method
='post' action
='services_by_category.php' name
='theform' id
='theform' onsubmit
='return top.restoreSession()'>
86 <div id
="report_parameters">
88 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
93 <div style
='float:left'>
98 <select name
='filter' class='form-control'>
99 <option value
='0'><?php
echo xlt('All'); ?
></option
>
101 foreach ($code_types as $key => $value) {
102 echo "<option value='" . attr($value['id']) . "'";
103 if ($value['id'] == $filter) {
107 echo ">" . text($key) . "</option>\n";
113 <div
class="checkbox">
114 <label
><input type
='checkbox' name
='include_uncat' value
='1'<?php
echo (!empty($_REQUEST['include_uncat'])) ?
" checked" : ""; ?
> />
115 <?php
echo xlt('Include Uncategorized'); ?
></label
>
124 <td align
='left' valign
='middle' height
="100%">
125 <table style
='border-left:1px solid; width:100%; height:100%' >
128 <div
class="text-center">
129 <div
class="btn-group" role
="group">
130 <a href
='#' class='btn btn-default btn-save' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
131 <?php
echo xlt('Submit'); ?
>
133 <?php
if ($_POST['form_refresh']) { ?
>
134 <a href
='#' class='btn btn-default btn-print' id
='printbutton'>
135 <?php
echo xlt('Print'); ?
>
146 </div
> <!-- end of parameters
-->
149 if ($_POST['form_refresh']) {
152 <div id
="report_results">
155 <table width
='98%' id
='mymaintable' class='mymaintable'>
156 <thead style
='display:table-header-group'>
157 <tr bgcolor
="#dddddd">
158 <th
class='bold'><?php
echo xlt('Category'); ?
></th
>
159 <th
class='bold'><?php
echo xlt('Type'); ?
></th
>
160 <th
class='bold'><?php
echo xlt('Code'); ?
></th
>
161 <th
class='bold'><?php
echo xlt('Mod'); ?
></th
>
162 <th
class='bold'><?php
echo xlt('Units'); ?
></th
>
163 <th
class='bold'><?php
echo xlt('Description'); ?
></th
>
164 <?php
if (related_codes_are_used()) { ?
>
165 <th
class='bold'><?php
echo xlt('Related'); ?
></th
>
168 $pres = sqlStatement("SELECT title FROM list_options " .
169 "WHERE list_id = 'pricelevel' AND activity = 1 ORDER BY seq");
170 while ($prow = sqlFetchArray($pres)) {
171 // Added 5-09 by BM - Translate label if applicable
172 echo " <th class='bold' align='right' nowrap>" . text(xl_list_label($prow['title'])) . "</th>\n";
180 $sqlBindArray = array();
181 $filter = sanitizeNumber($_REQUEST['filter']);
182 $where = "c.active = 1";
184 $where .= " AND c.code_type = ?";
185 array_push($sqlBindArray, $filter);
187 if (empty($_REQUEST['include_uncat'])) {
188 $where .= " AND c.superbill != '' AND c.superbill != '0'";
191 $res = sqlStatement("SELECT c.*, lo.title FROM codes AS c " .
192 "LEFT OUTER JOIN list_options AS lo ON lo.list_id = 'superbill' " .
193 "AND lo.option_id = c.superbill AND lo.activity = 1 " .
194 "WHERE $where ORDER BY lo.title, c.code_type, c.code, c.modifier", $sqlBindArray);
198 while ($row = sqlFetchArray($res)) {
199 $category = $row['title'] ?
$row['title'] : xl('Uncategorized');
200 $disp_category = ' ';
201 if ($category !== $last_category) {
202 $last_category = $category;
203 $disp_category = $category;
207 foreach ($code_types as $key => $value) {
208 if ($value['id'] == $row['code_type']) {
213 $bgcolor = (($irow & 1) ?
"#ffdddd" : "#ddddff");
214 echo " <tr bgcolor='$bgcolor'>\n";
215 // Added 5-09 by BM - Translate label if applicable
216 echo " <td class='text'>" . text(xl_list_label($disp_category)) . "</td>\n";
217 echo " <td class='text'>" . text($key) . "</td>\n";
218 echo " <td class='text'>" . text($row['code']) . "</td>\n";
219 echo " <td class='text'>" . text($row['modifier']) . "</td>\n";
220 echo " <td class='text'>" . text($row['units']) . "</td>\n";
221 echo " <td class='text'>" . text($row['code_text']) . "</td>\n";
223 if (related_codes_are_used()) {
224 // Show related codes.
225 echo " <td class='text'>";
226 $arel = explode(';', $row['related_code']);
227 foreach ($arel as $tmp) {
228 list($reltype, $relcode) = explode(':', $tmp);
229 $reltype = $code_types[$reltype]['id'];
230 $relrow = sqlQuery("SELECT code_text FROM codes WHERE " .
231 "code_type = ? AND code = ? LIMIT 1", array($reltype, $relcode));
232 echo text($relcode) . ' ' . text(trim($relrow['code_text'])) . '<br />';
238 $pres = sqlStatement("SELECT p.pr_price " .
239 "FROM list_options AS lo LEFT OUTER JOIN prices AS p ON " .
240 "p.pr_id = ? AND p.pr_selector = '' " .
241 "AND p.pr_level = lo.option_id " .
242 "WHERE lo.list_id = 'pricelevel' AND lo.activity = 1 ORDER BY lo.seq", array($row['id']));
243 while ($prow = sqlFetchArray($pres)) {
244 echo " <td class='text' align='right'>" . text(bucks($prow['pr_price'])) . "</td>\n";
253 <?php
} // end of submit logic ?>