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.v231.message;
009
010 import ca.uhn.hl7v2.model.v231.group.*;
011 import ca.uhn.hl7v2.model.v231.segment.*;
012
013 import ca.uhn.log.HapiLogFactory;
014 import ca.uhn.hl7v2.HL7Exception;
015 import ca.uhn.hl7v2.parser.ModelClassFactory;
016 import ca.uhn.hl7v2.parser.DefaultModelClassFactory;
017 import ca.uhn.hl7v2.model.AbstractMessage;
018
019 /**
020 * <p>Represents a NMR_N01 message structure (see chapter 14). This structure contains the
021 * following elements: </p>
022 * <ul>
023 * <li>1: MSH (MSH - message header segment) <b> </b></li>
024 * <li>2: MSA (MSA - message acknowledgment segment) <b> </b></li>
025 * <li>3: ERR (ERR - error segment) <b>optional repeating</b></li>
026 * <li>4: QRD (QRD - original-style query definition segment) <b>optional </b></li>
027 * <li>5: NMR_N01_NCKNTENSTNTENSCNTE (a Group object) <b> repeating</b></li>
028 * </ul>
029 */
030 public class NMR_N01 extends AbstractMessage {
031
032 /**
033 * Creates a new NMR_N01 message with DefaultModelClassFactory.
034 */
035 public NMR_N01() {
036 this(new DefaultModelClassFactory());
037 }
038
039 /**
040 * Creates a new NMR_N01 message with custom ModelClassFactory.
041 */
042 public NMR_N01(ModelClassFactory factory) {
043 super(factory);
044 init(factory);
045 }
046
047 private void init(ModelClassFactory factory) {
048 try {
049 this.add(MSH.class, true, false);
050 this.add(MSA.class, true, false);
051 this.add(ERR.class, false, true);
052 this.add(QRD.class, false, false);
053 this.add(NMR_N01_NCKNTENSTNTENSCNTE.class, true, true);
054 } catch(HL7Exception e) {
055 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating NMR_N01 - this is probably a bug in the source code generator.", e);
056 }
057 }
058
059 /**
060 * Returns "2.3.1"
061 */
062 public String getVersion() {
063 return "2.3.1";
064 }
065
066
067
068 /**
069 * Returns
070 * MSH (MSH - message header segment) - creates it if necessary
071 */
072 public MSH getMSH() {
073 MSH ret = null;
074 try {
075 ret = (MSH)this.get("MSH");
076 } catch(HL7Exception e) {
077 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
078 throw new RuntimeException(e);
079 }
080 return ret;
081 }
082
083
084
085
086 /**
087 * Returns
088 * MSA (MSA - message acknowledgment segment) - creates it if necessary
089 */
090 public MSA getMSA() {
091 MSA ret = null;
092 try {
093 ret = (MSA)this.get("MSA");
094 } catch(HL7Exception e) {
095 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
096 throw new RuntimeException(e);
097 }
098 return ret;
099 }
100
101
102
103
104 /**
105 * Returns
106 * the first repetition of
107 * ERR (ERR - error segment) - creates it if necessary
108 */
109 public ERR getERR() {
110 ERR ret = null;
111 try {
112 ret = (ERR)this.get("ERR");
113 } catch(HL7Exception e) {
114 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
115 throw new RuntimeException(e);
116 }
117 return ret;
118 }
119
120
121 /**
122 * Returns a specific repetition of
123 * ERR (ERR - error segment) - creates it if necessary
124 *
125 * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
126 * @throws HL7Exception if the repetition requested is more than one
127 * greater than the number of existing repetitions.
128 */
129 public ERR getERR(int rep) {
130 ERR ret = null;
131 try {
132 ret = (ERR)this.get("ERR", rep);
133 } catch(HL7Exception e) {
134 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
135 throw new RuntimeException(e);
136 }
137 return ret;
138 }
139
140 /**
141 * Returns the number of existing repetitions of ERR
142 */
143 public int getERRReps() {
144 int reps = -1;
145 try {
146 reps = this.getAll("ERR").length;
147 } catch (HL7Exception e) {
148 String message = "Unexpected error accessing data - this is probably a bug in the source code generator.";
149 HapiLogFactory.getHapiLog(this.getClass()).error(message, e);
150 throw new RuntimeException(message);
151 }
152 return reps;
153 }
154
155 /**
156 * Inserts a specific repetition of ERR (ERR - error segment)
157 * @see AbstractGroup\#insertRepetition(Structure, int)
158 */
159 public void insertERR(ERR structure, int rep) throws HL7Exception {
160 super.insertRepetition( "ERR", structure, rep);
161 }
162
163
164 /**
165 * Inserts a specific repetition of ERR (ERR - error segment)
166 * @see AbstractGroup\#insertRepetition(Structure, int)
167 */
168 public ERR insertERR(int rep) throws HL7Exception {
169 return (ERR)super.insertRepetition("ERR", rep);
170 }
171
172
173 /**
174 * Removes a specific repetition of ERR (ERR - error segment)
175 * @see AbstractGroup\#removeRepetition(String, int)
176 */
177 public ERR removeERR(int rep) throws HL7Exception {
178 return (ERR)super.removeRepetition("ERR", rep);
179 }
180
181
182
183 /**
184 * Returns
185 * QRD (QRD - original-style query definition segment) - creates it if necessary
186 */
187 public QRD getQRD() {
188 QRD ret = null;
189 try {
190 ret = (QRD)this.get("QRD");
191 } catch(HL7Exception e) {
192 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
193 throw new RuntimeException(e);
194 }
195 return ret;
196 }
197
198
199
200
201 /**
202 * Returns
203 * the first repetition of
204 * NCKNTENSTNTENSCNTE (a Group object) - creates it if necessary
205 */
206 public NMR_N01_NCKNTENSTNTENSCNTE getNCKNTENSTNTENSCNTE() {
207 NMR_N01_NCKNTENSTNTENSCNTE ret = null;
208 try {
209 ret = (NMR_N01_NCKNTENSTNTENSCNTE)this.get("NCKNTENSTNTENSCNTE");
210 } catch(HL7Exception e) {
211 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
212 throw new RuntimeException(e);
213 }
214 return ret;
215 }
216
217
218 /**
219 * Returns a specific repetition of
220 * NCKNTENSTNTENSCNTE (a Group object) - creates it if necessary
221 *
222 * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
223 * @throws HL7Exception if the repetition requested is more than one
224 * greater than the number of existing repetitions.
225 */
226 public NMR_N01_NCKNTENSTNTENSCNTE getNCKNTENSTNTENSCNTE(int rep) {
227 NMR_N01_NCKNTENSTNTENSCNTE ret = null;
228 try {
229 ret = (NMR_N01_NCKNTENSTNTENSCNTE)this.get("NCKNTENSTNTENSCNTE", rep);
230 } catch(HL7Exception e) {
231 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
232 throw new RuntimeException(e);
233 }
234 return ret;
235 }
236
237 /**
238 * Returns the number of existing repetitions of NCKNTENSTNTENSCNTE
239 */
240 public int getNCKNTENSTNTENSCNTEReps() {
241 int reps = -1;
242 try {
243 reps = this.getAll("NCKNTENSTNTENSCNTE").length;
244 } catch (HL7Exception e) {
245 String message = "Unexpected error accessing data - this is probably a bug in the source code generator.";
246 HapiLogFactory.getHapiLog(this.getClass()).error(message, e);
247 throw new RuntimeException(message);
248 }
249 return reps;
250 }
251
252 /**
253 * Inserts a specific repetition of NCKNTENSTNTENSCNTE (a Group object)
254 * @see AbstractGroup\#insertRepetition(Structure, int)
255 */
256 public void insertNCKNTENSTNTENSCNTE(NMR_N01_NCKNTENSTNTENSCNTE structure, int rep) throws HL7Exception {
257 super.insertRepetition( "NCKNTENSTNTENSCNTE", structure, rep);
258 }
259
260
261 /**
262 * Inserts a specific repetition of NCKNTENSTNTENSCNTE (a Group object)
263 * @see AbstractGroup\#insertRepetition(Structure, int)
264 */
265 public NMR_N01_NCKNTENSTNTENSCNTE insertNCKNTENSTNTENSCNTE(int rep) throws HL7Exception {
266 return (NMR_N01_NCKNTENSTNTENSCNTE)super.insertRepetition("NCKNTENSTNTENSCNTE", rep);
267 }
268
269
270 /**
271 * Removes a specific repetition of NCKNTENSTNTENSCNTE (a Group object)
272 * @see AbstractGroup\#removeRepetition(String, int)
273 */
274 public NMR_N01_NCKNTENSTNTENSCNTE removeNCKNTENSTNTENSCNTE(int rep) throws HL7Exception {
275 return (NMR_N01_NCKNTENSTNTENSCNTE)super.removeRepetition("NCKNTENSTNTENSCNTE", rep);
276 }
277
278
279
280 }
281