You are not telling the rule engine that GlucoseDecisionState has been
updated. You might also like to think about how the GlucoseDecisionState and
GlucoseDecision are related. If you have multiple instances of either class
the rules' behaviour might be unexpected (your RHS's suggest the two are
related but your LHS patterns suggest they are unrelated).
_____
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of J Michael Dean
Sent: 27 November 2007 13:41
To: rules-users(a)lists.jboss.org
Subject: [rules-users] Rule firing problem - must be missing
somethingobvious
I am passing a glucose decision object with a value of 12, and have a state
object that starts out with its flag set false. The desired behavior is
that the value will be recognized as "extremeHypoglycemia" by the first
rule, and then the second rule will recommend giving a glucose bolus.
When I pass both objects in without "true" to cause automatic updating, then
the first rule fires, the output is
false
Fired detect extreme hypoglycemia
true
and then the program stops. It does not fire the second rule.
When I add true to the insertion of these objects, then the program
recurses, and still never hits the second rule. Interestingly, the output is
true
Fired detect extreme hypoglycemia
true
true
Fired detect extreme hypoglycemia
true
...
ETC.
rule "First rule: Detect extreme hypoglycemia"
no-loop true
when
decision : GlucoseDecision( serumGlucoseConcentration < 40 )
decisionState : GlucoseDecisionState(extremeHypoglycemia == false)
then
System.out.println("Fired detect extreme hypoglycemia");
System.out.println(decisionState.isExtremeHypoglycemia());
decisionState.setExtremeHypoglycemia(true);
decision.setRationaleText(decision.getRationaleText() +
"Extreme hypoglycemia (Current glucose is " +
decision.getSerumGlucoseConcentration() +" mg/dL).\n");
System.out.println(decisionState.isExtremeHypoglycemia());
update(decision);
end
rule "Second rule: Give glucose bolus for extreme hypoglycemia"
no-loop true
when
decision : GlucoseDecision()
decisionState : GlucoseDecisionState(extremeHypoglycemia == true )
then
System.out.println("Fired glucose bolus rule");
decisionState.setRecommendedGlucoseBolus(true);
decision.setRationaleText(decision.getRationaleText() +
"Glucose bolus recommended because of extreme hypoglycemia.\n");
end