Search concepts by concept class via REST

In radiology, before you add an order you first need to set the Radiology Concept Classes global property which is a comma separated list of concept class UUIDs which define concepts that are orderable as radiology orders.

I have added the UUID of the Test concept class to that global property as shown by

and

I have created one concept of the concept class Test with name X-RAY.

When creating a an order. An imaging procedure is is asked which is a concept. If I use a query string like ‘X-RAY’ only one concept is been returned as expected.

When I do a search with other queries like ‘Tr’ or ‘True’ I get no result as expected.

But when I visit http://localhost:8080/openmrs/module/webservices/rest/apiDocs.htm#!/concept/getConcept

And make a get to /openmrs/ws/rest/v1/concept with the class param set to the UUID of the Test concept class and a search query of Tr, I actually get multiple results of which the concept True is one of them. I didn’t expect this. I expected it to behave like radiology add order form and return no result.

I’m trying to reimplement the add order form via angular2 and I’m searching for this concept via REST and I want it to behave exactly like the radiology add order form.

Below is the result of the search results from my angular app running on the same openmrs platform as above

I expected no results. That’s the same behavior I get when I try to do the same via the http://localhost:8080/openmrs/module/webservices/rest/apiDocs.htm

Below is the code in legacyui that handles that

 <tr>
    <td><spring:message code="radiology.imagingProcedure" /><span class="required">*</span></td>
    <td><spring:bind path="concept">
        <openmrs_tag:conceptField formFieldName="concept" formFieldId="conceptId"
          initialValue="${status.editor.value.conceptId}" onSelectFunction="onQuestionSelect"
          includeClasses="${radiologyConceptClassNames}" />
      </spring:bind> <form:errors path="concept" cssClass="error" />
      <div class="description" id="conceptDescription"></div></td>
  </tr>

We’ll not be using that and I don’t have the time to go through the openmrs_tag internals just to understand how to do this.

I found this thread Searching for orderable concepts via REST which led me to https://github.com/openmrs/openmrs-module-webservices.rest/commit/850202b434bcb5797625b6252e9a4d8f8f576b04

Which talks of a new OrderableResource but it’s not clear how to use that and I don’t see any orderable endpoint in

http://localhost:8080/openmrs/module/webservices/rest/apiDocs.htm

My server is setup via SDK for Platform 2.0.5 and it’s running Rest Web Services OMOD 2.19.0.f2b4a2

cc @teleivo

I think there are two ways to search for concepts by class:

  1. Use the conceptsearch resource with a conceptClasses query parameter. (This returns ConceptSearchResult instead of Concept, FYI.)
  2. Use the concept resource with query parameters ?searchType=fuzzy&class=xyz&name=xyz.
1 Like

Just tried this

Still doesn’t behave the way I want it to. When I checked the returned result I noticed that the concept class of all returned concepts matched the class parameter. But what I don’t get is why in the radiology order form only X-RAY is returned and the other concepts like True are not.