Skip to content

Commit

Permalink
feat: add billing event to front payment (openemr#6899)
Browse files Browse the repository at this point in the history
* clean up and ...

* update The event dispatcher was missing.
I need that for a new module and anyone else can use it.

* dispatcher changed
  • Loading branch information
juggernautsei committed Oct 5, 2023
1 parent 02475cb commit ea02e7f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions interface/patient_file/front_payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
use OpenEMR\OeUI\OemrUI;
use OpenEMR\PaymentProcessing\Sphere\SpherePayment;
use OpenEMR\Services\FacilityService;
use Symfony\Component\EventDispatcher\EventDispatcher;


if (!empty($_REQUEST['receipt']) && empty($_POST['form_save'])) {
if (!AclMain::aclCheckCore('acct', 'bill') && !AclMain::aclCheckCore('acct', 'rep_a') && !AclMain::aclCheckCore('patients', 'rx')) {
Expand Down Expand Up @@ -1170,7 +1172,7 @@ function make_insurance() {
<label class="control-label" for="form_method"><?php echo xlt('Payment Method'); ?>:</label>
<select class="form-control" id="form_method" name="form_method" onchange='CheckVisible("yes")'>
<?php
$query1112 = "SELECT * FROM list_options where activity=1 AND list_id=? ORDER BY seq, title ";
$query1112 = "SELECT * FROM `list_options` where activity=1 AND list_id=? ORDER BY seq, title ";
$bres1112 = sqlStatement($query1112, array('payment_method'));
while ($brow1112 = sqlFetchArray($bres1112)) {
if ($brow1112['option_id'] == 'electronic' || $brow1112['option_id'] == 'bank_draft') {
Expand Down Expand Up @@ -1276,7 +1278,7 @@ function make_insurance() {
$encs[$key]['charges'] += $brow['fee'];
// Add taxes.
$sql_array = array();
$query = "SELECT taxrates FROM codes WHERE " .
$query = "SELECT taxrates FROM `codes` WHERE " .
"code_type = ? AND " .
"code = ? AND ";
array_push($sql_array, ($code_types[$brow['code_type']]['id'] ?? null), $brow['code']);
Expand Down Expand Up @@ -1318,7 +1320,7 @@ function make_insurance() {

$encs[$key]['charges'] += $drow['fee'];
// Add taxes.
$trow = sqlQuery("SELECT taxrates FROM drug_templates WHERE drug_id = ? " .
$trow = sqlQuery("SELECT taxrates FROM `drug_templates` WHERE drug_id = ? " .
"ORDER BY selector LIMIT 1", array($drow['drug_id']));
$encs[$key]['charges'] += calcTaxes($trow, $drow['fee']);
}
Expand Down Expand Up @@ -1376,16 +1378,16 @@ function make_insurance() {

//------------------------------------------------------------------------------------
//NumberOfInsurance
$ResultNumberOfInsurance = sqlStatement("SELECT COUNT( DISTINCT TYPE ) NumberOfInsurance FROM insurance_data
$ResultNumberOfInsurance = sqlStatement("SELECT COUNT( DISTINCT TYPE ) NumberOfInsurance FROM `insurance_data`
where pid = ? and provider>0 ", array($pid));
$RowNumberOfInsurance = sqlFetchArray($ResultNumberOfInsurance);
$NumberOfInsurance = $RowNumberOfInsurance['NumberOfInsurance'] * 1;
//------------------------------------------------------------------------------------
$duept = 0;
if ((($NumberOfInsurance == 0 || $value['last_level_closed'] == 4 || $NumberOfInsurance == $value['last_level_closed']))) {//Patient balance
$brow = sqlQuery("SELECT SUM(fee) AS amount FROM billing WHERE " .
$brow = sqlQuery("SELECT SUM(fee) AS amount FROM `billing` WHERE " .
"pid = ? and encounter = ? AND activity = 1", array($pid, $enc));
$srow = sqlQuery("SELECT SUM(fee) AS amount FROM drug_sales WHERE " .
$srow = sqlQuery("SELECT SUM(fee) AS amount FROM `drug_sales` WHERE " .
"pid = ? and encounter = ? ", array($pid, $enc));
$drow = sqlQuery("SELECT SUM(pay_amount) AS payments, " .
"SUM(adj_amount) AS adjustments FROM ar_activity WHERE " .
Expand Down Expand Up @@ -1887,5 +1889,5 @@ function posDialog() {
} // forms else close
?>
</body>
<?php $ed->dispatch(new PostFrontPayment(), PostFrontPayment::ACTION_POST_FRONT_PAYMENT, 10); ?>
<?php $GLOBALS['kernel']->getEventDispatcher()->dispatch(new PostFrontPayment(), PostFrontPayment::ACTION_POST_FRONT_PAYMENT, 10); ?>
</html>

0 comments on commit ea02e7f

Please sign in to comment.