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 XTN (extended telecommunication number) data type.
019 * This type consists of the following components:</p>
020 * <ul>
021 * <li>[(999)] 999-9999 [X99999][C any text] (TN)
022 * <li>telecommunication use code (ID)
023 * <li>telecommunication equipment type (ID) (ID)
024 * <li>Email address (ST)
025 * <li>Country Code (NM)
026 * <li>Area/city code (NM)
027 * <li>Phone number (NM)
028 * <li>Extension (NM)
029 * <li>any text (ST)
030 * </ul>
031 */
032 public class XTN extends AbstractType implements Composite {
033
034 private Type[] data;
035
036 /**
037 * Creates a new XTN type
038 */
039 public XTN(Message message) {
040 super(message);
041 init();
042 }
043
044 private void init() {
045 data = new Type[9];
046 data[0] = new TN(getMessage());
047 data[1] = new ID(getMessage(), 0);
048 data[2] = new ID(getMessage(), 0);
049 data[3] = new ST(getMessage());
050 data[4] = new NM(getMessage());
051 data[5] = new NM(getMessage());
052 data[6] = new NM(getMessage());
053 data[7] = new NM(getMessage());
054 data[8] = new ST(getMessage());
055 }
056
057
058 /**
059 * Returns an array containing the data elements.
060 */
061 public Type[] getComponents() {
062 return this.data;
063 }
064
065 /**
066 * Returns an individual data component.
067 *
068 * @param number The component number (0-indexed)
069 * @throws DataTypeException if the given element number is out of range.
070 */
071 public Type getComponent(int number) throws DataTypeException {
072
073 try {
074 return this.data[number];
075 } catch (ArrayIndexOutOfBoundsException e) {
076 throw new DataTypeException("Element " + number + " doesn't exist (Type " + getClass().getName() + " has only " + this.data.length + " components)");
077 }
078 }
079
080
081 /**
082 * Returns [(999)] 999-9999 [X99999][C any text] (component #1). This is a convenience method that saves you from
083 * casting and handling an exception.
084 */
085 public TN get9999999X99999CAnyText() {
086 TN ret = null;
087 try {
088 ret = (TN)getComponent(0);
089 } catch (DataTypeException e) {
090 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
091 throw new RuntimeException(e);
092 }
093 return ret;
094 }
095
096
097 /**
098 * Returns [(999)] 999-9999 [X99999][C any text] (component #1). This is a convenience method that saves you from
099 * casting and handling an exception.
100 */
101 public TN getXtn1_9999999X99999CAnyText() {
102 TN ret = null;
103 try {
104 ret = (TN)getComponent(0);
105 } catch (DataTypeException e) {
106 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
107 throw new RuntimeException(e);
108 }
109 return ret;
110 }
111
112
113 /**
114 * Returns telecommunication use code (component #2). This is a convenience method that saves you from
115 * casting and handling an exception.
116 */
117 public ID getTelecommunicationUseCode() {
118 ID ret = null;
119 try {
120 ret = (ID)getComponent(1);
121 } catch (DataTypeException e) {
122 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
123 throw new RuntimeException(e);
124 }
125 return ret;
126 }
127
128
129 /**
130 * Returns telecommunication use code (component #2). This is a convenience method that saves you from
131 * casting and handling an exception.
132 */
133 public ID getXtn2_TelecommunicationUseCode() {
134 ID ret = null;
135 try {
136 ret = (ID)getComponent(1);
137 } catch (DataTypeException e) {
138 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
139 throw new RuntimeException(e);
140 }
141 return ret;
142 }
143
144
145 /**
146 * Returns telecommunication equipment type (ID) (component #3). This is a convenience method that saves you from
147 * casting and handling an exception.
148 */
149 public ID getTelecommunicationEquipmentType() {
150 ID ret = null;
151 try {
152 ret = (ID)getComponent(2);
153 } catch (DataTypeException e) {
154 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
155 throw new RuntimeException(e);
156 }
157 return ret;
158 }
159
160
161 /**
162 * Returns telecommunication equipment type (ID) (component #3). This is a convenience method that saves you from
163 * casting and handling an exception.
164 */
165 public ID getXtn3_TelecommunicationEquipmentType() {
166 ID ret = null;
167 try {
168 ret = (ID)getComponent(2);
169 } catch (DataTypeException e) {
170 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
171 throw new RuntimeException(e);
172 }
173 return ret;
174 }
175
176
177 /**
178 * Returns Email address (component #4). This is a convenience method that saves you from
179 * casting and handling an exception.
180 */
181 public ST getEmailAddress() {
182 ST ret = null;
183 try {
184 ret = (ST)getComponent(3);
185 } catch (DataTypeException e) {
186 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
187 throw new RuntimeException(e);
188 }
189 return ret;
190 }
191
192
193 /**
194 * Returns Email address (component #4). This is a convenience method that saves you from
195 * casting and handling an exception.
196 */
197 public ST getXtn4_EmailAddress() {
198 ST ret = null;
199 try {
200 ret = (ST)getComponent(3);
201 } catch (DataTypeException e) {
202 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
203 throw new RuntimeException(e);
204 }
205 return ret;
206 }
207
208
209 /**
210 * Returns Country Code (component #5). This is a convenience method that saves you from
211 * casting and handling an exception.
212 */
213 public NM getCountryCode() {
214 NM ret = null;
215 try {
216 ret = (NM)getComponent(4);
217 } catch (DataTypeException e) {
218 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
219 throw new RuntimeException(e);
220 }
221 return ret;
222 }
223
224
225 /**
226 * Returns Country Code (component #5). This is a convenience method that saves you from
227 * casting and handling an exception.
228 */
229 public NM getXtn5_CountryCode() {
230 NM ret = null;
231 try {
232 ret = (NM)getComponent(4);
233 } catch (DataTypeException e) {
234 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
235 throw new RuntimeException(e);
236 }
237 return ret;
238 }
239
240
241 /**
242 * Returns Area/city code (component #6). This is a convenience method that saves you from
243 * casting and handling an exception.
244 */
245 public NM getAreaCityCode() {
246 NM ret = null;
247 try {
248 ret = (NM)getComponent(5);
249 } catch (DataTypeException e) {
250 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
251 throw new RuntimeException(e);
252 }
253 return ret;
254 }
255
256
257 /**
258 * Returns Area/city code (component #6). This is a convenience method that saves you from
259 * casting and handling an exception.
260 */
261 public NM getXtn6_AreaCityCode() {
262 NM ret = null;
263 try {
264 ret = (NM)getComponent(5);
265 } catch (DataTypeException e) {
266 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
267 throw new RuntimeException(e);
268 }
269 return ret;
270 }
271
272
273 /**
274 * Returns Phone number (component #7). This is a convenience method that saves you from
275 * casting and handling an exception.
276 */
277 public NM getPhoneNumber() {
278 NM ret = null;
279 try {
280 ret = (NM)getComponent(6);
281 } catch (DataTypeException e) {
282 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
283 throw new RuntimeException(e);
284 }
285 return ret;
286 }
287
288
289 /**
290 * Returns Phone number (component #7). This is a convenience method that saves you from
291 * casting and handling an exception.
292 */
293 public NM getXtn7_PhoneNumber() {
294 NM ret = null;
295 try {
296 ret = (NM)getComponent(6);
297 } catch (DataTypeException e) {
298 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
299 throw new RuntimeException(e);
300 }
301 return ret;
302 }
303
304
305 /**
306 * Returns Extension (component #8). This is a convenience method that saves you from
307 * casting and handling an exception.
308 */
309 public NM getExtension() {
310 NM ret = null;
311 try {
312 ret = (NM)getComponent(7);
313 } catch (DataTypeException e) {
314 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
315 throw new RuntimeException(e);
316 }
317 return ret;
318 }
319
320
321 /**
322 * Returns Extension (component #8). This is a convenience method that saves you from
323 * casting and handling an exception.
324 */
325 public NM getXtn8_Extension() {
326 NM ret = null;
327 try {
328 ret = (NM)getComponent(7);
329 } catch (DataTypeException e) {
330 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
331 throw new RuntimeException(e);
332 }
333 return ret;
334 }
335
336
337 /**
338 * Returns any text (component #9). This is a convenience method that saves you from
339 * casting and handling an exception.
340 */
341 public ST getAnyText() {
342 ST ret = null;
343 try {
344 ret = (ST)getComponent(8);
345 } catch (DataTypeException e) {
346 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
347 throw new RuntimeException(e);
348 }
349 return ret;
350 }
351
352
353 /**
354 * Returns any text (component #9). This is a convenience method that saves you from
355 * casting and handling an exception.
356 */
357 public ST getXtn9_AnyText() {
358 ST ret = null;
359 try {
360 ret = (ST)getComponent(8);
361 } catch (DataTypeException e) {
362 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
363 throw new RuntimeException(e);
364 }
365 return ret;
366 }
367
368
369
370 }
371