Hey Octavio,

Let me try to explain to you how to solve your problem (or what i believe is 
what you want)

You can get a all available fields by using the :all value for fields. Like so

https://apps.dhis2.org/dev/api/organisationUnits.json?fields=:all

Then there is a parent field on each org unit so you could filter on the org 
unit id like so

https://apps.dhis2.org/dev/api/organisationUnits.json?fields=id,name,parent&filter=parent.id:eq:qtr8GGlm4gg

You can then also specify which fields you would want by using the 
parent[<fields>] notation.

https://apps.dhis2.org/dev/api/organisationUnits.json?fields=id,name,parent[id,name]&filter=parent.id:eq:qtr8GGlm4gg

You could even filter on the parent of the parent, but you might want to think 
about performance also.

https://apps.dhis2.org/dev/api/organisationUnits.json?fields=id,name,parent[id,name]&filter=parent.parent.id:eq:at6UHUQatSo

I hope this helps

Kind regards,

Mark Polak
[email protected]
[email protected]
+47 970 36 752

On 27 Oct 2014, at 17:43, Octavio GLORIO <[email protected]> 
wrote:

> Hi all there,
> I am facing some problems filtering orgunits with the API. Our scenario have 
> many Organisation Units with the same name. Basically, because we are 
> implementing the health services as part of the hierarchy. However, at 
> facility level, the names of the services are unique. 
> 
> The problem comes when we want to obtain the id of a specific service. We are 
> used to call the API and filter by name, this is an example with a service 
> named "Hospitalization Ward":
> 
> http://localhost:8080/dhis216/api/organisationUnits?filter=name:eq:Hospitalization%20Ward&paging=false
> <metadata xmlns="http://dhis2.org/schema/dxf/2.0";>
> <organisationUnits>
> <organisationUnit id="T91cWg6MWvQ" created="2014-10-27T12:23:46.916+0000" 
> name="Hospitalization Ward" lastUpdated="2014-10-27T12:23:48.462+0000"/>
> <organisationUnit id="TreNA1ZDZTG" created="2014-10-27T12:25:04.374+0000" 
> name="Hospitalization Ward" lastUpdated="2014-10-27T12:25:06.076+0000"/>
> <organisationUnit id="JRU3Bc7MzW7" created="2014-10-27T12:24:47.824+0000" 
> name="Hospitalization Ward" lastUpdated="2014-10-27T12:24:49.286+0000"/>
> <organisationUnit id="WeNs6saMkDc" created="2014-10-27T12:24:03.207+0000" 
> name="Hospitalization Ward" lastUpdated="2014-10-27T12:24:04.556+0000"/>
> <organisationUnit id="Xk1237nWyvx" created="2014-10-27T12:24:25.540+0000" 
> name="Hospitalization Ward" lastUpdated="2014-10-27T12:24:27.469+0000"/>
> <organisationUnit id="KyH6BHmueDC" created="2014-10-27T12:22:35.799+0000" 
> name="Hospitalization Ward" lastUpdated="2014-10-27T12:22:37.138+0000"/>
> <organisationUnit id="ItSNROLnYUR" created="2014-10-27T12:25:44.677+0000" 
> name="Hospitalization Ward" lastUpdated="2014-10-27T12:25:46.117+0000"/>
> </organisationUnits>
> </metadata>
> 
> We are interested in filtering this result with parent orgunit id (or name). 
> However, we do not find how to access this attribute (maybe because is a 
> nested one) using the filter of the API.
> Maybe I am losing something, maybe has to be thinked different. 
> Thanks in advance for any help.
> Cheers,
> Octavio.
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-users
> Post to     : [email protected]
> Unsubscribe : https://launchpad.net/~dhis2-users
> More help   : https://help.launchpad.net/ListHelp

_______________________________________________
Mailing list: https://launchpad.net/~dhis2-users
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~dhis2-users
More help   : https://help.launchpad.net/ListHelp

Reply via email to