Yes, I have explored this file. But I think, I can’t make it through the relevant Java calls. Because this UiSessionContext is initiated with a HttpServletRequest(see here), and the session is fetched through this HttpServletRequest(see here) to get the session location id.
Unfortunately, this class was not registered with the bean. So I couldn’t get this UiSessionContext class through the Context.getRegisteredComponent method also (using this following method),
Where in the Java code are you talking about? Are you in a controller in the web layer? Or in an API method? If you have access to the HTTP session, in other words from the web lair, you can get the location ID as a session attribute.
@suthagar23 the “session” is entirely a web layer concept. It doesn’t exist in the API. The OpenMRS API is basically stateless, and there’s no “current location”.
I’m not sure what you’re trying to do. Maybe you could fetch the session location in a web controller, and then pass it to your API layer method.
If they didn’t configure the app definition for the patient dashboard(then the user will not get the chance to select the access location), then I need to assign the access location value as the logged in user session location while registering the user.
Here, I can get the session from the fragment Controller class, and pass it to the API layer method (only possible when the fragment is loaded into the web layer). If the user didn’t configure the app definition with my custom fragment, then my custom fragment will not be loaded into the web layer. So the session will not be fetched for passing to the API layer.
AFAIK, Now Only we have a way to call that REST API to get the current session location information since it was implemented in the web layer.
Can we customize the UiSessionContext code to store the current session location value into the UserContext as well. Then we can simply fetch the current logged in user location information through the UserContext easily. It will very help full in the future implementation as well
Idea behind this is,
Just need to add a line after this line like this following,
No, global properties are, as the name says, global settings, they’re not specific to a single session or request.
I just took a quick peek at the short summary of your GSoC project, and I see it says:
Some implementations want to register users and patients in certain locations. Then access them based on the location that some one has logged in. That way, if some one is logged in a certain location, they should see only those encounters, observations, and patients registered in that location. But the System Developer account should be able to see patients in all locations.
Honestly this does not sound right to me. The way the Reference Application works is that a user simply selects a location when logging in, and there’s no authorization required to choose a login location. I would expect that users are assigned to one or more locations, and when the user logs in they’re allowed to see patients that belong to any of their locations. (But this user-location assignment would be at the API / data model level, not via the web session.)
Honestly this does not sound right to me. The way the Reference Application works is that a user simply selects a location when logging in, and there’s no authorization required to choose a login location. I would expect that users are assigned to one or more locations, and when the user logs in they’re allowed to see patients that belong to any of their locations. (But this user-location assignment would be at the API / data model level, not via the web session.)
Yes @darius , this is the idea behind my implementation
We will not remove the location selection(login) in the reference application until we reach a potential position on this project. After reaching a potential position, When a user logged in, System will automatically fetch the access location information.
Now the initial scenario will be,
If the patient registration dashboard of the system was customized with the location selection fragment(given through this module), then the user will assign the patient to a location! - NO PROBLEM AT THIS POINT
But if the patient registration dashboard of the system was not customized with the location selection fragment (some users, they might not change it for now), then the access location for the patient should be fetched from the current user session location - HERE IS THE PROBLEM (I need to fetch the session location information - See here )
So that, I have planned to store the current user location information into a global property from the appui module and decided to fetch that from my module.
Apart from that, there are no JAVA methods to get the current logged-in user session location information from the API Layer, So adding that information into a Global Property as follows will be a solution for those requirements as well!
I have checked this method again, and I was able to figure out the issue on this. I have fixed it and I was able to use this method to store the sessionLocation . So there are no need of Global Property !!
Hello There I am using LBAC, Is there any api to get the list of assign locations to list in dropdown. I need those locations which are assign to a particular user only. Thanks