Question
· May 12, 2021

Comparing HL7 Repeatable Segment/Field to Lookup table

Awhile back the Developer community helped me with a situation I was having... How to loop through a Repeating Segment and Single Filed, example OBX().5, within a Business Process Rule and compare it against a Data Lookup table.

Well now I need to take it a step further. I need a way to loop through OBR() segment, and loop through OBR().4() and the subfield 4.1 and compare it to a Data Lookup table.

So I thought I could copy my existing function code and add another level to it, but its not returning what I would expect.

ClassMethod DoesValueExistRepeatingSegmentFields(pHL7Msg As EnsLib.HL7.Message, pSegment As %String, pField As %String, pSubField As %String, pLookupTable As %String) As %Boolean
{
            #dim tSeg as EnsLib.HL7.Segment
            set tSegCount = pHL7Msg.SegCountGet()
            set i = 1
            Set tFound = 0
            //get new values
            set tval=""
            while ((i <= tSegCount) && (tval="")) {
                        set tSeg = pHL7Msg.GetSegmentAt(i)
                        if (tSeg.Name = pSegment) {
                                    set pField2 = pField_"(*)"
                                    $$$LOGINFO(pField2)
                                    set tRepCount = pHL7Msg.GetValueAt(pField2)
                                    $$$LOGINFO(tRepCount)
                                    For tRep =1:1:tRepCount{
                                        set tID = tSeg.GetValueAt(pField_"("_tRepCount_")"_"."_pSubField)
                                         set tval= ..Lookup(pLookupTabletID)
                                    }                        
                        }
                        set i = i + 1 
            }
            if (tval '= "")
            {
                        Q 1 
            }
            quit 0
}
 
So in a Business Routing Rule I am calling the following...
 
Can someone look over my ClassMethod above and double check my code to see why it is not capturing "tRepCount = pHL7Msg.GetValueAt(pField2)"
tRepCount is returning a 0 when it should be at least 1.
 
Thanks
Scott
Product version: HealthShare 2018.1
$ZV: Cache for UNIX (IBM AIX for System Power System-64) 2018.1.3 (Build 414U) Mon Oct 28 2019 11:24:02 EDT
Discussion (2)1
Log in or sign up to continue