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.segment;
009
010 // import ca.uhn.hl7v2.model.v24.group.*;
011 import ca.uhn.hl7v2.model.v24.datatype.*;
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.Type;
019 import ca.uhn.hl7v2.model.AbstractSegment;
020 import ca.uhn.hl7v2.model.Varies;
021
022 /**
023 *<p>Represents an HL7 AFF message segment (Professional Affiliation).
024 * This segment has the following fields:</p>
025 * <ul>
026 * <li>AFF-1: Set ID - AFF (SI) <b> </b>
027 * <li>AFF-2: Professional Organization (XON) <b> </b>
028 * <li>AFF-3: Professional Organization Address (XAD) <b>optional </b>
029 * <li>AFF-4: Professional Organization Affiliation Date Range (DR) <b>optional repeating</b>
030 * <li>AFF-5: Professional Affiliation Additional Information (ST) <b>optional </b>
031 * </ul>
032 */
033 public class AFF extends AbstractSegment {
034
035 /**
036 * Creates a new AFF segment
037 */
038 public AFF(Group parent, ModelClassFactory factory) {
039 super(parent, factory);
040 init(factory);
041 }
042
043 private void init(ModelClassFactory factory) {
044 try {
045 this.add(SI.class, true, 1, 60, new Object[]{ getMessage(), new Integer(0) }, "Set ID - AFF");
046 this.add(XON.class, true, 1, 250, new Object[]{ getMessage(), new Integer(0) }, "Professional Organization");
047 this.add(XAD.class, false, 1, 250, new Object[]{ getMessage(), new Integer(0) }, "Professional Organization Address");
048 this.add(DR.class, false, 0, 52, new Object[]{ getMessage(), new Integer(0) }, "Professional Organization Affiliation Date Range");
049 this.add(ST.class, false, 1, 60, new Object[]{ getMessage(), new Integer(0) }, "Professional Affiliation Additional Information");
050 } catch(HL7Exception e) {
051 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating AFF - this is probably a bug in the source code generator.", e);
052 }
053 }
054
055
056
057 /**
058 * Returns
059 * AFF-1: "Set ID - AFF" - creates it if necessary
060 */
061 public SI getSetIDAFF() {
062 SI ret = null;
063 try {
064 Type t = this.getField(1, 0);
065 ret = (SI)t;
066 } catch (ClassCastException cce) {
067 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
068 throw new RuntimeException(cce);
069 } catch (HL7Exception he) {
070 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
071 throw new RuntimeException(he);
072 }
073 return ret;
074 }
075
076
077 /**
078 * Returns
079 * AFF-1: "Set ID - AFF" - creates it if necessary
080 */
081 public SI getAff1_SetIDAFF() {
082 SI ret = null;
083 try {
084 Type t = this.getField(1, 0);
085 ret = (SI)t;
086 } catch (ClassCastException cce) {
087 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
088 throw new RuntimeException(cce);
089 } catch (HL7Exception he) {
090 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
091 throw new RuntimeException(he);
092 }
093 return ret;
094 }
095
096
097
098 /**
099 * Returns
100 * AFF-2: "Professional Organization" - creates it if necessary
101 */
102 public XON getProfessionalOrganization() {
103 XON ret = null;
104 try {
105 Type t = this.getField(2, 0);
106 ret = (XON)t;
107 } catch (ClassCastException cce) {
108 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
109 throw new RuntimeException(cce);
110 } catch (HL7Exception he) {
111 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
112 throw new RuntimeException(he);
113 }
114 return ret;
115 }
116
117
118 /**
119 * Returns
120 * AFF-2: "Professional Organization" - creates it if necessary
121 */
122 public XON getAff2_ProfessionalOrganization() {
123 XON ret = null;
124 try {
125 Type t = this.getField(2, 0);
126 ret = (XON)t;
127 } catch (ClassCastException cce) {
128 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
129 throw new RuntimeException(cce);
130 } catch (HL7Exception he) {
131 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
132 throw new RuntimeException(he);
133 }
134 return ret;
135 }
136
137
138
139 /**
140 * Returns
141 * AFF-3: "Professional Organization Address" - creates it if necessary
142 */
143 public XAD getProfessionalOrganizationAddress() {
144 XAD ret = null;
145 try {
146 Type t = this.getField(3, 0);
147 ret = (XAD)t;
148 } catch (ClassCastException cce) {
149 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
150 throw new RuntimeException(cce);
151 } catch (HL7Exception he) {
152 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
153 throw new RuntimeException(he);
154 }
155 return ret;
156 }
157
158
159 /**
160 * Returns
161 * AFF-3: "Professional Organization Address" - creates it if necessary
162 */
163 public XAD getAff3_ProfessionalOrganizationAddress() {
164 XAD ret = null;
165 try {
166 Type t = this.getField(3, 0);
167 ret = (XAD)t;
168 } catch (ClassCastException cce) {
169 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
170 throw new RuntimeException(cce);
171 } catch (HL7Exception he) {
172 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
173 throw new RuntimeException(he);
174 }
175 return ret;
176 }
177
178
179 /**
180 * Returns all repetitions of Professional Organization Affiliation Date Range (AFF-4).
181 */
182 public DR[] getProfessionalOrganizationAffiliationDateRange() {
183 DR[] ret = null;
184 try {
185 Type[] t = this.getField(4);
186 ret = new DR[t.length];
187 for (int i = 0; i < ret.length; i++) {
188 ret[i] = (DR)t[i];
189 }
190 } catch (ClassCastException cce) {
191 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
192 throw new RuntimeException(cce);
193 } catch (HL7Exception he) {
194 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
195 throw new RuntimeException(he);
196 }
197 return ret;
198 }
199
200
201 /**
202 * Returns a count of the current number of repetitions of Professional Organization Affiliation Date Range (AFF-4).
203 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
204 * it will return zero.
205 */
206 public int getProfessionalOrganizationAffiliationDateRangeReps() {
207 DR[] ret = null;
208 try {
209 Type[] t = this.getField(4);
210 return t.length;
211 } catch (ClassCastException cce) {
212 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
213 throw new RuntimeException(cce);
214 } catch (HL7Exception he) {
215 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
216 throw new RuntimeException(he);
217 }
218 }
219
220
221 /**
222 * Returns a specific repetition of
223 * AFF-4: "Professional Organization Affiliation Date Range" - creates it if necessary
224 *
225 * @param rep The repetition index (0-indexed)
226 */
227 public DR getProfessionalOrganizationAffiliationDateRange(int rep) {
228 DR ret = null;
229 try {
230 Type t = this.getField(4, rep);
231 ret = (DR)t;
232 } catch (ClassCastException cce) {
233 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
234 throw new RuntimeException(cce);
235 } catch (HL7Exception he) {
236 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
237 throw new RuntimeException(he);
238 }
239 return ret;
240 }
241
242 /**
243 * Returns a specific repetition of
244 * AFF-4: "Professional Organization Affiliation Date Range" - creates it if necessary
245 *
246 * @param rep The repetition index (0-indexed)
247 */
248 public DR getAff4_ProfessionalOrganizationAffiliationDateRange(int rep) {
249 DR ret = null;
250 try {
251 Type t = this.getField(4, rep);
252 ret = (DR)t;
253 } catch (ClassCastException cce) {
254 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
255 throw new RuntimeException(cce);
256 } catch (HL7Exception he) {
257 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
258 throw new RuntimeException(he);
259 }
260 return ret;
261 }
262
263
264 /**
265 * Returns a count of the current number of repetitions of Professional Organization Affiliation Date Range (AFF-4).
266 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
267 * it will return zero.
268 */
269 public int getAff4_ProfessionalOrganizationAffiliationDateRangeReps() {
270 DR[] ret = null;
271 try {
272 Type[] t = this.getField(4);
273 return t.length;
274 } catch (ClassCastException cce) {
275 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
276 throw new RuntimeException(cce);
277 } catch (HL7Exception he) {
278 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
279 throw new RuntimeException(he);
280 }
281 }
282
283
284
285 /**
286 * Inserts a repetition of
287 * AFF-4: "Professional Organization Affiliation Date Range" at a specific index
288 *
289 * @param rep The repetition index (0-indexed)
290 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
291 */
292 public DR insertProfessionalOrganizationAffiliationDateRange(int rep) throws HL7Exception {
293 return (DR) super.insertRepetition(4, rep);
294 }
295
296
297
298 /**
299 * Inserts a repetition of
300 * AFF-4: "Professional Organization Affiliation Date Range" at a specific index
301 *
302 * @param rep The repetition index (0-indexed)
303 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
304 */
305 public DR insertAff4_ProfessionalOrganizationAffiliationDateRange(int rep) throws HL7Exception {
306 return (DR) super.insertRepetition(4, rep);
307 }
308
309
310 /**
311 * Removes a repetition of
312 * AFF-4: "Professional Organization Affiliation Date Range" at a specific index
313 *
314 * @param rep The repetition index (0-indexed)
315 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
316 */
317 public DR removeProfessionalOrganizationAffiliationDateRange(int rep) throws HL7Exception {
318 return (DR) super.removeRepetition(4, rep);
319 }
320
321
322 /**
323 * Removes a repetition of
324 * AFF-4: "Professional Organization Affiliation Date Range" at a specific index
325 *
326 * @param rep The repetition index (0-indexed)
327 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
328 */
329 public DR removeAff4_ProfessionalOrganizationAffiliationDateRange(int rep) throws HL7Exception {
330 return (DR) super.removeRepetition(4, rep);
331 }
332
333
334
335
336 /**
337 * Returns
338 * AFF-5: "Professional Affiliation Additional Information" - creates it if necessary
339 */
340 public ST getProfessionalAffiliationAdditionalInformation() {
341 ST ret = null;
342 try {
343 Type t = this.getField(5, 0);
344 ret = (ST)t;
345 } catch (ClassCastException cce) {
346 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
347 throw new RuntimeException(cce);
348 } catch (HL7Exception he) {
349 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
350 throw new RuntimeException(he);
351 }
352 return ret;
353 }
354
355
356 /**
357 * Returns
358 * AFF-5: "Professional Affiliation Additional Information" - creates it if necessary
359 */
360 public ST getAff5_ProfessionalAffiliationAdditionalInformation() {
361 ST ret = null;
362 try {
363 Type t = this.getField(5, 0);
364 ret = (ST)t;
365 } catch (ClassCastException cce) {
366 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
367 throw new RuntimeException(cce);
368 } catch (HL7Exception he) {
369 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
370 throw new RuntimeException(he);
371 }
372 return ret;
373 }
374
375
376
377
378
379 /** {@inheritDoc} */
380 protected Type createNewTypeWithoutReflection(int field) {
381 switch (field) {
382 case 0: return new SI(getMessage());
383 case 1: return new XON(getMessage());
384 case 2: return new XAD(getMessage());
385 case 3: return new DR(getMessage());
386 case 4: return new ST(getMessage());
387 default: return null;
388 }
389 }
390
391
392 }
393