Backend program rules

Good morning all (and Markus),

I was wondering if you could help please shed some light for me on which program rules (if any) are supported on the backend/api?

I have a use-case where we have imported historic data for a program, and now would like to build some program indicators onto it, which rely on certain program rules triggering. To be able to retroactively trigger these rules for the calculation of the program indicators would require being able to do so on the backend. So I’m wondering if it is supported? And perhaps a very brief description of how it is done?

I wonder if the V{environment} variable is helpful here - but I am not sure if that would still fire retroactively for this situation or simply limit the rule to firing on the server-side when actioned in real time client-side.

I realise this may not be a small question but I am extremely grateful for your time.

All best,

Blake

2 Likes

Hi @bhansen,

Our team from @dhis2-backend will have a look at this and advice.

Best,
James.

Hey @bhansen,
The backend supports running rules, but the the purpose so far has been to send SMS messages. We have been talking about adding support for showing error and warning output based on the rules, and persisting any calculations that is performed(what would be what you asked about) - but this has not been implemented yet. I added a Jira to track this just now: DHIS2-7310 - Expand backend rules engine functionality: Assigning, errors and warnings

The issue describes the use case of submitting or updating event data. Running the rules retroactively is not possible at the moment. Perhaps you could describe your use case for the retroactive triggering in jira? We could potentially build a feature on top of DHIS2-7310 that triggers rules for existing events and stores the result of any ASSIGN rules. Also potentially flag events that is not passing validation(SHOWERROR and SHOWERRORONCOMPLETE is triggering).

As an additional comment - V{environment} will be useful if you for example want the rules only to run when the server runs the rule engine. But it won’t help in running the rules retroactively by itself.

Best regards,
Markus

2 Likes

Thank you @Markus - that was incredibly helpful. I’ll add to the Jira issue now and explain the use-case. I’m very grateful for your taking the time to document it and the possibility of expanding this functionality out.

All best,
Blake

2 Likes