CreateMessage()

Top  Previous  Next

Object: EHL7.EHL7Message

FileName: EHL7.dll

 

METHOD

 

Name: CreateMessage()

Parameters:

1.objVendor (Vendor Object)
2.bIncludeDefault (optional Boolean default = False)

Returns: Object (Segment Object) - The segment object for the MSH segment.

Description: This method will initiate the creation of an HL7 message using an opened vendor object.  If bIncludeDefault is passed as [True] then IF Extended Element Properties (with default values) have been set up for any elements in the MSH segment the default values will be populated.  If bIncludeDefault is passed as [False] (the default) then default values configured in the vendor definitions will be ignored.

 

*NOTE*: Regardless of whether default values have been configured in the Extended Element Properties for the MSH segment, the following values are automatically set in the MSH Segment when the CreateMessage() method is called.  They can, of course be overwritten by you in subsequent  SetFieldValue()method calls.

MSH - 1: Is set to the Field Delimiter designated in the Vendor Definition (this cannot be changed in a subsequent SetFieldValue() call.
MSH - 2: Is set to the Encoding Characters designated in the Vendor Definition  (this cannot be changed in a subsequent SetFieldValue() call.
MSH - 7: (Date Time of Message) is set to the current system time in 'yyyymmddhhnnss' format.
MSH - 10: (Message Control ID) is set to a control number derived from the system date and a sequential number that accumulates beginning at the instantiation of the vendor object passed in objVendor.
MSH - 12: (HL7 Version) is set to the VendorVersion Property of the Vendor object passed in objVendor.
MSH - 13: (Message Sequence) is set to "1" (no leading zeroes).

 

Example:

Private Sub MessageTest()

Dim myVendorObj As New EHL7.HL7Vendors

Dim myMsg As New EHL7.EHL7Message

Dim strVendorID As String

Dim oSegment 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 oSegment = .CreateMessage(myVendorObj)

   If .IsError Then

     MsgBox .LastError

     .ClearErrors

     Exit Sub

   End If

   MsgBox "Default Control Number = " & .GetFieldValue(oSegment,10)

   MsgBox "Message Created = " & .GetFieldValue(oSegment,7)

End With

End Sub