CreateFromXML() |
Top Previous Next |
Object: EHL7.EHL7Message FileName: EHL7.dll
METHOD
Name: CreateFromXML() Parameters: strXML (String) An EasyHL7 HL7 message in XML format Returns: Boolean Description: This method will populate the current message from an xml string that has been created with EasyHL7
Programming Note: The XML structure must match the EasyHL7 xml structure exactly or unexpected results will occur. Also, when importing the message contents, the currently opened vendor is NOT used to apply edits or errorchecking to the message, thus it's possible to export (saveXML) a message from Vendor A, and open it using this method with vendor B
Example: Private Sub MessageTest() Dim myVendorObj As New EHL7.HL7Vendors Dim myMsg As New EHL7.EHL7Message Dim myMsg2 As New EHL7.EHL7Message Dim strVendorID As String Dim strXML 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 Set oSegment = .AddSegment("EVN") If .IsError Then MsgBox .LastError .ClearErrors Exit Sub End If strXML = .HL7XML End With With myMsg2 SetVendorObj myVendorObj If Not .CreateFromXML(strXML) Then MsgBox .LastError .ClearErrors Exit Sub End If MsgBox "myMsg2 is now an exact copy of myMsg" End With End Sub
|