Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
jessepav committed Jun 17, 2020
1 parent 47d75e7 commit 538f4a8
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).

0 comments on commit 538f4a8

Please sign in to comment.