001/*
002 * This class is an auto-generated source file for a HAPI
003 * HL7 v2.x standard structure class.
004 *
005 * For more information, visit: http://hl7api.sourceforge.net/
006 * 
007 * The contents of this file are subject to the Mozilla Public License Version 1.1 
008 * (the "License"); you may not use this file except in compliance with the License. 
009 * You may obtain a copy of the License at http://www.mozilla.org/MPL/ 
010 * Software distributed under the License is distributed on an "AS IS" basis, 
011 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 
012 * specific language governing rights and limitations under the License. 
013 * 
014 * The Original Code is "[file_name]".  Description: 
015 * "[one_line_description]" 
016 * 
017 * The Initial Developer of the Original Code is University Health Network. Copyright (C) 
018 * 2012.  All Rights Reserved. 
019 * 
020 * Contributor(s): ______________________________________. 
021 * 
022 * Alternatively, the contents of this file may be used under the terms of the 
023 * GNU General Public License (the  "GPL"), in which case the provisions of the GPL are 
024 * applicable instead of those above.  If you wish to allow use of your version of this 
025 * file only under the terms of the GPL and not to allow others to use your version 
026 * of this file under the MPL, indicate your decision by deleting  the provisions above 
027 * and replace  them with the notice and other provisions required by the GPL License.  
028 * If you do not delete the provisions above, a recipient may use your version of 
029 * this file under either the MPL or the GPL. 
030 * 
031 */
032
033
034package ca.uhn.hl7v2.model.v23.segment;
035
036// import ca.uhn.hl7v2.model.v23.group.*;
037import ca.uhn.hl7v2.model.v23.datatype.*;
038import ca.uhn.hl7v2.HL7Exception;
039import ca.uhn.hl7v2.parser.ModelClassFactory;
040import ca.uhn.hl7v2.parser.DefaultModelClassFactory;
041import ca.uhn.hl7v2.model.AbstractMessage;
042import ca.uhn.hl7v2.model.Group;
043import ca.uhn.hl7v2.model.Type;
044import ca.uhn.hl7v2.model.AbstractSegment;
045import ca.uhn.hl7v2.model.Varies;
046
047/**
048 *<p>Represents an HL7 ODT message segment (Diet tray instructions segment). 
049 * This segment has the following fields:</p>
050 * <ul>
051     * <li>ODT-1: Tray Type (CE) <b> </b>
052     * <li>ODT-2: Service Period (CE) <b>optional repeating</b>
053     * <li>ODT-3: Text Instruction (ST) <b>optional </b>
054 * </ul>
055 */
056@SuppressWarnings("unused")
057public class ODT extends AbstractSegment {
058
059    /** 
060     * Creates a new ODT segment
061     */
062    public ODT(Group parent, ModelClassFactory factory) {
063       super(parent, factory);
064       init(factory);
065    }
066
067    private void init(ModelClassFactory factory) {
068       try {
069                                  this.add(CE.class, true, 1, 60, new Object[]{ getMessage() }, "Tray Type");
070                                  this.add(CE.class, false, 10, 60, new Object[]{ getMessage() }, "Service Period");
071                                  this.add(ST.class, false, 1, 80, new Object[]{ getMessage() }, "Text Instruction");
072       } catch(HL7Exception e) {
073          log.error("Unexpected error creating ODT - this is probably a bug in the source code generator.", e);
074       }
075    }
076
077
078
079    /**
080     * Returns
081     * ODT-1: "Tray Type" - creates it if necessary
082     */
083    public CE getTrayType() { 
084                CE retVal = this.getTypedField(1, 0);
085                return retVal;
086    }
087    
088    /**
089     * Returns
090     * ODT-1: "Tray Type" - creates it if necessary
091     */
092    public CE getOdt1_TrayType() { 
093                CE retVal = this.getTypedField(1, 0);
094                return retVal;
095    }
096
097
098    /**
099     * Returns all repetitions of Service Period (ODT-2).
100     */
101    public CE[] getServicePeriod() {
102        CE[] retVal = this.getTypedField(2, new CE[0]);
103        return retVal;
104    }
105
106
107    /**
108     * Returns all repetitions of Service Period (ODT-2).
109     */
110    public CE[] getOdt2_ServicePeriod() {
111        CE[] retVal = this.getTypedField(2, new CE[0]);
112        return retVal;
113    }
114
115
116    /**
117     * Returns a count of the current number of repetitions of Service Period (ODT-2).
118     * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
119     * it will return zero.
120     */
121    public int getServicePeriodReps() {
122        return this.getReps(2);
123    }
124
125
126    /**
127     * Returns a specific repetition of
128     * ODT-2: "Service Period" - creates it if necessary
129     *
130     * @param rep The repetition index (0-indexed)
131     */
132    public CE getServicePeriod(int rep) { 
133                CE retVal = this.getTypedField(2, rep);
134                return retVal;
135    }
136
137    /**
138     * Returns a specific repetition of
139     * ODT-2: "Service Period" - creates it if necessary
140     *
141     * @param rep The repetition index (0-indexed)
142     */
143    public CE getOdt2_ServicePeriod(int rep) { 
144                CE retVal = this.getTypedField(2, rep);
145                return retVal;
146    }
147
148    /**
149     * Returns a count of the current number of repetitions of Service Period (ODT-2).
150     * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
151     * it will return zero.
152     */
153    public int getOdt2_ServicePeriodReps() {
154        return this.getReps(2);
155    }
156
157
158    /**
159     * Inserts a repetition of
160     * ODT-2: "Service Period" at a specific index
161     *
162     * @param rep The repetition index (0-indexed)
163     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
164     */
165    public CE insertServicePeriod(int rep) throws HL7Exception { 
166        return (CE) super.insertRepetition(2, rep);
167    }
168
169
170    /**
171     * Inserts a repetition of
172     * ODT-2: "Service Period" at a specific index
173     *
174     * @param rep The repetition index (0-indexed)
175     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
176     */
177    public CE insertOdt2_ServicePeriod(int rep) throws HL7Exception { 
178        return (CE) super.insertRepetition(2, rep);
179    }
180
181
182    /**
183     * Removes a repetition of
184     * ODT-2: "Service Period" at a specific index
185     *
186     * @param rep The repetition index (0-indexed)
187     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
188     */
189    public CE removeServicePeriod(int rep) throws HL7Exception { 
190        return (CE) super.removeRepetition(2, rep);
191    }
192
193
194    /**
195     * Removes a repetition of
196     * ODT-2: "Service Period" at a specific index
197     *
198     * @param rep The repetition index (0-indexed)
199     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
200     */
201    public CE removeOdt2_ServicePeriod(int rep) throws HL7Exception { 
202        return (CE) super.removeRepetition(2, rep);
203    }
204
205
206
207
208    /**
209     * Returns
210     * ODT-3: "Text Instruction" - creates it if necessary
211     */
212    public ST getTextInstruction() { 
213                ST retVal = this.getTypedField(3, 0);
214                return retVal;
215    }
216    
217    /**
218     * Returns
219     * ODT-3: "Text Instruction" - creates it if necessary
220     */
221    public ST getOdt3_TextInstruction() { 
222                ST retVal = this.getTypedField(3, 0);
223                return retVal;
224    }
225
226
227
228
229
230    /** {@inheritDoc} */   
231    protected Type createNewTypeWithoutReflection(int field) {
232       switch (field) {
233          case 0: return new CE(getMessage());
234          case 1: return new CE(getMessage());
235          case 2: return new ST(getMessage());
236          default: return null;
237       }
238   }
239
240
241}
242