Package ca.uhn.hl7v2.model
Interface Segment
- All Superinterfaces:
Serializable,Structure,Visitable
- All Known Implementing Classes:
AbstractSegment,GenericSegment
Represents an HL7 message segment, which is a unit of data that contains multiple fields.
- Author:
- Bryan Tripp (bryan_tripp@sourceforge.net)
-
Method Summary
Modifier and TypeMethodDescriptionencode()Encodes this message using the parser returned byMessage.getParser()Type[]getField(int number) Returns the array of Fields at the specified index.getField(int number, int rep) Returns a specific repetition of field at the specified index.intgetLength(int number) Returns the maximum length of the field at the given index, in characters.intgetMaxCardinality(int number) Returns the maximum number of repetitions of this field that are allowed.String[]getNames()Returns the names of the fields in this segment.booleanisRequired(int number) Returns true if the field at the given index is required, false otherwise.intReturns the number of fields defined by this segment (repeating fields are not counted multiple times).voidParses the string into this segment using the parser returned byMessage.getParser()Methods inherited from interface ca.uhn.hl7v2.model.Structure
getMessage, getName, getParentMethods inherited from interface ca.uhn.hl7v2.model.Visitable
accept, isEmpty, provideLocation
-
Method Details
-
encode
Encodes this message using the parser returned byMessage.getParser()- Returns:
- the string-encoded segment
- Throws:
HL7Exception- if errors occurred during encoding
-
getField
Returns the array of Fields at the specified index. The array will be of length 1 for non-repeating fields, and >1 for repeating fields. Fields are numbered from 1.- Parameters:
number- field number (starting at 1)- Returns:
- the array of Fields at the specified field number
- Throws:
HL7Exception- if field index is out of range.
-
getField
Returns a specific repetition of field at the specified index. If there exist fewer repetitions than are required, the number of repetitions can be increased by specifying the lowest repetition that does not yet exist. For example if there are two repetitions but three are needed, the third can be created and accessed using the following code:
Type t = getField(x, 2);- Parameters:
number- the field number (starting at 1)rep- the repetition number (starting at 0)- Returns:
- field at the specified field number and repetition
- Throws:
HL7Exception- if field index is out of range, or if the specified repetition is more than 1 greater than the highest index of existing repetitions. NOTE: to facilitate local extensions, no exception is thrown if rep > max cardinality
-
getLength
Returns the maximum length of the field at the given index, in characters.- Parameters:
number- field number starting at 1- Returns:
- maximum length of the field
- Throws:
HL7Exception- if field index is out of range.
-
getMaxCardinality
Returns the maximum number of repetitions of this field that are allowed. The current cardinality can be obtained by checking the length of the array returned by getLength(n).- Parameters:
number- field number starting at 1- Returns:
- maximum number of repetitions of this field
- Throws:
HL7Exception- if field index is out of range.
-
getNames
Returns the names of the fields in this segment.- Returns:
- array of names
- Since:
- 1.0 - Note that if user defined types are being used, there is a possibility that some entries may be null. All official hapi structures will have all entries populated, but older user defined structures may not have populated all values, since this feature did not exist prior to release 1.0.
-
isRequired
Returns true if the field at the given index is required, false otherwise.- Parameters:
number- field number starting at 1- Returns:
- true if the field is required
- Throws:
HL7Exception- if field index is out of range.
-
numFields
int numFields()Returns the number of fields defined by this segment (repeating fields are not counted multiple times).- Returns:
- number of fields
-
parse
Parses the string into this segment using the parser returned byMessage.getParser()- Parameters:
string- encoded segment- Throws:
HL7Exception- if errors occurred during parsing
-