The Third Reminders email bug fix - contributed by arnabnaha
[openemr.git] / interface / billing / billing_report.php
blobf337e5bad2125d809a6e6591bb7dc9243a4ac4ae
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.
7 $fake_register_globals=false;
8 $sanitize_all_escapes=true;
10 require_once("../globals.php");
11 require_once("../../library/acl.inc");
12 require_once("../../custom/code_types.inc.php");
13 require_once("$srcdir/patient.inc");
14 include_once("$srcdir/../interface/reports/report.inc.php");//Criteria Section common php page
15 require_once("$srcdir/billrep.inc");
16 require_once(dirname(__FILE__) . "/../../library/classes/OFX.class.php");
17 require_once(dirname(__FILE__) . "/../../library/classes/X12Partner.class.php");
18 require_once("$srcdir/formatting.inc.php");
19 require_once("$srcdir/options.inc.php");
20 require_once("adjustment_reason_codes.php");
22 $EXPORT_INC = "$webserver_root/custom/BillingExport.php";
24 $alertmsg = '';
26 if ($_POST['mode'] == 'export') {
27 $sql = ReturnOFXSql();
28 $db = get_db();
29 $results = $db->Execute($sql);
30 $billings = array();
31 if ($results->RecordCount() == 0) {
32 echo xlt("No Bills Found to Include in OFX Export")."<br>";
34 else {
35 while(!$results->EOF) {
36 $billings[] = $results->fields;
37 $results->MoveNext();
39 $ofx = new OFX($billings);
40 header("Pragma: public");
41 header("Expires: 0");
42 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
43 header("Content-Disposition: attachment; filename=openemr_ofx.ofx");
44 header("Content-Type: text/xml");
45 echo $ofx->get_OFX();
46 exit;
51 // This is obsolete.
52 if ($_POST['mode'] == 'process') {
53 if (exec("ps x | grep 'process_bills[.]php'")) {
54 $alertmsg = xl('Request ignored - claims processing is already running!');
56 else {
57 exec("cd $webserver_root/library/freeb;" .
58 "php -q process_bills.php bill > process_bills.log 2>&1 &");
59 $alertmsg = xl('Batch processing initiated; this may take a while.');
63 //global variables:
64 if (!isset($_POST["mode"])) {
65 $from_date = isset($_POST['from_date']) ? $_POST['from_date'] : date('Y-m-d');
66 $to_date = isset($_POST['to_date' ]) ? $_POST['to_date' ] : '';
67 $code_type = isset($_POST['code_type']) ? $_POST['code_type'] : 'all';
68 $unbilled = isset($_POST['unbilled' ]) ? $_POST['unbilled' ] : 'on';
69 $my_authorized = $_POST["authorized"];
70 } else {
71 $from_date = $_POST["from_date"];
72 $to_date = $_POST["to_date"];
73 $code_type = $_POST["code_type"];
74 $unbilled = $_POST["unbilled"];
75 $my_authorized = $_POST["authorized"];
78 // This tells us if only encounters that appear to be missing a "25" modifier
79 // are to be reported.
80 $missing_mods_only = !empty($_POST['missing_mods_only']);
83 $from_date = isset($_POST['from_date']) ? $_POST['from_date'] : date('Y-m-d');
84 $to_date = empty($_POST['to_date' ]) ? $from_date : $_POST['to_date'];
85 $code_type = isset($_POST['code_type']) ? $_POST['code_type'] : 'all';
86 $unbilled = isset($_POST['unbilled' ]) ? $_POST['unbilled' ] : 'on';
87 $my_authorized = $_POST["authorized"];
90 $left_margin = isset($_POST["left_margin"]) ? $_POST["left_margin"] : 24;
91 $top_margin = isset($_POST["top_margin"] ) ? $_POST["top_margin" ] : 20;
93 $ofrom_date = $from_date;
94 $oto_date = $to_date;
95 $ocode_type = $code_type;
96 $ounbilled = $unbilled;
97 $oauthorized = $my_authorized;
100 <html>
101 <head>
102 <?php if (function_exists(html_header_show)) html_header_show(); ?>
103 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css">
104 <style>
105 .subbtn { margin-top:3px; margin-bottom:3px; margin-left:2px; margin-right:2px }
106 </style>
107 <script>
109 function select_all() {
110 for($i=0;$i < document.update_form.length;$i++) {
111 $name = document.update_form[$i].name;
112 if ($name.substring(0,7) == "claims[" && $name.substring($name.length -6) == "[bill]") {
113 document.update_form[$i].checked = true;
116 set_button_states();
119 function set_button_states() {
120 var f = document.update_form;
121 var count0 = 0; // selected and not billed or queued
122 var count1 = 0; // selected and queued
123 var count2 = 0; // selected and billed
124 for($i = 0; $i < f.length; ++$i) {
125 $name = f[$i].name;
126 if ($name.substring(0, 7) == "claims[" && $name.substring($name.length -6) == "[bill]" && f[$i].checked == true) {
127 if (f[$i].value == '0') ++count0;
128 else if (f[$i].value == '1' || f[$i].value == '5') ++count1;
129 else ++count2;
133 var can_generate = (count0 > 0 || count1 > 0 || count2 > 0);
134 var can_mark = (count1 > 0 || count0 > 0 || count2 > 0);
135 var can_bill = (count0 == 0 && count1 == 0 && count2 > 0);
137 <?php if (file_exists($EXPORT_INC)) { ?>
138 f.bn_external.disabled = !can_generate;
139 <?php } else { ?>
140 // f.bn_hcfa_print.disabled = !can_generate;
141 // f.bn_hcfa.disabled = !can_generate;
142 // f.bn_ub92_print.disabled = !can_generate;
143 // f.bn_ub92.disabled = !can_generate;
144 f.bn_x12.disabled = !can_generate;
145 <?php if ($GLOBALS['support_encounter_claims']) { ?>
146 f.bn_x12_encounter.disabled = !can_generate;
147 <?php } ?>
148 f.bn_process_hcfa.disabled = !can_generate;
149 f.bn_hcfa_txt_file.disabled = !can_generate;
150 // f.bn_electronic_file.disabled = !can_bill;
151 f.bn_reopen.disabled = !can_bill;
152 <?php } ?>
153 f.bn_mark.disabled = !can_mark;
156 // Process a click to go to an encounter.
157 function toencounter(pid, pubpid, pname, enc, datestr, dobstr) {
158 top.restoreSession();
159 <?php if ($GLOBALS['concurrent_layout']) { ?>
160 var othername = (window.name == 'RTop') ? 'RBot' : 'RTop';
161 parent.left_nav.setPatient(pname,pid,pubpid,'',dobstr);
162 parent.left_nav.setEncounter(datestr, enc, othername);
163 parent.left_nav.setRadio(othername, 'enc');
164 parent.frames[othername].location.href =
165 '../patient_file/encounter/encounter_top.php?set_encounter='
166 + enc + '&pid=' + pid;
167 <?php } else { ?>
168 location.href = '../patient_file/encounter/patient_encounter.php?set_encounter='
169 + enc + '&pid=' + pid;
170 <?php } ?>
172 // Process a click to go to an patient.
173 function topatient(pid, pubpid, pname, enc, datestr, dobstr) {
174 top.restoreSession();
175 <?php if ($GLOBALS['concurrent_layout']) { ?>
176 var othername = (window.name == 'RTop') ? 'RBot' : 'RTop';
177 parent.left_nav.setPatient(pname,pid,pubpid,'',dobstr);
178 parent.frames[othername].location.href =
179 '../patient_file/summary/demographics_full.php?pid=' + pid;
180 <?php } else { ?>
181 location.href = '../patient_file/summary/demographics_full.php?pid=' + pid;
182 <?php } ?>
184 </script>
185 <script language="javascript" type="text/javascript">
186 EncounterDateArray=new Array;
187 CalendarCategoryArray=new Array;
188 EncounterIdArray=new Array;
189 function SubmitTheScreen()
190 {//Action on Update List link
191 if(!ProcessBeforeSubmitting())
192 return false;
193 top.restoreSession();
194 document.the_form.mode.value='change';
195 document.the_form.target='_self';
196 document.the_form.action='billing_report.php';
197 document.the_form.submit();
198 return true;
200 function SubmitTheScreenPrint()
201 {//Action on View Printable Report link
202 if(!ProcessBeforeSubmitting())
203 return false;
204 top.restoreSession();
205 document.the_form.target='new';
206 document.the_form.action='print_billing_report.php';
207 document.the_form.submit();
208 return true;
210 function SubmitTheScreenExportOFX()
211 {//Action on Export OFX link
212 if(!ProcessBeforeSubmitting())
213 return false;
214 top.restoreSession();
215 document.the_form.mode.value='export';
216 document.the_form.target='_self';
217 document.the_form.action='billing_report.php';
218 document.the_form.submit();
219 return true;
221 function TestExpandCollapse()
222 {//Checks whether the Expand All, Collapse All labels need to be placed.If any result set is there these will be placed.
223 var set=-1;
224 for(i=1;i<=document.getElementById("divnos").value;i++)
226 var ele = document.getElementById("divid_"+i);
227 if(ele)
229 set=1;
230 break;
233 if(set==-1)
235 if(document.getElementById("ExpandAll"))
237 document.getElementById("ExpandAll").innerHTML='';
238 document.getElementById("CollapseAll").innerHTML='';
242 function expandcollapse(atr){
243 if(atr == "expand") {//Called in the Expand All, Collapse All links(All items will be expanded or collapsed)
244 for(i=1;i<=document.getElementById("divnos").value;i++){
245 var mydivid="divid_"+i;var myspanid="spanid_"+i;
246 var ele = document.getElementById(mydivid); var text = document.getElementById(myspanid);
247 if(ele)
249 ele.style.display = "inline";text.innerHTML = "<?php echo htmlspecialchars(xl('Collapse'), ENT_QUOTES); ?>";
253 else {
254 for(i=1;i<=document.getElementById("divnos").value;i++){
255 var mydivid="divid_"+i;var myspanid="spanid_"+i;
256 var ele = document.getElementById(mydivid); var text = document.getElementById(myspanid);
257 if(ele)
259 ele.style.display = "none"; text.innerHTML = "<?php echo htmlspecialchars(xl('Expand'), ENT_QUOTES); ?>";
265 function divtoggle(spanid, divid) {//Called in the Expand, Collapse links(This is for a single item)
266 var ele = document.getElementById(divid);
267 if(ele)
269 var text = document.getElementById(spanid);
270 if(ele.style.display == "inline") {
271 ele.style.display = "none";
272 text.innerHTML = "<?php echo htmlspecialchars(xl('Expand'), ENT_QUOTES); ?>";
274 else {
275 ele.style.display = "inline";
276 text.innerHTML = "<?php echo htmlspecialchars(xl('Collapse'), ENT_QUOTES); ?>";
280 function MarkAsCleared(Type)
282 CheckBoxBillingCount=0;
283 for (var CheckBoxBillingIndex =0; ; CheckBoxBillingIndex++)
285 CheckBoxBillingObject=document.getElementById('CheckBoxBilling'+CheckBoxBillingIndex);
286 if(!CheckBoxBillingObject)
287 break;
288 if(CheckBoxBillingObject.checked)
290 ++CheckBoxBillingCount;
293 if(Type==1)
295 Message='<?php echo htmlspecialchars( xl('After saving your batch, click [View Log] to check for errors.'), ENT_QUOTES); ?>';
297 if(Type==2)
299 Message='<?php echo htmlspecialchars( xl('After saving the PDF, click [View Log] to check for errors.'), ENT_QUOTES); ?>';
301 if(Type==3)
303 Message='<?php echo htmlspecialchars( xl('After saving the TEXT file(s), click [View Log] to check for errors.'), ENT_QUOTES); ?>';
305 if(confirm(Message + "\n\n\n<?php echo addslashes( xl('Total') ); ?>" + ' ' + CheckBoxBillingCount + ' ' + "<?php echo addslashes( xl('Selected') ); ?>\n" +
306 "<?php echo addslashes( xl('Would You Like them to be Marked as Cleared.') ); ?>"))
308 document.getElementById('HiddenMarkAsCleared').value='yes';
310 else
312 document.getElementById('HiddenMarkAsCleared').value='';
315 </script>
316 <?php include_once("$srcdir/../interface/reports/report.script.php"); ?><!-- Criteria Section common javascript page-->
317 <!-- ================================================== -->
318 <!-- =============Included for Insurance ajax criteria==== -->
319 <!-- ================================================== -->
320 <script type="text/javascript" src="../../library/js/jquery.1.3.2.js"></script>
321 <?php include_once("{$GLOBALS['srcdir']}/ajax/payment_ajax_jav.inc.php"); ?>
322 <script type="text/javascript" src="../../library/js/common.js"></script>
323 <style>
324 #ajax_div_insurance {
325 position: absolute;
326 z-index:10;
327 background-color: #FBFDD0;
328 border: 1px solid #ccc;
329 padding: 10px;
331 </style>
332 <script language="javascript" type="text/javascript">
333 document.onclick=TakeActionOnHide;
334 </script>
335 <!-- ================================================== -->
336 <!-- =============Included for Insurance ajax criteria==== -->
337 <!-- ================================================== -->
338 </head>
339 <body class="body_top" onLoad="TestExpandCollapse()">
341 <p style='margin-top:5px;margin-bottom:5px;margin-left:5px'>
343 <?php if ($GLOBALS['concurrent_layout']) { ?>
344 <font class='title'><?php echo xlt('Billing Manager') ?></font>
345 <?php } else if ($userauthorized) { ?>
346 <a href="../main/main.php" target='Main' onclick='top.restoreSession()'><font class=title><?php echo xlt('Billing Manager') ?></font><font class=more> <?php echo $tback; ?></font></a>
347 <?php } else { ?>
348 <a href="../main/onotes/office_comments.php" target='Main' onclick='top.restoreSession()'><font class=title><?php echo xlt('Billing Manager') ?></font><font class=more><?php echo $tback; ?></font></a>
349 <?php } ?>
351 </p>
353 <form name='the_form' method='post' action='billing_report.php' onsubmit='return top.restoreSession()' style="display:inline">
355 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
356 <script type="text/javascript" src="../../library/dialog.js"></script>
357 <script type="text/javascript" src="../../library/textformat.js"></script>
358 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
359 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
360 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
361 <script language='JavaScript'>
362 var mypcc = '1';
363 </script>
365 <input type='hidden' name='mode' value='change'>
366 <!-- ============================================================================================================================================= -->
367 <!-- Criteria section Starts -->
368 <!-- ============================================================================================================================================= -->
369 <?php
370 //The following are the search criteria per page.All the following variable which ends with 'Master' need to be filled properly.
371 //Each item is seperated by a comma(,).
372 //$ThisPageSearchCriteriaDisplayMaster ==>It is the display on screen for the set of criteria.
373 //$ThisPageSearchCriteriaKeyMaster ==>Corresponding database fields in the same order.
374 //$ThisPageSearchCriteriaDataTypeMaster ==>Corresponding data type in the same order.
375 $ThisPageSearchCriteriaDisplayRadioMaster=array();
376 $ThisPageSearchCriteriaRadioKeyMaster=array();
377 $ThisPageSearchCriteriaQueryDropDownMaster=array();
378 $ThisPageSearchCriteriaQueryDropDownMasterDefault=array();
379 $ThisPageSearchCriteriaQueryDropDownMasterDefaultKey=array();
380 $ThisPageSearchCriteriaIncludeMaster=array();
382 $ThisPageSearchCriteriaDisplayMaster= array( xl("Date of Service"),xl("Date of Entry"),xl("Date of Billing"),xl("Claim Type"),xl("Patient Name"),xl("Patient Id"),xl("Insurance Company"),xl("Encounter"),xl("Whether Insured"),xl("Charge Coded"),xl("Billing Status"),xl("Authorization Status"),xl("Last Level Billed"),xl("X12 Partner") );
383 $ThisPageSearchCriteriaKeyMaster="form_encounter.date,billing.date,claims.process_time,claims.target,patient_data.fname,".
384 "form_encounter.pid,claims.payer_id,form_encounter.encounter,insurance_data.provider,billing.id,billing.billed,".
385 "billing.authorized,form_encounter.last_level_billed,billing.x12_partner_id";
386 $ThisPageSearchCriteriaDataTypeMaster="datetime,datetime,datetime,radio,text_like,".
387 "text,include,text,radio,radio,radio,".
388 "radio_like,radio,query_drop_down";
389 //The below section is needed if there is any 'radio' or 'radio_like' type in the $ThisPageSearchCriteriaDataTypeMaster
390 //$ThisPageSearchCriteriaDisplayRadioMaster,$ThisPageSearchCriteriaRadioKeyMaster ==>For each radio data type this pair comes.
391 //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.
392 $ThisPageSearchCriteriaDisplayRadioMaster[1] = array( xl("All"),xl("eClaims"),xl("Paper") );//Display Value
393 $ThisPageSearchCriteriaRadioKeyMaster[1]="all,standard,hcfa";//Key
394 $ThisPageSearchCriteriaDisplayRadioMaster[2]= array( xl("All"),xl("Insured"),xl("Non-Insured") );//Display Value
395 $ThisPageSearchCriteriaRadioKeyMaster[2]="all,1,0";//Key
396 $ThisPageSearchCriteriaDisplayRadioMaster[3]= array( xl("All"),xl("Coded"),xl("Not Coded") );//Display Value
397 $ThisPageSearchCriteriaRadioKeyMaster[3]="all,not null,null";//Key
398 $ThisPageSearchCriteriaDisplayRadioMaster[4]= array( xl("All"),xl("Unbilled"),xl("Billed"),xl("Denied") );//Display Value
399 $ThisPageSearchCriteriaRadioKeyMaster[4]="all,0,1,7";//Key
400 $ThisPageSearchCriteriaDisplayRadioMaster[5]= array( xl("All"),xl("Authorized"),xl("Unauthorized") );
401 $ThisPageSearchCriteriaRadioKeyMaster[5]="%,1,0";
402 $ThisPageSearchCriteriaDisplayRadioMaster[6]= array( xl("All"),xl("None"),xl("Ins 1"),xl("Ins 2 or Ins 3") );
403 $ThisPageSearchCriteriaRadioKeyMaster[6]="all,0,1,2";
404 //The below section is needed if there is any 'query_drop_down' type in the $ThisPageSearchCriteriaDataTypeMaster
405 $ThisPageSearchCriteriaQueryDropDownMaster[1]="SELECT name,id FROM x12_partners;";
406 $ThisPageSearchCriteriaQueryDropDownMasterDefault[1]= xl("All");//Only one item will be here
407 $ThisPageSearchCriteriaQueryDropDownMasterDefaultKey[1]="all";//Only one item will be here
408 //The below section is needed if there is any 'include' type in the $ThisPageSearchCriteriaDataTypeMaster
409 //Function name is added here.Corresponding include files need to be included in the respective pages as done in this page.
410 //It is labled(Included for Insurance ajax criteria)(Line:-279-299).
411 $ThisPageSearchCriteriaIncludeMaster[1]="InsuranceCompanyDisplay";//This is php function defined in the file 'report.inc.php'
413 if(!isset($_REQUEST['mode']))//default case
415 $_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")."')";
416 $_REQUEST['final_this_page_criteria'][1]="billing.billed = '0'";
418 $_REQUEST['final_this_page_criteria_text'][0]=xl("Date of Service = Today");
419 $_REQUEST['final_this_page_criteria_text'][1]=xl("Billing Status = Unbilled");
421 $_REQUEST['date_master_criteria_form_encounter_date']="today";
422 $_REQUEST['master_from_date_form_encounter_date']=date("Y-m-d");
423 $_REQUEST['master_to_date_form_encounter_date']=date("Y-m-d");
425 $_REQUEST['radio_billing_billed']=0;
429 <table width='100%' border="0" cellspacing="0" cellpadding="0">
430 <tr>
431 <td width="25%">&nbsp;</td>
432 <td width="50%">
433 <?php include_once("$srcdir/../interface/reports/criteria.tab.php"); ?>
434 </td>
435 <td width="25%">
436 <?php
437 // ============================================================================================================================================= -->
438 // Criteria section Ends -->
439 // ============================================================================================================================================= -->
442 <table width="100%" border="0" cellspacing="0" cellpadding="0">
443 <tr>
444 <td width="15%">&nbsp;</td>
445 <td width="85%"><span class='text'><a onClick="javascript:return SubmitTheScreen();" href="#" class=link_submit>[<?php echo htmlspecialchars(xl('Update List'), ENT_QUOTES) ?>]</a>
447 <a onClick="javascript:return SubmitTheScreenExportOFX();" href="#" class='link_submit'><?php echo htmlspecialchars(xl('[Export OFX]'), ENT_QUOTES) ?></a></span> </td>
448 </tr>
449 <tr>
450 <td>&nbsp;</td>
451 <td><a onClick="javascript:return SubmitTheScreenPrint();" href="#"
452 class='link_submit' ><?php echo htmlspecialchars(xl('[View Printable Report]'), ENT_QUOTES) ?></a></td>
453 </tr>
454 <tr>
455 <td>&nbsp;</td>
456 <td>
457 <?php
458 $acct_config = $GLOBALS['oer_config']['ws_accounting'];
459 if($acct_config['enabled']) {
460 if($acct_config['enabled'] !== 2) {
461 print '<span class=text><a href="javascript:void window.open(\'' . $acct_config['url_path'] . '\')">' . htmlspecialchars(xl("[SQL-Ledger]"), ENT_QUOTES) . '</a> &nbsp; </span>';
463 if (acl_check('acct', 'rep')) {
464 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>';
466 if (acl_check('acct', 'eob')) {
467 print '<span class=text><a href="javascript:void window.open(\'sl_eob_search.php\')" onclick="top.restoreSession()">' . htmlspecialchars(xl('[EOBs]'), ENT_QUOTES) . '</a></span>';
471 </td>
472 </tr>
473 <tr>
474 <td>&nbsp;</td>
475 <td>
476 <?php if (! file_exists($EXPORT_INC)) { ?>
477 <!--
478 <a href="javascript:top.restoreSession();document.the_form.mode.value='process';document.the_form.submit()" class="link_submit"
479 title="Process all queued bills to create electronic data (and print if requested)"><?php echo htmlspecialchars(xl('[Start Batch Processing]'), ENT_QUOTES) ?></a>
480 &nbsp;
482 <a href='../../library/freeb/process_bills.log' target='_blank' class='link_submit'
483 title='<?php htmlspecialchars(xl('See messages from the last set of generated claims'), ENT_QUOTES); ?>'><?php echo htmlspecialchars(xl('[View Log]'), ENT_QUOTES) ?></a>
484 <?php } ?>
485 </td>
486 </tr>
487 <tr>
488 <td>&nbsp;</td>
489 <td><a href="javascript:select_all()" class="link_submit"><?php echo htmlspecialchars(xl('[Select All]','e'), ENT_QUOTES) ?></a></td>
490 </tr>
491 </table>
494 </td>
495 </tr>
496 </table>
497 <table width='100%' border="0" cellspacing="0" cellpadding="0" >
498 <tr>
499 <td>
500 <hr color="#000000">
501 </td>
502 </tr>
503 </table>
504 </form>
505 <form name='update_form' method='post' action='billing_process.php' onsubmit='return top.restoreSession()' style="display:inline">
506 <center>
507 <span class='text' style="display:inline">
508 <?php if (file_exists($EXPORT_INC)) { ?>
509 <input type="submit" class="subbtn" name="bn_external" value="Export Billing" title="<?php echo xla('Export to external billing system') ?>">
510 <input type="submit" class="subbtn" name="bn_mark" value="Mark as Cleared" title="<?php echo xla('Mark as billed but skip billing') ?>">
511 <?php } else { ?>
512 <!--
513 <input type="submit" class="subbtn" name="bn_hcfa_print" value="Queue HCFA &amp; Print" title="<?php echo xla('Queue for HCFA batch processing and printing') ?>">
514 <input type="submit" class="subbtn" name="bn_hcfa" value="Queue HCFA" title="<?php echo xla('Queue for HCFA batch processing')?>">
515 <input type="submit" class="subbtn" name="bn_ub92_print" value="Queue UB92 &amp; Print" title="<?php echo xla('Queue for UB-92 batch processing and printing')?>">
516 <input type="submit" class="subbtn" name="bn_ub92" value="Queue UB92" title="<?php echo xla('Queue for UB-92 batch processing')?>">
518 <input type="submit" class="subbtn" name="bn_x12" value="<?php echo xla('Generate X12')?>"
519 title="<?php echo xla('Generate and download X12 batch')?>"
520 onclick="MarkAsCleared(1)">
521 <?php if ($GLOBALS['support_encounter_claims']) { ?>
522 <input type="submit" class="subbtn" name="bn_x12_encounter" value="<?php echo xla('Generate X12 Encounter')?>"
523 title="<?php echo xla('Generate and download X12 encounter claim batch')?>"
524 onclick="MarkAsCleared(1)">
525 <?php } ?>
526 <input type="submit" class="subbtn" style="width:175px;" name="bn_process_hcfa" value="<?php echo xla('Generate CMS 1500 PDF')?>"
527 title="<?php echo xla('Generate and download CMS 1500 paper claims')?>"
528 onclick="MarkAsCleared(2)">
529 <input type="submit" class="subbtn" style="width:175px;" name="bn_hcfa_txt_file" value="<?php echo xla('Generate CMS 1500 TEXT')?>"
530 title="<?php echo xla('Making batch text files for uploading to Clearing House and will mark as billed')?>"
531 onclick="MarkAsCleared(3)">
532 <input type="submit" class="subbtn" name="bn_mark" value="<?php echo xla('Mark as Cleared')?>" title="<?php echo xla('Post to accounting and mark as billed')?>">
533 <input type="submit" class="subbtn" name="bn_reopen" value="<?php echo xla('Re-Open')?>" title="<?php echo xla('Mark as not billed')?>">
534 <!--
535 <input type="submit" class="subbtn" name="bn_electronic_file" value="Make Electronic Batch &amp; Clear" title="<?php echo xla('Download billing file, post to accounting and mark as billed')?>">
537 &nbsp;&nbsp;&nbsp;
538 <?php echo xlt('CMS 1500 Margins'); ?>:
539 &nbsp;<?php echo xlt('Left'); ?>:
540 <input type='text' size='2' name='left_margin'
541 value='<?php echo attr($left_margin); ?>'
542 title='<?php echo xla('HCFA left margin in points'); ?>' />
543 &nbsp;<?php echo xlt('Top'); ?>:
544 <input type='text' size='2' name='top_margin'
545 value='<?php echo attr($top_margin); ?>'
546 title='<?php echo xla('HCFA top margin in points'); ?>' />
547 </span>
548 <?php } ?>
550 </center>
551 <input type='hidden' name='HiddenMarkAsCleared' id='HiddenMarkAsCleared' value="" />
552 <input type='hidden' name='mode' value="bill" />
553 <input type='hidden' name='authorized' value="<?php echo attr($my_authorized); ?>" />
554 <input type='hidden' name='unbilled' value="<?php echo attr($unbilled); ?>" />
555 <input type='hidden' name='code_type' value="%" />
556 <input type='hidden' name='to_date' value="<?php echo attr($to_date); ?>" />
557 <input type='hidden' name='from_date' value="<?php echo attr($from_date); ?>" />
559 <?php
560 if ($my_authorized == "on" ) {
561 $my_authorized = "1";
562 } else {
563 $my_authorized = "%";
565 if ($unbilled == "on") {
566 $unbilled = "0";
567 } else {
568 $unbilled = "%";
570 $list = getBillsListBetween("%");
573 <input type='hidden' name='bill_list' value="<?php echo attr($list); ?>" />
575 <!-- new form for uploading -->
577 <?php
578 if (!isset($_POST["mode"])) {
579 if (!isset($_POST["from_date"])) {
580 $from_date = date("Y-m-d");
581 } else {
582 $from_date = $_POST["from_date"];
584 if (empty($_POST["to_date"])) {
585 $to_date = '';
586 } else {
587 $to_date = $_POST["to_date"];
589 if (!isset($_POST["code_type"])) {
590 $code_type="all";
591 } else {
592 $code_type = $_POST["code_type"];
594 if (!isset($_POST["unbilled"])) {
595 $unbilled = "on";
596 } else {
597 $unbilled = $_POST["unbilled"];
599 if (!isset($_POST["authorized"])) {
600 $my_authorized = "on";
601 } else {
602 $my_authorized = $_POST["authorized"];
604 } else {
605 $from_date = $_POST["from_date"];
606 $to_date = $_POST["to_date"];
607 $code_type = $_POST["code_type"];
608 $unbilled = $_POST["unbilled"];
609 $my_authorized = $_POST["authorized"];
612 if ($my_authorized == "on" ) {
613 $my_authorized = "1";
614 } else {
615 $my_authorized = "%";
618 if ($unbilled == "on") {
619 $unbilled = "0";
620 } else {
621 $unbilled = "%";
624 if (isset($_POST["mode"]) && $_POST["mode"] == "bill") {
625 billCodesList($list);
629 <table border="0" cellspacing="0" cellpadding="0" width="100%">
631 <?php
632 if ($ret = getBillsBetween("%"))
634 if(is_array($ret))
637 <tr ><td colspan='8' align="right" ><table width="250" border="0" cellspacing="0" cellpadding="0">
638 <tr>
639 <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>
640 <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>
641 <td width="50">&nbsp;</td>
642 </tr>
643 </table>
644 </td></tr>
645 <?php
647 $loop = 0;
648 $oldcode = "";
649 $last_encounter_id = "";
650 $lhtml = "";
651 $rhtml = "";
652 $lcount = 0;
653 $rcount = 0;
654 $bgcolor = "";
655 $skipping = FALSE;
657 $mmo_empty_mod = false;
658 $mmo_num_charges = 0;
659 $divnos=0;
661 foreach ($ret as $iter) {
663 // We include encounters here that have never been billed. However
664 // if it had no selected billing items but does have non-selected
665 // billing items, then it is not of interest.
666 if (!$iter['id']) {
667 $res = sqlQuery("SELECT count(*) AS count FROM billing WHERE " .
668 "encounter = ? AND " .
669 "pid=? AND " .
670 "activity = 1", array($iter['enc_encounter'],$iter['enc_pid']) );
671 if ($res['count'] > 0) continue;
674 $this_encounter_id = $iter['enc_pid'] . "-" . $iter['enc_encounter'];
676 if ($last_encounter_id != $this_encounter_id) {
678 // This dumps all HTML for the previous encounter.
680 if ($lhtml) {
681 while ($rcount < $lcount) {
682 $rhtml .= "<tr bgcolor='$bgcolor'><td colspan='7'></td></tr>";
683 ++$rcount;
685 // This test handles the case where we are only listing encounters
686 // that appear to have a missing "25" modifier.
687 if (!$missing_mods_only || ($mmo_empty_mod && $mmo_num_charges > 1)) {
688 if($DivPut=='yes')
690 $lhtml.='</div>';
691 $DivPut='no';
693 echo "<tr bgcolor='$bgcolor'>\n<td rowspan='$rcount' valign='top'>\n$lhtml</td>$rhtml\n";
694 echo "<tr bgcolor='$bgcolor'><td colspan='8' height='5'></td></tr>\n\n";
695 ++$encount;
699 $lhtml = "";
700 $rhtml = "";
701 $mmo_empty_mod = false;
702 $mmo_num_charges = 0;
704 // If there are ANY unauthorized items in this encounter and this is
705 // the normal case of viewing only authorized billing, then skip the
706 // entire encounter.
708 $skipping = FALSE;
709 if ($my_authorized == '1') {
710 $res = sqlQuery("select count(*) as count from billing where " .
711 "encounter = ? and " .
712 "pid=? and " .
713 "activity = 1 and authorized = 0", array($iter['enc_encounter'],$iter['enc_pid']) );
714 if ($res['count'] > 0) {
715 $skipping = TRUE;
716 $last_encounter_id = $this_encounter_id;
717 continue;
721 $name = getPatientData($iter['enc_pid'], "fname, mname, lname, pubpid, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
723 # Check if patient has primary insurance and a subscriber exists for it.
724 # If not we will highlight their name in red.
725 # TBD: more checking here.
727 $res = sqlQuery("select count(*) as count from insurance_data where " .
728 "pid = ? and " .
729 "type='primary' and " .
730 "subscriber_lname is not null and " .
731 "subscriber_lname != '' limit 1", array($iter['enc_pid']) );
732 $namecolor = ($res['count'] > 0) ? "black" : "#ff7777";
734 $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
735 echo "<tr bgcolor='$bgcolor'><td colspan='8' height='5'></td></tr>\n";
736 $lcount = 1;
737 $rcount = 0;
738 $oldcode = "";
740 $ptname = $name['fname'] . " " . $name['lname'];
741 $raw_encounter_date = date("Y-m-d", strtotime($iter['enc_date']));
743 // Add Encounter Date to display with "To Encounter" button 2/17/09 JCH
744 $lhtml .= "&nbsp;<span class=bold><font color='$namecolor'>". text($ptname) .
745 "</font></span><span class=small>&nbsp;(" . text($iter['enc_pid']) . "-" .
746 text($iter['enc_encounter']) . ")</span>";
748 //Encounter details are stored to javacript as array.
749 $result4 = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe ".
750 " left join openemr_postcalendar_categories on fe.pc_catid=openemr_postcalendar_categories.pc_catid WHERE fe.pid = ? order by fe.date desc", array($iter['enc_pid']) );
751 if(sqlNumRows($result4)>0)
753 <script language='JavaScript'>
754 Count=0;
755 EncounterDateArray[<?php echo attr($iter['enc_pid']); ?>]=new Array;
756 CalendarCategoryArray[<?php echo attr($iter['enc_pid']); ?>]=new Array;
757 EncounterIdArray[<?php echo attr($iter['enc_pid']); ?>]=new Array;
758 <?php
759 while($rowresult4 = sqlFetchArray($result4))
762 EncounterIdArray[<?php echo attr($iter['enc_pid']); ?>][Count]='<?php echo htmlspecialchars($rowresult4['encounter'], ENT_QUOTES); ?>';
763 EncounterDateArray[<?php echo attr($iter['enc_pid']); ?>][Count]='<?php echo htmlspecialchars(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date']))), ENT_QUOTES); ?>';
764 CalendarCategoryArray[<?php echo attr($iter['enc_pid']); ?>][Count]='<?php echo htmlspecialchars( xl_appt_category($rowresult4['pc_catname']), ENT_QUOTES); ?>';
765 Count++;
766 <?php
769 </script>
770 <?php
772 // Not sure why the next section seems to do nothing except post "To Encounter" button 2/17/09 JCH
773 $lhtml .= "&nbsp;&nbsp;&nbsp;<a class=\"link_submit\" " .
774 "href=\"javascript:window.toencounter(" . $iter['enc_pid'] .
775 ",'" . addslashes($name['pubpid']) .
776 "','" . addslashes($ptname) . "'," . $iter['enc_encounter'] .
777 ",'" . oeFormatShortDate($raw_encounter_date) . "',' " .
778 xl('DOB') . ": " . oeFormatShortDate($name['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAge($name['DOB_YMD']) . "');
779 top.window.parent.left_nav.setPatientEncounter(EncounterIdArray[" . $iter['enc_pid'] . "],EncounterDateArray[" . $iter['enc_pid'] .
780 "], CalendarCategoryArray[" . $iter['enc_pid'] . "])\">[" .
781 xlt('To Enctr') . " " . text(oeFormatShortDate($raw_encounter_date)) . "]</a>";
783 // Changed "To xxx" buttons to allow room for encounter date display 2/17/09 JCH
784 $lhtml .= "&nbsp;&nbsp;&nbsp;<a class=\"link_submit\" " .
785 "href=\"javascript:window.topatient(" . $iter['enc_pid'] .
786 ",'" . addslashes($name['pubpid']) .
787 "','" . addslashes($ptname) . "'," . $iter['enc_encounter'] .
788 ",'" . oeFormatShortDate($raw_encounter_date) . "',' " .
789 xl('DOB') . ": " . oeFormatShortDate($name['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAge($name['DOB_YMD']) . "');
790 top.window.parent.left_nav.setPatientEncounter(EncounterIdArray[" . $iter['enc_pid'] . "],EncounterDateArray[" . $iter['enc_pid'] .
791 "], CalendarCategoryArray[" . $iter['enc_pid'] . "])\">[" . xlt('To Dems') . "]</a>";
792 $divnos=$divnos+1;
793 $lhtml .= "&nbsp;&nbsp;&nbsp;<a onclick='divtoggle(\"spanid_$divnos\",\"divid_$divnos\");' class='small' id='aid_$divnos' href=\"JavaScript:void(0);".
794 "\">(<span id=spanid_$divnos class=\"indicator\">" . htmlspecialchars( xl('Expand'), ENT_QUOTES) . "</span>)</a>";
796 if ($iter['id']) {
798 $lcount += 2;
799 $lhtml .= "<br />\n";
800 $lhtml .= "&nbsp;<span class=text>Bill: ";
801 $lhtml .= "<select name='claims[" . attr($this_encounter_id) . "][payer]' style='background-color:$bgcolor'>";
803 $query = "SELECT id.provider AS id, id.type, id.date, " .
804 "ic.x12_default_partner_id AS ic_x12id, ic.name AS provider " .
805 "FROM insurance_data AS id, insurance_companies AS ic WHERE " .
806 "ic.id = id.provider AND " .
807 "id.pid = ? AND " .
808 "id.date <= ? " .
809 "ORDER BY id.type ASC, id.date DESC";
811 $result = sqlStatement($query, array($iter['enc_pid'],$raw_encounter_date) );
812 $count = 0;
813 $default_x12_partner = $iter['ic_x12id'];
814 $prevtype = '';
816 while ($row = sqlFetchArray($result)) {
817 if (strcmp($row['type'], $prevtype) == 0) continue;
818 $prevtype = $row['type'];
819 if (strlen($row['provider']) > 0) {
820 // This preserves any existing insurance company selection, which is
821 // important when EOB posting has re-queued for secondary billing.
822 $lhtml .= "<option value=\"" . attr(substr($row['type'],0,1).$row['id']) . "\"";
823 if (($count == 0 && !$iter['payer_id']) || $row['id'] == $iter['payer_id']) {
824 $lhtml .= " selected";
825 if (!is_numeric($default_x12_partner)) $default_x12_partner = $row['ic_x12id'];
827 $lhtml .= ">" . text($row['type']) . ": " . text($row['provider']) . "</option>";
829 $count++;
832 $lhtml .= "<option value='-1'>" . xlt("Unassigned") . "</option>\n";
833 $lhtml .= "</select>&nbsp;&nbsp;\n";
834 $lhtml .= "<select name='claims[" . attr($this_encounter_id) . "][partner]' style='background-color:$bgcolor'>";
835 $x = new X12Partner();
836 $partners = $x->_utility_array($x->x12_partner_factory());
837 foreach ($partners as $xid => $xname) {
838 $lhtml .= '<option label="' . attr($xname) . '" value="' . attr($xid) .'"';
839 if ($xid == $default_x12_partner) {
840 $lhtml .= "selected";
842 $lhtml .= '>' . text($xname) . '</option>';
844 $lhtml .= "</select>";
845 $DivPut='yes';
846 $lhtml .= "<br>\n&nbsp;<div id='divid_$divnos' style='display:none'>" . text(oeFormatShortDate(substr($iter['date'], 0, 10)))
847 . text(substr($iter['date'], 10, 6)) . " " . xlt("Encounter was coded");
849 $query = "SELECT * FROM claims WHERE " .
850 "patient_id = ? AND " .
851 "encounter_id = ? " .
852 "ORDER BY version";
853 $cres = sqlStatement($query, array($iter['enc_pid'],$iter['enc_encounter']) );
855 $lastcrow = false;
857 while ($crow = sqlFetchArray($cres)) {
858 $query = "SELECT id.type, ic.name " .
859 "FROM insurance_data AS id, insurance_companies AS ic WHERE " .
860 "id.pid = ? AND " .
861 "id.provider = ? AND " .
862 "id.date <= ? AND " .
863 "ic.id = id.provider " .
864 "ORDER BY id.type ASC, id.date DESC";
866 $irow= sqlQuery($query, array($iter['enc_pid'],$crow['payer_id'],$raw_encounter_date) );
868 if ($crow['bill_process']) {
869 $lhtml .= "<br>\n&nbsp;" .
870 text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) .
871 text(substr($crow['bill_time'], 10, 6)) . " " .
872 xlt("Queued for") . " " . text($irow['type']) . " " . text($crow['target']) . " " .
873 xlt("billing to ") . text($irow['name']);
874 ++$lcount;
876 else if ($crow['status'] < 6) {
877 if ($crow['status'] > 1) {
878 $lhtml .= "<br>\n&nbsp;" .
879 text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) .
880 text(substr($crow['bill_time'], 10, 6)) . " " .
881 htmlspecialchars( xl("Marked as cleared"), ENT_QUOTES);
882 ++$lcount;
884 else {
885 $lhtml .= "<br>\n&nbsp;" .
886 text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) .
887 text(substr($crow['bill_time'], 10, 6)) . " " .
888 htmlspecialchars( xl("Re-opened"), ENT_QUOTES);
889 ++$lcount;
892 else if ($crow['status'] == 6) {
893 $lhtml .= "<br>\n&nbsp;" .
894 text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) .
895 text(substr($crow['bill_time'], 10, 6)) . " " .
896 htmlspecialchars( xl("This claim has been forwarded to next level."), ENT_QUOTES);
897 ++$lcount;
899 else if ($crow['status'] == 7) {
900 $lhtml .= "<br>\n&nbsp;" .
901 text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) .
902 text(substr($crow['bill_time'], 10, 6)) . " " .
903 htmlspecialchars( xl("This claim has been denied.Reason:-"), ENT_QUOTES);
904 if($crow['process_file'])
906 $code_array=split(',',$crow['process_file']);
907 foreach($code_array as $code_key => $code_value)
909 $lhtml .= "<br>\n&nbsp;&nbsp;&nbsp;";
910 $reason_array=split('_',$code_value);
911 if(!isset($adjustment_reasons[$reason_array[3]]))
913 $lhtml .=htmlspecialchars( xl("For code"), ENT_QUOTES).' ['.text($reason_array[0]).'] '.htmlspecialchars( xl("and modifier"), ENT_QUOTES).' ['.text($reason_array[1]).'] '.htmlspecialchars( xl("the Denial code is"), ENT_QUOTES).' ['.text($reason_array[2]).' '.text($reason_array[3]).']';
915 else
917 $lhtml .=htmlspecialchars( xl("For code"), ENT_QUOTES).' ['.text($reason_array[0]).'] '.htmlspecialchars( xl("and modifier"), ENT_QUOTES).' ['.text($reason_array[1]).'] '.htmlspecialchars( xl("the Denial Group code is"), ENT_QUOTES).' ['.text($reason_array[2]).'] '.htmlspecialchars( xl("and the Reason is"), ENT_QUOTES).':- '.text($adjustment_reasons[$reason_array[3]]);
921 else
923 $lhtml .=htmlspecialchars( xl("Not Specified."), ENT_QUOTES);
925 ++$lcount;
928 if ($crow['process_time']) {
929 $lhtml .= "<br>\n&nbsp;" .
930 text(oeFormatShortDate(substr($crow['process_time'], 0, 10))) .
931 text(substr($crow['process_time'], 10, 6)) . " " .
932 xlt("Claim was generated to file") . " " .
933 "<a href='get_claim_file.php?key=" . attr($crow['process_file']) .
934 "' onclick='top.restoreSession()'>" .
935 text($crow['process_file']) . "</a>";
936 ++$lcount;
939 $lastcrow = $crow;
940 } // end while ($crow = sqlFetchArray($cres))
942 if ($lastcrow && $lastcrow['status'] == 4) {
943 $lhtml .= "<br>\n&nbsp;" . xlt("This claim has been closed.");
944 ++$lcount;
947 if ($lastcrow && $lastcrow['status'] == 5) {
948 $lhtml .= "<br>\n&nbsp;" . xlt("This claim has been canceled.");
949 ++$lcount;
951 } // end if ($iter['id'])
953 } // end if ($last_encounter_id != $this_encounter_id)
955 if ($skipping) continue;
957 // Collect info related to the missing modifiers test.
958 if ($iter['fee'] > 0) {
959 ++$mmo_num_charges;
960 $tmp = substr($iter['code'], 0, 3);
961 if (($tmp == '992' || $tmp == '993') && empty($iter['modifier']))
962 $mmo_empty_mod = true;
965 ++$rcount;
967 if ($rhtml) {
968 $rhtml .= "<tr bgcolor='$bgcolor'>\n";
970 $rhtml .= "<td width='50'>";
971 if ($iter['id'] && $oldcode != $iter['code_type']) {
972 $rhtml .= "<span class=text>" . text($iter['code_type']) . ": </span>";
975 $oldcode = $iter['code_type'];
976 $rhtml .= "</td>\n";
977 $justify = "";
979 if ($iter['id'] && $code_types[$iter['code_type']]['just']) {
980 $js = split(":",$iter['justify']);
981 $counter = 0;
982 foreach ($js as $j) {
983 if(!empty($j)) {
984 if ($counter == 0) {
985 $justify .= " (<b>" . text($j) . "</b>)";
987 else {
988 $justify .= " (" . text($j) . ")";
990 $counter++;
995 $rhtml .= "<td><span class='text'>" .
996 ($iter['code_type'] == 'COPAY' ? text(oeFormatMoney($iter['code'])) : text($iter['code']));
997 if ($iter['modifier']) $rhtml .= ":" . text($iter['modifier']);
998 $rhtml .= "</span><span style='font-size:8pt;'>$justify</span></td>\n";
1000 $rhtml .= '<td align="right"><span style="font-size:8pt;">&nbsp;&nbsp;&nbsp;';
1001 if ($iter['id'] && $iter['fee'] > 0) {
1002 $rhtml .= text(oeFormatMoney($iter['fee']));
1004 $rhtml .= "</span></td>\n";
1005 $rhtml .= '<td><span style="font-size:8pt;">&nbsp;&nbsp;&nbsp;';
1006 if ($iter['id']) $rhtml .= getProviderName(empty($iter['provider_id']) ? text($iter['enc_provider_id']) : text($iter['provider_id']));
1007 $rhtml .= "</span></td>\n";
1008 $rhtml .= '<td width=100>&nbsp;&nbsp;&nbsp;<span style="font-size:8pt;">';
1009 if ($iter['id']) $rhtml .= text(oeFormatSDFT(strtotime($iter{"date"})));
1010 $rhtml .= "</span></td>\n";
1011 if ($iter['id'] && $iter['authorized'] != 1) {
1012 $rhtml .= "<td><span class=alert>".xlt("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";
1014 else {
1015 $rhtml .= "<td></td>\n";
1017 if ($iter['id'] && $last_encounter_id != $this_encounter_id) {
1018 $tmpbpr = $iter['bill_process'];
1019 if ($tmpbpr == '0' && $iter['billed']) $tmpbpr = '2';
1020 $rhtml .= "<td><input type='checkbox' value='" . attr($tmpbpr) . "' name='claims[" . attr($this_encounter_id) . "][bill]' onclick='set_button_states()' id='CheckBoxBilling" . attr($CheckBoxBilling*1) . "'>&nbsp;</td>\n";
1021 $CheckBoxBilling++;
1023 else {
1024 $rhtml .= "<td></td>\n";
1026 if($last_encounter_id != $this_encounter_id){
1027 $rhtml2 = "";
1028 $rowcnt = 0;
1029 $resMoneyGot = sqlStatement("SELECT pay_amount as PatientPay,date(post_time) as date FROM ar_activity where ".
1030 "pid = ? and encounter = ? and payer_type=0 and account_code='PCP'",
1031 array($iter['enc_pid'],$iter['enc_encounter']));
1032 //new fees screen copay gives account_code='PCP'
1033 if(sqlNumRows($resMoneyGot) > 0){
1034 $lcount += 2;
1035 $rcount++;
1037 //checks whether a copay exists for the encounter and if exists displays it.
1038 while($rowMoneyGot = sqlFetchArray($resMoneyGot)){
1039 $rowcnt++;
1040 $PatientPay=$rowMoneyGot['PatientPay'];
1041 $date=$rowMoneyGot['date'];
1042 if($PatientPay > 0){
1043 if($rhtml){
1044 $rhtml2 .= "<tr bgcolor='$bgcolor'>\n";
1046 $rhtml2 .= "<td width='50'>";
1047 $rhtml2 .= "<span class='text'>".xlt('COPAY').": </span>";
1048 $rhtml2 .= "</td>\n";
1049 $rhtml2 .= "<td><span class='text'>".text(oeFormatMoney($PatientPay))."</span><span style='font-size:8pt;'>&nbsp;</span></td>\n";
1050 $rhtml2 .= '<td align="right"><span style="font-size:8pt;">&nbsp;&nbsp;&nbsp;';
1051 $rhtml2 .= "</span></td>\n";
1052 $rhtml2 .= '<td><span style="font-size:8pt;">&nbsp;&nbsp;&nbsp;';
1053 $rhtml2 .= "</span></td>\n";
1054 $rhtml2 .= '<td width=100>&nbsp;&nbsp;&nbsp;<span style="font-size:8pt;">';
1055 $rhtml2 .= text(oeFormatSDFT(strtotime($date)));
1056 $rhtml2 .= "</span></td>\n";
1057 if ($iter['id'] && $iter['authorized'] != 1) {
1058 $rhtml2 .= "<td><span class=alert>".xlt("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";
1059 }else{
1060 $rhtml2 .= "<td></td>\n";
1062 if(!$iter['id'] && $rowcnt == 1){
1063 $rhtml2 .= "<td><input type='checkbox' value='0' name='claims[" . attr($this_encounter_id) . "][bill]' onclick='set_button_states()' id='CheckBoxBilling" . attr($CheckBoxBilling*1) . "'>&nbsp;</td>\n";
1064 $CheckBoxBilling++;
1065 }else{
1066 $rhtml2 .= "<td></td>\n";
1070 $rhtml .= $rhtml2;
1072 $rhtml .= "</tr>\n";
1073 $last_encounter_id = $this_encounter_id;
1075 } // end foreach
1077 if ($lhtml) {
1078 while ($rcount < $lcount) {
1079 $rhtml .= "<tr bgcolor='$bgcolor'><td colspan='7'></td></tr>";
1080 ++$rcount;
1082 if (!$missing_mods_only || ($mmo_empty_mod && $mmo_num_charges > 1)) {
1083 if($DivPut=='yes')
1085 $lhtml.='</div>';
1086 $DivPut='no';
1088 echo "<tr bgcolor='$bgcolor'>\n<td rowspan='$rcount' valign='top'>\n$lhtml</td>$rhtml\n";
1089 echo "<tr bgcolor='$bgcolor'><td colspan='8' height='5'></td></tr>\n";
1097 </table>
1098 </form>
1100 <script>
1101 set_button_states();
1102 <?php
1103 if ($alertmsg) {
1104 echo "alert('".addslashes($alertmsg)."');\n";
1107 </script>
1108 <input type="hidden" name="divnos" id="divnos" value="<?php echo attr($divnos) ?>"/>
1109 <input type='hidden' name='ajax_mode' id='ajax_mode' value='' />
1110 </body>
1111 </html>