← Back to team overview

dhis2-users team mailing list archive

Re: HOW TO DELETE AN ENTITY IN TRACKER CAPTURE

 

Hi Stanley,
To add on to what Abyot - if you are doing it via sql statements then the
following tables might also have been populated:

trackedentityaudit
trackedentitydatavalueaudit
trackedentityattributevalueaudit
programstageinstance_messageconversation
programstageinstancecomments

and would need to be cleaned up otherwise you will hit foreign key
constraints.

I would think it would be a lot easier to update the organisationunit id in
the following tables:

Programstageinstance
Programinstance
Trackedentityinstance

and the sql statement would be something like:

update programstageinstance
set organisationunitid = nnnnnnnn (new orgunit's internal id)
where organisationunitid = nnnnnnn (current orgunit's internal id)
*(this will move all the trackerdata from the current orgunit to the new
orgunit)*

and

exactly the same for programinstance and trackedentityinstance.

Afterwards you would have to clear cache and re-run analytics

Regards

Ant

On 3 November 2016 at 11:57, Abyot Asalefew Gizaw <abyot@xxxxxxxxx> wrote:

> I don't have ready made statements at hand.
>
> But here is what you need to do - FOR THE TRACKED ENTITY INSTANCE in
> question
>
>    1. Delete event values from trackedentitydatavalue
>    2. Delete events from programstageinstance
>    3. Delete enrollments from programinstance
>    4. Delete attribute values from trackedentityattributevalue
>    5. Delete the instance from trackedentityinstance
>
> More on the associations:
>
> trackedentityinstance uid -> trackedentityinstance id -> programinstance
> id -> programstageinstance id
>
> --
> Abyot A. Gizaw.
> Senior Engineer, DHIS2
> University of Oslo
> http://www.dhis2.org
>
> On Thu, Nov 3, 2016 at 10:27 AM, Stanley Kalyati <skalyati@xxxxxxxxx>
> wrote:
>
>> Abyot,
>>
>> Could you help with the sql statements?
>>
>> Thanks in advance.
>>
>> Stanley
>>
>> On Thu, Nov 3, 2016 at 11:22 AM, Abyot Asalefew Gizaw <abyot@xxxxxxxxx>
>> wrote:
>>
>>> Hi Stanley,
>>>
>>> It is only version 2.25 that has UI support for deleting Tracked Entity
>>> Instance. For the other versions, one has to do it manually using sql
>>> statements.
>>>
>>> --
>>> Abyot A. Gizaw.
>>> Senior Engineer, DHIS2
>>> University of Oslo
>>> http://www.dhis2.org
>>>
>>> On Thu, Nov 3, 2016 at 10:16 AM, Stanley Kalyati <skalyati@xxxxxxxxx>
>>> wrote:
>>>
>>>> Colleagues,
>>>>
>>>> My colleague entered a tracked entity in a wrong OU and i want to
>>>> delete that.Can someone tell me how to delete this entity? or move this
>>>> entity to another OU.
>>>>
>>>> You usual support is always appreciated.
>>>>
>>>> Stanley
>>>>
>>>>
>>>> _______________________________________________
>>>> Mailing list: https://launchpad.net/~dhis2-users
>>>> Post to     : dhis2-users@xxxxxxxxxxxxxxxxxxx
>>>> Unsubscribe : https://launchpad.net/~dhis2-users
>>>> More help   : https://help.launchpad.net/ListHelp
>>>>
>>>>
>>>
>>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-users
> Post to     : dhis2-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dhis2-users
> More help   : https://help.launchpad.net/ListHelp
>
>


-- 

*Ant Snyman*

*Cell: 0824910449*

*Landline: 028 2713242*


Health Information Systems Program - SA

-- 


*This message and any attachments are subject to a disclaimer published at 
http://www.hisp.org/policies.html#comms_disclaimer 
<http://www.hisp.org/policies.html#comms_disclaimer>.  Please read the 
disclaimer before opening any attachment or taking any other action in 
terms of this electronic transmission.  If you cannot access the 
disclaimer, kindly send an email to disclaimer@xxxxxxxx 
<disclaimer@xxxxxxxx> and a copy will be provided to you. By replying to 
this e-mail or opening any attachment you agree to be bound by the 
provisions of the disclaimer.*

References