← Back to team overview

dhis2-devs team mailing list archive

Re: DELETING FACILITIES WITH DATA FROM THE DHIS

 

Yes, i did indeed overlook the native DHIS2 function, which Lars mentioned.
Its good its there and supported by the core code. It was not there when I
needed this function though.

It may be useful however to perform this operation via SQL in certain cases
however. This function , and hopefully the one from the Java side, was
developed specifically to be generic, only accepting a single paramater,
the UID of the orgunit to delete. So, if you have other criteria (start
date/end date, includeDescendants=true), you would need to feed both
functions the UIDs of these sites in the proper manner. If there are
children, the function will abort, as one could imagine a situation where
you provide the function the UID of the root orgunit, and it would proceed
to delete everything. So, its been made more with an atttempt to allow you
to delete a site, but not entire branches at the same time, which could be
easily achieved by simply calling the function multiple times in the
correct order of sites to delete.

The other reason for having it, is it is used by the "merge_orgunits.sql
<https://github.com/dhis2/dhis2-utils/blob/master/resources/sql/merge_orgunits.sql>",
which will perform the operation of merging orgunits (which was removed
from the core for the time bering). Once the data has been merged
(according to some strategies like MIN, MAX, LATEST, etc)  the site to be
removed will be deleted with this "delete_site_with_data.sql".

Regards,
Jason


On Thu, Apr 14, 2016 at 2:09 AM, Calle Hedberg <calle.hedberg@xxxxxxxxx>
wrote:

> Lars,
>
> Bugger! - I had overlooked that (and maybe Jason too?). But just to
> confirm - that dataPruning api call in reality works exactly like the pg
> function shared by Jason?
>
> Otherwise - very nice to see that has been included. I've had some
> sessions deleting duplicated OrgUnits that have been embedded all over the
> place, and it can be a pain in the b... to track down all the bits and
> pieces
>
> Regards
> Calle
>
> On 13 April 2016 at 16:53, Lars Helge Øverland <lars@xxxxxxxxx> wrote:
>
>> Hi Mohamed,
>>
>> in 2.22 we introduced a Web API feature for forcing delete of
>> organisation units:
>>
>> http://dhis2.github.io/dhis2-docs/master/en/developer/html/ch01s38.html
>>
>> So if you are able to send a POST request to the following URL if will
>> remove related data/completeness/approval records.
>>
>> regards,
>>
>> Lars
>>
>>
>> Data pruning will remove complete data set registrations, data approvals,
>> data value audits and data values, in this case for an organisation unit.
>>
>> /api/maintenance/dataPruning/organisationUnits/<org-unit-id>
>>
>>
>>
>>
>> On Wed, Apr 13, 2016 at 1:24 PM, Mohamed Bangura <mbangs87@xxxxxxxxx>
>> wrote:
>>
>>> Hi all,
>>>
>>> We are currently trying to delete old facilities from our main server
>>> but nothing seems to be happening since these facilities already have
>>> data.Is there a way one can do this or disable the facilities as this
>>> is currently affecting the completeness of our data.
>>>
>>> I need your help please.
>>>
>>> _______________________________________________
>>> 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
>>>
>>
>>
>>
>> --
>> Lars Helge Øverland
>> Lead developer, DHIS 2
>> University of Oslo
>> Skype: larshelgeoverland
>> http://www.dhis2.org <https://www.dhis2.org/>
>>
>>
>> _______________________________________________
>> 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
>>
>>
>
>
> --
>
> *******************************************
>
> Calle Hedberg
>
> 46D Alma Road, 7700 Rosebank, SOUTH AFRICA
>
> Tel/fax (home): +27-21-685-6472
>
> Cell: +27-82-853-5352
>
> Iridium SatPhone: +8816-315-19119
>
> Email: calle.hedberg@xxxxxxxxx
>
> Skype: calle_hedberg
>
> *******************************************
>
>
> _______________________________________________
> 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