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.segment;
009
010 // import ca.uhn.hl7v2.model.v24.group.*;
011 import ca.uhn.hl7v2.model.v24.datatype.*;
012 import ca.uhn.log.HapiLogFactory;
013 import ca.uhn.hl7v2.HL7Exception;
014 import ca.uhn.hl7v2.parser.ModelClassFactory;
015 import ca.uhn.hl7v2.parser.DefaultModelClassFactory;
016 import ca.uhn.hl7v2.model.AbstractMessage;
017 import ca.uhn.hl7v2.model.Group;
018 import ca.uhn.hl7v2.model.Type;
019 import ca.uhn.hl7v2.model.AbstractSegment;
020 import ca.uhn.hl7v2.model.Varies;
021
022 /**
023 *<p>Represents an HL7 ECR message segment (Equipment Command Response).
024 * This segment has the following fields:</p>
025 * <ul>
026 * <li>ECR-1: Command Response (CE) <b> </b>
027 * <li>ECR-2: Date/Time Completed (TS) <b> </b>
028 * <li>ECR-3: Command Response Parameters (ST) <b>optional repeating</b>
029 * </ul>
030 */
031 public class ECR extends AbstractSegment {
032
033 /**
034 * Creates a new ECR segment
035 */
036 public ECR(Group parent, ModelClassFactory factory) {
037 super(parent, factory);
038 init(factory);
039 }
040
041 private void init(ModelClassFactory factory) {
042 try {
043 this.add(CE.class, true, 1, 250, new Object[]{ getMessage(), new Integer(387) }, "Command Response");
044 this.add(TS.class, true, 1, 26, new Object[]{ getMessage(), new Integer(0) }, "Date/Time Completed");
045 this.add(ST.class, false, 0, 65536, new Object[]{ getMessage(), new Integer(0) }, "Command Response Parameters");
046 } catch(HL7Exception e) {
047 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating ECR - this is probably a bug in the source code generator.", e);
048 }
049 }
050
051
052
053 /**
054 * Returns
055 * ECR-1: "Command Response" - creates it if necessary
056 */
057 public CE getCommandResponse() {
058 CE ret = null;
059 try {
060 Type t = this.getField(1, 0);
061 ret = (CE)t;
062 } catch (ClassCastException cce) {
063 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
064 throw new RuntimeException(cce);
065 } catch (HL7Exception he) {
066 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
067 throw new RuntimeException(he);
068 }
069 return ret;
070 }
071
072
073 /**
074 * Returns
075 * ECR-1: "Command Response" - creates it if necessary
076 */
077 public CE getEcr1_CommandResponse() {
078 CE ret = null;
079 try {
080 Type t = this.getField(1, 0);
081 ret = (CE)t;
082 } catch (ClassCastException cce) {
083 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
084 throw new RuntimeException(cce);
085 } catch (HL7Exception he) {
086 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
087 throw new RuntimeException(he);
088 }
089 return ret;
090 }
091
092
093
094 /**
095 * Returns
096 * ECR-2: "Date/Time Completed" - creates it if necessary
097 */
098 public TS getDateTimeCompleted() {
099 TS ret = null;
100 try {
101 Type t = this.getField(2, 0);
102 ret = (TS)t;
103 } catch (ClassCastException cce) {
104 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
105 throw new RuntimeException(cce);
106 } catch (HL7Exception he) {
107 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
108 throw new RuntimeException(he);
109 }
110 return ret;
111 }
112
113
114 /**
115 * Returns
116 * ECR-2: "Date/Time Completed" - creates it if necessary
117 */
118 public TS getEcr2_DateTimeCompleted() {
119 TS ret = null;
120 try {
121 Type t = this.getField(2, 0);
122 ret = (TS)t;
123 } catch (ClassCastException cce) {
124 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
125 throw new RuntimeException(cce);
126 } catch (HL7Exception he) {
127 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
128 throw new RuntimeException(he);
129 }
130 return ret;
131 }
132
133
134 /**
135 * Returns all repetitions of Command Response Parameters (ECR-3).
136 */
137 public ST[] getCommandResponseParameters() {
138 ST[] ret = null;
139 try {
140 Type[] t = this.getField(3);
141 ret = new ST[t.length];
142 for (int i = 0; i < ret.length; i++) {
143 ret[i] = (ST)t[i];
144 }
145 } catch (ClassCastException cce) {
146 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
147 throw new RuntimeException(cce);
148 } catch (HL7Exception he) {
149 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
150 throw new RuntimeException(he);
151 }
152 return ret;
153 }
154
155
156 /**
157 * Returns a count of the current number of repetitions of Command Response Parameters (ECR-3).
158 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
159 * it will return zero.
160 */
161 public int getCommandResponseParametersReps() {
162 ST[] ret = null;
163 try {
164 Type[] t = this.getField(3);
165 return t.length;
166 } catch (ClassCastException cce) {
167 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
168 throw new RuntimeException(cce);
169 } catch (HL7Exception he) {
170 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
171 throw new RuntimeException(he);
172 }
173 }
174
175
176 /**
177 * Returns a specific repetition of
178 * ECR-3: "Command Response Parameters" - creates it if necessary
179 *
180 * @param rep The repetition index (0-indexed)
181 */
182 public ST getCommandResponseParameters(int rep) {
183 ST ret = null;
184 try {
185 Type t = this.getField(3, rep);
186 ret = (ST)t;
187 } catch (ClassCastException cce) {
188 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
189 throw new RuntimeException(cce);
190 } catch (HL7Exception he) {
191 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
192 throw new RuntimeException(he);
193 }
194 return ret;
195 }
196
197 /**
198 * Returns a specific repetition of
199 * ECR-3: "Command Response Parameters" - creates it if necessary
200 *
201 * @param rep The repetition index (0-indexed)
202 */
203 public ST getEcr3_CommandResponseParameters(int rep) {
204 ST ret = null;
205 try {
206 Type t = this.getField(3, rep);
207 ret = (ST)t;
208 } catch (ClassCastException cce) {
209 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
210 throw new RuntimeException(cce);
211 } catch (HL7Exception he) {
212 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
213 throw new RuntimeException(he);
214 }
215 return ret;
216 }
217
218
219 /**
220 * Returns a count of the current number of repetitions of Command Response Parameters (ECR-3).
221 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
222 * it will return zero.
223 */
224 public int getEcr3_CommandResponseParametersReps() {
225 ST[] ret = null;
226 try {
227 Type[] t = this.getField(3);
228 return t.length;
229 } catch (ClassCastException cce) {
230 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
231 throw new RuntimeException(cce);
232 } catch (HL7Exception he) {
233 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
234 throw new RuntimeException(he);
235 }
236 }
237
238
239
240 /**
241 * Inserts a repetition of
242 * ECR-3: "Command Response Parameters" at a specific index
243 *
244 * @param rep The repetition index (0-indexed)
245 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
246 */
247 public ST insertCommandResponseParameters(int rep) throws HL7Exception {
248 return (ST) super.insertRepetition(3, rep);
249 }
250
251
252
253 /**
254 * Inserts a repetition of
255 * ECR-3: "Command Response Parameters" at a specific index
256 *
257 * @param rep The repetition index (0-indexed)
258 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
259 */
260 public ST insertEcr3_CommandResponseParameters(int rep) throws HL7Exception {
261 return (ST) super.insertRepetition(3, rep);
262 }
263
264
265 /**
266 * Removes a repetition of
267 * ECR-3: "Command Response Parameters" at a specific index
268 *
269 * @param rep The repetition index (0-indexed)
270 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
271 */
272 public ST removeCommandResponseParameters(int rep) throws HL7Exception {
273 return (ST) super.removeRepetition(3, rep);
274 }
275
276
277 /**
278 * Removes a repetition of
279 * ECR-3: "Command Response Parameters" at a specific index
280 *
281 * @param rep The repetition index (0-indexed)
282 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
283 */
284 public ST removeEcr3_CommandResponseParameters(int rep) throws HL7Exception {
285 return (ST) super.removeRepetition(3, rep);
286 }
287
288
289
290
291
292
293 /** {@inheritDoc} */
294 protected Type createNewTypeWithoutReflection(int field) {
295 switch (field) {
296 case 0: return new CE(getMessage());
297 case 1: return new TS(getMessage());
298 case 2: return new ST(getMessage());
299 default: return null;
300 }
301 }
302
303
304 }
305