3 * Provides manual administration for codes
6 * @link http://www.open-emr.org
7 * @author Rod Roark <rod@sunsetsystems.com>
8 * @author Stephen Waite <stephen.waite@cmsvt.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2015-2017 Rod Roark <rod@sunsetsystems.com>
11 * @copyright Copyright (c) 2018 Stephen Waite <stephen.waite@cmsvt.com>
12 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
13 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
16 require_once("../../globals.php");
17 require_once("../../../custom/code_types.inc.php");
18 require_once("$srcdir/options.inc.php");
21 $thisauthview = acl_check('admin', 'superbill', false, 'view');
22 $thisauthwrite = acl_check('admin', 'superbill', false, 'write');
24 if (!($thisauthwrite ||
$thisauthview)) {
25 echo "<html>\n<body>\n";
26 echo "<p>" . xlt('You are not authorized for this.') . "</p>\n";
27 echo "</body>\n</html>\n";
31 $institutional = $GLOBALS['ub04_support'] == "1" ?
true : false;
33 // Translation for form fields.
34 function ffescape($field)
36 $field = add_escape_custom($field);
40 // Format dollars for display.
42 function bucks($amount)
45 $amount = oeFormatMoney($amount);
54 $mode = $_POST['mode'];
59 $financial_reporting = 0;
62 if (isset($mode) && $thisauthwrite) {
63 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
67 $code_id = empty($_POST['code_id']) ?
'' : $_POST['code_id'] +
0;
68 $code = $_POST['code'];
69 $code_type = $_POST['code_type'];
70 $code_text = $_POST['code_text'];
71 $modifier = $_POST['modifier'];
72 $superbill = $_POST['form_superbill'];
73 $related_code = $_POST['related_code'];
74 $cyp_factor = is_numeric($_POST['cyp_factor']) ?
$_POST['cyp_factor'] +
0 : 0;
75 $active = empty($_POST['active']) ?
0 : 1;
76 $reportable = empty($_POST['reportable']) ?
0 : 1; // dx reporting
77 $financial_reporting = empty($_POST['financial_reporting']) ?
0 : 1; // financial service reporting
78 $revenue_code = $_POST['revenue_code'];
81 if (!empty($_POST['taxrate'])) {
82 foreach ($_POST['taxrate'] as $key => $value) {
87 if ($mode == "delete") {
88 sqlStatement("DELETE FROM codes WHERE id = ?", array($code_id));
90 } else if ($mode == "add" ||
$mode == "modify_complete") { // this covers both adding and modifying
91 $crow = sqlQuery("SELECT COUNT(*) AS count FROM codes WHERE " .
92 "code_type = '" . ffescape($code_type) . "' AND " .
93 "code = '" . ffescape($code) . "' AND " .
94 "modifier = '" . ffescape($modifier) . "' AND " .
95 "id != '" . add_escape_custom($code_id) . "'");
97 $alertmsg = xl('Cannot add/update this entry because a duplicate already exists!');
100 "code = '" . ffescape($code) . "', " .
101 "code_type = '" . ffescape($code_type) . "', " .
102 "code_text = '" . ffescape($code_text) . "', " .
103 "modifier = '" . ffescape($modifier) . "', " .
104 "superbill = '" . ffescape($superbill) . "', " .
105 "related_code = '" . ffescape($related_code) . "', " .
106 "cyp_factor = '" . ffescape($cyp_factor) . "', " .
107 "taxrates = '" . ffescape($taxrates) . "', " .
108 "active = " . add_escape_custom($active) . ", " .
109 "financial_reporting = " . add_escape_custom($financial_reporting) . ", " .
110 "revenue_code = '" . ffescape($revenue_code) . "', " .
111 "reportable = '" . add_escape_custom($reportable) . "' ";
113 $query = "UPDATE codes SET $sql WHERE id = ?";
114 sqlStatement($query, array($code_id));
115 sqlStatement("DELETE FROM prices WHERE pr_id = ? AND " .
116 "pr_selector = ''", array($code_id));
118 $code_id = sqlInsert("INSERT INTO codes SET $sql");
122 foreach ($_POST['fee'] as $key => $value) {
125 sqlStatement("INSERT INTO prices ( " .
126 "pr_id, pr_selector, pr_level, pr_price ) VALUES ( " .
127 "?, '', ?, ?)", array($code_id,$key,$value));
131 $code = $code_type = $code_text = $modifier = $superbill = "";
141 } else if ($mode == "edit") { // someone clicked [Edit]
142 $sql = "SELECT * FROM codes WHERE id = ?";
143 $results = sqlStatement($sql, array($code_id));
144 while ($row = sqlFetchArray($results)) {
145 $code = $row['code'];
146 $code_text = $row['code_text'];
147 $code_type = $row['code_type'];
148 $modifier = $row['modifier'];
149 // $units = $row['units'];
150 $superbill = $row['superbill'];
151 $related_code = $row['related_code'];
152 $revenue_code = $row['revenue_code'];
153 $cyp_factor = $row['cyp_factor'];
154 $taxrates = $row['taxrates'];
155 $active = 0 +
$row['active'];
156 $reportable = 0 +
$row['reportable'];
157 $financial_reporting = 0 +
$row['financial_reporting'];
159 } else if ($mode == "modify") { // someone clicked [Modify]
160 // this is to modify external code types, of which the modifications
161 // are stored in the codes table
162 $code_type_name_external = $_POST['code_type_name_external'];
163 $code_external = $_POST['code_external'];
164 $code_id = $_POST['code_id'];
165 $results = return_code_information($code_type_name_external, $code_external, false); // only will return one item
166 while ($row = sqlFetchArray($results)) {
167 $code = $row['code'];
168 $code_text = $row['code_text'];
169 $code_type = $code_types[$code_type_name_external]['id'];
170 $modifier = $row['modifier'];
171 // $units = $row['units'];
172 $superbill = $row['superbill'];
173 $related_code = $row['related_code'];
174 $revenue_code = $row['revenue_code'];
175 $cyp_factor = $row['cyp_factor'];
176 $taxrates = $row['taxrates'];
177 $active = $row['active'];
178 $reportable = $row['reportable'];
179 $financial_reporting = $row['financial_reporting'];
183 // If codes history is enabled in the billing globals save data to codes history table
184 if ($GLOBALS['save_codes_history'] && $alertmsg=='' &&
185 ( $mode == "add" ||
$mode == "modify_complete" ||
$mode == "delete" ) ) {
186 $action_type= empty($_POST['code_id']) ?
'new' : $mode;
187 $action_type= ($action_type=='add') ?
'update' : $action_type ;
188 $code = $_POST['code'];
189 $code_type = $_POST['code_type'];
190 $code_text = $_POST['code_text'];
191 $modifier = $_POST['modifier'];
192 $superbill = $_POST['form_superbill'];
193 $related_code = $_POST['related_code'];
194 $revenue_code = $_POST['revenue_code'];
195 $cyp_factor = $_POST['cyp_factor'] +
0;
196 $active = empty($_POST['active']) ?
0 : 1;
197 $reportable = empty($_POST['reportable']) ?
0 : 1; // dx reporting
198 $financial_reporting = empty($_POST['financial_reporting']) ?
0 : 1; // financial service reporting
199 $fee=json_encode($_POST['fee']);
200 $code_sql= sqlFetchArray(sqlStatement("SELECT (ct_label) FROM code_types WHERE ct_id=?", array($code_type)));
204 $code_name=$code_sql['ct_label'];
207 $categorey_id= $_POST['form_superbill'];
208 $categorey_sql=sqlFetchArray(sqlStatement("SELECT (title ) FROM list_options WHERE list_id='superbill'".
209 " AND option_id=?", array($categorey_id)));
213 if ($categorey_sql) {
214 $categorey_name=$categorey_sql['title'];
217 $date=date('Y-m-d H:i:s');
218 $date=oeFormatShortDate($date);
219 $results = sqlStatement(
220 "INSERT INTO codes_history ( " .
221 "date, code, modifier, active,diagnosis_reporting,financial_reporting,category,code_type_name,".
222 "code_text,code_text_short,prices,action_type, update_by ) VALUES ( " .
223 "?, ?,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,?)",
224 array($date,$code,$modifier,$active,$reportable,$financial_reporting,$categorey_name,$code_name,$code_text,'',$fee,$action_type,$_SESSION['authUser'])
230 if (!empty($related_code)) {
231 $related_desc = $related_code;
234 $fstart = $_REQUEST['fstart'] +
0;
235 if (isset($_REQUEST['filter'])) {
237 $filter_key = array();
238 foreach ($_REQUEST['filter'] as $var) {
240 array_push($filter, $var);
241 $var_key = convert_type_id_to_key($var);
242 array_push($filter_key, $var_key);
246 $search = $_REQUEST['search'];
247 $search_reportable = $_REQUEST['search_reportable'];
248 $search_financial_reporting = $_REQUEST['search_financial_reporting'];
250 //Build the filter_elements array
251 $filter_elements = array();
252 if (!empty($search_reportable)) {
253 $filter_elements['reportable'] = $search_reportable;
256 if (!empty($search_financial_reporting)) {
257 $filter_elements['financial_reporting'] = $search_financial_reporting;
260 if (isset($_REQUEST['filter'])) {
261 $count = main_code_set_search($filter_key, $search, null, null, false, null, true, null, null, $filter_elements);
264 if ($fstart >= $count) {
265 $fstart -= $pagesize;
272 $fend = $fstart +
$pagesize;
273 if ($fend > $count) {
280 <title
><?php
echo xlt("Codes"); ?
></title
>
281 <?php
html_header_show(); ?
>
283 <link rel
="stylesheet" href
="<?php echo $css_header; ?>" type
="text/css">
284 <script type
="text/javascript" src
="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
285 <script type
="text/javascript" src
="../../../library/textformat.js"></script
>
286 <script type
="text/JavaScript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery/dist/jquery.min.js"></script
>
287 <link href
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-ui-themes/themes/base/jquery-ui.min.css" rel
="stylesheet" type
="text/css" />
288 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative'] ?>/jquery-ui/jquery-ui.min.js"></script
>
290 .ui
-autocomplete
{ max
-height
: 350px
; max
-width
: 35%
; overflow
-y
: auto
; overflow
-x
: hidden
; }
293 <?php
if ($institutional) { ?
>
296 $
( ".revcode" ).autocomplete({
298 source
: function( request
, response
) {
299 var term
= request
.term
;
300 request
.code_group
= "revenue_code";
301 if ( term in cache
) {
302 response( cache
[ term
] );
305 $
.getJSON( "<?php echo $GLOBALS['web_root'] ?>/interface/billing/ub04_helpers.php", request
, function( data
, status
, xhr
) {
306 cache
[ term
] = data
;
310 }).dblclick(function(event
) {
311 $
(this
).autocomplete('search'," ");
316 // This is for callback by the find-code popup.
317 // Appends to or erases the current list of related codes.
318 function set_related(codetype
, code
, selector
, codedesc
) {
319 var f
= document
.forms
[0];
320 var s
= f
.related_code
.value
;
322 if (s
.length
> 0) s +
= ';';
323 s +
= codetype +
':' + code
;
327 f
.related_code
.value
= s
;
328 f
.related_desc
.value
= s
;
331 // This is for callback by the find-code popup.
332 // Returns the array of currently selected codes with each element in codetype:code format.
333 function get_related() {
334 return document
.forms
[0].related_code
.value
.split(';');
337 // This is for callback by the find-code popup.
338 // Deletes the specified codetype:code from the currently selected list.
339 function del_related(s
) {
340 my_del_related(s
, document
.forms
[0].related_code
, false);
341 my_del_related(s
, document
.forms
[0].related_desc
, false);
344 // This invokes the find-code popup.
345 function sel_related() {
346 var f
= document
.forms
[0];
347 var i
= f
.code_type
.selectedIndex
;
350 var myid
= f
.code_type
.options
[i
].value
;
352 foreach ($code_types as $key => $value) {
353 $codeid = $value['id'];
354 $coderel = $value['rel'];
359 echo " if (myid == $codeid) codetype = '$coderel';";
364 alert(<?php
echo xlj('This code type does not accept relations.'); ?
>);
367 dlgopen('find_code_dynamic.php', '_blank', 900, 600);
370 // Some validation for saving a new code entry.
371 function validEntry(f
) {
373 alert(<?php
echo xlj('No code was specified!'); ?
>);
376 <?php
if ($GLOBALS['ippf_specific']) { ?
>
377 if (f
.code_type
.value
== 12 && !f
.related_code
.value
) {
378 alert(<?php
echo xlj('A related IPPF code is required!'); ?
>);
385 function submitAdd() {
386 var f
= document
.forms
[0];
387 if (!validEntry(f
)) return;
388 f
.mode
.value
= 'add';
389 f
.code_id
.value
= '';
393 function submitUpdate() {
394 var f
= document
.forms
[0];
395 if (! parseInt(f
.code_id
.value
)) {
396 alert(<?php
echo xlj('Cannot update because you are not editing an existing entry!'); ?
>);
399 if (!validEntry(f
)) return;
400 f
.mode
.value
= 'add';
404 function submitModifyComplete() {
405 var f
= document
.forms
[0];
406 f
.mode
.value
= 'modify_complete';
410 function submitList(offset
) {
411 var f
= document
.forms
[0];
412 var i
= parseInt(f
.fstart
.value
) + offset
;
418 function submitEdit(id
) {
419 var f
= document
.forms
[0];
420 f
.mode
.value
= 'edit';
421 f
.code_id
.value
= id
;
425 function submitModify(code_type_name
,code
,id
) {
426 var f
= document
.forms
[0];
427 f
.mode
.value
= 'modify';
428 f
.code_external
.value
= code
;
429 f
.code_id
.value
= id
;
430 f
.code_type_name_external
.value
= code_type_name
;
436 function submitDelete(id
) {
437 var f
= document
.forms
[0];
438 f
.mode
.value
= 'delete';
439 f
.code_id
.value
= id
;
443 function getCTMask() {
444 var ctid
= document
.forms
[0].code_type
.value
;
446 foreach ($code_types as $key => $value) {
447 $ctid = $value['id'];
448 $ctmask = $value['mask'];
449 echo " if (ctid == " . js_escape($ctid) . ") return " . js_escape($ctmask) . ";\n";
458 <body
class="body_top" >
460 <form method
='post' action
='superbill_custom_full.php' name
='theform'>
461 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(collectCsrfToken()); ?>" />
463 <input type
='hidden' name
='mode' value
=''>
468 <table border
='0' cellpadding
='0' cellspacing
='0'>
471 <td colspan
="3"> <?php
echo xlt('Not all fields are required for all codes or code types.'); ?
><br
><br
></td
>
475 <td
><?php
echo xlt('Type'); ?
>:</td
>
480 <?php
if ($mode != "modify") { ?
>
481 <select name
="code_type">
484 <?php
$external_sets = array(); ?
>
485 <?php
foreach ($code_types as $key => $value) { ?
>
486 <?php
if (!($value['external'])) { ?
>
487 <?php
if ($mode != "modify") { ?
>
488 <option value
="<?php echo attr($value['id']) ?>"<?php
if ($code_type == $value['id']) {
490 } ?
>><?php
echo xlt($value['label']) ?
></option
>
493 <?php
if ($value['external']) {
494 array_push($external_sets, $key);
496 <?php
} // end foreach ?>
498 <?php
if ($mode != "modify") { ?
>
502 <?php
if ($mode == "modify") { ?
>
503 <input type
='text' size
='4' name
='code_type' readonly
='readonly' style
='display:none' value
='<?php echo attr($code_type) ?>' />
504 <?php
echo text($code_type_name_external) ?
>
508 <?php
echo xlt('Code'); ?
>:
510 <?php
if ($mode == "modify") { ?
>
511 <input type
='text' size
='6' name
='code' readonly
='readonly' value
='<?php echo attr($code) ?>' />
513 <input type
='text' size
='6' name
='code' value
='<?php echo attr($code) ?>'
514 onkeyup
='maskkeyup(this,getCTMask())'
515 onblur
='maskblur(this,getCTMask())'
519 <?php
if (modifiers_are_used()) { ?
>
520  
; 
;<?php
echo xlt('Modifier'); ?
>:
521 <?php
if ($mode == "modify") { ?
>
522 <input type
='text' size
='6' name
='modifier' readonly
='readonly' value
='<?php echo attr($modifier) ?>'>
524 <input type
='text' size
='6' name
='modifier' value
='<?php echo attr($modifier) ?>'>
527 <input type
='hidden' name
='modifier' value
=''>
531 <input type
='checkbox' name
='active' value
='1'<?php
if (!empty($active) ||
($mode == 'modify' && $active == null)) {
534 <?php
echo xlt('Active'); ?
>
539 <td
><?php
echo xlt('Description'); ?
>:</td
>
542 <?php
if ($mode == "modify") { ?
>
543 <input type
='text' size
='50' name
="code_text" readonly
="readonly" value
='<?php echo attr($code_text) ?>'>
545 <input type
='text' size
='50' name
="code_text" value
='<?php echo attr($code_text) ?>'>
547 <?php
if ($institutional) { ?
>
548 <?php
echo xlt('Revenue Code'); ?
>:
549 <?php
if ($mode == "modify") { ?
>
550 <input type
='text' size
='6' name
="revenue_code" readonly
="readonly" value
='<?php echo attr($revenue_code) ?>'>
552 <input type
='text' size
='6' class='revcode' name
="revenue_code" title
='<?php echo xla('Type to search
and select revenue code
'); ?>' value
='<?php echo attr($revenue_code) ?>'>
559 <td
><?php
echo xlt('Category'); ?
>:</td
>
563 generate_form_field(array('data_type'=>1,'field_id'=>'superbill','list_id'=>'superbill'), $superbill);
566 <input type
='checkbox' title
='<?php echo xla("Syndromic Surveillance Report") ?>' name
='reportable' value
='1'<?php
if (!empty($reportable)) {
569 <?php
echo xlt('Diagnosis Reporting'); ?
>
570  
; 
; 
; 
;
571 <input type
='checkbox' title
='<?php echo xla("Service Code Finance Reporting") ?>' name
='financial_reporting' value
='1'<?php
if (!empty($financial_reporting)) {
574 <?php
echo xlt('Service Reporting'); ?
>
578 <tr
<?php
if (empty($GLOBALS['ippf_specific'])) {
579 echo " style='display:none'";
581 <td
><?php
echo xlt('CYP Factor'); ?
>:</td
>
584 <input type
='text' size
='10' maxlength
='20' name
="cyp_factor" value
='<?php echo attr($cyp_factor) ?>'>
589 <tr
<?php
if (!related_codes_are_used()) {
590 echo " style='display:none'";
592 <td
><?php
echo xlt('Relate To'); ?
>:</td
>
595 <input type
='text' size
='50' name
='related_desc'
596 value
='<?php echo attr($related_desc) ?>' onclick
="sel_related()"
597 title
='<?php echo xla('Click to select related code
'); ?>' readonly
/>
598 <input type
='hidden' name
='related_code' value
='<?php echo attr($related_code) ?>' />
603 <td
><?php
echo xlt('Fees'); ?
>:</td
>
607 $pres = sqlStatement("SELECT lo.option_id, lo.title, p.pr_price " .
608 "FROM list_options AS lo LEFT OUTER JOIN prices AS p ON " .
609 "p.pr_id = ? AND p.pr_selector = '' AND p.pr_level = lo.option_id " .
610 "WHERE lo.list_id = 'pricelevel' AND lo.activity = 1 ORDER BY lo.seq, lo.title", array($code_id));
611 for ($i = 0; $prow = sqlFetchArray($pres); ++
$i) {
616 echo text(xl_list_label($prow['title'])) . " ";
617 echo "<input type='text' size='6' name='fee[" . attr($prow['option_id']) . "]' " .
618 "value='" . attr($prow['pr_price']) . "' >\n";
626 $pres = sqlStatement("SELECT option_id, title FROM list_options " .
627 "WHERE list_id = 'taxrate' AND activity = 1 ORDER BY seq");
628 while ($prow = sqlFetchArray($pres)) {
630 $taxline .= " ";
633 $taxline .= "<input type='checkbox' name='taxrate[" . attr($prow['option_id']) . "]' value='1'";
634 if (strpos(":$taxrates", $prow['option_id']) !== false) {
635 $taxline .= " checked";
639 $taxline .= text(xl_list_label($prow['title'])) . "\n";
645 <td
><?php
echo xlt('Taxes'); ?
>:</td
>
648 <?php
echo $taxline ?
>
655 <td colspan
="3" align
="center">
656 <input type
="hidden" name
="code_id" value
="<?php echo attr($code_id) ?>"><br
>
657 <input type
="hidden" name
="code_type_name_external" value
="<?php echo attr($code_type_name_external) ?>">
658 <input type
="hidden" name
="code_external" value
="<?php echo attr($code_external) ?>">
659 <?php
if ($thisauthwrite) { ?
>
660 <?php
if ($mode == "modify") { ?
>
661 <a href
='javascript:submitModifyComplete();' class='link'>[<?php
echo xlt('Update'); ?
>]</a
>
663 <a href
='javascript:submitUpdate();' class='link'>[<?php
echo xlt('Update'); ?
>]</a
>
665 <a href
='javascript:submitAdd();' class='link'>[<?php
echo xlt('Add as New'); ?
>]</a
>
672 <table border
='0' cellpadding
='5' cellspacing
='0' width
='96%'>
676 <select name
='filter[]' multiple
='multiple'>
678 foreach ($code_types as $key => $value) {
679 echo "<option value='" . attr($value['id']) . "'";
680 if (isset($filter) && in_array($value['id'], $filter)) {
684 echo ">" . xlt($value['label']) . "</option>\n";
688  
; 
; 
; 
;
690 <input type
="text" name
="search" size
="5" value
="<?php echo attr($search) ?>"> 
;
691 <input type
="submit" name
="go" value
='<?php echo xla('Search
'); ?>'> 
; 
;
692 <input type
='checkbox' title
='<?php echo xla("Only Show Diagnosis Reporting Codes") ?>' name
='search_reportable' value
='1'<?php
if (!empty($search_reportable)) {
695 <?php
echo xlt('Diagnosis Reporting Only'); ?
>
696  
; 
; 
; 
;
697 <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)) {
700 <?php
echo xlt('Service Reporting Only'); ?
>
701 <input type
='hidden' name
='fstart' value
='<?php echo attr($fstart) ?>'>
704 <td
class='text' align
='right'>
705 <?php
if ($fstart) { ?
>
706 <a href
="javascript:submitList(<?php echo attr_js($pagesize); ?>)">
711 <?php
echo text(($fstart +
1)) . " - " . text($fend) . " of " . text($count); ?
>
713 <a href
="javascript:submitList(<?php echo attr_js($pagesize); ?>)">
723 <table border
='0' cellpadding
='5' cellspacing
='0' width
='96%'>
725 <td
><span
class='bold'><?php
echo xlt('Code'); ?
></span
></td
>
726 <td
><span
class='bold'><?php
echo xlt('Mod'); ?
></span
></td
>
727 <?php
if ($institutional) { ?
>
728 <td
><span
class='bold'><?php
echo xlt('Revenue'); ?
></span
></td
>
730 <td
><span
class='bold'><?php
echo xlt('Act'); ?
></span
></td
>
731 <td
><span
class='bold'><?php
echo xlt('Category'); ?
></span
></td
>
732 <td
><span
class='bold'><?php
echo xlt('Dx Rep'); ?
></span
></td
>
733 <td
><span
class='bold'><?php
echo xlt('Serv Rep'); ?
></span
></td
>
734 <td
><span
class='bold'><?php
echo xlt('Type'); ?
></span
></td
>
735 <td
><span
class='bold'><?php
echo xlt('Description'); ?
></span
></td
>
736 <td
><span
class='bold'><?php
echo xlt('Short Description'); ?
></span
></td
>
737 <?php
if (related_codes_are_used()) { ?
>
738 <td
><span
class='bold'><?php
echo xlt('Related'); ?
></span
></td
>
741 $pres = sqlStatement("SELECT title FROM list_options " .
742 "WHERE list_id = 'pricelevel' AND activity = 1 ORDER BY seq, title");
743 while ($prow = sqlFetchArray($pres)) {
744 echo " <td class='bold' align='right' nowrap>" . text(xl_list_label($prow['title'])) . "</td>\n";
752 if (isset($_REQUEST['filter'])) {
753 $res = main_code_set_search($filter_key, $search, null, null, false, null, false, $fstart, ($fend - $fstart), $filter_elements);
756 for ($i = 0; $row = sqlFetchArray($res);
763 foreach ($all as $iter) {
767 foreach ($code_types as $key => $value) {
768 if ($value['id'] == $iter['code_type']) {
769 $has_fees = $value['fee'];
775 echo " <td class='text'>" . text($iter["code"]) . "</td>\n";
776 echo " <td class='text'>" . text($iter["modifier"]) . "</td>\n";
777 if ($institutional) {
778 echo " <td class='text'>" . ($iter['revenue_code'] > '' ?
text($iter['revenue_code']) : 'none') ."</td>\n";
780 if ($iter["code_external"] > 0) {
781 // If there is no entry in codes sql table, then default to active
782 // (this is reason for including NULL below)
783 echo " <td class='text'>" . ( ($iter["active"] ||
$iter["active"]==null) ?
xlt('Yes') : xlt('No')) . "</td>\n";
785 echo " <td class='text'>" . ( ($iter["active"]) ?
xlt('Yes') : xlt('No')) . "</td>\n";
788 $sres = sqlStatement("SELECT title " .
789 "FROM list_options AS lo " .
790 "WHERE lo.list_id = 'superbill' AND lo.option_id = ?", array($iter['superbill']));
791 if ($srow = sqlFetchArray($sres)) {
792 echo " <td class='text'>" . text($srow['title']) . "</td>\n";
794 echo " <td class='text'>" . '' . "</td>\n";
796 echo " <td class='text'>" . ($iter["reportable"] ?
xlt('Yes') : xlt('No')) . "</td>\n";
797 echo " <td class='text'>" . ($iter["financial_reporting"] ?
xlt('Yes') : xlt('No')) . "</td>\n";
798 echo " <td class='text'>" . text($iter['code_type_name']) . "</td>\n";
799 echo " <td class='text'>" . text($iter['code_text']) . "</td>\n";
800 echo " <td class='text'>" . text($iter['code_text_short']) . "</td>\n";
802 if (related_codes_are_used()) {
803 // Show related codes.
804 echo " <td class='text'>";
805 $arel = explode(';', $iter['related_code']);
806 foreach ($arel as $tmp) {
807 list($reltype, $relcode) = explode(':', $tmp);
808 $code_description = lookup_code_descriptions($reltype.":".$relcode);
809 echo text($relcode) . ' ' . text(trim($code_description)) . '<br />';
815 $pres = sqlStatement("SELECT p.pr_price " .
816 "FROM list_options AS lo LEFT OUTER JOIN prices AS p ON " .
817 "p.pr_id = ? AND p.pr_selector = '' AND p.pr_level = lo.option_id " .
818 "WHERE lo.list_id = 'pricelevel' AND lo.activity = 1 ORDER BY lo.seq", array($iter['id']));
819 while ($prow = sqlFetchArray($pres)) {
820 echo "<td class='text' align='right'>" . text(bucks($prow['pr_price'])) . "</td>\n";
823 if ($thisauthwrite) {
824 if ($iter["code_external"] > 0) {
825 echo " <td align='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";
827 echo " <td align='right'><a class='link' href='javascript:submitDelete(" . attr_js($iter['id']) . ")'>[" . xlt('Delete') . "]</a></td>\n";
828 echo " <td align='right'><a class='link' href='javascript:submitEdit(" . attr_js($iter['id']) . ")'>[" . xlt('Edit') . "]</a></td>\n";
842 <script language
="JavaScript">
845 echo "alert(" . js_escape($alertmsg) . ");\n";