4 * Services by category report.
7 * @link http://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2008-2016 Rod Roark <rod@sunsetsystems.com>
11 * @copyright Copyright (c) 2017-2018 Brady Miller <brady.g.miller@gmail.com>
12 * @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\Common\Csrf\CsrfUtils
;
19 use OpenEMR\Common\Utils\FormatMoney
;
20 use OpenEMR\Core\Header
;
23 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
24 CsrfUtils
::csrfNotVerified();
31 <title
><?php
echo xlt('Services by Category'); ?
></title
>
33 <?php Header
::setupHeader(['datetime-picker', 'report-helper']); ?
>
36 /* specifically include & exclude from printing */
42 #report_parameters_daterange {
46 #report_results table {
51 /* specifically exclude some from the screen */
53 #report_parameters_daterange {
61 table
.mymaintable th
{
62 border
-collapse
: collapse
;
64 table
.mymaintable td
, table
.mymaintable th
{
65 padding
: 1pt
4pt
1pt
4pt
;
72 oeFixedHeaderSetup(document
.getElementById('mymaintable'));
73 var win
= top
.printLogSetup ? top
: opener
.top
;
74 win
.printLogSetup(document
.getElementById('printbutton'));
79 <body
class="body_top">
81 <span
class='title'><?php
echo xlt('Report'); ?
> - <?php
echo xlt('Services by Category'); ?
></span
>
83 <form method
='post' action
='services_by_category.php' name
='theform' id
='theform' onsubmit
='return top.restoreSession()'>
84 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
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 (!empty($filter) && ($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
class='h-100' align
='left' valign
='middle'>
125 <table
class='w-100 h-100' style
='border-left:1px solid;'>
128 <div
class="text-center">
129 <div
class="btn-group" role
="group">
130 <a href
='#' class='btn btn-secondary btn-save' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
131 <?php
echo xlt('Submit'); ?
>
133 <?php
if (!empty($_POST['form_refresh'])) { ?
>
134 <a href
='#' class='btn btn-secondary btn-print' id
='printbutton'>
135 <?php
echo xlt('Print'); ?
>
146 </div
> <!-- end of parameters
-->
149 if (!empty($_POST['form_refresh'])) {
152 <div id
="report_results">
155 <table width
='98%' id
='mymaintable' class='table table-striped mymaintable'>
156 <thead
class='thead-light'>
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']) {
214 // Added 5-09 by BM - Translate label if applicable
215 echo " <td class='text'>" . text(xl_list_label($disp_category)) . "</td>\n";
216 echo " <td class='text'>" . text($key) . "</td>\n";
217 echo " <td class='text'>" . text($row['code']) . "</td>\n";
218 echo " <td class='text'>" . text($row['modifier']) . "</td>\n";
219 echo " <td class='text'>" . text($row['units']) . "</td>\n";
220 echo " <td class='text'>" . text($row['code_text']) . "</td>\n";
222 if (related_codes_are_used()) {
223 // Show related codes.
224 echo " <td class='text'>";
225 $arel = explode(';', $row['related_code']);
226 foreach ($arel as $tmp) {
227 list($reltype, $relcode) = explode(':', $tmp);
228 $reltype = $code_types[$reltype]['id'];
229 $relrow = sqlQuery("SELECT code_text FROM codes WHERE " .
230 "code_type = ? AND code = ? LIMIT 1", array($reltype, $relcode));
231 echo text($relcode) . ' ' . text(trim($relrow['code_text'])) . '<br />';
237 $pres = sqlStatement("SELECT p.pr_price " .
238 "FROM list_options AS lo LEFT OUTER JOIN prices AS p ON " .
239 "p.pr_id = ? AND p.pr_selector = '' " .
240 "AND p.pr_level = lo.option_id " .
241 "WHERE lo.list_id = 'pricelevel' AND lo.activity = 1 ORDER BY lo.seq", array($row['id']));
242 while ($prow = sqlFetchArray($pres)) {
243 echo " <td class='text' align='right'>" . text(FormatMoney
::getBucks($prow['pr_price'])) . "</td>\n";
252 <?php
} // end of submit logic ?>