I have requirement to connect to Mirth/Rosetta (NextGen)
through TCP
connection, in order to send HL7
message an receive back response. Since this is my first time interaction with mirth, so I'm starting as test in order to get to know if it works.
Problem: When I try to send a random text to mirth, or even MLLP HL7 message
, it doesn't respond at all. I'm using very basic TCP
connection code (as shown below) in order to test connection. I'm expecting mirth to send ACK with error, or at least some error. But it stays blank when stream.Read
line is executed.
TcpClient client = new TcpClient("x.x.x.x", 1234);
var message = "HELLO MIRTH";
Byte[] data = System.Text.Encoding.ASCII.GetBytes(message);
NetworkStream stream = client.GetStream();
stream.Write(data, 0, data.Length);
Console.WriteLine("Sent: {0}", message);
data = new Byte[256];
while (true)
{
bytes = stream.Read(data, 0, data.Length);
if (bytes > 0)
break;
}
var responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
Console.WriteLine(DateTime.Now.ToString());
Console.WriteLine("Received: {0}", responseData);
What's surprising is that when I send the same message from some HAPI TestPanel
(a test tool to connect/send message to through TCP) it works fine and I receive response (as shown in following screenshot). This makes me think like there is something I'm missing. Even though my test code shown above works well if I connect it with my own TCP listener. But when it tries to connect with Mirth, it doesn't get any response.
Question: is there anything special that I need to add in my TCP sender, in order to talk to TCP server of Mirth (or any HL7 standard TCP server)? If not, please guide me in this regards. I need to connect and get response back.
Messages I tried:
- "Hello World"
- "MSH|^~&|xyz|xyz|xyzz||20210224162555.3992||ADT^A28|13391074-7b39-42f7-b6bf-f174fb6e8231|P|2.5 ..."
- HL7 message enclosed in VT and FS CR tags
Try out this on the Mirth Connect server receiving the message. Define a transformer step on the destination connector with the desired output/response format. If the desired response is the raw data then just have a Javascript transformer then call the in-built function connectorMessage.getRawData(). Finally, on the TCP listener, select the transformer name (created at the destination connector) in the item list under the response (just below the source queue).