Question
· Oct 15, 2017

HL7 Email Operation

Dear All,

I'm to create a HL7 business operation that uses the Enslib.Email.OutboundAdapter  to create and use AttachStream() to create a file attachment of the HL7 contents, using the RawContent property of a Enslib.HL7.Message.

The class compiles okay, however   when I send a message to the class I get the following error:

Event Log

')+'

'; content += ''; return content; }, "modalShow": function() { // add ensExceptionModalGroup to class for floating div var modalGroup = EnsException.modalGroup; if (modalGroup) { var div = modalGroup.getFloatingDiv(); if (div) div.className += ' ensExceptionModalGroup'; } // override default behaviour -- user must make a choice var mouseTrap = document.getElementById('zenMouseTrap'); if (mouseTrap) mouseTrap.onmouseup = null; }, "modalDelete": function() { // clean up floating div var modalGroup = EnsException.modalGroup; if (modalGroup) { var div = modalGroup.getFloatingDiv(); if (div && div.parentNode) { div.parentNode.removeChild(div); } } } } window.zenUserExceptionHandler = EnsException.exceptionHandler;
ID:7627513
Type:Error
Text:ERROR <Ens>ErrException: <INVALID OREF>zCopyFrom+2 ^%Library.AbstractStream.1 -- logged as '-'
number - @''
Logged:2017-10-15 00:15:41.566
Source:HL7-2-Email
Session:1680616
Job:7352
Class:CUH.Oper.HL7Email
Method:MessageHeaderHandler
Trace:(none)
Stack:
  • $$^zMessageHeaderHandler+198 ^CUH.Oper.HL7Email.1 +2
  • $$^zOnTask+42^Ens.Host.1 +1
  • DO^zStart+62^Ens.Job.1 +2

I have a genuine email in the recipient (my address) and the SMTP server is the same as we use for our email alerts.

Please could someone assist.

/// A class to send HL7 messages as email attachements
Class CUH.Oper.HL7Email Extends (Ens.BusinessOperation, EnsLib.HL7.Operation.BatchStandard)
{

Parameter ADAPTER = "EnsLib.EMail.OutboundAdapter";

Property Adapter As EnsLib.EMail.OutboundAdapter;

Parameter INVOCATION = "Queue";

Method OnMessage(pinput As EnsLib.HL7.Message, pResponse As Ens.Response) As %Status
{
 Set mail = ##class(%Net.MailMessage).%New()

 Set mail.Charset = "iso-8859-1" 
 Set mail.Subject = "HL7 Message Test"
 Set mail.TextData = "Hl7 Message Test"
 Set tSC = mail.AttachStream(pinput.RawContent,..Filename,1,"iso-8859-1") If $$$ISERR(tSC) Quit tSC
}

}

Discussion (8)0
Log in or sign up to continue

Hi Eduard,

Thank you for your suggestion. I am having trouble getting the OutputToIOStream method to work.

The code I have used in addition to the above is;

 set AttachementStream = pRequest.OutputToIOStream(pIOStream,..Separators,"",1)
 Set tSC = mail.AttachStream(AttachementStream,..Filename,1,"iso-8859-1") If $$$ISERR(tSC) Quit tSC

When I try and pass a HL7 message to the operation I get the following error:

ERROR <Ens>ErrException: <UNDEFINED>zOnMessage+5 ^CUH.Oper.HL7Email.1 *pIOStream -- logged as '-'
number - @'
set AttachementStream = pRequest.OutputToIOStream(pIOStream,..Separators,"",1)'

I am new to handling streams and the documentation isn't helping it make things clearer.

Thank you again Eduard.

I added the set and found a new error:

ERROR <Ens>ErrException: <INVALID OREF>zCopyFrom+2 ^%Library.FileCharacterStream.1 -- logged as '-'
number - @''


Logged: 2017-10-16 12:46:52.131

Source: HL7-2-Email

Session: 1680693

Job: 8932

Class: CUH.Oper.HL7Email

Method: MessageHeaderHandler

Trace: (none)

Stack: 
•$$^zMessageHeaderHandler+198 ^CUH.Oper.HL7Email.1 +2
•$$^zOnTask+42^Ens.Host.1 +1
•DO^zStart+62^Ens.Job.1 +2
 
I can't see what not's being referenced at this point.  I've had a look at the class and believe to be referencing everything correctly.

As you can see in the documentation, method OutputToIOStream returns a status and not a stream (first argument - a stream is written to in this method), so you should write:

Set pIOStream = ##Class(%IO.StringStream).%New()
Set tSC = pRequest.OutputToIOStream(pIOStream,..Separators,"",1)
Quit:$$$ISERR(tSC) tSC
Set tSC = mail.AttachStream(pIOStream,..Filename,1,"iso-8859-1")
Quit tSC