bug fixes in patient_files summary directory (#1964)
[openemr.git] / interface / patient_file / encounter / superbill_custom_full.php
blobe4b2611424d82a715a0f52c0ddd09fefd5e4cf64
1 <?php
2 /**
3 * Provides manual administration for codes
5 * @package OpenEMR
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");
20 // gacl control
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";
28 exit();
30 // For revenue codes
31 $institutional = $GLOBALS['ub04_support'] == "1" ? true : false;
33 // Translation for form fields.
34 function ffescape($field)
36 $field = add_escape_custom($field);
37 return trim($field);
40 // Format dollars for display.
42 function bucks($amount)
44 if ($amount) {
45 $amount = oeFormatMoney($amount);
46 return $amount;
49 return '';
52 $alertmsg = '';
53 $pagesize = 100;
54 $mode = $_POST['mode'];
55 $code_id = 0;
56 $related_code = '';
57 $active = 1;
58 $reportable = 0;
59 $financial_reporting = 0;
60 $revenue_code = '';
62 if (isset($mode) && $thisauthwrite) {
63 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
64 csrfNotVerified();
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'];
80 $taxrates = "";
81 if (!empty($_POST['taxrate'])) {
82 foreach ($_POST['taxrate'] as $key => $value) {
83 $taxrates .= "$key:";
87 if ($mode == "delete") {
88 sqlStatement("DELETE FROM codes WHERE id = ?", array($code_id));
89 $code_id = 0;
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) . "'");
96 if ($crow['count']) {
97 $alertmsg = xl('Cannot add/update this entry because a duplicate already exists!');
98 } else {
99 $sql =
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) . "' ";
112 if ($code_id) {
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));
117 } else {
118 $code_id = sqlInsert("INSERT INTO codes SET $sql");
121 if (!$alertmsg) {
122 foreach ($_POST['fee'] as $key => $value) {
123 $value = $value + 0;
124 if ($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 = "";
132 $code_id = 0;
133 $related_code = '';
134 $cyp_factor = 0;
135 $taxrates = '';
136 $active = 1;
137 $reportable = 0;
138 $revenue_code = '';
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)));
201 $code_name='';
203 if ($code_sql) {
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)));
211 $categorey_name='';
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'])
229 $related_desc = '';
230 if (!empty($related_code)) {
231 $related_desc = $related_code;
234 $fstart = $_REQUEST['fstart'] + 0;
235 if (isset($_REQUEST['filter'])) {
236 $filter = array();
237 $filter_key = array();
238 foreach ($_REQUEST['filter'] as $var) {
239 $var = $var+0;
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;
268 if ($fstart < 0) {
269 $fstart = 0;
272 $fend = $fstart + $pagesize;
273 if ($fend > $count) {
274 $fend = $count;
278 <html>
279 <head>
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>
289 <style>
290 .ui-autocomplete { max-height: 350px; max-width: 35%; overflow-y: auto; overflow-x: hidden; }
291 </style>
292 <script>
293 <?php if ($institutional) { ?>
294 $( function() {
295 var cache = {};
296 $( ".revcode" ).autocomplete({
297 minLength: 1,
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 ] );
303 return;
305 $.getJSON( "<?php echo $GLOBALS['web_root'] ?>/interface/billing/ub04_helpers.php", request, function( data, status, xhr ) {
306 cache[ term ] = data;
307 response( data );
310 }).dblclick(function(event) {
311 $(this).autocomplete('search'," ");
314 <?php } ?>
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;
321 if (code) {
322 if (s.length > 0) s += ';';
323 s += codetype + ':' + code;
324 } else {
325 s = '';
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;
348 var codetype = '';
349 if (i >= 0) {
350 var myid = f.code_type.options[i].value;
351 <?php
352 foreach ($code_types as $key => $value) {
353 $codeid = $value['id'];
354 $coderel = $value['rel'];
355 if (!$coderel) {
356 continue;
359 echo " if (myid == $codeid) codetype = '$coderel';";
363 if (!codetype) {
364 alert(<?php echo xlj('This code type does not accept relations.'); ?>);
365 return;
367 dlgopen('find_code_dynamic.php', '_blank', 900, 600);
370 // Some validation for saving a new code entry.
371 function validEntry(f) {
372 if (!f.code.value) {
373 alert(<?php echo xlj('No code was specified!'); ?>);
374 return false;
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!'); ?>);
379 return false;
381 <?php } ?>
382 return true;
385 function submitAdd() {
386 var f = document.forms[0];
387 if (!validEntry(f)) return;
388 f.mode.value = 'add';
389 f.code_id.value = '';
390 f.submit();
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!'); ?>);
397 return;
399 if (!validEntry(f)) return;
400 f.mode.value = 'add';
401 f.submit();
404 function submitModifyComplete() {
405 var f = document.forms[0];
406 f.mode.value = 'modify_complete';
407 f.submit();
410 function submitList(offset) {
411 var f = document.forms[0];
412 var i = parseInt(f.fstart.value) + offset;
413 if (i < 0) i = 0;
414 f.fstart.value = i;
415 f.submit();
418 function submitEdit(id) {
419 var f = document.forms[0];
420 f.mode.value = 'edit';
421 f.code_id.value = id;
422 f.submit();
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;
431 f.submit();
436 function submitDelete(id) {
437 var f = document.forms[0];
438 f.mode.value = 'delete';
439 f.code_id.value = id;
440 f.submit();
443 function getCTMask() {
444 var ctid = document.forms[0].code_type.value;
445 <?php
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";
452 return '';
455 </script>
457 </head>
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=''>
465 <br>
467 <center>
468 <table border='0' cellpadding='0' cellspacing='0'>
470 <tr>
471 <td colspan="3"> <?php echo xlt('Not all fields are required for all codes or code types.'); ?><br><br></td>
472 </tr>
474 <tr>
475 <td><?php echo xlt('Type'); ?>:</td>
476 <td width="5">
477 </td>
478 <td>
480 <?php if ($mode != "modify") { ?>
481 <select name="code_type">
482 <?php } ?>
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']) {
489 echo " selected";
490 } ?>><?php echo xlt($value['label']) ?></option>
491 <?php } ?>
492 <?php } ?>
493 <?php if ($value['external']) {
494 array_push($external_sets, $key);
495 } ?>
496 <?php } // end foreach ?>
498 <?php if ($mode != "modify") { ?>
499 </select>
500 <?php } ?>
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) ?>
505 <?php } ?>
507 &nbsp;&nbsp;
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) ?>' />
512 <?php } else { ?>
513 <input type='text' size='6' name='code' value='<?php echo attr($code) ?>'
514 onkeyup='maskkeyup(this,getCTMask())'
515 onblur='maskblur(this,getCTMask())'
517 <?php } ?>
519 <?php if (modifiers_are_used()) { ?>
520 &nbsp;&nbsp;<?php echo xlt('Modifier'); ?>:
521 <?php if ($mode == "modify") { ?>
522 <input type='text' size='6' name='modifier' readonly='readonly' value='<?php echo attr($modifier) ?>'>
523 <?php } else { ?>
524 <input type='text' size='6' name='modifier' value='<?php echo attr($modifier) ?>'>
525 <?php } ?>
526 <?php } else { ?>
527 <input type='hidden' name='modifier' value=''>
528 <?php } ?>
530 &nbsp;&nbsp;
531 <input type='checkbox' name='active' value='1'<?php if (!empty($active) || ($mode == 'modify' && $active == null)) {
532 echo ' checked';
533 } ?> />
534 <?php echo xlt('Active'); ?>
535 </td>
536 </tr>
538 <tr>
539 <td><?php echo xlt('Description'); ?>:</td>
540 <td></td>
541 <td>
542 <?php if ($mode == "modify") { ?>
543 <input type='text' size='50' name="code_text" readonly="readonly" value='<?php echo attr($code_text) ?>'>
544 <?php } else { ?>
545 <input type='text' size='50' name="code_text" value='<?php echo attr($code_text) ?>'>
546 <?php } ?>
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) ?>'>
551 <?php } else { ?>
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) ?>'>
553 <?php } ?>
554 <?php } ?>
555 </td>
556 </tr>
558 <tr>
559 <td><?php echo xlt('Category'); ?>:</td>
560 <td></td>
561 <td>
562 <?php
563 generate_form_field(array('data_type'=>1,'field_id'=>'superbill','list_id'=>'superbill'), $superbill);
565 &nbsp;&nbsp;
566 <input type='checkbox' title='<?php echo xla("Syndromic Surveillance Report") ?>' name='reportable' value='1'<?php if (!empty($reportable)) {
567 echo ' checked';
568 } ?> />
569 <?php echo xlt('Diagnosis Reporting'); ?>
570 &nbsp;&nbsp;&nbsp;&nbsp;
571 <input type='checkbox' title='<?php echo xla("Service Code Finance Reporting") ?>' name='financial_reporting' value='1'<?php if (!empty($financial_reporting)) {
572 echo ' checked';
573 } ?> />
574 <?php echo xlt('Service Reporting'); ?>
575 </td>
576 </tr>
578 <tr<?php if (empty($GLOBALS['ippf_specific'])) {
579 echo " style='display:none'";
580 } ?>>
581 <td><?php echo xlt('CYP Factor'); ?>:</td>
582 <td></td>
583 <td>
584 <input type='text' size='10' maxlength='20' name="cyp_factor" value='<?php echo attr($cyp_factor) ?>'>
585 </td>
586 </tr>
589 <tr<?php if (!related_codes_are_used()) {
590 echo " style='display:none'";
591 } ?>>
592 <td><?php echo xlt('Relate To'); ?>:</td>
593 <td></td>
594 <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) ?>' />
599 </td>
600 </tr>
602 <tr>
603 <td><?php echo xlt('Fees'); ?>:</td>
604 <td></td>
605 <td>
606 <?php
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) {
612 if ($i) {
613 echo "&nbsp;&nbsp;";
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";
621 </td>
622 </tr>
624 <?php
625 $taxline = '';
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)) {
629 if ($taxline) {
630 $taxline .= "&nbsp;&nbsp;";
633 $taxline .= "<input type='checkbox' name='taxrate[" . attr($prow['option_id']) . "]' value='1'";
634 if (strpos(":$taxrates", $prow['option_id']) !== false) {
635 $taxline .= " checked";
638 $taxline .= " />\n";
639 $taxline .= text(xl_list_label($prow['title'])) . "\n";
642 if ($taxline) {
644 <tr>
645 <td><?php echo xlt('Taxes'); ?>:</td>
646 <td></td>
647 <td>
648 <?php echo $taxline ?>
649 </td>
650 </tr>
651 <?php
652 } ?>
654 <tr>
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>
662 <?php } else { ?>
663 <a href='javascript:submitUpdate();' class='link'>[<?php echo xlt('Update'); ?>]</a>
664 &nbsp;&nbsp;
665 <a href='javascript:submitAdd();' class='link'>[<?php echo xlt('Add as New'); ?>]</a>
666 <?php } ?>
667 <?php } ?>
668 </td>
669 </tr>
670 </table>
671 <br>
672 <table border='0' cellpadding='5' cellspacing='0' width='96%'>
673 <tr>
675 <td class='text'>
676 <select name='filter[]' multiple='multiple'>
677 <?php
678 foreach ($code_types as $key => $value) {
679 echo "<option value='" . attr($value['id']) . "'";
680 if (isset($filter) && in_array($value['id'], $filter)) {
681 echo " selected";
684 echo ">" . xlt($value['label']) . "</option>\n";
687 </select>
688 &nbsp;&nbsp;&nbsp;&nbsp;
690 <input type="text" name="search" size="5" value="<?php echo attr($search) ?>">&nbsp;
691 <input type="submit" name="go" value='<?php echo xla('Search'); ?>'>&nbsp;&nbsp;
692 <input type='checkbox' title='<?php echo xla("Only Show Diagnosis Reporting Codes") ?>' name='search_reportable' value='1'<?php if (!empty($search_reportable)) {
693 echo ' checked';
694 } ?> />
695 <?php echo xlt('Diagnosis Reporting Only'); ?>
696 &nbsp;&nbsp;&nbsp;&nbsp;
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)) {
698 echo ' checked';
699 } ?> />
700 <?php echo xlt('Service Reporting Only'); ?>
701 <input type='hidden' name='fstart' value='<?php echo attr($fstart) ?>'>
702 </td>
704 <td class='text' align='right'>
705 <?php if ($fstart) { ?>
706 <a href="javascript:submitList(<?php echo attr_js($pagesize); ?>)">
707 &lt;&lt;
708 </a>
709 &nbsp;&nbsp;
710 <?php } ?>
711 <?php echo text(($fstart + 1)) . " - " . text($fend) . " of " . text($count); ?>
712 &nbsp;&nbsp;
713 <a href="javascript:submitList(<?php echo attr_js($pagesize); ?>)">
714 &gt;&gt;
715 </a>
716 </td>
718 </tr>
719 </table>
721 </form>
723 <table border='0' cellpadding='5' cellspacing='0' width='96%'>
724 <tr>
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>
729 <?php } ?>
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>
739 <?php } ?>
740 <?php
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";
747 <td></td>
748 <td></td>
749 </tr>
750 <?php
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);
757 $i++) {
758 $all[$i] = $row;
761 if (!empty($all)) {
762 $count = 0;
763 foreach ($all as $iter) {
764 $count++;
766 $has_fees = false;
767 foreach ($code_types as $key => $value) {
768 if ($value['id'] == $iter['code_type']) {
769 $has_fees = $value['fee'];
770 break;
774 echo " <tr>\n";
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";
784 } else {
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";
793 } else {
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 />';
812 echo "</td>\n";
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";
826 } else {
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";
832 echo " </tr>\n";
838 </table>
840 </center>
842 <script language="JavaScript">
843 <?php
844 if ($alertmsg) {
845 echo "alert(" . js_escape($alertmsg) . ");\n";
848 </script>
850 </body>
851 </html>