The issue of error coming when magic quotes is on is dealt with.We have coded in...
[openemr.git] / interface / billing / billing_report.php
blob73b4c5a89d062912872b5214de4b46851ac0c581
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.
8 // WHEN CONVERT THIS TO NEW SECURITY MODEL, NEED TO REMOVE FOLLOWING
9 // AT APPROXIMATELY LINE 377:
10 // $_REQUEST = stripslashes_deep($_REQUEST);
11 // http://www.openmedsoftware.org/wiki/Active_Projects#PLAN
14 require_once("../globals.php");
15 require_once("../../library/acl.inc");
16 require_once("../../custom/code_types.inc.php");
17 require_once("$srcdir/patient.inc");
18 include_once("$srcdir/../interface/reports/report.inc.php");//Criteria Section common php page
19 require_once("$srcdir/billrep.inc");
20 require_once(dirname(__FILE__) . "/../../library/classes/OFX.class.php");
21 require_once(dirname(__FILE__) . "/../../library/classes/X12Partner.class.php");
22 require_once("$srcdir/formatting.inc.php");
23 require_once("$srcdir/options.inc.php");
24 require_once("adjustment_reason_codes.php");
26 $EXPORT_INC = "$webserver_root/custom/BillingExport.php";
28 $alertmsg = '';
30 if ($_POST['mode'] == 'export') {
31 $sql = ReturnOFXSql();
32 $db = get_db();
33 $results = $db->Execute($sql);
34 $billings = array();
35 if ($results->RecordCount() == 0) {
36 echo xl("No Bills Found to Include in OFX Export<br>");
38 else {
39 while(!$results->EOF) {
40 $billings[] = $results->fields;
41 $results->MoveNext();
43 $ofx = new OFX($billings);
44 header("Pragma: public");
45 header("Expires: 0");
46 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
47 header("Content-Disposition: attachment; filename=openemr_ofx.ofx");
48 header("Content-Type: text/xml");
49 echo $ofx->get_OFX();
50 exit;
55 // This is obsolete.
56 if ($_POST['mode'] == 'process') {
57 if (exec("ps x | grep 'process_bills[.]php'")) {
58 $alertmsg = xl('Request ignored - claims processing is already running!');
60 else {
61 exec("cd $webserver_root/library/freeb;" .
62 "php -q process_bills.php bill > process_bills.log 2>&1 &");
63 $alertmsg = xl('Batch processing initiated; this may take a while.');
67 //global variables:
68 if (!isset($_POST["mode"])) {
69 $from_date = isset($_POST['from_date']) ? $_POST['from_date'] : date('Y-m-d');
70 $to_date = isset($_POST['to_date' ]) ? $_POST['to_date' ] : '';
71 $code_type = isset($_POST['code_type']) ? $_POST['code_type'] : 'all';
72 $unbilled = isset($_POST['unbilled' ]) ? $_POST['unbilled' ] : 'on';
73 $my_authorized = $_POST["authorized"];
74 } else {
75 $from_date = $_POST["from_date"];
76 $to_date = $_POST["to_date"];
77 $code_type = $_POST["code_type"];
78 $unbilled = $_POST["unbilled"];
79 $my_authorized = $_POST["authorized"];
82 // This tells us if only encounters that appear to be missing a "25" modifier
83 // are to be reported.
84 $missing_mods_only = !empty($_POST['missing_mods_only']);
87 $from_date = isset($_POST['from_date']) ? $_POST['from_date'] : date('Y-m-d');
88 $to_date = empty($_POST['to_date' ]) ? $from_date : $_POST['to_date'];
89 $code_type = isset($_POST['code_type']) ? $_POST['code_type'] : 'all';
90 $unbilled = isset($_POST['unbilled' ]) ? $_POST['unbilled' ] : 'on';
91 $my_authorized = $_POST["authorized"];
94 $left_margin = isset($_POST["left_margin"]) ? $_POST["left_margin"] : 24;
95 $top_margin = isset($_POST["top_margin"] ) ? $_POST["top_margin" ] : 20;
97 $ofrom_date = $from_date;
98 $oto_date = $to_date;
99 $ocode_type = $code_type;
100 $ounbilled = $unbilled;
101 $oauthorized = $my_authorized;
104 <html>
105 <head>
106 <?php if (function_exists(html_header_show)) html_header_show(); ?>
107 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css">
108 <style>
109 .subbtn { margin-top:3px; margin-bottom:3px; margin-left:2px; margin-right:2px }
110 </style>
111 <script>
113 function select_all() {
114 for($i=0;$i < document.update_form.length;$i++) {
115 $name = document.update_form[$i].name;
116 if ($name.substring(0,7) == "claims[" && $name.substring($name.length -6) == "[bill]") {
117 document.update_form[$i].checked = true;
120 set_button_states();
123 function set_button_states() {
124 var f = document.update_form;
125 var count0 = 0; // selected and not billed or queued
126 var count1 = 0; // selected and queued
127 var count2 = 0; // selected and billed
128 for($i = 0; $i < f.length; ++$i) {
129 $name = f[$i].name;
130 if ($name.substring(0, 7) == "claims[" && $name.substring($name.length -6) == "[bill]" && f[$i].checked == true) {
131 if (f[$i].value == '0') ++count0;
132 else if (f[$i].value == '1' || f[$i].value == '5') ++count1;
133 else ++count2;
137 var can_generate = (count0 > 0 || count1 > 0 || count2 > 0);
138 var can_mark = (count1 > 0 || count0 > 0 || count2 > 0);
139 var can_bill = (count0 == 0 && count1 == 0 && count2 > 0);
141 <?php if (file_exists($EXPORT_INC)) { ?>
142 f.bn_external.disabled = !can_generate;
143 <?php } else { ?>
144 // f.bn_hcfa_print.disabled = !can_generate;
145 // f.bn_hcfa.disabled = !can_generate;
146 // f.bn_ub92_print.disabled = !can_generate;
147 // f.bn_ub92.disabled = !can_generate;
148 f.bn_x12.disabled = !can_generate;
149 <?php if ($GLOBALS['support_encounter_claims']) { ?>
150 f.bn_x12_encounter.disabled = !can_generate;
151 <?php } ?>
152 f.bn_process_hcfa.disabled = !can_generate;
153 f.bn_hcfa_txt_file.disabled = !can_generate;
154 // f.bn_electronic_file.disabled = !can_bill;
155 f.bn_reopen.disabled = !can_bill;
156 <?php } ?>
157 f.bn_mark.disabled = !can_mark;
160 // Process a click to go to an encounter.
161 function toencounter(pid, pubpid, pname, enc, datestr, dobstr) {
162 top.restoreSession();
163 <?php if ($GLOBALS['concurrent_layout']) { ?>
164 var othername = (window.name == 'RTop') ? 'RBot' : 'RTop';
165 parent.left_nav.setPatient(pname,pid,pubpid,'',dobstr);
166 parent.left_nav.setEncounter(datestr, enc, othername);
167 parent.left_nav.setRadio(othername, 'enc');
168 parent.frames[othername].location.href =
169 '../patient_file/encounter/encounter_top.php?set_encounter='
170 + enc + '&pid=' + pid;
171 <?php } else { ?>
172 location.href = '../patient_file/encounter/patient_encounter.php?set_encounter='
173 + enc + '&pid=' + pid;
174 <?php } ?>
176 // Process a click to go to an patient.
177 function topatient(pid, pubpid, pname, enc, datestr, dobstr) {
178 top.restoreSession();
179 <?php if ($GLOBALS['concurrent_layout']) { ?>
180 var othername = (window.name == 'RTop') ? 'RBot' : 'RTop';
181 parent.left_nav.setPatient(pname,pid,pubpid,'',dobstr);
182 parent.frames[othername].location.href =
183 '../patient_file/summary/demographics_full.php?pid=' + pid;
184 <?php } else { ?>
185 location.href = '../patient_file/summary/demographics_full.php?pid=' + pid;
186 <?php } ?>
188 </script>
189 <script language="javascript" type="text/javascript">
190 EncounterDateArray=new Array;
191 CalendarCategoryArray=new Array;
192 EncounterIdArray=new Array;
193 function SubmitTheScreen()
194 {//Action on Update List link
195 if(!ProcessBeforeSubmitting())
196 return false;
197 top.restoreSession();
198 document.the_form.mode.value='change';
199 document.the_form.target='_self';
200 document.the_form.action='billing_report.php';
201 document.the_form.submit();
202 return true;
204 function SubmitTheScreenPrint()
205 {//Action on View Printable Report link
206 if(!ProcessBeforeSubmitting())
207 return false;
208 top.restoreSession();
209 document.the_form.target='new';
210 document.the_form.action='print_billing_report.php';
211 document.the_form.submit();
212 return true;
214 function SubmitTheScreenExportOFX()
215 {//Action on Export OFX link
216 if(!ProcessBeforeSubmitting())
217 return false;
218 top.restoreSession();
219 document.the_form.mode.value='export';
220 document.the_form.target='_self';
221 document.the_form.action='billing_report.php';
222 document.the_form.submit();
223 return true;
225 function TestExpandCollapse()
226 {//Checks whether the Expand All, Collapse All labels need to be placed.If any result set is there these will be placed.
227 var set=-1;
228 for(i=1;i<=document.getElementById("divnos").value;i++)
230 var ele = document.getElementById("divid_"+i);
231 if(ele)
233 set=1;
234 break;
237 if(set==-1)
239 if(document.getElementById("ExpandAll"))
241 document.getElementById("ExpandAll").innerHTML='';
242 document.getElementById("CollapseAll").innerHTML='';
246 function expandcollapse(atr){
247 if(atr == "expand") {//Called in the Expand All, Collapse All links(All items will be expanded or collapsed)
248 for(i=1;i<=document.getElementById("divnos").value;i++){
249 var mydivid="divid_"+i;var myspanid="spanid_"+i;
250 var ele = document.getElementById(mydivid); var text = document.getElementById(myspanid);
251 if(ele)
253 ele.style.display = "inline";text.innerHTML = "<?php echo htmlspecialchars(xl('Collapse'), ENT_QUOTES); ?>";
257 else {
258 for(i=1;i<=document.getElementById("divnos").value;i++){
259 var mydivid="divid_"+i;var myspanid="spanid_"+i;
260 var ele = document.getElementById(mydivid); var text = document.getElementById(myspanid);
261 if(ele)
263 ele.style.display = "none"; text.innerHTML = "<?php echo htmlspecialchars(xl('Expand'), ENT_QUOTES); ?>";
269 function divtoggle(spanid, divid) {//Called in the Expand, Collapse links(This is for a single item)
270 var ele = document.getElementById(divid);
271 if(ele)
273 var text = document.getElementById(spanid);
274 if(ele.style.display == "inline") {
275 ele.style.display = "none";
276 text.innerHTML = "<?php echo htmlspecialchars(xl('Expand'), ENT_QUOTES); ?>";
278 else {
279 ele.style.display = "inline";
280 text.innerHTML = "<?php echo htmlspecialchars(xl('Collapse'), ENT_QUOTES); ?>";
284 function MarkAsCleared(Type)
286 CheckBoxBillingCount=0;
287 for (var CheckBoxBillingIndex =0; ; CheckBoxBillingIndex++)
289 CheckBoxBillingObject=document.getElementById('CheckBoxBilling'+CheckBoxBillingIndex);
290 if(!CheckBoxBillingObject)
291 break;
292 if(CheckBoxBillingObject.checked)
294 ++CheckBoxBillingCount;
297 if(Type==1)
299 Message='<?php echo htmlspecialchars( xl('After saving your batch, click [View Log] to check for errors.'), ENT_QUOTES); ?>';
301 if(Type==2)
303 Message='<?php echo htmlspecialchars( xl('After saving the PDF, click [View Log] to check for errors.'), ENT_QUOTES); ?>';
305 if(Type==3)
307 Message='<?php echo htmlspecialchars( xl('After saving the TEXT file(s), click [View Log] to check for errors.'), ENT_QUOTES); ?>';
309 if(confirm(Message + "\n\n\n<?php echo htmlspecialchars( xl('Total'), ENT_QUOTES); ?>" + ' ' + CheckBoxBillingCount + ' ' + "<?php echo htmlspecialchars( xl('Selected'), ENT_QUOTES); ?>\n" +
310 "<?php echo htmlspecialchars( xl('Would You Like them to be Marked as Cleared.'), ENT_QUOTES); ?>"))
312 document.getElementById('HiddenMarkAsCleared').value='yes';
314 else
316 document.getElementById('HiddenMarkAsCleared').value='';
319 </script>
320 <?php include_once("$srcdir/../interface/reports/report.script.php"); ?><!-- Criteria Section common javascript page-->
321 <!-- ================================================== -->
322 <!-- =============Included for Insurance ajax criteria==== -->
323 <!-- ================================================== -->
324 <script type="text/javascript" src="../../library/js/jquery.1.3.2.js"></script>
325 <?php include_once("{$GLOBALS['srcdir']}/ajax/payment_ajax_jav.inc.php"); ?>
326 <script type="text/javascript" src="../../library/js/common.js"></script>
327 <style>
328 #ajax_div_insurance {
329 position: absolute;
330 z-index:10;
331 background-color: #FBFDD0;
332 border: 1px solid #ccc;
333 padding: 10px;
335 </style>
336 <script language="javascript" type="text/javascript">
337 document.onclick=TakeActionOnHide;
338 </script>
339 <!-- ================================================== -->
340 <!-- =============Included for Insurance ajax criteria==== -->
341 <!-- ================================================== -->
342 </head>
343 <body class="body_top" onLoad="TestExpandCollapse()">
345 <p style='margin-top:5px;margin-bottom:5px;margin-left:5px'>
347 <?php if ($GLOBALS['concurrent_layout']) { ?>
348 <font class='title'><?php xl('Billing Manager','e') ?></font>
349 <?php } else if ($userauthorized) { ?>
350 <a href="../main/main.php" target='Main' onclick='top.restoreSession()'><font class=title><?php xl('Billing Manager','e') ?></font><font class=more> <?php echo $tback; ?></font></a>
351 <?php } else { ?>
352 <a href="../main/onotes/office_comments.php" target='Main' onclick='top.restoreSession()'><font class=title><?php xl('Billing Manager','e') ?></font><font class=more><?php echo $tback; ?></font></a>
353 <?php } ?>
355 </p>
357 <form name='the_form' method='post' action='billing_report.php' onsubmit='return top.restoreSession()' style="display:inline">
359 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
360 <script type="text/javascript" src="../../library/dialog.js"></script>
361 <script type="text/javascript" src="../../library/textformat.js"></script>
362 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
363 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
364 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
365 <script language='JavaScript'>
366 var mypcc = '1';
367 </script>
369 <input type='hidden' name='mode' value='change'>
370 <!-- ============================================================================================================================================= -->
371 <!-- Criteria section Starts -->
372 <!-- ============================================================================================================================================= -->
373 <?php
374 //The following are the search criteria per page.All the following variable which ends with 'Master' need to be filled properly.
375 //Each item is seperated by a comma(,).
376 //$ThisPageSearchCriteriaDisplayMaster ==>It is the display on screen for the set of criteria.
377 //$ThisPageSearchCriteriaKeyMaster ==>Corresponding database fields in the same order.
378 //$ThisPageSearchCriteriaDataTypeMaster ==>Corresponding data type in the same order.
379 $_REQUEST = stripslashes_deep($_REQUEST);//To deal with magic quotes on.
380 $ThisPageSearchCriteriaDisplayRadioMaster=array();
381 $ThisPageSearchCriteriaRadioKeyMaster=array();
382 $ThisPageSearchCriteriaQueryDropDownMaster=array();
383 $ThisPageSearchCriteriaQueryDropDownMasterDefault=array();
384 $ThisPageSearchCriteriaQueryDropDownMasterDefaultKey=array();
385 $ThisPageSearchCriteriaIncludeMaster=array();
387 $ThisPageSearchCriteriaDisplayMaster="Date of Service,Date of Entry,Date of Billing,Claim Type,Patient Name,".
388 "Patient Id,Insurance Company,Encounter,Whether Insured,Charge Coded,Billing Status,".
389 "Authorization Status,Last Level Billed,X12 Partner";
390 $ThisPageSearchCriteriaKeyMaster="form_encounter.date,billing.date,claims.process_time,claims.target,patient_data.fname,".
391 "form_encounter.pid,claims.payer_id,form_encounter.encounter,insurance_data.provider,billing.id,billing.billed,".
392 "billing.authorized,form_encounter.last_level_billed,billing.x12_partner_id";
393 $ThisPageSearchCriteriaDataTypeMaster="datetime,datetime,datetime,radio,text_like,".
394 "text,include,text,radio,radio,radio,".
395 "radio_like,radio,query_drop_down";
396 //The below section is needed if there is any 'radio' or 'radio_like' type in the $ThisPageSearchCriteriaDataTypeMaster
397 //$ThisPageSearchCriteriaDisplayRadioMaster,$ThisPageSearchCriteriaRadioKeyMaster ==>For each radio data type this pair comes.
398 //The key value 'all' indicates that no action need to be taken based on this.For that the key must be 'all'.Display value can be any thing.
399 $ThisPageSearchCriteriaDisplayRadioMaster[1]="All,eClaims,Paper";//Display Value
400 $ThisPageSearchCriteriaRadioKeyMaster[1]="all,standard,hcfa";//Key
401 $ThisPageSearchCriteriaDisplayRadioMaster[2]="All,Insured,Non-Insured";//Display Value
402 $ThisPageSearchCriteriaRadioKeyMaster[2]="all,1,0";//Key
403 $ThisPageSearchCriteriaDisplayRadioMaster[3]="All,Coded,Not Coded";//Display Value
404 $ThisPageSearchCriteriaRadioKeyMaster[3]="all,not null,null";//Key
405 $ThisPageSearchCriteriaDisplayRadioMaster[4]="All,Unbilled,Billed,Denied";//Display Value
406 $ThisPageSearchCriteriaRadioKeyMaster[4]="all,0,1,7";//Key
407 $ThisPageSearchCriteriaDisplayRadioMaster[5]="All,Authorized,Unauthorized";
408 $ThisPageSearchCriteriaRadioKeyMaster[5]="%,1,0";
409 $ThisPageSearchCriteriaDisplayRadioMaster[6]="All,None,Ins 1,Ins 2 or Ins 3";
410 $ThisPageSearchCriteriaRadioKeyMaster[6]="all,0,1,2";
411 //The below section is needed if there is any 'query_drop_down' type in the $ThisPageSearchCriteriaDataTypeMaster
412 $ThisPageSearchCriteriaQueryDropDownMaster[1]="SELECT name,id FROM x12_partners;";
413 $ThisPageSearchCriteriaQueryDropDownMasterDefault[1]="All";//Only one item will be here
414 $ThisPageSearchCriteriaQueryDropDownMasterDefaultKey[1]="all";//Only one item will be here
415 //The below section is needed if there is any 'include' type in the $ThisPageSearchCriteriaDataTypeMaster
416 //Function name is added here.Corresponding include files need to be included in the respective pages as done in this page.
417 //It is labled(Included for Insurance ajax criteria)(Line:-279-299).
418 $ThisPageSearchCriteriaIncludeMaster[1]="InsuranceCompanyDisplay";//This is php function defined in the file 'report.inc.php'
420 if(!isset($_REQUEST['mode']))//default case
422 $_REQUEST['final_this_page_criteria'][0]="(form_encounter.date between '".date("Y-m-d 00:00:00")."' and '".date("Y-m-d 23:59:59")."')";
423 $_REQUEST['final_this_page_criteria'][1]="billing.billed = '0'";
425 $_REQUEST['final_this_page_criteria_text'][0]=htmlspecialchars(xl("Date of Service = Today"), ENT_QUOTES);
426 $_REQUEST['final_this_page_criteria_text'][1]=htmlspecialchars(xl("Billing Status = Unbilled"), ENT_QUOTES);
428 $_REQUEST['date_master_criteria_form_encounter_date']="today";
429 $_REQUEST['master_from_date_form_encounter_date']=date("Y-m-d");
430 $_REQUEST['master_to_date_form_encounter_date']=date("Y-m-d");
432 $_REQUEST['radio_billing_billed']=0;
436 <table width='100%' border="0" cellspacing="0" cellpadding="0">
437 <tr>
438 <td width="25%">&nbsp;</td>
439 <td width="50%">
440 <?php include_once("$srcdir/../interface/reports/criteria.tab.php"); ?>
441 </td>
442 <td width="25%">
443 <?php
444 // ============================================================================================================================================= -->
445 // Criteria section Ends -->
446 // ============================================================================================================================================= -->
449 <table width="100%" border="0" cellspacing="0" cellpadding="0">
450 <tr>
451 <td width="15%">&nbsp;</td>
452 <td width="85%"><span class='text'><a onClick="javascript:return SubmitTheScreen();" href="#" class=link_submit>[<?php echo htmlspecialchars(xl('Update List'), ENT_QUOTES) ?>]</a>
454 <a onClick="javascript:return SubmitTheScreenExportOFX();" href="#" class='link_submit'><?php echo htmlspecialchars(xl('[Export OFX]'), ENT_QUOTES) ?></a></span> </td>
455 </tr>
456 <tr>
457 <td>&nbsp;</td>
458 <td><a onClick="javascript:return SubmitTheScreenPrint();" href="#"
459 class='link_submit' ><?php echo htmlspecialchars(xl('[View Printable Report]'), ENT_QUOTES) ?></a></td>
460 </tr>
461 <tr>
462 <td>&nbsp;</td>
463 <td>
464 <?php
465 $acct_config = $GLOBALS['oer_config']['ws_accounting'];
466 if($acct_config['enabled']) {
467 if($acct_config['enabled'] !== 2) {
468 print '<span class=text><a href="javascript:void window.open(\'' . $acct_config['url_path'] . '\')">' . htmlspecialchars(xl("[SQL-Ledger]"), ENT_QUOTES) . '</a> &nbsp; </span>';
470 if (acl_check('acct', 'rep')) {
471 print '<span class=text><a href="javascript:void window.open(\'sl_receipts_report.php\')" onclick="top.restoreSession()">' . htmlspecialchars(xl('[Reports]'), ENT_QUOTES) . '</a> &nbsp; </span>';
473 if (acl_check('acct', 'eob')) {
474 print '<span class=text><a href="javascript:void window.open(\'sl_eob_search.php\')" onclick="top.restoreSession()">' . htmlspecialchars(xl('[EOBs]'), ENT_QUOTES) . '</a></span>';
478 </td>
479 </tr>
480 <tr>
481 <td>&nbsp;</td>
482 <td>
483 <?php if (! file_exists($EXPORT_INC)) { ?>
484 <!--
485 <a href="javascript:top.restoreSession();document.the_form.mode.value='process';document.the_form.submit()" class="link_submit"
486 title="Process all queued bills to create electronic data (and print if requested)"><?php echo htmlspecialchars(xl('[Start Batch Processing]'), ENT_QUOTES) ?></a>
487 &nbsp;
489 <a href='../../library/freeb/process_bills.php' target='_blank' class='link_submit'
490 title='<?php htmlspecialchars(xl('See messages from the last set of generated claims'), ENT_QUOTES); ?>'><?php echo htmlspecialchars(xl('[View Log]'), ENT_QUOTES) ?></a>
491 <?php } ?>
492 </td>
493 </tr>
494 <tr>
495 <td>&nbsp;</td>
496 <td><a href="javascript:select_all()" class="link_submit"><?php echo htmlspecialchars(xl('[Select All]','e'), ENT_QUOTES) ?></a></td>
497 </tr>
498 </table>
501 </td>
502 </tr>
503 </table>
504 <table width='100%' border="0" cellspacing="0" cellpadding="0" >
505 <tr>
506 <td>
507 <hr color="#000000">
508 </td>
509 </tr>
510 </table>
511 </form>
512 <form name='update_form' method='post' action='billing_process.php' onsubmit='return top.restoreSession()' style="display:inline">
513 <center>
514 <span class='text' style="display:inline">
515 <?php if (file_exists($EXPORT_INC)) { ?>
516 <input type="submit" class="subbtn" name="bn_external" value="Export Billing" title="<?php xl('Export to external billing system','e') ?>">
517 <input type="submit" class="subbtn" name="bn_mark" value="Mark as Cleared" title="<?php xl('Mark as billed but skip billing','e') ?>">
518 <?php } else { ?>
519 <!--
520 <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') ?>">
521 <input type="submit" class="subbtn" name="bn_hcfa" value="Queue HCFA" title="<?php xl('Queue for HCFA batch processing','e')?>">
522 <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')?>">
523 <input type="submit" class="subbtn" name="bn_ub92" value="Queue UB92" title="<?php xl('Queue for UB-92 batch processing','e')?>">
525 <input type="submit" class="subbtn" name="bn_x12" value="<?php xl('Generate X12','e')?>"
526 title="<?php xl('Generate and download X12 batch','e')?>"
527 onclick="MarkAsCleared(1)">
528 <?php if ($GLOBALS['support_encounter_claims']) { ?>
529 <input type="submit" class="subbtn" name="bn_x12_encounter" value="<?php xl('Generate X12 Encounter','e')?>"
530 title="<?php xl('Generate and download X12 encounter claim batch','e')?>"
531 onclick="MarkAsCleared(1)">
532 <?php } ?>
533 <input type="submit" class="subbtn" style="width:175px;" name="bn_process_hcfa" value="<?php xl('Generate CMS 1500 PDF','e')?>"
534 title="<?php xl('Generate and download CMS 1500 paper claims','e')?>"
535 onclick="MarkAsCleared(2)">
536 <input type="submit" class="subbtn" style="width:175px;" name="bn_hcfa_txt_file" value="<?php xl('Generate CMS 1500 TEXT','e')?>"
537 title="<?php xl('Making batch text files for uploading to Clearing House and will mark as billed', 'e')?>"
538 onclick="MarkAsCleared(3)">
539 <input type="submit" class="subbtn" name="bn_mark" value="<?php xl('Mark as Cleared','e')?>" title="<?php xl('Post to accounting and mark as billed','e')?>">
540 <input type="submit" class="subbtn" name="bn_reopen" value="<?php xl('Re-Open','e')?>" title="<?php xl('Mark as not billed','e')?>">
541 <!--
542 <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')?>">
544 &nbsp;&nbsp;&nbsp;
545 <?php xl('CMS 1500 Margins','e'); ?>:
546 &nbsp;<?php xl('Left','e'); ?>:
547 <input type='text' size='2' name='left_margin'
548 value='<?php echo $left_margin; ?>'
549 title=<?php xl('HCFA left margin in points','e','\'','\''); ?> />
550 &nbsp;<?php xl('Top','e'); ?>:
551 <input type='text' size='2' name='top_margin'
552 value='<?php echo $top_margin; ?>'
553 title=<?php xl('HCFA top margin in points','e','\'','\''); ?> />
554 </span>
555 <?php } ?>
557 </center>
558 <input type='hidden' name='HiddenMarkAsCleared' id='HiddenMarkAsCleared' value="" />
559 <input type='hidden' name='mode' value="bill" />
560 <input type='hidden' name='authorized' value="<?php echo $my_authorized; ?>" />
561 <input type='hidden' name='unbilled' value="<?php echo $unbilled; ?>" />
562 <input type='hidden' name='code_type' value="%" />
563 <input type='hidden' name='to_date' value="<?php echo $to_date; ?>" />
564 <input type='hidden' name='from_date' value="<?php echo $from_date; ?>" />
566 <?php
567 if ($my_authorized == "on" ) {
568 $my_authorized = "1";
569 } else {
570 $my_authorized = "%";
572 if ($unbilled == "on") {
573 $unbilled = "0";
574 } else {
575 $unbilled = "%";
577 $list = getBillsListBetween("%");
580 <input type='hidden' name='bill_list' value="<?php echo $list; ?>" />
582 <!-- new form for uploading -->
584 <?php
585 if (!isset($_POST["mode"])) {
586 if (!isset($_POST["from_date"])) {
587 $from_date = date("Y-m-d");
588 } else {
589 $from_date = $_POST["from_date"];
591 if (empty($_POST["to_date"])) {
592 $to_date = '';
593 } else {
594 $to_date = $_POST["to_date"];
596 if (!isset($_POST["code_type"])) {
597 $code_type="all";
598 } else {
599 $code_type = $_POST["code_type"];
601 if (!isset($_POST["unbilled"])) {
602 $unbilled = "on";
603 } else {
604 $unbilled = $_POST["unbilled"];
606 if (!isset($_POST["authorized"])) {
607 $my_authorized = "on";
608 } else {
609 $my_authorized = $_POST["authorized"];
611 } else {
612 $from_date = $_POST["from_date"];
613 $to_date = $_POST["to_date"];
614 $code_type = $_POST["code_type"];
615 $unbilled = $_POST["unbilled"];
616 $my_authorized = $_POST["authorized"];
619 if ($my_authorized == "on" ) {
620 $my_authorized = "1";
621 } else {
622 $my_authorized = "%";
625 if ($unbilled == "on") {
626 $unbilled = "0";
627 } else {
628 $unbilled = "%";
631 if (isset($_POST["mode"]) && $_POST["mode"] == "bill") {
632 billCodesList($list);
636 <table border="0" cellspacing="0" cellpadding="0" width="100%">
638 <?php
639 if ($ret = getBillsBetween("%"))
641 if(is_array($ret))
644 <tr ><td colspan='8' align="right" ><table width="250" border="0" cellspacing="0" cellpadding="0">
645 <tr>
646 <td width="100" id='ExpandAll'><a onclick="expandcollapse('expand');" class='small' href="JavaScript:void(0);"><?php echo '('.htmlspecialchars( xl('Expand All'), ENT_QUOTES).')' ?></a></td>
647 <td width="100" id='CollapseAll'><a onclick="expandcollapse('collapse');" class='small' href="JavaScript:void(0);"><?php echo '('.htmlspecialchars( xl('Collapse All'), ENT_QUOTES).')' ?></a></td>
648 <td width="50">&nbsp;</td>
649 </tr>
650 </table>
651 </td></tr>
652 <?php
654 $loop = 0;
655 $oldcode = "";
656 $last_encounter_id = "";
657 $lhtml = "";
658 $rhtml = "";
659 $lcount = 0;
660 $rcount = 0;
661 $bgcolor = "";
662 $skipping = FALSE;
664 $mmo_empty_mod = false;
665 $mmo_num_charges = 0;
666 $divnos=0;
668 foreach ($ret as $iter) {
670 // We include encounters here that have never been billed. However
671 // if it had no selected billing items but does have non-selected
672 // billing items, then it is not of interest.
673 if (!$iter['id']) {
674 $res = sqlQuery("SELECT count(*) AS count FROM billing WHERE " .
675 "encounter = '" . $iter['enc_encounter'] . "' AND " .
676 "pid='" . $iter['enc_pid'] . "' AND " .
677 "activity = 1");
678 if ($res['count'] > 0) continue;
681 $this_encounter_id = $iter['enc_pid'] . "-" . $iter['enc_encounter'];
683 if ($last_encounter_id != $this_encounter_id) {
685 // This dumps all HTML for the previous encounter.
687 if ($lhtml) {
688 while ($rcount < $lcount) {
689 $rhtml .= "<tr bgcolor='$bgcolor'><td colspan='7'></td></tr>";
690 ++$rcount;
692 // This test handles the case where we are only listing encounters
693 // that appear to have a missing "25" modifier.
694 if (!$missing_mods_only || ($mmo_empty_mod && $mmo_num_charges > 1)) {
695 if($DivPut=='yes')
697 $lhtml.='</div>';
698 $DivPut='no';
700 echo "<tr bgcolor='$bgcolor'>\n<td rowspan='$rcount' valign='top'>\n$lhtml</td>$rhtml\n";
701 echo "<tr bgcolor='$bgcolor'><td colspan='8' height='5'></td></tr>\n\n";
702 ++$encount;
706 $lhtml = "";
707 $rhtml = "";
708 $mmo_empty_mod = false;
709 $mmo_num_charges = 0;
711 // If there are ANY unauthorized items in this encounter and this is
712 // the normal case of viewing only authorized billing, then skip the
713 // entire encounter.
715 $skipping = FALSE;
716 if ($my_authorized == '1') {
717 $res = sqlQuery("select count(*) as count from billing where " .
718 "encounter = '" . $iter['enc_encounter'] . "' and " .
719 "pid='" . $iter['enc_pid'] . "' and " .
720 "activity = 1 and authorized = 0");
721 if ($res['count'] > 0) {
722 $skipping = TRUE;
723 $last_encounter_id = $this_encounter_id;
724 continue;
728 $name = getPatientData($iter['enc_pid'], "fname, mname, lname, pubpid, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
730 # Check if patient has primary insurance and a subscriber exists for it.
731 # If not we will highlight their name in red.
732 # TBD: more checking here.
734 $res = sqlQuery("select count(*) as count from insurance_data where " .
735 "pid = " . $iter['enc_pid'] . " and " .
736 "type='primary' and " .
737 "subscriber_lname is not null and " .
738 "subscriber_lname != '' limit 1");
739 $namecolor = ($res['count'] > 0) ? "black" : "#ff7777";
741 $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
742 echo "<tr bgcolor='$bgcolor'><td colspan='8' height='5'></td></tr>\n";
743 $lcount = 1;
744 $rcount = 0;
745 $oldcode = "";
747 $ptname = $name['fname'] . " " . $name['lname'];
748 $raw_encounter_date = date("Y-m-d", strtotime($iter['enc_date']));
750 // Add Encounter Date to display with "To Encounter" button 2/17/09 JCH
751 $lhtml .= "&nbsp;<span class=bold><font color='$namecolor'>$ptname" .
752 "</font></span><span class=small>&nbsp;(" . $iter['enc_pid'] . "-" .
753 $iter['enc_encounter'] . ")</span>";
755 //Encounter details are stored to javacript as array.
756 $result4 = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe ".
757 " left join openemr_postcalendar_categories on fe.pc_catid=openemr_postcalendar_categories.pc_catid WHERE fe.pid = '".$iter['enc_pid']."' order by fe.date desc");
758 if(sqlNumRows($result4)>0)
760 <script language='JavaScript'>
761 Count=0;
762 EncounterDateArray[<?php echo $iter['enc_pid']; ?>]=new Array;
763 CalendarCategoryArray[<?php echo $iter['enc_pid']; ?>]=new Array;
764 EncounterIdArray[<?php echo $iter['enc_pid']; ?>]=new Array;
765 <?php
766 while($rowresult4 = sqlFetchArray($result4))
769 EncounterIdArray[<?php echo $iter['enc_pid']; ?>][Count]='<?php echo htmlspecialchars($rowresult4['encounter'], ENT_QUOTES); ?>';
770 EncounterDateArray[<?php echo $iter['enc_pid']; ?>][Count]='<?php echo htmlspecialchars(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date']))), ENT_QUOTES); ?>';
771 CalendarCategoryArray[<?php echo $iter['enc_pid']; ?>][Count]='<?php echo htmlspecialchars( xl_appt_category($rowresult4['pc_catname']), ENT_QUOTES); ?>';
772 Count++;
773 <?php
776 </script>
777 <?php
779 // Not sure why the next section seems to do nothing except post "To Encounter" button 2/17/09 JCH
780 $lhtml .= "&nbsp;&nbsp;&nbsp;<a class=\"link_submit\" " .
781 "href=\"javascript:window.toencounter(" . $iter['enc_pid'] .
782 ",'" . addslashes($name['pubpid']) .
783 "','" . addslashes($ptname) . "'," . $iter['enc_encounter'] .
784 ",'" . oeFormatShortDate($raw_encounter_date) . "',' " .
785 xl('DOB') . ": " . oeFormatShortDate($name['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAge($name['DOB_YMD']) . "');
786 top.window.parent.left_nav.setPatientEncounter(EncounterIdArray[" . $iter['enc_pid'] . "],EncounterDateArray[" . $iter['enc_pid'] .
787 "], CalendarCategoryArray[" . $iter['enc_pid'] . "])\">[" .
788 xl('To Enctr') . " " . oeFormatShortDate($raw_encounter_date) . "]</a>";
790 // Changed "To xxx" buttons to allow room for encounter date display 2/17/09 JCH
791 $lhtml .= "&nbsp;&nbsp;&nbsp;<a class=\"link_submit\" " .
792 "href=\"javascript:window.topatient(" . $iter['enc_pid'] .
793 ",'" . addslashes($name['pubpid']) .
794 "','" . addslashes($ptname) . "'," . $iter['enc_encounter'] .
795 ",'" . oeFormatShortDate($raw_encounter_date) . "',' " .
796 xl('DOB') . ": " . oeFormatShortDate($name['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAge($name['DOB_YMD']) . "');
797 top.window.parent.left_nav.setPatientEncounter(EncounterIdArray[" . $iter['enc_pid'] . "],EncounterDateArray[" . $iter['enc_pid'] .
798 "], CalendarCategoryArray[" . $iter['enc_pid'] . "])\">[" . xl('To Dems') . "]</a>";
799 $divnos=$divnos+1;
800 $lhtml .= "&nbsp;&nbsp;&nbsp;<a onclick='divtoggle(\"spanid_$divnos\",\"divid_$divnos\");' class='small' id='aid_$divnos' href=\"JavaScript:void(0);".
801 "\">(<span id=spanid_$divnos class=\"indicator\">" . htmlspecialchars( xl('Expand'), ENT_QUOTES) . "</span>)</a>";
803 if ($iter['id']) {
805 $lcount += 2;
806 $lhtml .= "<br />\n";
807 $lhtml .= "&nbsp;<span class=text>Bill: ";
808 $lhtml .= "<select name='claims[" . $this_encounter_id . "][payer]' style='background-color:$bgcolor'>";
810 $query = "SELECT id.provider AS id, id.type, id.date, " .
811 "ic.x12_default_partner_id AS ic_x12id, ic.name AS provider " .
812 "FROM insurance_data AS id, insurance_companies AS ic WHERE " .
813 "ic.id = id.provider AND " .
814 "id.pid = '" . mysql_escape_string($iter['enc_pid']) . "' AND " .
815 "id.date <= '$raw_encounter_date' " .
816 "ORDER BY id.type ASC, id.date DESC";
818 $result = sqlStatement($query);
819 $count = 0;
820 $default_x12_partner = $iter['ic_x12id'];
821 $prevtype = '';
823 while ($row = mysql_fetch_array($result)) {
824 if (strcmp($row['type'], $prevtype) == 0) continue;
825 $prevtype = $row['type'];
826 if (strlen($row['provider']) > 0) {
827 // This preserves any existing insurance company selection, which is
828 // important when EOB posting has re-queued for secondary billing.
829 $lhtml .= "<option value=\"" . strtoupper(substr($row['type'],0,1)) . $row['id'] . "\"";
830 if (($count == 0 && !$iter['payer_id']) || $row['id'] == $iter['payer_id']) {
831 $lhtml .= " selected";
832 if (!is_numeric($default_x12_partner)) $default_x12_partner = $row['ic_x12id'];
834 $lhtml .= ">" . $row['type'] . ": " . $row['provider'] . "</option>";
836 $count++;
839 $lhtml .= "<option value='-1'>Unassigned</option>\n";
840 $lhtml .= "</select>&nbsp;&nbsp;\n";
841 $lhtml .= "<select name='claims[" . $this_encounter_id . "][partner]' style='background-color:$bgcolor'>";
842 $x = new X12Partner();
843 $partners = $x->_utility_array($x->x12_partner_factory());
844 foreach ($partners as $xid => $xname) {
845 $lhtml .= '<option label="' . $xname . '" value="' . $xid .'"';
846 if ($xid == $default_x12_partner) {
847 $lhtml .= "selected";
849 $lhtml .= '>' . $xname . '</option>';
851 $lhtml .= "</select>";
852 $DivPut='yes';
853 $lhtml .= "<br>\n&nbsp;<div id='divid_$divnos' style='display:none'>" . oeFormatShortDate(substr($iter['date'], 0, 10))
854 . substr($iter['date'], 10, 6) . " " . xl("Encounter was coded");
856 $query = "SELECT * FROM claims WHERE " .
857 "patient_id = '" . $iter['enc_pid'] . "' AND " .
858 "encounter_id = '" . $iter['enc_encounter'] . "' " .
859 "ORDER BY version";
860 $cres = sqlStatement($query);
862 $lastcrow = false;
864 while ($crow = sqlFetchArray($cres)) {
865 $query = "SELECT id.type, ic.name " .
866 "FROM insurance_data AS id, insurance_companies AS ic WHERE " .
867 "id.pid = '" . $iter['enc_pid'] . "' AND " .
868 "id.provider = '" . $crow['payer_id'] . "' AND " .
869 "id.date <= '$raw_encounter_date' AND " .
870 "ic.id = id.provider " .
871 "ORDER BY id.type ASC, id.date DESC";
873 $irow= sqlQuery($query);
875 if ($crow['bill_process']) {
876 $lhtml .= "<br>\n&nbsp;" .
877 oeFormatShortDate(substr($crow['bill_time'], 0, 10)) .
878 substr($crow['bill_time'], 10, 6) . " " .
879 xl("Queued for") . " {$irow['type']} {$crow['target']} " .
880 xl("billing to ") . $irow['name'];
881 ++$lcount;
883 else if ($crow['status'] < 6) {
884 if ($crow['status'] > 1) {
885 $lhtml .= "<br>\n&nbsp;" .
886 oeFormatShortDate(substr($crow['bill_time'], 0, 10)) .
887 substr($crow['bill_time'], 10, 6) . " " .
888 htmlspecialchars( xl("Marked as cleared"), ENT_QUOTES);
889 ++$lcount;
891 else {
892 $lhtml .= "<br>\n&nbsp;" .
893 oeFormatShortDate(substr($crow['bill_time'], 0, 10)) .
894 substr($crow['bill_time'], 10, 6) . " " .
895 htmlspecialchars( xl("Re-opened"), ENT_QUOTES);
896 ++$lcount;
899 else if ($crow['status'] == 6) {
900 $lhtml .= "<br>\n&nbsp;" .
901 oeFormatShortDate(substr($crow['bill_time'], 0, 10)) .
902 substr($crow['bill_time'], 10, 6) . " " .
903 htmlspecialchars( xl("This claim has been forwarded to next level."), ENT_QUOTES);
904 ++$lcount;
906 else if ($crow['status'] == 7) {
907 $lhtml .= "<br>\n&nbsp;" .
908 oeFormatShortDate(substr($crow['bill_time'], 0, 10)) .
909 substr($crow['bill_time'], 10, 6) . " " .
910 htmlspecialchars( xl("This claim has been denied.Reason:-"), ENT_QUOTES);
911 if($crow['process_file'])
913 $code_array=split(',',$crow['process_file']);
914 foreach($code_array as $code_key => $code_value)
916 $lhtml .= "<br>\n&nbsp;&nbsp;&nbsp;";
917 $reason_array=split('_',$code_value);
918 if(!isset($adjustment_reasons[$reason_array[3]]))
920 $lhtml .=htmlspecialchars( xl("For code"), ENT_QUOTES).' ['.$reason_array[0].'] '.htmlspecialchars( xl("and modifier"), ENT_QUOTES).' ['.$reason_array[1].'] '.htmlspecialchars( xl("the Denial code is"), ENT_QUOTES).' ['.$reason_array[2].' '.$reason_array[3].']';
922 else
924 $lhtml .=htmlspecialchars( xl("For code"), ENT_QUOTES).' ['.$reason_array[0].'] '.htmlspecialchars( xl("and modifier"), ENT_QUOTES).' ['.$reason_array[1].'] '.htmlspecialchars( xl("the Denial Group code is"), ENT_QUOTES).' ['.$reason_array[2].'] '.htmlspecialchars( xl("and the Reason is"), ENT_QUOTES).':- '.$adjustment_reasons[$reason_array[3]];
928 else
930 $lhtml .=htmlspecialchars( xl("Not Specified."), ENT_QUOTES);
932 ++$lcount;
935 if ($crow['process_time']) {
936 $lhtml .= "<br>\n&nbsp;" .
937 oeFormatShortDate(substr($crow['process_time'], 0, 10)) .
938 substr($crow['process_time'], 10, 6) . " " .
939 xl("Claim was generated to file ") .
940 "<a href='get_claim_file.php?key=" . $crow['process_file'] .
941 "' onclick='top.restoreSession()'>" .
942 $crow['process_file'] . "</a>";
943 ++$lcount;
946 $lastcrow = $crow;
947 } // end while ($crow = sqlFetchArray($cres))
949 if ($lastcrow && $lastcrow['status'] == 4) {
950 $lhtml .= "<br>\n&nbsp;This claim has been closed.";
951 ++$lcount;
954 if ($lastcrow && $lastcrow['status'] == 5) {
955 $lhtml .= "<br>\n&nbsp;This claim has been canceled.";
956 ++$lcount;
958 } // end if ($iter['id'])
960 } // end if ($last_encounter_id != $this_encounter_id)
962 if ($skipping) continue;
964 // Collect info related to the missing modifiers test.
965 if ($iter['fee'] > 0) {
966 ++$mmo_num_charges;
967 $tmp = substr($iter['code'], 0, 3);
968 if (($tmp == '992' || $tmp == '993') && empty($iter['modifier']))
969 $mmo_empty_mod = true;
972 ++$rcount;
974 if ($rhtml) {
975 $rhtml .= "<tr bgcolor='$bgcolor'>\n";
977 $rhtml .= "<td width='50'>";
978 if ($iter['id'] && $oldcode != $iter['code_type']) {
979 $rhtml .= "<span class=text>" . $iter['code_type'] . ": </span>";
982 $oldcode = $iter['code_type'];
983 $rhtml .= "</td>\n";
984 $justify = "";
986 if ($iter['id'] && $code_types[$iter['code_type']]['just']) {
987 $js = split(":",$iter['justify']);
988 $counter = 0;
989 foreach ($js as $j) {
990 if(!empty($j)) {
991 if ($counter == 0) {
992 $justify .= " (<b>$j</b>)";
994 else {
995 $justify .= " ($j)";
997 $counter++;
1002 $rhtml .= "<td><span class='text'>" .
1003 ($iter['code_type'] == 'COPAY' ? oeFormatMoney($iter['code']) : $iter['code']);
1004 if ($iter['modifier']) $rhtml .= ":" . $iter['modifier'];
1005 $rhtml .= "</span><span style='font-size:8pt;'>$justify</span></td>\n";
1007 $rhtml .= '<td align="right"><span style="font-size:8pt;">&nbsp;&nbsp;&nbsp;';
1008 if ($iter['id'] && $iter['fee'] > 0) {
1009 $rhtml .= oeFormatMoney($iter['fee']);
1011 $rhtml .= "</span></td>\n";
1012 $rhtml .= '<td><span style="font-size:8pt;">&nbsp;&nbsp;&nbsp;';
1013 if ($iter['id']) $rhtml .= getProviderName(empty($iter['provider_id']) ? $iter['enc_provider_id'] : $iter['provider_id']);
1014 $rhtml .= "</span></td>\n";
1015 $rhtml .= '<td width=100>&nbsp;&nbsp;&nbsp;<span style="font-size:8pt;">';
1016 if ($iter['id']) $rhtml .= oeFormatSDFT(strtotime($iter{"date"}));
1017 $rhtml .= "</span></td>\n";
1018 if ($iter['id'] && $iter['authorized'] != 1) {
1019 $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";
1021 else {
1022 $rhtml .= "<td></td>\n";
1024 if ($iter['id'] && $last_encounter_id != $this_encounter_id) {
1025 $tmpbpr = $iter['bill_process'];
1026 if ($tmpbpr == '0' && $iter['billed']) $tmpbpr = '2';
1027 $rhtml .= "<td><input type='checkbox' value='$tmpbpr' name='claims[" . $this_encounter_id . "][bill]' onclick='set_button_states()' id='CheckBoxBilling" . $CheckBoxBilling*1 . "'>&nbsp;</td>\n";
1028 $CheckBoxBilling++;
1030 else {
1031 $rhtml .= "<td></td>\n";
1033 $rhtml .= "</tr>\n";
1034 $last_encounter_id = $this_encounter_id;
1036 } // end foreach
1038 if ($lhtml) {
1039 while ($rcount < $lcount) {
1040 $rhtml .= "<tr bgcolor='$bgcolor'><td colspan='7'></td></tr>";
1041 ++$rcount;
1043 if (!$missing_mods_only || ($mmo_empty_mod && $mmo_num_charges > 1)) {
1044 if($DivPut=='yes')
1046 $lhtml.='</div>';
1047 $DivPut='no';
1049 echo "<tr bgcolor='$bgcolor'>\n<td rowspan='$rcount' valign='top'>\n$lhtml</td>$rhtml\n";
1050 echo "<tr bgcolor='$bgcolor'><td colspan='8' height='5'></td></tr>\n";
1058 </table>
1059 </form>
1061 <script>
1062 set_button_states();
1063 <?php
1064 if ($alertmsg) {
1065 echo "alert('$alertmsg');\n";
1068 </script>
1069 <input type="hidden" name="divnos" id="divnos" value="<?php echo $divnos ?>"/>
1070 <input type='hidden' name='ajax_mode' id='ajax_mode' value='' />
1071 </body>
1072 </html>