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 EAR_U08 message structure (see chapter 13). This structure contains the 
021     * following elements: </p>
022     * <ul>
023                     * <li>1: MSH (Message Header) <b> </b></li>
024                     * <li>2: EQU (Equipment Detail) <b> </b></li>
025                     * <li>3: EAR_U08_COMMAND_RESPONSE (a Group object) <b> repeating</b></li>
026                     * <li>4: ROL (Role) <b>optional </b></li>
027     * </ul>
028     */
029    public class EAR_U08 extends AbstractMessage  {
030    
031        /**
032         * Creates a new EAR_U08 message with DefaultModelClassFactory. 
033         */ 
034        public EAR_U08() { 
035           this(new DefaultModelClassFactory());
036        }
037    
038        /** 
039         * Creates a new EAR_U08 message with custom ModelClassFactory.
040         */
041        public EAR_U08(ModelClassFactory factory) {
042           super(factory);
043           init(factory);
044        }
045    
046        private void init(ModelClassFactory factory) {
047           try {
048                              this.add(MSH.class, true, false);
049                              this.add(EQU.class, true, false);
050                              this.add(EAR_U08_COMMAND_RESPONSE.class, true, true);
051                              this.add(ROL.class, false, false);
052           } catch(HL7Exception e) {
053              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating EAR_U08 - this is probably a bug in the source code generator.", e);
054           }
055        }
056    
057        /** 
058         * Returns "2.4"
059         */
060        public String getVersion() {
061           return "2.4";
062        }
063    
064    
065    
066        /**
067         * Returns
068         * MSH (Message Header) - creates it if necessary
069         */
070        public MSH getMSH() { 
071           MSH ret = null;
072           try {
073              ret = (MSH)this.get("MSH");
074           } catch(HL7Exception e) {
075              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
076              throw new RuntimeException(e);
077           }
078           return ret;
079        }
080    
081    
082    
083    
084        /**
085         * Returns
086         * EQU (Equipment Detail) - creates it if necessary
087         */
088        public EQU getEQU() { 
089           EQU ret = null;
090           try {
091              ret = (EQU)this.get("EQU");
092           } catch(HL7Exception e) {
093              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
094              throw new RuntimeException(e);
095           }
096           return ret;
097        }
098    
099    
100    
101    
102        /**
103         * Returns
104         * the first repetition of 
105         * COMMAND_RESPONSE (a Group object) - creates it if necessary
106         */
107        public EAR_U08_COMMAND_RESPONSE getCOMMAND_RESPONSE() { 
108           EAR_U08_COMMAND_RESPONSE ret = null;
109           try {
110              ret = (EAR_U08_COMMAND_RESPONSE)this.get("COMMAND_RESPONSE");
111           } catch(HL7Exception e) {
112              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
113              throw new RuntimeException(e);
114           }
115           return ret;
116        }
117    
118    
119        /**
120         * Returns a specific repetition of
121         * COMMAND_RESPONSE (a Group object) - creates it if necessary
122         *
123         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
124         * @throws HL7Exception if the repetition requested is more than one 
125         *     greater than the number of existing repetitions.
126         */
127        public EAR_U08_COMMAND_RESPONSE getCOMMAND_RESPONSE(int rep) { 
128           EAR_U08_COMMAND_RESPONSE ret = null;
129           try {
130              ret = (EAR_U08_COMMAND_RESPONSE)this.get("COMMAND_RESPONSE", rep);
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         * Returns the number of existing repetitions of COMMAND_RESPONSE 
140         */ 
141        public int getCOMMAND_RESPONSEReps() { 
142            int reps = -1; 
143            try { 
144                reps = this.getAll("COMMAND_RESPONSE").length; 
145            } catch (HL7Exception e) { 
146                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
147                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
148                throw new RuntimeException(message);
149            } 
150            return reps; 
151        } 
152    
153        /**
154         * Inserts a specific repetition of COMMAND_RESPONSE (a Group object)
155         * @see AbstractGroup\#insertRepetition(Structure, int) 
156         */
157        public void insertCOMMAND_RESPONSE(EAR_U08_COMMAND_RESPONSE structure, int rep) throws HL7Exception { 
158           super.insertRepetition( "COMMAND_RESPONSE", structure, rep);
159        }
160    
161    
162        /**
163         * Inserts a specific repetition of COMMAND_RESPONSE (a Group object)
164         * @see AbstractGroup\#insertRepetition(Structure, int) 
165         */
166        public EAR_U08_COMMAND_RESPONSE insertCOMMAND_RESPONSE(int rep) throws HL7Exception { 
167           return (EAR_U08_COMMAND_RESPONSE)super.insertRepetition("COMMAND_RESPONSE", rep);
168        }
169    
170    
171        /**
172         * Removes a specific repetition of COMMAND_RESPONSE (a Group object)
173         * @see AbstractGroup\#removeRepetition(String, int) 
174         */
175        public EAR_U08_COMMAND_RESPONSE removeCOMMAND_RESPONSE(int rep) throws HL7Exception { 
176           return (EAR_U08_COMMAND_RESPONSE)super.removeRepetition("COMMAND_RESPONSE", rep);
177        }
178    
179    
180    
181        /**
182         * Returns
183         * ROL (Role) - creates it if necessary
184         */
185        public ROL getROL() { 
186           ROL ret = null;
187           try {
188              ret = (ROL)this.get("ROL");
189           } catch(HL7Exception e) {
190              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
191              throw new RuntimeException(e);
192           }
193           return ret;
194        }
195    
196    
197    
198    
199    }
200