Appointments and Encounters Report bug

We encountered a slight but unpleasant problem with reporting on 5.0.0. If one patient visits two doctors on the same day and every doctor generate his/her encounter then you can see these two encounters in the patient’s history which is normal. But Appointments and Encounters report will double those entries and accordingly the amount of money charged. My client uses this report in connection with their billing to verify its correctness.

I managed to duplicate the case on the current demo. A patient John Doe visits Dr. Who first and then Dr. When after that. They both create their encounters and patient’s visit history looks normal with the billing charges of $55 and $75 for the total of $130. But Appt-Enc report shows 4 encounters instead of 2 and the total charge is $260.

It is probably just an SQL error but I could not find it yet. Screens attached.

hi @alexvolin, it looks like there’s a bug here, openemr/appt_encounter_report.php at master · openemr/openemr · GitHub

think this should compare to a previously stored value of docname