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 PCF (Pre-certification required) data type. 
019     * This type consists of the following components:</p>
020     * <ul>
021     * <li>pre-certification patient type (IS)
022     * <li>pre-certification required (ID)
023     * <li>pre-certification window (TS)
024     * </ul>
025     */
026    public class PCF extends AbstractType implements Composite {
027    
028        private Type[] data;
029    
030        /** 
031         * Creates a new PCF type
032         */
033        public PCF(Message message) {
034            super(message);
035            init();
036        }
037    
038        private void init() {
039            data = new Type[3];    
040            data[0] = new IS(getMessage(), 0);
041            data[1] = new ID(getMessage(), 0);
042            data[2] = new TS(getMessage());
043        }
044    
045    
046        /**
047         * Returns an array containing the data elements.
048         */
049        public Type[] getComponents() { 
050            return this.data; 
051        }
052    
053        /**
054         * Returns an individual data component.
055         *
056         * @param number The component number (0-indexed)
057         * @throws DataTypeException if the given element number is out of range.
058         */
059        public Type getComponent(int number) throws DataTypeException { 
060    
061            try { 
062                return this.data[number]; 
063            } catch (ArrayIndexOutOfBoundsException e) { 
064                throw new DataTypeException("Element " + number + " doesn't exist (Type " + getClass().getName() + " has only " + this.data.length + " components)"); 
065            } 
066        } 
067    
068    
069        /**
070         * Returns pre-certification patient type (component #1).  This is a convenience method that saves you from 
071         * casting and handling an exception.
072         */
073        public IS getPreCertificationPatientType() {
074           IS ret = null;
075           try {
076              ret = (IS)getComponent(0);
077           } catch (DataTypeException e) {
078              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
079              throw new RuntimeException(e);
080           }
081           return ret;
082        }
083    
084        
085        /**
086         * Returns pre-certification patient type (component #1).  This is a convenience method that saves you from 
087         * casting and handling an exception.
088         */
089        public IS getPcf1_PreCertificationPatientType() {
090           IS ret = null;
091           try {
092              ret = (IS)getComponent(0);
093           } catch (DataTypeException e) {
094              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
095              throw new RuntimeException(e);
096           }
097           return ret;
098        }
099    
100    
101        /**
102         * Returns pre-certification required (component #2).  This is a convenience method that saves you from 
103         * casting and handling an exception.
104         */
105        public ID getPreCertificationRequired() {
106           ID ret = null;
107           try {
108              ret = (ID)getComponent(1);
109           } catch (DataTypeException e) {
110              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
111              throw new RuntimeException(e);
112           }
113           return ret;
114        }
115    
116        
117        /**
118         * Returns pre-certification required (component #2).  This is a convenience method that saves you from 
119         * casting and handling an exception.
120         */
121        public ID getPcf2_PreCertificationRequired() {
122           ID ret = null;
123           try {
124              ret = (ID)getComponent(1);
125           } catch (DataTypeException e) {
126              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
127              throw new RuntimeException(e);
128           }
129           return ret;
130        }
131    
132    
133        /**
134         * Returns pre-certification window (component #3).  This is a convenience method that saves you from 
135         * casting and handling an exception.
136         */
137        public TS getPreCertificationWindow() {
138           TS ret = null;
139           try {
140              ret = (TS)getComponent(2);
141           } catch (DataTypeException e) {
142              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
143              throw new RuntimeException(e);
144           }
145           return ret;
146        }
147    
148        
149        /**
150         * Returns pre-certification window (component #3).  This is a convenience method that saves you from 
151         * casting and handling an exception.
152         */
153        public TS getPcf3_PreCertificationWindow() {
154           TS ret = null;
155           try {
156              ret = (TS)getComponent(2);
157           } catch (DataTypeException e) {
158              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
159              throw new RuntimeException(e);
160           }
161           return ret;
162        }
163    
164    
165    
166    }
167