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 CX (extended composite ID with check digit) data type.
019 * This type consists of the following components:</p>
020 * <ul>
021 * <li>ID (ST)
022 * <li>check digit (ST) (ST)
023 * <li>code identifying the check digit scheme employed (ID)
024 * <li>assigning authority (HD)
025 * <li>identifier type code (ID) (ID)
026 * <li>assigning facility (HD)
027 * <li>effective date (DT) (DT)
028 * <li>expiration date (DT)
029 * </ul>
030 */
031 public class CX extends AbstractType implements Composite {
032
033 private Type[] data;
034
035 /**
036 * Creates a new CX type
037 */
038 public CX(Message message) {
039 super(message);
040 init();
041 }
042
043 private void init() {
044 data = new Type[8];
045 data[0] = new ST(getMessage());
046 data[1] = new ST(getMessage());
047 data[2] = new ID(getMessage(), 0);
048 data[3] = new HD(getMessage());
049 data[4] = new ID(getMessage(), 203);
050 data[5] = new HD(getMessage());
051 data[6] = new DT(getMessage());
052 data[7] = new DT(getMessage());
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 ID (component #1). This is a convenience method that saves you from
081 * casting and handling an exception.
082 */
083 public ST getID() {
084 ST ret = null;
085 try {
086 ret = (ST)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 ID (component #1). This is a convenience method that saves you from
097 * casting and handling an exception.
098 */
099 public ST getCx1_ID() {
100 ST ret = null;
101 try {
102 ret = (ST)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 check digit (ST) (component #2). This is a convenience method that saves you from
113 * casting and handling an exception.
114 */
115 public ST getCheckDigit() {
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 check digit (ST) (component #2). This is a convenience method that saves you from
129 * casting and handling an exception.
130 */
131 public ST getCx2_CheckDigit() {
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 code identifying the check digit scheme employed (component #3). This is a convenience method that saves you from
145 * casting and handling an exception.
146 */
147 public ID getCodeIdentifyingTheCheckDigitSchemeEmployed() {
148 ID ret = null;
149 try {
150 ret = (ID)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 code identifying the check digit scheme employed (component #3). This is a convenience method that saves you from
161 * casting and handling an exception.
162 */
163 public ID getCx3_CodeIdentifyingTheCheckDigitSchemeEmployed() {
164 ID ret = null;
165 try {
166 ret = (ID)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 assigning authority (component #4). This is a convenience method that saves you from
177 * casting and handling an exception.
178 */
179 public HD getAssigningAuthority() {
180 HD ret = null;
181 try {
182 ret = (HD)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 assigning authority (component #4). This is a convenience method that saves you from
193 * casting and handling an exception.
194 */
195 public HD getCx4_AssigningAuthority() {
196 HD ret = null;
197 try {
198 ret = (HD)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 identifier type code (ID) (component #5). This is a convenience method that saves you from
209 * casting and handling an exception.
210 */
211 public ID getIdentifierTypeCode() {
212 ID ret = null;
213 try {
214 ret = (ID)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 identifier type code (ID) (component #5). This is a convenience method that saves you from
225 * casting and handling an exception.
226 */
227 public ID getCx5_IdentifierTypeCode() {
228 ID ret = null;
229 try {
230 ret = (ID)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 assigning facility (component #6). This is a convenience method that saves you from
241 * casting and handling an exception.
242 */
243 public HD getAssigningFacility() {
244 HD ret = null;
245 try {
246 ret = (HD)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 assigning facility (component #6). This is a convenience method that saves you from
257 * casting and handling an exception.
258 */
259 public HD getCx6_AssigningFacility() {
260 HD ret = null;
261 try {
262 ret = (HD)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 effective date (DT) (component #7). This is a convenience method that saves you from
273 * casting and handling an exception.
274 */
275 public DT getEffectiveDate() {
276 DT ret = null;
277 try {
278 ret = (DT)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 effective date (DT) (component #7). This is a convenience method that saves you from
289 * casting and handling an exception.
290 */
291 public DT getCx7_EffectiveDate() {
292 DT ret = null;
293 try {
294 ret = (DT)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 expiration date (component #8). This is a convenience method that saves you from
305 * casting and handling an exception.
306 */
307 public DT getExpirationDate() {
308 DT ret = null;
309 try {
310 ret = (DT)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 expiration date (component #8). This is a convenience method that saves you from
321 * casting and handling an exception.
322 */
323 public DT getCx8_ExpirationDate() {
324 DT ret = null;
325 try {
326 ret = (DT)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