Patient Payment and Collections do not match

ajperezcrespo wrote on Thursday, October 11, 2012:

Hi,
  This does not make sense to me.
The patient has a Serivce Charge of 20 and pays a copay of 8.  The Balance should be 12.
That shows up fine on the Collections report.  But on the payment screen what we see is totally different.
What the patient paid is not factored in and what happens is the charge is added to what the copay should be.

Here are the screen shots.

Thanks

zhhealthcare wrote on Thursday, October 11, 2012:

We will submit a fix.  Thanks for the bug report. 

jacob

zhhealthcare wrote on Friday, October 12, 2012:

Hi,

We have committed the changed code on github, the path to the code is:
https://github.com/zhhealthcare/openemr/commit/88b495b18b098ad682ad13202adc795eb5950e7a’.

Submitted the code for review.

Thanks and Regards,
Ajil P M

bradymiller wrote on Tuesday, October 16, 2012:

Hi Ajil,
Committed this to sourceforge and will include it in next 4.1.1 patch.
thanks for the bug fix,
-brady
OpenEMR

juggernautsei wrote on Monday, October 29, 2012:

I have posted earlier that the patient balance in the demographics are not the same and the balance on the patient statement.  I have work on this for two weeks. I would like a hand if possible please.

I tried to create a new function that would get the patient balance but have not found the missing piece of information that would render the same balance that is printed in the patient statement.

I copied the balance function and removed what was not necessary. Below is what I have now.

function get_patient_balance_owed($pid) {
 
   $brow = sqlQuery("SELECT SUM(fee) AS amount FROM billing WHERE " .
      “pid = ? AND activity = 1”, array($pid) );

    $drow = sqlQuery("SELECT SUM(pay_amount) AS payments, " .
      "SUM(adj_amount) AS adjustments FROM ar_activity WHERE " .
      “pid = ?”, array($pid) );
    return sprintf(’%01.2f’, $brow- $drow - $drow - $drow);
     
}

any help would be grealy appreciated! :slight_smile:

Thank you,

bradymiller wrote on Tuesday, October 30, 2012:

Hi,
What version of OpenEMR are you using? (note 4.1.1 has some extensive changes in where copays are stored and handled and suggest getting most recent patch to deal with above bug; thus if you have any customized code, will need to ensure it supports this also).
-brady
OpenEMR

juggernautsei wrote on Friday, November 02, 2012:

Brady,

after much discussion and workiing on the code here is the issue. The balance that is shown on the patient demographics is inccorrect because is every thing that is open. The amount that should be displaying is what is Due Patient or {Dt Pt] that is in the DOB section. The calculation in the patient demographics takes all the charges in billing and subtracts it from all the payments and adjustments in AR table. It does not filter out the charges that do not have any payments or adjustments. This would give the balance due patient if it only calculated the billed - payments - adjustments. So if there is $100 billed in the billing table and in the corrisponding AR table there are not payment or adjustment entries then the amount due patient would be 0 until after the insurance is paid or not paid.

The easiest solution I can think of is to create a function on the EOB form to display a total at the bottom of the form then use that function in the patient demographics. My programming skills are getting better that I can talk the talk a lot better now but I have not reached the master level of most of you. I would appreciate any help to speed this along.

Thank you,

Sherwin
openmedpractice.com

juggernautsei wrote on Monday, November 19, 2012:

Brady,

After working on this for a long time, I have gotten the patient balance in the demographics closer to the correct balance.

function get_patient_balance($pid) {
  if ($GLOBALS === 2) {
    $brow = sqlQuery("SELECT SUM(fee) AS amount FROM billing WHERE " .
      “pid = ? AND billed = 1 AND activity = 1”, array($pid) );
    $srow = sqlQuery("SELECT SUM(fee) AS amount FROM drug_sales WHERE " .
      “pid = ?”, array($pid) );
    $drow = sqlQuery("SELECT SUM(pay_amount) AS payments, " .
      "SUM(adj_amount) AS adjustments FROM ar_activity WHERE " .
      “pid = ?”, array($pid) );
    return sprintf(’%01.2f’, $brow + $srow
      - $drow - $drow);
  }

The one thing that I added to the script above is  “billed = 1”. This allowed me to filter out the payments that have no payments or adjustments. This brings the balance to the same as what is seen in the patient encounter window below the demographics. However, it does not match the EOB’s search page balance. The balance on the EOB’s page can exclude encounters that are billed but payments not posted from Ins1 and Ins2.

I have been trying to figure out how to use the table data from the billing and ar_activity to exclude amounts that have a PRV value of -1. I have going through the code for the sl_eob_search.php what feels like 700 times and can’t quite figure out how the PRV value is derived. Because I have learned that when looking at the EOB’s page if the PRV is -1 then the value is not included in the Due Pt calculation.

Thanks for you time and attention….

Sherwin
openmedpractice.com

juggernautsei wrote on Monday, November 19, 2012:

Brady, I am using the 4.1.1. The issue with the balance in the patient demographics page is still the same issue.