4 * Provides manual administration of codes
7 * @link http://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Stephen Waite <stephen.waite@cmsvt.com>
10 * @author Brady Miller <brady.g.miller@gmail.com>
11 * @copyright Copyright (c) 2015-2017, 2022 Rod Roark <rod@sunsetsystems.com>
12 * @copyright Copyright (c) 2018-2021 Stephen Waite <stephen.waite@cmsvt.com>
13 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
14 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
17 require_once("../../globals.php");
18 require_once("../../../custom/code_types.inc.php");
19 require_once("$srcdir/options.inc.php");
21 use OpenEMR\Common\Acl\AclMain
;
22 use OpenEMR\Common\Csrf\CsrfUtils
;
23 use OpenEMR\Core\Header
;
26 $thisauthview = AclMain
::aclCheckCore('admin', 'superbill', false, 'view');
27 $thisauthwrite = AclMain
::aclCheckCore('admin', 'superbill', false, 'write');
29 if (!($thisauthwrite ||
$thisauthview)) {
30 echo "<html>\n<body>\n";
31 echo "<p>" . xlt('You are not authorized for this.') . "</p>\n";
32 echo "</body>\n</html>\n";
36 $institutional = $GLOBALS['ub04_support'] == "1" ?
true : false;
38 // Translation for form fields.
39 function ffescape($field)
41 $field = add_escape_custom($field);
45 // Format dollars for display.
47 function bucks($amount)
50 $amount = oeFormatMoney($amount);
59 $mode = $_POST['mode'] ??
null;
64 $financial_reporting = 0;
67 if (isset($mode) && $thisauthwrite) {
68 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
69 CsrfUtils
::csrfNotVerified();
72 $code_id = empty($_POST['code_id']) ?
'' : $_POST['code_id'] +
0;
73 $code = $_POST['code'];
74 $code_type = $_POST['code_type'];
75 $code_text = $_POST['code_text'];
76 $modifier = $_POST['modifier'];
77 $superbill = $_POST['form_superbill'];
78 $related_code = $_POST['related_code'];
79 $cyp_factor = is_numeric($_POST['cyp_factor']) ?
$_POST['cyp_factor'] +
0 : 0;
80 $active = empty($_POST['active']) ?
0 : 1;
81 $reportable = empty($_POST['reportable']) ?
0 : 1; // dx reporting
82 $financial_reporting = empty($_POST['financial_reporting']) ?
0 : 1; // financial service reporting
83 $revenue_code = $_POST['revenue_code'] ??
'';
86 if (!empty($_POST['taxrate'])) {
87 foreach ($_POST['taxrate'] as $key => $value) {
92 if ($mode == "delete") {
93 sqlStatement("DELETE FROM codes WHERE id = ?", array($code_id));
95 } elseif ($mode == "add" ||
$mode == "modify_complete") { // this covers both adding and modifying
96 $crow = sqlQuery("SELECT COUNT(*) AS count FROM codes WHERE " .
97 "code_type = '" . ffescape($code_type) . "' AND " .
98 "code = '" . ffescape($code) . "' AND " .
99 "modifier = '" . ffescape($modifier) . "' AND " .
100 "id != '" . add_escape_custom($code_id) . "'");
101 if ($crow['count']) {
102 $alertmsg = xl('Cannot add/update this entry because a duplicate already exists!');
105 "code = '" . ffescape($code) . "', " .
106 "code_type = '" . ffescape($code_type) . "', " .
107 "code_text = '" . ffescape($code_text) . "', " .
108 "modifier = '" . ffescape($modifier) . "', " .
109 "superbill = '" . ffescape($superbill) . "', " .
110 "related_code = '" . ffescape($related_code) . "', " .
111 "cyp_factor = '" . ffescape($cyp_factor) . "', " .
112 "taxrates = '" . ffescape($taxrates) . "', " .
113 "active = " . add_escape_custom($active) . ", " .
114 "financial_reporting = " . add_escape_custom($financial_reporting) . ", " .
115 "revenue_code = '" . ffescape($revenue_code) . "', " .
116 "reportable = '" . add_escape_custom($reportable) . "' ";
118 $query = "UPDATE codes SET $sql WHERE id = ?";
119 sqlStatement($query, array($code_id));
120 sqlStatement("DELETE FROM prices WHERE pr_id = ? AND " .
121 "pr_selector = ''", array($code_id));
123 $code_id = sqlInsert("INSERT INTO codes SET $sql");
127 foreach ($_POST['fee'] as $key => $value) {
128 $value = $value ??
0;
130 sqlStatement("INSERT INTO prices ( " .
131 "pr_id, pr_selector, pr_level, pr_price ) VALUES ( " .
132 "?, '', ?, ?)", array($code_id,$key,$value));
136 $code = $code_type = $code_text = $modifier = $superbill = "";
146 } elseif ($mode == "edit") { // someone clicked [Edit]
147 $sql = "SELECT * FROM codes WHERE id = ?";
148 $results = sqlStatement($sql, array($code_id));
149 while ($row = sqlFetchArray($results)) {
150 $code = $row['code'];
151 $code_text = $row['code_text'];
152 $code_type = $row['code_type'];
153 $modifier = $row['modifier'];
154 // $units = $row['units'];
155 $superbill = $row['superbill'];
156 $related_code = $row['related_code'];
157 $revenue_code = $row['revenue_code'] ??
'';
158 $cyp_factor = $row['cyp_factor'];
159 $taxrates = $row['taxrates'];
160 $active = 0 +
$row['active'];
161 $reportable = 0 +
$row['reportable'];
162 $financial_reporting = 0 +
$row['financial_reporting'];
164 } elseif ($mode == "modify") { // someone clicked [Modify]
165 // this is to modify external code types, of which the modifications
166 // are stored in the codes table
167 $code_type_name_external = $_POST['code_type_name_external'];
168 $code_external = $_POST['code_external'];
169 $code_id = $_POST['code_id'];
170 $results = return_code_information($code_type_name_external, $code_external, false); // only will return one item
171 while ($row = sqlFetchArray($results)) {
172 $code = $row['code'];
173 $code_text = $row['code_text'];
174 $code_type = $code_types[$code_type_name_external]['id'];
175 $modifier = $row['modifier'];
176 // $units = $row['units'];
177 $superbill = $row['superbill'];
178 $related_code = $row['related_code'];
179 $revenue_code = $row['revenue_code'] ??
'';
180 $cyp_factor = $row['cyp_factor'];
181 $taxrates = $row['taxrates'];
182 $active = $row['active'];
183 $reportable = $row['reportable'];
184 $financial_reporting = $row['financial_reporting'];
188 // If codes history is enabled in the billing globals save data to codes history table
190 $GLOBALS['save_codes_history'] && $alertmsg == '' &&
191 ( $mode == "add" ||
$mode == "modify_complete" ||
$mode == "delete" )
193 $action_type = empty($_POST['code_id']) ?
'new' : $mode;
194 $action_type = ($action_type == 'add') ?
'update' : $action_type ;
195 $code = $_POST['code'];
196 $code_type = $_POST['code_type'];
197 $code_text = $_POST['code_text'];
198 $modifier = $_POST['modifier'];
199 $superbill = $_POST['form_superbill'];
200 $related_code = $_POST['related_code'];
201 $revenue_code = $_POST['revenue_code'] ??
'';
202 $cyp_factor = $_POST['cyp_factor'] ??
0;
203 $active = empty($_POST['active']) ?
0 : 1;
204 $reportable = empty($_POST['reportable']) ?
0 : 1; // dx reporting
205 $financial_reporting = empty($_POST['financial_reporting']) ?
0 : 1; // financial service reporting
206 $fee = json_encode($_POST['fee']);
207 $code_sql = sqlFetchArray(sqlStatement("SELECT (ct_label) FROM code_types WHERE ct_id=?", array($code_type)));
211 $code_name = $code_sql['ct_label'];
214 $category_id = $_POST['form_superbill'];
215 $category_sql = sqlFetchArray(sqlStatement("SELECT (title) FROM list_options WHERE list_id='superbill'" .
216 " AND option_id=?", array($category_id)));
221 $category_name = $category_sql['title'];
224 $date = date('Y-m-d H:i:s');
225 $date = oeFormatShortDate($date);
226 $results = sqlStatement(
227 "INSERT INTO codes_history ( " .
228 "date, code, modifier, active,diagnosis_reporting,financial_reporting,category,code_type_name," .
229 "code_text,code_text_short,prices,action_type, update_by ) VALUES ( " .
230 "?, ?,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,?)",
231 array($date,$code,$modifier,$active,$reportable,$financial_reporting,$category_name,$code_name,$code_text,'',$fee,$action_type,$_SESSION['authUser'])
237 if (!empty($related_code)) {
238 $related_desc = $related_code;
241 $fstart = ($_REQUEST['fstart'] ??
null) +
0;
242 if (isset($_REQUEST['filter'])) {
244 $filter_key = array();
245 foreach ($_REQUEST['filter'] as $var) {
247 array_push($filter, $var);
248 $var_key = convert_type_id_to_key($var);
249 array_push($filter_key, $var_key);
253 $search = $_REQUEST['search'] ??
null;
254 $search_reportable = $_REQUEST['search_reportable'] ??
null;
255 $search_financial_reporting = $_REQUEST['search_financial_reporting'] ??
null;
257 $search_active = $_REQUEST['search_active'] ??
null;
259 //Build the filter_elements array
260 $filter_elements = array();
261 if (!empty($search_reportable)) {
262 $filter_elements['reportable'] = $search_reportable;
265 if (!empty($search_financial_reporting)) {
266 $filter_elements['financial_reporting'] = $search_financial_reporting;
269 if (!empty($search_active)) {
270 $filter_elements['active'] = $search_active;
273 if (isset($_REQUEST['filter'])) {
274 $count = main_code_set_search($filter_key, $search, null, null, false, null, true, null, null, $filter_elements);
277 if ($fstart >= ($count ??
null)) {
278 $fstart -= $pagesize;
285 $fend = $fstart +
$pagesize;
286 if ($fend > ($count ??
null)) {
287 $fend = $count ??
null;
293 <title
><?php
echo xlt("Codes"); ?
></title
>
295 <?php Header
::setupHeader(['select2']); ?
>
306 <?php
if ($institutional) { ?
>
308 $
(".revcode").select2({
310 url
: "<?php echo $GLOBALS['web_root'] ?>/interface/billing/ub04_helpers.php",
312 data
: function(params
) {
314 code_group
: "revenue_code",
318 processResults
: function(data
) {
320 results
: $
.map(data
, function(item
, index
) {
336 // This is for callback by the find-code popup.
337 // Appends to or erases the current list of related codes.
338 function set_related(codetype
, code
, selector
, codedesc
) {
339 var f
= document
.forms
[0];
340 var s
= f
.related_code
.value
;
342 if (s
.length
> 0) s +
= ';';
343 s +
= codetype +
':' + code
;
347 f
.related_code
.value
= s
;
348 f
.related_desc
.value
= s
;
351 // This is for callback by the find-code popup.
352 // Returns the array of currently selected codes with each element in codetype:code format.
353 function get_related() {
354 return document
.forms
[0].related_code
.value
.split(';');
357 // This is for callback by the find-code popup.
358 // Deletes the specified codetype:code from the currently selected list.
359 function del_related(s
) {
360 my_del_related(s
, document
.forms
[0].related_code
, false);
361 my_del_related(s
, document
.forms
[0].related_desc
, false);
364 // This invokes the find-code popup.
365 function sel_related() {
366 var f
= document
.forms
[0];
367 var i
= f
.code_type
.selectedIndex
;
370 var myid
= f
.code_type
.options
[i
].value
;
372 foreach ($code_types as $key => $value) {
373 $codeid = $value['id'];
374 $coderel = $value['rel'];
379 echo " if (myid == $codeid) codetype = '$coderel';";
384 alert(<?php
echo xlj('This code type does not accept relations.'); ?
>);
387 dlgopen('find_code_dynamic.php', '_blank', 900, 600);
390 // Some validation for saving a new code entry.
391 function validEntry(f
) {
393 alert(<?php
echo xlj('No code was specified!'); ?
>);
396 <?php
if ($GLOBALS['ippf_specific']) { ?
>
397 if (f
.code_type
.value
== 12 && !f
.related_code
.value
) {
398 alert(<?php
echo xlj('A related IPPF code is required!'); ?
>);
405 function submitAdd() {
406 var f
= document
.forms
[0];
407 if (!validEntry(f
)) return;
408 f
.mode
.value
= 'add';
409 f
.code_id
.value
= '';
413 function submitUpdate() {
414 var f
= document
.forms
[0];
415 if (! parseInt(f
.code_id
.value
)) {
416 alert(<?php
echo xlj('Cannot update because you are not editing an existing entry!'); ?
>);
419 if (!validEntry(f
)) return;
420 f
.mode
.value
= 'add';
424 function submitModifyComplete() {
425 var f
= document
.forms
[0];
426 f
.mode
.value
= 'modify_complete';
430 function submitList(offset
) {
431 var f
= document
.forms
[0];
432 var i
= parseInt(f
.fstart
.value
) + offset
;
438 function submitEdit(id
) {
439 var f
= document
.forms
[0];
440 f
.mode
.value
= 'edit';
441 f
.code_id
.value
= id
;
445 function submitModify(code_type_name
,code
,id
) {
446 var f
= document
.forms
[0];
447 f
.mode
.value
= 'modify';
448 f
.code_external
.value
= code
;
449 f
.code_id
.value
= id
;
450 f
.code_type_name_external
.value
= code_type_name
;
456 function submitDelete(id
) {
457 var f
= document
.forms
[0];
458 f
.mode
.value
= 'delete';
459 f
.code_id
.value
= id
;
463 function getCTMask() {
464 var ctid
= document
.forms
[0].code_type
.value
;
466 foreach ($code_types as $key => $value) {
467 $ctid = $value['id'];
468 $ctmask = $value['mask'];
469 echo " if (ctid == " . js_escape($ctid) . ") return " . js_escape($ctmask) . ";\n";
478 <body
class="body_top" >
480 <form method
='post' action
='superbill_custom_full.php' name
='theform'>
481 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
483 <input type
='hidden' name
='mode' value
='' />
487 <div
class="container">
488 <p
><?php
echo xlt('Not all fields are required for all codes or code types.'); ?
></p
>
489 <div
class="form-group row">
490 <label
for="code_type" class="col-form-label col-form-label-sm col-md-1"><?php
echo xlt('Type'); ?
>:</label
>
492 <?php
if ($mode != "modify") { ?
>
493 <select name
="code_type" id
="code_type" class='form-control form-control-sm'>
496 <?php
$external_sets = array(); ?
>
497 <?php
foreach ($code_types as $key => $value) { ?
>
498 <?php
if (!($value['external'])) { ?
>
499 <?php
if ($mode != "modify") { ?
>
500 <option value
="<?php echo attr($value['id']) ?>"<?php
if (!empty($code_type) && ($code_type == $value['id'])) {
501 echo " selected"; } ?
>><?php
echo xlt($value['label']) ?
></option
>
504 <?php
if ($value['external']) {
505 array_push($external_sets, $key);
507 <?php
} // end foreach ?>
509 <?php
if ($mode != "modify") { ?
>
512 <?php
if ($mode == "modify") { ?
>
513 <input type
='text' class='form-control form-control-sm' size
='4' name
='code_type' readonly
='readonly' style
='display:none' value
='<?php echo attr($code_type) ?>' />
514 <?php
echo text($code_type_name_external); ?
>
517 <label
class="col-form-label col-form-label-sm col-md-1"><?php
echo xlt('Code'); ?
>:</label
>
519 <?php
if ($mode == "modify") { ?
>
520 <input type
='text' class='form-control form-control-sm' size
='6' name
='code' readonly
='readonly' value
='<?php echo attr($code) ?>' />
522 <input type
='text' class='form-control form-control-sm' size
='6' name
='code' value
='<?php echo attr($code ?? '') ?>' onkeyup
='maskkeyup(this,getCTMask())' onblur
='maskblur(this,getCTMask())' />
525 <?php
if (modifiers_are_used()) { ?
>
526 <label
for="modifier" class="col-form-label col-form-label-sm col-md-1"><?php
echo xlt('Modifier'); ?
>:</label
>
528 <?php
if ($mode == "modify") { ?
>
529 <input type
='text' size
='6' class='form-control form-control-sm' name
='modifier' readonly
='readonly' value
='<?php echo attr($modifier) ?>' />
531 <input type
='text' size
='6' class='form-control form-control-sm' name
='modifier' value
='<?php echo attr($modifier ?? '') ?>' />
534 <input type
='hidden' name
='modifier' value
='' />
538 <input type
='checkbox' name
='active' value
='1'<?php
if (!empty($active) ||
($mode == 'modify' && $active == null)) {
539 echo ' checked'; } ?
> />
540 <?php
echo xlt('Active'); ?
>
543 <div
class="form-group row">
544 <label
for="code_text" class="col-form-label col-form-label-sm col-md-1"><?php
echo xlt('Description'); ?
>:</label
>
546 <?php
if ($mode == "modify") { ?
>
547 <input type
='text' size
='50' class='form-control form-control-sm' name
="code_text" readonly
="readonly" value
='<?php echo attr($code_text ?? '') ?>' />
549 <input type
='text' size
='50' class='form-control form-control-sm' name
="code_text" value
='<?php echo attr($code_text ?? '') ?>' />
552 <?php
if ($institutional) { ?
>
553 <label
for="revenue_code" class="col-form-label col-form-label-sm col-md-1"><?php
echo xlt('Revenue Code'); ?
>:</label
>
555 <?php
if ($mode == "modify") { ?
>
556 <input type
='text' size
='6' class='form-control form-control-sm' name
="revenue_code" readonly
="readonly" value
='<?php echo attr($revenue_code) ?>' />
558 <select size
='6' style
='width:150px' class='form-control form-control-sm revcode' name
="revenue_code" title
='<?php echo xla('Type to search
and select revenue code
'); ?>' value
='<?php echo attr($revenue_code) ?>'> </select
>
563 <div
class="form-group row">
564 <label
for="superbill" class="col-form-label col-form-label-sm col-md-1"><?php
echo xlt('Category'); ?
>:</label
>
566 <?php
generate_form_field(array('data_type' => 1,'field_id' => 'superbill','list_id' => 'superbill', 'smallform' => 'true'), ($superbill ??
'')); ?
>
569 <input type
='checkbox' title
='<?php echo xla("Syndromic Surveillance Report") ?>' name
='reportable' value
='1'<?php
if (!empty($reportable)) {
570 echo ' checked'; } ?
> />
571 <?php
echo xlt('Diagnosis Reporting'); ?
>
574 <input type
='checkbox' title
='<?php echo xla("Service Code Finance Reporting") ?>' name
='financial_reporting' value
='1'<?php
if (!empty($financial_reporting)) {
575 echo ' checked'; } ?
> />
576 <?php
echo xlt('Service Reporting'); ?
>
579 <div
class="form-group row">
580 <label
class="col-form-label col-form-label-sm col-md-1 <?php if (empty($GLOBALS['ippf_specific'])) {
581 echo 'd-none'; } ?>"><?php
echo xlt('CYP Factor'); ?
>:</label
>
582 <div
class="col-md <?php if (empty($GLOBALS['ippf_specific'])) {
583 echo 'd-none'; } ?>">
584 <input type
='text' class='form-control form-control-sm' size
='10' maxlength
='20' name
="cyp_factor" value
='<?php echo attr($cyp_factor ?? '') ?>' />
586 <label
class="col-form-label col-form-label-sm col-md-1 <?php if (!related_codes_are_used()) {
587 echo "d
-none
"; } ?>"><?php
echo xlt('Relate To'); ?
>:</label
>
588 <div
class="col-md <?php if (!related_codes_are_used()) {
589 echo "d
-none
"; } ?>">
590 <input type
='text' class='form-control form-control-sm' size
='50' name
='related_desc'
591 value
='<?php echo attr($related_desc) ?>' onclick
="sel_related()"
592 title
='<?php echo xla('Click to select related code
'); ?>' readonly
/>
593 <input type
='hidden' name
='related_code' value
='<?php echo attr($related_code) ?>' />
595 <label
class="col-form-label col-form-label-sm col-md-1"><?php
echo xlt('Fees'); ?
>:</label
>
597 $pres = sqlStatement("SELECT lo.option_id, lo.title, p.pr_price " .
598 "FROM list_options AS lo LEFT OUTER JOIN prices AS p ON " .
599 "p.pr_id = ? AND p.pr_selector = '' AND p.pr_level = lo.option_id " .
600 "WHERE lo.list_id = 'pricelevel' AND lo.activity = 1 ORDER BY lo.seq, lo.title", array($code_id));
601 for ($i = 0; $prow = sqlFetchArray($pres); ++
$i) {
602 echo "<label class='col-form-label col-form-label-sm col-md-1'>" . text(xl_list_label($prow['title'])) . "</label>";
603 echo "<div class='col-md'><input type='text' class='form-control form-control-sm' size='6' name='fee[" . attr($prow['option_id']) . "]' " .
604 "value='" . attr($prow['pr_price']) . "' /></div>\n";
609 $pres = sqlStatement("SELECT option_id, title FROM list_options " .
610 "WHERE list_id = 'taxrate' AND activity = 1 ORDER BY seq");
611 while ($prow = sqlFetchArray($pres)) {
612 $taxline .= "<input type='checkbox' name='taxrate[" . attr($prow['option_id']) . "]' value='1'";
613 if (strpos(":$taxrates", $prow['option_id']) !== false) {
614 $taxline .= " checked";
618 $taxline .= text(xl_list_label($prow['title'])) . "\n";
622 <div
class="col-md"><?php
echo xlt('Taxes'); ?
>: <?php
echo $taxline; ?
></div
>
625 <input type
="hidden" name
="code_id" value
="<?php echo attr($code_id) ?>" />
626 <input type
="hidden" name
="code_type_name_external" value
="<?php echo attr($code_type_name_external ?? '') ?>" />
627 <input type
="hidden" name
="code_external" value
="<?php echo attr($code_external ?? '') ?>" />
628 <?php
if ($thisauthwrite) { ?
>
629 <p
class="text-center">
630 <?php
if ($mode == "modify") { ?
>
631 <a href
='javascript:submitModifyComplete();' class='link'>[<?php
echo xlt('Update'); ?
>]</a
>
633 <a href
='javascript:submitUpdate();' class='link'>[<?php
echo xlt('Update'); ?
>]</a
>
635 <a href
='javascript:submitAdd();' class='link'>[<?php
echo xlt('Add as New'); ?
>]</a
>
640 <div
class="container-fluid">
641 <div
class="row align-items-end">
642 <div
class="col-md-2">
643 <select name
='filter[]' class="form-control form-control-sm" multiple
='multiple'>
645 foreach ($code_types as $key => $value) {
646 echo "<option value='" . attr($value['id']) . "'";
647 if (isset($filter) && in_array($value['id'], $filter)) {
651 echo ">" . xlt($value['label']) . "</option>\n";
657 <input type
="text" name
="search" class="form-control form-control-sm" size
="5" value
="<?php echo attr($search) ?>" />
660 <input type
="submit" class="btn btn-primary btn-sm" name
="go" value
='<?php echo xla('Search
'); ?>' />
663 <input type
='checkbox' title
='<?php echo xla("Only Show Diagnosis Reporting Codes") ?>' name
='search_reportable' value
='1'<?php
if (!empty($search_reportable)) {
664 echo ' checked'; } ?
> /><?php
echo xlt('Diagnosis Reporting Only'); ?
>
667 <input type
='checkbox' title
='<?php echo xla("Only Show Service Code Finance Reporting Codes") ?>' name
='search_financial_reporting' value
='1'<?php
if (!empty($search_financial_reporting)) {
668 echo ' checked'; } ?
> /><?php
echo xlt('Service Reporting Only'); ?
>
669 <input type
='hidden' name
='fstart' value
='<?php echo attr($fstart) ?>' />
672 <input type
='checkbox' title
='<?php echo xla("Only Show Active Codes ") ?>' name
='search_active' value
='1'<?php
if (!empty($search_active)) {
673 echo ' checked'; } ?
> /><?php
echo xlt('Active Codes'); ?
>
675 <div
class="col-md text-right">
676 <?php
if ($fstart) { ?
>
677 <a href
="javascript:submitList(<?php echo attr_js($pagesize); ?>)">
682 <?php
echo text(($fstart +
1)) . " - " . text($fend) . " of " . text($count ??
''); ?
>
683 <a href
="javascript:submitList(<?php echo attr_js($pagesize); ?>)">
691 <table
class='table table-borderless' cellpadding
='5' cellspacing
='0'>
693 <td
><span
class='font-weight-bold'><?php
echo xlt('Code'); ?
></span
></td
>
694 <td
><span
class='font-weight-bold'><?php
echo xlt('Mod'); ?
></span
></td
>
695 <?php
if ($institutional) { ?
>
696 <td
><span
class='font-weight-bold'><?php
echo xlt('Revenue'); ?
></span
></td
>
698 <td
><span
class='font-weight-bold'><?php
echo xlt('Act'); ?
></span
></td
>
699 <td
><span
class='font-weight-bold'><?php
echo xlt('Category'); ?
></span
></td
>
700 <td
><span
class='font-weight-bold'><?php
echo xlt('Dx Rep'); ?
></span
></td
>
701 <td
><span
class='font-weight-bold'><?php
echo xlt('Serv Rep'); ?
></span
></td
>
702 <td
><span
class='font-weight-bold'><?php
echo xlt('Type'); ?
></span
></td
>
703 <td
><span
class='font-weight-bold'><?php
echo xlt('Description'); ?
></span
></td
>
704 <td
><span
class='font-weight-bold'><?php
echo xlt('Short Description'); ?
></span
></td
>
705 <?php
if (related_codes_are_used()) { ?
>
706 <td
><span
class='font-weight-bold'><?php
echo xlt('Related'); ?
></span
></td
>
709 $pres = sqlStatement("SELECT title FROM list_options " .
710 "WHERE list_id = 'pricelevel' AND activity = 1 ORDER BY seq, title");
711 while ($prow = sqlFetchArray($pres)) {
712 echo " <td class='font-weight-bold text-right text-nowrap'>" . text(xl_list_label($prow['title'])) . "</td>\n";
720 if (isset($_REQUEST['filter'])) {
721 $res = main_code_set_search($filter_key, $search, null, null, false, null, false, $fstart, ($fend - $fstart), $filter_elements);
724 for ($i = 0; $row = sqlFetchArray($res); $i++
) {
730 foreach ($all as $iter) {
734 foreach ($code_types as $key => $value) {
735 if ($value['id'] == $iter['code_type']) {
736 $has_fees = $value['fee'];
742 echo " <td class='text'>" . text($iter["code"]) . "</td>\n";
743 echo " <td class='text'>" . text($iter["modifier"]) . "</td>\n";
744 if ($institutional) {
745 echo " <td class='text'>" . ($iter['revenue_code'] > '' ?
text($iter['revenue_code']) : 'none') . "</td>\n";
747 if ($iter["code_external"] > 0) {
748 // If there is no entry in codes sql table, then default to active
749 // (this is reason for including NULL below)
750 echo " <td class='text'>" . ( ($iter["active"] ||
$iter["active"] == null) ?
xlt('Yes') : xlt('No')) . "</td>\n";
752 echo " <td class='text'>" . ( ($iter["active"]) ?
xlt('Yes') : xlt('No')) . "</td>\n";
755 $sres = sqlStatement("SELECT title " .
756 "FROM list_options AS lo " .
757 "WHERE lo.list_id = 'superbill' AND lo.option_id = ?", array($iter['superbill']));
758 if ($srow = sqlFetchArray($sres)) {
759 echo " <td class='text'>" . text($srow['title']) . "</td>\n";
761 echo " <td class='text'>" . '' . "</td>\n";
763 echo " <td class='text'>" . ($iter["reportable"] ?
xlt('Yes') : xlt('No')) . "</td>\n";
764 echo " <td class='text'>" . ($iter["financial_reporting"] ?
xlt('Yes') : xlt('No')) . "</td>\n";
765 echo " <td class='text'>" . text($iter['code_type_name']) . "</td>\n";
766 echo " <td class='text'>" . text($iter['code_text']) . "</td>\n";
767 echo " <td class='text'>" . text($iter['code_text_short']) . "</td>\n";
769 if (related_codes_are_used() && $iter['related_code']) {
770 // Show related codes.
771 echo " <td class='text'>";
772 $arel = explode(';', $iter['related_code']);
773 foreach ($arel as $tmp) {
774 list($reltype, $relcode) = explode(':', $tmp);
775 $code_description = lookup_code_descriptions($reltype . ":" . $relcode);
776 echo text($relcode) . ' ' . text(trim($code_description)) . '<br />';
782 $pres = sqlStatement("SELECT p.pr_price " .
783 "FROM list_options AS lo LEFT OUTER JOIN prices AS p ON " .
784 "p.pr_id = ? AND p.pr_selector = '' AND p.pr_level = lo.option_id " .
785 "WHERE lo.list_id = 'pricelevel' AND lo.activity = 1 ORDER BY lo.seq", array($iter['id']));
786 while ($prow = sqlFetchArray($pres)) {
787 echo "<td class='text text-right'>" . text(bucks($prow['pr_price'])) . "</td>\n";
790 if ($thisauthwrite) {
791 if ($iter["code_external"] > 0) {
792 echo " <td class='text-right'><a class='link' href='javascript:submitModify(" . attr_js($iter['code_type_name']) . "," . attr_js($iter['code']) . "," . attr_js($iter['id']) . ")'>[" . xlt('Modify') . "]</a></td>\n";
794 echo " <td class='text-right'><a class='link' href='javascript:submitDelete(" . attr_js($iter['id']) . ")'>[" . xlt('Delete') . "]</a></td>\n";
795 echo " <td class='text-right'><a class='link' href='javascript:submitEdit(" . attr_js($iter['id']) . ")'>[" . xlt('Edit') . "]</a></td>\n";
810 echo "alert(" . js_escape($alertmsg) . ");\n";