HL7 ACK Date and Time Format

Hi.

We have created an Ensemble production that receives HL7 information via TCP Adapters, but the requirement from the vendor is that we submit an ACK message with the MSH segment mist have a date and time populated with seconds.

We are utilising the standard class for the Service Adapter (EnsLib.HL7.Service.TCPService).

HL7 Version 2.5 no modifications currently.

The messages received via the service is correctly received in ddMMyyyyhhmmss but our ACK back is only ddMMyyyyhhmm.

Due to the ACK not having the ss the message is rejected by the vendor.

Ps: Our interface is using ACK Mode - Immediate

Answers

Your best option for doing this is to create a new HL7 TCPIP Service Class that extends EnsLib.HL7.Service.TCPService that overrides the OnConstructReply() Method. The example below includes the necessary code, along with the convenience of being able to adjust the MSH:7 date format by supporting the reconfiguration of the value of MSH7AckDateFormat in the Production's configuration panel for the service. It uses well-known strftime() formatting conventions.

This works with Ensemble version 2017.2.1:

Class HICG.HL7.Service.TCPService Extends EnsLib.HL7.Service.TCPService

{

/// Allows Customization of the date format used in the ACK's MSH:7 field. Uses C strftime() tokens to construct
/// the date in the desired format. Default is HL7 date/time format, yyyyMMddhhmmss.

Property MSH7AckDateFormat As %String [ InitialExpression = "%Y%m%d%H%M%S" ];

Parameter SETTINGS = "MSH7AckDateFormat";

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=pOriginalDoc.NewReplyDocument(,..LocalFacilityApplication)

       Set pReplyDoc.Source = pOriginalDoc.%Id()

       Do:..#UseOriginalControlId pReplyDoc.SetValueAt(pOriginalDoc.GetValueAt("1:10"),"1:10")

       Do pReplyDoc.SetValueAt(##class(Ens.Util.Time).ConvertDateTime($H,"%q(3)",..MSH7AckDateFormat),"1:7")

       Set tMSA=##class(EnsLib.HL7.Segment).%New($LB("",1))

       Set tMSA.Separators=pReplyDoc.Separators

       Do tMSA.SetValueAt("MSA",0)

       Do tMSA.SetValueAt(pReplyCode,1)

       Do tMSA.SetValueAt(pOriginalDoc.GetValueAt("1:10"),2)

       Do:$G($$$ExpectedSequenceNumber) tMSA.SetValueAt($$$ExpectedSequenceNumber,4)

       Do pReplyDoc.AppendSegment(tMSA)

       Set pReplyDoc.IsMutable = 0

       Quit $$$OK

 }

}