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:
ClassHICG.HL7.Service.TCPServiceExtendsEnsLib.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.
PropertyMSH7AckDateFormatAs%String [ InitialExpression = "%Y%m%d%H%M%S" ];
ParameterSETTINGS = "MSH7AckDateFormat";
MethodOnConstructReply(OutputpReplyDocAsEnsLib.EDI.Document, pOriginalDocAsEnsLib.EDI.Document, ByRefpReplyCodeAs%String, ByRefpSCAs%Status, pEarlyAckAs%Boolean) As%Status
{
SetpReplyDoc=pOriginalDoc.NewReplyDocument(,..LocalFacilityApplication)
SetpReplyDoc.Source=pOriginalDoc.%Id()
Do:..#UseOriginalControlIdpReplyDoc.SetValueAt(pOriginalDoc.GetValueAt("1:10"),"1:10")
DopReplyDoc.SetValueAt(##class(Ens.Util.Time).ConvertDateTime($H,"%q(3)",..MSH7AckDateFormat),"1:7")
SettMSA=##class(EnsLib.HL7.Segment).%New($LB("",1))
SettMSA.Separators=pReplyDoc.Separators
DotMSA.SetValueAt("MSA",0)
DotMSA.SetValueAt(pReplyCode,1)
DotMSA.SetValueAt(pOriginalDoc.GetValueAt("1:10"),2)
Do:$G($$$ExpectedSequenceNumber)tMSA.SetValueAt($$$ExpectedSequenceNumber,4)
DopReplyDoc.AppendSegment(tMSA)
SetpReplyDoc.IsMutable=0
Quit$$$OK
}
}
- Log in to post comments