Hi, 

You must make a difference between "facts" and other objects (that you can get 
by "bindings"). 
"facts" are the objects inserted in the working memory. Only those objects can 
be matched directly in LHS. Other entities can be accessed by using attributes 
(of facts) bindings or "from" constructions to get objects from "facts" fields. 
And finally, only the "facts" can be modified/inserted/retracted, ie actions 
that trigger a RETE evaluation and thus new candidate rules to fire. 

Here, in your first rule, your LHS is matching facts and use a binding 
$krankheitsbild for a field of KrankheitsbildVonPatient fact. 
And you are modifying the binded attribute, which is not a fact. So it won't 
trigger RETE evaluation... To me, it should not compile, but apparently it does 
.... 

You can think about 2 corrections : 
1 - make your $krankheitsbild objects real facts, ie insert them in the WM, and 
don't get them via attribute binding 
2 - do the set on $krankheitsbild, then "update" your containing fact object ( 
with update($krankheitsbildVonPatient) ) 


here are the approximative form of the resulting rules for the 2 approaches : 

---------------1------------------- 
I suppose that Krankheitsbild objects are inserted independently, and your 
model modified like that 
declare KrankheitsbildVonPatient 
patient : Patient 
end 

declare Krankheitsbild 
parent : KrankheitsbildVonPatient 
abdominaleAdipositas : boolean 
adipositasGrad : String 
risikoBegleiterkrankungGrad : int 
risikoMetabolischeKardiovaskulaereKomplikationen : String 
metabolischesSyndrom : boolean 
end 
so the rule should look like : 

rule "...." 
when 
MessdatenVonPatient($patient : patient && (getMessdaten().getBmi() >= 18.5) && 
(getMessdaten().getBmi() < 25)) 
$krankheitsbildVonPatient : KrankheitsbildVonPatient(patient == $patient ) 
$krankheitsbild : Krankheitsbild ( parent == $krankheitsbildVonPatient ) 
then 
modify($krankheitsbild){setAdipositasGrad("Normalgewicht"), 
setRisikoBegleiterkrankungGrad(1) 
} 
end 



---------------2------------------- 
May be simpler, but beware of loops ... 

rule "..." 
when 
MessdatenVonPatient($patient : patient && (getMessdaten().getBmi() >= 18.5) && 
(getMessdaten().getBmi() < 25)) 
$krankheitsbildVonPatient : KrankheitsbildVonPatient(patient == $patient && 
$krankheitsbild : krankheitsbild) 
then 
$krankheitsbild.setAdipositasGrad("Normalgewicht"); 
$krankheitsbild.setRisikoBegleiterkrankungGrad(1); 
update ( $krankheitsbildVonPatient ) ; 
end 



----- Mail original -----

De: "wichtl" <irr4e...@gmx.net> 
À: rules-users@lists.jboss.org 
Envoyé: Jeudi 30 Août 2012 15:56:29 
Objet: [rules-users] rules not being reconsidered after modify 

Hi, 

I'm new to using Drools and its probably just a problem with me 
understanding how this works, but I've tried everything i can think of, so I 
come to you in hope for some help! 

I have a set of rules which modify an object in the RHS and another set of 
Rules that should be fireing after the modification of the object. 

Rule modifying the Object: 

rule "Wenn der BMI des Patienten >= 18.5 und < 25 ist, dann gehört der 
Patient der Kategorie 'Normalgewicht' an und hat ein 'durchschnittliches' 
Risiko für Begleiterkrankungen des Übergewichts" 
when 
MessdatenVonPatient($patient : patient && (getMessdaten().getBmi() >= 
18.5) && (getMessdaten().getBmi() < 25)) 
$krankheitsbildVonPatient : KrankheitsbildVonPatient(patient == $patient 
&& $krankheitsbild : krankheitsbild) 
then 
modify($krankheitsbild){setAdipositasGrad("Normalgewicht"), 
setRisikoBegleiterkrankungGrad(1) 
} 
end 


Rule that should fire after the modification: 

rule "Wenn Patient der Kategorie 'Normalgewicht' angehoert, dann werden 
folgende Maßnahmen vorgeschlagen" 
when 
KrankheitsbildVonPatient($patient : patient, krankheitsbild.adipositasGrad 
== "Normalgewicht") 
then 
System.out.println("Some Text"); 
end 


Also I have encountered problems (application freezes) when trying to modify 
the "$krankheitsbildVonPatient" object in the RHS. And I still don't 
understand why it did freeze and why modifying "$krankheitsbild" does not. 

Heres my datamodel if needed: 
http://drools.46999.n3.nabble.com/file/n4019463/dataModel.drl dataModel.drl 


Best Regards, 

wichtl 




-- 
View this message in context: 
http://drools.46999.n3.nabble.com/rules-not-being-reconsidered-after-modify-tp4019463.html
 
Sent from the Drools: User forum mailing list archive at Nabble.com. 

_______________________________________________ 
rules-users mailing list 
rules-users@lists.jboss.org 
https://lists.jboss.org/mailman/listinfo/rules-users 

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to