View Javadoc
1   /*
2    * This class is an auto-generated source file for a HAPI
3    * HL7 v2.x standard structure class.
4    *
5    * For more information, visit: http://hl7api.sourceforge.net/
6    * 
7    * The contents of this file are subject to the Mozilla Public License Version 1.1 
8    * (the "License"); you may not use this file except in compliance with the License. 
9    * You may obtain a copy of the License at http://www.mozilla.org/MPL/ 
10   * Software distributed under the License is distributed on an "AS IS" basis, 
11   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 
12   * specific language governing rights and limitations under the License. 
13   * 
14   * The Original Code is "[file_name]".  Description: 
15   * "[one_line_description]" 
16   * 
17   * The Initial Developer of the Original Code is University Health Network. Copyright (C) 
18   * 2012.  All Rights Reserved. 
19   * 
20   * Contributor(s): ______________________________________. 
21   * 
22   * Alternatively, the contents of this file may be used under the terms of the 
23   * GNU General Public License (the  "GPL"), in which case the provisions of the GPL are 
24   * applicable instead of those above.  If you wish to allow use of your version of this 
25   * file only under the terms of the GPL and not to allow others to use your version 
26   * of this file under the MPL, indicate your decision by deleting  the provisions above 
27   * and replace  them with the notice and other provisions required by the GPL License.  
28   * If you do not delete the provisions above, a recipient may use your version of 
29   * this file under either the MPL or the GPL. 
30   * 
31   */
32  
33  
34  package ca.uhn.hl7v2.model.v22.segment;
35  
36  // import ca.uhn.hl7v2.model.v22.group.*;
37  import ca.uhn.hl7v2.model.v22.datatype.*;
38  import ca.uhn.hl7v2.HL7Exception;
39  import ca.uhn.hl7v2.parser.ModelClassFactory;
40  import ca.uhn.hl7v2.parser.DefaultModelClassFactory;
41  import ca.uhn.hl7v2.model.AbstractMessage;
42  import ca.uhn.hl7v2.model.Group;
43  import ca.uhn.hl7v2.model.Type;
44  import ca.uhn.hl7v2.model.AbstractSegment;
45  import ca.uhn.hl7v2.model.Varies;
46  
47  
48  /**
49   *<p>Represents an HL7 ODT message segment (DIET TRAY INSTRUCTION). 
50   * This segment has the following fields:</p>
51   * <ul>
52       * <li>ODT-1: Tray Type (CE) <b> </b>
53       * <li>ODT-2: Service Period (CE) <b>optional repeating</b>
54       * <li>ODT-3: Text Instruction (ST) <b>optional repeating</b>
55   * </ul>
56   */
57  @SuppressWarnings("unused")
58  public class ODT extends AbstractSegment {
59  
60      /** 
61       * Creates a new ODT segment
62       */
63      public ODT(Group parent, ModelClassFactory factory) {
64         super(parent, factory);
65         init(factory);
66      }
67  
68      private void init(ModelClassFactory factory) {
69         try {
70                                    this.add(CE.class, true, 1, 60, new Object[]{ getMessage() }, "Tray Type");
71                                    this.add(CE.class, false, 10, 60, new Object[]{ getMessage() }, "Service Period");
72                                    this.add(ST.class, false, 2, 80, new Object[]{ getMessage() }, "Text Instruction");
73         } catch(HL7Exception e) {
74            log.error("Unexpected error creating ODT - this is probably a bug in the source code generator.", e);
75         }
76      }
77  
78  
79  
80      /**
81       * Returns
82       * ODT-1: "Tray Type" - creates it if necessary
83       */
84      public CE getTrayType() { 
85  		CE retVal = this.getTypedField(1, 0);
86  		return retVal;
87      }
88      
89      /**
90       * Returns
91       * ODT-1: "Tray Type" - creates it if necessary
92       */
93      public CE getOdt1_TrayType() { 
94  		CE retVal = this.getTypedField(1, 0);
95  		return retVal;
96      }
97  
98  
99      /**
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