include encounters with no charges entered and default to including unauthorized...
[openemr.git] / interface / billing / billing_report.php
blobac7fb2d02a66568307ab0248287fa60eda989342
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"];
85 // }
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) {
392 // We include encounters here that have never been billed. However
393 // if it had no selected billing items but does have non-selected
394 // billing items, then it is not of interest.
395 if (!$iter['id']) {
396 $res = sqlQuery("SELECT count(*) AS count FROM billing WHERE " .
397 "encounter = '" . $iter['enc_encounter'] . "' AND " .
398 "pid='" . $iter['enc_pid'] . "' AND " .
399 "activity = 1");
400 if ($res['count'] > 0) continue;
403 $this_encounter_id = $iter['enc_pid'] . "-" . $iter['enc_encounter'];
405 // echo "<!-- $this_encounter_id -->\n"; // debugging
407 if ($last_encounter_id != $this_encounter_id) {
408 if ($lhtml) {
409 while ($rcount < $lcount) {
410 $rhtml .= "<tr bgcolor='$bgcolor'><td colspan='7'>&nbsp;</td></tr>";
411 ++$rcount;
413 echo "<tr bgcolor='$bgcolor'>\n<td rowspan='$rcount' valign='top'>\n$lhtml</td>$rhtml\n";
414 echo "<tr bgcolor='$bgcolor'><td colspan='8' height='5'></td></tr>\n\n";
417 $lhtml = "";
418 $rhtml = "";
420 // If there are ANY unauthorized items in this encounter and this is
421 // the normal case of viewing only authorized billing, then skip the
422 // entire encounter.
424 $skipping = FALSE;
425 if ($my_authorized == '1') {
426 $res = sqlQuery("select count(*) as count from billing where " .
427 "encounter = '" . $iter['enc_encounter'] . "' and " .
428 "pid='" . $iter['enc_pid'] . "' and " .
429 "activity = 1 and authorized = 0");
430 if ($res['count'] > 0) {
431 $skipping = TRUE;
432 $last_encounter_id = $this_encounter_id;
433 continue;
437 $name = getPatientData($iter['enc_pid'], "fname, mname, lname");
439 # Check if patient has primary insurance and a subscriber exists for it.
440 # If not we will highlight their name in red.
441 # TBD: more checking here.
443 $res = sqlQuery("select count(*) as count from insurance_data where " .
444 "pid = " . $iter['enc_pid'] . " and " .
445 "type='primary' and " .
446 "subscriber_lname is not null and " .
447 "subscriber_lname != '' limit 1");
448 $namecolor = ($res['count'] > 0) ? "black" : "#ff7777";
450 ++$encount;
451 $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
452 echo "<tr bgcolor='$bgcolor'><td colspan='8' height='5'></td></tr>\n";
453 $lcount = 1;
454 $rcount = 0;
455 $oldcode = "";
457 $ptname = $name['fname'] . " " . $name['lname'];
458 $raw_encounter_date = date("Y-m-d", strtotime($iter['enc_date']));
460 $lhtml .= "&nbsp;<span class=bold><font color='$namecolor'>$ptname" .
461 "</font></span><span class=small>&nbsp;(" . $iter['enc_pid'] . "-" .
462 $iter['enc_encounter'] . ")</span>";
464 // $lhtml .= "&nbsp;&nbsp;&nbsp;<a class=\"link_submit\" href=\"" .
465 // $GLOBALS['form_exit_url'] . "?set_encounter=" .
466 // $iter['encounter'] . "&pid=" . $iter['pid'] . "\">[To&nbsp;Encounter]</a>";
468 $lhtml .= "&nbsp;&nbsp;&nbsp;<a class=\"link_submit\" " .
469 "href=\"javascript:window.toencounter(" . $iter['enc_pid'] .
470 ",'" . addslashes($ptname) . "'," . $iter['enc_encounter'] .
471 ",'$raw_encounter_date')\">[To&nbsp;Encounter]</a>";
473 // $lhtml .= "&nbsp;&nbsp;&nbsp;<a class=\"link_submit\" href=\"" . $GLOBALS['webroot'] .
474 // "/interface/patient_file/summary/demographics_full.php?&pid=" .
475 // $iter['pid'] . "\">[To&nbsp;Demographics]</a>";
477 $lhtml .= "&nbsp;&nbsp;&nbsp;<a class=\"link_submit\" " .
478 "href=\"javascript:window.topatient(" . $iter['enc_pid'] .
479 ")\">[To&nbsp;Demographics]</a>";
481 if ($iter['id']) {
482 $lcount += 2;
483 $lhtml .= "<br />\n";
484 $lhtml .= "&nbsp;<span class=text>Bill: ";
485 $lhtml .= "<select name='claims[" . $this_encounter_id . "][payer]' style='background-color:$bgcolor'>";
486 $query = "SELECT id.provider AS id, id.type, " .
487 "ic.x12_default_partner_id AS ic_x12id, ic.name AS provider " .
488 "FROM insurance_data AS id, insurance_companies AS ic WHERE " .
489 "ic.id = id.provider AND pid = '" . mysql_escape_string($iter['enc_pid']) .
490 "' ORDER BY type";
491 $result = sqlStatement($query);
492 $count = 0;
493 $default_x12_partner = $iter['ic_x12id'];
494 while ($row = mysql_fetch_array($result)) {
495 if (strlen($row['provider']) > 0) {
496 // This preserves any existing insurance company selection, which is
497 // important when EOB posting has re-queued for secondary billing.
498 $lhtml .= "<option value=\"" . $row['id'] . "\"";
499 if (($count == 0 && !$iter['payer_id']) || $row['id'] == $iter['payer_id']) {
500 $lhtml .= " selected";
501 if (!is_numeric($default_x12_partner)) $default_x12_partner = $row['ic_x12id'];
503 $lhtml .= ">" . $row['type'] . ": " . $row['provider'] . "</option>";
505 $count++;
507 $lhtml .= "<option value='-1'>Unassigned</option>\n";
508 $lhtml .= "</select>&nbsp;&nbsp;\n";
509 $lhtml .= "<select name='claims[" . $this_encounter_id . "][partner]' style='background-color:$bgcolor'>";
510 $x = new X12Partner();
511 $partners = $x->_utility_array($x->x12_partner_factory());
512 foreach ($partners as $xid => $xname) {
513 $lhtml .= '<option label="' . $xname . '" value="' . $xid .'"';
514 if ($xid == $default_x12_partner) {
515 $lhtml .= "selected";
517 $lhtml .= '>' . $xname . '</option>';
519 $lhtml .= "</select>";
520 $lhtml .= "<br>\n&nbsp;".xl("Claim was initiated: ") . $iter['date'];
521 if ($iter['billed'] == 1) {
522 $lhtml .= "<br>\n&nbsp;".xl("Claim was billed: ") . $iter['bill_date'];
523 ++$lcount;
525 if ($iter['bill_process'] == 1) {
526 $lhtml .= "<br>\n&nbsp;".xl("Claim is queued for processing");
527 ++$lcount;
529 if ($iter['bill_process'] == 5) {
530 $lhtml .= "<br>\n&nbsp;".xl("Claim is queued for printing and processing");
531 ++$lcount;
533 if ($iter['bill_process'] == 2) {
534 $lhtml .= "<br>\n&nbsp;".xl("Claim was processed: ") . $iter['process_date'];
535 $lhtml .= '<br>' . "\n" . '&nbsp;'.xl("Claim is in file:").' <a href="get_claim_file.php?key=' . $iter['process_file'] .'">' . $iter['process_file'] . '</a> or ';
536 $lhtml .= '<a href="get_claim_file.php?action=print&key=' . $iter['process_file'] .'">Print It</a> or ';
537 $lhtml .= '<a target="_new" href="freebtest.php?format=' . $iter['target'] . '&billkey=' . $iter['enc_pid'] . '-' . $iter['enc_encounter'] . '">'.xl('Run Test').'</a>';
538 $lhtml .= '<input type="hidden" name="claims[' . $this_encounter_id . '][file]" value="' . $iter['process_file'] . '">';
539 $lcount += 2;
541 if ($iter['bill_process'] == 3) {
542 $lhtml .= "<br>\n&nbsp;".xl("Claim was processed: ") . $iter['process_date'] . xl(" but there was an error: "). $iter['process_file'];
543 ++$lcount;
545 } // end if ($iter['id'])
548 if ($skipping) continue;
550 ++$rcount;
551 if ($rhtml) {
552 $rhtml .= "<tr bgcolor='$bgcolor'>\n";
554 $rhtml .= "<td width='50'>";
555 if ($iter['id'] && $oldcode != $iter['code_type']) {
556 $rhtml .= "<span class=text>" . $iter['code_type'] . ": </span>";
558 $oldcode = $iter['code_type'];
559 $rhtml .= "</td>\n";
560 $justify = "";
561 if ($iter['id'] && $code_types[$iter['code_type']]['just']) {
562 $js = split(":",$iter['justify']);
563 $counter = 0;
564 foreach ($js as $j) {
565 if(!empty($j)) {
566 if ($counter == 0) {
567 $justify .= " (<b>$j</b>)";
569 else {
570 $justify .= " ($j)";
572 $counter++;
577 $rhtml .= "<td><span class=text>" . $iter{"code"}. "</span>" . '<span style="font-size:8pt;">' . $justify . "</span></td>\n";
578 $rhtml .= '<td align="right"><span style="font-size:8pt;">&nbsp;&nbsp;&nbsp;';
579 if ($iter['id'] && $iter['fee'] > 0) {
580 $rhtml .= '$' . $iter['fee'];
582 $rhtml .= "</span></td>\n";
583 $rhtml .= '<td><span style="font-size:8pt;">&nbsp;&nbsp;&nbsp;';
584 if ($iter['id']) $rhtml .= getProviderName($iter['provider_id']);
585 $rhtml .= "</span></td>\n";
586 $rhtml .= '<td width=100>&nbsp;&nbsp;&nbsp;<span style="font-size:8pt;">';
587 if ($iter['id']) $rhtml .= date("Y-m-d",strtotime($iter{"date"}));
588 $rhtml .= "</span></td>\n";
589 if ($iter['id'] && $iter['authorized'] != 1) {
590 $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";
592 else {
593 $rhtml .= "<td></td>\n";
595 if ($iter['id'] && $last_encounter_id != $this_encounter_id) {
596 $rhtml .= "<td><input type='checkbox' value='" . $iter['bill_process'] . "$procstatus' name='claims[" . $this_encounter_id . "][bill]' onclick='set_button_states()'>&nbsp;</td>\n";
598 else {
599 $rhtml .= "<td></td>\n";
601 $rhtml .= "</tr>\n";
602 $last_encounter_id = $this_encounter_id;
605 if ($lhtml) {
606 while ($rcount < $lcount) {
607 $rhtml .= "<tr bgcolor='$bgcolor'><td colspan='7'>&nbsp;</td></tr>";
608 ++$rcount;
610 echo "<tr bgcolor='$bgcolor'>\n<td rowspan='$rcount' valign='top'>\n$lhtml</td>$rhtml\n";
611 echo "<tr bgcolor='$bgcolor'><td colspan='8' height='5'></td></tr>\n";
617 </table>
619 </form>
620 <script>
621 set_button_states();
623 <?php
624 if ($alertmsg) {
625 echo "alert('$alertmsg');\n";
629 </script>
630 </body>
631 </html>