DTL with subTransformation to get Message Details

Primary tabs



I've got a Service that get ACK Messages originated by another system. 


I want to get the details of a Message when the ACK is CE (Failed Message).


I don't know whether this is the best approach but, at the moment, I have a DTL and I would like to search the Cache Database for a Message with the Control ID on the ACK in the MSA segment.


Any help with this would be great.



  • 0
  • 0
  • 373
  • 4
  • 5


Hi Joao,

I'm assuming you are sending an HL7 v2.x message from an operation, and its ACK is coming back via your service.

If this is the case then you might want to look at the deferred response functionality...


This allows you to automagically send the ACK back as a response to the sending process.

Depending on how you implement the process, you will have the original message in scope, or it will be passed as an on response argument with the ACK response.


João, boa tarde!


A resposta ao segmento a saber, a identificação de um MSA, seria para um protocolo de algum instrumento específico? 




Tks Sean.


I've think that is what we really need here. However, I can't reproduce the process... 


An example would be great. I couldn't find any though...



Joao Palma

Tks Again Sean.


My colleague and I've thought that would be the way through but we've looked into that together, tried everything and nothing.


But that's a good call. If you find any example I will thank you forever, eheh.  If you don't find, that's all right too.



I've knocked up a quick example using dual ack's.

I've put the source code in a gist here...


Save the code to a file and import into a test namespace.

Either create the "in" and "archive" folders are per the inbound test file feeder, or change to suit your environment.

Drop an HL7 message into the "in" folder and this is what you will see in the trace...

The ACK message is sent into the service and is automatically forwarded to the sending operation where it is returned to the calling process as if it was original messages ACK.

Make sure to follow the instructions here when configuring the service and operation, they specifically need to be implemented using EnsLib.HL7.Operation.TCPAckOutOperation and EnsLib.HL7.Service.TCPAckInService


Also note, that you need to set the reply code actions so that the AE ACK is returned to the process, otherwise it will stop at the operation, I have set the actions to...


Where a match on ?E will just warn and continue as if the message was ok.

Take a look at the custom class Examples.DeferredHL7.CustomProcess

Which contains the following OnResponse method...

Method OnResponse(request As EnsLib.HL7.Message, ByRef response As EnsLib.HL7.Message, callrequest As EnsLib.HL7.Message, callresponse As EnsLib.HL7.Message, pCompletionKey As %String) As %Status
    $$$TRACE("request contains the inbound request "_request.RawContent)
    $$$TRACE("callrequest contains the sent request "_callrequest.RawContent)
    $$$TRACE("callresponse contains the deferred ACK "_callresponse.RawContent)
    quit $$$OK


This is where you will have both the original request messages and the ACK in the same scope. From here you can construct a new message from the data in both messages.

This is just one approach but should fit your needs.


Thank you very much Sean.  


I will have a look straight away  with my colleague.

May I just  ask you another Question Sean?


We've got everything working. The only issue is that the operation partner which sends the original message out is dealing with the application ACKs (because it is the Partner). Our endpoint guys say they are getting a second message. Therefore, the original the ADT message and the ACK which the endpoint application don't want...


Is that because of the Reply Code Actions? I'm sorry if that's a dumb question. I am quite new to Ensemble and we don't learn everything at the Training...


Kind Regards,

Joao Palma

Tks Sean. 


You saved me. I was only missing the ResponseFrom setting and everything is working now.


Kind Regards,

Joao Palma