Problem with Cohort Builder OWA

I am working on exporting condition list data in cohort builder PR. I see that ever time I make some export from Concept/Observation it shows 0 results, though relevant data to be exported is available.


I see this part of code to be responsible for fetching data in cohort builder. On digging into the problem I found this code, which might be responsible for fetching data from data base. I discovered we have these evaluators in reporting module. When I click on search I see that the evaluators: DefinitionLibraryCohortDefinitionEvaluator , CodedObsCohortDefinitionEvaluator, BaseObsCohortDefinitionEvaluator and CompositionCohortDefinitionEvaluator are getting executed. I am not able to figure out what exactly is causing this problem and how this could be fixed.

Any help on this is appreciated.

Thank you :slight_smile:

cc: @dkayiwa , @ball

Did this problem exist even before you made your changes?

@dkayiwa Yes, It did. Retrieving observations is working but retrieving concepts is not working.

I have tried other work-arounds as well, which failed. I feel lost when it comes to fixing this. I have tried it with rest as well. I tried to fetch all patients and filter them by checking if each patient has a particular condition. I was trying to use: /ws/rest/v1/patient rest api to fetch all patients but its giving me this error. Its happening with the existing code as well( while exporting concepts) .

@mozzy @dev3 @dev4 @dev5 @burke @dkayiwa

Community I really need us to look at the issue raised above by @haripriya urgently to allow her to resolve this matter so that we can successfully include this MUCH AWAITED functionality in the Ref App in reasonable time. We are just too close to completing this piece of work .

Please assist

1 Like

sure ill try to also look at it in details, i ve been quiete a little caught up

1 Like

@haripriya sorry I’m slow to reply. Can you please share the exact query that gets sent to the back end? E.g. what query parameters or body are you GET/POSTing to the ad hoc query resource? (e.g. you can get this from the network tab of your js console)

@darius Thank you for your response on this :grinning: Here is the data that gets sent to adhoc query as post being called over here.

Just quickly peeking at this on my phone, the relevant part of the post is:

"rowFilters":[{"key":"reporting.library.cohortDefinition.builtIn.codedObsSearchAdvanced","parameterValues":{"timeModifier":"ANY","question":"117399AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA","operator1":"LESS_THAN","onOrBefore":"2019-08-12T06:30:00.000Z","onOrAfter":"2019-08-01T06:30:00.000Z","markHide":false}

Looks like you have a LESS_THAN operator with no value to compare against. Perhaps that fails?

Is there any error message in the server logs?

If I’m not wrong its comparing against the onOrAfter parameter. It is to consider range exclusive of endDate value. Also it doesn’t give any error.

@haripriya any sever logs ??

@mozzy no server logs are being generated.

@haripriya , that is a red flag in openmrs. you cant fetch all patients . That why that resource /ws/rest/v1/patient ,is not supported. imagine you had a million patients, retrieving them all would make you run out of memory. If you want to take that direction , you have to add atleast one param say /ws/rest/v1/patient?q=“xx”, or you can probably write a search handler that retrieves the patients with Conditons.

1 Like

I have just realised we even have no Swagger document for adhocquery resource. Let me try out Post man

@haripriya , i tried out posting the data above with the post url above and got this response

{
    "uuid": "f1c0de50-95a0-41df-ac5a-2fdd8781ca6e",
    "metadata": {
        "columns": []
    },
    "rows": [],
    "definition": {
        "class": "org.openmrs.module.reporting.dataset.definition.PatientDataSetDefinition",
        "uuid": "f1c0de50-95a0-41df-ac5a-2fdd8781ca6e",
        "name": null,
        "description": null,
        "parameters": [],
        "links": [
            {
                "rel": "self",
                "uri": "http://localhost:8081/openmrs-standalone/ws/reporting/v1/reportingrest/dataSetDefinition/f1c0de50-95a0-41df-ac5a-2fdd8781ca6e"
            },
            {
                "rel": "full",
                "uri": "http://localhost:8081/openmrs-standalone/ws/reporting/v1/reportingrest/dataSetDefinition/f1c0de50-95a0-41df-ac5a-2fdd8781ca6e?v=full"
            }
        ],
        "resourceVersion": "1.8"
    },
    "links": [
        {
            "rel": "self",
            "uri": "http://localhost:8081/openmrs-standalone/ws/rest/v1/reportingrest/dataSet/f1c0de50-95a0-41df-ac5a-2fdd8781ca6e"
        }
    ],
    "resourceVersion": "1.8"
} 

is it that what you would expect??

@mozzy Thank you for your response on this :slight_smile: . i want the ‘rows’ field in the above response to return data related to patients. As seen, the rows array is empty . It needs to return an array of patients with each object in the array in the following format:

firstname: “Mary”, gender: “F”, patientId: 8 , age:42, lastname: “Thomas”

I see that in cohort builder when we try to export some concept say Hypertension and select the option “Patient whose observation does not have value Hypertension” , It actually returns list of all patients present in the database. But its not able to return results of patients who are suffering Hypertension when we select “Patient whose observation has value Hypertension” though the required patients are present in the database.

@haripriya ,give me some params that i should register with a new patient ,to ensure the data exists in my database, and i try posting again. Am going to investigate deeper into that resource and do some work there , Is the patient(s) you want to return supposed to have a conditon based on the this data your posting? I surely havent yet gone deeper looking at it

@mozzy Thank you for looking into this issue :smiley: These are the fields required to register a patient in the database. Yes, the patients to be displayed are filtered based on this data . The question field over here has the value of ‘condition uuid’ using which we are trying to fetch patients suffering from a particular condition during the given time range.

Ok @haripriya , i have done some testing , the adhocquery resource can return Results to Numeric ,boolean and Text Concept observation , but cant return results to Coded concept observations. Now let me try to dig deeper int that resource.

@haripriya ,in a meantime , what approach do you want to take get this done ,

example the way you described it here below ,

Because here we are specifically fetching patients with a given obs concept value, Note , the above doesnt directly imply ,that the above retrieved patients have conditons. So youll still do further filtering.

So what do you exactly want to do ??

In a meantime Am trying to look into that resource