Attaching a document to an email from HL7

Primary tabs

HL7, Ensemble

Hopefully somebody can help with this :

Using healthshare - Ensemble::: I have an HL7 message (ORU^R01) where I have an RTF file embeded into an OBX segment as what appears to be plain text.

example below :

How would I  extract this file out and create an email and attach this RTF file as an attachment?

OBX|1|ED|GP Discharge Letter^GP Discharge Letter||^^TEXT/RTF^^{\E\rtf1\E\ansi\E\ansicpg1252\E\uc0\E\deff0{\E\fonttbl{\E\f0\E\fswiss\E\fcharset0\E\fprq2 Arial;}{\E\f1\E\fnil\E\fcharset0\E\fprq2 Times New Roman;}{\E\f2\E\fnil\E\fcharset0\E\fprq2 calibri;}{\E\f3\E\fnil\E\fcharset0\E\fprq2 arial;}{\E\f4\E\fnil\E\fcharset0\E\fprq2 Courier New;}{\E\f5\E\froman\E\fcharset0\E\fprq2 Times New Roman;}{\E\f6\E\fswiss\E\fcharset0\E\fprq2 calibri;}{\E\f7\E\froman\E\fcharset2\E\fprq2 Symbol;}}\.br\{\E\colortbl;\E\red0\E\green0\E\blue0;\E\red255\E\green255\E\blue255;\E\red255\E\green0\E\blue0;\E\red0\E\green0\E\blue255;}\.br\{\E\stylesheet{\E\s0\E\f0\E\fs24 [Normal];}{\E\*\E\cs10\E\additive Default Paragraph Font;}{\E\s17\E\sa146\E\f5\E\fs22\E\sbasedon0 BODY;}{\E\s18\E\f5\E\fs22\E\sbasedon17 P;}{\E\s19\E\f6\E\fs20\E\sbasedon18 P.MSONORMAL;}{\E\s20\E\f0\E\fs18\E\sbasedon18 P.TITLE;}{\E\s21\E\f0\E\fs16\E\sbasedon18 P.BODY;}{\E\s22\E\f6\E\fs20\E\sbasedon18 LI.MSONORMAL;}{\E\s23\E\f6\E\fs20\E\sbasedon18 DIV.MSONORMAL;}{\E\*\E\cs24\E\f6\E\fs20\E\cb0\E\additive\E\sbasedon10 SPAN.MSONORMAL;}{\E\s25\E\li600\E\f5\E\fs22\E\sbasedon18 .TAB;}{\E\s26\E\sb146\E\sa293\E\f5\E\fs44\E\b\E\sbasedon17 H1;}{\E\s27\E\sb120\E\sa240\E\f5\E\fs36\E\b\E\sbasedon17 H2;}{\E\s28\E\sb93\E\sa186\E\f5\E\fs28\E\b\E\sbasedon17 H3;}{\E\s29\E\sb73\E\sa146\E\f5\E\fs22\E\b\E\sbasedon17 H4;}{\E\s30\E\sb60\E\sa120\E\f5\E\fs18\E\b\E\sbasedon17 H5;}{\E\s31\E\sb46\E\sa93\E\f5\E\fs14\E\b\E\sbasedon17 H6;}{\E\s32\E\sb73\E\sa146\E\f4\E\fs22\E\sbasedon0 PRE;}}\.br\{\E\*\E\generator TX_RTF32 10.1.323.501;}{\E\info{\E\title Discharge Summary}}\.br\\E\deftab1134\E\paperw12000\E\paperh15000\E\margl720\E\margt720\E\margr720\E\margb720\E\pard\E\s17\E\plain\E\f5\E\fs22 {\E\v<%HIDEEMPTYGROUP%>} \E\plain\E\f6\E\fs20\E\b Medical Summary Status: \E\plain\E\f6\E\fs20 {\E\v<%DTAMEDICAL DISCHARGE SUMMARY STATUS%>}In Progress{\E\v<%END%>} {\E\v<%HIDEEMPTYGROUPEND%>} {\E\info\E\comment{\E\v<%HIDEEMPTYGROUP%>} \E\line\E\plain\E\f0\E\fs24\E\cf3 {\E\v<%DTADISCHARGE LETTER - ALREADY SENT TO GP%>}{\E\v<%END%>} {\E\v<%HIDEEMPTYGROUPEND%>}} \E\par\E\trowd\E\trgaph0\E\trleft0\E\trpaddl0\E\trpaddt0\E\trpaddr0\E\trpaddb0\E\trpaddfl3\E\trpaddft3\E\trpaddfr3\E\trpaddfb3\E\clvertalt\E\cellx10275\E\pard\E\s18\E\intbl\E\qr\E\plain\E\f6\E\fs28 Calderdale and Huddersfield \E\plain\E\f6\E\fs32\E\b\E\i\E\cf2\E\cb4\E\chshdng0\E\chcfpat0\E\chcbpat4 NHS \E\plain\E\f6\E\fs32\E\cf2\E\line\E\plain\E\f6\E\fs20\E\b\E\cf4 NHS Foundation Trust               \E\cell\E\intbl\E\row\E\pard\E\pard\E\s18\E\plain\E\f5\E\fs22\E\line\E\par\E\trowd\E\trgaph75\E\trleft0\E\trpaddl75\E\trpaddt75\E\trpaddr75\E\trpaddb75\E\trpaddfl3\E\trpaddft3\E\trpaddfr3\E\trpaddfb3\E\clvertalt\E\cellx5138\E\clvertalt\E\cellx10276\E\pard\E\s18\E\intbl\E\plain\E\f5\E\fs22\E\cell\E\pard\E\s18\E\intbl\E\qr\E\plain\E\f6\E\fs20 Huddersfield Royal Infirmary \E\line Trust Headquarters \E\line Acre Street \E\line Lindley \E\line Huddersfield \E\line HD3 3EA \E\line\E\line\E\plain\E\f6\E\fs20\E\b Main Switchboard: \E\plain\E\f6\E\fs20 01484 342000 \E\line\E\plain\E\f6\E\fs20\E\b Date: \E\plain\E\f6\E\fs20 {\E\v<%CURRENTDTTM%>}21/11/2016 14:13:44{\E\v<%END%>} \E\cell\E\intbl\E\row\E\pard\E\pard\E\s18\E\plain\E\f5\E\fs22 {\E\v<%UDTUK_GPADDRESS%>}{\E\uc0\.br\\.br\{\E\stylesheet{\E\s0\E\f0\E\fs24 [Normal];}{\E\*\E\cs10\E\additive Default Paragraph Font;}{\E\s17\E\sa146\E\f1\E\fs22\E\sbasedon0 BODY;}{\E\s18\E\f1\E\fs22\E\sbasedon17 P;}{\E\s19\E\f0\E\fs18\E\sbasedon18 P.TITLE;}{\E\s20\E\f0\E\fs16\E\sbasedon18 P.BODY;}{\E\s21\E\sb146\E\sa293\E\f1\E\fs44\E\b\E\sbasedon17 H1;}{\E\s22\E\sb120\E\sa240\E\f1\E\fs36\E\b\E\sbasedon17 H2;}{\E\s23\E\sb93\E\sa186\E\f1\E\fs28\E\b\E\sbasedon17 H3;}{\E\s24\E\sb73\E\sa146\E\f1\E\fs22\E\b\E\sbasedon17 H4;}{\E\s25\E\sb60\E\sa120\E\f1\E\fs18\E\b\E\sbasedon17 H5;}{\E\s26\E\sb46\E\sa93\E\f1\E\fs14\E\b\E\sbasedon17 H6;}{\E\s27\E\sb73\E\sa146\E\f4\E\fs22\E\sbasedon0 PRE;}}\.br\{\E\*\E\generator TX_RTF32 10.1.323.501;}\.br\\E\deftab1134\E\paperw12000\E\paperh15000\E\margl720\E\margt720\E\margr720\E\margb720\E\pard\E\s18\E\plain\E\f0\E\fs18 WOODLANDS SURGERY\E\par 5 WOODLANDS ROAD\E\par REDHILL \E\par SURREY\E\par RH1 6EY\E\par\E\pard\E\par }{\E\v<%END%>} \E\line\E\par\E\trowd\E\trgaph75\E\trleft0\E\trpaddl75\E\trpaddt75\E\trpaddr75\E\trpaddb75\E\trpaddfl3\E\trpaddft3\E\trpaddfr3\E\trpaddfb3\E\clvertalb\E\cellx5138\E\clvertalb\E\cellx10276\E\pard\E\s17\E\intbl\E\plain\E\f0\E\fs20  Dear {\E\v<%NAME%>}ZZZPORTAL TWO, DO NOT TOUCH{\E\v<%END%>} \E\cell\E\pard\E\s17\E\intbl\E\qr\E\plain\E\f5\E\fs22\E\cell\E\intbl\E\row\E\pard\E\trowd\E\trgaph0\E\trleft0\E\trpaddl0\E\trpaddt0\E\trpaddr0\E\trpaddb0\E\trpaddfl3\E\trpaddft3\E\trpaddfr3\E\trpaddfb3\E\clvertalb\E\cellx10275\E\pard\E\s17\E\intbl\E\qc\E\plain\E\f6\E\fs28\E\b\E\cf4 DISCHARGE SUMMARY\E\plain\E\f6\E\fs28\E\cf4  \E\cell\E\intbl\E\row\E\pard\E\trowd\E\trgaph0\E\trleft0\E\trpaddl0\E\trpaddt75\E\trpaddr0\E\trpaddb75\E\trpaddfl3\E\trpaddft3\E\trpaddfr3\E\trpaddfb3\E\clvertalc\E\clbrdrl\E\brdrs\E\brdrw15\E\clbrdrt\E\brdrs\E\brdrw15\E\clbrdrr\E\brdrs\E\brdrw15\E\clbrdrb\E\brdrs\E\brdrw15\E\cellx15\E\clvertalt\E\clbrdrl\E\brdrs\E\brdrw15\E\clbrdrt\E\brdrs\E\brdrw15\E\clbrdrr\E\brdrs\E\brdrw15\E\clbrdrb\E\brdrs\E\brdrw15\E\clpadt75\E\clpadft3\E\clpadr75\E\clpadfr3\E\cellx5153\E\clvertalt\E\clbrdrl\E\brdrs\E\brdrw15\E\clbrdrt\E\brdrs\E\brdrw15\E\clbrdrr\E\brdrs\E\brdrw15\E\clbrdrb\E\brdrs\E\brdrw15\E\clpadt75\E\clpadft3\E\clpadr75\E\clpadfr3\E\cellx10291\E\pard\E\s17\E\intbl\E\plain\E\f5\E\fs22\E\cell\E\pard\E\s19\E\intbl\E\plain\E\f6\E\fs20\E\b Patient Name: \E\plain\E\f6\E\fs20 {\E\v<%NAME%>}ZZZPORTAL TWO, DO NOT TOUCH{\E\v<%END%>}\E\line\E\plain\E\f6\E\fs20\E\b Date of Birth: \E\plain\E\f6\E\fs20 {\E\v<%DOB%>}01/01/1970{\E\v<%END%>}\E\line\E\plain\E\f6\E\fs20\E\b Gender: \E\plain\E\f6\E\fs20 {\E\v<%GENDER%>}Male{\E\v<%END%>}\E\line\E\plain\E\f6\E\fs20\E\b Patient Address: \E\plain\E\f6\E\fs20 {\E\v<%ADDRESS%>}38 Blackthorn Drive HUDDERSFIELD  HD3 3SB{\E\v<%END%>} \E\cell\E\plain\E\f6\E\fs20\E\b NHS Number: \E\plain\E\f6\E\fs20 {\E\v<%ALIASPSSN%>}{\E\v<%END%>}\E\line\E\plain\E\f6\E\fs20\E\b Hospital MRN: \E\plain\E\f6\E\fs20 {\E\v<%ALIASPMRN%>}4001043{\E\v<%END%>}\E\line\E\plain\E\f6\E\fs20\E\b Home Telephone:
  • 0
  • 0
  • 412
  • 1
  • 1

Answers

Good evening,

 

I would save the rtf-file locally and then send as attachment.

http://docs.intersystems.com/ens20081/csp/docbook/DocBook.UI.Page.cls?KE...

See attachfile.

 

If successful, it can be deleted.

Edit: Sorry forget the extract problem...

 set FileName = source.GetValueAt("TXA:16") or something else +rtf
 set stream = source.GetValueAt("OBXgrp(6).OBX:5.5")
 set file=##class(%FileBinaryStream).%New()
set filePath = "E:\transfer\smtp\rtfs\"
set file.Filename=Filepath_Filename
set tSc = file.Rewind()
set tSC = file.Write(stream)
set tSC = file.Rewind()
set tSC = file.%Save()

Only a idea, no functional guarantee

Best regards

Armin Gayl

If the embedded file is long enough, then that GetValueAt call will truncate it.  Instead you need to use GetFieldStreamRaw.  You do not need to save the file locally in order to attach it to an email.  If you want to do both, you should use a file operation for saving the file to disk and a separate email operation for sending out the email.

What I would do is extract the file from the HL7 with GetFieldStreamRaw and then store it in a message object.

To make Ensemble send an email you need a custom EMail operation:

http://docs.intersystems.com/ens20161/csp/docbook/DocBook.UI.Page.cls?KE...

Your message object that you send to the email operation needs to have a stream property to hold the file contents.

Your custom email operation will need to create a %Net.MailMessage object to send the mail.  This object is where you attach the file.  You can use the AttachStream method to attach the stream as a file.

http://docs.intersystems.com/ens20152/csp/documatic/%25CSP.Documatic.cls...