Service section by assigning code with * 'Service Reporting'. * * @package OpenEMR * @link https://www.open-emr.org * @author Rod Roark * @author Visolve * @author Brady Miller * @copyright Copyright (C) 2006-2020 Rod Roark * @copyright Copyright (c) 2017-2018 Brady Miller * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 */ require_once("../globals.php"); require_once("$srcdir/patient.inc"); require_once "$srcdir/options.inc.php"; require_once "$srcdir/appointments.inc.php"; use OpenEMR\Common\Acl\AclMain; use OpenEMR\Common\Csrf\CsrfUtils; use OpenEMR\Common\Twig\TwigContainer; use OpenEMR\Core\Header; if (!AclMain::aclCheckCore('acct', 'rep_a')) { echo (new TwigContainer(null, $GLOBALS['kernel']))->getTwig()->render('core/unauthorized.html.twig', ['pageTitle' => xl("Financial Summary by Service Code")]); exit; } if (!empty($_POST)) { if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) { CsrfUtils::csrfNotVerified(); } } $grand_total_units = 0; $grand_total_amt_billed = 0; $grand_total_amt_paid = 0; $grand_total_amt_adjustment = 0; $grand_total_amt_balance = 0; $form_from_date = (isset($_POST['form_from_date'])) ? DateToYYYYMMDD($_POST['form_from_date']) : date('Y-m-d'); $form_to_date = (isset($_POST['form_to_date'])) ? DateToYYYYMMDD($_POST['form_to_date']) : date('Y-m-d'); $form_facility = $_POST['form_facility'] ?? null; $form_provider = $_POST['form_provider'] ?? null; if (!empty($_POST['form_csvexport'])) { header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=svc_financial_report_" . attr($form_from_date) . "--" . attr($form_to_date) . ".csv"); header("Content-Description: File Transfer"); // CSV headers: } else { // end export ?> <?php echo xlt('Financial Summary by Service Code') ?> -
: : \n"; echo "
:     :
= ? AND fe.date <= ?"; array_push($sqlBindArray, "$from_date 00:00:00", "$to_date 23:59:59"); // If a facility was specified. if ($form_facility) { $query .= " AND fe.facility_id = ?"; array_push($sqlBindArray, $form_facility); } // If a provider was specified. if ($form_provider) { $query .= " AND b.provider_id = ?"; array_push($sqlBindArray, $form_provider); } // If selected important codes if (!empty($_POST['form_details'])) { $query .= " AND c.financial_reporting = '1'"; } $query .= " GROUP BY b.code ORDER BY b.code, fe.date, fe.id "; $res = sqlStatement($query, $sqlBindArray); $grand_total_units = 0; $grand_total_amt_billed = 0; $grand_total_amt_paid = 0; $grand_total_amt_adjustment = 0; $grand_total_amt_balance = 0; while ($erow = sqlFetchArray($res)) { $row = array(); $row['pid'] = $erow['pid'] ?? null; $row['provider_id'] = $erow['provider_id'] ?? null; $row['Procedure codes'] = $erow['code']; $row['Units'] = $erow['units']; $row['Amt Billed'] = $erow['billed']; $row['Paid Amt'] = $erow['PaidAmount']; $row['Adjustment Amt'] = $erow['AdjustAmount']; $row['Balance Amt'] = $erow['Balance']; $row['financial_reporting'] = $erow['financial_reporting']; $rows[($erow['pid'] ?? null) . '|' . $erow['code'] . '|' . $erow['units']] = $row; } if ($_POST['form_csvexport']) { // CSV headers: if (true) { echo csvEscape("Procedure codes") . ','; echo csvEscape("Units") . ','; echo csvEscape("Amt Billed") . ','; echo csvEscape("Paid Amt") . ','; echo csvEscape("Adjustment Amt") . ','; echo csvEscape("Balance Amt") . "\n"; } } else { ?>
$row) { $print = ''; $csv = ''; if ($row['financial_reporting']) { $bgcolor = "#FFFFDD"; } else { $bgcolor = "#FFDDDD"; } $print = ""; $csv = csvEscape($row['Procedure codes']) . ',' . csvEscape($row['Units']) . ',' . csvEscape(oeFormatMoney($row['Amt Billed'])) . ',' . csvEscape(oeFormatMoney($row['Paid Amt'])) . ',' . csvEscape(oeFormatMoney($row['Adjustment Amt'])) . ',' . csvEscape(oeFormatMoney($row['Balance Amt'])) . "\n"; $bgcolor = ((++$orow & 1) ? "#ffdddd" : "#ddddff"); $grand_total_units += $row['Units']; $grand_total_amt_billed += $row['Amt Billed']; $grand_total_amt_paid += $row['Paid Amt']; $grand_total_amt_adjustment += $row['Adjustment Amt']; $grand_total_amt_balance += $row['Balance Amt']; if ($_POST['form_csvexport']) { echo $csv; } else { echo $print; } } if (!$_POST['form_csvexport']) { echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; ?>
" . text($row['Procedure codes']) . "" . text($row['Units']) . "" . text(oeFormatMoney($row['Amt Billed'])) . "" . text(oeFormatMoney($row['Paid Amt'])) . "" . text(oeFormatMoney($row['Adjustment Amt'])) . "" . text(oeFormatMoney($row['Balance Amt'])) . "
" . xlt("Grand Total") . "" . text($grand_total_units) . "" . text(oeFormatMoney($grand_total_amt_billed)) . "" . text(oeFormatMoney($grand_total_amt_paid)) . "" . text(oeFormatMoney($grand_total_amt_adjustment)) . "" . text(oeFormatMoney($grand_total_amt_balance)) . "
"; echo xlt('No matches found. Try search again.'); echo ""; echo ''; } if (empty($_POST['form_refresh']) && empty($_POST['form_csvexport'])) { ?>