diff --git a/README.md b/README.md index f098d93..52c0545 100644 --- a/README.md +++ b/README.md @@ -17,4 +17,54 @@ But *Simple-HL7v2* is a 18K .jar with a dependency only on Commons-Lang3, and if have a clear idea of the type of messages you'll be receiving and sending, and handle your own file or network transport, it may be all you need. +# Download +Download JARs and source from the GitHub [releases](https://github.com/jessepav/simple-hl7v2/releases) +page. + +You'll need [Apache Commons Lang 3](http://commons.apache.org/proper/commons-lang/) in your +classpath to use the library. An older version (3.4, compatible with Java 7) is in the `lib` +directory of the source tree. + +# Usage + +For example code, see [examples/SimpleHL7v2Examples.java](https://github.com/jessepav/simple-hl7v2/blob/master/examples/SimpleHL7v2Examples.java) +but basic usage is quite easy: + +```java +HL7Parser parser = new HL7Parser(); +Message m = parser.parse(hl7text); + +String type = m.getMessageType(); // ex. "MDM^T02" + +String observationTimestamp1 = m.getField("OBR.7"); // Get a field value +String observationTimestamp2 = m.getField("OBR(2).7"); // Get a field value from a repeated segment + +m.setField("OBR(1).8", observationTimestamp2); // Change a field value + +HL7Encoder encoder = new HL7Encoder(); +String updatedHL7text = encoder.encode(m); + +``` + +Programmatic construction of segment values is made more efficient by static helper +methods like `indexed()` and `composite()`: + +```java +Segment PID = new Segment("PID"); +PID.addFieldValue(2, + indexed( + 1, "0493575", + 4, composite("Big", null, "Elephant"), + 5, "ID 1") +); +PID.addFieldValue(3, "454721"); +PID.addFieldValue(5, composite("DOE", "JOHN")); + +Message m = new Message(); +m.putSegment(PID); +``` + +# Javadoc + +Javadocs are available at [https://jessepav.github.io/simple-hl7v2/javadoc/](https://jessepav.github.io/simple-hl7v2/javadoc/).