GetSegmentByIDX()

Top  Previous  Next

Object: EHL7.EHL7Message

FileName: EHL7.dll

 

METHOD

 

Name: GetSegment()

Parameters:

1.nIndex (Long) The index of the segment to retrieve.

Returns: Object (Segment Object) - The segment object or Nothing on failure.

Description: Retrieve a segment object from the current message.  Passing 1 in nIndex will retrieve the MSH segment object.

 

Programming Note: The segment index passed in nIndex must exist in the current message (i.e. <= the return value of .SegmentCount method). 

 

See Also: AddSegment(), SegmentExists(), SegmentCount(), GetSegment(), SegmentName()

 

Example:

Private Sub MessageTest()

Dim myVendorObj As New EHL7.HL7Vendors

Dim myMsg As New EHL7.EHL7Message

Dim strVendorID As String

Dim oSegment As Object

Dim oMSH As Object

Dim i As Long, j As Long

myVendorObj.VendorPath = "C:\EasyHL7"

strVendorID = myVendorObj.GetVendorID("Default","2.3")

If strVendorID = "" Then

    MsgBox myVendorObj.LastError

    Set myVendorObj = Nothing

    Exit Sub

End If

If Not MyVendorObj.OpenVendor(strVendorID) Then

    MsgBox myVendorObj.LastError

    Set myVendorObj = Nothing

    Exit Sub

End If

With myMsg

   Set oMSH = .CreateMessage(myVendorObj)

   If .IsError Then

     MsgBox .LastError

     .ClearErrors

     Exit Sub

   End If

   Call .AddSegment("EVN")

   Call .AddSegment("SCH")

   Call .AddSegment("NTE")

   Call .AddSegment("PID")

   Call .AddSegment("IN1")

   Call .AddSegment("IN2")

   Call .AddSegment("IN1")

   Call .AddSegment("IN2")

   j = .SegmentCount()

   For i = 1 To j

      Set oSegment = .GetSegmentByIDX(i)

      MsgBox "Segment " & i & " = " & .SegmentName(oSegment)

      If .IsError Then

        MsgBox .LastError

        .ClearErrors

        Exit Sub

      End If

   Next

End With

End Sub