There is a minor assumption that is not performing right....
The query assumes calendar year while some patients have fiscal year coverage and thus their figures are showing zeros for annual maximum and everything else is not falling in the right places thereafter. Please comment out line for calendar year in FormRpTreatmentFinder.cs :
INSERT INTO tempannualmax
SELECT benefit.PlanNum, benefit.MonetaryAmt
FROM benefit, covcat
WHERE covcat.CovCatNum = benefit.CovCatNum
AND benefit.BenefitType = 5 /* limitation */
/*****************************************************************
AND benefit.TimePeriod = 2 /* calendar year */
*****************************************************************/
AND covcat.EbenefitCat=1
AND benefit.MonetaryAmt <> 0
GROUP BY benefit.PlanNum
ORDER BY benefit.PlanNum;
OK, I made the suggested change. So at least there will be more patients coming up on the list. But the amount used and remaining will still not be accurate since they are calculated on calendar year. There is no simple solution. There is a solution which is quite complex, and we'll look into that at some point.