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 CE (coded element) data type.
019 * This type consists of the following components:</p>
020 * <ul>
021 * <li>identifier (ST) (ST)
022 * <li>text (ST)
023 * <li>name of coding system (IS)
024 * <li>alternate identifier (ST) (ST)
025 * <li>alternate text (ST)
026 * <li>name of alternate coding system (IS)
027 * </ul>
028 */
029 public class CE extends AbstractType implements Composite {
030
031 private Type[] data;
032
033 /**
034 * Creates a new CE type
035 */
036 public CE(Message message) {
037 super(message);
038 init();
039 }
040
041 private void init() {
042 data = new Type[6];
043 data[0] = new ST(getMessage());
044 data[1] = new ST(getMessage());
045 data[2] = new IS(getMessage(), 0);
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 identifier (ST) (component #1). This is a convenience method that saves you from
077 * casting and handling an exception.
078 */
079 public ST getIdentifier() {
080 ST ret = null;
081 try {
082 ret = (ST)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 identifier (ST) (component #1). This is a convenience method that saves you from
093 * casting and handling an exception.
094 */
095 public ST getCe1_Identifier() {
096 ST ret = null;
097 try {
098 ret = (ST)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 text (component #2). This is a convenience method that saves you from
109 * casting and handling an exception.
110 */
111 public ST getText() {
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 text (component #2). This is a convenience method that saves you from
125 * casting and handling an exception.
126 */
127 public ST getCe2_Text() {
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 name of coding system (component #3). This is a convenience method that saves you from
141 * casting and handling an exception.
142 */
143 public IS getNameOfCodingSystem() {
144 IS ret = null;
145 try {
146 ret = (IS)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 name of coding system (component #3). This is a convenience method that saves you from
157 * casting and handling an exception.
158 */
159 public IS getCe3_NameOfCodingSystem() {
160 IS ret = null;
161 try {
162 ret = (IS)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 alternate identifier (ST) (component #4). This is a convenience method that saves you from
173 * casting and handling an exception.
174 */
175 public ST getAlternateIdentifier() {
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 alternate identifier (ST) (component #4). This is a convenience method that saves you from
189 * casting and handling an exception.
190 */
191 public ST getCe4_AlternateIdentifier() {
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 alternate text (component #5). This is a convenience method that saves you from
205 * casting and handling an exception.
206 */
207 public ST getAlternateText() {
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 alternate text (component #5). This is a convenience method that saves you from
221 * casting and handling an exception.
222 */
223 public ST getCe5_AlternateText() {
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 name of alternate coding system (component #6). This is a convenience method that saves you from
237 * casting and handling an exception.
238 */
239 public IS getNameOfAlternateCodingSystem() {
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 name of alternate coding system (component #6). This is a convenience method that saves you from
253 * casting and handling an exception.
254 */
255 public IS getCe6_NameOfAlternateCodingSystem() {
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