Remove concurrent_layout and clarify layout and themes selections (#272)
[openemr.git] / interface / billing / billing_report.php
blob8a3dc5fba9cf2252027ed491c2d2351fafe1ec5a
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 * Added hooks for UB04 and End of day reporting Terry Hill 2014 terry@lillysystems.com
8 */
10 $fake_register_globals=false;
11 $sanitize_all_escapes=true;
13 require_once("../globals.php");
14 require_once("../../library/acl.inc");
15 require_once("../../custom/code_types.inc.php");
16 require_once("$srcdir/patient.inc");
17 include_once("$srcdir/../interface/reports/report.inc.php");//Criteria Section common php page
18 require_once("$srcdir/billrep.inc");
19 require_once(dirname(__FILE__) . "/../../library/classes/OFX.class.php");
20 require_once(dirname(__FILE__) . "/../../library/classes/X12Partner.class.php");
21 require_once("$srcdir/formatting.inc.php");
22 require_once("$srcdir/options.inc.php");
23 require_once("adjustment_reason_codes.php");
25 $EXPORT_INC = "$webserver_root/custom/BillingExport.php";
26 //echo $GLOBALS['daysheet_provider_totals'];
28 $daysheet = false;
29 $daysheet_total = false;
30 $provider_run = false;
32 if ($GLOBALS['use_custom_daysheet'] != 0) {
33 $daysheet = true;
34 if ($GLOBALS['daysheet_provider_totals'] == 1) {
35 $daysheet_total = true;
36 $provider_run = false;
38 if ($GLOBALS['daysheet_provider_totals'] == 0) {
39 $daysheet_total = false;
40 $provider_run = true;
44 $alertmsg = '';
46 if (isset($_POST['mode'])) {
47 if ($_POST['mode'] == 'export') {
48 $sql = ReturnOFXSql();
49 $db = get_db();
50 $results = $db->Execute($sql);
51 $billings = array();
52 if ($results->RecordCount() == 0) {
53 echo xlt("No Bills Found to Include in OFX Export")."<br>";
54 } else {
55 while(!$results->EOF) {
56 $billings[] = $results->fields;
57 $results->MoveNext();
59 $ofx = new OFX($billings);
60 header("Pragma: public");
61 header("Expires: 0");
62 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
63 header("Content-Disposition: attachment; filename=openemr_ofx.ofx");
64 header("Content-Type: text/xml");
65 echo $ofx->get_OFX();
66 exit;
71 //global variables:
72 $from_date = isset($_POST['from_date']) ? $_POST['from_date'] : date('Y-m-d');
73 $to_date = isset($_POST['to_date' ]) ? $_POST['to_date' ] : '';
74 $code_type = isset($_POST['code_type']) ? $_POST['code_type'] : 'all';
75 $unbilled = isset($_POST['unbilled' ]) ? $_POST['unbilled' ] : 'on';
76 $my_authorized = isset($_POST["authorized"]) ? $_POST["authorized"] : '';
79 // This tells us if only encounters that appear to be missing a "25" modifier
80 // are to be reported.
81 $missing_mods_only = (isset($_POST['missing_mods_only']) && !empty($_POST['missing_mods_only']));
83 $left_margin = isset($_POST["left_margin"]) ? $_POST["left_margin"] : 24;
84 $top_margin = isset($_POST["top_margin"] ) ? $_POST["top_margin" ] : 20;
86 $ofrom_date = $from_date;
87 $oto_date = $to_date;
88 $ocode_type = $code_type;
89 $ounbilled = $unbilled;
90 $oauthorized = $my_authorized;
93 <html>
94 <head>
95 <?php if (function_exists('html_header_show')) html_header_show(); ?>
96 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css">
97 <style>
98 .subbtn { margin-top:3px; margin-bottom:3px; margin-left:2px; margin-right:2px }
99 </style>
100 <script>
102 function select_all() {
103 for($i=0;$i < document.update_form.length;$i++) {
104 $name = document.update_form[$i].name;
105 if ($name.substring(0,7) == "claims[" && $name.substring($name.length -6) == "[bill]") {
106 document.update_form[$i].checked = true;
109 set_button_states();
112 function set_button_states() {
113 var f = document.update_form;
114 var count0 = 0; // selected and not billed or queued
115 var count1 = 0; // selected and queued
116 var count2 = 0; // selected and billed
117 for($i = 0; $i < f.length; ++$i) {
118 $name = f[$i].name;
119 if ($name.substring(0, 7) == "claims[" && $name.substring($name.length -6) == "[bill]" && f[$i].checked == true) {
120 if (f[$i].value == '0') ++count0;
121 else if (f[$i].value == '1' || f[$i].value == '5') ++count1;
122 else ++count2;
126 var can_generate = (count0 > 0 || count1 > 0 || count2 > 0);
127 var can_mark = (count1 > 0 || count0 > 0 || count2 > 0);
128 var can_bill = (count0 == 0 && count1 == 0 && count2 > 0);
130 <?php if (file_exists($EXPORT_INC)) { ?>
131 f.bn_external.disabled = !can_generate;
132 <?php } else { ?>
133 // f.bn_hcfa_print.disabled = !can_generate;
134 // f.bn_hcfa.disabled = !can_generate;
135 // f.bn_ub92_print.disabled = !can_generate;
136 // f.bn_ub92.disabled = !can_generate;
137 f.bn_x12.disabled = !can_generate;
138 <?php if ($GLOBALS['support_encounter_claims']) { ?>
139 f.bn_x12_encounter.disabled = !can_generate;
140 <?php } ?>
141 f.bn_process_hcfa.disabled = !can_generate;
142 f.bn_hcfa_txt_file.disabled = !can_generate;
143 // f.bn_electronic_file.disabled = !can_bill;
144 f.bn_reopen.disabled = !can_bill;
145 <?php } ?>
146 f.bn_mark.disabled = !can_mark;
149 // Process a click to go to an encounter.
150 function toencounter(pid, pubpid, pname, enc, datestr, dobstr) {
151 top.restoreSession();
152 var othername = (window.name == 'RTop') ? 'RBot' : 'RTop';
153 parent.left_nav.setPatient(pname,pid,pubpid,'',dobstr);
154 parent.left_nav.setEncounter(datestr, enc, othername);
155 parent.frames[othername].location.href =
156 '../patient_file/encounter/encounter_top.php?set_encounter='
157 + enc + '&pid=' + pid;
159 // Process a click to go to an patient.
160 function topatient(pid, pubpid, pname, enc, datestr, dobstr) {
161 top.restoreSession();
162 var othername = (window.name == 'RTop') ? 'RBot' : 'RTop';
163 parent.left_nav.setPatient(pname,pid,pubpid,'',dobstr);
164 parent.frames[othername].location.href =
165 '../patient_file/summary/demographics_full.php?pid=' + pid;
167 </script>
168 <script language="javascript" type="text/javascript">
169 EncounterDateArray=new Array;
170 CalendarCategoryArray=new Array;
171 EncounterIdArray=new Array;
172 EncounterNoteArray=new Array;
173 function SubmitTheScreen()
174 {//Action on Update List link
175 if(!ProcessBeforeSubmitting())
176 return false;
177 top.restoreSession();
178 document.the_form.mode.value='change';
179 document.the_form.target='_self';
180 document.the_form.action='billing_report.php';
181 document.the_form.submit();
182 return true;
184 function SubmitTheScreenPrint()
185 {//Action on View Printable Report link
186 if(!ProcessBeforeSubmitting())
187 return false;
188 top.restoreSession();
189 document.the_form.target='new';
190 document.the_form.action='print_billing_report.php';
191 document.the_form.submit();
192 return true;
194 function SubmitTheEndDayPrint()
195 {//Action on View End of Day Report link
196 if(!ProcessBeforeSubmitting())
197 return false;
198 top.restoreSession();
199 document.the_form.target='new';
200 <?php if ($GLOBALS['use_custom_daysheet'] == 1) { ?>
201 document.the_form.action='print_daysheet_report_num1.php';
202 <?php } ?>
203 <?php if ($GLOBALS['use_custom_daysheet'] == 2) { ?>
204 document.the_form.action='print_daysheet_report_num2.php';
205 <?php } ?>
206 <?php if ($GLOBALS['use_custom_daysheet'] == 3) { ?>
207 document.the_form.action='print_daysheet_report_num3.php';
208 <?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="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.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 <font class='title'><?php echo xlt('Billing Manager') ?></font>
347 </p>
349 <form name='the_form' method='post' action='billing_report.php' onsubmit='return top.restoreSession()' style="display:inline">
351 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
352 <script type="text/javascript" src="../../library/dialog.js"></script>
353 <script type="text/javascript" src="../../library/textformat.js"></script>
354 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
355 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
356 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
357 <script language='JavaScript'>
358 var mypcc = '1';
359 </script>
361 <input type='hidden' name='mode' value='change'>
362 <!-- ============================================================================================================================================= -->
363 <!-- Criteria section Starts -->
364 <!-- ============================================================================================================================================= -->
365 <?php
366 //The following are the search criteria per page.All the following variable which ends with 'Master' need to be filled properly.
367 //Each item is seperated by a comma(,).
368 //$ThisPageSearchCriteriaDisplayMaster ==>It is the display on screen for the set of criteria.
369 //$ThisPageSearchCriteriaKeyMaster ==>Corresponding database fields in the same order.
370 //$ThisPageSearchCriteriaDataTypeMaster ==>Corresponding data type in the same order.
371 $ThisPageSearchCriteriaDisplayRadioMaster=array();
372 $ThisPageSearchCriteriaRadioKeyMaster=array();
373 $ThisPageSearchCriteriaQueryDropDownMaster=array();
374 $ThisPageSearchCriteriaQueryDropDownMasterDefault=array();
375 $ThisPageSearchCriteriaQueryDropDownMasterDefaultKey=array();
376 $ThisPageSearchCriteriaIncludeMaster=array();
378 if ($daysheet) {
379 $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"),xl("User") );
380 $ThisPageSearchCriteriaKeyMaster="form_encounter.date,billing.date,claims.process_time,claims.target,patient_data.fname,".
381 "form_encounter.pid,claims.payer_id,form_encounter.encounter,insurance_data.provider,billing.id,billing.billed,".
382 "billing.authorized,form_encounter.last_level_billed,billing.x12_partner_id,billing.user";
383 $ThisPageSearchCriteriaDataTypeMaster="datetime,datetime,datetime,radio,text_like,".
384 "text,include,text,radio,radio,radio,".
385 "radio_like,radio,query_drop_down,text";
387 else
390 $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") );
391 $ThisPageSearchCriteriaKeyMaster="form_encounter.date,billing.date,claims.process_time,claims.target,patient_data.fname,".
392 "form_encounter.pid,claims.payer_id,form_encounter.encounter,insurance_data.provider,billing.id,billing.billed,".
393 "billing.authorized,form_encounter.last_level_billed,billing.x12_partner_id";
394 $ThisPageSearchCriteriaDataTypeMaster="datetime,datetime,datetime,radio,text_like,".
395 "text,include,text,radio,radio,radio,".
396 "radio_like,radio,query_drop_down";
401 //The below section is needed if there is any 'radio' or 'radio_like' type in the $ThisPageSearchCriteriaDataTypeMaster
402 //$ThisPageSearchCriteriaDisplayRadioMaster,$ThisPageSearchCriteriaRadioKeyMaster ==>For each radio data type this pair comes.
403 //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.
404 $ThisPageSearchCriteriaDisplayRadioMaster[1] = array( xl("All"),xl("eClaims"),xl("Paper") );//Display Value
405 $ThisPageSearchCriteriaRadioKeyMaster[1]="all,standard,hcfa";//Key
406 $ThisPageSearchCriteriaDisplayRadioMaster[2]= array( xl("All"),xl("Insured"),xl("Non-Insured") );//Display Value
407 $ThisPageSearchCriteriaRadioKeyMaster[2]="all,1,0";//Key
408 $ThisPageSearchCriteriaDisplayRadioMaster[3]= array( xl("All"),xl("Coded"),xl("Not Coded") );//Display Value
409 $ThisPageSearchCriteriaRadioKeyMaster[3]="all,not null,null";//Key
410 $ThisPageSearchCriteriaDisplayRadioMaster[4]= array( xl("All"),xl("Unbilled"),xl("Billed"),xl("Denied") );//Display Value
411 $ThisPageSearchCriteriaRadioKeyMaster[4]="all,0,1,7";//Key
412 $ThisPageSearchCriteriaDisplayRadioMaster[5]= array( xl("All"),xl("Authorized"),xl("Unauthorized") );
413 $ThisPageSearchCriteriaRadioKeyMaster[5]="%,1,0";
414 $ThisPageSearchCriteriaDisplayRadioMaster[6]= array( xl("All"),xl("None"),xl("Ins 1"),xl("Ins 2 or Ins 3") );
415 $ThisPageSearchCriteriaRadioKeyMaster[6]="all,0,1,2";
416 //The below section is needed if there is any 'query_drop_down' type in the $ThisPageSearchCriteriaDataTypeMaster
417 $ThisPageSearchCriteriaQueryDropDownMaster[1]="SELECT name,id FROM x12_partners;";
418 $ThisPageSearchCriteriaQueryDropDownMasterDefault[1]= xl("All");//Only one item will be here
419 $ThisPageSearchCriteriaQueryDropDownMasterDefaultKey[1]="all";//Only one item will be here
420 //The below section is needed if there is any 'include' type in the $ThisPageSearchCriteriaDataTypeMaster
421 //Function name is added here.Corresponding include files need to be included in the respective pages as done in this page.
422 //It is labled(Included for Insurance ajax criteria)(Line:-279-299).
423 $ThisPageSearchCriteriaIncludeMaster[1]="InsuranceCompanyDisplay";//This is php function defined in the file 'report.inc.php'
425 if(!isset($_REQUEST['mode']))//default case
427 $_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")."')";
428 $_REQUEST['final_this_page_criteria'][1]="billing.billed = '0'";
430 $_REQUEST['final_this_page_criteria_text'][0]=xl("Date of Service = Today");
431 $_REQUEST['final_this_page_criteria_text'][1]=xl("Billing Status = Unbilled");
433 $_REQUEST['date_master_criteria_form_encounter_date']="today";
434 $_REQUEST['master_from_date_form_encounter_date']=date("Y-m-d");
435 $_REQUEST['master_to_date_form_encounter_date']=date("Y-m-d");
437 $_REQUEST['radio_billing_billed']=0;
441 <table width='100%' border="0" cellspacing="0" cellpadding="0">
442 <tr>
443 <td width="25%">&nbsp;</td>
444 <td width="50%">
445 <?php include_once("$srcdir/../interface/reports/criteria.tab.php"); ?>
446 </td>
447 <td width="25%">
448 <?php
449 // ============================================================================================================================================= -->
450 // Criteria section Ends -->
451 // ============================================================================================================================================= -->
454 <table width="100%" border="0" cellspacing="0" cellpadding="0">
455 <tr>
456 <td width="15%">&nbsp;</td>
457 <td width="85%"><span class='text'><a onClick="javascript:return SubmitTheScreen();" href="#" class=link_submit>[<?php echo xlt('Update List') ?>]</a>
459 <a onClick="javascript:return SubmitTheScreenExportOFX();" href="#" class='link_submit'><?php echo '[' . xlt('Export OFX') .']' ?></a></span> </td>
460 </tr>
461 <tr>
462 <td>&nbsp;</td>
463 <td><a onClick="javascript:return SubmitTheScreenPrint();" href="#"
464 class='link_submit' ><?php echo '['. xlt('View Printable Report').']' ?></a></td>
465 </tr>
467 <?php if ($daysheet) { ?>
468 <tr>
469 <td>&nbsp;</td>
470 <td><a onClick="javascript:return SubmitTheEndDayPrint();" href="#"
471 class='link_submit' ><?php echo '['.xlt('End Of Day Report').']' ?></a>
472 <?php if ($daysheet_total) { ?>
473 <span class=text><?php echo xlt('Totals'); ?> </span>
474 <input type=checkbox name="end_of_day_totals_only" value="1" <?php if ($obj['end_of_day_totals_only'] === '1') echo "checked";?>>
475 <?php } ?>
476 <?php if ($provider_run) { ?>
477 <span class=text><?php echo xlt('Provider'); ?> </span>
478 <input type=checkbox name="end_of_day_provider_only" value="1" <?php if ($obj['end_of_day_provider_only'] === '1') echo "checked";?>>
479 <?php } ?>
480 </td>
481 </tr>
482 <?php } ?>
483 <tr>
484 <td>&nbsp;</td>
485 <td>
486 <?php if (! file_exists($EXPORT_INC)) { ?>
487 <!--
488 <a href="javascript:top.restoreSession();document.the_form.mode.value='process';document.the_form.submit()" class="link_submit"
489 title="Process all queued bills to create electronic data (and print if requested)"><?php echo '['. xlt('Start Batch Processing') .']' ?></a>
490 &nbsp;
492 <a href='#' id="view-log-link" class='link_submit'
493 title='<?php xla('See messages from the last set of generated claims'); ?>'><?php echo '['. xlt('View Log') .']'?></a>
494 <?php } ?>
495 </td>
496 </tr>
497 <tr>
498 <td>&nbsp;</td>
499 <td><a href="javascript:select_all()" class="link_submit"><?php echo '['. xlt('Select All') .']'?></a></td>
500 </tr>
501 </table>
504 </td>
505 </tr>
506 </table>
507 <table width='100%' border="0" cellspacing="0" cellpadding="0" >
508 <tr>
509 <td>
510 <hr color="#000000">
511 </td>
512 </tr>
513 </table>
514 </form>
515 <form name='update_form' method='post' action='billing_process.php' onsubmit='return top.restoreSession()' style="display:inline">
516 <center>
517 <span class='text' style="display:inline">
518 <?php if (file_exists($EXPORT_INC)) { ?>
519 <input type="submit" data-open-popup="true" class="subbtn" name="bn_external" value="Export Billing" title="<?php echo xla('Export to external billing system') ?>">
520 <input type="submit" data-open-popup="true" class="subbtn" name="bn_mark" value="Mark as Cleared" title="<?php echo xla('Mark as billed but skip billing') ?>">
521 <?php } else { ?>
522 <!--
523 <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') ?>">
524 <input type="submit" class="subbtn" name="bn_hcfa" value="Queue HCFA" title="<?php echo xla('Queue for HCFA batch processing')?>">
525 <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')?>">
526 <input type="submit" class="subbtn" name="bn_ub92" value="Queue UB92" title="<?php echo xla('Queue for UB-92 batch processing')?>">
528 <input type="submit" class="subbtn" name="bn_x12" value="<?php echo xla('Generate X12')?>"
529 title="<?php echo xla('Generate and download X12 batch')?>"
530 onclick="MarkAsCleared(1)">
531 <?php if ($GLOBALS['support_encounter_claims']) { ?>
532 <input type="submit" class="subbtn" name="bn_x12_encounter" value="<?php echo xla('Generate X12 Encounter')?>"
533 title="<?php echo xla('Generate and download X12 encounter claim batch')?>"
534 onclick="MarkAsCleared(1)">
535 <?php } ?>
536 <input type="submit" class="subbtn" style="width:175px;" name="bn_process_hcfa" value="<?php echo xla('Generate CMS 1500 PDF')?>"
537 title="<?php echo xla('Generate and download CMS 1500 paper claims')?>"
538 onclick="MarkAsCleared(2)">
539 <input type="submit" class="subbtn" style="width:175px;" name="bn_hcfa_txt_file" value="<?php echo xla('Generate CMS 1500 TEXT')?>"
540 title="<?php echo xla('Making batch text files for uploading to Clearing House and will mark as billed')?>"
541 onclick="MarkAsCleared(3)">
542 <input type="submit" data-open-popup="true" class="subbtn" name="bn_mark" value="<?php echo xla('Mark as Cleared')?>" title="<?php echo xla('Post to accounting and mark as billed')?>">
543 <input type="submit" data-open-popup="true" class="subbtn" name="bn_reopen" value="<?php echo xla('Re-Open')?>" title="<?php echo xla('Mark as not billed')?>">
544 <!--
545 <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')?>">
547 &nbsp;&nbsp;&nbsp;
548 <?php echo xlt('CMS 1500 Margins'); ?>:
549 &nbsp;<?php echo xlt('Left'); ?>:
550 <input type='text' size='2' name='left_margin'
551 value='<?php echo attr($left_margin); ?>'
552 title='<?php echo xla('HCFA left margin in points'); ?>' />
553 &nbsp;<?php echo xlt('Top'); ?>:
554 <input type='text' size='2' name='top_margin'
555 value='<?php echo attr($top_margin); ?>'
556 title='<?php echo xla('HCFA top margin in points'); ?>' />
557 </span>
558 <?php } ?>
560 </center>
561 <input type='hidden' name='HiddenMarkAsCleared' id='HiddenMarkAsCleared' value="" />
562 <input type='hidden' name='mode' value="bill" />
563 <input type='hidden' name='authorized' value="<?php echo attr($my_authorized); ?>" />
564 <input type='hidden' name='unbilled' value="<?php echo attr($unbilled); ?>" />
565 <input type='hidden' name='code_type' value="%" />
566 <input type='hidden' name='to_date' value="<?php echo attr($to_date); ?>" />
567 <input type='hidden' name='from_date' value="<?php echo attr($from_date); ?>" />
569 <?php
570 if ($my_authorized == "on" ) {
571 $my_authorized = "1";
572 } else {
573 $my_authorized = "%";
575 if ($unbilled == "on") {
576 $unbilled = "0";
577 } else {
578 $unbilled = "%";
580 $list = getBillsListBetween("%");
583 <input type='hidden' name='bill_list' value="<?php echo attr($list); ?>" />
585 <!-- new form for uploading -->
587 <?php
588 if (!isset($_POST["mode"])) {
589 if (!isset($_POST["from_date"])) {
590 $from_date = date("Y-m-d");
591 } else {
592 $from_date = $_POST["from_date"];
594 if (empty($_POST["to_date"])) {
595 $to_date = '';
596 } else {
597 $to_date = $_POST["to_date"];
599 if (!isset($_POST["code_type"])) {
600 $code_type="all";
601 } else {
602 $code_type = $_POST["code_type"];
604 if (!isset($_POST["unbilled"])) {
605 $unbilled = "on";
606 } else {
607 $unbilled = $_POST["unbilled"];
609 if (!isset($_POST["authorized"])) {
610 $my_authorized = "on";
611 } else {
612 $my_authorized = $_POST["authorized"];
614 } else {
615 $from_date = $_POST["from_date"];
616 $to_date = $_POST["to_date"];
617 $code_type = $_POST["code_type"];
618 $unbilled = $_POST["unbilled"];
619 $my_authorized = $_POST["authorized"];
622 if ($my_authorized == "on" ) {
623 $my_authorized = "1";
624 } else {
625 $my_authorized = "%";
628 if ($unbilled == "on") {
629 $unbilled = "0";
630 } else {
631 $unbilled = "%";
634 if (isset($_POST["mode"]) && $_POST["mode"] == "bill") {
635 billCodesList($list);
639 <table border="0" cellspacing="0" cellpadding="0" width="100%">
641 <?php
642 $divnos=0;
643 if ($ret = getBillsBetween("%"))
645 if(is_array($ret))
648 <tr ><td colspan='9' align="right" ><table width="250" border="0" cellspacing="0" cellpadding="0">
649 <tr>
650 <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>
651 <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>
652 <td width="50">&nbsp;</td>
653 </tr>
654 </table>
655 </td></tr>
656 <?php
658 $loop = 0;
659 $oldcode = "";
660 $last_encounter_id = "";
661 $lhtml = "";
662 $rhtml = "";
663 $lcount = 0;
664 $rcount = 0;
665 $bgcolor = "";
666 $skipping = FALSE;
668 $mmo_empty_mod = false;
669 $mmo_num_charges = 0;
671 foreach ($ret as $iter) {
673 // We include encounters here that have never been billed. However
674 // if it had no selected billing items but does have non-selected
675 // billing items, then it is not of interest.
676 if (!$iter['id']) {
677 $res = sqlQuery("SELECT count(*) AS count FROM billing WHERE " .
678 "encounter = ? AND " .
679 "pid=? AND " .
680 "activity = 1", array($iter['enc_encounter'],$iter['enc_pid']) );
681 if ($res['count'] > 0) continue;
684 $this_encounter_id = $iter['enc_pid'] . "-" . $iter['enc_encounter'];
686 if ($last_encounter_id != $this_encounter_id) {
688 // This dumps all HTML for the previous encounter.
690 if ($lhtml) {
691 while ($rcount < $lcount) {
692 $rhtml .= "<tr bgcolor='$bgcolor'><td colspan='8'></td></tr>";
693 ++$rcount;
695 // This test handles the case where we are only listing encounters
696 // that appear to have a missing "25" modifier.
697 if (!$missing_mods_only || ($mmo_empty_mod && $mmo_num_charges > 1)) {
698 if($DivPut=='yes')
700 $lhtml.='</div>';
701 $DivPut='no';
703 echo "<tr bgcolor='$bgcolor'>\n<td rowspan='$rcount' valign='top'>\n$lhtml</td>$rhtml\n";
704 echo "<tr bgcolor='$bgcolor'><td colspan='9' height='5'></td></tr>\n\n";
705 ++$encount;
709 $lhtml = "";
710 $rhtml = "";
711 $mmo_empty_mod = false;
712 $mmo_num_charges = 0;
714 // If there are ANY unauthorized items in this encounter and this is
715 // the normal case of viewing only authorized billing, then skip the
716 // entire encounter.
718 $skipping = FALSE;
719 if ($my_authorized == '1') {
720 $res = sqlQuery("select count(*) as count from billing where " .
721 "encounter = ? and " .
722 "pid=? and " .
723 "activity = 1 and authorized = 0", array($iter['enc_encounter'],$iter['enc_pid']) );
724 if ($res['count'] > 0) {
725 $skipping = TRUE;
726 $last_encounter_id = $this_encounter_id;
727 continue;
731 $name = getPatientData($iter['enc_pid'], "fname, mname, lname, pubpid, billing_note, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
733 # Check if patient has primary insurance and a subscriber exists for it.
734 # If not we will highlight their name in red.
735 # TBD: more checking here.
737 $res = sqlQuery("select count(*) as count from insurance_data where " .
738 "pid = ? and " .
739 "type='primary' and " .
740 "subscriber_lname is not null and " .
741 "subscriber_lname != '' limit 1", array($iter['enc_pid']) );
742 $namecolor = ($res['count'] > 0) ? "black" : "#ff7777";
744 $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
745 echo "<tr bgcolor='$bgcolor'><td colspan='9' height='5'></td></tr>\n";
746 $lcount = 1;
747 $rcount = 0;
748 $oldcode = "";
750 $ptname = $name['fname'] . " " . $name['lname'];
751 $raw_encounter_date = date("Y-m-d", strtotime($iter['enc_date']));
752 $billing_note = $name['billing_note'];
753 // Add Encounter Date to display with "To Encounter" button 2/17/09 JCH
754 $lhtml .= "&nbsp;<span class=bold><font color='$namecolor'>". text($ptname) .
755 "</font></span><span class=small>&nbsp;(" . text($iter['enc_pid']) . "-" .
756 text($iter['enc_encounter']) . ")</span>";
758 //Encounter details are stored to javacript as array.
759 $result4 = sqlStatement("SELECT fe.encounter,fe.date,fe.billing_note,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe ".
760 " 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']) );
761 if(sqlNumRows($result4)>0)
763 <script language='JavaScript'>
764 Count=0;
765 EncounterDateArray[<?php echo attr($iter['enc_pid']); ?>]=new Array;
766 CalendarCategoryArray[<?php echo attr($iter['enc_pid']); ?>]=new Array;
767 EncounterIdArray[<?php echo attr($iter['enc_pid']); ?>]=new Array;
768 EncounterNoteArray[<?php echo attr($iter['enc_pid']); ?>]=new Array;
769 <?php
770 while($rowresult4 = sqlFetchArray($result4))
773 EncounterIdArray[<?php echo attr($iter['enc_pid']); ?>][Count]='<?php echo htmlspecialchars($rowresult4['encounter'], ENT_QUOTES); ?>';
774 EncounterDateArray[<?php echo attr($iter['enc_pid']); ?>][Count]='<?php echo htmlspecialchars(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date']))), ENT_QUOTES); ?>';
775 CalendarCategoryArray[<?php echo attr($iter['enc_pid']); ?>][Count]='<?php echo htmlspecialchars( xl_appt_category($rowresult4['pc_catname']), ENT_QUOTES); ?>';
776 EncounterNoteArray[<?php echo attr($iter['enc_pid']); ?>][Count]='<?php echo htmlspecialchars($rowresult4['billing_note'], ENT_QUOTES); ?>';
777 Count++;
778 <?php
779 $enc_billing_note = $rowresult4['billing_note'];
782 </script>
783 <?php
785 // Not sure why the next section seems to do nothing except post "To Encounter" button 2/17/09 JCH
786 $lhtml .= "&nbsp;&nbsp;&nbsp;<a class=\"link_submit\" " .
787 "href=\"javascript:window.toencounter(" . $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'] . "])\">[" .
794 xlt('To Enctr') . " " . text(oeFormatShortDate($raw_encounter_date)) . "]</a>";
796 // Changed "To xxx" buttons to allow room for encounter date display 2/17/09 JCH
797 $lhtml .= "&nbsp;&nbsp;&nbsp;<a class=\"link_submit\" " .
798 "href=\"javascript:window.topatient(" . $iter['enc_pid'] .
799 ",'" . addslashes($name['pubpid']) .
800 "','" . addslashes($ptname) . "'," . $iter['enc_encounter'] .
801 ",'" . oeFormatShortDate($raw_encounter_date) . "',' " .
802 xl('DOB') . ": " . oeFormatShortDate($name['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAge($name['DOB_YMD']) . "');
803 top.window.parent.left_nav.setPatientEncounter(EncounterIdArray[" . $iter['enc_pid'] . "],EncounterDateArray[" . $iter['enc_pid'] .
804 "], CalendarCategoryArray[" . $iter['enc_pid'] . "])\">[" . xlt('To Dems') . "]</a>";
805 $divnos=$divnos+1;
806 $lhtml .= "&nbsp;&nbsp;&nbsp;<a onclick='divtoggle(\"spanid_$divnos\",\"divid_$divnos\");' class='small' id='aid_$divnos' href=\"JavaScript:void(0);".
807 "\">(<span id=spanid_$divnos class=\"indicator\">" . htmlspecialchars( xl('Expand'), ENT_QUOTES) . '</span>)<br></a>';
808 if($GLOBALS['notes_to_display_in_Billing'] == 2 || $GLOBALS['notes_to_display_in_Billing'] == 3){
809 $lhtml .= '<span style="margin-left: 20px; font-weight bold; color: red">'.text($billing_note).'</span>';
812 if ($iter['id']) {
814 $lcount += 2;
815 $lhtml .= "<br />\n";
816 $lhtml .= "&nbsp;<span class=text>Bill: ";
817 $lhtml .= "<select name='claims[" . attr($this_encounter_id) . "][payer]' style='background-color:$bgcolor'>";
819 $query = "SELECT id.provider AS id, id.type, id.date, " .
820 "ic.x12_default_partner_id AS ic_x12id, ic.name AS provider " .
821 "FROM insurance_data AS id, insurance_companies AS ic WHERE " .
822 "ic.id = id.provider AND " .
823 "id.pid = ? AND " .
824 "id.date <= ? " .
825 "ORDER BY id.type ASC, id.date DESC";
827 $result = sqlStatement($query, array($iter['enc_pid'],$raw_encounter_date) );
828 $count = 0;
829 $default_x12_partner = $iter['ic_x12id'];
830 $prevtype = '';
832 while ($row = sqlFetchArray($result)) {
833 if (strcmp($row['type'], $prevtype) == 0) continue;
834 $prevtype = $row['type'];
835 if (strlen($row['provider']) > 0) {
836 // This preserves any existing insurance company selection, which is
837 // important when EOB posting has re-queued for secondary billing.
838 $lhtml .= "<option value=\"" . attr(substr($row['type'],0,1).$row['id']) . "\"";
839 if (($count == 0 && !$iter['payer_id']) || $row['id'] == $iter['payer_id']) {
840 $lhtml .= " selected";
841 if (!is_numeric($default_x12_partner)) $default_x12_partner = $row['ic_x12id'];
843 $lhtml .= ">" . text($row['type']) . ": " . text($row['provider']) . "</option>";
845 $count++;
848 $lhtml .= "<option value='-1'>" . xlt("Unassigned") . "</option>\n";
849 $lhtml .= "</select>&nbsp;&nbsp;\n";
850 $lhtml .= "<select name='claims[" . attr($this_encounter_id) . "][partner]' style='background-color:$bgcolor'>";
851 $x = new X12Partner();
852 $partners = $x->_utility_array($x->x12_partner_factory());
853 foreach ($partners as $xid => $xname) {
854 $lhtml .= '<option label="' . attr($xname) . '" value="' . attr($xid) .'"';
855 if ($xid == $default_x12_partner) {
856 $lhtml .= "selected";
858 $lhtml .= '>' . text($xname) . '</option>';
860 $lhtml .= "</select>";
861 $DivPut='yes';
863 if($GLOBALS['notes_to_display_in_Billing'] == 1 || $GLOBALS['notes_to_display_in_Billing'] == 3) {
864 $lhtml .= "<br><span style='margin-left: 20px; font-weight bold; color: red'>".text($enc_billing_note)."</span>";
866 $lhtml .= "<br>\n&nbsp;<div id='divid_$divnos' style='display:none'>" . text(oeFormatShortDate(substr($iter['date'], 0, 10)))
867 . text(substr($iter['date'], 10, 6)) . " " . xlt("Encounter was coded");
869 $query = "SELECT * FROM claims WHERE " .
870 "patient_id = ? AND " .
871 "encounter_id = ? " .
872 "ORDER BY version";
873 $cres = sqlStatement($query, array($iter['enc_pid'],$iter['enc_encounter']) );
875 $lastcrow = false;
877 while ($crow = sqlFetchArray($cres)) {
878 $query = "SELECT id.type, ic.name " .
879 "FROM insurance_data AS id, insurance_companies AS ic WHERE " .
880 "id.pid = ? AND " .
881 "id.provider = ? AND " .
882 "id.date <= ? AND " .
883 "ic.id = id.provider " .
884 "ORDER BY id.type ASC, id.date DESC";
886 $irow= sqlQuery($query, array($iter['enc_pid'],$crow['payer_id'],$raw_encounter_date) );
888 if ($crow['bill_process']) {
889 $lhtml .= "<br>\n&nbsp;" .
890 text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) .
891 text(substr($crow['bill_time'], 10, 6)) . " " .
892 xlt("Queued for") . " " . text($irow['type']) . " " . text($crow['target']) . " " .
893 xlt("billing to ") . text($irow['name']);
894 ++$lcount;
896 else if ($crow['status'] < 6) {
897 if ($crow['status'] > 1) {
898 $lhtml .= "<br>\n&nbsp;" .
899 text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) .
900 text(substr($crow['bill_time'], 10, 6)) . " " .
901 htmlspecialchars( xl("Marked as cleared"), ENT_QUOTES);
902 ++$lcount;
904 else {
905 $lhtml .= "<br>\n&nbsp;" .
906 text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) .
907 text(substr($crow['bill_time'], 10, 6)) . " " .
908 htmlspecialchars( xl("Re-opened"), ENT_QUOTES);
909 ++$lcount;
912 else if ($crow['status'] == 6) {
913 $lhtml .= "<br>\n&nbsp;" .
914 text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) .
915 text(substr($crow['bill_time'], 10, 6)) . " " .
916 htmlspecialchars( xl("This claim has been forwarded to next level."), ENT_QUOTES);
917 ++$lcount;
919 else if ($crow['status'] == 7) {
920 $lhtml .= "<br>\n&nbsp;" .
921 text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) .
922 text(substr($crow['bill_time'], 10, 6)) . " " .
923 htmlspecialchars( xl("This claim has been denied.Reason:-"), ENT_QUOTES);
924 if($crow['process_file'])
926 $code_array=explode(',',$crow['process_file']);
927 foreach($code_array as $code_key => $code_value)
929 $lhtml .= "<br>\n&nbsp;&nbsp;&nbsp;";
930 $reason_array=explode('_',$code_value);
931 if(!isset($adjustment_reasons[$reason_array[3]]))
933 $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]).']';
935 else
937 $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]]);
941 else
943 $lhtml .=htmlspecialchars( xl("Not Specified."), ENT_QUOTES);
945 ++$lcount;
948 if ($crow['process_time']) {
949 $lhtml .= "<br>\n&nbsp;" .
950 text(oeFormatShortDate(substr($crow['process_time'], 0, 10))) .
951 text(substr($crow['process_time'], 10, 6)) . " " .
952 xlt("Claim was generated to file") . " " .
953 "<a href='get_claim_file.php?key=" . attr($crow['process_file']) .
954 "' onclick='top.restoreSession()'>" .
955 text($crow['process_file']) . "</a>";
956 ++$lcount;
959 $lastcrow = $crow;
960 } // end while ($crow = sqlFetchArray($cres))
962 if ($lastcrow && $lastcrow['status'] == 4) {
963 $lhtml .= "<br>\n&nbsp;" . xlt("This claim has been closed.");
964 ++$lcount;
967 if ($lastcrow && $lastcrow['status'] == 5) {
968 $lhtml .= "<br>\n&nbsp;" . xlt("This claim has been canceled.");
969 ++$lcount;
971 } // end if ($iter['id'])
973 } // end if ($last_encounter_id != $this_encounter_id)
975 if ($skipping) continue;
977 // Collect info related to the missing modifiers test.
978 if ($iter['fee'] > 0) {
979 ++$mmo_num_charges;
980 $tmp = substr($iter['code'], 0, 3);
981 if (($tmp == '992' || $tmp == '993') && empty($iter['modifier']))
982 $mmo_empty_mod = true;
985 ++$rcount;
987 if ($rhtml) {
988 $rhtml .= "<tr bgcolor='$bgcolor'>\n";
990 $rhtml .= "<td width='50'>";
991 if ($iter['id'] && $oldcode != $iter['code_type']) {
992 $rhtml .= "<span class=text>" . text($iter['code_type']) . ": </span>";
995 $oldcode = $iter['code_type'];
996 $rhtml .= "</td>\n";
997 $justify = "";
999 if ($iter['id'] && $code_types[$iter['code_type']]['just']) {
1000 $js = explode(":",$iter['justify']);
1001 $counter = 0;
1002 foreach ($js as $j) {
1003 if(!empty($j)) {
1004 if ($counter == 0) {
1005 $justify .= " (<b>" . text($j) . "</b>)";
1007 else {
1008 $justify .= " (" . text($j) . ")";
1010 $counter++;
1015 $rhtml .= "<td><span class='text'>" .
1016 ($iter['code_type'] == 'COPAY' ? text(oeFormatMoney($iter['code'])) : text($iter['code']));
1017 if ($iter['modifier']) $rhtml .= ":" . text($iter['modifier']);
1018 $rhtml .= "</span><span style='font-size:8pt;'>$justify</span></td>\n";
1020 $rhtml .= '<td align="right"><span style="font-size:8pt;">&nbsp;&nbsp;&nbsp;';
1021 if ($iter['id'] && $iter['fee'] > 0) {
1022 $rhtml .= text(oeFormatMoney($iter['fee']));
1024 $rhtml .= "</span></td>\n";
1025 $rhtml .= '<td><span style="font-size:8pt;">&nbsp;&nbsp;&nbsp;';
1026 if ($iter['id']) $rhtml .= getProviderName(empty($iter['provider_id']) ? text($iter['enc_provider_id']) : text($iter['provider_id']));
1027 $rhtml .= "</span></td>\n";
1028 $rhtml .= '<td><span style="font-size:8pt;">&nbsp;&nbsp;&nbsp;';
1029 if($GLOBALS['display_units_in_billing'] != 0) {
1030 if ($iter['id']) $rhtml .= xlt("Units") . ":" . text($iter{"units"});
1032 $rhtml .= "</span></td>\n";
1033 $rhtml .= '<td width=100>&nbsp;&nbsp;&nbsp;<span style="font-size:8pt;">';
1034 if ($iter['id']) $rhtml .= text(oeFormatSDFT(strtotime($iter{"date"})));
1035 $rhtml .= "</span></td>\n";
1036 # This error message is generated if the authorized check box is not checked
1037 if ($iter['id'] && $iter['authorized'] != 1) {
1038 $rhtml .= "<td><span class=alert>".xlt("Note: This code has not been authorized.")."</span></td>\n";
1040 else {
1041 $rhtml .= "<td></td>\n";
1043 if ($iter['id'] && $last_encounter_id != $this_encounter_id) {
1044 $tmpbpr = $iter['bill_process'];
1045 if ($tmpbpr == '0' && $iter['billed']) $tmpbpr = '2';
1046 $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";
1047 $CheckBoxBilling++;
1049 else {
1050 $rhtml .= "<td></td>\n";
1052 if($last_encounter_id != $this_encounter_id){
1053 $rhtml2 = "";
1054 $rowcnt = 0;
1055 $resMoneyGot = sqlStatement("SELECT pay_amount as PatientPay,date(post_time) as date FROM ar_activity where ".
1056 "pid = ? and encounter = ? and payer_type=0 and account_code='PCP'",
1057 array($iter['enc_pid'],$iter['enc_encounter']));
1058 //new fees screen copay gives account_code='PCP'
1059 if(sqlNumRows($resMoneyGot) > 0){
1060 $lcount += 2;
1061 $rcount++;
1063 //checks whether a copay exists for the encounter and if exists displays it.
1064 while($rowMoneyGot = sqlFetchArray($resMoneyGot)){
1065 $rowcnt++;
1066 $PatientPay=$rowMoneyGot['PatientPay'];
1067 $date=$rowMoneyGot['date'];
1068 if($PatientPay > 0){
1069 if($rhtml){
1070 $rhtml2 .= "<tr bgcolor='$bgcolor'>\n";
1072 $rhtml2 .= "<td width='50'>";
1073 $rhtml2 .= "<span class='text'>".xlt('COPAY').": </span>";
1074 $rhtml2 .= "</td>\n";
1075 $rhtml2 .= "<td><span class='text'>".text(oeFormatMoney($PatientPay))."</span><span style='font-size:8pt;'>&nbsp;</span></td>\n";
1076 $rhtml2 .= '<td align="right"><span style="font-size:8pt;">&nbsp;&nbsp;&nbsp;';
1077 $rhtml2 .= "</span></td>\n";
1078 $rhtml2 .= '<td><span style="font-size:8pt;">&nbsp;&nbsp;&nbsp;';
1079 $rhtml2 .= "</span></td>\n";
1080 $rhtml2 .= '<td><span style="font-size:8pt;">&nbsp;&nbsp;&nbsp;';
1081 $rhtml2 .= "</span></td>\n";
1082 $rhtml2 .= '<td width=100>&nbsp;&nbsp;&nbsp;<span style="font-size:8pt;">';
1083 $rhtml2 .= text(oeFormatSDFT(strtotime($date)));
1084 $rhtml2 .= "</span></td>\n";
1085 if ($iter['id'] && $iter['authorized'] != 1) {
1086 $rhtml2 .= "<td><span class=alert>".xlt("Note: This copay was entered against billing that has not been authorized. Please review status.")."</span></td>\n";
1087 }else{
1088 $rhtml2 .= "<td></td>\n";
1090 if(!$iter['id'] && $rowcnt == 1){
1091 $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";
1092 $CheckBoxBilling++;
1093 }else{
1094 $rhtml2 .= "<td></td>\n";
1098 $rhtml .= $rhtml2;
1100 $rhtml .= "</tr>\n";
1101 $last_encounter_id = $this_encounter_id;
1103 } // end foreach
1105 if ($lhtml) {
1106 while ($rcount < $lcount) {
1107 $rhtml .= "<tr bgcolor='$bgcolor'><td colspan='8'></td></tr>";
1108 ++$rcount;
1110 if (!$missing_mods_only || ($mmo_empty_mod && $mmo_num_charges > 1)) {
1111 if($DivPut=='yes')
1113 $lhtml.='</div>';
1114 $DivPut='no';
1116 echo "<tr bgcolor='$bgcolor'>\n<td rowspan='$rcount' valign='top'>\n$lhtml</td>$rhtml\n";
1117 echo "<tr bgcolor='$bgcolor'><td colspan='9' height='5'></td></tr>\n";
1125 </table>
1126 </form>
1128 <script>
1129 set_button_states();
1130 <?php
1131 if ($alertmsg) {
1132 echo "alert('".addslashes($alertmsg)."');\n";
1135 $(document).ready(function() {
1136 $("#view-log-link").click( function() {
1137 top.restoreSession();
1138 dlgopen('customize_log.php', '_blank', 500, 400);
1141 $('input[type="submit"]').click( function() {
1142 top.restoreSession();
1143 $(this).attr('data-clicked', true);
1146 $('form[name="update_form"]').submit( function(e) {
1147 var clickedButton = $("input[type=submit][data-clicked='true'")[0];
1149 // clear clicked button indicator
1150 $('input[type="submit"]').attr('data-clicked', false);
1152 if ( !clickedButton || $(clickedButton).attr("data-open-popup") !== "true" ) {
1153 $(this).removeAttr("target");
1154 return top.restoreSession();
1155 } else {
1156 top.restoreSession();
1157 var w = window.open('about:blank','Popup_Window','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=300,left = 312,top = 234');
1158 this.target = 'Popup_Window';
1162 </script>
1163 <input type="hidden" name="divnos" id="divnos" value="<?php echo attr($divnos) ?>"/>
1164 <input type='hidden' name='ajax_mode' id='ajax_mode' value='' />
1165 </body>
1166 </html>