Want to update balance due against each encounter for faster results

Hi

Is there any way we can implement triggers to update balance due of an encounter against each encounter on form_encounter table.

Presently i’m implementing balance due report and i’m facing performance issues since i’m pulling balance due like below
Sum(fee)-SUM(Paymentallocations)-SUM(adjustments)-SUM(undistributed) from different tables

Since I’m running above calculation for 1000s of encounters it is taking much time.

So is balance due updated against each encounter then it is easy to pull balance due with out doing the calculations.

Provider any of your suggestions.

Thanks