[rules-users] Drools fact counts...

Jim Majure Jim at sourceallies.com
Thu Mar 29 13:37:50 EDT 2007


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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070329/26184068/attachment.html 


More information about the rules-users mailing list