Good day Everyone.
I’m currently working on the new Cohort Builder but I’ve hit a blocker. I noticed that the result returned when querying for observations using numeric input on “Weight (Kg)” concept in the Concept/Observation tab is incorrect. From the codebase, the query request is sent to the reportingrest/adhocquery
endpoint.
The current query object is shown below:
{
"type": "org.openmrs.module.reporting.dataset.definition.PatientDataSetDefinition",
"columns": [
{
"name": "firstname",
"key": "reporting.library.patientDataDefinition.builtIn.preferredName.givenName",
"type": "org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition"
},
{
"name": "lastname",
"key": "reporting.library.patientDataDefinition.builtIn.preferredName.familyName",
"type": "org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition"
},
{
"name": "gender",
"key": "reporting.library.patientDataDefinition.builtIn.gender",
"type": "org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition"
},
{
"name": "age",
"key": "reporting.library.patientDataDefinition.builtIn.ageOnDate.fullYears",
"type": "org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition"
},
{
"name": "patientId",
"key": "reporting.library.patientDataDefinition.builtIn.patientId",
"type": "org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition"
}
],
"rowFilters": [
{
"key": "reporting.library.cohortDefinition.builtIn.numericObsSearchAdvanced",
"parameterValues": {
"timeModifier": "ANY",
"question": "7fae062d-a5a4-4d02-885c-ddd60adde01f",
"operator": "LESS_THAN",
"value": "20"
},
"type": "org.openmrs.module.reporting.dataset.definition.PatientDataSetDefinition"
}
],
"customRowFilterCombination": "1"
}
And here’s the response object:
{
"uuid": "b538efe4-0af8-423e-b77d-da2cee86a618",
"metadata": {
"columns": [
{
"datatype": "java.lang.Object",
"name": "firstname",
"label": "firstname"
},
{
"datatype": "java.lang.Object",
"name": "lastname",
"label": "lastname"
},
{
"datatype": "java.lang.Object",
"name": "gender",
"label": "gender"
},
{
"datatype": "java.lang.Object",
"name": "age",
"label": "age"
},
{
"datatype": "java.lang.Object",
"name": "patientId",
"label": "patientId"
}
]
},
"rows": [
{
"firstname": "Brian",
"gender": "M",
"patientId": 103,
"age": 39,
"lastname": "Rodríguez"
}
],
"definition": {
"class": "org.openmrs.module.reporting.dataset.definition.PatientDataSetDefinition",
"uuid": "b538efe4-0af8-423e-b77d-da2cee86a618",
"name": null,
"description": null,
"parameters": [],
"links": [
{
"rel": "self",
"uri": "http://localhost:8081/openmrs-standalonehttp://localhost:8081/openmrs-standalone/ws/reporting/v1/reportingrest/dataSetDefinition/b538efe4-0af8-423e-b77d-da2cee86a618"
},
{
"rel": "full",
"uri": "http://localhost:8081/openmrs-standalonehttp://localhost:8081/openmrs-standalone/ws/reporting/v1/reportingrest/dataSetDefinition/b538efe4-0af8-423e-b77d-da2cee86a618?v=full"
}
],
"resourceVersion": "1.8"
},
"links": [
{
"rel": "self",
"uri": "http://localhost:8081/openmrs-standalonehttp://localhost:8081/openmrs-standalone/ws/rest/v1/reportingrest/dataSet/b538efe4-0af8-423e-b77d-da2cee86a618"
}
],
"resourceVersion": "1.8",
"searchDescription": "Patients with observations whose question is Weight (kg) .",
"query": {
"type": "org.openmrs.module.reporting.dataset.definition.PatientDataSetDefinition",
"columns": [
{
"name": "firstname",
"key": "reporting.library.patientDataDefinition.builtIn.preferredName.givenName",
"type": "org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition"
},
{
"name": "lastname",
"key": "reporting.library.patientDataDefinition.builtIn.preferredName.familyName",
"type": "org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition"
},
{
"name": "gender",
"key": "reporting.library.patientDataDefinition.builtIn.gender",
"type": "org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition"
},
{
"name": "age",
"key": "reporting.library.patientDataDefinition.builtIn.ageOnDate.fullYears",
"type": "org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition"
},
{
"name": "patientId",
"key": "reporting.library.patientDataDefinition.builtIn.patientId",
"type": "org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition"
}
],
"rowFilters": [
{
"key": "reporting.library.cohortDefinition.builtIn.numericObsSearchAdvanced",
"parameterValues": {
"timeModifier": "ANY",
"question": "7fae062d-a5a4-4d02-885c-ddd60adde01f",
"operator": "LESS_THAN",
"value": "20"
},
"type": "org.openmrs.module.reporting.dataset.definition.PatientDataSetDefinition"
}
],
"customRowFilterCombination": "1"
}
}
To reproduce this issue, go to the new Cohort Builder and on the Concept/Obersvation tab, type “weight” and select “Weight (kg)” on the list of options. Select any of the options and enter any numeric value in the values input field. Repeat for different numeric values. You’ll notice that the numeric values entered have no effect on the results returned.
I’m assuming this is happening because the request sent to the endpoint is not structured the way it is supposed to.
I have two questions
-
Is
reportingrest/adhocquery
the correct endpoint to use in this case? -
How is the query request supposed to be structured?