Has anybody connected to a Cloverleaf tcp/ip thread with a piece of tcl code using the socket command? Let me explain further.
We have a QRY process where a system can send a QRY^A19 (or QRY^Q01) message and will receive a ADR^A19 message back. Very basic stuff.
To test this interface, we have a test-thread which is configured with tcp/ip protocol. This thread is input with one patientnumber. This input (an FRL of one field) is then translated into a QRY^A19 message and sent to our HIS. The response is an ADR^A19 which is returned as reply. We use this test-thread with hcitcptest:
hcitcptest -h localhost -t 4 -p 8303
You can then type in the desired patientnumber and see the ADR^A19 reply coming back.
What I would like to do is write a piece of tcl script whose input is an HL7 message (mostly an ORU with a result) out of which I will extract the patientnumber. Now I want to check this patientnumber for validity, so I would like to connect to the test-thread, send out the patientnumber and receive the ADR^A19. Based on the reply I will then decide whether to forward the result, or send out an email to users that they have (once again) used an invalid patientnumber.
So I have been fooling around (changed the tcp-ip setting of the test-thread to Data Type ‘Ascii’ and length ’10’, inclusive) and got to to this:
set chan [socket localhost 3761]
fconfigure $chan -buffering none -blocking 1
puts $chan “0000000020010101CA20”
flush $chan
set answer {}
while {[gets $chan line] >= 0} {
echo “line: <$line>”
lappend answer $line
}
#set answer [gets $chan]
echo “length answer: <[string length $answer]>”
echo “answer: <$answer>”
Output is this:
line: < 747MSH|^~\&|PI|REC_FAC|CL|SIEMENS|20200212170006||ADR^A19|20|P|2.4>
line: <MSA|AA|20>
line: <QRD|20200212170006|R||20||||010101CA20|DEM>
line: <PID|1||010101CA20^^^^PI~999900456^^^NLMINBIZA^NNNLD||Stanton&&Stanton^Shani^Shani^^^^L||19001221|M|||Verlengde Wilhelminastraat 21&Verlengde Wilhelminastraat 21^^Hoensbroek^^6431XN^NL||06-12345678^PRN^PH||||||||||X|||||||N|N>
line: <ROL|1|UP|PP^Primary Care Provider|HA099999^NIET GEBRUIKEN Test Edifact^.|||||||Dr H Vd Hoffpln 1&Dr H Vd Hoffpln 1^^Geleen^^6162 BG^NL>
line: <PV1|1|O|||||||||||||||||||8|||3~3~3~3~3~3~3~3~3~3~3~3~3~3|18000101|8~8~8~8~8~8~8~8~8~8~8~8~8~1>
line: <OBX|1|ST|PM^Pacemaker||||||||F>
line: <OBX|1|ST|ALL05^Overige allergieen||||||||F>
line: <OBX|1|ST|IMM 01^Allergie immunomodulantia||||||||F>
line: <OBX|1|ST|ALL01^Jodium allergie||||||||F>
Each line (ended by <CR>) is sent separately, with the first line starting with the length encoding of the message. But the script doesn’t end: there is no EOF in the message so my guess is I will need to program using the length encoding of the first line and then read each line until the message has ended.
Also took a look if I could use hcitcptest, but it’s really only for online/interactive use.
So maybe someone else has done this before and doesn’t mind sharing his/her efforts. Or has some information that I could use. Thanks in advance!
Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands