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