Couple minor fixes to previous Direct Messages Receiving commit.
[openemr.git] / interface / billing / billing_report.php
blob53240ef69ce0d33147d68ce35dba0768d164a679
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU General Public License
5 * as published by the Free Software Foundation; either version 2
6 * of the License, or (at your option) any later version.
7 */
9 $fake_register_globals=false;
10 $sanitize_all_escapes=true;
12 require_once("../globals.php");
13 require_once("../../library/acl.inc");
14 require_once("../../custom/code_types.inc.php");
15 require_once("$srcdir/patient.inc");
16 include_once("$srcdir/../interface/reports/report.inc.php");//Criteria Section common php page
17 require_once("$srcdir/billrep.inc");
18 require_once(dirname(__FILE__) . "/../../library/classes/OFX.class.php");
19 require_once(dirname(__FILE__) . "/../../library/classes/X12Partner.class.php");
20 require_once("$srcdir/formatting.inc.php");
21 require_once("$srcdir/options.inc.php");
22 require_once("adjustment_reason_codes.php");
24 $EXPORT_INC = "$webserver_root/custom/BillingExport.php";
26 $alertmsg = '';
28 if ($_POST['mode'] == 'export') {
29 $sql = ReturnOFXSql();
30 $db = get_db();
31 $results = $db->Execute($sql);
32 $billings = array();
33 if ($results->RecordCount() == 0) {
34 echo xlt("No Bills Found to Include in OFX Export")."<br>";
36 else {
37 while(!$results->EOF) {
38 $billings[] = $results->fields;
39 $results->MoveNext();
41 $ofx = new OFX($billings);
42 header("Pragma: public");
43 header("Expires: 0");
44 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
45 header("Content-Disposition: attachment; filename=openemr_ofx.ofx");
46 header("Content-Type: text/xml");
47 echo $ofx->get_OFX();
48 exit;
53 // This is obsolete.
54 if ($_POST['mode'] == 'process') {
55 if (exec("ps x | grep 'process_bills[.]php'")) {
56 $alertmsg = xl('Request ignored - claims processing is already running!');
58 else {
59 exec("cd $webserver_root/library/freeb;" .
60 "php -q process_bills.php bill > process_bills.log 2>&1 &");
61 $alertmsg = xl('Batch processing initiated; this may take a while.');
65 //global variables:
66 if (!isset($_POST["mode"])) {
67 $from_date = isset($_POST['from_date']) ? $_POST['from_date'] : date('Y-m-d');
68 $to_date = isset($_POST['to_date' ]) ? $_POST['to_date' ] : '';
69 $code_type = isset($_POST['code_type']) ? $_POST['code_type'] : 'all';
70 $unbilled = isset($_POST['unbilled' ]) ? $_POST['unbilled' ] : 'on';
71 $my_authorized = $_POST["authorized"];
72 } else {
73 $from_date = $_POST["from_date"];
74 $to_date = $_POST["to_date"];
75 $code_type = $_POST["code_type"];
76 $unbilled = $_POST["unbilled"];
77 $my_authorized = $_POST["authorized"];
80 // This tells us if only encounters that appear to be missing a "25" modifier
81 // are to be reported.
82 $missing_mods_only = !empty($_POST['missing_mods_only']);
85 $from_date = isset($_POST['from_date']) ? $_POST['from_date'] : date('Y-m-d');
86 $to_date = empty($_POST['to_date' ]) ? $from_date : $_POST['to_date'];
87 $code_type = isset($_POST['code_type']) ? $_POST['code_type'] : 'all';
88 $unbilled = isset($_POST['unbilled' ]) ? $_POST['unbilled' ] : 'on';
89 $my_authorized = $_POST["authorized"];
92 $left_margin = isset($_POST["left_margin"]) ? $_POST["left_margin"] : 24;
93 $top_margin = isset($_POST["top_margin"] ) ? $_POST["top_margin" ] : 20;
95 $ofrom_date = $from_date;
96 $oto_date = $to_date;
97 $ocode_type = $code_type;
98 $ounbilled = $unbilled;
99 $oauthorized = $my_authorized;
102 <html>
103 <head>
104 <?php if (function_exists(html_header_show)) html_header_show(); ?>
105 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css">
106 <style>
107 .subbtn { margin-top:3px; margin-bottom:3px; margin-left:2px; margin-right:2px }
108 </style>
109 <script>
111 function select_all() {
112 for($i=0;$i < document.update_form.length;$i++) {
113 $name = document.update_form[$i].name;
114 if ($name.substring(0,7) == "claims[" && $name.substring($name.length -6) == "[bill]") {
115 document.update_form[$i].checked = true;
118 set_button_states();
121 function set_button_states() {
122 var f = document.update_form;
123 var count0 = 0; // selected and not billed or queued
124 var count1 = 0; // selected and queued
125 var count2 = 0; // selected and billed
126 for($i = 0; $i < f.length; ++$i) {
127 $name = f[$i].name;
128 if ($name.substring(0, 7) == "claims[" && $name.substring($name.length -6) == "[bill]" && f[$i].checked == true) {
129 if (f[$i].value == '0') ++count0;
130 else if (f[$i].value == '1' || f[$i].value == '5') ++count1;
131 else ++count2;
135 var can_generate = (count0 > 0 || count1 > 0 || count2 > 0);
136 var can_mark = (count1 > 0 || count0 > 0 || count2 > 0);
137 var can_bill = (count0 == 0 && count1 == 0 && count2 > 0);
139 <?php if (file_exists($EXPORT_INC)) { ?>
140 f.bn_external.disabled = !can_generate;
141 <?php } else { ?>
142 // f.bn_hcfa_print.disabled = !can_generate;
143 // f.bn_hcfa.disabled = !can_generate;
144 // f.bn_ub92_print.disabled = !can_generate;
145 // f.bn_ub92.disabled = !can_generate;
146 f.bn_x12.disabled = !can_generate;
147 <?php if ($GLOBALS['support_encounter_claims']) { ?>
148 f.bn_x12_encounter.disabled = !can_generate;
149 <?php } ?>
150 f.bn_process_hcfa.disabled = !can_generate;
151 f.bn_hcfa_txt_file.disabled = !can_generate;
152 // f.bn_electronic_file.disabled = !can_bill;
153 f.bn_reopen.disabled = !can_bill;
154 <?php } ?>
155 f.bn_mark.disabled = !can_mark;
158 // Process a click to go to an encounter.
159 function toencounter(pid, pubpid, pname, enc, datestr, dobstr) {
160 top.restoreSession();
161 <?php if ($GLOBALS['concurrent_layout']) { ?>
162 var othername = (window.name == 'RTop') ? 'RBot' : 'RTop';
163 parent.left_nav.setPatient(pname,pid,pubpid,'',dobstr);
164 parent.left_nav.setEncounter(datestr, enc, othername);
165 parent.left_nav.setRadio(othername, 'enc');
166 parent.frames[othername].location.href =
167 '../patient_file/encounter/encounter_top.php?set_encounter='
168 + enc + '&pid=' + pid;
169 <?php } else { ?>
170 location.href = '../patient_file/encounter/patient_encounter.php?set_encounter='
171 + enc + '&pid=' + pid;
172 <?php } ?>
174 // Process a click to go to an patient.
175 function topatient(pid, pubpid, pname, enc, datestr, dobstr) {
176 top.restoreSession();
177 <?php if ($GLOBALS['concurrent_layout']) { ?>
178 var othername = (window.name == 'RTop') ? 'RBot' : 'RTop';
179 parent.left_nav.setPatient(pname,pid,pubpid,'',dobstr);
180 parent.frames[othername].location.href =
181 '../patient_file/summary/demographics_full.php?pid=' + pid;
182 <?php } else { ?>
183 location.href = '../patient_file/summary/demographics_full.php?pid=' + pid;
184 <?php } ?>
186 </script>
187 <script language="javascript" type="text/javascript">
188 EncounterDateArray=new Array;
189 CalendarCategoryArray=new Array;
190 EncounterIdArray=new Array;
191 function SubmitTheScreen()
192 {//Action on Update List link
193 if(!ProcessBeforeSubmitting())
194 return false;
195 top.restoreSession();
196 document.the_form.mode.value='change';
197 document.the_form.target='_self';
198 document.the_form.action='billing_report.php';
199 document.the_form.submit();
200 return true;
202 function SubmitTheScreenPrint()
203 {//Action on View Printable Report link
204 if(!ProcessBeforeSubmitting())
205 return false;
206 top.restoreSession();
207 document.the_form.target='new';
208 document.the_form.action='print_billing_report.php';
209 document.the_form.submit();
210 return true;
212 function SubmitTheScreenExportOFX()
213 {//Action on Export OFX link
214 if(!ProcessBeforeSubmitting())
215 return false;
216 top.restoreSession();
217 document.the_form.mode.value='export';
218 document.the_form.target='_self';
219 document.the_form.action='billing_report.php';
220 document.the_form.submit();
221 return true;
223 function TestExpandCollapse()
224 {//Checks whether the Expand All, Collapse All labels need to be placed.If any result set is there these will be placed.
225 var set=-1;
226 for(i=1;i<=document.getElementById("divnos").value;i++)
228 var ele = document.getElementById("divid_"+i);
229 if(ele)
231 set=1;
232 break;
235 if(set==-1)
237 if(document.getElementById("ExpandAll"))
239 document.getElementById("ExpandAll").innerHTML='';
240 document.getElementById("CollapseAll").innerHTML='';
244 function expandcollapse(atr){
245 if(atr == "expand") {//Called in the Expand All, Collapse All links(All items will be expanded or collapsed)
246 for(i=1;i<=document.getElementById("divnos").value;i++){
247 var mydivid="divid_"+i;var myspanid="spanid_"+i;
248 var ele = document.getElementById(mydivid); var text = document.getElementById(myspanid);
249 if(ele)
251 ele.style.display = "inline";text.innerHTML = "<?php echo htmlspecialchars(xl('Collapse'), ENT_QUOTES); ?>";
255 else {
256 for(i=1;i<=document.getElementById("divnos").value;i++){
257 var mydivid="divid_"+i;var myspanid="spanid_"+i;
258 var ele = document.getElementById(mydivid); var text = document.getElementById(myspanid);
259 if(ele)
261 ele.style.display = "none"; text.innerHTML = "<?php echo htmlspecialchars(xl('Expand'), ENT_QUOTES); ?>";
267 function divtoggle(spanid, divid) {//Called in the Expand, Collapse links(This is for a single item)
268 var ele = document.getElementById(divid);
269 if(ele)
271 var text = document.getElementById(spanid);
272 if(ele.style.display == "inline") {
273 ele.style.display = "none";
274 text.innerHTML = "<?php echo htmlspecialchars(xl('Expand'), ENT_QUOTES); ?>";
276 else {
277 ele.style.display = "inline";
278 text.innerHTML = "<?php echo htmlspecialchars(xl('Collapse'), ENT_QUOTES); ?>";
282 function MarkAsCleared(Type)
284 CheckBoxBillingCount=0;
285 for (var CheckBoxBillingIndex =0; ; CheckBoxBillingIndex++)
287 CheckBoxBillingObject=document.getElementById('CheckBoxBilling'+CheckBoxBillingIndex);
288 if(!CheckBoxBillingObject)
289 break;
290 if(CheckBoxBillingObject.checked)
292 ++CheckBoxBillingCount;
295 if(Type==1)
297 Message='<?php echo htmlspecialchars( xl('After saving your batch, click [View Log] to check for errors.'), ENT_QUOTES); ?>';
299 if(Type==2)
301 Message='<?php echo htmlspecialchars( xl('After saving the PDF, click [View Log] to check for errors.'), ENT_QUOTES); ?>';
303 if(Type==3)
305 Message='<?php echo htmlspecialchars( xl('After saving the TEXT file(s), click [View Log] to check for errors.'), ENT_QUOTES); ?>';
307 if(confirm(Message + "\n\n\n<?php echo addslashes( xl('Total') ); ?>" + ' ' + CheckBoxBillingCount + ' ' + "<?php echo addslashes( xl('Selected') ); ?>\n" +
308 "<?php echo addslashes( xl('Would You Like them to be Marked as Cleared.') ); ?>"))
310 document.getElementById('HiddenMarkAsCleared').value='yes';
312 else
314 document.getElementById('HiddenMarkAsCleared').value='';
317 </script>
318 <?php include_once("$srcdir/../interface/reports/report.script.php"); ?><!-- Criteria Section common javascript page-->
319 <!-- ================================================== -->
320 <!-- =============Included for Insurance ajax criteria==== -->
321 <!-- ================================================== -->
322 <script type="text/javascript" src="../../library/js/jquery.1.3.2.js"></script>
323 <?php include_once("{$GLOBALS['srcdir']}/ajax/payment_ajax_jav.inc.php"); ?>
324 <script type="text/javascript" src="../../library/js/common.js"></script>
325 <style>
326 #ajax_div_insurance {
327 position: absolute;
328 z-index:10;
329 background-color: #FBFDD0;
330 border: 1px solid #ccc;
331 padding: 10px;
333 </style>
334 <script language="javascript" type="text/javascript">
335 document.onclick=TakeActionOnHide;
336 </script>
337 <!-- ================================================== -->
338 <!-- =============Included for Insurance ajax criteria==== -->
339 <!-- ================================================== -->
340 </head>
341 <body class="body_top" onLoad="TestExpandCollapse()">
343 <p style='margin-top:5px;margin-bottom:5px;margin-left:5px'>
345 <?php if ($GLOBALS['concurrent_layout']) { ?>
346 <font class='title'><?php echo xlt('Billing Manager') ?></font>
347 <?php } else if ($userauthorized) { ?>
348 <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>
349 <?php } else { ?>
350 <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>
351 <?php } ?>
353 </p>
355 <form name='the_form' method='post' action='billing_report.php' onsubmit='return top.restoreSession()' style="display:inline">
357 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
358 <script type="text/javascript" src="../../library/dialog.js"></script>
359 <script type="text/javascript" src="../../library/textformat.js"></script>
360 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
361 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
362 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
363 <script language='JavaScript'>
364 var mypcc = '1';
365 </script>
367 <input type='hidden' name='mode' value='change'>
368 <!-- ============================================================================================================================================= -->
369 <!-- Criteria section Starts -->
370 <!-- ============================================================================================================================================= -->
371 <?php
372 //The following are the search criteria per page.All the following variable which ends with 'Master' need to be filled properly.
373 //Each item is seperated by a comma(,).
374 //$ThisPageSearchCriteriaDisplayMaster ==>It is the display on screen for the set of criteria.
375 //$ThisPageSearchCriteriaKeyMaster ==>Corresponding database fields in the same order.
376 //$ThisPageSearchCriteriaDataTypeMaster ==>Corresponding data type in the same order.
377 $ThisPageSearchCriteriaDisplayRadioMaster=array();
378 $ThisPageSearchCriteriaRadioKeyMaster=array();
379 $ThisPageSearchCriteriaQueryDropDownMaster=array();
380 $ThisPageSearchCriteriaQueryDropDownMasterDefault=array();
381 $ThisPageSearchCriteriaQueryDropDownMasterDefaultKey=array();
382 $ThisPageSearchCriteriaIncludeMaster=array();
384 $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") );
385 $ThisPageSearchCriteriaKeyMaster="form_encounter.date,billing.date,claims.process_time,claims.target,patient_data.fname,".
386 "form_encounter.pid,claims.payer_id,form_encounter.encounter,insurance_data.provider,billing.id,billing.billed,".
387 "billing.authorized,form_encounter.last_level_billed,billing.x12_partner_id";
388 $ThisPageSearchCriteriaDataTypeMaster="datetime,datetime,datetime,radio,text_like,".
389 "text,include,text,radio,radio,radio,".
390 "radio_like,radio,query_drop_down";
391 //The below section is needed if there is any 'radio' or 'radio_like' type in the $ThisPageSearchCriteriaDataTypeMaster
392 //$ThisPageSearchCriteriaDisplayRadioMaster,$ThisPageSearchCriteriaRadioKeyMaster ==>For each radio data type this pair comes.
393 //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.
394 $ThisPageSearchCriteriaDisplayRadioMaster[1] = array( xl("All"),xl("eClaims"),xl("Paper") );//Display Value
395 $ThisPageSearchCriteriaRadioKeyMaster[1]="all,standard,hcfa";//Key
396 $ThisPageSearchCriteriaDisplayRadioMaster[2]= array( xl("All"),xl("Insured"),xl("Non-Insured") );//Display Value
397 $ThisPageSearchCriteriaRadioKeyMaster[2]="all,1,0";//Key
398 $ThisPageSearchCriteriaDisplayRadioMaster[3]= array( xl("All"),xl("Coded"),xl("Not Coded") );//Display Value
399 $ThisPageSearchCriteriaRadioKeyMaster[3]="all,not null,null";//Key
400 $ThisPageSearchCriteriaDisplayRadioMaster[4]= array( xl("All"),xl("Unbilled"),xl("Billed"),xl("Denied") );//Display Value
401 $ThisPageSearchCriteriaRadioKeyMaster[4]="all,0,1,7";//Key
402 $ThisPageSearchCriteriaDisplayRadioMaster[5]= array( xl("All"),xl("Authorized"),xl("Unauthorized") );
403 $ThisPageSearchCriteriaRadioKeyMaster[5]="%,1,0";
404 $ThisPageSearchCriteriaDisplayRadioMaster[6]= array( xl("All"),xl("None"),xl("Ins 1"),xl("Ins 2 or Ins 3") );
405 $ThisPageSearchCriteriaRadioKeyMaster[6]="all,0,1,2";
406 //The below section is needed if there is any 'query_drop_down' type in the $ThisPageSearchCriteriaDataTypeMaster
407 $ThisPageSearchCriteriaQueryDropDownMaster[1]="SELECT name,id FROM x12_partners;";
408 $ThisPageSearchCriteriaQueryDropDownMasterDefault[1]= xl("All");//Only one item will be here
409 $ThisPageSearchCriteriaQueryDropDownMasterDefaultKey[1]="all";//Only one item will be here
410 //The below section is needed if there is any 'include' type in the $ThisPageSearchCriteriaDataTypeMaster
411 //Function name is added here.Corresponding include files need to be included in the respective pages as done in this page.
412 //It is labled(Included for Insurance ajax criteria)(Line:-279-299).
413 $ThisPageSearchCriteriaIncludeMaster[1]="InsuranceCompanyDisplay";//This is php function defined in the file 'report.inc.php'
415 if(!isset($_REQUEST['mode']))//default case
417 $_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")."')";
418 $_REQUEST['final_this_page_criteria'][1]="billing.billed = '0'";
420 $_REQUEST['final_this_page_criteria_text'][0]=xl("Date of Service = Today");
421 $_REQUEST['final_this_page_criteria_text'][1]=xl("Billing Status = Unbilled");
423 $_REQUEST['date_master_criteria_form_encounter_date']="today";
424 $_REQUEST['master_from_date_form_encounter_date']=date("Y-m-d");
425 $_REQUEST['master_to_date_form_encounter_date']=date("Y-m-d");
427 $_REQUEST['radio_billing_billed']=0;
431 <table width='100%' border="0" cellspacing="0" cellpadding="0">
432 <tr>
433 <td width="25%">&nbsp;</td>
434 <td width="50%">
435 <?php include_once("$srcdir/../interface/reports/criteria.tab.php"); ?>
436 </td>
437 <td width="25%">
438 <?php
439 // ============================================================================================================================================= -->
440 // Criteria section Ends -->
441 // ============================================================================================================================================= -->
444 <table width="100%" border="0" cellspacing="0" cellpadding="0">
445 <tr>
446 <td width="15%">&nbsp;</td>
447 <td width="85%"><span class='text'><a onClick="javascript:return SubmitTheScreen();" href="#" class=link_submit>[<?php echo htmlspecialchars(xl('Update List'), ENT_QUOTES) ?>]</a>
449 <a onClick="javascript:return SubmitTheScreenExportOFX();" href="#" class='link_submit'><?php echo htmlspecialchars(xl('[Export OFX]'), ENT_QUOTES) ?></a></span> </td>
450 </tr>
451 <tr>
452 <td>&nbsp;</td>
453 <td><a onClick="javascript:return SubmitTheScreenPrint();" href="#"
454 class='link_submit' ><?php echo htmlspecialchars(xl('[View Printable Report]'), ENT_QUOTES) ?></a></td>
455 </tr>
456 <tr>
457 <td>&nbsp;</td>
458 <td>
459 <?php
460 $acct_config = $GLOBALS['oer_config']['ws_accounting'];
461 if($acct_config['enabled']) {
462 if($acct_config['enabled'] !== 2) {
463 print '<span class=text><a href="javascript:void window.open(\'' . $acct_config['url_path'] . '\')">' . htmlspecialchars(xl("[SQL-Ledger]"), ENT_QUOTES) . '</a> &nbsp; </span>';
465 if (acl_check('acct', 'rep')) {
466 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>';
468 if (acl_check('acct', 'eob')) {
469 print '<span class=text><a href="javascript:void window.open(\'sl_eob_search.php\')" onclick="top.restoreSession()">' . htmlspecialchars(xl('[EOBs]'), ENT_QUOTES) . '</a></span>';
473 </td>
474 </tr>
475 <tr>
476 <td>&nbsp;</td>
477 <td>
478 <?php if (! file_exists($EXPORT_INC)) { ?>
479 <!--
480 <a href="javascript:top.restoreSession();document.the_form.mode.value='process';document.the_form.submit()" class="link_submit"
481 title="Process all queued bills to create electronic data (and print if requested)"><?php echo htmlspecialchars(xl('[Start Batch Processing]'), ENT_QUOTES) ?></a>
482 &nbsp;
484 <a href='../../library/freeb/process_bills.log' target='_blank' class='link_submit'
485 title='<?php htmlspecialchars(xl('See messages from the last set of generated claims'), ENT_QUOTES); ?>'><?php echo htmlspecialchars(xl('[View Log]'), ENT_QUOTES) ?></a>
486 <?php } ?>
487 </td>
488 </tr>
489 <tr>
490 <td>&nbsp;</td>
491 <td><a href="javascript:select_all()" class="link_submit"><?php echo htmlspecialchars(xl('[Select All]','e'), ENT_QUOTES) ?></a></td>
492 </tr>
493 </table>
496 </td>
497 </tr>
498 </table>
499 <table width='100%' border="0" cellspacing="0" cellpadding="0" >
500 <tr>
501 <td>
502 <hr color="#000000">
503 </td>
504 </tr>
505 </table>
506 </form>
507 <form name='update_form' method='post' action='billing_process.php' onsubmit='return top.restoreSession()' style="display:inline">
508 <center>
509 <span class='text' style="display:inline">
510 <?php if (file_exists($EXPORT_INC)) { ?>
511 <input type="submit" class="subbtn" name="bn_external" value="Export Billing" title="<?php echo xla('Export to external billing system') ?>">
512 <input type="submit" class="subbtn" name="bn_mark" value="Mark as Cleared" title="<?php echo xla('Mark as billed but skip billing') ?>">
513 <?php } else { ?>
514 <!--
515 <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') ?>">
516 <input type="submit" class="subbtn" name="bn_hcfa" value="Queue HCFA" title="<?php echo xla('Queue for HCFA batch processing')?>">
517 <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')?>">
518 <input type="submit" class="subbtn" name="bn_ub92" value="Queue UB92" title="<?php echo xla('Queue for UB-92 batch processing')?>">
520 <input type="submit" class="subbtn" name="bn_x12" value="<?php echo xla('Generate X12')?>"
521 title="<?php echo xla('Generate and download X12 batch')?>"
522 onclick="MarkAsCleared(1)">
523 <?php if ($GLOBALS['support_encounter_claims']) { ?>
524 <input type="submit" class="subbtn" name="bn_x12_encounter" value="<?php echo xla('Generate X12 Encounter')?>"
525 title="<?php echo xla('Generate and download X12 encounter claim batch')?>"
526 onclick="MarkAsCleared(1)">
527 <?php } ?>
528 <input type="submit" class="subbtn" style="width:175px;" name="bn_process_hcfa" value="<?php echo xla('Generate CMS 1500 PDF')?>"
529 title="<?php echo xla('Generate and download CMS 1500 paper claims')?>"
530 onclick="MarkAsCleared(2)">
531 <input type="submit" class="subbtn" style="width:175px;" name="bn_hcfa_txt_file" value="<?php echo xla('Generate CMS 1500 TEXT')?>"
532 title="<?php echo xla('Making batch text files for uploading to Clearing House and will mark as billed')?>"
533 onclick="MarkAsCleared(3)">
534 <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')?>">
535 <input type="submit" class="subbtn" name="bn_reopen" value="<?php echo xla('Re-Open')?>" title="<?php echo xla('Mark as not billed')?>">
536 <!--
537 <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')?>">
539 &nbsp;&nbsp;&nbsp;
540 <?php echo xlt('CMS 1500 Margins'); ?>:
541 &nbsp;<?php echo xlt('Left'); ?>:
542 <input type='text' size='2' name='left_margin'
543 value='<?php echo attr($left_margin); ?>'
544 title='<?php echo xla('HCFA left margin in points'); ?>' />
545 &nbsp;<?php echo xlt('Top'); ?>:
546 <input type='text' size='2' name='top_margin'
547 value='<?php echo attr($top_margin); ?>'
548 title='<?php echo xla('HCFA top margin in points'); ?>' />
549 </span>
550 <?php } ?>
552 </center>
553 <input type='hidden' name='HiddenMarkAsCleared' id='HiddenMarkAsCleared' value="" />
554 <input type='hidden' name='mode' value="bill" />
555 <input type='hidden' name='authorized' value="<?php echo attr($my_authorized); ?>" />
556 <input type='hidden' name='unbilled' value="<?php echo attr($unbilled); ?>" />
557 <input type='hidden' name='code_type' value="%" />
558 <input type='hidden' name='to_date' value="<?php echo attr($to_date); ?>" />
559 <input type='hidden' name='from_date' value="<?php echo attr($from_date); ?>" />
561 <?php
562 if ($my_authorized == "on" ) {
563 $my_authorized = "1";
564 } else {
565 $my_authorized = "%";
567 if ($unbilled == "on") {
568 $unbilled = "0";
569 } else {
570 $unbilled = "%";
572 $list = getBillsListBetween("%");
575 <input type='hidden' name='bill_list' value="<?php echo attr($list); ?>" />
577 <!-- new form for uploading -->
579 <?php
580 if (!isset($_POST["mode"])) {
581 if (!isset($_POST["from_date"])) {
582 $from_date = date("Y-m-d");
583 } else {
584 $from_date = $_POST["from_date"];
586 if (empty($_POST["to_date"])) {
587 $to_date = '';
588 } else {
589 $to_date = $_POST["to_date"];
591 if (!isset($_POST["code_type"])) {
592 $code_type="all";
593 } else {
594 $code_type = $_POST["code_type"];
596 if (!isset($_POST["unbilled"])) {
597 $unbilled = "on";
598 } else {
599 $unbilled = $_POST["unbilled"];
601 if (!isset($_POST["authorized"])) {
602 $my_authorized = "on";
603 } else {
604 $my_authorized = $_POST["authorized"];
606 } else {
607 $from_date = $_POST["from_date"];
608 $to_date = $_POST["to_date"];
609 $code_type = $_POST["code_type"];
610 $unbilled = $_POST["unbilled"];
611 $my_authorized = $_POST["authorized"];
614 if ($my_authorized == "on" ) {
615 $my_authorized = "1";
616 } else {
617 $my_authorized = "%";
620 if ($unbilled == "on") {
621 $unbilled = "0";
622 } else {
623 $unbilled = "%";
626 if (isset($_POST["mode"]) && $_POST["mode"] == "bill") {
627 billCodesList($list);
631 <table border="0" cellspacing="0" cellpadding="0" width="100%">
633 <?php
634 if ($ret = getBillsBetween("%"))
636 if(is_array($ret))
639 <tr ><td colspan='8' align="right" ><table width="250" border="0" cellspacing="0" cellpadding="0">
640 <tr>
641 <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>
642 <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>
643 <td width="50">&nbsp;</td>
644 </tr>
645 </table>
646 </td></tr>
647 <?php
649 $loop = 0;
650 $oldcode = "";
651 $last_encounter_id = "";
652 $lhtml = "";
653 $rhtml = "";
654 $lcount = 0;
655 $rcount = 0;
656 $bgcolor = "";
657 $skipping = FALSE;
659 $mmo_empty_mod = false;
660 $mmo_num_charges = 0;
661 $divnos=0;
663 foreach ($ret as $iter) {
665 // We include encounters here that have never been billed. However
666 // if it had no selected billing items but does have non-selected
667 // billing items, then it is not of interest.
668 if (!$iter['id']) {
669 $res = sqlQuery("SELECT count(*) AS count FROM billing WHERE " .
670 "encounter = ? AND " .
671 "pid=? AND " .
672 "activity = 1", array($iter['enc_encounter'],$iter['enc_pid']) );
673 if ($res['count'] > 0) continue;
676 $this_encounter_id = $iter['enc_pid'] . "-" . $iter['enc_encounter'];
678 if ($last_encounter_id != $this_encounter_id) {
680 // This dumps all HTML for the previous encounter.
682 if ($lhtml) {
683 while ($rcount < $lcount) {
684 $rhtml .= "<tr bgcolor='$bgcolor'><td colspan='7'></td></tr>";
685 ++$rcount;
687 // This test handles the case where we are only listing encounters
688 // that appear to have a missing "25" modifier.
689 if (!$missing_mods_only || ($mmo_empty_mod && $mmo_num_charges > 1)) {
690 if($DivPut=='yes')
692 $lhtml.='</div>';
693 $DivPut='no';
695 echo "<tr bgcolor='$bgcolor'>\n<td rowspan='$rcount' valign='top'>\n$lhtml</td>$rhtml\n";
696 echo "<tr bgcolor='$bgcolor'><td colspan='8' height='5'></td></tr>\n\n";
697 ++$encount;
701 $lhtml = "";
702 $rhtml = "";
703 $mmo_empty_mod = false;
704 $mmo_num_charges = 0;
706 // If there are ANY unauthorized items in this encounter and this is
707 // the normal case of viewing only authorized billing, then skip the
708 // entire encounter.
710 $skipping = FALSE;
711 if ($my_authorized == '1') {
712 $res = sqlQuery("select count(*) as count from billing where " .
713 "encounter = ? and " .
714 "pid=? and " .
715 "activity = 1 and authorized = 0", array($iter['enc_encounter'],$iter['enc_pid']) );
716 if ($res['count'] > 0) {
717 $skipping = TRUE;
718 $last_encounter_id = $this_encounter_id;
719 continue;
723 $name = getPatientData($iter['enc_pid'], "fname, mname, lname, pubpid, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
725 # Check if patient has primary insurance and a subscriber exists for it.
726 # If not we will highlight their name in red.
727 # TBD: more checking here.
729 $res = sqlQuery("select count(*) as count from insurance_data where " .
730 "pid = ? and " .
731 "type='primary' and " .
732 "subscriber_lname is not null and " .
733 "subscriber_lname != '' limit 1", array($iter['enc_pid']) );
734 $namecolor = ($res['count'] > 0) ? "black" : "#ff7777";
736 $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
737 echo "<tr bgcolor='$bgcolor'><td colspan='8' height='5'></td></tr>\n";
738 $lcount = 1;
739 $rcount = 0;
740 $oldcode = "";
742 $ptname = $name['fname'] . " " . $name['lname'];
743 $raw_encounter_date = date("Y-m-d", strtotime($iter['enc_date']));
745 // Add Encounter Date to display with "To Encounter" button 2/17/09 JCH
746 $lhtml .= "&nbsp;<span class=bold><font color='$namecolor'>". text($ptname) .
747 "</font></span><span class=small>&nbsp;(" . text($iter['enc_pid']) . "-" .
748 text($iter['enc_encounter']) . ")</span>";
750 //Encounter details are stored to javacript as array.
751 $result4 = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe ".
752 " 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']) );
753 if(sqlNumRows($result4)>0)
755 <script language='JavaScript'>
756 Count=0;
757 EncounterDateArray[<?php echo attr($iter['enc_pid']); ?>]=new Array;
758 CalendarCategoryArray[<?php echo attr($iter['enc_pid']); ?>]=new Array;
759 EncounterIdArray[<?php echo attr($iter['enc_pid']); ?>]=new Array;
760 <?php
761 while($rowresult4 = sqlFetchArray($result4))
764 EncounterIdArray[<?php echo attr($iter['enc_pid']); ?>][Count]='<?php echo htmlspecialchars($rowresult4['encounter'], ENT_QUOTES); ?>';
765 EncounterDateArray[<?php echo attr($iter['enc_pid']); ?>][Count]='<?php echo htmlspecialchars(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date']))), ENT_QUOTES); ?>';
766 CalendarCategoryArray[<?php echo attr($iter['enc_pid']); ?>][Count]='<?php echo htmlspecialchars( xl_appt_category($rowresult4['pc_catname']), ENT_QUOTES); ?>';
767 Count++;
768 <?php
771 </script>
772 <?php
774 // Not sure why the next section seems to do nothing except post "To Encounter" button 2/17/09 JCH
775 $lhtml .= "&nbsp;&nbsp;&nbsp;<a class=\"link_submit\" " .
776 "href=\"javascript:window.toencounter(" . $iter['enc_pid'] .
777 ",'" . addslashes($name['pubpid']) .
778 "','" . addslashes($ptname) . "'," . $iter['enc_encounter'] .
779 ",'" . oeFormatShortDate($raw_encounter_date) . "',' " .
780 xl('DOB') . ": " . oeFormatShortDate($name['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAge($name['DOB_YMD']) . "');
781 top.window.parent.left_nav.setPatientEncounter(EncounterIdArray[" . $iter['enc_pid'] . "],EncounterDateArray[" . $iter['enc_pid'] .
782 "], CalendarCategoryArray[" . $iter['enc_pid'] . "])\">[" .
783 xlt('To Enctr') . " " . text(oeFormatShortDate($raw_encounter_date)) . "]</a>";
785 // Changed "To xxx" buttons to allow room for encounter date display 2/17/09 JCH
786 $lhtml .= "&nbsp;&nbsp;&nbsp;<a class=\"link_submit\" " .
787 "href=\"javascript:window.topatient(" . $iter['enc_pid'] .
788 ",'" . addslashes($name['pubpid']) .
789 "','" . addslashes($ptname) . "'," . $iter['enc_encounter'] .
790 ",'" . oeFormatShortDate($raw_encounter_date) . "',' " .
791 xl('DOB') . ": " . oeFormatShortDate($name['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAge($name['DOB_YMD']) . "');
792 top.window.parent.left_nav.setPatientEncounter(EncounterIdArray[" . $iter['enc_pid'] . "],EncounterDateArray[" . $iter['enc_pid'] .
793 "], CalendarCategoryArray[" . $iter['enc_pid'] . "])\">[" . xlt('To Dems') . "]</a>";
794 $divnos=$divnos+1;
795 $lhtml .= "&nbsp;&nbsp;&nbsp;<a onclick='divtoggle(\"spanid_$divnos\",\"divid_$divnos\");' class='small' id='aid_$divnos' href=\"JavaScript:void(0);".
796 "\">(<span id=spanid_$divnos class=\"indicator\">" . htmlspecialchars( xl('Expand'), ENT_QUOTES) . "</span>)</a>";
798 if ($iter['id']) {
800 $lcount += 2;
801 $lhtml .= "<br />\n";
802 $lhtml .= "&nbsp;<span class=text>Bill: ";
803 $lhtml .= "<select name='claims[" . attr($this_encounter_id) . "][payer]' style='background-color:$bgcolor'>";
805 $query = "SELECT id.provider AS id, id.type, id.date, " .
806 "ic.x12_default_partner_id AS ic_x12id, ic.name AS provider " .
807 "FROM insurance_data AS id, insurance_companies AS ic WHERE " .
808 "ic.id = id.provider AND " .
809 "id.pid = ? AND " .
810 "id.date <= ? " .
811 "ORDER BY id.type ASC, id.date DESC";
813 $result = sqlStatement($query, array($iter['enc_pid'],$raw_encounter_date) );
814 $count = 0;
815 $default_x12_partner = $iter['ic_x12id'];
816 $prevtype = '';
818 while ($row = sqlFetchArray($result)) {
819 if (strcmp($row['type'], $prevtype) == 0) continue;
820 $prevtype = $row['type'];
821 if (strlen($row['provider']) > 0) {
822 // This preserves any existing insurance company selection, which is
823 // important when EOB posting has re-queued for secondary billing.
824 $lhtml .= "<option value=\"" . attr(substr($row['type'],0,1).$row['id']) . "\"";
825 if (($count == 0 && !$iter['payer_id']) || $row['id'] == $iter['payer_id']) {
826 $lhtml .= " selected";
827 if (!is_numeric($default_x12_partner)) $default_x12_partner = $row['ic_x12id'];
829 $lhtml .= ">" . text($row['type']) . ": " . text($row['provider']) . "</option>";
831 $count++;
834 $lhtml .= "<option value='-1'>" . xlt("Unassigned") . "</option>\n";
835 $lhtml .= "</select>&nbsp;&nbsp;\n";
836 $lhtml .= "<select name='claims[" . attr($this_encounter_id) . "][partner]' style='background-color:$bgcolor'>";
837 $x = new X12Partner();
838 $partners = $x->_utility_array($x->x12_partner_factory());
839 foreach ($partners as $xid => $xname) {
840 $lhtml .= '<option label="' . attr($xname) . '" value="' . attr($xid) .'"';
841 if ($xid == $default_x12_partner) {
842 $lhtml .= "selected";
844 $lhtml .= '>' . text($xname) . '</option>';
846 $lhtml .= "</select>";
847 $DivPut='yes';
848 $lhtml .= "<br>\n&nbsp;<div id='divid_$divnos' style='display:none'>" . text(oeFormatShortDate(substr($iter['date'], 0, 10)))
849 . text(substr($iter['date'], 10, 6)) . " " . xlt("Encounter was coded");
851 $query = "SELECT * FROM claims WHERE " .
852 "patient_id = ? AND " .
853 "encounter_id = ? " .
854 "ORDER BY version";
855 $cres = sqlStatement($query, array($iter['enc_pid'],$iter['enc_encounter']) );
857 $lastcrow = false;
859 while ($crow = sqlFetchArray($cres)) {
860 $query = "SELECT id.type, ic.name " .
861 "FROM insurance_data AS id, insurance_companies AS ic WHERE " .
862 "id.pid = ? AND " .
863 "id.provider = ? AND " .
864 "id.date <= ? AND " .
865 "ic.id = id.provider " .
866 "ORDER BY id.type ASC, id.date DESC";
868 $irow= sqlQuery($query, array($iter['enc_pid'],$crow['payer_id'],$raw_encounter_date) );
870 if ($crow['bill_process']) {
871 $lhtml .= "<br>\n&nbsp;" .
872 text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) .
873 text(substr($crow['bill_time'], 10, 6)) . " " .
874 xlt("Queued for") . " " . text($irow['type']) . " " . text($crow['target']) . " " .
875 xlt("billing to ") . text($irow['name']);
876 ++$lcount;
878 else if ($crow['status'] < 6) {
879 if ($crow['status'] > 1) {
880 $lhtml .= "<br>\n&nbsp;" .
881 text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) .
882 text(substr($crow['bill_time'], 10, 6)) . " " .
883 htmlspecialchars( xl("Marked as cleared"), ENT_QUOTES);
884 ++$lcount;
886 else {
887 $lhtml .= "<br>\n&nbsp;" .
888 text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) .
889 text(substr($crow['bill_time'], 10, 6)) . " " .
890 htmlspecialchars( xl("Re-opened"), ENT_QUOTES);
891 ++$lcount;
894 else if ($crow['status'] == 6) {
895 $lhtml .= "<br>\n&nbsp;" .
896 text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) .
897 text(substr($crow['bill_time'], 10, 6)) . " " .
898 htmlspecialchars( xl("This claim has been forwarded to next level."), ENT_QUOTES);
899 ++$lcount;
901 else if ($crow['status'] == 7) {
902 $lhtml .= "<br>\n&nbsp;" .
903 text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) .
904 text(substr($crow['bill_time'], 10, 6)) . " " .
905 htmlspecialchars( xl("This claim has been denied.Reason:-"), ENT_QUOTES);
906 if($crow['process_file'])
908 $code_array=split(',',$crow['process_file']);
909 foreach($code_array as $code_key => $code_value)
911 $lhtml .= "<br>\n&nbsp;&nbsp;&nbsp;";
912 $reason_array=split('_',$code_value);
913 if(!isset($adjustment_reasons[$reason_array[3]]))
915 $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]).']';
917 else
919 $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]]);
923 else
925 $lhtml .=htmlspecialchars( xl("Not Specified."), ENT_QUOTES);
927 ++$lcount;
930 if ($crow['process_time']) {
931 $lhtml .= "<br>\n&nbsp;" .
932 text(oeFormatShortDate(substr($crow['process_time'], 0, 10))) .
933 text(substr($crow['process_time'], 10, 6)) . " " .
934 xlt("Claim was generated to file") . " " .
935 "<a href='get_claim_file.php?key=" . attr($crow['process_file']) .
936 "' onclick='top.restoreSession()'>" .
937 text($crow['process_file']) . "</a>";
938 ++$lcount;
941 $lastcrow = $crow;
942 } // end while ($crow = sqlFetchArray($cres))
944 if ($lastcrow && $lastcrow['status'] == 4) {
945 $lhtml .= "<br>\n&nbsp;" . xlt("This claim has been closed.");
946 ++$lcount;
949 if ($lastcrow && $lastcrow['status'] == 5) {
950 $lhtml .= "<br>\n&nbsp;" . xlt("This claim has been canceled.");
951 ++$lcount;
953 } // end if ($iter['id'])
955 } // end if ($last_encounter_id != $this_encounter_id)
957 if ($skipping) continue;
959 // Collect info related to the missing modifiers test.
960 if ($iter['fee'] > 0) {
961 ++$mmo_num_charges;
962 $tmp = substr($iter['code'], 0, 3);
963 if (($tmp == '992' || $tmp == '993') && empty($iter['modifier']))
964 $mmo_empty_mod = true;
967 ++$rcount;
969 if ($rhtml) {
970 $rhtml .= "<tr bgcolor='$bgcolor'>\n";
972 $rhtml .= "<td width='50'>";
973 if ($iter['id'] && $oldcode != $iter['code_type']) {
974 $rhtml .= "<span class=text>" . text($iter['code_type']) . ": </span>";
977 $oldcode = $iter['code_type'];
978 $rhtml .= "</td>\n";
979 $justify = "";
981 if ($iter['id'] && $code_types[$iter['code_type']]['just']) {
982 $js = split(":",$iter['justify']);
983 $counter = 0;
984 foreach ($js as $j) {
985 if(!empty($j)) {
986 if ($counter == 0) {
987 $justify .= " (<b>" . text($j) . "</b>)";
989 else {
990 $justify .= " (" . text($j) . ")";
992 $counter++;
997 $rhtml .= "<td><span class='text'>" .
998 ($iter['code_type'] == 'COPAY' ? text(oeFormatMoney($iter['code'])) : text($iter['code']));
999 if ($iter['modifier']) $rhtml .= ":" . text($iter['modifier']);
1000 $rhtml .= "</span><span style='font-size:8pt;'>$justify</span></td>\n";
1002 $rhtml .= '<td align="right"><span style="font-size:8pt;">&nbsp;&nbsp;&nbsp;';
1003 if ($iter['id'] && $iter['fee'] > 0) {
1004 $rhtml .= text(oeFormatMoney($iter['fee']));
1006 $rhtml .= "</span></td>\n";
1007 $rhtml .= '<td><span style="font-size:8pt;">&nbsp;&nbsp;&nbsp;';
1008 if ($iter['id']) $rhtml .= getProviderName(empty($iter['provider_id']) ? text($iter['enc_provider_id']) : text($iter['provider_id']));
1009 $rhtml .= "</span></td>\n";
1010 $rhtml .= '<td width=100>&nbsp;&nbsp;&nbsp;<span style="font-size:8pt;">';
1011 if ($iter['id']) $rhtml .= text(oeFormatSDFT(strtotime($iter{"date"})));
1012 $rhtml .= "</span></td>\n";
1013 if ($iter['id'] && $iter['authorized'] != 1) {
1014 $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";
1016 else {
1017 $rhtml .= "<td></td>\n";
1019 if ($iter['id'] && $last_encounter_id != $this_encounter_id) {
1020 $tmpbpr = $iter['bill_process'];
1021 if ($tmpbpr == '0' && $iter['billed']) $tmpbpr = '2';
1022 $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";
1023 $CheckBoxBilling++;
1025 else {
1026 $rhtml .= "<td></td>\n";
1028 if($last_encounter_id != $this_encounter_id){
1029 $rhtml2 = "";
1030 $rowcnt = 0;
1031 $resMoneyGot = sqlStatement("SELECT pay_amount as PatientPay,date(post_time) as date FROM ar_activity where ".
1032 "pid = ? and encounter = ? and payer_type=0 and account_code='PCP'",
1033 array($iter['enc_pid'],$iter['enc_encounter']));
1034 //new fees screen copay gives account_code='PCP'
1035 if(sqlNumRows($resMoneyGot) > 0){
1036 $lcount += 2;
1037 $rcount++;
1039 //checks whether a copay exists for the encounter and if exists displays it.
1040 while($rowMoneyGot = sqlFetchArray($resMoneyGot)){
1041 $rowcnt++;
1042 $PatientPay=$rowMoneyGot['PatientPay'];
1043 $date=$rowMoneyGot['date'];
1044 if($PatientPay > 0){
1045 if($rhtml){
1046 $rhtml2 .= "<tr bgcolor='$bgcolor'>\n";
1048 $rhtml2 .= "<td width='50'>";
1049 $rhtml2 .= "<span class='text'>".xlt('COPAY').": </span>";
1050 $rhtml2 .= "</td>\n";
1051 $rhtml2 .= "<td><span class='text'>".text(oeFormatMoney($PatientPay))."</span><span style='font-size:8pt;'>&nbsp;</span></td>\n";
1052 $rhtml2 .= '<td align="right"><span style="font-size:8pt;">&nbsp;&nbsp;&nbsp;';
1053 $rhtml2 .= "</span></td>\n";
1054 $rhtml2 .= '<td><span style="font-size:8pt;">&nbsp;&nbsp;&nbsp;';
1055 $rhtml2 .= "</span></td>\n";
1056 $rhtml2 .= '<td width=100>&nbsp;&nbsp;&nbsp;<span style="font-size:8pt;">';
1057 $rhtml2 .= text(oeFormatSDFT(strtotime($date)));
1058 $rhtml2 .= "</span></td>\n";
1059 if ($iter['id'] && $iter['authorized'] != 1) {
1060 $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";
1061 }else{
1062 $rhtml2 .= "<td></td>\n";
1064 if(!$iter['id'] && $rowcnt == 1){
1065 $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";
1066 $CheckBoxBilling++;
1067 }else{
1068 $rhtml2 .= "<td></td>\n";
1072 $rhtml .= $rhtml2;
1074 $rhtml .= "</tr>\n";
1075 $last_encounter_id = $this_encounter_id;
1077 } // end foreach
1079 if ($lhtml) {
1080 while ($rcount < $lcount) {
1081 $rhtml .= "<tr bgcolor='$bgcolor'><td colspan='7'></td></tr>";
1082 ++$rcount;
1084 if (!$missing_mods_only || ($mmo_empty_mod && $mmo_num_charges > 1)) {
1085 if($DivPut=='yes')
1087 $lhtml.='</div>';
1088 $DivPut='no';
1090 echo "<tr bgcolor='$bgcolor'>\n<td rowspan='$rcount' valign='top'>\n$lhtml</td>$rhtml\n";
1091 echo "<tr bgcolor='$bgcolor'><td colspan='8' height='5'></td></tr>\n";
1099 </table>
1100 </form>
1102 <script>
1103 set_button_states();
1104 <?php
1105 if ($alertmsg) {
1106 echo "alert('".addslashes($alertmsg)."');\n";
1109 </script>
1110 <input type="hidden" name="divnos" id="divnos" value="<?php echo attr($divnos) ?>"/>
1111 <input type='hidden' name='ajax_mode' id='ajax_mode' value='' />
1112 </body>
1113 </html>