[Dhis2-devs] Remove a full level from the pyramid

2017-09-18 Thread Martin Van Aken
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

Re: [Dhis2-devs] Remove a full level from the pyramid

2017-09-18 Thread Jason Pickering
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

Re: [Dhis2-devs] Remove a full level from the pyramid

2017-09-18 Thread Martin Van Aken
Thanks. What I don't know is how the OrgUnitLevel would react - we'll need to update those too. I think they are linked through a simple number (and not a foreign key to the level table), but I may be wrong. The script you shared is about deleting all data linked to a specific org unit, right ? No

Re: [Dhis2-devs] Remove a full level from the pyramid

2017-09-18 Thread Jason Pickering
Don't worry about the level. This should be regenerated when you regenerate the path, but you better check. Otherwise, it should be pretty simple to assign this with SQL. Where the delete_orgunit_with_data function comes in may be more apparent from the following example which should move all chi

Re: [Dhis2-devs] Remove a full level from the pyramid

2017-09-18 Thread Martin Van Aken
Thanks a lot, that clarify it. When you say the level should be regenerated, is this some kind of SQL trigger or it is a check/update the app does itself on start ? I was thinking to update those manually too (does not looks like a lot). Your script is actually handy to already check any link betw

Re: [Dhis2-devs] Remove a full level from the pyramid

2017-09-18 Thread Jason Pickering
I mean that the level and path should be regenerated by DHIS2, and does not need to be generated by the SQL script. The path and level should be properties which are "figured out" by DHIS2 based on the position of the orgunit in the hierarchy. On Mon, Sep 18, 2017 at 3:42 PM, Martin Van Aken wrot