Handling Errors
I have a case where our EMR is sending data, but not all the values needed for the Ancillary are valued properly and causes that message to error/halt processing on the Ancillary system, not ideal but its what they do. I would expect them to still process the message except that 1 field, but they don't.
I want to add validation to make sure certain fields are valued correctly for the Vendor.
So I add some statements to take those items that don't pass this validation out to a batch file with headers.
But I want to email out that batch file. How could I have the Email Operation validate that their is a file to send as an Attachment, if that file exists, use it to define who to send it to and what is included in the message?
Is there a sample of this somewhere?
Thanks
Scott
Comments
I think I found a way to handle it but I am struggling on how to send an Ens.Request message to another Operation in the middle of a DTL. I tried this through a function, but Ensemble does not recognize the SendRequestSync that I am trying to send.
Is it possible to send another message to another Business Operation using Code/Function in the middle of a DTL?
.png)
A reference to the business process (our message router) that the DTL is being run from is stored in %Ensemble.("%Process") and you can use that to do a SendRequestSync.
Be sure to add lots of error handling. DTLs throwing strange errors can be a pain to troubleshoot.
if '$D(%Ensemble("%Process")) {
write "This doesn't work in DTL test mode",!
quit $$$OK
} else {
#dim bp as Ens.BusinessProcess
set req = ##class(Ens.Request).%New()
set bp=%Ensemble("%Process")
set tSC=bp.SendRequestSync("My.Operation",req,.resp)
if $$$ISERR(tSC) {
// Oops... error!
}
quit tSC
}So...
%Ensemble("%Process") should be the Business Process (aka Router) that is calling the original DTL?Yep. It's a reference to the instantiated business process.
I keep getting the following...
ERROR <Ens>ErrException: <UNDEFINED>zTransform+134 ^osuwmc.EpicOMStoMatSysTecsysBkLoad.1 *%Ensemble("FeederScottRouting") -- logged as '-'
number - @'
set bp = %Ensemble("FeederScottRouting")'
.png)
You need to literally use %Ensemble("%Process")... Don't replace "%Process" with the name of your component.
I think $this would also suffice.
$this is a reference to the currently executing DTL. We need a reference to the BP that's calling the DTL.
Code action in DTL
set ^zmm("$this")=$this
set ^zmm("%Ensemble(""%Process"")")=%Ensemble("%Process")TESTING>zw ^zmm
^zmm("$this")="Demo.DTL.ChainTest1"
^zmm("%Ensemble(""%Process"")")="7@EnsLib.HL7.MsgRouter.RoutingEngine"Right.