New Encounter From - (Possible?) Encounter Provider Bug

So, i may have found one bug that i want to discuss if it’s really a bug or not.

If you have schedule two appointments for one patient for two diferent users, let’s say User1 has the appointment to 9AM and User2 has it to 5PM, and User1 enter in the New Encounter Form, the Encounter Provider field will be auto filled with the User2 info. This can imply an registration error if User1 did not pay attention to it.

To summarize, the encounter form is being auto-filled base on the most recent schedule appointment of the patient, and i think it’s a great feature, but it should also take in count the user that it’s logged in.

i already pin pointed the file to fix this, if we come to the conclusion that this is really a bug or the way it has to be.

file: newpatient/common.php line 308(?)

if (!$viewmode) {
$now = date(‘Y-m-d’);
$encnow = date(‘Y-m-d 00:00:00’);
$time = date(“H:i:00”);
$q = “SELECT pc_aid, pc_facility, pc_billing_location, pc_catid, pc_startTime” .
" FROM openemr_postcalendar_events WHERE pc_pid=? AND pc_eventDate=?" .
" ORDER BY pc_startTime ASC";
$q_events = sqlStatement($q, array($pid, $now));
while ($override = sqlFetchArray($q_events)) {
$q = "SELECT fe.encounter as encounter FROM form_encounter AS fe " .
"JOIN forms AS f ON f.form_id = fe.id AND f.encounter = fe.encounter " .
“WHERE fe.pid=? AND fe.date=? AND fe.provider_id=? AND f.deleted=0”;
$q_enc = sqlQuery($q, array($pid, $encnow, $override[‘pc_aid’]));
if (!empty($override) && is_array($override) && empty($q_enc[‘encounter’])) {
$provider_id = $override[‘pc_aid’];
$default_bill_fac_override = $override[‘pc_billing_location’];
$default_fac_override = $override[‘pc_facility’];
$default_catid_override = $override[‘pc_catid’];
}
}
}