Concept deletion in Bahmni

Hi everyone… I have deleted one concept from openmrs. After that when i try to open its parent concept im getting an error

“## An error has occurred! The following error happened somewhere on this page: javax.el.ELException: Problems calling function ‘fn:length’ (The full error stack trace output is in the source of this page.)](”

What is this error meant?? and how can i solve this?? Also i cant able to edit that parent concept. Please find the attached screenshots also…

Regards MIthun g

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

  1. 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]

  1. 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, 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 …

1 Like

If you must delete a concept, then first remove them from any set (where it is also a coded value)

Hello… I have noted the numeric id of the concept which is deleted.So the first comment is worked for me… Thank you for your support…

Sure bro…In future i will take care of it… Thank you for your valuable information…