[rules-users] How can I nested rules

leonardo_josue leonardo_josue at yahoo.com.mx
Thu Oct 25 11:24:04 EDT 2012


Hi everybody, I hope some of you can tell me if I can do something with my
problem. 

I have a table in a DB with medical information from too many patients. This
information was captured in paper and after put into the table. The
questions have a sequence, and a few answers depend of other answers, for
example:

P1. Age:____
P2. Gander: 1: Female, 2: Male 
--> if P1 >= 12 and P2 = 1 then go to p3, else go to p5
P3. How many times have you been pregnant? 0, 1, 2, 3, 4, 5, ______ 
--> if number > 1 go to P3 else P5
P4. How many babes were born alive? 0, 1, 2, 3, 4, 5, _______
P5. Do you smoke? 1: no, 2: yes

In the table I have something like this:

mysql> SELECT * FROM table;

|id||P1|P2|P3|P4|P5|STATUS
------------------------------
|1|34|1|3|2|1|NULL
|2|10|1|3|2|1|NULL
|3|21|2|1|1|1|NULL
|4|66|1|0|1|1|NULL
|5|14|2|NULL|NULL|1|NULL
|6|09|1|NULL|NULL|1|NULL

I try to set STATUS = "OK" when information was consistent, i.e. 

ID = 2. A girl of 10 years hardly been pregnant 3 times
ID = 3. A man can't get pregnant or abort
ID = 4. A woman can't abort if the number of times she has become pregnant
is zero

I'll try to use Drools to do something like this.

rule "Age and gender women"
	no-loop	
	when
        p : Person(p1 >= 12 && p2 = 1)
    then
        //execute rule "Pregnant"
end


rule "Pregnant"
	no-loop	
	when
        p : Person(p3 > 1)
    then
        //execute rule "Aborts"
end

rule "Pregnant"
	no-loop	
	when
        p : Person(p4 <= P3)
    then
        //it's ok
        p.Status = 'OK'
end

Is this possible??? I read than you can't nested rules, but I want to know
if exist some way to do. Since now my thanks for any help.

Best regards.
Leo.



--
View this message in context: http://drools.46999.n3.nabble.com/How-can-I-nested-rules-tp4020488.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list