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.v27.segment;
035
036// import ca.uhn.hl7v2.model.v27.group.*;
037import ca.uhn.hl7v2.model.v27.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 OM5 message segment (Observation Batteries (Sets)). 
050 * This segment has the following fields:</p>
051 * <ul>
052     * <li>OM5-1: Sequence Number - Test/Observation Master File (NM) <b>optional </b>
053     * <li>OM5-2: Test/Observations Included Within an Ordered Test Battery (CWE) <b>optional repeating</b>
054     * <li>OM5-3: Observation ID Suffixes (ST) <b>optional </b>
055 * </ul>
056 */
057@SuppressWarnings("unused")
058public class OM5 extends AbstractSegment {
059
060    /** 
061     * Creates a new OM5 segment
062     */
063    public OM5(Group parent, ModelClassFactory factory) {
064       super(parent, factory);
065       init(factory);
066    }
067
068    private void init(ModelClassFactory factory) {
069       try {
070                                  this.add(NM.class, false, 1, 0, new Object[]{ getMessage() }, "Sequence Number - Test/Observation Master File");
071                                  this.add(CWE.class, false, 0, 0, new Object[]{ getMessage() }, "Test/Observations Included Within an Ordered Test Battery");
072                                  this.add(ST.class, false, 1, 0, new Object[]{ getMessage() }, "Observation ID Suffixes");
073       } catch(HL7Exception e) {
074          log.error("Unexpected error creating OM5 - this is probably a bug in the source code generator.", e);
075       }
076    }
077
078
079
080    /**
081     * Returns
082     * OM5-1: "Sequence Number - Test/Observation Master File" - creates it if necessary
083     */
084    public NM getSequenceNumberTestObservationMasterFile() { 
085                NM retVal = this.getTypedField(1, 0);
086                return retVal;
087    }
088    
089    /**
090     * Returns
091     * OM5-1: "Sequence Number - Test/Observation Master File" - creates it if necessary
092     */
093    public NM getOm51_SequenceNumberTestObservationMasterFile() { 
094                NM retVal = this.getTypedField(1, 0);
095                return retVal;
096    }
097
098
099    /**
100     * Returns all repetitions of Test/Observations Included Within an Ordered Test Battery (OM5-2).
101     */
102    public CWE[] getTestObservationsIncludedWithinAnOrderedTestBattery() {
103        CWE[] retVal = this.getTypedField(2, new CWE[0]);
104        return retVal;
105    }
106
107
108    /**
109     * Returns all repetitions of Test/Observations Included Within an Ordered Test Battery (OM5-2).
110     */
111    public CWE[] getOm52_TestObservationsIncludedWithinAnOrderedTestBattery() {
112        CWE[] retVal = this.getTypedField(2, new CWE[0]);
113        return retVal;
114    }
115
116
117    /**
118     * Returns a count of the current number of repetitions of Test/Observations Included Within an Ordered Test Battery (OM5-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 getTestObservationsIncludedWithinAnOrderedTestBatteryReps() {
123        return this.getReps(2);
124    }
125
126
127    /**
128     * Returns a specific repetition of
129     * OM5-2: "Test/Observations Included Within an Ordered Test Battery" - creates it if necessary
130     *
131     * @param rep The repetition index (0-indexed)
132     */
133    public CWE getTestObservationsIncludedWithinAnOrderedTestBattery(int rep) { 
134                CWE retVal = this.getTypedField(2, rep);
135                return retVal;
136    }
137
138    /**
139     * Returns a specific repetition of
140     * OM5-2: "Test/Observations Included Within an Ordered Test Battery" - creates it if necessary
141     *
142     * @param rep The repetition index (0-indexed)
143     */
144    public CWE getOm52_TestObservationsIncludedWithinAnOrderedTestBattery(int rep) { 
145                CWE retVal = this.getTypedField(2, rep);
146                return retVal;
147    }
148
149    /**
150     * Returns a count of the current number of repetitions of Test/Observations Included Within an Ordered Test Battery (OM5-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 getOm52_TestObservationsIncludedWithinAnOrderedTestBatteryReps() {
155        return this.getReps(2);
156    }
157
158
159    /**
160     * Inserts a repetition of
161     * OM5-2: "Test/Observations Included Within an Ordered Test Battery" 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 CWE insertTestObservationsIncludedWithinAnOrderedTestBattery(int rep) throws HL7Exception { 
167        return (CWE) super.insertRepetition(2, rep);
168    }
169
170
171    /**
172     * Inserts a repetition of
173     * OM5-2: "Test/Observations Included Within an Ordered Test Battery" 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 CWE insertOm52_TestObservationsIncludedWithinAnOrderedTestBattery(int rep) throws HL7Exception { 
179        return (CWE) super.insertRepetition(2, rep);
180    }
181
182
183    /**
184     * Removes a repetition of
185     * OM5-2: "Test/Observations Included Within an Ordered Test Battery" 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 CWE removeTestObservationsIncludedWithinAnOrderedTestBattery(int rep) throws HL7Exception { 
191        return (CWE) super.removeRepetition(2, rep);
192    }
193
194
195    /**
196     * Removes a repetition of
197     * OM5-2: "Test/Observations Included Within an Ordered Test Battery" 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 CWE removeOm52_TestObservationsIncludedWithinAnOrderedTestBattery(int rep) throws HL7Exception { 
203        return (CWE) super.removeRepetition(2, rep);
204    }
205
206
207
208
209    /**
210     * Returns
211     * OM5-3: "Observation ID Suffixes" - creates it if necessary
212     */
213    public ST getObservationIDSuffixes() { 
214                ST retVal = this.getTypedField(3, 0);
215                return retVal;
216    }
217    
218    /**
219     * Returns
220     * OM5-3: "Observation ID Suffixes" - creates it if necessary
221     */
222    public ST getOm53_ObservationIDSuffixes() { 
223                ST retVal = this.getTypedField(3, 0);
224                return retVal;
225    }
226
227
228
229
230
231    /** {@inheritDoc} */   
232    protected Type createNewTypeWithoutReflection(int field) {
233       switch (field) {
234          case 0: return new NM(getMessage());
235          case 1: return new CWE(getMessage());
236          case 2: return new ST(getMessage());
237          default: return null;
238       }
239   }
240
241
242}
243