MessageReadObject

Top  Previous  Next

<----------New In Version 4.x---------->

Object: EHL7.HL7File

FileName: EHL7.dll

 

EVENT

 

Name: MessageReadObject

Parameters:

1.nMessage (Long) the sequential message number (1-nnn)
2.oMsgObject (Object) a fully instantiated loaded EHL7Message Object containing the HL7 message

 

Description: During processing of a file the three events that fire that allow you to interface with the object during processing are MessageRead, MessageReadObject and MessageProcessed.  MessageRead always fires first, followed by MessageReadObject and then MessageProcessed.  MessageRead will present the HL7 message in HL7 format to your application and MessageProcessed presents the message in XML Format.  The MessageReadObject event will pass a fully loaded EHL7Message object for your application to use to extract the HL7 data easily.

 

See Also: KeepMessagesInMemory, MessageProcessed

 

 

 

Example:

'At Class or Form Declaration Level

Private WithEvents myFileObj As EHL7.HL7File

 

'On Initialize or Load

Set myFileObj = New EHL7.HL7File

myFileObj.VendorPath = "C:\EasyHL7"

 

'On Terminate or Unload

Set myFileObj = Nothing

 

 

'Event Handlers for this new event

Private Sub myFileObj_MessageReadObject(nMessage As Long, oMsgObject As EHL7.EHL7Message)

   Dim oMSH As Object

   Dim oPID As Object

   Dim sEvent As String, sType As String, sTypeEvent As String, sControl As String

   Dim sPatientID As String, sPatientLN As String, sPatientFN As String

   With oMsgObject

        If Not .SegmentExists("PID") Then Exit Sub

        Set oMSH = .MSHObject

        sType = .GetFieldValue(oMSH, 9, 1)

        sEvent = .GetFieldValue(oMSH, 9, 2)

        sTypeEvent = sType & sEvent  'We'll concatenate the 2

        sControl = .GetFieldValue(oMSH, 10, 1)

        Set oPID = .GetSegment("PID")

        sPatientID = .GetFieldValue(oPID, 3, 1)

        sPatientLN = .GetFieldValue(oPID, 5, 1)

        sPatientFN = .GetFieldValue(oPID, 5, 2)

        

        Select Case sTypeEvent

          Case "ADTA08", "ADTA04"  'Patient Add, Modify

              LoadPatientDataToDB oMSGObject

          Case "ORU","ORUR01"      'Lab, Radiology or Other Result 

              LoadResultToDB oMSGObject

        End Select 

   End With

End Sub

 

 

 

'Command Button

Private Sub Command1_Click()

Dim myVendorObj As New EHL7.HL7Vendors

Dim strVendorID As String

Dim iCnt As Long, i As Long

Dim strMsg As String

'Note that here we are not going to accumulate the HL7 messages in

'memory because we are using the event to process the message.

myFileObj.KeepMessagesInMemory = False

myVendorObj.VendorPath = "C:\EasyHL7"

strVendorID = myVendorObj.GetVendorID("Default","2.3")

'Now open a file

If Not MyFileObj.OpenFile("C:\Test.hl7", strVendorID, -1)

       MsgBox myFileObj.LastError

      myFileObj.ClearErrors

      Exit Sub

End If

End Sub

 

Private Sub ProcessHL7Message(strHL7 As String)

'Code to Process HL7

End Sub

 

Private Sub ProcessXMLMessage(strXML As String)

'Code to Process XML

End Sub

 

 

Private Sub myFileObj_MessageProcessed(nMessage As Long, sHL7XML As String)

Call ProcessXMLMessage(sHL7XML)

End Sub

 

Private Sub myFileObj_Process(nFunction As Long, nFunctionCount As Long, nPct As Long, strMessage As String)

Label1.Caption = "Process " & nFunction & " of " & nFunctionCount & " is " & nPct & "% complete"

Label2.Caption = strMessage

DoEvents

End Sub

 

Private Sub myFileObj_ProcessCompleted()

If myFileObj.Cancel Then

  MsgBox "Process Cancelled"

Else

MsgBox "Process Completed"

End If

End Sub

 

Related Items: EasyHL7 Events in VB