How to get the value of a data element from the oldest event for a program stage

This might be a vague question but i was wondering if anyone has tried to get the value of a data element from the oldest event from a program stage using a program rule or program rule variable.

Thanks

1 Like

Hi there @paleu256,
Some have a baseline program stage, where the first value is collected. If this is the case, you can use the source type “Data element for the newest event for a program stage”, and selecting the first program stage.

Otherwise you would have to create a rule that stores the first value in a separate helper field when it is first entered.

You could also send us a jira ticket on jira.dhis2.org and describe your use case - and we can look into building either a function or source type to accomodate the use case.

Best regards,
Markus

1 Like

Hi @Markus and @paleu256,

I’m having the same challenge. In my case, I have a repeatable stage where I store a value in each event and I would like to subtract the first and last event of that stage and assign it to another DE. In order to get the first (oldest) event I was thinking on having a PR that populates a PR variable. Then, when it comes to define the condition… I don’t have a clear idea. The most accurate condition I found was that the v{event_count} equal to 1 but still not perfect since one could start entering data from another stage.

Hi @barreda,

Have you found the solution to your problem? Iam interested to know if you got it.

Thanks

Hi @fernando unfortunately not, perhaps someone should write a JIRA with this request for Improvement.

1 Like

@barreda and @fernando
That is a good suggestion. Please describe your use case(don’t leave out the functional detais) in a jira issue :slight_smile:

All the solutions I can think of is “workarounds” for the missing functionality:

  • Use a different data element in the first stage.
  • Use a program rule to assign the first entered value, and only the first entered value, to a helper data element, a bit similar to the point above.

Markus

1 Like