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 PIP (Privileges) data type.
019 * This type consists of the following components:</p>
020 * <ul>
021 * <li>privilege (CE)
022 * <li>privilege class (CE)
023 * <li>expiration date (DT)
024 * <li>activation date (DT)
025 * <li>facility (EI) (EI)
026 * </ul>
027 */
028 public class PIP extends AbstractType implements Composite {
029
030 private Type[] data;
031
032 /**
033 * Creates a new PIP type
034 */
035 public PIP(Message message) {
036 super(message);
037 init();
038 }
039
040 private void init() {
041 data = new Type[5];
042 data[0] = new CE(getMessage());
043 data[1] = new CE(getMessage());
044 data[2] = new DT(getMessage());
045 data[3] = new DT(getMessage());
046 data[4] = new EI(getMessage());
047 }
048
049
050 /**
051 * Returns an array containing the data elements.
052 */
053 public Type[] getComponents() {
054 return this.data;
055 }
056
057 /**
058 * Returns an individual data component.
059 *
060 * @param number The component number (0-indexed)
061 * @throws DataTypeException if the given element number is out of range.
062 */
063 public Type getComponent(int number) throws DataTypeException {
064
065 try {
066 return this.data[number];
067 } catch (ArrayIndexOutOfBoundsException e) {
068 throw new DataTypeException("Element " + number + " doesn't exist (Type " + getClass().getName() + " has only " + this.data.length + " components)");
069 }
070 }
071
072
073 /**
074 * Returns privilege (component #1). This is a convenience method that saves you from
075 * casting and handling an exception.
076 */
077 public CE getPrivilege() {
078 CE ret = null;
079 try {
080 ret = (CE)getComponent(0);
081 } catch (DataTypeException e) {
082 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
083 throw new RuntimeException(e);
084 }
085 return ret;
086 }
087
088
089 /**
090 * Returns privilege (component #1). This is a convenience method that saves you from
091 * casting and handling an exception.
092 */
093 public CE getPip1_Privilege() {
094 CE ret = null;
095 try {
096 ret = (CE)getComponent(0);
097 } catch (DataTypeException e) {
098 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
099 throw new RuntimeException(e);
100 }
101 return ret;
102 }
103
104
105 /**
106 * Returns privilege class (component #2). This is a convenience method that saves you from
107 * casting and handling an exception.
108 */
109 public CE getPrivilegeClass() {
110 CE ret = null;
111 try {
112 ret = (CE)getComponent(1);
113 } catch (DataTypeException e) {
114 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
115 throw new RuntimeException(e);
116 }
117 return ret;
118 }
119
120
121 /**
122 * Returns privilege class (component #2). This is a convenience method that saves you from
123 * casting and handling an exception.
124 */
125 public CE getPip2_PrivilegeClass() {
126 CE ret = null;
127 try {
128 ret = (CE)getComponent(1);
129 } catch (DataTypeException e) {
130 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
131 throw new RuntimeException(e);
132 }
133 return ret;
134 }
135
136
137 /**
138 * Returns expiration date (component #3). This is a convenience method that saves you from
139 * casting and handling an exception.
140 */
141 public DT getExpirationDate() {
142 DT ret = null;
143 try {
144 ret = (DT)getComponent(2);
145 } catch (DataTypeException e) {
146 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
147 throw new RuntimeException(e);
148 }
149 return ret;
150 }
151
152
153 /**
154 * Returns expiration date (component #3). This is a convenience method that saves you from
155 * casting and handling an exception.
156 */
157 public DT getPip3_ExpirationDate() {
158 DT ret = null;
159 try {
160 ret = (DT)getComponent(2);
161 } catch (DataTypeException e) {
162 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
163 throw new RuntimeException(e);
164 }
165 return ret;
166 }
167
168
169 /**
170 * Returns activation date (component #4). This is a convenience method that saves you from
171 * casting and handling an exception.
172 */
173 public DT getActivationDate() {
174 DT ret = null;
175 try {
176 ret = (DT)getComponent(3);
177 } catch (DataTypeException e) {
178 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
179 throw new RuntimeException(e);
180 }
181 return ret;
182 }
183
184
185 /**
186 * Returns activation date (component #4). This is a convenience method that saves you from
187 * casting and handling an exception.
188 */
189 public DT getPip4_ActivationDate() {
190 DT ret = null;
191 try {
192 ret = (DT)getComponent(3);
193 } catch (DataTypeException e) {
194 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
195 throw new RuntimeException(e);
196 }
197 return ret;
198 }
199
200
201 /**
202 * Returns facility (EI) (component #5). This is a convenience method that saves you from
203 * casting and handling an exception.
204 */
205 public EI getFacility() {
206 EI ret = null;
207 try {
208 ret = (EI)getComponent(4);
209 } catch (DataTypeException e) {
210 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
211 throw new RuntimeException(e);
212 }
213 return ret;
214 }
215
216
217 /**
218 * Returns facility (EI) (component #5). This is a convenience method that saves you from
219 * casting and handling an exception.
220 */
221 public EI getPip5_Facility() {
222 EI ret = null;
223 try {
224 ret = (EI)getComponent(4);
225 } catch (DataTypeException e) {
226 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
227 throw new RuntimeException(e);
228 }
229 return ret;
230 }
231
232
233
234 }
235