0

I'm working with the Google Healthcare API and there's a step in the walk through that uses netcat to send an HL7 message to the MLLP adapter.

(I used nmap to download ncat for Windows)

I have the adapter running locally but the command they provide is written for Mac/Nix users and I'm on Windows.

echo -n -e "\x0b$(cat hl7.txt)\x1c\x0d" | nc -q1 localhost 2575 | less

So I tried rewriting this for windows powershell:

$hl7 = type hl7.txt
Write-Output "-n -e \x0b" $hl7 "\x1c\x0d" | ncat -q1 localhost 2575 | less

When I try this, I get an error that "less" is invalid and also -q1 is also an invalid command.

If I remove -q1 and | less the command executes with no output or error message.

I'm wondering if I'm using ncat incorrectly here or the write-output incorrectly?

What is the -q1 parameter?

It doesn't seem to be a valid ncat parameter from what I've researched.

I've been following this walkthrough: https://cloud.google.com/healthcare/docs/how-tos/mllp-adapter#connection_refused_error_when_running_locally

Jack Marchetti
  • 15,536
  • 14
  • 81
  • 117
  • 1
    I think that the `-q1` parameter is used for waiting 1 second and quit as explained [here](https://www.computerhope.com/unix/nc.htm). Not sure how you could adapt this waiting on the Powershell side. – Daniel Ocando May 22 '20 at 21:05
  • Is there a specific reason why you need to follow the [tutorial for testing locally](https://cloud.google.com/healthcare/docs/how-tos/mllp-adapter#testing_the_mllp_adapter_locally_as_a_receiver) on a Windows Machine? Are you facing any difficulties with the Google Healthcare API itself? – Daniel Ocando May 22 '20 at 21:08
  • @janiel - you need to use MLLP to send HL7 messages to the Healthcare API. Once I got it to work locally I was going to then deploy the MLLP adapter Google uses to a Kubernates cluster – Jack Marchetti May 22 '20 at 23:36
  • @DanielOcando - gotcha, I think in windows -w1 would wait for 1 second. – Jack Marchetti May 22 '20 at 23:36

1 Answers1

1

We're really converting the echo command, not the ncat command. The syntax for ascii codes is different in powershell.

[char]0x0b + (get-content hl7.txt) + [char]0x1c + [char]0x0d | 
  ncat -q1 localhost 2575 

in ascii: 0b vertical tab, 1c file seperator, 0d carriage return http://www.asciitable.com

Or this. `v is 0b and `r is 0d

"`v$(get-content hl7.txt)`u{1c}`r" | ncat -q1 localhost 2575 

If you want it this way, it's the same thing. All three ways end up being the same.

"`u{0b}$(get-content hl7.txt)`u{1c}`u{0d}" | ncat -q1 localhost 2575 
js2010
  • 23,033
  • 6
  • 64
  • 66
  • I think HL7 messaging requires the certain characters to start and end, so perhaps the answer is: "-n -e \x0b$(get-content hl7.txt)\x1c\x0d" – Jack Marchetti May 22 '20 at 23:55