New Organization Units Import

Hi,

Is there any easy way(/preferred way) to import Organization Units (New ones) on blank DHIS2 system?

I have a list of organization units I like to add to the system, but like to know if there is an alternative to the individual manual add using DHIS UI.

It seems there isn¡¯t import function for this on DHIS, so I took a look at datatable for inserting straight to DB.

But, the ¡®OrganizationUnit¡¯ table has ¡®UID¡¯ field. How do I generate that? One of my data ¡®jII07NoHiO5¡¯ does seem like normal Uniquie Identifier number format.

And is this, adding rows straight to datatable, a OK way of mass importing the Organization Units on DHIS?

Do you have a structure in the data your are importing, or is it a flat list with any ou-levels? I would personally use the DHIS 2 web-api to import the data.

For examples, look at our documentation for meta-data import:

http://dhis2.org/doc/snapshot/en/user/html/ch23s04.html

So you would use something like:

···

For examples of the meta-data, have a look at:

http://apps.dhis2.org/demo/api

http://apps.dhis2.org/demo/api/metaData.xml

This can then be pushed into DHIS using your username/password, and a proper content-type (I would personally use cURL for this)


Morten

On Wed, Dec 5, 2012 at 4:20 PM, ChangJames jamesbjchang@hotmail.com wrote:

Hi,

Is there any easy way(/preferred way) to import Organization Units (New ones) on blank DHIS2 system?

I have a list of organization units I like to add to the system, but like to know if there is an alternative to the individual manual add using DHIS UI.

It seems there isn’t import function for this on DHIS, so I took a look at datatable for inserting straight to DB.

But, the ‘OrganizationUnit’ table has ‘UID’ field. How do I generate that? One of my data ‘jII07NoHiO5’ does seem like normal Uniquie Identifier number format.

And is this, adding rows straight to datatable, a OK way of mass importing the Organization Units on DHIS?


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

That should be “without any ou-levels”

···


Morten

On Wed, Dec 5, 2012 at 4:24 PM, Morten Olav Hansen mortenoh@gmail.com wrote:

Do you have a structure in the data your are importing, or is it a flat list with any ou-levels? I would personally use the DHIS 2 web-api to import the data.

For examples, look at our documentation for meta-data import:

http://dhis2.org/doc/snapshot/en/user/html/ch23s04.html

So you would use something like:

For examples of the meta-data, have a look at:

http://apps.dhis2.org/demo/api

http://apps.dhis2.org/demo/api/metaData.xml

This can then be pushed into DHIS using your username/password, and a proper content-type (I would personally use cURL for this)


Morten

On Wed, Dec 5, 2012 at 4:20 PM, ChangJames jamesbjchang@hotmail.com wrote:

Hi,

Is there any easy way(/preferred way) to import Organization Units (New ones) on blank DHIS2 system?

I have a list of organization units I like to add to the system, but like to know if there is an alternative to the individual manual add using DHIS UI.

It seems there isn’t import function for this on DHIS, so I took a look at datatable for inserting straight to DB.

But, the ‘OrganizationUnit’ table has ‘UID’ field. How do I generate that? One of my data ‘jII07NoHiO5’ does seem like normal Uniquie Identifier number format.

And is this, adding rows straight to datatable, a OK way of mass importing the Organization Units on DHIS?


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

Hi,

Populating the organisationunit table directly in the database is an OK approach when starting from scratch yes, at least on alternative approach to the web-api approach Morten suggested.

The UID field you can leave blank and then DHIS will automatically populate missing UIDs on next DHIS startup as part of the startup routines.

It can be a bit of a challenge to populate the parentid field. You need to make sure those parentids actually make up your hierarchy, so that the correct orgunits are linked.

The internal id, organisationunitid should be populated using the nextval(‘hibernate_sequence’) function in postgres to avoid duplicates.

Ola

···

Ola Hodne Titlestad (Mr)
HISP
Department of Informatics
University of Oslo

Mobile: +47 48069736
Home address: Eftasåsen 68, 0687 Oslo, Norway. Googlemaps link

On 5 December 2012 14:20, ChangJames jamesbjchang@hotmail.com wrote:

Hi,

Is there any easy way(/preferred way) to import Organization Units (New ones) on blank DHIS2 system?

I have a list of organization units I like to add to the system, but like to know if there is an alternative to the individual manual add using DHIS UI.

It seems there isn’t import function for this on DHIS, so I took a look at datatable for inserting straight to DB.

But, the ‘OrganizationUnit’ table has ‘UID’ field. How do I generate that? One of my data ‘jII07NoHiO5’ does seem like normal Uniquie Identifier number format.

And is this, adding rows straight to datatable, a OK way of mass importing the Organization Units on DHIS?


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

I tend to use an approach similar to Morten but this does involve getting data into an xml format which is not something that users will necessarily have the background or tooling to easily do,

Most of this data seems to be available in spreadsheet format most typically Excel. Unfortunately that’s where the similarity ends. Everywhere has a different spreadsheet layout. I did develop what I thought might be a “standard” excel layout some time back which I could import into dhis. I would need to try and find it again. Assuming users would find it easier to transform data within excel (using techniques of cut and paste and rearrange) to get the data into some sort of standard sheet then this would be a feasible general approach.

···

On 5 December 2012 13:29, Ola Hodne Titlestad olati@ifi.uio.no wrote:

Hi,

Populating the organisationunit table directly in the database is an OK approach when starting from scratch yes, at least on alternative approach to the web-api approach Morten suggested.

The UID field you can leave blank and then DHIS will automatically populate missing UIDs on next DHIS startup as part of the startup routines.

It can be a bit of a challenge to populate the parentid field. You need to make sure those parentids actually make up your hierarchy, so that the correct orgunits are linked.

The internal id, organisationunitid should be populated using the nextval(‘hibernate_sequence’) function in postgres to avoid duplicates.

Ola



Ola Hodne Titlestad (Mr)
HISP
Department of Informatics
University of Oslo

Mobile: +47 48069736
Home address: Eftasåsen 68, 0687 Oslo, Norway. Googlemaps link

On 5 December 2012 14:20, ChangJames jamesbjchang@hotmail.com wrote:

Hi,

Is there any easy way(/preferred way) to import Organization Units (New ones) on blank DHIS2 system?

I have a list of organization units I like to add to the system, but like to know if there is an alternative to the individual manual add using DHIS UI.

It seems there isn’t import function for this on DHIS, so I took a look at datatable for inserting straight to DB.

But, the ‘OrganizationUnit’ table has ‘UID’ field. How do I generate that? One of my data ‘jII07NoHiO5’ does seem like normal Uniquie Identifier number format.

And is this, adding rows straight to datatable, a OK way of mass importing the Organization Units on DHIS?


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


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

OK found it. This was actually working back in DHIS2.04 but I long since forgot about it (https://lists.launchpad.net/dhis2-devs/msg06490.html),

Would need to change a few things to get this working again as quite a lot has changed between then and now. But the attached is an example of how it looked then.

orgunits.xlsx (115 KB)

···

On 5 December 2012 13:48, Bob Jolliffe bobjolliffe@gmail.com wrote:

I tend to use an approach similar to Morten but this does involve getting data into an xml format which is not something that users will necessarily have the background or tooling to easily do,

Most of this data seems to be available in spreadsheet format most typically Excel. Unfortunately that’s where the similarity ends. Everywhere has a different spreadsheet layout. I did develop what I thought might be a “standard” excel layout some time back which I could import into dhis. I would need to try and find it again. Assuming users would find it easier to transform data within excel (using techniques of cut and paste and rearrange) to get the data into some sort of standard sheet then this would be a feasible general approach.

On 5 December 2012 13:29, Ola Hodne Titlestad olati@ifi.uio.no wrote:

Hi,

Populating the organisationunit table directly in the database is an OK approach when starting from scratch yes, at least on alternative approach to the web-api approach Morten suggested.

The UID field you can leave blank and then DHIS will automatically populate missing UIDs on next DHIS startup as part of the startup routines.

It can be a bit of a challenge to populate the parentid field. You need to make sure those parentids actually make up your hierarchy, so that the correct orgunits are linked.

The internal id, organisationunitid should be populated using the nextval(‘hibernate_sequence’) function in postgres to avoid duplicates.

Ola



Ola Hodne Titlestad (Mr)
HISP
Department of Informatics
University of Oslo

Mobile: +47 48069736
Home address: Eftasåsen 68, 0687 Oslo, Norway. Googlemaps link

On 5 December 2012 14:20, ChangJames jamesbjchang@hotmail.com wrote:

Hi,

Is there any easy way(/preferred way) to import Organization Units (New ones) on blank DHIS2 system?

I have a list of organization units I like to add to the system, but like to know if there is an alternative to the individual manual add using DHIS UI.

It seems there isn’t import function for this on DHIS, so I took a look at datatable for inserting straight to DB.

But, the ‘OrganizationUnit’ table has ‘UID’ field. How do I generate that? One of my data ‘jII07NoHiO5’ does seem like normal Uniquie Identifier number format.

And is this, adding rows straight to datatable, a OK way of mass importing the Organization Units on DHIS?


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


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

We definitely need to be able to import both metadata and data from Excel (.xlsx) templates, a kind of user friendly data loading mechanism. It’s something that has been talked about for years, but never prioritized.

The importing of data also requires functionality like HISP South Africa’s AntiPivot tool for normalization of matrices.

Knut

···

On 5 December 2012 13:48, Bob Jolliffe bobjolliffe@gmail.com wrote:

I tend to use an approach similar to Morten but this does involve getting data into an xml format which is not something that users will necessarily have the background or tooling to easily do,

Most of this data seems to be available in spreadsheet format most typically Excel. Unfortunately that’s where the similarity ends. Everywhere has a different spreadsheet layout. I did develop what I thought might be a “standard” excel layout some time back which I could import into dhis. I would need to try and find it again. Assuming users would find it easier to transform data within excel (using techniques of cut and paste and rearrange) to get the data into some sort of standard sheet then this would be a feasible general approach.

On 5 December 2012 13:29, Ola Hodne Titlestad olati@ifi.uio.no wrote:

Hi,

Populating the organisationunit table directly in the database is an OK approach when starting from scratch yes, at least on alternative approach to the web-api approach Morten suggested.

The UID field you can leave blank and then DHIS will automatically populate missing UIDs on next DHIS startup as part of the startup routines.

It can be a bit of a challenge to populate the parentid field. You need to make sure those parentids actually make up your hierarchy, so that the correct orgunits are linked.

The internal id, organisationunitid should be populated using the nextval(‘hibernate_sequence’) function in postgres to avoid duplicates.

Ola



Ola Hodne Titlestad (Mr)
HISP
Department of Informatics
University of Oslo

Mobile: +47 48069736
Home address: Eftasåsen 68, 0687 Oslo, Norway. Googlemaps link

On 5 December 2012 14:20, ChangJames jamesbjchang@hotmail.com wrote:

Hi,

Is there any easy way(/preferred way) to import Organization Units (New ones) on blank DHIS2 system?

I have a list of organization units I like to add to the system, but like to know if there is an alternative to the individual manual add using DHIS UI.

It seems there isn’t import function for this on DHIS, so I took a look at datatable for inserting straight to DB.

But, the ‘OrganizationUnit’ table has ‘UID’ field. How do I generate that? One of my data ‘jII07NoHiO5’ does seem like normal Uniquie Identifier number format.

And is this, adding rows straight to datatable, a OK way of mass importing the Organization Units on DHIS?


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


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

Thank you all for the help. They were quite helpful.

I have tried both database method and cURL Meta-data import.

The database method was successful, using ‘nextval(‘hibernate_sequence’)’ and restart of DHIS2 for UID auto populate.

However, I am still struggling with cURL method.

I have downloaded curl.exe and ran it (in Windows 7).

I keep on getting ‘HTTP Status 405 – Request method ‘POST’ not supported’ error.

Is there something I have to set on DHIS2 or on server for this?

The command I used is –> curl –d @test3.xmlhttp://107.—.—.—:8080/dhis/api/organizationUnits” –H “Content-Type:application/xml” –u —/— -v

This is for adding a new OrganizationUnit. In this email, I have attached curl error output and test Meta-data xml files.

I have tried variations of the curl commands (removing header parameters, etc) and variations of Meta-data xml file contents(adding/removing UID, ID, etc), but all gave me 405 error.

If it is not about the DHIS2 setup issue, I was wondering if someone can provide me with any success case curl command and Meta-data xml file, so that I can use that was an example to follow.

Thank you in advance for any help.

Export_SierraLeone2.xml (600 Bytes)

test3.xml (311 Bytes)

image

···

From: Morten Olav Hansen

Sent: Wednesday, December 05, 2012 10:25 PM

To: ChangJames

Cc: dhis2-users

Subject: Re: [Dhis2-users] New Organization Units Import

That should be “without any ou-levels”


Morten

On Wed, Dec 5, 2012 at 4:24 PM, Morten Olav Hansen mortenoh@gmail.com wrote:

Do you have a structure in the data your are importing, or is it a flat list with any ou-levels? I would personally use the DHIS 2 web-api to import the data.

For examples, look at our documentation for meta-data import:

http://dhis2.org/doc/snapshot/en/user/html/ch23s04.html

So you would use something like:

For examples of the meta-data, have a look at:

http://apps.dhis2.org/demo/api

http://apps.dhis2.org/demo/api/metaData.xml

This can then be pushed into DHIS using your username/password, and a proper content-type (I would personally use cURL for this)


Morten

On Wed, Dec 5, 2012 at 4:20 PM, ChangJames jamesbjchang@hotmail.com wrote:

Hi,

Is there any easy way(/preferred way) to import Organization Units (New ones) on blank DHIS2 system?
I have a list of organization units I like to add to the system, but like to know if there is an alternative to the individual manual add using DHIS UI.
It seems there isn’t import function for this on DHIS, so I took a look at datatable for inserting straight to DB.
But, the ‘OrganizationUnit’ table has ‘UID’ field.  How do I generate that?  One of my data ‘jII07NoHiO5    ’ does seem like normal Uniquie Identifier number format.
And is this, adding rows straight to datatable, a OK way of mass importing the Organization Units on DHIS?

Mailing list: [https://launchpad.net/~dhis2-users](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

Hi,

Writing is not supported for /api/organisationUnits (sorry, that might not have been clear). Try and push the XML to /api/metaData

···


Morten

On Wed, Dec 12, 2012 at 11:25 AM, ChangJames jamesbjchang@hotmail.com wrote:

Thank you all for the help. They were quite helpful.

I have tried both database method and cURL Meta-data import.

The database method was successful, using ‘nextval(‘hibernate_sequence’)’ and restart of DHIS2 for UID auto populate.

However, I am still struggling with cURL method.

I have downloaded curl.exe and ran it (in Windows 7).

I keep on getting ‘HTTP Status 405 – Request method ‘POST’ not supported’ error.

Is there something I have to set on DHIS2 or on server for this?

The command I used is –> curl –d @test3.xmlhttp://107.—.—.—:8080/dhis/api/organizationUnits” –H “Content-Type:application/xml” –u —/— -v

This is for adding a new OrganizationUnit. In this email, I have attached curl error output and test Meta-data xml files.

I have tried variations of the curl commands (removing header parameters, etc) and variations of Meta-data xml file contents(adding/removing UID, ID, etc), but all gave me 405 error.

If it is not about the DHIS2 setup issue, I was wondering if someone can provide me with any success case curl command and Meta-data xml file, so that I can use that was an example to follow.

Thank you in advance for any help.

From: Morten Olav Hansen

Sent: Wednesday, December 05, 2012 10:25 PM

To: ChangJames

Cc: dhis2-users

Subject: Re: [Dhis2-users] New Organization Units Import

That should be “without any ou-levels”


Morten

On Wed, Dec 5, 2012 at 4:24 PM, Morten Olav Hansen mortenoh@gmail.com wrote:

Do you have a structure in the data your are importing, or is it a flat list with any ou-levels? I would personally use the DHIS 2 web-api to import the data.

For examples, look at our documentation for meta-data import:

http://dhis2.org/doc/snapshot/en/user/html/ch23s04.html

So you would use something like:

For examples of the meta-data, have a look at:

http://apps.dhis2.org/demo/api

http://apps.dhis2.org/demo/api/metaData.xml

This can then be pushed into DHIS using your username/password, and a proper content-type (I would personally use cURL for this)


Morten

On Wed, Dec 5, 2012 at 4:20 PM, ChangJames jamesbjchang@hotmail.com wrote:

Hi,

Is there any easy way(/preferred way) to import Organization Units (New ones) on blank DHIS2 system?
I have a list of organization units I like to add to the system, but like to know if there is an alternative to the individual manual add using DHIS UI.
It seems there isn’t import function for this on DHIS, so I took a look at datatable for inserting straight to DB.
But, the ‘OrganizationUnit’ table has ‘UID’ field.  How do I generate that?  One of my data ‘jII07NoHiO5    ’ does seem like normal Uniquie Identifier number format.
And is this, adding rows straight to datatable, a OK way of mass importing the Organization Units on DHIS?

Mailing list: [https://launchpad.net/~dhis2-users](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

Yes that way does work. You can try a GET first on an instance, eg

http://apps.dhis2.org/dev/api/metaData.xml?assumeTrue=false&organisationUnits=true

so you can check the required format.

Bob

···

On 12 December 2012 09:27, Morten Olav Hansen mortenoh@gmail.com wrote:

Hi,

Writing is not supported for /api/organisationUnits (sorry, that might not have been clear). Try and push the XML to /api/metaData


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


Morten

On Wed, Dec 12, 2012 at 11:25 AM, ChangJames jamesbjchang@hotmail.com wrote:

Thank you all for the help. They were quite helpful.

I have tried both database method and cURL Meta-data import.

The database method was successful, using ‘nextval(‘hibernate_sequence’)’ and restart of DHIS2 for UID auto populate.

However, I am still struggling with cURL method.

I have downloaded curl.exe and ran it (in Windows 7).

I keep on getting ‘HTTP Status 405 – Request method ‘POST’ not supported’ error.

Is there something I have to set on DHIS2 or on server for this?

The command I used is –> curl –d @test3.xmlhttp://107.—.—.—:8080/dhis/api/organizationUnits” –H “Content-Type:application/xml” –u —/— -v

This is for adding a new OrganizationUnit. In this email, I have attached curl error output and test Meta-data xml files.

I have tried variations of the curl commands (removing header parameters, etc) and variations of Meta-data xml file contents(adding/removing UID, ID, etc), but all gave me 405 error.

If it is not about the DHIS2 setup issue, I was wondering if someone can provide me with any success case curl command and Meta-data xml file, so that I can use that was an example to follow.

Thank you in advance for any help.

From: Morten Olav Hansen

Sent: Wednesday, December 05, 2012 10:25 PM

To: ChangJames

Cc: dhis2-users

Subject: Re: [Dhis2-users] New Organization Units Import

That should be “without any ou-levels”


Morten

On Wed, Dec 5, 2012 at 4:24 PM, Morten Olav Hansen mortenoh@gmail.com wrote:

Do you have a structure in the data your are importing, or is it a flat list with any ou-levels? I would personally use the DHIS 2 web-api to import the data.

For examples, look at our documentation for meta-data import:

http://dhis2.org/doc/snapshot/en/user/html/ch23s04.html

So you would use something like:

For examples of the meta-data, have a look at:

http://apps.dhis2.org/demo/api

http://apps.dhis2.org/demo/api/metaData.xml

This can then be pushed into DHIS using your username/password, and a proper content-type (I would personally use cURL for this)


Morten

On Wed, Dec 5, 2012 at 4:20 PM, ChangJames jamesbjchang@hotmail.com wrote:

Hi,

Is there any easy way(/preferred way) to import Organization Units (New ones) on blank DHIS2 system?
I have a list of organization units I like to add to the system, but like to know if there is an alternative to the individual manual add using DHIS UI.
It seems there isn’t import function for this on DHIS, so I took a look at datatable for inserting straight to DB.
But, the ‘OrganizationUnit’ table has ‘UID’ field.  How do I generate that?  One of my data ‘jII07NoHiO5    ’ does seem like normal Uniquie Identifier number format.
And is this, adding rows straight to datatable, a OK way of mass importing the Organization Units on DHIS?

Mailing list: [https://launchpad.net/~dhis2-users](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