fixes for new frame layout
[openemr.git] / interface / billing / billing_report.php
blob73cb653104762e8a1cce9f21c15f4cbbd15ff2f5
1 <?php
2 include_once("../globals.php");
3 include_once("../../library/acl.inc");
4 include_once("../../custom/code_types.inc.php");
6 include_once("$srcdir/patient.inc");
7 include_once("$srcdir/billrep.inc");
8 include_once(dirname(__FILE__) . "/../../library/classes/OFX.class.php");
9 include_once(dirname(__FILE__) . "/../../library/classes/X12Partner.class.php");
11 $EXPORT_INC = "$webserver_root/custom/BillingExport.php";
13 $alertmsg = '';
15 if ($_POST['mode'] == 'export') {
16 $sdate = $_POST['from_date'];
17 $edate = $_POST['to_date'];
19 $sql = "SELECT billing.*, concat(pd.fname, ' ', pd.lname) as name from billing "
20 . "join patient_data as pd on pd.pid = billing.pid where billed = '1' and "
21 . "(process_date > '" . mysql_real_escape_string($sdate)
22 . "' or DATE_FORMAT( process_date, '%Y-%m-%d' ) = '" . mysql_real_escape_string($sdate) ."') "
23 . "and (process_date < '" . mysql_real_escape_string($edate)
24 . "'or DATE_FORMAT( process_date, '%Y-%m-%d' ) = '" . mysql_real_escape_string($edate) ."') "
25 . "order by pid,encounter";
26 $db = get_db();
27 $results = $db->Execute($sql);
28 $billings = array();
29 if ($results->RecordCount() == 0) {
30 echo xl("No Bills Found to Include in OFX Export<br>");
32 else {
33 while(!$results->EOF) {
34 $billings[] = $results->fields;
35 $results->MoveNext();
37 $ofx = new OFX($billings);
38 header("Pragma: public");
39 header("Expires: 0");
40 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
41 header("Content-Disposition: attachment; filename=openemr_ofx.ofx");
42 header("Content-Type: text/xml");
43 echo $ofx->get_OFX();
44 exit;
48 if ($_POST['mode'] == 'process') {
49 if (exec("ps x | grep 'process_bills[.]php'")) {
50 $alertmsg = xl('Request ignored - claims processing is already running!');
52 else {
53 exec("cd $webserver_root/library/freeb;" .
54 "php -q process_bills.php bill > process_bills.log 2>&1 &");
55 $alertmsg = xl('Batch processing initiated; this may take a while.');
59 //global variables:
60 if (!isset($_POST["mode"])) {
61 if (!isset($_POST["from_date"])) {
62 $from_date=date("Y-m-d");
63 } else {
64 $from_date = $_POST["from_date"];
66 if (!isset($_POST["to_date"])) {
67 $to_date = date("Y-m-d");
68 } else {
69 $to_date = $_POST["to_date"];
71 if (!isset($_POST["code_type"])) {
72 $code_type="all";
73 } else {
74 $code_type = $_POST["code_type"];
76 if (!isset($_POST["unbilled"])) {
77 $unbilled = "on";
78 } else {
79 $unbilled = $_POST["unbilled"];
81 if (!isset($_POST["authorized"])) {
82 $my_authorized = "on";
83 } else {
84 $my_authorized = $_POST["authorized"];
86 } else {
87 $from_date = $_POST["from_date"];
88 $to_date = $_POST["to_date"];
89 $code_type = $_POST["code_type"];
90 $unbilled = $_POST["unbilled"];
91 $my_authorized = $_POST["authorized"];
94 $ofrom_date = $from_date;
95 $oto_date = $to_date;
96 $ocode_type = $code_type;
97 $ounbilled = $unbilled;
98 $oauthorized = $my_authorized;
102 <html>
103 <head>
104 <link rel=stylesheet href="<?php echo $css_header; ?>" type="text/css">
105 <style>
106 .subbtn { margin-top:3px; margin-bottom:3px; margin-left:2px; margin-right:2px }
107 </style>
108 <script>
110 function select_all() {
111 for($i=0;$i < document.update_form.length;$i++) {
112 $name = document.update_form[$i].name;
113 if ($name.substring(0,7) == "claims[" && $name.substring($name.length -6) == "[bill]") {
114 document.update_form[$i].checked = true;
117 set_button_states();
120 function set_button_states() {
121 var f = document.update_form;
122 var count0 = 0;
123 var count1 = 0;
124 var count2 = 0;
125 for($i = 0; $i < f.length; ++$i) {
126 $name = f[$i].name;
127 if ($name.substring(0, 7) == "claims[" && $name.substring($name.length -6) == "[bill]" && f[$i].checked == true) {
128 if (f[$i].value == '0') ++count0;
129 else if (f[$i].value == '1' || f[$i].value == '5') ++count1;
130 else ++count2;
134 var can_generate = (count0 > 0 || count1 > 0 || count2 > 0);
135 var can_mark = (count1 == 0 && (count0 > 0 || count2 > 0));
136 var can_bill = (count0 == 0 && count1 == 0 && count2 > 0);
138 <?php if (file_exists($EXPORT_INC)) { ?>
139 f.bn_external.disabled = !can_generate;
140 <?php } else { ?>
141 f.bn_hcfa_print.disabled = !can_generate;
142 f.bn_hcfa.disabled = !can_generate;
143 f.bn_ub92_print.disabled = !can_generate;
144 f.bn_ub92.disabled = !can_generate;
145 f.bn_x12.disabled = !can_generate;
146 f.bn_electronic_file.disabled = !can_bill;
147 <?php } ?>
148 f.bn_mark.disabled = !can_mark;
151 // Process a click to go to an encounter.
152 function toencounter(pid, pname, enc, datestr) {
153 <?php if ($GLOBALS['concurrent_layout']) { ?>
154 var othername = (window.name == 'RTop') ? 'RBot' : 'RTop';
155 parent.left_nav.setPatient(pname,pid,'');
156 parent.left_nav.setEncounter(datestr, enc, othername);
157 parent.left_nav.setRadio(othername, 'enc');
158 parent.frames[othername].location.href =
159 '../patient_file/encounter/encounter_top.php?set_encounter='
160 + enc + '&pid=' + pid;
161 <?php } else { ?>
162 location.href = '../patient_file/encounter/patient_encounter.php?set_encounter='
163 + enc + '&pid=' + pid;
164 <?php } ?>
167 // Process a click to go to patient demographics.
168 function topatient(pid) {
169 <?php if ($GLOBALS['concurrent_layout']) { ?>
170 var othername = (window.name == 'RTop') ? 'RBot' : 'RTop';
171 parent.frames[othername].location.href =
172 '../patient_file/summary/demographics_full.php?pid=' + pid;
173 <?php } else { ?>
174 location.href = '../patient_file/summary/demographics_full.php?pid=' + pid;
175 <?php } ?>
178 </script>
179 </head>
180 <body <?php echo $top_bg_line; ?> topmargin=0 rightmargin=0 leftmargin=2 bottommargin=0 marginwidth=2 marginheight=0>
182 <p style='margin-top:5px;margin-bottom:5px;margin-left:5px'>
183 <?php if ($GLOBALS['concurrent_layout']) { ?>
184 <font class='title'><?php xl('Billing Report','e') ?></font>
185 <?php } else if ($userauthorized) { ?>
186 <a href="../main/main.php" target=Main><font class=title><?php xl('Billing Report','e') ?></font><font class=more> <?php echo $tback; ?></font></a>
187 <?php } else { ?>
188 <a href="../main/onotes/office_comments.php" target=Main><font class=title><?php xl('Billing Report','e') ?></font><font class=more><?php echo $tback; ?></font></a>
189 <?php } ?>
190 </p>
192 <form name=the_form method=post action=billing_report.php>
194 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
195 <script type="text/javascript" src="../../library/dialog.js"></script>
196 <script type="text/javascript" src="../../library/textformat.js"></script>
197 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
198 <script type="text/javascript" src="../../library/dynarch_calendar_en.js"></script>
199 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
200 <script language='JavaScript'>
201 var mypcc = '1';
202 </script>
204 <input type=hidden name=mode value="change">
205 <table width=100% border="1" cellspacing="0" cellpadding="0">
207 <tr>
209 <td nowrap>
210 &nbsp;<span class=text><?php xl('From: ','e') ?></span>
211 <input type='text' size='10' name='from_date' id='from_date'
212 value='<?php echo $from_date; ?>'
213 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
214 title='yyyy-mm-dd last date of this event' />
215 <img src='../../interface/pic/show_calendar.gif' align='absbottom' width='24' height='22'
216 id='img_fromdate' border='0' alt='[?]' style='cursor:pointer'
217 title='Click here to choose a date'>
218 <script>
219 Calendar.setup({inputField:"from_date", ifFormat:"%Y-%m-%d", button:"img_fromdate"});
220 </script>
221 </td>
223 <td nowrap>
224 &nbsp;<span class=text><?php xl('To: ','e') ?></span>
225 <input type='text' size='10' name='to_date' id='to_date'
226 value='<?php echo $to_date; ?>'
227 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
228 title='yyyy-mm-dd last date of this event' />
229 <img src='../../interface/pic/show_calendar.gif' align='absbottom' width='24' height='22'
230 id='img_todate' border='0' alt='[?]' style='cursor:pointer'
231 title='Click here to choose a date'>
232 <script>
233 Calendar.setup({inputField:"to_date", ifFormat:"%Y-%m-%d", button:"img_todate"});
234 </script>
235 </td>
237 <input type="hidden" name="code_type" value="%"></td>
238 <td nowrap><input type=checkbox name=unbilled <?php if ($unbilled == "on") {echo "checked";}; ?>><span class=text><?php xl('Show Unbilled Only','e') ?></span></td>
239 <td nowrap><input type=checkbox name=authorized <?php if ($my_authorized == "on") {echo "checked";}; ?>><span class=text><?php xl('Show Authorized Only','e') ?></span></td>
240 <td align='right' width='10%' nowrap>
241 &nbsp;<span class=text><a href="javascript:document.the_form.mode.value='change';document.the_form.submit()" class=link_submit><?php xl('[Change View]','e') ?></a>
243 <a href="javascript:document.the_form.mode.value='export';document.the_form.submit()" class=link_submit><?php xl('[Export OFX]','e') ?></a></span>&nbsp;
244 </td>
245 </tr>
246 <tr>
247 <td nowrap>&nbsp;<a href="print_billing_report.php?<?php print "from_date=".urlencode($ofrom_date)."&to_date=".urlencode($oto_date)."&code_type=".urlencode($ocode_type)."&unbilled=".urlencode($ounbilled)."&authorized=".urlencode($oauthorized); ?>" class=link_submit target=new><?php xl('[View Printable Report]','e') ?></a></td>
248 <td nowrap>
249 <?php
250 print '&nbsp;';
251 $acct_config = $GLOBALS['oer_config']['ws_accounting'];
252 if($acct_config['enabled'] == true) {
253 print '<span class=text><a href="javascript:void window.open(\'' . $acct_config['url_path'] . '\')">' . xl("[SQL-Ledger]") . '</a></span>';
254 if (acl_check('acct', 'rep')) {
255 print '<span class=text> &nbsp; <a href="javascript:void window.open(\'sl_receipts_report.php\')">' . xl('[Reports]') . '</a></span>';
257 if (acl_check('acct', 'eob')) {
258 print '<span class=text> &nbsp; <a href="javascript:void window.open(\'sl_eob_search.php\')">' . xl('[EOBs]') . '</a></span>';
262 </td>
263 <td colspan='2' nowrap>
264 &nbsp;
265 <?php if (! file_exists($EXPORT_INC)) { ?>
266 <a href="javascript:document.the_form.mode.value='process';document.the_form.submit()" class="link_submit"
267 title="Process all queued bills to create electronic data (and print if requested)"><?php xl('[Start Batch Processing]','e') ?></a>
268 &nbsp; <a href='../../library/freeb/process_bills.log' target='_blank' class='link_submit'
269 title='See messages from the last batch processing run'><?php xl('[view log]','e') ?></a></span>
270 <?php } ?>
271 </td>
272 <td align='right' nowrap>
273 <a href="javascript:select_all()" class="link_submit"><?php xl('[Select All]','e') ?></a>&nbsp;
274 </td>
275 </tr>
276 </table>
277 </form>
279 <form name=update_form method=post action=billing_process.php>
281 <center>
283 <?php if (file_exists($EXPORT_INC)) { ?>
284 <input type="submit" class="subbtn" name="bn_external" value="Export Billing" title="<?php xl('Export to external billing system','e') ?>">
285 <input type="submit" class="subbtn" name="bn_mark" value="Mark as Cleared" title="<?php xl('Mark as billed but skip billing','e') ?>">
286 <?php } else { ?>
287 <input type="submit" class="subbtn" name="bn_hcfa_print" value="Queue HCFA &amp; Print" title="<?php xl('Queue for HCFA batch processing and printing','e') ?>">
288 <input type="submit" class="subbtn" name="bn_hcfa" value="Queue HCFA" title="<?php xl('Queue for HCFA batch processing','e')?>">
289 <input type="submit" class="subbtn" name="bn_ub92_print" value="Queue UB92 &amp; Print" title="<?php xl('Queue for UB-92 batch processing and printing','e')?>">
290 <input type="submit" class="subbtn" name="bn_ub92" value="Queue UB92" title="<?php xl('Queue for UB-92 batch processing','e')?>">
291 <input type="submit" class="subbtn" name="bn_x12" value="Queue X12" title="<?php xl('Queue for X12 batch processing','e')?>">
292 <input type="submit" class="subbtn" name="bn_mark" value="Mark as Cleared" title="<?php xl('Post to accounting and mark as billed','e')?>">
293 <input type="submit" class="subbtn" name="bn_electronic_file" value="Make Electronic Batch &amp; Clear" title="<?php xl('Download billing file, post to accounting and mark as billed','e')?>">
294 <?php } ?>
296 </center>
298 <input type=hidden name=mode value="bill">
299 <input type=hidden name=authorized value="<?php echo $my_authorized; ?>">
300 <input type=hidden name=unbilled value="<?php echo $unbilled; ?>">
301 <input type=hidden name=code_type value="%">
302 <input type=hidden name=to_date value="<?php echo $to_date; ?>">
303 <input type=hidden name=from_date value="<?php echo $from_date; ?>">
304 <?php
305 if ($my_authorized == "on" ) {
306 $my_authorized = "1";
307 } else {
308 $my_authorized = "%";
311 if ($unbilled == "on") {
312 $unbilled = "0";
313 } else {
314 $unbilled = "%";
317 <input type=hidden name=bill_list value="<?php
318 $list = getBillsListBetween($from_date,$to_date,$my_authorized,$unbilled,"%");
319 print $list;
320 ?>">
321 <!-- new form for uploading -->
322 <?php
323 if (!isset($_POST["mode"])) {
324 if (!isset($_POST["from_date"])) {
325 $from_date=date("Y-m-d");
326 } else {
327 $from_date = $_POST["from_date"];
329 if (!isset($_POST["to_date"])) {
330 $to_date = date("Y-m-d");
331 } else {
332 $to_date = $_POST["to_date"];
334 if (!isset($_POST["code_type"])) {
335 $code_type="all";
336 } else {
337 $code_type = $_POST["code_type"];
339 if (!isset($_POST["unbilled"])) {
340 $unbilled = "on";
341 } else {
342 $unbilled = $_POST["unbilled"];
344 if (!isset($_POST["authorized"])) {
345 $my_authorized = "on";
346 } else {
347 $my_authorized = $_POST["authorized"];
349 } else {
350 $from_date = $_POST["from_date"];
351 $to_date = $_POST["to_date"];
352 $code_type = $_POST["code_type"];
353 $unbilled = $_POST["unbilled"];
354 $my_authorized = $_POST["authorized"];
356 if ($my_authorized == "on" ) {
357 $my_authorized = "1";
358 } else {
359 $my_authorized = "%";
362 if ($unbilled == "on") {
363 $unbilled = "0";
364 } else {
365 $unbilled = "%";
370 if (isset($_POST["mode"]) && $_POST["mode"] == "bill") {
371 billCodesList($list);
376 <table border="0" cellspacing="0" cellpadding="0" width="100%">
379 if ($ret = getBillsBetween($from_date,$to_date,$my_authorized,$unbilled,"%")) {
380 $loop = 0;
381 $oldcode = "";
382 $last_encounter_id = "";
383 $lhtml = "";
384 $rhtml = "";
385 $lcount = 0;
386 $rcount = 0;
387 $bgcolor = "";
388 $skipping = FALSE;
390 foreach ($ret as $iter) {
391 $this_encounter_id = $iter['pid'] . "-" . $iter['encounter'];
393 // echo "<!-- $this_encounter_id -->\n"; // debugging
395 if ($last_encounter_id != $this_encounter_id) {
396 if ($lhtml) {
397 while ($rcount < $lcount) {
398 $rhtml .= "<tr bgcolor='$bgcolor'><td colspan='7'>&nbsp;</td></tr>";
399 ++$rcount;
401 echo "<tr bgcolor='$bgcolor'>\n<td rowspan='$rcount' valign='top'>\n$lhtml</td>$rhtml\n";
402 echo "<tr bgcolor='$bgcolor'><td colspan='8' height='5'></td></tr>\n\n";
405 $lhtml = "";
406 $rhtml = "";
408 // If there are ANY unauthorized items in this encounter and this is
409 // the normal case of viewing only authorized billing, then skip the
410 // entire encounter.
412 $skipping = FALSE;
413 if ($my_authorized == '1') {
414 $res = sqlQuery("select count(*) as count from billing where " .
415 "encounter = '" . $iter['encounter'] . "' and " .
416 "pid='" . $iter['pid'] . "' and " .
417 "activity = 1 and authorized = 0");
418 if ($res['count'] > 0) {
419 $skipping = TRUE;
420 $last_encounter_id = $this_encounter_id;
421 continue;
425 $name = getPatientData($iter['pid'], "fname, mname, lname");
427 # Check if patient has primary insurance and a subscriber exists for it.
428 # If not we will highlight their name in red.
429 # TBD: more checking here.
431 $res = sqlQuery("select count(*) as count from insurance_data where " .
432 "pid = " . $iter['pid'] . " and " .
433 "type='primary' and " .
434 "subscriber_lname is not null and " .
435 "subscriber_lname != '' limit 1");
436 $namecolor = ($res['count'] > 0) ? "black" : "#ff7777";
438 ++$encount;
439 $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
440 echo "<tr bgcolor='$bgcolor'><td colspan='8' height='5'></td></tr>\n";
441 $lcount = 3;
442 $rcount = 0;
443 $oldcode = "";
445 $ptname = $name['fname'] . " " . $name['lname'];
446 $raw_encounter_date = date("Y-m-d", strtotime($iter['enc_date']));
448 $lhtml .= "&nbsp;<span class=bold><font color='$namecolor'>$ptname" .
449 "</font></span><span class=small>&nbsp;(" . $iter['pid'] . "-" .
450 $iter['encounter'] . ")</span>";
452 // $lhtml .= "&nbsp;&nbsp;&nbsp;<a class=\"link_submit\" href=\"" .
453 // $GLOBALS['form_exit_url'] . "?set_encounter=" .
454 // $iter['encounter'] . "&pid=" . $iter['pid'] . "\">[To&nbsp;Encounter]</a>";
456 $lhtml .= "&nbsp;&nbsp;&nbsp;<a class=\"link_submit\" " .
457 "href=\"javascript:window.toencounter(" . $iter['pid'] .
458 ",'" . addslashes($ptname) . "'," . $iter['encounter'] .
459 ",'$raw_encounter_date')\">[To&nbsp;Encounter]</a>";
461 // $lhtml .= "&nbsp;&nbsp;&nbsp;<a class=\"link_submit\" href=\"" . $GLOBALS['webroot'] .
462 // "/interface/patient_file/summary/demographics_full.php?&pid=" .
463 // $iter['pid'] . "\">[To&nbsp;Demographics]</a>";
465 $lhtml .= "&nbsp;&nbsp;&nbsp;<a class=\"link_submit\" " .
466 "href=\"javascript:window.topatient(" . $iter['pid'] .
467 ")\">[To&nbsp;Demographics]</a>";
469 $lhtml .= "<br />\n";
470 $lhtml .= "&nbsp;<span class=text>Bill: ";
471 $lhtml .= "<select name='claims[" . $this_encounter_id . "][payer]' style='background-color:$bgcolor'>";
473 $query = "SELECT id.provider AS id, id.type, " .
474 "ic.x12_default_partner_id AS ic_x12id, ic.name AS provider " .
475 "FROM insurance_data AS id, insurance_companies AS ic WHERE " .
476 "ic.id = id.provider AND pid = '" . mysql_escape_string($iter['pid']) .
477 "' ORDER BY type";
478 $result = sqlStatement($query);
480 $count = 0;
481 $default_x12_partner = $iter['ic_x12id'];
483 while ($row = mysql_fetch_array($result)) {
484 if (strlen($row['provider']) > 0) {
486 // This preserves any existing insurance company selection, which is
487 // important when EOB posting has re-queued for secondary billing.
488 $lhtml .= "<option value=\"" . $row['id'] . "\"";
489 if (($count == 0 && !$iter['payer_id']) || $row['id'] == $iter['payer_id']) {
490 $lhtml .= " selected";
491 if (!is_numeric($default_x12_partner)) $default_x12_partner = $row['ic_x12id'];
493 $lhtml .= ">" . $row['type'] . ": " . $row['provider'] . "</option>";
496 $count++;
499 $lhtml .= "<option value='-1'>Unassigned</option>\n";
500 $lhtml .= "</select>&nbsp;&nbsp;\n";
501 $lhtml .= "<select name='claims[" . $this_encounter_id . "][partner]' style='background-color:$bgcolor'>";
502 $x = new X12Partner();
503 $partners = $x->_utility_array($x->x12_partner_factory());
504 foreach ($partners as $xid => $xname) {
505 $lhtml .= '<option label="' . $xname . '" value="' . $xid .'"';
506 if ($xid == $default_x12_partner) {
507 $lhtml .= "selected";
509 $lhtml .= '>' . $xname . '</option>';
511 $lhtml .= "</select>";
512 $lhtml .= "<br>\n&nbsp;".xl("Claim was initiated: ") . $iter['date'];
513 if ($iter['billed'] == 1) {
514 $lhtml .= "<br>\n&nbsp;".xl("Claim was billed: ") . $iter['bill_date'];
515 ++$lcount;
517 if ($iter['bill_process'] == 1) {
518 $lhtml .= "<br>\n&nbsp;".xl("Claim is queued for processing");
519 ++$lcount;
521 if ($iter['bill_process'] == 5) {
522 $lhtml .= "<br>\n&nbsp;".xl("Claim is queued for printing and processing");
523 ++$lcount;
525 if ($iter['bill_process'] == 2) {
526 $lhtml .= "<br>\n&nbsp;".xl("Claim was processed: ") . $iter['process_date'];
527 $lhtml .= '<br>' . "\n" . '&nbsp;'.xl("Claim is in file:").' <a href="get_claim_file.php?key=' . $iter['process_file'] .'">' . $iter['process_file'] . '</a> or ';
528 $lhtml .= '<a href="get_claim_file.php?action=print&key=' . $iter['process_file'] .'">Print It</a> or ';
529 $lhtml .= '<a target="_new" href="freebtest.php?format=' . $iter['target'] . '&billkey=' . $iter['pid'] . '-' . $iter['encounter'] . '">'.xl('Run Test').'</a>';
530 $lhtml .= '<input type="hidden" name="claims[' . $this_encounter_id . '][file]" value="' . $iter['process_file'] . '">';
531 $lcount += 2;
533 if ($iter['bill_process'] == 3) {
534 $lhtml .= "<br>\n&nbsp;".xl("Claim was processed: ") . $iter['process_date'] . xl(" but there was an error: "). $iter['process_file'];
535 ++$lcount;
539 if ($skipping) continue;
541 ++$rcount;
542 if ($rhtml) {
543 $rhtml .= "<tr bgcolor='$bgcolor'>\n";
545 $rhtml .= "<td width='50'>";
546 if ($oldcode != $iter['code_type']) {
547 $rhtml .= "<span class=text>" . $iter['code_type'] . ": </span>";
549 $oldcode = $iter['code_type'];
550 $rhtml .= "</td>\n";
551 $justify = "";
552 // if ($iter['code_type'] == "CPT4" || $iter['code_type'] == "HCPCS") {
553 if ($code_types[$iter['code_type']]['just']) {
554 $js = split(":",$iter['justify']);
555 $counter = 0;
556 foreach ($js as $j) {
557 if(!empty($j)) {
558 if ($counter == 0) {
559 $justify .= " (<b>$j</b>)";
561 else {
562 $justify .= " ($j)";
564 $counter++;
569 $rhtml .= "<td><span class=text>" . $iter{"code"}. "</span>" . '<span style="font-size:8pt;">' . $justify . "</span></td>\n";
570 $rhtml .= '<td align="right"><span style="font-size:8pt;">&nbsp;&nbsp;&nbsp;';
571 if ($iter['fee'] > 0) {
572 $rhtml .= '$' . $iter['fee'];
574 $rhtml .= "</span></td>\n";
575 $rhtml .= '<td><span style="font-size:8pt;">&nbsp;&nbsp;&nbsp;';
576 $rhtml .= getProviderName($iter['provider_id']);
577 $rhtml .= "</span></td>\n";
578 $rhtml .= '<td width=100>&nbsp;&nbsp;&nbsp;<span style="font-size:8pt;">' . date("Y-m-d",strtotime($iter{"date"})) . "</span></td>\n";
579 if ($iter['authorized'] != 1) {
580 $rhtml .= "<td><span class=alert>".xl("Note: This code was not entered by an authorized user. Only authorized codes may be uploaded to the Open Medical Billing Network for processing. If you wish to upload these codes, please select an authorized user here.")."</span></td>\n";
582 else {
583 $rhtml .= "<td></td>\n";
585 if ($last_encounter_id != $this_encounter_id) {
586 $rhtml .= "<td><input type='checkbox' value='" . $iter['bill_process'] . "$procstatus' name='claims[" . $this_encounter_id . "][bill]' onclick='set_button_states()'>&nbsp;</td>\n";
588 else {
589 $rhtml .= "<td></td>\n";
591 $rhtml .= "</tr>\n";
592 $last_encounter_id = $this_encounter_id;
595 if ($lhtml) {
596 while ($rcount < $lcount) {
597 $rhtml .= "<tr bgcolor='$bgcolor'><td colspan='7'>&nbsp;</td></tr>";
598 ++$rcount;
600 echo "<tr bgcolor='$bgcolor'>\n<td rowspan='$rcount' valign='top'>\n$lhtml</td>$rhtml\n";
601 echo "<tr bgcolor='$bgcolor'><td colspan='8' height='5'></td></tr>\n";
607 </table>
609 </form>
610 <script>
611 set_button_states();
613 <?php
614 if ($alertmsg) {
615 echo "alert('$alertmsg');\n";
619 </script>
620 </body>
621 </html>