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