Reporting Rest Web Services is not returning same number of results as reporting module

Application Name: Platform Version Number: 1.11.6

Problem Details: I’m trying to access a cohortquery in the Reporting module through the reporting REST web services module. I created a simple SQL cohort query that returns all the patients in the system (select patient_id from patient where voided = :void;) on (cohortquery link) This query collects the ‘void’ parameter which should have a string value of ‘0’ or ‘1’. In the preview screen of the reporting module I see 2705 members of the cohort when I use the value void=0. I see 5427 results when void=1.

The next thing I do is test the reporting REST API thorough curl. The following command returns 2705 members where void=0 (matches the reporting module) curl -X GET --header ‘Accept: application/json’ ‘’ -u admin:Admin123

The following command returns 0 members where void=1 (the reporting module returns 5427 results) curl -X GET --header ‘Accept: application/json’ ‘’ -u admin:Admin123

I created another cohortquery that doesn’t collect a parameter and should return 8132 patients according to the reporting module, but it returns 2705.

curl -X GET --header ‘Accept: application/json’ ‘’ -u admin:Admin123

Questions: Do you have any thoughts on why the Reporting REST module is behaving this way? Is the Reporting REST module’s cohortquery returning patients where void=0 by default? Are there any limits on the number of patients returned from the Reporting REST module? Is pagination used? If so, how can I work through those?

Thanks! Craig

FYI @mseaton

@craigappl - one possible answer is that your “void” parameter was of datatype String. I have done into int02 and changed this to datatype = boolean. I haven’t confirmed whether or not this fixes things with the REST response - can you do this? Do you have an easy way of testing this (I can run the CURL command, but not easily get the size of the members in the response without throwing together some JS - what do you use?).

In a broader sense, the reporting module does try its best to excluded voided data from queries if at all possible. Where this is most difficult is with SQL-based definitions, but we do it when we can. That being said, there shouldn’t be any reason why the REST module would return different results from the core API.

Let me know if the parameter datatype change helps fix things. Otherwise we can keep digging.

Thanks, Mike

Hi Mike,

Thanks for your reply. Changing the data type didn’t change the number of members returned. I used the REST web services test page in the UI to identify how many members were returned in the query. {BASE_URL}/openmrs/module/webservices/rest/test.htm

I did a number of other tests on other parameters and didn’t have any issues and feel that this is likely only an issue when you try to dynamically change the voided parameter. Our production environment is only looking for active records, so it’s not an issue that we need to address.