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 XPN (extended person name) data type.
019 * This type consists of the following components:</p>
020 * <ul>
021 * <li>family name (FN)
022 * <li>given name (ST)
023 * <li>second and further given names or initials thereof (ST)
024 * <li>suffix (e.g., JR or III) (ST)
025 * <li>prefix (e.g., DR) (ST)
026 * <li>degree (e.g., MD) (IS)
027 * <li>name type code (ID)
028 * <li>Name Representation code (ID)
029 * <li>name context (CE)
030 * <li>name validity range (DR)
031 * <li>name assembly order (ID)
032 * </ul>
033 */
034 public class XPN extends AbstractType implements Composite {
035
036 private Type[] data;
037
038 /**
039 * Creates a new XPN type
040 */
041 public XPN(Message message) {
042 super(message);
043 init();
044 }
045
046 private void init() {
047 data = new Type[11];
048 data[0] = new FN(getMessage());
049 data[1] = new ST(getMessage());
050 data[2] = new ST(getMessage());
051 data[3] = new ST(getMessage());
052 data[4] = new ST(getMessage());
053 data[5] = new IS(getMessage(), 0);
054 data[6] = new ID(getMessage(), 0);
055 data[7] = new ID(getMessage(), 0);
056 data[8] = new CE(getMessage());
057 data[9] = new DR(getMessage());
058 data[10] = new ID(getMessage(), 0);
059 }
060
061
062 /**
063 * Returns an array containing the data elements.
064 */
065 public Type[] getComponents() {
066 return this.data;
067 }
068
069 /**
070 * Returns an individual data component.
071 *
072 * @param number The component number (0-indexed)
073 * @throws DataTypeException if the given element number is out of range.
074 */
075 public Type getComponent(int number) throws DataTypeException {
076
077 try {
078 return this.data[number];
079 } catch (ArrayIndexOutOfBoundsException e) {
080 throw new DataTypeException("Element " + number + " doesn't exist (Type " + getClass().getName() + " has only " + this.data.length + " components)");
081 }
082 }
083
084
085 /**
086 * Returns family name (component #1). This is a convenience method that saves you from
087 * casting and handling an exception.
088 */
089 public FN getFamilyName() {
090 FN ret = null;
091 try {
092 ret = (FN)getComponent(0);
093 } catch (DataTypeException e) {
094 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
095 throw new RuntimeException(e);
096 }
097 return ret;
098 }
099
100
101 /**
102 * Returns family name (component #1). This is a convenience method that saves you from
103 * casting and handling an exception.
104 */
105 public FN getXpn1_FamilyName() {
106 FN ret = null;
107 try {
108 ret = (FN)getComponent(0);
109 } catch (DataTypeException e) {
110 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
111 throw new RuntimeException(e);
112 }
113 return ret;
114 }
115
116
117 /**
118 * Returns given name (component #2). This is a convenience method that saves you from
119 * casting and handling an exception.
120 */
121 public ST getGivenName() {
122 ST ret = null;
123 try {
124 ret = (ST)getComponent(1);
125 } catch (DataTypeException e) {
126 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
127 throw new RuntimeException(e);
128 }
129 return ret;
130 }
131
132
133 /**
134 * Returns given name (component #2). This is a convenience method that saves you from
135 * casting and handling an exception.
136 */
137 public ST getXpn2_GivenName() {
138 ST ret = null;
139 try {
140 ret = (ST)getComponent(1);
141 } catch (DataTypeException e) {
142 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
143 throw new RuntimeException(e);
144 }
145 return ret;
146 }
147
148
149 /**
150 * Returns second and further given names or initials thereof (component #3). This is a convenience method that saves you from
151 * casting and handling an exception.
152 */
153 public ST getSecondAndFurtherGivenNamesOrInitialsThereof() {
154 ST ret = null;
155 try {
156 ret = (ST)getComponent(2);
157 } catch (DataTypeException e) {
158 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
159 throw new RuntimeException(e);
160 }
161 return ret;
162 }
163
164
165 /**
166 * Returns second and further given names or initials thereof (component #3). This is a convenience method that saves you from
167 * casting and handling an exception.
168 */
169 public ST getXpn3_SecondAndFurtherGivenNamesOrInitialsThereof() {
170 ST ret = null;
171 try {
172 ret = (ST)getComponent(2);
173 } catch (DataTypeException e) {
174 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
175 throw new RuntimeException(e);
176 }
177 return ret;
178 }
179
180
181 /**
182 * Returns suffix (e.g., JR or III) (component #4). This is a convenience method that saves you from
183 * casting and handling an exception.
184 */
185 public ST getSuffixEgJRorIII() {
186 ST ret = null;
187 try {
188 ret = (ST)getComponent(3);
189 } catch (DataTypeException e) {
190 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
191 throw new RuntimeException(e);
192 }
193 return ret;
194 }
195
196
197 /**
198 * Returns suffix (e.g., JR or III) (component #4). This is a convenience method that saves you from
199 * casting and handling an exception.
200 */
201 public ST getXpn4_SuffixEgJRorIII() {
202 ST ret = null;
203 try {
204 ret = (ST)getComponent(3);
205 } catch (DataTypeException e) {
206 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
207 throw new RuntimeException(e);
208 }
209 return ret;
210 }
211
212
213 /**
214 * Returns prefix (e.g., DR) (component #5). This is a convenience method that saves you from
215 * casting and handling an exception.
216 */
217 public ST getPrefixEgDR() {
218 ST ret = null;
219 try {
220 ret = (ST)getComponent(4);
221 } catch (DataTypeException e) {
222 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
223 throw new RuntimeException(e);
224 }
225 return ret;
226 }
227
228
229 /**
230 * Returns prefix (e.g., DR) (component #5). This is a convenience method that saves you from
231 * casting and handling an exception.
232 */
233 public ST getXpn5_PrefixEgDR() {
234 ST ret = null;
235 try {
236 ret = (ST)getComponent(4);
237 } catch (DataTypeException e) {
238 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
239 throw new RuntimeException(e);
240 }
241 return ret;
242 }
243
244
245 /**
246 * Returns degree (e.g., MD) (component #6). This is a convenience method that saves you from
247 * casting and handling an exception.
248 */
249 public IS getDegreeEgMD() {
250 IS ret = null;
251 try {
252 ret = (IS)getComponent(5);
253 } catch (DataTypeException e) {
254 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
255 throw new RuntimeException(e);
256 }
257 return ret;
258 }
259
260
261 /**
262 * Returns degree (e.g., MD) (component #6). This is a convenience method that saves you from
263 * casting and handling an exception.
264 */
265 public IS getXpn6_DegreeEgMD() {
266 IS ret = null;
267 try {
268 ret = (IS)getComponent(5);
269 } catch (DataTypeException e) {
270 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
271 throw new RuntimeException(e);
272 }
273 return ret;
274 }
275
276
277 /**
278 * Returns name type code (component #7). This is a convenience method that saves you from
279 * casting and handling an exception.
280 */
281 public ID getNameTypeCode() {
282 ID ret = null;
283 try {
284 ret = (ID)getComponent(6);
285 } catch (DataTypeException e) {
286 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
287 throw new RuntimeException(e);
288 }
289 return ret;
290 }
291
292
293 /**
294 * Returns name type code (component #7). This is a convenience method that saves you from
295 * casting and handling an exception.
296 */
297 public ID getXpn7_NameTypeCode() {
298 ID ret = null;
299 try {
300 ret = (ID)getComponent(6);
301 } catch (DataTypeException e) {
302 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
303 throw new RuntimeException(e);
304 }
305 return ret;
306 }
307
308
309 /**
310 * Returns Name Representation code (component #8). This is a convenience method that saves you from
311 * casting and handling an exception.
312 */
313 public ID getNameRepresentationCode() {
314 ID ret = null;
315 try {
316 ret = (ID)getComponent(7);
317 } catch (DataTypeException e) {
318 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
319 throw new RuntimeException(e);
320 }
321 return ret;
322 }
323
324
325 /**
326 * Returns Name Representation code (component #8). This is a convenience method that saves you from
327 * casting and handling an exception.
328 */
329 public ID getXpn8_NameRepresentationCode() {
330 ID ret = null;
331 try {
332 ret = (ID)getComponent(7);
333 } catch (DataTypeException e) {
334 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
335 throw new RuntimeException(e);
336 }
337 return ret;
338 }
339
340
341 /**
342 * Returns name context (component #9). This is a convenience method that saves you from
343 * casting and handling an exception.
344 */
345 public CE getNameContext() {
346 CE ret = null;
347 try {
348 ret = (CE)getComponent(8);
349 } catch (DataTypeException e) {
350 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
351 throw new RuntimeException(e);
352 }
353 return ret;
354 }
355
356
357 /**
358 * Returns name context (component #9). This is a convenience method that saves you from
359 * casting and handling an exception.
360 */
361 public CE getXpn9_NameContext() {
362 CE ret = null;
363 try {
364 ret = (CE)getComponent(8);
365 } catch (DataTypeException e) {
366 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
367 throw new RuntimeException(e);
368 }
369 return ret;
370 }
371
372
373 /**
374 * Returns name validity range (component #10). This is a convenience method that saves you from
375 * casting and handling an exception.
376 */
377 public DR getNameValidityRange() {
378 DR ret = null;
379 try {
380 ret = (DR)getComponent(9);
381 } catch (DataTypeException e) {
382 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
383 throw new RuntimeException(e);
384 }
385 return ret;
386 }
387
388
389 /**
390 * Returns name validity range (component #10). This is a convenience method that saves you from
391 * casting and handling an exception.
392 */
393 public DR getXpn10_NameValidityRange() {
394 DR ret = null;
395 try {
396 ret = (DR)getComponent(9);
397 } catch (DataTypeException e) {
398 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
399 throw new RuntimeException(e);
400 }
401 return ret;
402 }
403
404
405 /**
406 * Returns name assembly order (component #11). This is a convenience method that saves you from
407 * casting and handling an exception.
408 */
409 public ID getNameAssemblyOrder() {
410 ID ret = null;
411 try {
412 ret = (ID)getComponent(10);
413 } catch (DataTypeException e) {
414 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
415 throw new RuntimeException(e);
416 }
417 return ret;
418 }
419
420
421 /**
422 * Returns name assembly order (component #11). This is a convenience method that saves you from
423 * casting and handling an exception.
424 */
425 public ID getXpn11_NameAssemblyOrder() {
426 ID ret = null;
427 try {
428 ret = (ID)getComponent(10);
429 } catch (DataTypeException e) {
430 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
431 throw new RuntimeException(e);
432 }
433 return ret;
434 }
435
436
437
438 }
439