Question
· Dec 11, 2023

Transforming from HL7 to XML with OBX 5 Stream

Hi all

I'm having trouble defining the mapping needed to take the very large base64 string in OBX:5.5, and map it to an XML virtual document property that supports Stream.GlobalCharacter. I know from within the DTL you have to use custom code to manage the segment due to its size. 

do target.StoreFieldStreamRaw(.stream,"LetterAttachment(1).Base64EncodedFile(1)", .rem)
 set tObx14Value = $piece(rem,"|",10)
 set convertedDate = ##class(Phu.Shared.Util.DateTime).ConvertHl7DateTimeToXmlDateTime(tObx14Value)
 do target.SetValueAt(convertedDate,"DocumentDetails(1).AuthoredDate(1)")
 do target.SetValueAt(convertedDate,"DocumentDetails(1).CreatedDate(1)")

The above code errors as StoreFieldStreamRaw is only a HL7 concept. I've tried the following, which doesn't error but the SetValueAt is limited to the 3mb size limit:
do source.GetFieldStreamRaw(.stream, "PIDgrpgrp(1).ORCgrp(1).OBXgrp(1).OBX:5(1).5", .rem)
 do target.SetValueAt(stream,"LetterAttachment(1).Base64EncodedFile(1)")
 set tObx14Value = $piece(rem,"|",10)
 set convertedDate = ##class(Phu.Shared.Util.DateTime).ConvertHl7DateTimeToXmlDateTime(tObx14Value)
 do target.SetValueAt(convertedDate,"DocumentDetails(1).AuthoredDate(1)")
 do target.SetValueAt(convertedDate,"DocumentDetails(1).CreatedDate(1)")

I want to be able to take OBX:5.5 from the HL7 message and copy it to the XML document, as well as set the Authored Date and Created Date (the latter 2 work without issue). 

How can I copy/set the stream from OBX:5.5 to the XML Property?

Thanks in advance
 

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

I was reviewing the documentation and I think that the only option available is to split your base64 by the MAXSTRING limit and append all the pieces that you get using SetValueAt defining the action as append:

method SetValueAt(pValue As %String, 
                  pPropertyPath As %String, 
                  pAction As %String = "set", 
                  pKey As %String = "") as %Status

It could be something like:

Do stream.Rewind()
While (stream.AtEnd = 0) {
    // Not sure about the len
    Set len = 3641144
    do target.SetValueAt(stream.Read(.len), "LetterAttachment(1).Base64EncodedFile(1)", "append")
}

Yeah, probably is your best option.

Anyway, I think that you could add the pieces of the base64 field as values of the Base64EncodedFile list removing the (1) in my code:

Do stream.Rewind()
While (stream.AtEnd = 0) {
    // Not sure about the len
    Set len = 3641144
    do target.SetValueAt(stream.Read(.len), "LetterAttachment(1).Base64EncodedFile", "append")
}

The problem of this is that you couldn't include more documents attached because all the list would belong to just one document.