Multiple improvements from IPPF related to layouts. (#1081)
[openemr.git] / interface / patient_file / encounter / superbill_custom_full.php
blob017ee00e0bfd34feecf6cb619b6398aeed49586f
1 <?php
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
10 require_once("../../globals.php");
11 require_once("../../../custom/code_types.inc.php");
12 require_once("$srcdir/options.inc.php");
14 // gacl control
15 $thisauthview = acl_check('admin', 'superbill', false, 'view');
16 $thisauthwrite = acl_check('admin', 'superbill', false, 'write');
18 if (!($thisauthwrite || $thisauthview)) {
19 echo "<html>\n<body>\n";
20 echo "<p>" . xlt('You are not authorized for this.') . "</p>\n";
21 echo "</body>\n</html>\n";
22 exit();
24 // For revenue codes
25 $institutional = $GLOBALS['ub04_support'] == "1" ? true : false;
27 // Translation for form fields.
28 function ffescape($field)
30 $field = add_escape_custom($field);
31 return trim($field);
34 // Format dollars for display.
36 function bucks($amount)
38 if ($amount) {
39 $amount = oeFormatMoney($amount);
40 return $amount;
43 return '';
46 $alertmsg = '';
47 $pagesize = 100;
48 $mode = $_POST['mode'];
49 $code_id = 0;
50 $related_code = '';
51 $active = 1;
52 $reportable = 0;
53 $financial_reporting = 0;
54 $revenue_code = '';
56 if (isset($mode) && $thisauthwrite) {
57 $code_id = empty($_POST['code_id']) ? '' : $_POST['code_id'] + 0;
58 $code = $_POST['code'];
59 $code_type = $_POST['code_type'];
60 $code_text = $_POST['code_text'];
61 $modifier = $_POST['modifier'];
62 $superbill = $_POST['form_superbill'];
63 $related_code = $_POST['related_code'];
64 $cyp_factor = $_POST['cyp_factor'] + 0;
65 $active = empty($_POST['active']) ? 0 : 1;
66 $reportable = empty($_POST['reportable']) ? 0 : 1; // dx reporting
67 $financial_reporting = empty($_POST['financial_reporting']) ? 0 : 1; // financial service reporting
68 $revenue_code = $_POST['revenue_code'];
70 $taxrates = "";
71 if (!empty($_POST['taxrate'])) {
72 foreach ($_POST['taxrate'] as $key => $value) {
73 $taxrates .= "$key:";
77 if ($mode == "delete") {
78 sqlStatement("DELETE FROM codes WHERE id = ?", array($code_id));
79 $code_id = 0;
80 } else if ($mode == "add" || $mode == "modify_complete") { // this covers both adding and modifying
81 $crow = sqlQuery("SELECT COUNT(*) AS count FROM codes WHERE " .
82 "code_type = '" . ffescape($code_type) . "' AND " .
83 "code = '" . ffescape($code) . "' AND " .
84 "modifier = '" . ffescape($modifier) . "' AND " .
85 "id != '" . add_escape_custom($code_id) . "'");
86 if ($crow['count']) {
87 $alertmsg = xl('Cannot add/update this entry because a duplicate already exists!');
88 } else {
89 $sql =
90 "code = '" . ffescape($code) . "', " .
91 "code_type = '" . ffescape($code_type) . "', " .
92 "code_text = '" . ffescape($code_text) . "', " .
93 "modifier = '" . ffescape($modifier) . "', " .
94 "superbill = '" . ffescape($superbill) . "', " .
95 "related_code = '" . ffescape($related_code) . "', " .
96 "cyp_factor = '" . ffescape($cyp_factor) . "', " .
97 "taxrates = '" . ffescape($taxrates) . "', " .
98 "active = " . add_escape_custom($active) . ", " .
99 "financial_reporting = " . add_escape_custom($financial_reporting) . ", " .
100 "revenue_code = '" . ffescape($revenue_code) . "', " .
101 "reportable = " . add_escape_custom($reportable);
102 if ($code_id) {
103 $query = "UPDATE codes SET $sql WHERE id = ?";
104 sqlStatement($query, array($code_id));
105 sqlStatement("DELETE FROM prices WHERE pr_id = ? AND " .
106 "pr_selector = ''", array($code_id));
107 } else {
108 $code_id = sqlInsert("INSERT INTO codes SET $sql");
111 if (!$alertmsg) {
112 foreach ($_POST['fee'] as $key => $value) {
113 $value = $value + 0;
114 if ($value) {
115 sqlStatement("INSERT INTO prices ( " .
116 "pr_id, pr_selector, pr_level, pr_price ) VALUES ( " .
117 "?, '', ?, ?)", array($code_id,$key,$value));
121 $code = $code_type = $code_text = $modifier = $superbill = "";
122 $code_id = 0;
123 $related_code = '';
124 $cyp_factor = 0;
125 $taxrates = '';
126 $active = 1;
127 $reportable = 0;
128 $revenue_code = '';
131 } else if ($mode == "edit") { // someone clicked [Edit]
132 $sql = "SELECT * FROM codes WHERE id = ?";
133 $results = sqlStatement($sql, array($code_id));
134 while ($row = sqlFetchArray($results)) {
135 $code = $row['code'];
136 $code_text = $row['code_text'];
137 $code_type = $row['code_type'];
138 $modifier = $row['modifier'];
139 // $units = $row['units'];
140 $superbill = $row['superbill'];
141 $related_code = $row['related_code'];
142 $revenue_code = $row['revenue_code'];
143 $cyp_factor = $row['cyp_factor'];
144 $taxrates = $row['taxrates'];
145 $active = 0 + $row['active'];
146 $reportable = 0 + $row['reportable'];
147 $financial_reporting = 0 + $row['financial_reporting'];
149 } else if ($mode == "modify") { // someone clicked [Modify]
150 // this is to modify external code types, of which the modifications
151 // are stored in the codes table
152 $code_type_name_external = $_POST['code_type_name_external'];
153 $code_external = $_POST['code_external'];
154 $code_id = $_POST['code_id'];
155 $results = return_code_information($code_type_name_external, $code_external, false); // only will return one item
156 while ($row = sqlFetchArray($results)) {
157 $code = $row['code'];
158 $code_text = $row['code_text'];
159 $code_type = $code_types[$code_type_name_external]['id'];
160 $modifier = $row['modifier'];
161 // $units = $row['units'];
162 $superbill = $row['superbill'];
163 $related_code = $row['related_code'];
164 $revenue_code = $row['revenue_code'];
165 $cyp_factor = $row['cyp_factor'];
166 $taxrates = $row['taxrates'];
167 $active = $row['active'];
168 $reportable = $row['reportable'];
169 $financial_reporting = $row['financial_reporting'];
173 // If codes history is enabled in the billing globals save data to codes history table
174 if ($GLOBALS['save_codes_history'] && $alertmsg=='' &&
175 ( $mode == "add" || $mode == "modify_complete" || $mode == "delete" ) ) {
176 $action_type= empty($_POST['code_id']) ? 'new' : $mode;
177 $action_type= ($action_type=='add') ? 'update' : $action_type ;
178 $code = $_POST['code'];
179 $code_type = $_POST['code_type'];
180 $code_text = $_POST['code_text'];
181 $modifier = $_POST['modifier'];
182 $superbill = $_POST['form_superbill'];
183 $related_code = $_POST['related_code'];
184 $revenue_code = $_POST['revenue_code'];
185 $cyp_factor = $_POST['cyp_factor'] + 0;
186 $active = empty($_POST['active']) ? 0 : 1;
187 $reportable = empty($_POST['reportable']) ? 0 : 1; // dx reporting
188 $financial_reporting = empty($_POST['financial_reporting']) ? 0 : 1; // financial service reporting
189 $fee=json_encode($_POST['fee']);
190 $code_sql= sqlFetchArray(sqlStatement("SELECT (ct_label) FROM code_types WHERE ct_id=?", array($code_type)));
191 $code_name='';
193 if ($code_sql) {
194 $code_name=$code_sql['ct_label'];
197 $categorey_id= $_POST['form_superbill'];
198 $categorey_sql=sqlFetchArray(sqlStatement("SELECT (title ) FROM list_options WHERE list_id='superbill'".
199 " AND option_id=?", array($categorey_id)));
201 $categorey_name='';
203 if ($categorey_sql) {
204 $categorey_name=$categorey_sql['title'];
207 $date=date('Y-m-d H:i:s');
208 $date=oeFormatShortDate($date);
209 $results = sqlStatement(
210 "INSERT INTO codes_history ( " .
211 "date, code, modifier, active,diagnosis_reporting,financial_reporting,category,code_type_name,".
212 "code_text,code_text_short,prices,action_type, update_by ) VALUES ( " .
213 "?, ?,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,?)",
214 array($date,$code,$modifier,$active,$reportable,$financial_reporting,$categorey_name,$code_name,$code_text,'',$fee,$action_type,$_SESSION['authUser'])
219 $related_desc = '';
220 if (!empty($related_code)) {
221 $related_desc = $related_code;
224 $fstart = $_REQUEST['fstart'] + 0;
225 if (isset($_REQUEST['filter'])) {
226 $filter = array();
227 $filter_key = array();
228 foreach ($_REQUEST['filter'] as $var) {
229 $var = $var+0;
230 array_push($filter, $var);
231 $var_key = convert_type_id_to_key($var);
232 array_push($filter_key, $var_key);
236 $search = $_REQUEST['search'];
237 $search_reportable = $_REQUEST['search_reportable'];
238 $search_financial_reporting = $_REQUEST['search_financial_reporting'];
240 //Build the filter_elements array
241 $filter_elements = array();
242 if (!empty($search_reportable)) {
243 $filter_elements['reportable'] = $search_reportable;
246 if (!empty($search_financial_reporting)) {
247 $filter_elements['financial_reporting'] = $search_financial_reporting;
250 if (isset($_REQUEST['filter'])) {
251 $count = main_code_set_search($filter_key, $search, null, null, false, null, true, null, null, $filter_elements);
254 if ($fstart >= $count) {
255 $fstart -= $pagesize;
258 if ($fstart < 0) {
259 $fstart = 0;
262 $fend = $fstart + $pagesize;
263 if ($fend > $count) {
264 $fend = $count;
268 <html>
269 <head>
270 <title><?php echo xlt("Codes"); ?></title>
271 <?php html_header_show(); ?>
273 <link rel="stylesheet" href="<?php echo attr($css_header);?>" type="text/css">
274 <script type="text/javascript" src="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
275 <script type="text/javascript" src="../../../library/textformat.js"></script>
276 <script type="text/JavaScript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script>
277 <link href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-ui-1-12-1/themes/base/jquery-ui.min.css" rel="stylesheet" type="text/css" />
278 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative'] ?>/jquery-ui-1-12-1/jquery-ui.min.js"></script>
279 <style>
280 .ui-autocomplete { max-height: 350px; max-width: 35%; overflow-y: auto; overflow-x: hidden; }
281 </style>
282 <script>
283 <?php if ($institutional) { ?>
284 $( function() {
285 var cache = {};
286 $( ".revcode" ).autocomplete({
287 minLength: 1,
288 source: function( request, response ) {
289 var term = request.term;
290 request.code_group = "revenue_code";
291 if ( term in cache ) {
292 response( cache[ term ] );
293 return;
295 $.getJSON( "<?php echo $GLOBALS['web_root'] ?>/interface/billing/ub04_helpers.php", request, function( data, status, xhr ) {
296 cache[ term ] = data;
297 response( data );
300 }).dblclick(function(event) {
301 $(this).autocomplete('search'," ");
304 <?php } ?>
306 // This is for callback by the find-code popup.
307 // Appends to or erases the current list of related codes.
308 function set_related(codetype, code, selector, codedesc) {
309 var f = document.forms[0];
310 var s = f.related_code.value;
311 if (code) {
312 if (s.length > 0) s += ';';
313 s += codetype + ':' + code;
314 } else {
315 s = '';
317 f.related_code.value = s;
318 f.related_desc.value = s;
321 // This invokes the find-code popup.
322 function sel_related() {
323 var f = document.forms[0];
324 var i = f.code_type.selectedIndex;
325 var codetype = '';
326 if (i >= 0) {
327 var myid = f.code_type.options[i].value;
328 <?php
329 foreach ($code_types as $key => $value) {
330 $codeid = $value['id'];
331 $coderel = $value['rel'];
332 if (!$coderel) {
333 continue;
336 echo " if (myid == $codeid) codetype = '$coderel';";
340 if (!codetype) {
341 alert('<?php echo addslashes(xl('This code type does not accept relations.')); ?>');
342 return;
344 dlgopen('find_code_popup.php', '_blank', 500, 400);
347 // Some validation for saving a new code entry.
348 function validEntry(f) {
349 if (!f.code.value) {
350 alert('<?php echo addslashes(xl('No code was specified!')); ?>');
351 return false;
353 <?php if ($GLOBALS['ippf_specific']) { ?>
354 if (f.code_type.value == 12 && !f.related_code.value) {
355 alert('<?php echo addslashes(xl('A related IPPF code is required!')); ?>');
356 return false;
358 <?php } ?>
359 return true;
362 function submitAdd() {
363 var f = document.forms[0];
364 if (!validEntry(f)) return;
365 f.mode.value = 'add';
366 f.code_id.value = '';
367 f.submit();
370 function submitUpdate() {
371 var f = document.forms[0];
372 if (! parseInt(f.code_id.value)) {
373 alert('<?php echo addslashes(xl('Cannot update because you are not editing an existing entry!')); ?>');
374 return;
376 if (!validEntry(f)) return;
377 f.mode.value = 'add';
378 f.submit();
381 function submitModifyComplete() {
382 var f = document.forms[0];
383 f.mode.value = 'modify_complete';
384 f.submit();
387 function submitList(offset) {
388 var f = document.forms[0];
389 var i = parseInt(f.fstart.value) + offset;
390 if (i < 0) i = 0;
391 f.fstart.value = i;
392 f.submit();
395 function submitEdit(id) {
396 var f = document.forms[0];
397 f.mode.value = 'edit';
398 f.code_id.value = id;
399 f.submit();
402 function submitModify(code_type_name,code,id) {
403 var f = document.forms[0];
404 f.mode.value = 'modify';
405 f.code_external.value = code;
406 f.code_id.value = id;
407 f.code_type_name_external.value = code_type_name;
408 f.submit();
413 function submitDelete(id) {
414 var f = document.forms[0];
415 f.mode.value = 'delete';
416 f.code_id.value = id;
417 f.submit();
420 function getCTMask() {
421 var ctid = document.forms[0].code_type.value;
422 <?php
423 foreach ($code_types as $key => $value) {
424 $ctid = attr($value['id']);
425 $ctmask = attr($value['mask']);
426 echo " if (ctid == '$ctid') return '$ctmask';\n";
429 return '';
432 </script>
434 </head>
435 <body class="body_top" >
437 <form method='post' action='superbill_custom_full.php' name='theform'>
439 <input type='hidden' name='mode' value=''>
441 <br>
443 <center>
444 <table border='0' cellpadding='0' cellspacing='0'>
446 <tr>
447 <td colspan="3"> <?php echo xlt('Not all fields are required for all codes or code types.'); ?><br><br></td>
448 </tr>
450 <tr>
451 <td><?php echo xlt('Type'); ?>:</td>
452 <td width="5">
453 </td>
454 <td>
456 <?php if ($mode != "modify") { ?>
457 <select name="code_type">
458 <?php } ?>
460 <?php $external_sets = array(); ?>
461 <?php foreach ($code_types as $key => $value) { ?>
462 <?php if (!($value['external'])) { ?>
463 <?php if ($mode != "modify") { ?>
464 <option value="<?php echo attr($value['id']) ?>"<?php if ($code_type == $value['id']) {
465 echo " selected";
466 } ?>><?php echo xlt($value['label']) ?></option>
467 <?php } ?>
468 <?php } ?>
469 <?php if ($value['external']) {
470 array_push($external_sets, $key);
471 } ?>
472 <?php } // end foreach ?>
474 <?php if ($mode != "modify") { ?>
475 </select>
476 <?php } ?>
478 <?php if ($mode == "modify") { ?>
479 <input type='text' size='4' name='code_type' readonly='readonly' style='display:none' value='<?php echo attr($code_type) ?>' />
480 <?php echo attr($code_type_name_external) ?>
481 <?php } ?>
483 &nbsp;&nbsp;
484 <?php echo xlt('Code'); ?>:
486 <?php if ($mode == "modify") { ?>
487 <input type='text' size='6' name='code' readonly='readonly' value='<?php echo attr($code) ?>' />
488 <?php } else { ?>
489 <input type='text' size='6' name='code' value='<?php echo attr($code) ?>'
490 onkeyup='maskkeyup(this,getCTMask())'
491 onblur='maskblur(this,getCTMask())'
493 <?php } ?>
495 <?php if (modifiers_are_used()) { ?>
496 &nbsp;&nbsp;<?php echo xlt('Modifier'); ?>:
497 <?php if ($mode == "modify") { ?>
498 <input type='text' size='6' name='modifier' readonly='readonly' value='<?php echo attr($modifier) ?>'>
499 <?php } else { ?>
500 <input type='text' size='6' name='modifier' value='<?php echo attr($modifier) ?>'>
501 <?php } ?>
502 <?php } else { ?>
503 <input type='hidden' name='modifier' value=''>
504 <?php } ?>
506 &nbsp;&nbsp;
507 <input type='checkbox' name='active' value='1'<?php if (!empty($active) || ($mode == 'modify' && $active == null)) {
508 echo ' checked';
509 } ?> />
510 <?php echo xlt('Active'); ?>
511 </td>
512 </tr>
514 <tr>
515 <td><?php echo xlt('Description'); ?>:</td>
516 <td></td>
517 <td>
518 <?php if ($mode == "modify") { ?>
519 <input type='text' size='50' name="code_text" readonly="readonly" value='<?php echo attr($code_text) ?>'>
520 <?php } else { ?>
521 <input type='text' size='50' name="code_text" value='<?php echo attr($code_text) ?>'>
522 <?php } ?>
523 <?php if ($institutional) { ?>
524 <?php echo xlt('Revenue Code'); ?>:
525 <?php if ($mode == "modify") { ?>
526 <input type='text' size='6' name="revenue_code" readonly="readonly" value='<?php echo attr($revenue_code) ?>'>
527 <?php } else { ?>
528 <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) ?>'>
529 <?php } ?>
530 <?php } ?>
531 </td>
532 </tr>
534 <tr>
535 <td><?php echo xlt('Category'); ?>:</td>
536 <td></td>
537 <td>
538 <?php
539 generate_form_field(array('data_type'=>1,'field_id'=>'superbill','list_id'=>'superbill'), $superbill);
541 &nbsp;&nbsp;
542 <input type='checkbox' title='<?php echo xlt("Syndromic Surveillance Report") ?>' name='reportable' value='1'<?php if (!empty($reportable)) {
543 echo ' checked';
544 } ?> />
545 <?php echo xlt('Diagnosis Reporting'); ?>
546 &nbsp;&nbsp;&nbsp;&nbsp;
547 <input type='checkbox' title='<?php echo xlt("Service Code Finance Reporting") ?>' name='financial_reporting' value='1'<?php if (!empty($financial_reporting)) {
548 echo ' checked';
549 } ?> />
550 <?php echo xlt('Service Reporting'); ?>
551 </td>
552 </tr>
554 <tr<?php if (empty($GLOBALS['ippf_specific'])) {
555 echo " style='display:none'";
556 } ?>>
557 <td><?php echo xlt('CYP Factor'); ?>:</td>
558 <td></td>
559 <td>
560 <input type='text' size='10' maxlength='20' name="cyp_factor" value='<?php echo attr($cyp_factor) ?>'>
561 </td>
562 </tr>
565 <tr<?php if (!related_codes_are_used()) {
566 echo " style='display:none'";
567 } ?>>
568 <td><?php echo xlt('Relate To'); ?>:</td>
569 <td></td>
570 <td>
571 <input type='text' size='50' name='related_desc'
572 value='<?php echo attr($related_desc) ?>' onclick="sel_related()"
573 title='<?php echo xla('Click to select related code'); ?>' readonly />
574 <input type='hidden' name='related_code' value='<?php echo attr($related_code) ?>' />
575 </td>
576 </tr>
578 <tr>
579 <td><?php echo xlt('Fees'); ?>:</td>
580 <td></td>
581 <td>
582 <?php
583 $pres = sqlStatement("SELECT lo.option_id, lo.title, p.pr_price " .
584 "FROM list_options AS lo LEFT OUTER JOIN prices AS p ON " .
585 "p.pr_id = ? AND p.pr_selector = '' AND p.pr_level = lo.option_id " .
586 "WHERE lo.list_id = 'pricelevel' AND lo.activity = 1 ORDER BY lo.seq, lo.title", array($code_id));
587 for ($i = 0; $prow = sqlFetchArray($pres); ++$i) {
588 if ($i) {
589 echo "&nbsp;&nbsp;";
592 echo text(xl_list_label($prow['title'])) . " ";
593 echo "<input type='text' size='6' name='fee[" . attr($prow['option_id']) . "]' " .
594 "value='" . attr($prow['pr_price']) . "' >\n";
597 </td>
598 </tr>
600 <?php
601 $taxline = '';
602 $pres = sqlStatement("SELECT option_id, title FROM list_options " .
603 "WHERE list_id = 'taxrate' AND activity = 1 ORDER BY seq");
604 while ($prow = sqlFetchArray($pres)) {
605 if ($taxline) {
606 $taxline .= "&nbsp;&nbsp;";
609 $taxline .= "<input type='checkbox' name='taxrate[" . attr($prow['option_id']) . "]' value='1'";
610 if (strpos(":$taxrates", $prow['option_id']) !== false) {
611 $taxline .= " checked";
614 $taxline .= " />\n";
615 $taxline .= text(xl_list_label($prow['title'])) . "\n";
618 if ($taxline) {
620 <tr>
621 <td><?php echo xlt('Taxes'); ?>:</td>
622 <td></td>
623 <td>
624 <?php echo $taxline ?>
625 </td>
626 </tr>
627 <?php
628 } ?>
630 <tr>
631 <td colspan="3" align="center">
632 <input type="hidden" name="code_id" value="<?php echo attr($code_id) ?>"><br>
633 <input type="hidden" name="code_type_name_external" value="<?php echo attr($code_type_name_external) ?>">
634 <input type="hidden" name="code_external" value="<?php echo attr($code_external) ?>">
635 <?php if ($thisauthwrite) { ?>
636 <?php if ($mode == "modify") { ?>
637 <a href='javascript:submitModifyComplete();' class='link'>[<?php echo xlt('Update'); ?>]</a>
638 <?php } else { ?>
639 <a href='javascript:submitUpdate();' class='link'>[<?php echo xlt('Update'); ?>]</a>
640 &nbsp;&nbsp;
641 <a href='javascript:submitAdd();' class='link'>[<?php echo xlt('Add as New'); ?>]</a>
642 <?php } ?>
643 <?php } ?>
644 </td>
645 </tr>
646 </table>
647 <br>
648 <table border='0' cellpadding='5' cellspacing='0' width='96%'>
649 <tr>
651 <td class='text'>
652 <select name='filter[]' multiple='multiple'>
653 <?php
654 foreach ($code_types as $key => $value) {
655 echo "<option value='" . attr($value['id']) . "'";
656 if (isset($filter) && in_array($value['id'], $filter)) {
657 echo " selected";
660 echo ">" . xlt($value['label']) . "</option>\n";
663 </select>
664 &nbsp;&nbsp;&nbsp;&nbsp;
666 <input type="text" name="search" size="5" value="<?php echo attr($search) ?>">&nbsp;
667 <input type="submit" name="go" value='<?php echo xla('Search'); ?>'>&nbsp;&nbsp;
668 <input type='checkbox' title='<?php echo xlt("Only Show Diagnosis Reporting Codes") ?>' name='search_reportable' value='1'<?php if (!empty($search_reportable)) {
669 echo ' checked';
670 } ?> />
671 <?php echo xlt('Diagnosis Reporting Only'); ?>
672 &nbsp;&nbsp;&nbsp;&nbsp;
673 <input type='checkbox' title='<?php echo xlt("Only Show Service Code Finance Reporting Codes") ?>' name='search_financial_reporting' value='1'<?php if (!empty($search_financial_reporting)) {
674 echo ' checked';
675 } ?> />
676 <?php echo xlt('Service Reporting Only'); ?>
677 <input type='hidden' name='fstart' value='<?php echo attr($fstart) ?>'>
678 </td>
680 <td class='text' align='right'>
681 <?php if ($fstart) { ?>
682 <a href="javascript:submitList(<?php echo attr($pagesize) ?>)">
683 &lt;&lt;
684 </a>
685 &nbsp;&nbsp;
686 <?php } ?>
687 <?php echo ($fstart + 1) . " - $fend of $count" ?>
688 &nbsp;&nbsp;
689 <a href="javascript:submitList(<?php echo attr($pagesize) ?>)">
690 &gt;&gt;
691 </a>
692 </td>
694 </tr>
695 </table>
697 </form>
699 <table border='0' cellpadding='5' cellspacing='0' width='96%'>
700 <tr>
701 <td><span class='bold'><?php echo xlt('Code'); ?></span></td>
702 <td><span class='bold'><?php echo xlt('Mod'); ?></span></td>
703 <?php if ($institutional) { ?>
704 <td><span class='bold'><?php echo xlt('Revenue'); ?></span></td>
705 <?php } ?>
706 <td><span class='bold'><?php echo xlt('Act'); ?></span></td>
707 <td><span class='bold'><?php echo xlt('Dx Rep'); ?></span></td>
708 <td><span class='bold'><?php echo xlt('Serv Rep'); ?></span></td>
709 <td><span class='bold'><?php echo xlt('Type'); ?></span></td>
710 <td><span class='bold'><?php echo xlt('Description'); ?></span></td>
711 <td><span class='bold'><?php echo xlt('Short Description'); ?></span></td>
712 <?php if (related_codes_are_used()) { ?>
713 <td><span class='bold'><?php echo xlt('Related'); ?></span></td>
714 <?php } ?>
715 <?php
716 $pres = sqlStatement("SELECT title FROM list_options " .
717 "WHERE list_id = 'pricelevel' AND activity = 1 ORDER BY seq, title");
718 while ($prow = sqlFetchArray($pres)) {
719 echo " <td class='bold' align='right' nowrap>" . text(xl_list_label($prow['title'])) . "</td>\n";
722 <td></td>
723 <td></td>
724 </tr>
725 <?php
727 if (isset($_REQUEST['filter'])) {
728 $res = main_code_set_search($filter_key, $search, null, null, false, null, false, $fstart, ($fend - $fstart), $filter_elements);
731 for ($i = 0; $row = sqlFetchArray($res);
732 $i++) {
733 $all[$i] = $row;
736 if (!empty($all)) {
737 $count = 0;
738 foreach ($all as $iter) {
739 $count++;
741 $has_fees = false;
742 foreach ($code_types as $key => $value) {
743 if ($value['id'] == $iter['code_type']) {
744 $has_fees = $value['fee'];
745 break;
749 echo " <tr>\n";
750 echo " <td class='text'>" . text($iter["code"]) . "</td>\n";
751 echo " <td class='text'>" . text($iter["modifier"]) . "</td>\n";
752 if ($institutional) {
753 echo " <td class='text'>" . ($iter['revenue_code'] > '' ? text($iter['revenue_code']) : 'none') ."</td>\n";
755 if ($iter["code_external"] > 0) {
756 // If there is no entry in codes sql table, then default to active
757 // (this is reason for including NULL below)
758 echo " <td class='text'>" . ( ($iter["active"] || $iter["active"]==null) ? xlt('Yes') : xlt('No')) . "</td>\n";
759 } else {
760 echo " <td class='text'>" . ( ($iter["active"]) ? xlt('Yes') : xlt('No')) . "</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()) {
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 />';
779 echo "</td>\n";
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' align='right'>" . text(bucks($prow['pr_price'])) . "</td>\n";
790 if ($thisauthwrite) {
791 if ($iter["code_external"] > 0) {
792 echo " <td align='right'><a class='link' href='javascript:submitModify(\"" . attr($iter['code_type_name']) . "\",\"" . attr($iter['code']) . "\",\"" . attr($iter['id']) . "\")'>[" . xlt('Modify') . "]</a></td>\n";
793 } else {
794 echo " <td align='right'><a class='link' href='javascript:submitDelete(" . attr($iter['id']) . ")'>[" . xlt('Delete') . "]</a></td>\n";
795 echo " <td align='right'><a class='link' href='javascript:submitEdit(" . attr($iter['id']) . ")'>[" . xlt('Edit') . "]</a></td>\n";
799 echo " </tr>\n";
805 </table>
807 </center>
809 <script language="JavaScript">
810 <?php
811 if ($alertmsg) {
812 echo "alert('" . addslashes($alertmsg) . "');\n";
815 </script>
817 </body>
818 </html>