ca.uhn.hl7v2.model
Interface Segment

All Superinterfaces:
java.io.Serializable, Structure
All Known Implementing Classes:
AbstractSegment, GenericSegment

public interface Segment
extends Structure

Represents an HL7 message segment, which is a unit of data that contains multiple fields.

Author:
Bryan Tripp (bryan_tripp@sourceforge.net)

Method Summary
 java.lang.String encode()
          Encodes this message using the parser returned by Message.getParser()
 Type[] getField(int number)
          Returns the array of Fields at the specified index.
 Type getField(int number, int rep)
          Returns a specific repetition of field at the specified index.
 int getLength(int number)
          Returns the maximum length of the field at the given index, in characters.
 int getMaxCardinality(int number)
          Returns the maximum number of repetitions of this field that are allowed.
 java.lang.String[] getNames()
          Returns the names of the fields in this segment.
 boolean isRequired(int number)
          Returns true if the field at the given index is required, false otherwise.
 int numFields()
          Returns the number of fields defined by this segment (repeating fields are not counted multiple times).
 void parse(java.lang.String string)
          Parses the string into this segment using the parser returned by Message.getParser()
 
Methods inherited from interface ca.uhn.hl7v2.model.Structure
getMessage, getName, getParent
 

Method Detail

getField

Type[] getField(int number)
                throws HL7Exception
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.

Throws:
HL7Exception - if field index is out of range.

getField

Type getField(int number,
              int rep)
              throws HL7Exception
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)
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

isRequired

boolean isRequired(int number)
                   throws HL7Exception
Returns true if the field at the given index is required, false otherwise.

Throws:
HL7Exception - if field index is out of range.

getLength

int getLength(int number)
              throws HL7Exception
Returns the maximum length of the field at the given index, in characters.

Throws:
HL7Exception - if field index is out of range.

getMaxCardinality

int getMaxCardinality(int number)
                      throws HL7Exception
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).

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).


getNames

java.lang.String[] getNames()
Returns the names of the fields in this segment.

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.

parse

void parse(java.lang.String string)
           throws HL7Exception
Parses the string into this segment using the parser returned by Message.getParser()

Throws:
HL7Exception

encode

java.lang.String encode()
                        throws HL7Exception
Encodes this message using the parser returned by Message.getParser()

Throws:
HL7Exception


Copyright © 2001-2011 University Health Network. All Rights Reserved.