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.segment;
009    
010    // import ca.uhn.hl7v2.model.v24.group.*;
011    import ca.uhn.hl7v2.model.v24.datatype.*;
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.Type;
019    import ca.uhn.hl7v2.model.AbstractSegment;
020    import ca.uhn.hl7v2.model.Varies;
021    
022    /**
023     *<p>Represents an HL7 RGS message segment (Resource Group). 
024     * This segment has the following fields:</p>
025     * <ul>
026         * <li>RGS-1: Set ID - RGS (SI) <b> </b>
027         * <li>RGS-2: Segment Action Code (ID) <b>optional </b>
028         * <li>RGS-3: Resource Group ID (CE) <b>optional </b>
029     * </ul>
030     */
031    public class RGS extends AbstractSegment {
032    
033        /** 
034         * Creates a new RGS segment
035         */
036        public RGS(Group parent, ModelClassFactory factory) {
037           super(parent, factory);
038           init(factory);
039        }
040    
041        private void init(ModelClassFactory factory) {
042           try {
043                                      this.add(SI.class, true, 1, 4, new Object[]{ getMessage(), new Integer(0) }, "Set ID - RGS");
044                                      this.add(ID.class, false, 1, 3, new Object[]{ getMessage() }, "Segment Action Code");
045                                      this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(0) }, "Resource Group ID");
046           } catch(HL7Exception e) {
047              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating RGS - this is probably a bug in the source code generator.", e);
048           }
049        }
050    
051    
052    
053        /**
054         * Returns
055         * RGS-1: "Set ID - RGS" - creates it if necessary
056         */
057        public SI getSetIDRGS() { 
058            SI ret = null;
059            try {
060                Type t = this.getField(1, 0);
061                ret = (SI)t;
062            } catch (ClassCastException cce) {
063                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
064                throw new RuntimeException(cce);
065            } catch (HL7Exception he) {
066                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
067                throw new RuntimeException(he);
068            }
069            return ret;
070        }
071    
072    
073        /**
074         * Returns
075         * RGS-1: "Set ID - RGS" - creates it if necessary
076         */
077        public SI getRgs1_SetIDRGS() { 
078            SI ret = null;
079            try {
080                Type t = this.getField(1, 0);
081                ret = (SI)t;
082            } catch (ClassCastException cce) {
083                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
084                throw new RuntimeException(cce);
085            } catch (HL7Exception he) {
086                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
087                throw new RuntimeException(he);
088            }
089            return ret;
090        }
091    
092    
093    
094        /**
095         * Returns
096         * RGS-2: "Segment Action Code" - creates it if necessary
097         */
098        public ID getSegmentActionCode() { 
099            ID ret = null;
100            try {
101                Type t = this.getField(2, 0);
102                ret = (ID)t;
103            } catch (ClassCastException cce) {
104                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
105                throw new RuntimeException(cce);
106            } catch (HL7Exception he) {
107                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
108                throw new RuntimeException(he);
109            }
110            return ret;
111        }
112    
113    
114        /**
115         * Returns
116         * RGS-2: "Segment Action Code" - creates it if necessary
117         */
118        public ID getRgs2_SegmentActionCode() { 
119            ID ret = null;
120            try {
121                Type t = this.getField(2, 0);
122                ret = (ID)t;
123            } catch (ClassCastException cce) {
124                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
125                throw new RuntimeException(cce);
126            } catch (HL7Exception he) {
127                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
128                throw new RuntimeException(he);
129            }
130            return ret;
131        }
132    
133    
134    
135        /**
136         * Returns
137         * RGS-3: "Resource Group ID" - creates it if necessary
138         */
139        public CE getResourceGroupID() { 
140            CE ret = null;
141            try {
142                Type t = this.getField(3, 0);
143                ret = (CE)t;
144            } catch (ClassCastException cce) {
145                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
146                throw new RuntimeException(cce);
147            } catch (HL7Exception he) {
148                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
149                throw new RuntimeException(he);
150            }
151            return ret;
152        }
153    
154    
155        /**
156         * Returns
157         * RGS-3: "Resource Group ID" - creates it if necessary
158         */
159        public CE getRgs3_ResourceGroupID() { 
160            CE ret = null;
161            try {
162                Type t = this.getField(3, 0);
163                ret = (CE)t;
164            } catch (ClassCastException cce) {
165                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
166                throw new RuntimeException(cce);
167            } catch (HL7Exception he) {
168                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
169                throw new RuntimeException(he);
170            }
171            return ret;
172        }
173    
174    
175    
176    
177    
178        /** {@inheritDoc} */   
179        protected Type createNewTypeWithoutReflection(int field) {
180           switch (field) {
181              case 0: return new SI(getMessage());
182              case 1: return new ID(getMessage(), new Integer( 206 ));
183              case 2: return new CE(getMessage());
184              default: return null;
185           }
186       }
187    
188    
189    }
190