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 SID message segment (Substance Identifier). 
024     * This segment has the following fields:</p>
025     * <ul>
026         * <li>SID-1: Application / Method Identifier (CE) <b>optional </b>
027         * <li>SID-2: Substance Lot Number (ST) <b>optional </b>
028         * <li>SID-3: Substance Container Identifier (ST) <b>optional </b>
029         * <li>SID-4: Substance Manufacturer Identifier (CE) <b>optional </b>
030     * </ul>
031     */
032    public class SID extends AbstractSegment {
033    
034        /** 
035         * Creates a new SID segment
036         */
037        public SID(Group parent, ModelClassFactory factory) {
038           super(parent, factory);
039           init(factory);
040        }
041    
042        private void init(ModelClassFactory factory) {
043           try {
044                                      this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(0) }, "Application / Method Identifier");
045                                      this.add(ST.class, false, 1, 20, new Object[]{ getMessage(), new Integer(0) }, "Substance Lot Number");
046                                      this.add(ST.class, false, 1, 200, new Object[]{ getMessage(), new Integer(0) }, "Substance Container Identifier");
047                                      this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(385) }, "Substance Manufacturer Identifier");
048           } catch(HL7Exception e) {
049              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating SID - this is probably a bug in the source code generator.", e);
050           }
051        }
052    
053    
054    
055        /**
056         * Returns
057         * SID-1: "Application / Method Identifier" - creates it if necessary
058         */
059        public CE getApplicationMethodIdentifier() { 
060            CE ret = null;
061            try {
062                Type t = this.getField(1, 0);
063                ret = (CE)t;
064            } catch (ClassCastException cce) {
065                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
066                throw new RuntimeException(cce);
067            } catch (HL7Exception he) {
068                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
069                throw new RuntimeException(he);
070            }
071            return ret;
072        }
073    
074    
075        /**
076         * Returns
077         * SID-1: "Application / Method Identifier" - creates it if necessary
078         */
079        public CE getSid1_ApplicationMethodIdentifier() { 
080            CE ret = null;
081            try {
082                Type t = this.getField(1, 0);
083                ret = (CE)t;
084            } catch (ClassCastException cce) {
085                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
086                throw new RuntimeException(cce);
087            } catch (HL7Exception he) {
088                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
089                throw new RuntimeException(he);
090            }
091            return ret;
092        }
093    
094    
095    
096        /**
097         * Returns
098         * SID-2: "Substance Lot Number" - creates it if necessary
099         */
100        public ST getSubstanceLotNumber() { 
101            ST ret = null;
102            try {
103                Type t = this.getField(2, 0);
104                ret = (ST)t;
105            } catch (ClassCastException cce) {
106                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
107                throw new RuntimeException(cce);
108            } catch (HL7Exception he) {
109                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
110                throw new RuntimeException(he);
111            }
112            return ret;
113        }
114    
115    
116        /**
117         * Returns
118         * SID-2: "Substance Lot Number" - creates it if necessary
119         */
120        public ST getSid2_SubstanceLotNumber() { 
121            ST ret = null;
122            try {
123                Type t = this.getField(2, 0);
124                ret = (ST)t;
125            } catch (ClassCastException cce) {
126                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
127                throw new RuntimeException(cce);
128            } catch (HL7Exception he) {
129                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
130                throw new RuntimeException(he);
131            }
132            return ret;
133        }
134    
135    
136    
137        /**
138         * Returns
139         * SID-3: "Substance Container Identifier" - creates it if necessary
140         */
141        public ST getSubstanceContainerIdentifier() { 
142            ST ret = null;
143            try {
144                Type t = this.getField(3, 0);
145                ret = (ST)t;
146            } catch (ClassCastException cce) {
147                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
148                throw new RuntimeException(cce);
149            } catch (HL7Exception he) {
150                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
151                throw new RuntimeException(he);
152            }
153            return ret;
154        }
155    
156    
157        /**
158         * Returns
159         * SID-3: "Substance Container Identifier" - creates it if necessary
160         */
161        public ST getSid3_SubstanceContainerIdentifier() { 
162            ST ret = null;
163            try {
164                Type t = this.getField(3, 0);
165                ret = (ST)t;
166            } catch (ClassCastException cce) {
167                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
168                throw new RuntimeException(cce);
169            } catch (HL7Exception he) {
170                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
171                throw new RuntimeException(he);
172            }
173            return ret;
174        }
175    
176    
177    
178        /**
179         * Returns
180         * SID-4: "Substance Manufacturer Identifier" - creates it if necessary
181         */
182        public CE getSubstanceManufacturerIdentifier() { 
183            CE ret = null;
184            try {
185                Type t = this.getField(4, 0);
186                ret = (CE)t;
187            } catch (ClassCastException cce) {
188                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
189                throw new RuntimeException(cce);
190            } catch (HL7Exception he) {
191                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
192                throw new RuntimeException(he);
193            }
194            return ret;
195        }
196    
197    
198        /**
199         * Returns
200         * SID-4: "Substance Manufacturer Identifier" - creates it if necessary
201         */
202        public CE getSid4_SubstanceManufacturerIdentifier() { 
203            CE ret = null;
204            try {
205                Type t = this.getField(4, 0);
206                ret = (CE)t;
207            } catch (ClassCastException cce) {
208                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
209                throw new RuntimeException(cce);
210            } catch (HL7Exception he) {
211                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
212                throw new RuntimeException(he);
213            }
214            return ret;
215        }
216    
217    
218    
219    
220    
221        /** {@inheritDoc} */   
222        protected Type createNewTypeWithoutReflection(int field) {
223           switch (field) {
224              case 0: return new CE(getMessage());
225              case 1: return new ST(getMessage());
226              case 2: return new ST(getMessage());
227              case 3: return new CE(getMessage());
228              default: return null;
229           }
230       }
231    
232    
233    }
234