This is a very useful event. It allows you to intercept
each message before Chameleon attempts to parse it. This is useful
for:
Logging each incoming message before parsing it.
Sending a generated ACK message.
The following code fragment shows an example of how you might
use this event:
procedure TServerForm.sckServerMessage(Sender: TObject;
Client: TCHMhl7ClientSocket; Message: String);
var
ACK : String;
begin
hl7Engine.WriteToLog('Received an HL7 message');
// We use the CHMconvertLineFeeds function to 'pretty print'
// the HL7 message into a format that can be easily read in
// the log files.
hl7Engine.WriteToLog(CHMconvertLineFeeds(Message));
hl7Engine.ParseMessage(Message, 0);
// Send an ACK or NACK back to the client after parsing the message
trytry// Generate an ACK using the auto-acknowledgement engine
ACK := ackEngine.GenerateAck(Message);
except
on TCHMexception dobegin// The ACK generation failed, so we send back a hard coded NACK
ACK := 'MSH|^~\\&|ACME|ACME_APP|XYZ|XYZ_APP|||NACK|XXX|P|2.4|\rMSA|AA|XXX|\r';
end;
end;
finally
Client.SendMessage(ACK);
end;
end;