* @author Tyler Wrenn * @copyright Copyright (c) 2014 Terry Hill * @copyright Copyright (c) 2020 Tyler Wrenn * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 */ /* TODO: Code Cleanup */ require_once("../globals.php"); require_once("$srcdir/patient.inc"); require_once("$srcdir/daysheet.inc.php"); use OpenEMR\Billing\BillingReport; use OpenEMR\Core\Header; //global variables: if (!isset($_GET["mode"])) { if (!isset($_GET["from_date"])) { $from_date = date("Y-m-d"); } else { $from_date = $_GET["from_date"]; } if (!isset($_GET["to_date"])) { $to_date = date("Y-m-d"); } else { $to_date = $_GET["to_date"]; } if (!isset($_GET["code_type"])) { $code_type = "all"; } else { $code_type = $_GET["code_type"]; } if (!isset($_GET["unbilled"])) { $unbilled = "on"; } else { $unbilled = $_GET["unbilled"]; } if (!isset($_GET["authorized"])) { $my_authorized = "on"; } else { $my_authorized = $_GET["authorized"]; } } else { $from_date = $_GET["from_date"]; $to_date = $_GET["to_date"]; $code_type = $_GET["code_type"]; $unbilled = $_GET["unbilled"]; $my_authorized = $_GET["authorized"]; } ?>

" . xlt('Total') . "
"; Printf("
" . " %1\$.2f", text($line_total)) . "
"; } else { print "
" . xlt('Total') . "
"; Printf("
" . " %1\$.2f", text($line_total_pay)) . "
"; } $line_total = 0; $line_total_pay = 0; } if ($first_time) { print "\n"; // small table $first_time = 0; } // Displays name print "\n"; //================================== if ($iter['code_type'] === 'COPAY' || $iter['code_type'] === 'Patient Payment' || $iter['code_type'] === 'Insurance Payment') { print "\n"; } else { print "\n"; } //Next patient $old_pid = $iter['pid']; } // get dollar amounts to appear on pat,ins payments and copays if ($iter['code_type'] != 'payment_info') { if ($iter['code_type'] === 'COPAY' || $iter['code_type'] === 'Patient Payment' || $iter['code_type'] === 'Insurance Payment') { print "\n"; } else { if (date("Y-m-d", strtotime($iter['bill_date'])) == "1969-12-31") { print "\n"; } else { if ($iter['fee'] != 0) { $line_total = $line_total + $iter['fee']; print "\n"; } } } $res_count++; if ($res_count == $N) { print "\n"; $res_count = 0; } $itero = $iter; if ($old_pid != $new_old_pid and ($iter['code_type'] != 'payment_info')) { $new_old_pid = $old_pid; } } } // end totals only } // end for } if ($anypats == 0) { ?>
" . xlt('Total') . "
"; Printf("
\n
"; print "\n"; } else { print "\n
"; print "\n"; } } if ($totals_only == 1) { $from_date = oeFormatShortDate(substr($query_part_day, 37, 10)); $to_date = oeFormatShortDate(substr($query_part_day, 63, 10)); print "

"; ?>\n"; print "

"; Printf(""; } print "

" . text($name["fname"]) . " " . text($name["lname"]) . "

" . xlt("Units") . "
"; print "
" . xlt("Fee") . "
" ; print "
" . xlt("Code") . "
" ; print "
"; print "
" . xlt("User") . "
"; print "
" ; print "
" . xlt("Post Date") . "
"; print "
" . xlt("Units") . "
"; print "
" . xlt("Fee") . "
"; print "
" . xlt("Code") . "
"; print "
" . xlt("Provider Id") . "
"; print "
" . xlt("User") . "
"; print "
" . xlt("Bill Date") . "
"; print "
" . xlt("Date of Service") . "
"; print "
" . "1" . "
" ; // start fee output // [pat_code] => 0.00 // [ins_code] => 0.00 // [pat_adjust_dollar] => 0.00 // [ins_adjust_dollar] => 0.00 if (($iter['ins_adjust_dollar']) != 0 and ($iter['code_type']) === 'Insurance Payment') { $line_total_pay = $line_total_pay + $iter['ins_adjust_dollar']; print "
" . text($iter['ins_adjust_dollar']) . "
"; } if (($iter['ins_code']) != 0 and ($iter['code_type']) === 'Insurance Payment') { $line_total_pay = $line_total_pay + $iter['ins_code']; print "
" . text($iter['ins_code']) . "
"; } if (($iter['code_type']) != 'Patient Payment' and ($iter['code_type']) != 'Insurance Payment') { $line_total_pay = $line_total_pay + $iter["code"]; print "
" . text($iter["code"]) . "
"; } if (($iter['pat_adjust_dollar']) != 0 and ($iter['code_type']) === 'Patient Payment') { $line_total_pay = $line_total_pay + $iter['pat_adjust_dollar']; print "
" . text($iter['pat_adjust_dollar']) . "
"; } if (($iter['pat_code']) != 0 and ($iter['code_type']) === 'Patient Payment') { $line_total_pay = $line_total_pay + $iter['pat_code']; print "
" . text($iter['pat_code']) . "
"; } // end fee output if (($iter['ins_adjust_dollar']) != 0 and ($iter['code_type']) === 'Insurance Payment') { print "
" . xlt("Insurance Adjustment") . "
"; } if (($iter['pat_adjust_dollar']) != 0 and ($iter['code_type']) === 'Patient Payment') { print "
" . xlt("Patient Adjustment") . "
"; } if (($iter['ins_code']) > 0 and ($iter['code_type']) === 'Insurance Payment') { print "
" . xlt('Insurance Payment') . "
"; } if (($iter['pat_code']) > 0 and ($iter['code_type']) === 'Patient Payment' and $iter['paytype'] != 'PCP') { print "
" . xlt('Patient Payment') . "
"; } if (($iter['ins_code']) < 0 and ($iter['code_type']) === 'Insurance Payment') { print "
" . xlt("Insurance Credit") . "
"; } if (($iter['pat_code']) < 0 and ($iter['code_type']) === 'Patient Payment' and $iter['paytype'] != 'PCP') { print "
" . xlt("Patient Credit") . "
"; } if ($iter['paytype'] == 'PCP') { print "
" . xlt('COPAY') . "
"; } if (($iter['code_type']) != 'Insurance Payment' and ($iter['code_type']) != 'Patient Payment' and $iter['paytype'] != 'PCP') { print "
" . text($iter['code_type']) . "
"; } print "
" . text($iter['provider_id']) . "
"; print "
" . text($iter['user']) . "
" ; print "
"; print "
" . text(date("Y-m-d", strtotime($iter['date']))) . "
"; print "
" . text($iter['units']) . "
" ; print "
" . text($iter['fee']) . "
"; if ($GLOBALS['language_default'] === 'English (Standard)') { print "
" . text(ucwords(strtolower(substr($iter['code_text'], 0, 38)))) . "
"; } else { print "
" . text(substr($iter['code_text'], 0, 38)) . "
"; } print "
" . text($iter['provider_id']) . "
" ; print "
" . text($iter['user']) . "
" ; print "
" . xlt('Not Billed') . "
"; print "
" . text(date("Y-m-d", strtotime($iter['date']))) . "
"; print "
" . text($iter["units"]) . "
"; print "
" . text($iter['fee']) . "
"; if ($GLOBALS['language_default'] === 'English (Standard)') { print "
" . text(ucwords(strtolower(substr($iter['code_text'], 0, 38)))) . "
"; } else { print "
" . text(substr($iter['code_text'], 0, 38)) . "
"; } print "
" . text($iter['provider_id']) . "
"; print "
" . text($iter['user']) . "
"; print "
" . text(date("Y-m-d", strtotime($iter['bill_date']))) . "
"; print "
" . text(date("Y-m-d", strtotime($iter["date"]))) . "
"; print "
" . " %1\$.2f", text($line_total)) . "

" . xlt('Total') . "
"; Printf("
" . " %1\$.2f", text($line_total_pay)) . "
" . xlt("User") . ' ' . "
" . text($user_info['user'][$i])) . "
"; Printf("
" . xlt("Charges") . ' ' . "
" . " %1\$.2f", text($user_info['fee'][$i])) . "
"; Printf("
" . xlt("Insurance Adj") . '. ' . "
" . "%1\$.2f", text($user_info['insadj'][$i])) . "
"; Printf("
" . xlt("Insurance Payments") . ' ' . "
" . "%1\$.2f", text($user_info['inspay'][$i])) . "
"; Printf("
" . xlt("Patient Adj") . '. ' . "
" . "%1\$.2f", text($user_info['patadj'][$i])) . "
"; Printf("
" . xlt("Patient Payments") . ' ' . "
" . "%1\$.2f", text($user_info['patpay'][$i])) . "
"; $gtotal_fee = $gtotal_fee + $user_info[fee][$i]; $gtotal_insadj = $gtotal_insadj + $user_info[insadj][$i]; $gtotal_inspay = $gtotal_inspay + $user_info[inspay][$i]; $gtotal_patadj = $gtotal_patadj + $user_info[patadj][$i]; $gtotal_patpay = $gtotal_patpay + $user_info[patpay][$i]; ++$i; print "
\n"; print "

"; Printf(""; print "
" . xlt("Grand Totals") . ' '); Printf("
" . xlt("Total Charges") . ' ' . "
" . " %1\$.2f", text($gtotal_fee)) . "
"; Printf("
" . xlt("Insurance Adj") . '. ' . "
" . "%1\$.2f", text($gtotal_insadj)) . "
"; Printf("
" . xlt("Insurance Payments") . ' ' . "
" . "%1\$.2f", text($gtotal_inspay)) . "
"; Printf("
" . xlt("Patient Adj") . '.' . "
" . "%1\$.2f", text($gtotal_patadj)) . "
"; Printf("
" . xlt("Patient Payments") . ' ' . "
" . "%1\$.2f", text($gtotal_patpay)) . "
"; print "
"; ?>