Question
· Nov 8

How to handle a XML without Schema in a Business Rule?

Hi guys,

Is it possible to apply business rule on a XML without Schema?

Say, I'm trying to make some business rules on FHIR XML payload. I transferred the XML stream as an EnsLib.EDI.XML.Document in a BPL and passed it to a General Business Rule.

 Set context.xmlDocument = ##Class(EnsLib.EDI.XML.Document).ImportFromLibraryStream(##class(HS.SDA3.QuickStream).%OpenId(request.QuickStreamId))

I'm handling following XML document 

With this rule

Then I got stuck at visiting the elements in the XML.

I.e How may I evaluate the profile value?

 

Thanks。

Product version: IRIS 2024.1
Discussion (6)1
Log in or sign up to continue

It can be down by adding a custom function

Class MDMDemo.Utils.XMLDocumentUtils Extends Ens.Rule.FunctionSet

{

/// GetAt implementation for rulesets

ClassMethod ElementGetAt(ByRef pDocument As EnsLib.EDI.XML.Document, pPath As %String) As %String [ CodeMode = expression, Final ]

{

pDocument.GetValueAt(pPath)

}

}

But is there anyway to directly visit the elements in the rule?

EnsLib.EDI.XML.Document implements Ens.VDoc.Interface, and exposes GetValueAt(propertyPath) method.

This method accepts XPath-like property paths such as "/foo/bar" or "/foo/bar/@attr".

This also means you can use the curly brace syntax in business rules (classes extending Ens.Rule.Definition).

For example, if the context class has a "xmlDocument" property, this expression

xmlDocument.{/foo/bar}

will be compiled into 

xmlDocument.GetValueAt("/foo/bar")