<div dir="ltr"><br>&nbsp;&nbsp; Hehe, well, we could argue that english is not a formal language and as so may be ambiguous... ;)<br><br>&nbsp;&nbsp; How I would do it? My first try would be:<br><br>$l1 : LabResult( value &lt; 1, $date1:date, eval( inLastMonth($date1) )<br>

$l2 : LabResult( value &lt; 1, $date2:date &gt; $date1, eval( inLastMonth($date2) )<br>
$l3 : LabResult( value &lt; 1, $date3:date &gt; $date2, eval( inLastMonth($date3) )<br>not LabResult( date &gt; $date1 &amp;&amp; &lt; $date2, this not in ($l1, $l2, $l3) ) <br><br>&nbsp;&nbsp;&nbsp; Let us know what you come up with. :)<br>
<br>&nbsp;&nbsp;&nbsp; []s<br>&nbsp;&nbsp;&nbsp; Edson<br>
<br><br><div class="gmail_quote">2008/7/30 Yoni Mazar <span dir="ltr">&lt;<a href="mailto:y.mazar@gmail.com">y.mazar@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Hi again,<br>
<br>
Sorry for nagging, but I&#39;m failing again and again to implement simple<br>
business logic using rules.<br>
Lets assume, we have LabResult facts with date and value fields. The<br>
business requirement is to detect &quot;patients that have at least 3 consecutive<br>
LabResults with value&lt;1 in the last month&quot;.<br>
detecting one fact is simple:<br>
LabResult(value&lt;1 &amp;&amp; eval(inLastMonth(date)))<br>
But detecting 2 consecutive facts, actually requires that there is not a<br>
third fact in the middle with value &gt;= 1!<br>
something like:<br>
<br>
LabResult(value&lt;1, date1:date, eval(inLastMonth(date1))),<br>
LabResult(value&lt;1, date2:date, eval(inLastMonth(date2))),<br>
eval(date1.before(date2)),<br>
not( &nbsp; LabResult(value&gt;=1, date3:date, eval(inLastMonth(date3))),<br>
 &nbsp; &nbsp; &nbsp; &nbsp;eval(date1.before(date3))<br>
 &nbsp; &nbsp; &nbsp; &nbsp;eval(date3.before(date2)) )<br>
<br>
Now, imagine how to detect 3 consecutive facts...<br>
<br>
Does someone has a simple idea how to implement this? How comes that one<br>
English sentence is translated to so many lines of code?<br>
<br>
Thanks for the help, Yoni<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://www.nabble.com/Finding-a-sequence-within-the-data-tp18738051p18738051.html" target="_blank">http://www.nabble.com/Finding-a-sequence-within-the-data-tp18738051p18738051.html</a><br>

Sent from the drools - user mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>
</div>