← Back to team overview

dhis2-devs team mailing list archive

Aggregating events based on last value of the data element

 

Hi,

We are currently using DHIS2 to track nutrition problems of children under
5 years.

Assume we have only two children in the database and DE1 be a certain
condition that we monitor continuously,

child 1 -> [event 1, DE1=1, time=t1] [event 2 - DE1=1,time=t2] [event 3 -
DE1=0,time=t3]
child 2 -> [event 1, DE1=0, time=t1] [event 2 - DE1=0,time=t2] [event 3 -
DE1=0,time=t3]

Now if I call "events/aggregate/<psi>?dimension=*DE1*:EQ:1&startDate=*T1*
&endDate=*T2*&dimension=ou:<ouid>", is there a parameter that we can set in
the query to consider only the last value of the data element in the chosen
event series.

eg :

case

T1

T2

Result

*Expected result*

1

t1

t1+delta

1

*1*

2

t1

t2+delta

2

*1*

3

t1

t3+delta

2

*0*

4

t2

t3+delta

1

*0*

case 1 : child 1 has the condition (because DE1=1), hence result =1
case 2 : child 1 still has the condition, but we want to consider him only
once.
case 3 : child 1 has got rid of the condition, so we don't want to consider
him for the results

Why we need this :  we want to analyze the state of org unit during a
specific period of time and draw a trend chart to determine whether
measures taken to improve child health has actually worked or not.

[image: Inline image 1]
 And also we need to compare the identified risk factors graphically, so we
know which area should get the highest focus or attention.

[image: Inline image 2]

Please let us know whether above results can be achieved using API version
2.26.
Currently we are using SQL Views (2 SQL views + 1 Query) to generate above
results, but that is extremely inefficient and expensive.

Thanks



-- 
Best Regards,

*Chathura Widanage,*
Undergraduate,
Department of Computer Science and Engineering,
University of Moratuwa,
Sri Lanka
<https://www.linkedin.com/profile/public-profile-settings?trk=prof-edit-edit-public_profile>
  <http://facebook.com/chathura.widanage>
<https://plus.google.com/u/0/109418781686423002025>
<https://github.com/chathurawidanage>

PNG image

PNG image


Follow ups