Query format in REST API

I find the sample rest api like this:

GET /ws/rest/v1/resource?q=query = search

What i can send with this parameter? For example, i want to get all person, which are female.

GET /ws/rest/v1/person?q=query = search

You can specify name of the person If you have person in database you will get result back. ws/rest/v1/person?q=john

Only name?

yes this working try it. /openmrs/ws/rest/v1/person?q=john

And i cannot sent another query? I can’t get person by gender or by age?

@maryjis, the openmrs-core API (both REST and Java) is not designed for analytics, or querying for large numbers of patients.

If you add the reporting and reportingrest modules, you can use the REST API described here: https://github.com/openmrs/openmrs-module-reportingrest/wiki

To query for patients (not persons) by gender I think you can first use the definitionlibrary resource, which will give you some available queries, including one for females. And then you execute this query with the cohort resource.

1 Like

I tried to use reportingrest. I created Male Sql DataSet and recieved the response presented below.But I want to recieve json, which contain person dataset with parameter gander=‘M’, not only information about class, name and e.t.c. Can I recieve this information by rest?

{ “class”: “org.openmrs.module.reporting.dataset.definition.SqlDataSetDefinition”, “uuid”: “926d3c75-fcbc-4c95-8776-b92f431b18d1”, “name”: “Male SQL DataSet”, “description”: “”, “parameters”: [], “links”: [ { “rel”: “self”, “uri”: “http://localhost:8080/openmrs/ws/reporting/v1/reportingrest/dataSetDefinition/926d3c75-fcbc-4c95-8776-b92f431b18d1” } ], “resourceVersion”: “1.8” }

The resource for evaluating a dataset definition is https://github.com/openmrs/openmrs-module-reportingrest/wiki/Data-Sets#dataset

I was actually suggesting that you can just do this:

GET https://demo.openmrs.org/openmrs/ws/rest/v1/reportingrest/cohort/reporting.library.cohortDefinition.builtIn.males

And you can find all available built-in definitions via

GET https://demo.openmrs.org/openmrs/ws/rest/v1/reportingrest/definitionlibrary?q=cohort

There’s also this advanced resource: https://github.com/openmrs/openmrs-module-reportingrest/wiki/Ad-Hoc-Analysis

Thank you! And can I create SqlDataSetDefinition by rest?