GetSegment() |
Top Previous Next |
Object: EHL7.EHL7Message FileName: EHL7.dll
METHOD
Name: GetSegment() Parameters:
Returns: Object (Segment Object) - The segment object or Nothing on failure. Description: Retrieve a segment object from the current message.
Programming Note: The segment name passed in strSegment must exist in the current message. If nIndex is > 1 the segment for that index must also exist. If nIndex is <= 1 then the first instance of the segment is returned. See The Segment Object for further information about the capabilities of the Segment Object.
See Also: AddSegment(), SegmentExists(), SegmentCount(), GetSegmentByIDX()
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 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") Set oSegment = .GetSegment("PID") If .IsError Then MsgBox .LastError .ClearErrors Exit Sub End If 'Retrieve the 2nd IN1 segment Set oSegment = .GetSegment("IN1",2)
End With End Sub
|