001package org.hl7.fhir.r4.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
033import java.util.ArrayList;
034import java.util.List;
035
036import org.hl7.fhir.exceptions.FHIRException;
037import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
038import org.hl7.fhir.utilities.Utilities;
039
040import ca.uhn.fhir.model.api.annotation.Block;
041import ca.uhn.fhir.model.api.annotation.Child;
042import ca.uhn.fhir.model.api.annotation.Description;
043import ca.uhn.fhir.model.api.annotation.ResourceDef;
044import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
045
046/**
047 * Financial instrument which may be used to reimburse or pay for health care
048 * products and services. Includes both insurance and self-payment.
049 */
050@ResourceDef(name = "Coverage", profile = "http://hl7.org/fhir/StructureDefinition/Coverage")
051public class Coverage extends DomainResource {
052
053  public enum CoverageStatus {
054    /**
055     * The instance is currently in-force.
056     */
057    ACTIVE,
058    /**
059     * The instance is withdrawn, rescinded or reversed.
060     */
061    CANCELLED,
062    /**
063     * A new instance the contents of which is not complete.
064     */
065    DRAFT,
066    /**
067     * The instance was entered in error.
068     */
069    ENTEREDINERROR,
070    /**
071     * added to help the parsers with the generic types
072     */
073    NULL;
074
075    public static CoverageStatus fromCode(String codeString) throws FHIRException {
076      if (codeString == null || "".equals(codeString))
077        return null;
078      if ("active".equals(codeString))
079        return ACTIVE;
080      if ("cancelled".equals(codeString))
081        return CANCELLED;
082      if ("draft".equals(codeString))
083        return DRAFT;
084      if ("entered-in-error".equals(codeString))
085        return ENTEREDINERROR;
086      if (Configuration.isAcceptInvalidEnums())
087        return null;
088      else
089        throw new FHIRException("Unknown CoverageStatus code '" + codeString + "'");
090    }
091
092    public String toCode() {
093      switch (this) {
094      case ACTIVE:
095        return "active";
096      case CANCELLED:
097        return "cancelled";
098      case DRAFT:
099        return "draft";
100      case ENTEREDINERROR:
101        return "entered-in-error";
102      case NULL:
103        return null;
104      default:
105        return "?";
106      }
107    }
108
109    public String getSystem() {
110      switch (this) {
111      case ACTIVE:
112        return "http://hl7.org/fhir/fm-status";
113      case CANCELLED:
114        return "http://hl7.org/fhir/fm-status";
115      case DRAFT:
116        return "http://hl7.org/fhir/fm-status";
117      case ENTEREDINERROR:
118        return "http://hl7.org/fhir/fm-status";
119      case NULL:
120        return null;
121      default:
122        return "?";
123      }
124    }
125
126    public String getDefinition() {
127      switch (this) {
128      case ACTIVE:
129        return "The instance is currently in-force.";
130      case CANCELLED:
131        return "The instance is withdrawn, rescinded or reversed.";
132      case DRAFT:
133        return "A new instance the contents of which is not complete.";
134      case ENTEREDINERROR:
135        return "The instance was entered in error.";
136      case NULL:
137        return null;
138      default:
139        return "?";
140      }
141    }
142
143    public String getDisplay() {
144      switch (this) {
145      case ACTIVE:
146        return "Active";
147      case CANCELLED:
148        return "Cancelled";
149      case DRAFT:
150        return "Draft";
151      case ENTEREDINERROR:
152        return "Entered in Error";
153      case NULL:
154        return null;
155      default:
156        return "?";
157      }
158    }
159  }
160
161  public static class CoverageStatusEnumFactory implements EnumFactory<CoverageStatus> {
162    public CoverageStatus fromCode(String codeString) throws IllegalArgumentException {
163      if (codeString == null || "".equals(codeString))
164        if (codeString == null || "".equals(codeString))
165          return null;
166      if ("active".equals(codeString))
167        return CoverageStatus.ACTIVE;
168      if ("cancelled".equals(codeString))
169        return CoverageStatus.CANCELLED;
170      if ("draft".equals(codeString))
171        return CoverageStatus.DRAFT;
172      if ("entered-in-error".equals(codeString))
173        return CoverageStatus.ENTEREDINERROR;
174      throw new IllegalArgumentException("Unknown CoverageStatus code '" + codeString + "'");
175    }
176
177    public Enumeration<CoverageStatus> fromType(PrimitiveType<?> code) throws FHIRException {
178      if (code == null)
179        return null;
180      if (code.isEmpty())
181        return new Enumeration<CoverageStatus>(this, CoverageStatus.NULL, code);
182      String codeString = code.asStringValue();
183      if (codeString == null || "".equals(codeString))
184        return new Enumeration<CoverageStatus>(this, CoverageStatus.NULL, code);
185      if ("active".equals(codeString))
186        return new Enumeration<CoverageStatus>(this, CoverageStatus.ACTIVE, code);
187      if ("cancelled".equals(codeString))
188        return new Enumeration<CoverageStatus>(this, CoverageStatus.CANCELLED, code);
189      if ("draft".equals(codeString))
190        return new Enumeration<CoverageStatus>(this, CoverageStatus.DRAFT, code);
191      if ("entered-in-error".equals(codeString))
192        return new Enumeration<CoverageStatus>(this, CoverageStatus.ENTEREDINERROR, code);
193      throw new FHIRException("Unknown CoverageStatus code '" + codeString + "'");
194    }
195
196    public String toCode(CoverageStatus code) {
197      if (code == CoverageStatus.ACTIVE)
198        return "active";
199      if (code == CoverageStatus.CANCELLED)
200        return "cancelled";
201      if (code == CoverageStatus.DRAFT)
202        return "draft";
203      if (code == CoverageStatus.ENTEREDINERROR)
204        return "entered-in-error";
205      return "?";
206    }
207
208    public String toSystem(CoverageStatus code) {
209      return code.getSystem();
210    }
211  }
212
213  @Block()
214  public static class ClassComponent extends BackboneElement implements IBaseBackboneElement {
215    /**
216     * The type of classification for which an insurer-specific class label or
217     * number and optional name is provided, for example may be used to identify a
218     * class of coverage or employer group, Policy, Plan.
219     */
220    @Child(name = "type", type = {
221        CodeableConcept.class }, order = 1, min = 1, max = 1, modifier = false, summary = true)
222    @Description(shortDefinition = "Type of class such as 'group' or 'plan'", formalDefinition = "The type of classification for which an insurer-specific class label or number and optional name is provided, for example may be used to identify a class of coverage or employer group, Policy, Plan.")
223    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/coverage-class")
224    protected CodeableConcept type;
225
226    /**
227     * The alphanumeric string value associated with the insurer issued label.
228     */
229    @Child(name = "value", type = { StringType.class }, order = 2, min = 1, max = 1, modifier = false, summary = true)
230    @Description(shortDefinition = "Value associated with the type", formalDefinition = "The alphanumeric string value associated with the insurer issued label.")
231    protected StringType value;
232
233    /**
234     * A short description for the class.
235     */
236    @Child(name = "name", type = { StringType.class }, order = 3, min = 0, max = 1, modifier = false, summary = true)
237    @Description(shortDefinition = "Human readable description of the type and value", formalDefinition = "A short description for the class.")
238    protected StringType name;
239
240    private static final long serialVersionUID = -1501519769L;
241
242    /**
243     * Constructor
244     */
245    public ClassComponent() {
246      super();
247    }
248
249    /**
250     * Constructor
251     */
252    public ClassComponent(CodeableConcept type, StringType value) {
253      super();
254      this.type = type;
255      this.value = value;
256    }
257
258    /**
259     * @return {@link #type} (The type of classification for which an
260     *         insurer-specific class label or number and optional name is provided,
261     *         for example may be used to identify a class of coverage or employer
262     *         group, Policy, Plan.)
263     */
264    public CodeableConcept getType() {
265      if (this.type == null)
266        if (Configuration.errorOnAutoCreate())
267          throw new Error("Attempt to auto-create ClassComponent.type");
268        else if (Configuration.doAutoCreate())
269          this.type = new CodeableConcept(); // cc
270      return this.type;
271    }
272
273    public boolean hasType() {
274      return this.type != null && !this.type.isEmpty();
275    }
276
277    /**
278     * @param value {@link #type} (The type of classification for which an
279     *              insurer-specific class label or number and optional name is
280     *              provided, for example may be used to identify a class of
281     *              coverage or employer group, Policy, Plan.)
282     */
283    public ClassComponent setType(CodeableConcept value) {
284      this.type = value;
285      return this;
286    }
287
288    /**
289     * @return {@link #value} (The alphanumeric string value associated with the
290     *         insurer issued label.). This is the underlying object with id, value
291     *         and extensions. The accessor "getValue" gives direct access to the
292     *         value
293     */
294    public StringType getValueElement() {
295      if (this.value == null)
296        if (Configuration.errorOnAutoCreate())
297          throw new Error("Attempt to auto-create ClassComponent.value");
298        else if (Configuration.doAutoCreate())
299          this.value = new StringType(); // bb
300      return this.value;
301    }
302
303    public boolean hasValueElement() {
304      return this.value != null && !this.value.isEmpty();
305    }
306
307    public boolean hasValue() {
308      return this.value != null && !this.value.isEmpty();
309    }
310
311    /**
312     * @param value {@link #value} (The alphanumeric string value associated with
313     *              the insurer issued label.). This is the underlying object with
314     *              id, value and extensions. The accessor "getValue" gives direct
315     *              access to the value
316     */
317    public ClassComponent setValueElement(StringType value) {
318      this.value = value;
319      return this;
320    }
321
322    /**
323     * @return The alphanumeric string value associated with the insurer issued
324     *         label.
325     */
326    public String getValue() {
327      return this.value == null ? null : this.value.getValue();
328    }
329
330    /**
331     * @param value The alphanumeric string value associated with the insurer issued
332     *              label.
333     */
334    public ClassComponent setValue(String value) {
335      if (this.value == null)
336        this.value = new StringType();
337      this.value.setValue(value);
338      return this;
339    }
340
341    /**
342     * @return {@link #name} (A short description for the class.). This is the
343     *         underlying object with id, value and extensions. The accessor
344     *         "getName" gives direct access to the value
345     */
346    public StringType getNameElement() {
347      if (this.name == null)
348        if (Configuration.errorOnAutoCreate())
349          throw new Error("Attempt to auto-create ClassComponent.name");
350        else if (Configuration.doAutoCreate())
351          this.name = new StringType(); // bb
352      return this.name;
353    }
354
355    public boolean hasNameElement() {
356      return this.name != null && !this.name.isEmpty();
357    }
358
359    public boolean hasName() {
360      return this.name != null && !this.name.isEmpty();
361    }
362
363    /**
364     * @param value {@link #name} (A short description for the class.). This is the
365     *              underlying object with id, value and extensions. The accessor
366     *              "getName" gives direct access to the value
367     */
368    public ClassComponent setNameElement(StringType value) {
369      this.name = value;
370      return this;
371    }
372
373    /**
374     * @return A short description for the class.
375     */
376    public String getName() {
377      return this.name == null ? null : this.name.getValue();
378    }
379
380    /**
381     * @param value A short description for the class.
382     */
383    public ClassComponent setName(String value) {
384      if (Utilities.noString(value))
385        this.name = null;
386      else {
387        if (this.name == null)
388          this.name = new StringType();
389        this.name.setValue(value);
390      }
391      return this;
392    }
393
394    protected void listChildren(List<Property> children) {
395      super.listChildren(children);
396      children.add(new Property("type", "CodeableConcept",
397          "The type of classification for which an insurer-specific class label or number and optional name is provided, for example may be used to identify a class of coverage or employer group, Policy, Plan.",
398          0, 1, type));
399      children.add(new Property("value", "string",
400          "The alphanumeric string value associated with the insurer issued label.", 0, 1, value));
401      children.add(new Property("name", "string", "A short description for the class.", 0, 1, name));
402    }
403
404    @Override
405    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
406      switch (_hash) {
407      case 3575610:
408        /* type */ return new Property("type", "CodeableConcept",
409            "The type of classification for which an insurer-specific class label or number and optional name is provided, for example may be used to identify a class of coverage or employer group, Policy, Plan.",
410            0, 1, type);
411      case 111972721:
412        /* value */ return new Property("value", "string",
413            "The alphanumeric string value associated with the insurer issued label.", 0, 1, value);
414      case 3373707:
415        /* name */ return new Property("name", "string", "A short description for the class.", 0, 1, name);
416      default:
417        return super.getNamedProperty(_hash, _name, _checkValid);
418      }
419
420    }
421
422    @Override
423    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
424      switch (hash) {
425      case 3575610:
426        /* type */ return this.type == null ? new Base[0] : new Base[] { this.type }; // CodeableConcept
427      case 111972721:
428        /* value */ return this.value == null ? new Base[0] : new Base[] { this.value }; // StringType
429      case 3373707:
430        /* name */ return this.name == null ? new Base[0] : new Base[] { this.name }; // StringType
431      default:
432        return super.getProperty(hash, name, checkValid);
433      }
434
435    }
436
437    @Override
438    public Base setProperty(int hash, String name, Base value) throws FHIRException {
439      switch (hash) {
440      case 3575610: // type
441        this.type = castToCodeableConcept(value); // CodeableConcept
442        return value;
443      case 111972721: // value
444        this.value = castToString(value); // StringType
445        return value;
446      case 3373707: // name
447        this.name = castToString(value); // StringType
448        return value;
449      default:
450        return super.setProperty(hash, name, value);
451      }
452
453    }
454
455    @Override
456    public Base setProperty(String name, Base value) throws FHIRException {
457      if (name.equals("type")) {
458        this.type = castToCodeableConcept(value); // CodeableConcept
459      } else if (name.equals("value")) {
460        this.value = castToString(value); // StringType
461      } else if (name.equals("name")) {
462        this.name = castToString(value); // StringType
463      } else
464        return super.setProperty(name, value);
465      return value;
466    }
467
468  @Override
469  public void removeChild(String name, Base value) throws FHIRException {
470      if (name.equals("type")) {
471        this.type = null;
472      } else if (name.equals("value")) {
473        this.value = null;
474      } else if (name.equals("name")) {
475        this.name = null;
476      } else
477        super.removeChild(name, value);
478      
479    }
480
481    @Override
482    public Base makeProperty(int hash, String name) throws FHIRException {
483      switch (hash) {
484      case 3575610:
485        return getType();
486      case 111972721:
487        return getValueElement();
488      case 3373707:
489        return getNameElement();
490      default:
491        return super.makeProperty(hash, name);
492      }
493
494    }
495
496    @Override
497    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
498      switch (hash) {
499      case 3575610:
500        /* type */ return new String[] { "CodeableConcept" };
501      case 111972721:
502        /* value */ return new String[] { "string" };
503      case 3373707:
504        /* name */ return new String[] { "string" };
505      default:
506        return super.getTypesForProperty(hash, name);
507      }
508
509    }
510
511    @Override
512    public Base addChild(String name) throws FHIRException {
513      if (name.equals("type")) {
514        this.type = new CodeableConcept();
515        return this.type;
516      } else if (name.equals("value")) {
517        throw new FHIRException("Cannot call addChild on a singleton property Coverage.value");
518      } else if (name.equals("name")) {
519        throw new FHIRException("Cannot call addChild on a singleton property Coverage.name");
520      } else
521        return super.addChild(name);
522    }
523
524    public ClassComponent copy() {
525      ClassComponent dst = new ClassComponent();
526      copyValues(dst);
527      return dst;
528    }
529
530    public void copyValues(ClassComponent dst) {
531      super.copyValues(dst);
532      dst.type = type == null ? null : type.copy();
533      dst.value = value == null ? null : value.copy();
534      dst.name = name == null ? null : name.copy();
535    }
536
537    @Override
538    public boolean equalsDeep(Base other_) {
539      if (!super.equalsDeep(other_))
540        return false;
541      if (!(other_ instanceof ClassComponent))
542        return false;
543      ClassComponent o = (ClassComponent) other_;
544      return compareDeep(type, o.type, true) && compareDeep(value, o.value, true) && compareDeep(name, o.name, true);
545    }
546
547    @Override
548    public boolean equalsShallow(Base other_) {
549      if (!super.equalsShallow(other_))
550        return false;
551      if (!(other_ instanceof ClassComponent))
552        return false;
553      ClassComponent o = (ClassComponent) other_;
554      return compareValues(value, o.value, true) && compareValues(name, o.name, true);
555    }
556
557    public boolean isEmpty() {
558      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, value, name);
559    }
560
561    public String fhirType() {
562      return "Coverage.class";
563
564    }
565
566  }
567
568  @Block()
569  public static class CostToBeneficiaryComponent extends BackboneElement implements IBaseBackboneElement {
570    /**
571     * The category of patient centric costs associated with treatment.
572     */
573    @Child(name = "type", type = {
574        CodeableConcept.class }, order = 1, min = 0, max = 1, modifier = false, summary = true)
575    @Description(shortDefinition = "Cost category", formalDefinition = "The category of patient centric costs associated with treatment.")
576    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/coverage-copay-type")
577    protected CodeableConcept type;
578
579    /**
580     * The amount due from the patient for the cost category.
581     */
582    @Child(name = "value", type = { Quantity.class,
583        Money.class }, order = 2, min = 1, max = 1, modifier = false, summary = true)
584    @Description(shortDefinition = "The amount or percentage due from the beneficiary", formalDefinition = "The amount due from the patient for the cost category.")
585    protected Type value;
586
587    /**
588     * A suite of codes indicating exceptions or reductions to patient costs and
589     * their effective periods.
590     */
591    @Child(name = "exception", type = {}, order = 3, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
592    @Description(shortDefinition = "Exceptions for patient payments", formalDefinition = "A suite of codes indicating exceptions or reductions to patient costs and their effective periods.")
593    protected List<ExemptionComponent> exception;
594
595    private static final long serialVersionUID = -1302829059L;
596
597    /**
598     * Constructor
599     */
600    public CostToBeneficiaryComponent() {
601      super();
602    }
603
604    /**
605     * Constructor
606     */
607    public CostToBeneficiaryComponent(Type value) {
608      super();
609      this.value = value;
610    }
611
612    /**
613     * @return {@link #type} (The category of patient centric costs associated with
614     *         treatment.)
615     */
616    public CodeableConcept getType() {
617      if (this.type == null)
618        if (Configuration.errorOnAutoCreate())
619          throw new Error("Attempt to auto-create CostToBeneficiaryComponent.type");
620        else if (Configuration.doAutoCreate())
621          this.type = new CodeableConcept(); // cc
622      return this.type;
623    }
624
625    public boolean hasType() {
626      return this.type != null && !this.type.isEmpty();
627    }
628
629    /**
630     * @param value {@link #type} (The category of patient centric costs associated
631     *              with treatment.)
632     */
633    public CostToBeneficiaryComponent setType(CodeableConcept value) {
634      this.type = value;
635      return this;
636    }
637
638    /**
639     * @return {@link #value} (The amount due from the patient for the cost
640     *         category.)
641     */
642    public Type getValue() {
643      return this.value;
644    }
645
646    /**
647     * @return {@link #value} (The amount due from the patient for the cost
648     *         category.)
649     */
650    public Quantity getValueQuantity() throws FHIRException {
651      if (this.value == null)
652        this.value = new Quantity();
653      if (!(this.value instanceof Quantity))
654        throw new FHIRException("Type mismatch: the type Quantity was expected, but " + this.value.getClass().getName()
655            + " was encountered");
656      return (Quantity) this.value;
657    }
658
659    public boolean hasValueQuantity() {
660      return this != null && this.value instanceof Quantity;
661    }
662
663    /**
664     * @return {@link #value} (The amount due from the patient for the cost
665     *         category.)
666     */
667    public Money getValueMoney() throws FHIRException {
668      if (this.value == null)
669        this.value = new Money();
670      if (!(this.value instanceof Money))
671        throw new FHIRException(
672            "Type mismatch: the type Money was expected, but " + this.value.getClass().getName() + " was encountered");
673      return (Money) this.value;
674    }
675
676    public boolean hasValueMoney() {
677      return this != null && this.value instanceof Money;
678    }
679
680    public boolean hasValue() {
681      return this.value != null && !this.value.isEmpty();
682    }
683
684    /**
685     * @param value {@link #value} (The amount due from the patient for the cost
686     *              category.)
687     */
688    public CostToBeneficiaryComponent setValue(Type value) {
689      if (value != null && !(value instanceof Quantity || value instanceof Money))
690        throw new Error("Not the right type for Coverage.costToBeneficiary.value[x]: " + value.fhirType());
691      this.value = value;
692      return this;
693    }
694
695    /**
696     * @return {@link #exception} (A suite of codes indicating exceptions or
697     *         reductions to patient costs and their effective periods.)
698     */
699    public List<ExemptionComponent> getException() {
700      if (this.exception == null)
701        this.exception = new ArrayList<ExemptionComponent>();
702      return this.exception;
703    }
704
705    /**
706     * @return Returns a reference to <code>this</code> for easy method chaining
707     */
708    public CostToBeneficiaryComponent setException(List<ExemptionComponent> theException) {
709      this.exception = theException;
710      return this;
711    }
712
713    public boolean hasException() {
714      if (this.exception == null)
715        return false;
716      for (ExemptionComponent item : this.exception)
717        if (!item.isEmpty())
718          return true;
719      return false;
720    }
721
722    public ExemptionComponent addException() { // 3
723      ExemptionComponent t = new ExemptionComponent();
724      if (this.exception == null)
725        this.exception = new ArrayList<ExemptionComponent>();
726      this.exception.add(t);
727      return t;
728    }
729
730    public CostToBeneficiaryComponent addException(ExemptionComponent t) { // 3
731      if (t == null)
732        return this;
733      if (this.exception == null)
734        this.exception = new ArrayList<ExemptionComponent>();
735      this.exception.add(t);
736      return this;
737    }
738
739    /**
740     * @return The first repetition of repeating field {@link #exception}, creating
741     *         it if it does not already exist
742     */
743    public ExemptionComponent getExceptionFirstRep() {
744      if (getException().isEmpty()) {
745        addException();
746      }
747      return getException().get(0);
748    }
749
750    protected void listChildren(List<Property> children) {
751      super.listChildren(children);
752      children.add(new Property("type", "CodeableConcept",
753          "The category of patient centric costs associated with treatment.", 0, 1, type));
754      children.add(new Property("value[x]", "SimpleQuantity|Money",
755          "The amount due from the patient for the cost category.", 0, 1, value));
756      children.add(new Property("exception", "",
757          "A suite of codes indicating exceptions or reductions to patient costs and their effective periods.", 0,
758          java.lang.Integer.MAX_VALUE, exception));
759    }
760
761    @Override
762    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
763      switch (_hash) {
764      case 3575610:
765        /* type */ return new Property("type", "CodeableConcept",
766            "The category of patient centric costs associated with treatment.", 0, 1, type);
767      case -1410166417:
768        /* value[x] */ return new Property("value[x]", "SimpleQuantity|Money",
769            "The amount due from the patient for the cost category.", 0, 1, value);
770      case 111972721:
771        /* value */ return new Property("value[x]", "SimpleQuantity|Money",
772            "The amount due from the patient for the cost category.", 0, 1, value);
773      case -2029823716:
774        /* valueQuantity */ return new Property("value[x]", "SimpleQuantity|Money",
775            "The amount due from the patient for the cost category.", 0, 1, value);
776      case 2026560975:
777        /* valueMoney */ return new Property("value[x]", "SimpleQuantity|Money",
778            "The amount due from the patient for the cost category.", 0, 1, value);
779      case 1481625679:
780        /* exception */ return new Property("exception", "",
781            "A suite of codes indicating exceptions or reductions to patient costs and their effective periods.", 0,
782            java.lang.Integer.MAX_VALUE, exception);
783      default:
784        return super.getNamedProperty(_hash, _name, _checkValid);
785      }
786
787    }
788
789    @Override
790    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
791      switch (hash) {
792      case 3575610:
793        /* type */ return this.type == null ? new Base[0] : new Base[] { this.type }; // CodeableConcept
794      case 111972721:
795        /* value */ return this.value == null ? new Base[0] : new Base[] { this.value }; // Type
796      case 1481625679:
797        /* exception */ return this.exception == null ? new Base[0]
798            : this.exception.toArray(new Base[this.exception.size()]); // ExemptionComponent
799      default:
800        return super.getProperty(hash, name, checkValid);
801      }
802
803    }
804
805    @Override
806    public Base setProperty(int hash, String name, Base value) throws FHIRException {
807      switch (hash) {
808      case 3575610: // type
809        this.type = castToCodeableConcept(value); // CodeableConcept
810        return value;
811      case 111972721: // value
812        this.value = castToType(value); // Type
813        return value;
814      case 1481625679: // exception
815        this.getException().add((ExemptionComponent) value); // ExemptionComponent
816        return value;
817      default:
818        return super.setProperty(hash, name, value);
819      }
820
821    }
822
823    @Override
824    public Base setProperty(String name, Base value) throws FHIRException {
825      if (name.equals("type")) {
826        this.type = castToCodeableConcept(value); // CodeableConcept
827      } else if (name.equals("value[x]")) {
828        this.value = castToType(value); // Type
829      } else if (name.equals("exception")) {
830        this.getException().add((ExemptionComponent) value);
831      } else
832        return super.setProperty(name, value);
833      return value;
834    }
835
836  @Override
837  public void removeChild(String name, Base value) throws FHIRException {
838      if (name.equals("type")) {
839        this.type = null;
840      } else if (name.equals("value[x]")) {
841        this.value = null;
842      } else if (name.equals("exception")) {
843        this.getException().remove((ExemptionComponent) value);
844      } else
845        super.removeChild(name, value);
846      
847    }
848
849    @Override
850    public Base makeProperty(int hash, String name) throws FHIRException {
851      switch (hash) {
852      case 3575610:
853        return getType();
854      case -1410166417:
855        return getValue();
856      case 111972721:
857        return getValue();
858      case 1481625679:
859        return addException();
860      default:
861        return super.makeProperty(hash, name);
862      }
863
864    }
865
866    @Override
867    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
868      switch (hash) {
869      case 3575610:
870        /* type */ return new String[] { "CodeableConcept" };
871      case 111972721:
872        /* value */ return new String[] { "SimpleQuantity", "Money" };
873      case 1481625679:
874        /* exception */ return new String[] {};
875      default:
876        return super.getTypesForProperty(hash, name);
877      }
878
879    }
880
881    @Override
882    public Base addChild(String name) throws FHIRException {
883      if (name.equals("type")) {
884        this.type = new CodeableConcept();
885        return this.type;
886      } else if (name.equals("valueQuantity")) {
887        this.value = new Quantity();
888        return this.value;
889      } else if (name.equals("valueMoney")) {
890        this.value = new Money();
891        return this.value;
892      } else if (name.equals("exception")) {
893        return addException();
894      } else
895        return super.addChild(name);
896    }
897
898    public CostToBeneficiaryComponent copy() {
899      CostToBeneficiaryComponent dst = new CostToBeneficiaryComponent();
900      copyValues(dst);
901      return dst;
902    }
903
904    public void copyValues(CostToBeneficiaryComponent dst) {
905      super.copyValues(dst);
906      dst.type = type == null ? null : type.copy();
907      dst.value = value == null ? null : value.copy();
908      if (exception != null) {
909        dst.exception = new ArrayList<ExemptionComponent>();
910        for (ExemptionComponent i : exception)
911          dst.exception.add(i.copy());
912      }
913      ;
914    }
915
916    @Override
917    public boolean equalsDeep(Base other_) {
918      if (!super.equalsDeep(other_))
919        return false;
920      if (!(other_ instanceof CostToBeneficiaryComponent))
921        return false;
922      CostToBeneficiaryComponent o = (CostToBeneficiaryComponent) other_;
923      return compareDeep(type, o.type, true) && compareDeep(value, o.value, true)
924          && compareDeep(exception, o.exception, true);
925    }
926
927    @Override
928    public boolean equalsShallow(Base other_) {
929      if (!super.equalsShallow(other_))
930        return false;
931      if (!(other_ instanceof CostToBeneficiaryComponent))
932        return false;
933      CostToBeneficiaryComponent o = (CostToBeneficiaryComponent) other_;
934      return true;
935    }
936
937    public boolean isEmpty() {
938      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, value, exception);
939    }
940
941    public String fhirType() {
942      return "Coverage.costToBeneficiary";
943
944    }
945
946  }
947
948  @Block()
949  public static class ExemptionComponent extends BackboneElement implements IBaseBackboneElement {
950    /**
951     * The code for the specific exception.
952     */
953    @Child(name = "type", type = {
954        CodeableConcept.class }, order = 1, min = 1, max = 1, modifier = false, summary = true)
955    @Description(shortDefinition = "Exception category", formalDefinition = "The code for the specific exception.")
956    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/coverage-financial-exception")
957    protected CodeableConcept type;
958
959    /**
960     * The timeframe during when the exception is in force.
961     */
962    @Child(name = "period", type = { Period.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
963    @Description(shortDefinition = "The effective period of the exception", formalDefinition = "The timeframe during when the exception is in force.")
964    protected Period period;
965
966    private static final long serialVersionUID = 523191991L;
967
968    /**
969     * Constructor
970     */
971    public ExemptionComponent() {
972      super();
973    }
974
975    /**
976     * Constructor
977     */
978    public ExemptionComponent(CodeableConcept type) {
979      super();
980      this.type = type;
981    }
982
983    /**
984     * @return {@link #type} (The code for the specific exception.)
985     */
986    public CodeableConcept getType() {
987      if (this.type == null)
988        if (Configuration.errorOnAutoCreate())
989          throw new Error("Attempt to auto-create ExemptionComponent.type");
990        else if (Configuration.doAutoCreate())
991          this.type = new CodeableConcept(); // cc
992      return this.type;
993    }
994
995    public boolean hasType() {
996      return this.type != null && !this.type.isEmpty();
997    }
998
999    /**
1000     * @param value {@link #type} (The code for the specific exception.)
1001     */
1002    public ExemptionComponent setType(CodeableConcept value) {
1003      this.type = value;
1004      return this;
1005    }
1006
1007    /**
1008     * @return {@link #period} (The timeframe during when the exception is in
1009     *         force.)
1010     */
1011    public Period getPeriod() {
1012      if (this.period == null)
1013        if (Configuration.errorOnAutoCreate())
1014          throw new Error("Attempt to auto-create ExemptionComponent.period");
1015        else if (Configuration.doAutoCreate())
1016          this.period = new Period(); // cc
1017      return this.period;
1018    }
1019
1020    public boolean hasPeriod() {
1021      return this.period != null && !this.period.isEmpty();
1022    }
1023
1024    /**
1025     * @param value {@link #period} (The timeframe during when the exception is in
1026     *              force.)
1027     */
1028    public ExemptionComponent setPeriod(Period value) {
1029      this.period = value;
1030      return this;
1031    }
1032
1033    protected void listChildren(List<Property> children) {
1034      super.listChildren(children);
1035      children.add(new Property("type", "CodeableConcept", "The code for the specific exception.", 0, 1, type));
1036      children
1037          .add(new Property("period", "Period", "The timeframe during when the exception is in force.", 0, 1, period));
1038    }
1039
1040    @Override
1041    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1042      switch (_hash) {
1043      case 3575610:
1044        /* type */ return new Property("type", "CodeableConcept", "The code for the specific exception.", 0, 1, type);
1045      case -991726143:
1046        /* period */ return new Property("period", "Period", "The timeframe during when the exception is in force.", 0,
1047            1, period);
1048      default:
1049        return super.getNamedProperty(_hash, _name, _checkValid);
1050      }
1051
1052    }
1053
1054    @Override
1055    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1056      switch (hash) {
1057      case 3575610:
1058        /* type */ return this.type == null ? new Base[0] : new Base[] { this.type }; // CodeableConcept
1059      case -991726143:
1060        /* period */ return this.period == null ? new Base[0] : new Base[] { this.period }; // Period
1061      default:
1062        return super.getProperty(hash, name, checkValid);
1063      }
1064
1065    }
1066
1067    @Override
1068    public Base setProperty(int hash, String name, Base value) throws FHIRException {
1069      switch (hash) {
1070      case 3575610: // type
1071        this.type = castToCodeableConcept(value); // CodeableConcept
1072        return value;
1073      case -991726143: // period
1074        this.period = castToPeriod(value); // Period
1075        return value;
1076      default:
1077        return super.setProperty(hash, name, value);
1078      }
1079
1080    }
1081
1082    @Override
1083    public Base setProperty(String name, Base value) throws FHIRException {
1084      if (name.equals("type")) {
1085        this.type = castToCodeableConcept(value); // CodeableConcept
1086      } else if (name.equals("period")) {
1087        this.period = castToPeriod(value); // Period
1088      } else
1089        return super.setProperty(name, value);
1090      return value;
1091    }
1092
1093  @Override
1094  public void removeChild(String name, Base value) throws FHIRException {
1095      if (name.equals("type")) {
1096        this.type = null;
1097      } else if (name.equals("period")) {
1098        this.period = null;
1099      } else
1100        super.removeChild(name, value);
1101      
1102    }
1103
1104    @Override
1105    public Base makeProperty(int hash, String name) throws FHIRException {
1106      switch (hash) {
1107      case 3575610:
1108        return getType();
1109      case -991726143:
1110        return getPeriod();
1111      default:
1112        return super.makeProperty(hash, name);
1113      }
1114
1115    }
1116
1117    @Override
1118    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1119      switch (hash) {
1120      case 3575610:
1121        /* type */ return new String[] { "CodeableConcept" };
1122      case -991726143:
1123        /* period */ return new String[] { "Period" };
1124      default:
1125        return super.getTypesForProperty(hash, name);
1126      }
1127
1128    }
1129
1130    @Override
1131    public Base addChild(String name) throws FHIRException {
1132      if (name.equals("type")) {
1133        this.type = new CodeableConcept();
1134        return this.type;
1135      } else if (name.equals("period")) {
1136        this.period = new Period();
1137        return this.period;
1138      } else
1139        return super.addChild(name);
1140    }
1141
1142    public ExemptionComponent copy() {
1143      ExemptionComponent dst = new ExemptionComponent();
1144      copyValues(dst);
1145      return dst;
1146    }
1147
1148    public void copyValues(ExemptionComponent dst) {
1149      super.copyValues(dst);
1150      dst.type = type == null ? null : type.copy();
1151      dst.period = period == null ? null : period.copy();
1152    }
1153
1154    @Override
1155    public boolean equalsDeep(Base other_) {
1156      if (!super.equalsDeep(other_))
1157        return false;
1158      if (!(other_ instanceof ExemptionComponent))
1159        return false;
1160      ExemptionComponent o = (ExemptionComponent) other_;
1161      return compareDeep(type, o.type, true) && compareDeep(period, o.period, true);
1162    }
1163
1164    @Override
1165    public boolean equalsShallow(Base other_) {
1166      if (!super.equalsShallow(other_))
1167        return false;
1168      if (!(other_ instanceof ExemptionComponent))
1169        return false;
1170      ExemptionComponent o = (ExemptionComponent) other_;
1171      return true;
1172    }
1173
1174    public boolean isEmpty() {
1175      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, period);
1176    }
1177
1178    public String fhirType() {
1179      return "Coverage.costToBeneficiary.exception";
1180
1181    }
1182
1183  }
1184
1185  /**
1186   * A unique identifier assigned to this coverage.
1187   */
1188  @Child(name = "identifier", type = {
1189      Identifier.class }, order = 0, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
1190  @Description(shortDefinition = "Business Identifier for the coverage", formalDefinition = "A unique identifier assigned to this coverage.")
1191  protected List<Identifier> identifier;
1192
1193  /**
1194   * The status of the resource instance.
1195   */
1196  @Child(name = "status", type = { CodeType.class }, order = 1, min = 1, max = 1, modifier = true, summary = true)
1197  @Description(shortDefinition = "active | cancelled | draft | entered-in-error", formalDefinition = "The status of the resource instance.")
1198  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/fm-status")
1199  protected Enumeration<CoverageStatus> status;
1200
1201  /**
1202   * The type of coverage: social program, medical plan, accident coverage
1203   * (workers compensation, auto), group health or payment by an individual or
1204   * organization.
1205   */
1206  @Child(name = "type", type = { CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
1207  @Description(shortDefinition = "Coverage category such as medical or accident", formalDefinition = "The type of coverage: social program, medical plan, accident coverage (workers compensation, auto), group health or payment by an individual or organization.")
1208  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/coverage-type")
1209  protected CodeableConcept type;
1210
1211  /**
1212   * The party who 'owns' the insurance policy.
1213   */
1214  @Child(name = "policyHolder", type = { Patient.class, RelatedPerson.class,
1215      Organization.class }, order = 3, min = 0, max = 1, modifier = false, summary = true)
1216  @Description(shortDefinition = "Owner of the policy", formalDefinition = "The party who 'owns' the insurance policy.")
1217  protected Reference policyHolder;
1218
1219  /**
1220   * The actual object that is the target of the reference (The party who 'owns'
1221   * the insurance policy.)
1222   */
1223  protected Resource policyHolderTarget;
1224
1225  /**
1226   * The party who has signed-up for or 'owns' the contractual relationship to the
1227   * policy or to whom the benefit of the policy for services rendered to them or
1228   * their family is due.
1229   */
1230  @Child(name = "subscriber", type = { Patient.class,
1231      RelatedPerson.class }, order = 4, min = 0, max = 1, modifier = false, summary = true)
1232  @Description(shortDefinition = "Subscriber to the policy", formalDefinition = "The party who has signed-up for or 'owns' the contractual relationship to the policy or to whom the benefit of the policy for services rendered to them or their family is due.")
1233  protected Reference subscriber;
1234
1235  /**
1236   * The actual object that is the target of the reference (The party who has
1237   * signed-up for or 'owns' the contractual relationship to the policy or to whom
1238   * the benefit of the policy for services rendered to them or their family is
1239   * due.)
1240   */
1241  protected Resource subscriberTarget;
1242
1243  /**
1244   * The insurer assigned ID for the Subscriber.
1245   */
1246  @Child(name = "subscriberId", type = {
1247      StringType.class }, order = 5, min = 0, max = 1, modifier = false, summary = true)
1248  @Description(shortDefinition = "ID assigned to the subscriber", formalDefinition = "The insurer assigned ID for the Subscriber.")
1249  protected StringType subscriberId;
1250
1251  /**
1252   * The party who benefits from the insurance coverage; the patient when products
1253   * and/or services are provided.
1254   */
1255  @Child(name = "beneficiary", type = { Patient.class }, order = 6, min = 1, max = 1, modifier = false, summary = true)
1256  @Description(shortDefinition = "Plan beneficiary", formalDefinition = "The party who benefits from the insurance coverage; the patient when products and/or services are provided.")
1257  protected Reference beneficiary;
1258
1259  /**
1260   * The actual object that is the target of the reference (The party who benefits
1261   * from the insurance coverage; the patient when products and/or services are
1262   * provided.)
1263   */
1264  protected Patient beneficiaryTarget;
1265
1266  /**
1267   * A unique identifier for a dependent under the coverage.
1268   */
1269  @Child(name = "dependent", type = { StringType.class }, order = 7, min = 0, max = 1, modifier = false, summary = true)
1270  @Description(shortDefinition = "Dependent number", formalDefinition = "A unique identifier for a dependent under the coverage.")
1271  protected StringType dependent;
1272
1273  /**
1274   * The relationship of beneficiary (patient) to the subscriber.
1275   */
1276  @Child(name = "relationship", type = {
1277      CodeableConcept.class }, order = 8, min = 0, max = 1, modifier = false, summary = false)
1278  @Description(shortDefinition = "Beneficiary relationship to the subscriber", formalDefinition = "The relationship of beneficiary (patient) to the subscriber.")
1279  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/subscriber-relationship")
1280  protected CodeableConcept relationship;
1281
1282  /**
1283   * Time period during which the coverage is in force. A missing start date
1284   * indicates the start date isn't known, a missing end date means the coverage
1285   * is continuing to be in force.
1286   */
1287  @Child(name = "period", type = { Period.class }, order = 9, min = 0, max = 1, modifier = false, summary = true)
1288  @Description(shortDefinition = "Coverage start and end dates", formalDefinition = "Time period during which the coverage is in force. A missing start date indicates the start date isn't known, a missing end date means the coverage is continuing to be in force.")
1289  protected Period period;
1290
1291  /**
1292   * The program or plan underwriter or payor including both insurance and
1293   * non-insurance agreements, such as patient-pay agreements.
1294   */
1295  @Child(name = "payor", type = { Organization.class, Patient.class,
1296      RelatedPerson.class }, order = 10, min = 1, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
1297  @Description(shortDefinition = "Issuer of the policy", formalDefinition = "The program or plan underwriter or payor including both insurance and non-insurance agreements, such as patient-pay agreements.")
1298  protected List<Reference> payor;
1299  /**
1300   * The actual objects that are the target of the reference (The program or plan
1301   * underwriter or payor including both insurance and non-insurance agreements,
1302   * such as patient-pay agreements.)
1303   */
1304  protected List<Resource> payorTarget;
1305
1306  /**
1307   * A suite of underwriter specific classifiers.
1308   */
1309  @Child(name = "class", type = {}, order = 11, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1310  @Description(shortDefinition = "Additional coverage classifications", formalDefinition = "A suite of underwriter specific classifiers.")
1311  protected List<ClassComponent> class_;
1312
1313  /**
1314   * The order of applicability of this coverage relative to other coverages which
1315   * are currently in force. Note, there may be gaps in the numbering and this
1316   * does not imply primary, secondary etc. as the specific positioning of
1317   * coverages depends upon the episode of care.
1318   */
1319  @Child(name = "order", type = {
1320      PositiveIntType.class }, order = 12, min = 0, max = 1, modifier = false, summary = true)
1321  @Description(shortDefinition = "Relative order of the coverage", formalDefinition = "The order of applicability of this coverage relative to other coverages which are currently in force. Note, there may be gaps in the numbering and this does not imply primary, secondary etc. as the specific positioning of coverages depends upon the episode of care.")
1322  protected PositiveIntType order;
1323
1324  /**
1325   * The insurer-specific identifier for the insurer-defined network of providers
1326   * to which the beneficiary may seek treatment which will be covered at the
1327   * 'in-network' rate, otherwise 'out of network' terms and conditions apply.
1328   */
1329  @Child(name = "network", type = { StringType.class }, order = 13, min = 0, max = 1, modifier = false, summary = true)
1330  @Description(shortDefinition = "Insurer network", formalDefinition = "The insurer-specific identifier for the insurer-defined network of providers to which the beneficiary may seek treatment which will be covered at the 'in-network' rate, otherwise 'out of network' terms and conditions apply.")
1331  protected StringType network;
1332
1333  /**
1334   * A suite of codes indicating the cost category and associated amount which
1335   * have been detailed in the policy and may have been included on the health
1336   * card.
1337   */
1338  @Child(name = "costToBeneficiary", type = {}, order = 14, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1339  @Description(shortDefinition = "Patient payments for services/products", formalDefinition = "A suite of codes indicating the cost category and associated amount which have been detailed in the policy and may have been  included on the health card.")
1340  protected List<CostToBeneficiaryComponent> costToBeneficiary;
1341
1342  /**
1343   * When 'subrogation=true' this insurance instance has been included not for
1344   * adjudication but to provide insurers with the details to recover costs.
1345   */
1346  @Child(name = "subrogation", type = {
1347      BooleanType.class }, order = 15, min = 0, max = 1, modifier = false, summary = false)
1348  @Description(shortDefinition = "Reimbursement to insurer", formalDefinition = "When 'subrogation=true' this insurance instance has been included not for adjudication but to provide insurers with the details to recover costs.")
1349  protected BooleanType subrogation;
1350
1351  /**
1352   * The policy(s) which constitute this insurance coverage.
1353   */
1354  @Child(name = "contract", type = {
1355      Contract.class }, order = 16, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1356  @Description(shortDefinition = "Contract details", formalDefinition = "The policy(s) which constitute this insurance coverage.")
1357  protected List<Reference> contract;
1358  /**
1359   * The actual objects that are the target of the reference (The policy(s) which
1360   * constitute this insurance coverage.)
1361   */
1362  protected List<Contract> contractTarget;
1363
1364  private static final long serialVersionUID = 212315315L;
1365
1366  /**
1367   * Constructor
1368   */
1369  public Coverage() {
1370    super();
1371  }
1372
1373  /**
1374   * Constructor
1375   */
1376  public Coverage(Enumeration<CoverageStatus> status, Reference beneficiary) {
1377    super();
1378    this.status = status;
1379    this.beneficiary = beneficiary;
1380  }
1381
1382  /**
1383   * @return {@link #identifier} (A unique identifier assigned to this coverage.)
1384   */
1385  public List<Identifier> getIdentifier() {
1386    if (this.identifier == null)
1387      this.identifier = new ArrayList<Identifier>();
1388    return this.identifier;
1389  }
1390
1391  /**
1392   * @return Returns a reference to <code>this</code> for easy method chaining
1393   */
1394  public Coverage setIdentifier(List<Identifier> theIdentifier) {
1395    this.identifier = theIdentifier;
1396    return this;
1397  }
1398
1399  public boolean hasIdentifier() {
1400    if (this.identifier == null)
1401      return false;
1402    for (Identifier item : this.identifier)
1403      if (!item.isEmpty())
1404        return true;
1405    return false;
1406  }
1407
1408  public Identifier addIdentifier() { // 3
1409    Identifier t = new Identifier();
1410    if (this.identifier == null)
1411      this.identifier = new ArrayList<Identifier>();
1412    this.identifier.add(t);
1413    return t;
1414  }
1415
1416  public Coverage addIdentifier(Identifier t) { // 3
1417    if (t == null)
1418      return this;
1419    if (this.identifier == null)
1420      this.identifier = new ArrayList<Identifier>();
1421    this.identifier.add(t);
1422    return this;
1423  }
1424
1425  /**
1426   * @return The first repetition of repeating field {@link #identifier}, creating
1427   *         it if it does not already exist
1428   */
1429  public Identifier getIdentifierFirstRep() {
1430    if (getIdentifier().isEmpty()) {
1431      addIdentifier();
1432    }
1433    return getIdentifier().get(0);
1434  }
1435
1436  /**
1437   * @return {@link #status} (The status of the resource instance.). This is the
1438   *         underlying object with id, value and extensions. The accessor
1439   *         "getStatus" gives direct access to the value
1440   */
1441  public Enumeration<CoverageStatus> getStatusElement() {
1442    if (this.status == null)
1443      if (Configuration.errorOnAutoCreate())
1444        throw new Error("Attempt to auto-create Coverage.status");
1445      else if (Configuration.doAutoCreate())
1446        this.status = new Enumeration<CoverageStatus>(new CoverageStatusEnumFactory()); // bb
1447    return this.status;
1448  }
1449
1450  public boolean hasStatusElement() {
1451    return this.status != null && !this.status.isEmpty();
1452  }
1453
1454  public boolean hasStatus() {
1455    return this.status != null && !this.status.isEmpty();
1456  }
1457
1458  /**
1459   * @param value {@link #status} (The status of the resource instance.). This is
1460   *              the underlying object with id, value and extensions. The
1461   *              accessor "getStatus" gives direct access to the value
1462   */
1463  public Coverage setStatusElement(Enumeration<CoverageStatus> value) {
1464    this.status = value;
1465    return this;
1466  }
1467
1468  /**
1469   * @return The status of the resource instance.
1470   */
1471  public CoverageStatus getStatus() {
1472    return this.status == null ? null : this.status.getValue();
1473  }
1474
1475  /**
1476   * @param value The status of the resource instance.
1477   */
1478  public Coverage setStatus(CoverageStatus value) {
1479    if (this.status == null)
1480      this.status = new Enumeration<CoverageStatus>(new CoverageStatusEnumFactory());
1481    this.status.setValue(value);
1482    return this;
1483  }
1484
1485  /**
1486   * @return {@link #type} (The type of coverage: social program, medical plan,
1487   *         accident coverage (workers compensation, auto), group health or
1488   *         payment by an individual or organization.)
1489   */
1490  public CodeableConcept getType() {
1491    if (this.type == null)
1492      if (Configuration.errorOnAutoCreate())
1493        throw new Error("Attempt to auto-create Coverage.type");
1494      else if (Configuration.doAutoCreate())
1495        this.type = new CodeableConcept(); // cc
1496    return this.type;
1497  }
1498
1499  public boolean hasType() {
1500    return this.type != null && !this.type.isEmpty();
1501  }
1502
1503  /**
1504   * @param value {@link #type} (The type of coverage: social program, medical
1505   *              plan, accident coverage (workers compensation, auto), group
1506   *              health or payment by an individual or organization.)
1507   */
1508  public Coverage setType(CodeableConcept value) {
1509    this.type = value;
1510    return this;
1511  }
1512
1513  /**
1514   * @return {@link #policyHolder} (The party who 'owns' the insurance policy.)
1515   */
1516  public Reference getPolicyHolder() {
1517    if (this.policyHolder == null)
1518      if (Configuration.errorOnAutoCreate())
1519        throw new Error("Attempt to auto-create Coverage.policyHolder");
1520      else if (Configuration.doAutoCreate())
1521        this.policyHolder = new Reference(); // cc
1522    return this.policyHolder;
1523  }
1524
1525  public boolean hasPolicyHolder() {
1526    return this.policyHolder != null && !this.policyHolder.isEmpty();
1527  }
1528
1529  /**
1530   * @param value {@link #policyHolder} (The party who 'owns' the insurance
1531   *              policy.)
1532   */
1533  public Coverage setPolicyHolder(Reference value) {
1534    this.policyHolder = value;
1535    return this;
1536  }
1537
1538  /**
1539   * @return {@link #policyHolder} The actual object that is the target of the
1540   *         reference. The reference library doesn't populate this, but you can
1541   *         use it to hold the resource if you resolve it. (The party who 'owns'
1542   *         the insurance policy.)
1543   */
1544  public Resource getPolicyHolderTarget() {
1545    return this.policyHolderTarget;
1546  }
1547
1548  /**
1549   * @param value {@link #policyHolder} The actual object that is the target of
1550   *              the reference. The reference library doesn't use these, but you
1551   *              can use it to hold the resource if you resolve it. (The party
1552   *              who 'owns' the insurance policy.)
1553   */
1554  public Coverage setPolicyHolderTarget(Resource value) {
1555    this.policyHolderTarget = value;
1556    return this;
1557  }
1558
1559  /**
1560   * @return {@link #subscriber} (The party who has signed-up for or 'owns' the
1561   *         contractual relationship to the policy or to whom the benefit of the
1562   *         policy for services rendered to them or their family is due.)
1563   */
1564  public Reference getSubscriber() {
1565    if (this.subscriber == null)
1566      if (Configuration.errorOnAutoCreate())
1567        throw new Error("Attempt to auto-create Coverage.subscriber");
1568      else if (Configuration.doAutoCreate())
1569        this.subscriber = new Reference(); // cc
1570    return this.subscriber;
1571  }
1572
1573  public boolean hasSubscriber() {
1574    return this.subscriber != null && !this.subscriber.isEmpty();
1575  }
1576
1577  /**
1578   * @param value {@link #subscriber} (The party who has signed-up for or 'owns'
1579   *              the contractual relationship to the policy or to whom the
1580   *              benefit of the policy for services rendered to them or their
1581   *              family is due.)
1582   */
1583  public Coverage setSubscriber(Reference value) {
1584    this.subscriber = value;
1585    return this;
1586  }
1587
1588  /**
1589   * @return {@link #subscriber} The actual object that is the target of the
1590   *         reference. The reference library doesn't populate this, but you can
1591   *         use it to hold the resource if you resolve it. (The party who has
1592   *         signed-up for or 'owns' the contractual relationship to the policy or
1593   *         to whom the benefit of the policy for services rendered to them or
1594   *         their family is due.)
1595   */
1596  public Resource getSubscriberTarget() {
1597    return this.subscriberTarget;
1598  }
1599
1600  /**
1601   * @param value {@link #subscriber} The actual object that is the target of the
1602   *              reference. The reference library doesn't use these, but you can
1603   *              use it to hold the resource if you resolve it. (The party who
1604   *              has signed-up for or 'owns' the contractual relationship to the
1605   *              policy or to whom the benefit of the policy for services
1606   *              rendered to them or their family is due.)
1607   */
1608  public Coverage setSubscriberTarget(Resource value) {
1609    this.subscriberTarget = value;
1610    return this;
1611  }
1612
1613  /**
1614   * @return {@link #subscriberId} (The insurer assigned ID for the Subscriber.).
1615   *         This is the underlying object with id, value and extensions. The
1616   *         accessor "getSubscriberId" gives direct access to the value
1617   */
1618  public StringType getSubscriberIdElement() {
1619    if (this.subscriberId == null)
1620      if (Configuration.errorOnAutoCreate())
1621        throw new Error("Attempt to auto-create Coverage.subscriberId");
1622      else if (Configuration.doAutoCreate())
1623        this.subscriberId = new StringType(); // bb
1624    return this.subscriberId;
1625  }
1626
1627  public boolean hasSubscriberIdElement() {
1628    return this.subscriberId != null && !this.subscriberId.isEmpty();
1629  }
1630
1631  public boolean hasSubscriberId() {
1632    return this.subscriberId != null && !this.subscriberId.isEmpty();
1633  }
1634
1635  /**
1636   * @param value {@link #subscriberId} (The insurer assigned ID for the
1637   *              Subscriber.). This is the underlying object with id, value and
1638   *              extensions. The accessor "getSubscriberId" gives direct access
1639   *              to the value
1640   */
1641  public Coverage setSubscriberIdElement(StringType value) {
1642    this.subscriberId = value;
1643    return this;
1644  }
1645
1646  /**
1647   * @return The insurer assigned ID for the Subscriber.
1648   */
1649  public String getSubscriberId() {
1650    return this.subscriberId == null ? null : this.subscriberId.getValue();
1651  }
1652
1653  /**
1654   * @param value The insurer assigned ID for the Subscriber.
1655   */
1656  public Coverage setSubscriberId(String value) {
1657    if (Utilities.noString(value))
1658      this.subscriberId = null;
1659    else {
1660      if (this.subscriberId == null)
1661        this.subscriberId = new StringType();
1662      this.subscriberId.setValue(value);
1663    }
1664    return this;
1665  }
1666
1667  /**
1668   * @return {@link #beneficiary} (The party who benefits from the insurance
1669   *         coverage; the patient when products and/or services are provided.)
1670   */
1671  public Reference getBeneficiary() {
1672    if (this.beneficiary == null)
1673      if (Configuration.errorOnAutoCreate())
1674        throw new Error("Attempt to auto-create Coverage.beneficiary");
1675      else if (Configuration.doAutoCreate())
1676        this.beneficiary = new Reference(); // cc
1677    return this.beneficiary;
1678  }
1679
1680  public boolean hasBeneficiary() {
1681    return this.beneficiary != null && !this.beneficiary.isEmpty();
1682  }
1683
1684  /**
1685   * @param value {@link #beneficiary} (The party who benefits from the insurance
1686   *              coverage; the patient when products and/or services are
1687   *              provided.)
1688   */
1689  public Coverage setBeneficiary(Reference value) {
1690    this.beneficiary = value;
1691    return this;
1692  }
1693
1694  /**
1695   * @return {@link #beneficiary} The actual object that is the target of the
1696   *         reference. The reference library doesn't populate this, but you can
1697   *         use it to hold the resource if you resolve it. (The party who
1698   *         benefits from the insurance coverage; the patient when products
1699   *         and/or services are provided.)
1700   */
1701  public Patient getBeneficiaryTarget() {
1702    if (this.beneficiaryTarget == null)
1703      if (Configuration.errorOnAutoCreate())
1704        throw new Error("Attempt to auto-create Coverage.beneficiary");
1705      else if (Configuration.doAutoCreate())
1706        this.beneficiaryTarget = new Patient(); // aa
1707    return this.beneficiaryTarget;
1708  }
1709
1710  /**
1711   * @param value {@link #beneficiary} The actual object that is the target of the
1712   *              reference. The reference library doesn't use these, but you can
1713   *              use it to hold the resource if you resolve it. (The party who
1714   *              benefits from the insurance coverage; the patient when products
1715   *              and/or services are provided.)
1716   */
1717  public Coverage setBeneficiaryTarget(Patient value) {
1718    this.beneficiaryTarget = value;
1719    return this;
1720  }
1721
1722  /**
1723   * @return {@link #dependent} (A unique identifier for a dependent under the
1724   *         coverage.). This is the underlying object with id, value and
1725   *         extensions. The accessor "getDependent" gives direct access to the
1726   *         value
1727   */
1728  public StringType getDependentElement() {
1729    if (this.dependent == null)
1730      if (Configuration.errorOnAutoCreate())
1731        throw new Error("Attempt to auto-create Coverage.dependent");
1732      else if (Configuration.doAutoCreate())
1733        this.dependent = new StringType(); // bb
1734    return this.dependent;
1735  }
1736
1737  public boolean hasDependentElement() {
1738    return this.dependent != null && !this.dependent.isEmpty();
1739  }
1740
1741  public boolean hasDependent() {
1742    return this.dependent != null && !this.dependent.isEmpty();
1743  }
1744
1745  /**
1746   * @param value {@link #dependent} (A unique identifier for a dependent under
1747   *              the coverage.). This is the underlying object with id, value and
1748   *              extensions. The accessor "getDependent" gives direct access to
1749   *              the value
1750   */
1751  public Coverage setDependentElement(StringType value) {
1752    this.dependent = value;
1753    return this;
1754  }
1755
1756  /**
1757   * @return A unique identifier for a dependent under the coverage.
1758   */
1759  public String getDependent() {
1760    return this.dependent == null ? null : this.dependent.getValue();
1761  }
1762
1763  /**
1764   * @param value A unique identifier for a dependent under the coverage.
1765   */
1766  public Coverage setDependent(String value) {
1767    if (Utilities.noString(value))
1768      this.dependent = null;
1769    else {
1770      if (this.dependent == null)
1771        this.dependent = new StringType();
1772      this.dependent.setValue(value);
1773    }
1774    return this;
1775  }
1776
1777  /**
1778   * @return {@link #relationship} (The relationship of beneficiary (patient) to
1779   *         the subscriber.)
1780   */
1781  public CodeableConcept getRelationship() {
1782    if (this.relationship == null)
1783      if (Configuration.errorOnAutoCreate())
1784        throw new Error("Attempt to auto-create Coverage.relationship");
1785      else if (Configuration.doAutoCreate())
1786        this.relationship = new CodeableConcept(); // cc
1787    return this.relationship;
1788  }
1789
1790  public boolean hasRelationship() {
1791    return this.relationship != null && !this.relationship.isEmpty();
1792  }
1793
1794  /**
1795   * @param value {@link #relationship} (The relationship of beneficiary (patient)
1796   *              to the subscriber.)
1797   */
1798  public Coverage setRelationship(CodeableConcept value) {
1799    this.relationship = value;
1800    return this;
1801  }
1802
1803  /**
1804   * @return {@link #period} (Time period during which the coverage is in force. A
1805   *         missing start date indicates the start date isn't known, a missing
1806   *         end date means the coverage is continuing to be in force.)
1807   */
1808  public Period getPeriod() {
1809    if (this.period == null)
1810      if (Configuration.errorOnAutoCreate())
1811        throw new Error("Attempt to auto-create Coverage.period");
1812      else if (Configuration.doAutoCreate())
1813        this.period = new Period(); // cc
1814    return this.period;
1815  }
1816
1817  public boolean hasPeriod() {
1818    return this.period != null && !this.period.isEmpty();
1819  }
1820
1821  /**
1822   * @param value {@link #period} (Time period during which the coverage is in
1823   *              force. A missing start date indicates the start date isn't
1824   *              known, a missing end date means the coverage is continuing to be
1825   *              in force.)
1826   */
1827  public Coverage setPeriod(Period value) {
1828    this.period = value;
1829    return this;
1830  }
1831
1832  /**
1833   * @return {@link #payor} (The program or plan underwriter or payor including
1834   *         both insurance and non-insurance agreements, such as patient-pay
1835   *         agreements.)
1836   */
1837  public List<Reference> getPayor() {
1838    if (this.payor == null)
1839      this.payor = new ArrayList<Reference>();
1840    return this.payor;
1841  }
1842
1843  /**
1844   * @return Returns a reference to <code>this</code> for easy method chaining
1845   */
1846  public Coverage setPayor(List<Reference> thePayor) {
1847    this.payor = thePayor;
1848    return this;
1849  }
1850
1851  public boolean hasPayor() {
1852    if (this.payor == null)
1853      return false;
1854    for (Reference item : this.payor)
1855      if (!item.isEmpty())
1856        return true;
1857    return false;
1858  }
1859
1860  public Reference addPayor() { // 3
1861    Reference t = new Reference();
1862    if (this.payor == null)
1863      this.payor = new ArrayList<Reference>();
1864    this.payor.add(t);
1865    return t;
1866  }
1867
1868  public Coverage addPayor(Reference t) { // 3
1869    if (t == null)
1870      return this;
1871    if (this.payor == null)
1872      this.payor = new ArrayList<Reference>();
1873    this.payor.add(t);
1874    return this;
1875  }
1876
1877  /**
1878   * @return The first repetition of repeating field {@link #payor}, creating it
1879   *         if it does not already exist
1880   */
1881  public Reference getPayorFirstRep() {
1882    if (getPayor().isEmpty()) {
1883      addPayor();
1884    }
1885    return getPayor().get(0);
1886  }
1887
1888  /**
1889   * @deprecated Use Reference#setResource(IBaseResource) instead
1890   */
1891  @Deprecated
1892  public List<Resource> getPayorTarget() {
1893    if (this.payorTarget == null)
1894      this.payorTarget = new ArrayList<Resource>();
1895    return this.payorTarget;
1896  }
1897
1898  /**
1899   * @return {@link #class_} (A suite of underwriter specific classifiers.)
1900   */
1901  public List<ClassComponent> getClass_() {
1902    if (this.class_ == null)
1903      this.class_ = new ArrayList<ClassComponent>();
1904    return this.class_;
1905  }
1906
1907  /**
1908   * @return Returns a reference to <code>this</code> for easy method chaining
1909   */
1910  public Coverage setClass_(List<ClassComponent> theClass_) {
1911    this.class_ = theClass_;
1912    return this;
1913  }
1914
1915  public boolean hasClass_() {
1916    if (this.class_ == null)
1917      return false;
1918    for (ClassComponent item : this.class_)
1919      if (!item.isEmpty())
1920        return true;
1921    return false;
1922  }
1923
1924  public ClassComponent addClass_() { // 3
1925    ClassComponent t = new ClassComponent();
1926    if (this.class_ == null)
1927      this.class_ = new ArrayList<ClassComponent>();
1928    this.class_.add(t);
1929    return t;
1930  }
1931
1932  public Coverage addClass_(ClassComponent t) { // 3
1933    if (t == null)
1934      return this;
1935    if (this.class_ == null)
1936      this.class_ = new ArrayList<ClassComponent>();
1937    this.class_.add(t);
1938    return this;
1939  }
1940
1941  /**
1942   * @return The first repetition of repeating field {@link #class_}, creating it
1943   *         if it does not already exist
1944   */
1945  public ClassComponent getClass_FirstRep() {
1946    if (getClass_().isEmpty()) {
1947      addClass_();
1948    }
1949    return getClass_().get(0);
1950  }
1951
1952  /**
1953   * @return {@link #order} (The order of applicability of this coverage relative
1954   *         to other coverages which are currently in force. Note, there may be
1955   *         gaps in the numbering and this does not imply primary, secondary etc.
1956   *         as the specific positioning of coverages depends upon the episode of
1957   *         care.). This is the underlying object with id, value and extensions.
1958   *         The accessor "getOrder" gives direct access to the value
1959   */
1960  public PositiveIntType getOrderElement() {
1961    if (this.order == null)
1962      if (Configuration.errorOnAutoCreate())
1963        throw new Error("Attempt to auto-create Coverage.order");
1964      else if (Configuration.doAutoCreate())
1965        this.order = new PositiveIntType(); // bb
1966    return this.order;
1967  }
1968
1969  public boolean hasOrderElement() {
1970    return this.order != null && !this.order.isEmpty();
1971  }
1972
1973  public boolean hasOrder() {
1974    return this.order != null && !this.order.isEmpty();
1975  }
1976
1977  /**
1978   * @param value {@link #order} (The order of applicability of this coverage
1979   *              relative to other coverages which are currently in force. Note,
1980   *              there may be gaps in the numbering and this does not imply
1981   *              primary, secondary etc. as the specific positioning of coverages
1982   *              depends upon the episode of care.). This is the underlying
1983   *              object with id, value and extensions. The accessor "getOrder"
1984   *              gives direct access to the value
1985   */
1986  public Coverage setOrderElement(PositiveIntType value) {
1987    this.order = value;
1988    return this;
1989  }
1990
1991  /**
1992   * @return The order of applicability of this coverage relative to other
1993   *         coverages which are currently in force. Note, there may be gaps in
1994   *         the numbering and this does not imply primary, secondary etc. as the
1995   *         specific positioning of coverages depends upon the episode of care.
1996   */
1997  public int getOrder() {
1998    return this.order == null || this.order.isEmpty() ? 0 : this.order.getValue();
1999  }
2000
2001  /**
2002   * @param value The order of applicability of this coverage relative to other
2003   *              coverages which are currently in force. Note, there may be gaps
2004   *              in the numbering and this does not imply primary, secondary etc.
2005   *              as the specific positioning of coverages depends upon the
2006   *              episode of care.
2007   */
2008  public Coverage setOrder(int value) {
2009    if (this.order == null)
2010      this.order = new PositiveIntType();
2011    this.order.setValue(value);
2012    return this;
2013  }
2014
2015  /**
2016   * @return {@link #network} (The insurer-specific identifier for the
2017   *         insurer-defined network of providers to which the beneficiary may
2018   *         seek treatment which will be covered at the 'in-network' rate,
2019   *         otherwise 'out of network' terms and conditions apply.). This is the
2020   *         underlying object with id, value and extensions. The accessor
2021   *         "getNetwork" gives direct access to the value
2022   */
2023  public StringType getNetworkElement() {
2024    if (this.network == null)
2025      if (Configuration.errorOnAutoCreate())
2026        throw new Error("Attempt to auto-create Coverage.network");
2027      else if (Configuration.doAutoCreate())
2028        this.network = new StringType(); // bb
2029    return this.network;
2030  }
2031
2032  public boolean hasNetworkElement() {
2033    return this.network != null && !this.network.isEmpty();
2034  }
2035
2036  public boolean hasNetwork() {
2037    return this.network != null && !this.network.isEmpty();
2038  }
2039
2040  /**
2041   * @param value {@link #network} (The insurer-specific identifier for the
2042   *              insurer-defined network of providers to which the beneficiary
2043   *              may seek treatment which will be covered at the 'in-network'
2044   *              rate, otherwise 'out of network' terms and conditions apply.).
2045   *              This is the underlying object with id, value and extensions. The
2046   *              accessor "getNetwork" gives direct access to the value
2047   */
2048  public Coverage setNetworkElement(StringType value) {
2049    this.network = value;
2050    return this;
2051  }
2052
2053  /**
2054   * @return The insurer-specific identifier for the insurer-defined network of
2055   *         providers to which the beneficiary may seek treatment which will be
2056   *         covered at the 'in-network' rate, otherwise 'out of network' terms
2057   *         and conditions apply.
2058   */
2059  public String getNetwork() {
2060    return this.network == null ? null : this.network.getValue();
2061  }
2062
2063  /**
2064   * @param value The insurer-specific identifier for the insurer-defined network
2065   *              of providers to which the beneficiary may seek treatment which
2066   *              will be covered at the 'in-network' rate, otherwise 'out of
2067   *              network' terms and conditions apply.
2068   */
2069  public Coverage setNetwork(String value) {
2070    if (Utilities.noString(value))
2071      this.network = null;
2072    else {
2073      if (this.network == null)
2074        this.network = new StringType();
2075      this.network.setValue(value);
2076    }
2077    return this;
2078  }
2079
2080  /**
2081   * @return {@link #costToBeneficiary} (A suite of codes indicating the cost
2082   *         category and associated amount which have been detailed in the policy
2083   *         and may have been included on the health card.)
2084   */
2085  public List<CostToBeneficiaryComponent> getCostToBeneficiary() {
2086    if (this.costToBeneficiary == null)
2087      this.costToBeneficiary = new ArrayList<CostToBeneficiaryComponent>();
2088    return this.costToBeneficiary;
2089  }
2090
2091  /**
2092   * @return Returns a reference to <code>this</code> for easy method chaining
2093   */
2094  public Coverage setCostToBeneficiary(List<CostToBeneficiaryComponent> theCostToBeneficiary) {
2095    this.costToBeneficiary = theCostToBeneficiary;
2096    return this;
2097  }
2098
2099  public boolean hasCostToBeneficiary() {
2100    if (this.costToBeneficiary == null)
2101      return false;
2102    for (CostToBeneficiaryComponent item : this.costToBeneficiary)
2103      if (!item.isEmpty())
2104        return true;
2105    return false;
2106  }
2107
2108  public CostToBeneficiaryComponent addCostToBeneficiary() { // 3
2109    CostToBeneficiaryComponent t = new CostToBeneficiaryComponent();
2110    if (this.costToBeneficiary == null)
2111      this.costToBeneficiary = new ArrayList<CostToBeneficiaryComponent>();
2112    this.costToBeneficiary.add(t);
2113    return t;
2114  }
2115
2116  public Coverage addCostToBeneficiary(CostToBeneficiaryComponent t) { // 3
2117    if (t == null)
2118      return this;
2119    if (this.costToBeneficiary == null)
2120      this.costToBeneficiary = new ArrayList<CostToBeneficiaryComponent>();
2121    this.costToBeneficiary.add(t);
2122    return this;
2123  }
2124
2125  /**
2126   * @return The first repetition of repeating field {@link #costToBeneficiary},
2127   *         creating it if it does not already exist
2128   */
2129  public CostToBeneficiaryComponent getCostToBeneficiaryFirstRep() {
2130    if (getCostToBeneficiary().isEmpty()) {
2131      addCostToBeneficiary();
2132    }
2133    return getCostToBeneficiary().get(0);
2134  }
2135
2136  /**
2137   * @return {@link #subrogation} (When 'subrogation=true' this insurance instance
2138   *         has been included not for adjudication but to provide insurers with
2139   *         the details to recover costs.). This is the underlying object with
2140   *         id, value and extensions. The accessor "getSubrogation" gives direct
2141   *         access to the value
2142   */
2143  public BooleanType getSubrogationElement() {
2144    if (this.subrogation == null)
2145      if (Configuration.errorOnAutoCreate())
2146        throw new Error("Attempt to auto-create Coverage.subrogation");
2147      else if (Configuration.doAutoCreate())
2148        this.subrogation = new BooleanType(); // bb
2149    return this.subrogation;
2150  }
2151
2152  public boolean hasSubrogationElement() {
2153    return this.subrogation != null && !this.subrogation.isEmpty();
2154  }
2155
2156  public boolean hasSubrogation() {
2157    return this.subrogation != null && !this.subrogation.isEmpty();
2158  }
2159
2160  /**
2161   * @param value {@link #subrogation} (When 'subrogation=true' this insurance
2162   *              instance has been included not for adjudication but to provide
2163   *              insurers with the details to recover costs.). This is the
2164   *              underlying object with id, value and extensions. The accessor
2165   *              "getSubrogation" gives direct access to the value
2166   */
2167  public Coverage setSubrogationElement(BooleanType value) {
2168    this.subrogation = value;
2169    return this;
2170  }
2171
2172  /**
2173   * @return When 'subrogation=true' this insurance instance has been included not
2174   *         for adjudication but to provide insurers with the details to recover
2175   *         costs.
2176   */
2177  public boolean getSubrogation() {
2178    return this.subrogation == null || this.subrogation.isEmpty() ? false : this.subrogation.getValue();
2179  }
2180
2181  /**
2182   * @param value When 'subrogation=true' this insurance instance has been
2183   *              included not for adjudication but to provide insurers with the
2184   *              details to recover costs.
2185   */
2186  public Coverage setSubrogation(boolean value) {
2187    if (this.subrogation == null)
2188      this.subrogation = new BooleanType();
2189    this.subrogation.setValue(value);
2190    return this;
2191  }
2192
2193  /**
2194   * @return {@link #contract} (The policy(s) which constitute this insurance
2195   *         coverage.)
2196   */
2197  public List<Reference> getContract() {
2198    if (this.contract == null)
2199      this.contract = new ArrayList<Reference>();
2200    return this.contract;
2201  }
2202
2203  /**
2204   * @return Returns a reference to <code>this</code> for easy method chaining
2205   */
2206  public Coverage setContract(List<Reference> theContract) {
2207    this.contract = theContract;
2208    return this;
2209  }
2210
2211  public boolean hasContract() {
2212    if (this.contract == null)
2213      return false;
2214    for (Reference item : this.contract)
2215      if (!item.isEmpty())
2216        return true;
2217    return false;
2218  }
2219
2220  public Reference addContract() { // 3
2221    Reference t = new Reference();
2222    if (this.contract == null)
2223      this.contract = new ArrayList<Reference>();
2224    this.contract.add(t);
2225    return t;
2226  }
2227
2228  public Coverage addContract(Reference t) { // 3
2229    if (t == null)
2230      return this;
2231    if (this.contract == null)
2232      this.contract = new ArrayList<Reference>();
2233    this.contract.add(t);
2234    return this;
2235  }
2236
2237  /**
2238   * @return The first repetition of repeating field {@link #contract}, creating
2239   *         it if it does not already exist
2240   */
2241  public Reference getContractFirstRep() {
2242    if (getContract().isEmpty()) {
2243      addContract();
2244    }
2245    return getContract().get(0);
2246  }
2247
2248  /**
2249   * @deprecated Use Reference#setResource(IBaseResource) instead
2250   */
2251  @Deprecated
2252  public List<Contract> getContractTarget() {
2253    if (this.contractTarget == null)
2254      this.contractTarget = new ArrayList<Contract>();
2255    return this.contractTarget;
2256  }
2257
2258  /**
2259   * @deprecated Use Reference#setResource(IBaseResource) instead
2260   */
2261  @Deprecated
2262  public Contract addContractTarget() {
2263    Contract r = new Contract();
2264    if (this.contractTarget == null)
2265      this.contractTarget = new ArrayList<Contract>();
2266    this.contractTarget.add(r);
2267    return r;
2268  }
2269
2270  protected void listChildren(List<Property> children) {
2271    super.listChildren(children);
2272    children.add(new Property("identifier", "Identifier", "A unique identifier assigned to this coverage.", 0,
2273        java.lang.Integer.MAX_VALUE, identifier));
2274    children.add(new Property("status", "code", "The status of the resource instance.", 0, 1, status));
2275    children.add(new Property("type", "CodeableConcept",
2276        "The type of coverage: social program, medical plan, accident coverage (workers compensation, auto), group health or payment by an individual or organization.",
2277        0, 1, type));
2278    children.add(new Property("policyHolder", "Reference(Patient|RelatedPerson|Organization)",
2279        "The party who 'owns' the insurance policy.", 0, 1, policyHolder));
2280    children.add(new Property("subscriber", "Reference(Patient|RelatedPerson)",
2281        "The party who has signed-up for or 'owns' the contractual relationship to the policy or to whom the benefit of the policy for services rendered to them or their family is due.",
2282        0, 1, subscriber));
2283    children
2284        .add(new Property("subscriberId", "string", "The insurer assigned ID for the Subscriber.", 0, 1, subscriberId));
2285    children.add(new Property("beneficiary", "Reference(Patient)",
2286        "The party who benefits from the insurance coverage; the patient when products and/or services are provided.",
2287        0, 1, beneficiary));
2288    children.add(new Property("dependent", "string", "A unique identifier for a dependent under the coverage.", 0, 1,
2289        dependent));
2290    children.add(new Property("relationship", "CodeableConcept",
2291        "The relationship of beneficiary (patient) to the subscriber.", 0, 1, relationship));
2292    children.add(new Property("period", "Period",
2293        "Time period during which the coverage is in force. A missing start date indicates the start date isn't known, a missing end date means the coverage is continuing to be in force.",
2294        0, 1, period));
2295    children.add(new Property("payor", "Reference(Organization|Patient|RelatedPerson)",
2296        "The program or plan underwriter or payor including both insurance and non-insurance agreements, such as patient-pay agreements.",
2297        0, java.lang.Integer.MAX_VALUE, payor));
2298    children.add(new Property("class", "", "A suite of underwriter specific classifiers.", 0,
2299        java.lang.Integer.MAX_VALUE, class_));
2300    children.add(new Property("order", "positiveInt",
2301        "The order of applicability of this coverage relative to other coverages which are currently in force. Note, there may be gaps in the numbering and this does not imply primary, secondary etc. as the specific positioning of coverages depends upon the episode of care.",
2302        0, 1, order));
2303    children.add(new Property("network", "string",
2304        "The insurer-specific identifier for the insurer-defined network of providers to which the beneficiary may seek treatment which will be covered at the 'in-network' rate, otherwise 'out of network' terms and conditions apply.",
2305        0, 1, network));
2306    children.add(new Property("costToBeneficiary", "",
2307        "A suite of codes indicating the cost category and associated amount which have been detailed in the policy and may have been  included on the health card.",
2308        0, java.lang.Integer.MAX_VALUE, costToBeneficiary));
2309    children.add(new Property("subrogation", "boolean",
2310        "When 'subrogation=true' this insurance instance has been included not for adjudication but to provide insurers with the details to recover costs.",
2311        0, 1, subrogation));
2312    children.add(new Property("contract", "Reference(Contract)",
2313        "The policy(s) which constitute this insurance coverage.", 0, java.lang.Integer.MAX_VALUE, contract));
2314  }
2315
2316  @Override
2317  public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2318    switch (_hash) {
2319    case -1618432855:
2320      /* identifier */ return new Property("identifier", "Identifier", "A unique identifier assigned to this coverage.",
2321          0, java.lang.Integer.MAX_VALUE, identifier);
2322    case -892481550:
2323      /* status */ return new Property("status", "code", "The status of the resource instance.", 0, 1, status);
2324    case 3575610:
2325      /* type */ return new Property("type", "CodeableConcept",
2326          "The type of coverage: social program, medical plan, accident coverage (workers compensation, auto), group health or payment by an individual or organization.",
2327          0, 1, type);
2328    case 2046898558:
2329      /* policyHolder */ return new Property("policyHolder", "Reference(Patient|RelatedPerson|Organization)",
2330          "The party who 'owns' the insurance policy.", 0, 1, policyHolder);
2331    case -1219769240:
2332      /* subscriber */ return new Property("subscriber", "Reference(Patient|RelatedPerson)",
2333          "The party who has signed-up for or 'owns' the contractual relationship to the policy or to whom the benefit of the policy for services rendered to them or their family is due.",
2334          0, 1, subscriber);
2335    case 327834531:
2336      /* subscriberId */ return new Property("subscriberId", "string", "The insurer assigned ID for the Subscriber.", 0,
2337          1, subscriberId);
2338    case -565102875:
2339      /* beneficiary */ return new Property("beneficiary", "Reference(Patient)",
2340          "The party who benefits from the insurance coverage; the patient when products and/or services are provided.",
2341          0, 1, beneficiary);
2342    case -1109226753:
2343      /* dependent */ return new Property("dependent", "string",
2344          "A unique identifier for a dependent under the coverage.", 0, 1, dependent);
2345    case -261851592:
2346      /* relationship */ return new Property("relationship", "CodeableConcept",
2347          "The relationship of beneficiary (patient) to the subscriber.", 0, 1, relationship);
2348    case -991726143:
2349      /* period */ return new Property("period", "Period",
2350          "Time period during which the coverage is in force. A missing start date indicates the start date isn't known, a missing end date means the coverage is continuing to be in force.",
2351          0, 1, period);
2352    case 106443915:
2353      /* payor */ return new Property("payor", "Reference(Organization|Patient|RelatedPerson)",
2354          "The program or plan underwriter or payor including both insurance and non-insurance agreements, such as patient-pay agreements.",
2355          0, java.lang.Integer.MAX_VALUE, payor);
2356    case 94742904:
2357      /* class */ return new Property("class", "", "A suite of underwriter specific classifiers.", 0,
2358          java.lang.Integer.MAX_VALUE, class_);
2359    case 106006350:
2360      /* order */ return new Property("order", "positiveInt",
2361          "The order of applicability of this coverage relative to other coverages which are currently in force. Note, there may be gaps in the numbering and this does not imply primary, secondary etc. as the specific positioning of coverages depends upon the episode of care.",
2362          0, 1, order);
2363    case 1843485230:
2364      /* network */ return new Property("network", "string",
2365          "The insurer-specific identifier for the insurer-defined network of providers to which the beneficiary may seek treatment which will be covered at the 'in-network' rate, otherwise 'out of network' terms and conditions apply.",
2366          0, 1, network);
2367    case -1866474851:
2368      /* costToBeneficiary */ return new Property("costToBeneficiary", "",
2369          "A suite of codes indicating the cost category and associated amount which have been detailed in the policy and may have been  included on the health card.",
2370          0, java.lang.Integer.MAX_VALUE, costToBeneficiary);
2371    case 837389739:
2372      /* subrogation */ return new Property("subrogation", "boolean",
2373          "When 'subrogation=true' this insurance instance has been included not for adjudication but to provide insurers with the details to recover costs.",
2374          0, 1, subrogation);
2375    case -566947566:
2376      /* contract */ return new Property("contract", "Reference(Contract)",
2377          "The policy(s) which constitute this insurance coverage.", 0, java.lang.Integer.MAX_VALUE, contract);
2378    default:
2379      return super.getNamedProperty(_hash, _name, _checkValid);
2380    }
2381
2382  }
2383
2384  @Override
2385  public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2386    switch (hash) {
2387    case -1618432855:
2388      /* identifier */ return this.identifier == null ? new Base[0]
2389          : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2390    case -892481550:
2391      /* status */ return this.status == null ? new Base[0] : new Base[] { this.status }; // Enumeration<CoverageStatus>
2392    case 3575610:
2393      /* type */ return this.type == null ? new Base[0] : new Base[] { this.type }; // CodeableConcept
2394    case 2046898558:
2395      /* policyHolder */ return this.policyHolder == null ? new Base[0] : new Base[] { this.policyHolder }; // Reference
2396    case -1219769240:
2397      /* subscriber */ return this.subscriber == null ? new Base[0] : new Base[] { this.subscriber }; // Reference
2398    case 327834531:
2399      /* subscriberId */ return this.subscriberId == null ? new Base[0] : new Base[] { this.subscriberId }; // StringType
2400    case -565102875:
2401      /* beneficiary */ return this.beneficiary == null ? new Base[0] : new Base[] { this.beneficiary }; // Reference
2402    case -1109226753:
2403      /* dependent */ return this.dependent == null ? new Base[0] : new Base[] { this.dependent }; // StringType
2404    case -261851592:
2405      /* relationship */ return this.relationship == null ? new Base[0] : new Base[] { this.relationship }; // CodeableConcept
2406    case -991726143:
2407      /* period */ return this.period == null ? new Base[0] : new Base[] { this.period }; // Period
2408    case 106443915:
2409      /* payor */ return this.payor == null ? new Base[0] : this.payor.toArray(new Base[this.payor.size()]); // Reference
2410    case 94742904:
2411      /* class */ return this.class_ == null ? new Base[0] : this.class_.toArray(new Base[this.class_.size()]); // ClassComponent
2412    case 106006350:
2413      /* order */ return this.order == null ? new Base[0] : new Base[] { this.order }; // PositiveIntType
2414    case 1843485230:
2415      /* network */ return this.network == null ? new Base[0] : new Base[] { this.network }; // StringType
2416    case -1866474851:
2417      /* costToBeneficiary */ return this.costToBeneficiary == null ? new Base[0]
2418          : this.costToBeneficiary.toArray(new Base[this.costToBeneficiary.size()]); // CostToBeneficiaryComponent
2419    case 837389739:
2420      /* subrogation */ return this.subrogation == null ? new Base[0] : new Base[] { this.subrogation }; // BooleanType
2421    case -566947566:
2422      /* contract */ return this.contract == null ? new Base[0] : this.contract.toArray(new Base[this.contract.size()]); // Reference
2423    default:
2424      return super.getProperty(hash, name, checkValid);
2425    }
2426
2427  }
2428
2429  @Override
2430  public Base setProperty(int hash, String name, Base value) throws FHIRException {
2431    switch (hash) {
2432    case -1618432855: // identifier
2433      this.getIdentifier().add(castToIdentifier(value)); // Identifier
2434      return value;
2435    case -892481550: // status
2436      value = new CoverageStatusEnumFactory().fromType(castToCode(value));
2437      this.status = (Enumeration) value; // Enumeration<CoverageStatus>
2438      return value;
2439    case 3575610: // type
2440      this.type = castToCodeableConcept(value); // CodeableConcept
2441      return value;
2442    case 2046898558: // policyHolder
2443      this.policyHolder = castToReference(value); // Reference
2444      return value;
2445    case -1219769240: // subscriber
2446      this.subscriber = castToReference(value); // Reference
2447      return value;
2448    case 327834531: // subscriberId
2449      this.subscriberId = castToString(value); // StringType
2450      return value;
2451    case -565102875: // beneficiary
2452      this.beneficiary = castToReference(value); // Reference
2453      return value;
2454    case -1109226753: // dependent
2455      this.dependent = castToString(value); // StringType
2456      return value;
2457    case -261851592: // relationship
2458      this.relationship = castToCodeableConcept(value); // CodeableConcept
2459      return value;
2460    case -991726143: // period
2461      this.period = castToPeriod(value); // Period
2462      return value;
2463    case 106443915: // payor
2464      this.getPayor().add(castToReference(value)); // Reference
2465      return value;
2466    case 94742904: // class
2467      this.getClass_().add((ClassComponent) value); // ClassComponent
2468      return value;
2469    case 106006350: // order
2470      this.order = castToPositiveInt(value); // PositiveIntType
2471      return value;
2472    case 1843485230: // network
2473      this.network = castToString(value); // StringType
2474      return value;
2475    case -1866474851: // costToBeneficiary
2476      this.getCostToBeneficiary().add((CostToBeneficiaryComponent) value); // CostToBeneficiaryComponent
2477      return value;
2478    case 837389739: // subrogation
2479      this.subrogation = castToBoolean(value); // BooleanType
2480      return value;
2481    case -566947566: // contract
2482      this.getContract().add(castToReference(value)); // Reference
2483      return value;
2484    default:
2485      return super.setProperty(hash, name, value);
2486    }
2487
2488  }
2489
2490  @Override
2491  public Base setProperty(String name, Base value) throws FHIRException {
2492    if (name.equals("identifier")) {
2493      this.getIdentifier().add(castToIdentifier(value));
2494    } else if (name.equals("status")) {
2495      value = new CoverageStatusEnumFactory().fromType(castToCode(value));
2496      this.status = (Enumeration) value; // Enumeration<CoverageStatus>
2497    } else if (name.equals("type")) {
2498      this.type = castToCodeableConcept(value); // CodeableConcept
2499    } else if (name.equals("policyHolder")) {
2500      this.policyHolder = castToReference(value); // Reference
2501    } else if (name.equals("subscriber")) {
2502      this.subscriber = castToReference(value); // Reference
2503    } else if (name.equals("subscriberId")) {
2504      this.subscriberId = castToString(value); // StringType
2505    } else if (name.equals("beneficiary")) {
2506      this.beneficiary = castToReference(value); // Reference
2507    } else if (name.equals("dependent")) {
2508      this.dependent = castToString(value); // StringType
2509    } else if (name.equals("relationship")) {
2510      this.relationship = castToCodeableConcept(value); // CodeableConcept
2511    } else if (name.equals("period")) {
2512      this.period = castToPeriod(value); // Period
2513    } else if (name.equals("payor")) {
2514      this.getPayor().add(castToReference(value));
2515    } else if (name.equals("class")) {
2516      this.getClass_().add((ClassComponent) value);
2517    } else if (name.equals("order")) {
2518      this.order = castToPositiveInt(value); // PositiveIntType
2519    } else if (name.equals("network")) {
2520      this.network = castToString(value); // StringType
2521    } else if (name.equals("costToBeneficiary")) {
2522      this.getCostToBeneficiary().add((CostToBeneficiaryComponent) value);
2523    } else if (name.equals("subrogation")) {
2524      this.subrogation = castToBoolean(value); // BooleanType
2525    } else if (name.equals("contract")) {
2526      this.getContract().add(castToReference(value));
2527    } else
2528      return super.setProperty(name, value);
2529    return value;
2530  }
2531
2532  @Override
2533  public void removeChild(String name, Base value) throws FHIRException {
2534    if (name.equals("identifier")) {
2535      this.getIdentifier().remove(castToIdentifier(value));
2536    } else if (name.equals("status")) {
2537      this.status = null;
2538    } else if (name.equals("type")) {
2539      this.type = null;
2540    } else if (name.equals("policyHolder")) {
2541      this.policyHolder = null;
2542    } else if (name.equals("subscriber")) {
2543      this.subscriber = null;
2544    } else if (name.equals("subscriberId")) {
2545      this.subscriberId = null;
2546    } else if (name.equals("beneficiary")) {
2547      this.beneficiary = null;
2548    } else if (name.equals("dependent")) {
2549      this.dependent = null;
2550    } else if (name.equals("relationship")) {
2551      this.relationship = null;
2552    } else if (name.equals("period")) {
2553      this.period = null;
2554    } else if (name.equals("payor")) {
2555      this.getPayor().remove(castToReference(value));
2556    } else if (name.equals("class")) {
2557      this.getClass_().remove((ClassComponent) value);
2558    } else if (name.equals("order")) {
2559      this.order = null;
2560    } else if (name.equals("network")) {
2561      this.network = null;
2562    } else if (name.equals("costToBeneficiary")) {
2563      this.getCostToBeneficiary().remove((CostToBeneficiaryComponent) value);
2564    } else if (name.equals("subrogation")) {
2565      this.subrogation = null;
2566    } else if (name.equals("contract")) {
2567      this.getContract().remove(castToReference(value));
2568    } else
2569      super.removeChild(name, value);
2570    
2571  }
2572
2573  @Override
2574  public Base makeProperty(int hash, String name) throws FHIRException {
2575    switch (hash) {
2576    case -1618432855:
2577      return addIdentifier();
2578    case -892481550:
2579      return getStatusElement();
2580    case 3575610:
2581      return getType();
2582    case 2046898558:
2583      return getPolicyHolder();
2584    case -1219769240:
2585      return getSubscriber();
2586    case 327834531:
2587      return getSubscriberIdElement();
2588    case -565102875:
2589      return getBeneficiary();
2590    case -1109226753:
2591      return getDependentElement();
2592    case -261851592:
2593      return getRelationship();
2594    case -991726143:
2595      return getPeriod();
2596    case 106443915:
2597      return addPayor();
2598    case 94742904:
2599      return addClass_();
2600    case 106006350:
2601      return getOrderElement();
2602    case 1843485230:
2603      return getNetworkElement();
2604    case -1866474851:
2605      return addCostToBeneficiary();
2606    case 837389739:
2607      return getSubrogationElement();
2608    case -566947566:
2609      return addContract();
2610    default:
2611      return super.makeProperty(hash, name);
2612    }
2613
2614  }
2615
2616  @Override
2617  public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2618    switch (hash) {
2619    case -1618432855:
2620      /* identifier */ return new String[] { "Identifier" };
2621    case -892481550:
2622      /* status */ return new String[] { "code" };
2623    case 3575610:
2624      /* type */ return new String[] { "CodeableConcept" };
2625    case 2046898558:
2626      /* policyHolder */ return new String[] { "Reference" };
2627    case -1219769240:
2628      /* subscriber */ return new String[] { "Reference" };
2629    case 327834531:
2630      /* subscriberId */ return new String[] { "string" };
2631    case -565102875:
2632      /* beneficiary */ return new String[] { "Reference" };
2633    case -1109226753:
2634      /* dependent */ return new String[] { "string" };
2635    case -261851592:
2636      /* relationship */ return new String[] { "CodeableConcept" };
2637    case -991726143:
2638      /* period */ return new String[] { "Period" };
2639    case 106443915:
2640      /* payor */ return new String[] { "Reference" };
2641    case 94742904:
2642      /* class */ return new String[] {};
2643    case 106006350:
2644      /* order */ return new String[] { "positiveInt" };
2645    case 1843485230:
2646      /* network */ return new String[] { "string" };
2647    case -1866474851:
2648      /* costToBeneficiary */ return new String[] {};
2649    case 837389739:
2650      /* subrogation */ return new String[] { "boolean" };
2651    case -566947566:
2652      /* contract */ return new String[] { "Reference" };
2653    default:
2654      return super.getTypesForProperty(hash, name);
2655    }
2656
2657  }
2658
2659  @Override
2660  public Base addChild(String name) throws FHIRException {
2661    if (name.equals("identifier")) {
2662      return addIdentifier();
2663    } else if (name.equals("status")) {
2664      throw new FHIRException("Cannot call addChild on a singleton property Coverage.status");
2665    } else if (name.equals("type")) {
2666      this.type = new CodeableConcept();
2667      return this.type;
2668    } else if (name.equals("policyHolder")) {
2669      this.policyHolder = new Reference();
2670      return this.policyHolder;
2671    } else if (name.equals("subscriber")) {
2672      this.subscriber = new Reference();
2673      return this.subscriber;
2674    } else if (name.equals("subscriberId")) {
2675      throw new FHIRException("Cannot call addChild on a singleton property Coverage.subscriberId");
2676    } else if (name.equals("beneficiary")) {
2677      this.beneficiary = new Reference();
2678      return this.beneficiary;
2679    } else if (name.equals("dependent")) {
2680      throw new FHIRException("Cannot call addChild on a singleton property Coverage.dependent");
2681    } else if (name.equals("relationship")) {
2682      this.relationship = new CodeableConcept();
2683      return this.relationship;
2684    } else if (name.equals("period")) {
2685      this.period = new Period();
2686      return this.period;
2687    } else if (name.equals("payor")) {
2688      return addPayor();
2689    } else if (name.equals("class")) {
2690      return addClass_();
2691    } else if (name.equals("order")) {
2692      throw new FHIRException("Cannot call addChild on a singleton property Coverage.order");
2693    } else if (name.equals("network")) {
2694      throw new FHIRException("Cannot call addChild on a singleton property Coverage.network");
2695    } else if (name.equals("costToBeneficiary")) {
2696      return addCostToBeneficiary();
2697    } else if (name.equals("subrogation")) {
2698      throw new FHIRException("Cannot call addChild on a singleton property Coverage.subrogation");
2699    } else if (name.equals("contract")) {
2700      return addContract();
2701    } else
2702      return super.addChild(name);
2703  }
2704
2705  public String fhirType() {
2706    return "Coverage";
2707
2708  }
2709
2710  public Coverage copy() {
2711    Coverage dst = new Coverage();
2712    copyValues(dst);
2713    return dst;
2714  }
2715
2716  public void copyValues(Coverage dst) {
2717    super.copyValues(dst);
2718    if (identifier != null) {
2719      dst.identifier = new ArrayList<Identifier>();
2720      for (Identifier i : identifier)
2721        dst.identifier.add(i.copy());
2722    }
2723    ;
2724    dst.status = status == null ? null : status.copy();
2725    dst.type = type == null ? null : type.copy();
2726    dst.policyHolder = policyHolder == null ? null : policyHolder.copy();
2727    dst.subscriber = subscriber == null ? null : subscriber.copy();
2728    dst.subscriberId = subscriberId == null ? null : subscriberId.copy();
2729    dst.beneficiary = beneficiary == null ? null : beneficiary.copy();
2730    dst.dependent = dependent == null ? null : dependent.copy();
2731    dst.relationship = relationship == null ? null : relationship.copy();
2732    dst.period = period == null ? null : period.copy();
2733    if (payor != null) {
2734      dst.payor = new ArrayList<Reference>();
2735      for (Reference i : payor)
2736        dst.payor.add(i.copy());
2737    }
2738    ;
2739    if (class_ != null) {
2740      dst.class_ = new ArrayList<ClassComponent>();
2741      for (ClassComponent i : class_)
2742        dst.class_.add(i.copy());
2743    }
2744    ;
2745    dst.order = order == null ? null : order.copy();
2746    dst.network = network == null ? null : network.copy();
2747    if (costToBeneficiary != null) {
2748      dst.costToBeneficiary = new ArrayList<CostToBeneficiaryComponent>();
2749      for (CostToBeneficiaryComponent i : costToBeneficiary)
2750        dst.costToBeneficiary.add(i.copy());
2751    }
2752    ;
2753    dst.subrogation = subrogation == null ? null : subrogation.copy();
2754    if (contract != null) {
2755      dst.contract = new ArrayList<Reference>();
2756      for (Reference i : contract)
2757        dst.contract.add(i.copy());
2758    }
2759    ;
2760  }
2761
2762  protected Coverage typedCopy() {
2763    return copy();
2764  }
2765
2766  @Override
2767  public boolean equalsDeep(Base other_) {
2768    if (!super.equalsDeep(other_))
2769      return false;
2770    if (!(other_ instanceof Coverage))
2771      return false;
2772    Coverage o = (Coverage) other_;
2773    return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true)
2774        && compareDeep(type, o.type, true) && compareDeep(policyHolder, o.policyHolder, true)
2775        && compareDeep(subscriber, o.subscriber, true) && compareDeep(subscriberId, o.subscriberId, true)
2776        && compareDeep(beneficiary, o.beneficiary, true) && compareDeep(dependent, o.dependent, true)
2777        && compareDeep(relationship, o.relationship, true) && compareDeep(period, o.period, true)
2778        && compareDeep(payor, o.payor, true) && compareDeep(class_, o.class_, true) && compareDeep(order, o.order, true)
2779        && compareDeep(network, o.network, true) && compareDeep(costToBeneficiary, o.costToBeneficiary, true)
2780        && compareDeep(subrogation, o.subrogation, true) && compareDeep(contract, o.contract, true);
2781  }
2782
2783  @Override
2784  public boolean equalsShallow(Base other_) {
2785    if (!super.equalsShallow(other_))
2786      return false;
2787    if (!(other_ instanceof Coverage))
2788      return false;
2789    Coverage o = (Coverage) other_;
2790    return compareValues(status, o.status, true) && compareValues(subscriberId, o.subscriberId, true)
2791        && compareValues(dependent, o.dependent, true) && compareValues(order, o.order, true)
2792        && compareValues(network, o.network, true) && compareValues(subrogation, o.subrogation, true);
2793  }
2794
2795  public boolean isEmpty() {
2796    return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, type, policyHolder, subscriber,
2797        subscriberId, beneficiary, dependent, relationship, period, payor, class_, order, network, costToBeneficiary,
2798        subrogation, contract);
2799  }
2800
2801  @Override
2802  public ResourceType getResourceType() {
2803    return ResourceType.Coverage;
2804  }
2805
2806  /**
2807   * Search parameter: <b>identifier</b>
2808   * <p>
2809   * Description: <b>The primary identifier of the insured and the
2810   * coverage</b><br>
2811   * Type: <b>token</b><br>
2812   * Path: <b>Coverage.identifier</b><br>
2813   * </p>
2814   */
2815  @SearchParamDefinition(name = "identifier", path = "Coverage.identifier", description = "The primary identifier of the insured and the coverage", type = "token")
2816  public static final String SP_IDENTIFIER = "identifier";
2817  /**
2818   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2819   * <p>
2820   * Description: <b>The primary identifier of the insured and the
2821   * coverage</b><br>
2822   * Type: <b>token</b><br>
2823   * Path: <b>Coverage.identifier</b><br>
2824   * </p>
2825   */
2826  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(
2827      SP_IDENTIFIER);
2828
2829  /**
2830   * Search parameter: <b>payor</b>
2831   * <p>
2832   * Description: <b>The identity of the insurer or party paying for
2833   * services</b><br>
2834   * Type: <b>reference</b><br>
2835   * Path: <b>Coverage.payor</b><br>
2836   * </p>
2837   */
2838  @SearchParamDefinition(name = "payor", path = "Coverage.payor", description = "The identity of the insurer or party paying for services", type = "reference", providesMembershipIn = {
2839      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Patient"),
2840      @ca.uhn.fhir.model.api.annotation.Compartment(name = "RelatedPerson") }, target = { Organization.class,
2841          Patient.class, RelatedPerson.class })
2842  public static final String SP_PAYOR = "payor";
2843  /**
2844   * <b>Fluent Client</b> search parameter constant for <b>payor</b>
2845   * <p>
2846   * Description: <b>The identity of the insurer or party paying for
2847   * services</b><br>
2848   * Type: <b>reference</b><br>
2849   * Path: <b>Coverage.payor</b><br>
2850   * </p>
2851   */
2852  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PAYOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
2853      SP_PAYOR);
2854
2855  /**
2856   * Constant for fluent queries to be used to add include statements. Specifies
2857   * the path value of "<b>Coverage:payor</b>".
2858   */
2859  public static final ca.uhn.fhir.model.api.Include INCLUDE_PAYOR = new ca.uhn.fhir.model.api.Include("Coverage:payor")
2860      .toLocked();
2861
2862  /**
2863   * Search parameter: <b>subscriber</b>
2864   * <p>
2865   * Description: <b>Reference to the subscriber</b><br>
2866   * Type: <b>reference</b><br>
2867   * Path: <b>Coverage.subscriber</b><br>
2868   * </p>
2869   */
2870  @SearchParamDefinition(name = "subscriber", path = "Coverage.subscriber", description = "Reference to the subscriber", type = "reference", providesMembershipIn = {
2871      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Patient"),
2872      @ca.uhn.fhir.model.api.annotation.Compartment(name = "RelatedPerson") }, target = { Patient.class,
2873          RelatedPerson.class })
2874  public static final String SP_SUBSCRIBER = "subscriber";
2875  /**
2876   * <b>Fluent Client</b> search parameter constant for <b>subscriber</b>
2877   * <p>
2878   * Description: <b>Reference to the subscriber</b><br>
2879   * Type: <b>reference</b><br>
2880   * Path: <b>Coverage.subscriber</b><br>
2881   * </p>
2882   */
2883  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBSCRIBER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
2884      SP_SUBSCRIBER);
2885
2886  /**
2887   * Constant for fluent queries to be used to add include statements. Specifies
2888   * the path value of "<b>Coverage:subscriber</b>".
2889   */
2890  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBSCRIBER = new ca.uhn.fhir.model.api.Include(
2891      "Coverage:subscriber").toLocked();
2892
2893  /**
2894   * Search parameter: <b>beneficiary</b>
2895   * <p>
2896   * Description: <b>Covered party</b><br>
2897   * Type: <b>reference</b><br>
2898   * Path: <b>Coverage.beneficiary</b><br>
2899   * </p>
2900   */
2901  @SearchParamDefinition(name = "beneficiary", path = "Coverage.beneficiary", description = "Covered party", type = "reference", providesMembershipIn = {
2902      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Patient") }, target = { Patient.class })
2903  public static final String SP_BENEFICIARY = "beneficiary";
2904  /**
2905   * <b>Fluent Client</b> search parameter constant for <b>beneficiary</b>
2906   * <p>
2907   * Description: <b>Covered party</b><br>
2908   * Type: <b>reference</b><br>
2909   * Path: <b>Coverage.beneficiary</b><br>
2910   * </p>
2911   */
2912  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam BENEFICIARY = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
2913      SP_BENEFICIARY);
2914
2915  /**
2916   * Constant for fluent queries to be used to add include statements. Specifies
2917   * the path value of "<b>Coverage:beneficiary</b>".
2918   */
2919  public static final ca.uhn.fhir.model.api.Include INCLUDE_BENEFICIARY = new ca.uhn.fhir.model.api.Include(
2920      "Coverage:beneficiary").toLocked();
2921
2922  /**
2923   * Search parameter: <b>patient</b>
2924   * <p>
2925   * Description: <b>Retrieve coverages for a patient</b><br>
2926   * Type: <b>reference</b><br>
2927   * Path: <b>Coverage.beneficiary</b><br>
2928   * </p>
2929   */
2930  @SearchParamDefinition(name = "patient", path = "Coverage.beneficiary", description = "Retrieve coverages for a patient", type = "reference", target = {
2931      Patient.class })
2932  public static final String SP_PATIENT = "patient";
2933  /**
2934   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2935   * <p>
2936   * Description: <b>Retrieve coverages for a patient</b><br>
2937   * Type: <b>reference</b><br>
2938   * Path: <b>Coverage.beneficiary</b><br>
2939   * </p>
2940   */
2941  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
2942      SP_PATIENT);
2943
2944  /**
2945   * Constant for fluent queries to be used to add include statements. Specifies
2946   * the path value of "<b>Coverage:patient</b>".
2947   */
2948  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include(
2949      "Coverage:patient").toLocked();
2950
2951  /**
2952   * Search parameter: <b>class-value</b>
2953   * <p>
2954   * Description: <b>Value of the class (eg. Plan number, group number)</b><br>
2955   * Type: <b>string</b><br>
2956   * Path: <b>Coverage.class.value</b><br>
2957   * </p>
2958   */
2959  @SearchParamDefinition(name = "class-value", path = "Coverage.class.value", description = "Value of the class (eg. Plan number, group number)", type = "string")
2960  public static final String SP_CLASS_VALUE = "class-value";
2961  /**
2962   * <b>Fluent Client</b> search parameter constant for <b>class-value</b>
2963   * <p>
2964   * Description: <b>Value of the class (eg. Plan number, group number)</b><br>
2965   * Type: <b>string</b><br>
2966   * Path: <b>Coverage.class.value</b><br>
2967   * </p>
2968   */
2969  public static final ca.uhn.fhir.rest.gclient.StringClientParam CLASS_VALUE = new ca.uhn.fhir.rest.gclient.StringClientParam(
2970      SP_CLASS_VALUE);
2971
2972  /**
2973   * Search parameter: <b>type</b>
2974   * <p>
2975   * Description: <b>The kind of coverage (health plan, auto, Workers
2976   * Compensation)</b><br>
2977   * Type: <b>token</b><br>
2978   * Path: <b>Coverage.type</b><br>
2979   * </p>
2980   */
2981  @SearchParamDefinition(name = "type", path = "Coverage.type", description = "The kind of coverage (health plan, auto, Workers Compensation)", type = "token")
2982  public static final String SP_TYPE = "type";
2983  /**
2984   * <b>Fluent Client</b> search parameter constant for <b>type</b>
2985   * <p>
2986   * Description: <b>The kind of coverage (health plan, auto, Workers
2987   * Compensation)</b><br>
2988   * Type: <b>token</b><br>
2989   * Path: <b>Coverage.type</b><br>
2990   * </p>
2991   */
2992  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(
2993      SP_TYPE);
2994
2995  /**
2996   * Search parameter: <b>dependent</b>
2997   * <p>
2998   * Description: <b>Dependent number</b><br>
2999   * Type: <b>string</b><br>
3000   * Path: <b>Coverage.dependent</b><br>
3001   * </p>
3002   */
3003  @SearchParamDefinition(name = "dependent", path = "Coverage.dependent", description = "Dependent number", type = "string")
3004  public static final String SP_DEPENDENT = "dependent";
3005  /**
3006   * <b>Fluent Client</b> search parameter constant for <b>dependent</b>
3007   * <p>
3008   * Description: <b>Dependent number</b><br>
3009   * Type: <b>string</b><br>
3010   * Path: <b>Coverage.dependent</b><br>
3011   * </p>
3012   */
3013  public static final ca.uhn.fhir.rest.gclient.StringClientParam DEPENDENT = new ca.uhn.fhir.rest.gclient.StringClientParam(
3014      SP_DEPENDENT);
3015
3016  /**
3017   * Search parameter: <b>class-type</b>
3018   * <p>
3019   * Description: <b>Coverage class (eg. plan, group)</b><br>
3020   * Type: <b>token</b><br>
3021   * Path: <b>Coverage.class.type</b><br>
3022   * </p>
3023   */
3024  @SearchParamDefinition(name = "class-type", path = "Coverage.class.type", description = "Coverage class (eg. plan, group)", type = "token")
3025  public static final String SP_CLASS_TYPE = "class-type";
3026  /**
3027   * <b>Fluent Client</b> search parameter constant for <b>class-type</b>
3028   * <p>
3029   * Description: <b>Coverage class (eg. plan, group)</b><br>
3030   * Type: <b>token</b><br>
3031   * Path: <b>Coverage.class.type</b><br>
3032   * </p>
3033   */
3034  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CLASS_TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(
3035      SP_CLASS_TYPE);
3036
3037  /**
3038   * Search parameter: <b>policy-holder</b>
3039   * <p>
3040   * Description: <b>Reference to the policyholder</b><br>
3041   * Type: <b>reference</b><br>
3042   * Path: <b>Coverage.policyHolder</b><br>
3043   * </p>
3044   */
3045  @SearchParamDefinition(name = "policy-holder", path = "Coverage.policyHolder", description = "Reference to the policyholder", type = "reference", providesMembershipIn = {
3046      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Patient"),
3047      @ca.uhn.fhir.model.api.annotation.Compartment(name = "RelatedPerson") }, target = { Organization.class,
3048          Patient.class, RelatedPerson.class })
3049  public static final String SP_POLICY_HOLDER = "policy-holder";
3050  /**
3051   * <b>Fluent Client</b> search parameter constant for <b>policy-holder</b>
3052   * <p>
3053   * Description: <b>Reference to the policyholder</b><br>
3054   * Type: <b>reference</b><br>
3055   * Path: <b>Coverage.policyHolder</b><br>
3056   * </p>
3057   */
3058  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam POLICY_HOLDER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
3059      SP_POLICY_HOLDER);
3060
3061  /**
3062   * Constant for fluent queries to be used to add include statements. Specifies
3063   * the path value of "<b>Coverage:policy-holder</b>".
3064   */
3065  public static final ca.uhn.fhir.model.api.Include INCLUDE_POLICY_HOLDER = new ca.uhn.fhir.model.api.Include(
3066      "Coverage:policy-holder").toLocked();
3067
3068  /**
3069   * Search parameter: <b>status</b>
3070   * <p>
3071   * Description: <b>The status of the Coverage</b><br>
3072   * Type: <b>token</b><br>
3073   * Path: <b>Coverage.status</b><br>
3074   * </p>
3075   */
3076  @SearchParamDefinition(name = "status", path = "Coverage.status", description = "The status of the Coverage", type = "token")
3077  public static final String SP_STATUS = "status";
3078  /**
3079   * <b>Fluent Client</b> search parameter constant for <b>status</b>
3080   * <p>
3081   * Description: <b>The status of the Coverage</b><br>
3082   * Type: <b>token</b><br>
3083   * Path: <b>Coverage.status</b><br>
3084   * </p>
3085   */
3086  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(
3087      SP_STATUS);
3088
3089}