Downloading HAPI

If you aren't using Maven, HAPI can be downloaded at our Sourceforge Download Site.

Adding HAPI to your application

Adding HAPI to your application requires one or more HAPI JARs to be added to your application classpath.

HAPI Libraries

hapi-base-$hapi.version.stable.jar This is the base HAPI library. It contains parsers, transports, validators, etc.
hapi-structures-vXX-$hapi.version.stable.jar Each HL7 version (2.1, 2.2, etc) has a messsage library contained within a structures JAR. If you are constructing messages of that particular version of HL7, you should include the appropriate JAR.

HAPI Dependencies

HAPI also requires the following JARs to function. Newer versions of these JARs *should* also work. Note that these dependencies can be found in the "hapi-all" bundle available in the Download area.

slf4j-api-$slf4j.version.jar log4j-$log4j.version.jar slf4j-log4j12-$slf4j.version.jar HAPI uses SLF4J for logging. SLF4J is a logging abstraction framework which generally uses an underlying logger to write the logs to disk. LOG4J and can be used, but others will work as well.
xercesImpl-2.11.0.jar xml-apis-1.4.01.jar xml-resolver-1.2.jar When HAPI runs on older Java versions (particularly Java 1.4.x) and XML-related functions are used (including parsing XML messages and working with conformance profiles), you have to add these libraries.

Maven Dependencies

To use HAPI , add hapi-base to your dependencies section, and add the structures versions you need.

<!-- This is the core HAPI library -->
<dependency>
        <groupId>ca.uhn.hapi</groupId>
        <artifactId>hapi-base</artifactId>
        <version>${hapi.version.stable}</version>
</dependency>       

<!-- This is the structure JAR for HL7 v2.1 -->
<dependency>
        <groupId>ca.uhn.hapi</groupId>
        <artifactId>hapi-structures-v21</artifactId>
        <version>${hapi.version.stable}</version>
</dependency>

<!-- 
        If you want to use log4j for logging (recommended), you should include
        it, as well as the slf4j adaptor
-->
<dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>${slf4j.version}</version>
</dependency>
<dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>${log4j.version}</version>
</dependency>

<!-- 
        Also add hapi-structures-v22, v23, etc. depending on which versions 
        of HL7 you need to create or parse 
-->     
<dependency>
        <groupId>ca.uhn.hapi</groupId>
        <artifactId>hapi-structures-v22</artifactId>
        <version>${hapi.version.stable}</version>
</dependency>
<dependency>
        <groupId>ca.uhn.hapi</groupId>
        <artifactId>hapi-structures-v23</artifactId>
        <version>${hapi.version.stable}</version>
</dependency>
<dependency>
        <groupId>ca.uhn.hapi</groupId>
        <artifactId>hapi-structures-v231</artifactId>
        <version>${hapi.version.stable}</version>
</dependency>
<dependency>
        <groupId>ca.uhn.hapi</groupId>
        <artifactId>hapi-structures-v24</artifactId>
        <version>${hapi.version.stable}</version>
</dependency>
<dependency>
        <groupId>ca.uhn.hapi</groupId>
        <artifactId>hapi-structures-v25</artifactId>
        <version>${hapi.version.stable}</version>
</dependency>
<dependency>
        <groupId>ca.uhn.hapi</groupId>
        <artifactId>hapi-structures-v251</artifactId>
        <version>${hapi.version.stable}</version>
</dependency>
<dependency>
        <groupId>ca.uhn.hapi</groupId>
        <artifactId>hapi-structures-v26</artifactId>
        <version>${hapi.version.stable}</version>
</dependency>