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
033
034package ca.uhn.hl7v2.model.v22.segment;
035
036// import ca.uhn.hl7v2.model.v22.group.*;
037import ca.uhn.hl7v2.model.v22.datatype.*;
038import ca.uhn.hl7v2.HL7Exception;
039import ca.uhn.hl7v2.parser.ModelClassFactory;
040import ca.uhn.hl7v2.parser.DefaultModelClassFactory;
041import ca.uhn.hl7v2.model.AbstractMessage;
042import ca.uhn.hl7v2.model.Group;
043import ca.uhn.hl7v2.model.Type;
044import ca.uhn.hl7v2.model.AbstractSegment;
045import ca.uhn.hl7v2.model.Varies;
046
047
048/**
049 *<p>Represents an HL7 PV2 message segment (PATIENT VISIT - additional information). 
050 * This segment has the following fields:</p>
051 * <ul>
052     * <li>PV2-1: Prior Pending Location (CM_INTERNAL_LOCATION) <b>optional </b>
053     * <li>PV2-2: Accommodation Code (CE) <b>optional </b>
054     * <li>PV2-3: Admit Reason (CE) <b>optional </b>
055     * <li>PV2-4: Transfer Reason (CE) <b>optional </b>
056     * <li>PV2-5: Patient Valuables (ST) <b>optional repeating</b>
057     * <li>PV2-6: Patient Valuables Location (ST) <b>optional </b>
058     * <li>PV2-7: Visit User Code (ID) <b>optional </b>
059     * <li>PV2-8: Expected Admit Date (DT) <b>optional </b>
060     * <li>PV2-9: Expected Discharge Date (DT) <b>optional </b>
061 * </ul>
062 */
063@SuppressWarnings("unused")
064public class PV2 extends AbstractSegment {
065
066    /** 
067     * Creates a new PV2 segment
068     */
069    public PV2(Group parent, ModelClassFactory factory) {
070       super(parent, factory);
071       init(factory);
072    }
073
074    private void init(ModelClassFactory factory) {
075       try {
076                                  this.add(CM_INTERNAL_LOCATION.class, false, 1, 12, new Object[]{ getMessage() }, "Prior Pending Location");
077                                  this.add(CE.class, false, 1, 60, new Object[]{ getMessage() }, "Accommodation Code");
078                                  this.add(CE.class, false, 1, 60, new Object[]{ getMessage() }, "Admit Reason");
079                                  this.add(CE.class, false, 1, 60, new Object[]{ getMessage() }, "Transfer Reason");
080                                  this.add(ST.class, false, 0, 25, new Object[]{ getMessage() }, "Patient Valuables");
081                                  this.add(ST.class, false, 1, 25, new Object[]{ getMessage() }, "Patient Valuables Location");
082                                              this.add(ID.class, false, 1, 2, new Object[]{ getMessage(), new Integer(130) }, "Visit User Code");
083                                  this.add(DT.class, false, 1, 8, new Object[]{ getMessage() }, "Expected Admit Date");
084                                  this.add(DT.class, false, 1, 8, new Object[]{ getMessage() }, "Expected Discharge Date");
085       } catch(HL7Exception e) {
086          log.error("Unexpected error creating PV2 - this is probably a bug in the source code generator.", e);
087       }
088    }
089
090
091
092    /**
093     * Returns
094     * PV2-1: "Prior Pending Location" - creates it if necessary
095     */
096    public CM_INTERNAL_LOCATION getPriorPendingLocation() { 
097                CM_INTERNAL_LOCATION retVal = this.getTypedField(1, 0);
098                return retVal;
099    }
100    
101    /**
102     * Returns
103     * PV2-1: "Prior Pending Location" - creates it if necessary
104     */
105    public CM_INTERNAL_LOCATION getPv21_PriorPendingLocation() { 
106                CM_INTERNAL_LOCATION retVal = this.getTypedField(1, 0);
107                return retVal;
108    }
109
110
111
112    /**
113     * Returns
114     * PV2-2: "Accommodation Code" - creates it if necessary
115     */
116    public CE getAccommodationCode() { 
117                CE retVal = this.getTypedField(2, 0);
118                return retVal;
119    }
120    
121    /**
122     * Returns
123     * PV2-2: "Accommodation Code" - creates it if necessary
124     */
125    public CE getPv22_AccommodationCode() { 
126                CE retVal = this.getTypedField(2, 0);
127                return retVal;
128    }
129
130
131
132    /**
133     * Returns
134     * PV2-3: "Admit Reason" - creates it if necessary
135     */
136    public CE getAdmitReason() { 
137                CE retVal = this.getTypedField(3, 0);
138                return retVal;
139    }
140    
141    /**
142     * Returns
143     * PV2-3: "Admit Reason" - creates it if necessary
144     */
145    public CE getPv23_AdmitReason() { 
146                CE retVal = this.getTypedField(3, 0);
147                return retVal;
148    }
149
150
151
152    /**
153     * Returns
154     * PV2-4: "Transfer Reason" - creates it if necessary
155     */
156    public CE getTransferReason() { 
157                CE retVal = this.getTypedField(4, 0);
158                return retVal;
159    }
160    
161    /**
162     * Returns
163     * PV2-4: "Transfer Reason" - creates it if necessary
164     */
165    public CE getPv24_TransferReason() { 
166                CE retVal = this.getTypedField(4, 0);
167                return retVal;
168    }
169
170
171    /**
172     * Returns all repetitions of Patient Valuables (PV2-5).
173     */
174    public ST[] getPatientValuables() {
175        ST[] retVal = this.getTypedField(5, new ST[0]);
176        return retVal;
177    }
178
179
180    /**
181     * Returns all repetitions of Patient Valuables (PV2-5).
182     */
183    public ST[] getPv25_PatientValuables() {
184        ST[] retVal = this.getTypedField(5, new ST[0]);
185        return retVal;
186    }
187
188
189    /**
190     * Returns a count of the current number of repetitions of Patient Valuables (PV2-5).
191     * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
192     * it will return zero.
193     */
194    public int getPatientValuablesReps() {
195        return this.getReps(5);
196    }
197
198
199    /**
200     * Returns a specific repetition of
201     * PV2-5: "Patient Valuables" - creates it if necessary
202     *
203     * @param rep The repetition index (0-indexed)
204     */
205    public ST getPatientValuables(int rep) { 
206                ST retVal = this.getTypedField(5, rep);
207                return retVal;
208    }
209
210    /**
211     * Returns a specific repetition of
212     * PV2-5: "Patient Valuables" - creates it if necessary
213     *
214     * @param rep The repetition index (0-indexed)
215     */
216    public ST getPv25_PatientValuables(int rep) { 
217                ST retVal = this.getTypedField(5, rep);
218                return retVal;
219    }
220
221    /**
222     * Returns a count of the current number of repetitions of Patient Valuables (PV2-5).
223     * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
224     * it will return zero.
225     */
226    public int getPv25_PatientValuablesReps() {
227        return this.getReps(5);
228    }
229
230
231    /**
232     * Inserts a repetition of
233     * PV2-5: "Patient Valuables" at a specific index
234     *
235     * @param rep The repetition index (0-indexed)
236     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
237     */
238    public ST insertPatientValuables(int rep) throws HL7Exception { 
239        return (ST) super.insertRepetition(5, rep);
240    }
241
242
243    /**
244     * Inserts a repetition of
245     * PV2-5: "Patient Valuables" at a specific index
246     *
247     * @param rep The repetition index (0-indexed)
248     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
249     */
250    public ST insertPv25_PatientValuables(int rep) throws HL7Exception { 
251        return (ST) super.insertRepetition(5, rep);
252    }
253
254
255    /**
256     * Removes a repetition of
257     * PV2-5: "Patient Valuables" at a specific index
258     *
259     * @param rep The repetition index (0-indexed)
260     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
261     */
262    public ST removePatientValuables(int rep) throws HL7Exception { 
263        return (ST) super.removeRepetition(5, rep);
264    }
265
266
267    /**
268     * Removes a repetition of
269     * PV2-5: "Patient Valuables" at a specific index
270     *
271     * @param rep The repetition index (0-indexed)
272     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
273     */
274    public ST removePv25_PatientValuables(int rep) throws HL7Exception { 
275        return (ST) super.removeRepetition(5, rep);
276    }
277
278
279
280
281    /**
282     * Returns
283     * PV2-6: "Patient Valuables Location" - creates it if necessary
284     */
285    public ST getPatientValuablesLocation() { 
286                ST retVal = this.getTypedField(6, 0);
287                return retVal;
288    }
289    
290    /**
291     * Returns
292     * PV2-6: "Patient Valuables Location" - creates it if necessary
293     */
294    public ST getPv26_PatientValuablesLocation() { 
295                ST retVal = this.getTypedField(6, 0);
296                return retVal;
297    }
298
299
300
301    /**
302     * Returns
303     * PV2-7: "Visit User Code" - creates it if necessary
304     */
305    public ID getVisitUserCode() { 
306                ID retVal = this.getTypedField(7, 0);
307                return retVal;
308    }
309    
310    /**
311     * Returns
312     * PV2-7: "Visit User Code" - creates it if necessary
313     */
314    public ID getPv27_VisitUserCode() { 
315                ID retVal = this.getTypedField(7, 0);
316                return retVal;
317    }
318
319
320
321    /**
322     * Returns
323     * PV2-8: "Expected Admit Date" - creates it if necessary
324     */
325    public DT getExpectedAdmitDate() { 
326                DT retVal = this.getTypedField(8, 0);
327                return retVal;
328    }
329    
330    /**
331     * Returns
332     * PV2-8: "Expected Admit Date" - creates it if necessary
333     */
334    public DT getPv28_ExpectedAdmitDate() { 
335                DT retVal = this.getTypedField(8, 0);
336                return retVal;
337    }
338
339
340
341    /**
342     * Returns
343     * PV2-9: "Expected Discharge Date" - creates it if necessary
344     */
345    public DT getExpectedDischargeDate() { 
346                DT retVal = this.getTypedField(9, 0);
347                return retVal;
348    }
349    
350    /**
351     * Returns
352     * PV2-9: "Expected Discharge Date" - creates it if necessary
353     */
354    public DT getPv29_ExpectedDischargeDate() { 
355                DT retVal = this.getTypedField(9, 0);
356                return retVal;
357    }
358
359
360
361
362
363    /** {@inheritDoc} */   
364    protected Type createNewTypeWithoutReflection(int field) {
365       switch (field) {
366          case 0: return new CM_INTERNAL_LOCATION(getMessage());
367          case 1: return new CE(getMessage());
368          case 2: return new CE(getMessage());
369          case 3: return new CE(getMessage());
370          case 4: return new ST(getMessage());
371          case 5: return new ST(getMessage());
372          case 6: return new ID(getMessage(), new Integer( 130 ));
373          case 7: return new DT(getMessage());
374          case 8: return new DT(getMessage());
375          default: return null;
376       }
377   }
378
379
380}
381