Question
Lionel Woods · Sep 12

Replying with a customised HL7 ACK

Am trying to create a custom ACK to return to sending system as it does not accept standard 2.3:ACK, want to send the below:

 

Set pResponse=##class(EnsLib.HL7.Message).%New()
Set pResponse.DocType="2.4:ACK"
Set MSHStr="MSH|^~\&|EnsembleHL7|ISC|ARiM Server|ROWA|"_$REPLACE($REPLACE($ZDATETIME($HOROLOG,8,1),":",""), " ","")_"||ACK|"_pRequest.GetValueAt("MSH:10")_"|P|2.3"
Set MSHSeg=##class(EnsLib.HL7.Segment).ImportFromString(MSHStr,.tSC,pRequest.Separators)
Set MSAStr="MSA|AA|"_pRequest.GetValueAt("MSH:10")
Set MSASeg=##class(EnsLib.HL7.Segment).ImportFromString(MSAStr,.tSC,pRequest.Separators)
Set tSC=pResponse.SetSegmentAt(MSHSeg,1)
Set tSC=pResponse.AppendSegment(MSASeg)

The problem I have encountered is I am not sure where to trigger the custom ACK so it will not send the default 2.3:ACK 

The Service is a TCPInboundAdaptor class 

Product version: IRIS 2021.1
0
1 150
Discussion (8)1
Log in or sign up to continue

You can override the OnConstructReply method from EnsLib.HL7.Service.Standard. The following worked for me.

Class DC.CustomACKBS Extends EnsLib.HL7.Service.TCPService
{

Method OnConstructReply(Output pReplyDoc As EnsLib.EDI.Document, pOriginalDoc As EnsLib.EDI.Document, ByRef pReplyCode As %String, ByRef pSC As %Status, pEarlyAck As %Boolean) As %Status
{
    Set pReplyDoc=##class(EnsLib.HL7.Message).%New()
    Set pReplyDoc.DocType="2.4:ACK"
    Set MSHStr="MSH|^~\&|EnsembleHL7|ISC|ARiM Server|ROWA|"_$REPLACE($REPLACE($ZDATETIME($HOROLOG,8,1),":",""), " ","")_"||ACK|"_pOriginalDoc.GetValueAt("MSH:10")_"|P|2.3"
    Set MSHSeg=##class(EnsLib.HL7.Segment).ImportFromString(MSHStr,.tSC,pOriginalDoc.Separators)
    Set MSAStr="MSA|AA|"_pOriginalDoc.GetValueAt("MSH:10")
    Set MSASeg=##class(EnsLib.HL7.Segment).ImportFromString(MSAStr,.tSC,pOriginalDoc.Separators)
    Set tSC=pReplyDoc.SetSegmentAt(MSHSeg,1)
    Set tSC=pReplyDoc.AppendSegment(MSASeg)

    Quit tSC
}

}

Thanks for your response, I have created a new Class with the OnConstructReply Method and changed the Class for the Service under the Action tab but it still does not call the Class when sending an ACK back to the sending system, is this the correct way of applying the class?

That sounds correct. You should also have a Red Update button when you change the class. When you click that Update button, the component will start using your new code. If you do not have the update button you can restart the component by double clicking on the component and clicking Restart.

If that does not do the trick, perhaps you can post your code and ACK related settings for your component. I'm also interested to hear what is happening. Is the standard ACK being returned? No ACK at all?

The code that I have used is as above in the original post

I did try to restart the Service just now but as before it still sends standard ACK back 

I did try to change the settings to Application got ACK Mode but had no joy

The output is being passed by reference. Are you using the correct variable name for your response message? The first argument in my method signature is pReplyDoc so I use pReplyDoc throughout my method.

Then don't forget to restart your component...I just forgot like 3 or 4 times.

Yes I updated the variable name here is the class

Class BDROWA.Service.BDROWAACK Extends EnsLib.HL7.Service.TCPService
{

Method OnConstructReply(Output pResponse As EnsLib.EDI.Document, pRequest As EnsLib.EDI.Document, ByRef pReplyCode As %String, ByRef pSC As %Status, pEarlyAck As %Boolean) As %Status
{
    Set pResponse=##class(EnsLib.HL7.Message).%New()
    Set pResponse.DocType="2.4:ACK"
    Set MSHStr="MSH|^~\&|EnsembleHL7|ISC|ARiM Server|ROWA|"_$REPLACE($REPLACE($ZDATETIME($HOROLOG,8,1),":",""), " ","")_"||ACK|"_pRequest.GetValueAt("MSH:10")_"|P|2.3"
    Set MSHSeg=##class(EnsLib.HL7.Segment).ImportFromString(MSHStr,.tSC,pRequest.Separators)
    Set MSAStr="MSA|AA|"_pRequest.GetValueAt("MSH:10")
    Set MSASeg=##class(EnsLib.HL7.Segment).ImportFromString(MSAStr,.tSC,pRequest.Separators)
    Set tSC=pResponse.SetSegmentAt(MSHSeg,1)
    Set tSC=pResponse.AppendSegment(MSASeg)

    Quit tSC
}

}

The restart did not help

Ok, I just copy and pasted your code and it seems to work for me. Is this the response you are expecting?

And here is the Visual Trace. I added $$$LOGINFO("Constructing Reply") in the first line to make sure your method was being called.

Just wondering at this point if the hierarchy of the method I am using needs to be adjusted, as changing the class only did not help..