Issue deleting organisation unit and programs

Hi, we’ve been facing issues while deleting organisation unit and programs even after clearing all the associated data values. How to resolve this? Would be helpful if someone can give us idea about the structure and related dependencies.
I’ve attached a screenshot for reference where JHK is one of the organisation unit we’re trying to delete but can’t (there are no values associated to tracked entity).
Thank You

Deleting data and orgunits is probably the more difficult task in dhis2.
Since audit/users/dashboards/… and tons of other table might refer to orgunits.

If you deleted the datavalues/events through the ui of dhis2, it’s actually just soft deleted. The message show says “you still have tracked entity instances” referencing this orgunit (due to the soft delete )

Usually it’s advised to keep the data and just “soft delete” the orgunit by providing a closed date.

If you really want to delete the data and have access to the database, then perhaps you can try