API: Getting all sub-ordinate organisationUnits from a root

Dear all,

is there a way to read a certain organisation with all its ancestors on
all/specific lower levels via api? Something like the "children" parameter in
the dataValueSets api for the organisationUnits api would be helpful ...

The alternative would be looping down the hierarchy level by level from outside,
which I'd like to avoid.

Thanks a lot,

Uwe (currently on 2.23, could upgrade to 2.24)

Dear Uwe,

api/organisationUnits.json?paging=false&fields=id,name,children[id,name,children[id,name,children[id,name]]]

Note the inside children[id,name]

Alex

···

On Wed, Aug 10, 2016 at 4:10 PM, Uwe Wahser uwe@wahser.de wrote:

Dear all,

is there a way to read a certain organisation with all its ancestors on

all/specific lower levels via api? Something like the “children” parameter in

the dataValueSets api for the organisationUnits api would be helpful …

The alternative would be looping down the hierarchy level by level from outside,

which I’d like to avoid.

Thanks a lot,

Uwe (currently on 2.23, could upgrade to 2.24)


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp

Alex Tumwesigye

Technical Advisor - DHIS2 (Consultant),
Ministry of Health/AFENET | HISP Uganda

Kampala

Uganda
+256 774149 775, + 256 759 800161

Skype ID: talexie

IT Consultant (Servers, Networks and Security, Health Information Systems - DHIS2, Disease Outbreak & Surveillance Systems) & Solar Consultant

"I don’t want to be anything other than what I have been - one tree hill "

Hi Alex,

thanks for the quick reply. Seems to be a good starting point.

I didn't know that these can be used recursively. There doesn't seem to be a
limit to the number of levels, either, so it might be worth trying to build an
url that points directly at the target level. Not yet sure, though, how to get
the results from the recursive json into a flat structure with kettle. I'll look
into that tomorrow. Actually I was hoping for something that returns a simple
flat list of all the subsequent OUs, so any other idea is still welcome :slight_smile:

Regards,

Uwe

···

Alex Tumwesigye <atumwesigye@gmail.com> hat am 10. August 2016 um 18:33
geschrieben:

Dear Uwe,

api/organisationUnits.json?paging=false&fields=id,name,children[id,name,children[id,name,children[id,name]]]

Note the inside children[id,name]

Alex

On Wed, Aug 10, 2016 at 4:10 PM, Uwe Wahser <uwe@wahser.de> wrote:

> Dear all,
>
> is there a way to read a certain organisation with all its ancestors on
> all/specific lower levels via api? Something like the "children" parameter
> in
> the dataValueSets api for the organisationUnits api would be helpful ...
>
> The alternative would be looping down the hierarchy level by level from
> outside,
> which I'd like to avoid.
>
> Thanks a lot,
>
> Uwe (currently on 2.23, could upgrade to 2.24)
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-users
> Post to : dhis2-users@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~dhis2-users
> More help : https://help.launchpad.net/ListHelp
>

--
Alex Tumwesigye

Technical Advisor - DHIS2 (Consultant),
Ministry of Health/AFENET | HISP Uganda
Kampala
Uganda
+256 774149 775, + 256 759 800161
Skype ID: talexie

IT Consultant (Servers, Networks and Security, Health Information Systems -
DHIS2, Disease Outbreak & Surveillance Systems) & Solar Consultant

"I don't want to be anything other than what I have been - one tree hill "

Hi Uwe

Did you try and have a look at the path property? probably you can use something like ?filter=path:^like:/uid1/uid2/uid3/ to get all ancestors of a particular org unit

···

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Wed, Aug 10, 2016 at 7:33 PM, Uwe Wahser uwe@wahser.de wrote:

Hi Alex,

thanks for the quick reply. Seems to be a good starting point.

I didn’t know that these can be used recursively. There doesn’t seem to be a

limit to the number of levels, either, so it might be worth trying to build an

url that points directly at the target level. Not yet sure, though, how to get

the results from the recursive json into a flat structure with kettle. I’ll look

into that tomorrow. Actually I was hoping for something that returns a simple

flat list of all the subsequent OUs, so any other idea is still welcome :slight_smile:

Regards,

Uwe

Alex Tumwesigye atumwesigye@gmail.com hat am 10. August 2016 um 18:33

geschrieben:

Dear Uwe,

api/organisationUnits.json?paging=false&fields=id,name,children[id,name,children[id,name,children[id,name]]]

Note the inside children[id,name]

Alex

On Wed, Aug 10, 2016 at 4:10 PM, Uwe Wahser uwe@wahser.de wrote:

Dear all,

is there a way to read a certain organisation with all its ancestors on

all/specific lower levels via api? Something like the “children” parameter

in

the dataValueSets api for the organisationUnits api would be helpful …

The alternative would be looping down the hierarchy level by level from

outside,

which I’d like to avoid.

Thanks a lot,

Uwe (currently on 2.23, could upgrade to 2.24)


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp

Alex Tumwesigye

Technical Advisor - DHIS2 (Consultant),

Ministry of Health/AFENET | HISP Uganda

Kampala

Uganda

+256 774149 775, + 256 759 800161

Skype ID: talexie

IT Consultant (Servers, Networks and Security, Health Information Systems -

DHIS2, Disease Outbreak & Surveillance Systems) & Solar Consultant

"I don’t want to be anything other than what I have been - one tree hill "

I think that's it. In that sense, actually ?filter=path:like:uid2 should be
sufficient to get all descendents of uid2 plus uid2 itself, right?

Thanks a lot!

···

Morten Olav Hansen <morten@dhis2.org> hat am 10. August 2016 um 20:35
geschrieben:

Hi Uwe

Did you try and have a look at the path property? probably you can use
something like ?filter=path:^like:/uid1/uid2/uid3/ to get all ancestors of
a particular org unit

--
Morten Olav Hansen
Senior Engineer, DHIS 2
University of Oslo
http://www.dhis2.org

On Wed, Aug 10, 2016 at 7:33 PM, Uwe Wahser <uwe@wahser.de> wrote:

> Hi Alex,
>
> thanks for the quick reply. Seems to be a good starting point.
>
> I didn't know that these can be used recursively. There doesn't seem to be
> a
> limit to the number of levels, either, so it might be worth trying to
> build an
> url that points directly at the target level. Not yet sure, though, how to
> get
> the results from the recursive json into a flat structure with kettle.
> I'll look
> into that tomorrow. Actually I was hoping for something that returns a
> simple
> flat list of all the subsequent OUs, so any other idea is still welcome :slight_smile:
>
> Regards,
>
> Uwe
>
> > Alex Tumwesigye <atumwesigye@gmail.com> hat am 10. August 2016 um 18:33
> > geschrieben:
> >
> >
> > Dear Uwe,
> >
> > api/organisationUnits.json?paging=false&fields=id,name,child
> ren[id,name,children[id,name,children[id,name]]]
> >
> > Note the inside children[id,name]
> >
> > Alex
> >
> > On Wed, Aug 10, 2016 at 4:10 PM, Uwe Wahser <uwe@wahser.de> wrote:
> >
> > > Dear all,
> > >
> > > is there a way to read a certain organisation with all its ancestors on
> > > all/specific lower levels via api? Something like the "children"
> parameter
> > > in
> > > the dataValueSets api for the organisationUnits api would be helpful
> ...
> > >
> > > The alternative would be looping down the hierarchy level by level from
> > > outside,
> > > which I'd like to avoid.
> > >
> > > Thanks a lot,
> > >
> > > Uwe (currently on 2.23, could upgrade to 2.24)
> > >
> > > _______________________________________________
> > > Mailing list: https://launchpad.net/~dhis2-users
> > > Post to : dhis2-users@lists.launchpad.net
> > > Unsubscribe : https://launchpad.net/~dhis2-users
> > > More help : https://help.launchpad.net/ListHelp
> > >
> >
> >
> >
> > --
> > Alex Tumwesigye
> >
> > Technical Advisor - DHIS2 (Consultant),
> > Ministry of Health/AFENET | HISP Uganda
> > Kampala
> > Uganda
> > +256 774149 775, + 256 759 800161
> > Skype ID: talexie
> >
> > IT Consultant (Servers, Networks and Security, Health Information
> Systems -
> > DHIS2, Disease Outbreak & Surveillance Systems) & Solar Consultant
> >
> >
> > "I don't want to be anything other than what I have been - one tree hill
> "
>

Well, yeah… as long as the uid is unique, which it has to :wink: you might need to have uid2/ if you don’t want to include the org unit with that uid itself, and only its ancestors

···

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Wed, Aug 10, 2016 at 7:51 PM, Uwe Wahser uwe@wahser.de wrote:

I think that’s it. In that sense, actually ?filter=path:like:uid2 should be

sufficient to get all descendents of uid2 plus uid2 itself, right?

Thanks a lot!

Morten Olav Hansen morten@dhis2.org hat am 10. August 2016 um 20:35

geschrieben:

Hi Uwe

Did you try and have a look at the path property? probably you can use

something like ?filter=path:^like:/uid1/uid2/uid3/ to get all ancestors of

a particular org unit

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Wed, Aug 10, 2016 at 7:33 PM, Uwe Wahser uwe@wahser.de wrote:

Hi Alex,

thanks for the quick reply. Seems to be a good starting point.

I didn’t know that these can be used recursively. There doesn’t seem to be

a

limit to the number of levels, either, so it might be worth trying to

build an

url that points directly at the target level. Not yet sure, though, how to

get

the results from the recursive json into a flat structure with kettle.

I’ll look

into that tomorrow. Actually I was hoping for something that returns a

simple

flat list of all the subsequent OUs, so any other idea is still welcome :slight_smile:

Regards,

Uwe

Alex Tumwesigye atumwesigye@gmail.com hat am 10. August 2016 um 18:33

geschrieben:

Dear Uwe,

api/organisationUnits.json?paging=false&fields=id,name,child

ren[id,name,children[id,name,children[id,name]]]

Note the inside children[id,name]

Alex

On Wed, Aug 10, 2016 at 4:10 PM, Uwe Wahser uwe@wahser.de wrote:

Dear all,

is there a way to read a certain organisation with all its ancestors on

all/specific lower levels via api? Something like the “children”

parameter

in

the dataValueSets api for the organisationUnits api would be helpful

The alternative would be looping down the hierarchy level by level from

outside,

which I’d like to avoid.

Thanks a lot,

Uwe (currently on 2.23, could upgrade to 2.24)


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp

Alex Tumwesigye

Technical Advisor - DHIS2 (Consultant),

Ministry of Health/AFENET | HISP Uganda

Kampala

Uganda

+256 774149 775, + 256 759 800161

Skype ID: talexie

IT Consultant (Servers, Networks and Security, Health Information

Systems -

DHIS2, Disease Outbreak & Surveillance Systems) & Solar Consultant

"I don’t want to be anything other than what I have been - one tree hill

"

I think that’s it. In that sense, actually ?filter=path:like:uid2 should be
sufficient to get all descendents of uid2 plus uid2 itself, right?

To get descendants (not ancestors), I think you can use https://play.dhis2.org/dev/api/organisationUnits/O6uvpzGd5pu?fields=id,name&includeDescendants=true&paging=false

···

On Wed, Aug 10, 2016 at 7:51 PM, Uwe Wahser uwe@wahser.de wrote:

I think that’s it. In that sense, actually ?filter=path:like:uid2 should be

sufficient to get all descendents of uid2 plus uid2 itself, right?

Thanks a lot!

Morten Olav Hansen morten@dhis2.org hat am 10. August 2016 um 20:35

geschrieben:

Hi Uwe

Did you try and have a look at the path property? probably you can use

something like ?filter=path:^like:/uid1/uid2/uid3/ to get all ancestors of

a particular org unit

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Wed, Aug 10, 2016 at 7:33 PM, Uwe Wahser uwe@wahser.de wrote:

Hi Alex,

thanks for the quick reply. Seems to be a good starting point.

I didn’t know that these can be used recursively. There doesn’t seem to be

a

limit to the number of levels, either, so it might be worth trying to

build an

url that points directly at the target level. Not yet sure, though, how to

get

the results from the recursive json into a flat structure with kettle.

I’ll look

into that tomorrow. Actually I was hoping for something that returns a

simple

flat list of all the subsequent OUs, so any other idea is still welcome :slight_smile:

Regards,

Uwe

Alex Tumwesigye atumwesigye@gmail.com hat am 10. August 2016 um 18:33

geschrieben:

Dear Uwe,

api/organisationUnits.json?paging=false&fields=id,name,child

ren[id,name,children[id,name,children[id,name]]]

Note the inside children[id,name]

Alex

On Wed, Aug 10, 2016 at 4:10 PM, Uwe Wahser uwe@wahser.de wrote:

Dear all,

is there a way to read a certain organisation with all its ancestors on

all/specific lower levels via api? Something like the “children”

parameter

in

the dataValueSets api for the organisationUnits api would be helpful

The alternative would be looping down the hierarchy level by level from

outside,

which I’d like to avoid.

Thanks a lot,

Uwe (currently on 2.23, could upgrade to 2.24)


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp

Alex Tumwesigye

Technical Advisor - DHIS2 (Consultant),

Ministry of Health/AFENET | HISP Uganda

Kampala

Uganda

+256 774149 775, + 256 759 800161

Skype ID: talexie

IT Consultant (Servers, Networks and Security, Health Information

Systems -

DHIS2, Disease Outbreak & Surveillance Systems) & Solar Consultant

"I don’t want to be anything other than what I have been - one tree hill

"


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp

David Huser
DHIS2 Support Specialist

dhuser@baosystems.com | https://baosystems.com | Skype: dafhus | 2900 K Street, Suite 404, Washington D.C. 20007

This one is even nicer and it returns the same result as the filter on the path.
I think I'll this that one.

Unfortunately the parameter is hidden in the section on "Current user
information" in the developers manual. Would be very useful to have it in the
api section on Organisation Units (currently 1.51)

Thanks, Uwe

···

David Huser <dhuser@baosystems.com> hat am 10. August 2016 um 23:09
geschrieben:

>
> I think that's it. In that sense, actually ?filter=path:like:uid2 should be
> sufficient to get all descendents of uid2 plus uid2 itself, right?

To get descendants (not ancestors), I think you can use
https://play.dhis2.org/dev/api/organisationUnits/O6uvpzGd5pu?fields=id,name&
*includeDescendants=true*&paging=false

On Wed, Aug 10, 2016 at 7:51 PM, Uwe Wahser <uwe@wahser.de> wrote:

> I think that's it. In that sense, actually ?filter=path:like:uid2 should be
> sufficient to get all descendents of uid2 plus uid2 itself, right?
>
> Thanks a lot!
>
> > Morten Olav Hansen <morten@dhis2.org> hat am 10. August 2016 um 20:35
> > geschrieben:
> >
> >
> > Hi Uwe
> >
> > Did you try and have a look at the path property? probably you can use
> > something like ?filter=path:^like:/uid1/uid2/uid3/ to get all ancestors
> of
> > a particular org unit
> >
> > --
> > Morten Olav Hansen
> > Senior Engineer, DHIS 2
> > University of Oslo
> > http://www.dhis2.org
> >
> > On Wed, Aug 10, 2016 at 7:33 PM, Uwe Wahser <uwe@wahser.de> wrote:
> >
> > > Hi Alex,
> > >
> > > thanks for the quick reply. Seems to be a good starting point.
> > >
> > > I didn't know that these can be used recursively. There doesn't seem
> to be
> > > a
> > > limit to the number of levels, either, so it might be worth trying to
> > > build an
> > > url that points directly at the target level. Not yet sure, though,
> how to
> > > get
> > > the results from the recursive json into a flat structure with kettle.
> > > I'll look
> > > into that tomorrow. Actually I was hoping for something that returns a
> > > simple
> > > flat list of all the subsequent OUs, so any other idea is still
> welcome :slight_smile:
> > >
> > > Regards,
> > >
> > > Uwe
> > >
> > > > Alex Tumwesigye <atumwesigye@gmail.com> hat am 10. August 2016 um
> 18:33
> > > > geschrieben:
> > > >
> > > >
> > > > Dear Uwe,
> > > >
> > > > api/organisationUnits.json?paging=false&fields=id,name,child
> > > ren[id,name,children[id,name,children[id,name]]]
> > > >
> > > > Note the inside children[id,name]
> > > >
> > > > Alex
> > > >
> > > > On Wed, Aug 10, 2016 at 4:10 PM, Uwe Wahser <uwe@wahser.de> wrote:
> > > >
> > > > > Dear all,
> > > > >
> > > > > is there a way to read a certain organisation with all its
> ancestors on
> > > > > all/specific lower levels via api? Something like the "children"
> > > parameter
> > > > > in
> > > > > the dataValueSets api for the organisationUnits api would be
> helpful
> > > ...
> > > > >
> > > > > The alternative would be looping down the hierarchy level by level
> from
> > > > > outside,
> > > > > which I'd like to avoid.
> > > > >
> > > > > Thanks a lot,
> > > > >
> > > > > Uwe (currently on 2.23, could upgrade to 2.24)
> > > > >
> > > > > _______________________________________________
> > > > > Mailing list: https://launchpad.net/~dhis2-users
> > > > > Post to : dhis2-users@lists.launchpad.net
> > > > > Unsubscribe : https://launchpad.net/~dhis2-users
> > > > > More help : https://help.launchpad.net/ListHelp
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Alex Tumwesigye
> > > >
> > > > Technical Advisor - DHIS2 (Consultant),
> > > > Ministry of Health/AFENET | HISP Uganda
> > > > Kampala
> > > > Uganda
> > > > +256 774149 775, + 256 759 800161
> > > > Skype ID: talexie
> > > >
> > > > IT Consultant (Servers, Networks and Security, Health Information
> > > Systems -
> > > > DHIS2, Disease Outbreak & Surveillance Systems) & Solar Consultant
> > > >
> > > >
> > > > "I don't want to be anything other than what I have been - one tree
> hill
> > > "
> > >
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-users
> Post to : dhis2-users@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~dhis2-users
> More help : https://help.launchpad.net/ListHelp
>

--

*David Huser*
DHIS2 Support Specialist
dhuser@baosystems.com | https://baosystems.com | Skype: dafhus | 2900 K
Street, Suite 404, Washington D.C. 20007

I would suggest going with the path approach as this is the preferred way going forward (which is why the other approach is not documented), depending on your use-case the path approach might be quicker also (it is send directly to the database)

···

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Thu, Aug 11, 2016 at 11:21 AM, Uwe Wahser uwe@wahser.de wrote:

On Wed, Aug 10, 2016 at 7:51 PM, Uwe Wahser uwe@wahser.de wrote:

I think that’s it. In that sense, actually ?filter=path:like:uid2 should be

sufficient to get all descendents of uid2 plus uid2 itself, right?

Thanks a lot!

Morten Olav Hansen morten@dhis2.org hat am 10. August 2016 um 20:35

geschrieben:

Hi Uwe

Did you try and have a look at the path property? probably you can use

something like ?filter=path:^like:/uid1/uid2/uid3/ to get all ancestors

of

a particular org unit

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Wed, Aug 10, 2016 at 7:33 PM, Uwe Wahser uwe@wahser.de wrote:

Hi Alex,

thanks for the quick reply. Seems to be a good starting point.

I didn’t know that these can be used recursively. There doesn’t seem

to be

a

limit to the number of levels, either, so it might be worth trying to

build an

url that points directly at the target level. Not yet sure, though,

how to

get

the results from the recursive json into a flat structure with kettle.

I’ll look

into that tomorrow. Actually I was hoping for something that returns a

simple

flat list of all the subsequent OUs, so any other idea is still

welcome :slight_smile:

Regards,

Uwe

Alex Tumwesigye atumwesigye@gmail.com hat am 10. August 2016 um

18:33

geschrieben:

Dear Uwe,

api/organisationUnits.json?paging=false&fields=id,name,child

ren[id,name,children[id,name,children[id,name]]]

Note the inside children[id,name]

Alex

On Wed, Aug 10, 2016 at 4:10 PM, Uwe Wahser uwe@wahser.de wrote:

Dear all,

is there a way to read a certain organisation with all its

ancestors on

all/specific lower levels via api? Something like the “children”

parameter

in

the dataValueSets api for the organisationUnits api would be

helpful

The alternative would be looping down the hierarchy level by level

from

outside,

which I’d like to avoid.

Thanks a lot,

Uwe (currently on 2.23, could upgrade to 2.24)


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp

Alex Tumwesigye

Technical Advisor - DHIS2 (Consultant),

Ministry of Health/AFENET | HISP Uganda

Kampala

Uganda

+256 774149 775, + 256 759 800161

Skype ID: talexie

IT Consultant (Servers, Networks and Security, Health Information

Systems -

DHIS2, Disease Outbreak & Surveillance Systems) & Solar Consultant

"I don’t want to be anything other than what I have been - one tree

hill

"


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp

DHIS2 Support Specialist

dhuser@baosystems.com | https://baosystems.com | Skype: dafhus | 2900 K

Street, Suite 404, Washington D.C. 20007

This one is even nicer and it returns the same result as the filter on the path.

I think I’ll this that one.

Unfortunately the parameter is hidden in the section on "Current user

information" in the developers manual. Would be very useful to have it in the

api section on Organisation Units (currently 1.51)

Thanks, Uwe

David Huser dhuser@baosystems.com hat am 10. August 2016 um 23:09

geschrieben:

I think that’s it. In that sense, actually ?filter=path:like:uid2 should be

sufficient to get all descendents of uid2 plus uid2 itself, right?

To get descendants (not ancestors), I think you can use

https://play.dhis2.org/dev/api/organisationUnits/O6uvpzGd5pu?fields=id,name&

includeDescendants=true&paging=false
David Huser

Thanks Morten for this clarification, did not know that.

···

On Thu, Aug 11, 2016 at 12:29 PM, Morten Olav Hansen morten@dhis2.org wrote:

I would suggest going with the path approach as this is the preferred way going forward (which is why the other approach is not documented), depending on your use-case the path approach might be quicker also (it is send directly to the database)

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Thu, Aug 11, 2016 at 11:21 AM, Uwe Wahser uwe@wahser.de wrote:

On Wed, Aug 10, 2016 at 7:51 PM, Uwe Wahser uwe@wahser.de wrote:

I think that’s it. In that sense, actually ?filter=path:like:uid2 should be

sufficient to get all descendents of uid2 plus uid2 itself, right?

Thanks a lot!

Morten Olav Hansen morten@dhis2.org hat am 10. August 2016 um 20:35

geschrieben:

Hi Uwe

Did you try and have a look at the path property? probably you can use

something like ?filter=path:^like:/uid1/uid2/uid3/ to get all ancestors

of

a particular org unit

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Wed, Aug 10, 2016 at 7:33 PM, Uwe Wahser uwe@wahser.de wrote:

Hi Alex,

thanks for the quick reply. Seems to be a good starting point.

I didn’t know that these can be used recursively. There doesn’t seem

to be

a

limit to the number of levels, either, so it might be worth trying to

build an

url that points directly at the target level. Not yet sure, though,

how to

get

the results from the recursive json into a flat structure with kettle.

I’ll look

into that tomorrow. Actually I was hoping for something that returns a

simple

flat list of all the subsequent OUs, so any other idea is still

welcome :slight_smile:

Regards,

Uwe

Alex Tumwesigye atumwesigye@gmail.com hat am 10. August 2016 um

18:33

geschrieben:

Dear Uwe,

api/organisationUnits.json?paging=false&fields=id,name,child

ren[id,name,children[id,name,children[id,name]]]

Note the inside children[id,name]

Alex

On Wed, Aug 10, 2016 at 4:10 PM, Uwe Wahser uwe@wahser.de wrote:

Dear all,

is there a way to read a certain organisation with all its

ancestors on

all/specific lower levels via api? Something like the “children”

parameter

in

the dataValueSets api for the organisationUnits api would be

helpful

The alternative would be looping down the hierarchy level by level

from

outside,

which I’d like to avoid.

Thanks a lot,

Uwe (currently on 2.23, could upgrade to 2.24)


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp

Alex Tumwesigye

Technical Advisor - DHIS2 (Consultant),

Ministry of Health/AFENET | HISP Uganda

Kampala

Uganda

+256 774149 775, + 256 759 800161

Skype ID: talexie

IT Consultant (Servers, Networks and Security, Health Information

Systems -

DHIS2, Disease Outbreak & Surveillance Systems) & Solar Consultant

"I don’t want to be anything other than what I have been - one tree

hill

"


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp

DHIS2 Support Specialist

dhuser@baosystems.com | https://baosystems.com | Skype: dafhus | 2900 K

Street, Suite 404, Washington D.C. 20007

This one is even nicer and it returns the same result as the filter on the path.

I think I’ll this that one.

Unfortunately the parameter is hidden in the section on "Current user

information" in the developers manual. Would be very useful to have it in the

api section on Organisation Units (currently 1.51)

Thanks, Uwe

David Huser dhuser@baosystems.com hat am 10. August 2016 um 23:09

geschrieben:

I think that’s it. In that sense, actually ?filter=path:like:uid2 should be

sufficient to get all descendents of uid2 plus uid2 itself, right?

To get descendants (not ancestors), I think you can use

https://play.dhis2.org/dev/api/organisationUnits/O6uvpzGd5pu?fields=id,name&

includeDescendants=true&paging=false
David Huser

David Huser
DHIS2 Support Specialist

dhuser@baosystems.com | https://baosystems.com | Skype: dafhus | 2900 K Street, Suite 404, Washington D.C. 20007