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 * The contents of this file are subject to the Mozilla Public License Version 1.1 
008 * (the "License"); you may not use this file except in compliance with the License. 
009 * You may obtain a copy of the License at http://www.mozilla.org/MPL/ 
010 * Software distributed under the License is distributed on an "AS IS" basis, 
011 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 
012 * specific language governing rights and limitations under the License. 
013 * 
014 * The Original Code is "[file_name]".  Description: 
015 * "[one_line_description]" 
016 * 
017 * The Initial Developer of the Original Code is University Health Network. Copyright (C) 
018 * 2012.  All Rights Reserved. 
019 * 
020 * Contributor(s): ______________________________________. 
021 * 
022 * Alternatively, the contents of this file may be used under the terms of the 
023 * GNU General Public License (the  "GPL"), in which case the provisions of the GPL are 
024 * applicable instead of those above.  If you wish to allow use of your version of this 
025 * file only under the terms of the GPL and not to allow others to use your version 
026 * of this file under the MPL, indicate your decision by deleting  the provisions above 
027 * and replace  them with the notice and other provisions required by the GPL License.  
028 * If you do not delete the provisions above, a recipient may use your version of 
029 * this file under either the MPL or the GPL. 
030 * 
031 */
032
033
034package ca.uhn.hl7v2.model.v251.segment;
035
036// import ca.uhn.hl7v2.model.v251.group.*;
037import ca.uhn.hl7v2.model.v251.datatype.*;
038import ca.uhn.hl7v2.HL7Exception;
039import ca.uhn.hl7v2.parser.ModelClassFactory;
040import ca.uhn.hl7v2.parser.DefaultModelClassFactory;
041import ca.uhn.hl7v2.model.AbstractMessage;
042import ca.uhn.hl7v2.model.Group;
043import ca.uhn.hl7v2.model.Type;
044import ca.uhn.hl7v2.model.AbstractSegment;
045import ca.uhn.hl7v2.model.Varies;
046
047
048/**
049 *<p>Represents an HL7 QRI message segment (Query Response Instance). 
050 * This segment has the following fields:</p>
051 * <ul>
052     * <li>QRI-1: Candidate Confidence (NM) <b>optional </b>
053     * <li>QRI-2: Match Reason Code (IS) <b>optional repeating</b>
054     * <li>QRI-3: Algorithm Descriptor (CE) <b>optional </b>
055 * </ul>
056 */
057@SuppressWarnings("unused")
058public class QRI extends AbstractSegment {
059
060    /** 
061     * Creates a new QRI segment
062     */
063    public QRI(Group parent, ModelClassFactory factory) {
064       super(parent, factory);
065       init(factory);
066    }
067
068    private void init(ModelClassFactory factory) {
069       try {
070                                  this.add(NM.class, false, 1, 10, new Object[]{ getMessage() }, "Candidate Confidence");
071                                              this.add(IS.class, false, 0, 2, new Object[]{ getMessage(), new Integer(392) }, "Match Reason Code");
072                                  this.add(CE.class, false, 1, 250, new Object[]{ getMessage() }, "Algorithm Descriptor");
073       } catch(HL7Exception e) {
074          log.error("Unexpected error creating QRI - this is probably a bug in the source code generator.", e);
075       }
076    }
077
078
079
080    /**
081     * Returns
082     * QRI-1: "Candidate Confidence" - creates it if necessary
083     */
084    public NM getCandidateConfidence() { 
085                NM retVal = this.getTypedField(1, 0);
086                return retVal;
087    }
088    
089    /**
090     * Returns
091     * QRI-1: "Candidate Confidence" - creates it if necessary
092     */
093    public NM getQri1_CandidateConfidence() { 
094                NM retVal = this.getTypedField(1, 0);
095                return retVal;
096    }
097
098
099    /**
100     * Returns all repetitions of Match Reason Code (QRI-2).
101     */
102    public IS[] getMatchReasonCode() {
103        IS[] retVal = this.getTypedField(2, new IS[0]);
104        return retVal;
105    }
106
107
108    /**
109     * Returns all repetitions of Match Reason Code (QRI-2).
110     */
111    public IS[] getQri2_MatchReasonCode() {
112        IS[] retVal = this.getTypedField(2, new IS[0]);
113        return retVal;
114    }
115
116
117    /**
118     * Returns a count of the current number of repetitions of Match Reason Code (QRI-2).
119     * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
120     * it will return zero.
121     */
122    public int getMatchReasonCodeReps() {
123        return this.getReps(2);
124    }
125
126
127    /**
128     * Returns a specific repetition of
129     * QRI-2: "Match Reason Code" - creates it if necessary
130     *
131     * @param rep The repetition index (0-indexed)
132     */
133    public IS getMatchReasonCode(int rep) { 
134                IS retVal = this.getTypedField(2, rep);
135                return retVal;
136    }
137
138    /**
139     * Returns a specific repetition of
140     * QRI-2: "Match Reason Code" - creates it if necessary
141     *
142     * @param rep The repetition index (0-indexed)
143     */
144    public IS getQri2_MatchReasonCode(int rep) { 
145                IS retVal = this.getTypedField(2, rep);
146                return retVal;
147    }
148
149    /**
150     * Returns a count of the current number of repetitions of Match Reason Code (QRI-2).
151     * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
152     * it will return zero.
153     */
154    public int getQri2_MatchReasonCodeReps() {
155        return this.getReps(2);
156    }
157
158
159    /**
160     * Inserts a repetition of
161     * QRI-2: "Match Reason Code" at a specific index
162     *
163     * @param rep The repetition index (0-indexed)
164     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
165     */
166    public IS insertMatchReasonCode(int rep) throws HL7Exception { 
167        return (IS) super.insertRepetition(2, rep);
168    }
169
170
171    /**
172     * Inserts a repetition of
173     * QRI-2: "Match Reason Code" at a specific index
174     *
175     * @param rep The repetition index (0-indexed)
176     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
177     */
178    public IS insertQri2_MatchReasonCode(int rep) throws HL7Exception { 
179        return (IS) super.insertRepetition(2, rep);
180    }
181
182
183    /**
184     * Removes a repetition of
185     * QRI-2: "Match Reason Code" at a specific index
186     *
187     * @param rep The repetition index (0-indexed)
188     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
189     */
190    public IS removeMatchReasonCode(int rep) throws HL7Exception { 
191        return (IS) super.removeRepetition(2, rep);
192    }
193
194
195    /**
196     * Removes a repetition of
197     * QRI-2: "Match Reason Code" at a specific index
198     *
199     * @param rep The repetition index (0-indexed)
200     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
201     */
202    public IS removeQri2_MatchReasonCode(int rep) throws HL7Exception { 
203        return (IS) super.removeRepetition(2, rep);
204    }
205
206
207
208
209    /**
210     * Returns
211     * QRI-3: "Algorithm Descriptor" - creates it if necessary
212     */
213    public CE getAlgorithmDescriptor() { 
214                CE retVal = this.getTypedField(3, 0);
215                return retVal;
216    }
217    
218    /**
219     * Returns
220     * QRI-3: "Algorithm Descriptor" - creates it if necessary
221     */
222    public CE getQri3_AlgorithmDescriptor() { 
223                CE retVal = this.getTypedField(3, 0);
224                return retVal;
225    }
226
227
228
229
230
231    /** {@inheritDoc} */   
232    protected Type createNewTypeWithoutReflection(int field) {
233       switch (field) {
234          case 0: return new NM(getMessage());
235          case 1: return new IS(getMessage(), new Integer( 392 ));
236          case 2: return new CE(getMessage());
237          default: return null;
238       }
239   }
240
241
242}
243