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