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 NSC message segment (Application status change). 
024     * This segment has the following fields:</p>
025     * <ul>
026         * <li>NSC-1: Application Change Type (IS) <b> </b>
027         * <li>NSC-2: Current CPU (ST) <b>optional </b>
028         * <li>NSC-3: Current Fileserver (ST) <b>optional </b>
029         * <li>NSC-4: Current Application (HD) <b>optional </b>
030         * <li>NSC-5: Current Facility (HD) <b>optional </b>
031         * <li>NSC-6: New CPU (ST) <b>optional </b>
032         * <li>NSC-7: New Fileserver (ST) <b>optional </b>
033         * <li>NSC-8: New Application (HD) <b>optional </b>
034         * <li>NSC-9: New Facility (HD) <b>optional </b>
035     * </ul>
036     */
037    public class NSC extends AbstractSegment {
038    
039        /** 
040         * Creates a new NSC segment
041         */
042        public NSC(Group parent, ModelClassFactory factory) {
043           super(parent, factory);
044           init(factory);
045        }
046    
047        private void init(ModelClassFactory factory) {
048           try {
049                                      this.add(IS.class, true, 1, 4, new Object[]{ getMessage() }, "Application Change Type");
050                                      this.add(ST.class, false, 1, 30, new Object[]{ getMessage(), new Integer(0) }, "Current CPU");
051                                      this.add(ST.class, false, 1, 30, new Object[]{ getMessage(), new Integer(0) }, "Current Fileserver");
052                                      this.add(HD.class, false, 1, 30, new Object[]{ getMessage(), new Integer(0) }, "Current Application");
053                                      this.add(HD.class, false, 1, 30, new Object[]{ getMessage(), new Integer(0) }, "Current Facility");
054                                      this.add(ST.class, false, 1, 30, new Object[]{ getMessage(), new Integer(0) }, "New CPU");
055                                      this.add(ST.class, false, 1, 30, new Object[]{ getMessage(), new Integer(0) }, "New Fileserver");
056                                      this.add(HD.class, false, 1, 30, new Object[]{ getMessage(), new Integer(0) }, "New Application");
057                                      this.add(HD.class, false, 1, 30, new Object[]{ getMessage(), new Integer(0) }, "New Facility");
058           } catch(HL7Exception e) {
059              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating NSC - this is probably a bug in the source code generator.", e);
060           }
061        }
062    
063    
064    
065        /**
066         * Returns
067         * NSC-1: "Application Change Type" - creates it if necessary
068         */
069        public IS getApplicationChangeType() { 
070            IS ret = null;
071            try {
072                Type t = this.getField(1, 0);
073                ret = (IS)t;
074            } catch (ClassCastException cce) {
075                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
076                throw new RuntimeException(cce);
077            } catch (HL7Exception he) {
078                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
079                throw new RuntimeException(he);
080            }
081            return ret;
082        }
083    
084    
085        /**
086         * Returns
087         * NSC-1: "Application Change Type" - creates it if necessary
088         */
089        public IS getNsc1_ApplicationChangeType() { 
090            IS ret = null;
091            try {
092                Type t = this.getField(1, 0);
093                ret = (IS)t;
094            } catch (ClassCastException cce) {
095                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
096                throw new RuntimeException(cce);
097            } catch (HL7Exception he) {
098                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
099                throw new RuntimeException(he);
100            }
101            return ret;
102        }
103    
104    
105    
106        /**
107         * Returns
108         * NSC-2: "Current CPU" - creates it if necessary
109         */
110        public ST getCurrentCPU() { 
111            ST ret = null;
112            try {
113                Type t = this.getField(2, 0);
114                ret = (ST)t;
115            } catch (ClassCastException cce) {
116                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
117                throw new RuntimeException(cce);
118            } catch (HL7Exception he) {
119                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
120                throw new RuntimeException(he);
121            }
122            return ret;
123        }
124    
125    
126        /**
127         * Returns
128         * NSC-2: "Current CPU" - creates it if necessary
129         */
130        public ST getNsc2_CurrentCPU() { 
131            ST ret = null;
132            try {
133                Type t = this.getField(2, 0);
134                ret = (ST)t;
135            } catch (ClassCastException cce) {
136                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
137                throw new RuntimeException(cce);
138            } catch (HL7Exception he) {
139                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
140                throw new RuntimeException(he);
141            }
142            return ret;
143        }
144    
145    
146    
147        /**
148         * Returns
149         * NSC-3: "Current Fileserver" - creates it if necessary
150         */
151        public ST getCurrentFileserver() { 
152            ST ret = null;
153            try {
154                Type t = this.getField(3, 0);
155                ret = (ST)t;
156            } catch (ClassCastException cce) {
157                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
158                throw new RuntimeException(cce);
159            } catch (HL7Exception he) {
160                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
161                throw new RuntimeException(he);
162            }
163            return ret;
164        }
165    
166    
167        /**
168         * Returns
169         * NSC-3: "Current Fileserver" - creates it if necessary
170         */
171        public ST getNsc3_CurrentFileserver() { 
172            ST ret = null;
173            try {
174                Type t = this.getField(3, 0);
175                ret = (ST)t;
176            } catch (ClassCastException cce) {
177                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
178                throw new RuntimeException(cce);
179            } catch (HL7Exception he) {
180                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
181                throw new RuntimeException(he);
182            }
183            return ret;
184        }
185    
186    
187    
188        /**
189         * Returns
190         * NSC-4: "Current Application" - creates it if necessary
191         */
192        public HD getCurrentApplication() { 
193            HD ret = null;
194            try {
195                Type t = this.getField(4, 0);
196                ret = (HD)t;
197            } catch (ClassCastException cce) {
198                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
199                throw new RuntimeException(cce);
200            } catch (HL7Exception he) {
201                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
202                throw new RuntimeException(he);
203            }
204            return ret;
205        }
206    
207    
208        /**
209         * Returns
210         * NSC-4: "Current Application" - creates it if necessary
211         */
212        public HD getNsc4_CurrentApplication() { 
213            HD ret = null;
214            try {
215                Type t = this.getField(4, 0);
216                ret = (HD)t;
217            } catch (ClassCastException cce) {
218                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
219                throw new RuntimeException(cce);
220            } catch (HL7Exception he) {
221                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
222                throw new RuntimeException(he);
223            }
224            return ret;
225        }
226    
227    
228    
229        /**
230         * Returns
231         * NSC-5: "Current Facility" - creates it if necessary
232         */
233        public HD getCurrentFacility() { 
234            HD ret = null;
235            try {
236                Type t = this.getField(5, 0);
237                ret = (HD)t;
238            } catch (ClassCastException cce) {
239                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
240                throw new RuntimeException(cce);
241            } catch (HL7Exception he) {
242                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
243                throw new RuntimeException(he);
244            }
245            return ret;
246        }
247    
248    
249        /**
250         * Returns
251         * NSC-5: "Current Facility" - creates it if necessary
252         */
253        public HD getNsc5_CurrentFacility() { 
254            HD ret = null;
255            try {
256                Type t = this.getField(5, 0);
257                ret = (HD)t;
258            } catch (ClassCastException cce) {
259                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
260                throw new RuntimeException(cce);
261            } catch (HL7Exception he) {
262                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
263                throw new RuntimeException(he);
264            }
265            return ret;
266        }
267    
268    
269    
270        /**
271         * Returns
272         * NSC-6: "New CPU" - creates it if necessary
273         */
274        public ST getNewCPU() { 
275            ST ret = null;
276            try {
277                Type t = this.getField(6, 0);
278                ret = (ST)t;
279            } catch (ClassCastException cce) {
280                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
281                throw new RuntimeException(cce);
282            } catch (HL7Exception he) {
283                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
284                throw new RuntimeException(he);
285            }
286            return ret;
287        }
288    
289    
290        /**
291         * Returns
292         * NSC-6: "New CPU" - creates it if necessary
293         */
294        public ST getNsc6_NewCPU() { 
295            ST ret = null;
296            try {
297                Type t = this.getField(6, 0);
298                ret = (ST)t;
299            } catch (ClassCastException cce) {
300                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
301                throw new RuntimeException(cce);
302            } catch (HL7Exception he) {
303                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
304                throw new RuntimeException(he);
305            }
306            return ret;
307        }
308    
309    
310    
311        /**
312         * Returns
313         * NSC-7: "New Fileserver" - creates it if necessary
314         */
315        public ST getNewFileserver() { 
316            ST ret = null;
317            try {
318                Type t = this.getField(7, 0);
319                ret = (ST)t;
320            } catch (ClassCastException cce) {
321                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
322                throw new RuntimeException(cce);
323            } catch (HL7Exception he) {
324                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
325                throw new RuntimeException(he);
326            }
327            return ret;
328        }
329    
330    
331        /**
332         * Returns
333         * NSC-7: "New Fileserver" - creates it if necessary
334         */
335        public ST getNsc7_NewFileserver() { 
336            ST ret = null;
337            try {
338                Type t = this.getField(7, 0);
339                ret = (ST)t;
340            } catch (ClassCastException cce) {
341                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
342                throw new RuntimeException(cce);
343            } catch (HL7Exception he) {
344                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
345                throw new RuntimeException(he);
346            }
347            return ret;
348        }
349    
350    
351    
352        /**
353         * Returns
354         * NSC-8: "New Application" - creates it if necessary
355         */
356        public HD getNewApplication() { 
357            HD ret = null;
358            try {
359                Type t = this.getField(8, 0);
360                ret = (HD)t;
361            } catch (ClassCastException cce) {
362                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
363                throw new RuntimeException(cce);
364            } catch (HL7Exception he) {
365                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
366                throw new RuntimeException(he);
367            }
368            return ret;
369        }
370    
371    
372        /**
373         * Returns
374         * NSC-8: "New Application" - creates it if necessary
375         */
376        public HD getNsc8_NewApplication() { 
377            HD ret = null;
378            try {
379                Type t = this.getField(8, 0);
380                ret = (HD)t;
381            } catch (ClassCastException cce) {
382                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
383                throw new RuntimeException(cce);
384            } catch (HL7Exception he) {
385                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
386                throw new RuntimeException(he);
387            }
388            return ret;
389        }
390    
391    
392    
393        /**
394         * Returns
395         * NSC-9: "New Facility" - creates it if necessary
396         */
397        public HD getNewFacility() { 
398            HD ret = null;
399            try {
400                Type t = this.getField(9, 0);
401                ret = (HD)t;
402            } catch (ClassCastException cce) {
403                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
404                throw new RuntimeException(cce);
405            } catch (HL7Exception he) {
406                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
407                throw new RuntimeException(he);
408            }
409            return ret;
410        }
411    
412    
413        /**
414         * Returns
415         * NSC-9: "New Facility" - creates it if necessary
416         */
417        public HD getNsc9_NewFacility() { 
418            HD ret = null;
419            try {
420                Type t = this.getField(9, 0);
421                ret = (HD)t;
422            } catch (ClassCastException cce) {
423                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
424                throw new RuntimeException(cce);
425            } catch (HL7Exception he) {
426                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
427                throw new RuntimeException(he);
428            }
429            return ret;
430        }
431    
432    
433    
434    
435    
436        /** {@inheritDoc} */   
437        protected Type createNewTypeWithoutReflection(int field) {
438           switch (field) {
439              case 0: return new IS(getMessage(), new Integer( 409 ));
440              case 1: return new ST(getMessage());
441              case 2: return new ST(getMessage());
442              case 3: return new HD(getMessage());
443              case 4: return new HD(getMessage());
444              case 5: return new ST(getMessage());
445              case 6: return new ST(getMessage());
446              case 7: return new HD(getMessage());
447              case 8: return new HD(getMessage());
448              default: return null;
449           }
450       }
451    
452    
453    }
454