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;
|
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
}
}
Comments
RawContent is a string, from docs:
The raw text content of the document. Note that this is a truncated version suitable for use in SQL results and visual inspection, but not a complete or definitive representation of the document.
To get message as a stream use OutputToIOStream method in EnsLib.HL7.Message class.
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.
Adding a recipient to your mail could could eventually improve your result significantly
If no other part of your code does it.
http://docs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cls?…
You should init pIOStream:
Set pIOStream=##Class(%IO.StringStream).%New()
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
Thank you Eduard. This works well now.
I'll make sure I declare everything next time.
I wonder Do I need to call on the recipient, cc, bcc and from details in the adapter settings?