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 PPP_PCB_PROBLEM_ROLE 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: ROL (Role) <b> </b></li>
028                     * <li>2: VAR (Variance) <b>optional repeating</b></li>
029     * </ul>
030     */
031    public class PPP_PCB_PROBLEM_ROLE extends AbstractGroup {
032    
033        /** 
034         * Creates a new PPP_PCB_PROBLEM_ROLE group
035         */
036        public PPP_PCB_PROBLEM_ROLE(Group parent, ModelClassFactory factory) {
037           super(parent, factory);
038           init(factory);
039        }
040    
041        private void init(ModelClassFactory factory) {
042           try {
043                              this.add(ROL.class, true, false);
044                              this.add(VAR.class, false, true);
045           } catch(HL7Exception e) {
046              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating PPP_PCB_PROBLEM_ROLE - 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         * ROL (Role) - creates it if necessary
062         */
063        public ROL getROL() { 
064           ROL ret = null;
065           try {
066              ret = (ROL)this.get("ROL");
067           } catch(HL7Exception e) {
068              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
069              throw new RuntimeException(e);
070           }
071           return ret;
072        }
073    
074    
075    
076    
077        /**
078         * Returns
079         * the first repetition of 
080         * VAR (Variance) - creates it if necessary
081         */
082        public VAR getVAR() { 
083           VAR ret = null;
084           try {
085              ret = (VAR)this.get("VAR");
086           } catch(HL7Exception e) {
087              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
088              throw new RuntimeException(e);
089           }
090           return ret;
091        }
092    
093    
094        /**
095         * Returns a specific repetition of
096         * VAR (Variance) - creates it if necessary
097         *
098         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
099         * @throws HL7Exception if the repetition requested is more than one 
100         *     greater than the number of existing repetitions.
101         */
102        public VAR getVAR(int rep) { 
103           VAR ret = null;
104           try {
105              ret = (VAR)this.get("VAR", rep);
106           } catch(HL7Exception e) {
107              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
108              throw new RuntimeException(e);
109           }
110           return ret;
111        }
112    
113        /** 
114         * Returns the number of existing repetitions of VAR 
115         */ 
116        public int getVARReps() { 
117            int reps = -1; 
118            try { 
119                reps = this.getAll("VAR").length; 
120            } catch (HL7Exception e) { 
121                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
122                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
123                throw new RuntimeException(message);
124            } 
125            return reps; 
126        } 
127    
128        /**
129         * Inserts a specific repetition of VAR (Variance)
130         * @see AbstractGroup#insertRepetition(Structure, int) 
131         */
132        public void insertVAR(VAR structure, int rep) throws HL7Exception { 
133           super.insertRepetition("VAR", structure, rep);
134        }
135    
136    
137        /**
138         * Inserts a specific repetition of VAR (Variance)
139         * @see AbstractGroup#insertRepetition(Structure, int) 
140         */
141        public VAR insertVAR(int rep) throws HL7Exception { 
142           return (VAR)super.insertRepetition("VAR", rep);
143        }
144    
145    
146        /**
147         * Removes a specific repetition of VAR (Variance)
148         * @see AbstractGroup#removeRepetition(String, int) 
149         */
150        public VAR removeVAR(int rep) throws HL7Exception { 
151           return (VAR)super.removeRepetition("VAR", rep);
152        }
153    
154    
155    
156    }
157