title: Sending a hl7 test message and listen to it with node
body: <p>I want to create a hl7 test message and send it to my express server (which is listening to localhost:3000).</p>
  
  <p>1) I took the message from
  <a href="http://hl7inspector.com/" rel="nofollow noreferrer">http://hl7inspector.com/</a> and downloaded the inspector.</p>
  
  <p>2) I copied the message into a file (with sublime) and loaded the message into the tool. Here can be a lot of options selected. <strong>What do I need to setup if I want to use it with express?</strong></p>
  
  <p><a href="https://i.stack.imgur.com/o5iXg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o5iXg.png" alt="enter image description here"></a></p>
  
  <p>3) I validated the message with the tool, here it throws a lot of warnings (unknown segments and fields). <strong>Is there anything wrong with the message in the link above?</strong> I tried several messages but none of them worked.</p>
  
  <p><a href="https://i.stack.imgur.com/Esjiq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Esjiq.png" alt="enter image description here"></a></p>
  
  <p>4) I setup a route in express and use the nodengine-hl7 (<a href="http://evanlucas.com/nodengine-hl7/" rel="nofollow noreferrer">http://evanlucas.com/nodengine-hl7/</a>) to parse it</p>
  
  <pre><code>  hl7 = require('nodengine-hl7')
    hl7Parser = hl7.Parser
  
    app.get('/hl7/:hl7Msg', (req, res) -&gt;
      console.log req.params
    )
  </code></pre>
  
  <p><strong>Is the hl7 message sent as a get request, or is it an own request type?? And how can I address the url, in the inspector? I can just select the host and the port.</strong></p>
  
  <p>EDIT:
  I guess hl7 can not be sent and received with express. A new server has to be created. <code>nodengine-hl7</code> is a parser only, so I decided to switch to <code>node-hl7</code>. The new code is:</p>
  
  <pre><code>hl7 = require('node-hl7')
  hl7Server = new hl7.Server()
  
  hl7Server.on('hl7', (msg)-&gt;
    console.log msg
  )
  </code></pre>
  
  <h2>My own research:</h2>
  
  <p>How a hl7 message is read
  <a href="http://www.interfaceware.com/blog/what-does-an-hl7-message-look-like/" rel="nofollow noreferrer">http://www.interfaceware.com/blog/what-does-an-hl7-message-look-like/</a></p>
  
  <p>A message consists of multiple segments. Each segments has fields (&amp;maybe sub fields etc.). To see when segments and fields start delimiters are used.</p>
  
  <p><code>|</code> Field delimiter</p>
  
  <p><code>^</code> Sub-field delimeter </p>
  
  <p><code>~</code> Repeating field delimiter</p>
  
  <p><code>&amp;</code> Escape character</p>
  
  <p><code>\</code> Sub-sub-field delimiter</p>
  
  <p>The delimiters are always in the message's MSH Segment. The 9th field of the MSH is the message type.</p>
  
  <p>There are certain predefined standarized segments. And with the message type I know which fields are expected.</p>
  
  <h2>Node Packages</h2>
  
  <ul>
  <li><a href="https://github.com/amida-tech/hl7" rel="nofollow noreferrer">https://github.com/amida-tech/hl7</a> </li>
  <li><a href="https://github.com/ekryski/node-hl7" rel="nofollow noreferrer">https://github.com/ekryski/node-hl7</a></li>
  <li><a href="https://github.com/evanlucas/nodengine-hl7" rel="nofollow noreferrer">https://github.com/evanlucas/nodengine-hl7</a> (parsing only, no server)</li>
  </ul>
  
  <h2>Testing Tools</h2>
  
  <p><a href="https://stackoverflow.com/questions/9308945/testing-hl7-messages">Testing HL7 Messages</a></p>
  
  <h2>Additional Ressource:</h2>
  
  <p><a href="http://www.hl7.org/" rel="nofollow noreferrer">http://www.hl7.org/</a></p>