Ken Schaefer
2 years ago
5 changed files with 297 additions and 47 deletions
@ -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> |
@ -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; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue