1/**2The contents of this file are subject to the Mozilla Public License Version 1.13(the "License"); you may not use this file except in compliance with the License.4You may obtain a copy of the License at http://www.mozilla.org/MPL/5Software distributed under the License is distributed on an "AS IS" basis,6WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the7specific language governing rights and limitations under the License.8 9The Original Code is "Segment.java". Description:10"Represents an HL7 message segment, which is a unit of data that contains multiple fields.11@author Bryan Tripp (bryan_tripp@sourceforge.net)"12 13The Initial Developer of the Original Code is University Health Network. Copyright (C)142001. All Rights Reserved.15 16Contributor(s): ______________________________________.17 18Alternatively, the contents of this file may be used under the terms of the19GNU General Public License (the �GPL�), in which case the provisions of the GPL are20applicable instead of those above. If you wish to allow use of your version of this21file only under the terms of the GPL and not to allow others to use your version22of this file under the MPL, indicate your decision by deleting the provisions above23and replace them with the notice and other provisions required by the GPL License.24If you do not delete the provisions above, a recipient may use your version of25this file under either the MPL or the GPL.26 27*/28packageca.uhn.hl7v2.model; 29 30importca.uhn.hl7v2.HL7Exception; 31 32/**33* Represents an HL7 message segment, which is a unit of data that contains multiple fields.34* @author Bryan Tripp (bryan_tripp@sourceforge.net)35*/36publicinterfaceSegmentextendsStructure { 37 38/**39* Encodes this message using the parser returned by {@link Message#getParser() }40*41* @return the string-encoded segment42* @throws HL7Exception if errors occurred during encoding43*/44publicString encode()throwsHL7Exception; 45 46/**47* Returns the array of Fields at the specified index. The array will be of length 1 for48* non-repeating fields, and >1 for repeating fields. Fields are numbered from 1.49*50* @param number field number (starting at 1)51* @return the array of Fields at the specified field number52* @throws HL7Exception if field index is out of range.53*/54publicType[] getField(intnumber)throwsHL7Exception; 55 56/**57* Returns a specific repetition of field at the specified index. If there exist58* fewer repetitions than are required, the number of repetitions can be increased59* by specifying the lowest repetition that does not yet exist. For example60* if there are two repetitions but three are needed, the third can be created61* and accessed using the following code: <br>62* <code>Type t = getField(x, 2);</code>63* @param number the field number (starting at 1)64* @param rep the repetition number (starting at 0)65* @return field at the specified field number and repetition66* @throws HL7Exception if field index is out of range, or if the specified67* repetition is more than 1 greater than the highest index of existing repetitions.68* NOTE: to facilitate local extensions, no exception is thrown if69* rep > max cardinality70*/71publicType getField(intnumber,intrep)throwsHL7Exception; 72 73/**74* Returns the maximum length of the field at the given index, in characters.75* @param number field number starting at 176* @return maximum length of the field77* @throws HL7Exception if field index is out of range.78*/79publicintgetLength(intnumber)throwsHL7Exception; 80 81/**82* Returns the maximum number of repetitions of this field that are allowed.83* The current cardinality can be obtained by checking the length84* of the array returned by getLength(n).85* @param number field number starting at 186* @return maximum number of repetitions of this field87* @throws HL7Exception if field index is out of range.88*/89publicintgetMaxCardinality(intnumber)throwsHL7Exception; 90 91/**92* Returns the names of the fields in this segment.93* @return array of names94*95* @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.96*/97publicString[] getNames(); 98 99/**100* Returns true if the field at the given index is required, false otherwise.101*102* @param number field number starting at 1103* @return true if the field is required104* @throws HL7Exception if field index is out of range.105*/106publicbooleanisRequired(intnumber)throwsHL7Exception; 107 108 109/**110* Returns the number of fields defined by this segment (repeating111* fields are not counted multiple times).112* @return number of fields113*/114publicintnumFields(); 115 116 117/**118* Parses the string into this segment using the parser returned by {@link Message#getParser() }119* @param string encoded segment120* @throws HL7Exception if errors occurred during parsing121*/122publicvoidparse(String string)throwsHL7Exception; 123 124 125 }