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 NPU message segment (Bed status update). 
024     * This segment has the following fields:</p>
025     * <ul>
026         * <li>NPU-1: Bed Location (PL) <b> </b>
027         * <li>NPU-2: Bed Status (IS) <b>optional </b>
028     * </ul>
029     */
030    public class NPU extends AbstractSegment {
031    
032        /** 
033         * Creates a new NPU segment
034         */
035        public NPU(Group parent, ModelClassFactory factory) {
036           super(parent, factory);
037           init(factory);
038        }
039    
040        private void init(ModelClassFactory factory) {
041           try {
042                                      this.add(PL.class, true, 1, 80, new Object[]{ getMessage(), new Integer(0) }, "Bed Location");
043                                      this.add(IS.class, false, 1, 1, new Object[]{ getMessage() }, "Bed Status");
044           } catch(HL7Exception e) {
045              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating NPU - this is probably a bug in the source code generator.", e);
046           }
047        }
048    
049    
050    
051        /**
052         * Returns
053         * NPU-1: "Bed Location" - creates it if necessary
054         */
055        public PL getBedLocation() { 
056            PL ret = null;
057            try {
058                Type t = this.getField(1, 0);
059                ret = (PL)t;
060            } catch (ClassCastException cce) {
061                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
062                throw new RuntimeException(cce);
063            } catch (HL7Exception he) {
064                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
065                throw new RuntimeException(he);
066            }
067            return ret;
068        }
069    
070    
071        /**
072         * Returns
073         * NPU-1: "Bed Location" - creates it if necessary
074         */
075        public PL getNpu1_BedLocation() { 
076            PL ret = null;
077            try {
078                Type t = this.getField(1, 0);
079                ret = (PL)t;
080            } catch (ClassCastException cce) {
081                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
082                throw new RuntimeException(cce);
083            } catch (HL7Exception he) {
084                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
085                throw new RuntimeException(he);
086            }
087            return ret;
088        }
089    
090    
091    
092        /**
093         * Returns
094         * NPU-2: "Bed Status" - creates it if necessary
095         */
096        public IS getBedStatus() { 
097            IS ret = null;
098            try {
099                Type t = this.getField(2, 0);
100                ret = (IS)t;
101            } catch (ClassCastException cce) {
102                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
103                throw new RuntimeException(cce);
104            } catch (HL7Exception he) {
105                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
106                throw new RuntimeException(he);
107            }
108            return ret;
109        }
110    
111    
112        /**
113         * Returns
114         * NPU-2: "Bed Status" - creates it if necessary
115         */
116        public IS getNpu2_BedStatus() { 
117            IS ret = null;
118            try {
119                Type t = this.getField(2, 0);
120                ret = (IS)t;
121            } catch (ClassCastException cce) {
122                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
123                throw new RuntimeException(cce);
124            } catch (HL7Exception he) {
125                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
126                throw new RuntimeException(he);
127            }
128            return ret;
129        }
130    
131    
132    
133    
134    
135        /** {@inheritDoc} */   
136        protected Type createNewTypeWithoutReflection(int field) {
137           switch (field) {
138              case 0: return new PL(getMessage());
139              case 1: return new IS(getMessage(), new Integer( 116 ));
140              default: return null;
141           }
142       }
143    
144    
145    }
146