Developing Business Rules
Example Rule Classes
[Back] [Next]
   
Server:docs1
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

Ensemble contains various demonstration productions that contain examples of the different rule types. The following sections display an example rule class for each type:

General Business Rule Example
The Demo.ZenService.Bproc.WeatherReport.TempScale class is an example of a general business rule. It is part of the Demo.ZenService.Prod.GetTheWeather production in the ENSDEMO namespace.
The following figure shows how the rule definition looks in the Ensemble Rule Editor:
The following is the class definition:
/// Business rule responsible for mapping an input location 
/// to "F" for Fahrenheit or "C" for Celsius temperature scale.
Class Demo.ZenService.Bproc.WeatherReport.TempScale Extends Ens.Rule.Definition
{

Parameter RuleAssistClass = "Ens.Rule.GeneralBusinessRuleAssist";

XData RuleDefinition [ XMLNamespace = "http://www.intersystems.com/rule" ]
{
<ruleDefinition alias="" context="Demo.ZenService.Bproc.WeatherReport.Context">
<ruleSet name="" effectiveBegin="" effectiveEnd="">
<rule name="" disabled="false">
<when condition="(Location=&quot;US&quot;)||(Location=&quot;USA&quot;)">
<return>"F"</return>
</when>
<otherwise>
<return>"C"</return>
</otherwise>
</rule>
</ruleSet>
</ruleDefinition>
}

}
HL7 Message Routing Rule Example
The Demo.HL7.MsgRouter.XYZRoutingRule class is an example of a HL7 message routing business rule. It is part of the Demo.HL7.MsgRouter.Production production in the ENSDEMO namespace.
The following figure shows how the rule definition looks in the Ensemble Rule Editor:
The following code shows the class definition:
/// Routing from the XYZ message source.
Class Demo.HL7.MsgRouter.XYZRoutingRule Extends Ens.Rule.Definition
{

Parameter RuleAssistClass = "EnsLib.HL7.MsgRouter.RuleAssistCompatible";

XData RuleDefinition [ XMLNamespace = "http://www.intersystems.com/rule" ]
{
<ruleDefinition alias="" context="EnsLib.HL7.MsgRouter.RoutingEngine">
<ruleSet name="" effectiveBegin="" effectiveEnd="">
<rule name="">
<constraint name="msgClass" value="EnsLib.HL7.Message"></constraint>
<constraint name="docCategory" value="Demo.HL7.MsgRouter.Schema"></constraint>
<when condition="(HL7.ParentId!=&quot;&quot;)">
<send transform="" target="Batch_FileOperation"></send>
<return></return>
</when>
</rule>
<rule name="">
<constraint name="msgClass" value="EnsLib.HL7.Message"></constraint>
<constraint name="docCategory" value="2.3.1"></constraint>
<constraint name="docType" value="FHS,BHS"></constraint>
<when condition="1">
<send transform="" target="Batch_FileOperation"></send>
<return></return>
</when>
</rule>
<rule name="">
<constraint name="msgClass" value="EnsLib.HL7.Message"></constraint>
<constraint name="docName" value="ADT_A08"></constraint>
<constraint name="docCategory" value="Demo.HL7.MsgRouter.Schema"></constraint>
<constraint name="docType" value="ADT_A01"></constraint>
<when condition="(Contains(HL7.{PID:PatientName(1).familylastname},&quot;&lt;S&gt;&quot;))
     ||(StartsWith(HL7.{PID:PatientName(1).familylastname},&quot;Z&quot;))">
<send transform="Demo.HL7.MsgRouter.ADTLastNameTransform" target="Other_FileOperation"></send>
<return></return>
</when>
</rule>
<rule name="">
<constraint name="msgClass" value="EnsLib.HL7.Message"></constraint>
<constraint name="docName" value="ORM_O01"></constraint>
<constraint name="docCategory" value="Demo.HL7.MsgRouter.Schema"></constraint>
<constraint name="docType" value="ORM_O01"></constraint>
<when condition="(StartsWith(HL7.{PIDgrp.PID:PatientName(1).familylastname},&quot;S&quot;))
     ||(StartsWith(HL7.{PIDgrp.PID:PatientName(1).familylastname},&quot;Z&quot;))">
<send transform="Demo.HL7.MsgRouter.ORMLastNameTransform" target="Other_FileOperation"></send>
<return></return>
</when>
</rule>
<rule name="">
<constraint name="msgClass" value="EnsLib.HL7.Message"></constraint>
<constraint name="docCategory" value="Demo.HL7.MsgRouter.Schema"></constraint>
<when condition="1">
<send transform="" target="Regular_FileOperation"></send>
<return></return>
</when>
</rule>
</ruleSet>
</ruleDefinition>
}

}
General Message Routing Rule Example
The Demo.HL7.MsgRouter.AlertRule class is an example of a general message routing business rule. It is part of the Demo.HL7.MsgRouter.Production production in the ENSDEMO namespace.
The following figure shows how the rule definition looks in the Ensemble Rule Editor:
The following code shows the class definition:
/// See the AlertTable lookup table for a mapping of alert sources to email addresses.
/// If no match is found in the lookup, EmailAlertTransformation sends the alert
/// to the configured Recipient for the EMailAlertOperation.
Class Demo.HL7.MsgRouter.AlertRule Extends Ens.Rule.Definition
{

Parameter RuleAssistClass = "EnsLib.MsgRouter.RuleAssist";

XData RuleDefinition [ XMLNamespace = "http://www.intersystems.com/rule" ]
{
<ruleDefinition alias="" context="EnsLib.MsgRouter.RoutingEngine">
<ruleSet name="" effectiveBegin="" effectiveEnd="">
<rule name="">
<constraint name="msgClass" value="Ens.AlertRequest"></constraint>
<when condition="1">
<send transform="Demo.HL7.MsgRouter.EmailAlertTransform" target="EMailAlertOperation"></send>
<return></return>
</when>
</rule>
</ruleSet>
</ruleDefinition>
}

}
Virtual Document Message Routing Rule Example
The Demo.HL7v3.Rule.RouteAndTransform class is an example of a virtual document message routing business rule. It is part of the Demo.HL7v3.Production.InterfaceEngine production in the ENSDEMO namespace.
The following figure shows how the rule definition looks in the Ensemble Rule Editor:
The following code shows the class definition:
/// Test rule for HL7 version 3 productions
Class Demo.HL7v3.Rule.RouteAndTransform Extends Ens.Rule.Definition
{

Parameter RuleAssistClass = "EnsLib.MsgRouter.VDocRuleAssistCompatible";

XData RuleDefinition [ XMLNamespace = "http://www.intersystems.com/rule" ]
{
<ruleDefinition alias="" context="Demo.HL7v3.Rule.Context">
<ruleSet name="" effectiveBegin="" effectiveEnd="">
<rule name="" disabled="false">
<constraint name="msgClass" value="Demo.HL7v3.Message"></constraint>
<constraint name="docName" value="MFMT_IN002101"></constraint>
<when condition="1">
<send transform="Demo.HL7v3.Transformation.MFMTIN002101" target="HL7v3 SOAP Out"></send>
<send transform="Demo.HL7v3.Transformation.MFMTIN002101" target="HL7v3 File Out MFMT"></send>
<return></return>
</when>
</rule>
<rule name="" disabled="false">
<constraint name="msgClass" value="Demo.HL7v3.Message"></constraint>
<constraint name="docName" value="QUPA_IN101103"></constraint>
<when condition="1">
<send transform="Demo.HL7v3.Transformation.QUPAIN101103" target="HL7v3 SOAP Out"></send>
<send transform="Demo.HL7v3.Transformation.QUPAIN101103" target="HL7v3 File Out QUPA"></send>
<return></return>
</when>
</rule>
</ruleSet>
</ruleDefinition>
}

}