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
}
}
- Log in to post comments