Here we are at the end of August and I find out the problem is not fixed. Here is an example.
Here is a query of the payment table for a patient.
Here is a query of the ar_sessions table for the same patient.
It should be obvious that the last entry for the patient was not recorded in the ar_session table.
The original solution that I posted is not panning out long term.
So I tried a different approach of including a third identifier. The date time stamp was going to be used but. There is inconsistency in the data time stamp in the two tables.
fix_ar_session.php (874 Bytes)
The results of the query are not correct using the query results for the above-posted patient as my litmus test. I can’t seem to get it down to show me the last missing payment.
I see in my image I have the last payment circled. It is the one above it that is missing from the ar_session table.
Look at payment amount 238.04, the creation time is 2017-07-21 00:26:59 in the ar_session table and it is 2017-05-13 12:33:23 in the payment table.
So, if a patient makes the same payment amount multiple times. That has to be a separate loop to find all of the same payments and see if the ar_session table has the same number of payments.
All of this is to try and clean up the accounting error before addressing the code that is causing the issue to begin with.