Program indicator with data elements in different program stages

Hello community,
I am trying to create a program indicator that has different data elements at different stages. I want to find out the number of HIV positive males and females. The gender data element is in the screening stage, and the custom date and HIV status are in a different stage (confirmatory). How do I go about this?

This is what I had in my filter expression, but it gives me blanks/zeros

CONFIRMATORY\.Final Interpretation == "1_Positive" && SCREENING\.Sex at birth == "FEMALE"

What am I missing?



Hi again Andrew,

If you want to evaluate an enrollment based on data in different program stages, you need to use program indicators with Enrollment analytics type. See here for more details as to why: Tracker Analytics - DHIS2 Documentation

If you change to enrollment analytics type, then your filter should work correctly.

There are a few other conditions to consider:

  • The analytics period would default to the enrollment dates that fall within the reporting period. For example if you request month of March in data visualizer for this program indicator, you would only count patients where the enrollment date is March. Is this what you want? OR do you want to know those that had a CONFIRMATORY stage within the month? If you want to know which enrollments had FINAL INTERPRETATION in the period, use Custom Analytics period boundaries for the program stage PS_EVENTDATE:programStageUid. See details here
  • Use V{enrollment_count} in your expression and Count as the aggregation type.
  • Are both Screening and Confirmatory stages repeatable? I assume not, but if they are, keep in mind that only the data element values from the latest event would be evaluated for each enrollment.

Hi Brian,
Thanks for your response and putting things in proper perspective.

I would like to count patients whose enrollments met this filter condition
CONFIRMATORY\.Final Interpretation == "1_Positive" && SCREENING\.Sex at birth == "FEMALE"
within the custom analytics period, in this case, the quarterly period where the custom date is the CONFIRMATORY\.DATE_CONFIRM. I made both the screening and confirmatory stages non-repeatable

I get the following error message after implementing it like that


OK, so… for our records, you are combining the filter requirements above with the custom analytics period from your earlier post, Calculate the number of events between two dates

Your goal is in fact to count the number of patients, marked as Final Positive Cases and Female, (both data elements in separate nonrepeatable program stages), and you would like the period to be the date of ART start date.

This behaviour appears to be a bug. It looks like you are using 40.0 or 40.1 as you have the Organization Unit field, which version are you using? I was not able to replicate this on 40.0

One thing that might cause the error is if the CONFIRMATORY\.DATE_CONFIRM is of type DATETIME. Is it just a date?

As a workaround, you might instead make your boundary
Enrollment date : before end of period
and your filter
CONFIRMATORY\.Final Interpretation == "1_Positive" && SCREENING\.Sex at birth == "FEMALE" && d2:daysBetween(V{analytics_period_start}, #{ART_start_date})>=0 && d2:daysBetween(#{ART_start_date}, V{analytics_period_end})>=0

Relatedly, I see that you have a period boundary offset this would evaluate data from the previous quarter of your Data Visualizer query – if you request data for Q2 2023, it would return ART start dates in Q1, etc

Hi Brian,
Thanks for taking the time to understand and replicate this. The earlier post about ARTstartdate is unrelated to this and was affecting a different indicator, but you got the goal somewhat right.
For this indicator, I would like the period to be DATE_CONFIRM (date the patient was finally confirmed positive), which is in the confirmatory stage together with the Final interpretation.
I downgraded from DHIS2, which had a lot of bugs, to, which was considered more stable.
So I changed it to this:

The error disappears, but I still get zero values.

Ahh, apologies for my typo, corrected above. The filter should be

CONFIRMATORY\.Final Interpretation == "1_Positive" && SCREENING\.Sex at birth == "FEMALE" && d2:daysBetween(V{analytics_period_start}, #{ART_start_date})>=0 && d2:daysBetween(#{ART_start_date}, V{analytics_period_end})>=0

The last one is period_end