Hi Joey, 

@Arun Tiriveedhi is correct that you need to use square bracket syntax, as this returns a comma delimited list.

I had a case where I had a whitelist of OBR-4.1 values for filtering result messages to a particular system.

@Stephen Renshaw made a great suggestion to create a function to loop through the list and query the lookup table here: https://community.intersystems.com/post/using-lookup-or-exists-repeating-fields-ensemble-business-rule

Regards

Stuart
 

I've tried testing in the console using the %Net.FTP Command.

I ran the following (server name substituted):

do ftpcall.Connect("sftp.ldh.nhs.uk",username,pwd,"990")

I did a zwrite and found the connection was sucessful and on:

I got the following for the Return message:

write !, ftpcall.ReturnMessage
 
Features:
 MDTM
 REST STREAM
 SIZE
 MLST type*;size*;modify*;
 MLSD
 AUTH SSL
 AUTH TLS
 PROT
 PBSZ
 UTF8
 CLNT
 MFMT
 EPSV
 EPRT
End

This says it supports PROT protocol, but I am not sure from the %Net.FTP documentation how to set this feature.

Hi Kevin,

I had gone down your route in the end. 

I had been using the FindSegment method from the EnsLib.HL7.Message, which uses the 2nd input variable, however I was having issues implementing the key byref.

Creating my own counter using the same as you suggested with   

"set obxCounter=source.GetValueAt("PIDgrpgrp("_(1)_").ORCgrp("_(1)_").OBXgrp("_("*")_")") "  and then using the full HL7 segment structure to retrieve the fields removed all woes.

Thank you Vic for your help too, I think my use of the FindSegment method was causing my issues.

Excerpt of Code as Promised:

set list = "ABC~DEF~GHI~JKL~MNO~[~PQR~]"

set SegmentList = $LISTFROMSTRING(list,"~")
Set SegmentCount = $LISTLENGTH(SegmentList)
FOR i = 1:1:SegmentCount{
IF ($LISTGET(SegmentList,i,i)= "[") {
set $LIST(SegmentList,i,i)=""
set OptionalSegment = "Y" 
}
ELSEIF ($LISTGET(SegmentList,i,i)= "]") {
set $LIST(SegmentList,i,i)=""
}
ELSEIF ($LISTGET(SegmentList,i,i)= "") {
QUIT
}
Write !, "Current Segment: "_$LISTGET(SegmentList,i,i)
Set SegmentFields = $LISTFROMSTRING(object.SegmentSubStructure,"~")
Set SegFieldCount = $LISTLENGTH(SegmentFields)