[rules-users] Finding a sequence within the data

Yoni Mazar y.mazar at gmail.com
Wed Jul 30 13:12:40 EDT 2008


Hi again,

Sorry for nagging, but I'm failing again and again to implement simple
business logic using rules.
Lets assume, we have LabResult facts with date and value fields. The
business requirement is to detect "patients that have at least 3 consecutive
LabResults with value<1 in the last month".
detecting one fact is simple:
LabResult(value<1 && eval(inLastMonth(date)))
But detecting 2 consecutive facts, actually requires that there is not a
third fact in the middle with value >= 1!
something like:

LabResult(value<1, date1:date, eval(inLastMonth(date1))), 
LabResult(value<1, date2:date, eval(inLastMonth(date2))), 
eval(date1.before(date2)),
not(   LabResult(value>=1, date3:date, eval(inLastMonth(date3))),
        eval(date1.before(date3))
        eval(date3.before(date2)) )

Now, imagine how to detect 3 consecutive facts...

Does someone has a simple idea how to implement this? How comes that one
English sentence is translated to so many lines of code?

Thanks for the help, Yoni

-- 
View this message in context: http://www.nabble.com/Finding-a-sequence-within-the-data-tp18738051p18738051.html
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list