Question
· May 6, 2020

How are the request and response messages saved in the messageheader table?

Hi, 

I want to insert custom hook into message send and receive flow. for example:

1. parse request or response message, pick up bussiness field to do bussiness logic

Is it have method to do this? 

Tks.

Discussion (4)1
Log in or sign up to continue

I need pick bussiness field from message body on more high level , I don't want to modify every process logic.

And if the business service is builtIn process not custom process.  for example:

EnsLib.HL7.Service.TCPService -> EnsLib.HL7.Operation.TCPOperation

above flow will insert hl7 request and response to table EnsLib_HL7.Message and other message tables. 

I want to get message body to parse it before insert.

But The EnsLib.HL7.Service.TCPService   and EnsLib.HL7.Operation.TCPOperation is builtIn .

So I think ensembe is provide some hook like before and after

EnsLib.HL7.Service.TCPService ->before hook ->sendSync->After hook-> EnsLib.HL7.Operation.TCPOperation

Thank You.

Hi Alex,

I think when your message is inserted into EnsLib.HL7.Message, it is already parsed... you just need to extract specific data from specific fields.  EnsLib.HL7.Message  class provides lots of methods that you might be able to use. Here is a fairly simple way to do what you need I think:

1) Add a special Business Process type to your Production called "HL7 Router" - you can go to HL7 Router tab in the Business Process Wizard. You can check "Auto-Create Rule" so that it would create your first Routing Rule. You just need to put some name into HL7 Routing Process Name box (it automatically picks the class EnsLib.HL7.MsgRouterRoutingEngine). Your HL7 router will sit between your HL7 Service and HL7 Operation.

2) Create a custom Business Operation (extend Ens.BusinessOperation) and define one method (call it "processHL7Message") that would take EnsLib.HL7.Message object as input. You can now call the following Properties and Methods of EnsLib.HL7.Message:

- Property SeqCount - total number of Segments in the message

- Method GetSegmentAt(segmentCounter).GetValueAt(0): Get the type of the segment (each segment type is in field 0 i.e., MSH, PID, PV1 etc..)

- Method GetSegmentByIndex or GetMutableSegmentByIndex(segmentCounter): Get message Segment object

  Once you get the Segment object you can call GetValueAt(segmentField) - passing in "field.subfield" - for field PID:3.1 you would pass "3.1"

3) Your HL7 Router will have 2 routing rules: the first one will simply pass the message to Enslib.HL7.Operation.TCPOperation. The 2nd rule will pass the message to your custom operation created in step 2:

EnsLib.HL7.Service.TCPService -> HL7Router -> EnsLib.HL7.Operation.TCPOperation

                                                                                            -> Custom Operation (extract fields from message for your business logic)

This discussion assumes that you do not need to change the HL7 message itself, just extract data from it. If you need to also modify the message then you would first need to clone your input Enslib.HL7.Message (so that you have a Response object), do all of the work on the clone and define it as an Output parameter... you can use SetValueAt on the Segment to pass in new field values. your workflow would be:

EnsLib.HL7.Service.TCPService -> HL7Router (orig. message) <-> Custom Operation (extract fields from message and modify them)

                                                                                                                            ->  EnsLib.HL7.Operation.TCPOperation  (modified message)

 I hope this helps