Does openmrs/ws/rest/v1/admissionLocation return all child locations without checking if the child location has any Tags (Admission Location, Login Location etc.)? Is it possible to return only those locations having tags? Otherwise one has to make another call to check if the location is valid (has any tags) or not.
Are you seeing different behavior?
Yes, I see different behavior. Hopefully I am making right call (openmrs/ws/rest/v1/admissionLocation).
May be related to this? HibernateBedManagementDAO::getAdmissionLocationsBy as it calls HibernateBedManagementDAO::getPhysicalLocationsByLocationTag which checks ward.tags tag where tag.name = :locationTag
If you do
GET https://demo.mybahmni.org/openmrs/ws/rest/v1/admissionLocation then you get back two results (ward + totalBeds + occupiedBeds).
The “ward” is an OpenMRS location, i.e. it represents a location hierarchy, and what you’re pointing out is a child location.
In other words, this REST API call is behaving as expected: it returns two wards (i.e. locations tagged as Admission Location).
Yes, that’s what I asked in my original question “if it returns all child locations without checking if the child location has any Tags (Admission Location, Login Location etc.)?”
Sorry, I had not read your initial question carefully enough.
The top-level results are filtered, but their children are not.
Oh no…I must thank you for the prompt responses.
The current Bahmni implementation uses openmrs/ws/rest/v1/admissionLocation call to get list of wards. Further it makes openmrs/ws/rest/v1/admissionLocation/uuid?v=full to get beds and layout for that ward and displays it in ADT.
Just out of curiosity, what will happen if there are some beds inserted from database to one such child location (say General Ward - Room 2), will this call fetch beds for that child location also without checking if it has any tags? In that case, will get displayed in ADT?
- Will this call return children of a child location also? Eg. “General Ward Room 1” which is a child location has “Male Section” as its child.
- Will this call return wards even if there are no beds?
What happens if you test it out and check?
Yes, we added Subcenter 1 at the peer level of General Ward and it is not seen in the admissionLocation API result.
So, what you’re seeing now is the current behavior.
(Are you suggesting it should be different?)
We were trying to see if we could have used this call for the bed management UI that we are working on and required all “Admission Locations” in a hierarchical manner. But we may not be able to use this call for
- It returns only those admission locations which have beds
- It does not filter children (ie gets all children even with no tags) http://youtu.be/mybhWIf6oG0?hd=1
@ramashish, have you tried just
GET .../location?tag=Admission+Location ? This will get you all locations that have that tag. (You’d have to filter still. And you might need to merge it with the bed info from the other REST call.)
We were looking to see if any call gives hierarchical result as well as total beds so that binding to a tree view becomes easier and that’s how we started with admissionLodation.
Though Get …/location?tag=Admission+Location does not give hierarchical result (and the included hierarchy is not filtered here too) we will still use this call by appropriate filtering as you suggested.