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