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 PN (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     * </ul>
028     */
029    public class PN extends AbstractType implements Composite {
030    
031        private Type[] data;
032    
033        /** 
034         * Creates a new PN type
035         */
036        public PN(Message message) {
037            super(message);
038            init();
039        }
040    
041        private void init() {
042            data = new Type[6];    
043            data[0] = new FN(getMessage());
044            data[1] = new ST(getMessage());
045            data[2] = new ST(getMessage());
046            data[3] = new ST(getMessage());
047            data[4] = new ST(getMessage());
048            data[5] = new IS(getMessage(), 0);
049        }
050    
051    
052        /**
053         * Returns an array containing the data elements.
054         */
055        public Type[] getComponents() { 
056            return this.data; 
057        }
058    
059        /**
060         * Returns an individual data component.
061         *
062         * @param number The component number (0-indexed)
063         * @throws DataTypeException if the given element number is out of range.
064         */
065        public Type getComponent(int number) throws DataTypeException { 
066    
067            try { 
068                return this.data[number]; 
069            } catch (ArrayIndexOutOfBoundsException e) { 
070                throw new DataTypeException("Element " + number + " doesn't exist (Type " + getClass().getName() + " has only " + this.data.length + " components)"); 
071            } 
072        } 
073    
074    
075        /**
076         * Returns family name (component #1).  This is a convenience method that saves you from 
077         * casting and handling an exception.
078         */
079        public FN getFamilyName() {
080           FN ret = null;
081           try {
082              ret = (FN)getComponent(0);
083           } catch (DataTypeException e) {
084              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
085              throw new RuntimeException(e);
086           }
087           return ret;
088        }
089    
090        
091        /**
092         * Returns family name (component #1).  This is a convenience method that saves you from 
093         * casting and handling an exception.
094         */
095        public FN getPn1_FamilyName() {
096           FN ret = null;
097           try {
098              ret = (FN)getComponent(0);
099           } catch (DataTypeException e) {
100              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
101              throw new RuntimeException(e);
102           }
103           return ret;
104        }
105    
106    
107        /**
108         * Returns given name (component #2).  This is a convenience method that saves you from 
109         * casting and handling an exception.
110         */
111        public ST getGivenName() {
112           ST ret = null;
113           try {
114              ret = (ST)getComponent(1);
115           } catch (DataTypeException e) {
116              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
117              throw new RuntimeException(e);
118           }
119           return ret;
120        }
121    
122        
123        /**
124         * Returns given name (component #2).  This is a convenience method that saves you from 
125         * casting and handling an exception.
126         */
127        public ST getPn2_GivenName() {
128           ST ret = null;
129           try {
130              ret = (ST)getComponent(1);
131           } catch (DataTypeException e) {
132              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
133              throw new RuntimeException(e);
134           }
135           return ret;
136        }
137    
138    
139        /**
140         * Returns second and further given names or initials thereof (component #3).  This is a convenience method that saves you from 
141         * casting and handling an exception.
142         */
143        public ST getSecondAndFurtherGivenNamesOrInitialsThereof() {
144           ST ret = null;
145           try {
146              ret = (ST)getComponent(2);
147           } catch (DataTypeException e) {
148              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
149              throw new RuntimeException(e);
150           }
151           return ret;
152        }
153    
154        
155        /**
156         * Returns second and further given names or initials thereof (component #3).  This is a convenience method that saves you from 
157         * casting and handling an exception.
158         */
159        public ST getPn3_SecondAndFurtherGivenNamesOrInitialsThereof() {
160           ST ret = null;
161           try {
162              ret = (ST)getComponent(2);
163           } catch (DataTypeException e) {
164              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
165              throw new RuntimeException(e);
166           }
167           return ret;
168        }
169    
170    
171        /**
172         * Returns suffix (e.g., JR or III) (component #4).  This is a convenience method that saves you from 
173         * casting and handling an exception.
174         */
175        public ST getSuffixEgJRorIII() {
176           ST ret = null;
177           try {
178              ret = (ST)getComponent(3);
179           } catch (DataTypeException e) {
180              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
181              throw new RuntimeException(e);
182           }
183           return ret;
184        }
185    
186        
187        /**
188         * Returns suffix (e.g., JR or III) (component #4).  This is a convenience method that saves you from 
189         * casting and handling an exception.
190         */
191        public ST getPn4_SuffixEgJRorIII() {
192           ST ret = null;
193           try {
194              ret = (ST)getComponent(3);
195           } catch (DataTypeException e) {
196              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
197              throw new RuntimeException(e);
198           }
199           return ret;
200        }
201    
202    
203        /**
204         * Returns prefix (e.g., DR) (component #5).  This is a convenience method that saves you from 
205         * casting and handling an exception.
206         */
207        public ST getPrefixEgDR() {
208           ST ret = null;
209           try {
210              ret = (ST)getComponent(4);
211           } catch (DataTypeException e) {
212              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
213              throw new RuntimeException(e);
214           }
215           return ret;
216        }
217    
218        
219        /**
220         * Returns prefix (e.g., DR) (component #5).  This is a convenience method that saves you from 
221         * casting and handling an exception.
222         */
223        public ST getPn5_PrefixEgDR() {
224           ST ret = null;
225           try {
226              ret = (ST)getComponent(4);
227           } catch (DataTypeException e) {
228              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
229              throw new RuntimeException(e);
230           }
231           return ret;
232        }
233    
234    
235        /**
236         * Returns degree (e.g., MD) (component #6).  This is a convenience method that saves you from 
237         * casting and handling an exception.
238         */
239        public IS getDegreeEgMD() {
240           IS ret = null;
241           try {
242              ret = (IS)getComponent(5);
243           } catch (DataTypeException e) {
244              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
245              throw new RuntimeException(e);
246           }
247           return ret;
248        }
249    
250        
251        /**
252         * Returns degree (e.g., MD) (component #6).  This is a convenience method that saves you from 
253         * casting and handling an exception.
254         */
255        public IS getPn6_DegreeEgMD() {
256           IS ret = null;
257           try {
258              ret = (IS)getComponent(5);
259           } catch (DataTypeException e) {
260              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
261              throw new RuntimeException(e);
262           }
263           return ret;
264        }
265    
266    
267    
268    }
269