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.datatype;
009
010 import ca.uhn.hl7v2.model.Composite;
011 import ca.uhn.hl7v2.model.DataTypeException;
012 import ca.uhn.hl7v2.model.Message;
013 import ca.uhn.hl7v2.model.Type;
014 import ca.uhn.hl7v2.model.AbstractType;
015 import ca.uhn.log.HapiLogFactory;
016
017 /**
018 * <p>Represents an HL7 XAD (extended address) data type.
019 * This type consists of the following components:</p>
020 * <ul>
021 * <li>street address (SAD) (SAD)
022 * <li>other designation (ST)
023 * <li>city (ST)
024 * <li>state or province (ST)
025 * <li>zip or postal code (ST)
026 * <li>country (ID)
027 * <li>address type (ID)
028 * <li>other geographic designation (ST)
029 * <li>county/parish code (IS)
030 * <li>census tract (IS)
031 * <li>address representation code (ID)
032 * <li>address validity range (DR)
033 * </ul>
034 */
035 public class XAD extends AbstractType implements Composite {
036
037 private Type[] data;
038
039 /**
040 * Creates a new XAD type
041 */
042 public XAD(Message message) {
043 super(message);
044 init();
045 }
046
047 private void init() {
048 data = new Type[12];
049 data[0] = new SAD(getMessage());
050 data[1] = new ST(getMessage());
051 data[2] = new ST(getMessage());
052 data[3] = new ST(getMessage());
053 data[4] = new ST(getMessage());
054 data[5] = new ID(getMessage(), 0);
055 data[6] = new ID(getMessage(), 0);
056 data[7] = new ST(getMessage());
057 data[8] = new IS(getMessage(), 0);
058 data[9] = new IS(getMessage(), 0);
059 data[10] = new ID(getMessage(), 0);
060 data[11] = new DR(getMessage());
061 }
062
063
064 /**
065 * Returns an array containing the data elements.
066 */
067 public Type[] getComponents() {
068 return this.data;
069 }
070
071 /**
072 * Returns an individual data component.
073 *
074 * @param number The component number (0-indexed)
075 * @throws DataTypeException if the given element number is out of range.
076 */
077 public Type getComponent(int number) throws DataTypeException {
078
079 try {
080 return this.data[number];
081 } catch (ArrayIndexOutOfBoundsException e) {
082 throw new DataTypeException("Element " + number + " doesn't exist (Type " + getClass().getName() + " has only " + this.data.length + " components)");
083 }
084 }
085
086
087 /**
088 * Returns street address (SAD) (component #1). This is a convenience method that saves you from
089 * casting and handling an exception.
090 */
091 public SAD getStreetAddress() {
092 SAD ret = null;
093 try {
094 ret = (SAD)getComponent(0);
095 } catch (DataTypeException e) {
096 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
097 throw new RuntimeException(e);
098 }
099 return ret;
100 }
101
102
103 /**
104 * Returns street address (SAD) (component #1). This is a convenience method that saves you from
105 * casting and handling an exception.
106 */
107 public SAD getXad1_StreetAddress() {
108 SAD ret = null;
109 try {
110 ret = (SAD)getComponent(0);
111 } catch (DataTypeException e) {
112 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
113 throw new RuntimeException(e);
114 }
115 return ret;
116 }
117
118
119 /**
120 * Returns other designation (component #2). This is a convenience method that saves you from
121 * casting and handling an exception.
122 */
123 public ST getOtherDesignation() {
124 ST ret = null;
125 try {
126 ret = (ST)getComponent(1);
127 } catch (DataTypeException e) {
128 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
129 throw new RuntimeException(e);
130 }
131 return ret;
132 }
133
134
135 /**
136 * Returns other designation (component #2). This is a convenience method that saves you from
137 * casting and handling an exception.
138 */
139 public ST getXad2_OtherDesignation() {
140 ST ret = null;
141 try {
142 ret = (ST)getComponent(1);
143 } catch (DataTypeException e) {
144 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
145 throw new RuntimeException(e);
146 }
147 return ret;
148 }
149
150
151 /**
152 * Returns city (component #3). This is a convenience method that saves you from
153 * casting and handling an exception.
154 */
155 public ST getCity() {
156 ST ret = null;
157 try {
158 ret = (ST)getComponent(2);
159 } catch (DataTypeException e) {
160 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
161 throw new RuntimeException(e);
162 }
163 return ret;
164 }
165
166
167 /**
168 * Returns city (component #3). This is a convenience method that saves you from
169 * casting and handling an exception.
170 */
171 public ST getXad3_City() {
172 ST ret = null;
173 try {
174 ret = (ST)getComponent(2);
175 } catch (DataTypeException e) {
176 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
177 throw new RuntimeException(e);
178 }
179 return ret;
180 }
181
182
183 /**
184 * Returns state or province (component #4). This is a convenience method that saves you from
185 * casting and handling an exception.
186 */
187 public ST getStateOrProvince() {
188 ST ret = null;
189 try {
190 ret = (ST)getComponent(3);
191 } catch (DataTypeException e) {
192 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
193 throw new RuntimeException(e);
194 }
195 return ret;
196 }
197
198
199 /**
200 * Returns state or province (component #4). This is a convenience method that saves you from
201 * casting and handling an exception.
202 */
203 public ST getXad4_StateOrProvince() {
204 ST ret = null;
205 try {
206 ret = (ST)getComponent(3);
207 } catch (DataTypeException e) {
208 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
209 throw new RuntimeException(e);
210 }
211 return ret;
212 }
213
214
215 /**
216 * Returns zip or postal code (component #5). This is a convenience method that saves you from
217 * casting and handling an exception.
218 */
219 public ST getZipOrPostalCode() {
220 ST ret = null;
221 try {
222 ret = (ST)getComponent(4);
223 } catch (DataTypeException e) {
224 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
225 throw new RuntimeException(e);
226 }
227 return ret;
228 }
229
230
231 /**
232 * Returns zip or postal code (component #5). This is a convenience method that saves you from
233 * casting and handling an exception.
234 */
235 public ST getXad5_ZipOrPostalCode() {
236 ST ret = null;
237 try {
238 ret = (ST)getComponent(4);
239 } catch (DataTypeException e) {
240 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
241 throw new RuntimeException(e);
242 }
243 return ret;
244 }
245
246
247 /**
248 * Returns country (component #6). This is a convenience method that saves you from
249 * casting and handling an exception.
250 */
251 public ID getCountry() {
252 ID ret = null;
253 try {
254 ret = (ID)getComponent(5);
255 } catch (DataTypeException e) {
256 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
257 throw new RuntimeException(e);
258 }
259 return ret;
260 }
261
262
263 /**
264 * Returns country (component #6). This is a convenience method that saves you from
265 * casting and handling an exception.
266 */
267 public ID getXad6_Country() {
268 ID ret = null;
269 try {
270 ret = (ID)getComponent(5);
271 } catch (DataTypeException e) {
272 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
273 throw new RuntimeException(e);
274 }
275 return ret;
276 }
277
278
279 /**
280 * Returns address type (component #7). This is a convenience method that saves you from
281 * casting and handling an exception.
282 */
283 public ID getAddressType() {
284 ID ret = null;
285 try {
286 ret = (ID)getComponent(6);
287 } catch (DataTypeException e) {
288 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
289 throw new RuntimeException(e);
290 }
291 return ret;
292 }
293
294
295 /**
296 * Returns address type (component #7). This is a convenience method that saves you from
297 * casting and handling an exception.
298 */
299 public ID getXad7_AddressType() {
300 ID ret = null;
301 try {
302 ret = (ID)getComponent(6);
303 } catch (DataTypeException e) {
304 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
305 throw new RuntimeException(e);
306 }
307 return ret;
308 }
309
310
311 /**
312 * Returns other geographic designation (component #8). This is a convenience method that saves you from
313 * casting and handling an exception.
314 */
315 public ST getOtherGeographicDesignation() {
316 ST ret = null;
317 try {
318 ret = (ST)getComponent(7);
319 } catch (DataTypeException e) {
320 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
321 throw new RuntimeException(e);
322 }
323 return ret;
324 }
325
326
327 /**
328 * Returns other geographic designation (component #8). This is a convenience method that saves you from
329 * casting and handling an exception.
330 */
331 public ST getXad8_OtherGeographicDesignation() {
332 ST ret = null;
333 try {
334 ret = (ST)getComponent(7);
335 } catch (DataTypeException e) {
336 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
337 throw new RuntimeException(e);
338 }
339 return ret;
340 }
341
342
343 /**
344 * Returns county/parish code (component #9). This is a convenience method that saves you from
345 * casting and handling an exception.
346 */
347 public IS getCountyParishCode() {
348 IS ret = null;
349 try {
350 ret = (IS)getComponent(8);
351 } catch (DataTypeException e) {
352 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
353 throw new RuntimeException(e);
354 }
355 return ret;
356 }
357
358
359 /**
360 * Returns county/parish code (component #9). This is a convenience method that saves you from
361 * casting and handling an exception.
362 */
363 public IS getXad9_CountyParishCode() {
364 IS ret = null;
365 try {
366 ret = (IS)getComponent(8);
367 } catch (DataTypeException e) {
368 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
369 throw new RuntimeException(e);
370 }
371 return ret;
372 }
373
374
375 /**
376 * Returns census tract (component #10). This is a convenience method that saves you from
377 * casting and handling an exception.
378 */
379 public IS getCensusTract() {
380 IS ret = null;
381 try {
382 ret = (IS)getComponent(9);
383 } catch (DataTypeException e) {
384 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
385 throw new RuntimeException(e);
386 }
387 return ret;
388 }
389
390
391 /**
392 * Returns census tract (component #10). This is a convenience method that saves you from
393 * casting and handling an exception.
394 */
395 public IS getXad10_CensusTract() {
396 IS ret = null;
397 try {
398 ret = (IS)getComponent(9);
399 } catch (DataTypeException e) {
400 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
401 throw new RuntimeException(e);
402 }
403 return ret;
404 }
405
406
407 /**
408 * Returns address representation code (component #11). This is a convenience method that saves you from
409 * casting and handling an exception.
410 */
411 public ID getAddressRepresentationCode() {
412 ID ret = null;
413 try {
414 ret = (ID)getComponent(10);
415 } catch (DataTypeException e) {
416 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
417 throw new RuntimeException(e);
418 }
419 return ret;
420 }
421
422
423 /**
424 * Returns address representation code (component #11). This is a convenience method that saves you from
425 * casting and handling an exception.
426 */
427 public ID getXad11_AddressRepresentationCode() {
428 ID ret = null;
429 try {
430 ret = (ID)getComponent(10);
431 } catch (DataTypeException e) {
432 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
433 throw new RuntimeException(e);
434 }
435 return ret;
436 }
437
438
439 /**
440 * Returns address validity range (component #12). This is a convenience method that saves you from
441 * casting and handling an exception.
442 */
443 public DR getAddressValidityRange() {
444 DR ret = null;
445 try {
446 ret = (DR)getComponent(11);
447 } catch (DataTypeException e) {
448 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
449 throw new RuntimeException(e);
450 }
451 return ret;
452 }
453
454
455 /**
456 * Returns address validity range (component #12). This is a convenience method that saves you from
457 * casting and handling an exception.
458 */
459 public DR getXad12_AddressValidityRange() {
460 DR ret = null;
461 try {
462 ret = (DR)getComponent(11);
463 } catch (DataTypeException e) {
464 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
465 throw new RuntimeException(e);
466 }
467 return ret;
468 }
469
470
471
472 }
473