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 AL1 message segment (Patient allergy information).
024 * This segment has the following fields:</p>
025 * <ul>
026 * <li>AL1-1: Set ID - AL1 (CE) <b> </b>
027 * <li>AL1-2: Allergen Type Code (CE) <b>optional </b>
028 * <li>AL1-3: Allergen Code/Mnemonic/Description (CE) <b> </b>
029 * <li>AL1-4: Allergy Severity Code (CE) <b>optional </b>
030 * <li>AL1-5: Allergy Reaction Code (ST) <b>optional repeating</b>
031 * <li>AL1-6: Identification Date (DT) <b>optional </b>
032 * </ul>
033 */
034 public class AL1 extends AbstractSegment {
035
036 /**
037 * Creates a new AL1 segment
038 */
039 public AL1(Group parent, ModelClassFactory factory) {
040 super(parent, factory);
041 init(factory);
042 }
043
044 private void init(ModelClassFactory factory) {
045 try {
046 this.add(CE.class, true, 1, 250, new Object[]{ getMessage(), new Integer(0) }, "Set ID - AL1");
047 this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(127) }, "Allergen Type Code");
048 this.add(CE.class, true, 1, 250, new Object[]{ getMessage(), new Integer(0) }, "Allergen Code/Mnemonic/Description");
049 this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(128) }, "Allergy Severity Code");
050 this.add(ST.class, false, 0, 15, new Object[]{ getMessage(), new Integer(0) }, "Allergy Reaction Code");
051 this.add(DT.class, false, 1, 8, new Object[]{ getMessage(), new Integer(0) }, "Identification Date");
052 } catch(HL7Exception e) {
053 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating AL1 - this is probably a bug in the source code generator.", e);
054 }
055 }
056
057
058
059 /**
060 * Returns
061 * AL1-1: "Set ID - AL1" - creates it if necessary
062 */
063 public CE getSetIDAL1() {
064 CE ret = null;
065 try {
066 Type t = this.getField(1, 0);
067 ret = (CE)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 * AL1-1: "Set ID - AL1" - creates it if necessary
082 */
083 public CE getAl11_SetIDAL1() {
084 CE ret = null;
085 try {
086 Type t = this.getField(1, 0);
087 ret = (CE)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 * AL1-2: "Allergen Type Code" - creates it if necessary
103 */
104 public CE getAllergenTypeCode() {
105 CE ret = null;
106 try {
107 Type t = this.getField(2, 0);
108 ret = (CE)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 * AL1-2: "Allergen Type Code" - creates it if necessary
123 */
124 public CE getAl12_AllergenTypeCode() {
125 CE ret = null;
126 try {
127 Type t = this.getField(2, 0);
128 ret = (CE)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 * AL1-3: "Allergen Code/Mnemonic/Description" - creates it if necessary
144 */
145 public CE getAllergenCodeMnemonicDescription() {
146 CE ret = null;
147 try {
148 Type t = this.getField(3, 0);
149 ret = (CE)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 * AL1-3: "Allergen Code/Mnemonic/Description" - creates it if necessary
164 */
165 public CE getAl13_AllergenCodeMnemonicDescription() {
166 CE ret = null;
167 try {
168 Type t = this.getField(3, 0);
169 ret = (CE)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 * AL1-4: "Allergy Severity Code" - creates it if necessary
185 */
186 public CE getAllergySeverityCode() {
187 CE ret = null;
188 try {
189 Type t = this.getField(4, 0);
190 ret = (CE)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 * AL1-4: "Allergy Severity Code" - creates it if necessary
205 */
206 public CE getAl14_AllergySeverityCode() {
207 CE ret = null;
208 try {
209 Type t = this.getField(4, 0);
210 ret = (CE)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 Allergy Reaction Code (AL1-5).
224 */
225 public ST[] getAllergyReactionCode() {
226 ST[] ret = null;
227 try {
228 Type[] t = this.getField(5);
229 ret = new ST[t.length];
230 for (int i = 0; i < ret.length; i++) {
231 ret[i] = (ST)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 Allergy Reaction Code (AL1-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 getAllergyReactionCodeReps() {
250 ST[] 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 * AL1-5: "Allergy Reaction Code" - creates it if necessary
267 *
268 * @param rep The repetition index (0-indexed)
269 */
270 public ST getAllergyReactionCode(int rep) {
271 ST ret = null;
272 try {
273 Type t = this.getField(5, rep);
274 ret = (ST)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 * AL1-5: "Allergy Reaction Code" - creates it if necessary
288 *
289 * @param rep The repetition index (0-indexed)
290 */
291 public ST getAl15_AllergyReactionCode(int rep) {
292 ST ret = null;
293 try {
294 Type t = this.getField(5, rep);
295 ret = (ST)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 Allergy Reaction Code (AL1-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 getAl15_AllergyReactionCodeReps() {
313 ST[] 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 * AL1-5: "Allergy Reaction Code" 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 ST insertAllergyReactionCode(int rep) throws HL7Exception {
336 return (ST) super.insertRepetition(5, rep);
337 }
338
339
340
341 /**
342 * Inserts a repetition of
343 * AL1-5: "Allergy Reaction Code" 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 ST insertAl15_AllergyReactionCode(int rep) throws HL7Exception {
349 return (ST) super.insertRepetition(5, rep);
350 }
351
352
353 /**
354 * Removes a repetition of
355 * AL1-5: "Allergy Reaction Code" 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 ST removeAllergyReactionCode(int rep) throws HL7Exception {
361 return (ST) super.removeRepetition(5, rep);
362 }
363
364
365 /**
366 * Removes a repetition of
367 * AL1-5: "Allergy Reaction Code" 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 ST removeAl15_AllergyReactionCode(int rep) throws HL7Exception {
373 return (ST) super.removeRepetition(5, rep);
374 }
375
376
377
378
379 /**
380 * Returns
381 * AL1-6: "Identification Date" - creates it if necessary
382 */
383 public DT getIdentificationDate() {
384 DT ret = null;
385 try {
386 Type t = this.getField(6, 0);
387 ret = (DT)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 * AL1-6: "Identification Date" - creates it if necessary
402 */
403 public DT getAl16_IdentificationDate() {
404 DT ret = null;
405 try {
406 Type t = this.getField(6, 0);
407 ret = (DT)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 CE(getMessage());
426 case 1: return new CE(getMessage());
427 case 2: return new CE(getMessage());
428 case 3: return new CE(getMessage());
429 case 4: return new ST(getMessage());
430 case 5: return new DT(getMessage());
431 default: return null;
432 }
433 }
434
435
436 }
437