Question
· Aug 19, 2021

Embedded PDF's - GetFieldStreamRaw & StoreFieldStreamRaw

Hello,

When using GetFieldStreamRaw(), by passing in a variable instead of using an output for the Remainder, will this affect how it is stored into a segment in a cloned message? I know it would usually output the remaining fields of the segment but in order to conform to a supplier's spec, they'd require "^^PDF" rather than the rest of the segment. Because the segment becomes immutable, the code below seems to be the way to do it. This code is working, but I'm curious if by passing in a variable rather than referencing the Remainder output, it will somehow truncate the embedded PDF when I store it into the OBX segment using StoreFieldStreamRaw().

This first block of code is getting the embedded PDF and storing it into a stream but is passing in a variable of Remainder rather than referencing an output of the remaining fields.

If $ISOBJECT(MsgIn.FindSegment("OBX"))
{
    Set OBX=MsgIn.FindSegment("OBX",.IDx,.tSC)
    While IDx'=""
    {
       If OBX.GetValueAt(2)="ED"
       {
          Set Remainder="^^PDF"
          Set EmbeddedPDF=OBX.GetFieldStreamRaw(.Stream,5.5,Remainder)
       }
       Set OBX=MsgIn.FindSegment("OBX",.IDx,.tSC)
   }
}

The stream is then passed to another method as a stream object of %Stream.TmpCharacter which executes the block of code below. It is creating the OBX segment and storing the stream into OBX:5.1 whilst using my variable as the remainder.

Set OBX=##class(EnsLib.HL7.Segment).%New()
Set tSC=OBX.SetValueAt("OBX",0)
Set tSC=OBX.SetValueAt("RP",2)
Set tSC=OBX.StoreFieldStreamRaw(EmbeddedPDF,5.1,Remainder)

 

Thanks

Product version: IRIS 2020.1
Discussion (1)1
Log in or sign up to continue

Hi Jordan,

Looking at the method implementation, the Remainder is being overwritten from the method. So your assignment before GetFieldStreamRaw() method call is not considered.

Set Remainder="^^PDF"

If you need to set the "^^PDF" at the end of the segment, I would set it before Storing the stream.

Set tSC=OBX.SetValueAt("OBX",0)
Set tSC=OBX.SetValueAt("RP",2)
Set tSC=OBX.SetValueAt("PDF",5.4)
Set tSC=OBX.StoreFieldStreamRaw(EmbeddedPDF,5.1,Remainder)