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 SUR_P09_FACILITY 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: FAC (Facility) <b> </b></li>
028                     * <li>2: SUR_P09_PRODUCT (a Group object) <b> repeating</b></li>
029                     * <li>3: PSH (Product Summary Header) <b> </b></li>
030                     * <li>4: SUR_P09_FACILITY_DETAIL (a Group object) <b> repeating</b></li>
031     * </ul>
032     */
033    public class SUR_P09_FACILITY extends AbstractGroup {
034    
035        /** 
036         * Creates a new SUR_P09_FACILITY group
037         */
038        public SUR_P09_FACILITY(Group parent, ModelClassFactory factory) {
039           super(parent, factory);
040           init(factory);
041        }
042    
043        private void init(ModelClassFactory factory) {
044           try {
045                              this.add(FAC.class, true, false);
046                              this.add(SUR_P09_PRODUCT.class, true, true);
047                              this.add(PSH.class, true, false);
048                              this.add(SUR_P09_FACILITY_DETAIL.class, true, true);
049           } catch(HL7Exception e) {
050              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating SUR_P09_FACILITY - 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         * FAC (Facility) - creates it if necessary
066         */
067        public FAC getFAC() { 
068           FAC ret = null;
069           try {
070              ret = (FAC)this.get("FAC");
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         * the first repetition of 
084         * PRODUCT (a Group object) - creates it if necessary
085         */
086        public SUR_P09_PRODUCT getPRODUCT() { 
087           SUR_P09_PRODUCT ret = null;
088           try {
089              ret = (SUR_P09_PRODUCT)this.get("PRODUCT");
090           } catch(HL7Exception e) {
091              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
092              throw new RuntimeException(e);
093           }
094           return ret;
095        }
096    
097    
098        /**
099         * Returns a specific repetition of
100         * PRODUCT (a Group object) - creates it if necessary
101         *
102         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
103         * @throws HL7Exception if the repetition requested is more than one 
104         *     greater than the number of existing repetitions.
105         */
106        public SUR_P09_PRODUCT getPRODUCT(int rep) { 
107           SUR_P09_PRODUCT ret = null;
108           try {
109              ret = (SUR_P09_PRODUCT)this.get("PRODUCT", rep);
110           } catch(HL7Exception e) {
111              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
112              throw new RuntimeException(e);
113           }
114           return ret;
115        }
116    
117        /** 
118         * Returns the number of existing repetitions of PRODUCT 
119         */ 
120        public int getPRODUCTReps() { 
121            int reps = -1; 
122            try { 
123                reps = this.getAll("PRODUCT").length; 
124            } catch (HL7Exception e) { 
125                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
126                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
127                throw new RuntimeException(message);
128            } 
129            return reps; 
130        } 
131    
132        /**
133         * Inserts a specific repetition of PRODUCT (a Group object)
134         * @see AbstractGroup#insertRepetition(Structure, int) 
135         */
136        public void insertPRODUCT(SUR_P09_PRODUCT structure, int rep) throws HL7Exception { 
137           super.insertRepetition("PRODUCT", structure, rep);
138        }
139    
140    
141        /**
142         * Inserts a specific repetition of PRODUCT (a Group object)
143         * @see AbstractGroup#insertRepetition(Structure, int) 
144         */
145        public SUR_P09_PRODUCT insertPRODUCT(int rep) throws HL7Exception { 
146           return (SUR_P09_PRODUCT)super.insertRepetition("PRODUCT", rep);
147        }
148    
149    
150        /**
151         * Removes a specific repetition of PRODUCT (a Group object)
152         * @see AbstractGroup#removeRepetition(String, int) 
153         */
154        public SUR_P09_PRODUCT removePRODUCT(int rep) throws HL7Exception { 
155           return (SUR_P09_PRODUCT)super.removeRepetition("PRODUCT", rep);
156        }
157    
158    
159    
160        /**
161         * Returns
162         * PSH (Product Summary Header) - creates it if necessary
163         */
164        public PSH getPSH() { 
165           PSH ret = null;
166           try {
167              ret = (PSH)this.get("PSH");
168           } catch(HL7Exception e) {
169              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
170              throw new RuntimeException(e);
171           }
172           return ret;
173        }
174    
175    
176    
177    
178        /**
179         * Returns
180         * the first repetition of 
181         * FACILITY_DETAIL (a Group object) - creates it if necessary
182         */
183        public SUR_P09_FACILITY_DETAIL getFACILITY_DETAIL() { 
184           SUR_P09_FACILITY_DETAIL ret = null;
185           try {
186              ret = (SUR_P09_FACILITY_DETAIL)this.get("FACILITY_DETAIL");
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         * FACILITY_DETAIL (a Group object) - 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 SUR_P09_FACILITY_DETAIL getFACILITY_DETAIL(int rep) { 
204           SUR_P09_FACILITY_DETAIL ret = null;
205           try {
206              ret = (SUR_P09_FACILITY_DETAIL)this.get("FACILITY_DETAIL", 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 FACILITY_DETAIL 
216         */ 
217        public int getFACILITY_DETAILReps() { 
218            int reps = -1; 
219            try { 
220                reps = this.getAll("FACILITY_DETAIL").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 FACILITY_DETAIL (a Group object)
231         * @see AbstractGroup#insertRepetition(Structure, int) 
232         */
233        public void insertFACILITY_DETAIL(SUR_P09_FACILITY_DETAIL structure, int rep) throws HL7Exception { 
234           super.insertRepetition("FACILITY_DETAIL", structure, rep);
235        }
236    
237    
238        /**
239         * Inserts a specific repetition of FACILITY_DETAIL (a Group object)
240         * @see AbstractGroup#insertRepetition(Structure, int) 
241         */
242        public SUR_P09_FACILITY_DETAIL insertFACILITY_DETAIL(int rep) throws HL7Exception { 
243           return (SUR_P09_FACILITY_DETAIL)super.insertRepetition("FACILITY_DETAIL", rep);
244        }
245    
246    
247        /**
248         * Removes a specific repetition of FACILITY_DETAIL (a Group object)
249         * @see AbstractGroup#removeRepetition(String, int) 
250         */
251        public SUR_P09_FACILITY_DETAIL removeFACILITY_DETAIL(int rep) throws HL7Exception { 
252           return (SUR_P09_FACILITY_DETAIL)super.removeRepetition("FACILITY_DETAIL", rep);
253        }
254    
255    
256    
257    }
258