Thomas Schroyen · Jul 14, 2021

creation of a bidirectionnial connector

Hello everyone,


I have a question and if you have some code, it would be lovely.


I had to create a connector which is biredictionnal. What does I mean by this?

I have to send ADT to an certain ip +port by TCP but I have to receive query A19 by this same ip+port.

Is it possible to create such a connector that can do both?


I read about pipe but i think it's too low-leveled .





Product version: HealthShare 2018.1
0 122
Discussion (6)2
Log in or sign up to continue

Are you receiving the A19 message as a response to each ADT message? Or are they being sent asynchronously?

No, this is not a response to ADT messages.

They are being sent asynchronously and there are 2 separates entities that must be sent and receveid by the same connector.

Let's say that my connector is the bridge between 2 ip (A et B)

A send to my connector and resend to B
B send to my connector and resend to A

The ip and port must be the same whatever the flow.


@Robert C. Cemper has you on the right track, but I'm curious as to whether the vendor of the foreign (i.e. non-HealthShare/HealthConnect) system has provided a specification. Do you need to accommodate Acknowledgement messages for both sending/receiving? Is there some sort of handshake protocol that is used to indicate when it's safe to send, a sort of RTS/CTS-type mechanism? Or is this being designed "on the fly?"

If I were designing something like this, I'd go with a web service ... always over the same port, and when you want to send something you'd POST it. When there's nothing to POST, you'd periodically GET to see if anything is waiting.

Anything else would most likely be a one-off in healthcare integration.

to get a clearer picture of the requirements it is essential to understand
how the connection operates:

  1. connection is established and messages are exchanged leaving the connection open
  2. connection is established, the message is sent, the connection is closed

It's evident that the behaviors are different  on both ends 
for #1 you start with a Listener and keep it cyclic reading, eventually writing

for #2 you open the listener, receive something and close it
to send your message you need an open - write - close cycle.

both are possible but you have to know what your opponent expects and how it reacts.

The whole requirement is rather archaic. Sounds like a webserver without HTTP.
REST would be the better approach.

Finally, you may consider outplacing the whole connection management to Node.js
which is far better suited for such exercises. Eg: wrap incoming stream into REST 

see this docu TCP Client/Server Communication
- the key trick is to use  READ with a timer
- if there is no input, you either write 
or place the next timed read if there's nothing to send

Is it expected that this will be a single socket connection that is continually available for bi-directional communications?  I ask because my initial thought was that we have to completely separate interfaces here.  On the remote side (ip) there is a listener on the indicated port number.  You will be connecting to this ip+port to send your ADT.

A completely separate communication is initiated by the remote system to YOUR ip address where you would have a listener on the same port.  This would be limited to accept communications only from the remote ip.  The remote system would send the A19 over this connection which would.  If this is the case then you can simply use our built-in HL7 TCP operation and service  to accomplish this.

If this is truly a bi-directional communications over the same open TCP connection then @Jeffrey Drumm is correct.  They would need to provide the custom protocol they use to manage the communications.