Written by

Question Nicky Zhu · Nov 8, 2024

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

Comments

Nicky Zhu · Nov 8, 2024

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?

0
Eduard Lebedyuk · Nov 8, 2024

Convert xml to FHIR object:

Set payload=##class(HS.FHIR.DTL.vR4.Model.Resource.Organization).FromXML(FHIRxmlStream)
0
Nicky Zhu  Nov 8, 2024 to Eduard Lebedyuk

Thanks Eduard.

It works in this case indeed. While there are still cases for some of our partners to work on XMLs without schema. Is there someway to do it?

0
Nicky Zhu  Nov 10, 2024 to Eduard Lebedyuk

Yes I'm using virtual document thus the xml was loaded as an EnsLib.EDI.XML.Document and saved into BPL context.

While the path about seems not working.

0
Robert Barbiaux  Nov 10, 2024 to Nicky Zhu

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

0