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.message;
009
010 import ca.uhn.hl7v2.model.v24.group.*;
011 import ca.uhn.hl7v2.model.v24.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 ADT_A21 message structure (see chapter 3). This structure contains the
021 * following elements: </p>
022 * <ul>
023 * <li>1: MSH (Message Header) <b> </b></li>
024 * <li>2: EVN (Event Type) <b> </b></li>
025 * <li>3: PID (Patient identification) <b> </b></li>
026 * <li>4: PD1 (patient additional demographic) <b>optional </b></li>
027 * <li>5: PV1 (Patient visit) <b> </b></li>
028 * <li>6: PV2 (Patient visit - additional information) <b>optional </b></li>
029 * <li>7: DB1 (Disability) <b>optional repeating</b></li>
030 * <li>8: OBX (Observation/Result) <b>optional repeating</b></li>
031 * </ul>
032 */
033 public class ADT_A21 extends AbstractMessage {
034
035 /**
036 * Creates a new ADT_A21 message with DefaultModelClassFactory.
037 */
038 public ADT_A21() {
039 this(new DefaultModelClassFactory());
040 }
041
042 /**
043 * Creates a new ADT_A21 message with custom ModelClassFactory.
044 */
045 public ADT_A21(ModelClassFactory factory) {
046 super(factory);
047 init(factory);
048 }
049
050 private void init(ModelClassFactory factory) {
051 try {
052 this.add(MSH.class, true, false);
053 this.add(EVN.class, true, false);
054 this.add(PID.class, true, false);
055 this.add(PD1.class, false, false);
056 this.add(PV1.class, true, false);
057 this.add(PV2.class, false, false);
058 this.add(DB1.class, false, true);
059 this.add(OBX.class, false, true);
060 } catch(HL7Exception e) {
061 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating ADT_A21 - this is probably a bug in the source code generator.", e);
062 }
063 }
064
065 /**
066 * Returns "2.4"
067 */
068 public String getVersion() {
069 return "2.4";
070 }
071
072
073
074 /**
075 * Returns
076 * MSH (Message Header) - creates it if necessary
077 */
078 public MSH getMSH() {
079 MSH ret = null;
080 try {
081 ret = (MSH)this.get("MSH");
082 } catch(HL7Exception e) {
083 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
084 throw new RuntimeException(e);
085 }
086 return ret;
087 }
088
089
090
091
092 /**
093 * Returns
094 * EVN (Event Type) - creates it if necessary
095 */
096 public EVN getEVN() {
097 EVN ret = null;
098 try {
099 ret = (EVN)this.get("EVN");
100 } catch(HL7Exception e) {
101 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
102 throw new RuntimeException(e);
103 }
104 return ret;
105 }
106
107
108
109
110 /**
111 * Returns
112 * PID (Patient identification) - creates it if necessary
113 */
114 public PID getPID() {
115 PID ret = null;
116 try {
117 ret = (PID)this.get("PID");
118 } catch(HL7Exception e) {
119 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
120 throw new RuntimeException(e);
121 }
122 return ret;
123 }
124
125
126
127
128 /**
129 * Returns
130 * PD1 (patient additional demographic) - creates it if necessary
131 */
132 public PD1 getPD1() {
133 PD1 ret = null;
134 try {
135 ret = (PD1)this.get("PD1");
136 } catch(HL7Exception e) {
137 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
138 throw new RuntimeException(e);
139 }
140 return ret;
141 }
142
143
144
145
146 /**
147 * Returns
148 * PV1 (Patient visit) - creates it if necessary
149 */
150 public PV1 getPV1() {
151 PV1 ret = null;
152 try {
153 ret = (PV1)this.get("PV1");
154 } catch(HL7Exception e) {
155 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
156 throw new RuntimeException(e);
157 }
158 return ret;
159 }
160
161
162
163
164 /**
165 * Returns
166 * PV2 (Patient visit - additional information) - creates it if necessary
167 */
168 public PV2 getPV2() {
169 PV2 ret = null;
170 try {
171 ret = (PV2)this.get("PV2");
172 } catch(HL7Exception e) {
173 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
174 throw new RuntimeException(e);
175 }
176 return ret;
177 }
178
179
180
181
182 /**
183 * Returns
184 * the first repetition of
185 * DB1 (Disability) - creates it if necessary
186 */
187 public DB1 getDB1() {
188 DB1 ret = null;
189 try {
190 ret = (DB1)this.get("DB1");
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 * Returns a specific repetition of
201 * DB1 (Disability) - creates it if necessary
202 *
203 * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
204 * @throws HL7Exception if the repetition requested is more than one
205 * greater than the number of existing repetitions.
206 */
207 public DB1 getDB1(int rep) {
208 DB1 ret = null;
209 try {
210 ret = (DB1)this.get("DB1", rep);
211 } catch(HL7Exception e) {
212 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
213 throw new RuntimeException(e);
214 }
215 return ret;
216 }
217
218 /**
219 * Returns the number of existing repetitions of DB1
220 */
221 public int getDB1Reps() {
222 int reps = -1;
223 try {
224 reps = this.getAll("DB1").length;
225 } catch (HL7Exception e) {
226 String message = "Unexpected error accessing data - this is probably a bug in the source code generator.";
227 HapiLogFactory.getHapiLog(this.getClass()).error(message, e);
228 throw new RuntimeException(message);
229 }
230 return reps;
231 }
232
233 /**
234 * Inserts a specific repetition of DB1 (Disability)
235 * @see AbstractGroup\#insertRepetition(Structure, int)
236 */
237 public void insertDB1(DB1 structure, int rep) throws HL7Exception {
238 super.insertRepetition( "DB1", structure, rep);
239 }
240
241
242 /**
243 * Inserts a specific repetition of DB1 (Disability)
244 * @see AbstractGroup\#insertRepetition(Structure, int)
245 */
246 public DB1 insertDB1(int rep) throws HL7Exception {
247 return (DB1)super.insertRepetition("DB1", rep);
248 }
249
250
251 /**
252 * Removes a specific repetition of DB1 (Disability)
253 * @see AbstractGroup\#removeRepetition(String, int)
254 */
255 public DB1 removeDB1(int rep) throws HL7Exception {
256 return (DB1)super.removeRepetition("DB1", rep);
257 }
258
259
260
261 /**
262 * Returns
263 * the first repetition of
264 * OBX (Observation/Result) - creates it if necessary
265 */
266 public OBX getOBX() {
267 OBX ret = null;
268 try {
269 ret = (OBX)this.get("OBX");
270 } catch(HL7Exception e) {
271 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
272 throw new RuntimeException(e);
273 }
274 return ret;
275 }
276
277
278 /**
279 * Returns a specific repetition of
280 * OBX (Observation/Result) - creates it if necessary
281 *
282 * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
283 * @throws HL7Exception if the repetition requested is more than one
284 * greater than the number of existing repetitions.
285 */
286 public OBX getOBX(int rep) {
287 OBX ret = null;
288 try {
289 ret = (OBX)this.get("OBX", rep);
290 } catch(HL7Exception e) {
291 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
292 throw new RuntimeException(e);
293 }
294 return ret;
295 }
296
297 /**
298 * Returns the number of existing repetitions of OBX
299 */
300 public int getOBXReps() {
301 int reps = -1;
302 try {
303 reps = this.getAll("OBX").length;
304 } catch (HL7Exception e) {
305 String message = "Unexpected error accessing data - this is probably a bug in the source code generator.";
306 HapiLogFactory.getHapiLog(this.getClass()).error(message, e);
307 throw new RuntimeException(message);
308 }
309 return reps;
310 }
311
312 /**
313 * Inserts a specific repetition of OBX (Observation/Result)
314 * @see AbstractGroup\#insertRepetition(Structure, int)
315 */
316 public void insertOBX(OBX structure, int rep) throws HL7Exception {
317 super.insertRepetition( "OBX", structure, rep);
318 }
319
320
321 /**
322 * Inserts a specific repetition of OBX (Observation/Result)
323 * @see AbstractGroup\#insertRepetition(Structure, int)
324 */
325 public OBX insertOBX(int rep) throws HL7Exception {
326 return (OBX)super.insertRepetition("OBX", rep);
327 }
328
329
330 /**
331 * Removes a specific repetition of OBX (Observation/Result)
332 * @see AbstractGroup\#removeRepetition(String, int)
333 */
334 public OBX removeOBX(int rep) throws HL7Exception {
335 return (OBX)super.removeRepetition("OBX", rep);
336 }
337
338
339
340 }
341