From 4bafa598b3c2e2ffe8ca61f38dfc24e251aa6480 Mon Sep 17 00:00:00 2001 From: stephen waite Date: Wed, 24 Jan 2024 16:34:53 -0500 Subject: [PATCH] fix: post adjustment bug contractual obligations (#7187) * fix: post adjustment bug contractual obligations * use elseif --- interface/billing/sl_eob_process.php | 79 +++++++++++++--------------- 1 file changed, 38 insertions(+), 41 deletions(-) diff --git a/interface/billing/sl_eob_process.php b/interface/billing/sl_eob_process.php index 78624a25440..a730a97c480 100644 --- a/interface/billing/sl_eob_process.php +++ b/interface/billing/sl_eob_process.php @@ -373,7 +373,7 @@ function era_callback(&$out) // This reports detail lines already on file for this service item. if ($prev) { - $codetype = $codes[$codekey]['code_type']; //store code type + $codetype = $codes[$codekey]['code_type'] ?? 'none'; //store code type writeOldDetail($prev, $patient_name, $invnumber, $service_date, $codekey, $bgcolor); // Check for sanity in amount charged. $prevchg = sprintf("%.2f", $prev['chg'] + ($prev['adj'] ?? null)); @@ -386,19 +386,6 @@ function era_callback(&$out) $error = true; } - // Check for already-existing primary remittance activity. - // Removed this check because it was not allowing for copays manually - // entered into the invoice under a non-copay billing code. - /**** - if ((sprintf("%.2f",$prev['chg']) != sprintf("%.2f",$prev['bal']) || - $prev['adj'] != 0) && $primary) - { - writeMessageLine($bgcolor, 'errdetail', - "This service item already has primary payments and/or adjustments!"); - $error = true; - } - ****/ - unset($codes[$codekey]); } else { // If the service item is not in our database... // This is not an error. If we are not in error mode and not debugging, @@ -546,36 +533,46 @@ function era_callback(&$out) writeMessageLine($bgcolor, $class, $description . ' ' . sprintf("%.2f", $adj['amount'])); - } else { // Other group codes for primary insurance are real adjustments. - if (!$error && !$debug) { - SLEOB::arPostAdjustment( - $pid, - $encounter, - $InsertionId[$out['check_number']], - $adj['amount'], //$InsertionId[$out['check_number']] gives the session id - $codekey, - substr($inslabel, 3), - "Adjust code " . $adj['reason_code'], - $debug, - '', - $codetype ?? '', - $out['payer_claim_id'] - ); - $invoice_total -= $adj['amount']; - } - - writeDetailLine( - $bgcolor, - $class, - $patient_name, - $invnumber, + } elseif ( + $svc['paid'] == 0 + && !( + $adj['group_code'] == "CO" + && ( + $adj['reason_code'] == '45' + || $adj['reason_code'] == '59' + ) + ) + ) { + $class = 'errdetail'; + $error = true; + } elseif (!$error && !$debug) { + SLEOB::arPostAdjustment( + $pid, + $encounter, + $InsertionId[$out['check_number']], + $adj['amount'], //$InsertionId[$out['check_number']] gives the session id $codekey, - $production_date, - $description, - 0 - $adj['amount'], - ($error ? '' : $invoice_total) + substr($inslabel, 3), + "Adjust code " . $adj['reason_code'], + $debug, + '', + $codetype ?? '', + $out['payer_claim_id'] ); + $invoice_total -= $adj['amount']; } + + writeDetailLine( + $bgcolor, + $class, + $patient_name, + $invnumber, + $codekey, + $production_date, + $description, + 0 - $adj['amount'], + ($error ? '' : $invoice_total) + ); } } // End of service item