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.datatype;
009    
010    import ca.uhn.hl7v2.model.Composite;
011    import ca.uhn.hl7v2.model.DataTypeException;
012    import ca.uhn.hl7v2.model.Message;
013    import ca.uhn.hl7v2.model.Type;
014    import ca.uhn.hl7v2.model.AbstractType;
015    import ca.uhn.log.HapiLogFactory;
016    
017    /**
018     * <p>Represents an HL7 MOC (Charge To Practise) data type. 
019     * This type consists of the following components:</p>
020     * <ul>
021     * <li>dollar amount (MO)
022     * <li>charge code (CE)
023     * </ul>
024     */
025    public class MOC extends AbstractType implements Composite {
026    
027        private Type[] data;
028    
029        /** 
030         * Creates a new MOC type
031         */
032        public MOC(Message message) {
033            super(message);
034            init();
035        }
036    
037        private void init() {
038            data = new Type[2];    
039            data[0] = new MO(getMessage());
040            data[1] = new CE(getMessage());
041        }
042    
043    
044        /**
045         * Returns an array containing the data elements.
046         */
047        public Type[] getComponents() { 
048            return this.data; 
049        }
050    
051        /**
052         * Returns an individual data component.
053         *
054         * @param number The component number (0-indexed)
055         * @throws DataTypeException if the given element number is out of range.
056         */
057        public Type getComponent(int number) throws DataTypeException { 
058    
059            try { 
060                return this.data[number]; 
061            } catch (ArrayIndexOutOfBoundsException e) { 
062                throw new DataTypeException("Element " + number + " doesn't exist (Type " + getClass().getName() + " has only " + this.data.length + " components)"); 
063            } 
064        } 
065    
066    
067        /**
068         * Returns dollar amount (component #1).  This is a convenience method that saves you from 
069         * casting and handling an exception.
070         */
071        public MO getDollarAmount() {
072           MO ret = null;
073           try {
074              ret = (MO)getComponent(0);
075           } catch (DataTypeException e) {
076              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
077              throw new RuntimeException(e);
078           }
079           return ret;
080        }
081    
082        
083        /**
084         * Returns dollar amount (component #1).  This is a convenience method that saves you from 
085         * casting and handling an exception.
086         */
087        public MO getMoc1_DollarAmount() {
088           MO ret = null;
089           try {
090              ret = (MO)getComponent(0);
091           } catch (DataTypeException e) {
092              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
093              throw new RuntimeException(e);
094           }
095           return ret;
096        }
097    
098    
099        /**
100         * Returns charge code (component #2).  This is a convenience method that saves you from 
101         * casting and handling an exception.
102         */
103        public CE getChargeCode() {
104           CE ret = null;
105           try {
106              ret = (CE)getComponent(1);
107           } catch (DataTypeException e) {
108              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
109              throw new RuntimeException(e);
110           }
111           return ret;
112        }
113    
114        
115        /**
116         * Returns charge code (component #2).  This is a convenience method that saves you from 
117         * casting and handling an exception.
118         */
119        public CE getMoc2_ChargeCode() {
120           CE ret = null;
121           try {
122              ret = (CE)getComponent(1);
123           } catch (DataTypeException e) {
124              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
125              throw new RuntimeException(e);
126           }
127           return ret;
128        }
129    
130    
131    
132    }
133