Don't you think the problem might be StoreFieldStreamBase64 using Base64Encode from %SYSTEM.Encryption with default flags value at 0 ?
I'll try encoding the stream myself and using StoreFieldStreamRaw instead of StoreFieldStreamBase64
If my solution doesn't work i'll try yours :)
Thanks
Second option : An OBX:5 with the value ABCDEFGHIJKL (get rid of all crlf)
[Updated last comment with code]
I need to add a file inside the obx:5(1) segment as a base64 encoded stream.
I'm using the StoreFieldStreamBase64 method from EnsLib.HL7.Segment.
This method add extra escaped CRLF inside my OBX segment and i don't know why.
When i write the hl7 message on disk with the new OBX segment, i can't parse it anymore with an EnsLib.HL7.Service.FileService, the extra crlf character is the problem.
Maybe i'm doing something wrong in my way to process the file.
Encoding the stream myself using Base64Encode and flags set to 1 fixed my problem.
There is no CRLF anymore in my stream.
Here is my final solution (error handle ommited)
s stream.Filename = filename
s encodedStream = ##class(%GlobalBinaryStream).%New()
while ('stream.AtEnd) {
d encodedStream.Write(##class(%SYSTEM.Encryption).Base64Encode(stream.Read(12000),1))
}
s propertyPath = "PIDgrpgrp(1).ORCgrp(1).OBXgrp(1).OBX:5(1)"
s seg=target.GetMutableSegmentAt($P(propertyPath,":",1),.tSC)
s tSC = seg.StoreFieldStreamRaw(.encodedStream,$P(propertyPath,":",2))
Thanks Armin for your help.