* @copyright Copyright (c) 2014 Terry Hill * @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"]; } ?>
\n"; // small table $first_time = 0; } // Displays name print "
" . " " . text($name["fname"]) . " " . text($name["lname"]) . "

\n"; //================================== if ($iter['code_type'] === 'COPAY' || $iter['code_type'] === 'Patient Payment' || $iter['code_type'] === 'Insurance Payment') { print "
" . xlt("Units") . "
"; print "
" . xlt("Fee") . "
" ; print "
" . xlt("Code") . "
" ; print "
"; print "
" . xlt("User") . "
"; print "
"; print "
" . xlt("Post Date") . "
"; print "
\n"; } else { 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 "
" . xlt("Encounter") . "
"; 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 "
" . "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') { print "
" . text("(" . $iter['ins_adjust_dollar'] . ")") . "
"; } if (($iter['ins_code']) != 0 and ($iter['code_type']) === 'Insurance Payment') { print "
" . text("(" . $iter['ins_code'] . ")") . "
"; } if (($iter['code_type']) != "Patient Payment" and ($iter['code_type']) != 'Insurance Payment') { print "
" . text("(" . $iter["code"] . ")") . "
"; } if (($iter['pat_adjust_dollar']) != 0 and ($iter['code_type']) === 'Patient Payment') { print "
" . text("(" . $iter['pat_adjust_dollar'] . ")") . "
"; } if (($iter['pat_code']) != 0 and ($iter['code_type']) === 'Patient Payment') { 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 "
\n"; } else { if (date("Y-m-d", strtotime($iter['bill_date'])) === '1969-12-31') { 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['encounter']) . "
"; print "
\n"; } else { if ($iter['fee'] != 0) { 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 "
" . text($iter['encounter']) . "
"; print "
\n"; } } } $res_count++; if ($res_count == $N) { print "\n"; $res_count = 0; } $itero = $iter; } } // end totals only } // end for } if ($anypats == 0) { ?>
"; ?>\n"; print "

"; Printf("" . 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 "
"; } 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 "
"; ?>