← Back to team overview

dhis2-devs team mailing list archive

Re: In DHIS 2.27 Issues with deleting organisation unit

 

Thanks Jason,

Since we just have data values for the organisation units (which should be
deleted), we are able to remove them after clearing the data associated
with them using /api/maintenance/dataPruning/organisationUnits API.

Thanks,
Jhansi

On Fri, Dec 15, 2017 at 11:51 AM, Jason Pickering <
jason.p.pickering@xxxxxxxxx> wrote:

> It might work for you, but I am not 100% sure if that API endpoint will
> clear out everything. As you can  see from the SQL function, orgunits may
> also have other dependencies, like pivots, charts, user associations, etc.
> The deletion handler for orgunits may refuse to remove it,  if the object
> is associated with other objects.
>
> It might work in your case, but may not.
>
> Good luck,
> Jason
>
>
> On Fri, Dec 15, 2017 at 7:14 AM, Jhansi Reddy Karee <
> jhansirk@xxxxxxxxxxxxxxxx> wrote:
>
>> Thanks for the quick reply Jason,
>>
>> In DHIS documentation
>> <https://docs.dhis2.org/2.27/en/developer/html/webapi_maintenance.html>,
>> we came across a WEB API which can clear all the data of the organisation
>> unit.
>>
>> /api/26/maintenance/dataPruning/organisationUnits/<org-unit-id>
>>
>> API Details: Data pruning will remove complete data set registrations,
>> data approvals, data value audits and data values, in this case of an
>> organisation unit.
>>
>> We are expecting that this API will clear all the data of the given
>> organisation unit and any data/approvals of its parent organisation units
>> will be untouched. Is our expectation correct?
>>
>> Do you see any problem with deleting data for the organisation unit using
>> this API.
>>
>> Thanks,
>> Jhansi
>>
>> On Thu, Dec 14, 2017 at 9:12 PM, Jason Pickering <
>> jason.p.pickering@xxxxxxxxx> wrote:
>>
>>> Hi Jhansi,
>>> You will also need to get rid of the data in the data value audit table.
>>>
>>> Here is an SQL function which might work for you.
>>>
>>> https://github.com/dhis2/dhis2-utils/blob/master/resources/s
>>> ql/delete_orgunit_with_data.sql
>>>
>>> Regards,
>>> Jason
>>>
>>>
>>> On Thu, Dec 14, 2017 at 2:49 PM, Jhansi Reddy Karee <
>>> jhansirk@xxxxxxxxxxxxxxxx> wrote:
>>>
>>>> Hello Team,
>>>>
>>>>
>>>> In DHIS 2.27, we are not able to delete an organisation unit after
>>>> deleting all the data associated to it.
>>>>
>>>>
>>>> Following are the steps we have followed to do this:
>>>>
>>>>    -
>>>>
>>>>    Delete all the data associated to the organisation unit
>>>>    -
>>>>
>>>>    In Data administration app, under maintenance, we have performed
>>>>    maintenance over “Permanently remove soft deleted data values”.
>>>>    -
>>>>
>>>>    Tried deleting the organisation unit. But, we are getting the
>>>>    following error: Could not delete due to association with another object:
>>>>    DataValueAudit
>>>>
>>>>
>>>> Please let us know if we have missed anything.
>>>>
>>>>
>>>> Thanks,
>>>>
>>>> Jhansi
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> 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 <076-414%2070%2049>
>>>
>>
>>
>
>
> --
> Jason P. Pickering
> email: jason.p.pickering@xxxxxxxxx
> tel:+46764147049
>

References