Custom working list customization

Dear community members,

@Gassim would you please help me on how I can customize custom working list and base on given conditions
I want to achieve something like it is shown on below image

how can I create something like Ongoing foci responses I think if I can achieve this it can help me to track TEIs based on various conditions

1 Like

Hi @Pacifique_Hategekima,

Yes, thanks! Very nice question! (:
For the ‘custom working list’ you can choose the filters on the fly; however, for something like ‘ongoing foci responses’ list then I think you will have to use the API to create what is called trackedEntityInstanceFilters which are “a predefined set of query parameters”

For example, the ones you list in the image above are listed here: https://play.dhis2.org/2.37.2/api/trackedEntityInstanceFilters

If you would like to create these trackedEntityInstanceFilters “Working lists” using API, here’s a link to the docs (and please feel free to post back to the community with your questions and/or your experiences/ use cases):
/api/trackedEntityInstanceFilters resource - API Docs - Using the API - DHIS2 Documentation

1 Like

This means that I will need to navigate API using an external tool like Postman of swagger to post my filter?
if possible would you please give me an example of post payload to create a trackedEntityInstanceFilter , that I can fire in postman to create a new one

Thanks @Gassim

1 Like

Hi @Pacifique_Hategekima,
Yes, there’s no problem it’s very easy; however, the challenge is choosing the filters which will require that you go through the Payload in the docs and select exactly what you want to be filtered.

Here’s an example API POST request to https://play.dhis2.org/2.37dev/api/33/trackedEntityInstanceFilters:

{
  "name": "A 2022 Working-list",
  "displayName": "A 2022 Working-list",
  "description": "A 2022 Working-list",
  "displayDescription": "A 2022 Working-list",
  "followup": false,
  "enrollmentStatus": "ACTIVE",
  "sortOrder": 2,
  "favorite": false,
  "program": {
  "id": "IpHINAT79UW"
  },
  "attributeValues": [],
  "eventFilters": [],
  "userAccesses": []
}

1 Like

Thank you @Gassim for your detailed instruction!

We in Palestine have a system for the patient medical record that consists of different programs. The starting point is from registration, we register the patient in the registration program then fill a stage for the purpose of the visit. Then enroll the patient in related programs, It could be Immunization, lab, radiology…etc. The following screenshots shows the workflow:



I created a custom working list following your instructions. One for the patients assigned to the current user, and the other for the patients that are not assigned.

Now I want to created a list for the patient order depends on the event date inside the registration program. For example If Patient X came first and we filled the “Purpose of the visit” stage for him, then Patient Y came after him, the list must show Patient X in the top of the list then Patient Y then Patient Z and so on.

The date that should be followed in the filter is this date:

My Question is: What should I put in the filter to obtain this result?

My current filter:
{
“name”: “Patient order”,
“displayName”: “Patient order”,
“description”: “Patient order”,
“displayDescription”: “Patient order”,
“enrollmentStatus”: “ACTIVE”,
“sortOrder”: 4,
“program”: {
“id”: “jygXgtmtsfE”
},
“entityQueryCriteria”: {
“followUp”: false,
“enrollmentStatus”: “ACTIVE”,
“attributeValueFilters”: []
},
“eventFilters”: [
{
“eventCreatedPeriod”: {
“periodFrom”: -1,
“periodTo”: 1
},
“assignedUserMode”: “ANY”,
“assignedUsers”: []
}
]
}

@Gassim Your advise is highly appreciated

1 Like

Dear @Gassim can you help me in reforming the POST request for our customized list?
The conditions are explained in the previous comment.
It’s a top priority in out project, your help is appreciated

1 Like

Hi @hanin.saadah
Thank you for your patience! And thanks a lot for the clear explanation, pictures, and template. It helps a lot. :slight_smile:

I’d add to the entityQueryCriteria "order": "createdDate:asc" which will allow you to view the TEI in order of registration from first to last.

It’d be:

{
"name": "Patient order",
"displayName": "Patient order",
"description": "Patient order",
"displayDescription": "Patient order",
"enrollmentStatus": "ACTIVE",
"sortOrder": 4,
"program": {
"id": "jygXgtmtsfE"
},
"entityQueryCriteria": {
"order": "createdDate:asc" ,
"followUp": false,
"enrollmentStatus": "ACTIVE",
"attributeValueFilters": []
},
"eventFilters": [
{
"eventCreatedPeriod": {
"periodFrom": -1,
"periodTo": 1
},
"assignedUserMode": "ANY",
"assignedUsers": []
}
]
}

I hope this solves it for this type of ordering:


If it doesn’t work please let me know what change do you see after adding the order?

And, if there’s anything else you’d like to see filtered or ordered properly in that list please feel free to post back.


Update: If 'createdDate is not the one you’re looking for please replace createdDate:asc with eventDate:asc (in order of event date)

1 Like

Hi @Gassim
Thank you so much for your support!

I put the eventDate inside the entityQueryCriteria, and this is the result after post the request!

I read the documentation about the “order” property and implemented it as the documentation

But this time the postman showed error because the request body has equal (=) sign!

Where could be the problem?

1 Like

Hi @hanin.saadah

Yes, the equal sign is wrong. The first one is correct but then it might be that the JSON format above has a syntax error. Please check if the quotation marks are all the same? Sometimes that is something that could change because of keyboard language or copy/paste. I tried eventDate:asc and it’s working, see screenshot:

Either post the JSON into VSCode which will help you find out what’s wrong on the syntax or you can post it here and I can double check the syntax.

1 Like

Dear @Gassim , Here is my json code. I validate the code online, it has no errors.

{
    "name": "Patient order",
    "displayName": "Patient order",
    "description": "Patient order",
    "displayDescription": "Patient order",
    "enrollmentStatus": "ACTIVE",
    "sortOrder": 4,
    "program": {
        "id": "jygXgtmtsfE"
    },
    "entityQueryCriteria": {
        "programStage": "ydoXYBR0eMM",
        "order": "eventDate:asc",
        "followUp": false,
        "enrollmentStatus": "ACTIVE",
        "attributeValueFilters": []
    },
    "eventFilters": [
        {
            "eventStatus": "COMPLETED",
            "period": "TODAY",
            "eventCreatedPeriod": {
                "periodFrom": -0,
                "periodTo": 0
            },
            "assignedUserMode": "ANY",
            "assignedUsers": []
        }
    ]
}

Yes, @hanin.saadah! Thank you! I validated the code and it’s working 100%

Maybe this has to do with the version number. Please what is the version number of the instance you are using?

1 Like

@Gassim
Our DHIS2 instance version is 2.38.1.1 , and these are the specifications of the Postman

Postman for Windows
Version 10.0.22
UI Version 10.0.22-ui-221011-0439
Desktop Platform Version 10.0.1
Architecture x64
OS Platform win32 10.0.19044
1 Like

Hi @hanin.saadah

Thank you for reporting this! I was testing on 2.37dev but it seems that 2.38.1.1 gives me the same error you posted above. I will check with @tracker-backend on this issue.

It might be a bug (or because of the new tracker API…) If it turns out a bug, I will ask you to please create a ticket here and will tag you in the bug hunters list in the copmonthly :slight_smile: :+1::+1:

POST Request: https://play.dhis2.org/ Add-Version-Here /api/33/trackedEntityInstanceFilters

See example payload with eventDate
{
    "name": "Patient order 2",
    "displayName": "Patient order 2",
    "description": "Patient order 2",
    "displayDescription": "Patient order 2",
    "enrollmentStatus": "ACTIVE",
    "sortOrder": 4,
    "program": {
        "id": "IpHINAT79UW"
    },
    "entityQueryCriteria": {
        "programStage": "A03MvHHogjR",
        "order": "eventDate:asc",
        "followUp": false,
        "enrollmentStatus": "ACTIVE",
        "attributeValueFilters": []
    },
    "eventFilters": [
        {
            "eventStatus": "COMPLETED",
            "period": "TODAY",
            "eventCreatedPeriod": {
                "periodFrom": -0,
                "periodTo": 0
            },
            "assignedUserMode": "ANY",
            "assignedUsers": []
        }
    ]
}
See screenshots

Screenshot of the error:

works on 2.37dev

Thanks!

1 Like

Hi @Gassim

I’ll wait your request to create a ticket in the DHIS2 Jira system, and thank you very much for your quick responses.

1 Like

Hi @hanin.saadah,

Thank you for your patience! There were updates in the API endpoint and one of the updates was was validating the properties. It seems that even in older versions ‘eventDate’ didn’t actually work but it was ignored by the API; however, with the validation, we can now see it as an error on Postman. (@Simona.Domnisoru and @Karoline, please feel free to correct me or add to this)

We can’t say it’s a bug but you did help uncover that the docs needs an update so we’ll count that. :+1:

As for now I’m not sure exactly what’s the option to use instead of eventDate but if I find out, I will let you know. If you decide to test as well, I recommend to check after each POST request whether it’s actually displaying the list as expected or not (I didn’t do that last time so that’s why we got to this.)

Thanks! :+1:
______________________________________________________

UPDATE:
______________________________________________________
Sorry @hanin.saadah for my outdated response. :sleepy:

You can now use predefined list views in the Capture app (without having to use the API), please see docs:

2 Likes

Thank you @Gassim for this information. I’ve gone through these views and tried to create mine, but unfortunately I didn’t find the “event date or Report date” as a parameter to be filtered or ordered. In addition, I cant choose specific stage inside a program. Can you advise?
As I mentioned before, I want to order patients according to the event date/Report date of a specific stage inside a program

1 Like

@hanin.saadah I understand but it seems that it’s not currently supported. Maybe there’s a workaround to this such as creating a data element that will be assigned the event date of the event using a program rule and then using that data element in the filters?

1 Like

Hi @hanin.saadah

We are building workinglists that lists events from a program stage, and probably will solve your issue… Its not released yet, but it will be. This will be in the new capture app and not the old tracker capture.

Caroline

2 Likes

Thank you @Caroline for the clarification, and thanks @Gassim for helping me in every step, very appreciated!

Waiting the new release :+1:

2 Likes

11 posts were split to a new topic: Creating working lists in capture app