I have what I think is a very simple rule to implement, but I can't find a way to do
it without "cheating" by using an eval/function. Here's the basic rule in
English:
Reject a claim if it contains a treatment that has already been claimed more than 70 times
in the same calendar month.
In other words, I need to count the number of instances of the treatment that have already
been paid.
Assume for the sake of this discussion, my facts are instances of the Treatment class.
If I replace "70" with, say, "2" in this rule I could do this:
rule
when
Treatment(id=="t1", status=="pending")
Treatment(id=="t1", status=="paid")
Treatment(id=="t1", status=="paid")
then
assert ( new Rejection("reason"));
end
Unfortunately, I can't simply replace "70" with "2", and using the
same strategy to check for 70 instances doesn't seem quite right.
Am I missing something very simple here? Are there standard strategies to deal with this
type of rule?