public class HL7Message extends Object implements Serializable
| Modifier and Type | Field and Description |
|---|---|
static char |
SEGMENT_TERMINATOR
The character that separates segments in an HL7 message.
|
protected HL7SegmentList |
segments
The segments in this message.
|
| Constructor and Description |
|---|
HL7Message()
Convenience constructor.
|
HL7Message(HL7Seps seps)
Construct an empty HL7 message.
|
HL7Message(MSHSegment msh)
Construct a new HL7 message containing only the given MSH segment.
|
HL7Message(String msg)
Parsing constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
HL7Segment |
findSegment(String segname)
Convenience method.
|
HL7Segment |
findSegment(String segname,
int segnum)
Get the first occurrence of a
segname segment in this message. |
String |
get(String name)
Convenience method.
|
String |
get(String name,
int segnum,
int repeat)
Find a string value by HL7 name.
|
HL7Field |
getField(String name)
Convenience method.
|
HL7Field |
getField(String name,
int segnum)
Find a field by HL7 name.
|
MSHSegment |
getMSHSegment()
Get the MSH segment of this message.
|
HL7SegmentList |
getSegments()
Get all of the segments in this message.
|
int |
hashCode() |
String |
toString()
Convert this message into a string by concatenating the segments in string form, each terminated with a carriage return.
|
String |
toString(HL7Seps seps)
Format this message using the supplied separators instead of the ones defined by the MSH segment.
|
public static final char SEGMENT_TERMINATOR
protected final HL7SegmentList segments
MSHSegment.public HL7Message(MSHSegment msh)
msh - MSH segmentpublic HL7Message(HL7Seps seps)
A MSH segment will be automatically added.
seps - separator and escape characters to use for this messagepublic HL7Message()
HL7Message(HL7Seps.DEFAULT)
public HL7Message(String msg) throws HL7ContentException
msg - string-encoded messageHL7ContentException - if the string is invalidpublic MSHSegment getMSHSegment()
public HL7SegmentList getSegments()
The returned list does not allow removing the first element (the MSH segment) or changing it to anything other than an
MSHSegment.
public HL7Segment findSegment(String segname, int segnum)
segname segment in this message.segname - segment name, e.g., "PV1"segnum - starting segment index to start search;
index zero refers to the MSH segmentIllegalArgumentException - if segnum is negativepublic HL7Segment findSegment(String segname)
findSegment(name, 0)
segname - segment name, e.g., "PV1"public HL7Field getField(String name, int segnum)
name - field name, e.g., "PV1.3"segnum - starting segment index (zero to start from MSH segment)null if the named field doesn't exist in this messageIllegalArgumentException - if name is not properly formattedIllegalArgumentException - if segnum is negativepublic HL7Field getField(String name)
getField(name, 0)
name - field name, e.g., "PV1.3"null if the named field doesn't exist in this messagepublic String get(String name, int segnum, int repeat)
XYZ.N[.M[.L]]
where XYZ is the segment name, N is the field number, M is the
optional component number, and L is the optional subcomponent number.
If either of M or L are not given, they are assumed to be 1
so an unambiguous string value can always be returned.
name - HL7 value name, e.g., "PV1.3", "MSH.9.1", "ZZZ.3.2.1"segnum - starting segment indexrepeat - repeat index (starting from zero)null if the named value doesn't exist in this messageIllegalArgumentException - if name is not properly formattedIllegalArgumentException - if "M" or "L" is negativeIllegalArgumentException - if segnum or repeat is negativepublic String get(String name)
getField(name, 0, 0)
name - HL7 value name, e.g., "PV1.3", "MSH.9.1", "ZZZ.3.2.1"null if the named field doesn't exist in this messagepublic String toString()
public String toString(HL7Seps seps)
seps
does not define an escape character, then characters that need to be escaped are silently elided.seps - HL7 separator charactersCopyright © 2018. All rights reserved.