Title: Can rules fire while executing RHS of another rule?
Hello again,
It looks like rules can get activated from some assertion happening in the RHS of another rule, but the firering only happens after...
Indeed (you must think I am crazy about aspirin:-):
(defrule SCRIPT_AGE_HIGH
(script ?script ?request ?context & :(> (get (get ?context patient) age) 65))
=>
(call ?script addInstruction (new OrmedScriptInstruction "000" "Attention, patient agé" FALSE FALSE TRUE TRUE))
)
(defrule KEY_SCRIPT0
(OrmedRequest
(key "script")
(ormedContext ?c)
(OBJECT ?r)
)
(OrmedContext
(selectedCompleterResponse ?s & :(and (neq ?s nil) (eq "ASP" (get ?s key))))
(OBJECT ?c)
)
=>
(bind ?n (new OrmedScript "ASP" "Apirines diverses"))
(call ?n addInstruction (new OrmedScriptInstruction "ASP1" "Aspirine Cardio (100mg)" FALSE TRUE TRUE TRUE))
(call ?n addInstruction (new OrmedScriptInstruction "ASP2" "Aspirine 500mg" FALSE TRUE TRUE TRUE))
(call ?n addInstruction (new OrmedScriptInstruction "ASP3" "Aspirine 1000mg" FALSE TRUE TRUE TRUE))
(bind ?fact (assert (script ?n ?r ?c)))
(call ?r setValue ?n TRUE)
(retract ?fact)
)
Works fine if I remove the last retract. However, if I don’t do the retract, I am gradually “polluting” my database.
What I am trying to do here is provide a way to add some “last minutes info” to a script being built by a rule. Indeed, once I call setValue in my OrmedRequest, the OrmedRequest is undefinstanced.
Thanks,
Alex
--
Alexander Lamb
Groupe Serveurs Applicatifs
Division d'Informatique Médicale
Hôpitaux Universitaires de Genève
21 rue Micheli-du-Crest
CH-1211 Genève 4 / Switzerland
Tel: +41-22 372.48.46 Fax: +41-22 382.86.80
[EMAIL PROTECTED] / http://www.hcuge.ch
