← Back to team overview

dhis2-devs team mailing list archive

Re: Remove a full level from the pyramid

 

Hi Martin,

I  do not think we  have anything specifically for that, but I think you
could write a short script

1) Reassign the direct descendants of the level you want to remove to the
desired level.  This could be done through the API or SQL I guess.
2) Use this script
<https://github.com/dhis2/dhis2-utils/blob/master/resources/sql/delete_orgunit_with_data.sql>
to
remove the level. You would need to loop through all of the levels to
remove of course.
3) Clear the cache and rebuild the orgunit paths.

Regards,
Jason


On Mon, Sep 18, 2017 at 1:22 PM, Martin Van Aken <martin@xxxxxxxxxxxxxxxx>
wrote:

> Hello,
> We have a DHIS2 instance we support that already has data (Health Pyramid,
> Data Elements, DataValues). The system takes into account a level that is
> actually not used by most people and more importantly not by systems we
> need to integrate with.
>
> On a business side, it make sense removing it altogether - I'm wondering
> if someone already did something like that and how ?
>
> I can imagine something such as (supposing last level is 4 and we remove
> level 3):
>
> - Check any data linked to Org Unit of level 3 and backup/delete
> - Reattach all org unit of level 4 to their grand parent (level 2)
> - Delete level 3 entities
> - Regenerate or update the level 4 to 3
>
> I suppose this would be easier done in the DB than with the API.
>
> Anyone with experience or advice on a process like that ?
>
> Thanks,
>
> Martin
>
> --
> *Martin Van Aken - **Freelance Enthusiast Developer*
>
> Mobile : +32 486 899 652
>
> Follow me on Twitter : @martinvanaken <http://twitter.com/martinvanaken>
> Call me on Skype : vanakenm
> Hang out with me : martin@xxxxxxxxxxxxxxxx
> Contact me on LinkedIn : http://www.linkedin.com/in/martinvanaken
> Company website : www.joyouscoding.com
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-devs
> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dhis2-devs
> More help   : https://help.launchpad.net/ListHelp
>
>


-- 
Jason P. Pickering
email: jason.p.pickering@xxxxxxxxx
tel:+46764147049

Follow ups

References