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 BAR_P05 message structure (see chapter 6). 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: BAR_P05_VISIT (a Group object) <b> repeating</b></li>
029 * </ul>
030 */
031 public class BAR_P05 extends AbstractMessage {
032
033 /**
034 * Creates a new BAR_P05 message with DefaultModelClassFactory.
035 */
036 public BAR_P05() {
037 this(new DefaultModelClassFactory());
038 }
039
040 /**
041 * Creates a new BAR_P05 message with custom ModelClassFactory.
042 */
043 public BAR_P05(ModelClassFactory factory) {
044 super(factory);
045 init(factory);
046 }
047
048 private void init(ModelClassFactory factory) {
049 try {
050 this.add(MSH.class, true, false);
051 this.add(EVN.class, true, false);
052 this.add(PID.class, true, false);
053 this.add(PD1.class, false, false);
054 this.add(ROL.class, false, true);
055 this.add(BAR_P05_VISIT.class, true, true);
056 } catch(HL7Exception e) {
057 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating BAR_P05 - this is probably a bug in the source code generator.", e);
058 }
059 }
060
061 /**
062 * Returns "2.4"
063 */
064 public String getVersion() {
065 return "2.4";
066 }
067
068
069
070 /**
071 * Returns
072 * MSH (Message Header) - creates it if necessary
073 */
074 public MSH getMSH() {
075 MSH ret = null;
076 try {
077 ret = (MSH)this.get("MSH");
078 } catch(HL7Exception e) {
079 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
080 throw new RuntimeException(e);
081 }
082 return ret;
083 }
084
085
086
087
088 /**
089 * Returns
090 * EVN (Event Type) - creates it if necessary
091 */
092 public EVN getEVN() {
093 EVN ret = null;
094 try {
095 ret = (EVN)this.get("EVN");
096 } catch(HL7Exception e) {
097 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
098 throw new RuntimeException(e);
099 }
100 return ret;
101 }
102
103
104
105
106 /**
107 * Returns
108 * PID (Patient identification) - creates it if necessary
109 */
110 public PID getPID() {
111 PID ret = null;
112 try {
113 ret = (PID)this.get("PID");
114 } catch(HL7Exception e) {
115 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
116 throw new RuntimeException(e);
117 }
118 return ret;
119 }
120
121
122
123
124 /**
125 * Returns
126 * PD1 (patient additional demographic) - creates it if necessary
127 */
128 public PD1 getPD1() {
129 PD1 ret = null;
130 try {
131 ret = (PD1)this.get("PD1");
132 } catch(HL7Exception e) {
133 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
134 throw new RuntimeException(e);
135 }
136 return ret;
137 }
138
139
140
141
142 /**
143 * Returns
144 * the first repetition of
145 * ROL (Role) - creates it if necessary
146 */
147 public ROL getROL() {
148 ROL ret = null;
149 try {
150 ret = (ROL)this.get("ROL");
151 } catch(HL7Exception e) {
152 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
153 throw new RuntimeException(e);
154 }
155 return ret;
156 }
157
158
159 /**
160 * Returns a specific repetition of
161 * ROL (Role) - creates it if necessary
162 *
163 * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
164 * @throws HL7Exception if the repetition requested is more than one
165 * greater than the number of existing repetitions.
166 */
167 public ROL getROL(int rep) {
168 ROL ret = null;
169 try {
170 ret = (ROL)this.get("ROL", rep);
171 } catch(HL7Exception e) {
172 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
173 throw new RuntimeException(e);
174 }
175 return ret;
176 }
177
178 /**
179 * Returns the number of existing repetitions of ROL
180 */
181 public int getROLReps() {
182 int reps = -1;
183 try {
184 reps = this.getAll("ROL").length;
185 } catch (HL7Exception e) {
186 String message = "Unexpected error accessing data - this is probably a bug in the source code generator.";
187 HapiLogFactory.getHapiLog(this.getClass()).error(message, e);
188 throw new RuntimeException(message);
189 }
190 return reps;
191 }
192
193 /**
194 * Inserts a specific repetition of ROL (Role)
195 * @see AbstractGroup\#insertRepetition(Structure, int)
196 */
197 public void insertROL(ROL structure, int rep) throws HL7Exception {
198 super.insertRepetition( "ROL", structure, rep);
199 }
200
201
202 /**
203 * Inserts a specific repetition of ROL (Role)
204 * @see AbstractGroup\#insertRepetition(Structure, int)
205 */
206 public ROL insertROL(int rep) throws HL7Exception {
207 return (ROL)super.insertRepetition("ROL", rep);
208 }
209
210
211 /**
212 * Removes a specific repetition of ROL (Role)
213 * @see AbstractGroup\#removeRepetition(String, int)
214 */
215 public ROL removeROL(int rep) throws HL7Exception {
216 return (ROL)super.removeRepetition("ROL", rep);
217 }
218
219
220
221 /**
222 * Returns
223 * the first repetition of
224 * VISIT (a Group object) - creates it if necessary
225 */
226 public BAR_P05_VISIT getVISIT() {
227 BAR_P05_VISIT ret = null;
228 try {
229 ret = (BAR_P05_VISIT)this.get("VISIT");
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 /**
239 * Returns a specific repetition of
240 * VISIT (a Group object) - creates it if necessary
241 *
242 * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
243 * @throws HL7Exception if the repetition requested is more than one
244 * greater than the number of existing repetitions.
245 */
246 public BAR_P05_VISIT getVISIT(int rep) {
247 BAR_P05_VISIT ret = null;
248 try {
249 ret = (BAR_P05_VISIT)this.get("VISIT", rep);
250 } catch(HL7Exception e) {
251 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
252 throw new RuntimeException(e);
253 }
254 return ret;
255 }
256
257 /**
258 * Returns the number of existing repetitions of VISIT
259 */
260 public int getVISITReps() {
261 int reps = -1;
262 try {
263 reps = this.getAll("VISIT").length;
264 } catch (HL7Exception e) {
265 String message = "Unexpected error accessing data - this is probably a bug in the source code generator.";
266 HapiLogFactory.getHapiLog(this.getClass()).error(message, e);
267 throw new RuntimeException(message);
268 }
269 return reps;
270 }
271
272 /**
273 * Inserts a specific repetition of VISIT (a Group object)
274 * @see AbstractGroup\#insertRepetition(Structure, int)
275 */
276 public void insertVISIT(BAR_P05_VISIT structure, int rep) throws HL7Exception {
277 super.insertRepetition( "VISIT", structure, rep);
278 }
279
280
281 /**
282 * Inserts a specific repetition of VISIT (a Group object)
283 * @see AbstractGroup\#insertRepetition(Structure, int)
284 */
285 public BAR_P05_VISIT insertVISIT(int rep) throws HL7Exception {
286 return (BAR_P05_VISIT)super.insertRepetition("VISIT", rep);
287 }
288
289
290 /**
291 * Removes a specific repetition of VISIT (a Group object)
292 * @see AbstractGroup\#removeRepetition(String, int)
293 */
294 public BAR_P05_VISIT removeVISIT(int rep) throws HL7Exception {
295 return (BAR_P05_VISIT)super.removeRepetition("VISIT", rep);
296 }
297
298
299
300 }
301