diff --git a/interface/custom/attendance/attendance_report.php b/interface/custom/attendance/attendance_report.php index 6d22b19..34fa59a 100644 --- a/interface/custom/attendance/attendance_report.php +++ b/interface/custom/attendance/attendance_report.php @@ -30,8 +30,18 @@ $attendance = new Attendance(); $currentDate = new DateTime(); $lastSixMonths = $currentDate->sub(new DateInterval('P6M')); -$attendance->from_date = (isset($_POST['form_from_date'])) ? DateToYYYYMMDD($_POST['form_from_date']) : $lastSixMonths->format('Y-m-d'); -$attendance->to_date = (isset($_POST['form_to_date'])) ? DateToYYYYMMDD($_POST['form_to_date']) : date('Y-m-d'); +if (isset($_POST['form_from_date'])) { + $attendance->from_date = date("Y-m-d", strtotime($_POST['form_from_date'])); +} else { + $dt = date_create(date('Y-m-d')); + date_sub($dt, date_interval_create_from_date_string("180 days")); + $attendance->from_date = date_format($dt, "Y-m-d"); +} +if (isset($_POST['form_to_date'])) { + $attendance->to_date = date("Y-m-d", strtotime($_POST['form_to_date'])); +} else { + $attendance->to_date = date('Y-m-d'); +} $attendance->level = (isset($_POST['form_level'])) ? $_POST['form_level'] : 1; // SQL Query @@ -72,7 +82,9 @@ if (!empty($_POST)) {

- This report shows scofflaws. + Attendance report shows a listing of patients who have either cancelled less than 24 hours or did not + show for an appointment. The total column is the total number of missed appointments during the selected + period. Click on the Patient ID to see a detailed listing of the missed appointments.

@@ -102,7 +114,7 @@ if (!empty($_POST)) { -
+
diff --git a/interface/custom/billing/billing-activity.php b/interface/custom/billing/billing-activity.php index e69de29..de9da75 100755 --- a/interface/custom/billing/billing-activity.php +++ b/interface/custom/billing/billing-activity.php @@ -0,0 +1,190 @@ + + * @copyright Copyright (c) 2022 Ken Schaefer + * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 + */ + +require_once("../../globals.php"); +require_once("$srcdir/forms.inc"); +require_once("$srcdir/options.inc.php"); +require_once("billing.class.php"); + +use OpenEMR\Common\Csrf\CsrfUtils; +use OpenEMR\Core\Header; + +if (!empty($_POST)) { + if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) { + CsrfUtils::csrfNotVerified(); + } +} + +// Store form variables +if (isset($_POST['form_from_date'])) { + $form_from_date = date("Y-m-d", strtotime($_POST['form_from_date'])); +} else { + $form_from_date = date('Y-m-d'); +} +if (isset($_POST['form_to_date'])) { + $form_to_date = date("Y-m-d", strtotime($_POST['form_to_date'])); +} else { + $form_to_date = date('Y-m-d'); +} +if (isset($_POST['form_biller'])) { + $form_biller = $_POST['form_biller']; +} else { + $form_biller = 0; +} + +$billing = new Billing(); + +if (!empty($_POST)) { + // Process form data + $main_query = $billing->getARActivity($form_biller, $form_from_date, $form_to_date); + $main_results = sqlStatement($main_query); +} + +?> + + + + + <?php echo xlt('Activity'); ?> + + + + + + +
+ + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
EncounterDate of ServicePatientCodeModifierBill DatePost DateUserPaymentAdjustment
+
+ + + \ No newline at end of file diff --git a/interface/custom/billing/billing.class.php b/interface/custom/billing/billing.class.php new file mode 100644 index 0000000..fefd8a5 --- /dev/null +++ b/interface/custom/billing/billing.class.php @@ -0,0 +1,38 @@ + + * @copyright Copyright (c) 2022 Ken Schaefer + * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 + */ + +class Billing +{ + + public function getARActivity($biller_id, $from_date, $to_date) + { + $query = " + SELECT + r.encounter, r.code, r.modifier, r.post_time, r.post_user, r.pay_amount, r.adj_amount, + (SELECT CONCAT(lname, ', ', fname) FROM users AS u WHERE r.post_user = u.id) AS username, + fe.date AS dos, fe.pid, fe.provider_id, b.billed, b.bill_date, + (SELECT CONCAT(lname, ', ', fname) FROM patient_data AS p WHERE p.pid = fe.pid) AS patient_name + FROM openemr.ar_activity AS r + LEFT JOIN form_encounter AS fe ON r.encounter = fe.encounter + LEFT JOIN (SELECT * FROM billing WHERE id IN (SELECT MIN(id) FROM billing GROUP BY encounter)) AS b ON fe.encounter = b.encounter + WHERE r.post_time BETWEEN '" . $from_date . "' AND '" . $to_date . "' AND + r.deleted IS NULL + "; + + if($biller_id != 0) { + $query = $query . " AND r.post_user = " . $biller_id; + } + + $query = $query . " ORDER BY r.post_user, r.post_time DESC"; + + return $query; + } +} diff --git a/interface/custom/billing/reconciliation.php b/interface/custom/billing/reconciliation.php index 96e2136..8290e13 100755 --- a/interface/custom/billing/reconciliation.php +++ b/interface/custom/billing/reconciliation.php @@ -24,8 +24,8 @@ if (!empty($_POST)) { } // Store form variables -$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'); +if(isset($_POST['form_from_date'])){$form_from_date=date("Y-m-d", strtotime($_POST['form_from_date']));}else{$form_from_date=date('Y-m-d');} +if(isset($_POST['form_to_date'])){$form_to_date=date("Y-m-d", strtotime($_POST['form_to_date']));}else{$form_to_date=date('Y-m-d');} $form_provider = (isset($_POST['form_provider'])) ? $_POST['form_provider'] : '0'; $form_patient = (isset($_POST['form_patient'])) ? $_POST['form_patient'] : null; $form_insurance = (isset($_POST['form_insurance'])) ? $_POST['form_insurance'] : '0'; @@ -46,12 +46,11 @@ if (!empty($_POST)) { ( SELECT SUM(a.pay_amount) FROM ar_activity AS a WHERE a.pid = fe.pid AND a.encounter = fe.encounter AND a.deleted IS NULL AND a.payer_type = 0 AND a.account_code = 'PCP') AS copays FROM form_encounter AS fe - LEFT JOIN billing b USING(encounter) + LEFT JOIN (SELECT * FROM billing WHERE id IN (SELECT MIN(id) FROM billing GROUP BY encounter)) AS b ON fe.encounter = b.encounter LEFT JOIN users u ON fe.provider_id = u.id LEFT JOIN patient_data p ON fe.pid = p.pid - WHERE fe.date BETWEEN '" . $form_from_date. "' AND '" . $form_to_date . "' - AND (b.code_type IS NULL OR b.code_type = 'CPT4')"; + WHERE fe.date BETWEEN '" . $form_from_date. "' AND '" . $form_to_date . "'"; if(floatval($form_provider) != 0) { @@ -79,7 +78,6 @@ if (!empty($_POST)) { "; $main_results = sqlStatement($main_query); - } @@ -92,9 +90,11 @@ if (!empty($_POST)) {