Pruning the OU hierarchy

Hi everyone,

Are there some easy ways of pruning an OrgUnit tree?

Basically, I have a number of countries with varying numbers of subnational levels, but am only interested in one of the countries. I guess in previous DHIS2 versions I could have done a detailed metadata export. What would be a quick way to prune now?

Knut

Try this

https://github.com/dhis2/dhis2-utils/blob/master/resources/sql/delete_orgunittree_with_data.sql

which will prune an entire branch of the orgunit tree.

Regards,

Jason

···

On Tue, Dec 5, 2017 at 9:07 AM, Knut Staring knutst@gmail.com wrote:

Hi everyone,

Are there some easy ways of pruning an OrgUnit tree?

Basically, I have a number of countries with varying numbers of subnational levels, but am only interested in one of the countries. I guess in previous DHIS2 versions I could have done a detailed metadata export. What would be a quick way to prune now?

Knut


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

Jason P. Pickering
email: jason.p.pickering@gmail.com
tel:+46764147049

Thanks!

···

On Tue, Dec 5, 2017 at 1:15 PM, Jason Pickering jason.p.pickering@gmail.com wrote:

Try this

https://github.com/dhis2/dhis2-utils/blob/master/resources/sql/delete_orgunittree_with_data.sql

which will prune an entire branch of the orgunit tree.

Regards,

Jason

On Tue, Dec 5, 2017 at 9:07 AM, Knut Staring knutst@gmail.com wrote:

Hi everyone,

Are there some easy ways of pruning an OrgUnit tree?

Basically, I have a number of countries with varying numbers of subnational levels, but am only interested in one of the countries. I guess in previous DHIS2 versions I could have done a detailed metadata export. What would be a quick way to prune now?

Knut


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

Jason P. Pickering
email: jason.p.pickering@gmail.com
tel:+46764147049

Knut Staring

Department of Information, Evidence and Research
World Health Organization, Geneva, Switzerland
Office: +41 22 791 3683 Mob1: +33 6 4434 2931 Mob2: +47 9188 0522
Skype: knutstar

Works nicely (I first mistakenly used organisationunitid instead of uid), except that the following part should be updated (I just removed it):

EXECUTE 'DELETE FROM programstageinstance_outboundsms WHERE programstageinstanceid IN (SELECT programstageinstanceid FROM programstageinstance WHERE organisationunitid = $1 OR programinstanceid IN (SELECT programinstanceid FROM programinstance WHERE organisationunitid = $1 OR trackedentityinstanceid IN (SELECT trackedentityinstanceid FROM trackedentityinstance WHERE organisationunitid = $1))) ’

USING organisationunitid;

···

On Tue, Dec 5, 2017 at 1:21 PM, Knut Staring knutst@gmail.com wrote:

Thanks!

On Tue, Dec 5, 2017 at 1:15 PM, Jason Pickering jason.p.pickering@gmail.com wrote:

Try this

https://github.com/dhis2/dhis2-utils/blob/master/resources/sql/delete_orgunittree_with_data.sql

which will prune an entire branch of the orgunit tree.

Regards,

Jason

Knut Staring

Department of Information, Evidence and Research
World Health Organization, Geneva, Switzerland
Office: +41 22 791 3683 Mob1: +33 6 4434 2931 Mob2: +47 9188 0522
Skype: knutstar

On Tue, Dec 5, 2017 at 9:07 AM, Knut Staring knutst@gmail.com wrote:

Hi everyone,

Are there some easy ways of pruning an OrgUnit tree?

Basically, I have a number of countries with varying numbers of subnational levels, but am only interested in one of the countries. I guess in previous DHIS2 versions I could have done a detailed metadata export. What would be a quick way to prune now?

Knut


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

Jason P. Pickering
email: jason.p.pickering@gmail.com
tel:+46764147049

Knut Staring

Department of Information, Evidence and Research
World Health Organization, Geneva, Switzerland
Office: +41 22 791 3683 Mob1: +33 6 4434 2931 Mob2: +47 9188 0522
Skype: knutstar