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.v22.segment;
035
036// import ca.uhn.hl7v2.model.v22.group.*;
037import ca.uhn.hl7v2.model.v22.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/**
049 *<p>Represents an HL7 ODT message segment (DIET TRAY INSTRUCTION). 
050 * This segment has the following fields:</p>
051 * <ul>
052     * <li>ODT-1: Tray Type (CE) <b> </b>
053     * <li>ODT-2: Service Period (CE) <b>optional repeating</b>
054     * <li>ODT-3: Text Instruction (ST) <b>optional repeating</b>
055 * </ul>
056 */
057@SuppressWarnings("unused")
058public class ODT extends AbstractSegment {
059
060    /** 
061     * Creates a new ODT segment
062     */
063    public ODT(Group parent, ModelClassFactory factory) {
064       super(parent, factory);
065       init(factory);
066    }
067
068    private void init(ModelClassFactory factory) {
069       try {
070                                  this.add(CE.class, true, 1, 60, new Object[]{ getMessage() }, "Tray Type");
071                                  this.add(CE.class, false, 10, 60, new Object[]{ getMessage() }, "Service Period");
072                                  this.add(ST.class, false, 2, 80, new Object[]{ getMessage() }, "Text Instruction");
073       } catch(HL7Exception e) {
074          log.error("Unexpected error creating ODT - this is probably a bug in the source code generator.", e);
075       }
076    }
077
078
079
080    /**
081     * Returns
082     * ODT-1: "Tray Type" - creates it if necessary
083     */
084    public CE getTrayType() { 
085                CE retVal = this.getTypedField(1, 0);
086                return retVal;
087    }
088    
089    /**
090     * Returns
091     * ODT-1: "Tray Type" - creates it if necessary
092     */
093    public CE getOdt1_TrayType() { 
094                CE retVal = this.getTypedField(1, 0);
095                return retVal;
096    }
097
098
099    /**
100     * Returns all repetitions of Service Period (ODT-2).
101     */
102    public CE[] getServicePeriod() {
103        CE[] retVal = this.getTypedField(2, new CE[0]);
104        return retVal;
105    }
106
107
108    /**
109     * Returns all repetitions of Service Period (ODT-2).
110     */
111    public CE[] getOdt2_ServicePeriod() {
112        CE[] retVal = this.getTypedField(2, new CE[0]);
113        return retVal;
114    }
115
116
117    /**
118     * Returns a count of the current number of repetitions of Service Period (ODT-2).
119     * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
120     * it will return zero.
121     */
122    public int getServicePeriodReps() {
123        return this.getReps(2);
124    }
125
126
127    /**
128     * Returns a specific repetition of
129     * ODT-2: "Service Period" - creates it if necessary
130     *
131     * @param rep The repetition index (0-indexed)
132     */
133    public CE getServicePeriod(int rep) { 
134                CE retVal = this.getTypedField(2, rep);
135                return retVal;
136    }
137
138    /**
139     * Returns a specific repetition of
140     * ODT-2: "Service Period" - creates it if necessary
141     *
142     * @param rep The repetition index (0-indexed)
143     */
144    public CE getOdt2_ServicePeriod(int rep) { 
145                CE retVal = this.getTypedField(2, rep);
146                return retVal;
147    }
148
149    /**
150     * Returns a count of the current number of repetitions of Service Period (ODT-2).
151     * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
152     * it will return zero.
153     */
154    public int getOdt2_ServicePeriodReps() {
155        return this.getReps(2);
156    }
157
158
159    /**
160     * Inserts a repetition of
161     * ODT-2: "Service Period" at a specific index
162     *
163     * @param rep The repetition index (0-indexed)
164     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
165     */
166    public CE insertServicePeriod(int rep) throws HL7Exception { 
167        return (CE) super.insertRepetition(2, rep);
168    }
169
170
171    /**
172     * Inserts a repetition of
173     * ODT-2: "Service Period" at a specific index
174     *
175     * @param rep The repetition index (0-indexed)
176     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
177     */
178    public CE insertOdt2_ServicePeriod(int rep) throws HL7Exception { 
179        return (CE) super.insertRepetition(2, rep);
180    }
181
182
183    /**
184     * Removes a repetition of
185     * ODT-2: "Service Period" at a specific index
186     *
187     * @param rep The repetition index (0-indexed)
188     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
189     */
190    public CE removeServicePeriod(int rep) throws HL7Exception { 
191        return (CE) super.removeRepetition(2, rep);
192    }
193
194
195    /**
196     * Removes a repetition of
197     * ODT-2: "Service Period" at a specific index
198     *
199     * @param rep The repetition index (0-indexed)
200     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
201     */
202    public CE removeOdt2_ServicePeriod(int rep) throws HL7Exception { 
203        return (CE) super.removeRepetition(2, rep);
204    }
205
206
207
208    /**
209     * Returns all repetitions of Text Instruction (ODT-3).
210     */
211    public ST[] getTextInstruction() {
212        ST[] retVal = this.getTypedField(3, new ST[0]);
213        return retVal;
214    }
215
216
217    /**
218     * Returns all repetitions of Text Instruction (ODT-3).
219     */
220    public ST[] getOdt3_TextInstruction() {
221        ST[] retVal = this.getTypedField(3, new ST[0]);
222        return retVal;
223    }
224
225
226    /**
227     * Returns a count of the current number of repetitions of Text Instruction (ODT-3).
228     * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
229     * it will return zero.
230     */
231    public int getTextInstructionReps() {
232        return this.getReps(3);
233    }
234
235
236    /**
237     * Returns a specific repetition of
238     * ODT-3: "Text Instruction" - creates it if necessary
239     *
240     * @param rep The repetition index (0-indexed)
241     */
242    public ST getTextInstruction(int rep) { 
243                ST retVal = this.getTypedField(3, rep);
244                return retVal;
245    }
246
247    /**
248     * Returns a specific repetition of
249     * ODT-3: "Text Instruction" - creates it if necessary
250     *
251     * @param rep The repetition index (0-indexed)
252     */
253    public ST getOdt3_TextInstruction(int rep) { 
254                ST retVal = this.getTypedField(3, rep);
255                return retVal;
256    }
257
258    /**
259     * Returns a count of the current number of repetitions of Text Instruction (ODT-3).
260     * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
261     * it will return zero.
262     */
263    public int getOdt3_TextInstructionReps() {
264        return this.getReps(3);
265    }
266
267
268    /**
269     * Inserts a repetition of
270     * ODT-3: "Text Instruction" at a specific index
271     *
272     * @param rep The repetition index (0-indexed)
273     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
274     */
275    public ST insertTextInstruction(int rep) throws HL7Exception { 
276        return (ST) super.insertRepetition(3, rep);
277    }
278
279
280    /**
281     * Inserts a repetition of
282     * ODT-3: "Text Instruction" at a specific index
283     *
284     * @param rep The repetition index (0-indexed)
285     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
286     */
287    public ST insertOdt3_TextInstruction(int rep) throws HL7Exception { 
288        return (ST) super.insertRepetition(3, rep);
289    }
290
291
292    /**
293     * Removes a repetition of
294     * ODT-3: "Text Instruction" at a specific index
295     *
296     * @param rep The repetition index (0-indexed)
297     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
298     */
299    public ST removeTextInstruction(int rep) throws HL7Exception { 
300        return (ST) super.removeRepetition(3, rep);
301    }
302
303
304    /**
305     * Removes a repetition of
306     * ODT-3: "Text Instruction" at a specific index
307     *
308     * @param rep The repetition index (0-indexed)
309     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
310     */
311    public ST removeOdt3_TextInstruction(int rep) throws HL7Exception { 
312        return (ST) super.removeRepetition(3, rep);
313    }
314
315
316
317
318
319
320    /** {@inheritDoc} */   
321    protected Type createNewTypeWithoutReflection(int field) {
322       switch (field) {
323          case 0: return new CE(getMessage());
324          case 1: return new CE(getMessage());
325          case 2: return new ST(getMessage());
326          default: return null;
327       }
328   }
329
330
331}
332