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 * The contents of this file are subject to the Mozilla Public License Version 1.1 
008 * (the "License"); you may not use this file except in compliance with the License. 
009 * You may obtain a copy of the License at http://www.mozilla.org/MPL/ 
010 * Software distributed under the License is distributed on an "AS IS" basis, 
011 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 
012 * specific language governing rights and limitations under the License. 
013 * 
014 * The Original Code is "[file_name]".  Description: 
015 * "[one_line_description]" 
016 * 
017 * The Initial Developer of the Original Code is University Health Network. Copyright (C) 
018 * 2012.  All Rights Reserved. 
019 * 
020 * Contributor(s): ______________________________________. 
021 * 
022 * Alternatively, the contents of this file may be used under the terms of the 
023 * GNU General Public License (the  "GPL"), in which case the provisions of the GPL are 
024 * applicable instead of those above.  If you wish to allow use of your version of this 
025 * file only under the terms of the GPL and not to allow others to use your version 
026 * of this file under the MPL, indicate your decision by deleting  the provisions above 
027 * and replace  them with the notice and other provisions required by the GPL License.  
028 * If you do not delete the provisions above, a recipient may use your version of 
029 * this file under either the MPL or the GPL. 
030 * 
031 */
032
033package ca.uhn.hl7v2.model.v251.datatype;
034
035import ca.uhn.hl7v2.model.DataTypeException;
036import ca.uhn.hl7v2.model.Message;
037import ca.uhn.hl7v2.model.Type;
038import ca.uhn.hl7v2.model.AbstractComposite;
039
040/**
041 * <p>Represents an HL7 OCD (Occurrence Code and Date) data type. 
042 * This type consists of the following components:</p>
043 * <ul>
044 * <li>Occurrence Code (CNE)
045 * <li>Occurrence Date (DT)
046 * </ul>
047 */
048@SuppressWarnings("unused")
049public class OCD extends AbstractComposite {
050
051    private Type[] data;
052
053    /** 
054     * Creates a new OCD type
055     */
056    public OCD(Message message) {
057        super(message);
058        init();
059    }
060
061    private void init() {
062        data = new Type[2];    
063        data[0] = new CNE(getMessage());
064        data[1] = new DT(getMessage());
065    }
066
067
068    /**
069     * Returns an array containing the data elements.
070     */
071    public Type[] getComponents() { 
072        return this.data; 
073    }
074
075    /**
076     * Returns an individual data component.
077     *
078     * @param number The component number (0-indexed)
079     * @throws DataTypeException if the given element number is out of range.
080     */
081    public Type getComponent(int number) throws DataTypeException { 
082
083        try { 
084            return this.data[number]; 
085        } catch (ArrayIndexOutOfBoundsException e) { 
086            throw new DataTypeException("Element " + number + " doesn't exist (Type " + getClass().getName() + " has only " + this.data.length + " components)"); 
087        } 
088    } 
089
090
091    /**
092     * Returns Occurrence Code (component 1).  This is a convenience method that saves you from 
093     * casting and handling an exception.
094     */
095    public CNE getOccurrenceCode() {
096       return getTyped(0, CNE.class);
097    }
098
099    
100    /**
101     * Returns Occurrence Code (component 1).  This is a convenience method that saves you from 
102     * casting and handling an exception.
103     */
104    public CNE getOcd1_OccurrenceCode() {
105       return getTyped(0, CNE.class);
106    }
107
108
109    /**
110     * Returns Occurrence Date (component 2).  This is a convenience method that saves you from 
111     * casting and handling an exception.
112     */
113    public DT getOccurrenceDate() {
114       return getTyped(1, DT.class);
115    }
116
117    
118    /**
119     * Returns Occurrence Date (component 2).  This is a convenience method that saves you from 
120     * casting and handling an exception.
121     */
122    public DT getOcd2_OccurrenceDate() {
123       return getTyped(1, DT.class);
124    }
125
126
127
128}
129