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.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+last name (FN)
022     * <li>given name (ST)
023     * <li>middle initial or name (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     * </ul>
030     */
031    public class XPN extends AbstractType implements Composite {
032    
033        private Type[] data;
034    
035        /** 
036         * Creates a new XPN type
037         */
038        public XPN(Message message) {
039            super(message);
040            init();
041        }
042    
043        private void init() {
044            data = new Type[8];    
045            data[0] = new FN(getMessage());
046            data[1] = new ST(getMessage());
047            data[2] = new ST(getMessage());
048            data[3] = new ST(getMessage());
049            data[4] = new ST(getMessage());
050            data[5] = new IS(getMessage(), 0);
051            data[6] = new ID(getMessage(), 0);
052            data[7] = new ID(getMessage(), 0);
053        }
054    
055    
056        /**
057         * Returns an array containing the data elements.
058         */
059        public Type[] getComponents() { 
060            return this.data; 
061        }
062    
063        /**
064         * Returns an individual data component.
065         *
066         * @param number The component number (0-indexed)
067         * @throws DataTypeException if the given element number is out of range.
068         */
069        public Type getComponent(int number) throws DataTypeException { 
070    
071            try { 
072                return this.data[number]; 
073            } catch (ArrayIndexOutOfBoundsException e) { 
074                throw new DataTypeException("Element " + number + " doesn't exist (Type " + getClass().getName() + " has only " + this.data.length + " components)"); 
075            } 
076        } 
077    
078    
079        /**
080         * Returns family+last name (component #1).  This is a convenience method that saves you from 
081         * casting and handling an exception.
082         */
083        public FN getFamilyLastName() {
084           FN ret = null;
085           try {
086              ret = (FN)getComponent(0);
087           } catch (DataTypeException e) {
088              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
089              throw new RuntimeException(e);
090           }
091           return ret;
092        }
093    
094        
095        /**
096         * Returns family+last name (component #1).  This is a convenience method that saves you from 
097         * casting and handling an exception.
098         */
099        public FN getXpn1_FamilyLastName() {
100           FN ret = null;
101           try {
102              ret = (FN)getComponent(0);
103           } catch (DataTypeException e) {
104              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
105              throw new RuntimeException(e);
106           }
107           return ret;
108        }
109    
110    
111        /**
112         * Returns given name (component #2).  This is a convenience method that saves you from 
113         * casting and handling an exception.
114         */
115        public ST getGivenName() {
116           ST ret = null;
117           try {
118              ret = (ST)getComponent(1);
119           } catch (DataTypeException e) {
120              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
121              throw new RuntimeException(e);
122           }
123           return ret;
124        }
125    
126        
127        /**
128         * Returns given name (component #2).  This is a convenience method that saves you from 
129         * casting and handling an exception.
130         */
131        public ST getXpn2_GivenName() {
132           ST ret = null;
133           try {
134              ret = (ST)getComponent(1);
135           } catch (DataTypeException e) {
136              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
137              throw new RuntimeException(e);
138           }
139           return ret;
140        }
141    
142    
143        /**
144         * Returns middle initial or name (component #3).  This is a convenience method that saves you from 
145         * casting and handling an exception.
146         */
147        public ST getMiddleInitialOrName() {
148           ST ret = null;
149           try {
150              ret = (ST)getComponent(2);
151           } catch (DataTypeException e) {
152              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
153              throw new RuntimeException(e);
154           }
155           return ret;
156        }
157    
158        
159        /**
160         * Returns middle initial or name (component #3).  This is a convenience method that saves you from 
161         * casting and handling an exception.
162         */
163        public ST getXpn3_MiddleInitialOrName() {
164           ST ret = null;
165           try {
166              ret = (ST)getComponent(2);
167           } catch (DataTypeException e) {
168              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
169              throw new RuntimeException(e);
170           }
171           return ret;
172        }
173    
174    
175        /**
176         * Returns suffix (e.g., JR or III) (component #4).  This is a convenience method that saves you from 
177         * casting and handling an exception.
178         */
179        public ST getSuffixEgJRorIII() {
180           ST ret = null;
181           try {
182              ret = (ST)getComponent(3);
183           } catch (DataTypeException e) {
184              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
185              throw new RuntimeException(e);
186           }
187           return ret;
188        }
189    
190        
191        /**
192         * Returns suffix (e.g., JR or III) (component #4).  This is a convenience method that saves you from 
193         * casting and handling an exception.
194         */
195        public ST getXpn4_SuffixEgJRorIII() {
196           ST ret = null;
197           try {
198              ret = (ST)getComponent(3);
199           } catch (DataTypeException e) {
200              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
201              throw new RuntimeException(e);
202           }
203           return ret;
204        }
205    
206    
207        /**
208         * Returns prefix (e.g., DR) (component #5).  This is a convenience method that saves you from 
209         * casting and handling an exception.
210         */
211        public ST getPrefixEgDR() {
212           ST ret = null;
213           try {
214              ret = (ST)getComponent(4);
215           } catch (DataTypeException e) {
216              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
217              throw new RuntimeException(e);
218           }
219           return ret;
220        }
221    
222        
223        /**
224         * Returns prefix (e.g., DR) (component #5).  This is a convenience method that saves you from 
225         * casting and handling an exception.
226         */
227        public ST getXpn5_PrefixEgDR() {
228           ST ret = null;
229           try {
230              ret = (ST)getComponent(4);
231           } catch (DataTypeException e) {
232              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
233              throw new RuntimeException(e);
234           }
235           return ret;
236        }
237    
238    
239        /**
240         * Returns degree (e.g., MD) (component #6).  This is a convenience method that saves you from 
241         * casting and handling an exception.
242         */
243        public IS getDegreeEgMD() {
244           IS ret = null;
245           try {
246              ret = (IS)getComponent(5);
247           } catch (DataTypeException e) {
248              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
249              throw new RuntimeException(e);
250           }
251           return ret;
252        }
253    
254        
255        /**
256         * Returns degree (e.g., MD) (component #6).  This is a convenience method that saves you from 
257         * casting and handling an exception.
258         */
259        public IS getXpn6_DegreeEgMD() {
260           IS ret = null;
261           try {
262              ret = (IS)getComponent(5);
263           } catch (DataTypeException e) {
264              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
265              throw new RuntimeException(e);
266           }
267           return ret;
268        }
269    
270    
271        /**
272         * Returns name type code (component #7).  This is a convenience method that saves you from 
273         * casting and handling an exception.
274         */
275        public ID getNameTypeCode() {
276           ID ret = null;
277           try {
278              ret = (ID)getComponent(6);
279           } catch (DataTypeException e) {
280              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
281              throw new RuntimeException(e);
282           }
283           return ret;
284        }
285    
286        
287        /**
288         * Returns name type code (component #7).  This is a convenience method that saves you from 
289         * casting and handling an exception.
290         */
291        public ID getXpn7_NameTypeCode() {
292           ID ret = null;
293           try {
294              ret = (ID)getComponent(6);
295           } catch (DataTypeException e) {
296              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
297              throw new RuntimeException(e);
298           }
299           return ret;
300        }
301    
302    
303        /**
304         * Returns Name Representation code (component #8).  This is a convenience method that saves you from 
305         * casting and handling an exception.
306         */
307        public ID getNameRepresentationCode() {
308           ID ret = null;
309           try {
310              ret = (ID)getComponent(7);
311           } catch (DataTypeException e) {
312              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
313              throw new RuntimeException(e);
314           }
315           return ret;
316        }
317    
318        
319        /**
320         * Returns Name Representation code (component #8).  This is a convenience method that saves you from 
321         * casting and handling an exception.
322         */
323        public ID getXpn8_NameRepresentationCode() {
324           ID ret = null;
325           try {
326              ret = (ID)getComponent(7);
327           } catch (DataTypeException e) {
328              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
329              throw new RuntimeException(e);
330           }
331           return ret;
332        }
333    
334    
335    
336    }
337