001package org.hl7.fhir.dstu2.model;
002
003
004
005
006/*
007  Copyright (c) 2011+, HL7, Inc.
008  All rights reserved.
009  
010  Redistribution and use in source and binary forms, with or without modification, 
011  are permitted provided that the following conditions are met:
012  
013   * Redistributions of source code must retain the above copyright notice, this 
014     list of conditions and the following disclaimer.
015   * Redistributions in binary form must reproduce the above copyright notice, 
016     this list of conditions and the following disclaimer in the documentation 
017     and/or other materials provided with the distribution.
018   * Neither the name of HL7 nor the names of its contributors may be used to 
019     endorse or promote products derived from this software without specific 
020     prior written permission.
021  
022  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
023  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
024  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
025  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
026  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
027  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
028  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
029  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
030  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
031  POSSIBILITY OF SUCH DAMAGE.
032  
033*/
034
035// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
036import java.util.ArrayList;
037import java.util.List;
038
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.Description;
041import ca.uhn.fhir.model.api.annotation.ResourceDef;
042import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
043import org.hl7.fhir.exceptions.FHIRException;
044import org.hl7.fhir.utilities.Utilities;
045/**
046 * Financial instrument which may be used to pay for or reimburse health care products and services.
047 */
048@ResourceDef(name="Coverage", profile="http://hl7.org/fhir/Profile/Coverage")
049public class Coverage extends DomainResource {
050
051    /**
052     * The program or plan underwriter or payor.
053     */
054    @Child(name = "issuer", type = {Organization.class}, order=0, min=0, max=1, modifier=false, summary=true)
055    @Description(shortDefinition="An identifier for the plan issuer", formalDefinition="The program or plan underwriter or payor." )
056    protected Reference issuer;
057
058    /**
059     * The actual object that is the target of the reference (The program or plan underwriter or payor.)
060     */
061    protected Organization issuerTarget;
062
063    /**
064     * Business Identification Number (BIN number) used to identify the routing  of eclaims if the insurer themselves don't have a BIN number for all of their business.
065     */
066    @Child(name = "bin", type = {Identifier.class}, order=1, min=0, max=1, modifier=false, summary=false)
067    @Description(shortDefinition="BIN Number", formalDefinition="Business Identification Number (BIN number) used to identify the routing  of eclaims if the insurer themselves don't have a BIN number for all of their business." )
068    protected Identifier bin;
069
070    /**
071     * 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.
072     */
073    @Child(name = "period", type = {Period.class}, order=2, min=0, max=1, modifier=false, summary=true)
074    @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." )
075    protected Period period;
076
077    /**
078     * The type of coverage: social program, medical plan, accident coverage (workers compensation, auto), group health.
079     */
080    @Child(name = "type", type = {Coding.class}, order=3, min=0, max=1, modifier=false, summary=true)
081    @Description(shortDefinition="Type of coverage", formalDefinition="The type of coverage: social program, medical plan, accident coverage (workers compensation, auto), group health." )
082    protected Coding type;
083
084    /**
085     * The id issued to the subscriber.
086     */
087    @Child(name = "subscriberId", type = {Identifier.class}, order=4, min=0, max=1, modifier=false, summary=true)
088    @Description(shortDefinition="Subscriber ID", formalDefinition="The id issued to the subscriber." )
089    protected Identifier subscriberId;
090
091    /**
092     * The main (and possibly only) identifier for the coverage - often referred to as a Member Id, Subscriber Id, Certificate number or Personal Health Number or Case ID.
093     */
094    @Child(name = "identifier", type = {Identifier.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
095    @Description(shortDefinition="The primary coverage ID", formalDefinition="The main (and possibly only) identifier for the coverage - often referred to as a Member Id, Subscriber Id, Certificate number or Personal Health Number or Case ID." )
096    protected List<Identifier> identifier;
097
098    /**
099     * Identifies a style or collective of coverage issues by the underwriter, for example may be used to identify a class of coverage or employer group. May also be referred to as a Policy or Group ID.
100     */
101    @Child(name = "group", type = {StringType.class}, order=6, min=0, max=1, modifier=false, summary=true)
102    @Description(shortDefinition="An identifier for the group", formalDefinition="Identifies a style or collective of coverage issues by the underwriter, for example may be used to identify a class of coverage or employer group. May also be referred to as a Policy or Group ID." )
103    protected StringType group;
104
105    /**
106     * Identifies a style or collective of coverage issues by the underwriter, for example may be used to identify a class of coverage or employer group. May also be referred to as a Policy or Group ID.
107     */
108    @Child(name = "plan", type = {StringType.class}, order=7, min=0, max=1, modifier=false, summary=true)
109    @Description(shortDefinition="An identifier for the plan", formalDefinition="Identifies a style or collective of coverage issues by the underwriter, for example may be used to identify a class of coverage or employer group. May also be referred to as a Policy or Group ID." )
110    protected StringType plan;
111
112    /**
113     * Identifies a sub-style or sub-collective of coverage issues by the underwriter, for example may be used to identify a specific employer group within a class of employers. May be referred to as a Section or Division ID.
114     */
115    @Child(name = "subPlan", type = {StringType.class}, order=8, min=0, max=1, modifier=false, summary=true)
116    @Description(shortDefinition="An identifier for the subsection of the plan", formalDefinition="Identifies a sub-style or sub-collective of coverage issues by the underwriter, for example may be used to identify a specific employer group within a class of employers. May be referred to as a Section or Division ID." )
117    protected StringType subPlan;
118
119    /**
120     * A unique identifier for a dependent under the coverage.
121     */
122    @Child(name = "dependent", type = {PositiveIntType.class}, order=9, min=0, max=1, modifier=false, summary=true)
123    @Description(shortDefinition="The dependent number", formalDefinition="A unique identifier for a dependent under the coverage." )
124    protected PositiveIntType dependent;
125
126    /**
127     * An optional counter for a particular instance of the identified coverage which increments upon each renewal.
128     */
129    @Child(name = "sequence", type = {PositiveIntType.class}, order=10, min=0, max=1, modifier=false, summary=true)
130    @Description(shortDefinition="The plan instance or sequence counter", formalDefinition="An optional counter for a particular instance of the identified coverage which increments upon each renewal." )
131    protected PositiveIntType sequence;
132
133    /**
134     * The party who 'owns' the insurance contractual relationship to the policy or to whom the benefit of the policy is due.
135     */
136    @Child(name = "subscriber", type = {Patient.class}, order=11, min=0, max=1, modifier=true, summary=false)
137    @Description(shortDefinition="Plan holder information", formalDefinition="The party who 'owns' the insurance contractual relationship to the policy or to whom the benefit of the policy is due." )
138    protected Reference subscriber;
139
140    /**
141     * The actual object that is the target of the reference (The party who 'owns' the insurance contractual relationship to the policy or to whom the benefit of the policy is due.)
142     */
143    protected Patient subscriberTarget;
144
145    /**
146     * The identifier for a community of providers.
147     */
148    @Child(name = "network", type = {Identifier.class}, order=12, min=0, max=1, modifier=false, summary=true)
149    @Description(shortDefinition="Insurer network", formalDefinition="The identifier for a community of providers." )
150    protected Identifier network;
151
152    /**
153     * The policy(s) which constitute this insurance coverage.
154     */
155    @Child(name = "contract", type = {Contract.class}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
156    @Description(shortDefinition="Contract details", formalDefinition="The policy(s) which constitute this insurance coverage." )
157    protected List<Reference> contract;
158    /**
159     * The actual objects that are the target of the reference (The policy(s) which constitute this insurance coverage.)
160     */
161    protected List<Contract> contractTarget;
162
163
164    private static final long serialVersionUID = -1312031251L;
165
166  /*
167   * Constructor
168   */
169    public Coverage() {
170      super();
171    }
172
173    /**
174     * @return {@link #issuer} (The program or plan underwriter or payor.)
175     */
176    public Reference getIssuer() { 
177      if (this.issuer == null)
178        if (Configuration.errorOnAutoCreate())
179          throw new Error("Attempt to auto-create Coverage.issuer");
180        else if (Configuration.doAutoCreate())
181          this.issuer = new Reference(); // cc
182      return this.issuer;
183    }
184
185    public boolean hasIssuer() { 
186      return this.issuer != null && !this.issuer.isEmpty();
187    }
188
189    /**
190     * @param value {@link #issuer} (The program or plan underwriter or payor.)
191     */
192    public Coverage setIssuer(Reference value) { 
193      this.issuer = value;
194      return this;
195    }
196
197    /**
198     * @return {@link #issuer} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The program or plan underwriter or payor.)
199     */
200    public Organization getIssuerTarget() { 
201      if (this.issuerTarget == null)
202        if (Configuration.errorOnAutoCreate())
203          throw new Error("Attempt to auto-create Coverage.issuer");
204        else if (Configuration.doAutoCreate())
205          this.issuerTarget = new Organization(); // aa
206      return this.issuerTarget;
207    }
208
209    /**
210     * @param value {@link #issuer} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The program or plan underwriter or payor.)
211     */
212    public Coverage setIssuerTarget(Organization value) { 
213      this.issuerTarget = value;
214      return this;
215    }
216
217    /**
218     * @return {@link #bin} (Business Identification Number (BIN number) used to identify the routing  of eclaims if the insurer themselves don't have a BIN number for all of their business.)
219     */
220    public Identifier getBin() { 
221      if (this.bin == null)
222        if (Configuration.errorOnAutoCreate())
223          throw new Error("Attempt to auto-create Coverage.bin");
224        else if (Configuration.doAutoCreate())
225          this.bin = new Identifier(); // cc
226      return this.bin;
227    }
228
229    public boolean hasBin() { 
230      return this.bin != null && !this.bin.isEmpty();
231    }
232
233    /**
234     * @param value {@link #bin} (Business Identification Number (BIN number) used to identify the routing  of eclaims if the insurer themselves don't have a BIN number for all of their business.)
235     */
236    public Coverage setBin(Identifier value) { 
237      this.bin = value;
238      return this;
239    }
240
241    /**
242     * @return {@link #period} (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.)
243     */
244    public Period getPeriod() { 
245      if (this.period == null)
246        if (Configuration.errorOnAutoCreate())
247          throw new Error("Attempt to auto-create Coverage.period");
248        else if (Configuration.doAutoCreate())
249          this.period = new Period(); // cc
250      return this.period;
251    }
252
253    public boolean hasPeriod() { 
254      return this.period != null && !this.period.isEmpty();
255    }
256
257    /**
258     * @param value {@link #period} (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.)
259     */
260    public Coverage setPeriod(Period value) { 
261      this.period = value;
262      return this;
263    }
264
265    /**
266     * @return {@link #type} (The type of coverage: social program, medical plan, accident coverage (workers compensation, auto), group health.)
267     */
268    public Coding getType() { 
269      if (this.type == null)
270        if (Configuration.errorOnAutoCreate())
271          throw new Error("Attempt to auto-create Coverage.type");
272        else if (Configuration.doAutoCreate())
273          this.type = new Coding(); // cc
274      return this.type;
275    }
276
277    public boolean hasType() { 
278      return this.type != null && !this.type.isEmpty();
279    }
280
281    /**
282     * @param value {@link #type} (The type of coverage: social program, medical plan, accident coverage (workers compensation, auto), group health.)
283     */
284    public Coverage setType(Coding value) { 
285      this.type = value;
286      return this;
287    }
288
289    /**
290     * @return {@link #subscriberId} (The id issued to the subscriber.)
291     */
292    public Identifier getSubscriberId() { 
293      if (this.subscriberId == null)
294        if (Configuration.errorOnAutoCreate())
295          throw new Error("Attempt to auto-create Coverage.subscriberId");
296        else if (Configuration.doAutoCreate())
297          this.subscriberId = new Identifier(); // cc
298      return this.subscriberId;
299    }
300
301    public boolean hasSubscriberId() { 
302      return this.subscriberId != null && !this.subscriberId.isEmpty();
303    }
304
305    /**
306     * @param value {@link #subscriberId} (The id issued to the subscriber.)
307     */
308    public Coverage setSubscriberId(Identifier value) { 
309      this.subscriberId = value;
310      return this;
311    }
312
313    /**
314     * @return {@link #identifier} (The main (and possibly only) identifier for the coverage - often referred to as a Member Id, Subscriber Id, Certificate number or Personal Health Number or Case ID.)
315     */
316    public List<Identifier> getIdentifier() { 
317      if (this.identifier == null)
318        this.identifier = new ArrayList<Identifier>();
319      return this.identifier;
320    }
321
322    public boolean hasIdentifier() { 
323      if (this.identifier == null)
324        return false;
325      for (Identifier item : this.identifier)
326        if (!item.isEmpty())
327          return true;
328      return false;
329    }
330
331    /**
332     * @return {@link #identifier} (The main (and possibly only) identifier for the coverage - often referred to as a Member Id, Subscriber Id, Certificate number or Personal Health Number or Case ID.)
333     */
334    // syntactic sugar
335    public Identifier addIdentifier() { //3
336      Identifier t = new Identifier();
337      if (this.identifier == null)
338        this.identifier = new ArrayList<Identifier>();
339      this.identifier.add(t);
340      return t;
341    }
342
343    // syntactic sugar
344    public Coverage addIdentifier(Identifier t) { //3
345      if (t == null)
346        return this;
347      if (this.identifier == null)
348        this.identifier = new ArrayList<Identifier>();
349      this.identifier.add(t);
350      return this;
351    }
352
353    /**
354     * @return {@link #group} (Identifies a style or collective of coverage issues by the underwriter, for example may be used to identify a class of coverage or employer group. May also be referred to as a Policy or Group ID.). This is the underlying object with id, value and extensions. The accessor "getGroup" gives direct access to the value
355     */
356    public StringType getGroupElement() { 
357      if (this.group == null)
358        if (Configuration.errorOnAutoCreate())
359          throw new Error("Attempt to auto-create Coverage.group");
360        else if (Configuration.doAutoCreate())
361          this.group = new StringType(); // bb
362      return this.group;
363    }
364
365    public boolean hasGroupElement() { 
366      return this.group != null && !this.group.isEmpty();
367    }
368
369    public boolean hasGroup() { 
370      return this.group != null && !this.group.isEmpty();
371    }
372
373    /**
374     * @param value {@link #group} (Identifies a style or collective of coverage issues by the underwriter, for example may be used to identify a class of coverage or employer group. May also be referred to as a Policy or Group ID.). This is the underlying object with id, value and extensions. The accessor "getGroup" gives direct access to the value
375     */
376    public Coverage setGroupElement(StringType value) { 
377      this.group = value;
378      return this;
379    }
380
381    /**
382     * @return Identifies a style or collective of coverage issues by the underwriter, for example may be used to identify a class of coverage or employer group. May also be referred to as a Policy or Group ID.
383     */
384    public String getGroup() { 
385      return this.group == null ? null : this.group.getValue();
386    }
387
388    /**
389     * @param value Identifies a style or collective of coverage issues by the underwriter, for example may be used to identify a class of coverage or employer group. May also be referred to as a Policy or Group ID.
390     */
391    public Coverage setGroup(String value) { 
392      if (Utilities.noString(value))
393        this.group = null;
394      else {
395        if (this.group == null)
396          this.group = new StringType();
397        this.group.setValue(value);
398      }
399      return this;
400    }
401
402    /**
403     * @return {@link #plan} (Identifies a style or collective of coverage issues by the underwriter, for example may be used to identify a class of coverage or employer group. May also be referred to as a Policy or Group ID.). This is the underlying object with id, value and extensions. The accessor "getPlan" gives direct access to the value
404     */
405    public StringType getPlanElement() { 
406      if (this.plan == null)
407        if (Configuration.errorOnAutoCreate())
408          throw new Error("Attempt to auto-create Coverage.plan");
409        else if (Configuration.doAutoCreate())
410          this.plan = new StringType(); // bb
411      return this.plan;
412    }
413
414    public boolean hasPlanElement() { 
415      return this.plan != null && !this.plan.isEmpty();
416    }
417
418    public boolean hasPlan() { 
419      return this.plan != null && !this.plan.isEmpty();
420    }
421
422    /**
423     * @param value {@link #plan} (Identifies a style or collective of coverage issues by the underwriter, for example may be used to identify a class of coverage or employer group. May also be referred to as a Policy or Group ID.). This is the underlying object with id, value and extensions. The accessor "getPlan" gives direct access to the value
424     */
425    public Coverage setPlanElement(StringType value) { 
426      this.plan = value;
427      return this;
428    }
429
430    /**
431     * @return Identifies a style or collective of coverage issues by the underwriter, for example may be used to identify a class of coverage or employer group. May also be referred to as a Policy or Group ID.
432     */
433    public String getPlan() { 
434      return this.plan == null ? null : this.plan.getValue();
435    }
436
437    /**
438     * @param value Identifies a style or collective of coverage issues by the underwriter, for example may be used to identify a class of coverage or employer group. May also be referred to as a Policy or Group ID.
439     */
440    public Coverage setPlan(String value) { 
441      if (Utilities.noString(value))
442        this.plan = null;
443      else {
444        if (this.plan == null)
445          this.plan = new StringType();
446        this.plan.setValue(value);
447      }
448      return this;
449    }
450
451    /**
452     * @return {@link #subPlan} (Identifies a sub-style or sub-collective of coverage issues by the underwriter, for example may be used to identify a specific employer group within a class of employers. May be referred to as a Section or Division ID.). This is the underlying object with id, value and extensions. The accessor "getSubPlan" gives direct access to the value
453     */
454    public StringType getSubPlanElement() { 
455      if (this.subPlan == null)
456        if (Configuration.errorOnAutoCreate())
457          throw new Error("Attempt to auto-create Coverage.subPlan");
458        else if (Configuration.doAutoCreate())
459          this.subPlan = new StringType(); // bb
460      return this.subPlan;
461    }
462
463    public boolean hasSubPlanElement() { 
464      return this.subPlan != null && !this.subPlan.isEmpty();
465    }
466
467    public boolean hasSubPlan() { 
468      return this.subPlan != null && !this.subPlan.isEmpty();
469    }
470
471    /**
472     * @param value {@link #subPlan} (Identifies a sub-style or sub-collective of coverage issues by the underwriter, for example may be used to identify a specific employer group within a class of employers. May be referred to as a Section or Division ID.). This is the underlying object with id, value and extensions. The accessor "getSubPlan" gives direct access to the value
473     */
474    public Coverage setSubPlanElement(StringType value) { 
475      this.subPlan = value;
476      return this;
477    }
478
479    /**
480     * @return Identifies a sub-style or sub-collective of coverage issues by the underwriter, for example may be used to identify a specific employer group within a class of employers. May be referred to as a Section or Division ID.
481     */
482    public String getSubPlan() { 
483      return this.subPlan == null ? null : this.subPlan.getValue();
484    }
485
486    /**
487     * @param value Identifies a sub-style or sub-collective of coverage issues by the underwriter, for example may be used to identify a specific employer group within a class of employers. May be referred to as a Section or Division ID.
488     */
489    public Coverage setSubPlan(String value) { 
490      if (Utilities.noString(value))
491        this.subPlan = null;
492      else {
493        if (this.subPlan == null)
494          this.subPlan = new StringType();
495        this.subPlan.setValue(value);
496      }
497      return this;
498    }
499
500    /**
501     * @return {@link #dependent} (A unique identifier for a dependent under the coverage.). This is the underlying object with id, value and extensions. The accessor "getDependent" gives direct access to the value
502     */
503    public PositiveIntType getDependentElement() { 
504      if (this.dependent == null)
505        if (Configuration.errorOnAutoCreate())
506          throw new Error("Attempt to auto-create Coverage.dependent");
507        else if (Configuration.doAutoCreate())
508          this.dependent = new PositiveIntType(); // bb
509      return this.dependent;
510    }
511
512    public boolean hasDependentElement() { 
513      return this.dependent != null && !this.dependent.isEmpty();
514    }
515
516    public boolean hasDependent() { 
517      return this.dependent != null && !this.dependent.isEmpty();
518    }
519
520    /**
521     * @param value {@link #dependent} (A unique identifier for a dependent under the coverage.). This is the underlying object with id, value and extensions. The accessor "getDependent" gives direct access to the value
522     */
523    public Coverage setDependentElement(PositiveIntType value) { 
524      this.dependent = value;
525      return this;
526    }
527
528    /**
529     * @return A unique identifier for a dependent under the coverage.
530     */
531    public int getDependent() { 
532      return this.dependent == null || this.dependent.isEmpty() ? 0 : this.dependent.getValue();
533    }
534
535    /**
536     * @param value A unique identifier for a dependent under the coverage.
537     */
538    public Coverage setDependent(int value) { 
539        if (this.dependent == null)
540          this.dependent = new PositiveIntType();
541        this.dependent.setValue(value);
542      return this;
543    }
544
545    /**
546     * @return {@link #sequence} (An optional counter for a particular instance of the identified coverage which increments upon each renewal.). This is the underlying object with id, value and extensions. The accessor "getSequence" gives direct access to the value
547     */
548    public PositiveIntType getSequenceElement() { 
549      if (this.sequence == null)
550        if (Configuration.errorOnAutoCreate())
551          throw new Error("Attempt to auto-create Coverage.sequence");
552        else if (Configuration.doAutoCreate())
553          this.sequence = new PositiveIntType(); // bb
554      return this.sequence;
555    }
556
557    public boolean hasSequenceElement() { 
558      return this.sequence != null && !this.sequence.isEmpty();
559    }
560
561    public boolean hasSequence() { 
562      return this.sequence != null && !this.sequence.isEmpty();
563    }
564
565    /**
566     * @param value {@link #sequence} (An optional counter for a particular instance of the identified coverage which increments upon each renewal.). This is the underlying object with id, value and extensions. The accessor "getSequence" gives direct access to the value
567     */
568    public Coverage setSequenceElement(PositiveIntType value) { 
569      this.sequence = value;
570      return this;
571    }
572
573    /**
574     * @return An optional counter for a particular instance of the identified coverage which increments upon each renewal.
575     */
576    public int getSequence() { 
577      return this.sequence == null || this.sequence.isEmpty() ? 0 : this.sequence.getValue();
578    }
579
580    /**
581     * @param value An optional counter for a particular instance of the identified coverage which increments upon each renewal.
582     */
583    public Coverage setSequence(int value) { 
584        if (this.sequence == null)
585          this.sequence = new PositiveIntType();
586        this.sequence.setValue(value);
587      return this;
588    }
589
590    /**
591     * @return {@link #subscriber} (The party who 'owns' the insurance contractual relationship to the policy or to whom the benefit of the policy is due.)
592     */
593    public Reference getSubscriber() { 
594      if (this.subscriber == null)
595        if (Configuration.errorOnAutoCreate())
596          throw new Error("Attempt to auto-create Coverage.subscriber");
597        else if (Configuration.doAutoCreate())
598          this.subscriber = new Reference(); // cc
599      return this.subscriber;
600    }
601
602    public boolean hasSubscriber() { 
603      return this.subscriber != null && !this.subscriber.isEmpty();
604    }
605
606    /**
607     * @param value {@link #subscriber} (The party who 'owns' the insurance contractual relationship to the policy or to whom the benefit of the policy is due.)
608     */
609    public Coverage setSubscriber(Reference value) { 
610      this.subscriber = value;
611      return this;
612    }
613
614    /**
615     * @return {@link #subscriber} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The party who 'owns' the insurance contractual relationship to the policy or to whom the benefit of the policy is due.)
616     */
617    public Patient getSubscriberTarget() { 
618      if (this.subscriberTarget == null)
619        if (Configuration.errorOnAutoCreate())
620          throw new Error("Attempt to auto-create Coverage.subscriber");
621        else if (Configuration.doAutoCreate())
622          this.subscriberTarget = new Patient(); // aa
623      return this.subscriberTarget;
624    }
625
626    /**
627     * @param value {@link #subscriber} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The party who 'owns' the insurance contractual relationship to the policy or to whom the benefit of the policy is due.)
628     */
629    public Coverage setSubscriberTarget(Patient value) { 
630      this.subscriberTarget = value;
631      return this;
632    }
633
634    /**
635     * @return {@link #network} (The identifier for a community of providers.)
636     */
637    public Identifier getNetwork() { 
638      if (this.network == null)
639        if (Configuration.errorOnAutoCreate())
640          throw new Error("Attempt to auto-create Coverage.network");
641        else if (Configuration.doAutoCreate())
642          this.network = new Identifier(); // cc
643      return this.network;
644    }
645
646    public boolean hasNetwork() { 
647      return this.network != null && !this.network.isEmpty();
648    }
649
650    /**
651     * @param value {@link #network} (The identifier for a community of providers.)
652     */
653    public Coverage setNetwork(Identifier value) { 
654      this.network = value;
655      return this;
656    }
657
658    /**
659     * @return {@link #contract} (The policy(s) which constitute this insurance coverage.)
660     */
661    public List<Reference> getContract() { 
662      if (this.contract == null)
663        this.contract = new ArrayList<Reference>();
664      return this.contract;
665    }
666
667    public boolean hasContract() { 
668      if (this.contract == null)
669        return false;
670      for (Reference item : this.contract)
671        if (!item.isEmpty())
672          return true;
673      return false;
674    }
675
676    /**
677     * @return {@link #contract} (The policy(s) which constitute this insurance coverage.)
678     */
679    // syntactic sugar
680    public Reference addContract() { //3
681      Reference t = new Reference();
682      if (this.contract == null)
683        this.contract = new ArrayList<Reference>();
684      this.contract.add(t);
685      return t;
686    }
687
688    // syntactic sugar
689    public Coverage addContract(Reference t) { //3
690      if (t == null)
691        return this;
692      if (this.contract == null)
693        this.contract = new ArrayList<Reference>();
694      this.contract.add(t);
695      return this;
696    }
697
698    /**
699     * @return {@link #contract} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. The policy(s) which constitute this insurance coverage.)
700     */
701    public List<Contract> getContractTarget() { 
702      if (this.contractTarget == null)
703        this.contractTarget = new ArrayList<Contract>();
704      return this.contractTarget;
705    }
706
707    // syntactic sugar
708    /**
709     * @return {@link #contract} (Add an actual object that is the target of the reference. The reference library doesn't use these, but you can use this to hold the resources if you resolvethemt. The policy(s) which constitute this insurance coverage.)
710     */
711    public Contract addContractTarget() { 
712      Contract r = new Contract();
713      if (this.contractTarget == null)
714        this.contractTarget = new ArrayList<Contract>();
715      this.contractTarget.add(r);
716      return r;
717    }
718
719      protected void listChildren(List<Property> childrenList) {
720        super.listChildren(childrenList);
721        childrenList.add(new Property("issuer", "Reference(Organization)", "The program or plan underwriter or payor.", 0, java.lang.Integer.MAX_VALUE, issuer));
722        childrenList.add(new Property("bin", "Identifier", "Business Identification Number (BIN number) used to identify the routing  of eclaims if the insurer themselves don't have a BIN number for all of their business.", 0, java.lang.Integer.MAX_VALUE, bin));
723        childrenList.add(new Property("period", "Period", "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.", 0, java.lang.Integer.MAX_VALUE, period));
724        childrenList.add(new Property("type", "Coding", "The type of coverage: social program, medical plan, accident coverage (workers compensation, auto), group health.", 0, java.lang.Integer.MAX_VALUE, type));
725        childrenList.add(new Property("subscriberId", "Identifier", "The id issued to the subscriber.", 0, java.lang.Integer.MAX_VALUE, subscriberId));
726        childrenList.add(new Property("identifier", "Identifier", "The main (and possibly only) identifier for the coverage - often referred to as a Member Id, Subscriber Id, Certificate number or Personal Health Number or Case ID.", 0, java.lang.Integer.MAX_VALUE, identifier));
727        childrenList.add(new Property("group", "string", "Identifies a style or collective of coverage issues by the underwriter, for example may be used to identify a class of coverage or employer group. May also be referred to as a Policy or Group ID.", 0, java.lang.Integer.MAX_VALUE, group));
728        childrenList.add(new Property("plan", "string", "Identifies a style or collective of coverage issues by the underwriter, for example may be used to identify a class of coverage or employer group. May also be referred to as a Policy or Group ID.", 0, java.lang.Integer.MAX_VALUE, plan));
729        childrenList.add(new Property("subPlan", "string", "Identifies a sub-style or sub-collective of coverage issues by the underwriter, for example may be used to identify a specific employer group within a class of employers. May be referred to as a Section or Division ID.", 0, java.lang.Integer.MAX_VALUE, subPlan));
730        childrenList.add(new Property("dependent", "positiveInt", "A unique identifier for a dependent under the coverage.", 0, java.lang.Integer.MAX_VALUE, dependent));
731        childrenList.add(new Property("sequence", "positiveInt", "An optional counter for a particular instance of the identified coverage which increments upon each renewal.", 0, java.lang.Integer.MAX_VALUE, sequence));
732        childrenList.add(new Property("subscriber", "Reference(Patient)", "The party who 'owns' the insurance contractual relationship to the policy or to whom the benefit of the policy is due.", 0, java.lang.Integer.MAX_VALUE, subscriber));
733        childrenList.add(new Property("network", "Identifier", "The identifier for a community of providers.", 0, java.lang.Integer.MAX_VALUE, network));
734        childrenList.add(new Property("contract", "Reference(Contract)", "The policy(s) which constitute this insurance coverage.", 0, java.lang.Integer.MAX_VALUE, contract));
735      }
736
737      @Override
738      public void setProperty(String name, Base value) throws FHIRException {
739        if (name.equals("issuer"))
740          this.issuer = castToReference(value); // Reference
741        else if (name.equals("bin"))
742          this.bin = castToIdentifier(value); // Identifier
743        else if (name.equals("period"))
744          this.period = castToPeriod(value); // Period
745        else if (name.equals("type"))
746          this.type = castToCoding(value); // Coding
747        else if (name.equals("subscriberId"))
748          this.subscriberId = castToIdentifier(value); // Identifier
749        else if (name.equals("identifier"))
750          this.getIdentifier().add(castToIdentifier(value));
751        else if (name.equals("group"))
752          this.group = castToString(value); // StringType
753        else if (name.equals("plan"))
754          this.plan = castToString(value); // StringType
755        else if (name.equals("subPlan"))
756          this.subPlan = castToString(value); // StringType
757        else if (name.equals("dependent"))
758          this.dependent = castToPositiveInt(value); // PositiveIntType
759        else if (name.equals("sequence"))
760          this.sequence = castToPositiveInt(value); // PositiveIntType
761        else if (name.equals("subscriber"))
762          this.subscriber = castToReference(value); // Reference
763        else if (name.equals("network"))
764          this.network = castToIdentifier(value); // Identifier
765        else if (name.equals("contract"))
766          this.getContract().add(castToReference(value));
767        else
768          super.setProperty(name, value);
769      }
770
771      @Override
772      public Base addChild(String name) throws FHIRException {
773        if (name.equals("issuer")) {
774          this.issuer = new Reference();
775          return this.issuer;
776        }
777        else if (name.equals("bin")) {
778          this.bin = new Identifier();
779          return this.bin;
780        }
781        else if (name.equals("period")) {
782          this.period = new Period();
783          return this.period;
784        }
785        else if (name.equals("type")) {
786          this.type = new Coding();
787          return this.type;
788        }
789        else if (name.equals("subscriberId")) {
790          this.subscriberId = new Identifier();
791          return this.subscriberId;
792        }
793        else if (name.equals("identifier")) {
794          return addIdentifier();
795        }
796        else if (name.equals("group")) {
797          throw new FHIRException("Cannot call addChild on a primitive type Coverage.group");
798        }
799        else if (name.equals("plan")) {
800          throw new FHIRException("Cannot call addChild on a primitive type Coverage.plan");
801        }
802        else if (name.equals("subPlan")) {
803          throw new FHIRException("Cannot call addChild on a primitive type Coverage.subPlan");
804        }
805        else if (name.equals("dependent")) {
806          throw new FHIRException("Cannot call addChild on a primitive type Coverage.dependent");
807        }
808        else if (name.equals("sequence")) {
809          throw new FHIRException("Cannot call addChild on a primitive type Coverage.sequence");
810        }
811        else if (name.equals("subscriber")) {
812          this.subscriber = new Reference();
813          return this.subscriber;
814        }
815        else if (name.equals("network")) {
816          this.network = new Identifier();
817          return this.network;
818        }
819        else if (name.equals("contract")) {
820          return addContract();
821        }
822        else
823          return super.addChild(name);
824      }
825
826  public String fhirType() {
827    return "Coverage";
828
829  }
830
831      public Coverage copy() {
832        Coverage dst = new Coverage();
833        copyValues(dst);
834        dst.issuer = issuer == null ? null : issuer.copy();
835        dst.bin = bin == null ? null : bin.copy();
836        dst.period = period == null ? null : period.copy();
837        dst.type = type == null ? null : type.copy();
838        dst.subscriberId = subscriberId == null ? null : subscriberId.copy();
839        if (identifier != null) {
840          dst.identifier = new ArrayList<Identifier>();
841          for (Identifier i : identifier)
842            dst.identifier.add(i.copy());
843        };
844        dst.group = group == null ? null : group.copy();
845        dst.plan = plan == null ? null : plan.copy();
846        dst.subPlan = subPlan == null ? null : subPlan.copy();
847        dst.dependent = dependent == null ? null : dependent.copy();
848        dst.sequence = sequence == null ? null : sequence.copy();
849        dst.subscriber = subscriber == null ? null : subscriber.copy();
850        dst.network = network == null ? null : network.copy();
851        if (contract != null) {
852          dst.contract = new ArrayList<Reference>();
853          for (Reference i : contract)
854            dst.contract.add(i.copy());
855        };
856        return dst;
857      }
858
859      protected Coverage typedCopy() {
860        return copy();
861      }
862
863      @Override
864      public boolean equalsDeep(Base other) {
865        if (!super.equalsDeep(other))
866          return false;
867        if (!(other instanceof Coverage))
868          return false;
869        Coverage o = (Coverage) other;
870        return compareDeep(issuer, o.issuer, true) && compareDeep(bin, o.bin, true) && compareDeep(period, o.period, true)
871           && compareDeep(type, o.type, true) && compareDeep(subscriberId, o.subscriberId, true) && compareDeep(identifier, o.identifier, true)
872           && compareDeep(group, o.group, true) && compareDeep(plan, o.plan, true) && compareDeep(subPlan, o.subPlan, true)
873           && compareDeep(dependent, o.dependent, true) && compareDeep(sequence, o.sequence, true) && compareDeep(subscriber, o.subscriber, true)
874           && compareDeep(network, o.network, true) && compareDeep(contract, o.contract, true);
875      }
876
877      @Override
878      public boolean equalsShallow(Base other) {
879        if (!super.equalsShallow(other))
880          return false;
881        if (!(other instanceof Coverage))
882          return false;
883        Coverage o = (Coverage) other;
884        return compareValues(group, o.group, true) && compareValues(plan, o.plan, true) && compareValues(subPlan, o.subPlan, true)
885           && compareValues(dependent, o.dependent, true) && compareValues(sequence, o.sequence, true);
886      }
887
888      public boolean isEmpty() {
889        return super.isEmpty() && (issuer == null || issuer.isEmpty()) && (bin == null || bin.isEmpty())
890           && (period == null || period.isEmpty()) && (type == null || type.isEmpty()) && (subscriberId == null || subscriberId.isEmpty())
891           && (identifier == null || identifier.isEmpty()) && (group == null || group.isEmpty()) && (plan == null || plan.isEmpty())
892           && (subPlan == null || subPlan.isEmpty()) && (dependent == null || dependent.isEmpty()) && (sequence == null || sequence.isEmpty())
893           && (subscriber == null || subscriber.isEmpty()) && (network == null || network.isEmpty())
894           && (contract == null || contract.isEmpty());
895      }
896
897  @Override
898  public ResourceType getResourceType() {
899    return ResourceType.Coverage;
900   }
901
902  @SearchParamDefinition(name="identifier", path="Coverage.identifier", description="The primary identifier of the insured", type="token" )
903  public static final String SP_IDENTIFIER = "identifier";
904  @SearchParamDefinition(name="sequence", path="Coverage.sequence", description="Sequence number", type="token" )
905  public static final String SP_SEQUENCE = "sequence";
906  @SearchParamDefinition(name="subplan", path="Coverage.subPlan", description="Sub-plan identifier", type="token" )
907  public static final String SP_SUBPLAN = "subplan";
908  @SearchParamDefinition(name="type", path="Coverage.type", description="The kind of coverage", type="token" )
909  public static final String SP_TYPE = "type";
910  @SearchParamDefinition(name="plan", path="Coverage.plan", description="A plan or policy identifier", type="token" )
911  public static final String SP_PLAN = "plan";
912  @SearchParamDefinition(name="dependent", path="Coverage.dependent", description="Dependent number", type="token" )
913  public static final String SP_DEPENDENT = "dependent";
914  @SearchParamDefinition(name="issuer", path="Coverage.issuer", description="The identity of the insurer", type="reference" )
915  public static final String SP_ISSUER = "issuer";
916  @SearchParamDefinition(name="group", path="Coverage.group", description="Group identifier", type="token" )
917  public static final String SP_GROUP = "group";
918
919}