Question
Jonathan Lent · Oct 4

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
10
2 0 4 99
Log in or sign up to continue

As a follow up -- we might do this as a post-processing exercise and just deal with the initial %Save -- but I am curious if the split can happen earlier.

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()

    ///$$$LOGINFO(FaxDateDir_FileName)

    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

}

  • The idea being that we would than implement an OnDelete that would remove the file when the HL7 message is purged.

When and how will the HL7 message be purged ? Shell batch ?

I would assume that @Jonathan Lent has a scheduled purge job in Task Manager; ISC ships HealthConnect with one (Ens.Util.Tasks.Purge) that can be configured for a retention period, along with a few other settings:

If he's overriding the OnDelete method, I suppose it could be used to delete the on-disk file.