Issue with Program Rule Calculations Not Updating via API

Hello DHIS2 Community,

I’ve encountered a challenge while working with program rules in the DHIS2 Tracker. Specifically, I’ve set up a program rule to calculate a field value based on other inputs. This works perfectly when using the Capture app or any other front-end interfaces; the calculated field updates in real-time as expected.

However, when I create an event using the API endpoint, the calculated fields do not update immediately. These fields only seem to be calculated and updated when I subsequently open the enrollment or event in the web app. This delay poses a significant issue for processes that rely on accurate and immediate data via API interactions.

Has anyone else faced this issue? If so, how have you handled it? Are there any recommended workarounds or configurations that ensure program rules are triggered and calculated correctly when events are created or updated via the API?

I appreciate any insights or suggestions the community can provide.

Best regards,
Tafsir

Hi @diallotafsir52

I think the calculation are performed in the frontend side that why you do not have the same result via the API (Server side).

The solution could be to manually perform the calculation before sending the data to the API.

Regards.

2 Likes

Thanks @didate .

1 Like