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