Need to query the rule data from the tables in the InterSystems database
I need read only access using a JDBC query to the tables that contain the rules data for a particular interface. I'm having difficulty locating the tables that house the rule data and I'm wondering if someone could help me with that information and any sample queries if possible.
Thanks in advance!
Comments
Just to clarify a bit:
Are you talking about, for example, HL7 routing rules that are used with the standard business process EnsLib.HL7.MsgRouter.RoutingEngine?
What information do you want to retrieve for the rules?
Yes, I would like to query the rule structure.
Would you mind specify what kind of rule?
Edit to add: note that rules are defined as XML, there is no table available to directly query a rule
I would like to query all rules. Rules of any kind.
As Enrico mentioned, the rule logic is stored as XML in a rule class, so you can't query the logic directly via SQL.
You can find the names of all rule classes using SQL:
SELECT ID FROM %Dictionary.ClassDefinition where Super='Ens.Rule.Definition'
To then view the rule logic you would need to open a class and view the "RuleDefinition" XData block:
Class ORU.RouterRoutingRule Extends Ens.Rule.Definition
{
Parameter RuleAssistClass = "EnsLib.HL7.MsgRouter.RuleAssist";
XData RuleDefinition [ XMLNamespace = "http://www.intersystems.com/rule" ]
{
<ruleDefinition alias="" context="EnsLib.HL7.MsgRouter.RoutingEngine" production="ADTPKG.FoundationProduction">
<ruleSet name="" effectiveBegin="" effectiveEnd="">
<rule name="">
<when condition="1" comment="">
<send transform="Demo.ORUTransformation" target="ORU.Out"></send>
<send transform="Demo.ORUTransformation" target="ORU.Two"></send>
</when>
</rule>
</ruleSet>
</ruleDefinition>
}
}To get the XML rule definition from SQL you can write/define a stored procedure that returns the XML rule definition, then....parse the XML. Something like:
Class Community.Rule.XDATA
{
ClassMethod GetXML(RuleName As%String) As%String(MAXLEN="") [ SqlProc ]
{
Set xdataOBJ = ##class(%Dictionary.XDataDefinition).IDKEYOpen(RuleName,"RuleDefinition")
Quit xdataOBJ.Data.Read($$$MaxLocalLength)
}
}Then from SQL:
select Community_Rule.XDATA_GetXML('Your.Rule.Name')