************************************************************************ * Create the Objects that listen for messages * Using the Symphonia HL7 Communication componenets ************************************************************************ ovfpcomm = CREATEOBJECT('vfpCom.comutil') vfpsockevent = NEWOBJECT("_IConnectionFactoryEvents") sockfactory = CREATEOBJECT("S2TCPComms.TCPConnectionFactory.1") ************************************************************************ * Define The Parser Control for decoding the messages ************************************************************************ oparser = CREATEOBJECT("pbaradt.inputParser.1") IF VARTYPE(oParser)!=[O] =MESSAGEBOX("Could not create oParser - pbaradt.inputParser",16,"PBARLIST",20000) ENDIF ************************************************************************* * Bind the HL7 Message events so that VFP can do something when they * (messages) are received ************************************************************************* ovFpcomm.bindEvents(sockfactory,vfpSockEvent) ************************************************************************* * Tell it which port to listen on and to start listening ************************************************************************* sockfactory.listen(lcPortid) read events ************************************************************************** * Here is the message class factory code that is bound to events ************************************************************************** DEFINE CLASS _IConnectionFactoryEvents AS CUSTOM PROCEDURE NewMessage LPARAMETERS CONNECTION *********************************************************** * This event fires when we receive a message * from the remote system *********************************************************** ***************************************************************** * Get the message from the connection object into a string * varaible, and save it as a file ***************************************************************** dataReceived = CONNECTION.readmessage STRTOFILE(dataReceived, lcFile, 0) ***************************************************************** * Send Ack back to other system ***************************************************************** CONNECTION.sendmessage(oack.parse) ***************************************************************** * Parse and Process Message ***************************************************************** do ParseMsg with lcFile EndProc ENDDEFINE