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 QRI message segment (Query Response Instance).
024 * This segment has the following fields:</p>
025 * <ul>
026 * <li>QRI-1: Candidate Confidence (NM) <b>optional </b>
027 * <li>QRI-2: Match Reason Code (IS) <b>optional repeating</b>
028 * <li>QRI-3: Algorithm Descriptor (CE) <b>optional </b>
029 * </ul>
030 */
031 public class QRI extends AbstractSegment {
032
033 /**
034 * Creates a new QRI segment
035 */
036 public QRI(Group parent, ModelClassFactory factory) {
037 super(parent, factory);
038 init(factory);
039 }
040
041 private void init(ModelClassFactory factory) {
042 try {
043 this.add(NM.class, false, 1, 10, new Object[]{ getMessage(), new Integer(0) }, "Candidate Confidence");
044 this.add(IS.class, false, 0, 2, new Object[]{ getMessage() }, "Match Reason Code");
045 this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(393) }, "Algorithm Descriptor");
046 } catch(HL7Exception e) {
047 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating QRI - this is probably a bug in the source code generator.", e);
048 }
049 }
050
051
052
053 /**
054 * Returns
055 * QRI-1: "Candidate Confidence" - creates it if necessary
056 */
057 public NM getCandidateConfidence() {
058 NM ret = null;
059 try {
060 Type t = this.getField(1, 0);
061 ret = (NM)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 * QRI-1: "Candidate Confidence" - creates it if necessary
076 */
077 public NM getQri1_CandidateConfidence() {
078 NM ret = null;
079 try {
080 Type t = this.getField(1, 0);
081 ret = (NM)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 * Returns all repetitions of Match Reason Code (QRI-2).
095 */
096 public IS[] getMatchReasonCode() {
097 IS[] ret = null;
098 try {
099 Type[] t = this.getField(2);
100 ret = new IS[t.length];
101 for (int i = 0; i < ret.length; i++) {
102 ret[i] = (IS)t[i];
103 }
104 } catch (ClassCastException cce) {
105 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
106 throw new RuntimeException(cce);
107 } catch (HL7Exception he) {
108 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
109 throw new RuntimeException(he);
110 }
111 return ret;
112 }
113
114
115 /**
116 * Returns a count of the current number of repetitions of Match Reason Code (QRI-2).
117 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
118 * it will return zero.
119 */
120 public int getMatchReasonCodeReps() {
121 IS[] ret = null;
122 try {
123 Type[] t = this.getField(2);
124 return t.length;
125 } catch (ClassCastException cce) {
126 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
127 throw new RuntimeException(cce);
128 } catch (HL7Exception he) {
129 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
130 throw new RuntimeException(he);
131 }
132 }
133
134
135 /**
136 * Returns a specific repetition of
137 * QRI-2: "Match Reason Code" - creates it if necessary
138 *
139 * @param rep The repetition index (0-indexed)
140 */
141 public IS getMatchReasonCode(int rep) {
142 IS ret = null;
143 try {
144 Type t = this.getField(2, rep);
145 ret = (IS)t;
146 } catch (ClassCastException cce) {
147 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
148 throw new RuntimeException(cce);
149 } catch (HL7Exception he) {
150 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
151 throw new RuntimeException(he);
152 }
153 return ret;
154 }
155
156 /**
157 * Returns a specific repetition of
158 * QRI-2: "Match Reason Code" - creates it if necessary
159 *
160 * @param rep The repetition index (0-indexed)
161 */
162 public IS getQri2_MatchReasonCode(int rep) {
163 IS ret = null;
164 try {
165 Type t = this.getField(2, rep);
166 ret = (IS)t;
167 } catch (ClassCastException cce) {
168 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
169 throw new RuntimeException(cce);
170 } catch (HL7Exception he) {
171 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
172 throw new RuntimeException(he);
173 }
174 return ret;
175 }
176
177
178 /**
179 * Returns a count of the current number of repetitions of Match Reason Code (QRI-2).
180 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
181 * it will return zero.
182 */
183 public int getQri2_MatchReasonCodeReps() {
184 IS[] ret = null;
185 try {
186 Type[] t = this.getField(2);
187 return t.length;
188 } catch (ClassCastException cce) {
189 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
190 throw new RuntimeException(cce);
191 } catch (HL7Exception he) {
192 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
193 throw new RuntimeException(he);
194 }
195 }
196
197
198
199 /**
200 * Inserts a repetition of
201 * QRI-2: "Match Reason Code" at a specific index
202 *
203 * @param rep The repetition index (0-indexed)
204 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
205 */
206 public IS insertMatchReasonCode(int rep) throws HL7Exception {
207 return (IS) super.insertRepetition(2, rep);
208 }
209
210
211
212 /**
213 * Inserts a repetition of
214 * QRI-2: "Match Reason Code" at a specific index
215 *
216 * @param rep The repetition index (0-indexed)
217 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
218 */
219 public IS insertQri2_MatchReasonCode(int rep) throws HL7Exception {
220 return (IS) super.insertRepetition(2, rep);
221 }
222
223
224 /**
225 * Removes a repetition of
226 * QRI-2: "Match Reason Code" at a specific index
227 *
228 * @param rep The repetition index (0-indexed)
229 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
230 */
231 public IS removeMatchReasonCode(int rep) throws HL7Exception {
232 return (IS) super.removeRepetition(2, rep);
233 }
234
235
236 /**
237 * Removes a repetition of
238 * QRI-2: "Match Reason Code" at a specific index
239 *
240 * @param rep The repetition index (0-indexed)
241 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
242 */
243 public IS removeQri2_MatchReasonCode(int rep) throws HL7Exception {
244 return (IS) super.removeRepetition(2, rep);
245 }
246
247
248
249
250 /**
251 * Returns
252 * QRI-3: "Algorithm Descriptor" - creates it if necessary
253 */
254 public CE getAlgorithmDescriptor() {
255 CE ret = null;
256 try {
257 Type t = this.getField(3, 0);
258 ret = (CE)t;
259 } catch (ClassCastException cce) {
260 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
261 throw new RuntimeException(cce);
262 } catch (HL7Exception he) {
263 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
264 throw new RuntimeException(he);
265 }
266 return ret;
267 }
268
269
270 /**
271 * Returns
272 * QRI-3: "Algorithm Descriptor" - creates it if necessary
273 */
274 public CE getQri3_AlgorithmDescriptor() {
275 CE ret = null;
276 try {
277 Type t = this.getField(3, 0);
278 ret = (CE)t;
279 } catch (ClassCastException cce) {
280 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
281 throw new RuntimeException(cce);
282 } catch (HL7Exception he) {
283 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
284 throw new RuntimeException(he);
285 }
286 return ret;
287 }
288
289
290
291
292
293 /** {@inheritDoc} */
294 protected Type createNewTypeWithoutReflection(int field) {
295 switch (field) {
296 case 0: return new NM(getMessage());
297 case 1: return new IS(getMessage(), new Integer( 392 ));
298 case 2: return new CE(getMessage());
299 default: return null;
300 }
301 }
302
303
304 }
305