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 DLT (delta check) data type. 
019     * This type consists of the following components:</p>
020     * <ul>
021     * <li>Range (NR)
022     * <li>numeric threshold (NM)
023     * <li>change computation (ST)
024     * <li>length of time-days (NM)
025     * </ul>
026     */
027    public class DLT extends AbstractType implements Composite {
028    
029        private Type[] data;
030    
031        /** 
032         * Creates a new DLT type
033         */
034        public DLT(Message message) {
035            super(message);
036            init();
037        }
038    
039        private void init() {
040            data = new Type[4];    
041            data[0] = new NR(getMessage());
042            data[1] = new NM(getMessage());
043            data[2] = new ST(getMessage());
044            data[3] = new NM(getMessage());
045        }
046    
047    
048        /**
049         * Returns an array containing the data elements.
050         */
051        public Type[] getComponents() { 
052            return this.data; 
053        }
054    
055        /**
056         * Returns an individual data component.
057         *
058         * @param number The component number (0-indexed)
059         * @throws DataTypeException if the given element number is out of range.
060         */
061        public Type getComponent(int number) throws DataTypeException { 
062    
063            try { 
064                return this.data[number]; 
065            } catch (ArrayIndexOutOfBoundsException e) { 
066                throw new DataTypeException("Element " + number + " doesn't exist (Type " + getClass().getName() + " has only " + this.data.length + " components)"); 
067            } 
068        } 
069    
070    
071        /**
072         * Returns Range (component #1).  This is a convenience method that saves you from 
073         * casting and handling an exception.
074         */
075        public NR getRange() {
076           NR ret = null;
077           try {
078              ret = (NR)getComponent(0);
079           } catch (DataTypeException e) {
080              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
081              throw new RuntimeException(e);
082           }
083           return ret;
084        }
085    
086        
087        /**
088         * Returns Range (component #1).  This is a convenience method that saves you from 
089         * casting and handling an exception.
090         */
091        public NR getDlt1_Range() {
092           NR ret = null;
093           try {
094              ret = (NR)getComponent(0);
095           } catch (DataTypeException e) {
096              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
097              throw new RuntimeException(e);
098           }
099           return ret;
100        }
101    
102    
103        /**
104         * Returns numeric threshold (component #2).  This is a convenience method that saves you from 
105         * casting and handling an exception.
106         */
107        public NM getNumericThreshold() {
108           NM ret = null;
109           try {
110              ret = (NM)getComponent(1);
111           } catch (DataTypeException e) {
112              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
113              throw new RuntimeException(e);
114           }
115           return ret;
116        }
117    
118        
119        /**
120         * Returns numeric threshold (component #2).  This is a convenience method that saves you from 
121         * casting and handling an exception.
122         */
123        public NM getDlt2_NumericThreshold() {
124           NM ret = null;
125           try {
126              ret = (NM)getComponent(1);
127           } catch (DataTypeException e) {
128              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
129              throw new RuntimeException(e);
130           }
131           return ret;
132        }
133    
134    
135        /**
136         * Returns change computation (component #3).  This is a convenience method that saves you from 
137         * casting and handling an exception.
138         */
139        public ST getChangeComputation() {
140           ST ret = null;
141           try {
142              ret = (ST)getComponent(2);
143           } catch (DataTypeException e) {
144              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
145              throw new RuntimeException(e);
146           }
147           return ret;
148        }
149    
150        
151        /**
152         * Returns change computation (component #3).  This is a convenience method that saves you from 
153         * casting and handling an exception.
154         */
155        public ST getDlt3_ChangeComputation() {
156           ST ret = null;
157           try {
158              ret = (ST)getComponent(2);
159           } catch (DataTypeException e) {
160              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
161              throw new RuntimeException(e);
162           }
163           return ret;
164        }
165    
166    
167        /**
168         * Returns length of time-days (component #4).  This is a convenience method that saves you from 
169         * casting and handling an exception.
170         */
171        public NM getLengthOfTimeDays() {
172           NM ret = null;
173           try {
174              ret = (NM)getComponent(3);
175           } catch (DataTypeException e) {
176              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
177              throw new RuntimeException(e);
178           }
179           return ret;
180        }
181    
182        
183        /**
184         * Returns length of time-days (component #4).  This is a convenience method that saves you from 
185         * casting and handling an exception.
186         */
187        public NM getDlt4_LengthOfTimeDays() {
188           NM ret = null;
189           try {
190              ret = (NM)getComponent(3);
191           } catch (DataTypeException e) {
192              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
193              throw new RuntimeException(e);
194           }
195           return ret;
196        }
197    
198    
199    
200    }
201