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.v24.segment;
35  
36  // import ca.uhn.hl7v2.model.v24.group.*;
37  import ca.uhn.hl7v2.model.v24.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 ODS message segment (Dietary Orders, Supplements, and Preferences). 
50   * This segment has the following fields:</p>
51   * <ul>
52       * <li>ODS-1: Type (ID) <b> </b>
53       * <li>ODS-2: Service Period (CE) <b>optional repeating</b>
54       * <li>ODS-3: Diet, Supplement, or Preference Code (CE) <b> repeating</b>
55       * <li>ODS-4: Text Instruction (ST) <b>optional repeating</b>
56   * </ul>
57   */
58  @SuppressWarnings("unused")
59  public class ODS extends AbstractSegment {
60  
61      /** 
62       * Creates a new ODS segment
63       */
64      public ODS(Group parent, ModelClassFactory factory) {
65         super(parent, factory);
66         init(factory);
67      }
68  
69      private void init(ModelClassFactory factory) {
70         try {
71                                                this.add(ID.class, true, 1, 1, new Object[]{ getMessage(), new Integer(159) }, "Type");
72                                    this.add(CE.class, false, 10, 250, new Object[]{ getMessage() }, "Service Period");
73                                    this.add(CE.class, true, 20, 250, new Object[]{ getMessage() }, "Diet, Supplement, or Preference Code");
74                                    this.add(ST.class, false, 2, 80, new Object[]{ getMessage() }, "Text Instruction");
75         } catch(HL7Exception e) {
76            log.error("Unexpected error creating ODS - this is probably a bug in the source code generator.", e);
77         }
78      }
79  
80  
81  
82      /**
83       * Returns
84       * ODS-1: "Type" - creates it if necessary
85       */
86      public ID getType() { 
87  		ID retVal = this.getTypedField(1, 0);
88  		return retVal;
89      }
90      
91      /**
92       * Returns
93       * ODS-1: "Type" - creates it if necessary
94       */
95      public ID getOds1_Type() { 
96  		ID retVal = this.getTypedField(1, 0);
97  		return retVal;
98      }
99  
100 
101     /**
102      * Returns all repetitions of Service Period (ODS-2).
103      */
104     public CE[] getServicePeriod() {
105     	CE[] retVal = this.getTypedField(2, new CE[0]);
106     	return retVal;
107     }
108 
109 
110     /**
111      * Returns all repetitions of Service Period (ODS-2).
112      */
113     public CE[] getOds2_ServicePeriod() {
114     	CE[] retVal = this.getTypedField(2, new CE[0]);
115     	return retVal;
116     }
117 
118 
119     /**
120      * Returns a count of the current number of repetitions of Service Period (ODS-2).
121      * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
122      * it will return zero.
123      */
124     public int getServicePeriodReps() {
125     	return this.getReps(2);
126     }
127 
128 
129     /**
130      * Returns a specific repetition of
131      * ODS-2: "Service Period" - creates it if necessary
132      *
133      * @param rep The repetition index (0-indexed)
134      */
135     public CE getServicePeriod(int rep) { 
136 		CE retVal = this.getTypedField(2, rep);
137 		return retVal;
138     }
139 
140     /**
141      * Returns a specific repetition of
142      * ODS-2: "Service Period" - creates it if necessary
143      *
144      * @param rep The repetition index (0-indexed)
145      */
146     public CE getOds2_ServicePeriod(int rep) { 
147 		CE retVal = this.getTypedField(2, rep);
148 		return retVal;
149     }
150 
151     /**
152      * Returns a count of the current number of repetitions of Service Period (ODS-2).
153      * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
154      * it will return zero.
155      */
156     public int getOds2_ServicePeriodReps() {
157     	return this.getReps(2);
158     }
159 
160 
161     /**
162      * Inserts a repetition of
163      * ODS-2: "Service Period" at a specific index
164      *
165      * @param rep The repetition index (0-indexed)
166      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
167      */
168     public CE insertServicePeriod(int rep) throws HL7Exception { 
169         return (CE) super.insertRepetition(2, rep);
170     }
171 
172 
173     /**
174      * Inserts a repetition of
175      * ODS-2: "Service Period" at a specific index
176      *
177      * @param rep The repetition index (0-indexed)
178      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
179      */
180     public CE insertOds2_ServicePeriod(int rep) throws HL7Exception { 
181         return (CE) super.insertRepetition(2, rep);
182     }
183 
184 
185     /**
186      * Removes a repetition of
187      * ODS-2: "Service Period" at a specific index
188      *
189      * @param rep The repetition index (0-indexed)
190      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
191      */
192     public CE removeServicePeriod(int rep) throws HL7Exception { 
193         return (CE) super.removeRepetition(2, rep);
194     }
195 
196 
197     /**
198      * Removes a repetition of
199      * ODS-2: "Service Period" at a specific index
200      *
201      * @param rep The repetition index (0-indexed)
202      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
203      */
204     public CE removeOds2_ServicePeriod(int rep) throws HL7Exception { 
205         return (CE) super.removeRepetition(2, rep);
206     }
207 
208 
209 
210     /**
211      * Returns all repetitions of Diet, Supplement, or Preference Code (ODS-3).
212      */
213     public CE[] getDietSupplementOrPreferenceCode() {
214     	CE[] retVal = this.getTypedField(3, new CE[0]);
215     	return retVal;
216     }
217 
218 
219     /**
220      * Returns all repetitions of Diet, Supplement, or Preference Code (ODS-3).
221      */
222     public CE[] getOds3_DietSupplementOrPreferenceCode() {
223     	CE[] retVal = this.getTypedField(3, new CE[0]);
224     	return retVal;
225     }
226 
227 
228     /**
229      * Returns a count of the current number of repetitions of Diet, Supplement, or Preference Code (ODS-3).
230      * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
231      * it will return zero.
232      */
233     public int getDietSupplementOrPreferenceCodeReps() {
234     	return this.getReps(3);
235     }
236 
237 
238     /**
239      * Returns a specific repetition of
240      * ODS-3: "Diet, Supplement, or Preference Code" - creates it if necessary
241      *
242      * @param rep The repetition index (0-indexed)
243      */
244     public CE getDietSupplementOrPreferenceCode(int rep) { 
245 		CE retVal = this.getTypedField(3, rep);
246 		return retVal;
247     }
248 
249     /**
250      * Returns a specific repetition of
251      * ODS-3: "Diet, Supplement, or Preference Code" - creates it if necessary
252      *
253      * @param rep The repetition index (0-indexed)
254      */
255     public CE getOds3_DietSupplementOrPreferenceCode(int rep) { 
256 		CE retVal = this.getTypedField(3, rep);
257 		return retVal;
258     }
259 
260     /**
261      * Returns a count of the current number of repetitions of Diet, Supplement, or Preference Code (ODS-3).
262      * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
263      * it will return zero.
264      */
265     public int getOds3_DietSupplementOrPreferenceCodeReps() {
266     	return this.getReps(3);
267     }
268 
269 
270     /**
271      * Inserts a repetition of
272      * ODS-3: "Diet, Supplement, or Preference Code" at a specific index
273      *
274      * @param rep The repetition index (0-indexed)
275      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
276      */
277     public CE insertDietSupplementOrPreferenceCode(int rep) throws HL7Exception { 
278         return (CE) super.insertRepetition(3, rep);
279     }
280 
281 
282     /**
283      * Inserts a repetition of
284      * ODS-3: "Diet, Supplement, or Preference Code" at a specific index
285      *
286      * @param rep The repetition index (0-indexed)
287      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
288      */
289     public CE insertOds3_DietSupplementOrPreferenceCode(int rep) throws HL7Exception { 
290         return (CE) super.insertRepetition(3, rep);
291     }
292 
293 
294     /**
295      * Removes a repetition of
296      * ODS-3: "Diet, Supplement, or Preference Code" at a specific index
297      *
298      * @param rep The repetition index (0-indexed)
299      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
300      */
301     public CE removeDietSupplementOrPreferenceCode(int rep) throws HL7Exception { 
302         return (CE) super.removeRepetition(3, rep);
303     }
304 
305 
306     /**
307      * Removes a repetition of
308      * ODS-3: "Diet, Supplement, or Preference Code" at a specific index
309      *
310      * @param rep The repetition index (0-indexed)
311      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
312      */
313     public CE removeOds3_DietSupplementOrPreferenceCode(int rep) throws HL7Exception { 
314         return (CE) super.removeRepetition(3, rep);
315     }
316 
317 
318 
319     /**
320      * Returns all repetitions of Text Instruction (ODS-4).
321      */
322     public ST[] getTextInstruction() {
323     	ST[] retVal = this.getTypedField(4, new ST[0]);
324     	return retVal;
325     }
326 
327 
328     /**
329      * Returns all repetitions of Text Instruction (ODS-4).
330      */
331     public ST[] getOds4_TextInstruction() {
332     	ST[] retVal = this.getTypedField(4, new ST[0]);
333     	return retVal;
334     }
335 
336 
337     /**
338      * Returns a count of the current number of repetitions of Text Instruction (ODS-4).
339      * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
340      * it will return zero.
341      */
342     public int getTextInstructionReps() {
343     	return this.getReps(4);
344     }
345 
346 
347     /**
348      * Returns a specific repetition of
349      * ODS-4: "Text Instruction" - creates it if necessary
350      *
351      * @param rep The repetition index (0-indexed)
352      */
353     public ST getTextInstruction(int rep) { 
354 		ST retVal = this.getTypedField(4, rep);
355 		return retVal;
356     }
357 
358     /**
359      * Returns a specific repetition of
360      * ODS-4: "Text Instruction" - creates it if necessary
361      *
362      * @param rep The repetition index (0-indexed)
363      */
364     public ST getOds4_TextInstruction(int rep) { 
365 		ST retVal = this.getTypedField(4, rep);
366 		return retVal;
367     }
368 
369     /**
370      * Returns a count of the current number of repetitions of Text Instruction (ODS-4).
371      * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
372      * it will return zero.
373      */
374     public int getOds4_TextInstructionReps() {
375     	return this.getReps(4);
376     }
377 
378 
379     /**
380      * Inserts a repetition of
381      * ODS-4: "Text Instruction" at a specific index
382      *
383      * @param rep The repetition index (0-indexed)
384      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
385      */
386     public ST insertTextInstruction(int rep) throws HL7Exception { 
387         return (ST) super.insertRepetition(4, rep);
388     }
389 
390 
391     /**
392      * Inserts a repetition of
393      * ODS-4: "Text Instruction" at a specific index
394      *
395      * @param rep The repetition index (0-indexed)
396      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
397      */
398     public ST insertOds4_TextInstruction(int rep) throws HL7Exception { 
399         return (ST) super.insertRepetition(4, rep);
400     }
401 
402 
403     /**
404      * Removes a repetition of
405      * ODS-4: "Text Instruction" at a specific index
406      *
407      * @param rep The repetition index (0-indexed)
408      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
409      */
410     public ST removeTextInstruction(int rep) throws HL7Exception { 
411         return (ST) super.removeRepetition(4, rep);
412     }
413 
414 
415     /**
416      * Removes a repetition of
417      * ODS-4: "Text Instruction" at a specific index
418      *
419      * @param rep The repetition index (0-indexed)
420      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
421      */
422     public ST removeOds4_TextInstruction(int rep) throws HL7Exception { 
423         return (ST) super.removeRepetition(4, rep);
424     }
425 
426 
427 
428 
429 
430 
431     /** {@inheritDoc} */   
432     protected Type createNewTypeWithoutReflection(int field) {
433        switch (field) {
434           case 0: return new ID(getMessage(), new Integer( 159 ));
435           case 1: return new CE(getMessage());
436           case 2: return new CE(getMessage());
437           case 3: return new ST(getMessage());
438           default: return null;
439        }
440    }
441 
442 
443 }
444