pipehat.api

Read and write vertical bar encoded HL7 messages (v2.x).

Publics

read

function

  • [reader]
  • [reader options]

Given a java.io.PushbackReader, parse the HL7 message in the reader and return the result.

Options:

:protocol: Iff :mllp, enable MLLP mode. In MLLP mode, the parser discards every character preceding the MLLP start-of-block (0x0B) character.

read-string

function

  • [s]

Given a string containing an HL7 message, parse the string and return the result.

read+string

function

  • [reader]
  • [reader options]

Given a java.io.Reader, parse the HL7 message in the reader and return a two- element vector where the first element is the parsed message and the second element is a string containing the message.

Same options as read.

Caller must close the reader, as with read.

shape

function

  • [message]

Given an HL7 message parsed by read, shape it into a map that's easy to reach into with Clojure core functions. For example:

user=> (def message (-> "MSH|^~\&|ACME" read-string shape))
#'user/message
user=> (get-in message ["MSH" 0 ["MSH" 3]])
"ACME"

Shaping is a lossy operation: you CAN NOT round-trip a shaped message back into an HL7 string.

Shaping is therefore only useful if you need to extract data from a message. It is not useful if you need to update a message.

write

function

  • [writer message]
  • [writer message options]

Given a java.io.BufferedWriter and a vector representing an HL7 message (presumably parsed by read), write the message into the writer.

Options:

:protocol: Iff :mllp, wrap message with MLLP start-of-block (0x0B) and end-of-block (0x1C) characters.

write-string

function

  • [message]
  • [message options]

Given a vector representing an HL7 message (presumably parsed by read), write the message into a string and return the string.

ack

function

  • [writer]

Given a java.io.BufferedWriter, write a Commit Acknowledgement Block (ACK) into the writer and flush.

nak

function

  • [writer]

Given a java.io.BufferedWriter, write a Negative Commit Acknowledgement Block (NAK) into the writer and flush.