← Back to team overview

dhis2-devs team mailing list archive

Re: Filtering by attribute values on /api/organisations

 

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@xxxxxxxxxxxxxxxx> wrote:

> Cool. Thanks!
>
> On Mon, Mar 30, 2015 at 3:04 PM, Morten Olav Hansen <mortenoh@xxxxxxxxx>
> 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@xxxxxxxxx>
>> 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@xxxxxxxxxxxxxxxx> 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?
>>>>
>>>
>>>
>>
>

References