Question
· Feb 20

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!

Product version: IRIS 2023.2
Discussion (6)2
Log in or sign up to continue

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')