我创建了一个简单的客户端将HL7格式的消息发送到服务器。不幸的是,我无法访问服务器以查看邮件是如何传入的以及正在传回的内容。现在我的消息发送了,但是当我等待消息(ACK)时,它只是在那里等待。HL7 C# - 收到来自服务器的ACK响应
任何意见非常感谢。
try {
using (var client = new TcpClient())
{
client.Connect("10.25.60.8", 10000);
using (Stream stm = client.GetStream())
{
byte[] ba = Encoding.ASCII.GetBytes(segment1 + segment2 + segment3 + segment4 + segment5);
Console.WriteLine("Transmitting.....");
stm.Write(ba, 0, ba.Length);
Console.WriteLine("MessageSend reading response");
byte[] bb = new byte[1000];
int k = stm.Read(bb, 0, 1000);
for (int i = 0; i < k; i++)
Console.WriteLine(Convert.ToChar(bb[i]));
client.Close();
}
}
}
catch (Exception e)
{
Console.WriteLine(e.StackTrace);
}
这是我创建的消息段:
clnt p = new clnt();
patientAdmit r = new patientAdmit();
r.admitMessage = "MSH|^~\\&|MP|M1|MP|M2|201701011500||ADT^A01|HL7MSG00001|P|2.3|EVN|A01|201701011500||PID|||MRN222222||TEST^MICHAEL||19890101|M||C|1 MP STREET^^MARK^ON^L4C|GL|(416)123-1234|(647)123-1234|||||||NK1|1|TEST^BARBARA|WIFE||||||NK^NEXT OF KIN|PV1|1|I|20^201^01||||123456^TEST^DOC|||SUR||||ADM|A0|";
string vt = Convert.ToChar(11).ToString();
string cr = Convert.ToChar(13).ToString();
string fs = Convert.ToChar(28).ToString();
int startSegment2 = p.GetNthIndex(r.admitMessage, Convert.ToChar("|"), 12) + 1;
int startSegment3 = p.GetNthIndex(r.admitMessage, Convert.ToChar("|"), 16) + 1;
int startSegment4 = p.GetNthIndex(r.admitMessage, Convert.ToChar("|"), 16 + 21) + 1;
int startSegment5 = p.GetNthIndex(r.admitMessage, Convert.ToChar("|"), 16 + 21 + 10) + 1;
string segment1 = vt + r.admitMessage.Substring(0, startSegment2);
string segment2 = cr + r.admitMessage.Substring(startSegment2, startSegment3 - startSegment2);
string segment3 = cr + r.admitMessage.Substring(startSegment3, startSegment4 - startSegment3);
string segment4 = cr + r.admitMessage.Substring(startSegment4, startSegment5 - startSegment4);
string segment5 = cr + r.admitMessage.Substring(startSegment5, r.admitMessage.Length - startSegment5) + cr + fs;
+0
您发送的信息应该包裹在[MLLP信封](https://blog.interfaceware.com/common-hl7-transports/) –