· Oct 4, 2021

Removing Embedded PDF before Save%

Before I run down the "overengineered solution" path, I wanted to throw this out to the group.

We will be receiving HL7 messages via TCP/MLLP that have a PDF document stored in a single OBX segment. As the volume is expected to be somewhat high and the documents could be megabytes in size, it would be preferable to save the PDF payload to disk and replace it with a filesystem path before IRIS does it's first Save%. The idea being that we would than implement an OnDelete that would remove the file when the HL7 message is purged.

In trying to find a cutpoint where I can override something to do this, I currently find myself deep in the HL7 parser class -- not somewhere I particularly want to be.

Given the goal and without resorting to saving the whole message out to disk first, is there something simpler I am missing here as far as implementation goes?

Thanks in advance for your opinions!

- Jonathan

Product version: IRIS 2021.1
Discussion (4)2
Log in or sign up to continue

I do something similar to what you are trying to do, I Decode the PDF, save the PDF locally, and return a path to the DTL.

Several on the developer community helped me figure this out...

ClassMethod DecodeBase64HL7ToFile(base64 As %Stream.GlobalBinary, Ancillary As %String, FileName As %String) As %String


    set ArchDir = "/ensemble/data/transfer/AncillaryPDF/"

    set ArchAncDir = ArchDir_Ancillary_"/"

    set FaxDateDir = ArchAncDir_$PIECE($ZDATE($HOROLOG,7)," ",1)_"-"_$PIECE($ZDATE($HOROLOG,7)," ",2)_"-1/"

    if '##class(%Library.File).DirectoryExists(ArchDir)


        do ##class(%Library.File).CreateDirectory(ArchDir)


    if '##class(%Library.File).DirectoryExists(ArchAncDir)


        do ##class(%Library.File).CreateDirectory(ArchAncDir)


    if '##class(%Library.File).DirectoryExists(FaxDateDir)


        do ##class(%Library.File).CreateDirectory(FaxDateDir)




    set Oref = ##class(%FileBinaryStream).%New()


    set Oref.Filename = FaxDateDir_FileName

    Do base64.Rewind()

    While 'base64.AtEnd {

        set ln = base64.ReadLine()

        set lnDecoded = $system.Encryption.Base64Decode(ln)

        do Oref.Write(lnDecoded)


    Do Oref.%Save()

    set PDFFilePath = FaxDateDir_FileName

    return PDFFilePath