This because the RawContent field is a %String where MAXLEN is 10000. You will need to get the contents out as a stream. So it'll be like:

s msg=##class(EnsLib.HL7.Message).%OpenId(EnsMsgBodyID)

d msg.OutputToLibraryStream(.msgstream)

s newmsg=##class(EnsLib.HL7.Message).ImportFromLibraryStream(msgstream)

You cannot change the doc type of "msg" as its state is immutable. You'll need to create a clone then change doc type. To create the clone:

s outmsg=msg.%ConstructClone(1)

Also note that not all trigger events (MSH:9.2) share the same doctype either, so you'll need to derive it appropriately. e.g. ADT^A01, ADT^A04, ADT^A05 the doc type is  ADT_A01.

Tony has not followed anybody yet.
Global Masters badges:
Tony has no Global Masters badges yet.