Question
· Sep 14, 2018

Business Rule Looping

Does anyone know how to loop through a segment that is part of an ordered set in a Business Rule and if one of about 10 possible values exist in any of the iterations of the segemnt:field I then allow the message to be skipped?

It seems like it should be fairly simple, but i am having a difficult time figuring this out. The Contains function only allow for one value to be identified. I have tried the intersectsList and while I think I have it formatted correctly i believe it only allows for 4 values to be verified. 

Discussion (5)1
Log in or sign up to continue

We've have done something similar but wrote a function to do the looping... This example loops through a given segment and field and looks that value up against a lookup table. This could be modified for your use. This is the only way I know to do the looping within the BusinessRule.

ClassMethod GroupIDExists(pHL7Msg As EnsLib.HL7.Message, pSegment As %String, pField As %String, pLookupTable As %String) As %Boolean
{
            #dim tSeg as EnsLib.HL7.Segment
            
            set tSegCount = pHL7Msg.SegCountGet()
            set = 1
            Set tFound = 0
            //get new values
            set tval=""
            while ((<= tSegCount) && (tval="")) {
                         
                        set tSeg = pHL7Msg.GetSegmentAt(i)
                        if (tSeg.Name = pSegment) {
                                    set tID = tSeg.GetValueAt(pField)
                                    set tval= ..Lookup(pLookupTable, tID)
                                                            
                        }
                        set = + 1
            }
            if (tval '= "")
            {
                        1
            }
            quit 0
}