Package com.framed.interop.hl7.hl7v2
Class Hl7Message
java.lang.Object
com.framed.interop.hl7.hl7v2.Hl7Message
A lightweight, read-oriented HL7 v2 pipe-encoded message: a list of segments, each split into
fields on
|. Components (^) and repetitions (~) are exposed as raw field
text for callers to split as needed.
Field numbering follows HL7's convention. For most segments field n is at array index
n (index 0 being the segment id). MSH is special: its first | is
field 1 (the field separator), so MSH-n for n >= 2 lives at array index
n - 1. field(String, int) hides this difference.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringReturns field n of a specific segment instance, honouring theMSHoffset.Returns field n of the firstidsegment, honouring theMSHoffset.static StringfirstComponent(String field) static Hl7MessageParses a raw HL7 message.String[]
-
Method Details
-
parse
Parses a raw HL7 message. Segment separators may be\r,\nor\r\n.- Parameters:
raw- the raw message text- Returns:
- the parsed message
-
segment
- Returns:
- the first segment with the given id, or
null.
-
segments
- Returns:
- all segments with the given id, in order.
-
field
Returns field n of the firstidsegment, honouring theMSHoffset.- Parameters:
id- the segment id (e.g."MSH","OBR")field- the HL7 field number (e.g.9for MSH-9)- Returns:
- the field text, or
""if absent
-
field
Returns field n of a specific segment instance, honouring theMSHoffset.- Parameters:
seg- the segment fields array (as returned bysegment(String))id- the segment idfield- the HL7 field number- Returns:
- the field text, or
""if absent
-
firstComponent
- Returns:
- the first component (before
^) of a field value.
-
messageType
- Returns:
- the message type triplet from MSH-9, e.g.
"ORU^R01"(trailing structure dropped).
-
controlId
- Returns:
- the message control id (MSH-10).
-
