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 CSU (channel sensitivity/units) data type. 
019     * This type consists of the following components:</p>
020     * <ul>
021     * <li>channel sensitivity (NM)
022     * <li>unit of measure identifier (ST)
023     * <li>unit of measure description (ST)
024     * <li>unit of measure coding system (IS)
025     * <li>alternate unit of measure identifier (ST)
026     * <li>alternate unit of measure description (ST)
027     * <li>alternate unit of measure coding system (IS)
028     * </ul>
029     */
030    public class CSU extends AbstractType implements Composite {
031    
032        private Type[] data;
033    
034        /** 
035         * Creates a new CSU type
036         */
037        public CSU(Message message) {
038            super(message);
039            init();
040        }
041    
042        private void init() {
043            data = new Type[7];    
044            data[0] = new NM(getMessage());
045            data[1] = new ST(getMessage());
046            data[2] = new ST(getMessage());
047            data[3] = new IS(getMessage(), 0);
048            data[4] = new ST(getMessage());
049            data[5] = new ST(getMessage());
050            data[6] = new IS(getMessage(), 0);
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 channel sensitivity (component #1).  This is a convenience method that saves you from 
079         * casting and handling an exception.
080         */
081        public NM getChannelSensitivity() {
082           NM ret = null;
083           try {
084              ret = (NM)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 channel sensitivity (component #1).  This is a convenience method that saves you from 
095         * casting and handling an exception.
096         */
097        public NM getCsu1_ChannelSensitivity() {
098           NM ret = null;
099           try {
100              ret = (NM)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 unit of measure identifier (component #2).  This is a convenience method that saves you from 
111         * casting and handling an exception.
112         */
113        public ST getUnitOfMeasureIdentifier() {
114           ST ret = null;
115           try {
116              ret = (ST)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 unit of measure identifier (component #2).  This is a convenience method that saves you from 
127         * casting and handling an exception.
128         */
129        public ST getCsu2_UnitOfMeasureIdentifier() {
130           ST ret = null;
131           try {
132              ret = (ST)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 unit of measure description (component #3).  This is a convenience method that saves you from 
143         * casting and handling an exception.
144         */
145        public ST getUnitOfMeasureDescription() {
146           ST ret = null;
147           try {
148              ret = (ST)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 unit of measure description (component #3).  This is a convenience method that saves you from 
159         * casting and handling an exception.
160         */
161        public ST getCsu3_UnitOfMeasureDescription() {
162           ST ret = null;
163           try {
164              ret = (ST)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 unit of measure coding system (component #4).  This is a convenience method that saves you from 
175         * casting and handling an exception.
176         */
177        public IS getUnitOfMeasureCodingSystem() {
178           IS ret = null;
179           try {
180              ret = (IS)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 unit of measure coding system (component #4).  This is a convenience method that saves you from 
191         * casting and handling an exception.
192         */
193        public IS getCsu4_UnitOfMeasureCodingSystem() {
194           IS ret = null;
195           try {
196              ret = (IS)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 alternate unit of measure identifier (component #5).  This is a convenience method that saves you from 
207         * casting and handling an exception.
208         */
209        public ST getAlternateUnitOfMeasureIdentifier() {
210           ST ret = null;
211           try {
212              ret = (ST)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 alternate unit of measure identifier (component #5).  This is a convenience method that saves you from 
223         * casting and handling an exception.
224         */
225        public ST getCsu5_AlternateUnitOfMeasureIdentifier() {
226           ST ret = null;
227           try {
228              ret = (ST)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 alternate unit of measure description (component #6).  This is a convenience method that saves you from 
239         * casting and handling an exception.
240         */
241        public ST getAlternateUnitOfMeasureDescription() {
242           ST ret = null;
243           try {
244              ret = (ST)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 alternate unit of measure description (component #6).  This is a convenience method that saves you from 
255         * casting and handling an exception.
256         */
257        public ST getCsu6_AlternateUnitOfMeasureDescription() {
258           ST ret = null;
259           try {
260              ret = (ST)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 alternate unit of measure coding system (component #7).  This is a convenience method that saves you from 
271         * casting and handling an exception.
272         */
273        public IS getAlternateUnitOfMeasureCodingSystem() {
274           IS ret = null;
275           try {
276              ret = (IS)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 alternate unit of measure coding system (component #7).  This is a convenience method that saves you from 
287         * casting and handling an exception.
288         */
289        public IS getCsu7_AlternateUnitOfMeasureCodingSystem() {
290           IS ret = null;
291           try {
292              ret = (IS)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