camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > HL7 DataFormat
Date Sun, 21 Feb 2010 16:54:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/CAMEL/HL7+DataFormat">HL7
DataFormat</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~mrt1nz">Martin
Krasser</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <h2><a name="HL7DataFormat-HL7DataFormat"></a>HL7 DataFormat</h2>
<p>The <a href="/confluence/display/CAMEL/HL7" title="HL7">HL7</a> component
ships with a HL7 data format that can be used to format between <tt>String</tt>
and HL7 model objects. </p>
<ul class="alternate" type="square">
	<li><tt>marshal</tt> = from Message to byte stream (can be used when returning
as response using the HL7 MLLP codec)</li>
	<li><tt>unmarshal</tt> = from byte stream to Message (can be used when
receiving streamed data from the HL7 MLLP</li>
</ul>


<p>To use the data format, simply instantiate an instance and invoke the marhsal or
unmarshl operation in the route builder:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
  DataFormat hl7 = <span class="code-keyword">new</span> HL7DataFormat();
  ...
  from(<span class="code-quote">"direct:hl7in"</span>).marshal(hl7).to(<span
class="code-quote">"jms:queue:hl7out"</span>);
</pre>
</div></div>
<p>In the sample above, the HL7 is marshalled from a HAPI Message object to a byte stream
and put on a JMS queue.<br/>
The next example is the opposite:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
  DataFormat hl7 = <span class="code-keyword">new</span> HL7DataFormat();
  ...
  from(<span class="code-quote">"jms:queue:hl7out"</span>).unmarshal(hl7).to(<span
class="code-quote">"patientLookupService"</span>);
</pre>
</div></div>
<p>Here we unmarshal the byte stream into a HAPI Message object that is passed to our
patient lookup service.</p>

<p>Notice there is a shorthand syntax in Camel for well-known data formats that is commonly
used.<br/>
Then you don't need to create an instance of the <tt>HL7DataFormat</tt> object:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
  from(<span class="code-quote">"direct:hl7in"</span>).marshal().hl7().to(<span
class="code-quote">"jms:queue:hl7out"</span>);
  from(<span class="code-quote">"jms:queue:hl7out"</span>).unmarshal().hl7().to(<span
class="code-quote">"patientLookupService"</span>);
</pre>
</div></div>

<h3><a name="HL7DataFormat-MessageHeaders"></a>Message Headers</h3>
<p>The <b>unmarshal</b> operation adds these MSH fields as headers on the
Camel message:</p>

<h4><a name="HL7DataFormat-Camel1.x"></a>Camel 1.x</h4>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Key </th>
<th class='confluenceTh'> MSH field </th>
<th class='confluenceTh'> Example </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>hl7.msh.sendingApplication</tt> </td>
<td class='confluenceTd'> <tt>MSH-3</tt> </td>
<td class='confluenceTd'> <tt>MYSERVER</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hl7.msh.sendingFacility</tt> </td>
<td class='confluenceTd'> <tt>MSH-4</tt> </td>
<td class='confluenceTd'> <tt>MYSERVERAPP</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hl7.msh.receivingApplication</tt> </td>
<td class='confluenceTd'> <tt>MSH-5</tt> </td>
<td class='confluenceTd'> <tt>MYCLIENT</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hl7.msh.receivingFacility</tt> </td>
<td class='confluenceTd'> <tt>MSH-6</tt> </td>
<td class='confluenceTd'> <tt>MYCLIENTAPP</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hl7.msh.timestamp</tt> </td>
<td class='confluenceTd'> <tt>MSH-7</tt> </td>
<td class='confluenceTd'> <tt>20071231235900</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hl7.msh.security</tt> </td>
<td class='confluenceTd'> <tt>MSH-8</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hl7.msh.messageType</tt> </td>
<td class='confluenceTd'> <tt>MSH-9-1</tt> </td>
<td class='confluenceTd'> <tt>ADT</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hl7.msh.triggerEvent</tt> </td>
<td class='confluenceTd'> <tt>MSH-9-2</tt> </td>
<td class='confluenceTd'> <tt>A01</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hl7.msh.messageControl</tt> </td>
<td class='confluenceTd'> <tt>MSH-10</tt> </td>
<td class='confluenceTd'> <tt>1234</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hl7.msh.processingId</tt> </td>
<td class='confluenceTd'> <tt>MSH-11</tt> </td>
<td class='confluenceTd'> <tt>P</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hl7.msh.versionId</tt> </td>
<td class='confluenceTd'> <tt>MSH-12</tt> </td>
<td class='confluenceTd'> <tt>2.4</tt> </td>
</tr>
</tbody></table>

<h4><a name="HL7DataFormat-Camel2.0"></a>Camel 2.0</h4>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Key </th>
<th class='confluenceTh'> MSH field </th>
<th class='confluenceTh'> Example </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHL7SendingApplication</tt> </td>
<td class='confluenceTd'> <tt>MSH-3</tt> </td>
<td class='confluenceTd'> <tt>MYSERVER</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHL7SendingFacility</tt> </td>
<td class='confluenceTd'> <tt>MSH-4</tt> </td>
<td class='confluenceTd'> <tt>MYSERVERAPP</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHL7ReceivingApplication</tt> </td>
<td class='confluenceTd'> <tt>MSH-5</tt> </td>
<td class='confluenceTd'> <tt>MYCLIENT</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHL7ReceivingFacility</tt> </td>
<td class='confluenceTd'> <tt>MSH-6</tt> </td>
<td class='confluenceTd'> <tt>MYCLIENTAPP</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHL7Timestamp</tt> </td>
<td class='confluenceTd'> <tt>MSH-7</tt> </td>
<td class='confluenceTd'> <tt>20071231235900</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHL7Security</tt> </td>
<td class='confluenceTd'> <tt>MSH-8</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHL7MessageType</tt> </td>
<td class='confluenceTd'> <tt>MSH-9-1</tt> </td>
<td class='confluenceTd'> <tt>ADT</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHL7TriggerEvent</tt> </td>
<td class='confluenceTd'> <tt>MSH-9-2</tt> </td>
<td class='confluenceTd'> <tt>A01</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHL7MessageControl</tt> </td>
<td class='confluenceTd'> <tt>MSH-10</tt> </td>
<td class='confluenceTd'> <tt>1234</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHL7ProcessingId</tt> </td>
<td class='confluenceTd'> <tt>MSH-11</tt> </td>
<td class='confluenceTd'> <tt>P</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHL7VersionId</tt> </td>
<td class='confluenceTd'> <tt>MSH-12</tt> </td>
<td class='confluenceTd'> <tt>2.4</tt> </td>
</tr>
</tbody></table>

<p>All headers are <tt>String</tt> types. If a header value is missing,
its value is <tt>null</tt>.</p>

<h3><a name="HL7DataFormat-Options"></a>Options</h3>
<p>The HL7 Data Format supports the following options:</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Option </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> validate </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> <b>Camel 2.0</b>: Whether the HAPI Parser should
validate. </td>
</tr>
</tbody></table>

<h3><a name="HL7DataFormat-Dependencies"></a>Dependencies</h3>

<p>To use HL7 in your camel routes you need to add a dependency on <b>camel-hl7</b>,
which implements this data format. </p>

<p>If you use Maven, you could just add the following to your <tt>pom.xml</tt>,
substituting the version number for the latest &amp; greatest release (see <a href="/confluence/display/CAMEL/Download"
title="Download">the download page for the latest versions</a>).</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;dependency&gt;
  &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
  &lt;artifactId&gt;camel-hl7&lt;/artifactId&gt;
  &lt;version&gt;1.6.0&lt;/version&gt;
&lt;/dependency&gt;
</pre>
</div></div>

<p><b>Camel 2.3:</b> The HAPI library version 0.6 has been split into a
<a href="http://hl7api.sourceforge.net/m2/ca/uhn/hapi/hapi-base/0.6/" rel="nofollow">base
library</a> and several structures libraries, one for each HL7v2 message version:</p>

<ul>
	<li><a href="http://hl7api.sourceforge.net/m2/ca/uhn/hapi/hapi-structures-v21/0.6/"
rel="nofollow">v2.1 structures library</a></li>
	<li><a href="http://hl7api.sourceforge.net/m2/ca/uhn/hapi/hapi-structures-v22/0.6/"
rel="nofollow">v2.2 structures library</a></li>
	<li><a href="http://hl7api.sourceforge.net/m2/ca/uhn/hapi/hapi-structures-v23/0.6/"
rel="nofollow">v2.3 structures library</a></li>
	<li><a href="http://hl7api.sourceforge.net/m2/ca/uhn/hapi/hapi-structures-v231/0.6/"
rel="nofollow">v2.3.1 structures library</a></li>
	<li><a href="http://hl7api.sourceforge.net/m2/ca/uhn/hapi/hapi-structures-v24/0.6/"
rel="nofollow">v2.4 structures library</a></li>
	<li><a href="http://hl7api.sourceforge.net/m2/ca/uhn/hapi/hapi-structures-v24/0.6/"
rel="nofollow">v2.5 structures library</a></li>
	<li><a href="http://hl7api.sourceforge.net/m2/ca/uhn/hapi/hapi-structures-v251/0.6/"
rel="nofollow">v2.5.1 structures library</a></li>
</ul>


<p>By default <tt>camel-hl7</tt> only references the HAPI <a href="http://hl7api.sourceforge.net/m2/ca/uhn/hapi/hapi-base/0.6/"
rel="nofollow">base library</a>. Applications are responsible for including structures
libraries themselves. For example, if a application works with HL7v2 message versions 2.4
and 2.5 then the following dependencies must be added:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;dependency&gt;
    &lt;groupId&gt;ca.uhn.hapi&lt;/groupId&gt;
    &lt;artifactId&gt;hapi-structures-v24&lt;/artifactId&gt;
    &lt;version&gt;0.6&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupId&gt;ca.uhn.hapi&lt;/groupId&gt;
    &lt;artifactId&gt;hapi-structures-v25&lt;/artifactId&gt;
    &lt;version&gt;0.6&lt;/version&gt;
&lt;/dependency&gt;
</pre>
</div></div>
     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/CAMEL/HL7+DataFormat">View
Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=92523&revisedVersion=13&originalVersion=12">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/CAMEL/HL7+DataFormat?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message