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
008 package ca.uhn.hl7v2.model.v24.segment;
009
010 // import ca.uhn.hl7v2.model.v24.group.*;
011 import ca.uhn.hl7v2.model.v24.datatype.*;
012 import ca.uhn.log.HapiLogFactory;
013 import ca.uhn.hl7v2.HL7Exception;
014 import ca.uhn.hl7v2.parser.ModelClassFactory;
015 import ca.uhn.hl7v2.parser.DefaultModelClassFactory;
016 import ca.uhn.hl7v2.model.AbstractMessage;
017 import ca.uhn.hl7v2.model.Group;
018 import ca.uhn.hl7v2.model.Type;
019 import ca.uhn.hl7v2.model.AbstractSegment;
020 import ca.uhn.hl7v2.model.Varies;
021
022 /**
023 *<p>Represents an HL7 OM5 message segment (Observation Batteries (Sets)).
024 * This segment has the following fields:</p>
025 * <ul>
026 * <li>OM5-1: Sequence Number - Test/ Observation Master File (NM) <b>optional </b>
027 * <li>OM5-2: Test/Observations Included within an Ordered Test Battery (CE) <b>optional repeating</b>
028 * <li>OM5-3: Observation ID Suffixes (ST) <b>optional </b>
029 * </ul>
030 */
031 public class OM5 extends AbstractSegment {
032
033 /**
034 * Creates a new OM5 segment
035 */
036 public OM5(Group parent, ModelClassFactory factory) {
037 super(parent, factory);
038 init(factory);
039 }
040
041 private void init(ModelClassFactory factory) {
042 try {
043 this.add(NM.class, false, 1, 4, new Object[]{ getMessage(), new Integer(0) }, "Sequence Number - Test/ Observation Master File");
044 this.add(CE.class, false, 0, 250, new Object[]{ getMessage(), new Integer(9999) }, "Test/Observations Included within an Ordered Test Battery");
045 this.add(ST.class, false, 1, 250, new Object[]{ getMessage(), new Integer(0) }, "Observation ID Suffixes");
046 } catch(HL7Exception e) {
047 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating OM5 - this is probably a bug in the source code generator.", e);
048 }
049 }
050
051
052
053 /**
054 * Returns
055 * OM5-1: "Sequence Number - Test/ Observation Master File" - creates it if necessary
056 */
057 public NM getSequenceNumberTestObservationMasterFile() {
058 NM ret = null;
059 try {
060 Type t = this.getField(1, 0);
061 ret = (NM)t;
062 } catch (ClassCastException cce) {
063 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
064 throw new RuntimeException(cce);
065 } catch (HL7Exception he) {
066 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
067 throw new RuntimeException(he);
068 }
069 return ret;
070 }
071
072
073 /**
074 * Returns
075 * OM5-1: "Sequence Number - Test/ Observation Master File" - creates it if necessary
076 */
077 public NM getOm51_SequenceNumberTestObservationMasterFile() {
078 NM ret = null;
079 try {
080 Type t = this.getField(1, 0);
081 ret = (NM)t;
082 } catch (ClassCastException cce) {
083 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
084 throw new RuntimeException(cce);
085 } catch (HL7Exception he) {
086 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
087 throw new RuntimeException(he);
088 }
089 return ret;
090 }
091
092
093 /**
094 * Returns all repetitions of Test/Observations Included within an Ordered Test Battery (OM5-2).
095 */
096 public CE[] getTestObservationsIncludedWithinAnOrderedTestBattery() {
097 CE[] ret = null;
098 try {
099 Type[] t = this.getField(2);
100 ret = new CE[t.length];
101 for (int i = 0; i < ret.length; i++) {
102 ret[i] = (CE)t[i];
103 }
104 } catch (ClassCastException cce) {
105 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
106 throw new RuntimeException(cce);
107 } catch (HL7Exception he) {
108 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
109 throw new RuntimeException(he);
110 }
111 return ret;
112 }
113
114
115 /**
116 * Returns a count of the current number of repetitions of Test/Observations Included within an Ordered Test Battery (OM5-2).
117 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
118 * it will return zero.
119 */
120 public int getTestObservationsIncludedWithinAnOrderedTestBatteryReps() {
121 CE[] ret = null;
122 try {
123 Type[] t = this.getField(2);
124 return t.length;
125 } catch (ClassCastException cce) {
126 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
127 throw new RuntimeException(cce);
128 } catch (HL7Exception he) {
129 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
130 throw new RuntimeException(he);
131 }
132 }
133
134
135 /**
136 * Returns a specific repetition of
137 * OM5-2: "Test/Observations Included within an Ordered Test Battery" - creates it if necessary
138 *
139 * @param rep The repetition index (0-indexed)
140 */
141 public CE getTestObservationsIncludedWithinAnOrderedTestBattery(int rep) {
142 CE ret = null;
143 try {
144 Type t = this.getField(2, rep);
145 ret = (CE)t;
146 } catch (ClassCastException cce) {
147 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
148 throw new RuntimeException(cce);
149 } catch (HL7Exception he) {
150 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
151 throw new RuntimeException(he);
152 }
153 return ret;
154 }
155
156 /**
157 * Returns a specific repetition of
158 * OM5-2: "Test/Observations Included within an Ordered Test Battery" - creates it if necessary
159 *
160 * @param rep The repetition index (0-indexed)
161 */
162 public CE getOm52_TestObservationsIncludedWithinAnOrderedTestBattery(int rep) {
163 CE ret = null;
164 try {
165 Type t = this.getField(2, rep);
166 ret = (CE)t;
167 } catch (ClassCastException cce) {
168 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
169 throw new RuntimeException(cce);
170 } catch (HL7Exception he) {
171 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
172 throw new RuntimeException(he);
173 }
174 return ret;
175 }
176
177
178 /**
179 * Returns a count of the current number of repetitions of Test/Observations Included within an Ordered Test Battery (OM5-2).
180 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
181 * it will return zero.
182 */
183 public int getOm52_TestObservationsIncludedWithinAnOrderedTestBatteryReps() {
184 CE[] ret = null;
185 try {
186 Type[] t = this.getField(2);
187 return t.length;
188 } catch (ClassCastException cce) {
189 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
190 throw new RuntimeException(cce);
191 } catch (HL7Exception he) {
192 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
193 throw new RuntimeException(he);
194 }
195 }
196
197
198
199 /**
200 * Inserts a repetition of
201 * OM5-2: "Test/Observations Included within an Ordered Test Battery" at a specific index
202 *
203 * @param rep The repetition index (0-indexed)
204 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
205 */
206 public CE insertTestObservationsIncludedWithinAnOrderedTestBattery(int rep) throws HL7Exception {
207 return (CE) super.insertRepetition(2, rep);
208 }
209
210
211
212 /**
213 * Inserts a repetition of
214 * OM5-2: "Test/Observations Included within an Ordered Test Battery" at a specific index
215 *
216 * @param rep The repetition index (0-indexed)
217 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
218 */
219 public CE insertOm52_TestObservationsIncludedWithinAnOrderedTestBattery(int rep) throws HL7Exception {
220 return (CE) super.insertRepetition(2, rep);
221 }
222
223
224 /**
225 * Removes a repetition of
226 * OM5-2: "Test/Observations Included within an Ordered Test Battery" at a specific index
227 *
228 * @param rep The repetition index (0-indexed)
229 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
230 */
231 public CE removeTestObservationsIncludedWithinAnOrderedTestBattery(int rep) throws HL7Exception {
232 return (CE) super.removeRepetition(2, rep);
233 }
234
235
236 /**
237 * Removes a repetition of
238 * OM5-2: "Test/Observations Included within an Ordered Test Battery" at a specific index
239 *
240 * @param rep The repetition index (0-indexed)
241 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
242 */
243 public CE removeOm52_TestObservationsIncludedWithinAnOrderedTestBattery(int rep) throws HL7Exception {
244 return (CE) super.removeRepetition(2, rep);
245 }
246
247
248
249
250 /**
251 * Returns
252 * OM5-3: "Observation ID Suffixes" - creates it if necessary
253 */
254 public ST getObservationIDSuffixes() {
255 ST ret = null;
256 try {
257 Type t = this.getField(3, 0);
258 ret = (ST)t;
259 } catch (ClassCastException cce) {
260 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
261 throw new RuntimeException(cce);
262 } catch (HL7Exception he) {
263 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
264 throw new RuntimeException(he);
265 }
266 return ret;
267 }
268
269
270 /**
271 * Returns
272 * OM5-3: "Observation ID Suffixes" - creates it if necessary
273 */
274 public ST getOm53_ObservationIDSuffixes() {
275 ST ret = null;
276 try {
277 Type t = this.getField(3, 0);
278 ret = (ST)t;
279 } catch (ClassCastException cce) {
280 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
281 throw new RuntimeException(cce);
282 } catch (HL7Exception he) {
283 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
284 throw new RuntimeException(he);
285 }
286 return ret;
287 }
288
289
290
291
292
293 /** {@inheritDoc} */
294 protected Type createNewTypeWithoutReflection(int field) {
295 switch (field) {
296 case 0: return new NM(getMessage());
297 case 1: return new CE(getMessage());
298 case 2: return new ST(getMessage());
299 default: return null;
300 }
301 }
302
303
304 }
305