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 RPI_I04_GUARANTOR_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: GT1 (Guarantor) <b>optional repeating</b></li>
028                     * <li>2: RPI_I04_INSURANCE (a Group object) <b> repeating</b></li>
029     * </ul>
030     */
031    public class RPI_I04_GUARANTOR_INSURANCE extends AbstractGroup {
032    
033        /** 
034         * Creates a new RPI_I04_GUARANTOR_INSURANCE group
035         */
036        public RPI_I04_GUARANTOR_INSURANCE(Group parent, ModelClassFactory factory) {
037           super(parent, factory);
038           init(factory);
039        }
040    
041        private void init(ModelClassFactory factory) {
042           try {
043                              this.add(GT1.class, false, true);
044                              this.add(RPI_I04_INSURANCE.class, true, true);
045           } catch(HL7Exception e) {
046              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating RPI_I04_GUARANTOR_INSURANCE - this is probably a bug in the source code generator.", e);
047           }
048        }
049    
050        /** 
051         * Returns "2.4"
052         */
053        public String getVersion() {
054           return "2.4";
055        }
056    
057    
058    
059        /**
060         * Returns
061         * the first repetition of 
062         * GT1 (Guarantor) - creates it if necessary
063         */
064        public GT1 getGT1() { 
065           GT1 ret = null;
066           try {
067              ret = (GT1)this.get("GT1");
068           } catch(HL7Exception e) {
069              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
070              throw new RuntimeException(e);
071           }
072           return ret;
073        }
074    
075    
076        /**
077         * Returns a specific repetition of
078         * GT1 (Guarantor) - creates it if necessary
079         *
080         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
081         * @throws HL7Exception if the repetition requested is more than one 
082         *     greater than the number of existing repetitions.
083         */
084        public GT1 getGT1(int rep) { 
085           GT1 ret = null;
086           try {
087              ret = (GT1)this.get("GT1", rep);
088           } catch(HL7Exception e) {
089              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
090              throw new RuntimeException(e);
091           }
092           return ret;
093        }
094    
095        /** 
096         * Returns the number of existing repetitions of GT1 
097         */ 
098        public int getGT1Reps() { 
099            int reps = -1; 
100            try { 
101                reps = this.getAll("GT1").length; 
102            } catch (HL7Exception e) { 
103                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
104                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
105                throw new RuntimeException(message);
106            } 
107            return reps; 
108        } 
109    
110        /**
111         * Inserts a specific repetition of GT1 (Guarantor)
112         * @see AbstractGroup#insertRepetition(Structure, int) 
113         */
114        public void insertGT1(GT1 structure, int rep) throws HL7Exception { 
115           super.insertRepetition("GT1", structure, rep);
116        }
117    
118    
119        /**
120         * Inserts a specific repetition of GT1 (Guarantor)
121         * @see AbstractGroup#insertRepetition(Structure, int) 
122         */
123        public GT1 insertGT1(int rep) throws HL7Exception { 
124           return (GT1)super.insertRepetition("GT1", rep);
125        }
126    
127    
128        /**
129         * Removes a specific repetition of GT1 (Guarantor)
130         * @see AbstractGroup#removeRepetition(String, int) 
131         */
132        public GT1 removeGT1(int rep) throws HL7Exception { 
133           return (GT1)super.removeRepetition("GT1", rep);
134        }
135    
136    
137    
138        /**
139         * Returns
140         * the first repetition of 
141         * INSURANCE (a Group object) - creates it if necessary
142         */
143        public RPI_I04_INSURANCE getINSURANCE() { 
144           RPI_I04_INSURANCE ret = null;
145           try {
146              ret = (RPI_I04_INSURANCE)this.get("INSURANCE");
147           } catch(HL7Exception e) {
148              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
149              throw new RuntimeException(e);
150           }
151           return ret;
152        }
153    
154    
155        /**
156         * Returns a specific repetition of
157         * INSURANCE (a Group object) - creates it if necessary
158         *
159         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
160         * @throws HL7Exception if the repetition requested is more than one 
161         *     greater than the number of existing repetitions.
162         */
163        public RPI_I04_INSURANCE getINSURANCE(int rep) { 
164           RPI_I04_INSURANCE ret = null;
165           try {
166              ret = (RPI_I04_INSURANCE)this.get("INSURANCE", rep);
167           } catch(HL7Exception e) {
168              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
169              throw new RuntimeException(e);
170           }
171           return ret;
172        }
173    
174        /** 
175         * Returns the number of existing repetitions of INSURANCE 
176         */ 
177        public int getINSURANCEReps() { 
178            int reps = -1; 
179            try { 
180                reps = this.getAll("INSURANCE").length; 
181            } catch (HL7Exception e) { 
182                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
183                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
184                throw new RuntimeException(message);
185            } 
186            return reps; 
187        } 
188    
189        /**
190         * Inserts a specific repetition of INSURANCE (a Group object)
191         * @see AbstractGroup#insertRepetition(Structure, int) 
192         */
193        public void insertINSURANCE(RPI_I04_INSURANCE structure, int rep) throws HL7Exception { 
194           super.insertRepetition("INSURANCE", structure, rep);
195        }
196    
197    
198        /**
199         * Inserts a specific repetition of INSURANCE (a Group object)
200         * @see AbstractGroup#insertRepetition(Structure, int) 
201         */
202        public RPI_I04_INSURANCE insertINSURANCE(int rep) throws HL7Exception { 
203           return (RPI_I04_INSURANCE)super.insertRepetition("INSURANCE", rep);
204        }
205    
206    
207        /**
208         * Removes a specific repetition of INSURANCE (a Group object)
209         * @see AbstractGroup#removeRepetition(String, int) 
210         */
211        public RPI_I04_INSURANCE removeINSURANCE(int rep) throws HL7Exception { 
212           return (RPI_I04_INSURANCE)super.removeRepetition("INSURANCE", rep);
213        }
214    
215    
216    
217    }
218