Browse Source

activity report

master
Ken Schaefer 2 years ago
parent
commit
474f25b2ed
  1. 20
      interface/custom/attendance/attendance_report.php
  2. 190
      interface/custom/billing/billing-activity.php
  3. 38
      interface/custom/billing/billing.class.php
  4. 56
      interface/custom/billing/reconciliation.php
  5. 14
      interface/main/tabs/menu/menus/standard.json

20
interface/custom/attendance/attendance_report.php

@ -30,8 +30,18 @@ $attendance = new Attendance();
$currentDate = new DateTime(); $currentDate = new DateTime();
$lastSixMonths = $currentDate->sub(new DateInterval('P6M')); $lastSixMonths = $currentDate->sub(new DateInterval('P6M'));
$attendance->from_date = (isset($_POST['form_from_date'])) ? DateToYYYYMMDD($_POST['form_from_date']) : $lastSixMonths->format('Y-m-d'); if (isset($_POST['form_from_date'])) {
$attendance->to_date = (isset($_POST['form_to_date'])) ? DateToYYYYMMDD($_POST['form_to_date']) : date('Y-m-d'); $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; $attendance->level = (isset($_POST['form_level'])) ? $_POST['form_level'] : 1;
// SQL Query // SQL Query
@ -72,7 +82,9 @@ if (!empty($_POST)) {
<div class="search-info"> <div class="search-info">
<h2><?php echo xlt('Attendance Report'); ?></h2> <h2><?php echo xlt('Attendance Report'); ?></h2>
<p> <p>
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.
</p> </p>
</div> </div>
</div> </div>
@ -102,7 +114,7 @@ if (!empty($_POST)) {
</div> </div>
</div> </div>
<div class="row"> <div class="row mt-3">
<div class="col-md-12"> <div class="col-md-12">
<a href='#' class='btn btn-secondary btn-save' onclick='$("#theform").submit();'> <a href='#' class='btn btn-secondary btn-save' onclick='$("#theform").submit();'>
<?php echo xlt('Submit'); ?> <?php echo xlt('Submit'); ?>

190
interface/custom/billing/billing-activity.php

@ -0,0 +1,190 @@
<?php
/**
*
* @package OpenEMR
* @link
* @author Ken Schaefer <kschaefer@harmonyhealthmedical.com>
* @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);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title><?php echo xlt('Activity'); ?></title>
<?php Header::setupHeader(['datetime-picker', 'report-helper']); ?>
<style>
.container {
margin: 10px 0;
max-width: 100%;
width: 100%;
}
.totals {
font-weight: bold;
}
</style>
</head>
<body class="body_top">
<form method='post' id='theform' action='billing-activity.php' onsubmit='return top.restoreSession()'>
<input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
<div class="container">
<div class="row">
<div class="col-md-2">
<div class="search-info">
<h2><?php echo xlt('Activity'); ?></h2>
<p>
This is the AR Activity report that shows line item posting data during the provided time period.
</p>
</div>
</div>
<div class="col-md-10">
<!-- date row -->
<div class="row">
<div class="col">
<div class="form-group">
<input type="date" class="form-control input-lg" name="form_from_date" id="form_from_date" value="<?php if (isset($form_from_date)) echo $form_from_date; ?>">
</div>
</div>
<div class="col">
<div class="form-group">
<input type="date" class="form-control input-lg" name="form_to_date" id="form_to_date" value="<?php if (isset($form_to_date)) echo $form_to_date; ?>">
</div>
</div>
</div>
<!-- users row -->
<div class="row">
<div class="col">
<div class="form-group">
<?php
$cq = "select * from openemr.users where active = 1 and info like '%[AR]%'";
$cr = sqlStatement($cq);
?>
<select name="form_biller" id="form_code" class="form-control">
<option value="0" <?php if ($form_biller == 0) echo " selected"; ?>>All Billers</option>
<?php foreach ($cr as $r) {
echo "<option value = '" . $r['id'] . "'";
if ($form_biller == $r['id']) echo " selected ";
echo ">" . $r['fname'] . " " . $r['lname'] . "</option>";
} ?>
</select>
</div>
</div>
</div>
<!-- submission row -->
<div class="row">
<div class="col-md-12">
<a href='#' class='btn btn-secondary btn-save' onclick='$("#theform").submit();'>
<?php echo xlt('Submit'); ?>
</a>
<a href='#' class='btn btn-secondary btn-print' onclick='window.print()'>
<?php echo xlt('Print'); ?>
</a>
</div>
</div>
</div>
</div>
</div>
</form>
<div>
<table class="table">
<thead class="thead-light">
<tr>
<th>Encounter</th>
<th>Date of Service</th>
<th>Patient</th>
<th>Code</th>
<th>Modifier</th>
<th>Bill Date</th>
<th>Post Date</th>
<th>User</th>
<th>Payment</th>
<th>Adjustment</th>
</tr>
</thead>
<tbody>
<?php
$total_payments = 0.00;
$total_adjustments = 0.00;
foreach ($main_results as $row) {
$payment = floatval($row['pay_amount']);
$adjustment = floatval($row['adj_amount']);
$total_payments += $payment;
$total_adjustments += $adjustment;
?>
<tr class="data-row">
<td><?php echo $row['encounter']; ?></td>
<td><?php $dos = date_create($row['dos']);
echo date_format($dos, "m/d/Y"); ?></td>
<td><?php echo $row['patient_name']; ?></td>
<td><?php echo $row['code']; ?></td>
<td><?php echo $row['modifier']; ?></td>
<td><?php $bd = date_create($row['bill_date']);
echo date_format($bd, "m/d/Y"); ?></td>
<td><?php $pd = date_create($row['post_time']);
echo date_format($pd, "m/d/Y"); ?></td>
<td><?php echo $row['username']; ?></td>
<td align="right"><?php echo number_format($payment, 2); ?></td>
<td align="right"><?php echo number_format($adjustment, 2); ?></td>
</tr>
<?php } ?>
</tbody>
<tfoot>
<tr class="totals">
<td colspan="8"></td>
<td align="right"><?php echo "$ " . number_format($total_payments, 2) . " ($ " . number_format($total_payments * .06, 2) . ")"; ?></td>
<td align="right"><?php echo "$ " . number_format($total_adjustments, 2); ?></td>
</tr>
</tfoot>
</table>
</div>
</body>
</html>

38
interface/custom/billing/billing.class.php

@ -0,0 +1,38 @@
<?php
/**
*
* @package OpenEMR
* @link
* @author Ken Schaefer <kschaefer@harmonyhealthmedical.com>
* @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;
}
}

56
interface/custom/billing/reconciliation.php

@ -24,8 +24,8 @@ if (!empty($_POST)) {
} }
// Store form variables // Store form variables
$form_from_date = (isset($_POST['form_from_date'])) ? DateToYYYYMMDD($_POST['form_from_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');}
$form_to_date = (isset($_POST['form_to_date'])) ? DateToYYYYMMDD($_POST['form_to_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_provider = (isset($_POST['form_provider'])) ? $_POST['form_provider'] : '0';
$form_patient = (isset($_POST['form_patient'])) ? $_POST['form_patient'] : null; $form_patient = (isset($_POST['form_patient'])) ? $_POST['form_patient'] : null;
$form_insurance = (isset($_POST['form_insurance'])) ? $_POST['form_insurance'] : '0'; $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 ( 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 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 users u ON fe.provider_id = u.id
LEFT JOIN patient_data p ON fe.pid = p.pid LEFT JOIN patient_data p ON fe.pid = p.pid
WHERE fe.date BETWEEN '" . $form_from_date. "' AND '" . $form_to_date . "' WHERE fe.date BETWEEN '" . $form_from_date. "' AND '" . $form_to_date . "'";
AND (b.code_type IS NULL OR b.code_type = 'CPT4')";
if(floatval($form_provider) != 0) { if(floatval($form_provider) != 0) {
@ -80,7 +79,6 @@ if (!empty($_POST)) {
$main_results = sqlStatement($main_query); $main_results = sqlStatement($main_query);
} }
?> ?>
@ -92,9 +90,11 @@ if (!empty($_POST)) {
<?php Header::setupHeader(['datetime-picker', 'report-helper']); ?> <?php Header::setupHeader(['datetime-picker', 'report-helper']); ?>
<style> <style>
.balance-due {
background-color: #a39f2c;
}
.not-posted { .not-posted {
background-color: orange; background-color: #bd91ff;
color: white;
} }
.container { .container {
margin: 10px 0; margin: 10px 0;
@ -234,16 +234,15 @@ if (!empty($_POST)) {
<table class="table"> <table class="table">
<thead class="thead-light"> <thead class="thead-light">
<tr> <tr>
<th>Encounter</th> <th>Enc</th>
<th>Service Date</th> <th>DOS</th>
<th>Provider</th>
<th>PID</th>
<th>Patient</th> <th>Patient</th>
<th>Insurance</th> <th>Insurance</th>
<th>Code</th> <th>Code</th>
<th>Billed</th> <th>Modifier</th>
<th>Justify</th>
<th>Bill Dt</th>
<th>Charges</th> <th>Charges</th>
<th>Billed Amt</th>
<th>Adjustments</th> <th>Adjustments</th>
<th>Payments</th> <th>Payments</th>
<th>Copays</th> <th>Copays</th>
@ -269,11 +268,6 @@ if (!empty($_POST)) {
// Get values from the query and convert to numbers // Get values from the query and convert to numbers
$charges = floatval($row['charges']); $charges = floatval($row['charges']);
$billed = 0.00;
// If the claim was sent in then the billed amount is what was charged
if($row['process_file'] != '') {
$billed = floatval($row['charges']);
}
$adjustments = floatval($row['adjustments']); $adjustments = floatval($row['adjustments']);
$payments = floatval($row['payments']); $payments = floatval($row['payments']);
$copays = floatval($row['copays']); $copays = floatval($row['copays']);
@ -290,24 +284,31 @@ if (!empty($_POST)) {
// Increment the running totals // Increment the running totals
$total_charges += $charges; $total_charges += $charges;
$total_billed += $billed;
$total_adjustments += $adjustments; $total_adjustments += $adjustments;
$total_payments += $payments; $total_payments += $payments;
$total_copays += $copays; $total_copays += $copays;
$total_patients += $patient_due; $total_patients += $patient_due;
$total_balance += $balance; $total_balance += $balance;
?> ?>
<tr <?php //if(floatval($row['adjustments']) == 0) echo "class='not-posted'"; ?>> <tr class='data-row<?php if($row['bill_date'] == '') echo ' not-posted'; if($balance > 0) echo ' balance-due'; ?>'>
<td><?php echo "<a role='button' href='javascript:showEncounter(".attr_js($row['encounter']).",".attr_js($row['pid']).",".attr_js(oeFormatShortDate($row['date'])).");'>" . $row["encounter"] . "</a>"; ?></td> <td><?php echo "<a role='button' href='javascript:showEncounter(".attr_js($row['encounter']).",".attr_js($row['pid']).",".attr_js(oeFormatShortDate($row['date'])).");'>" . $row["encounter"] . "</a>"; ?></td>
<td><?php $dt = date_create($row['date']); echo date_format($dt, "m/d/Y"); ?></td> <td><?php $dt = date_create($row['date']); echo date_format($dt, "m/d/Y"); ?></td>
<td><?php echo $row['provider']; ?></td> <td><?php echo $row['patient'] . ' (' . $row['pid'] . ')'; ?></td>
<td><?php echo $row['pid']; ?></td>
<td><?php echo $row['patient']; ?></td>
<td><?php echo $row['insurance']; ?></td> <td><?php echo $row['insurance']; ?></td>
<td><?php echo $row['code']; ?></td> <td><?php echo $row['code']; ?></td>
<td align="center"><?php echo substr($row['process_file'],0,10); ?></td> <td><?php echo $row['modifier']; ?></td>
<td><?php
$jus = explode(':', $row['justify']);
foreach($jus as $j) {
echo substr($j, 6) . "<br>";
}
?>
</td>
<!--<td align="center"><?php echo substr($row['process_file'],0,10); ?></td>-->
<td align="center"><?php echo substr($row['bill_date'],0,10); ?></td>
<td align="right"><?php echo number_format($charges, 2); ?></td> <td align="right"><?php echo number_format($charges, 2); ?></td>
<td align="right"><?php echo number_format($billed, 2); ?></td>
<td align="right"><?php echo number_format($adjustments, 2); ?></td> <td align="right"><?php echo number_format($adjustments, 2); ?></td>
<td align="right"><?php echo number_format($payments, 2); ?></td> <td align="right"><?php echo number_format($payments, 2); ?></td>
<td align="right"><?php echo number_format($copays, 2); ?></td> <td align="right"><?php echo number_format($copays, 2); ?></td>
@ -320,7 +321,6 @@ if (!empty($_POST)) {
<tr class="totals"> <tr class="totals">
<td colspan="8">Number of records: <?php echo $db_count; ?></td> <td colspan="8">Number of records: <?php echo $db_count; ?></td>
<td align="right"><?php echo '$ ' . number_format($total_charges, 2); ?></td> <td align="right"><?php echo '$ ' . number_format($total_charges, 2); ?></td>
<td align="right"><?php echo '$ ' . number_format($total_billed, 2); ?></td>
<td align="right"><?php echo '$ ' . number_format($total_adjustments, 2); ?></td> <td align="right"><?php echo '$ ' . number_format($total_adjustments, 2); ?></td>
<td align="right"><?php echo '$ ' . number_format($total_payments, 2); ?></td> <td align="right"><?php echo '$ ' . number_format($total_payments, 2); ?></td>
<td align="right"><?php echo '$ ' . number_format($total_copays, 2); ?></td> <td align="right"><?php echo '$ ' . number_format($total_copays, 2); ?></td>
@ -330,7 +330,6 @@ if (!empty($_POST)) {
<tr> <tr>
<td colspan="8">Totals for <?php echo $form_from_date; ?> through <?php echo $form_to_date; ?></td> <td colspan="8">Totals for <?php echo $form_from_date; ?> through <?php echo $form_to_date; ?></td>
<td align="right">Charges</td> <td align="right">Charges</td>
<td align="right">Billed</td>
<td align="right">Adjustments</td> <td align="right">Adjustments</td>
<td align="right">Payments</td> <td align="right">Payments</td>
<td align="right">Copays</td> <td align="right">Copays</td>
@ -340,7 +339,6 @@ if (!empty($_POST)) {
</tfoot> </tfoot>
</table> </table>
<?php } ?> <?php } ?>
</div> </div>

14
interface/main/tabs/menu/menus/standard.json

@ -2333,9 +2333,21 @@
"icon": "fa-caret-right", "icon": "fa-caret-right",
"children": [ "children": [
{ {
"label": "Reconciliation", "label": "Activity",
"menu_id": "spr00", "menu_id": "spr00",
"target": "item1", "target": "item1",
"url": "/interface/custom/billing/billing-activity.php",
"children":[],
"requirement": 0,
"acl_req": [
"acct",
"bill"
]
},
{
"label": "Reconciliation",
"menu_id": "spr01",
"target": "item2",
"url": "/interface/custom/billing/reconciliation.php", "url": "/interface/custom/billing/reconciliation.php",
"children":[], "children":[],
"requirement": 0, "requirement": 0,

Loading…
Cancel
Save