Published on InterSystems Developer Community (https://community.intersystems.com)

Home > Programmatically define new message and segment without %Clone

Question
Salma Sarwar · Oct 6, 2020

Programmatically define new message and segment without %Clone

Hi

 

I would like to create a new message of a particular type and append various segments programmatically.  I have started with the following snippet.  What I am currently finding difficult is to define a segment of a particular segment structure.  I would like to append a pid segment of 2.3.1 to my message.  I know I could you the importfromstring but I wanted to know whether there was a better way of achieving this.

 

Set tOutputMessage = ##class(EnsLib.HL7.Message).%New()
Set target.DocType="2.3.1:DFT_P03"

#Dim tPID As EnsLib.HL7.Segment

s tPID.SegTypeName ="PID"

Any help would be much appreciated.

 

Kind Regards,

 

Salma

#Code Snippet #HL7 #Caché #HealthShare

Source URL:https://community.intersystems.com/post/programmatically-define-new-message-and-segment-without-clone