3 * Billing Report Program
5 * This program displays the main search and select screen for claims generation
7 * Copyright (C) 2016 Terry Hill <terry@lillysystems.com>
8 * Copyright (C) 2014 Brady Miller <brady.g.miller@gmail.com>
10 * LICENSE: This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 3
13 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see http://opensource.org/licenses/gpl-license.php.
22 * @author Terry Hill <terry@lilysystems.com>
23 * @author Brady Miller <brady.g.miller@gmail.com>
24 * @link http://www.open-emr.org
27 $fake_register_globals=false;
28 $sanitize_all_escapes=true;
30 require_once("../globals.php");
31 require_once("../../library/acl.inc");
32 require_once("../../custom/code_types.inc.php");
33 require_once("$srcdir/patient.inc");
34 include_once("$srcdir/../interface/reports/report.inc.php");//Criteria Section common php page
35 require_once("$srcdir/billrep.inc");
36 require_once("$srcdir/formatting.inc.php");
37 require_once("$srcdir/options.inc.php");
38 require_once("adjustment_reason_codes.php");
40 $EXPORT_INC = "$webserver_root/custom/BillingExport.php";
41 //echo $GLOBALS['daysheet_provider_totals'];
44 $daysheet_total = false;
45 $provider_run = false;
47 if ($GLOBALS['use_custom_daysheet'] != 0) {
49 if ($GLOBALS['daysheet_provider_totals'] == 1) {
50 $daysheet_total = true;
51 $provider_run = false;
53 if ($GLOBALS['daysheet_provider_totals'] == 0) {
54 $daysheet_total = false;
61 if (isset($_POST['mode'])) {
62 if ($_POST['mode'] == 'export') {
63 $sql = ReturnOFXSql();
65 $results = $db->Execute($sql);
67 if ($results->RecordCount() == 0) {
68 echo xlt("No Bills Found to Include in OFX Export")."<br>";
70 while(!$results->EOF
) {
71 $billings[] = $results->fields
;
74 $ofx = new OFX($billings);
75 header("Pragma: public");
77 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
78 header("Content-Disposition: attachment; filename=openemr_ofx.ofx");
79 header("Content-Type: text/xml");
87 $from_date = isset($_POST['from_date']) ?
$_POST['from_date'] : date('Y-m-d');
88 $to_date = isset($_POST['to_date' ]) ?
$_POST['to_date' ] : '';
89 $code_type = isset($_POST['code_type']) ?
$_POST['code_type'] : 'all';
90 $unbilled = isset($_POST['unbilled' ]) ?
$_POST['unbilled' ] : 'on';
91 $my_authorized = isset($_POST["authorized"]) ?
$_POST["authorized"] : '';
94 // This tells us if only encounters that appear to be missing a "25" modifier
95 // are to be reported.
96 $missing_mods_only = (isset($_POST['missing_mods_only']) && !empty($_POST['missing_mods_only']));
98 $left_margin = isset($_POST["left_margin"]) ?
$_POST["left_margin"] : $GLOBALS['cms_left_margin_default'];
99 $top_margin = isset($_POST["top_margin"] ) ?
$_POST["top_margin" ] : $GLOBALS['cms_top_margin_default'];
101 $ofrom_date = $from_date;
102 $oto_date = $to_date;
103 $ocode_type = $code_type;
104 $ounbilled = $unbilled;
105 $oauthorized = $my_authorized;
110 <?php
if (function_exists('html_header_show')) html_header_show(); ?
>
111 <link rel
="stylesheet" href
="<?php echo $css_header; ?>" type
="text/css">
113 .subbtn
{ margin
-top
:3px
; margin
-bottom
:3px
; margin
-left
:2px
; margin
-right
:2px
}
117 function select_all() {
118 for($i=0;$i < document
.update_form
.length
;$i++
) {
119 $name = document
.update_form
[$i].name
;
120 if ($name.substring(0,7) == "claims[" && $name.substring($name.length
-6) == "[bill]") {
121 document
.update_form
[$i].checked
= true;
127 function set_button_states() {
128 var f
= document
.update_form
;
129 var count0
= 0; // selected and not billed or queued
130 var count1
= 0; // selected and queued
131 var count2
= 0; // selected and billed
132 for($i = 0; $i < f
.length
; ++
$i) {
134 if ($name.substring(0, 7) == "claims[" && $name.substring($name.length
-6) == "[bill]" && f
[$i].checked
== true) {
135 if (f
[$i].value
== '0') ++count0
;
136 else if (f
[$i].value
== '1' || f
[$i].value
== '5') ++count1
;
141 var can_generate
= (count0
> 0 || count1
> 0 || count2
> 0);
142 var can_mark
= (count1
> 0 || count0
> 0 || count2
> 0);
143 var can_bill
= (count0
== 0 && count1
== 0 && count2
> 0);
145 <?php
if (file_exists($EXPORT_INC)) { ?
>
146 f
.bn_external
.disabled
= !can_generate
;
148 // f.bn_hcfa_print.disabled = !can_generate;
149 // f.bn_hcfa.disabled = !can_generate;
150 // f.bn_ub92_print.disabled = !can_generate;
151 // f.bn_ub92.disabled = !can_generate;
152 f
.bn_x12
.disabled
= !can_generate
;
153 <?php
if ($GLOBALS['support_encounter_claims']) { ?
>
154 f
.bn_x12_encounter
.disabled
= !can_generate
;
156 f
.bn_process_hcfa
.disabled
= !can_generate
;
157 <?php
if ($GLOBALS['preprinted_cms_1500']) { ?
>
158 f
.bn_process_hcfa_form
.disabled
= !can_generate
;
160 f
.bn_hcfa_txt_file
.disabled
= !can_generate
;
161 // f.bn_electronic_file.disabled = !can_bill;
162 f
.bn_reopen
.disabled
= !can_bill
;
164 f
.bn_mark
.disabled
= !can_mark
;
167 // Process a click to go to an encounter.
168 function toencounter(pid
, pubpid
, pname
, enc
, datestr
, dobstr
) {
169 top
.restoreSession();
170 encurl
= 'patient_file/encounter/encounter_top.php?set_encounter=' + enc +
'&pid=' + pid
;
171 parent
.left_nav
.setPatient(pname
,pid
,pubpid
,'',dobstr
);
172 <?php
if ($GLOBALS['new_tabs_layout']) { ?
>
173 parent
.left_nav
.setEncounter(datestr
, enc
, 'enc');
174 parent
.left_nav
.loadFrame('enc2', 'enc', encurl
);
176 var othername
= (window
.name
== 'RTop') ?
'RBot' : 'RTop';
177 parent
.left_nav
.setEncounter(datestr
, enc
, othername
);
178 parent
.frames
[othername
].location
.href
= '../' + encurl
;
181 // Process a click to go to an patient.
182 function topatient(pid
, pubpid
, pname
, enc
, datestr
, dobstr
) {
183 top
.restoreSession();
184 paturl
= 'patient_file/summary/demographics_full.php?pid=' + pid
;
185 parent
.left_nav
.setPatient(pname
,pid
,pubpid
,'',dobstr
);
186 <?php
if ($GLOBALS['new_tabs_layout']) { ?
>
187 parent
.left_nav
.loadFrame('ens1', 'enc', 'patient_file/history/encounters.php?pid=' + pid
);
188 parent
.left_nav
.loadFrame('dem1', 'pat', paturl
);
190 var othername
= (window
.name
== 'RTop') ?
'RBot' : 'RTop';
191 parent
.frames
[othername
].location
.href
= '../' + paturl
;
195 <script language
="javascript" type
="text/javascript">
196 EncounterDateArray
=new Array;
197 CalendarCategoryArray
=new Array;
198 EncounterIdArray
=new Array;
199 EncounterNoteArray
=new Array;
200 function SubmitTheScreen()
201 {//Action on Update List link
202 if(!ProcessBeforeSubmitting())
204 top
.restoreSession();
205 document
.the_form
.mode
.value
='change';
206 document
.the_form
.target
='_self';
207 document
.the_form
.action
='billing_report.php';
208 document
.the_form
.submit();
211 function SubmitTheScreenPrint()
212 {//Action on View Printable Report link
213 if(!ProcessBeforeSubmitting())
215 top
.restoreSession();
216 document
.the_form
.target
='new';
217 document
.the_form
.action
='print_billing_report.php';
218 document
.the_form
.submit();
221 function SubmitTheEndDayPrint()
222 {//Action on View End of Day Report link
223 if(!ProcessBeforeSubmitting())
225 top
.restoreSession();
226 document
.the_form
.target
='new';
227 <?php
if ($GLOBALS['use_custom_daysheet'] == 1) { ?
>
228 document
.the_form
.action
='print_daysheet_report_num1.php';
230 <?php
if ($GLOBALS['use_custom_daysheet'] == 2) { ?
>
231 document
.the_form
.action
='print_daysheet_report_num2.php';
233 <?php
if ($GLOBALS['use_custom_daysheet'] == 3) { ?
>
234 document
.the_form
.action
='print_daysheet_report_num3.php';
236 document
.the_form
.submit();
239 function SubmitTheScreenExportOFX()
240 {//Action on Export OFX link
241 if(!ProcessBeforeSubmitting())
243 top
.restoreSession();
244 document
.the_form
.mode
.value
='export';
245 document
.the_form
.target
='_self';
246 document
.the_form
.action
='billing_report.php';
247 document
.the_form
.submit();
250 function TestExpandCollapse()
251 {//Checks whether the Expand All, Collapse All labels need to be placed.If any result set is there these will be placed.
253 for(i
=1;i
<=document
.getElementById("divnos").value
;i++
)
255 var ele
= document
.getElementById("divid_"+i
);
264 if(document
.getElementById("ExpandAll"))
266 document
.getElementById("ExpandAll").innerHTML
='';
267 document
.getElementById("CollapseAll").innerHTML
='';
271 function expandcollapse(atr
){
272 if(atr
== "expand") {//Called in the Expand All, Collapse All links(All items will be expanded or collapsed)
273 for(i
=1;i
<=document
.getElementById("divnos").value
;i++
){
274 var mydivid
="divid_"+i
;var myspanid
="spanid_"+i
;
275 var ele
= document
.getElementById(mydivid
); var text
= document
.getElementById(myspanid
);
278 ele
.style
.display
= "inline";text
.innerHTML
= "<?php echo htmlspecialchars(xl('Collapse'), ENT_QUOTES); ?>";
283 for(i
=1;i
<=document
.getElementById("divnos").value
;i++
){
284 var mydivid
="divid_"+i
;var myspanid
="spanid_"+i
;
285 var ele
= document
.getElementById(mydivid
); var text
= document
.getElementById(myspanid
);
288 ele
.style
.display
= "none"; text
.innerHTML
= "<?php echo htmlspecialchars(xl('Expand'), ENT_QUOTES); ?>";
294 function divtoggle(spanid
, divid
) {//Called in the Expand, Collapse links(This is for a single item)
295 var ele
= document
.getElementById(divid
);
298 var text
= document
.getElementById(spanid
);
299 if(ele
.style
.display
== "inline") {
300 ele
.style
.display
= "none";
301 text
.innerHTML
= "<?php echo htmlspecialchars(xl('Expand'), ENT_QUOTES); ?>";
304 ele
.style
.display
= "inline";
305 text
.innerHTML
= "<?php echo htmlspecialchars(xl('Collapse'), ENT_QUOTES); ?>";
309 function MarkAsCleared(Type
)
311 CheckBoxBillingCount
=0;
312 for (var CheckBoxBillingIndex
=0; ; CheckBoxBillingIndex++
)
314 CheckBoxBillingObject
=document
.getElementById('CheckBoxBilling'+CheckBoxBillingIndex
);
315 if(!CheckBoxBillingObject
)
317 if(CheckBoxBillingObject
.checked
)
319 ++CheckBoxBillingCount
;
324 Message
='<?php echo htmlspecialchars( xl('After saving your batch
, click
[View Log
] to check
for errors
.'), ENT_QUOTES); ?>';
328 Message
='<?php echo htmlspecialchars( xl('After saving the PDF
, click
[View Log
] to check
for errors
.'), ENT_QUOTES); ?>';
332 Message
='<?php echo htmlspecialchars( xl('After saving the TEXT
file(s
), click
[View Log
] to check
for errors
.'), ENT_QUOTES); ?>';
334 if(confirm(Message +
"\n\n\n<?php echo addslashes( xl('Total') ); ?>" +
' ' + CheckBoxBillingCount +
' ' +
"<?php echo addslashes( xl('Selected') ); ?>\n" +
335 "<?php echo addslashes( xl('Would You Like them to be Marked as Cleared.') ); ?>"))
337 document
.getElementById('HiddenMarkAsCleared').value
='yes';
341 document
.getElementById('HiddenMarkAsCleared').value
='';
345 <?php
include_once("$srcdir/../interface/reports/report.script.php"); ?
><!-- Criteria Section common javascript page
-->
346 <!-- ================================================== -->
347 <!-- =============Included
for Insurance ajax criteria
==== -->
348 <!-- ================================================== -->
349 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script
>
350 <?php
include_once("{$GLOBALS['srcdir']}/ajax/payment_ajax_jav.inc.php"); ?
>
351 <script type
="text/javascript" src
="../../library/js/common.js"></script
>
353 #ajax_div_insurance {
356 background
-color
: #FBFDD0;
357 border
: 1px solid
#ccc;
361 <script language
="javascript" type
="text/javascript">
362 document
.onclick
=TakeActionOnHide
;
364 <!-- ================================================== -->
365 <!-- =============Included
for Insurance ajax criteria
==== -->
366 <!-- ================================================== -->
368 <body
class="body_top" onLoad
="TestExpandCollapse()">
370 <p style
='margin-top:5px;margin-bottom:5px;margin-left:5px'>
372 <font
class='title'><?php
echo xlt('Billing Manager') ?
></font
>
376 <form name
='the_form' method
='post' action
='billing_report.php' onsubmit
='return top.restoreSession()' style
="display:inline">
378 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
379 <script type
="text/javascript" src
="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
380 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
381 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
382 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
383 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
384 <script language
='JavaScript'>
388 <input type
='hidden' name
='mode' value
='change'>
389 <!-- ============================================================================================================================================= -->
390 <!-- Criteria section Starts
-->
391 <!-- ============================================================================================================================================= -->
393 //The following are the search criteria per page.All the following variable which ends with 'Master' need to be filled properly.
394 //Each item is seperated by a comma(,).
395 //$ThisPageSearchCriteriaDisplayMaster ==>It is the display on screen for the set of criteria.
396 //$ThisPageSearchCriteriaKeyMaster ==>Corresponding database fields in the same order.
397 //$ThisPageSearchCriteriaDataTypeMaster ==>Corresponding data type in the same order.
398 $ThisPageSearchCriteriaDisplayRadioMaster=array();
399 $ThisPageSearchCriteriaRadioKeyMaster=array();
400 $ThisPageSearchCriteriaQueryDropDownMaster=array();
401 $ThisPageSearchCriteriaQueryDropDownMasterDefault=array();
402 $ThisPageSearchCriteriaQueryDropDownMasterDefaultKey=array();
403 $ThisPageSearchCriteriaIncludeMaster=array();
406 $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") );
407 $ThisPageSearchCriteriaKeyMaster="form_encounter.date,billing.date,claims.process_time,claims.target,patient_data.fname,".
408 "form_encounter.pid,claims.payer_id,form_encounter.encounter,insurance_data.provider,billing.id,billing.billed,".
409 "billing.authorized,form_encounter.last_level_billed,billing.x12_partner_id,billing.user";
410 $ThisPageSearchCriteriaDataTypeMaster="datetime,datetime,datetime,radio,text_like,".
411 "text,include,text,radio,radio,radio,".
412 "radio_like,radio,query_drop_down,text";
417 $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") );
418 $ThisPageSearchCriteriaKeyMaster="form_encounter.date,billing.date,claims.process_time,claims.target,patient_data.fname,".
419 "form_encounter.pid,claims.payer_id,form_encounter.encounter,insurance_data.provider,billing.id,billing.billed,".
420 "billing.authorized,form_encounter.last_level_billed,billing.x12_partner_id";
421 $ThisPageSearchCriteriaDataTypeMaster="datetime,datetime,datetime,radio,text_like,".
422 "text,include,text,radio,radio,radio,".
423 "radio_like,radio,query_drop_down";
428 //The below section is needed if there is any 'radio' or 'radio_like' type in the $ThisPageSearchCriteriaDataTypeMaster
429 //$ThisPageSearchCriteriaDisplayRadioMaster,$ThisPageSearchCriteriaRadioKeyMaster ==>For each radio data type this pair comes.
430 //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.
431 $ThisPageSearchCriteriaDisplayRadioMaster[1] = array( xl("All"),xl("eClaims"),xl("Paper") );//Display Value
432 $ThisPageSearchCriteriaRadioKeyMaster[1]="all,standard,hcfa";//Key
433 $ThisPageSearchCriteriaDisplayRadioMaster[2]= array( xl("All"),xl("Insured"),xl("Non-Insured") );//Display Value
434 $ThisPageSearchCriteriaRadioKeyMaster[2]="all,1,0";//Key
435 $ThisPageSearchCriteriaDisplayRadioMaster[3]= array( xl("All"),xl("Coded"),xl("Not Coded") );//Display Value
436 $ThisPageSearchCriteriaRadioKeyMaster[3]="all,not null,null";//Key
437 $ThisPageSearchCriteriaDisplayRadioMaster[4]= array( xl("All"),xl("Unbilled"),xl("Billed"),xl("Denied") );//Display Value
438 $ThisPageSearchCriteriaRadioKeyMaster[4]="all,0,1,7";//Key
439 $ThisPageSearchCriteriaDisplayRadioMaster[5]= array( xl("All"),xl("Authorized"),xl("Unauthorized") );
440 $ThisPageSearchCriteriaRadioKeyMaster[5]="%,1,0";
441 $ThisPageSearchCriteriaDisplayRadioMaster[6]= array( xl("All"),xl("None"),xl("Ins 1"),xl("Ins 2 or Ins 3") );
442 $ThisPageSearchCriteriaRadioKeyMaster[6]="all,0,1,2";
443 //The below section is needed if there is any 'query_drop_down' type in the $ThisPageSearchCriteriaDataTypeMaster
444 $ThisPageSearchCriteriaQueryDropDownMaster[1]="SELECT name,id FROM x12_partners;";
445 $ThisPageSearchCriteriaQueryDropDownMasterDefault[1]= xl("All");//Only one item will be here
446 $ThisPageSearchCriteriaQueryDropDownMasterDefaultKey[1]="all";//Only one item will be here
447 //The below section is needed if there is any 'include' type in the $ThisPageSearchCriteriaDataTypeMaster
448 //Function name is added here.Corresponding include files need to be included in the respective pages as done in this page.
449 //It is labled(Included for Insurance ajax criteria)(Line:-279-299).
450 $ThisPageSearchCriteriaIncludeMaster[1]="InsuranceCompanyDisplay";//This is php function defined in the file 'report.inc.php'
452 if(!isset($_REQUEST['mode']))//default case
454 $_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")."')";
455 $_REQUEST['final_this_page_criteria'][1]="billing.billed = '0'";
457 $_REQUEST['final_this_page_criteria_text'][0]=xl("Date of Service = Today");
458 $_REQUEST['final_this_page_criteria_text'][1]=xl("Billing Status = Unbilled");
460 $_REQUEST['date_master_criteria_form_encounter_date']="today";
461 $_REQUEST['master_from_date_form_encounter_date']=date("Y-m-d");
462 $_REQUEST['master_to_date_form_encounter_date']=date("Y-m-d");
464 $_REQUEST['radio_billing_billed']=0;
468 <table width
='100%' border
="0" cellspacing
="0" cellpadding
="0">
470 <td width
="25%"> 
;</td
>
472 <?php
include_once("$srcdir/../interface/reports/criteria.tab.php"); ?
>
476 // ============================================================================================================================================= -->
477 // Criteria section Ends -->
478 // ============================================================================================================================================= -->
481 <table width
="100%" border
="0" cellspacing
="0" cellpadding
="0">
483 <td width
="15%"> 
;</td
>
484 <td width
="85%"><span
class='text'><a onClick
="javascript:return SubmitTheScreen();" href
="#" class=link_submit
>[<?php
echo xlt('Update List') ?
>]</a
>
486 <a onClick
="javascript:return SubmitTheScreenExportOFX();" href
="#" class='link_submit'><?php
echo '[' . xlt('Export OFX') .']' ?
></a
></span
> </td
>
490 <td
><a onClick
="javascript:return SubmitTheScreenPrint();" href
="#"
491 class='link_submit' ><?php
echo '['. xlt('View Printable Report').']' ?
></a
></td
>
494 <?php
if ($daysheet) { ?
>
497 <td
><a onClick
="javascript:return SubmitTheEndDayPrint();" href
="#"
498 class='link_submit' ><?php
echo '['.xlt('End Of Day Report').']' ?
></a
>
499 <?php
if ($daysheet_total) { ?
>
500 <span
class=text
><?php
echo xlt('Totals'); ?
> </span
>
501 <input type
=checkbox name
="end_of_day_totals_only" value
="1" <?php
if ($obj['end_of_day_totals_only'] === '1') echo "checked";?
>>
503 <?php
if ($provider_run) { ?
>
504 <span
class=text
><?php
echo xlt('Provider'); ?
> </span
>
505 <input type
=checkbox name
="end_of_day_provider_only" value
="1" <?php
if ($obj['end_of_day_provider_only'] === '1') echo "checked";?
>>
513 <?php
if (! file_exists($EXPORT_INC)) { ?
>
515 <a href
="javascript:top.restoreSession();document.the_form.mode.value='process';document.the_form.submit()" class="link_submit"
516 title
="Process all queued bills to create electronic data (and print if requested)"><?php
echo '['. xlt('Start Batch Processing') .']' ?
></a
>
519 <a href
='#' id
="view-log-link" class='link_submit'
520 title
='<?php xla('See messages from the last set of generated claims
'); ?>'><?php
echo '['. xlt('View Log') .']'?
></a
>
526 <td
><a href
="javascript:select_all()" class="link_submit"><?php
echo '['. xlt('Select All') .']'?
></a
></td
>
534 <table width
='100%' border
="0" cellspacing
="0" cellpadding
="0" >
542 <form name
='update_form' method
='post' action
='billing_process.php' onsubmit
='return top.restoreSession()' style
="display:inline">
544 <span
class='text' style
="display:inline">
545 <?php
if (file_exists($EXPORT_INC)) { ?
>
546 <input type
="submit" data
-open
-popup
="true" class="subbtn" name
="bn_external" value
="Export Billing" title
="<?php echo xla('Export to external billing system') ?>">
547 <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') ?>">
550 <input type
="submit" class="subbtn" name
="bn_hcfa_print" value
="Queue HCFA & Print" title
="<?php echo xla('Queue for HCFA batch processing and printing') ?>">
551 <input type
="submit" class="subbtn" name
="bn_hcfa" value
="Queue HCFA" title
="<?php echo xla('Queue for HCFA batch processing')?>">
552 <input type
="submit" class="subbtn" name
="bn_ub92_print" value
="Queue UB92 & Print" title
="<?php echo xla('Queue for UB-92 batch processing and printing')?>">
553 <input type
="submit" class="subbtn" name
="bn_ub92" value
="Queue UB92" title
="<?php echo xla('Queue for UB-92 batch processing')?>">
555 <input type
="submit" class="subbtn" name
="bn_x12" value
="<?php echo xla('Generate X12')?>"
556 title
="<?php echo xla('Generate and download X12 batch')?>"
557 onclick
="MarkAsCleared(1)">
558 <?php
if ($GLOBALS['support_encounter_claims']) { ?
>
559 <input type
="submit" class="subbtn" name
="bn_x12_encounter" value
="<?php echo xla('Generate X12 Encounter')?>"
560 title
="<?php echo xla('Generate and download X12 encounter claim batch')?>"
561 onclick
="MarkAsCleared(1)">
563 <input type
="submit" class="subbtn" style
="width:105px;" name
="bn_process_hcfa" value
="<?php echo xla('CMS 1500 PDF')?>"
564 title
="<?php echo xla('Generate and download CMS 1500 paper claims')?>"
565 onclick
="MarkAsCleared(2)">
566 <?php
if ($GLOBALS['preprinted_cms_1500']) { ?
>
567 <input type
="submit" class="subbtn" style
="width:210px;" name
="bn_process_hcfa_form" value
="<?php echo xla('CMS 1500 PREPRINTED FORM')?>"
568 title
="<?php echo xla('Generate and download CMS 1500 paper claims on Preprinted form')?>"
569 onclick
="MarkAsCleared(2)">
571 <input type
="submit" class="subbtn" style
="width:120px;" name
="bn_hcfa_txt_file" value
="<?php echo xla('CMS 1500 TEXT')?>"
572 title
="<?php echo xla('Making batch text files for uploading to Clearing House and will mark as billed')?>"
573 onclick
="MarkAsCleared(3)">
574 <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')?>">
575 <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')?>">
577 <input type
="submit" class="subbtn" name
="bn_electronic_file" value
="Make Electronic Batch & Clear" title
="<?php echo xla('Download billing file, post to accounting and mark as billed')?>">
580 <?php
echo xlt('CMS 1500 Margins'); ?
>:
581  
;<?php
echo xlt('Left'); ?
>:
582 <input type
='text' size
='2' name
='left_margin'
583 value
='<?php echo attr($left_margin); ?>'
584 title
='<?php echo xla('HCFA left margin in points
'); ?>' />
585  
;<?php
echo xlt('Top'); ?
>:
586 <input type
='text' size
='2' name
='top_margin'
587 value
='<?php echo attr($top_margin); ?>'
588 title
='<?php echo xla('HCFA top margin in points
'); ?>' />
593 <input type
='hidden' name
='HiddenMarkAsCleared' id
='HiddenMarkAsCleared' value
="" />
594 <input type
='hidden' name
='mode' value
="bill" />
595 <input type
='hidden' name
='authorized' value
="<?php echo attr($my_authorized); ?>" />
596 <input type
='hidden' name
='unbilled' value
="<?php echo attr($unbilled); ?>" />
597 <input type
='hidden' name
='code_type' value
="%" />
598 <input type
='hidden' name
='to_date' value
="<?php echo attr($to_date); ?>" />
599 <input type
='hidden' name
='from_date' value
="<?php echo attr($from_date); ?>" />
602 if ($my_authorized == "on" ) {
603 $my_authorized = "1";
605 $my_authorized = "%";
607 if ($unbilled == "on") {
612 $list = getBillsListBetween("%");
615 <input type
='hidden' name
='bill_list' value
="<?php echo attr($list); ?>" />
617 <!-- new form
for uploading
-->
620 if (!isset($_POST["mode"])) {
621 if (!isset($_POST["from_date"])) {
622 $from_date = date("Y-m-d");
624 $from_date = $_POST["from_date"];
626 if (empty($_POST["to_date"])) {
629 $to_date = $_POST["to_date"];
631 if (!isset($_POST["code_type"])) {
634 $code_type = $_POST["code_type"];
636 if (!isset($_POST["unbilled"])) {
639 $unbilled = $_POST["unbilled"];
641 if (!isset($_POST["authorized"])) {
642 $my_authorized = "on";
644 $my_authorized = $_POST["authorized"];
647 $from_date = $_POST["from_date"];
648 $to_date = $_POST["to_date"];
649 $code_type = $_POST["code_type"];
650 $unbilled = $_POST["unbilled"];
651 $my_authorized = $_POST["authorized"];
654 if ($my_authorized == "on" ) {
655 $my_authorized = "1";
657 $my_authorized = "%";
660 if ($unbilled == "on") {
666 if (isset($_POST["mode"]) && $_POST["mode"] == "bill") {
667 billCodesList($list);
671 <table border
="0" cellspacing
="0" cellpadding
="0" width
="100%">
675 if ($ret = getBillsBetween("%"))
680 <tr
><td colspan
='9' align
="right" ><table width
="250" border
="0" cellspacing
="0" cellpadding
="0">
682 <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
>
683 <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
>
684 <td width
="50"> 
;</td
>
692 $last_encounter_id = "";
700 $mmo_empty_mod = false;
701 $mmo_num_charges = 0;
703 foreach ($ret as $iter) {
705 // We include encounters here that have never been billed. However
706 // if it had no selected billing items but does have non-selected
707 // billing items, then it is not of interest.
709 $res = sqlQuery("SELECT count(*) AS count FROM billing WHERE " .
710 "encounter = ? AND " .
712 "activity = 1", array($iter['enc_encounter'],$iter['enc_pid']) );
713 if ($res['count'] > 0) continue;
716 $this_encounter_id = $iter['enc_pid'] . "-" . $iter['enc_encounter'];
718 if ($last_encounter_id != $this_encounter_id) {
720 // This dumps all HTML for the previous encounter.
723 while ($rcount < $lcount) {
724 $rhtml .= "<tr bgcolor='$bgcolor'><td colspan='8'></td></tr>";
727 // This test handles the case where we are only listing encounters
728 // that appear to have a missing "25" modifier.
729 if (!$missing_mods_only ||
($mmo_empty_mod && $mmo_num_charges > 1)) {
735 echo "<tr bgcolor='$bgcolor'>\n<td rowspan='$rcount' valign='top'>\n$lhtml</td>$rhtml\n";
736 echo "<tr bgcolor='$bgcolor'><td colspan='9' height='5'></td></tr>\n\n";
743 $mmo_empty_mod = false;
744 $mmo_num_charges = 0;
746 // If there are ANY unauthorized items in this encounter and this is
747 // the normal case of viewing only authorized billing, then skip the
751 if ($my_authorized == '1') {
752 $res = sqlQuery("select count(*) as count from billing where " .
753 "encounter = ? and " .
755 "activity = 1 and authorized = 0", array($iter['enc_encounter'],$iter['enc_pid']) );
756 if ($res['count'] > 0) {
758 $last_encounter_id = $this_encounter_id;
763 $name = getPatientData($iter['enc_pid'], "fname, mname, lname, pubpid, billing_note, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
765 # Check if patient has primary insurance and a subscriber exists for it.
766 # If not we will highlight their name in red.
767 # TBD: more checking here.
769 $res = sqlQuery("select count(*) as count from insurance_data where " .
771 "type='primary' and " .
772 "subscriber_lname is not null and " .
773 "subscriber_lname != '' limit 1", array($iter['enc_pid']) );
774 $namecolor = ($res['count'] > 0) ?
"black" : "#ff7777";
776 $bgcolor = "#" . (($encount & 1) ?
"ddddff" : "ffdddd");
777 echo "<tr bgcolor='$bgcolor'><td colspan='9' height='5'></td></tr>\n";
782 $ptname = $name['fname'] . " " . $name['lname'];
783 $raw_encounter_date = date("Y-m-d", strtotime($iter['enc_date']));
784 $billing_note = $name['billing_note'];
785 // Add Encounter Date to display with "To Encounter" button 2/17/09 JCH
786 $lhtml .= " <span class=bold><font color='$namecolor'>". text($ptname) .
787 "</font></span><span class=small> (" . text($iter['enc_pid']) . "-" .
788 text($iter['enc_encounter']) . ")</span>";
790 //Encounter details are stored to javacript as array.
791 $result4 = sqlStatement("SELECT fe.encounter,fe.date,fe.billing_note,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe ".
792 " 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']) );
793 if(sqlNumRows($result4)>0)
795 <script language
='JavaScript'>
797 EncounterDateArray
[<?php
echo attr($iter['enc_pid']); ?
>]=new Array;
798 CalendarCategoryArray
[<?php
echo attr($iter['enc_pid']); ?
>]=new Array;
799 EncounterIdArray
[<?php
echo attr($iter['enc_pid']); ?
>]=new Array;
800 EncounterNoteArray
[<?php
echo attr($iter['enc_pid']); ?
>]=new Array;
802 while($rowresult4 = sqlFetchArray($result4))
805 EncounterIdArray
[<?php
echo attr($iter['enc_pid']); ?
>][Count
]='<?php echo htmlspecialchars($rowresult4['encounter
'], ENT_QUOTES); ?>';
806 EncounterDateArray
[<?php
echo attr($iter['enc_pid']); ?
>][Count
]='<?php echo htmlspecialchars(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date
']))), ENT_QUOTES); ?>';
807 CalendarCategoryArray
[<?php
echo attr($iter['enc_pid']); ?
>][Count
]='<?php echo htmlspecialchars( xl_appt_category($rowresult4['pc_catname
']), ENT_QUOTES); ?>';
808 EncounterNoteArray
[<?php
echo attr($iter['enc_pid']); ?
>][Count
]='<?php echo htmlspecialchars($rowresult4['billing_note
'], ENT_QUOTES); ?>';
811 $enc_billing_note = $rowresult4['billing_note'];
817 // Not sure why the next section seems to do nothing except post "To Encounter" button 2/17/09 JCH
818 $lhtml .= " <a class=\"link_submit\" " .
819 "href=\"javascript:window.toencounter(" . $iter['enc_pid'] .
820 ",'" . addslashes($name['pubpid']) .
821 "','" . addslashes($ptname) . "'," . $iter['enc_encounter'] .
822 ",'" . oeFormatShortDate($raw_encounter_date) . "',' " .
823 xl('DOB') . ": " . oeFormatShortDate($name['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAge($name['DOB_YMD']) . "');
824 top.window.parent.left_nav.setPatientEncounter(EncounterIdArray[" . $iter['enc_pid'] . "],EncounterDateArray[" . $iter['enc_pid'] .
825 "], CalendarCategoryArray[" . $iter['enc_pid'] . "])\">[" .
826 xlt('To Enctr') . " " . text(oeFormatShortDate($raw_encounter_date)) . "]</a>";
828 // Changed "To xxx" buttons to allow room for encounter date display 2/17/09 JCH
829 $lhtml .= " <a class=\"link_submit\" " .
830 "href=\"javascript:window.topatient(" . $iter['enc_pid'] .
831 ",'" . addslashes($name['pubpid']) .
832 "','" . addslashes($ptname) . "'," . $iter['enc_encounter'] .
833 ",'" . oeFormatShortDate($raw_encounter_date) . "',' " .
834 xl('DOB') . ": " . oeFormatShortDate($name['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAge($name['DOB_YMD']) . "');
835 top.window.parent.left_nav.setPatientEncounter(EncounterIdArray[" . $iter['enc_pid'] . "],EncounterDateArray[" . $iter['enc_pid'] .
836 "], CalendarCategoryArray[" . $iter['enc_pid'] . "])\">[" . xlt('To Dems') . "]</a>";
838 $lhtml .= " <a onclick='divtoggle(\"spanid_$divnos\",\"divid_$divnos\");' class='small' id='aid_$divnos' href=\"JavaScript:void(0);".
839 "\">(<span id=spanid_$divnos class=\"indicator\">" . htmlspecialchars( xl('Expand'), ENT_QUOTES
) . '</span>)<br></a>';
840 if($GLOBALS['notes_to_display_in_Billing'] == 2 ||
$GLOBALS['notes_to_display_in_Billing'] == 3){
841 $lhtml .= '<span style="margin-left: 20px; font-weight bold; color: red">'.text($billing_note).'</span>';
847 $lhtml .= "<br />\n";
848 $lhtml .= " <span class=text>Bill: ";
849 $lhtml .= "<select name='claims[" . attr($this_encounter_id) . "][payer]' style='background-color:$bgcolor'>";
851 $query = "SELECT id.provider AS id, id.type, id.date, " .
852 "ic.x12_default_partner_id AS ic_x12id, ic.name AS provider " .
853 "FROM insurance_data AS id, insurance_companies AS ic WHERE " .
854 "ic.id = id.provider AND " .
857 "ORDER BY id.type ASC, id.date DESC";
859 $result = sqlStatement($query, array($iter['enc_pid'],$raw_encounter_date) );
861 $default_x12_partner = $iter['ic_x12id'];
864 while ($row = sqlFetchArray($result)) {
865 if (strcmp($row['type'], $prevtype) == 0) continue;
866 $prevtype = $row['type'];
867 if (strlen($row['provider']) > 0) {
868 // This preserves any existing insurance company selection, which is
869 // important when EOB posting has re-queued for secondary billing.
870 $lhtml .= "<option value=\"" . attr(substr($row['type'],0,1).$row['id']) . "\"";
871 if (($count == 0 && !$iter['payer_id']) ||
$row['id'] == $iter['payer_id']) {
872 $lhtml .= " selected";
873 if (!is_numeric($default_x12_partner)) $default_x12_partner = $row['ic_x12id'];
875 $lhtml .= ">" . text($row['type']) . ": " . text($row['provider']) . "</option>";
880 $lhtml .= "<option value='-1'>" . xlt("Unassigned") . "</option>\n";
881 $lhtml .= "</select> \n";
882 $lhtml .= "<select name='claims[" . attr($this_encounter_id) . "][partner]' style='background-color:$bgcolor'>";
883 $x = new X12Partner();
884 $partners = $x->_utility_array($x->x12_partner_factory());
885 foreach ($partners as $xid => $xname) {
886 $lhtml .= '<option label="' . attr($xname) . '" value="' . attr($xid) .'"';
887 if ($xid == $default_x12_partner) {
888 $lhtml .= "selected";
890 $lhtml .= '>' . text($xname) . '</option>';
892 $lhtml .= "</select>";
895 if($GLOBALS['notes_to_display_in_Billing'] == 1 ||
$GLOBALS['notes_to_display_in_Billing'] == 3) {
896 $lhtml .= "<br><span style='margin-left: 20px; font-weight bold; color: green'>".text($enc_billing_note)."</span>";
898 $lhtml .= "<br>\n <div id='divid_$divnos' style='display:none'>" . text(oeFormatShortDate(substr($iter['date'], 0, 10)))
899 . text(substr($iter['date'], 10, 6)) . " " . xlt("Encounter was coded");
901 $query = "SELECT * FROM claims WHERE " .
902 "patient_id = ? AND " .
903 "encounter_id = ? " .
905 $cres = sqlStatement($query, array($iter['enc_pid'],$iter['enc_encounter']) );
909 while ($crow = sqlFetchArray($cres)) {
910 $query = "SELECT id.type, ic.name " .
911 "FROM insurance_data AS id, insurance_companies AS ic WHERE " .
913 "id.provider = ? AND " .
914 "id.date <= ? AND " .
915 "ic.id = id.provider " .
916 "ORDER BY id.type ASC, id.date DESC";
918 $irow= sqlQuery($query, array($iter['enc_pid'],$crow['payer_id'],$raw_encounter_date) );
920 if ($crow['bill_process']) {
921 $lhtml .= "<br>\n " .
922 text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) .
923 text(substr($crow['bill_time'], 10, 6)) . " " .
924 xlt("Queued for") . " " . text($irow['type']) . " " . text($crow['target']) . " " .
925 xlt("billing to ") . text($irow['name']);
928 else if ($crow['status'] < 6) {
929 if ($crow['status'] > 1) {
930 $lhtml .= "<br>\n " .
931 text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) .
932 text(substr($crow['bill_time'], 10, 6)) . " " .
933 htmlspecialchars( xl("Marked as cleared"), ENT_QUOTES
);
937 $lhtml .= "<br>\n " .
938 text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) .
939 text(substr($crow['bill_time'], 10, 6)) . " " .
940 htmlspecialchars( xl("Re-opened"), ENT_QUOTES
);
944 else if ($crow['status'] == 6) {
945 $lhtml .= "<br>\n " .
946 text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) .
947 text(substr($crow['bill_time'], 10, 6)) . " " .
948 htmlspecialchars( xl("This claim has been forwarded to next level."), ENT_QUOTES
);
951 else if ($crow['status'] == 7) {
952 $lhtml .= "<br>\n " .
953 text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) .
954 text(substr($crow['bill_time'], 10, 6)) . " " .
955 htmlspecialchars( xl("This claim has been denied.Reason:-"), ENT_QUOTES
);
956 if($crow['process_file'])
958 $code_array=explode(',',$crow['process_file']);
959 foreach($code_array as $code_key => $code_value)
961 $lhtml .= "<br>\n ";
962 $reason_array=explode('_',$code_value);
963 if(!isset($adjustment_reasons[$reason_array[3]]))
965 $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]).']';
969 $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]]);
975 $lhtml .=htmlspecialchars( xl("Not Specified."), ENT_QUOTES
);
980 if ($crow['process_time']) {
981 $lhtml .= "<br>\n " .
982 text(oeFormatShortDate(substr($crow['process_time'], 0, 10))) .
983 text(substr($crow['process_time'], 10, 6)) . " " .
984 xlt("Claim was generated to file") . " " .
985 "<a href='get_claim_file.php?key=" . attr($crow['process_file']) .
986 "' onclick='top.restoreSession()'>" .
987 text($crow['process_file']) . "</a>";
992 } // end while ($crow = sqlFetchArray($cres))
994 if ($lastcrow && $lastcrow['status'] == 4) {
995 $lhtml .= "<br>\n " . xlt("This claim has been closed.");
999 if ($lastcrow && $lastcrow['status'] == 5) {
1000 $lhtml .= "<br>\n " . xlt("This claim has been canceled.");
1003 } // end if ($iter['id'])
1005 } // end if ($last_encounter_id != $this_encounter_id)
1007 if ($skipping) continue;
1009 // Collect info related to the missing modifiers test.
1010 if ($iter['fee'] > 0) {
1012 $tmp = substr($iter['code'], 0, 3);
1013 if (($tmp == '992' ||
$tmp == '993') && empty($iter['modifier']))
1014 $mmo_empty_mod = true;
1020 $rhtml .= "<tr bgcolor='$bgcolor'>\n";
1022 $rhtml .= "<td width='50'>";
1023 if ($iter['id'] && $oldcode != $iter['code_type']) {
1024 $rhtml .= "<span class=text>" . text($iter['code_type']) . ": </span>";
1027 $oldcode = $iter['code_type'];
1028 $rhtml .= "</td>\n";
1031 if ($iter['id'] && $code_types[$iter['code_type']]['just']) {
1032 $js = explode(":",$iter['justify']);
1034 foreach ($js as $j) {
1036 if ($counter == 0) {
1037 $justify .= " (<b>" . text($j) . "</b>)";
1040 $justify .= " (" . text($j) . ")";
1047 $rhtml .= "<td><span class='text'>" .
1048 ($iter['code_type'] == 'COPAY' ?
text(oeFormatMoney($iter['code'])) : text($iter['code']));
1049 if ($iter['modifier']) $rhtml .= ":" . text($iter['modifier']);
1050 $rhtml .= "</span><span style='font-size:8pt;'>$justify</span></td>\n";
1052 $rhtml .= '<td align="right"><span style="font-size:8pt;"> ';
1053 if ($iter['id'] && $iter['fee'] > 0) {
1054 $rhtml .= text(oeFormatMoney($iter['fee']));
1056 $rhtml .= "</span></td>\n";
1057 $rhtml .= '<td><span style="font-size:8pt;"> ';
1058 if ($iter['id']) $rhtml .= getProviderName(empty($iter['provider_id']) ?
text($iter['enc_provider_id']) : text($iter['provider_id']));
1059 $rhtml .= "</span></td>\n";
1060 $rhtml .= '<td><span style="font-size:8pt;"> ';
1061 if($GLOBALS['display_units_in_billing'] != 0) {
1062 if ($iter['id']) $rhtml .= xlt("Units") . ":" . text($iter{"units"});
1064 $rhtml .= "</span></td>\n";
1065 $rhtml .= '<td width=100> <span style="font-size:8pt;">';
1066 if ($iter['id']) $rhtml .= text(oeFormatSDFT(strtotime($iter{"date"})));
1067 $rhtml .= "</span></td>\n";
1068 # This error message is generated if the authorized check box is not checked
1069 if ($iter['id'] && $iter['authorized'] != 1) {
1070 $rhtml .= "<td><span class=alert>".xlt("Note: This code has not been authorized.")."</span></td>\n";
1073 $rhtml .= "<td></td>\n";
1075 if ($iter['id'] && $last_encounter_id != $this_encounter_id) {
1076 $tmpbpr = $iter['bill_process'];
1077 if ($tmpbpr == '0' && $iter['billed']) $tmpbpr = '2';
1078 $rhtml .= "<td><input type='checkbox' value='" . attr($tmpbpr) . "' name='claims[" . attr($this_encounter_id) . "][bill]' onclick='set_button_states()' id='CheckBoxBilling" . attr($CheckBoxBilling*1) . "'> </td>\n";
1082 $rhtml .= "<td></td>\n";
1084 if($last_encounter_id != $this_encounter_id){
1087 $resMoneyGot = sqlStatement("SELECT pay_amount as PatientPay,date(post_time) as date FROM ar_activity where ".
1088 "pid = ? and encounter = ? and payer_type=0 and account_code='PCP'",
1089 array($iter['enc_pid'],$iter['enc_encounter']));
1090 //new fees screen copay gives account_code='PCP'
1091 if(sqlNumRows($resMoneyGot) > 0){
1095 //checks whether a copay exists for the encounter and if exists displays it.
1096 while($rowMoneyGot = sqlFetchArray($resMoneyGot)){
1098 $PatientPay=$rowMoneyGot['PatientPay'];
1099 $date=$rowMoneyGot['date'];
1100 if($PatientPay > 0){
1102 $rhtml2 .= "<tr bgcolor='$bgcolor'>\n";
1104 $rhtml2 .= "<td width='50'>";
1105 $rhtml2 .= "<span class='text'>".xlt('COPAY').": </span>";
1106 $rhtml2 .= "</td>\n";
1107 $rhtml2 .= "<td><span class='text'>".text(oeFormatMoney($PatientPay))."</span><span style='font-size:8pt;'> </span></td>\n";
1108 $rhtml2 .= '<td align="right"><span style="font-size:8pt;"> ';
1109 $rhtml2 .= "</span></td>\n";
1110 $rhtml2 .= '<td><span style="font-size:8pt;"> ';
1111 $rhtml2 .= "</span></td>\n";
1112 $rhtml2 .= '<td><span style="font-size:8pt;"> ';
1113 $rhtml2 .= "</span></td>\n";
1114 $rhtml2 .= '<td width=100> <span style="font-size:8pt;">';
1115 $rhtml2 .= text(oeFormatSDFT(strtotime($date)));
1116 $rhtml2 .= "</span></td>\n";
1117 if ($iter['id'] && $iter['authorized'] != 1) {
1118 $rhtml2 .= "<td><span class=alert>".xlt("Note: This copay was entered against billing that has not been authorized. Please review status.")."</span></td>\n";
1120 $rhtml2 .= "<td></td>\n";
1122 if(!$iter['id'] && $rowcnt == 1){
1123 $rhtml2 .= "<td><input type='checkbox' value='0' name='claims[" . attr($this_encounter_id) . "][bill]' onclick='set_button_states()' id='CheckBoxBilling" . attr($CheckBoxBilling*1) . "'> </td>\n";
1126 $rhtml2 .= "<td></td>\n";
1132 $rhtml .= "</tr>\n";
1133 $last_encounter_id = $this_encounter_id;
1138 while ($rcount < $lcount) {
1139 $rhtml .= "<tr bgcolor='$bgcolor'><td colspan='8'></td></tr>";
1142 if (!$missing_mods_only ||
($mmo_empty_mod && $mmo_num_charges > 1)) {
1148 echo "<tr bgcolor='$bgcolor'>\n<td rowspan='$rcount' valign='top'>\n$lhtml</td>$rhtml\n";
1149 echo "<tr bgcolor='$bgcolor'><td colspan='9' height='5'></td></tr>\n";
1161 set_button_states();
1164 echo "alert('".addslashes($alertmsg)."');\n";
1167 $
(document
).ready(function() {
1168 $
("#view-log-link").click( function() {
1169 top
.restoreSession();
1170 dlgopen('customize_log.php', '_blank', 500, 400);
1173 $
('input[type="submit"]').click( function() {
1174 top
.restoreSession();
1175 $
(this
).attr('data-clicked', true);
1178 $
('form[name="update_form"]').submit( function(e
) {
1179 var clickedButton
= $
("input[type=submit][data-clicked='true'")[0];
1181 // clear clicked button indicator
1182 $
('input[type="submit"]').attr('data-clicked', false);
1184 if ( !clickedButton || $
(clickedButton
).attr("data-open-popup") !== "true" ) {
1185 $
(this
).removeAttr("target");
1186 return top
.restoreSession();
1188 top
.restoreSession();
1189 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');
1190 this
.target
= 'Popup_Window';
1195 <input type
="hidden" name
="divnos" id
="divnos" value
="<?php echo attr($divnos) ?>"/>
1196 <input type
='hidden' name
='ajax_mode' id
='ajax_mode' value
='' />