create a rule in programming
HI world , i want to creat my own rule in ensemble without rule editor , how can i do it?
thank's
Comments
Same as with modifying a rule:
Business Rule Definition is stored as XML in XData block named RuleDefinition inside rule class and can be (de)serialized as an object of Ens.Rule.Model.ruleDefinition class. Some utility methods are available there.
Here's an example of modifying Demo.ComplexMap.Rule.SemesterBatchRouting rule in ENSDEMO class. It modifies "when" condition from 1 to 0.
zn "ENSDEMO" set ruleClass = "Demo.ComplexMap.Rule.SemesterBatchRouting" set sc = ##class(Ens.Rule.Model.ruleDefinition).LoadFromClass(ruleClass, .rule) set rule.ruleSets.GetAt(1).actions.GetAt(1).whens.GetAt(1).condition=0 w rule.SaveAs(ruleClass) set sc=$system.OBJ.Compile(ruleClass,"k-d")
But instead of:
set sc = ##class(Ens.Rule.Model.ruleDefinition).LoadFromClass(ruleClass, .rule)
You need to create and fill rule object manually.
Why don't you want to do it in the rule editor?
Hi Eduard , i used this code to edit a rule fields and it functionnes very well, but in my program i take measure of the patient (for example temprature )and i want to creat a rule wich generat alert if temperature is higher than 39°C for example.