morten
(Morten Hansen)
30 March 2015 09:33
#1
Hi
You can do something like this:
/api/organisationUnits?filter=attributeValues.attribute.id:eq:ATTRIBUTE_ID&filter=attributeValues.value:eq:VALUE
You can read more about the object filter here:
https://www.dhis2.org/doc/snapshot/en/developer/html/ch01s06.html
Please be aware that attributeValue paths are not currently optimised, so it means they will use in-memory filtering
···
–
Morten
On Sat, Mar 28, 2015 at 10:57 PM, Mahendra Kariya mahendra.kariya@thoughtworks.com wrote:
Hi,
We have a few custom attributes for org units. For example, attribute named “Type” can have values like “Hospital”, “Dispensary”, etc.
We want to GET org units having particular attribute values through /api/organisationUnits. Say, we want to GET all org units of type “Hospital”.
What would be the easiest way to do this?
morten
(Morten Hansen)
30 March 2015 09:34
#2
Please also not that in 2.19 metadata attributes support option-sets, which might be nice if you have a pre-defined list of ou types.
···
On Mon, Mar 30, 2015 at 4:33 PM, Morten Olav Hansen mortenoh@gmail.com wrote:
Hi
You can do something like this:
/api/organisationUnits?filter=attributeValues.attribute.id:eq:ATTRIBUTE_ID&filter=attributeValues.value:eq:VALUE
You can read more about the object filter here:
https://www.dhis2.org/doc/snapshot/en/developer/html/ch01s06.html
Please be aware that attributeValue paths are not currently optimised, so it means they will use in-memory filtering
–
Morten
–
Morten
On Sat, Mar 28, 2015 at 10:57 PM, Mahendra Kariya mahendra.kariya@thoughtworks.com wrote:
Hi,
We have a few custom attributes for org units. For example, attribute named “Type” can have values like “Hospital”, “Dispensary”, etc.
We want to GET org units having particular attribute values through /api/organisationUnits. Say, we want to GET all org units of type “Hospital”.
What would be the easiest way to do this?
Lars
(Lars Øverland)
31 March 2015 15:33
#3
Hi Mahendra,
are you, or did you consider, using org unit groups and group sets for this?
If you have pre-defined values for your attributes this is a better approach, as it gives you the ability to do analysis based on it (basically have the group set as a dimension in pivot/visualizer/event report etc).
It also simple to fetch all org units members of org unit groups.
Lars
···
On Mon, Mar 30, 2015 at 12:06 PM, Mahendra Kariya mahendra.kariya@thoughtworks.com wrote:
Cool. Thanks!
On Mon, Mar 30, 2015 at 3:04 PM, Morten Olav Hansen mortenoh@gmail.com wrote:
Please also not that in 2.19 metadata attributes support option-sets, which might be nice if you have a pre-defined list of ou types.
–
Morten
On Mon, Mar 30, 2015 at 4:33 PM, Morten Olav Hansen mortenoh@gmail.com wrote:
Hi
You can do something like this:
/api/organisationUnits?filter=attributeValues.attribute.id:eq:ATTRIBUTE_ID&filter=attributeValues.value:eq:VALUE
You can read more about the object filter here:
https://www.dhis2.org/doc/snapshot/en/developer/html/ch01s06.html
Please be aware that attributeValue paths are not currently optimised, so it means they will use in-memory filtering
–
Morten
On Sat, Mar 28, 2015 at 10:57 PM, Mahendra Kariya mahendra.kariya@thoughtworks.com wrote:
Hi,
We have a few custom attributes for org units. For example, attribute named “Type” can have values like “Hospital”, “Dispensary”, etc.
We want to GET org units having particular attribute values through /api/organisationUnits. Say, we want to GET all org units of type “Hospital”.
What would be the easiest way to do this?
Lars
(Lars Øverland)
4 June 2015 09:22
#4
Hi Mahendra,
I see. Still, you could decide to only sync a few of those groups/group sets that you actually need in your app - it would not really be more complicated. When its time to analyse the data it will pay off.
Anyway, I will stop messing about this
cheers
Lars
···
On Tue, Mar 31, 2015 at 6:08 PM, Mahendra Kariya mahendra.kariya@thoughtworks.com wrote:
Hi Lars,
Thanks for pointing this out.
We do have org unit groups and group sets.
We want to filter based on attribute values because we don’t want to sync all the metadata from DHIS to our offline field app. Our app deals with only a subset of it.
On Tue, Mar 31, 2015 at 9:03 PM, Lars Helge Øverland larshelge@gmail.com wrote:
Hi Mahendra,
are you, or did you consider, using org unit groups and group sets for this?
If you have pre-defined values for your attributes this is a better approach, as it gives you the ability to do analysis based on it (basically have the group set as a dimension in pivot/visualizer/event report etc).
It also simple to fetch all org units members of org unit groups.
Lars
On Mon, Mar 30, 2015 at 12:06 PM, Mahendra Kariya mahendra.kariya@thoughtworks.com wrote:
Cool. Thanks!
On Mon, Mar 30, 2015 at 3:04 PM, Morten Olav Hansen mortenoh@gmail.com wrote:
Please also not that in 2.19 metadata attributes support option-sets, which might be nice if you have a pre-defined list of ou types.
–
Morten
On Mon, Mar 30, 2015 at 4:33 PM, Morten Olav Hansen mortenoh@gmail.com wrote:
Hi
You can do something like this:
/api/organisationUnits?filter=attributeValues.attribute.id:eq:ATTRIBUTE_ID&filter=attributeValues.value:eq:VALUE
You can read more about the object filter here:
https://www.dhis2.org/doc/snapshot/en/developer/html/ch01s06.html
Please be aware that attributeValue paths are not currently optimised, so it means they will use in-memory filtering
–
Morten
On Sat, Mar 28, 2015 at 10:57 PM, Mahendra Kariya mahendra.kariya@thoughtworks.com wrote:
Hi,
We have a few custom attributes for org units. For example, attribute named “Type” can have values like “Hospital”, “Dispensary”, etc.
We want to GET org units having particular attribute values through /api/organisationUnits. Say, we want to GET all org units of type “Hospital”.
What would be the easiest way to do this?