DTL Transformations and GetValueAt/SetValueAt calls on HL7 messages will truncate any fields longer than 32K. To avoid this, the methods GetFieldStreamRaw and StoreFieldStreamRaw must be used when dealing with fields that might be larger than 32K. OBX:5 is a frequent example. These methods have some subtleties and must be used carefully.
This can't be done by simply dragging from left to right in a DTL. It must be done with a code action. Also, the StoreFieldStreamRaw call must be the last edit made to the segment because the segment becomes immutable after that.
StoreFieldStreamRaw takes 3 arguments: The stream to put in the field, the VDoc path of the field in which to store the stream, and a pRemainder argument. If the pRemainder argument isn't specified, then all fields after the field being stored are blown away. If pRemainder is specified, then all fields after the one being stored are replaced with what's in pRemainder.
after StoreFieldStreamRaw(stream, "OBX:5")
(notice fields 6 and 7 are gone).
after StoreFieldStreamRaw(stream, "OBX:5", "|six|seven"):
Likewise, GetFieldStreamRaw takes 3 arguments: the stream output argument, the VDoc path of the field, and the pRemainder output argument. pRemainder will be filled with all fields after the one being extracted.
after GetFieldStreamRaw(stream, "OBX:5", .rem)
rem contains "|6|7"
So, to put it altogether, we want to extract the field from the source and store it in the target. But we don't want to take the remainder from the source and store that in the target because it will revert any edits we already made to fields after the long field in the target. Therefore, what we want to do is take the stream field from the source, but the remainder from the target, and store both of those in the target like this:
do source.GetFieldStreamRaw(.stream, "OBX:5") do target.GetFieldStreamRaw(.dummy, "OBX:5", .rem) do target.StoreFieldStreamRaw(stream, "OBX:5", rem)
Doing it this way prevents the previous edits made to fields after OBX:5 in the target from being reverted or deleted.