diff --git a/.gitignore b/.gitignore index d6d9b5e..8eebe32 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ samples/input/*.xml samples/input/*.hl7 samples/output/*.xml +samples/output/xslt/*.xml samples/output/*.hl7* samples/log/*.xml samples/error/*.xml diff --git a/module.xml b/module.xml index 0818e2a..7dd7830 100644 --- a/module.xml +++ b/module.xml @@ -3,7 +3,7 @@ healthcare-hl7-xml - 3.4.0 + 3.5.0 HealthCare HL7 XML eases the implementation of HL7 v.2.x in XML format using InterSystems technology xml interoperability hl7 iris healthconnect diff --git a/samples/output/xslt/.gitkeep b/samples/output/xslt/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/ITB/HL7/BO/XMLOperation.cls b/src/ITB/HL7/BO/XMLOperation.cls index 2f8336b..717cb5e 100644 --- a/src/ITB/HL7/BO/XMLOperation.cls +++ b/src/ITB/HL7/BO/XMLOperation.cls @@ -29,10 +29,13 @@ Method SendHL7XML(pRequest As EnsLib.HL7.Message, Output pResponse As EnsLib.HL7 // convert EnsLib.HL7.Message to XML set tXML = ##class(ITB.HL7.Util.Convert).ER7ToXML(pRequest,.tSC,..MessageSchemaCategory,,,..StripNamespace) if $$$ISERR(tSC) $$$ThrowStatus(tSC) + + // call XML message handler before sending + $$$ThrowOnError(..HandleXMLBeforeSending(tXML, .tXMLToSend)) // send XML through adapter set tAckXML = ##class(%Stream.GlobalCharacter).%New() - $$$THROWONERROR(tSC, ..AdapterSendStream(tXML,.tAckXML)) + $$$THROWONERROR(tSC, ..AdapterSendStream(tXMLToSend, .tAckXML)) if pGetAck { // show received XML @@ -70,6 +73,13 @@ Method AdapterSendStream(pRequest As %Stream.Object, Output pResponse As %Stream { } +/// Handle XML before sending. This method can be overridden to perform transformations in XML before sending message. +Method HandleXMLBeforeSending(pXML As %Stream.Object, Output pXMLToSend As %Stream.Object) As %Status +{ + set pXMLToSend = pXML + quit $$$OK +} + /// Return an array of connections for drawing lines on the config diagram ClassMethod OnGetConnections(Output pArray As %String, pItem As Ens.Config.Item) { diff --git a/src/ITB/Info.cls b/src/ITB/Info.cls index 8c7d0c5..1a81143 100644 --- a/src/ITB/Info.cls +++ b/src/ITB/Info.cls @@ -37,11 +37,12 @@ ///
  • 3.2 - Fixed ITB.HL7.Format.HL7XMLv2, added support to unescape XML inside a CDATA block
  • ///
  • 3.3 - Fixed ITB.HL7.Format.HL7XMLv2, fixed <0> HL7 XML Segment added when no group found in LookUp Table
  • ///
  • 3.4 - Added support for zpm. Supported versions are now only >= 2020
  • +///
  • 3.5 - Added HandleXMLBeforeSending callback for operations, so it can be overridden to transform XML before sending message
  • /// Class ITB.Info Extends %RegisteredObject { -Parameter VERSION = 3.4; +Parameter VERSION = 3.5; Parameter PORTING = 2014; diff --git a/src/ITB/Production/Sample/FileXMLOperationXSLT.cls b/src/ITB/Production/Sample/FileXMLOperationXSLT.cls new file mode 100644 index 0000000..ca54424 --- /dev/null +++ b/src/ITB/Production/Sample/FileXMLOperationXSLT.cls @@ -0,0 +1,33 @@ +/// +/// This is an simple example of an operation that transforms HL7 XML using XSLT before sending the message +/// See ITB.Production.Sample.SimpleXSLT for XSLT sample. +Class ITB.Production.Sample.FileXMLOperationXSLT Extends ITB.HL7.BO.FileXMLOperation +{ + +/// Class name which contains an XData block with XSLT +Property XSLTClass As %String(MAXLEN = 255); + +/// Name of the XData block which contains XSLT +Property XSLTXData As %String(MAXLEN = 255); + +Parameter SETTINGS = "XSLTClass:XSLT,XSLTXData:XSLT"; + +/// Handle XML before sending. This method can be overridden to perform transformations in XML before sending message. +Method HandleXMLBeforeSending(pXML As %Stream.Object, Output pXMLToSend As %Stream.Object) As %Status +{ + set ret = $$$OK + try { + set pXMLToSend = ##class(%Stream.GlobalCharacter).%New() + + // open XSLT XData + Set tXSLT = ##class(%Dictionary.CompiledXData).%OpenId(..XSLTClass_"||"_..XSLTXData).Data + // transform XML using XSLT + $$$ThrowOnError(##class(%XML.XSLT.Transformer).TransformStream(pXML, tXSLT, .pXMLToSend)) + + } catch ex { + set ret = ex.AsStatus() + } + quit ret +} + +} diff --git a/src/ITB/Production/Sample/SimpleXSLT.cls b/src/ITB/Production/Sample/SimpleXSLT.cls new file mode 100644 index 0000000..b979af1 --- /dev/null +++ b/src/ITB/Production/Sample/SimpleXSLT.cls @@ -0,0 +1,19 @@ +/// Simple XSLT that replace ORM_O01.ORDER_DETAIL for TRANSFORMED.ORDER_DETAIL +Class ITB.Production.Sample.SimpleXSLT Extends %RegisteredObject +{ + +XData XSLT +{ + + + + + + + + + + +} + +} diff --git a/src/ITB/Production/TestXMLHL7File.cls b/src/ITB/Production/TestXMLHL7File.cls index 8b593e4..f05693a 100644 --- a/src/ITB/Production/TestXMLHL7File.cls +++ b/src/ITB/Production/TestXMLHL7File.cls @@ -22,7 +22,7 @@ XData ProductionDefinition ITB - HL7FileXMLOperation,HL7FileER7Operation + HL7FileXMLOperation,HL7FileER7Operation,HL7FileXMLOperationXSLT /app/samples/input *.hl7 ITB @@ -30,6 +30,14 @@ XData ProductionDefinition /app/samples/output + + /app/samples/output/xslt + 1 + UTF-8 + ITB + ITB.Production.Sample.SimpleXSLT + XSLT + }