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.v28.segment;
035
036// import ca.uhn.hl7v2.model.v28.group.*;
037import ca.uhn.hl7v2.model.v28.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 MRG message segment (Merge Patient Information). 
050 * This segment has the following fields:</p>
051 * <ul>
052     * <li>MRG-1: Prior Patient Identifier List (CX) <b> repeating</b>
053     * <li>MRG-2: Prior Alternate Patient ID (NULLDT) <b>optional </b>
054     * <li>MRG-3: Prior Patient Account Number (CX) <b>optional </b>
055     * <li>MRG-4: Prior Patient ID (NULLDT) <b>optional </b>
056     * <li>MRG-5: Prior Visit Number (CX) <b>optional </b>
057     * <li>MRG-6: Prior Alternate Visit ID (CX) <b>optional repeating</b>
058     * <li>MRG-7: Prior Patient Name (XPN) <b>optional repeating</b>
059 * </ul>
060 */
061@SuppressWarnings("unused")
062public class MRG extends AbstractSegment {
063
064    /** 
065     * Creates a new MRG segment
066     */
067    public MRG(Group parent, ModelClassFactory factory) {
068       super(parent, factory);
069       init(factory);
070    }
071
072    private void init(ModelClassFactory factory) {
073       try {
074                                  this.add(CX.class, true, 0, 0, new Object[]{ getMessage() }, "Prior Patient Identifier List");
075                                  this.add(NULLDT.class, false, 1, 0, new Object[]{ getMessage() }, "Prior Alternate Patient ID");
076                                  this.add(CX.class, false, 1, 0, new Object[]{ getMessage() }, "Prior Patient Account Number");
077                                  this.add(NULLDT.class, false, 1, 0, new Object[]{ getMessage() }, "Prior Patient ID");
078                                  this.add(CX.class, false, 1, 0, new Object[]{ getMessage() }, "Prior Visit Number");
079                                  this.add(CX.class, false, 0, 0, new Object[]{ getMessage() }, "Prior Alternate Visit ID");
080                                  this.add(XPN.class, false, 0, 0, new Object[]{ getMessage() }, "Prior Patient Name");
081       } catch(HL7Exception e) {
082          log.error("Unexpected error creating MRG - this is probably a bug in the source code generator.", e);
083       }
084    }
085
086
087    /**
088     * Returns all repetitions of Prior Patient Identifier List (MRG-1).
089     */
090    public CX[] getPriorPatientIdentifierList() {
091        CX[] retVal = this.getTypedField(1, new CX[0]);
092        return retVal;
093    }
094
095
096    /**
097     * Returns all repetitions of Prior Patient Identifier List (MRG-1).
098     */
099    public CX[] getMrg1_PriorPatientIdentifierList() {
100        CX[] retVal = this.getTypedField(1, new CX[0]);
101        return retVal;
102    }
103
104
105    /**
106     * Returns a count of the current number of repetitions of Prior Patient Identifier List (MRG-1).
107     * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
108     * it will return zero.
109     */
110    public int getPriorPatientIdentifierListReps() {
111        return this.getReps(1);
112    }
113
114
115    /**
116     * Returns a specific repetition of
117     * MRG-1: "Prior Patient Identifier List" - creates it if necessary
118     *
119     * @param rep The repetition index (0-indexed)
120     */
121    public CX getPriorPatientIdentifierList(int rep) { 
122                CX retVal = this.getTypedField(1, rep);
123                return retVal;
124    }
125
126    /**
127     * Returns a specific repetition of
128     * MRG-1: "Prior Patient Identifier List" - creates it if necessary
129     *
130     * @param rep The repetition index (0-indexed)
131     */
132    public CX getMrg1_PriorPatientIdentifierList(int rep) { 
133                CX retVal = this.getTypedField(1, rep);
134                return retVal;
135    }
136
137    /**
138     * Returns a count of the current number of repetitions of Prior Patient Identifier List (MRG-1).
139     * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
140     * it will return zero.
141     */
142    public int getMrg1_PriorPatientIdentifierListReps() {
143        return this.getReps(1);
144    }
145
146
147    /**
148     * Inserts a repetition of
149     * MRG-1: "Prior Patient Identifier List" at a specific index
150     *
151     * @param rep The repetition index (0-indexed)
152     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
153     */
154    public CX insertPriorPatientIdentifierList(int rep) throws HL7Exception { 
155        return (CX) super.insertRepetition(1, rep);
156    }
157
158
159    /**
160     * Inserts a repetition of
161     * MRG-1: "Prior Patient Identifier List" at a specific index
162     *
163     * @param rep The repetition index (0-indexed)
164     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
165     */
166    public CX insertMrg1_PriorPatientIdentifierList(int rep) throws HL7Exception { 
167        return (CX) super.insertRepetition(1, rep);
168    }
169
170
171    /**
172     * Removes a repetition of
173     * MRG-1: "Prior Patient Identifier List" at a specific index
174     *
175     * @param rep The repetition index (0-indexed)
176     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
177     */
178    public CX removePriorPatientIdentifierList(int rep) throws HL7Exception { 
179        return (CX) super.removeRepetition(1, rep);
180    }
181
182
183    /**
184     * Removes a repetition of
185     * MRG-1: "Prior Patient Identifier List" at a specific index
186     *
187     * @param rep The repetition index (0-indexed)
188     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
189     */
190    public CX removeMrg1_PriorPatientIdentifierList(int rep) throws HL7Exception { 
191        return (CX) super.removeRepetition(1, rep);
192    }
193
194
195
196
197    /**
198     * Returns
199     * MRG-2: "Prior Alternate Patient ID" - creates it if necessary
200     */
201    public NULLDT getPriorAlternatePatientID() { 
202                NULLDT retVal = this.getTypedField(2, 0);
203                return retVal;
204    }
205    
206    /**
207     * Returns
208     * MRG-2: "Prior Alternate Patient ID" - creates it if necessary
209     */
210    public NULLDT getMrg2_PriorAlternatePatientID() { 
211                NULLDT retVal = this.getTypedField(2, 0);
212                return retVal;
213    }
214
215
216
217    /**
218     * Returns
219     * MRG-3: "Prior Patient Account Number" - creates it if necessary
220     */
221    public CX getPriorPatientAccountNumber() { 
222                CX retVal = this.getTypedField(3, 0);
223                return retVal;
224    }
225    
226    /**
227     * Returns
228     * MRG-3: "Prior Patient Account Number" - creates it if necessary
229     */
230    public CX getMrg3_PriorPatientAccountNumber() { 
231                CX retVal = this.getTypedField(3, 0);
232                return retVal;
233    }
234
235
236
237    /**
238     * Returns
239     * MRG-4: "Prior Patient ID" - creates it if necessary
240     */
241    public NULLDT getPriorPatientID() { 
242                NULLDT retVal = this.getTypedField(4, 0);
243                return retVal;
244    }
245    
246    /**
247     * Returns
248     * MRG-4: "Prior Patient ID" - creates it if necessary
249     */
250    public NULLDT getMrg4_PriorPatientID() { 
251                NULLDT retVal = this.getTypedField(4, 0);
252                return retVal;
253    }
254
255
256
257    /**
258     * Returns
259     * MRG-5: "Prior Visit Number" - creates it if necessary
260     */
261    public CX getPriorVisitNumber() { 
262                CX retVal = this.getTypedField(5, 0);
263                return retVal;
264    }
265    
266    /**
267     * Returns
268     * MRG-5: "Prior Visit Number" - creates it if necessary
269     */
270    public CX getMrg5_PriorVisitNumber() { 
271                CX retVal = this.getTypedField(5, 0);
272                return retVal;
273    }
274
275
276    /**
277     * Returns all repetitions of Prior Alternate Visit ID (MRG-6).
278     */
279    public CX[] getPriorAlternateVisitID() {
280        CX[] retVal = this.getTypedField(6, new CX[0]);
281        return retVal;
282    }
283
284
285    /**
286     * Returns all repetitions of Prior Alternate Visit ID (MRG-6).
287     */
288    public CX[] getMrg6_PriorAlternateVisitID() {
289        CX[] retVal = this.getTypedField(6, new CX[0]);
290        return retVal;
291    }
292
293
294    /**
295     * Returns a count of the current number of repetitions of Prior Alternate Visit ID (MRG-6).
296     * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
297     * it will return zero.
298     */
299    public int getPriorAlternateVisitIDReps() {
300        return this.getReps(6);
301    }
302
303
304    /**
305     * Returns a specific repetition of
306     * MRG-6: "Prior Alternate Visit ID" - creates it if necessary
307     *
308     * @param rep The repetition index (0-indexed)
309     */
310    public CX getPriorAlternateVisitID(int rep) { 
311                CX retVal = this.getTypedField(6, rep);
312                return retVal;
313    }
314
315    /**
316     * Returns a specific repetition of
317     * MRG-6: "Prior Alternate Visit ID" - creates it if necessary
318     *
319     * @param rep The repetition index (0-indexed)
320     */
321    public CX getMrg6_PriorAlternateVisitID(int rep) { 
322                CX retVal = this.getTypedField(6, rep);
323                return retVal;
324    }
325
326    /**
327     * Returns a count of the current number of repetitions of Prior Alternate Visit ID (MRG-6).
328     * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
329     * it will return zero.
330     */
331    public int getMrg6_PriorAlternateVisitIDReps() {
332        return this.getReps(6);
333    }
334
335
336    /**
337     * Inserts a repetition of
338     * MRG-6: "Prior Alternate Visit ID" at a specific index
339     *
340     * @param rep The repetition index (0-indexed)
341     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
342     */
343    public CX insertPriorAlternateVisitID(int rep) throws HL7Exception { 
344        return (CX) super.insertRepetition(6, rep);
345    }
346
347
348    /**
349     * Inserts a repetition of
350     * MRG-6: "Prior Alternate Visit ID" at a specific index
351     *
352     * @param rep The repetition index (0-indexed)
353     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
354     */
355    public CX insertMrg6_PriorAlternateVisitID(int rep) throws HL7Exception { 
356        return (CX) super.insertRepetition(6, rep);
357    }
358
359
360    /**
361     * Removes a repetition of
362     * MRG-6: "Prior Alternate Visit ID" at a specific index
363     *
364     * @param rep The repetition index (0-indexed)
365     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
366     */
367    public CX removePriorAlternateVisitID(int rep) throws HL7Exception { 
368        return (CX) super.removeRepetition(6, rep);
369    }
370
371
372    /**
373     * Removes a repetition of
374     * MRG-6: "Prior Alternate Visit ID" at a specific index
375     *
376     * @param rep The repetition index (0-indexed)
377     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
378     */
379    public CX removeMrg6_PriorAlternateVisitID(int rep) throws HL7Exception { 
380        return (CX) super.removeRepetition(6, rep);
381    }
382
383
384
385    /**
386     * Returns all repetitions of Prior Patient Name (MRG-7).
387     */
388    public XPN[] getPriorPatientName() {
389        XPN[] retVal = this.getTypedField(7, new XPN[0]);
390        return retVal;
391    }
392
393
394    /**
395     * Returns all repetitions of Prior Patient Name (MRG-7).
396     */
397    public XPN[] getMrg7_PriorPatientName() {
398        XPN[] retVal = this.getTypedField(7, new XPN[0]);
399        return retVal;
400    }
401
402
403    /**
404     * Returns a count of the current number of repetitions of Prior Patient Name (MRG-7).
405     * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
406     * it will return zero.
407     */
408    public int getPriorPatientNameReps() {
409        return this.getReps(7);
410    }
411
412
413    /**
414     * Returns a specific repetition of
415     * MRG-7: "Prior Patient Name" - creates it if necessary
416     *
417     * @param rep The repetition index (0-indexed)
418     */
419    public XPN getPriorPatientName(int rep) { 
420                XPN retVal = this.getTypedField(7, rep);
421                return retVal;
422    }
423
424    /**
425     * Returns a specific repetition of
426     * MRG-7: "Prior Patient Name" - creates it if necessary
427     *
428     * @param rep The repetition index (0-indexed)
429     */
430    public XPN getMrg7_PriorPatientName(int rep) { 
431                XPN retVal = this.getTypedField(7, rep);
432                return retVal;
433    }
434
435    /**
436     * Returns a count of the current number of repetitions of Prior Patient Name (MRG-7).
437     * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
438     * it will return zero.
439     */
440    public int getMrg7_PriorPatientNameReps() {
441        return this.getReps(7);
442    }
443
444
445    /**
446     * Inserts a repetition of
447     * MRG-7: "Prior Patient Name" at a specific index
448     *
449     * @param rep The repetition index (0-indexed)
450     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
451     */
452    public XPN insertPriorPatientName(int rep) throws HL7Exception { 
453        return (XPN) super.insertRepetition(7, rep);
454    }
455
456
457    /**
458     * Inserts a repetition of
459     * MRG-7: "Prior Patient Name" at a specific index
460     *
461     * @param rep The repetition index (0-indexed)
462     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
463     */
464    public XPN insertMrg7_PriorPatientName(int rep) throws HL7Exception { 
465        return (XPN) super.insertRepetition(7, rep);
466    }
467
468
469    /**
470     * Removes a repetition of
471     * MRG-7: "Prior Patient Name" at a specific index
472     *
473     * @param rep The repetition index (0-indexed)
474     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
475     */
476    public XPN removePriorPatientName(int rep) throws HL7Exception { 
477        return (XPN) super.removeRepetition(7, rep);
478    }
479
480
481    /**
482     * Removes a repetition of
483     * MRG-7: "Prior Patient Name" at a specific index
484     *
485     * @param rep The repetition index (0-indexed)
486     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
487     */
488    public XPN removeMrg7_PriorPatientName(int rep) throws HL7Exception { 
489        return (XPN) super.removeRepetition(7, rep);
490    }
491
492
493
494
495
496
497    /** {@inheritDoc} */   
498    protected Type createNewTypeWithoutReflection(int field) {
499       switch (field) {
500          case 0: return new CX(getMessage());
501          case 1: return new NULLDT(getMessage());
502          case 2: return new CX(getMessage());
503          case 3: return new NULLDT(getMessage());
504          case 4: return new CX(getMessage());
505          case 5: return new CX(getMessage());
506          case 6: return new XPN(getMessage());
507          default: return null;
508       }
509   }
510
511
512}
513