How do I create an XForms search field for CIEL dictionary diagnoses?

Platform Version: 1.11.3 OpenMRS Version: 2.2

Question: Hello,

I am trying to create a text box able to search all the diagnosis of the CIEL dictionary. In order to do this, I am writing the following in the text box in Xforms:

External Source: select distinct, concat(cn.concept_id,concat(concat(’^’,name),’^99DCT’)) as concept_id from concept_name cn inner join concept c on c.concept_id=cn.concept_id where class_id=4 Value Field: concept_id Display Field: name

When I am searching throughout “Finding” and therefore I use class_id=5, I can found all the correct concepts. However, using class_id=4 and therefore looking for “Diagnosis”, nothing appears. I think it is probably because there are too many concepts within the class “Diagnosis”.

Am I doing something wrong? Any better solution for achieve this?

Any help would be really appreciated.

1 Like

While in the form designer, select “save as” from the file menu. Then paste the contents of the saved file at

Thank you very much for your help.

There it is:

Are you able to search for them here?


It works perfectly. I created a form called “Xforms_searchbox_test” and I was able to search for the diagnosis using exactly what I described above.

After all, maybe the problem is exactly the huge amount of diagnosis concepts provided by the CIEL dictionary right? Is there any solution for this?

Thank you very much for your help and time.

After trying to search for the diagnosis, can you paste the log file contents at

The log file has 2 errors related with this. They are both here:

I mean the tomcat logs.


Sorry, my mistake. Got 2 errors in the tomcat log file:

Thank you, Best, Tiago

Are you sure this is all that your tomcat log file has? What is the file name?

Sorry for taking so much answering, I am not responsible for the server, so I have always to contact someone else.

What I gave to you was in the file “catalina.out”.

Anyway, I did not find anything in the logs. If you have the kindness to check for yourself, I am providing you the logs of today here: http://www.■■■■■■■■■■■■■■■/openmrs

Should be easy for you to find what you want since today I just tried to search in the searchbox 3 times (around 12h30min). I did not make anything else in OpenMRS, so the logs are quite small.

Can you try execute the same sql statement on your database and tell me how many results it returns?

We got 83029 results.

Try do the following and tell me what happens: After selecting the widget on the design surface, set the following using the Widget Properties Pane.

External Source: concept

Filter Field: Diagnosis

Do it exactly i have done here:

Lets say i have concept 123 which is diagnosis … how can you add these on the xform

in htmlformentry it would be

<obs conceptId="1296" answerClasses="Drug" style="autocomplete"/>

What is exactly what Tiago Silva is doing.

Thank you very much. Using those parameters, it works fine.

I am very grateful that you spent so much time and effort helping me.

Tiago could you please post the updated code that worked for you



I just used what Daniel recommended in a post above:

External Source: concept Filter Field: Diagnosis

It worked for me.

Can you filter by concept ID or uuid in the filter class?