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