Re: [Dhis2-devs] Problem creating the parent org unit through the API

2016-05-25 Thread Knut Staring
Thanks Bob, very useful indeed. I guess we should all have a closer look at what is shared here: https://github.com/dhis2/dhis2-utils Including your function: https://github.com/dhis2/dhis2-utils/blob/master/resources/sql/uid.sql On Wed, May 25, 2016 at 2:14 PM, Bob Jolliffe wrote: > If you hav

Re: [Dhis2-devs] Problem creating the parent org unit through the API

2016-05-25 Thread Sergio Valenzuela
Yeah Bob, our source data is in postgresql so this is indeed very handy. Thanks a lot! *Sergio Valenzuela* Fundación EHAS Telemedicina para países en desarrollo -* www.ehas.org * E.T.S.I. de Telecomunicación A.101-9L. Ciudad Universitaria 30, 28040 Madrid - España Tlfno. (+

Re: [Dhis2-devs] Problem creating the parent org unit through the API

2016-05-25 Thread Bob Jolliffe
If you have your source data in postgresql, you can also use the following handy function to generate uids directly from the database: CREATE OR REPLACE FUNCTION uid() RETURNS text AS $$ SELECT substring('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' FROM (random()*51)::int +1 for 1

Re: [Dhis2-devs] Problem creating the parent org unit through the API

2016-05-25 Thread Sergio Valenzuela
I wanted to avoid the level by level option because I thought there has to be an easier way to do it. And there is! I'll go with the UID generation like both of you suggested me. Thanks for your advice! El 25/5/2016 14:01, "Jason Pickering" escribió: > Hi Sergio, > The easier way to do this is to

Re: [Dhis2-devs] Problem creating the parent org unit through the API

2016-05-25 Thread Jason Pickering
Hi Sergio, The easier way to do this is to generate the UID prior to importing everything. You can do this pretty easily with the system with the following command https://play.dhis2.org/demo/api/system/uid?limit=3 Or they can be generated externally pretty easily. Here is some R code , but I am

Re: [Dhis2-devs] Problem creating the parent org unit through the API

2016-05-25 Thread Morten Olav Hansen
Hi Sergio You have a couple of options, you can switch to using "code", which can basically be anything. Another option is to simply generate the parent UIDs beforehand using /api/system/id?limit=X http://dhis2.github.io/dhis2-docs/master/en/developer/html/ch01s39.html#d0e9612 -- Morten Olav H

Re: [Dhis2-devs] Problem creating the parent org unit through the API

2016-05-25 Thread Sergio Valenzuela
Thanks Morten, yes, we were trying to create a new root and we were missing that step. My question now is: In the "parent" object included in "organisationUnits", is it possible to swap the attribute "id" to "name" (or something you know when you are creating the parents)? Otherwise, how can be do

Re: [Dhis2-devs] Problem creating the parent org unit through the API

2016-05-25 Thread Morten Olav Hansen
Hi Sergio So you are creating a new root? Could it be that your user is attached to a different org unit, and so the problem is that you can't see them? Maybe you could verify in the database, or using the web-api? /api/organisationUnits.json?filter=name:like:abc -- Morten Olav Hansen Senior En

[Dhis2-devs] Problem creating the parent org unit through the API

2016-05-25 Thread Sergio Valenzuela
Hello devs, We are trying to create a whole org unit hierarchy through the new API resource /api/23/metadata . During the process, we realized there should be some kind of problem when we tried to create the parent org unit (the parent of the whole hierarchy), because even If the answer from the s