I now understand how to add/delete data from the user_facility table and the global variable but I’m still left with a few questions:
1) How is using a COOKIE different than using the SESSION (which is itself a cookie)?
2) If a provider goes between different locations, how would the cookie move with them? Maybe they’re using a laptop or tablet that they carry around?
3) Is there a solution that can be integrated into the SESSION variable? I’ve proposed a user_preferences table in the past. Perhaps a preference variable for ‘preferred_facility’ could be set and used like the cookie is being used here?
Sorry if it seems like my skull is too thick here but the cookie thing is really throwing me. Years ago I passed cookies all the time in my code. But, today, the PHP $_SESSION variable is so much easier to work with.
The point is that when a user goes between locations they will be different facilities. The cookie on his computer in Orlando is facility 1 and the cookie on his different computer in Kissimmee is facility 2.
If a user totes a laptop between locations then that defeats the purpose of the cookie anyway. The only other way I can think to implement this would be based on the source IP.
Wouldn’t it be easier just to ask at login for a facility selection if it;s different than the default assigned to the user? Just seems a bit over engineered to me.
You could even just use a URL variable in the book mark to designate the default facility for that computer, ie: http:// … openemr/clinicorg/login.php?facility=1 (as an example)
I agree with Tony that a login option for facility should be used. In fact, didn’t that used to be an option? hmmm…
After looking I see that there used to be a select option at login that was related to ‘groups’ which I believe was the idea of facilities but with a different word. That same could could be resurrected with with some rework to be facility instead of group.
I think I like Tony’s other suggestion of using a URL parameter so it can be embedded in the shortcut. Perhaps a combination of both, with the URL param used to select an item in a dropdown on the login screen (or hiding that option entirely). And then losing the cookie, but keeping the pc_facility setting in the session.