Situation
I found what appears to be an order-dependent Encounter Provider defaulting issue in OpenEMR 8.0.0 patch 3, and I was able to reproduce the same behavior in the online demo.
Scenario:
- Create/log in as a non-provider staff user.
- Provider checkbox is unchecked.
- See Authorizations is set to None.
- NPI/taxonomy are blank.
- Create a new encounter directly, with no appointment provider involved.
Observed behavior:
If the non-provider staff user’s last name sorts after at least one active provider, the Encounter Provider field defaults to the logged-in staff user and displays them as “Name (Non-Provider).”
If the non-provider staff user’s last name sorts before the providers, the issue may not appear.
Root cause appears to be in:
interface/forms/newpatient/C_EncounterVisitForm.class.php
Inside getProvidersForTemplate(), when provider_id is empty, the code falls back to $_SESSION[‘authUserID’] without first confirming that the logged-in user is actually a provider. Because the active users are processed in name order, this can cause a non-provider staff user to become selected as Encounter Provider depending on where they fall in the sorted user list.
Expected behavior:
The logged-in user should only be used as the default Encounter Provider if users.authorized = 1 / Provider is checked. Non-provider staff should not be auto-selected as the encounter provider.
Proposed fix:
Gate the fallback to $_SESSION[‘authUserID’] so it only happens when the logged-in user is an actual provider. Appointment provider defaults and historical encounters with a saved non-provider provider_id should still be preserved.
OpenEMR Version
I’m using OpenEMR version 8.0.0 patch 3
Browser:
I’m using: Chrome
Operating System
I’m using: Debian
Search
Did you search the forum for similar questions?
Logs
Did you check the logs?
Was there anything pertinent in them?
Please paste them here (surround with three backticks (```) for readability.
You can also turn on User Debugging under Administration->Globals->Logging User Debugging Options=>All
