Question
· Sep 12, 2022

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
Discussion (9)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
}

}

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?

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