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