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 SPS (specimen source) data type.
019 * This type consists of the following components:</p>
020 * <ul>
021 * <li>specimen source name or code (CE)
022 * <li>additives (TX)
023 * <li>freetext (TX)
024 * <li>body site (CE)
025 * <li>site modifier (CE)
026 * <li>collection modifier method code (CE)
027 * <li>specimen role (CE)
028 * </ul>
029 */
030 public class SPS extends AbstractType implements Composite {
031
032 private Type[] data;
033
034 /**
035 * Creates a new SPS type
036 */
037 public SPS(Message message) {
038 super(message);
039 init();
040 }
041
042 private void init() {
043 data = new Type[7];
044 data[0] = new CE(getMessage());
045 data[1] = new TX(getMessage());
046 data[2] = new TX(getMessage());
047 data[3] = new CE(getMessage());
048 data[4] = new CE(getMessage());
049 data[5] = new CE(getMessage());
050 data[6] = new CE(getMessage());
051 }
052
053
054 /**
055 * Returns an array containing the data elements.
056 */
057 public Type[] getComponents() {
058 return this.data;
059 }
060
061 /**
062 * Returns an individual data component.
063 *
064 * @param number The component number (0-indexed)
065 * @throws DataTypeException if the given element number is out of range.
066 */
067 public Type getComponent(int number) throws DataTypeException {
068
069 try {
070 return this.data[number];
071 } catch (ArrayIndexOutOfBoundsException e) {
072 throw new DataTypeException("Element " + number + " doesn't exist (Type " + getClass().getName() + " has only " + this.data.length + " components)");
073 }
074 }
075
076
077 /**
078 * Returns specimen source name or code (component #1). This is a convenience method that saves you from
079 * casting and handling an exception.
080 */
081 public CE getSpecimenSourceNameOrCode() {
082 CE ret = null;
083 try {
084 ret = (CE)getComponent(0);
085 } catch (DataTypeException e) {
086 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
087 throw new RuntimeException(e);
088 }
089 return ret;
090 }
091
092
093 /**
094 * Returns specimen source name or code (component #1). This is a convenience method that saves you from
095 * casting and handling an exception.
096 */
097 public CE getSps1_SpecimenSourceNameOrCode() {
098 CE ret = null;
099 try {
100 ret = (CE)getComponent(0);
101 } catch (DataTypeException e) {
102 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
103 throw new RuntimeException(e);
104 }
105 return ret;
106 }
107
108
109 /**
110 * Returns additives (component #2). This is a convenience method that saves you from
111 * casting and handling an exception.
112 */
113 public TX getAdditives() {
114 TX ret = null;
115 try {
116 ret = (TX)getComponent(1);
117 } catch (DataTypeException e) {
118 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
119 throw new RuntimeException(e);
120 }
121 return ret;
122 }
123
124
125 /**
126 * Returns additives (component #2). This is a convenience method that saves you from
127 * casting and handling an exception.
128 */
129 public TX getSps2_Additives() {
130 TX ret = null;
131 try {
132 ret = (TX)getComponent(1);
133 } catch (DataTypeException e) {
134 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
135 throw new RuntimeException(e);
136 }
137 return ret;
138 }
139
140
141 /**
142 * Returns freetext (component #3). This is a convenience method that saves you from
143 * casting and handling an exception.
144 */
145 public TX getFreetext() {
146 TX ret = null;
147 try {
148 ret = (TX)getComponent(2);
149 } catch (DataTypeException e) {
150 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
151 throw new RuntimeException(e);
152 }
153 return ret;
154 }
155
156
157 /**
158 * Returns freetext (component #3). This is a convenience method that saves you from
159 * casting and handling an exception.
160 */
161 public TX getSps3_Freetext() {
162 TX ret = null;
163 try {
164 ret = (TX)getComponent(2);
165 } catch (DataTypeException e) {
166 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
167 throw new RuntimeException(e);
168 }
169 return ret;
170 }
171
172
173 /**
174 * Returns body site (component #4). This is a convenience method that saves you from
175 * casting and handling an exception.
176 */
177 public CE getBodySite() {
178 CE ret = null;
179 try {
180 ret = (CE)getComponent(3);
181 } catch (DataTypeException e) {
182 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
183 throw new RuntimeException(e);
184 }
185 return ret;
186 }
187
188
189 /**
190 * Returns body site (component #4). This is a convenience method that saves you from
191 * casting and handling an exception.
192 */
193 public CE getSps4_BodySite() {
194 CE ret = null;
195 try {
196 ret = (CE)getComponent(3);
197 } catch (DataTypeException e) {
198 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
199 throw new RuntimeException(e);
200 }
201 return ret;
202 }
203
204
205 /**
206 * Returns site modifier (component #5). This is a convenience method that saves you from
207 * casting and handling an exception.
208 */
209 public CE getSiteModifier() {
210 CE ret = null;
211 try {
212 ret = (CE)getComponent(4);
213 } catch (DataTypeException e) {
214 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
215 throw new RuntimeException(e);
216 }
217 return ret;
218 }
219
220
221 /**
222 * Returns site modifier (component #5). This is a convenience method that saves you from
223 * casting and handling an exception.
224 */
225 public CE getSps5_SiteModifier() {
226 CE ret = null;
227 try {
228 ret = (CE)getComponent(4);
229 } catch (DataTypeException e) {
230 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
231 throw new RuntimeException(e);
232 }
233 return ret;
234 }
235
236
237 /**
238 * Returns collection modifier method code (component #6). This is a convenience method that saves you from
239 * casting and handling an exception.
240 */
241 public CE getCollectionModifierMethodCode() {
242 CE ret = null;
243 try {
244 ret = (CE)getComponent(5);
245 } catch (DataTypeException e) {
246 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
247 throw new RuntimeException(e);
248 }
249 return ret;
250 }
251
252
253 /**
254 * Returns collection modifier method code (component #6). This is a convenience method that saves you from
255 * casting and handling an exception.
256 */
257 public CE getSps6_CollectionModifierMethodCode() {
258 CE ret = null;
259 try {
260 ret = (CE)getComponent(5);
261 } catch (DataTypeException e) {
262 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
263 throw new RuntimeException(e);
264 }
265 return ret;
266 }
267
268
269 /**
270 * Returns specimen role (component #7). This is a convenience method that saves you from
271 * casting and handling an exception.
272 */
273 public CE getSpecimenRole() {
274 CE ret = null;
275 try {
276 ret = (CE)getComponent(6);
277 } catch (DataTypeException e) {
278 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
279 throw new RuntimeException(e);
280 }
281 return ret;
282 }
283
284
285 /**
286 * Returns specimen role (component #7). This is a convenience method that saves you from
287 * casting and handling an exception.
288 */
289 public CE getSps7_SpecimenRole() {
290 CE ret = null;
291 try {
292 ret = (CE)getComponent(6);
293 } catch (DataTypeException e) {
294 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
295 throw new RuntimeException(e);
296 }
297 return ret;
298 }
299
300
301
302 }
303