From f2ee4e267d91f835e832feef6059cd6c4430a309 Mon Sep 17 00:00:00 2001 From: Brady Miller Date: Tue, 17 Oct 2017 00:10:26 -0700 Subject: [PATCH] Indigent Patients Report Cleanup --- interface/billing/indigent_patients_report.php | 128 ++++++++++++------------- 1 file changed, 59 insertions(+), 69 deletions(-) diff --git a/interface/billing/indigent_patients_report.php b/interface/billing/indigent_patients_report.php index 6e580f134..588b4664d 100644 --- a/interface/billing/indigent_patients_report.php +++ b/interface/billing/indigent_patients_report.php @@ -4,24 +4,13 @@ * encounters within the specified time period for patients without * insurance. * - * Copyright (C) 2005-2015 Rod Roark - * Copyright (C) 2017 Brady Miller - * - * LICENSE: This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * You should have received a copy of the GNU General Public License - * along with this program. If not, see ;. - * - * @package OpenEMR - * @author Rod Roark - * @author Brady Miller - * @link http://www.open-emr.org + * @package OpenEMR + * @link http://www.open-emr.org + * @author Rod Roark + * @author Brady Miller + * @copyright Copyright (c) 2005-2015 Rod Roark + * @copyright Copyright (c) 2017 Brady Miller + * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 */ use OpenEMR\Core\Header; @@ -40,8 +29,8 @@ function bucks($amount) return ""; } -$form_start_date = fixDate($_POST['form_start_date'], date("Y-01-01")); -$form_end_date = fixDate($_POST['form_end_date'], date("Y-m-d")); +$form_start_date = (!empty($_POST['form_start_date'])) ? DateToYYYYMMDD($_POST['form_start_date']) : date('Y-01-01'); +$form_end_date = (!empty($_POST['form_end_date'])) ? DateToYYYYMMDD($_POST['form_end_date']) : date('Y-m-d'); ?> @@ -76,22 +65,22 @@ $form_end_date = fixDate($_POST['form_end_date'], date("Y-m-d")); -<?php xl('Indigent Patients Report', 'e')?> +<?php echo xlt('Indigent Patients Report')?> @@ -99,9 +88,9 @@ $form_end_date = fixDate($_POST['form_end_date'], date("Y-m-d")); - - + - -
+
@@ -115,18 +104,16 @@ $form_end_date = fixDate($_POST['form_end_date'], date("Y-m-d"));
- : + : - + : - +
@@ -163,41 +150,44 @@ $form_end_date = fixDate($_POST['form_end_date'], date("Y-m-d")); -   +   -   +   -   +   -   +   -   +   -   +   -   +   -   +   = '$form_start_date'"; + $where .= " AND e.date >= ?"; + array_push($sqlBindArray, $form_start_date); } if ($form_end_date) { - $where .= " AND e.date <= '$form_end_date'"; + $where .= " AND e.date <= ?"; + array_push($sqlBindArray, $form_end_date); } $rez = sqlStatement("SELECT " . @@ -205,7 +195,7 @@ if ($_POST['form_refresh']) { "FROM form_encounter AS e, patient_data AS p, insurance_data AS i " . "WHERE p.pid = e.pid AND i.pid = e.pid AND i.type = 'primary' " . "AND i.provider = ''$where " . - "ORDER BY p.lname, p.fname, p.mname, p.pid, e.date"); + "ORDER BY p.lname, p.fname, p.mname, p.pid, e.date", $sqlBindArray); $total_amount = 0; $total_paid = 0; @@ -216,19 +206,19 @@ if ($_POST['form_refresh']) { $invnumber = $row['pid'] . "." . $row['encounter']; $inv_duedate = ''; $arow = sqlQuery("SELECT SUM(fee) AS amount FROM drug_sales WHERE " . - "pid = '$patient_id' AND encounter = '$encounter_id'"); + "pid = ? AND encounter = ?", array($patient_id, $encounter_id)); $inv_amount = $arow['amount']; $arow = sqlQuery("SELECT SUM(fee) AS amount FROM billing WHERE " . - "pid = '$patient_id' AND encounter = '$encounter_id' AND " . - "activity = 1 AND code_type != 'COPAY'"); + "pid = ? AND encounter = ? AND " . + "activity = 1 AND code_type != 'COPAY'", array($patient_id, $encounter_id)); $inv_amount += $arow['amount']; $arow = sqlQuery("SELECT SUM(fee) AS amount FROM billing WHERE " . - "pid = '$patient_id' AND encounter = '$encounter_id' AND " . - "activity = 1 AND code_type = 'COPAY'"); + "pid = ? AND encounter = ? AND " . + "activity = 1 AND code_type = 'COPAY'", array($patient_id, $encounter_id)); $inv_paid = 0 - $arow['amount']; $arow = sqlQuery("SELECT SUM(pay_amount) AS pay, " . "sum(adj_amount) AS adj FROM ar_activity WHERE " . - "pid = '$patient_id' AND encounter = '$encounter_id'"); + "pid = ? AND encounter = ?", array($patient_id, $encounter_id)); $inv_paid += $arow['pay']; $inv_amount -= $arow['adj']; $total_amount += bucks($inv_amount); @@ -238,28 +228,28 @@ if ($_POST['form_refresh']) { ?> -   +   -   +   -   +   -   +   -   +   -   +   -   +   -   +     @@ -282,13 +272,13 @@ if ($_POST['form_refresh']) {   -  +  -  +  -  +  -- 2.11.4.GIT