Collection Report Wrong?

Hi @growlingflea @robertovasquez @visolve,

This report was received from an active user and they reported that the collection report is incorrect. The report is showing patients that still have secondary insurance to be billed as overdue. Have any of you looked into this or can some give me your opinion on this report?

I’ve checked the 5.0.2 dev and the code is largely the same. So, the same issue is going to exist in the next release.

Line 730 is where the bug maybe.

  // If we have not yet billed the patient, then compute $duncount as a
  // negative count of the number of insurance plans for which we have not
  // yet closed out insurance.  Here we also compute $insname as the name of
  // the insurance plan from which we are awaiting payment, and its sequence
  // number $insposition (1-3).
    $last_level_closed = $erow['last_level_closed'];
    $duncount = $erow['stmt_count'];
    $payerids = array();
    $insposition = 0;
    $insname = '';
    if (! $duncount) {
        for ($i = 1; $i <= 3; ++$i) {
            $tmp = arGetPayerID($patient_id, $svcdate, $i);

            if (empty($tmp)) {
                break;
            }

            $payerids[] = $tmp;
        }

        $duncount = $last_level_closed - count($payerids);
        if ($duncount < 0) {
            if (!empty($payerids[$last_level_closed])) {
                $insname = getInsName($payerids[$last_level_closed]);
                $insposition = $last_level_closed + 1;
            }
        }
    }

Thoughts and comments are welcome.

After some digging, I can see the $duncount may hold the key. The first patient on the list has a statement count of 1. The patient is placed on the collections list. I do realize that we are more than 90 days from January. I am going to bring up that issue with those that reported the possibility the report is incorrect.

The first patient on the list has two insurance and only one has been billed. 1 statement has been sent. So, this person should not be on the collection list unless the time lapse is the trigger.

UPDATE: I just saw where secondary billing needed has not been checked. I will ask them to check the box and run the report again.

if ($duncount != 0) {  <-- Changed this line see original above.
        for ($i = 1; $i <= 3; ++$i) {
            $tmp = arGetPayerID($patient_id, $svcdate, $i);

            if (empty($tmp)) {
                break;
            }

            $payerids[] = $tmp;
        }

This made the report better. But not complete. There are a couple of entries that are still incorrect.

53c7b80
@brady.miller @stephenwaite
Pull Request.

I was talking with the user that started this path and the question came up as to why are statements a part of this equation?

They are not using the internal statements at the moment so the report will always be off.

@stephenwaite do you know why statements are included in the equation?

This statement:

  // If we have not yet billed the patient, then compute $duncount as a
  // negative count of the number of insurance plans for which we have not
  // yet closed out insurance.  Here we also compute $insname as the name of
  // the insurance plan from which we are awaiting payment, and its sequence
  // number $insposition (1-3).

  $duncount = $erow['stmt_count'];

Duncount is set equal to the number of statements. Why is this important? @brady.miller are you one of the original architects of this report?