WebAPI getting all orgunits with hierarchy info

Hey Simen=2C
Depending on how many organisation units you have you can do something like=
this.
https://apps.dhis2.org/dev/api/organisationUnits.json?fields=3Did=2Cname=2C=
level=2Cparent[id]&paging=3Dfalse
That will get you all the org units and you could re-create the which are c=
hildren of what org unit by level and parent id.
This is normally very slow however so depending on the amount of org units =
you might want to concider loading the other levels separately eventhough t=
he ping is high.
Or you could concider loading the first level first and loading the other l=
evels in the background (no matter whether they are used or not.=0A=
Kind regards=2C
Mark Polakmark@thedutchies.commarkpo@ifi.uio.no+47 970 36 752=0A=
=0A=

On 15 Dec 2014=2C at 14:37=2C Jan Henrik =D8verland <janhenrik.overland@gma=
il.com> wrote:You can do this by using the fields param.
Go e.g. to https://apps.dhis2.org/dev/dhis-web-pivot -> orgunit tab and hav=
e a look at the network console when you expand nodes.

On Mon=2C Dec 15=2C 2014 at 2:34 PM=2C Simen Skogly Russnes <simen_russnes@=
hotmail.com> wrote:=0A=
=0A=
=0A=
Dear all=2C

can someone give me a suggestion on how to retrieve all orgunits through th=
e WebAPI=2C including parent-child relationships of orgunits=2C so that an =
orgunit view can be created similarly to the view in Data Entry and Individ=
ual Records in DHIS 2? Perhaps it's possible to pass a parameter to api/org=
anisationUnits so to include children or something=2C or in analytics get o=
rgunits to include parent when passing the LEVEL-<level> parameter.
The query wouldn't happen very often in the use case=2C but a low number of=
requests to the WebAPI would be preferable as ping rather than bandwidth i=
s an issue.

Regards=2C
Simen S. Russnes
                 =0A=

···

_______________________________________________
=0A=
Mailing list: https://launchpad.net/~dhis2-devs
=0A=
Post to : dhis2-devs@lists.launchpad.net
=0A=
Unsubscribe : https://launchpad.net/~dhis2-devs
=0A=
More help : https://help.launchpad.net/ListHelp
=0A=

=0A=
_______________________________________________
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help : https://help.launchpad.net/ListHelp

                 =

--_9e61f233-89b2-4af1-8ea0-c2441fc44a35_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<style><!--
.hmmessage P
{
margin:0px=3B
padding:0px
}
body.hmmessage
{
font-size: 12pt=3B
font-family:Calibri
}
--></style></head>
<body class=3D'hmmessage'><div dir=3D'ltr'>Thanks all=2C<br><br>I think wha=
t you suggest Mark is probably the best solution in this case. Having to do=
only 3-4 requests is ok for dividing into levels. I was more worried I'd h=
ave to do something like one request per org unit with children.<br><br><di=

<hr id=3D"stopSpelling">Subject: Re: [Dhis2-devs] WebAPI getting all orgu=

nits with hierarchy info<br>From: markpo@ifi.uio.no<br>Date: Mon=2C 15 Dec =
2014 14:44:41 +0100<br>CC: dhis2-devs@lists.launchpad.net=3B janhenrik.over=
land@gmail.com<br>To: simen_russnes@hotmail.com<br><br><div>Hey Simen=2C</d=

<div><br></div>Depending on how many organisation units you have you can=

do something like this.<div><br></div><div><a href=3D"https://apps.dhis2.o=
rg/dev/api/organisationUnits.json?fields=3Did%2cname%2clevel%2cparent%5bid%=
5d&amp=3Bpaging=3Dfalse" target=3D"_blank">https://apps.dhis2.org/dev/api/o=
rganisationUnits.json?fields=3Did=2Cname=2Clevel=2Cparent[id]&amp=3Bpaging=
=3Dfalse</a></div><div><br></div><div>That will get you all the org units a=
nd you could re-create the which are children of what org unit by level and=
parent id.</div><div><br></div><div>This is normally very slow however so =
depending on the amount of org units you might want to concider loading the=
other levels separately eventhough the ping is high.</div><div><br></div><=

Or you could concider loading the first level first and loading the oth=

er levels in the background (no matter whether they are used or not.</div><=

<div>=0A=

<div style=3D"color:rgb(0=2C 0=2C 0)=3Bfont-family:Helvetica=3Bfont-style:n=
ormal=3Bfont-variant:normal=3Bfont-weight:normal=3Bletter-spacing:normal=3B=
line-height:normal=3Borphans:2=3Btext-align:-webkit-auto=3Btext-indent:0px=
=3Btext-transform:none=3Bwhite-space:normal=3Bwidows:2=3Bword-spacing:0px=
=3B"><br class=3D"ecxApple-interchange-newline">Kind regards=2C</div><div s=
tyle=3D"color:rgb(0=2C 0=2C 0)=3Bfont-family:Helvetica=3Bfont-style:normal=
=3Bfont-variant:normal=3Bfont-weight:normal=3Bletter-spacing:normal=3Bline-=
height:normal=3Borphans:2=3Btext-align:-webkit-auto=3Btext-indent:0px=3Btex=
t-transform:none=3Bwhite-space:normal=3Bwidows:2=3Bword-spacing:0px=3B"><br=

</div><div style=3D"color:rgb(0=2C 0=2C 0)=3Bfont-family:Helvetica=3Bfont-=

style:normal=3Bfont-variant:normal=3Bfont-weight:normal=3Bletter-spacing:no=
rmal=3Bline-height:normal=3Borphans:2=3Btext-align:-webkit-auto=3Btext-inde=
nt:0px=3Btext-transform:none=3Bwhite-space:normal=3Bwidows:2=3Bword-spacing=
:0px=3B">Mark Polak</div><div style=3D"color:rgb(0=2C 0=2C 0)=3Bfont-family=
:Helvetica=3Bfont-style:normal=3Bfont-variant:normal=3Bfont-weight:normal=
=3Bletter-spacing:normal=3Bline-height:normal=3Borphans:2=3Btext-align:-web=
kit-auto=3Btext-indent:0px=3Btext-transform:none=3Bwhite-space:normal=3Bwid=
ows:2=3Bword-spacing:0px=3B"><a href=3D"mailto:mark@thedutchies.com">mark@t=
hedutchies.com</a></div><div style=3D"color:rgb(0=2C 0=2C 0)=3Bfont-family:=
Helvetica=3Bfont-style:normal=3Bfont-variant:normal=3Bfont-weight:normal=3B=
letter-spacing:normal=3Bline-height:normal=3Borphans:2=3Btext-align:-webkit=
-auto=3Btext-indent:0px=3Btext-transform:none=3Bwhite-space:normal=3Bwidows=
:2=3Bword-spacing:0px=3B"><a href=3D"mailto:markpo@ifi.uio.no">markpo@ifi.u=
io.no</a></div><div style=3D"color:rgb(0=2C 0=2C 0)=3Bfont-family:Helvetica=
=3Bfont-style:normal=3Bfont-variant:normal=3Bfont-weight:normal=3Bletter-sp=
acing:normal=3Bline-height:normal=3Borphans:2=3Btext-align:-webkit-auto=3Bt=
ext-indent:0px=3Btext-transform:none=3Bwhite-space:normal=3Bwidows:2=3Bword=
-spacing:0px=3B">+47 970 36 752</div>=0A=
</div>=0A=
<br><div><div>On 15 Dec 2014=2C at 14:37=2C Jan Henrik =D8verland &lt=3B<a =
href=3D"mailto:janhenrik.overland@gmail.com">janhenrik.overland@gmail.com</=

&gt=3B wrote:</div><br class=3D"ecxApple-interchange-newline"><blockquote=
<div dir=3D"ltr"><div>You can do this by using the&nbsp=3B<i>fields</i>&nb=

sp=3Bparam.</div><div><br></div>Go e.g. to&nbsp=3B<a href=3D"https://apps.d=
his2.org/dev/dhis-web-pivot" target=3D"_blank">https://apps.dhis2.org/dev/d=
his-web-pivot</a> -&gt=3B orgunit tab and have a look at the network consol=
e when you expand nodes.<div><br></div><div><br></div></div><div class=3D"e=
cxgmail_extra"><br><div class=3D"ecxgmail_quote">On Mon=2C Dec 15=2C 2014 a=
t 2:34 PM=2C Simen Skogly Russnes <span dir=3D"ltr">&lt=3B<a href=3D"mailto=
:simen_russnes@hotmail.com" target=3D"_blank">simen_russnes@hotmail.com</a>=
&gt=3B</span> wrote:<blockquote class=3D"ecxgmail_quote" style=3D"border-le=
ft:1px #ccc solid=3Bpadding-left:1ex=3B">=0A=
=0A=
=0A=
<div><div dir=3D"ltr">Dear all=2C<br><br>can someone give me a suggestion o=
n how to retrieve all orgunits through the WebAPI=2C including parent-child=
relationships of orgunits=2C so that an orgunit view can be created simila=
rly to the view in Data Entry and Individual Records in DHIS 2? Perhaps it’=
s possible to pass a parameter to api/organisationUnits so to include child=
ren or something=2C or in analytics get orgunits to include parent when pas=
sing the LEVEL-&lt=3Blevel&gt=3B parameter.<br>The query wouldn’t happen ve=
ry often in the use case=2C but a low number of requests to the WebAPI woul=
d be preferable as ping rather than bandwidth is an issue.<br><br>Regards=
=2C<br>Simen S. Russnes<br> </div></div>=0A=
<br>_______________________________________________<br>=0A=
Mailing list: <a href=3D"https://launchpad.net/~dhis2-devs" target=3D"_blan=
k">https://launchpad.net/~dhis2-devs</a><br>=0A=
Post to&nbsp=3B &nbsp=3B &nbsp=3B: <a href=3D"mailto:dhis2-devs@lists.launc=
hpad.net">dhis2-devs@lists.launchpad.net</a><br>=0A=
Unsubscribe : <a href=3D"https://launchpad.net/~dhis2-devs" target=3D"_blan=
k">https://launchpad.net/~dhis2-devs</a><br>=0A=
More help&nbsp=3B &nbsp=3B: <a href=3D"https://help.launchpad.net/ListHelp"=
target=3D"_blank">https://help.launchpad.net/ListHelp</a><br>=0A=
<br></blockquote></div></div>=0A=
_______________________________________________<br>Mailing list: <a href=3D=
https://launchpad.net/~dhis2-devs” target=3D"_blank">https://launchpad.net=
/~dhis2-devs</a><br>Post to &nbsp=3B&nbsp=3B&nbsp=3B&nbsp=3B: <a href=3D"ma=
ilto:dhis2-devs@lists.launchpad.net">dhis2-devs@lists.launchpad.net</a><br>=
Unsubscribe : <a href=3D"https://launchpad.net/~dhis2-devs" target=3D"_blan=
k">https://launchpad.net/~dhis2-devs</a><br>More help &nbsp=3B&nbsp=3B: <a =
href=3D"https://help.launchpad.net/ListHelp" target=3D"_blank">https://help=
.launchpad.net/ListHelp</a><br></blockquote></div><br></div></div> =
    </div></body>
</html>=

--_9e61f233-89b2-4af1-8ea0-c2441fc44a35_--