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