2 // Copyright (C) 2008-2016 Rod Roark <rod@sunsetsystems.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.
9 use OpenEMR\Core\Header
;
11 require_once("../globals.php");
12 require_once("../../custom/code_types.inc.php");
14 // Format dollars for display.
16 function bucks($amount)
22 return oeFormatMoney($amount);
25 $filter = $_REQUEST['filter'] +
0;
26 $where = "c.active = 1";
28 $where .= " AND c.code_type = '$filter'";
31 if (empty($_REQUEST['include_uncat'])) {
32 $where .= " AND c.superbill != '' AND c.superbill != '0'";
38 <?php Header
::setupHeader(['datetime-picker', 'report-helper']); ?
>
40 <style type
="text/css">
42 /* specifically include & exclude from printing */
48 #report_parameters_daterange {
52 #report_results table {
57 /* specifically exclude some from the screen */
59 #report_parameters_daterange {
65 table
.mymaintable
, table
.mymaintable td
, table
.mymaintable th
{
66 border
: 1px solid
#aaaaaa;
67 border
-collapse
: collapse
;
69 table
.mymaintable td
, table
.mymaintable th
{
70 padding
: 1pt
4pt
1pt
4pt
;
74 <title
><?php
xl('Services by Category', 'e'); ?
></title
>
76 <script language
="JavaScript">
78 $
(document
).ready(function() {
79 oeFixedHeaderSetup(document
.getElementById('mymaintable'));
80 var win
= top
.printLogSetup ? top
: opener
.top
;
81 win
.printLogSetup(document
.getElementById('printbutton'));
88 <body
class="body_top">
90 <span
class='title'><?php
xl('Report', 'e'); ?
> - <?php
xl('Services by Category', 'e'); ?
></span
>
92 <form method
='post' action
='services_by_category.php' name
='theform' id
='theform'>
94 <div id
="report_parameters">
96 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
101 <div style
='float:left'>
106 <select name
='filter' class='form-control'>
107 <option value
='0'><?php
xl('All', 'e'); ?
></option
>
109 foreach ($code_types as $key => $value) {
110 echo "<option value='" . $value['id'] . "'";
111 if ($value['id'] == $filter) {
115 echo ">$key</option>\n";
121 <div
class="checkbox">
122 <label
><input type
='checkbox' name
='include_uncat' value
='1'<?php
if (!empty($_REQUEST['include_uncat'])) {
125 <?php
xl('Include Uncategorized', 'e'); ?
></label
>
134 <td align
='left' valign
='middle' height
="100%">
135 <table style
='border-left:1px solid; width:100%; height:100%' >
138 <div
class="text-center">
139 <div
class="btn-group" role
="group">
140 <a href
='#' class='btn btn-default btn-save' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
141 <?php
echo xlt('Submit'); ?
>
143 <?php
if ($_POST['form_refresh']) { ?
>
144 <a href
='#' class='btn btn-default btn-print' id
='printbutton'>
145 <?php
echo xlt('Print'); ?
>
156 </div
> <!-- end of parameters
-->
159 if ($_POST['form_refresh']) {
162 <div id
="report_results">
165 <table width
='98%' id
='mymaintable' class='mymaintable'>
166 <thead style
='display:table-header-group'>
167 <tr bgcolor
="#dddddd">
168 <th
class='bold'><?php
xl('Category', 'e'); ?
></th
>
169 <th
class='bold'><?php
xl('Type', 'e'); ?
></th
>
170 <th
class='bold'><?php
xl('Code', 'e'); ?
></th
>
171 <th
class='bold'><?php
xl('Mod', 'e'); ?
></th
>
172 <th
class='bold'><?php
xl('Units', 'e'); ?
></th
>
173 <th
class='bold'><?php
xl('Description', 'e'); ?
></th
>
174 <?php
if (related_codes_are_used()) { ?
>
175 <th
class='bold'><?php
xl('Related', 'e'); ?
></th
>
178 $pres = sqlStatement("SELECT title FROM list_options " .
179 "WHERE list_id = 'pricelevel' AND activity = 1 ORDER BY seq");
180 while ($prow = sqlFetchArray($pres)) {
181 // Added 5-09 by BM - Translate label if applicable
182 echo " <th class='bold' align='right' nowrap>" . xl_list_label($prow['title']) . "</th>\n";
189 $res = sqlStatement("SELECT c.*, lo.title FROM codes AS c " .
190 "LEFT OUTER JOIN list_options AS lo ON lo.list_id = 'superbill' " .
191 "AND lo.option_id = c.superbill AND lo.activity = 1 " .
192 "WHERE $where ORDER BY lo.title, c.code_type, c.code, c.modifier");
196 while ($row = sqlFetchArray($res)) {
197 $category = $row['title'] ?
$row['title'] : 'Uncategorized';
198 $disp_category = ' ';
199 if ($category !== $last_category) {
200 $last_category = $category;
201 $disp_category = $category;
205 foreach ($code_types as $key => $value) {
206 if ($value['id'] == $row['code_type']) {
211 $bgcolor = (($irow & 1) ?
"#ffdddd" : "#ddddff");
212 echo " <tr bgcolor='$bgcolor'>\n";
213 // Added 5-09 by BM - Translate label if applicable
214 echo " <td class='text'>" . xl_list_label($disp_category) . "</td>\n";
215 echo " <td class='text'>$key</td>\n";
216 echo " <td class='text'>" . $row['code'] . "</td>\n";
217 echo " <td class='text'>" . $row['modifier'] . "</td>\n";
218 echo " <td class='text'>" . $row['units'] . "</td>\n";
219 echo " <td class='text'>" . $row['code_text'] . "</td>\n";
221 if (related_codes_are_used()) {
222 // Show related codes.
223 echo " <td class='text'>";
224 $arel = explode(';', $row['related_code']);
225 foreach ($arel as $tmp) {
226 list($reltype, $relcode) = explode(':', $tmp);
227 $reltype = $code_types[$reltype]['id'];
228 $relrow = sqlQuery("SELECT code_text FROM codes WHERE " .
229 "code_type = '$reltype' AND code = '$relcode' LIMIT 1");
230 echo $relcode . ' ' . trim($relrow['code_text']) . '<br />';
236 $pres = sqlStatement("SELECT p.pr_price " .
237 "FROM list_options AS lo LEFT OUTER JOIN prices AS p ON " .
238 "p.pr_id = '" . $row['id'] . "' AND p.pr_selector = '' " .
239 "AND p.pr_level = lo.option_id " .
240 "WHERE lo.list_id = 'pricelevel' AND lo.activity = 1 ORDER BY lo.seq");
241 while ($prow = sqlFetchArray($pres)) {
242 echo " <td class='text' align='right'>" . bucks($prow['pr_price']) . "</td>\n";
251 <?php
} // end of submit logic ?>