If you aren't using Maven, HAPI can be downloaded at our Sourceforge Download Site.
Adding HAPI to your application requires one or more HAPI JARs to be added to your application classpath.
hapi-base-2.2.jar | This is the base HAPI library. It contains parsers, transports, validators, etc. | ||
hapi-structures-v21-2.2.jar
hapi-structures-v22-2.2.jar etc... |
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-hl7overhttp-2.2.jar | If you are using HL7 over HTTP in your application, you must include the hl7overhttp JAR as well. |
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-1.7.30.jar | HAPI uses SLF4J for logging. SLF4J is a logging abstraction framework which generally uses an underlying logger to write the logs to disk. At a minimum, you must include the "slf4j-api" dependency JAR, but you should also include a binding to an underlying log system. |
log4j-1.2.17.jar
slf4j-log4j12-1.7.30.jar |
LOG4J is a good choice for an underlying log system (the library which actually writes the logs to disk). You may include these two JARs to use LOG4J (to be clear, this is optional. HAPI has no dependencies on LOG4J but will take advantage of its functionality through SLF4J's bridge.) |
slf4j-api-1.7.30.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. |
To use HAPI in a Maven based project, add the hapi-base artifact to your dependencies section, as well as any structure JAR versions you need.
<!-- This is the core HAPI library --> <dependency> <groupId>ca.uhn.hapi</groupId> <artifactId>hapi-base</artifactId> <version>2.2</version> </dependency> <!-- These are structure JARs for HL7 v2.1 and 2.5.1 (as an example) --> <dependency> <groupId>ca.uhn.hapi</groupId> <artifactId>hapi-structures-v21</artifactId> <version>2.2</version> </dependency> <dependency> <groupId>ca.uhn.hapi</groupId> <artifactId>hapi-structures-v251</artifactId> <version>2.2</version> </dependency>
If you wish to use LOG4J, add the following as well:
<dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.30</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency>
If you are using HL7 over HTTP, include the "hapi-hl7overhttp" dependency as well.
<dependency> <groupId>ca.uhn.hapi</groupId> <artifactId>hapi-hl7overhttp</artifactId> <version>2.2</version> </dependency>
Once you have the library downloaded and added to a project, see the HAPI By Example page for what to try next.