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 MFN_M09_MF_TEST_CAT_DETAIL 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: OM3 (Categorical Service/Test/Observation) <b> </b></li>
028                     * <li>2: OM4 (Observations that Require Specimens) <b>optional repeating</b></li>
029     * </ul>
030     */
031    public class MFN_M09_MF_TEST_CAT_DETAIL extends AbstractGroup {
032    
033        /** 
034         * Creates a new MFN_M09_MF_TEST_CAT_DETAIL group
035         */
036        public MFN_M09_MF_TEST_CAT_DETAIL(Group parent, ModelClassFactory factory) {
037           super(parent, factory);
038           init(factory);
039        }
040    
041        private void init(ModelClassFactory factory) {
042           try {
043                              this.add(OM3.class, true, false);
044                              this.add(OM4.class, false, true);
045           } catch(HL7Exception e) {
046              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating MFN_M09_MF_TEST_CAT_DETAIL - this is probably a bug in the source code generator.", e);
047           }
048        }
049    
050        /** 
051         * Returns "2.4"
052         */
053        public String getVersion() {
054           return "2.4";
055        }
056    
057    
058    
059        /**
060         * Returns
061         * OM3 (Categorical Service/Test/Observation) - creates it if necessary
062         */
063        public OM3 getOM3() { 
064           OM3 ret = null;
065           try {
066              ret = (OM3)this.get("OM3");
067           } catch(HL7Exception e) {
068              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
069              throw new RuntimeException(e);
070           }
071           return ret;
072        }
073    
074    
075    
076    
077        /**
078         * Returns
079         * the first repetition of 
080         * OM4 (Observations that Require Specimens) - creates it if necessary
081         */
082        public OM4 getOM4() { 
083           OM4 ret = null;
084           try {
085              ret = (OM4)this.get("OM4");
086           } catch(HL7Exception e) {
087              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
088              throw new RuntimeException(e);
089           }
090           return ret;
091        }
092    
093    
094        /**
095         * Returns a specific repetition of
096         * OM4 (Observations that Require Specimens) - creates it if necessary
097         *
098         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
099         * @throws HL7Exception if the repetition requested is more than one 
100         *     greater than the number of existing repetitions.
101         */
102        public OM4 getOM4(int rep) { 
103           OM4 ret = null;
104           try {
105              ret = (OM4)this.get("OM4", rep);
106           } catch(HL7Exception e) {
107              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
108              throw new RuntimeException(e);
109           }
110           return ret;
111        }
112    
113        /** 
114         * Returns the number of existing repetitions of OM4 
115         */ 
116        public int getOM4Reps() { 
117            int reps = -1; 
118            try { 
119                reps = this.getAll("OM4").length; 
120            } catch (HL7Exception e) { 
121                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
122                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
123                throw new RuntimeException(message);
124            } 
125            return reps; 
126        } 
127    
128        /**
129         * Inserts a specific repetition of OM4 (Observations that Require Specimens)
130         * @see AbstractGroup#insertRepetition(Structure, int) 
131         */
132        public void insertOM4(OM4 structure, int rep) throws HL7Exception { 
133           super.insertRepetition("OM4", structure, rep);
134        }
135    
136    
137        /**
138         * Inserts a specific repetition of OM4 (Observations that Require Specimens)
139         * @see AbstractGroup#insertRepetition(Structure, int) 
140         */
141        public OM4 insertOM4(int rep) throws HL7Exception { 
142           return (OM4)super.insertRepetition("OM4", rep);
143        }
144    
145    
146        /**
147         * Removes a specific repetition of OM4 (Observations that Require Specimens)
148         * @see AbstractGroup#removeRepetition(String, int) 
149         */
150        public OM4 removeOM4(int rep) throws HL7Exception { 
151           return (OM4)super.removeRepetition("OM4", rep);
152        }
153    
154    
155    
156    }
157