2 require_once("../globals.php");
3 require_once("../../library/acl.inc");
4 require_once("../../custom/code_types.inc.php");
6 require_once("$srcdir/patient.inc");
7 require_once("$srcdir/billrep.inc");
8 require_once(dirname(__FILE__
) . "/../../library/classes/OFX.class.php");
9 require_once(dirname(__FILE__
) . "/../../library/classes/X12Partner.class.php");
11 $EXPORT_INC = "$webserver_root/custom/BillingExport.php";
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";
27 $results = $db->Execute($sql);
29 if ($results->RecordCount() == 0) {
30 echo xl("No Bills Found to Include in OFX Export<br>");
33 while(!$results->EOF
) {
34 $billings[] = $results->fields
;
37 $ofx = new OFX($billings);
38 header("Pragma: public");
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");
49 if ($_POST['mode'] == 'process') {
50 if (exec("ps x | grep 'process_bills[.]php'")) {
51 $alertmsg = xl('Request ignored - claims processing is already running!');
54 exec("cd $webserver_root/library/freeb;" .
55 "php -q process_bills.php bill > process_bills.log 2>&1 &");
56 $alertmsg = xl('Batch processing initiated; this may take a while.');
61 if (!isset($_POST["mode"])) {
62 $from_date = isset($_POST['from_date']) ?
$_POST['from_date'] : date('Y-m-d');
63 $to_date = isset($_POST['to_date' ]) ?
$_POST['to_date' ] : '';
64 $code_type = isset($_POST['code_type']) ?
$_POST['code_type'] : 'all';
65 $unbilled = isset($_POST['unbilled' ]) ?
$_POST['unbilled' ] : 'on';
66 $my_authorized = $_POST["authorized"];
68 $from_date = $_POST["from_date"];
69 $to_date = $_POST["to_date"];
70 $code_type = $_POST["code_type"];
71 $unbilled = $_POST["unbilled"];
72 $my_authorized = $_POST["authorized"];
76 $from_date = isset($_POST['from_date']) ? $_POST['from_date'] : date('Y-m-d');
77 $to_date = empty($_POST['to_date' ]) ? $from_date : $_POST['to_date'];
78 $code_type = isset($_POST['code_type']) ? $_POST['code_type'] : 'all';
79 $unbilled = isset($_POST['unbilled' ]) ? $_POST['unbilled' ] : 'on';
80 $my_authorized = $_POST["authorized"];
83 $left_margin = isset($_POST["left_margin"]) ?
$_POST["left_margin"] : 24;
84 $top_margin = isset($_POST["top_margin"] ) ?
$_POST["top_margin" ] : 27;
86 $ofrom_date = $from_date;
88 $ocode_type = $code_type;
89 $ounbilled = $unbilled;
90 $oauthorized = $my_authorized;
95 <?php
if (function_exists(html_header_show
)) html_header_show(); ?
>
96 <link rel
="stylesheet" href
="<?php echo $css_header; ?>" type
="text/css">
98 .subbtn
{ margin
-top
:3px
; margin
-bottom
:3px
; margin
-left
:2px
; margin
-right
:2px
}
102 function select_all() {
103 for($i=0;$i < document
.update_form
.length
;$i++
) {
104 $name = document
.update_form
[$i].name
;
105 if ($name.substring(0,7) == "claims[" && $name.substring($name.length
-6) == "[bill]") {
106 document
.update_form
[$i].checked
= true;
112 function set_button_states() {
113 var f
= document
.update_form
;
114 var count0
= 0; // selected and not billed or queued
115 var count1
= 0; // selected and queued
116 var count2
= 0; // selected and billed
117 for($i = 0; $i < f
.length
; ++
$i) {
119 if ($name.substring(0, 7) == "claims[" && $name.substring($name.length
-6) == "[bill]" && f
[$i].checked
== true) {
120 if (f
[$i].value
== '0') ++count0
;
121 else if (f
[$i].value
== '1' || f
[$i].value
== '5') ++count1
;
126 var can_generate
= (count0
> 0 || count1
> 0 || count2
> 0);
127 var can_mark
= (count1
> 0 || count0
> 0 || count2
> 0);
128 var can_bill
= (count0
== 0 && count1
== 0 && count2
> 0);
130 <?php
if (file_exists($EXPORT_INC)) { ?
>
131 f
.bn_external
.disabled
= !can_generate
;
133 // f.bn_hcfa_print.disabled = !can_generate;
134 // f.bn_hcfa.disabled = !can_generate;
135 // f.bn_ub92_print.disabled = !can_generate;
136 // f.bn_ub92.disabled = !can_generate;
137 f
.bn_x12
.disabled
= !can_generate
;
138 f
.bn_process_hcfa
.disabled
= !can_generate
;
139 // f.bn_electronic_file.disabled = !can_bill;
140 f
.bn_reopen
.disabled
= !can_bill
;
142 f
.bn_mark
.disabled
= !can_mark
;
145 // Process a click to go to an encounter.
146 function toencounter(pid
, pubpid
, pname
, enc
, datestr
) {
147 top
.restoreSession();
148 <?php
if ($GLOBALS['concurrent_layout']) { ?
>
149 var othername
= (window
.name
== 'RTop') ?
'RBot' : 'RTop';
150 parent
.left_nav
.setPatient(pname
,pid
,pubpid
,'');
151 parent
.left_nav
.setEncounter(datestr
, enc
, othername
);
152 parent
.left_nav
.setRadio(othername
, 'enc');
153 parent
.frames
[othername
].location
.href
=
154 '../patient_file/encounter/encounter_top.php?set_encounter='
155 + enc +
'&pid=' + pid
;
157 location
.href
= '../patient_file/encounter/patient_encounter.php?set_encounter='
158 + enc +
'&pid=' + pid
;
162 // Process a click to go to patient demographics.
163 // larry :: dbc insert
164 <?php
if( $GLOBALS['dutchpc'] )
167 function topatient(pid
) {
168 top
.restoreSession();
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_dutch.php?pid=' + pid
;
174 location
.href
= '../patient_file/summary/demographics_full_dutch.php?pid=' + pid
;
181 function topatient(pid
) {
182 top
.restoreSession();
183 <?php
if ($GLOBALS['concurrent_layout']) { ?
>
184 var othername
= (window
.name
== 'RTop') ?
'RBot' : 'RTop';
185 parent
.frames
[othername
].location
.href
=
186 '../patient_file/summary/demographics_full.php?pid=' + pid
;
188 location
.href
= '../patient_file/summary/demographics_full.php?pid=' + pid
;
192 // larry :: end of dbc change
196 <body
class="body_top">
198 <p style
='margin-top:5px;margin-bottom:5px;margin-left:5px'>
200 <?php
if ($GLOBALS['concurrent_layout']) { ?
>
201 <font
class='title'><?php
xl('Billing Report','e') ?
></font
>
202 <?php
} else if ($userauthorized) { ?
>
203 <a href
="../main/main.php" target
='Main' onclick
='top.restoreSession()'><font
class=title
><?php
xl('Billing Report','e') ?
></font
><font
class=more
> <?php
echo $tback; ?
></font
></a
>
205 <a href
="../main/onotes/office_comments.php" target
='Main' onclick
='top.restoreSession()'><font
class=title
><?php
xl('Billing Report','e') ?
></font
><font
class=more
><?php
echo $tback; ?
></font
></a
>
210 <form name
='the_form' method
='post' action
='billing_report.php' onsubmit
='return top.restoreSession()'>
212 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
213 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
214 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
215 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
216 <script type
="text/javascript" src
="../../library/dynarch_calendar_en.js"></script
>
217 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
218 <script language
='JavaScript'>
222 <input type
='hidden' name
='mode' value
='change'>
224 <table width
='100%' border
="1" cellspacing
="0" cellpadding
="0">
227  
;<span
class='text'><?php
xl('From: ','e') ?
></span
>
228 <input type
='text' size
='10' name
='from_date' id
='from_date'
229 value
='<?php echo $from_date; ?>'
230 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)'
231 title
='yyyy-mm-dd last date of this event' />
232 <img src
='../../interface/pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
233 id
='img_fromdate' border
='0' alt
='[?]' style
='cursor:pointer'
234 title
='Click here to choose a date'>
236 Calendar
.setup({inputField
:"from_date", ifFormat
:"%Y-%m-%d", button
:"img_fromdate"});
241  
;<span
class='text'><?php
xl('To: ','e') ?
></span
>
242 <input type
='text' size
='10' name
='to_date' id
='to_date'
243 value
='<?php echo $to_date; ?>'
244 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)'
245 title
='yyyy-mm-dd last date of this event' />
246 <img src
='../../interface/pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
247 id
='img_todate' border
='0' alt
='[?]' style
='cursor:pointer'
248 title
='Click here to choose a date' />
250 Calendar
.setup({inputField
:"to_date", ifFormat
:"%Y-%m-%d", button
:"img_todate"});
252 <input type
="hidden" name
="code_type" value
="%" />
256 <input type
='checkbox' name
='unbilled' <?php
if ($unbilled == "on") {echo "checked";}; ?
> />
257 <span
class='text'><?php
xl('Show Unbilled Only','e') ?
></span
>
261 <input type
='checkbox' name
='authorized' <?php
if ($my_authorized == "on") {echo "checked";}; ?
> />
262 <span
class='text'><?php
xl('Show Authorized Only','e') ?
></span
>
265 <td align
='right' width
='10%' nowrap
>
266  
;<span
class='text'><a href
="javascript:top.restoreSession();document.the_form.mode.value='change';document.the_form.submit()" class=link_submit
><?php
xl('[Change View]','e') ?
></a
>
268 <a href
="javascript:top.restoreSession();document.the_form.mode.value='export';document.the_form.submit()" class='link_submit'><?php
xl('[Export OFX]','e') ?
></a
></span
> 
;
276  
;<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); ?>"
277 class='link_submit' target
='new' onclick
='top.restoreSession()'><?php
xl('[View Printable Report]','e') ?
></a
>
283 $acct_config = $GLOBALS['oer_config']['ws_accounting'];
284 if($acct_config['enabled']) {
285 if($acct_config['enabled'] !== 2) {
286 print '<span class=text><a href="javascript:void window.open(\'' . $acct_config['url_path'] . '\')">' . xl("[SQL-Ledger]") . '</a> </span>';
288 if (acl_check('acct', 'rep')) {
289 print '<span class=text><a href="javascript:void window.open(\'sl_receipts_report.php\')" onclick="top.restoreSession()">' . xl('[Reports]') . '</a> </span>';
291 if (acl_check('acct', 'eob')) {
292 print '<span class=text><a href="javascript:void window.open(\'sl_eob_search.php\')" onclick="top.restoreSession()">' . xl('[EOBs]') . '</a></span>';
298 <td colspan
='2' class='text' nowrap
>
300 <?php
if (! file_exists($EXPORT_INC)) { ?
>
302 <a href
="javascript:top.restoreSession();document.the_form.mode.value='process';document.the_form.submit()" class="link_submit"
303 title
="Process all queued bills to create electronic data (and print if requested)"><?php
xl('[Start Batch Processing]','e') ?
></a
>
306 <a href
='../../library/freeb/process_bills.log' target
='_blank' class='link_submit'
307 title
='See messages from the last set of generated claims'><?php
xl('[View Log]','e') ?
></a
>
311 <td align
='right' nowrap
>
312 <a href
="javascript:select_all()" class="link_submit"><?php
xl('[Select All]','e') ?
></a
> 
;
320 <form name
='update_form' method
='post' action
='billing_process.php' onsubmit
='return top.restoreSession()'>
325 <?php
if (file_exists($EXPORT_INC)) { ?
>
326 <input type
="submit" class="subbtn" name
="bn_external" value
="Export Billing" title
="<?php xl('Export to external billing system','e') ?>">
327 <input type
="submit" class="subbtn" name
="bn_mark" value
="Mark as Cleared" title
="<?php xl('Mark as billed but skip billing','e') ?>">
330 <input type
="submit" class="subbtn" name
="bn_hcfa_print" value
="Queue HCFA & Print" title
="<?php xl('Queue for HCFA batch processing and printing','e') ?>">
331 <input type
="submit" class="subbtn" name
="bn_hcfa" value
="Queue HCFA" title
="<?php xl('Queue for HCFA batch processing','e')?>">
332 <input type
="submit" class="subbtn" name
="bn_ub92_print" value
="Queue UB92 & Print" title
="<?php xl('Queue for UB-92 batch processing and printing','e')?>">
333 <input type
="submit" class="subbtn" name
="bn_ub92" value
="Queue UB92" title
="<?php xl('Queue for UB-92 batch processing','e')?>">
335 <input type
="submit" class="subbtn" name
="bn_x12" value
="Generate X12"
336 title
="<?php xl('Generate and download X12 batch','e')?>"
337 onclick
="alert('After saving your batch, click [View Log] to check for errors.')">
338 <input type
="submit" class="subbtn" name
="bn_process_hcfa" value
="Generate HCFA"
339 title
="<?php xl('Generate and download HCFA 1500 paper claims','e')?>"
340 onclick
="alert('After saving the PDF, click [View Log] to check for errors.')">
341 <input type
="submit" class="subbtn" name
="bn_mark" value
="Mark as Cleared" title
="<?php xl('Post to accounting and mark as billed','e')?>">
342 <input type
="submit" class="subbtn" name
="bn_reopen" value
="Re-Open" title
="<?php xl('Mark as not billed','e')?>">
344 <input type
="submit" class="subbtn" name
="bn_electronic_file" value
="Make Electronic Batch & Clear" title
="<?php xl('Download billing file, post to accounting and mark as billed','e')?>">
349 <input type
='text' size
='2' name
='left_margin'
350 value
='<?php echo $left_margin; ?>'
351 title
='HCFA left margin in points' />
353 <input type
='text' size
='2' name
='top_margin'
354 value
='<?php echo $top_margin; ?>'
355 title
='HCFA top margin in points' />
361 <input type
='hidden' name
='mode' value
="bill" />
362 <input type
='hidden' name
='authorized' value
="<?php echo $my_authorized; ?>" />
363 <input type
='hidden' name
='unbilled' value
="<?php echo $unbilled; ?>" />
364 <input type
='hidden' name
='code_type' value
="%" />
365 <input type
='hidden' name
='to_date' value
="<?php echo $to_date; ?>" />
366 <input type
='hidden' name
='from_date' value
="<?php echo $from_date; ?>" />
369 if ($my_authorized == "on" ) {
370 $my_authorized = "1";
372 $my_authorized = "%";
374 if ($unbilled == "on") {
380 $list = getBillsListBetween($from_date,
381 empty($to_date) ?
$from_date : $to_date,
382 $my_authorized,$unbilled,"%");
385 <input type
='hidden' name
='bill_list' value
="<?php echo $list; ?>" />
387 <!-- new form
for uploading
-->
390 if (!isset($_POST["mode"])) {
391 if (!isset($_POST["from_date"])) {
392 $from_date = date("Y-m-d");
394 $from_date = $_POST["from_date"];
396 if (empty($_POST["to_date"])) {
399 $to_date = $_POST["to_date"];
401 if (!isset($_POST["code_type"])) {
404 $code_type = $_POST["code_type"];
406 if (!isset($_POST["unbilled"])) {
409 $unbilled = $_POST["unbilled"];
411 if (!isset($_POST["authorized"])) {
412 $my_authorized = "on";
414 $my_authorized = $_POST["authorized"];
417 $from_date = $_POST["from_date"];
418 $to_date = $_POST["to_date"];
419 $code_type = $_POST["code_type"];
420 $unbilled = $_POST["unbilled"];
421 $my_authorized = $_POST["authorized"];
424 if ($my_authorized == "on" ) {
425 $my_authorized = "1";
427 $my_authorized = "%";
430 if ($unbilled == "on") {
436 if (isset($_POST["mode"]) && $_POST["mode"] == "bill") {
437 billCodesList($list);
442 <table border
="0" cellspacing
="0" cellpadding
="0" width
="100%">
445 if ($ret = getBillsBetween($from_date,
446 empty($to_date) ?
$from_date : $to_date,
447 $my_authorized, $unbilled, "%"))
451 $last_encounter_id = "";
459 foreach ($ret as $iter) {
461 // We include encounters here that have never been billed. However
462 // if it had no selected billing items but does have non-selected
463 // billing items, then it is not of interest.
465 $res = sqlQuery("SELECT count(*) AS count FROM billing WHERE " .
466 "encounter = '" . $iter['enc_encounter'] . "' AND " .
467 "pid='" . $iter['enc_pid'] . "' AND " .
469 if ($res['count'] > 0) continue;
472 $this_encounter_id = $iter['enc_pid'] . "-" . $iter['enc_encounter'];
474 if ($last_encounter_id != $this_encounter_id) {
476 while ($rcount < $lcount) {
477 $rhtml .= "<tr bgcolor='$bgcolor'><td colspan='7'> </td></tr>";
480 echo "<tr bgcolor='$bgcolor'>\n<td rowspan='$rcount' valign='top'>\n$lhtml</td>$rhtml\n";
481 echo "<tr bgcolor='$bgcolor'><td colspan='8' height='5'></td></tr>\n\n";
487 // If there are ANY unauthorized items in this encounter and this is
488 // the normal case of viewing only authorized billing, then skip the
492 if ($my_authorized == '1') {
493 $res = sqlQuery("select count(*) as count from billing where " .
494 "encounter = '" . $iter['enc_encounter'] . "' and " .
495 "pid='" . $iter['enc_pid'] . "' and " .
496 "activity = 1 and authorized = 0");
497 if ($res['count'] > 0) {
499 $last_encounter_id = $this_encounter_id;
504 $name = getPatientData($iter['enc_pid'], "fname, mname, lname, pubpid");
506 # Check if patient has primary insurance and a subscriber exists for it.
507 # If not we will highlight their name in red.
508 # TBD: more checking here.
510 $res = sqlQuery("select count(*) as count from insurance_data where " .
511 "pid = " . $iter['enc_pid'] . " and " .
512 "type='primary' and " .
513 "subscriber_lname is not null and " .
514 "subscriber_lname != '' limit 1");
515 $namecolor = ($res['count'] > 0) ?
"black" : "#ff7777";
518 $bgcolor = "#" . (($encount & 1) ?
"ddddff" : "ffdddd");
519 echo "<tr bgcolor='$bgcolor'><td colspan='8' height='5'></td></tr>\n";
524 $ptname = $name['fname'] . " " . $name['lname'];
525 $raw_encounter_date = date("Y-m-d", strtotime($iter['enc_date']));
527 $lhtml .= " <span class=bold><font color='$namecolor'>$ptname" .
528 "</font></span><span class=small> (" . $iter['enc_pid'] . "-" .
529 $iter['enc_encounter'] . ")</span>";
531 $lhtml .= " <a class=\"link_submit\" " .
532 "href=\"javascript:window.toencounter(" . $iter['enc_pid'] .
533 ",'" . addslashes($name['pubpid']) .
534 "','" . addslashes($ptname) . "'," . $iter['enc_encounter'] .
535 ",'$raw_encounter_date')\">[To Encounter]</a>";
537 $lhtml .= " <a class=\"link_submit\" " .
538 "href=\"javascript:window.topatient(" . $iter['enc_pid'] .
539 ")\">[To Demographics]</a>";
544 $lhtml .= "<br />\n";
545 $lhtml .= " <span class=text>Bill: ";
546 $lhtml .= "<select name='claims[" . $this_encounter_id . "][payer]' style='background-color:$bgcolor'>";
548 $query = "SELECT id.provider AS id, id.type, id.date, " .
549 "ic.x12_default_partner_id AS ic_x12id, ic.name AS provider " .
550 "FROM insurance_data AS id, insurance_companies AS ic WHERE " .
551 "ic.id = id.provider AND " .
552 "id.pid = '" . mysql_escape_string($iter['enc_pid']) . "' AND " .
553 "id.date <= '$raw_encounter_date' " .
554 "ORDER BY id.type ASC, id.date DESC";
556 $result = sqlStatement($query);
558 $default_x12_partner = $iter['ic_x12id'];
561 while ($row = mysql_fetch_array($result)) {
562 if (strcmp($row['type'], $prevtype) == 0) continue;
563 $prevtype = $row['type'];
564 if (strlen($row['provider']) > 0) {
565 // This preserves any existing insurance company selection, which is
566 // important when EOB posting has re-queued for secondary billing.
567 $lhtml .= "<option value=\"" . strtoupper(substr($row['type'],0,1)) . $row['id'] . "\"";
568 if (($count == 0 && !$iter['payer_id']) ||
$row['id'] == $iter['payer_id']) {
569 $lhtml .= " selected";
570 if (!is_numeric($default_x12_partner)) $default_x12_partner = $row['ic_x12id'];
572 $lhtml .= ">" . $row['type'] . ": " . $row['provider'] . "</option>";
577 $lhtml .= "<option value='-1'>Unassigned</option>\n";
578 $lhtml .= "</select> \n";
579 $lhtml .= "<select name='claims[" . $this_encounter_id . "][partner]' style='background-color:$bgcolor'>";
580 $x = new X12Partner();
581 $partners = $x->_utility_array($x->x12_partner_factory());
582 foreach ($partners as $xid => $xname) {
583 $lhtml .= '<option label="' . $xname . '" value="' . $xid .'"';
584 if ($xid == $default_x12_partner) {
585 $lhtml .= "selected";
587 $lhtml .= '>' . $xname . '</option>';
589 $lhtml .= "</select>";
590 $lhtml .= "<br>\n " . substr($iter['date'], 0, 16) . " " .
591 xl("Encounter was coded");
593 $query = "SELECT * FROM claims WHERE " .
594 "patient_id = '" . $iter['enc_pid'] . "' AND " .
595 "encounter_id = '" . $iter['enc_encounter'] . "' " .
597 $cres = sqlStatement($query);
601 while ($crow = sqlFetchArray($cres)) {
602 $query = "SELECT id.type, ic.name " .
603 "FROM insurance_data AS id, insurance_companies AS ic WHERE " .
604 "id.pid = '" . $iter['enc_pid'] . "' AND " .
605 "id.provider = '" . $crow['payer_id'] . "' AND " .
606 "id.date <= '$raw_encounter_date' AND " .
607 "ic.id = id.provider " .
608 "ORDER BY id.type ASC, id.date DESC";
610 $irow= sqlQuery($query);
612 if ($crow['bill_process']) {
613 $lhtml .= "<br>\n " . substr($crow['bill_time'], 0, 16) . " " .
614 xl("Queued for") . " {$irow['type']} {$crow['target']} " .
615 xl("billing to ") . $irow['name'];
618 else if ($crow['status'] > 1) {
619 $lhtml .= "<br>\n " . substr($crow['bill_time'], 0, 16) . " " .
620 xl("Marked as cleared");
624 $lhtml .= "<br>\n " . substr($crow['bill_time'], 0, 16) . " " .
629 if ($crow['process_time']) {
630 $lhtml .= "<br>\n " . substr($crow['process_time'], 0, 16) . " " .
631 xl("Claim was generated to file ") .
632 "<a href='get_claim_file.php?key=" . $crow['process_file'] .
633 "' onclick='top.restoreSession()'>" .
634 $crow['process_file'] . "</a>";
639 } // end while ($crow = sqlFetchArray($cres))
641 if ($lastcrow && $lastcrow['status'] == 4) {
642 $lhtml .= "<br>\n This claim has been closed.";
646 if ($lastcrow && $lastcrow['status'] == 5) {
647 $lhtml .= "<br>\n This claim has been canceled.";
650 } // end if ($iter['id'])
652 } // end if ($last_encounter_id != $this_encounter_id)
654 if ($skipping) continue;
659 $rhtml .= "<tr bgcolor='$bgcolor'>\n";
661 $rhtml .= "<td width='50'>";
662 if ($iter['id'] && $oldcode != $iter['code_type']) {
663 $rhtml .= "<span class=text>" . $iter['code_type'] . ": </span>";
666 $oldcode = $iter['code_type'];
670 if ($iter['id'] && $code_types[$iter['code_type']]['just']) {
671 $js = split(":",$iter['justify']);
673 foreach ($js as $j) {
676 $justify .= " (<b>$j</b>)";
686 $rhtml .= "<td><span class=text>" . $iter{"code"}. "</span>" . '<span style="font-size:8pt;">' . $justify . "</span></td>\n";
687 $rhtml .= '<td align="right"><span style="font-size:8pt;"> ';
688 if ($iter['id'] && $iter['fee'] > 0) {
689 $rhtml .= '$' . $iter['fee'];
691 $rhtml .= "</span></td>\n";
692 $rhtml .= '<td><span style="font-size:8pt;"> ';
693 if ($iter['id']) $rhtml .= getProviderName($iter['provider_id']);
694 $rhtml .= "</span></td>\n";
695 $rhtml .= '<td width=100> <span style="font-size:8pt;">';
696 if ($iter['id']) $rhtml .= date("Y-m-d",strtotime($iter{"date"}));
697 $rhtml .= "</span></td>\n";
698 if ($iter['id'] && $iter['authorized'] != 1) {
699 $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";
702 $rhtml .= "<td></td>\n";
704 if ($iter['id'] && $last_encounter_id != $this_encounter_id) {
705 $tmpbpr = $iter['bill_process'];
706 if ($tmpbpr == '0' && $iter['billed']) $tmpbpr = '2';
707 $rhtml .= "<td><input type='checkbox' value='$tmpbpr' name='claims[" . $this_encounter_id . "][bill]' onclick='set_button_states()'> </td>\n";
710 $rhtml .= "<td></td>\n";
713 $last_encounter_id = $this_encounter_id;
718 while ($rcount < $lcount) {
719 $rhtml .= "<tr bgcolor='$bgcolor'><td colspan='7'> </td></tr>";
722 echo "<tr bgcolor='$bgcolor'>\n<td rowspan='$rcount' valign='top'>\n$lhtml</td>$rhtml\n";
723 echo "<tr bgcolor='$bgcolor'><td colspan='8' height='5'></td></tr>\n";
737 echo "alert('$alertmsg');\n";