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_A54 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: ROL (Role) <b>optional repeating</b></li>
028 * <li>6: PV1 (Patient visit) <b> </b></li>
029 * <li>7: PV2 (Patient visit - additional information) <b>optional </b></li>
030 * <li>8: ROL (Role) <b>optional repeating</b></li>
031 * </ul>
032 */
033 public class ADT_A54 extends AbstractMessage {
034
035 /**
036 * Creates a new ADT_A54 message with DefaultModelClassFactory.
037 */
038 public ADT_A54() {
039 this(new DefaultModelClassFactory());
040 }
041
042 /**
043 * Creates a new ADT_A54 message with custom ModelClassFactory.
044 */
045 public ADT_A54(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(ROL.class, false, true);
057 this.add(PV1.class, true, false);
058 this.add(PV2.class, false, false);
059 this.add(ROL.class, false, true);
060 } catch(HL7Exception e) {
061 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating ADT_A54 - 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 * the first repetition of
149 * ROL (Role) - creates it if necessary
150 */
151 public ROL getROL() {
152 ROL ret = null;
153 try {
154 ret = (ROL)this.get("ROL");
155 } catch(HL7Exception e) {
156 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
157 throw new RuntimeException(e);
158 }
159 return ret;
160 }
161
162
163 /**
164 * Returns a specific repetition of
165 * ROL (Role) - creates it if necessary
166 *
167 * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
168 * @throws HL7Exception if the repetition requested is more than one
169 * greater than the number of existing repetitions.
170 */
171 public ROL getROL(int rep) {
172 ROL ret = null;
173 try {
174 ret = (ROL)this.get("ROL", rep);
175 } catch(HL7Exception e) {
176 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
177 throw new RuntimeException(e);
178 }
179 return ret;
180 }
181
182 /**
183 * Returns the number of existing repetitions of ROL
184 */
185 public int getROLReps() {
186 int reps = -1;
187 try {
188 reps = this.getAll("ROL").length;
189 } catch (HL7Exception e) {
190 String message = "Unexpected error accessing data - this is probably a bug in the source code generator.";
191 HapiLogFactory.getHapiLog(this.getClass()).error(message, e);
192 throw new RuntimeException(message);
193 }
194 return reps;
195 }
196
197 /**
198 * Inserts a specific repetition of ROL (Role)
199 * @see AbstractGroup\#insertRepetition(Structure, int)
200 */
201 public void insertROL(ROL structure, int rep) throws HL7Exception {
202 super.insertRepetition( "ROL", structure, rep);
203 }
204
205
206 /**
207 * Inserts a specific repetition of ROL (Role)
208 * @see AbstractGroup\#insertRepetition(Structure, int)
209 */
210 public ROL insertROL(int rep) throws HL7Exception {
211 return (ROL)super.insertRepetition("ROL", rep);
212 }
213
214
215 /**
216 * Removes a specific repetition of ROL (Role)
217 * @see AbstractGroup\#removeRepetition(String, int)
218 */
219 public ROL removeROL(int rep) throws HL7Exception {
220 return (ROL)super.removeRepetition("ROL", rep);
221 }
222
223
224
225 /**
226 * Returns
227 * PV1 (Patient visit) - creates it if necessary
228 */
229 public PV1 getPV1() {
230 PV1 ret = null;
231 try {
232 ret = (PV1)this.get("PV1");
233 } catch(HL7Exception e) {
234 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
235 throw new RuntimeException(e);
236 }
237 return ret;
238 }
239
240
241
242
243 /**
244 * Returns
245 * PV2 (Patient visit - additional information) - creates it if necessary
246 */
247 public PV2 getPV2() {
248 PV2 ret = null;
249 try {
250 ret = (PV2)this.get("PV2");
251 } catch(HL7Exception e) {
252 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
253 throw new RuntimeException(e);
254 }
255 return ret;
256 }
257
258
259
260
261 /**
262 * Returns
263 * the first repetition of
264 * ROL2 (Role) - creates it if necessary
265 */
266 public ROL getROL2() {
267 ROL ret = null;
268 try {
269 ret = (ROL)this.get("ROL2");
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 * ROL2 (Role) - 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 ROL getROL2(int rep) {
287 ROL ret = null;
288 try {
289 ret = (ROL)this.get("ROL2", 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 ROL2
299 */
300 public int getROL2Reps() {
301 int reps = -1;
302 try {
303 reps = this.getAll("ROL2").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 ROL2 (Role)
314 * @see AbstractGroup\#insertRepetition(Structure, int)
315 */
316 public void insertROL2(ROL structure, int rep) throws HL7Exception {
317 super.insertRepetition( "ROL2", structure, rep);
318 }
319
320
321 /**
322 * Inserts a specific repetition of ROL2 (Role)
323 * @see AbstractGroup\#insertRepetition(Structure, int)
324 */
325 public ROL insertROL2(int rep) throws HL7Exception {
326 return (ROL)super.insertRepetition("ROL2", rep);
327 }
328
329
330 /**
331 * Removes a specific repetition of ROL2 (Role)
332 * @see AbstractGroup\#removeRepetition(String, int)
333 */
334 public ROL removeROL2(int rep) throws HL7Exception {
335 return (ROL)super.removeRepetition("ROL2", rep);
336 }
337
338
339
340 }
341