How do I query Observations based on numeric input in Cohort Builder?

Good day Everyone.

I am currently working on Cohort Builder’s Concept/Observation. Currently, the numeric input does not have any effect on the query result. The endpoint being used is reportingrest/adhocquery.

I’ve searched and can’t find any documentation on this endpoint. Does anyone here know if this is the correct endpoint/how to structure the query?

The querying does not depend on concept data type. You should be able to query as the existing code.

I can query with the existing code but the returned result is not accurate. For example, using Weight (kg) concept, querying any observation with the values below returns the same result:

  • Less than 20
  • Greater than 20
  • Greater than 2000
  • Equal to 50

Good day,

As adviced by @dkayiwa, I did a search on the old Cohort Builder to determine if there is any difference in the result returned in the old Cohort Builder and the new one and couldn’t find any instance where the results were different.

I took my search further and decided to try the query both on the old and new Cohort Builder in the refapp. On trying the query in the old Cohort Builder on the refapp, I get an error. Here is a link to the error I got: https://pastebin.com/bmKBHwYM

Which version of the old cohort builder are you using? And what are the exact steps to reproduce that error?

@dkayiwa The current version on the refapp is Version: 2.0.5

The steps are:

  • Login to refapp: https://modules-refapp.openmrs.org
  • Click on System Administration
  • When page loads, Click on Advanced administration
  • Click on Cohort Builder in the top navigation area
  • On the Search by Concepts and Observations textbox, enter ‘weight’ without the quotes and click on ‘Weight (kg)’ in the result list
  • On the ‘Patients with observations whose question is Weight (kg)’ tab, select any of the options and enter any value in the values field

@joelakwes i have just updated that server with a version of the module which has this bug fixed. Are you now able to proceed?

@dkayiwa I’m now able to query on the old Cohort Builder without any errors but the new Cohort Builder now returns a 500 Internal server Error when request is made to reportingrest/adhocquery endpoint

What does the server log look like?

I can’t view the server logs. The error is the response gotten when a request is sent to the reportingrest/adhocquery endpoint. The request is sent using JS. I have attached a screenshot of my browser console displaying this error.

If you just run openmrs locally without using modules-refapp, are you able to reproduce it?

Yes, it works locally

Then just test with your local server

The major problem here is not testing with local server or refapp actually. The problem here is that the result returned on both the old Cohort Builder and the new Cohort Builder are the same when tested locally. The results from the new Cohort Builder have been reported to be inaccurate that’s why I also wanted to confirm using the old and new Cohort Builder in the refapp.

Is it possible for me to go through the code that handles the reportingrest/adhocquery endpoint? I’m sure that will help in some way

I have updated modules-refapp with the latest snapshot version of the reportingrest module. Are you able to still reproduce the problem? If yes, what are the exact steps.

FWIW, the resource is: https://github.com/openmrs/openmrs-module-reportingrest/blob/master/omod/src/main/java/org/openmrs/module/reportingrest/web/resource/AdHocQueryResource.java

Thanks Daniel,

I’ve tried but still not able to query using the new Cohort Builder on refapp. I still get the 500 Internal server Error response. Here’s a link to the logs https://pastebin.com/2Rt0F4gG

As i said before, you need to include the exact steps to reproduce.

The steps are:

  • Login to refapp: https://modules-refapp.openmrs.org/
  • Click on Add on Manager
  • On the Add on Manager, click on Cohort Builder
  • On the Search by Concepts and Observations textbox, enter ‘weight’ without the quotes and click on ‘Weight (kg)’ in the result list
  • On the ‘Patients with observations whose question is Weight (kg)’ tab, select any of the options and enter any value in the values field and click on search

This will bring up Search error occurred, check the server log for more details error notification.

On inspecting the browser’s console in the developer tools, a 500 Internal Server Error is returned as shown in the image below:

Clicking on the url in the browser’s console displays the log as shown here: 0.7512161errormessageThe Resource Does not Support the Requested Operation [AdHo - Pastebin.com

I have just updated that server with the latest version of the reporting module. Are you still able to reproduce it?

I no longer get an error and I have gotten the confirmation I’m looking for. The query result in the old Cohort Builder is different from the new Cohort Builder in the refapp. The issue now is how to format the query request to the endpoint