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