Question Rick Rowbotham · Feb 20, 2025

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

Comments

Marc Mundt · Feb 21, 2025

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?

0
Rick Rowbotham  Feb 24, 2025 to Marc Mundt

Yes, I would like to query the rule structure.

0
Enrico Parisi  Feb 24, 2025 to Rick Rowbotham

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

0
Rick Rowbotham  Feb 27, 2025 to Enrico Parisi

 I would like to query all rules. Rules of any kind.

0
Marc Mundt  Feb 27, 2025 to Rick Rowbotham

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>
}

}
0
Enrico Parisi  Feb 28, 2025 to Rick Rowbotham

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

0