001package org.hl7.fhir.r4.model;
002
003/*-
004 * #%L
005 * org.hl7.fhir.r4
006 * %%
007 * Copyright (C) 2014 - 2019 Health Level 7
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023/*
024  Copyright (c) 2011+, HL7, Inc.
025  All rights reserved.
026  
027  Redistribution and use in source and binary forms, with or without modification, 
028  are permitted provided that the following conditions are met:
029  
030   * Redistributions of source code must retain the above copyright notice, this 
031     list of conditions and the following disclaimer.
032   * Redistributions in binary form must reproduce the above copyright notice, 
033     this list of conditions and the following disclaimer in the documentation 
034     and/or other materials provided with the distribution.
035   * Neither the name of HL7 nor the names of its contributors may be used to 
036     endorse or promote products derived from this software without specific 
037     prior written permission.
038  
039  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
040  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
041  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
042  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
043  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
044  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
045  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
046  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
047  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
048  POSSIBILITY OF SUCH DAMAGE.
049  
050*/
051
052// Generated on Thu, Dec 13, 2018 14:07+1100 for FHIR v4.0.0
053import java.util.ArrayList;
054import java.util.Date;
055import java.util.List;
056
057import org.hl7.fhir.exceptions.FHIRException;
058
059import ca.uhn.fhir.model.api.annotation.Child;
060import ca.uhn.fhir.model.api.annotation.Description;
061import ca.uhn.fhir.model.api.annotation.ResourceDef;
062import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
063/**
064 * This resource provides the insurance enrollment details to the insurer regarding a specified coverage.
065 */
066@ResourceDef(name="EnrollmentRequest", profile="http://hl7.org/fhir/StructureDefinition/EnrollmentRequest")
067public class EnrollmentRequest extends DomainResource {
068
069    public enum EnrollmentRequestStatus {
070        /**
071         * The instance is currently in-force.
072         */
073        ACTIVE, 
074        /**
075         * The instance is withdrawn, rescinded or reversed.
076         */
077        CANCELLED, 
078        /**
079         * A new instance the contents of which is not complete.
080         */
081        DRAFT, 
082        /**
083         * The instance was entered in error.
084         */
085        ENTEREDINERROR, 
086        /**
087         * added to help the parsers with the generic types
088         */
089        NULL;
090        public static EnrollmentRequestStatus fromCode(String codeString) throws FHIRException {
091            if (codeString == null || "".equals(codeString))
092                return null;
093        if ("active".equals(codeString))
094          return ACTIVE;
095        if ("cancelled".equals(codeString))
096          return CANCELLED;
097        if ("draft".equals(codeString))
098          return DRAFT;
099        if ("entered-in-error".equals(codeString))
100          return ENTEREDINERROR;
101        if (Configuration.isAcceptInvalidEnums())
102          return null;
103        else
104          throw new FHIRException("Unknown EnrollmentRequestStatus code '"+codeString+"'");
105        }
106        public String toCode() {
107          switch (this) {
108            case ACTIVE: return "active";
109            case CANCELLED: return "cancelled";
110            case DRAFT: return "draft";
111            case ENTEREDINERROR: return "entered-in-error";
112            default: return "?";
113          }
114        }
115        public String getSystem() {
116          switch (this) {
117            case ACTIVE: return "http://hl7.org/fhir/fm-status";
118            case CANCELLED: return "http://hl7.org/fhir/fm-status";
119            case DRAFT: return "http://hl7.org/fhir/fm-status";
120            case ENTEREDINERROR: return "http://hl7.org/fhir/fm-status";
121            default: return "?";
122          }
123        }
124        public String getDefinition() {
125          switch (this) {
126            case ACTIVE: return "The instance is currently in-force.";
127            case CANCELLED: return "The instance is withdrawn, rescinded or reversed.";
128            case DRAFT: return "A new instance the contents of which is not complete.";
129            case ENTEREDINERROR: return "The instance was entered in error.";
130            default: return "?";
131          }
132        }
133        public String getDisplay() {
134          switch (this) {
135            case ACTIVE: return "Active";
136            case CANCELLED: return "Cancelled";
137            case DRAFT: return "Draft";
138            case ENTEREDINERROR: return "Entered in Error";
139            default: return "?";
140          }
141        }
142    }
143
144  public static class EnrollmentRequestStatusEnumFactory implements EnumFactory<EnrollmentRequestStatus> {
145    public EnrollmentRequestStatus fromCode(String codeString) throws IllegalArgumentException {
146      if (codeString == null || "".equals(codeString))
147            if (codeString == null || "".equals(codeString))
148                return null;
149        if ("active".equals(codeString))
150          return EnrollmentRequestStatus.ACTIVE;
151        if ("cancelled".equals(codeString))
152          return EnrollmentRequestStatus.CANCELLED;
153        if ("draft".equals(codeString))
154          return EnrollmentRequestStatus.DRAFT;
155        if ("entered-in-error".equals(codeString))
156          return EnrollmentRequestStatus.ENTEREDINERROR;
157        throw new IllegalArgumentException("Unknown EnrollmentRequestStatus code '"+codeString+"'");
158        }
159        public Enumeration<EnrollmentRequestStatus> fromType(Base code) throws FHIRException {
160          if (code == null)
161            return null;
162          if (code.isEmpty())
163            return new Enumeration<EnrollmentRequestStatus>(this);
164          String codeString = ((PrimitiveType) code).asStringValue();
165          if (codeString == null || "".equals(codeString))
166            return null;
167        if ("active".equals(codeString))
168          return new Enumeration<EnrollmentRequestStatus>(this, EnrollmentRequestStatus.ACTIVE);
169        if ("cancelled".equals(codeString))
170          return new Enumeration<EnrollmentRequestStatus>(this, EnrollmentRequestStatus.CANCELLED);
171        if ("draft".equals(codeString))
172          return new Enumeration<EnrollmentRequestStatus>(this, EnrollmentRequestStatus.DRAFT);
173        if ("entered-in-error".equals(codeString))
174          return new Enumeration<EnrollmentRequestStatus>(this, EnrollmentRequestStatus.ENTEREDINERROR);
175        throw new FHIRException("Unknown EnrollmentRequestStatus code '"+codeString+"'");
176        }
177    public String toCode(EnrollmentRequestStatus code) {
178      if (code == EnrollmentRequestStatus.ACTIVE)
179        return "active";
180      if (code == EnrollmentRequestStatus.CANCELLED)
181        return "cancelled";
182      if (code == EnrollmentRequestStatus.DRAFT)
183        return "draft";
184      if (code == EnrollmentRequestStatus.ENTEREDINERROR)
185        return "entered-in-error";
186      return "?";
187      }
188    public String toSystem(EnrollmentRequestStatus code) {
189      return code.getSystem();
190      }
191    }
192
193    /**
194     * The Response business identifier.
195     */
196    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
197    @Description(shortDefinition="Business Identifier", formalDefinition="The Response business identifier." )
198    protected List<Identifier> identifier;
199
200    /**
201     * The status of the resource instance.
202     */
203    @Child(name = "status", type = {CodeType.class}, order=1, min=0, max=1, modifier=true, summary=true)
204    @Description(shortDefinition="active | cancelled | draft | entered-in-error", formalDefinition="The status of the resource instance." )
205    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/fm-status")
206    protected Enumeration<EnrollmentRequestStatus> status;
207
208    /**
209     * The date when this resource was created.
210     */
211    @Child(name = "created", type = {DateTimeType.class}, order=2, min=0, max=1, modifier=false, summary=false)
212    @Description(shortDefinition="Creation date", formalDefinition="The date when this resource was created." )
213    protected DateTimeType created;
214
215    /**
216     * The Insurer who is target  of the request.
217     */
218    @Child(name = "insurer", type = {Organization.class}, order=3, min=0, max=1, modifier=false, summary=false)
219    @Description(shortDefinition="Target", formalDefinition="The Insurer who is target  of the request." )
220    protected Reference insurer;
221
222    /**
223     * The actual object that is the target of the reference (The Insurer who is target  of the request.)
224     */
225    protected Organization insurerTarget;
226
227    /**
228     * The practitioner who is responsible for the services rendered to the patient.
229     */
230    @Child(name = "provider", type = {Practitioner.class, PractitionerRole.class, Organization.class}, order=4, min=0, max=1, modifier=false, summary=false)
231    @Description(shortDefinition="Responsible practitioner", formalDefinition="The practitioner who is responsible for the services rendered to the patient." )
232    protected Reference provider;
233
234    /**
235     * The actual object that is the target of the reference (The practitioner who is responsible for the services rendered to the patient.)
236     */
237    protected Resource providerTarget;
238
239    /**
240     * Patient Resource.
241     */
242    @Child(name = "candidate", type = {Patient.class}, order=5, min=0, max=1, modifier=false, summary=false)
243    @Description(shortDefinition="The subject to be enrolled", formalDefinition="Patient Resource." )
244    protected Reference candidate;
245
246    /**
247     * The actual object that is the target of the reference (Patient Resource.)
248     */
249    protected Patient candidateTarget;
250
251    /**
252     * Reference to the program or plan identification, underwriter or payor.
253     */
254    @Child(name = "coverage", type = {Coverage.class}, order=6, min=0, max=1, modifier=false, summary=false)
255    @Description(shortDefinition="Insurance information", formalDefinition="Reference to the program or plan identification, underwriter or payor." )
256    protected Reference coverage;
257
258    /**
259     * The actual object that is the target of the reference (Reference to the program or plan identification, underwriter or payor.)
260     */
261    protected Coverage coverageTarget;
262
263    private static final long serialVersionUID = 631501951L;
264
265  /**
266   * Constructor
267   */
268    public EnrollmentRequest() {
269      super();
270    }
271
272    /**
273     * @return {@link #identifier} (The Response business identifier.)
274     */
275    public List<Identifier> getIdentifier() { 
276      if (this.identifier == null)
277        this.identifier = new ArrayList<Identifier>();
278      return this.identifier;
279    }
280
281    /**
282     * @return Returns a reference to <code>this</code> for easy method chaining
283     */
284    public EnrollmentRequest setIdentifier(List<Identifier> theIdentifier) { 
285      this.identifier = theIdentifier;
286      return this;
287    }
288
289    public boolean hasIdentifier() { 
290      if (this.identifier == null)
291        return false;
292      for (Identifier item : this.identifier)
293        if (!item.isEmpty())
294          return true;
295      return false;
296    }
297
298    public Identifier addIdentifier() { //3
299      Identifier t = new Identifier();
300      if (this.identifier == null)
301        this.identifier = new ArrayList<Identifier>();
302      this.identifier.add(t);
303      return t;
304    }
305
306    public EnrollmentRequest addIdentifier(Identifier t) { //3
307      if (t == null)
308        return this;
309      if (this.identifier == null)
310        this.identifier = new ArrayList<Identifier>();
311      this.identifier.add(t);
312      return this;
313    }
314
315    /**
316     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
317     */
318    public Identifier getIdentifierFirstRep() { 
319      if (getIdentifier().isEmpty()) {
320        addIdentifier();
321      }
322      return getIdentifier().get(0);
323    }
324
325    /**
326     * @return {@link #status} (The status of the resource instance.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
327     */
328    public Enumeration<EnrollmentRequestStatus> getStatusElement() { 
329      if (this.status == null)
330        if (Configuration.errorOnAutoCreate())
331          throw new Error("Attempt to auto-create EnrollmentRequest.status");
332        else if (Configuration.doAutoCreate())
333          this.status = new Enumeration<EnrollmentRequestStatus>(new EnrollmentRequestStatusEnumFactory()); // bb
334      return this.status;
335    }
336
337    public boolean hasStatusElement() { 
338      return this.status != null && !this.status.isEmpty();
339    }
340
341    public boolean hasStatus() { 
342      return this.status != null && !this.status.isEmpty();
343    }
344
345    /**
346     * @param value {@link #status} (The status of the resource instance.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
347     */
348    public EnrollmentRequest setStatusElement(Enumeration<EnrollmentRequestStatus> value) { 
349      this.status = value;
350      return this;
351    }
352
353    /**
354     * @return The status of the resource instance.
355     */
356    public EnrollmentRequestStatus getStatus() { 
357      return this.status == null ? null : this.status.getValue();
358    }
359
360    /**
361     * @param value The status of the resource instance.
362     */
363    public EnrollmentRequest setStatus(EnrollmentRequestStatus value) { 
364      if (value == null)
365        this.status = null;
366      else {
367        if (this.status == null)
368          this.status = new Enumeration<EnrollmentRequestStatus>(new EnrollmentRequestStatusEnumFactory());
369        this.status.setValue(value);
370      }
371      return this;
372    }
373
374    /**
375     * @return {@link #created} (The date when this resource was created.). This is the underlying object with id, value and extensions. The accessor "getCreated" gives direct access to the value
376     */
377    public DateTimeType getCreatedElement() { 
378      if (this.created == null)
379        if (Configuration.errorOnAutoCreate())
380          throw new Error("Attempt to auto-create EnrollmentRequest.created");
381        else if (Configuration.doAutoCreate())
382          this.created = new DateTimeType(); // bb
383      return this.created;
384    }
385
386    public boolean hasCreatedElement() { 
387      return this.created != null && !this.created.isEmpty();
388    }
389
390    public boolean hasCreated() { 
391      return this.created != null && !this.created.isEmpty();
392    }
393
394    /**
395     * @param value {@link #created} (The date when this resource was created.). This is the underlying object with id, value and extensions. The accessor "getCreated" gives direct access to the value
396     */
397    public EnrollmentRequest setCreatedElement(DateTimeType value) { 
398      this.created = value;
399      return this;
400    }
401
402    /**
403     * @return The date when this resource was created.
404     */
405    public Date getCreated() { 
406      return this.created == null ? null : this.created.getValue();
407    }
408
409    /**
410     * @param value The date when this resource was created.
411     */
412    public EnrollmentRequest setCreated(Date value) { 
413      if (value == null)
414        this.created = null;
415      else {
416        if (this.created == null)
417          this.created = new DateTimeType();
418        this.created.setValue(value);
419      }
420      return this;
421    }
422
423    /**
424     * @return {@link #insurer} (The Insurer who is target  of the request.)
425     */
426    public Reference getInsurer() { 
427      if (this.insurer == null)
428        if (Configuration.errorOnAutoCreate())
429          throw new Error("Attempt to auto-create EnrollmentRequest.insurer");
430        else if (Configuration.doAutoCreate())
431          this.insurer = new Reference(); // cc
432      return this.insurer;
433    }
434
435    public boolean hasInsurer() { 
436      return this.insurer != null && !this.insurer.isEmpty();
437    }
438
439    /**
440     * @param value {@link #insurer} (The Insurer who is target  of the request.)
441     */
442    public EnrollmentRequest setInsurer(Reference value) { 
443      this.insurer = value;
444      return this;
445    }
446
447    /**
448     * @return {@link #insurer} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The Insurer who is target  of the request.)
449     */
450    public Organization getInsurerTarget() { 
451      if (this.insurerTarget == null)
452        if (Configuration.errorOnAutoCreate())
453          throw new Error("Attempt to auto-create EnrollmentRequest.insurer");
454        else if (Configuration.doAutoCreate())
455          this.insurerTarget = new Organization(); // aa
456      return this.insurerTarget;
457    }
458
459    /**
460     * @param value {@link #insurer} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The Insurer who is target  of the request.)
461     */
462    public EnrollmentRequest setInsurerTarget(Organization value) { 
463      this.insurerTarget = value;
464      return this;
465    }
466
467    /**
468     * @return {@link #provider} (The practitioner who is responsible for the services rendered to the patient.)
469     */
470    public Reference getProvider() { 
471      if (this.provider == null)
472        if (Configuration.errorOnAutoCreate())
473          throw new Error("Attempt to auto-create EnrollmentRequest.provider");
474        else if (Configuration.doAutoCreate())
475          this.provider = new Reference(); // cc
476      return this.provider;
477    }
478
479    public boolean hasProvider() { 
480      return this.provider != null && !this.provider.isEmpty();
481    }
482
483    /**
484     * @param value {@link #provider} (The practitioner who is responsible for the services rendered to the patient.)
485     */
486    public EnrollmentRequest setProvider(Reference value) { 
487      this.provider = value;
488      return this;
489    }
490
491    /**
492     * @return {@link #provider} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The practitioner who is responsible for the services rendered to the patient.)
493     */
494    public Resource getProviderTarget() { 
495      return this.providerTarget;
496    }
497
498    /**
499     * @param value {@link #provider} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The practitioner who is responsible for the services rendered to the patient.)
500     */
501    public EnrollmentRequest setProviderTarget(Resource value) { 
502      this.providerTarget = value;
503      return this;
504    }
505
506    /**
507     * @return {@link #candidate} (Patient Resource.)
508     */
509    public Reference getCandidate() { 
510      if (this.candidate == null)
511        if (Configuration.errorOnAutoCreate())
512          throw new Error("Attempt to auto-create EnrollmentRequest.candidate");
513        else if (Configuration.doAutoCreate())
514          this.candidate = new Reference(); // cc
515      return this.candidate;
516    }
517
518    public boolean hasCandidate() { 
519      return this.candidate != null && !this.candidate.isEmpty();
520    }
521
522    /**
523     * @param value {@link #candidate} (Patient Resource.)
524     */
525    public EnrollmentRequest setCandidate(Reference value) { 
526      this.candidate = value;
527      return this;
528    }
529
530    /**
531     * @return {@link #candidate} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Patient Resource.)
532     */
533    public Patient getCandidateTarget() { 
534      if (this.candidateTarget == null)
535        if (Configuration.errorOnAutoCreate())
536          throw new Error("Attempt to auto-create EnrollmentRequest.candidate");
537        else if (Configuration.doAutoCreate())
538          this.candidateTarget = new Patient(); // aa
539      return this.candidateTarget;
540    }
541
542    /**
543     * @param value {@link #candidate} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Patient Resource.)
544     */
545    public EnrollmentRequest setCandidateTarget(Patient value) { 
546      this.candidateTarget = value;
547      return this;
548    }
549
550    /**
551     * @return {@link #coverage} (Reference to the program or plan identification, underwriter or payor.)
552     */
553    public Reference getCoverage() { 
554      if (this.coverage == null)
555        if (Configuration.errorOnAutoCreate())
556          throw new Error("Attempt to auto-create EnrollmentRequest.coverage");
557        else if (Configuration.doAutoCreate())
558          this.coverage = new Reference(); // cc
559      return this.coverage;
560    }
561
562    public boolean hasCoverage() { 
563      return this.coverage != null && !this.coverage.isEmpty();
564    }
565
566    /**
567     * @param value {@link #coverage} (Reference to the program or plan identification, underwriter or payor.)
568     */
569    public EnrollmentRequest setCoverage(Reference value) { 
570      this.coverage = value;
571      return this;
572    }
573
574    /**
575     * @return {@link #coverage} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Reference to the program or plan identification, underwriter or payor.)
576     */
577    public Coverage getCoverageTarget() { 
578      if (this.coverageTarget == null)
579        if (Configuration.errorOnAutoCreate())
580          throw new Error("Attempt to auto-create EnrollmentRequest.coverage");
581        else if (Configuration.doAutoCreate())
582          this.coverageTarget = new Coverage(); // aa
583      return this.coverageTarget;
584    }
585
586    /**
587     * @param value {@link #coverage} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Reference to the program or plan identification, underwriter or payor.)
588     */
589    public EnrollmentRequest setCoverageTarget(Coverage value) { 
590      this.coverageTarget = value;
591      return this;
592    }
593
594      protected void listChildren(List<Property> children) {
595        super.listChildren(children);
596        children.add(new Property("identifier", "Identifier", "The Response business identifier.", 0, java.lang.Integer.MAX_VALUE, identifier));
597        children.add(new Property("status", "code", "The status of the resource instance.", 0, 1, status));
598        children.add(new Property("created", "dateTime", "The date when this resource was created.", 0, 1, created));
599        children.add(new Property("insurer", "Reference(Organization)", "The Insurer who is target  of the request.", 0, 1, insurer));
600        children.add(new Property("provider", "Reference(Practitioner|PractitionerRole|Organization)", "The practitioner who is responsible for the services rendered to the patient.", 0, 1, provider));
601        children.add(new Property("candidate", "Reference(Patient)", "Patient Resource.", 0, 1, candidate));
602        children.add(new Property("coverage", "Reference(Coverage)", "Reference to the program or plan identification, underwriter or payor.", 0, 1, coverage));
603      }
604
605      @Override
606      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
607        switch (_hash) {
608        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "The Response business identifier.", 0, java.lang.Integer.MAX_VALUE, identifier);
609        case -892481550: /*status*/  return new Property("status", "code", "The status of the resource instance.", 0, 1, status);
610        case 1028554472: /*created*/  return new Property("created", "dateTime", "The date when this resource was created.", 0, 1, created);
611        case 1957615864: /*insurer*/  return new Property("insurer", "Reference(Organization)", "The Insurer who is target  of the request.", 0, 1, insurer);
612        case -987494927: /*provider*/  return new Property("provider", "Reference(Practitioner|PractitionerRole|Organization)", "The practitioner who is responsible for the services rendered to the patient.", 0, 1, provider);
613        case 508663171: /*candidate*/  return new Property("candidate", "Reference(Patient)", "Patient Resource.", 0, 1, candidate);
614        case -351767064: /*coverage*/  return new Property("coverage", "Reference(Coverage)", "Reference to the program or plan identification, underwriter or payor.", 0, 1, coverage);
615        default: return super.getNamedProperty(_hash, _name, _checkValid);
616        }
617
618      }
619
620      @Override
621      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
622        switch (hash) {
623        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
624        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<EnrollmentRequestStatus>
625        case 1028554472: /*created*/ return this.created == null ? new Base[0] : new Base[] {this.created}; // DateTimeType
626        case 1957615864: /*insurer*/ return this.insurer == null ? new Base[0] : new Base[] {this.insurer}; // Reference
627        case -987494927: /*provider*/ return this.provider == null ? new Base[0] : new Base[] {this.provider}; // Reference
628        case 508663171: /*candidate*/ return this.candidate == null ? new Base[0] : new Base[] {this.candidate}; // Reference
629        case -351767064: /*coverage*/ return this.coverage == null ? new Base[0] : new Base[] {this.coverage}; // Reference
630        default: return super.getProperty(hash, name, checkValid);
631        }
632
633      }
634
635      @Override
636      public Base setProperty(int hash, String name, Base value) throws FHIRException {
637        switch (hash) {
638        case -1618432855: // identifier
639          this.getIdentifier().add(castToIdentifier(value)); // Identifier
640          return value;
641        case -892481550: // status
642          value = new EnrollmentRequestStatusEnumFactory().fromType(castToCode(value));
643          this.status = (Enumeration) value; // Enumeration<EnrollmentRequestStatus>
644          return value;
645        case 1028554472: // created
646          this.created = castToDateTime(value); // DateTimeType
647          return value;
648        case 1957615864: // insurer
649          this.insurer = castToReference(value); // Reference
650          return value;
651        case -987494927: // provider
652          this.provider = castToReference(value); // Reference
653          return value;
654        case 508663171: // candidate
655          this.candidate = castToReference(value); // Reference
656          return value;
657        case -351767064: // coverage
658          this.coverage = castToReference(value); // Reference
659          return value;
660        default: return super.setProperty(hash, name, value);
661        }
662
663      }
664
665      @Override
666      public Base setProperty(String name, Base value) throws FHIRException {
667        if (name.equals("identifier")) {
668          this.getIdentifier().add(castToIdentifier(value));
669        } else if (name.equals("status")) {
670          value = new EnrollmentRequestStatusEnumFactory().fromType(castToCode(value));
671          this.status = (Enumeration) value; // Enumeration<EnrollmentRequestStatus>
672        } else if (name.equals("created")) {
673          this.created = castToDateTime(value); // DateTimeType
674        } else if (name.equals("insurer")) {
675          this.insurer = castToReference(value); // Reference
676        } else if (name.equals("provider")) {
677          this.provider = castToReference(value); // Reference
678        } else if (name.equals("candidate")) {
679          this.candidate = castToReference(value); // Reference
680        } else if (name.equals("coverage")) {
681          this.coverage = castToReference(value); // Reference
682        } else
683          return super.setProperty(name, value);
684        return value;
685      }
686
687      @Override
688      public Base makeProperty(int hash, String name) throws FHIRException {
689        switch (hash) {
690        case -1618432855:  return addIdentifier(); 
691        case -892481550:  return getStatusElement();
692        case 1028554472:  return getCreatedElement();
693        case 1957615864:  return getInsurer(); 
694        case -987494927:  return getProvider(); 
695        case 508663171:  return getCandidate(); 
696        case -351767064:  return getCoverage(); 
697        default: return super.makeProperty(hash, name);
698        }
699
700      }
701
702      @Override
703      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
704        switch (hash) {
705        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
706        case -892481550: /*status*/ return new String[] {"code"};
707        case 1028554472: /*created*/ return new String[] {"dateTime"};
708        case 1957615864: /*insurer*/ return new String[] {"Reference"};
709        case -987494927: /*provider*/ return new String[] {"Reference"};
710        case 508663171: /*candidate*/ return new String[] {"Reference"};
711        case -351767064: /*coverage*/ return new String[] {"Reference"};
712        default: return super.getTypesForProperty(hash, name);
713        }
714
715      }
716
717      @Override
718      public Base addChild(String name) throws FHIRException {
719        if (name.equals("identifier")) {
720          return addIdentifier();
721        }
722        else if (name.equals("status")) {
723          throw new FHIRException("Cannot call addChild on a primitive type EnrollmentRequest.status");
724        }
725        else if (name.equals("created")) {
726          throw new FHIRException("Cannot call addChild on a primitive type EnrollmentRequest.created");
727        }
728        else if (name.equals("insurer")) {
729          this.insurer = new Reference();
730          return this.insurer;
731        }
732        else if (name.equals("provider")) {
733          this.provider = new Reference();
734          return this.provider;
735        }
736        else if (name.equals("candidate")) {
737          this.candidate = new Reference();
738          return this.candidate;
739        }
740        else if (name.equals("coverage")) {
741          this.coverage = new Reference();
742          return this.coverage;
743        }
744        else
745          return super.addChild(name);
746      }
747
748  public String fhirType() {
749    return "EnrollmentRequest";
750
751  }
752
753      public EnrollmentRequest copy() {
754        EnrollmentRequest dst = new EnrollmentRequest();
755        copyValues(dst);
756        if (identifier != null) {
757          dst.identifier = new ArrayList<Identifier>();
758          for (Identifier i : identifier)
759            dst.identifier.add(i.copy());
760        };
761        dst.status = status == null ? null : status.copy();
762        dst.created = created == null ? null : created.copy();
763        dst.insurer = insurer == null ? null : insurer.copy();
764        dst.provider = provider == null ? null : provider.copy();
765        dst.candidate = candidate == null ? null : candidate.copy();
766        dst.coverage = coverage == null ? null : coverage.copy();
767        return dst;
768      }
769
770      protected EnrollmentRequest typedCopy() {
771        return copy();
772      }
773
774      @Override
775      public boolean equalsDeep(Base other_) {
776        if (!super.equalsDeep(other_))
777          return false;
778        if (!(other_ instanceof EnrollmentRequest))
779          return false;
780        EnrollmentRequest o = (EnrollmentRequest) other_;
781        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(created, o.created, true)
782           && compareDeep(insurer, o.insurer, true) && compareDeep(provider, o.provider, true) && compareDeep(candidate, o.candidate, true)
783           && compareDeep(coverage, o.coverage, true);
784      }
785
786      @Override
787      public boolean equalsShallow(Base other_) {
788        if (!super.equalsShallow(other_))
789          return false;
790        if (!(other_ instanceof EnrollmentRequest))
791          return false;
792        EnrollmentRequest o = (EnrollmentRequest) other_;
793        return compareValues(status, o.status, true) && compareValues(created, o.created, true);
794      }
795
796      public boolean isEmpty() {
797        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, created
798          , insurer, provider, candidate, coverage);
799      }
800
801  @Override
802  public ResourceType getResourceType() {
803    return ResourceType.EnrollmentRequest;
804   }
805
806 /**
807   * Search parameter: <b>identifier</b>
808   * <p>
809   * Description: <b>The business identifier of the Enrollment</b><br>
810   * Type: <b>token</b><br>
811   * Path: <b>EnrollmentRequest.identifier</b><br>
812   * </p>
813   */
814  @SearchParamDefinition(name="identifier", path="EnrollmentRequest.identifier", description="The business identifier of the Enrollment", type="token" )
815  public static final String SP_IDENTIFIER = "identifier";
816 /**
817   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
818   * <p>
819   * Description: <b>The business identifier of the Enrollment</b><br>
820   * Type: <b>token</b><br>
821   * Path: <b>EnrollmentRequest.identifier</b><br>
822   * </p>
823   */
824  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
825
826 /**
827   * Search parameter: <b>subject</b>
828   * <p>
829   * Description: <b>The party to be enrolled</b><br>
830   * Type: <b>reference</b><br>
831   * Path: <b>EnrollmentRequest.candidate</b><br>
832   * </p>
833   */
834  @SearchParamDefinition(name="subject", path="EnrollmentRequest.candidate", description="The party to be enrolled", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Patient.class } )
835  public static final String SP_SUBJECT = "subject";
836 /**
837   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
838   * <p>
839   * Description: <b>The party to be enrolled</b><br>
840   * Type: <b>reference</b><br>
841   * Path: <b>EnrollmentRequest.candidate</b><br>
842   * </p>
843   */
844  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
845
846/**
847   * Constant for fluent queries to be used to add include statements. Specifies
848   * the path value of "<b>EnrollmentRequest:subject</b>".
849   */
850  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("EnrollmentRequest:subject").toLocked();
851
852 /**
853   * Search parameter: <b>patient</b>
854   * <p>
855   * Description: <b>The party to be enrolled</b><br>
856   * Type: <b>reference</b><br>
857   * Path: <b>EnrollmentRequest.candidate</b><br>
858   * </p>
859   */
860  @SearchParamDefinition(name="patient", path="EnrollmentRequest.candidate", description="The party to be enrolled", type="reference", target={Patient.class } )
861  public static final String SP_PATIENT = "patient";
862 /**
863   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
864   * <p>
865   * Description: <b>The party to be enrolled</b><br>
866   * Type: <b>reference</b><br>
867   * Path: <b>EnrollmentRequest.candidate</b><br>
868   * </p>
869   */
870  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
871
872/**
873   * Constant for fluent queries to be used to add include statements. Specifies
874   * the path value of "<b>EnrollmentRequest:patient</b>".
875   */
876  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("EnrollmentRequest:patient").toLocked();
877
878 /**
879   * Search parameter: <b>status</b>
880   * <p>
881   * Description: <b>The status of the enrollment</b><br>
882   * Type: <b>token</b><br>
883   * Path: <b>EnrollmentRequest.status</b><br>
884   * </p>
885   */
886  @SearchParamDefinition(name="status", path="EnrollmentRequest.status", description="The status of the enrollment", type="token" )
887  public static final String SP_STATUS = "status";
888 /**
889   * <b>Fluent Client</b> search parameter constant for <b>status</b>
890   * <p>
891   * Description: <b>The status of the enrollment</b><br>
892   * Type: <b>token</b><br>
893   * Path: <b>EnrollmentRequest.status</b><br>
894   * </p>
895   */
896  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
897
898
899}
900