SegmentCount()

Top  Previous  Next

Object: EHL7.EHL7Message

FileName: EHL7.dll

 

METHOD

 

Name: SegmentCount()

Parameters: strSegment (Optional String) Default = "", the name of the HL7 Segment to count instances of.

Returns: Long

Description: Returns a count of the instances of a specific segment name within the current message.  If no segment name is passed, returns the total segment count for the current message including the MSH segment.

 

 

See Also: AddSegment(), GetSegment()

 

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 iCnt 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("NTE")

   Call .AddSegment("NTE")

   Call .AddSegment("PID")

   Call .AddSegment("IN1")

   Call .AddSegment("IN2")

   Call .AddSegment("IN1")

   Call .AddSegment("IN2")

  iCnt = .SegmentCount("NTE")

   MsgBox "There are " & iCnt & " NTE segments in the current message"

  iCnt = .SegmentCount("IN1")

   MsgBox "There are " & iCnt & " IN1 segments in the current message"

   'Now show the total

   iCnt = .SegmentCount()

   MsgBox "There are " & iCnt & " total segments in this message"

End With

End Sub