[Location Hierarchy] Add location hierarchy lineage ids to each location. #3676
Replies: 8 comments 17 replies
-
For the mobile client you mention Same question for the server side, what is the nature of the query now and how does this address that , please add more details there. For the OpenSRP web client, that only addresses one way that the data can become stale. A client can make call directly against the API that would make the data stale. Please add a list of the edge cases that can make the data become stale. For avoiding staleness for changes on the web, the approach is unclear, are you suggesting we regenerate the entire hierarchy with it's meta data whenever there is any change to any location? I agree, that would avoid staleness introduced through interactions on the fhir web, but it would be expensive, but only at write time, so that cost may be fine. Also on the web when you say On the specific metadata we are including, more detail on the use cases in the gateway and the mobile app will help with this. If we are only ever using this for further fetches or comparisons, storing a display seems unnecessary (it's duplicative of what we'll get when we do the ID search, and that will be authoritative). It's also not clear if it is important at what level the ancestors are at other than by either parsing display name (if we have it there like in your example), or fetching the resource referred to, if it stores it's level. If it's not important to know the levels of the ancestor, we only care about what are the ID's of the ancestors, putting them in a single string also seems reasonable. The approach we could take is instead of storing this information in the nodes themselves, we could maintain a separate mapping from each node to it's list of ancestors, and update that mapping whenever a node is added, moved, or removed. It's not clear exactly where we would store that, but it might be much simpler, certainly in terms of update logic. Please add more details on the client and gateway use cases and then we can refine the approach with that, thank you for the detailed write up, glad we are looking into this! |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
An edge case on the cost of the write operation; If a parent location's level on the hierarchy changes then we are looking at at-least as many api write requests as there are descendants to the modified location. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
{
"resourceType": "Location",
"id": "aa5ac053-d8aa-4f42-b326-bae32e5944e1",
"meta": {
"versionId": "4",
"lastUpdated": "2025-01-15T11:06:04.655+00:00",
"source": "#68b1bd0c9a81ad67",
"tag": [
{
"system": "http://smartregister.org/CodeSystem/location-hierarchy",
"code": "03176924-6b3c-4b74-bccd-32afcceebabd,bf116fdd-6617-4302-88e4-72fd1af2851c,696b532f-15b1-4422-a0ab-3525587260cd"
}
]
},
"identifier": [
{"use": "official", "value": "aa5ac053-d8aa-4f42-b326-bae32e5944e1"}
],
"status": "active",
"name": "Ambandrika",
"type": [
{
"coding": [
{
"system" : "http://terminology.hl7.org/CodeSystem/location-type",
"code" : "jdn" ,
"display": "jurisdiction"
}
]
},
{
"coding": [
{
"system" : "https://smartregister.org/codes/administrative-level",
"code" : "4" ,
"display": "Level 4"
}
]
},
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/location-physical-type",
"code": "jdn",
"display": "Jurisdiction"
}
]
}
],
"physicalType": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/location-physical-type",
"code": "jdn",
"display": "Jurisdiction"
}
]
},
"partOf": {
"reference": "Location/696b532f-15b1-4422-a0ab-3525587260cd",
"display" : "Ambatondrazaka"
}
} |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Context
partOf
relationship in Location resources.meta.tags
with the IDs of all parent locations, up to the root.meta.tags
, search queries for a given location ID can be handled natively by HAPI or other SDK search libraries, removing the need for expensive custom recursion logic.system
- This is an OpenSRP defined system. We can change it to anything.code
- This is the location id for the parent locationdisplay
- This can be the Location Name. We can also add the location level here e.gLevel 2
Implementation
Web client & Tooling
Server side
location.meta.tags
.Mobile Client
location.meta.tags
, thereby reducing memory usage and improving performance.Sample Location Resources
Beta Was this translation helpful? Give feedback.
All reactions