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.v231.segment;
009
010 // import ca.uhn.hl7v2.model.v231.group.*;
011 import ca.uhn.hl7v2.model.v231.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 EVN message segment (EVN - event type segment).
024 * This segment has the following fields:</p>
025 * <ul>
026 * <li>EVN-1: Event Type Code (ID) <b>optional </b>
027 * <li>EVN-2: Recorded Date/Time (TS) <b> </b>
028 * <li>EVN-3: Date/Time Planned Event (TS) <b>optional </b>
029 * <li>EVN-4: Event Reason Code (IS) <b>optional </b>
030 * <li>EVN-5: Operator ID (XCN) <b>optional repeating</b>
031 * <li>EVN-6: Event Occurred (TS) <b>optional </b>
032 * </ul>
033 */
034 public class EVN extends AbstractSegment {
035
036 /**
037 * Creates a new EVN segment
038 */
039 public EVN(Group parent, ModelClassFactory factory) {
040 super(parent, factory);
041 init(factory);
042 }
043
044 private void init(ModelClassFactory factory) {
045 try {
046 this.add(ID.class, false, 1, 3, new Object[]{ getMessage() }, "Event Type Code");
047 this.add(TS.class, true, 1, 26, new Object[]{ getMessage(), new Integer(0) }, "Recorded Date/Time");
048 this.add(TS.class, false, 1, 26, new Object[]{ getMessage(), new Integer(0) }, "Date/Time Planned Event");
049 this.add(IS.class, false, 1, 3, new Object[]{ getMessage() }, "Event Reason Code");
050 this.add(XCN.class, false, 0, 60, new Object[]{ getMessage(), new Integer(188) }, "Operator ID");
051 this.add(TS.class, false, 1, 26, new Object[]{ getMessage(), new Integer(0) }, "Event Occurred");
052 } catch(HL7Exception e) {
053 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating EVN - this is probably a bug in the source code generator.", e);
054 }
055 }
056
057
058
059 /**
060 * Returns
061 * EVN-1: "Event Type Code" - creates it if necessary
062 */
063 public ID getEventTypeCode() {
064 ID ret = null;
065 try {
066 Type t = this.getField(1, 0);
067 ret = (ID)t;
068 } catch (ClassCastException cce) {
069 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
070 throw new RuntimeException(cce);
071 } catch (HL7Exception he) {
072 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
073 throw new RuntimeException(he);
074 }
075 return ret;
076 }
077
078
079 /**
080 * Returns
081 * EVN-1: "Event Type Code" - creates it if necessary
082 */
083 public ID getEvn1_EventTypeCode() {
084 ID ret = null;
085 try {
086 Type t = this.getField(1, 0);
087 ret = (ID)t;
088 } catch (ClassCastException cce) {
089 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
090 throw new RuntimeException(cce);
091 } catch (HL7Exception he) {
092 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
093 throw new RuntimeException(he);
094 }
095 return ret;
096 }
097
098
099
100 /**
101 * Returns
102 * EVN-2: "Recorded Date/Time" - creates it if necessary
103 */
104 public TS getRecordedDateTime() {
105 TS ret = null;
106 try {
107 Type t = this.getField(2, 0);
108 ret = (TS)t;
109 } catch (ClassCastException cce) {
110 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
111 throw new RuntimeException(cce);
112 } catch (HL7Exception he) {
113 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
114 throw new RuntimeException(he);
115 }
116 return ret;
117 }
118
119
120 /**
121 * Returns
122 * EVN-2: "Recorded Date/Time" - creates it if necessary
123 */
124 public TS getEvn2_RecordedDateTime() {
125 TS ret = null;
126 try {
127 Type t = this.getField(2, 0);
128 ret = (TS)t;
129 } catch (ClassCastException cce) {
130 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
131 throw new RuntimeException(cce);
132 } catch (HL7Exception he) {
133 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
134 throw new RuntimeException(he);
135 }
136 return ret;
137 }
138
139
140
141 /**
142 * Returns
143 * EVN-3: "Date/Time Planned Event" - creates it if necessary
144 */
145 public TS getDateTimePlannedEvent() {
146 TS ret = null;
147 try {
148 Type t = this.getField(3, 0);
149 ret = (TS)t;
150 } catch (ClassCastException cce) {
151 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
152 throw new RuntimeException(cce);
153 } catch (HL7Exception he) {
154 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
155 throw new RuntimeException(he);
156 }
157 return ret;
158 }
159
160
161 /**
162 * Returns
163 * EVN-3: "Date/Time Planned Event" - creates it if necessary
164 */
165 public TS getEvn3_DateTimePlannedEvent() {
166 TS ret = null;
167 try {
168 Type t = this.getField(3, 0);
169 ret = (TS)t;
170 } catch (ClassCastException cce) {
171 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
172 throw new RuntimeException(cce);
173 } catch (HL7Exception he) {
174 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
175 throw new RuntimeException(he);
176 }
177 return ret;
178 }
179
180
181
182 /**
183 * Returns
184 * EVN-4: "Event Reason Code" - creates it if necessary
185 */
186 public IS getEventReasonCode() {
187 IS ret = null;
188 try {
189 Type t = this.getField(4, 0);
190 ret = (IS)t;
191 } catch (ClassCastException cce) {
192 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
193 throw new RuntimeException(cce);
194 } catch (HL7Exception he) {
195 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
196 throw new RuntimeException(he);
197 }
198 return ret;
199 }
200
201
202 /**
203 * Returns
204 * EVN-4: "Event Reason Code" - creates it if necessary
205 */
206 public IS getEvn4_EventReasonCode() {
207 IS ret = null;
208 try {
209 Type t = this.getField(4, 0);
210 ret = (IS)t;
211 } catch (ClassCastException cce) {
212 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
213 throw new RuntimeException(cce);
214 } catch (HL7Exception he) {
215 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
216 throw new RuntimeException(he);
217 }
218 return ret;
219 }
220
221
222 /**
223 * Returns all repetitions of Operator ID (EVN-5).
224 */
225 public XCN[] getOperatorID() {
226 XCN[] ret = null;
227 try {
228 Type[] t = this.getField(5);
229 ret = new XCN[t.length];
230 for (int i = 0; i < ret.length; i++) {
231 ret[i] = (XCN)t[i];
232 }
233 } catch (ClassCastException cce) {
234 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
235 throw new RuntimeException(cce);
236 } catch (HL7Exception he) {
237 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
238 throw new RuntimeException(he);
239 }
240 return ret;
241 }
242
243
244 /**
245 * Returns a count of the current number of repetitions of Operator ID (EVN-5).
246 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
247 * it will return zero.
248 */
249 public int getOperatorIDReps() {
250 XCN[] ret = null;
251 try {
252 Type[] t = this.getField(5);
253 return t.length;
254 } catch (ClassCastException cce) {
255 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
256 throw new RuntimeException(cce);
257 } catch (HL7Exception he) {
258 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
259 throw new RuntimeException(he);
260 }
261 }
262
263
264 /**
265 * Returns a specific repetition of
266 * EVN-5: "Operator ID" - creates it if necessary
267 *
268 * @param rep The repetition index (0-indexed)
269 */
270 public XCN getOperatorID(int rep) {
271 XCN ret = null;
272 try {
273 Type t = this.getField(5, rep);
274 ret = (XCN)t;
275 } catch (ClassCastException cce) {
276 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
277 throw new RuntimeException(cce);
278 } catch (HL7Exception he) {
279 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
280 throw new RuntimeException(he);
281 }
282 return ret;
283 }
284
285 /**
286 * Returns a specific repetition of
287 * EVN-5: "Operator ID" - creates it if necessary
288 *
289 * @param rep The repetition index (0-indexed)
290 */
291 public XCN getEvn5_OperatorID(int rep) {
292 XCN ret = null;
293 try {
294 Type t = this.getField(5, rep);
295 ret = (XCN)t;
296 } catch (ClassCastException cce) {
297 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
298 throw new RuntimeException(cce);
299 } catch (HL7Exception he) {
300 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
301 throw new RuntimeException(he);
302 }
303 return ret;
304 }
305
306
307 /**
308 * Returns a count of the current number of repetitions of Operator ID (EVN-5).
309 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
310 * it will return zero.
311 */
312 public int getEvn5_OperatorIDReps() {
313 XCN[] ret = null;
314 try {
315 Type[] t = this.getField(5);
316 return t.length;
317 } catch (ClassCastException cce) {
318 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
319 throw new RuntimeException(cce);
320 } catch (HL7Exception he) {
321 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
322 throw new RuntimeException(he);
323 }
324 }
325
326
327
328 /**
329 * Inserts a repetition of
330 * EVN-5: "Operator ID" at a specific index
331 *
332 * @param rep The repetition index (0-indexed)
333 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
334 */
335 public XCN insertOperatorID(int rep) throws HL7Exception {
336 return (XCN) super.insertRepetition(5, rep);
337 }
338
339
340
341 /**
342 * Inserts a repetition of
343 * EVN-5: "Operator ID" at a specific index
344 *
345 * @param rep The repetition index (0-indexed)
346 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
347 */
348 public XCN insertEvn5_OperatorID(int rep) throws HL7Exception {
349 return (XCN) super.insertRepetition(5, rep);
350 }
351
352
353 /**
354 * Removes a repetition of
355 * EVN-5: "Operator ID" at a specific index
356 *
357 * @param rep The repetition index (0-indexed)
358 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
359 */
360 public XCN removeOperatorID(int rep) throws HL7Exception {
361 return (XCN) super.removeRepetition(5, rep);
362 }
363
364
365 /**
366 * Removes a repetition of
367 * EVN-5: "Operator ID" at a specific index
368 *
369 * @param rep The repetition index (0-indexed)
370 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
371 */
372 public XCN removeEvn5_OperatorID(int rep) throws HL7Exception {
373 return (XCN) super.removeRepetition(5, rep);
374 }
375
376
377
378
379 /**
380 * Returns
381 * EVN-6: "Event Occurred" - creates it if necessary
382 */
383 public TS getEventOccurred() {
384 TS ret = null;
385 try {
386 Type t = this.getField(6, 0);
387 ret = (TS)t;
388 } catch (ClassCastException cce) {
389 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
390 throw new RuntimeException(cce);
391 } catch (HL7Exception he) {
392 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
393 throw new RuntimeException(he);
394 }
395 return ret;
396 }
397
398
399 /**
400 * Returns
401 * EVN-6: "Event Occurred" - creates it if necessary
402 */
403 public TS getEvn6_EventOccurred() {
404 TS ret = null;
405 try {
406 Type t = this.getField(6, 0);
407 ret = (TS)t;
408 } catch (ClassCastException cce) {
409 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
410 throw new RuntimeException(cce);
411 } catch (HL7Exception he) {
412 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
413 throw new RuntimeException(he);
414 }
415 return ret;
416 }
417
418
419
420
421
422 /** {@inheritDoc} */
423 protected Type createNewTypeWithoutReflection(int field) {
424 switch (field) {
425 case 0: return new ID(getMessage(), new Integer( 3 ));
426 case 1: return new TS(getMessage());
427 case 2: return new TS(getMessage());
428 case 3: return new IS(getMessage(), new Integer( 62 ));
429 case 4: return new XCN(getMessage());
430 case 5: return new TS(getMessage());
431 default: return null;
432 }
433 }
434
435
436 }
437