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 NCK message segment (System clock). 
024     * This segment has the following fields:</p>
025     * <ul>
026         * <li>NCK-1: System Date/Time (TS) <b> </b>
027     * </ul>
028     */
029    public class NCK extends AbstractSegment {
030    
031        /** 
032         * Creates a new NCK segment
033         */
034        public NCK(Group parent, ModelClassFactory factory) {
035           super(parent, factory);
036           init(factory);
037        }
038    
039        private void init(ModelClassFactory factory) {
040           try {
041                                      this.add(TS.class, true, 1, 26, new Object[]{ getMessage(), new Integer(0) }, "System Date/Time");
042           } catch(HL7Exception e) {
043              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating NCK - this is probably a bug in the source code generator.", e);
044           }
045        }
046    
047    
048    
049        /**
050         * Returns
051         * NCK-1: "System Date/Time" - creates it if necessary
052         */
053        public TS getSystemDateTime() { 
054            TS ret = null;
055            try {
056                Type t = this.getField(1, 0);
057                ret = (TS)t;
058            } catch (ClassCastException cce) {
059                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
060                throw new RuntimeException(cce);
061            } catch (HL7Exception he) {
062                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
063                throw new RuntimeException(he);
064            }
065            return ret;
066        }
067    
068    
069        /**
070         * Returns
071         * NCK-1: "System Date/Time" - creates it if necessary
072         */
073        public TS getNck1_SystemDateTime() { 
074            TS ret = null;
075            try {
076                Type t = this.getField(1, 0);
077                ret = (TS)t;
078            } catch (ClassCastException cce) {
079                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
080                throw new RuntimeException(cce);
081            } catch (HL7Exception he) {
082                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
083                throw new RuntimeException(he);
084            }
085            return ret;
086        }
087    
088    
089    
090    
091    
092        /** {@inheritDoc} */   
093        protected Type createNewTypeWithoutReflection(int field) {
094           switch (field) {
095              case 0: return new TS(getMessage());
096              default: return null;
097           }
098       }
099    
100    
101    }
102