[rules-users] Finding a sequence within the data

Edson Tirelli tirelli at post.com
Wed Jul 30 17:41:23 EDT 2008


   Hehe, well, we could argue that english is not a formal language and as
so may be ambiguous... ;)

   How I would do it? My first try would be:

$l1 : LabResult( value < 1, $date1:date, eval( inLastMonth($date1) )
$l2 : LabResult( value < 1, $date2:date > $date1, eval( inLastMonth($date2)
)
$l3 : LabResult( value < 1, $date3:date > $date2, eval( inLastMonth($date3)
)
not LabResult( date > $date1 && < $date2, this not in ($l1, $l2, $l3) )

    Let us know what you come up with. :)

    []s
    Edson


2008/7/30 Yoni Mazar <y.mazar at gmail.com>

>
> 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.
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
Edson Tirelli
JBoss Drools Core Development
JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080730/c0f52705/attachment.html 


More information about the rules-users mailing list