Hmm … I have faced the same in some extreme cases when I wanted to delete a concept, which also happens to be a member of another concept set. Its seems doable from Legacy UI, although I feel the model do not allow for deletion of concept if there are references in other tables.
Anyway, try executing the below scripts to get some idea
- If you know the “concept_id” (the numeric ID) of the concept you already deleted - then its a easy fix.
delete from concept_set where concept_id = [the numeric ID of the concept you deleted]
- Most likely, you don’t know the ID of the concept you deleted. For this, you first need to know whats the ID of the concept thats still lingering in reference of “concept_set.concept_id”.
- Identify the parent concept ID first:
select concept_id, name from concept_name where name like ‘%name of your parent concept%’
Identify the “concept_id” returned above.
- Now lets try to find out which concepts are missing in the set members of the above identified concept. To do this, fire the sql below
select cs.concept_set, cs.concept_id, cn.name from concept_set cs left outer join concept_name cn on cn.concept_id=cs.concept_id and cn.concept_name_type=‘FULLY_SPECIFIED’ and cn.locale_preferred=1 where cs.concept_set= [the concept_id you identified above]
From the above result, if you see the name column NULL, that indicates - the concept might be missing/deleted. so, verify if thats the case
select * from concept where concept_id = [ concept id from above where name is blank/null]
if the above returns no record, voila! you found the culprit … now delete the record in the concept_set table
delete from concept_set where concept_id = [ the missing concept id]
Go to openmrs and try to open the “parent” concept …