Background
DHIS2 has provided PSI, as well as many other organisation use DHIS2 as their de facto Master List of Facilities. DHIS2 provides various API endpoints to conveniently perform numerous CRUD operation. They have been a building blocks for all the DHIS2 apps the community built. These endpoints are mostly complete, comprehensive and well documented. But it has some shortfalls too. We cannot still perform any filters based on user location or specific coordinates. We cannot fetch a nearest organization units, its either all or none.
Introduction
Locator API is an add-on to the DHIS2. This API endpoint provides a new way to retrieve organization unit.
Developers can now request for closest ounit based on a specific coordinates.
Developer can also request for ‘n' numbers of ounits within 'x’ radius surrounding the specific coordinates
Developer can also find a closest ounit that is of specific type or provide specific facility.
Github
Change log
v.0.0.1: Planningvarious operation across Org Units. DHIS API has a comprehensive documentation on how to execute DHIS2 Org Unit API operations.
When creating consumer services, PSI’s solutions require in many instances produce a list of facilities based on the current location of the user - this means listing facilities that are closest to the provided Latitude and Longitude for the user. This search operation is not present in DHIS2 API, at least in the reviewed versions (2.38, 2.39 and 2.40 dev version - reviewed in February 2023).
Additionally, when performing a search by custom attributes, it is currently no possible to specify what attribute you are doing the search on - instead it searches all of them. This is a major issue for location searching.
Last, users may want to make use of custom attributes to store an array of value (perhaps as comma delimited values). A search operation by the individual value is not supported by DHIS2 API.
Locator API - Introduction
Locator API is a self-contained API that support the retrieval or Org Units based on alternative, non-native DHIS2 API calls, in particular:
Request for closest org units based on a given geo-coordinate, with the possibility to define a boundary as a ratio in Kms.
Return an enumeration of Custom Org Unit Attributes values - implemented for Area and SubArea, two of the suggested custom attributes that we recommend to install as part of the Org Units.
Enhance (by making precise) the search by custom attributes.*
Search by single values for an specific attributes (instead of all attributes, as it currently happens)
Search of a value on an array of values