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 PPR_PC1 message structure (see chapter 12). This structure contains the 
021     * following elements: </p>
022     * <ul>
023                     * <li>1: MSH (Message Header) <b> </b></li>
024                     * <li>2: PID (Patient identification) <b> </b></li>
025                     * <li>3: PPR_PC1_PATIENT_VISIT (a Group object) <b>optional </b></li>
026                     * <li>4: PPR_PC1_PROBLEM (a Group object) <b> repeating</b></li>
027     * </ul>
028     */
029    public class PPR_PC1 extends AbstractMessage  {
030    
031        /**
032         * Creates a new PPR_PC1 message with DefaultModelClassFactory. 
033         */ 
034        public PPR_PC1() { 
035           this(new DefaultModelClassFactory());
036        }
037    
038        /** 
039         * Creates a new PPR_PC1 message with custom ModelClassFactory.
040         */
041        public PPR_PC1(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(PID.class, true, false);
050                              this.add(PPR_PC1_PATIENT_VISIT.class, false, false);
051                              this.add(PPR_PC1_PROBLEM.class, true, true);
052           } catch(HL7Exception e) {
053              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating PPR_PC1 - 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         * PID (Patient identification) - creates it if necessary
087         */
088        public PID getPID() { 
089           PID ret = null;
090           try {
091              ret = (PID)this.get("PID");
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         * PATIENT_VISIT (a Group object) - creates it if necessary
105         */
106        public PPR_PC1_PATIENT_VISIT getPATIENT_VISIT() { 
107           PPR_PC1_PATIENT_VISIT ret = null;
108           try {
109              ret = (PPR_PC1_PATIENT_VISIT)this.get("PATIENT_VISIT");
110           } catch(HL7Exception e) {
111              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
112              throw new RuntimeException(e);
113           }
114           return ret;
115        }
116    
117    
118    
119    
120        /**
121         * Returns
122         * the first repetition of 
123         * PROBLEM (a Group object) - creates it if necessary
124         */
125        public PPR_PC1_PROBLEM getPROBLEM() { 
126           PPR_PC1_PROBLEM ret = null;
127           try {
128              ret = (PPR_PC1_PROBLEM)this.get("PROBLEM");
129           } catch(HL7Exception e) {
130              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
131              throw new RuntimeException(e);
132           }
133           return ret;
134        }
135    
136    
137        /**
138         * Returns a specific repetition of
139         * PROBLEM (a Group object) - creates it if necessary
140         *
141         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
142         * @throws HL7Exception if the repetition requested is more than one 
143         *     greater than the number of existing repetitions.
144         */
145        public PPR_PC1_PROBLEM getPROBLEM(int rep) { 
146           PPR_PC1_PROBLEM ret = null;
147           try {
148              ret = (PPR_PC1_PROBLEM)this.get("PROBLEM", rep);
149           } catch(HL7Exception e) {
150              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
151              throw new RuntimeException(e);
152           }
153           return ret;
154        }
155    
156        /** 
157         * Returns the number of existing repetitions of PROBLEM 
158         */ 
159        public int getPROBLEMReps() { 
160            int reps = -1; 
161            try { 
162                reps = this.getAll("PROBLEM").length; 
163            } catch (HL7Exception e) { 
164                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
165                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
166                throw new RuntimeException(message);
167            } 
168            return reps; 
169        } 
170    
171        /**
172         * Inserts a specific repetition of PROBLEM (a Group object)
173         * @see AbstractGroup\#insertRepetition(Structure, int) 
174         */
175        public void insertPROBLEM(PPR_PC1_PROBLEM structure, int rep) throws HL7Exception { 
176           super.insertRepetition( "PROBLEM", structure, rep);
177        }
178    
179    
180        /**
181         * Inserts a specific repetition of PROBLEM (a Group object)
182         * @see AbstractGroup\#insertRepetition(Structure, int) 
183         */
184        public PPR_PC1_PROBLEM insertPROBLEM(int rep) throws HL7Exception { 
185           return (PPR_PC1_PROBLEM)super.insertRepetition("PROBLEM", rep);
186        }
187    
188    
189        /**
190         * Removes a specific repetition of PROBLEM (a Group object)
191         * @see AbstractGroup\#removeRepetition(String, int) 
192         */
193        public PPR_PC1_PROBLEM removePROBLEM(int rep) throws HL7Exception { 
194           return (PPR_PC1_PROBLEM)super.removeRepetition("PROBLEM", rep);
195        }
196    
197    
198    
199    }
200