AddSegment()

Top  Previous  Next

Object: EHL7.EHL7Message

FileName: EHL7.dll

 

METHOD

 

Name: AddSegment()

Parameters:

1.strSegment (String) the name of the HL7 Segment to add.
2.bIncludeDefault (optional Boolean default = False)

Returns: Object (Segment Object) - The segment object that was created.

Description: Adds a segment to the current message

 

Programming Notes:

1.The segment name passed in strSegment must exist in the HL7 definition of the vendor being used to create the message. 
2.The MSH segment is automatically created, see CreateMessage()
3.EasyHL7 does not validate the sequential validity of the message, segments will appear in the message in the order in which they are added.  It is up to you to add the segments in the correct order (if applicable) for the type of hl7 message you are creating.
4.If bIncludeDefault is passed as [True] then IF default values have been set up in the vendor definitions, the default values will be populated for all elements in the segment.  If bIncludeDefault is passed as [False] (the default) default values configured in the vendor definition are ignored.  See Extended Element Properties.

 

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, True)

   If .IsError Then

     MsgBox .LastError

     .ClearErrors

     Exit Sub

   End If

   Set oSegment = .AddSegment("EVN",True)

   If .IsError Then

     MsgBox .LastError

     .ClearErrors

     Exit Sub

   End If

End With

End Sub