public void TestGetAckIdForInvalidMessages() { const string missingMSASegment = "MSH|^~\\&|Main_HIS|XYZ_HOSPITAL|iFW|ABC_Lab|20160915003015||ACK|9B38584D|P|2.6.1|\r" + "ZSA|AA|9B38584D|Everything was okay dokay!|"; const string msaOnly = "MSA|AA|1|"; var parser = new PipeParser(); Assert.AreEqual(null, parser.GetAckID(missingMSASegment)); Assert.AreEqual(null, parser.GetAckID(msaOnly)); }
/// <summary> ///实现处理的接口 /// </summary> /// <param name="message">传入的消息字符</param> /// <returns></returns> public string Process(string message) { IMessage m = null; try { m = parser.Parse(message); } catch (Exception ex) { //MediII.Common.LogHelper.LogError(string.Format("消息消息失败,传入消息为:\n\r{0}",message),LogCatagories.AdapterBiz); string sendingApp = System.Configuration.ConfigurationManager.AppSettings["SedingApplication"]; string recvApp = "MediII"; string ackMsg = MediII.Common.MessageHelper.SetACK("ACK", "", "", sendingApp, sendingApp, recvApp, recvApp, "123456789", ex.Message); return(ackMsg); } ISegment msh = (ISegment)m.GetStructure("MSH"); string messageID = Terser.Get(msh, 10, 0, 1, 1); string guid = MediII.Common.GUIDHelper.NewGUID(); OnProcessing(guid, messageID, message); string ack = DoProcess(m); OnProcessed(guid, parser.GetAckID(ack), ack, true); return(ack); }
public void TestGetAckId() { const string ackMsg = "MSH|^~\\&|Main_HIS|XYZ_HOSPITAL|iFW|ABC_Lab|20160915003015||ACK|9B38584D|P|2.6.1|\r" + "MSA|AA|9B38584D|Everything was okay dokay!|"; const string nakMsg = "MSH|^~\\&|^^|DOE^^|DCC^^|DOE^^|20050829141336||ACK^|1125342816253.100000055|P|2.3.1|\r" + "MSA|AE|00000001|Patient id was not found, must be of type 'MR'|||^^HL70357|\r" + "ERR|PID^1^3^^^HL70357|"; const string messageRejection = "MSH|^~\\&|DCS|MYIIS|MYIIS||200906040000-0500||ACK^V04^ACK|12343467|P|2.5.1|||\r" + "MSA|AR|9299381\r" + "ERR||MSH^1^12|203^unsupported version id^^HL70357|E||||Unsupported HL7 Version ID-Message rejected\r"; var parser = new PipeParser(); Assert.AreEqual("9B38584D", parser.GetAckID(ackMsg)); Assert.AreEqual("00000001", parser.GetAckID(nakMsg)); Assert.AreEqual("9299381", parser.GetAckID(messageRejection)); }