001package org.hl7.fhir.r5.model;
002
003
004/*
005  Copyright (c) 2011+, HL7, Inc.
006  All rights reserved.
007  
008  Redistribution and use in source and binary forms, with or without modification, \
009  are permitted provided that the following conditions are met:
010  
011   * Redistributions of source code must retain the above copyright notice, this \
012     list of conditions and the following disclaimer.
013   * Redistributions in binary form must reproduce the above copyright notice, \
014     this list of conditions and the following disclaimer in the documentation \
015     and/or other materials provided with the distribution.
016   * Neither the name of HL7 nor the names of its contributors may be used to 
017     endorse or promote products derived from this software without specific 
018     prior written permission.
019  
020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
021  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
022  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
023  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
024  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
025  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
026  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
027  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
028  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
029  POSSIBILITY OF SUCH DAMAGE.
030  */
031
032// Generated on Tue, Dec 28, 2021 07:16+1100 for FHIR v5.0.0-snapshot1
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import java.math.*;
038import org.hl7.fhir.utilities.Utilities;
039import org.hl7.fhir.r5.model.Enumerations.*;
040import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
041import org.hl7.fhir.exceptions.FHIRException;
042import org.hl7.fhir.instance.model.api.ICompositeType;
043import ca.uhn.fhir.model.api.annotation.ResourceDef;
044import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
045import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
046import ca.uhn.fhir.model.api.annotation.Child;
047import ca.uhn.fhir.model.api.annotation.ChildOrder;
048import ca.uhn.fhir.model.api.annotation.Description;
049import ca.uhn.fhir.model.api.annotation.Block;
050
051/**
052 * This resource provides: the claim details; adjudication details from the processing of a Claim; and optionally account balance information, for informing the subscriber of the benefits provided.
053 */
054@ResourceDef(name="ExplanationOfBenefit", profile="http://hl7.org/fhir/StructureDefinition/ExplanationOfBenefit")
055public class ExplanationOfBenefit extends DomainResource {
056
057    public enum ExplanationOfBenefitStatus {
058        /**
059         * The resource instance is currently in-force.
060         */
061        ACTIVE, 
062        /**
063         * The resource instance is withdrawn, rescinded or reversed.
064         */
065        CANCELLED, 
066        /**
067         * A new resource instance the contents of which is not complete.
068         */
069        DRAFT, 
070        /**
071         * The resource instance was entered in error.
072         */
073        ENTEREDINERROR, 
074        /**
075         * added to help the parsers with the generic types
076         */
077        NULL;
078        public static ExplanationOfBenefitStatus fromCode(String codeString) throws FHIRException {
079            if (codeString == null || "".equals(codeString))
080                return null;
081        if ("active".equals(codeString))
082          return ACTIVE;
083        if ("cancelled".equals(codeString))
084          return CANCELLED;
085        if ("draft".equals(codeString))
086          return DRAFT;
087        if ("entered-in-error".equals(codeString))
088          return ENTEREDINERROR;
089        if (Configuration.isAcceptInvalidEnums())
090          return null;
091        else
092          throw new FHIRException("Unknown ExplanationOfBenefitStatus code '"+codeString+"'");
093        }
094        public String toCode() {
095          switch (this) {
096            case ACTIVE: return "active";
097            case CANCELLED: return "cancelled";
098            case DRAFT: return "draft";
099            case ENTEREDINERROR: return "entered-in-error";
100            default: return "?";
101          }
102        }
103        public String getSystem() {
104          switch (this) {
105            case ACTIVE: return "http://hl7.org/fhir/explanationofbenefit-status";
106            case CANCELLED: return "http://hl7.org/fhir/explanationofbenefit-status";
107            case DRAFT: return "http://hl7.org/fhir/explanationofbenefit-status";
108            case ENTEREDINERROR: return "http://hl7.org/fhir/explanationofbenefit-status";
109            default: return "?";
110          }
111        }
112        public String getDefinition() {
113          switch (this) {
114            case ACTIVE: return "The resource instance is currently in-force.";
115            case CANCELLED: return "The resource instance is withdrawn, rescinded or reversed.";
116            case DRAFT: return "A new resource instance the contents of which is not complete.";
117            case ENTEREDINERROR: return "The resource instance was entered in error.";
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            default: return "?";
128          }
129        }
130    }
131
132  public static class ExplanationOfBenefitStatusEnumFactory implements EnumFactory<ExplanationOfBenefitStatus> {
133    public ExplanationOfBenefitStatus fromCode(String codeString) throws IllegalArgumentException {
134      if (codeString == null || "".equals(codeString))
135            if (codeString == null || "".equals(codeString))
136                return null;
137        if ("active".equals(codeString))
138          return ExplanationOfBenefitStatus.ACTIVE;
139        if ("cancelled".equals(codeString))
140          return ExplanationOfBenefitStatus.CANCELLED;
141        if ("draft".equals(codeString))
142          return ExplanationOfBenefitStatus.DRAFT;
143        if ("entered-in-error".equals(codeString))
144          return ExplanationOfBenefitStatus.ENTEREDINERROR;
145        throw new IllegalArgumentException("Unknown ExplanationOfBenefitStatus code '"+codeString+"'");
146        }
147        public Enumeration<ExplanationOfBenefitStatus> fromType(Base code) throws FHIRException {
148          if (code == null)
149            return null;
150          if (code.isEmpty())
151            return new Enumeration<ExplanationOfBenefitStatus>(this);
152          String codeString = ((PrimitiveType) code).asStringValue();
153          if (codeString == null || "".equals(codeString))
154            return null;
155        if ("active".equals(codeString))
156          return new Enumeration<ExplanationOfBenefitStatus>(this, ExplanationOfBenefitStatus.ACTIVE);
157        if ("cancelled".equals(codeString))
158          return new Enumeration<ExplanationOfBenefitStatus>(this, ExplanationOfBenefitStatus.CANCELLED);
159        if ("draft".equals(codeString))
160          return new Enumeration<ExplanationOfBenefitStatus>(this, ExplanationOfBenefitStatus.DRAFT);
161        if ("entered-in-error".equals(codeString))
162          return new Enumeration<ExplanationOfBenefitStatus>(this, ExplanationOfBenefitStatus.ENTEREDINERROR);
163        throw new FHIRException("Unknown ExplanationOfBenefitStatus code '"+codeString+"'");
164        }
165    public String toCode(ExplanationOfBenefitStatus code) {
166      if (code == ExplanationOfBenefitStatus.ACTIVE)
167        return "active";
168      if (code == ExplanationOfBenefitStatus.CANCELLED)
169        return "cancelled";
170      if (code == ExplanationOfBenefitStatus.DRAFT)
171        return "draft";
172      if (code == ExplanationOfBenefitStatus.ENTEREDINERROR)
173        return "entered-in-error";
174      return "?";
175      }
176    public String toSystem(ExplanationOfBenefitStatus code) {
177      return code.getSystem();
178      }
179    }
180
181    @Block()
182    public static class RelatedClaimComponent extends BackboneElement implements IBaseBackboneElement {
183        /**
184         * Reference to a related claim.
185         */
186        @Child(name = "claim", type = {Claim.class}, order=1, min=0, max=1, modifier=false, summary=false)
187        @Description(shortDefinition="Reference to the related claim", formalDefinition="Reference to a related claim." )
188        protected Reference claim;
189
190        /**
191         * A code to convey how the claims are related.
192         */
193        @Child(name = "relationship", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
194        @Description(shortDefinition="How the reference claim is related", formalDefinition="A code to convey how the claims are related." )
195        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/related-claim-relationship")
196        protected CodeableConcept relationship;
197
198        /**
199         * An alternate organizational reference to the case or file to which this particular claim pertains.
200         */
201        @Child(name = "reference", type = {Identifier.class}, order=3, min=0, max=1, modifier=false, summary=false)
202        @Description(shortDefinition="File or case reference", formalDefinition="An alternate organizational reference to the case or file to which this particular claim pertains." )
203        protected Identifier reference;
204
205        private static final long serialVersionUID = 1047077926L;
206
207    /**
208     * Constructor
209     */
210      public RelatedClaimComponent() {
211        super();
212      }
213
214        /**
215         * @return {@link #claim} (Reference to a related claim.)
216         */
217        public Reference getClaim() { 
218          if (this.claim == null)
219            if (Configuration.errorOnAutoCreate())
220              throw new Error("Attempt to auto-create RelatedClaimComponent.claim");
221            else if (Configuration.doAutoCreate())
222              this.claim = new Reference(); // cc
223          return this.claim;
224        }
225
226        public boolean hasClaim() { 
227          return this.claim != null && !this.claim.isEmpty();
228        }
229
230        /**
231         * @param value {@link #claim} (Reference to a related claim.)
232         */
233        public RelatedClaimComponent setClaim(Reference value) { 
234          this.claim = value;
235          return this;
236        }
237
238        /**
239         * @return {@link #relationship} (A code to convey how the claims are related.)
240         */
241        public CodeableConcept getRelationship() { 
242          if (this.relationship == null)
243            if (Configuration.errorOnAutoCreate())
244              throw new Error("Attempt to auto-create RelatedClaimComponent.relationship");
245            else if (Configuration.doAutoCreate())
246              this.relationship = new CodeableConcept(); // cc
247          return this.relationship;
248        }
249
250        public boolean hasRelationship() { 
251          return this.relationship != null && !this.relationship.isEmpty();
252        }
253
254        /**
255         * @param value {@link #relationship} (A code to convey how the claims are related.)
256         */
257        public RelatedClaimComponent setRelationship(CodeableConcept value) { 
258          this.relationship = value;
259          return this;
260        }
261
262        /**
263         * @return {@link #reference} (An alternate organizational reference to the case or file to which this particular claim pertains.)
264         */
265        public Identifier getReference() { 
266          if (this.reference == null)
267            if (Configuration.errorOnAutoCreate())
268              throw new Error("Attempt to auto-create RelatedClaimComponent.reference");
269            else if (Configuration.doAutoCreate())
270              this.reference = new Identifier(); // cc
271          return this.reference;
272        }
273
274        public boolean hasReference() { 
275          return this.reference != null && !this.reference.isEmpty();
276        }
277
278        /**
279         * @param value {@link #reference} (An alternate organizational reference to the case or file to which this particular claim pertains.)
280         */
281        public RelatedClaimComponent setReference(Identifier value) { 
282          this.reference = value;
283          return this;
284        }
285
286        protected void listChildren(List<Property> children) {
287          super.listChildren(children);
288          children.add(new Property("claim", "Reference(Claim)", "Reference to a related claim.", 0, 1, claim));
289          children.add(new Property("relationship", "CodeableConcept", "A code to convey how the claims are related.", 0, 1, relationship));
290          children.add(new Property("reference", "Identifier", "An alternate organizational reference to the case or file to which this particular claim pertains.", 0, 1, reference));
291        }
292
293        @Override
294        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
295          switch (_hash) {
296          case 94742588: /*claim*/  return new Property("claim", "Reference(Claim)", "Reference to a related claim.", 0, 1, claim);
297          case -261851592: /*relationship*/  return new Property("relationship", "CodeableConcept", "A code to convey how the claims are related.", 0, 1, relationship);
298          case -925155509: /*reference*/  return new Property("reference", "Identifier", "An alternate organizational reference to the case or file to which this particular claim pertains.", 0, 1, reference);
299          default: return super.getNamedProperty(_hash, _name, _checkValid);
300          }
301
302        }
303
304      @Override
305      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
306        switch (hash) {
307        case 94742588: /*claim*/ return this.claim == null ? new Base[0] : new Base[] {this.claim}; // Reference
308        case -261851592: /*relationship*/ return this.relationship == null ? new Base[0] : new Base[] {this.relationship}; // CodeableConcept
309        case -925155509: /*reference*/ return this.reference == null ? new Base[0] : new Base[] {this.reference}; // Identifier
310        default: return super.getProperty(hash, name, checkValid);
311        }
312
313      }
314
315      @Override
316      public Base setProperty(int hash, String name, Base value) throws FHIRException {
317        switch (hash) {
318        case 94742588: // claim
319          this.claim = TypeConvertor.castToReference(value); // Reference
320          return value;
321        case -261851592: // relationship
322          this.relationship = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
323          return value;
324        case -925155509: // reference
325          this.reference = TypeConvertor.castToIdentifier(value); // Identifier
326          return value;
327        default: return super.setProperty(hash, name, value);
328        }
329
330      }
331
332      @Override
333      public Base setProperty(String name, Base value) throws FHIRException {
334        if (name.equals("claim")) {
335          this.claim = TypeConvertor.castToReference(value); // Reference
336        } else if (name.equals("relationship")) {
337          this.relationship = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
338        } else if (name.equals("reference")) {
339          this.reference = TypeConvertor.castToIdentifier(value); // Identifier
340        } else
341          return super.setProperty(name, value);
342        return value;
343      }
344
345      @Override
346      public Base makeProperty(int hash, String name) throws FHIRException {
347        switch (hash) {
348        case 94742588:  return getClaim();
349        case -261851592:  return getRelationship();
350        case -925155509:  return getReference();
351        default: return super.makeProperty(hash, name);
352        }
353
354      }
355
356      @Override
357      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
358        switch (hash) {
359        case 94742588: /*claim*/ return new String[] {"Reference"};
360        case -261851592: /*relationship*/ return new String[] {"CodeableConcept"};
361        case -925155509: /*reference*/ return new String[] {"Identifier"};
362        default: return super.getTypesForProperty(hash, name);
363        }
364
365      }
366
367      @Override
368      public Base addChild(String name) throws FHIRException {
369        if (name.equals("claim")) {
370          this.claim = new Reference();
371          return this.claim;
372        }
373        else if (name.equals("relationship")) {
374          this.relationship = new CodeableConcept();
375          return this.relationship;
376        }
377        else if (name.equals("reference")) {
378          this.reference = new Identifier();
379          return this.reference;
380        }
381        else
382          return super.addChild(name);
383      }
384
385      public RelatedClaimComponent copy() {
386        RelatedClaimComponent dst = new RelatedClaimComponent();
387        copyValues(dst);
388        return dst;
389      }
390
391      public void copyValues(RelatedClaimComponent dst) {
392        super.copyValues(dst);
393        dst.claim = claim == null ? null : claim.copy();
394        dst.relationship = relationship == null ? null : relationship.copy();
395        dst.reference = reference == null ? null : reference.copy();
396      }
397
398      @Override
399      public boolean equalsDeep(Base other_) {
400        if (!super.equalsDeep(other_))
401          return false;
402        if (!(other_ instanceof RelatedClaimComponent))
403          return false;
404        RelatedClaimComponent o = (RelatedClaimComponent) other_;
405        return compareDeep(claim, o.claim, true) && compareDeep(relationship, o.relationship, true) && compareDeep(reference, o.reference, true)
406          ;
407      }
408
409      @Override
410      public boolean equalsShallow(Base other_) {
411        if (!super.equalsShallow(other_))
412          return false;
413        if (!(other_ instanceof RelatedClaimComponent))
414          return false;
415        RelatedClaimComponent o = (RelatedClaimComponent) other_;
416        return true;
417      }
418
419      public boolean isEmpty() {
420        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(claim, relationship, reference
421          );
422      }
423
424  public String fhirType() {
425    return "ExplanationOfBenefit.related";
426
427  }
428
429  }
430
431    @Block()
432    public static class PayeeComponent extends BackboneElement implements IBaseBackboneElement {
433        /**
434         * Type of Party to be reimbursed: Subscriber, provider, other.
435         */
436        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
437        @Description(shortDefinition="Category of recipient", formalDefinition="Type of Party to be reimbursed: Subscriber, provider, other." )
438        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/payeetype")
439        protected CodeableConcept type;
440
441        /**
442         * Reference to the individual or organization to whom any payment will be made.
443         */
444        @Child(name = "party", type = {Practitioner.class, PractitionerRole.class, Organization.class, Patient.class, RelatedPerson.class}, order=2, min=0, max=1, modifier=false, summary=false)
445        @Description(shortDefinition="Recipient reference", formalDefinition="Reference to the individual or organization to whom any payment will be made." )
446        protected Reference party;
447
448        private static final long serialVersionUID = -1948897146L;
449
450    /**
451     * Constructor
452     */
453      public PayeeComponent() {
454        super();
455      }
456
457        /**
458         * @return {@link #type} (Type of Party to be reimbursed: Subscriber, provider, other.)
459         */
460        public CodeableConcept getType() { 
461          if (this.type == null)
462            if (Configuration.errorOnAutoCreate())
463              throw new Error("Attempt to auto-create PayeeComponent.type");
464            else if (Configuration.doAutoCreate())
465              this.type = new CodeableConcept(); // cc
466          return this.type;
467        }
468
469        public boolean hasType() { 
470          return this.type != null && !this.type.isEmpty();
471        }
472
473        /**
474         * @param value {@link #type} (Type of Party to be reimbursed: Subscriber, provider, other.)
475         */
476        public PayeeComponent setType(CodeableConcept value) { 
477          this.type = value;
478          return this;
479        }
480
481        /**
482         * @return {@link #party} (Reference to the individual or organization to whom any payment will be made.)
483         */
484        public Reference getParty() { 
485          if (this.party == null)
486            if (Configuration.errorOnAutoCreate())
487              throw new Error("Attempt to auto-create PayeeComponent.party");
488            else if (Configuration.doAutoCreate())
489              this.party = new Reference(); // cc
490          return this.party;
491        }
492
493        public boolean hasParty() { 
494          return this.party != null && !this.party.isEmpty();
495        }
496
497        /**
498         * @param value {@link #party} (Reference to the individual or organization to whom any payment will be made.)
499         */
500        public PayeeComponent setParty(Reference value) { 
501          this.party = value;
502          return this;
503        }
504
505        protected void listChildren(List<Property> children) {
506          super.listChildren(children);
507          children.add(new Property("type", "CodeableConcept", "Type of Party to be reimbursed: Subscriber, provider, other.", 0, 1, type));
508          children.add(new Property("party", "Reference(Practitioner|PractitionerRole|Organization|Patient|RelatedPerson)", "Reference to the individual or organization to whom any payment will be made.", 0, 1, party));
509        }
510
511        @Override
512        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
513          switch (_hash) {
514          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "Type of Party to be reimbursed: Subscriber, provider, other.", 0, 1, type);
515          case 106437350: /*party*/  return new Property("party", "Reference(Practitioner|PractitionerRole|Organization|Patient|RelatedPerson)", "Reference to the individual or organization to whom any payment will be made.", 0, 1, party);
516          default: return super.getNamedProperty(_hash, _name, _checkValid);
517          }
518
519        }
520
521      @Override
522      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
523        switch (hash) {
524        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
525        case 106437350: /*party*/ return this.party == null ? new Base[0] : new Base[] {this.party}; // Reference
526        default: return super.getProperty(hash, name, checkValid);
527        }
528
529      }
530
531      @Override
532      public Base setProperty(int hash, String name, Base value) throws FHIRException {
533        switch (hash) {
534        case 3575610: // type
535          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
536          return value;
537        case 106437350: // party
538          this.party = TypeConvertor.castToReference(value); // Reference
539          return value;
540        default: return super.setProperty(hash, name, value);
541        }
542
543      }
544
545      @Override
546      public Base setProperty(String name, Base value) throws FHIRException {
547        if (name.equals("type")) {
548          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
549        } else if (name.equals("party")) {
550          this.party = TypeConvertor.castToReference(value); // Reference
551        } else
552          return super.setProperty(name, value);
553        return value;
554      }
555
556      @Override
557      public Base makeProperty(int hash, String name) throws FHIRException {
558        switch (hash) {
559        case 3575610:  return getType();
560        case 106437350:  return getParty();
561        default: return super.makeProperty(hash, name);
562        }
563
564      }
565
566      @Override
567      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
568        switch (hash) {
569        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
570        case 106437350: /*party*/ return new String[] {"Reference"};
571        default: return super.getTypesForProperty(hash, name);
572        }
573
574      }
575
576      @Override
577      public Base addChild(String name) throws FHIRException {
578        if (name.equals("type")) {
579          this.type = new CodeableConcept();
580          return this.type;
581        }
582        else if (name.equals("party")) {
583          this.party = new Reference();
584          return this.party;
585        }
586        else
587          return super.addChild(name);
588      }
589
590      public PayeeComponent copy() {
591        PayeeComponent dst = new PayeeComponent();
592        copyValues(dst);
593        return dst;
594      }
595
596      public void copyValues(PayeeComponent dst) {
597        super.copyValues(dst);
598        dst.type = type == null ? null : type.copy();
599        dst.party = party == null ? null : party.copy();
600      }
601
602      @Override
603      public boolean equalsDeep(Base other_) {
604        if (!super.equalsDeep(other_))
605          return false;
606        if (!(other_ instanceof PayeeComponent))
607          return false;
608        PayeeComponent o = (PayeeComponent) other_;
609        return compareDeep(type, o.type, true) && compareDeep(party, o.party, true);
610      }
611
612      @Override
613      public boolean equalsShallow(Base other_) {
614        if (!super.equalsShallow(other_))
615          return false;
616        if (!(other_ instanceof PayeeComponent))
617          return false;
618        PayeeComponent o = (PayeeComponent) other_;
619        return true;
620      }
621
622      public boolean isEmpty() {
623        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, party);
624      }
625
626  public String fhirType() {
627    return "ExplanationOfBenefit.payee";
628
629  }
630
631  }
632
633    @Block()
634    public static class CareTeamComponent extends BackboneElement implements IBaseBackboneElement {
635        /**
636         * A number to uniquely identify care team entries.
637         */
638        @Child(name = "sequence", type = {PositiveIntType.class}, order=1, min=1, max=1, modifier=false, summary=false)
639        @Description(shortDefinition="Order of care team", formalDefinition="A number to uniquely identify care team entries." )
640        protected PositiveIntType sequence;
641
642        /**
643         * Member of the team who provided the product or service.
644         */
645        @Child(name = "provider", type = {Practitioner.class, PractitionerRole.class, Organization.class}, order=2, min=1, max=1, modifier=false, summary=false)
646        @Description(shortDefinition="Practitioner or organization", formalDefinition="Member of the team who provided the product or service." )
647        protected Reference provider;
648
649        /**
650         * The party who is billing and/or responsible for the claimed products or services.
651         */
652        @Child(name = "responsible", type = {BooleanType.class}, order=3, min=0, max=1, modifier=false, summary=false)
653        @Description(shortDefinition="Indicator of the lead practitioner", formalDefinition="The party who is billing and/or responsible for the claimed products or services." )
654        protected BooleanType responsible;
655
656        /**
657         * The lead, assisting or supervising practitioner and their discipline if a multidisciplinary team.
658         */
659        @Child(name = "role", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=false)
660        @Description(shortDefinition="Function within the team", formalDefinition="The lead, assisting or supervising practitioner and their discipline if a multidisciplinary team." )
661        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/claim-careteamrole")
662        protected CodeableConcept role;
663
664        /**
665         * The qualification of the practitioner which is applicable for this service.
666         */
667        @Child(name = "qualification", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=false)
668        @Description(shortDefinition="Practitioner credential or specialization", formalDefinition="The qualification of the practitioner which is applicable for this service." )
669        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/provider-qualification")
670        protected CodeableConcept qualification;
671
672        private static final long serialVersionUID = 1479624238L;
673
674    /**
675     * Constructor
676     */
677      public CareTeamComponent() {
678        super();
679      }
680
681    /**
682     * Constructor
683     */
684      public CareTeamComponent(int sequence, Reference provider) {
685        super();
686        this.setSequence(sequence);
687        this.setProvider(provider);
688      }
689
690        /**
691         * @return {@link #sequence} (A number to uniquely identify care team entries.). This is the underlying object with id, value and extensions. The accessor "getSequence" gives direct access to the value
692         */
693        public PositiveIntType getSequenceElement() { 
694          if (this.sequence == null)
695            if (Configuration.errorOnAutoCreate())
696              throw new Error("Attempt to auto-create CareTeamComponent.sequence");
697            else if (Configuration.doAutoCreate())
698              this.sequence = new PositiveIntType(); // bb
699          return this.sequence;
700        }
701
702        public boolean hasSequenceElement() { 
703          return this.sequence != null && !this.sequence.isEmpty();
704        }
705
706        public boolean hasSequence() { 
707          return this.sequence != null && !this.sequence.isEmpty();
708        }
709
710        /**
711         * @param value {@link #sequence} (A number to uniquely identify care team entries.). This is the underlying object with id, value and extensions. The accessor "getSequence" gives direct access to the value
712         */
713        public CareTeamComponent setSequenceElement(PositiveIntType value) { 
714          this.sequence = value;
715          return this;
716        }
717
718        /**
719         * @return A number to uniquely identify care team entries.
720         */
721        public int getSequence() { 
722          return this.sequence == null || this.sequence.isEmpty() ? 0 : this.sequence.getValue();
723        }
724
725        /**
726         * @param value A number to uniquely identify care team entries.
727         */
728        public CareTeamComponent setSequence(int value) { 
729            if (this.sequence == null)
730              this.sequence = new PositiveIntType();
731            this.sequence.setValue(value);
732          return this;
733        }
734
735        /**
736         * @return {@link #provider} (Member of the team who provided the product or service.)
737         */
738        public Reference getProvider() { 
739          if (this.provider == null)
740            if (Configuration.errorOnAutoCreate())
741              throw new Error("Attempt to auto-create CareTeamComponent.provider");
742            else if (Configuration.doAutoCreate())
743              this.provider = new Reference(); // cc
744          return this.provider;
745        }
746
747        public boolean hasProvider() { 
748          return this.provider != null && !this.provider.isEmpty();
749        }
750
751        /**
752         * @param value {@link #provider} (Member of the team who provided the product or service.)
753         */
754        public CareTeamComponent setProvider(Reference value) { 
755          this.provider = value;
756          return this;
757        }
758
759        /**
760         * @return {@link #responsible} (The party who is billing and/or responsible for the claimed products or services.). This is the underlying object with id, value and extensions. The accessor "getResponsible" gives direct access to the value
761         */
762        public BooleanType getResponsibleElement() { 
763          if (this.responsible == null)
764            if (Configuration.errorOnAutoCreate())
765              throw new Error("Attempt to auto-create CareTeamComponent.responsible");
766            else if (Configuration.doAutoCreate())
767              this.responsible = new BooleanType(); // bb
768          return this.responsible;
769        }
770
771        public boolean hasResponsibleElement() { 
772          return this.responsible != null && !this.responsible.isEmpty();
773        }
774
775        public boolean hasResponsible() { 
776          return this.responsible != null && !this.responsible.isEmpty();
777        }
778
779        /**
780         * @param value {@link #responsible} (The party who is billing and/or responsible for the claimed products or services.). This is the underlying object with id, value and extensions. The accessor "getResponsible" gives direct access to the value
781         */
782        public CareTeamComponent setResponsibleElement(BooleanType value) { 
783          this.responsible = value;
784          return this;
785        }
786
787        /**
788         * @return The party who is billing and/or responsible for the claimed products or services.
789         */
790        public boolean getResponsible() { 
791          return this.responsible == null || this.responsible.isEmpty() ? false : this.responsible.getValue();
792        }
793
794        /**
795         * @param value The party who is billing and/or responsible for the claimed products or services.
796         */
797        public CareTeamComponent setResponsible(boolean value) { 
798            if (this.responsible == null)
799              this.responsible = new BooleanType();
800            this.responsible.setValue(value);
801          return this;
802        }
803
804        /**
805         * @return {@link #role} (The lead, assisting or supervising practitioner and their discipline if a multidisciplinary team.)
806         */
807        public CodeableConcept getRole() { 
808          if (this.role == null)
809            if (Configuration.errorOnAutoCreate())
810              throw new Error("Attempt to auto-create CareTeamComponent.role");
811            else if (Configuration.doAutoCreate())
812              this.role = new CodeableConcept(); // cc
813          return this.role;
814        }
815
816        public boolean hasRole() { 
817          return this.role != null && !this.role.isEmpty();
818        }
819
820        /**
821         * @param value {@link #role} (The lead, assisting or supervising practitioner and their discipline if a multidisciplinary team.)
822         */
823        public CareTeamComponent setRole(CodeableConcept value) { 
824          this.role = value;
825          return this;
826        }
827
828        /**
829         * @return {@link #qualification} (The qualification of the practitioner which is applicable for this service.)
830         */
831        public CodeableConcept getQualification() { 
832          if (this.qualification == null)
833            if (Configuration.errorOnAutoCreate())
834              throw new Error("Attempt to auto-create CareTeamComponent.qualification");
835            else if (Configuration.doAutoCreate())
836              this.qualification = new CodeableConcept(); // cc
837          return this.qualification;
838        }
839
840        public boolean hasQualification() { 
841          return this.qualification != null && !this.qualification.isEmpty();
842        }
843
844        /**
845         * @param value {@link #qualification} (The qualification of the practitioner which is applicable for this service.)
846         */
847        public CareTeamComponent setQualification(CodeableConcept value) { 
848          this.qualification = value;
849          return this;
850        }
851
852        protected void listChildren(List<Property> children) {
853          super.listChildren(children);
854          children.add(new Property("sequence", "positiveInt", "A number to uniquely identify care team entries.", 0, 1, sequence));
855          children.add(new Property("provider", "Reference(Practitioner|PractitionerRole|Organization)", "Member of the team who provided the product or service.", 0, 1, provider));
856          children.add(new Property("responsible", "boolean", "The party who is billing and/or responsible for the claimed products or services.", 0, 1, responsible));
857          children.add(new Property("role", "CodeableConcept", "The lead, assisting or supervising practitioner and their discipline if a multidisciplinary team.", 0, 1, role));
858          children.add(new Property("qualification", "CodeableConcept", "The qualification of the practitioner which is applicable for this service.", 0, 1, qualification));
859        }
860
861        @Override
862        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
863          switch (_hash) {
864          case 1349547969: /*sequence*/  return new Property("sequence", "positiveInt", "A number to uniquely identify care team entries.", 0, 1, sequence);
865          case -987494927: /*provider*/  return new Property("provider", "Reference(Practitioner|PractitionerRole|Organization)", "Member of the team who provided the product or service.", 0, 1, provider);
866          case 1847674614: /*responsible*/  return new Property("responsible", "boolean", "The party who is billing and/or responsible for the claimed products or services.", 0, 1, responsible);
867          case 3506294: /*role*/  return new Property("role", "CodeableConcept", "The lead, assisting or supervising practitioner and their discipline if a multidisciplinary team.", 0, 1, role);
868          case -631333393: /*qualification*/  return new Property("qualification", "CodeableConcept", "The qualification of the practitioner which is applicable for this service.", 0, 1, qualification);
869          default: return super.getNamedProperty(_hash, _name, _checkValid);
870          }
871
872        }
873
874      @Override
875      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
876        switch (hash) {
877        case 1349547969: /*sequence*/ return this.sequence == null ? new Base[0] : new Base[] {this.sequence}; // PositiveIntType
878        case -987494927: /*provider*/ return this.provider == null ? new Base[0] : new Base[] {this.provider}; // Reference
879        case 1847674614: /*responsible*/ return this.responsible == null ? new Base[0] : new Base[] {this.responsible}; // BooleanType
880        case 3506294: /*role*/ return this.role == null ? new Base[0] : new Base[] {this.role}; // CodeableConcept
881        case -631333393: /*qualification*/ return this.qualification == null ? new Base[0] : new Base[] {this.qualification}; // CodeableConcept
882        default: return super.getProperty(hash, name, checkValid);
883        }
884
885      }
886
887      @Override
888      public Base setProperty(int hash, String name, Base value) throws FHIRException {
889        switch (hash) {
890        case 1349547969: // sequence
891          this.sequence = TypeConvertor.castToPositiveInt(value); // PositiveIntType
892          return value;
893        case -987494927: // provider
894          this.provider = TypeConvertor.castToReference(value); // Reference
895          return value;
896        case 1847674614: // responsible
897          this.responsible = TypeConvertor.castToBoolean(value); // BooleanType
898          return value;
899        case 3506294: // role
900          this.role = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
901          return value;
902        case -631333393: // qualification
903          this.qualification = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
904          return value;
905        default: return super.setProperty(hash, name, value);
906        }
907
908      }
909
910      @Override
911      public Base setProperty(String name, Base value) throws FHIRException {
912        if (name.equals("sequence")) {
913          this.sequence = TypeConvertor.castToPositiveInt(value); // PositiveIntType
914        } else if (name.equals("provider")) {
915          this.provider = TypeConvertor.castToReference(value); // Reference
916        } else if (name.equals("responsible")) {
917          this.responsible = TypeConvertor.castToBoolean(value); // BooleanType
918        } else if (name.equals("role")) {
919          this.role = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
920        } else if (name.equals("qualification")) {
921          this.qualification = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
922        } else
923          return super.setProperty(name, value);
924        return value;
925      }
926
927      @Override
928      public Base makeProperty(int hash, String name) throws FHIRException {
929        switch (hash) {
930        case 1349547969:  return getSequenceElement();
931        case -987494927:  return getProvider();
932        case 1847674614:  return getResponsibleElement();
933        case 3506294:  return getRole();
934        case -631333393:  return getQualification();
935        default: return super.makeProperty(hash, name);
936        }
937
938      }
939
940      @Override
941      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
942        switch (hash) {
943        case 1349547969: /*sequence*/ return new String[] {"positiveInt"};
944        case -987494927: /*provider*/ return new String[] {"Reference"};
945        case 1847674614: /*responsible*/ return new String[] {"boolean"};
946        case 3506294: /*role*/ return new String[] {"CodeableConcept"};
947        case -631333393: /*qualification*/ return new String[] {"CodeableConcept"};
948        default: return super.getTypesForProperty(hash, name);
949        }
950
951      }
952
953      @Override
954      public Base addChild(String name) throws FHIRException {
955        if (name.equals("sequence")) {
956          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.careTeam.sequence");
957        }
958        else if (name.equals("provider")) {
959          this.provider = new Reference();
960          return this.provider;
961        }
962        else if (name.equals("responsible")) {
963          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.careTeam.responsible");
964        }
965        else if (name.equals("role")) {
966          this.role = new CodeableConcept();
967          return this.role;
968        }
969        else if (name.equals("qualification")) {
970          this.qualification = new CodeableConcept();
971          return this.qualification;
972        }
973        else
974          return super.addChild(name);
975      }
976
977      public CareTeamComponent copy() {
978        CareTeamComponent dst = new CareTeamComponent();
979        copyValues(dst);
980        return dst;
981      }
982
983      public void copyValues(CareTeamComponent dst) {
984        super.copyValues(dst);
985        dst.sequence = sequence == null ? null : sequence.copy();
986        dst.provider = provider == null ? null : provider.copy();
987        dst.responsible = responsible == null ? null : responsible.copy();
988        dst.role = role == null ? null : role.copy();
989        dst.qualification = qualification == null ? null : qualification.copy();
990      }
991
992      @Override
993      public boolean equalsDeep(Base other_) {
994        if (!super.equalsDeep(other_))
995          return false;
996        if (!(other_ instanceof CareTeamComponent))
997          return false;
998        CareTeamComponent o = (CareTeamComponent) other_;
999        return compareDeep(sequence, o.sequence, true) && compareDeep(provider, o.provider, true) && compareDeep(responsible, o.responsible, true)
1000           && compareDeep(role, o.role, true) && compareDeep(qualification, o.qualification, true);
1001      }
1002
1003      @Override
1004      public boolean equalsShallow(Base other_) {
1005        if (!super.equalsShallow(other_))
1006          return false;
1007        if (!(other_ instanceof CareTeamComponent))
1008          return false;
1009        CareTeamComponent o = (CareTeamComponent) other_;
1010        return compareValues(sequence, o.sequence, true) && compareValues(responsible, o.responsible, true)
1011          ;
1012      }
1013
1014      public boolean isEmpty() {
1015        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(sequence, provider, responsible
1016          , role, qualification);
1017      }
1018
1019  public String fhirType() {
1020    return "ExplanationOfBenefit.careTeam";
1021
1022  }
1023
1024  }
1025
1026    @Block()
1027    public static class SupportingInformationComponent extends BackboneElement implements IBaseBackboneElement {
1028        /**
1029         * A number to uniquely identify supporting information entries.
1030         */
1031        @Child(name = "sequence", type = {PositiveIntType.class}, order=1, min=1, max=1, modifier=false, summary=false)
1032        @Description(shortDefinition="Information instance identifier", formalDefinition="A number to uniquely identify supporting information entries." )
1033        protected PositiveIntType sequence;
1034
1035        /**
1036         * The general class of the information supplied: information; exception; accident, employment; onset, etc.
1037         */
1038        @Child(name = "category", type = {CodeableConcept.class}, order=2, min=1, max=1, modifier=false, summary=false)
1039        @Description(shortDefinition="Classification of the supplied information", formalDefinition="The general class of the information supplied: information; exception; accident, employment; onset, etc." )
1040        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/claim-informationcategory")
1041        protected CodeableConcept category;
1042
1043        /**
1044         * System and code pertaining to the specific information regarding special conditions relating to the setting, treatment or patient  for which care is sought.
1045         */
1046        @Child(name = "code", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=false)
1047        @Description(shortDefinition="Type of information", formalDefinition="System and code pertaining to the specific information regarding special conditions relating to the setting, treatment or patient  for which care is sought." )
1048        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/claim-exception")
1049        protected CodeableConcept code;
1050
1051        /**
1052         * The date when or period to which this information refers.
1053         */
1054        @Child(name = "timing", type = {DateType.class, Period.class}, order=4, min=0, max=1, modifier=false, summary=false)
1055        @Description(shortDefinition="When it occurred", formalDefinition="The date when or period to which this information refers." )
1056        protected DataType timing;
1057
1058        /**
1059         * Additional data or information such as resources, documents, images etc. including references to the data or the actual inclusion of the data.
1060         */
1061        @Child(name = "value", type = {BooleanType.class, StringType.class, Quantity.class, Attachment.class, Reference.class}, order=5, min=0, max=1, modifier=false, summary=false)
1062        @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." )
1063        protected DataType value;
1064
1065        /**
1066         * Provides the reason in the situation where a reason code is required in addition to the content.
1067         */
1068        @Child(name = "reason", type = {Coding.class}, order=6, min=0, max=1, modifier=false, summary=false)
1069        @Description(shortDefinition="Explanation for the information", formalDefinition="Provides the reason in the situation where a reason code is required in addition to the content." )
1070        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/missing-tooth-reason")
1071        protected Coding reason;
1072
1073        private static final long serialVersionUID = 1577205655L;
1074
1075    /**
1076     * Constructor
1077     */
1078      public SupportingInformationComponent() {
1079        super();
1080      }
1081
1082    /**
1083     * Constructor
1084     */
1085      public SupportingInformationComponent(int sequence, CodeableConcept category) {
1086        super();
1087        this.setSequence(sequence);
1088        this.setCategory(category);
1089      }
1090
1091        /**
1092         * @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
1093         */
1094        public PositiveIntType getSequenceElement() { 
1095          if (this.sequence == null)
1096            if (Configuration.errorOnAutoCreate())
1097              throw new Error("Attempt to auto-create SupportingInformationComponent.sequence");
1098            else if (Configuration.doAutoCreate())
1099              this.sequence = new PositiveIntType(); // bb
1100          return this.sequence;
1101        }
1102
1103        public boolean hasSequenceElement() { 
1104          return this.sequence != null && !this.sequence.isEmpty();
1105        }
1106
1107        public boolean hasSequence() { 
1108          return this.sequence != null && !this.sequence.isEmpty();
1109        }
1110
1111        /**
1112         * @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
1113         */
1114        public SupportingInformationComponent setSequenceElement(PositiveIntType value) { 
1115          this.sequence = value;
1116          return this;
1117        }
1118
1119        /**
1120         * @return A number to uniquely identify supporting information entries.
1121         */
1122        public int getSequence() { 
1123          return this.sequence == null || this.sequence.isEmpty() ? 0 : this.sequence.getValue();
1124        }
1125
1126        /**
1127         * @param value A number to uniquely identify supporting information entries.
1128         */
1129        public SupportingInformationComponent setSequence(int value) { 
1130            if (this.sequence == null)
1131              this.sequence = new PositiveIntType();
1132            this.sequence.setValue(value);
1133          return this;
1134        }
1135
1136        /**
1137         * @return {@link #category} (The general class of the information supplied: information; exception; accident, employment; onset, etc.)
1138         */
1139        public CodeableConcept getCategory() { 
1140          if (this.category == null)
1141            if (Configuration.errorOnAutoCreate())
1142              throw new Error("Attempt to auto-create SupportingInformationComponent.category");
1143            else if (Configuration.doAutoCreate())
1144              this.category = new CodeableConcept(); // cc
1145          return this.category;
1146        }
1147
1148        public boolean hasCategory() { 
1149          return this.category != null && !this.category.isEmpty();
1150        }
1151
1152        /**
1153         * @param value {@link #category} (The general class of the information supplied: information; exception; accident, employment; onset, etc.)
1154         */
1155        public SupportingInformationComponent setCategory(CodeableConcept value) { 
1156          this.category = value;
1157          return this;
1158        }
1159
1160        /**
1161         * @return {@link #code} (System and code pertaining to the specific information regarding special conditions relating to the setting, treatment or patient  for which care is sought.)
1162         */
1163        public CodeableConcept getCode() { 
1164          if (this.code == null)
1165            if (Configuration.errorOnAutoCreate())
1166              throw new Error("Attempt to auto-create SupportingInformationComponent.code");
1167            else if (Configuration.doAutoCreate())
1168              this.code = new CodeableConcept(); // cc
1169          return this.code;
1170        }
1171
1172        public boolean hasCode() { 
1173          return this.code != null && !this.code.isEmpty();
1174        }
1175
1176        /**
1177         * @param value {@link #code} (System and code pertaining to the specific information regarding special conditions relating to the setting, treatment or patient  for which care is sought.)
1178         */
1179        public SupportingInformationComponent setCode(CodeableConcept value) { 
1180          this.code = value;
1181          return this;
1182        }
1183
1184        /**
1185         * @return {@link #timing} (The date when or period to which this information refers.)
1186         */
1187        public DataType getTiming() { 
1188          return this.timing;
1189        }
1190
1191        /**
1192         * @return {@link #timing} (The date when or period to which this information refers.)
1193         */
1194        public DateType getTimingDateType() throws FHIRException { 
1195          if (this.timing == null)
1196            this.timing = new DateType();
1197          if (!(this.timing instanceof DateType))
1198            throw new FHIRException("Type mismatch: the type DateType was expected, but "+this.timing.getClass().getName()+" was encountered");
1199          return (DateType) this.timing;
1200        }
1201
1202        public boolean hasTimingDateType() { 
1203          return this != null && this.timing instanceof DateType;
1204        }
1205
1206        /**
1207         * @return {@link #timing} (The date when or period to which this information refers.)
1208         */
1209        public Period getTimingPeriod() throws FHIRException { 
1210          if (this.timing == null)
1211            this.timing = new Period();
1212          if (!(this.timing instanceof Period))
1213            throw new FHIRException("Type mismatch: the type Period was expected, but "+this.timing.getClass().getName()+" was encountered");
1214          return (Period) this.timing;
1215        }
1216
1217        public boolean hasTimingPeriod() { 
1218          return this != null && this.timing instanceof Period;
1219        }
1220
1221        public boolean hasTiming() { 
1222          return this.timing != null && !this.timing.isEmpty();
1223        }
1224
1225        /**
1226         * @param value {@link #timing} (The date when or period to which this information refers.)
1227         */
1228        public SupportingInformationComponent setTiming(DataType value) { 
1229          if (value != null && !(value instanceof DateType || value instanceof Period))
1230            throw new Error("Not the right type for ExplanationOfBenefit.supportingInfo.timing[x]: "+value.fhirType());
1231          this.timing = value;
1232          return this;
1233        }
1234
1235        /**
1236         * @return {@link #value} (Additional data or information such as resources, documents, images etc. including references to the data or the actual inclusion of the data.)
1237         */
1238        public DataType getValue() { 
1239          return this.value;
1240        }
1241
1242        /**
1243         * @return {@link #value} (Additional data or information such as resources, documents, images etc. including references to the data or the actual inclusion of the data.)
1244         */
1245        public BooleanType getValueBooleanType() throws FHIRException { 
1246          if (this.value == null)
1247            this.value = new BooleanType();
1248          if (!(this.value instanceof BooleanType))
1249            throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.value.getClass().getName()+" was encountered");
1250          return (BooleanType) this.value;
1251        }
1252
1253        public boolean hasValueBooleanType() { 
1254          return this != null && this.value instanceof BooleanType;
1255        }
1256
1257        /**
1258         * @return {@link #value} (Additional data or information such as resources, documents, images etc. including references to the data or the actual inclusion of the data.)
1259         */
1260        public StringType getValueStringType() throws FHIRException { 
1261          if (this.value == null)
1262            this.value = new StringType();
1263          if (!(this.value instanceof StringType))
1264            throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.value.getClass().getName()+" was encountered");
1265          return (StringType) this.value;
1266        }
1267
1268        public boolean hasValueStringType() { 
1269          return this != null && this.value instanceof StringType;
1270        }
1271
1272        /**
1273         * @return {@link #value} (Additional data or information such as resources, documents, images etc. including references to the data or the actual inclusion of the data.)
1274         */
1275        public Quantity getValueQuantity() throws FHIRException { 
1276          if (this.value == null)
1277            this.value = new Quantity();
1278          if (!(this.value instanceof Quantity))
1279            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.value.getClass().getName()+" was encountered");
1280          return (Quantity) this.value;
1281        }
1282
1283        public boolean hasValueQuantity() { 
1284          return this != null && this.value instanceof Quantity;
1285        }
1286
1287        /**
1288         * @return {@link #value} (Additional data or information such as resources, documents, images etc. including references to the data or the actual inclusion of the data.)
1289         */
1290        public Attachment getValueAttachment() throws FHIRException { 
1291          if (this.value == null)
1292            this.value = new Attachment();
1293          if (!(this.value instanceof Attachment))
1294            throw new FHIRException("Type mismatch: the type Attachment was expected, but "+this.value.getClass().getName()+" was encountered");
1295          return (Attachment) this.value;
1296        }
1297
1298        public boolean hasValueAttachment() { 
1299          return this != null && this.value instanceof Attachment;
1300        }
1301
1302        /**
1303         * @return {@link #value} (Additional data or information such as resources, documents, images etc. including references to the data or the actual inclusion of the data.)
1304         */
1305        public Reference getValueReference() throws FHIRException { 
1306          if (this.value == null)
1307            this.value = new Reference();
1308          if (!(this.value instanceof Reference))
1309            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.value.getClass().getName()+" was encountered");
1310          return (Reference) this.value;
1311        }
1312
1313        public boolean hasValueReference() { 
1314          return this != null && this.value instanceof Reference;
1315        }
1316
1317        public boolean hasValue() { 
1318          return this.value != null && !this.value.isEmpty();
1319        }
1320
1321        /**
1322         * @param value {@link #value} (Additional data or information such as resources, documents, images etc. including references to the data or the actual inclusion of the data.)
1323         */
1324        public SupportingInformationComponent setValue(DataType value) { 
1325          if (value != null && !(value instanceof BooleanType || value instanceof StringType || value instanceof Quantity || value instanceof Attachment || value instanceof Reference))
1326            throw new Error("Not the right type for ExplanationOfBenefit.supportingInfo.value[x]: "+value.fhirType());
1327          this.value = value;
1328          return this;
1329        }
1330
1331        /**
1332         * @return {@link #reason} (Provides the reason in the situation where a reason code is required in addition to the content.)
1333         */
1334        public Coding getReason() { 
1335          if (this.reason == null)
1336            if (Configuration.errorOnAutoCreate())
1337              throw new Error("Attempt to auto-create SupportingInformationComponent.reason");
1338            else if (Configuration.doAutoCreate())
1339              this.reason = new Coding(); // cc
1340          return this.reason;
1341        }
1342
1343        public boolean hasReason() { 
1344          return this.reason != null && !this.reason.isEmpty();
1345        }
1346
1347        /**
1348         * @param value {@link #reason} (Provides the reason in the situation where a reason code is required in addition to the content.)
1349         */
1350        public SupportingInformationComponent setReason(Coding value) { 
1351          this.reason = value;
1352          return this;
1353        }
1354
1355        protected void listChildren(List<Property> children) {
1356          super.listChildren(children);
1357          children.add(new Property("sequence", "positiveInt", "A number to uniquely identify supporting information entries.", 0, 1, sequence));
1358          children.add(new Property("category", "CodeableConcept", "The general class of the information supplied: information; exception; accident, employment; onset, etc.", 0, 1, category));
1359          children.add(new Property("code", "CodeableConcept", "System and code pertaining to the specific information regarding special conditions relating to the setting, treatment or patient  for which care is sought.", 0, 1, code));
1360          children.add(new Property("timing[x]", "date|Period", "The date when or period to which this information refers.", 0, 1, timing));
1361          children.add(new Property("value[x]", "boolean|string|Quantity|Attachment|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, value));
1362          children.add(new Property("reason", "Coding", "Provides the reason in the situation where a reason code is required in addition to the content.", 0, 1, reason));
1363        }
1364
1365        @Override
1366        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1367          switch (_hash) {
1368          case 1349547969: /*sequence*/  return new Property("sequence", "positiveInt", "A number to uniquely identify supporting information entries.", 0, 1, sequence);
1369          case 50511102: /*category*/  return new Property("category", "CodeableConcept", "The general class of the information supplied: information; exception; accident, employment; onset, etc.", 0, 1, category);
1370          case 3059181: /*code*/  return new Property("code", "CodeableConcept", "System and code pertaining to the specific information regarding special conditions relating to the setting, treatment or patient  for which care is sought.", 0, 1, code);
1371          case 164632566: /*timing[x]*/  return new Property("timing[x]", "date|Period", "The date when or period to which this information refers.", 0, 1, timing);
1372          case -873664438: /*timing*/  return new Property("timing[x]", "date|Period", "The date when or period to which this information refers.", 0, 1, timing);
1373          case 807935768: /*timingDate*/  return new Property("timing[x]", "date", "The date when or period to which this information refers.", 0, 1, timing);
1374          case -615615829: /*timingPeriod*/  return new Property("timing[x]", "Period", "The date when or period to which this information refers.", 0, 1, timing);
1375          case -1410166417: /*value[x]*/  return new Property("value[x]", "boolean|string|Quantity|Attachment|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, value);
1376          case 111972721: /*value*/  return new Property("value[x]", "boolean|string|Quantity|Attachment|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, value);
1377          case 733421943: /*valueBoolean*/  return new Property("value[x]", "boolean", "Additional data or information such as resources, documents, images etc. including references to the data or the actual inclusion of the data.", 0, 1, value);
1378          case -1424603934: /*valueString*/  return new Property("value[x]", "string", "Additional data or information such as resources, documents, images etc. including references to the data or the actual inclusion of the data.", 0, 1, value);
1379          case -2029823716: /*valueQuantity*/  return new Property("value[x]", "Quantity", "Additional data or information such as resources, documents, images etc. including references to the data or the actual inclusion of the data.", 0, 1, value);
1380          case -475566732: /*valueAttachment*/  return new Property("value[x]", "Attachment", "Additional data or information such as resources, documents, images etc. including references to the data or the actual inclusion of the data.", 0, 1, value);
1381          case 1755241690: /*valueReference*/  return new Property("value[x]", "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, value);
1382          case -934964668: /*reason*/  return new Property("reason", "Coding", "Provides the reason in the situation where a reason code is required in addition to the content.", 0, 1, reason);
1383          default: return super.getNamedProperty(_hash, _name, _checkValid);
1384          }
1385
1386        }
1387
1388      @Override
1389      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1390        switch (hash) {
1391        case 1349547969: /*sequence*/ return this.sequence == null ? new Base[0] : new Base[] {this.sequence}; // PositiveIntType
1392        case 50511102: /*category*/ return this.category == null ? new Base[0] : new Base[] {this.category}; // CodeableConcept
1393        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
1394        case -873664438: /*timing*/ return this.timing == null ? new Base[0] : new Base[] {this.timing}; // DataType
1395        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // DataType
1396        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : new Base[] {this.reason}; // Coding
1397        default: return super.getProperty(hash, name, checkValid);
1398        }
1399
1400      }
1401
1402      @Override
1403      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1404        switch (hash) {
1405        case 1349547969: // sequence
1406          this.sequence = TypeConvertor.castToPositiveInt(value); // PositiveIntType
1407          return value;
1408        case 50511102: // category
1409          this.category = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1410          return value;
1411        case 3059181: // code
1412          this.code = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1413          return value;
1414        case -873664438: // timing
1415          this.timing = TypeConvertor.castToType(value); // DataType
1416          return value;
1417        case 111972721: // value
1418          this.value = TypeConvertor.castToType(value); // DataType
1419          return value;
1420        case -934964668: // reason
1421          this.reason = TypeConvertor.castToCoding(value); // Coding
1422          return value;
1423        default: return super.setProperty(hash, name, value);
1424        }
1425
1426      }
1427
1428      @Override
1429      public Base setProperty(String name, Base value) throws FHIRException {
1430        if (name.equals("sequence")) {
1431          this.sequence = TypeConvertor.castToPositiveInt(value); // PositiveIntType
1432        } else if (name.equals("category")) {
1433          this.category = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1434        } else if (name.equals("code")) {
1435          this.code = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1436        } else if (name.equals("timing[x]")) {
1437          this.timing = TypeConvertor.castToType(value); // DataType
1438        } else if (name.equals("value[x]")) {
1439          this.value = TypeConvertor.castToType(value); // DataType
1440        } else if (name.equals("reason")) {
1441          this.reason = TypeConvertor.castToCoding(value); // Coding
1442        } else
1443          return super.setProperty(name, value);
1444        return value;
1445      }
1446
1447      @Override
1448      public Base makeProperty(int hash, String name) throws FHIRException {
1449        switch (hash) {
1450        case 1349547969:  return getSequenceElement();
1451        case 50511102:  return getCategory();
1452        case 3059181:  return getCode();
1453        case 164632566:  return getTiming();
1454        case -873664438:  return getTiming();
1455        case -1410166417:  return getValue();
1456        case 111972721:  return getValue();
1457        case -934964668:  return getReason();
1458        default: return super.makeProperty(hash, name);
1459        }
1460
1461      }
1462
1463      @Override
1464      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1465        switch (hash) {
1466        case 1349547969: /*sequence*/ return new String[] {"positiveInt"};
1467        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
1468        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
1469        case -873664438: /*timing*/ return new String[] {"date", "Period"};
1470        case 111972721: /*value*/ return new String[] {"boolean", "string", "Quantity", "Attachment", "Reference"};
1471        case -934964668: /*reason*/ return new String[] {"Coding"};
1472        default: return super.getTypesForProperty(hash, name);
1473        }
1474
1475      }
1476
1477      @Override
1478      public Base addChild(String name) throws FHIRException {
1479        if (name.equals("sequence")) {
1480          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.supportingInfo.sequence");
1481        }
1482        else if (name.equals("category")) {
1483          this.category = new CodeableConcept();
1484          return this.category;
1485        }
1486        else if (name.equals("code")) {
1487          this.code = new CodeableConcept();
1488          return this.code;
1489        }
1490        else if (name.equals("timingDate")) {
1491          this.timing = new DateType();
1492          return this.timing;
1493        }
1494        else if (name.equals("timingPeriod")) {
1495          this.timing = new Period();
1496          return this.timing;
1497        }
1498        else if (name.equals("valueBoolean")) {
1499          this.value = new BooleanType();
1500          return this.value;
1501        }
1502        else if (name.equals("valueString")) {
1503          this.value = new StringType();
1504          return this.value;
1505        }
1506        else if (name.equals("valueQuantity")) {
1507          this.value = new Quantity();
1508          return this.value;
1509        }
1510        else if (name.equals("valueAttachment")) {
1511          this.value = new Attachment();
1512          return this.value;
1513        }
1514        else if (name.equals("valueReference")) {
1515          this.value = new Reference();
1516          return this.value;
1517        }
1518        else if (name.equals("reason")) {
1519          this.reason = new Coding();
1520          return this.reason;
1521        }
1522        else
1523          return super.addChild(name);
1524      }
1525
1526      public SupportingInformationComponent copy() {
1527        SupportingInformationComponent dst = new SupportingInformationComponent();
1528        copyValues(dst);
1529        return dst;
1530      }
1531
1532      public void copyValues(SupportingInformationComponent dst) {
1533        super.copyValues(dst);
1534        dst.sequence = sequence == null ? null : sequence.copy();
1535        dst.category = category == null ? null : category.copy();
1536        dst.code = code == null ? null : code.copy();
1537        dst.timing = timing == null ? null : timing.copy();
1538        dst.value = value == null ? null : value.copy();
1539        dst.reason = reason == null ? null : reason.copy();
1540      }
1541
1542      @Override
1543      public boolean equalsDeep(Base other_) {
1544        if (!super.equalsDeep(other_))
1545          return false;
1546        if (!(other_ instanceof SupportingInformationComponent))
1547          return false;
1548        SupportingInformationComponent o = (SupportingInformationComponent) other_;
1549        return compareDeep(sequence, o.sequence, true) && compareDeep(category, o.category, true) && compareDeep(code, o.code, true)
1550           && compareDeep(timing, o.timing, true) && compareDeep(value, o.value, true) && compareDeep(reason, o.reason, true)
1551          ;
1552      }
1553
1554      @Override
1555      public boolean equalsShallow(Base other_) {
1556        if (!super.equalsShallow(other_))
1557          return false;
1558        if (!(other_ instanceof SupportingInformationComponent))
1559          return false;
1560        SupportingInformationComponent o = (SupportingInformationComponent) other_;
1561        return compareValues(sequence, o.sequence, true);
1562      }
1563
1564      public boolean isEmpty() {
1565        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(sequence, category, code
1566          , timing, value, reason);
1567      }
1568
1569  public String fhirType() {
1570    return "ExplanationOfBenefit.supportingInfo";
1571
1572  }
1573
1574  }
1575
1576    @Block()
1577    public static class DiagnosisComponent extends BackboneElement implements IBaseBackboneElement {
1578        /**
1579         * A number to uniquely identify diagnosis entries.
1580         */
1581        @Child(name = "sequence", type = {PositiveIntType.class}, order=1, min=1, max=1, modifier=false, summary=false)
1582        @Description(shortDefinition="Diagnosis instance identifier", formalDefinition="A number to uniquely identify diagnosis entries." )
1583        protected PositiveIntType sequence;
1584
1585        /**
1586         * The nature of illness or problem in a coded form or as a reference to an external defined Condition.
1587         */
1588        @Child(name = "diagnosis", type = {CodeableConcept.class, Condition.class}, order=2, min=1, max=1, modifier=false, summary=false)
1589        @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." )
1590        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/icd-10")
1591        protected DataType diagnosis;
1592
1593        /**
1594         * When the condition was observed or the relative ranking.
1595         */
1596        @Child(name = "type", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1597        @Description(shortDefinition="Timing or nature of the diagnosis", formalDefinition="When the condition was observed or the relative ranking." )
1598        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/ex-diagnosistype")
1599        protected List<CodeableConcept> type;
1600
1601        /**
1602         * Indication of whether the diagnosis was present on admission to a facility.
1603         */
1604        @Child(name = "onAdmission", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=false)
1605        @Description(shortDefinition="Present on admission", formalDefinition="Indication of whether the diagnosis was present on admission to a facility." )
1606        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/ex-diagnosis-on-admission")
1607        protected CodeableConcept onAdmission;
1608
1609        /**
1610         * A package billing code or bundle code used to group products and services to a particular health condition (such as heart attack) which is based on a predetermined grouping code system.
1611         */
1612        @Child(name = "packageCode", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=false)
1613        @Description(shortDefinition="Package billing code", formalDefinition="A package billing code or bundle code used to group products and services to a particular health condition (such as heart attack) which is based on a predetermined grouping code system." )
1614        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/ex-diagnosisrelatedgroup")
1615        protected CodeableConcept packageCode;
1616
1617        private static final long serialVersionUID = 550515328L;
1618
1619    /**
1620     * Constructor
1621     */
1622      public DiagnosisComponent() {
1623        super();
1624      }
1625
1626    /**
1627     * Constructor
1628     */
1629      public DiagnosisComponent(int sequence, DataType diagnosis) {
1630        super();
1631        this.setSequence(sequence);
1632        this.setDiagnosis(diagnosis);
1633      }
1634
1635        /**
1636         * @return {@link #sequence} (A number to uniquely identify diagnosis entries.). This is the underlying object with id, value and extensions. The accessor "getSequence" gives direct access to the value
1637         */
1638        public PositiveIntType getSequenceElement() { 
1639          if (this.sequence == null)
1640            if (Configuration.errorOnAutoCreate())
1641              throw new Error("Attempt to auto-create DiagnosisComponent.sequence");
1642            else if (Configuration.doAutoCreate())
1643              this.sequence = new PositiveIntType(); // bb
1644          return this.sequence;
1645        }
1646
1647        public boolean hasSequenceElement() { 
1648          return this.sequence != null && !this.sequence.isEmpty();
1649        }
1650
1651        public boolean hasSequence() { 
1652          return this.sequence != null && !this.sequence.isEmpty();
1653        }
1654
1655        /**
1656         * @param value {@link #sequence} (A number to uniquely identify diagnosis entries.). This is the underlying object with id, value and extensions. The accessor "getSequence" gives direct access to the value
1657         */
1658        public DiagnosisComponent setSequenceElement(PositiveIntType value) { 
1659          this.sequence = value;
1660          return this;
1661        }
1662
1663        /**
1664         * @return A number to uniquely identify diagnosis entries.
1665         */
1666        public int getSequence() { 
1667          return this.sequence == null || this.sequence.isEmpty() ? 0 : this.sequence.getValue();
1668        }
1669
1670        /**
1671         * @param value A number to uniquely identify diagnosis entries.
1672         */
1673        public DiagnosisComponent setSequence(int value) { 
1674            if (this.sequence == null)
1675              this.sequence = new PositiveIntType();
1676            this.sequence.setValue(value);
1677          return this;
1678        }
1679
1680        /**
1681         * @return {@link #diagnosis} (The nature of illness or problem in a coded form or as a reference to an external defined Condition.)
1682         */
1683        public DataType getDiagnosis() { 
1684          return this.diagnosis;
1685        }
1686
1687        /**
1688         * @return {@link #diagnosis} (The nature of illness or problem in a coded form or as a reference to an external defined Condition.)
1689         */
1690        public CodeableConcept getDiagnosisCodeableConcept() throws FHIRException { 
1691          if (this.diagnosis == null)
1692            this.diagnosis = new CodeableConcept();
1693          if (!(this.diagnosis instanceof CodeableConcept))
1694            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.diagnosis.getClass().getName()+" was encountered");
1695          return (CodeableConcept) this.diagnosis;
1696        }
1697
1698        public boolean hasDiagnosisCodeableConcept() { 
1699          return this != null && this.diagnosis instanceof CodeableConcept;
1700        }
1701
1702        /**
1703         * @return {@link #diagnosis} (The nature of illness or problem in a coded form or as a reference to an external defined Condition.)
1704         */
1705        public Reference getDiagnosisReference() throws FHIRException { 
1706          if (this.diagnosis == null)
1707            this.diagnosis = new Reference();
1708          if (!(this.diagnosis instanceof Reference))
1709            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.diagnosis.getClass().getName()+" was encountered");
1710          return (Reference) this.diagnosis;
1711        }
1712
1713        public boolean hasDiagnosisReference() { 
1714          return this != null && this.diagnosis instanceof Reference;
1715        }
1716
1717        public boolean hasDiagnosis() { 
1718          return this.diagnosis != null && !this.diagnosis.isEmpty();
1719        }
1720
1721        /**
1722         * @param value {@link #diagnosis} (The nature of illness or problem in a coded form or as a reference to an external defined Condition.)
1723         */
1724        public DiagnosisComponent setDiagnosis(DataType value) { 
1725          if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
1726            throw new Error("Not the right type for ExplanationOfBenefit.diagnosis.diagnosis[x]: "+value.fhirType());
1727          this.diagnosis = value;
1728          return this;
1729        }
1730
1731        /**
1732         * @return {@link #type} (When the condition was observed or the relative ranking.)
1733         */
1734        public List<CodeableConcept> getType() { 
1735          if (this.type == null)
1736            this.type = new ArrayList<CodeableConcept>();
1737          return this.type;
1738        }
1739
1740        /**
1741         * @return Returns a reference to <code>this</code> for easy method chaining
1742         */
1743        public DiagnosisComponent setType(List<CodeableConcept> theType) { 
1744          this.type = theType;
1745          return this;
1746        }
1747
1748        public boolean hasType() { 
1749          if (this.type == null)
1750            return false;
1751          for (CodeableConcept item : this.type)
1752            if (!item.isEmpty())
1753              return true;
1754          return false;
1755        }
1756
1757        public CodeableConcept addType() { //3
1758          CodeableConcept t = new CodeableConcept();
1759          if (this.type == null)
1760            this.type = new ArrayList<CodeableConcept>();
1761          this.type.add(t);
1762          return t;
1763        }
1764
1765        public DiagnosisComponent addType(CodeableConcept t) { //3
1766          if (t == null)
1767            return this;
1768          if (this.type == null)
1769            this.type = new ArrayList<CodeableConcept>();
1770          this.type.add(t);
1771          return this;
1772        }
1773
1774        /**
1775         * @return The first repetition of repeating field {@link #type}, creating it if it does not already exist {3}
1776         */
1777        public CodeableConcept getTypeFirstRep() { 
1778          if (getType().isEmpty()) {
1779            addType();
1780          }
1781          return getType().get(0);
1782        }
1783
1784        /**
1785         * @return {@link #onAdmission} (Indication of whether the diagnosis was present on admission to a facility.)
1786         */
1787        public CodeableConcept getOnAdmission() { 
1788          if (this.onAdmission == null)
1789            if (Configuration.errorOnAutoCreate())
1790              throw new Error("Attempt to auto-create DiagnosisComponent.onAdmission");
1791            else if (Configuration.doAutoCreate())
1792              this.onAdmission = new CodeableConcept(); // cc
1793          return this.onAdmission;
1794        }
1795
1796        public boolean hasOnAdmission() { 
1797          return this.onAdmission != null && !this.onAdmission.isEmpty();
1798        }
1799
1800        /**
1801         * @param value {@link #onAdmission} (Indication of whether the diagnosis was present on admission to a facility.)
1802         */
1803        public DiagnosisComponent setOnAdmission(CodeableConcept value) { 
1804          this.onAdmission = value;
1805          return this;
1806        }
1807
1808        /**
1809         * @return {@link #packageCode} (A package billing code or bundle code used to group products and services to a particular health condition (such as heart attack) which is based on a predetermined grouping code system.)
1810         */
1811        public CodeableConcept getPackageCode() { 
1812          if (this.packageCode == null)
1813            if (Configuration.errorOnAutoCreate())
1814              throw new Error("Attempt to auto-create DiagnosisComponent.packageCode");
1815            else if (Configuration.doAutoCreate())
1816              this.packageCode = new CodeableConcept(); // cc
1817          return this.packageCode;
1818        }
1819
1820        public boolean hasPackageCode() { 
1821          return this.packageCode != null && !this.packageCode.isEmpty();
1822        }
1823
1824        /**
1825         * @param value {@link #packageCode} (A package billing code or bundle code used to group products and services to a particular health condition (such as heart attack) which is based on a predetermined grouping code system.)
1826         */
1827        public DiagnosisComponent setPackageCode(CodeableConcept value) { 
1828          this.packageCode = value;
1829          return this;
1830        }
1831
1832        protected void listChildren(List<Property> children) {
1833          super.listChildren(children);
1834          children.add(new Property("sequence", "positiveInt", "A number to uniquely identify diagnosis entries.", 0, 1, sequence));
1835          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));
1836          children.add(new Property("type", "CodeableConcept", "When the condition was observed or the relative ranking.", 0, java.lang.Integer.MAX_VALUE, type));
1837          children.add(new Property("onAdmission", "CodeableConcept", "Indication of whether the diagnosis was present on admission to a facility.", 0, 1, onAdmission));
1838          children.add(new Property("packageCode", "CodeableConcept", "A package billing code or bundle code used to group products and services to a particular health condition (such as heart attack) which is based on a predetermined grouping code system.", 0, 1, packageCode));
1839        }
1840
1841        @Override
1842        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1843          switch (_hash) {
1844          case 1349547969: /*sequence*/  return new Property("sequence", "positiveInt", "A number to uniquely identify diagnosis entries.", 0, 1, sequence);
1845          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);
1846          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);
1847          case 277781616: /*diagnosisCodeableConcept*/  return new Property("diagnosis[x]", "CodeableConcept", "The nature of illness or problem in a coded form or as a reference to an external defined Condition.", 0, 1, diagnosis);
1848          case 2050454362: /*diagnosisReference*/  return new Property("diagnosis[x]", "Reference(Condition)", "The nature of illness or problem in a coded form or as a reference to an external defined Condition.", 0, 1, diagnosis);
1849          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "When the condition was observed or the relative ranking.", 0, java.lang.Integer.MAX_VALUE, type);
1850          case -3386134: /*onAdmission*/  return new Property("onAdmission", "CodeableConcept", "Indication of whether the diagnosis was present on admission to a facility.", 0, 1, onAdmission);
1851          case 908444499: /*packageCode*/  return new Property("packageCode", "CodeableConcept", "A package billing code or bundle code used to group products and services to a particular health condition (such as heart attack) which is based on a predetermined grouping code system.", 0, 1, packageCode);
1852          default: return super.getNamedProperty(_hash, _name, _checkValid);
1853          }
1854
1855        }
1856
1857      @Override
1858      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1859        switch (hash) {
1860        case 1349547969: /*sequence*/ return this.sequence == null ? new Base[0] : new Base[] {this.sequence}; // PositiveIntType
1861        case 1196993265: /*diagnosis*/ return this.diagnosis == null ? new Base[0] : new Base[] {this.diagnosis}; // DataType
1862        case 3575610: /*type*/ return this.type == null ? new Base[0] : this.type.toArray(new Base[this.type.size()]); // CodeableConcept
1863        case -3386134: /*onAdmission*/ return this.onAdmission == null ? new Base[0] : new Base[] {this.onAdmission}; // CodeableConcept
1864        case 908444499: /*packageCode*/ return this.packageCode == null ? new Base[0] : new Base[] {this.packageCode}; // CodeableConcept
1865        default: return super.getProperty(hash, name, checkValid);
1866        }
1867
1868      }
1869
1870      @Override
1871      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1872        switch (hash) {
1873        case 1349547969: // sequence
1874          this.sequence = TypeConvertor.castToPositiveInt(value); // PositiveIntType
1875          return value;
1876        case 1196993265: // diagnosis
1877          this.diagnosis = TypeConvertor.castToType(value); // DataType
1878          return value;
1879        case 3575610: // type
1880          this.getType().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
1881          return value;
1882        case -3386134: // onAdmission
1883          this.onAdmission = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1884          return value;
1885        case 908444499: // packageCode
1886          this.packageCode = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1887          return value;
1888        default: return super.setProperty(hash, name, value);
1889        }
1890
1891      }
1892
1893      @Override
1894      public Base setProperty(String name, Base value) throws FHIRException {
1895        if (name.equals("sequence")) {
1896          this.sequence = TypeConvertor.castToPositiveInt(value); // PositiveIntType
1897        } else if (name.equals("diagnosis[x]")) {
1898          this.diagnosis = TypeConvertor.castToType(value); // DataType
1899        } else if (name.equals("type")) {
1900          this.getType().add(TypeConvertor.castToCodeableConcept(value));
1901        } else if (name.equals("onAdmission")) {
1902          this.onAdmission = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1903        } else if (name.equals("packageCode")) {
1904          this.packageCode = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1905        } else
1906          return super.setProperty(name, value);
1907        return value;
1908      }
1909
1910      @Override
1911      public Base makeProperty(int hash, String name) throws FHIRException {
1912        switch (hash) {
1913        case 1349547969:  return getSequenceElement();
1914        case -1487009809:  return getDiagnosis();
1915        case 1196993265:  return getDiagnosis();
1916        case 3575610:  return addType(); 
1917        case -3386134:  return getOnAdmission();
1918        case 908444499:  return getPackageCode();
1919        default: return super.makeProperty(hash, name);
1920        }
1921
1922      }
1923
1924      @Override
1925      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1926        switch (hash) {
1927        case 1349547969: /*sequence*/ return new String[] {"positiveInt"};
1928        case 1196993265: /*diagnosis*/ return new String[] {"CodeableConcept", "Reference"};
1929        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1930        case -3386134: /*onAdmission*/ return new String[] {"CodeableConcept"};
1931        case 908444499: /*packageCode*/ return new String[] {"CodeableConcept"};
1932        default: return super.getTypesForProperty(hash, name);
1933        }
1934
1935      }
1936
1937      @Override
1938      public Base addChild(String name) throws FHIRException {
1939        if (name.equals("sequence")) {
1940          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.diagnosis.sequence");
1941        }
1942        else if (name.equals("diagnosisCodeableConcept")) {
1943          this.diagnosis = new CodeableConcept();
1944          return this.diagnosis;
1945        }
1946        else if (name.equals("diagnosisReference")) {
1947          this.diagnosis = new Reference();
1948          return this.diagnosis;
1949        }
1950        else if (name.equals("type")) {
1951          return addType();
1952        }
1953        else if (name.equals("onAdmission")) {
1954          this.onAdmission = new CodeableConcept();
1955          return this.onAdmission;
1956        }
1957        else if (name.equals("packageCode")) {
1958          this.packageCode = new CodeableConcept();
1959          return this.packageCode;
1960        }
1961        else
1962          return super.addChild(name);
1963      }
1964
1965      public DiagnosisComponent copy() {
1966        DiagnosisComponent dst = new DiagnosisComponent();
1967        copyValues(dst);
1968        return dst;
1969      }
1970
1971      public void copyValues(DiagnosisComponent dst) {
1972        super.copyValues(dst);
1973        dst.sequence = sequence == null ? null : sequence.copy();
1974        dst.diagnosis = diagnosis == null ? null : diagnosis.copy();
1975        if (type != null) {
1976          dst.type = new ArrayList<CodeableConcept>();
1977          for (CodeableConcept i : type)
1978            dst.type.add(i.copy());
1979        };
1980        dst.onAdmission = onAdmission == null ? null : onAdmission.copy();
1981        dst.packageCode = packageCode == null ? null : packageCode.copy();
1982      }
1983
1984      @Override
1985      public boolean equalsDeep(Base other_) {
1986        if (!super.equalsDeep(other_))
1987          return false;
1988        if (!(other_ instanceof DiagnosisComponent))
1989          return false;
1990        DiagnosisComponent o = (DiagnosisComponent) other_;
1991        return compareDeep(sequence, o.sequence, true) && compareDeep(diagnosis, o.diagnosis, true) && compareDeep(type, o.type, true)
1992           && compareDeep(onAdmission, o.onAdmission, true) && compareDeep(packageCode, o.packageCode, true)
1993          ;
1994      }
1995
1996      @Override
1997      public boolean equalsShallow(Base other_) {
1998        if (!super.equalsShallow(other_))
1999          return false;
2000        if (!(other_ instanceof DiagnosisComponent))
2001          return false;
2002        DiagnosisComponent o = (DiagnosisComponent) other_;
2003        return compareValues(sequence, o.sequence, true);
2004      }
2005
2006      public boolean isEmpty() {
2007        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(sequence, diagnosis, type
2008          , onAdmission, packageCode);
2009      }
2010
2011  public String fhirType() {
2012    return "ExplanationOfBenefit.diagnosis";
2013
2014  }
2015
2016  }
2017
2018    @Block()
2019    public static class ProcedureComponent extends BackboneElement implements IBaseBackboneElement {
2020        /**
2021         * A number to uniquely identify procedure entries.
2022         */
2023        @Child(name = "sequence", type = {PositiveIntType.class}, order=1, min=1, max=1, modifier=false, summary=false)
2024        @Description(shortDefinition="Procedure instance identifier", formalDefinition="A number to uniquely identify procedure entries." )
2025        protected PositiveIntType sequence;
2026
2027        /**
2028         * When the condition was observed or the relative ranking.
2029         */
2030        @Child(name = "type", type = {CodeableConcept.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2031        @Description(shortDefinition="Category of Procedure", formalDefinition="When the condition was observed or the relative ranking." )
2032        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/ex-procedure-type")
2033        protected List<CodeableConcept> type;
2034
2035        /**
2036         * Date and optionally time the procedure was performed.
2037         */
2038        @Child(name = "date", type = {DateTimeType.class}, order=3, min=0, max=1, modifier=false, summary=false)
2039        @Description(shortDefinition="When the procedure was performed", formalDefinition="Date and optionally time the procedure was performed." )
2040        protected DateTimeType date;
2041
2042        /**
2043         * The code or reference to a Procedure resource which identifies the clinical intervention performed.
2044         */
2045        @Child(name = "procedure", type = {CodeableConcept.class, Procedure.class}, order=4, min=1, max=1, modifier=false, summary=false)
2046        @Description(shortDefinition="Specific clinical procedure", formalDefinition="The code or reference to a Procedure resource which identifies the clinical intervention performed." )
2047        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/icd-10-procedures")
2048        protected DataType procedure;
2049
2050        /**
2051         * Unique Device Identifiers associated with this line item.
2052         */
2053        @Child(name = "udi", type = {Device.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2054        @Description(shortDefinition="Unique device identifier", formalDefinition="Unique Device Identifiers associated with this line item." )
2055        protected List<Reference> udi;
2056
2057        private static final long serialVersionUID = 1165684715L;
2058
2059    /**
2060     * Constructor
2061     */
2062      public ProcedureComponent() {
2063        super();
2064      }
2065
2066    /**
2067     * Constructor
2068     */
2069      public ProcedureComponent(int sequence, DataType procedure) {
2070        super();
2071        this.setSequence(sequence);
2072        this.setProcedure(procedure);
2073      }
2074
2075        /**
2076         * @return {@link #sequence} (A number to uniquely identify procedure entries.). This is the underlying object with id, value and extensions. The accessor "getSequence" gives direct access to the value
2077         */
2078        public PositiveIntType getSequenceElement() { 
2079          if (this.sequence == null)
2080            if (Configuration.errorOnAutoCreate())
2081              throw new Error("Attempt to auto-create ProcedureComponent.sequence");
2082            else if (Configuration.doAutoCreate())
2083              this.sequence = new PositiveIntType(); // bb
2084          return this.sequence;
2085        }
2086
2087        public boolean hasSequenceElement() { 
2088          return this.sequence != null && !this.sequence.isEmpty();
2089        }
2090
2091        public boolean hasSequence() { 
2092          return this.sequence != null && !this.sequence.isEmpty();
2093        }
2094
2095        /**
2096         * @param value {@link #sequence} (A number to uniquely identify procedure entries.). This is the underlying object with id, value and extensions. The accessor "getSequence" gives direct access to the value
2097         */
2098        public ProcedureComponent setSequenceElement(PositiveIntType value) { 
2099          this.sequence = value;
2100          return this;
2101        }
2102
2103        /**
2104         * @return A number to uniquely identify procedure entries.
2105         */
2106        public int getSequence() { 
2107          return this.sequence == null || this.sequence.isEmpty() ? 0 : this.sequence.getValue();
2108        }
2109
2110        /**
2111         * @param value A number to uniquely identify procedure entries.
2112         */
2113        public ProcedureComponent setSequence(int value) { 
2114            if (this.sequence == null)
2115              this.sequence = new PositiveIntType();
2116            this.sequence.setValue(value);
2117          return this;
2118        }
2119
2120        /**
2121         * @return {@link #type} (When the condition was observed or the relative ranking.)
2122         */
2123        public List<CodeableConcept> getType() { 
2124          if (this.type == null)
2125            this.type = new ArrayList<CodeableConcept>();
2126          return this.type;
2127        }
2128
2129        /**
2130         * @return Returns a reference to <code>this</code> for easy method chaining
2131         */
2132        public ProcedureComponent setType(List<CodeableConcept> theType) { 
2133          this.type = theType;
2134          return this;
2135        }
2136
2137        public boolean hasType() { 
2138          if (this.type == null)
2139            return false;
2140          for (CodeableConcept item : this.type)
2141            if (!item.isEmpty())
2142              return true;
2143          return false;
2144        }
2145
2146        public CodeableConcept addType() { //3
2147          CodeableConcept t = new CodeableConcept();
2148          if (this.type == null)
2149            this.type = new ArrayList<CodeableConcept>();
2150          this.type.add(t);
2151          return t;
2152        }
2153
2154        public ProcedureComponent addType(CodeableConcept t) { //3
2155          if (t == null)
2156            return this;
2157          if (this.type == null)
2158            this.type = new ArrayList<CodeableConcept>();
2159          this.type.add(t);
2160          return this;
2161        }
2162
2163        /**
2164         * @return The first repetition of repeating field {@link #type}, creating it if it does not already exist {3}
2165         */
2166        public CodeableConcept getTypeFirstRep() { 
2167          if (getType().isEmpty()) {
2168            addType();
2169          }
2170          return getType().get(0);
2171        }
2172
2173        /**
2174         * @return {@link #date} (Date and optionally time the procedure was performed.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
2175         */
2176        public DateTimeType getDateElement() { 
2177          if (this.date == null)
2178            if (Configuration.errorOnAutoCreate())
2179              throw new Error("Attempt to auto-create ProcedureComponent.date");
2180            else if (Configuration.doAutoCreate())
2181              this.date = new DateTimeType(); // bb
2182          return this.date;
2183        }
2184
2185        public boolean hasDateElement() { 
2186          return this.date != null && !this.date.isEmpty();
2187        }
2188
2189        public boolean hasDate() { 
2190          return this.date != null && !this.date.isEmpty();
2191        }
2192
2193        /**
2194         * @param value {@link #date} (Date and optionally time the procedure was performed.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
2195         */
2196        public ProcedureComponent setDateElement(DateTimeType value) { 
2197          this.date = value;
2198          return this;
2199        }
2200
2201        /**
2202         * @return Date and optionally time the procedure was performed.
2203         */
2204        public Date getDate() { 
2205          return this.date == null ? null : this.date.getValue();
2206        }
2207
2208        /**
2209         * @param value Date and optionally time the procedure was performed.
2210         */
2211        public ProcedureComponent setDate(Date value) { 
2212          if (value == null)
2213            this.date = null;
2214          else {
2215            if (this.date == null)
2216              this.date = new DateTimeType();
2217            this.date.setValue(value);
2218          }
2219          return this;
2220        }
2221
2222        /**
2223         * @return {@link #procedure} (The code or reference to a Procedure resource which identifies the clinical intervention performed.)
2224         */
2225        public DataType getProcedure() { 
2226          return this.procedure;
2227        }
2228
2229        /**
2230         * @return {@link #procedure} (The code or reference to a Procedure resource which identifies the clinical intervention performed.)
2231         */
2232        public CodeableConcept getProcedureCodeableConcept() throws FHIRException { 
2233          if (this.procedure == null)
2234            this.procedure = new CodeableConcept();
2235          if (!(this.procedure instanceof CodeableConcept))
2236            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.procedure.getClass().getName()+" was encountered");
2237          return (CodeableConcept) this.procedure;
2238        }
2239
2240        public boolean hasProcedureCodeableConcept() { 
2241          return this != null && this.procedure instanceof CodeableConcept;
2242        }
2243
2244        /**
2245         * @return {@link #procedure} (The code or reference to a Procedure resource which identifies the clinical intervention performed.)
2246         */
2247        public Reference getProcedureReference() throws FHIRException { 
2248          if (this.procedure == null)
2249            this.procedure = new Reference();
2250          if (!(this.procedure instanceof Reference))
2251            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.procedure.getClass().getName()+" was encountered");
2252          return (Reference) this.procedure;
2253        }
2254
2255        public boolean hasProcedureReference() { 
2256          return this != null && this.procedure instanceof Reference;
2257        }
2258
2259        public boolean hasProcedure() { 
2260          return this.procedure != null && !this.procedure.isEmpty();
2261        }
2262
2263        /**
2264         * @param value {@link #procedure} (The code or reference to a Procedure resource which identifies the clinical intervention performed.)
2265         */
2266        public ProcedureComponent setProcedure(DataType value) { 
2267          if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
2268            throw new Error("Not the right type for ExplanationOfBenefit.procedure.procedure[x]: "+value.fhirType());
2269          this.procedure = value;
2270          return this;
2271        }
2272
2273        /**
2274         * @return {@link #udi} (Unique Device Identifiers associated with this line item.)
2275         */
2276        public List<Reference> getUdi() { 
2277          if (this.udi == null)
2278            this.udi = new ArrayList<Reference>();
2279          return this.udi;
2280        }
2281
2282        /**
2283         * @return Returns a reference to <code>this</code> for easy method chaining
2284         */
2285        public ProcedureComponent setUdi(List<Reference> theUdi) { 
2286          this.udi = theUdi;
2287          return this;
2288        }
2289
2290        public boolean hasUdi() { 
2291          if (this.udi == null)
2292            return false;
2293          for (Reference item : this.udi)
2294            if (!item.isEmpty())
2295              return true;
2296          return false;
2297        }
2298
2299        public Reference addUdi() { //3
2300          Reference t = new Reference();
2301          if (this.udi == null)
2302            this.udi = new ArrayList<Reference>();
2303          this.udi.add(t);
2304          return t;
2305        }
2306
2307        public ProcedureComponent addUdi(Reference t) { //3
2308          if (t == null)
2309            return this;
2310          if (this.udi == null)
2311            this.udi = new ArrayList<Reference>();
2312          this.udi.add(t);
2313          return this;
2314        }
2315
2316        /**
2317         * @return The first repetition of repeating field {@link #udi}, creating it if it does not already exist {3}
2318         */
2319        public Reference getUdiFirstRep() { 
2320          if (getUdi().isEmpty()) {
2321            addUdi();
2322          }
2323          return getUdi().get(0);
2324        }
2325
2326        protected void listChildren(List<Property> children) {
2327          super.listChildren(children);
2328          children.add(new Property("sequence", "positiveInt", "A number to uniquely identify procedure entries.", 0, 1, sequence));
2329          children.add(new Property("type", "CodeableConcept", "When the condition was observed or the relative ranking.", 0, java.lang.Integer.MAX_VALUE, type));
2330          children.add(new Property("date", "dateTime", "Date and optionally time the procedure was performed.", 0, 1, date));
2331          children.add(new Property("procedure[x]", "CodeableConcept|Reference(Procedure)", "The code or reference to a Procedure resource which identifies the clinical intervention performed.", 0, 1, procedure));
2332          children.add(new Property("udi", "Reference(Device)", "Unique Device Identifiers associated with this line item.", 0, java.lang.Integer.MAX_VALUE, udi));
2333        }
2334
2335        @Override
2336        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2337          switch (_hash) {
2338          case 1349547969: /*sequence*/  return new Property("sequence", "positiveInt", "A number to uniquely identify procedure entries.", 0, 1, sequence);
2339          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "When the condition was observed or the relative ranking.", 0, java.lang.Integer.MAX_VALUE, type);
2340          case 3076014: /*date*/  return new Property("date", "dateTime", "Date and optionally time the procedure was performed.", 0, 1, date);
2341          case 1640074445: /*procedure[x]*/  return new Property("procedure[x]", "CodeableConcept|Reference(Procedure)", "The code or reference to a Procedure resource which identifies the clinical intervention performed.", 0, 1, procedure);
2342          case -1095204141: /*procedure*/  return new Property("procedure[x]", "CodeableConcept|Reference(Procedure)", "The code or reference to a Procedure resource which identifies the clinical intervention performed.", 0, 1, procedure);
2343          case -1284783026: /*procedureCodeableConcept*/  return new Property("procedure[x]", "CodeableConcept", "The code or reference to a Procedure resource which identifies the clinical intervention performed.", 0, 1, procedure);
2344          case 881809848: /*procedureReference*/  return new Property("procedure[x]", "Reference(Procedure)", "The code or reference to a Procedure resource which identifies the clinical intervention performed.", 0, 1, procedure);
2345          case 115642: /*udi*/  return new Property("udi", "Reference(Device)", "Unique Device Identifiers associated with this line item.", 0, java.lang.Integer.MAX_VALUE, udi);
2346          default: return super.getNamedProperty(_hash, _name, _checkValid);
2347          }
2348
2349        }
2350
2351      @Override
2352      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2353        switch (hash) {
2354        case 1349547969: /*sequence*/ return this.sequence == null ? new Base[0] : new Base[] {this.sequence}; // PositiveIntType
2355        case 3575610: /*type*/ return this.type == null ? new Base[0] : this.type.toArray(new Base[this.type.size()]); // CodeableConcept
2356        case 3076014: /*date*/ return this.date == null ? new Base[0] : new Base[] {this.date}; // DateTimeType
2357        case -1095204141: /*procedure*/ return this.procedure == null ? new Base[0] : new Base[] {this.procedure}; // DataType
2358        case 115642: /*udi*/ return this.udi == null ? new Base[0] : this.udi.toArray(new Base[this.udi.size()]); // Reference
2359        default: return super.getProperty(hash, name, checkValid);
2360        }
2361
2362      }
2363
2364      @Override
2365      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2366        switch (hash) {
2367        case 1349547969: // sequence
2368          this.sequence = TypeConvertor.castToPositiveInt(value); // PositiveIntType
2369          return value;
2370        case 3575610: // type
2371          this.getType().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
2372          return value;
2373        case 3076014: // date
2374          this.date = TypeConvertor.castToDateTime(value); // DateTimeType
2375          return value;
2376        case -1095204141: // procedure
2377          this.procedure = TypeConvertor.castToType(value); // DataType
2378          return value;
2379        case 115642: // udi
2380          this.getUdi().add(TypeConvertor.castToReference(value)); // Reference
2381          return value;
2382        default: return super.setProperty(hash, name, value);
2383        }
2384
2385      }
2386
2387      @Override
2388      public Base setProperty(String name, Base value) throws FHIRException {
2389        if (name.equals("sequence")) {
2390          this.sequence = TypeConvertor.castToPositiveInt(value); // PositiveIntType
2391        } else if (name.equals("type")) {
2392          this.getType().add(TypeConvertor.castToCodeableConcept(value));
2393        } else if (name.equals("date")) {
2394          this.date = TypeConvertor.castToDateTime(value); // DateTimeType
2395        } else if (name.equals("procedure[x]")) {
2396          this.procedure = TypeConvertor.castToType(value); // DataType
2397        } else if (name.equals("udi")) {
2398          this.getUdi().add(TypeConvertor.castToReference(value));
2399        } else
2400          return super.setProperty(name, value);
2401        return value;
2402      }
2403
2404      @Override
2405      public Base makeProperty(int hash, String name) throws FHIRException {
2406        switch (hash) {
2407        case 1349547969:  return getSequenceElement();
2408        case 3575610:  return addType(); 
2409        case 3076014:  return getDateElement();
2410        case 1640074445:  return getProcedure();
2411        case -1095204141:  return getProcedure();
2412        case 115642:  return addUdi(); 
2413        default: return super.makeProperty(hash, name);
2414        }
2415
2416      }
2417
2418      @Override
2419      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2420        switch (hash) {
2421        case 1349547969: /*sequence*/ return new String[] {"positiveInt"};
2422        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
2423        case 3076014: /*date*/ return new String[] {"dateTime"};
2424        case -1095204141: /*procedure*/ return new String[] {"CodeableConcept", "Reference"};
2425        case 115642: /*udi*/ return new String[] {"Reference"};
2426        default: return super.getTypesForProperty(hash, name);
2427        }
2428
2429      }
2430
2431      @Override
2432      public Base addChild(String name) throws FHIRException {
2433        if (name.equals("sequence")) {
2434          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.procedure.sequence");
2435        }
2436        else if (name.equals("type")) {
2437          return addType();
2438        }
2439        else if (name.equals("date")) {
2440          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.procedure.date");
2441        }
2442        else if (name.equals("procedureCodeableConcept")) {
2443          this.procedure = new CodeableConcept();
2444          return this.procedure;
2445        }
2446        else if (name.equals("procedureReference")) {
2447          this.procedure = new Reference();
2448          return this.procedure;
2449        }
2450        else if (name.equals("udi")) {
2451          return addUdi();
2452        }
2453        else
2454          return super.addChild(name);
2455      }
2456
2457      public ProcedureComponent copy() {
2458        ProcedureComponent dst = new ProcedureComponent();
2459        copyValues(dst);
2460        return dst;
2461      }
2462
2463      public void copyValues(ProcedureComponent dst) {
2464        super.copyValues(dst);
2465        dst.sequence = sequence == null ? null : sequence.copy();
2466        if (type != null) {
2467          dst.type = new ArrayList<CodeableConcept>();
2468          for (CodeableConcept i : type)
2469            dst.type.add(i.copy());
2470        };
2471        dst.date = date == null ? null : date.copy();
2472        dst.procedure = procedure == null ? null : procedure.copy();
2473        if (udi != null) {
2474          dst.udi = new ArrayList<Reference>();
2475          for (Reference i : udi)
2476            dst.udi.add(i.copy());
2477        };
2478      }
2479
2480      @Override
2481      public boolean equalsDeep(Base other_) {
2482        if (!super.equalsDeep(other_))
2483          return false;
2484        if (!(other_ instanceof ProcedureComponent))
2485          return false;
2486        ProcedureComponent o = (ProcedureComponent) other_;
2487        return compareDeep(sequence, o.sequence, true) && compareDeep(type, o.type, true) && compareDeep(date, o.date, true)
2488           && compareDeep(procedure, o.procedure, true) && compareDeep(udi, o.udi, true);
2489      }
2490
2491      @Override
2492      public boolean equalsShallow(Base other_) {
2493        if (!super.equalsShallow(other_))
2494          return false;
2495        if (!(other_ instanceof ProcedureComponent))
2496          return false;
2497        ProcedureComponent o = (ProcedureComponent) other_;
2498        return compareValues(sequence, o.sequence, true) && compareValues(date, o.date, true);
2499      }
2500
2501      public boolean isEmpty() {
2502        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(sequence, type, date, procedure
2503          , udi);
2504      }
2505
2506  public String fhirType() {
2507    return "ExplanationOfBenefit.procedure";
2508
2509  }
2510
2511  }
2512
2513    @Block()
2514    public static class InsuranceComponent extends BackboneElement implements IBaseBackboneElement {
2515        /**
2516         * A flag to indicate that this Coverage is to be used for adjudication of this claim when set to true.
2517         */
2518        @Child(name = "focal", type = {BooleanType.class}, order=1, min=1, max=1, modifier=false, summary=true)
2519        @Description(shortDefinition="Coverage to be used for adjudication", formalDefinition="A flag to indicate that this Coverage is to be used for adjudication of this claim when set to true." )
2520        protected BooleanType focal;
2521
2522        /**
2523         * 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.
2524         */
2525        @Child(name = "coverage", type = {Coverage.class}, order=2, min=1, max=1, modifier=false, summary=true)
2526        @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." )
2527        protected Reference coverage;
2528
2529        /**
2530         * Reference numbers previously provided by the insurer to the provider to be quoted on subsequent claims containing services or products related to the prior authorization.
2531         */
2532        @Child(name = "preAuthRef", type = {StringType.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2533        @Description(shortDefinition="Prior authorization reference number", formalDefinition="Reference numbers previously provided by the insurer to the provider to be quoted on subsequent claims containing services or products related to the prior authorization." )
2534        protected List<StringType> preAuthRef;
2535
2536        private static final long serialVersionUID = 1519900285L;
2537
2538    /**
2539     * Constructor
2540     */
2541      public InsuranceComponent() {
2542        super();
2543      }
2544
2545    /**
2546     * Constructor
2547     */
2548      public InsuranceComponent(boolean focal, Reference coverage) {
2549        super();
2550        this.setFocal(focal);
2551        this.setCoverage(coverage);
2552      }
2553
2554        /**
2555         * @return {@link #focal} (A flag to indicate that this Coverage is to be used for adjudication of this claim when set to true.). This is the underlying object with id, value and extensions. The accessor "getFocal" gives direct access to the value
2556         */
2557        public BooleanType getFocalElement() { 
2558          if (this.focal == null)
2559            if (Configuration.errorOnAutoCreate())
2560              throw new Error("Attempt to auto-create InsuranceComponent.focal");
2561            else if (Configuration.doAutoCreate())
2562              this.focal = new BooleanType(); // bb
2563          return this.focal;
2564        }
2565
2566        public boolean hasFocalElement() { 
2567          return this.focal != null && !this.focal.isEmpty();
2568        }
2569
2570        public boolean hasFocal() { 
2571          return this.focal != null && !this.focal.isEmpty();
2572        }
2573
2574        /**
2575         * @param value {@link #focal} (A flag to indicate that this Coverage is to be used for adjudication of this claim when set to true.). This is the underlying object with id, value and extensions. The accessor "getFocal" gives direct access to the value
2576         */
2577        public InsuranceComponent setFocalElement(BooleanType value) { 
2578          this.focal = value;
2579          return this;
2580        }
2581
2582        /**
2583         * @return A flag to indicate that this Coverage is to be used for adjudication of this claim when set to true.
2584         */
2585        public boolean getFocal() { 
2586          return this.focal == null || this.focal.isEmpty() ? false : this.focal.getValue();
2587        }
2588
2589        /**
2590         * @param value A flag to indicate that this Coverage is to be used for adjudication of this claim when set to true.
2591         */
2592        public InsuranceComponent setFocal(boolean value) { 
2593            if (this.focal == null)
2594              this.focal = new BooleanType();
2595            this.focal.setValue(value);
2596          return this;
2597        }
2598
2599        /**
2600         * @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.)
2601         */
2602        public Reference getCoverage() { 
2603          if (this.coverage == null)
2604            if (Configuration.errorOnAutoCreate())
2605              throw new Error("Attempt to auto-create InsuranceComponent.coverage");
2606            else if (Configuration.doAutoCreate())
2607              this.coverage = new Reference(); // cc
2608          return this.coverage;
2609        }
2610
2611        public boolean hasCoverage() { 
2612          return this.coverage != null && !this.coverage.isEmpty();
2613        }
2614
2615        /**
2616         * @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.)
2617         */
2618        public InsuranceComponent setCoverage(Reference value) { 
2619          this.coverage = value;
2620          return this;
2621        }
2622
2623        /**
2624         * @return {@link #preAuthRef} (Reference numbers previously provided by the insurer to the provider to be quoted on subsequent claims containing services or products related to the prior authorization.)
2625         */
2626        public List<StringType> getPreAuthRef() { 
2627          if (this.preAuthRef == null)
2628            this.preAuthRef = new ArrayList<StringType>();
2629          return this.preAuthRef;
2630        }
2631
2632        /**
2633         * @return Returns a reference to <code>this</code> for easy method chaining
2634         */
2635        public InsuranceComponent setPreAuthRef(List<StringType> thePreAuthRef) { 
2636          this.preAuthRef = thePreAuthRef;
2637          return this;
2638        }
2639
2640        public boolean hasPreAuthRef() { 
2641          if (this.preAuthRef == null)
2642            return false;
2643          for (StringType item : this.preAuthRef)
2644            if (!item.isEmpty())
2645              return true;
2646          return false;
2647        }
2648
2649        /**
2650         * @return {@link #preAuthRef} (Reference numbers previously provided by the insurer to the provider to be quoted on subsequent claims containing services or products related to the prior authorization.)
2651         */
2652        public StringType addPreAuthRefElement() {//2 
2653          StringType t = new StringType();
2654          if (this.preAuthRef == null)
2655            this.preAuthRef = new ArrayList<StringType>();
2656          this.preAuthRef.add(t);
2657          return t;
2658        }
2659
2660        /**
2661         * @param value {@link #preAuthRef} (Reference numbers previously provided by the insurer to the provider to be quoted on subsequent claims containing services or products related to the prior authorization.)
2662         */
2663        public InsuranceComponent addPreAuthRef(String value) { //1
2664          StringType t = new StringType();
2665          t.setValue(value);
2666          if (this.preAuthRef == null)
2667            this.preAuthRef = new ArrayList<StringType>();
2668          this.preAuthRef.add(t);
2669          return this;
2670        }
2671
2672        /**
2673         * @param value {@link #preAuthRef} (Reference numbers previously provided by the insurer to the provider to be quoted on subsequent claims containing services or products related to the prior authorization.)
2674         */
2675        public boolean hasPreAuthRef(String value) { 
2676          if (this.preAuthRef == null)
2677            return false;
2678          for (StringType v : this.preAuthRef)
2679            if (v.getValue().equals(value)) // string
2680              return true;
2681          return false;
2682        }
2683
2684        protected void listChildren(List<Property> children) {
2685          super.listChildren(children);
2686          children.add(new Property("focal", "boolean", "A flag to indicate that this Coverage is to be used for adjudication of this claim when set to true.", 0, 1, focal));
2687          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));
2688          children.add(new Property("preAuthRef", "string", "Reference numbers previously provided by the insurer to the provider to be quoted on subsequent claims containing services or products related to the prior authorization.", 0, java.lang.Integer.MAX_VALUE, preAuthRef));
2689        }
2690
2691        @Override
2692        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2693          switch (_hash) {
2694          case 97604197: /*focal*/  return new Property("focal", "boolean", "A flag to indicate that this Coverage is to be used for adjudication of this claim when set to true.", 0, 1, focal);
2695          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);
2696          case 522246568: /*preAuthRef*/  return new Property("preAuthRef", "string", "Reference numbers previously provided by the insurer to the provider to be quoted on subsequent claims containing services or products related to the prior authorization.", 0, java.lang.Integer.MAX_VALUE, preAuthRef);
2697          default: return super.getNamedProperty(_hash, _name, _checkValid);
2698          }
2699
2700        }
2701
2702      @Override
2703      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2704        switch (hash) {
2705        case 97604197: /*focal*/ return this.focal == null ? new Base[0] : new Base[] {this.focal}; // BooleanType
2706        case -351767064: /*coverage*/ return this.coverage == null ? new Base[0] : new Base[] {this.coverage}; // Reference
2707        case 522246568: /*preAuthRef*/ return this.preAuthRef == null ? new Base[0] : this.preAuthRef.toArray(new Base[this.preAuthRef.size()]); // StringType
2708        default: return super.getProperty(hash, name, checkValid);
2709        }
2710
2711      }
2712
2713      @Override
2714      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2715        switch (hash) {
2716        case 97604197: // focal
2717          this.focal = TypeConvertor.castToBoolean(value); // BooleanType
2718          return value;
2719        case -351767064: // coverage
2720          this.coverage = TypeConvertor.castToReference(value); // Reference
2721          return value;
2722        case 522246568: // preAuthRef
2723          this.getPreAuthRef().add(TypeConvertor.castToString(value)); // StringType
2724          return value;
2725        default: return super.setProperty(hash, name, value);
2726        }
2727
2728      }
2729
2730      @Override
2731      public Base setProperty(String name, Base value) throws FHIRException {
2732        if (name.equals("focal")) {
2733          this.focal = TypeConvertor.castToBoolean(value); // BooleanType
2734        } else if (name.equals("coverage")) {
2735          this.coverage = TypeConvertor.castToReference(value); // Reference
2736        } else if (name.equals("preAuthRef")) {
2737          this.getPreAuthRef().add(TypeConvertor.castToString(value));
2738        } else
2739          return super.setProperty(name, value);
2740        return value;
2741      }
2742
2743      @Override
2744      public Base makeProperty(int hash, String name) throws FHIRException {
2745        switch (hash) {
2746        case 97604197:  return getFocalElement();
2747        case -351767064:  return getCoverage();
2748        case 522246568:  return addPreAuthRefElement();
2749        default: return super.makeProperty(hash, name);
2750        }
2751
2752      }
2753
2754      @Override
2755      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2756        switch (hash) {
2757        case 97604197: /*focal*/ return new String[] {"boolean"};
2758        case -351767064: /*coverage*/ return new String[] {"Reference"};
2759        case 522246568: /*preAuthRef*/ return new String[] {"string"};
2760        default: return super.getTypesForProperty(hash, name);
2761        }
2762
2763      }
2764
2765      @Override
2766      public Base addChild(String name) throws FHIRException {
2767        if (name.equals("focal")) {
2768          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.insurance.focal");
2769        }
2770        else if (name.equals("coverage")) {
2771          this.coverage = new Reference();
2772          return this.coverage;
2773        }
2774        else if (name.equals("preAuthRef")) {
2775          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.insurance.preAuthRef");
2776        }
2777        else
2778          return super.addChild(name);
2779      }
2780
2781      public InsuranceComponent copy() {
2782        InsuranceComponent dst = new InsuranceComponent();
2783        copyValues(dst);
2784        return dst;
2785      }
2786
2787      public void copyValues(InsuranceComponent dst) {
2788        super.copyValues(dst);
2789        dst.focal = focal == null ? null : focal.copy();
2790        dst.coverage = coverage == null ? null : coverage.copy();
2791        if (preAuthRef != null) {
2792          dst.preAuthRef = new ArrayList<StringType>();
2793          for (StringType i : preAuthRef)
2794            dst.preAuthRef.add(i.copy());
2795        };
2796      }
2797
2798      @Override
2799      public boolean equalsDeep(Base other_) {
2800        if (!super.equalsDeep(other_))
2801          return false;
2802        if (!(other_ instanceof InsuranceComponent))
2803          return false;
2804        InsuranceComponent o = (InsuranceComponent) other_;
2805        return compareDeep(focal, o.focal, true) && compareDeep(coverage, o.coverage, true) && compareDeep(preAuthRef, o.preAuthRef, true)
2806          ;
2807      }
2808
2809      @Override
2810      public boolean equalsShallow(Base other_) {
2811        if (!super.equalsShallow(other_))
2812          return false;
2813        if (!(other_ instanceof InsuranceComponent))
2814          return false;
2815        InsuranceComponent o = (InsuranceComponent) other_;
2816        return compareValues(focal, o.focal, true) && compareValues(preAuthRef, o.preAuthRef, true);
2817      }
2818
2819      public boolean isEmpty() {
2820        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(focal, coverage, preAuthRef
2821          );
2822      }
2823
2824  public String fhirType() {
2825    return "ExplanationOfBenefit.insurance";
2826
2827  }
2828
2829  }
2830
2831    @Block()
2832    public static class AccidentComponent extends BackboneElement implements IBaseBackboneElement {
2833        /**
2834         * Date of an accident event  related to the products and services contained in the claim.
2835         */
2836        @Child(name = "date", type = {DateType.class}, order=1, min=0, max=1, modifier=false, summary=false)
2837        @Description(shortDefinition="When the incident occurred", formalDefinition="Date of an accident event  related to the products and services contained in the claim." )
2838        protected DateType date;
2839
2840        /**
2841         * The type or context of the accident event for the purposes of selection of potential insurance coverages and determination of coordination between insurers.
2842         */
2843        @Child(name = "type", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
2844        @Description(shortDefinition="The nature of the accident", formalDefinition="The type or context of the accident event for the purposes of selection of potential insurance coverages and determination of coordination between insurers." )
2845        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v3-ActIncidentCode")
2846        protected CodeableConcept type;
2847
2848        /**
2849         * The physical location of the accident event.
2850         */
2851        @Child(name = "location", type = {Address.class, Location.class}, order=3, min=0, max=1, modifier=false, summary=false)
2852        @Description(shortDefinition="Where the event occurred", formalDefinition="The physical location of the accident event." )
2853        protected DataType location;
2854
2855        private static final long serialVersionUID = 11882722L;
2856
2857    /**
2858     * Constructor
2859     */
2860      public AccidentComponent() {
2861        super();
2862      }
2863
2864        /**
2865         * @return {@link #date} (Date of an accident event  related to the products and services contained in the claim.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
2866         */
2867        public DateType getDateElement() { 
2868          if (this.date == null)
2869            if (Configuration.errorOnAutoCreate())
2870              throw new Error("Attempt to auto-create AccidentComponent.date");
2871            else if (Configuration.doAutoCreate())
2872              this.date = new DateType(); // bb
2873          return this.date;
2874        }
2875
2876        public boolean hasDateElement() { 
2877          return this.date != null && !this.date.isEmpty();
2878        }
2879
2880        public boolean hasDate() { 
2881          return this.date != null && !this.date.isEmpty();
2882        }
2883
2884        /**
2885         * @param value {@link #date} (Date of an accident event  related to the products and services contained in the claim.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
2886         */
2887        public AccidentComponent setDateElement(DateType value) { 
2888          this.date = value;
2889          return this;
2890        }
2891
2892        /**
2893         * @return Date of an accident event  related to the products and services contained in the claim.
2894         */
2895        public Date getDate() { 
2896          return this.date == null ? null : this.date.getValue();
2897        }
2898
2899        /**
2900         * @param value Date of an accident event  related to the products and services contained in the claim.
2901         */
2902        public AccidentComponent setDate(Date value) { 
2903          if (value == null)
2904            this.date = null;
2905          else {
2906            if (this.date == null)
2907              this.date = new DateType();
2908            this.date.setValue(value);
2909          }
2910          return this;
2911        }
2912
2913        /**
2914         * @return {@link #type} (The type or context of the accident event for the purposes of selection of potential insurance coverages and determination of coordination between insurers.)
2915         */
2916        public CodeableConcept getType() { 
2917          if (this.type == null)
2918            if (Configuration.errorOnAutoCreate())
2919              throw new Error("Attempt to auto-create AccidentComponent.type");
2920            else if (Configuration.doAutoCreate())
2921              this.type = new CodeableConcept(); // cc
2922          return this.type;
2923        }
2924
2925        public boolean hasType() { 
2926          return this.type != null && !this.type.isEmpty();
2927        }
2928
2929        /**
2930         * @param value {@link #type} (The type or context of the accident event for the purposes of selection of potential insurance coverages and determination of coordination between insurers.)
2931         */
2932        public AccidentComponent setType(CodeableConcept value) { 
2933          this.type = value;
2934          return this;
2935        }
2936
2937        /**
2938         * @return {@link #location} (The physical location of the accident event.)
2939         */
2940        public DataType getLocation() { 
2941          return this.location;
2942        }
2943
2944        /**
2945         * @return {@link #location} (The physical location of the accident event.)
2946         */
2947        public Address getLocationAddress() throws FHIRException { 
2948          if (this.location == null)
2949            this.location = new Address();
2950          if (!(this.location instanceof Address))
2951            throw new FHIRException("Type mismatch: the type Address was expected, but "+this.location.getClass().getName()+" was encountered");
2952          return (Address) this.location;
2953        }
2954
2955        public boolean hasLocationAddress() { 
2956          return this != null && this.location instanceof Address;
2957        }
2958
2959        /**
2960         * @return {@link #location} (The physical location of the accident event.)
2961         */
2962        public Reference getLocationReference() throws FHIRException { 
2963          if (this.location == null)
2964            this.location = new Reference();
2965          if (!(this.location instanceof Reference))
2966            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.location.getClass().getName()+" was encountered");
2967          return (Reference) this.location;
2968        }
2969
2970        public boolean hasLocationReference() { 
2971          return this != null && this.location instanceof Reference;
2972        }
2973
2974        public boolean hasLocation() { 
2975          return this.location != null && !this.location.isEmpty();
2976        }
2977
2978        /**
2979         * @param value {@link #location} (The physical location of the accident event.)
2980         */
2981        public AccidentComponent setLocation(DataType value) { 
2982          if (value != null && !(value instanceof Address || value instanceof Reference))
2983            throw new Error("Not the right type for ExplanationOfBenefit.accident.location[x]: "+value.fhirType());
2984          this.location = value;
2985          return this;
2986        }
2987
2988        protected void listChildren(List<Property> children) {
2989          super.listChildren(children);
2990          children.add(new Property("date", "date", "Date of an accident event  related to the products and services contained in the claim.", 0, 1, date));
2991          children.add(new Property("type", "CodeableConcept", "The type or context of the accident event for the purposes of selection of potential insurance coverages and determination of coordination between insurers.", 0, 1, type));
2992          children.add(new Property("location[x]", "Address|Reference(Location)", "The physical location of the accident event.", 0, 1, location));
2993        }
2994
2995        @Override
2996        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2997          switch (_hash) {
2998          case 3076014: /*date*/  return new Property("date", "date", "Date of an accident event  related to the products and services contained in the claim.", 0, 1, date);
2999          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "The type or context of the accident event for the purposes of selection of potential insurance coverages and determination of coordination between insurers.", 0, 1, type);
3000          case 552316075: /*location[x]*/  return new Property("location[x]", "Address|Reference(Location)", "The physical location of the accident event.", 0, 1, location);
3001          case 1901043637: /*location*/  return new Property("location[x]", "Address|Reference(Location)", "The physical location of the accident event.", 0, 1, location);
3002          case -1280020865: /*locationAddress*/  return new Property("location[x]", "Address", "The physical location of the accident event.", 0, 1, location);
3003          case 755866390: /*locationReference*/  return new Property("location[x]", "Reference(Location)", "The physical location of the accident event.", 0, 1, location);
3004          default: return super.getNamedProperty(_hash, _name, _checkValid);
3005          }
3006
3007        }
3008
3009      @Override
3010      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
3011        switch (hash) {
3012        case 3076014: /*date*/ return this.date == null ? new Base[0] : new Base[] {this.date}; // DateType
3013        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
3014        case 1901043637: /*location*/ return this.location == null ? new Base[0] : new Base[] {this.location}; // DataType
3015        default: return super.getProperty(hash, name, checkValid);
3016        }
3017
3018      }
3019
3020      @Override
3021      public Base setProperty(int hash, String name, Base value) throws FHIRException {
3022        switch (hash) {
3023        case 3076014: // date
3024          this.date = TypeConvertor.castToDate(value); // DateType
3025          return value;
3026        case 3575610: // type
3027          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3028          return value;
3029        case 1901043637: // location
3030          this.location = TypeConvertor.castToType(value); // DataType
3031          return value;
3032        default: return super.setProperty(hash, name, value);
3033        }
3034
3035      }
3036
3037      @Override
3038      public Base setProperty(String name, Base value) throws FHIRException {
3039        if (name.equals("date")) {
3040          this.date = TypeConvertor.castToDate(value); // DateType
3041        } else if (name.equals("type")) {
3042          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3043        } else if (name.equals("location[x]")) {
3044          this.location = TypeConvertor.castToType(value); // DataType
3045        } else
3046          return super.setProperty(name, value);
3047        return value;
3048      }
3049
3050      @Override
3051      public Base makeProperty(int hash, String name) throws FHIRException {
3052        switch (hash) {
3053        case 3076014:  return getDateElement();
3054        case 3575610:  return getType();
3055        case 552316075:  return getLocation();
3056        case 1901043637:  return getLocation();
3057        default: return super.makeProperty(hash, name);
3058        }
3059
3060      }
3061
3062      @Override
3063      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
3064        switch (hash) {
3065        case 3076014: /*date*/ return new String[] {"date"};
3066        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
3067        case 1901043637: /*location*/ return new String[] {"Address", "Reference"};
3068        default: return super.getTypesForProperty(hash, name);
3069        }
3070
3071      }
3072
3073      @Override
3074      public Base addChild(String name) throws FHIRException {
3075        if (name.equals("date")) {
3076          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.accident.date");
3077        }
3078        else if (name.equals("type")) {
3079          this.type = new CodeableConcept();
3080          return this.type;
3081        }
3082        else if (name.equals("locationAddress")) {
3083          this.location = new Address();
3084          return this.location;
3085        }
3086        else if (name.equals("locationReference")) {
3087          this.location = new Reference();
3088          return this.location;
3089        }
3090        else
3091          return super.addChild(name);
3092      }
3093
3094      public AccidentComponent copy() {
3095        AccidentComponent dst = new AccidentComponent();
3096        copyValues(dst);
3097        return dst;
3098      }
3099
3100      public void copyValues(AccidentComponent dst) {
3101        super.copyValues(dst);
3102        dst.date = date == null ? null : date.copy();
3103        dst.type = type == null ? null : type.copy();
3104        dst.location = location == null ? null : location.copy();
3105      }
3106
3107      @Override
3108      public boolean equalsDeep(Base other_) {
3109        if (!super.equalsDeep(other_))
3110          return false;
3111        if (!(other_ instanceof AccidentComponent))
3112          return false;
3113        AccidentComponent o = (AccidentComponent) other_;
3114        return compareDeep(date, o.date, true) && compareDeep(type, o.type, true) && compareDeep(location, o.location, true)
3115          ;
3116      }
3117
3118      @Override
3119      public boolean equalsShallow(Base other_) {
3120        if (!super.equalsShallow(other_))
3121          return false;
3122        if (!(other_ instanceof AccidentComponent))
3123          return false;
3124        AccidentComponent o = (AccidentComponent) other_;
3125        return compareValues(date, o.date, true);
3126      }
3127
3128      public boolean isEmpty() {
3129        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(date, type, location);
3130      }
3131
3132  public String fhirType() {
3133    return "ExplanationOfBenefit.accident";
3134
3135  }
3136
3137  }
3138
3139    @Block()
3140    public static class ItemComponent extends BackboneElement implements IBaseBackboneElement {
3141        /**
3142         * A number to uniquely identify item entries.
3143         */
3144        @Child(name = "sequence", type = {PositiveIntType.class}, order=1, min=1, max=1, modifier=false, summary=false)
3145        @Description(shortDefinition="Item instance identifier", formalDefinition="A number to uniquely identify item entries." )
3146        protected PositiveIntType sequence;
3147
3148        /**
3149         * Care team members related to this service or product.
3150         */
3151        @Child(name = "careTeamSequence", type = {PositiveIntType.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
3152        @Description(shortDefinition="Applicable care team members", formalDefinition="Care team members related to this service or product." )
3153        protected List<PositiveIntType> careTeamSequence;
3154
3155        /**
3156         * Diagnoses applicable for this service or product.
3157         */
3158        @Child(name = "diagnosisSequence", type = {PositiveIntType.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
3159        @Description(shortDefinition="Applicable diagnoses", formalDefinition="Diagnoses applicable for this service or product." )
3160        protected List<PositiveIntType> diagnosisSequence;
3161
3162        /**
3163         * Procedures applicable for this service or product.
3164         */
3165        @Child(name = "procedureSequence", type = {PositiveIntType.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
3166        @Description(shortDefinition="Applicable procedures", formalDefinition="Procedures applicable for this service or product." )
3167        protected List<PositiveIntType> procedureSequence;
3168
3169        /**
3170         * Exceptions, special conditions and supporting information applicable for this service or product.
3171         */
3172        @Child(name = "informationSequence", type = {PositiveIntType.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
3173        @Description(shortDefinition="Applicable exception and supporting information", formalDefinition="Exceptions, special conditions and supporting information applicable for this service or product." )
3174        protected List<PositiveIntType> informationSequence;
3175
3176        /**
3177         * The type of revenue or cost center providing the product and/or service.
3178         */
3179        @Child(name = "revenue", type = {CodeableConcept.class}, order=6, min=0, max=1, modifier=false, summary=false)
3180        @Description(shortDefinition="Revenue or cost center code", formalDefinition="The type of revenue or cost center providing the product and/or service." )
3181        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/ex-revenue-center")
3182        protected CodeableConcept revenue;
3183
3184        /**
3185         * Code to identify the general type of benefits under which products and services are provided.
3186         */
3187        @Child(name = "category", type = {CodeableConcept.class}, order=7, min=0, max=1, modifier=false, summary=false)
3188        @Description(shortDefinition="Benefit classification", formalDefinition="Code to identify the general type of benefits under which products and services are provided." )
3189        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/ex-benefitcategory")
3190        protected CodeableConcept category;
3191
3192        /**
3193         * When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.
3194         */
3195        @Child(name = "productOrService", type = {CodeableConcept.class}, order=8, min=1, max=1, modifier=false, summary=false)
3196        @Description(shortDefinition="Billing, service, product, or drug code", formalDefinition="When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item." )
3197        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/service-uscls")
3198        protected CodeableConcept productOrService;
3199
3200        /**
3201         * Item typification or modifiers codes to convey additional context for the product or service.
3202         */
3203        @Child(name = "modifier", type = {CodeableConcept.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
3204        @Description(shortDefinition="Product or service billing modifiers", formalDefinition="Item typification or modifiers codes to convey additional context for the product or service." )
3205        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/claim-modifiers")
3206        protected List<CodeableConcept> modifier;
3207
3208        /**
3209         * Identifies the program under which this may be recovered.
3210         */
3211        @Child(name = "programCode", type = {CodeableConcept.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
3212        @Description(shortDefinition="Program the product or service is provided under", formalDefinition="Identifies the program under which this may be recovered." )
3213        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/ex-program-code")
3214        protected List<CodeableConcept> programCode;
3215
3216        /**
3217         * The date or dates when the service or product was supplied, performed or completed.
3218         */
3219        @Child(name = "serviced", type = {DateType.class, Period.class}, order=11, min=0, max=1, modifier=false, summary=false)
3220        @Description(shortDefinition="Date or dates of service or product delivery", formalDefinition="The date or dates when the service or product was supplied, performed or completed." )
3221        protected DataType serviced;
3222
3223        /**
3224         * Where the product or service was provided.
3225         */
3226        @Child(name = "location", type = {CodeableConcept.class, Address.class, Location.class}, order=12, min=0, max=1, modifier=false, summary=false)
3227        @Description(shortDefinition="Place of service or where product was supplied", formalDefinition="Where the product or service was provided." )
3228        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/service-place")
3229        protected DataType location;
3230
3231        /**
3232         * The number of repetitions of a service or product.
3233         */
3234        @Child(name = "quantity", type = {Quantity.class}, order=13, min=0, max=1, modifier=false, summary=false)
3235        @Description(shortDefinition="Count of products or services", formalDefinition="The number of repetitions of a service or product." )
3236        protected Quantity quantity;
3237
3238        /**
3239         * If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.
3240         */
3241        @Child(name = "unitPrice", type = {Money.class}, order=14, min=0, max=1, modifier=false, summary=false)
3242        @Description(shortDefinition="Fee, charge or cost per item", formalDefinition="If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group." )
3243        protected Money unitPrice;
3244
3245        /**
3246         * A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
3247         */
3248        @Child(name = "factor", type = {DecimalType.class}, order=15, min=0, max=1, modifier=false, summary=false)
3249        @Description(shortDefinition="Price scaling factor", formalDefinition="A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount." )
3250        protected DecimalType factor;
3251
3252        /**
3253         * The quantity times the unit price for an additional service or product or charge.
3254         */
3255        @Child(name = "net", type = {Money.class}, order=16, min=0, max=1, modifier=false, summary=false)
3256        @Description(shortDefinition="Total item cost", formalDefinition="The quantity times the unit price for an additional service or product or charge." )
3257        protected Money net;
3258
3259        /**
3260         * Unique Device Identifiers associated with this line item.
3261         */
3262        @Child(name = "udi", type = {Device.class}, order=17, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
3263        @Description(shortDefinition="Unique device identifier", formalDefinition="Unique Device Identifiers associated with this line item." )
3264        protected List<Reference> udi;
3265
3266        /**
3267         * Physical service site on the patient (limb, tooth, etc.).
3268         */
3269        @Child(name = "bodySite", type = {CodeableConcept.class}, order=18, min=0, max=1, modifier=false, summary=false)
3270        @Description(shortDefinition="Anatomical location", formalDefinition="Physical service site on the patient (limb, tooth, etc.)." )
3271        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/tooth")
3272        protected CodeableConcept bodySite;
3273
3274        /**
3275         * A region or surface of the bodySite, e.g. limb region or tooth surface(s).
3276         */
3277        @Child(name = "subSite", type = {CodeableConcept.class}, order=19, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
3278        @Description(shortDefinition="Anatomical sub-location", formalDefinition="A region or surface of the bodySite, e.g. limb region or tooth surface(s)." )
3279        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/surface")
3280        protected List<CodeableConcept> subSite;
3281
3282        /**
3283         * A billed item may include goods or services provided in multiple encounters.
3284         */
3285        @Child(name = "encounter", type = {Encounter.class}, order=20, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
3286        @Description(shortDefinition="Encounters related to this billed item", formalDefinition="A billed item may include goods or services provided in multiple encounters." )
3287        protected List<Reference> encounter;
3288
3289        /**
3290         * The numbers associated with notes below which apply to the adjudication of this item.
3291         */
3292        @Child(name = "noteNumber", type = {PositiveIntType.class}, order=21, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
3293        @Description(shortDefinition="Applicable note numbers", formalDefinition="The numbers associated with notes below which apply to the adjudication of this item." )
3294        protected List<PositiveIntType> noteNumber;
3295
3296        /**
3297         * If this item is a group then the values here are a summary of the adjudication of the detail items. If this item is a simple product or service then this is the result of the adjudication of this item.
3298         */
3299        @Child(name = "adjudication", type = {}, order=22, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
3300        @Description(shortDefinition="Adjudication details", formalDefinition="If this item is a group then the values here are a summary of the adjudication of the detail items. If this item is a simple product or service then this is the result of the adjudication of this item." )
3301        protected List<AdjudicationComponent> adjudication;
3302
3303        /**
3304         * Second-tier of goods and services.
3305         */
3306        @Child(name = "detail", type = {}, order=23, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
3307        @Description(shortDefinition="Additional items", formalDefinition="Second-tier of goods and services." )
3308        protected List<DetailComponent> detail;
3309
3310        private static final long serialVersionUID = -1350957145L;
3311
3312    /**
3313     * Constructor
3314     */
3315      public ItemComponent() {
3316        super();
3317      }
3318
3319    /**
3320     * Constructor
3321     */
3322      public ItemComponent(int sequence, CodeableConcept productOrService) {
3323        super();
3324        this.setSequence(sequence);
3325        this.setProductOrService(productOrService);
3326      }
3327
3328        /**
3329         * @return {@link #sequence} (A number to uniquely identify item entries.). This is the underlying object with id, value and extensions. The accessor "getSequence" gives direct access to the value
3330         */
3331        public PositiveIntType getSequenceElement() { 
3332          if (this.sequence == null)
3333            if (Configuration.errorOnAutoCreate())
3334              throw new Error("Attempt to auto-create ItemComponent.sequence");
3335            else if (Configuration.doAutoCreate())
3336              this.sequence = new PositiveIntType(); // bb
3337          return this.sequence;
3338        }
3339
3340        public boolean hasSequenceElement() { 
3341          return this.sequence != null && !this.sequence.isEmpty();
3342        }
3343
3344        public boolean hasSequence() { 
3345          return this.sequence != null && !this.sequence.isEmpty();
3346        }
3347
3348        /**
3349         * @param value {@link #sequence} (A number to uniquely identify item entries.). This is the underlying object with id, value and extensions. The accessor "getSequence" gives direct access to the value
3350         */
3351        public ItemComponent setSequenceElement(PositiveIntType value) { 
3352          this.sequence = value;
3353          return this;
3354        }
3355
3356        /**
3357         * @return A number to uniquely identify item entries.
3358         */
3359        public int getSequence() { 
3360          return this.sequence == null || this.sequence.isEmpty() ? 0 : this.sequence.getValue();
3361        }
3362
3363        /**
3364         * @param value A number to uniquely identify item entries.
3365         */
3366        public ItemComponent setSequence(int value) { 
3367            if (this.sequence == null)
3368              this.sequence = new PositiveIntType();
3369            this.sequence.setValue(value);
3370          return this;
3371        }
3372
3373        /**
3374         * @return {@link #careTeamSequence} (Care team members related to this service or product.)
3375         */
3376        public List<PositiveIntType> getCareTeamSequence() { 
3377          if (this.careTeamSequence == null)
3378            this.careTeamSequence = new ArrayList<PositiveIntType>();
3379          return this.careTeamSequence;
3380        }
3381
3382        /**
3383         * @return Returns a reference to <code>this</code> for easy method chaining
3384         */
3385        public ItemComponent setCareTeamSequence(List<PositiveIntType> theCareTeamSequence) { 
3386          this.careTeamSequence = theCareTeamSequence;
3387          return this;
3388        }
3389
3390        public boolean hasCareTeamSequence() { 
3391          if (this.careTeamSequence == null)
3392            return false;
3393          for (PositiveIntType item : this.careTeamSequence)
3394            if (!item.isEmpty())
3395              return true;
3396          return false;
3397        }
3398
3399        /**
3400         * @return {@link #careTeamSequence} (Care team members related to this service or product.)
3401         */
3402        public PositiveIntType addCareTeamSequenceElement() {//2 
3403          PositiveIntType t = new PositiveIntType();
3404          if (this.careTeamSequence == null)
3405            this.careTeamSequence = new ArrayList<PositiveIntType>();
3406          this.careTeamSequence.add(t);
3407          return t;
3408        }
3409
3410        /**
3411         * @param value {@link #careTeamSequence} (Care team members related to this service or product.)
3412         */
3413        public ItemComponent addCareTeamSequence(int value) { //1
3414          PositiveIntType t = new PositiveIntType();
3415          t.setValue(value);
3416          if (this.careTeamSequence == null)
3417            this.careTeamSequence = new ArrayList<PositiveIntType>();
3418          this.careTeamSequence.add(t);
3419          return this;
3420        }
3421
3422        /**
3423         * @param value {@link #careTeamSequence} (Care team members related to this service or product.)
3424         */
3425        public boolean hasCareTeamSequence(int value) { 
3426          if (this.careTeamSequence == null)
3427            return false;
3428          for (PositiveIntType v : this.careTeamSequence)
3429            if (v.getValue().equals(value)) // positiveInt
3430              return true;
3431          return false;
3432        }
3433
3434        /**
3435         * @return {@link #diagnosisSequence} (Diagnoses applicable for this service or product.)
3436         */
3437        public List<PositiveIntType> getDiagnosisSequence() { 
3438          if (this.diagnosisSequence == null)
3439            this.diagnosisSequence = new ArrayList<PositiveIntType>();
3440          return this.diagnosisSequence;
3441        }
3442
3443        /**
3444         * @return Returns a reference to <code>this</code> for easy method chaining
3445         */
3446        public ItemComponent setDiagnosisSequence(List<PositiveIntType> theDiagnosisSequence) { 
3447          this.diagnosisSequence = theDiagnosisSequence;
3448          return this;
3449        }
3450
3451        public boolean hasDiagnosisSequence() { 
3452          if (this.diagnosisSequence == null)
3453            return false;
3454          for (PositiveIntType item : this.diagnosisSequence)
3455            if (!item.isEmpty())
3456              return true;
3457          return false;
3458        }
3459
3460        /**
3461         * @return {@link #diagnosisSequence} (Diagnoses applicable for this service or product.)
3462         */
3463        public PositiveIntType addDiagnosisSequenceElement() {//2 
3464          PositiveIntType t = new PositiveIntType();
3465          if (this.diagnosisSequence == null)
3466            this.diagnosisSequence = new ArrayList<PositiveIntType>();
3467          this.diagnosisSequence.add(t);
3468          return t;
3469        }
3470
3471        /**
3472         * @param value {@link #diagnosisSequence} (Diagnoses applicable for this service or product.)
3473         */
3474        public ItemComponent addDiagnosisSequence(int value) { //1
3475          PositiveIntType t = new PositiveIntType();
3476          t.setValue(value);
3477          if (this.diagnosisSequence == null)
3478            this.diagnosisSequence = new ArrayList<PositiveIntType>();
3479          this.diagnosisSequence.add(t);
3480          return this;
3481        }
3482
3483        /**
3484         * @param value {@link #diagnosisSequence} (Diagnoses applicable for this service or product.)
3485         */
3486        public boolean hasDiagnosisSequence(int value) { 
3487          if (this.diagnosisSequence == null)
3488            return false;
3489          for (PositiveIntType v : this.diagnosisSequence)
3490            if (v.getValue().equals(value)) // positiveInt
3491              return true;
3492          return false;
3493        }
3494
3495        /**
3496         * @return {@link #procedureSequence} (Procedures applicable for this service or product.)
3497         */
3498        public List<PositiveIntType> getProcedureSequence() { 
3499          if (this.procedureSequence == null)
3500            this.procedureSequence = new ArrayList<PositiveIntType>();
3501          return this.procedureSequence;
3502        }
3503
3504        /**
3505         * @return Returns a reference to <code>this</code> for easy method chaining
3506         */
3507        public ItemComponent setProcedureSequence(List<PositiveIntType> theProcedureSequence) { 
3508          this.procedureSequence = theProcedureSequence;
3509          return this;
3510        }
3511
3512        public boolean hasProcedureSequence() { 
3513          if (this.procedureSequence == null)
3514            return false;
3515          for (PositiveIntType item : this.procedureSequence)
3516            if (!item.isEmpty())
3517              return true;
3518          return false;
3519        }
3520
3521        /**
3522         * @return {@link #procedureSequence} (Procedures applicable for this service or product.)
3523         */
3524        public PositiveIntType addProcedureSequenceElement() {//2 
3525          PositiveIntType t = new PositiveIntType();
3526          if (this.procedureSequence == null)
3527            this.procedureSequence = new ArrayList<PositiveIntType>();
3528          this.procedureSequence.add(t);
3529          return t;
3530        }
3531
3532        /**
3533         * @param value {@link #procedureSequence} (Procedures applicable for this service or product.)
3534         */
3535        public ItemComponent addProcedureSequence(int value) { //1
3536          PositiveIntType t = new PositiveIntType();
3537          t.setValue(value);
3538          if (this.procedureSequence == null)
3539            this.procedureSequence = new ArrayList<PositiveIntType>();
3540          this.procedureSequence.add(t);
3541          return this;
3542        }
3543
3544        /**
3545         * @param value {@link #procedureSequence} (Procedures applicable for this service or product.)
3546         */
3547        public boolean hasProcedureSequence(int value) { 
3548          if (this.procedureSequence == null)
3549            return false;
3550          for (PositiveIntType v : this.procedureSequence)
3551            if (v.getValue().equals(value)) // positiveInt
3552              return true;
3553          return false;
3554        }
3555
3556        /**
3557         * @return {@link #informationSequence} (Exceptions, special conditions and supporting information applicable for this service or product.)
3558         */
3559        public List<PositiveIntType> getInformationSequence() { 
3560          if (this.informationSequence == null)
3561            this.informationSequence = new ArrayList<PositiveIntType>();
3562          return this.informationSequence;
3563        }
3564
3565        /**
3566         * @return Returns a reference to <code>this</code> for easy method chaining
3567         */
3568        public ItemComponent setInformationSequence(List<PositiveIntType> theInformationSequence) { 
3569          this.informationSequence = theInformationSequence;
3570          return this;
3571        }
3572
3573        public boolean hasInformationSequence() { 
3574          if (this.informationSequence == null)
3575            return false;
3576          for (PositiveIntType item : this.informationSequence)
3577            if (!item.isEmpty())
3578              return true;
3579          return false;
3580        }
3581
3582        /**
3583         * @return {@link #informationSequence} (Exceptions, special conditions and supporting information applicable for this service or product.)
3584         */
3585        public PositiveIntType addInformationSequenceElement() {//2 
3586          PositiveIntType t = new PositiveIntType();
3587          if (this.informationSequence == null)
3588            this.informationSequence = new ArrayList<PositiveIntType>();
3589          this.informationSequence.add(t);
3590          return t;
3591        }
3592
3593        /**
3594         * @param value {@link #informationSequence} (Exceptions, special conditions and supporting information applicable for this service or product.)
3595         */
3596        public ItemComponent addInformationSequence(int value) { //1
3597          PositiveIntType t = new PositiveIntType();
3598          t.setValue(value);
3599          if (this.informationSequence == null)
3600            this.informationSequence = new ArrayList<PositiveIntType>();
3601          this.informationSequence.add(t);
3602          return this;
3603        }
3604
3605        /**
3606         * @param value {@link #informationSequence} (Exceptions, special conditions and supporting information applicable for this service or product.)
3607         */
3608        public boolean hasInformationSequence(int value) { 
3609          if (this.informationSequence == null)
3610            return false;
3611          for (PositiveIntType v : this.informationSequence)
3612            if (v.getValue().equals(value)) // positiveInt
3613              return true;
3614          return false;
3615        }
3616
3617        /**
3618         * @return {@link #revenue} (The type of revenue or cost center providing the product and/or service.)
3619         */
3620        public CodeableConcept getRevenue() { 
3621          if (this.revenue == null)
3622            if (Configuration.errorOnAutoCreate())
3623              throw new Error("Attempt to auto-create ItemComponent.revenue");
3624            else if (Configuration.doAutoCreate())
3625              this.revenue = new CodeableConcept(); // cc
3626          return this.revenue;
3627        }
3628
3629        public boolean hasRevenue() { 
3630          return this.revenue != null && !this.revenue.isEmpty();
3631        }
3632
3633        /**
3634         * @param value {@link #revenue} (The type of revenue or cost center providing the product and/or service.)
3635         */
3636        public ItemComponent setRevenue(CodeableConcept value) { 
3637          this.revenue = value;
3638          return this;
3639        }
3640
3641        /**
3642         * @return {@link #category} (Code to identify the general type of benefits under which products and services are provided.)
3643         */
3644        public CodeableConcept getCategory() { 
3645          if (this.category == null)
3646            if (Configuration.errorOnAutoCreate())
3647              throw new Error("Attempt to auto-create ItemComponent.category");
3648            else if (Configuration.doAutoCreate())
3649              this.category = new CodeableConcept(); // cc
3650          return this.category;
3651        }
3652
3653        public boolean hasCategory() { 
3654          return this.category != null && !this.category.isEmpty();
3655        }
3656
3657        /**
3658         * @param value {@link #category} (Code to identify the general type of benefits under which products and services are provided.)
3659         */
3660        public ItemComponent setCategory(CodeableConcept value) { 
3661          this.category = value;
3662          return this;
3663        }
3664
3665        /**
3666         * @return {@link #productOrService} (When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.)
3667         */
3668        public CodeableConcept getProductOrService() { 
3669          if (this.productOrService == null)
3670            if (Configuration.errorOnAutoCreate())
3671              throw new Error("Attempt to auto-create ItemComponent.productOrService");
3672            else if (Configuration.doAutoCreate())
3673              this.productOrService = new CodeableConcept(); // cc
3674          return this.productOrService;
3675        }
3676
3677        public boolean hasProductOrService() { 
3678          return this.productOrService != null && !this.productOrService.isEmpty();
3679        }
3680
3681        /**
3682         * @param value {@link #productOrService} (When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.)
3683         */
3684        public ItemComponent setProductOrService(CodeableConcept value) { 
3685          this.productOrService = value;
3686          return this;
3687        }
3688
3689        /**
3690         * @return {@link #modifier} (Item typification or modifiers codes to convey additional context for the product or service.)
3691         */
3692        public List<CodeableConcept> getModifier() { 
3693          if (this.modifier == null)
3694            this.modifier = new ArrayList<CodeableConcept>();
3695          return this.modifier;
3696        }
3697
3698        /**
3699         * @return Returns a reference to <code>this</code> for easy method chaining
3700         */
3701        public ItemComponent setModifier(List<CodeableConcept> theModifier) { 
3702          this.modifier = theModifier;
3703          return this;
3704        }
3705
3706        public boolean hasModifier() { 
3707          if (this.modifier == null)
3708            return false;
3709          for (CodeableConcept item : this.modifier)
3710            if (!item.isEmpty())
3711              return true;
3712          return false;
3713        }
3714
3715        public CodeableConcept addModifier() { //3
3716          CodeableConcept t = new CodeableConcept();
3717          if (this.modifier == null)
3718            this.modifier = new ArrayList<CodeableConcept>();
3719          this.modifier.add(t);
3720          return t;
3721        }
3722
3723        public ItemComponent addModifier(CodeableConcept t) { //3
3724          if (t == null)
3725            return this;
3726          if (this.modifier == null)
3727            this.modifier = new ArrayList<CodeableConcept>();
3728          this.modifier.add(t);
3729          return this;
3730        }
3731
3732        /**
3733         * @return The first repetition of repeating field {@link #modifier}, creating it if it does not already exist {3}
3734         */
3735        public CodeableConcept getModifierFirstRep() { 
3736          if (getModifier().isEmpty()) {
3737            addModifier();
3738          }
3739          return getModifier().get(0);
3740        }
3741
3742        /**
3743         * @return {@link #programCode} (Identifies the program under which this may be recovered.)
3744         */
3745        public List<CodeableConcept> getProgramCode() { 
3746          if (this.programCode == null)
3747            this.programCode = new ArrayList<CodeableConcept>();
3748          return this.programCode;
3749        }
3750
3751        /**
3752         * @return Returns a reference to <code>this</code> for easy method chaining
3753         */
3754        public ItemComponent setProgramCode(List<CodeableConcept> theProgramCode) { 
3755          this.programCode = theProgramCode;
3756          return this;
3757        }
3758
3759        public boolean hasProgramCode() { 
3760          if (this.programCode == null)
3761            return false;
3762          for (CodeableConcept item : this.programCode)
3763            if (!item.isEmpty())
3764              return true;
3765          return false;
3766        }
3767
3768        public CodeableConcept addProgramCode() { //3
3769          CodeableConcept t = new CodeableConcept();
3770          if (this.programCode == null)
3771            this.programCode = new ArrayList<CodeableConcept>();
3772          this.programCode.add(t);
3773          return t;
3774        }
3775
3776        public ItemComponent addProgramCode(CodeableConcept t) { //3
3777          if (t == null)
3778            return this;
3779          if (this.programCode == null)
3780            this.programCode = new ArrayList<CodeableConcept>();
3781          this.programCode.add(t);
3782          return this;
3783        }
3784
3785        /**
3786         * @return The first repetition of repeating field {@link #programCode}, creating it if it does not already exist {3}
3787         */
3788        public CodeableConcept getProgramCodeFirstRep() { 
3789          if (getProgramCode().isEmpty()) {
3790            addProgramCode();
3791          }
3792          return getProgramCode().get(0);
3793        }
3794
3795        /**
3796         * @return {@link #serviced} (The date or dates when the service or product was supplied, performed or completed.)
3797         */
3798        public DataType getServiced() { 
3799          return this.serviced;
3800        }
3801
3802        /**
3803         * @return {@link #serviced} (The date or dates when the service or product was supplied, performed or completed.)
3804         */
3805        public DateType getServicedDateType() throws FHIRException { 
3806          if (this.serviced == null)
3807            this.serviced = new DateType();
3808          if (!(this.serviced instanceof DateType))
3809            throw new FHIRException("Type mismatch: the type DateType was expected, but "+this.serviced.getClass().getName()+" was encountered");
3810          return (DateType) this.serviced;
3811        }
3812
3813        public boolean hasServicedDateType() { 
3814          return this != null && this.serviced instanceof DateType;
3815        }
3816
3817        /**
3818         * @return {@link #serviced} (The date or dates when the service or product was supplied, performed or completed.)
3819         */
3820        public Period getServicedPeriod() throws FHIRException { 
3821          if (this.serviced == null)
3822            this.serviced = new Period();
3823          if (!(this.serviced instanceof Period))
3824            throw new FHIRException("Type mismatch: the type Period was expected, but "+this.serviced.getClass().getName()+" was encountered");
3825          return (Period) this.serviced;
3826        }
3827
3828        public boolean hasServicedPeriod() { 
3829          return this != null && this.serviced instanceof Period;
3830        }
3831
3832        public boolean hasServiced() { 
3833          return this.serviced != null && !this.serviced.isEmpty();
3834        }
3835
3836        /**
3837         * @param value {@link #serviced} (The date or dates when the service or product was supplied, performed or completed.)
3838         */
3839        public ItemComponent setServiced(DataType value) { 
3840          if (value != null && !(value instanceof DateType || value instanceof Period))
3841            throw new Error("Not the right type for ExplanationOfBenefit.item.serviced[x]: "+value.fhirType());
3842          this.serviced = value;
3843          return this;
3844        }
3845
3846        /**
3847         * @return {@link #location} (Where the product or service was provided.)
3848         */
3849        public DataType getLocation() { 
3850          return this.location;
3851        }
3852
3853        /**
3854         * @return {@link #location} (Where the product or service was provided.)
3855         */
3856        public CodeableConcept getLocationCodeableConcept() throws FHIRException { 
3857          if (this.location == null)
3858            this.location = new CodeableConcept();
3859          if (!(this.location instanceof CodeableConcept))
3860            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.location.getClass().getName()+" was encountered");
3861          return (CodeableConcept) this.location;
3862        }
3863
3864        public boolean hasLocationCodeableConcept() { 
3865          return this != null && this.location instanceof CodeableConcept;
3866        }
3867
3868        /**
3869         * @return {@link #location} (Where the product or service was provided.)
3870         */
3871        public Address getLocationAddress() throws FHIRException { 
3872          if (this.location == null)
3873            this.location = new Address();
3874          if (!(this.location instanceof Address))
3875            throw new FHIRException("Type mismatch: the type Address was expected, but "+this.location.getClass().getName()+" was encountered");
3876          return (Address) this.location;
3877        }
3878
3879        public boolean hasLocationAddress() { 
3880          return this != null && this.location instanceof Address;
3881        }
3882
3883        /**
3884         * @return {@link #location} (Where the product or service was provided.)
3885         */
3886        public Reference getLocationReference() throws FHIRException { 
3887          if (this.location == null)
3888            this.location = new Reference();
3889          if (!(this.location instanceof Reference))
3890            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.location.getClass().getName()+" was encountered");
3891          return (Reference) this.location;
3892        }
3893
3894        public boolean hasLocationReference() { 
3895          return this != null && this.location instanceof Reference;
3896        }
3897
3898        public boolean hasLocation() { 
3899          return this.location != null && !this.location.isEmpty();
3900        }
3901
3902        /**
3903         * @param value {@link #location} (Where the product or service was provided.)
3904         */
3905        public ItemComponent setLocation(DataType value) { 
3906          if (value != null && !(value instanceof CodeableConcept || value instanceof Address || value instanceof Reference))
3907            throw new Error("Not the right type for ExplanationOfBenefit.item.location[x]: "+value.fhirType());
3908          this.location = value;
3909          return this;
3910        }
3911
3912        /**
3913         * @return {@link #quantity} (The number of repetitions of a service or product.)
3914         */
3915        public Quantity getQuantity() { 
3916          if (this.quantity == null)
3917            if (Configuration.errorOnAutoCreate())
3918              throw new Error("Attempt to auto-create ItemComponent.quantity");
3919            else if (Configuration.doAutoCreate())
3920              this.quantity = new Quantity(); // cc
3921          return this.quantity;
3922        }
3923
3924        public boolean hasQuantity() { 
3925          return this.quantity != null && !this.quantity.isEmpty();
3926        }
3927
3928        /**
3929         * @param value {@link #quantity} (The number of repetitions of a service or product.)
3930         */
3931        public ItemComponent setQuantity(Quantity value) { 
3932          this.quantity = value;
3933          return this;
3934        }
3935
3936        /**
3937         * @return {@link #unitPrice} (If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.)
3938         */
3939        public Money getUnitPrice() { 
3940          if (this.unitPrice == null)
3941            if (Configuration.errorOnAutoCreate())
3942              throw new Error("Attempt to auto-create ItemComponent.unitPrice");
3943            else if (Configuration.doAutoCreate())
3944              this.unitPrice = new Money(); // cc
3945          return this.unitPrice;
3946        }
3947
3948        public boolean hasUnitPrice() { 
3949          return this.unitPrice != null && !this.unitPrice.isEmpty();
3950        }
3951
3952        /**
3953         * @param value {@link #unitPrice} (If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.)
3954         */
3955        public ItemComponent setUnitPrice(Money value) { 
3956          this.unitPrice = value;
3957          return this;
3958        }
3959
3960        /**
3961         * @return {@link #factor} (A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.). This is the underlying object with id, value and extensions. The accessor "getFactor" gives direct access to the value
3962         */
3963        public DecimalType getFactorElement() { 
3964          if (this.factor == null)
3965            if (Configuration.errorOnAutoCreate())
3966              throw new Error("Attempt to auto-create ItemComponent.factor");
3967            else if (Configuration.doAutoCreate())
3968              this.factor = new DecimalType(); // bb
3969          return this.factor;
3970        }
3971
3972        public boolean hasFactorElement() { 
3973          return this.factor != null && !this.factor.isEmpty();
3974        }
3975
3976        public boolean hasFactor() { 
3977          return this.factor != null && !this.factor.isEmpty();
3978        }
3979
3980        /**
3981         * @param value {@link #factor} (A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.). This is the underlying object with id, value and extensions. The accessor "getFactor" gives direct access to the value
3982         */
3983        public ItemComponent setFactorElement(DecimalType value) { 
3984          this.factor = value;
3985          return this;
3986        }
3987
3988        /**
3989         * @return A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
3990         */
3991        public BigDecimal getFactor() { 
3992          return this.factor == null ? null : this.factor.getValue();
3993        }
3994
3995        /**
3996         * @param value A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
3997         */
3998        public ItemComponent setFactor(BigDecimal value) { 
3999          if (value == null)
4000            this.factor = null;
4001          else {
4002            if (this.factor == null)
4003              this.factor = new DecimalType();
4004            this.factor.setValue(value);
4005          }
4006          return this;
4007        }
4008
4009        /**
4010         * @param value A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
4011         */
4012        public ItemComponent setFactor(long value) { 
4013              this.factor = new DecimalType();
4014            this.factor.setValue(value);
4015          return this;
4016        }
4017
4018        /**
4019         * @param value A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
4020         */
4021        public ItemComponent setFactor(double value) { 
4022              this.factor = new DecimalType();
4023            this.factor.setValue(value);
4024          return this;
4025        }
4026
4027        /**
4028         * @return {@link #net} (The quantity times the unit price for an additional service or product or charge.)
4029         */
4030        public Money getNet() { 
4031          if (this.net == null)
4032            if (Configuration.errorOnAutoCreate())
4033              throw new Error("Attempt to auto-create ItemComponent.net");
4034            else if (Configuration.doAutoCreate())
4035              this.net = new Money(); // cc
4036          return this.net;
4037        }
4038
4039        public boolean hasNet() { 
4040          return this.net != null && !this.net.isEmpty();
4041        }
4042
4043        /**
4044         * @param value {@link #net} (The quantity times the unit price for an additional service or product or charge.)
4045         */
4046        public ItemComponent setNet(Money value) { 
4047          this.net = value;
4048          return this;
4049        }
4050
4051        /**
4052         * @return {@link #udi} (Unique Device Identifiers associated with this line item.)
4053         */
4054        public List<Reference> getUdi() { 
4055          if (this.udi == null)
4056            this.udi = new ArrayList<Reference>();
4057          return this.udi;
4058        }
4059
4060        /**
4061         * @return Returns a reference to <code>this</code> for easy method chaining
4062         */
4063        public ItemComponent setUdi(List<Reference> theUdi) { 
4064          this.udi = theUdi;
4065          return this;
4066        }
4067
4068        public boolean hasUdi() { 
4069          if (this.udi == null)
4070            return false;
4071          for (Reference item : this.udi)
4072            if (!item.isEmpty())
4073              return true;
4074          return false;
4075        }
4076
4077        public Reference addUdi() { //3
4078          Reference t = new Reference();
4079          if (this.udi == null)
4080            this.udi = new ArrayList<Reference>();
4081          this.udi.add(t);
4082          return t;
4083        }
4084
4085        public ItemComponent addUdi(Reference t) { //3
4086          if (t == null)
4087            return this;
4088          if (this.udi == null)
4089            this.udi = new ArrayList<Reference>();
4090          this.udi.add(t);
4091          return this;
4092        }
4093
4094        /**
4095         * @return The first repetition of repeating field {@link #udi}, creating it if it does not already exist {3}
4096         */
4097        public Reference getUdiFirstRep() { 
4098          if (getUdi().isEmpty()) {
4099            addUdi();
4100          }
4101          return getUdi().get(0);
4102        }
4103
4104        /**
4105         * @return {@link #bodySite} (Physical service site on the patient (limb, tooth, etc.).)
4106         */
4107        public CodeableConcept getBodySite() { 
4108          if (this.bodySite == null)
4109            if (Configuration.errorOnAutoCreate())
4110              throw new Error("Attempt to auto-create ItemComponent.bodySite");
4111            else if (Configuration.doAutoCreate())
4112              this.bodySite = new CodeableConcept(); // cc
4113          return this.bodySite;
4114        }
4115
4116        public boolean hasBodySite() { 
4117          return this.bodySite != null && !this.bodySite.isEmpty();
4118        }
4119
4120        /**
4121         * @param value {@link #bodySite} (Physical service site on the patient (limb, tooth, etc.).)
4122         */
4123        public ItemComponent setBodySite(CodeableConcept value) { 
4124          this.bodySite = value;
4125          return this;
4126        }
4127
4128        /**
4129         * @return {@link #subSite} (A region or surface of the bodySite, e.g. limb region or tooth surface(s).)
4130         */
4131        public List<CodeableConcept> getSubSite() { 
4132          if (this.subSite == null)
4133            this.subSite = new ArrayList<CodeableConcept>();
4134          return this.subSite;
4135        }
4136
4137        /**
4138         * @return Returns a reference to <code>this</code> for easy method chaining
4139         */
4140        public ItemComponent setSubSite(List<CodeableConcept> theSubSite) { 
4141          this.subSite = theSubSite;
4142          return this;
4143        }
4144
4145        public boolean hasSubSite() { 
4146          if (this.subSite == null)
4147            return false;
4148          for (CodeableConcept item : this.subSite)
4149            if (!item.isEmpty())
4150              return true;
4151          return false;
4152        }
4153
4154        public CodeableConcept addSubSite() { //3
4155          CodeableConcept t = new CodeableConcept();
4156          if (this.subSite == null)
4157            this.subSite = new ArrayList<CodeableConcept>();
4158          this.subSite.add(t);
4159          return t;
4160        }
4161
4162        public ItemComponent addSubSite(CodeableConcept t) { //3
4163          if (t == null)
4164            return this;
4165          if (this.subSite == null)
4166            this.subSite = new ArrayList<CodeableConcept>();
4167          this.subSite.add(t);
4168          return this;
4169        }
4170
4171        /**
4172         * @return The first repetition of repeating field {@link #subSite}, creating it if it does not already exist {3}
4173         */
4174        public CodeableConcept getSubSiteFirstRep() { 
4175          if (getSubSite().isEmpty()) {
4176            addSubSite();
4177          }
4178          return getSubSite().get(0);
4179        }
4180
4181        /**
4182         * @return {@link #encounter} (A billed item may include goods or services provided in multiple encounters.)
4183         */
4184        public List<Reference> getEncounter() { 
4185          if (this.encounter == null)
4186            this.encounter = new ArrayList<Reference>();
4187          return this.encounter;
4188        }
4189
4190        /**
4191         * @return Returns a reference to <code>this</code> for easy method chaining
4192         */
4193        public ItemComponent setEncounter(List<Reference> theEncounter) { 
4194          this.encounter = theEncounter;
4195          return this;
4196        }
4197
4198        public boolean hasEncounter() { 
4199          if (this.encounter == null)
4200            return false;
4201          for (Reference item : this.encounter)
4202            if (!item.isEmpty())
4203              return true;
4204          return false;
4205        }
4206
4207        public Reference addEncounter() { //3
4208          Reference t = new Reference();
4209          if (this.encounter == null)
4210            this.encounter = new ArrayList<Reference>();
4211          this.encounter.add(t);
4212          return t;
4213        }
4214
4215        public ItemComponent addEncounter(Reference t) { //3
4216          if (t == null)
4217            return this;
4218          if (this.encounter == null)
4219            this.encounter = new ArrayList<Reference>();
4220          this.encounter.add(t);
4221          return this;
4222        }
4223
4224        /**
4225         * @return The first repetition of repeating field {@link #encounter}, creating it if it does not already exist {3}
4226         */
4227        public Reference getEncounterFirstRep() { 
4228          if (getEncounter().isEmpty()) {
4229            addEncounter();
4230          }
4231          return getEncounter().get(0);
4232        }
4233
4234        /**
4235         * @return {@link #noteNumber} (The numbers associated with notes below which apply to the adjudication of this item.)
4236         */
4237        public List<PositiveIntType> getNoteNumber() { 
4238          if (this.noteNumber == null)
4239            this.noteNumber = new ArrayList<PositiveIntType>();
4240          return this.noteNumber;
4241        }
4242
4243        /**
4244         * @return Returns a reference to <code>this</code> for easy method chaining
4245         */
4246        public ItemComponent setNoteNumber(List<PositiveIntType> theNoteNumber) { 
4247          this.noteNumber = theNoteNumber;
4248          return this;
4249        }
4250
4251        public boolean hasNoteNumber() { 
4252          if (this.noteNumber == null)
4253            return false;
4254          for (PositiveIntType item : this.noteNumber)
4255            if (!item.isEmpty())
4256              return true;
4257          return false;
4258        }
4259
4260        /**
4261         * @return {@link #noteNumber} (The numbers associated with notes below which apply to the adjudication of this item.)
4262         */
4263        public PositiveIntType addNoteNumberElement() {//2 
4264          PositiveIntType t = new PositiveIntType();
4265          if (this.noteNumber == null)
4266            this.noteNumber = new ArrayList<PositiveIntType>();
4267          this.noteNumber.add(t);
4268          return t;
4269        }
4270
4271        /**
4272         * @param value {@link #noteNumber} (The numbers associated with notes below which apply to the adjudication of this item.)
4273         */
4274        public ItemComponent addNoteNumber(int value) { //1
4275          PositiveIntType t = new PositiveIntType();
4276          t.setValue(value);
4277          if (this.noteNumber == null)
4278            this.noteNumber = new ArrayList<PositiveIntType>();
4279          this.noteNumber.add(t);
4280          return this;
4281        }
4282
4283        /**
4284         * @param value {@link #noteNumber} (The numbers associated with notes below which apply to the adjudication of this item.)
4285         */
4286        public boolean hasNoteNumber(int value) { 
4287          if (this.noteNumber == null)
4288            return false;
4289          for (PositiveIntType v : this.noteNumber)
4290            if (v.getValue().equals(value)) // positiveInt
4291              return true;
4292          return false;
4293        }
4294
4295        /**
4296         * @return {@link #adjudication} (If this item is a group then the values here are a summary of the adjudication of the detail items. If this item is a simple product or service then this is the result of the adjudication of this item.)
4297         */
4298        public List<AdjudicationComponent> getAdjudication() { 
4299          if (this.adjudication == null)
4300            this.adjudication = new ArrayList<AdjudicationComponent>();
4301          return this.adjudication;
4302        }
4303
4304        /**
4305         * @return Returns a reference to <code>this</code> for easy method chaining
4306         */
4307        public ItemComponent setAdjudication(List<AdjudicationComponent> theAdjudication) { 
4308          this.adjudication = theAdjudication;
4309          return this;
4310        }
4311
4312        public boolean hasAdjudication() { 
4313          if (this.adjudication == null)
4314            return false;
4315          for (AdjudicationComponent item : this.adjudication)
4316            if (!item.isEmpty())
4317              return true;
4318          return false;
4319        }
4320
4321        public AdjudicationComponent addAdjudication() { //3
4322          AdjudicationComponent t = new AdjudicationComponent();
4323          if (this.adjudication == null)
4324            this.adjudication = new ArrayList<AdjudicationComponent>();
4325          this.adjudication.add(t);
4326          return t;
4327        }
4328
4329        public ItemComponent addAdjudication(AdjudicationComponent t) { //3
4330          if (t == null)
4331            return this;
4332          if (this.adjudication == null)
4333            this.adjudication = new ArrayList<AdjudicationComponent>();
4334          this.adjudication.add(t);
4335          return this;
4336        }
4337
4338        /**
4339         * @return The first repetition of repeating field {@link #adjudication}, creating it if it does not already exist {3}
4340         */
4341        public AdjudicationComponent getAdjudicationFirstRep() { 
4342          if (getAdjudication().isEmpty()) {
4343            addAdjudication();
4344          }
4345          return getAdjudication().get(0);
4346        }
4347
4348        /**
4349         * @return {@link #detail} (Second-tier of goods and services.)
4350         */
4351        public List<DetailComponent> getDetail() { 
4352          if (this.detail == null)
4353            this.detail = new ArrayList<DetailComponent>();
4354          return this.detail;
4355        }
4356
4357        /**
4358         * @return Returns a reference to <code>this</code> for easy method chaining
4359         */
4360        public ItemComponent setDetail(List<DetailComponent> theDetail) { 
4361          this.detail = theDetail;
4362          return this;
4363        }
4364
4365        public boolean hasDetail() { 
4366          if (this.detail == null)
4367            return false;
4368          for (DetailComponent item : this.detail)
4369            if (!item.isEmpty())
4370              return true;
4371          return false;
4372        }
4373
4374        public DetailComponent addDetail() { //3
4375          DetailComponent t = new DetailComponent();
4376          if (this.detail == null)
4377            this.detail = new ArrayList<DetailComponent>();
4378          this.detail.add(t);
4379          return t;
4380        }
4381
4382        public ItemComponent addDetail(DetailComponent t) { //3
4383          if (t == null)
4384            return this;
4385          if (this.detail == null)
4386            this.detail = new ArrayList<DetailComponent>();
4387          this.detail.add(t);
4388          return this;
4389        }
4390
4391        /**
4392         * @return The first repetition of repeating field {@link #detail}, creating it if it does not already exist {3}
4393         */
4394        public DetailComponent getDetailFirstRep() { 
4395          if (getDetail().isEmpty()) {
4396            addDetail();
4397          }
4398          return getDetail().get(0);
4399        }
4400
4401        protected void listChildren(List<Property> children) {
4402          super.listChildren(children);
4403          children.add(new Property("sequence", "positiveInt", "A number to uniquely identify item entries.", 0, 1, sequence));
4404          children.add(new Property("careTeamSequence", "positiveInt", "Care team members related to this service or product.", 0, java.lang.Integer.MAX_VALUE, careTeamSequence));
4405          children.add(new Property("diagnosisSequence", "positiveInt", "Diagnoses applicable for this service or product.", 0, java.lang.Integer.MAX_VALUE, diagnosisSequence));
4406          children.add(new Property("procedureSequence", "positiveInt", "Procedures applicable for this service or product.", 0, java.lang.Integer.MAX_VALUE, procedureSequence));
4407          children.add(new Property("informationSequence", "positiveInt", "Exceptions, special conditions and supporting information applicable for this service or product.", 0, java.lang.Integer.MAX_VALUE, informationSequence));
4408          children.add(new Property("revenue", "CodeableConcept", "The type of revenue or cost center providing the product and/or service.", 0, 1, revenue));
4409          children.add(new Property("category", "CodeableConcept", "Code to identify the general type of benefits under which products and services are provided.", 0, 1, category));
4410          children.add(new Property("productOrService", "CodeableConcept", "When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.", 0, 1, productOrService));
4411          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));
4412          children.add(new Property("programCode", "CodeableConcept", "Identifies the program under which this may be recovered.", 0, java.lang.Integer.MAX_VALUE, programCode));
4413          children.add(new Property("serviced[x]", "date|Period", "The date or dates when the service or product was supplied, performed or completed.", 0, 1, serviced));
4414          children.add(new Property("location[x]", "CodeableConcept|Address|Reference(Location)", "Where the product or service was provided.", 0, 1, location));
4415          children.add(new Property("quantity", "Quantity", "The number of repetitions of a service or product.", 0, 1, quantity));
4416          children.add(new Property("unitPrice", "Money", "If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.", 0, 1, unitPrice));
4417          children.add(new Property("factor", "decimal", "A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.", 0, 1, factor));
4418          children.add(new Property("net", "Money", "The quantity times the unit price for an additional service or product or charge.", 0, 1, net));
4419          children.add(new Property("udi", "Reference(Device)", "Unique Device Identifiers associated with this line item.", 0, java.lang.Integer.MAX_VALUE, udi));
4420          children.add(new Property("bodySite", "CodeableConcept", "Physical service site on the patient (limb, tooth, etc.).", 0, 1, bodySite));
4421          children.add(new Property("subSite", "CodeableConcept", "A region or surface of the bodySite, e.g. limb region or tooth surface(s).", 0, java.lang.Integer.MAX_VALUE, subSite));
4422          children.add(new Property("encounter", "Reference(Encounter)", "A billed item may include goods or services provided in multiple encounters.", 0, java.lang.Integer.MAX_VALUE, encounter));
4423          children.add(new Property("noteNumber", "positiveInt", "The numbers associated with notes below which apply to the adjudication of this item.", 0, java.lang.Integer.MAX_VALUE, noteNumber));
4424          children.add(new Property("adjudication", "", "If this item is a group then the values here are a summary of the adjudication of the detail items. If this item is a simple product or service then this is the result of the adjudication of this item.", 0, java.lang.Integer.MAX_VALUE, adjudication));
4425          children.add(new Property("detail", "", "Second-tier of goods and services.", 0, java.lang.Integer.MAX_VALUE, detail));
4426        }
4427
4428        @Override
4429        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
4430          switch (_hash) {
4431          case 1349547969: /*sequence*/  return new Property("sequence", "positiveInt", "A number to uniquely identify item entries.", 0, 1, sequence);
4432          case 1070083823: /*careTeamSequence*/  return new Property("careTeamSequence", "positiveInt", "Care team members related to this service or product.", 0, java.lang.Integer.MAX_VALUE, careTeamSequence);
4433          case -909769262: /*diagnosisSequence*/  return new Property("diagnosisSequence", "positiveInt", "Diagnoses applicable for this service or product.", 0, java.lang.Integer.MAX_VALUE, diagnosisSequence);
4434          case -808920140: /*procedureSequence*/  return new Property("procedureSequence", "positiveInt", "Procedures applicable for this service or product.", 0, java.lang.Integer.MAX_VALUE, procedureSequence);
4435          case -702585587: /*informationSequence*/  return new Property("informationSequence", "positiveInt", "Exceptions, special conditions and supporting information applicable for this service or product.", 0, java.lang.Integer.MAX_VALUE, informationSequence);
4436          case 1099842588: /*revenue*/  return new Property("revenue", "CodeableConcept", "The type of revenue or cost center providing the product and/or service.", 0, 1, revenue);
4437          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);
4438          case 1957227299: /*productOrService*/  return new Property("productOrService", "CodeableConcept", "When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.", 0, 1, productOrService);
4439          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);
4440          case 1010065041: /*programCode*/  return new Property("programCode", "CodeableConcept", "Identifies the program under which this may be recovered.", 0, java.lang.Integer.MAX_VALUE, programCode);
4441          case -1927922223: /*serviced[x]*/  return new Property("serviced[x]", "date|Period", "The date or dates when the service or product was supplied, performed or completed.", 0, 1, serviced);
4442          case 1379209295: /*serviced*/  return new Property("serviced[x]", "date|Period", "The date or dates when the service or product was supplied, performed or completed.", 0, 1, serviced);
4443          case 363246749: /*servicedDate*/  return new Property("serviced[x]", "date", "The date or dates when the service or product was supplied, performed or completed.", 0, 1, serviced);
4444          case 1534966512: /*servicedPeriod*/  return new Property("serviced[x]", "Period", "The date or dates when the service or product was supplied, performed or completed.", 0, 1, serviced);
4445          case 552316075: /*location[x]*/  return new Property("location[x]", "CodeableConcept|Address|Reference(Location)", "Where the product or service was provided.", 0, 1, location);
4446          case 1901043637: /*location*/  return new Property("location[x]", "CodeableConcept|Address|Reference(Location)", "Where the product or service was provided.", 0, 1, location);
4447          case -1224800468: /*locationCodeableConcept*/  return new Property("location[x]", "CodeableConcept", "Where the product or service was provided.", 0, 1, location);
4448          case -1280020865: /*locationAddress*/  return new Property("location[x]", "Address", "Where the product or service was provided.", 0, 1, location);
4449          case 755866390: /*locationReference*/  return new Property("location[x]", "Reference(Location)", "Where the product or service was provided.", 0, 1, location);
4450          case -1285004149: /*quantity*/  return new Property("quantity", "Quantity", "The number of repetitions of a service or product.", 0, 1, quantity);
4451          case -486196699: /*unitPrice*/  return new Property("unitPrice", "Money", "If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.", 0, 1, unitPrice);
4452          case -1282148017: /*factor*/  return new Property("factor", "decimal", "A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.", 0, 1, factor);
4453          case 108957: /*net*/  return new Property("net", "Money", "The quantity times the unit price for an additional service or product or charge.", 0, 1, net);
4454          case 115642: /*udi*/  return new Property("udi", "Reference(Device)", "Unique Device Identifiers associated with this line item.", 0, java.lang.Integer.MAX_VALUE, udi);
4455          case 1702620169: /*bodySite*/  return new Property("bodySite", "CodeableConcept", "Physical service site on the patient (limb, tooth, etc.).", 0, 1, bodySite);
4456          case -1868566105: /*subSite*/  return new Property("subSite", "CodeableConcept", "A region or surface of the bodySite, e.g. limb region or tooth surface(s).", 0, java.lang.Integer.MAX_VALUE, subSite);
4457          case 1524132147: /*encounter*/  return new Property("encounter", "Reference(Encounter)", "A billed item may include goods or services provided in multiple encounters.", 0, java.lang.Integer.MAX_VALUE, encounter);
4458          case -1110033957: /*noteNumber*/  return new Property("noteNumber", "positiveInt", "The numbers associated with notes below which apply to the adjudication of this item.", 0, java.lang.Integer.MAX_VALUE, noteNumber);
4459          case -231349275: /*adjudication*/  return new Property("adjudication", "", "If this item is a group then the values here are a summary of the adjudication of the detail items. If this item is a simple product or service then this is the result of the adjudication of this item.", 0, java.lang.Integer.MAX_VALUE, adjudication);
4460          case -1335224239: /*detail*/  return new Property("detail", "", "Second-tier of goods and services.", 0, java.lang.Integer.MAX_VALUE, detail);
4461          default: return super.getNamedProperty(_hash, _name, _checkValid);
4462          }
4463
4464        }
4465
4466      @Override
4467      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
4468        switch (hash) {
4469        case 1349547969: /*sequence*/ return this.sequence == null ? new Base[0] : new Base[] {this.sequence}; // PositiveIntType
4470        case 1070083823: /*careTeamSequence*/ return this.careTeamSequence == null ? new Base[0] : this.careTeamSequence.toArray(new Base[this.careTeamSequence.size()]); // PositiveIntType
4471        case -909769262: /*diagnosisSequence*/ return this.diagnosisSequence == null ? new Base[0] : this.diagnosisSequence.toArray(new Base[this.diagnosisSequence.size()]); // PositiveIntType
4472        case -808920140: /*procedureSequence*/ return this.procedureSequence == null ? new Base[0] : this.procedureSequence.toArray(new Base[this.procedureSequence.size()]); // PositiveIntType
4473        case -702585587: /*informationSequence*/ return this.informationSequence == null ? new Base[0] : this.informationSequence.toArray(new Base[this.informationSequence.size()]); // PositiveIntType
4474        case 1099842588: /*revenue*/ return this.revenue == null ? new Base[0] : new Base[] {this.revenue}; // CodeableConcept
4475        case 50511102: /*category*/ return this.category == null ? new Base[0] : new Base[] {this.category}; // CodeableConcept
4476        case 1957227299: /*productOrService*/ return this.productOrService == null ? new Base[0] : new Base[] {this.productOrService}; // CodeableConcept
4477        case -615513385: /*modifier*/ return this.modifier == null ? new Base[0] : this.modifier.toArray(new Base[this.modifier.size()]); // CodeableConcept
4478        case 1010065041: /*programCode*/ return this.programCode == null ? new Base[0] : this.programCode.toArray(new Base[this.programCode.size()]); // CodeableConcept
4479        case 1379209295: /*serviced*/ return this.serviced == null ? new Base[0] : new Base[] {this.serviced}; // DataType
4480        case 1901043637: /*location*/ return this.location == null ? new Base[0] : new Base[] {this.location}; // DataType
4481        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // Quantity
4482        case -486196699: /*unitPrice*/ return this.unitPrice == null ? new Base[0] : new Base[] {this.unitPrice}; // Money
4483        case -1282148017: /*factor*/ return this.factor == null ? new Base[0] : new Base[] {this.factor}; // DecimalType
4484        case 108957: /*net*/ return this.net == null ? new Base[0] : new Base[] {this.net}; // Money
4485        case 115642: /*udi*/ return this.udi == null ? new Base[0] : this.udi.toArray(new Base[this.udi.size()]); // Reference
4486        case 1702620169: /*bodySite*/ return this.bodySite == null ? new Base[0] : new Base[] {this.bodySite}; // CodeableConcept
4487        case -1868566105: /*subSite*/ return this.subSite == null ? new Base[0] : this.subSite.toArray(new Base[this.subSite.size()]); // CodeableConcept
4488        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : this.encounter.toArray(new Base[this.encounter.size()]); // Reference
4489        case -1110033957: /*noteNumber*/ return this.noteNumber == null ? new Base[0] : this.noteNumber.toArray(new Base[this.noteNumber.size()]); // PositiveIntType
4490        case -231349275: /*adjudication*/ return this.adjudication == null ? new Base[0] : this.adjudication.toArray(new Base[this.adjudication.size()]); // AdjudicationComponent
4491        case -1335224239: /*detail*/ return this.detail == null ? new Base[0] : this.detail.toArray(new Base[this.detail.size()]); // DetailComponent
4492        default: return super.getProperty(hash, name, checkValid);
4493        }
4494
4495      }
4496
4497      @Override
4498      public Base setProperty(int hash, String name, Base value) throws FHIRException {
4499        switch (hash) {
4500        case 1349547969: // sequence
4501          this.sequence = TypeConvertor.castToPositiveInt(value); // PositiveIntType
4502          return value;
4503        case 1070083823: // careTeamSequence
4504          this.getCareTeamSequence().add(TypeConvertor.castToPositiveInt(value)); // PositiveIntType
4505          return value;
4506        case -909769262: // diagnosisSequence
4507          this.getDiagnosisSequence().add(TypeConvertor.castToPositiveInt(value)); // PositiveIntType
4508          return value;
4509        case -808920140: // procedureSequence
4510          this.getProcedureSequence().add(TypeConvertor.castToPositiveInt(value)); // PositiveIntType
4511          return value;
4512        case -702585587: // informationSequence
4513          this.getInformationSequence().add(TypeConvertor.castToPositiveInt(value)); // PositiveIntType
4514          return value;
4515        case 1099842588: // revenue
4516          this.revenue = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
4517          return value;
4518        case 50511102: // category
4519          this.category = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
4520          return value;
4521        case 1957227299: // productOrService
4522          this.productOrService = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
4523          return value;
4524        case -615513385: // modifier
4525          this.getModifier().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
4526          return value;
4527        case 1010065041: // programCode
4528          this.getProgramCode().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
4529          return value;
4530        case 1379209295: // serviced
4531          this.serviced = TypeConvertor.castToType(value); // DataType
4532          return value;
4533        case 1901043637: // location
4534          this.location = TypeConvertor.castToType(value); // DataType
4535          return value;
4536        case -1285004149: // quantity
4537          this.quantity = TypeConvertor.castToQuantity(value); // Quantity
4538          return value;
4539        case -486196699: // unitPrice
4540          this.unitPrice = TypeConvertor.castToMoney(value); // Money
4541          return value;
4542        case -1282148017: // factor
4543          this.factor = TypeConvertor.castToDecimal(value); // DecimalType
4544          return value;
4545        case 108957: // net
4546          this.net = TypeConvertor.castToMoney(value); // Money
4547          return value;
4548        case 115642: // udi
4549          this.getUdi().add(TypeConvertor.castToReference(value)); // Reference
4550          return value;
4551        case 1702620169: // bodySite
4552          this.bodySite = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
4553          return value;
4554        case -1868566105: // subSite
4555          this.getSubSite().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
4556          return value;
4557        case 1524132147: // encounter
4558          this.getEncounter().add(TypeConvertor.castToReference(value)); // Reference
4559          return value;
4560        case -1110033957: // noteNumber
4561          this.getNoteNumber().add(TypeConvertor.castToPositiveInt(value)); // PositiveIntType
4562          return value;
4563        case -231349275: // adjudication
4564          this.getAdjudication().add((AdjudicationComponent) value); // AdjudicationComponent
4565          return value;
4566        case -1335224239: // detail
4567          this.getDetail().add((DetailComponent) value); // DetailComponent
4568          return value;
4569        default: return super.setProperty(hash, name, value);
4570        }
4571
4572      }
4573
4574      @Override
4575      public Base setProperty(String name, Base value) throws FHIRException {
4576        if (name.equals("sequence")) {
4577          this.sequence = TypeConvertor.castToPositiveInt(value); // PositiveIntType
4578        } else if (name.equals("careTeamSequence")) {
4579          this.getCareTeamSequence().add(TypeConvertor.castToPositiveInt(value));
4580        } else if (name.equals("diagnosisSequence")) {
4581          this.getDiagnosisSequence().add(TypeConvertor.castToPositiveInt(value));
4582        } else if (name.equals("procedureSequence")) {
4583          this.getProcedureSequence().add(TypeConvertor.castToPositiveInt(value));
4584        } else if (name.equals("informationSequence")) {
4585          this.getInformationSequence().add(TypeConvertor.castToPositiveInt(value));
4586        } else if (name.equals("revenue")) {
4587          this.revenue = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
4588        } else if (name.equals("category")) {
4589          this.category = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
4590        } else if (name.equals("productOrService")) {
4591          this.productOrService = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
4592        } else if (name.equals("modifier")) {
4593          this.getModifier().add(TypeConvertor.castToCodeableConcept(value));
4594        } else if (name.equals("programCode")) {
4595          this.getProgramCode().add(TypeConvertor.castToCodeableConcept(value));
4596        } else if (name.equals("serviced[x]")) {
4597          this.serviced = TypeConvertor.castToType(value); // DataType
4598        } else if (name.equals("location[x]")) {
4599          this.location = TypeConvertor.castToType(value); // DataType
4600        } else if (name.equals("quantity")) {
4601          this.quantity = TypeConvertor.castToQuantity(value); // Quantity
4602        } else if (name.equals("unitPrice")) {
4603          this.unitPrice = TypeConvertor.castToMoney(value); // Money
4604        } else if (name.equals("factor")) {
4605          this.factor = TypeConvertor.castToDecimal(value); // DecimalType
4606        } else if (name.equals("net")) {
4607          this.net = TypeConvertor.castToMoney(value); // Money
4608        } else if (name.equals("udi")) {
4609          this.getUdi().add(TypeConvertor.castToReference(value));
4610        } else if (name.equals("bodySite")) {
4611          this.bodySite = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
4612        } else if (name.equals("subSite")) {
4613          this.getSubSite().add(TypeConvertor.castToCodeableConcept(value));
4614        } else if (name.equals("encounter")) {
4615          this.getEncounter().add(TypeConvertor.castToReference(value));
4616        } else if (name.equals("noteNumber")) {
4617          this.getNoteNumber().add(TypeConvertor.castToPositiveInt(value));
4618        } else if (name.equals("adjudication")) {
4619          this.getAdjudication().add((AdjudicationComponent) value);
4620        } else if (name.equals("detail")) {
4621          this.getDetail().add((DetailComponent) value);
4622        } else
4623          return super.setProperty(name, value);
4624        return value;
4625      }
4626
4627      @Override
4628      public Base makeProperty(int hash, String name) throws FHIRException {
4629        switch (hash) {
4630        case 1349547969:  return getSequenceElement();
4631        case 1070083823:  return addCareTeamSequenceElement();
4632        case -909769262:  return addDiagnosisSequenceElement();
4633        case -808920140:  return addProcedureSequenceElement();
4634        case -702585587:  return addInformationSequenceElement();
4635        case 1099842588:  return getRevenue();
4636        case 50511102:  return getCategory();
4637        case 1957227299:  return getProductOrService();
4638        case -615513385:  return addModifier(); 
4639        case 1010065041:  return addProgramCode(); 
4640        case -1927922223:  return getServiced();
4641        case 1379209295:  return getServiced();
4642        case 552316075:  return getLocation();
4643        case 1901043637:  return getLocation();
4644        case -1285004149:  return getQuantity();
4645        case -486196699:  return getUnitPrice();
4646        case -1282148017:  return getFactorElement();
4647        case 108957:  return getNet();
4648        case 115642:  return addUdi(); 
4649        case 1702620169:  return getBodySite();
4650        case -1868566105:  return addSubSite(); 
4651        case 1524132147:  return addEncounter(); 
4652        case -1110033957:  return addNoteNumberElement();
4653        case -231349275:  return addAdjudication(); 
4654        case -1335224239:  return addDetail(); 
4655        default: return super.makeProperty(hash, name);
4656        }
4657
4658      }
4659
4660      @Override
4661      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
4662        switch (hash) {
4663        case 1349547969: /*sequence*/ return new String[] {"positiveInt"};
4664        case 1070083823: /*careTeamSequence*/ return new String[] {"positiveInt"};
4665        case -909769262: /*diagnosisSequence*/ return new String[] {"positiveInt"};
4666        case -808920140: /*procedureSequence*/ return new String[] {"positiveInt"};
4667        case -702585587: /*informationSequence*/ return new String[] {"positiveInt"};
4668        case 1099842588: /*revenue*/ return new String[] {"CodeableConcept"};
4669        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
4670        case 1957227299: /*productOrService*/ return new String[] {"CodeableConcept"};
4671        case -615513385: /*modifier*/ return new String[] {"CodeableConcept"};
4672        case 1010065041: /*programCode*/ return new String[] {"CodeableConcept"};
4673        case 1379209295: /*serviced*/ return new String[] {"date", "Period"};
4674        case 1901043637: /*location*/ return new String[] {"CodeableConcept", "Address", "Reference"};
4675        case -1285004149: /*quantity*/ return new String[] {"Quantity"};
4676        case -486196699: /*unitPrice*/ return new String[] {"Money"};
4677        case -1282148017: /*factor*/ return new String[] {"decimal"};
4678        case 108957: /*net*/ return new String[] {"Money"};
4679        case 115642: /*udi*/ return new String[] {"Reference"};
4680        case 1702620169: /*bodySite*/ return new String[] {"CodeableConcept"};
4681        case -1868566105: /*subSite*/ return new String[] {"CodeableConcept"};
4682        case 1524132147: /*encounter*/ return new String[] {"Reference"};
4683        case -1110033957: /*noteNumber*/ return new String[] {"positiveInt"};
4684        case -231349275: /*adjudication*/ return new String[] {};
4685        case -1335224239: /*detail*/ return new String[] {};
4686        default: return super.getTypesForProperty(hash, name);
4687        }
4688
4689      }
4690
4691      @Override
4692      public Base addChild(String name) throws FHIRException {
4693        if (name.equals("sequence")) {
4694          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.item.sequence");
4695        }
4696        else if (name.equals("careTeamSequence")) {
4697          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.item.careTeamSequence");
4698        }
4699        else if (name.equals("diagnosisSequence")) {
4700          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.item.diagnosisSequence");
4701        }
4702        else if (name.equals("procedureSequence")) {
4703          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.item.procedureSequence");
4704        }
4705        else if (name.equals("informationSequence")) {
4706          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.item.informationSequence");
4707        }
4708        else if (name.equals("revenue")) {
4709          this.revenue = new CodeableConcept();
4710          return this.revenue;
4711        }
4712        else if (name.equals("category")) {
4713          this.category = new CodeableConcept();
4714          return this.category;
4715        }
4716        else if (name.equals("productOrService")) {
4717          this.productOrService = new CodeableConcept();
4718          return this.productOrService;
4719        }
4720        else if (name.equals("modifier")) {
4721          return addModifier();
4722        }
4723        else if (name.equals("programCode")) {
4724          return addProgramCode();
4725        }
4726        else if (name.equals("servicedDate")) {
4727          this.serviced = new DateType();
4728          return this.serviced;
4729        }
4730        else if (name.equals("servicedPeriod")) {
4731          this.serviced = new Period();
4732          return this.serviced;
4733        }
4734        else if (name.equals("locationCodeableConcept")) {
4735          this.location = new CodeableConcept();
4736          return this.location;
4737        }
4738        else if (name.equals("locationAddress")) {
4739          this.location = new Address();
4740          return this.location;
4741        }
4742        else if (name.equals("locationReference")) {
4743          this.location = new Reference();
4744          return this.location;
4745        }
4746        else if (name.equals("quantity")) {
4747          this.quantity = new Quantity();
4748          return this.quantity;
4749        }
4750        else if (name.equals("unitPrice")) {
4751          this.unitPrice = new Money();
4752          return this.unitPrice;
4753        }
4754        else if (name.equals("factor")) {
4755          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.item.factor");
4756        }
4757        else if (name.equals("net")) {
4758          this.net = new Money();
4759          return this.net;
4760        }
4761        else if (name.equals("udi")) {
4762          return addUdi();
4763        }
4764        else if (name.equals("bodySite")) {
4765          this.bodySite = new CodeableConcept();
4766          return this.bodySite;
4767        }
4768        else if (name.equals("subSite")) {
4769          return addSubSite();
4770        }
4771        else if (name.equals("encounter")) {
4772          return addEncounter();
4773        }
4774        else if (name.equals("noteNumber")) {
4775          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.item.noteNumber");
4776        }
4777        else if (name.equals("adjudication")) {
4778          return addAdjudication();
4779        }
4780        else if (name.equals("detail")) {
4781          return addDetail();
4782        }
4783        else
4784          return super.addChild(name);
4785      }
4786
4787      public ItemComponent copy() {
4788        ItemComponent dst = new ItemComponent();
4789        copyValues(dst);
4790        return dst;
4791      }
4792
4793      public void copyValues(ItemComponent dst) {
4794        super.copyValues(dst);
4795        dst.sequence = sequence == null ? null : sequence.copy();
4796        if (careTeamSequence != null) {
4797          dst.careTeamSequence = new ArrayList<PositiveIntType>();
4798          for (PositiveIntType i : careTeamSequence)
4799            dst.careTeamSequence.add(i.copy());
4800        };
4801        if (diagnosisSequence != null) {
4802          dst.diagnosisSequence = new ArrayList<PositiveIntType>();
4803          for (PositiveIntType i : diagnosisSequence)
4804            dst.diagnosisSequence.add(i.copy());
4805        };
4806        if (procedureSequence != null) {
4807          dst.procedureSequence = new ArrayList<PositiveIntType>();
4808          for (PositiveIntType i : procedureSequence)
4809            dst.procedureSequence.add(i.copy());
4810        };
4811        if (informationSequence != null) {
4812          dst.informationSequence = new ArrayList<PositiveIntType>();
4813          for (PositiveIntType i : informationSequence)
4814            dst.informationSequence.add(i.copy());
4815        };
4816        dst.revenue = revenue == null ? null : revenue.copy();
4817        dst.category = category == null ? null : category.copy();
4818        dst.productOrService = productOrService == null ? null : productOrService.copy();
4819        if (modifier != null) {
4820          dst.modifier = new ArrayList<CodeableConcept>();
4821          for (CodeableConcept i : modifier)
4822            dst.modifier.add(i.copy());
4823        };
4824        if (programCode != null) {
4825          dst.programCode = new ArrayList<CodeableConcept>();
4826          for (CodeableConcept i : programCode)
4827            dst.programCode.add(i.copy());
4828        };
4829        dst.serviced = serviced == null ? null : serviced.copy();
4830        dst.location = location == null ? null : location.copy();
4831        dst.quantity = quantity == null ? null : quantity.copy();
4832        dst.unitPrice = unitPrice == null ? null : unitPrice.copy();
4833        dst.factor = factor == null ? null : factor.copy();
4834        dst.net = net == null ? null : net.copy();
4835        if (udi != null) {
4836          dst.udi = new ArrayList<Reference>();
4837          for (Reference i : udi)
4838            dst.udi.add(i.copy());
4839        };
4840        dst.bodySite = bodySite == null ? null : bodySite.copy();
4841        if (subSite != null) {
4842          dst.subSite = new ArrayList<CodeableConcept>();
4843          for (CodeableConcept i : subSite)
4844            dst.subSite.add(i.copy());
4845        };
4846        if (encounter != null) {
4847          dst.encounter = new ArrayList<Reference>();
4848          for (Reference i : encounter)
4849            dst.encounter.add(i.copy());
4850        };
4851        if (noteNumber != null) {
4852          dst.noteNumber = new ArrayList<PositiveIntType>();
4853          for (PositiveIntType i : noteNumber)
4854            dst.noteNumber.add(i.copy());
4855        };
4856        if (adjudication != null) {
4857          dst.adjudication = new ArrayList<AdjudicationComponent>();
4858          for (AdjudicationComponent i : adjudication)
4859            dst.adjudication.add(i.copy());
4860        };
4861        if (detail != null) {
4862          dst.detail = new ArrayList<DetailComponent>();
4863          for (DetailComponent i : detail)
4864            dst.detail.add(i.copy());
4865        };
4866      }
4867
4868      @Override
4869      public boolean equalsDeep(Base other_) {
4870        if (!super.equalsDeep(other_))
4871          return false;
4872        if (!(other_ instanceof ItemComponent))
4873          return false;
4874        ItemComponent o = (ItemComponent) other_;
4875        return compareDeep(sequence, o.sequence, true) && compareDeep(careTeamSequence, o.careTeamSequence, true)
4876           && compareDeep(diagnosisSequence, o.diagnosisSequence, true) && compareDeep(procedureSequence, o.procedureSequence, true)
4877           && compareDeep(informationSequence, o.informationSequence, true) && compareDeep(revenue, o.revenue, true)
4878           && compareDeep(category, o.category, true) && compareDeep(productOrService, o.productOrService, true)
4879           && compareDeep(modifier, o.modifier, true) && compareDeep(programCode, o.programCode, true) && compareDeep(serviced, o.serviced, true)
4880           && compareDeep(location, o.location, true) && compareDeep(quantity, o.quantity, true) && compareDeep(unitPrice, o.unitPrice, true)
4881           && compareDeep(factor, o.factor, true) && compareDeep(net, o.net, true) && compareDeep(udi, o.udi, true)
4882           && compareDeep(bodySite, o.bodySite, true) && compareDeep(subSite, o.subSite, true) && compareDeep(encounter, o.encounter, true)
4883           && compareDeep(noteNumber, o.noteNumber, true) && compareDeep(adjudication, o.adjudication, true)
4884           && compareDeep(detail, o.detail, true);
4885      }
4886
4887      @Override
4888      public boolean equalsShallow(Base other_) {
4889        if (!super.equalsShallow(other_))
4890          return false;
4891        if (!(other_ instanceof ItemComponent))
4892          return false;
4893        ItemComponent o = (ItemComponent) other_;
4894        return compareValues(sequence, o.sequence, true) && compareValues(careTeamSequence, o.careTeamSequence, true)
4895           && compareValues(diagnosisSequence, o.diagnosisSequence, true) && compareValues(procedureSequence, o.procedureSequence, true)
4896           && compareValues(informationSequence, o.informationSequence, true) && compareValues(factor, o.factor, true)
4897           && compareValues(noteNumber, o.noteNumber, true);
4898      }
4899
4900      public boolean isEmpty() {
4901        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(sequence, careTeamSequence
4902          , diagnosisSequence, procedureSequence, informationSequence, revenue, category, productOrService
4903          , modifier, programCode, serviced, location, quantity, unitPrice, factor, net
4904          , udi, bodySite, subSite, encounter, noteNumber, adjudication, detail);
4905      }
4906
4907  public String fhirType() {
4908    return "ExplanationOfBenefit.item";
4909
4910  }
4911
4912  }
4913
4914    @Block()
4915    public static class AdjudicationComponent extends BackboneElement implements IBaseBackboneElement {
4916        /**
4917         * A code to indicate the information type of this adjudication record. Information types may include: the value submitted, maximum values or percentages allowed or payable under the plan, amounts that the patient is responsible for in-aggregate or pertaining to this item, amounts paid by other coverages, and the benefit payable for this item.
4918         */
4919        @Child(name = "category", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=false)
4920        @Description(shortDefinition="Type of adjudication information", formalDefinition="A code to indicate the information type of this adjudication record. Information types may include: the value submitted, maximum values or percentages allowed or payable under the plan, amounts that the patient is responsible for in-aggregate or pertaining to this item, amounts paid by other coverages, and the benefit payable for this item." )
4921        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/adjudication")
4922        protected CodeableConcept category;
4923
4924        /**
4925         * A code supporting the understanding of the adjudication result and explaining variance from expected amount.
4926         */
4927        @Child(name = "reason", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
4928        @Description(shortDefinition="Explanation of adjudication outcome", formalDefinition="A code supporting the understanding of the adjudication result and explaining variance from expected amount." )
4929        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/adjudication-reason")
4930        protected CodeableConcept reason;
4931
4932        /**
4933         * Monetary amount associated with the category.
4934         */
4935        @Child(name = "amount", type = {Money.class}, order=3, min=0, max=1, modifier=false, summary=false)
4936        @Description(shortDefinition="Monetary amount", formalDefinition="Monetary amount associated with the category." )
4937        protected Money amount;
4938
4939        /**
4940         * A non-monetary value associated with the category. Mutually exclusive to the amount element above.
4941         */
4942        @Child(name = "value", type = {DecimalType.class}, order=4, min=0, max=1, modifier=false, summary=false)
4943        @Description(shortDefinition="Non-monitary value", formalDefinition="A non-monetary value associated with the category. Mutually exclusive to the amount element above." )
4944        protected DecimalType value;
4945
4946        private static final long serialVersionUID = 1559898786L;
4947
4948    /**
4949     * Constructor
4950     */
4951      public AdjudicationComponent() {
4952        super();
4953      }
4954
4955    /**
4956     * Constructor
4957     */
4958      public AdjudicationComponent(CodeableConcept category) {
4959        super();
4960        this.setCategory(category);
4961      }
4962
4963        /**
4964         * @return {@link #category} (A code to indicate the information type of this adjudication record. Information types may include: the value submitted, maximum values or percentages allowed or payable under the plan, amounts that the patient is responsible for in-aggregate or pertaining to this item, amounts paid by other coverages, and the benefit payable for this item.)
4965         */
4966        public CodeableConcept getCategory() { 
4967          if (this.category == null)
4968            if (Configuration.errorOnAutoCreate())
4969              throw new Error("Attempt to auto-create AdjudicationComponent.category");
4970            else if (Configuration.doAutoCreate())
4971              this.category = new CodeableConcept(); // cc
4972          return this.category;
4973        }
4974
4975        public boolean hasCategory() { 
4976          return this.category != null && !this.category.isEmpty();
4977        }
4978
4979        /**
4980         * @param value {@link #category} (A code to indicate the information type of this adjudication record. Information types may include: the value submitted, maximum values or percentages allowed or payable under the plan, amounts that the patient is responsible for in-aggregate or pertaining to this item, amounts paid by other coverages, and the benefit payable for this item.)
4981         */
4982        public AdjudicationComponent setCategory(CodeableConcept value) { 
4983          this.category = value;
4984          return this;
4985        }
4986
4987        /**
4988         * @return {@link #reason} (A code supporting the understanding of the adjudication result and explaining variance from expected amount.)
4989         */
4990        public CodeableConcept getReason() { 
4991          if (this.reason == null)
4992            if (Configuration.errorOnAutoCreate())
4993              throw new Error("Attempt to auto-create AdjudicationComponent.reason");
4994            else if (Configuration.doAutoCreate())
4995              this.reason = new CodeableConcept(); // cc
4996          return this.reason;
4997        }
4998
4999        public boolean hasReason() { 
5000          return this.reason != null && !this.reason.isEmpty();
5001        }
5002
5003        /**
5004         * @param value {@link #reason} (A code supporting the understanding of the adjudication result and explaining variance from expected amount.)
5005         */
5006        public AdjudicationComponent setReason(CodeableConcept value) { 
5007          this.reason = value;
5008          return this;
5009        }
5010
5011        /**
5012         * @return {@link #amount} (Monetary amount associated with the category.)
5013         */
5014        public Money getAmount() { 
5015          if (this.amount == null)
5016            if (Configuration.errorOnAutoCreate())
5017              throw new Error("Attempt to auto-create AdjudicationComponent.amount");
5018            else if (Configuration.doAutoCreate())
5019              this.amount = new Money(); // cc
5020          return this.amount;
5021        }
5022
5023        public boolean hasAmount() { 
5024          return this.amount != null && !this.amount.isEmpty();
5025        }
5026
5027        /**
5028         * @param value {@link #amount} (Monetary amount associated with the category.)
5029         */
5030        public AdjudicationComponent setAmount(Money value) { 
5031          this.amount = value;
5032          return this;
5033        }
5034
5035        /**
5036         * @return {@link #value} (A non-monetary value associated with the category. Mutually exclusive to the amount element above.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
5037         */
5038        public DecimalType getValueElement() { 
5039          if (this.value == null)
5040            if (Configuration.errorOnAutoCreate())
5041              throw new Error("Attempt to auto-create AdjudicationComponent.value");
5042            else if (Configuration.doAutoCreate())
5043              this.value = new DecimalType(); // bb
5044          return this.value;
5045        }
5046
5047        public boolean hasValueElement() { 
5048          return this.value != null && !this.value.isEmpty();
5049        }
5050
5051        public boolean hasValue() { 
5052          return this.value != null && !this.value.isEmpty();
5053        }
5054
5055        /**
5056         * @param value {@link #value} (A non-monetary value associated with the category. Mutually exclusive to the amount element above.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
5057         */
5058        public AdjudicationComponent setValueElement(DecimalType value) { 
5059          this.value = value;
5060          return this;
5061        }
5062
5063        /**
5064         * @return A non-monetary value associated with the category. Mutually exclusive to the amount element above.
5065         */
5066        public BigDecimal getValue() { 
5067          return this.value == null ? null : this.value.getValue();
5068        }
5069
5070        /**
5071         * @param value A non-monetary value associated with the category. Mutually exclusive to the amount element above.
5072         */
5073        public AdjudicationComponent setValue(BigDecimal value) { 
5074          if (value == null)
5075            this.value = null;
5076          else {
5077            if (this.value == null)
5078              this.value = new DecimalType();
5079            this.value.setValue(value);
5080          }
5081          return this;
5082        }
5083
5084        /**
5085         * @param value A non-monetary value associated with the category. Mutually exclusive to the amount element above.
5086         */
5087        public AdjudicationComponent setValue(long value) { 
5088              this.value = new DecimalType();
5089            this.value.setValue(value);
5090          return this;
5091        }
5092
5093        /**
5094         * @param value A non-monetary value associated with the category. Mutually exclusive to the amount element above.
5095         */
5096        public AdjudicationComponent setValue(double value) { 
5097              this.value = new DecimalType();
5098            this.value.setValue(value);
5099          return this;
5100        }
5101
5102        protected void listChildren(List<Property> children) {
5103          super.listChildren(children);
5104          children.add(new Property("category", "CodeableConcept", "A code to indicate the information type of this adjudication record. Information types may include: the value submitted, maximum values or percentages allowed or payable under the plan, amounts that the patient is responsible for in-aggregate or pertaining to this item, amounts paid by other coverages, and the benefit payable for this item.", 0, 1, category));
5105          children.add(new Property("reason", "CodeableConcept", "A code supporting the understanding of the adjudication result and explaining variance from expected amount.", 0, 1, reason));
5106          children.add(new Property("amount", "Money", "Monetary amount associated with the category.", 0, 1, amount));
5107          children.add(new Property("value", "decimal", "A non-monetary value associated with the category. Mutually exclusive to the amount element above.", 0, 1, value));
5108        }
5109
5110        @Override
5111        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
5112          switch (_hash) {
5113          case 50511102: /*category*/  return new Property("category", "CodeableConcept", "A code to indicate the information type of this adjudication record. Information types may include: the value submitted, maximum values or percentages allowed or payable under the plan, amounts that the patient is responsible for in-aggregate or pertaining to this item, amounts paid by other coverages, and the benefit payable for this item.", 0, 1, category);
5114          case -934964668: /*reason*/  return new Property("reason", "CodeableConcept", "A code supporting the understanding of the adjudication result and explaining variance from expected amount.", 0, 1, reason);
5115          case -1413853096: /*amount*/  return new Property("amount", "Money", "Monetary amount associated with the category.", 0, 1, amount);
5116          case 111972721: /*value*/  return new Property("value", "decimal", "A non-monetary value associated with the category. Mutually exclusive to the amount element above.", 0, 1, value);
5117          default: return super.getNamedProperty(_hash, _name, _checkValid);
5118          }
5119
5120        }
5121
5122      @Override
5123      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
5124        switch (hash) {
5125        case 50511102: /*category*/ return this.category == null ? new Base[0] : new Base[] {this.category}; // CodeableConcept
5126        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : new Base[] {this.reason}; // CodeableConcept
5127        case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // Money
5128        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // DecimalType
5129        default: return super.getProperty(hash, name, checkValid);
5130        }
5131
5132      }
5133
5134      @Override
5135      public Base setProperty(int hash, String name, Base value) throws FHIRException {
5136        switch (hash) {
5137        case 50511102: // category
5138          this.category = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
5139          return value;
5140        case -934964668: // reason
5141          this.reason = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
5142          return value;
5143        case -1413853096: // amount
5144          this.amount = TypeConvertor.castToMoney(value); // Money
5145          return value;
5146        case 111972721: // value
5147          this.value = TypeConvertor.castToDecimal(value); // DecimalType
5148          return value;
5149        default: return super.setProperty(hash, name, value);
5150        }
5151
5152      }
5153
5154      @Override
5155      public Base setProperty(String name, Base value) throws FHIRException {
5156        if (name.equals("category")) {
5157          this.category = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
5158        } else if (name.equals("reason")) {
5159          this.reason = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
5160        } else if (name.equals("amount")) {
5161          this.amount = TypeConvertor.castToMoney(value); // Money
5162        } else if (name.equals("value")) {
5163          this.value = TypeConvertor.castToDecimal(value); // DecimalType
5164        } else
5165          return super.setProperty(name, value);
5166        return value;
5167      }
5168
5169      @Override
5170      public Base makeProperty(int hash, String name) throws FHIRException {
5171        switch (hash) {
5172        case 50511102:  return getCategory();
5173        case -934964668:  return getReason();
5174        case -1413853096:  return getAmount();
5175        case 111972721:  return getValueElement();
5176        default: return super.makeProperty(hash, name);
5177        }
5178
5179      }
5180
5181      @Override
5182      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
5183        switch (hash) {
5184        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
5185        case -934964668: /*reason*/ return new String[] {"CodeableConcept"};
5186        case -1413853096: /*amount*/ return new String[] {"Money"};
5187        case 111972721: /*value*/ return new String[] {"decimal"};
5188        default: return super.getTypesForProperty(hash, name);
5189        }
5190
5191      }
5192
5193      @Override
5194      public Base addChild(String name) throws FHIRException {
5195        if (name.equals("category")) {
5196          this.category = new CodeableConcept();
5197          return this.category;
5198        }
5199        else if (name.equals("reason")) {
5200          this.reason = new CodeableConcept();
5201          return this.reason;
5202        }
5203        else if (name.equals("amount")) {
5204          this.amount = new Money();
5205          return this.amount;
5206        }
5207        else if (name.equals("value")) {
5208          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.item.adjudication.value");
5209        }
5210        else
5211          return super.addChild(name);
5212      }
5213
5214      public AdjudicationComponent copy() {
5215        AdjudicationComponent dst = new AdjudicationComponent();
5216        copyValues(dst);
5217        return dst;
5218      }
5219
5220      public void copyValues(AdjudicationComponent dst) {
5221        super.copyValues(dst);
5222        dst.category = category == null ? null : category.copy();
5223        dst.reason = reason == null ? null : reason.copy();
5224        dst.amount = amount == null ? null : amount.copy();
5225        dst.value = value == null ? null : value.copy();
5226      }
5227
5228      @Override
5229      public boolean equalsDeep(Base other_) {
5230        if (!super.equalsDeep(other_))
5231          return false;
5232        if (!(other_ instanceof AdjudicationComponent))
5233          return false;
5234        AdjudicationComponent o = (AdjudicationComponent) other_;
5235        return compareDeep(category, o.category, true) && compareDeep(reason, o.reason, true) && compareDeep(amount, o.amount, true)
5236           && compareDeep(value, o.value, true);
5237      }
5238
5239      @Override
5240      public boolean equalsShallow(Base other_) {
5241        if (!super.equalsShallow(other_))
5242          return false;
5243        if (!(other_ instanceof AdjudicationComponent))
5244          return false;
5245        AdjudicationComponent o = (AdjudicationComponent) other_;
5246        return compareValues(value, o.value, true);
5247      }
5248
5249      public boolean isEmpty() {
5250        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(category, reason, amount
5251          , value);
5252      }
5253
5254  public String fhirType() {
5255    return "ExplanationOfBenefit.item.adjudication";
5256
5257  }
5258
5259  }
5260
5261    @Block()
5262    public static class DetailComponent extends BackboneElement implements IBaseBackboneElement {
5263        /**
5264         * A claim detail line. Either a simple (a product or service) or a 'group' of sub-details which are simple items.
5265         */
5266        @Child(name = "sequence", type = {PositiveIntType.class}, order=1, min=1, max=1, modifier=false, summary=false)
5267        @Description(shortDefinition="Product or service provided", formalDefinition="A claim detail line. Either a simple (a product or service) or a 'group' of sub-details which are simple items." )
5268        protected PositiveIntType sequence;
5269
5270        /**
5271         * The type of revenue or cost center providing the product and/or service.
5272         */
5273        @Child(name = "revenue", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
5274        @Description(shortDefinition="Revenue or cost center code", formalDefinition="The type of revenue or cost center providing the product and/or service." )
5275        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/ex-revenue-center")
5276        protected CodeableConcept revenue;
5277
5278        /**
5279         * Code to identify the general type of benefits under which products and services are provided.
5280         */
5281        @Child(name = "category", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=false)
5282        @Description(shortDefinition="Benefit classification", formalDefinition="Code to identify the general type of benefits under which products and services are provided." )
5283        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/ex-benefitcategory")
5284        protected CodeableConcept category;
5285
5286        /**
5287         * When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.
5288         */
5289        @Child(name = "productOrService", type = {CodeableConcept.class}, order=4, min=1, max=1, modifier=false, summary=false)
5290        @Description(shortDefinition="Billing, service, product, or drug code", formalDefinition="When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item." )
5291        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/service-uscls")
5292        protected CodeableConcept productOrService;
5293
5294        /**
5295         * Item typification or modifiers codes to convey additional context for the product or service.
5296         */
5297        @Child(name = "modifier", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
5298        @Description(shortDefinition="Service/Product billing modifiers", formalDefinition="Item typification or modifiers codes to convey additional context for the product or service." )
5299        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/claim-modifiers")
5300        protected List<CodeableConcept> modifier;
5301
5302        /**
5303         * Identifies the program under which this may be recovered.
5304         */
5305        @Child(name = "programCode", type = {CodeableConcept.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
5306        @Description(shortDefinition="Program the product or service is provided under", formalDefinition="Identifies the program under which this may be recovered." )
5307        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/ex-program-code")
5308        protected List<CodeableConcept> programCode;
5309
5310        /**
5311         * The number of repetitions of a service or product.
5312         */
5313        @Child(name = "quantity", type = {Quantity.class}, order=7, min=0, max=1, modifier=false, summary=false)
5314        @Description(shortDefinition="Count of products or services", formalDefinition="The number of repetitions of a service or product." )
5315        protected Quantity quantity;
5316
5317        /**
5318         * If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.
5319         */
5320        @Child(name = "unitPrice", type = {Money.class}, order=8, min=0, max=1, modifier=false, summary=false)
5321        @Description(shortDefinition="Fee, charge or cost per item", formalDefinition="If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group." )
5322        protected Money unitPrice;
5323
5324        /**
5325         * A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
5326         */
5327        @Child(name = "factor", type = {DecimalType.class}, order=9, min=0, max=1, modifier=false, summary=false)
5328        @Description(shortDefinition="Price scaling factor", formalDefinition="A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount." )
5329        protected DecimalType factor;
5330
5331        /**
5332         * The quantity times the unit price for an additional service or product or charge.
5333         */
5334        @Child(name = "net", type = {Money.class}, order=10, min=0, max=1, modifier=false, summary=false)
5335        @Description(shortDefinition="Total item cost", formalDefinition="The quantity times the unit price for an additional service or product or charge." )
5336        protected Money net;
5337
5338        /**
5339         * Unique Device Identifiers associated with this line item.
5340         */
5341        @Child(name = "udi", type = {Device.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
5342        @Description(shortDefinition="Unique device identifier", formalDefinition="Unique Device Identifiers associated with this line item." )
5343        protected List<Reference> udi;
5344
5345        /**
5346         * The numbers associated with notes below which apply to the adjudication of this item.
5347         */
5348        @Child(name = "noteNumber", type = {PositiveIntType.class}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
5349        @Description(shortDefinition="Applicable note numbers", formalDefinition="The numbers associated with notes below which apply to the adjudication of this item." )
5350        protected List<PositiveIntType> noteNumber;
5351
5352        /**
5353         * The adjudication results.
5354         */
5355        @Child(name = "adjudication", type = {AdjudicationComponent.class}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
5356        @Description(shortDefinition="Detail level adjudication details", formalDefinition="The adjudication results." )
5357        protected List<AdjudicationComponent> adjudication;
5358
5359        /**
5360         * Third-tier of goods and services.
5361         */
5362        @Child(name = "subDetail", type = {}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
5363        @Description(shortDefinition="Additional items", formalDefinition="Third-tier of goods and services." )
5364        protected List<SubDetailComponent> subDetail;
5365
5366        private static final long serialVersionUID = -318460001L;
5367
5368    /**
5369     * Constructor
5370     */
5371      public DetailComponent() {
5372        super();
5373      }
5374
5375    /**
5376     * Constructor
5377     */
5378      public DetailComponent(int sequence, CodeableConcept productOrService) {
5379        super();
5380        this.setSequence(sequence);
5381        this.setProductOrService(productOrService);
5382      }
5383
5384        /**
5385         * @return {@link #sequence} (A claim detail line. Either a simple (a product or service) or a 'group' of sub-details which are simple items.). This is the underlying object with id, value and extensions. The accessor "getSequence" gives direct access to the value
5386         */
5387        public PositiveIntType getSequenceElement() { 
5388          if (this.sequence == null)
5389            if (Configuration.errorOnAutoCreate())
5390              throw new Error("Attempt to auto-create DetailComponent.sequence");
5391            else if (Configuration.doAutoCreate())
5392              this.sequence = new PositiveIntType(); // bb
5393          return this.sequence;
5394        }
5395
5396        public boolean hasSequenceElement() { 
5397          return this.sequence != null && !this.sequence.isEmpty();
5398        }
5399
5400        public boolean hasSequence() { 
5401          return this.sequence != null && !this.sequence.isEmpty();
5402        }
5403
5404        /**
5405         * @param value {@link #sequence} (A claim detail line. Either a simple (a product or service) or a 'group' of sub-details which are simple items.). This is the underlying object with id, value and extensions. The accessor "getSequence" gives direct access to the value
5406         */
5407        public DetailComponent setSequenceElement(PositiveIntType value) { 
5408          this.sequence = value;
5409          return this;
5410        }
5411
5412        /**
5413         * @return A claim detail line. Either a simple (a product or service) or a 'group' of sub-details which are simple items.
5414         */
5415        public int getSequence() { 
5416          return this.sequence == null || this.sequence.isEmpty() ? 0 : this.sequence.getValue();
5417        }
5418
5419        /**
5420         * @param value A claim detail line. Either a simple (a product or service) or a 'group' of sub-details which are simple items.
5421         */
5422        public DetailComponent setSequence(int value) { 
5423            if (this.sequence == null)
5424              this.sequence = new PositiveIntType();
5425            this.sequence.setValue(value);
5426          return this;
5427        }
5428
5429        /**
5430         * @return {@link #revenue} (The type of revenue or cost center providing the product and/or service.)
5431         */
5432        public CodeableConcept getRevenue() { 
5433          if (this.revenue == null)
5434            if (Configuration.errorOnAutoCreate())
5435              throw new Error("Attempt to auto-create DetailComponent.revenue");
5436            else if (Configuration.doAutoCreate())
5437              this.revenue = new CodeableConcept(); // cc
5438          return this.revenue;
5439        }
5440
5441        public boolean hasRevenue() { 
5442          return this.revenue != null && !this.revenue.isEmpty();
5443        }
5444
5445        /**
5446         * @param value {@link #revenue} (The type of revenue or cost center providing the product and/or service.)
5447         */
5448        public DetailComponent setRevenue(CodeableConcept value) { 
5449          this.revenue = value;
5450          return this;
5451        }
5452
5453        /**
5454         * @return {@link #category} (Code to identify the general type of benefits under which products and services are provided.)
5455         */
5456        public CodeableConcept getCategory() { 
5457          if (this.category == null)
5458            if (Configuration.errorOnAutoCreate())
5459              throw new Error("Attempt to auto-create DetailComponent.category");
5460            else if (Configuration.doAutoCreate())
5461              this.category = new CodeableConcept(); // cc
5462          return this.category;
5463        }
5464
5465        public boolean hasCategory() { 
5466          return this.category != null && !this.category.isEmpty();
5467        }
5468
5469        /**
5470         * @param value {@link #category} (Code to identify the general type of benefits under which products and services are provided.)
5471         */
5472        public DetailComponent setCategory(CodeableConcept value) { 
5473          this.category = value;
5474          return this;
5475        }
5476
5477        /**
5478         * @return {@link #productOrService} (When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.)
5479         */
5480        public CodeableConcept getProductOrService() { 
5481          if (this.productOrService == null)
5482            if (Configuration.errorOnAutoCreate())
5483              throw new Error("Attempt to auto-create DetailComponent.productOrService");
5484            else if (Configuration.doAutoCreate())
5485              this.productOrService = new CodeableConcept(); // cc
5486          return this.productOrService;
5487        }
5488
5489        public boolean hasProductOrService() { 
5490          return this.productOrService != null && !this.productOrService.isEmpty();
5491        }
5492
5493        /**
5494         * @param value {@link #productOrService} (When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.)
5495         */
5496        public DetailComponent setProductOrService(CodeableConcept value) { 
5497          this.productOrService = value;
5498          return this;
5499        }
5500
5501        /**
5502         * @return {@link #modifier} (Item typification or modifiers codes to convey additional context for the product or service.)
5503         */
5504        public List<CodeableConcept> getModifier() { 
5505          if (this.modifier == null)
5506            this.modifier = new ArrayList<CodeableConcept>();
5507          return this.modifier;
5508        }
5509
5510        /**
5511         * @return Returns a reference to <code>this</code> for easy method chaining
5512         */
5513        public DetailComponent setModifier(List<CodeableConcept> theModifier) { 
5514          this.modifier = theModifier;
5515          return this;
5516        }
5517
5518        public boolean hasModifier() { 
5519          if (this.modifier == null)
5520            return false;
5521          for (CodeableConcept item : this.modifier)
5522            if (!item.isEmpty())
5523              return true;
5524          return false;
5525        }
5526
5527        public CodeableConcept addModifier() { //3
5528          CodeableConcept t = new CodeableConcept();
5529          if (this.modifier == null)
5530            this.modifier = new ArrayList<CodeableConcept>();
5531          this.modifier.add(t);
5532          return t;
5533        }
5534
5535        public DetailComponent addModifier(CodeableConcept t) { //3
5536          if (t == null)
5537            return this;
5538          if (this.modifier == null)
5539            this.modifier = new ArrayList<CodeableConcept>();
5540          this.modifier.add(t);
5541          return this;
5542        }
5543
5544        /**
5545         * @return The first repetition of repeating field {@link #modifier}, creating it if it does not already exist {3}
5546         */
5547        public CodeableConcept getModifierFirstRep() { 
5548          if (getModifier().isEmpty()) {
5549            addModifier();
5550          }
5551          return getModifier().get(0);
5552        }
5553
5554        /**
5555         * @return {@link #programCode} (Identifies the program under which this may be recovered.)
5556         */
5557        public List<CodeableConcept> getProgramCode() { 
5558          if (this.programCode == null)
5559            this.programCode = new ArrayList<CodeableConcept>();
5560          return this.programCode;
5561        }
5562
5563        /**
5564         * @return Returns a reference to <code>this</code> for easy method chaining
5565         */
5566        public DetailComponent setProgramCode(List<CodeableConcept> theProgramCode) { 
5567          this.programCode = theProgramCode;
5568          return this;
5569        }
5570
5571        public boolean hasProgramCode() { 
5572          if (this.programCode == null)
5573            return false;
5574          for (CodeableConcept item : this.programCode)
5575            if (!item.isEmpty())
5576              return true;
5577          return false;
5578        }
5579
5580        public CodeableConcept addProgramCode() { //3
5581          CodeableConcept t = new CodeableConcept();
5582          if (this.programCode == null)
5583            this.programCode = new ArrayList<CodeableConcept>();
5584          this.programCode.add(t);
5585          return t;
5586        }
5587
5588        public DetailComponent addProgramCode(CodeableConcept t) { //3
5589          if (t == null)
5590            return this;
5591          if (this.programCode == null)
5592            this.programCode = new ArrayList<CodeableConcept>();
5593          this.programCode.add(t);
5594          return this;
5595        }
5596
5597        /**
5598         * @return The first repetition of repeating field {@link #programCode}, creating it if it does not already exist {3}
5599         */
5600        public CodeableConcept getProgramCodeFirstRep() { 
5601          if (getProgramCode().isEmpty()) {
5602            addProgramCode();
5603          }
5604          return getProgramCode().get(0);
5605        }
5606
5607        /**
5608         * @return {@link #quantity} (The number of repetitions of a service or product.)
5609         */
5610        public Quantity getQuantity() { 
5611          if (this.quantity == null)
5612            if (Configuration.errorOnAutoCreate())
5613              throw new Error("Attempt to auto-create DetailComponent.quantity");
5614            else if (Configuration.doAutoCreate())
5615              this.quantity = new Quantity(); // cc
5616          return this.quantity;
5617        }
5618
5619        public boolean hasQuantity() { 
5620          return this.quantity != null && !this.quantity.isEmpty();
5621        }
5622
5623        /**
5624         * @param value {@link #quantity} (The number of repetitions of a service or product.)
5625         */
5626        public DetailComponent setQuantity(Quantity value) { 
5627          this.quantity = value;
5628          return this;
5629        }
5630
5631        /**
5632         * @return {@link #unitPrice} (If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.)
5633         */
5634        public Money getUnitPrice() { 
5635          if (this.unitPrice == null)
5636            if (Configuration.errorOnAutoCreate())
5637              throw new Error("Attempt to auto-create DetailComponent.unitPrice");
5638            else if (Configuration.doAutoCreate())
5639              this.unitPrice = new Money(); // cc
5640          return this.unitPrice;
5641        }
5642
5643        public boolean hasUnitPrice() { 
5644          return this.unitPrice != null && !this.unitPrice.isEmpty();
5645        }
5646
5647        /**
5648         * @param value {@link #unitPrice} (If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.)
5649         */
5650        public DetailComponent setUnitPrice(Money value) { 
5651          this.unitPrice = value;
5652          return this;
5653        }
5654
5655        /**
5656         * @return {@link #factor} (A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.). This is the underlying object with id, value and extensions. The accessor "getFactor" gives direct access to the value
5657         */
5658        public DecimalType getFactorElement() { 
5659          if (this.factor == null)
5660            if (Configuration.errorOnAutoCreate())
5661              throw new Error("Attempt to auto-create DetailComponent.factor");
5662            else if (Configuration.doAutoCreate())
5663              this.factor = new DecimalType(); // bb
5664          return this.factor;
5665        }
5666
5667        public boolean hasFactorElement() { 
5668          return this.factor != null && !this.factor.isEmpty();
5669        }
5670
5671        public boolean hasFactor() { 
5672          return this.factor != null && !this.factor.isEmpty();
5673        }
5674
5675        /**
5676         * @param value {@link #factor} (A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.). This is the underlying object with id, value and extensions. The accessor "getFactor" gives direct access to the value
5677         */
5678        public DetailComponent setFactorElement(DecimalType value) { 
5679          this.factor = value;
5680          return this;
5681        }
5682
5683        /**
5684         * @return A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
5685         */
5686        public BigDecimal getFactor() { 
5687          return this.factor == null ? null : this.factor.getValue();
5688        }
5689
5690        /**
5691         * @param value A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
5692         */
5693        public DetailComponent setFactor(BigDecimal value) { 
5694          if (value == null)
5695            this.factor = null;
5696          else {
5697            if (this.factor == null)
5698              this.factor = new DecimalType();
5699            this.factor.setValue(value);
5700          }
5701          return this;
5702        }
5703
5704        /**
5705         * @param value A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
5706         */
5707        public DetailComponent setFactor(long value) { 
5708              this.factor = new DecimalType();
5709            this.factor.setValue(value);
5710          return this;
5711        }
5712
5713        /**
5714         * @param value A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
5715         */
5716        public DetailComponent setFactor(double value) { 
5717              this.factor = new DecimalType();
5718            this.factor.setValue(value);
5719          return this;
5720        }
5721
5722        /**
5723         * @return {@link #net} (The quantity times the unit price for an additional service or product or charge.)
5724         */
5725        public Money getNet() { 
5726          if (this.net == null)
5727            if (Configuration.errorOnAutoCreate())
5728              throw new Error("Attempt to auto-create DetailComponent.net");
5729            else if (Configuration.doAutoCreate())
5730              this.net = new Money(); // cc
5731          return this.net;
5732        }
5733
5734        public boolean hasNet() { 
5735          return this.net != null && !this.net.isEmpty();
5736        }
5737
5738        /**
5739         * @param value {@link #net} (The quantity times the unit price for an additional service or product or charge.)
5740         */
5741        public DetailComponent setNet(Money value) { 
5742          this.net = value;
5743          return this;
5744        }
5745
5746        /**
5747         * @return {@link #udi} (Unique Device Identifiers associated with this line item.)
5748         */
5749        public List<Reference> getUdi() { 
5750          if (this.udi == null)
5751            this.udi = new ArrayList<Reference>();
5752          return this.udi;
5753        }
5754
5755        /**
5756         * @return Returns a reference to <code>this</code> for easy method chaining
5757         */
5758        public DetailComponent setUdi(List<Reference> theUdi) { 
5759          this.udi = theUdi;
5760          return this;
5761        }
5762
5763        public boolean hasUdi() { 
5764          if (this.udi == null)
5765            return false;
5766          for (Reference item : this.udi)
5767            if (!item.isEmpty())
5768              return true;
5769          return false;
5770        }
5771
5772        public Reference addUdi() { //3
5773          Reference t = new Reference();
5774          if (this.udi == null)
5775            this.udi = new ArrayList<Reference>();
5776          this.udi.add(t);
5777          return t;
5778        }
5779
5780        public DetailComponent addUdi(Reference t) { //3
5781          if (t == null)
5782            return this;
5783          if (this.udi == null)
5784            this.udi = new ArrayList<Reference>();
5785          this.udi.add(t);
5786          return this;
5787        }
5788
5789        /**
5790         * @return The first repetition of repeating field {@link #udi}, creating it if it does not already exist {3}
5791         */
5792        public Reference getUdiFirstRep() { 
5793          if (getUdi().isEmpty()) {
5794            addUdi();
5795          }
5796          return getUdi().get(0);
5797        }
5798
5799        /**
5800         * @return {@link #noteNumber} (The numbers associated with notes below which apply to the adjudication of this item.)
5801         */
5802        public List<PositiveIntType> getNoteNumber() { 
5803          if (this.noteNumber == null)
5804            this.noteNumber = new ArrayList<PositiveIntType>();
5805          return this.noteNumber;
5806        }
5807
5808        /**
5809         * @return Returns a reference to <code>this</code> for easy method chaining
5810         */
5811        public DetailComponent setNoteNumber(List<PositiveIntType> theNoteNumber) { 
5812          this.noteNumber = theNoteNumber;
5813          return this;
5814        }
5815
5816        public boolean hasNoteNumber() { 
5817          if (this.noteNumber == null)
5818            return false;
5819          for (PositiveIntType item : this.noteNumber)
5820            if (!item.isEmpty())
5821              return true;
5822          return false;
5823        }
5824
5825        /**
5826         * @return {@link #noteNumber} (The numbers associated with notes below which apply to the adjudication of this item.)
5827         */
5828        public PositiveIntType addNoteNumberElement() {//2 
5829          PositiveIntType t = new PositiveIntType();
5830          if (this.noteNumber == null)
5831            this.noteNumber = new ArrayList<PositiveIntType>();
5832          this.noteNumber.add(t);
5833          return t;
5834        }
5835
5836        /**
5837         * @param value {@link #noteNumber} (The numbers associated with notes below which apply to the adjudication of this item.)
5838         */
5839        public DetailComponent addNoteNumber(int value) { //1
5840          PositiveIntType t = new PositiveIntType();
5841          t.setValue(value);
5842          if (this.noteNumber == null)
5843            this.noteNumber = new ArrayList<PositiveIntType>();
5844          this.noteNumber.add(t);
5845          return this;
5846        }
5847
5848        /**
5849         * @param value {@link #noteNumber} (The numbers associated with notes below which apply to the adjudication of this item.)
5850         */
5851        public boolean hasNoteNumber(int value) { 
5852          if (this.noteNumber == null)
5853            return false;
5854          for (PositiveIntType v : this.noteNumber)
5855            if (v.getValue().equals(value)) // positiveInt
5856              return true;
5857          return false;
5858        }
5859
5860        /**
5861         * @return {@link #adjudication} (The adjudication results.)
5862         */
5863        public List<AdjudicationComponent> getAdjudication() { 
5864          if (this.adjudication == null)
5865            this.adjudication = new ArrayList<AdjudicationComponent>();
5866          return this.adjudication;
5867        }
5868
5869        /**
5870         * @return Returns a reference to <code>this</code> for easy method chaining
5871         */
5872        public DetailComponent setAdjudication(List<AdjudicationComponent> theAdjudication) { 
5873          this.adjudication = theAdjudication;
5874          return this;
5875        }
5876
5877        public boolean hasAdjudication() { 
5878          if (this.adjudication == null)
5879            return false;
5880          for (AdjudicationComponent item : this.adjudication)
5881            if (!item.isEmpty())
5882              return true;
5883          return false;
5884        }
5885
5886        public AdjudicationComponent addAdjudication() { //3
5887          AdjudicationComponent t = new AdjudicationComponent();
5888          if (this.adjudication == null)
5889            this.adjudication = new ArrayList<AdjudicationComponent>();
5890          this.adjudication.add(t);
5891          return t;
5892        }
5893
5894        public DetailComponent addAdjudication(AdjudicationComponent t) { //3
5895          if (t == null)
5896            return this;
5897          if (this.adjudication == null)
5898            this.adjudication = new ArrayList<AdjudicationComponent>();
5899          this.adjudication.add(t);
5900          return this;
5901        }
5902
5903        /**
5904         * @return The first repetition of repeating field {@link #adjudication}, creating it if it does not already exist {3}
5905         */
5906        public AdjudicationComponent getAdjudicationFirstRep() { 
5907          if (getAdjudication().isEmpty()) {
5908            addAdjudication();
5909          }
5910          return getAdjudication().get(0);
5911        }
5912
5913        /**
5914         * @return {@link #subDetail} (Third-tier of goods and services.)
5915         */
5916        public List<SubDetailComponent> getSubDetail() { 
5917          if (this.subDetail == null)
5918            this.subDetail = new ArrayList<SubDetailComponent>();
5919          return this.subDetail;
5920        }
5921
5922        /**
5923         * @return Returns a reference to <code>this</code> for easy method chaining
5924         */
5925        public DetailComponent setSubDetail(List<SubDetailComponent> theSubDetail) { 
5926          this.subDetail = theSubDetail;
5927          return this;
5928        }
5929
5930        public boolean hasSubDetail() { 
5931          if (this.subDetail == null)
5932            return false;
5933          for (SubDetailComponent item : this.subDetail)
5934            if (!item.isEmpty())
5935              return true;
5936          return false;
5937        }
5938
5939        public SubDetailComponent addSubDetail() { //3
5940          SubDetailComponent t = new SubDetailComponent();
5941          if (this.subDetail == null)
5942            this.subDetail = new ArrayList<SubDetailComponent>();
5943          this.subDetail.add(t);
5944          return t;
5945        }
5946
5947        public DetailComponent addSubDetail(SubDetailComponent t) { //3
5948          if (t == null)
5949            return this;
5950          if (this.subDetail == null)
5951            this.subDetail = new ArrayList<SubDetailComponent>();
5952          this.subDetail.add(t);
5953          return this;
5954        }
5955
5956        /**
5957         * @return The first repetition of repeating field {@link #subDetail}, creating it if it does not already exist {3}
5958         */
5959        public SubDetailComponent getSubDetailFirstRep() { 
5960          if (getSubDetail().isEmpty()) {
5961            addSubDetail();
5962          }
5963          return getSubDetail().get(0);
5964        }
5965
5966        protected void listChildren(List<Property> children) {
5967          super.listChildren(children);
5968          children.add(new Property("sequence", "positiveInt", "A claim detail line. Either a simple (a product or service) or a 'group' of sub-details which are simple items.", 0, 1, sequence));
5969          children.add(new Property("revenue", "CodeableConcept", "The type of revenue or cost center providing the product and/or service.", 0, 1, revenue));
5970          children.add(new Property("category", "CodeableConcept", "Code to identify the general type of benefits under which products and services are provided.", 0, 1, category));
5971          children.add(new Property("productOrService", "CodeableConcept", "When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.", 0, 1, productOrService));
5972          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));
5973          children.add(new Property("programCode", "CodeableConcept", "Identifies the program under which this may be recovered.", 0, java.lang.Integer.MAX_VALUE, programCode));
5974          children.add(new Property("quantity", "Quantity", "The number of repetitions of a service or product.", 0, 1, quantity));
5975          children.add(new Property("unitPrice", "Money", "If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.", 0, 1, unitPrice));
5976          children.add(new Property("factor", "decimal", "A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.", 0, 1, factor));
5977          children.add(new Property("net", "Money", "The quantity times the unit price for an additional service or product or charge.", 0, 1, net));
5978          children.add(new Property("udi", "Reference(Device)", "Unique Device Identifiers associated with this line item.", 0, java.lang.Integer.MAX_VALUE, udi));
5979          children.add(new Property("noteNumber", "positiveInt", "The numbers associated with notes below which apply to the adjudication of this item.", 0, java.lang.Integer.MAX_VALUE, noteNumber));
5980          children.add(new Property("adjudication", "@ExplanationOfBenefit.item.adjudication", "The adjudication results.", 0, java.lang.Integer.MAX_VALUE, adjudication));
5981          children.add(new Property("subDetail", "", "Third-tier of goods and services.", 0, java.lang.Integer.MAX_VALUE, subDetail));
5982        }
5983
5984        @Override
5985        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
5986          switch (_hash) {
5987          case 1349547969: /*sequence*/  return new Property("sequence", "positiveInt", "A claim detail line. Either a simple (a product or service) or a 'group' of sub-details which are simple items.", 0, 1, sequence);
5988          case 1099842588: /*revenue*/  return new Property("revenue", "CodeableConcept", "The type of revenue or cost center providing the product and/or service.", 0, 1, revenue);
5989          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);
5990          case 1957227299: /*productOrService*/  return new Property("productOrService", "CodeableConcept", "When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.", 0, 1, productOrService);
5991          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);
5992          case 1010065041: /*programCode*/  return new Property("programCode", "CodeableConcept", "Identifies the program under which this may be recovered.", 0, java.lang.Integer.MAX_VALUE, programCode);
5993          case -1285004149: /*quantity*/  return new Property("quantity", "Quantity", "The number of repetitions of a service or product.", 0, 1, quantity);
5994          case -486196699: /*unitPrice*/  return new Property("unitPrice", "Money", "If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.", 0, 1, unitPrice);
5995          case -1282148017: /*factor*/  return new Property("factor", "decimal", "A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.", 0, 1, factor);
5996          case 108957: /*net*/  return new Property("net", "Money", "The quantity times the unit price for an additional service or product or charge.", 0, 1, net);
5997          case 115642: /*udi*/  return new Property("udi", "Reference(Device)", "Unique Device Identifiers associated with this line item.", 0, java.lang.Integer.MAX_VALUE, udi);
5998          case -1110033957: /*noteNumber*/  return new Property("noteNumber", "positiveInt", "The numbers associated with notes below which apply to the adjudication of this item.", 0, java.lang.Integer.MAX_VALUE, noteNumber);
5999          case -231349275: /*adjudication*/  return new Property("adjudication", "@ExplanationOfBenefit.item.adjudication", "The adjudication results.", 0, java.lang.Integer.MAX_VALUE, adjudication);
6000          case -828829007: /*subDetail*/  return new Property("subDetail", "", "Third-tier of goods and services.", 0, java.lang.Integer.MAX_VALUE, subDetail);
6001          default: return super.getNamedProperty(_hash, _name, _checkValid);
6002          }
6003
6004        }
6005
6006      @Override
6007      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
6008        switch (hash) {
6009        case 1349547969: /*sequence*/ return this.sequence == null ? new Base[0] : new Base[] {this.sequence}; // PositiveIntType
6010        case 1099842588: /*revenue*/ return this.revenue == null ? new Base[0] : new Base[] {this.revenue}; // CodeableConcept
6011        case 50511102: /*category*/ return this.category == null ? new Base[0] : new Base[] {this.category}; // CodeableConcept
6012        case 1957227299: /*productOrService*/ return this.productOrService == null ? new Base[0] : new Base[] {this.productOrService}; // CodeableConcept
6013        case -615513385: /*modifier*/ return this.modifier == null ? new Base[0] : this.modifier.toArray(new Base[this.modifier.size()]); // CodeableConcept
6014        case 1010065041: /*programCode*/ return this.programCode == null ? new Base[0] : this.programCode.toArray(new Base[this.programCode.size()]); // CodeableConcept
6015        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // Quantity
6016        case -486196699: /*unitPrice*/ return this.unitPrice == null ? new Base[0] : new Base[] {this.unitPrice}; // Money
6017        case -1282148017: /*factor*/ return this.factor == null ? new Base[0] : new Base[] {this.factor}; // DecimalType
6018        case 108957: /*net*/ return this.net == null ? new Base[0] : new Base[] {this.net}; // Money
6019        case 115642: /*udi*/ return this.udi == null ? new Base[0] : this.udi.toArray(new Base[this.udi.size()]); // Reference
6020        case -1110033957: /*noteNumber*/ return this.noteNumber == null ? new Base[0] : this.noteNumber.toArray(new Base[this.noteNumber.size()]); // PositiveIntType
6021        case -231349275: /*adjudication*/ return this.adjudication == null ? new Base[0] : this.adjudication.toArray(new Base[this.adjudication.size()]); // AdjudicationComponent
6022        case -828829007: /*subDetail*/ return this.subDetail == null ? new Base[0] : this.subDetail.toArray(new Base[this.subDetail.size()]); // SubDetailComponent
6023        default: return super.getProperty(hash, name, checkValid);
6024        }
6025
6026      }
6027
6028      @Override
6029      public Base setProperty(int hash, String name, Base value) throws FHIRException {
6030        switch (hash) {
6031        case 1349547969: // sequence
6032          this.sequence = TypeConvertor.castToPositiveInt(value); // PositiveIntType
6033          return value;
6034        case 1099842588: // revenue
6035          this.revenue = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
6036          return value;
6037        case 50511102: // category
6038          this.category = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
6039          return value;
6040        case 1957227299: // productOrService
6041          this.productOrService = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
6042          return value;
6043        case -615513385: // modifier
6044          this.getModifier().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
6045          return value;
6046        case 1010065041: // programCode
6047          this.getProgramCode().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
6048          return value;
6049        case -1285004149: // quantity
6050          this.quantity = TypeConvertor.castToQuantity(value); // Quantity
6051          return value;
6052        case -486196699: // unitPrice
6053          this.unitPrice = TypeConvertor.castToMoney(value); // Money
6054          return value;
6055        case -1282148017: // factor
6056          this.factor = TypeConvertor.castToDecimal(value); // DecimalType
6057          return value;
6058        case 108957: // net
6059          this.net = TypeConvertor.castToMoney(value); // Money
6060          return value;
6061        case 115642: // udi
6062          this.getUdi().add(TypeConvertor.castToReference(value)); // Reference
6063          return value;
6064        case -1110033957: // noteNumber
6065          this.getNoteNumber().add(TypeConvertor.castToPositiveInt(value)); // PositiveIntType
6066          return value;
6067        case -231349275: // adjudication
6068          this.getAdjudication().add((AdjudicationComponent) value); // AdjudicationComponent
6069          return value;
6070        case -828829007: // subDetail
6071          this.getSubDetail().add((SubDetailComponent) value); // SubDetailComponent
6072          return value;
6073        default: return super.setProperty(hash, name, value);
6074        }
6075
6076      }
6077
6078      @Override
6079      public Base setProperty(String name, Base value) throws FHIRException {
6080        if (name.equals("sequence")) {
6081          this.sequence = TypeConvertor.castToPositiveInt(value); // PositiveIntType
6082        } else if (name.equals("revenue")) {
6083          this.revenue = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
6084        } else if (name.equals("category")) {
6085          this.category = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
6086        } else if (name.equals("productOrService")) {
6087          this.productOrService = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
6088        } else if (name.equals("modifier")) {
6089          this.getModifier().add(TypeConvertor.castToCodeableConcept(value));
6090        } else if (name.equals("programCode")) {
6091          this.getProgramCode().add(TypeConvertor.castToCodeableConcept(value));
6092        } else if (name.equals("quantity")) {
6093          this.quantity = TypeConvertor.castToQuantity(value); // Quantity
6094        } else if (name.equals("unitPrice")) {
6095          this.unitPrice = TypeConvertor.castToMoney(value); // Money
6096        } else if (name.equals("factor")) {
6097          this.factor = TypeConvertor.castToDecimal(value); // DecimalType
6098        } else if (name.equals("net")) {
6099          this.net = TypeConvertor.castToMoney(value); // Money
6100        } else if (name.equals("udi")) {
6101          this.getUdi().add(TypeConvertor.castToReference(value));
6102        } else if (name.equals("noteNumber")) {
6103          this.getNoteNumber().add(TypeConvertor.castToPositiveInt(value));
6104        } else if (name.equals("adjudication")) {
6105          this.getAdjudication().add((AdjudicationComponent) value);
6106        } else if (name.equals("subDetail")) {
6107          this.getSubDetail().add((SubDetailComponent) value);
6108        } else
6109          return super.setProperty(name, value);
6110        return value;
6111      }
6112
6113      @Override
6114      public Base makeProperty(int hash, String name) throws FHIRException {
6115        switch (hash) {
6116        case 1349547969:  return getSequenceElement();
6117        case 1099842588:  return getRevenue();
6118        case 50511102:  return getCategory();
6119        case 1957227299:  return getProductOrService();
6120        case -615513385:  return addModifier(); 
6121        case 1010065041:  return addProgramCode(); 
6122        case -1285004149:  return getQuantity();
6123        case -486196699:  return getUnitPrice();
6124        case -1282148017:  return getFactorElement();
6125        case 108957:  return getNet();
6126        case 115642:  return addUdi(); 
6127        case -1110033957:  return addNoteNumberElement();
6128        case -231349275:  return addAdjudication(); 
6129        case -828829007:  return addSubDetail(); 
6130        default: return super.makeProperty(hash, name);
6131        }
6132
6133      }
6134
6135      @Override
6136      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
6137        switch (hash) {
6138        case 1349547969: /*sequence*/ return new String[] {"positiveInt"};
6139        case 1099842588: /*revenue*/ return new String[] {"CodeableConcept"};
6140        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
6141        case 1957227299: /*productOrService*/ return new String[] {"CodeableConcept"};
6142        case -615513385: /*modifier*/ return new String[] {"CodeableConcept"};
6143        case 1010065041: /*programCode*/ return new String[] {"CodeableConcept"};
6144        case -1285004149: /*quantity*/ return new String[] {"Quantity"};
6145        case -486196699: /*unitPrice*/ return new String[] {"Money"};
6146        case -1282148017: /*factor*/ return new String[] {"decimal"};
6147        case 108957: /*net*/ return new String[] {"Money"};
6148        case 115642: /*udi*/ return new String[] {"Reference"};
6149        case -1110033957: /*noteNumber*/ return new String[] {"positiveInt"};
6150        case -231349275: /*adjudication*/ return new String[] {"@ExplanationOfBenefit.item.adjudication"};
6151        case -828829007: /*subDetail*/ return new String[] {};
6152        default: return super.getTypesForProperty(hash, name);
6153        }
6154
6155      }
6156
6157      @Override
6158      public Base addChild(String name) throws FHIRException {
6159        if (name.equals("sequence")) {
6160          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.item.detail.sequence");
6161        }
6162        else if (name.equals("revenue")) {
6163          this.revenue = new CodeableConcept();
6164          return this.revenue;
6165        }
6166        else if (name.equals("category")) {
6167          this.category = new CodeableConcept();
6168          return this.category;
6169        }
6170        else if (name.equals("productOrService")) {
6171          this.productOrService = new CodeableConcept();
6172          return this.productOrService;
6173        }
6174        else if (name.equals("modifier")) {
6175          return addModifier();
6176        }
6177        else if (name.equals("programCode")) {
6178          return addProgramCode();
6179        }
6180        else if (name.equals("quantity")) {
6181          this.quantity = new Quantity();
6182          return this.quantity;
6183        }
6184        else if (name.equals("unitPrice")) {
6185          this.unitPrice = new Money();
6186          return this.unitPrice;
6187        }
6188        else if (name.equals("factor")) {
6189          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.item.detail.factor");
6190        }
6191        else if (name.equals("net")) {
6192          this.net = new Money();
6193          return this.net;
6194        }
6195        else if (name.equals("udi")) {
6196          return addUdi();
6197        }
6198        else if (name.equals("noteNumber")) {
6199          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.item.detail.noteNumber");
6200        }
6201        else if (name.equals("adjudication")) {
6202          return addAdjudication();
6203        }
6204        else if (name.equals("subDetail")) {
6205          return addSubDetail();
6206        }
6207        else
6208          return super.addChild(name);
6209      }
6210
6211      public DetailComponent copy() {
6212        DetailComponent dst = new DetailComponent();
6213        copyValues(dst);
6214        return dst;
6215      }
6216
6217      public void copyValues(DetailComponent dst) {
6218        super.copyValues(dst);
6219        dst.sequence = sequence == null ? null : sequence.copy();
6220        dst.revenue = revenue == null ? null : revenue.copy();
6221        dst.category = category == null ? null : category.copy();
6222        dst.productOrService = productOrService == null ? null : productOrService.copy();
6223        if (modifier != null) {
6224          dst.modifier = new ArrayList<CodeableConcept>();
6225          for (CodeableConcept i : modifier)
6226            dst.modifier.add(i.copy());
6227        };
6228        if (programCode != null) {
6229          dst.programCode = new ArrayList<CodeableConcept>();
6230          for (CodeableConcept i : programCode)
6231            dst.programCode.add(i.copy());
6232        };
6233        dst.quantity = quantity == null ? null : quantity.copy();
6234        dst.unitPrice = unitPrice == null ? null : unitPrice.copy();
6235        dst.factor = factor == null ? null : factor.copy();
6236        dst.net = net == null ? null : net.copy();
6237        if (udi != null) {
6238          dst.udi = new ArrayList<Reference>();
6239          for (Reference i : udi)
6240            dst.udi.add(i.copy());
6241        };
6242        if (noteNumber != null) {
6243          dst.noteNumber = new ArrayList<PositiveIntType>();
6244          for (PositiveIntType i : noteNumber)
6245            dst.noteNumber.add(i.copy());
6246        };
6247        if (adjudication != null) {
6248          dst.adjudication = new ArrayList<AdjudicationComponent>();
6249          for (AdjudicationComponent i : adjudication)
6250            dst.adjudication.add(i.copy());
6251        };
6252        if (subDetail != null) {
6253          dst.subDetail = new ArrayList<SubDetailComponent>();
6254          for (SubDetailComponent i : subDetail)
6255            dst.subDetail.add(i.copy());
6256        };
6257      }
6258
6259      @Override
6260      public boolean equalsDeep(Base other_) {
6261        if (!super.equalsDeep(other_))
6262          return false;
6263        if (!(other_ instanceof DetailComponent))
6264          return false;
6265        DetailComponent o = (DetailComponent) other_;
6266        return compareDeep(sequence, o.sequence, true) && compareDeep(revenue, o.revenue, true) && compareDeep(category, o.category, true)
6267           && compareDeep(productOrService, o.productOrService, true) && compareDeep(modifier, o.modifier, true)
6268           && compareDeep(programCode, o.programCode, true) && compareDeep(quantity, o.quantity, true) && compareDeep(unitPrice, o.unitPrice, true)
6269           && compareDeep(factor, o.factor, true) && compareDeep(net, o.net, true) && compareDeep(udi, o.udi, true)
6270           && compareDeep(noteNumber, o.noteNumber, true) && compareDeep(adjudication, o.adjudication, true)
6271           && compareDeep(subDetail, o.subDetail, true);
6272      }
6273
6274      @Override
6275      public boolean equalsShallow(Base other_) {
6276        if (!super.equalsShallow(other_))
6277          return false;
6278        if (!(other_ instanceof DetailComponent))
6279          return false;
6280        DetailComponent o = (DetailComponent) other_;
6281        return compareValues(sequence, o.sequence, true) && compareValues(factor, o.factor, true) && compareValues(noteNumber, o.noteNumber, true)
6282          ;
6283      }
6284
6285      public boolean isEmpty() {
6286        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(sequence, revenue, category
6287          , productOrService, modifier, programCode, quantity, unitPrice, factor, net, udi
6288          , noteNumber, adjudication, subDetail);
6289      }
6290
6291  public String fhirType() {
6292    return "ExplanationOfBenefit.item.detail";
6293
6294  }
6295
6296  }
6297
6298    @Block()
6299    public static class SubDetailComponent extends BackboneElement implements IBaseBackboneElement {
6300        /**
6301         * A claim detail line. Either a simple (a product or service) or a 'group' of sub-details which are simple items.
6302         */
6303        @Child(name = "sequence", type = {PositiveIntType.class}, order=1, min=1, max=1, modifier=false, summary=false)
6304        @Description(shortDefinition="Product or service provided", formalDefinition="A claim detail line. Either a simple (a product or service) or a 'group' of sub-details which are simple items." )
6305        protected PositiveIntType sequence;
6306
6307        /**
6308         * The type of revenue or cost center providing the product and/or service.
6309         */
6310        @Child(name = "revenue", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
6311        @Description(shortDefinition="Revenue or cost center code", formalDefinition="The type of revenue or cost center providing the product and/or service." )
6312        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/ex-revenue-center")
6313        protected CodeableConcept revenue;
6314
6315        /**
6316         * Code to identify the general type of benefits under which products and services are provided.
6317         */
6318        @Child(name = "category", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=false)
6319        @Description(shortDefinition="Benefit classification", formalDefinition="Code to identify the general type of benefits under which products and services are provided." )
6320        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/ex-benefitcategory")
6321        protected CodeableConcept category;
6322
6323        /**
6324         * When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.
6325         */
6326        @Child(name = "productOrService", type = {CodeableConcept.class}, order=4, min=1, max=1, modifier=false, summary=false)
6327        @Description(shortDefinition="Billing, service, product, or drug code", formalDefinition="When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item." )
6328        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/service-uscls")
6329        protected CodeableConcept productOrService;
6330
6331        /**
6332         * Item typification or modifiers codes to convey additional context for the product or service.
6333         */
6334        @Child(name = "modifier", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
6335        @Description(shortDefinition="Service/Product billing modifiers", formalDefinition="Item typification or modifiers codes to convey additional context for the product or service." )
6336        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/claim-modifiers")
6337        protected List<CodeableConcept> modifier;
6338
6339        /**
6340         * Identifies the program under which this may be recovered.
6341         */
6342        @Child(name = "programCode", type = {CodeableConcept.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
6343        @Description(shortDefinition="Program the product or service is provided under", formalDefinition="Identifies the program under which this may be recovered." )
6344        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/ex-program-code")
6345        protected List<CodeableConcept> programCode;
6346
6347        /**
6348         * The number of repetitions of a service or product.
6349         */
6350        @Child(name = "quantity", type = {Quantity.class}, order=7, min=0, max=1, modifier=false, summary=false)
6351        @Description(shortDefinition="Count of products or services", formalDefinition="The number of repetitions of a service or product." )
6352        protected Quantity quantity;
6353
6354        /**
6355         * If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.
6356         */
6357        @Child(name = "unitPrice", type = {Money.class}, order=8, min=0, max=1, modifier=false, summary=false)
6358        @Description(shortDefinition="Fee, charge or cost per item", formalDefinition="If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group." )
6359        protected Money unitPrice;
6360
6361        /**
6362         * A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
6363         */
6364        @Child(name = "factor", type = {DecimalType.class}, order=9, min=0, max=1, modifier=false, summary=false)
6365        @Description(shortDefinition="Price scaling factor", formalDefinition="A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount." )
6366        protected DecimalType factor;
6367
6368        /**
6369         * The quantity times the unit price for an additional service or product or charge.
6370         */
6371        @Child(name = "net", type = {Money.class}, order=10, min=0, max=1, modifier=false, summary=false)
6372        @Description(shortDefinition="Total item cost", formalDefinition="The quantity times the unit price for an additional service or product or charge." )
6373        protected Money net;
6374
6375        /**
6376         * Unique Device Identifiers associated with this line item.
6377         */
6378        @Child(name = "udi", type = {Device.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
6379        @Description(shortDefinition="Unique device identifier", formalDefinition="Unique Device Identifiers associated with this line item." )
6380        protected List<Reference> udi;
6381
6382        /**
6383         * The numbers associated with notes below which apply to the adjudication of this item.
6384         */
6385        @Child(name = "noteNumber", type = {PositiveIntType.class}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
6386        @Description(shortDefinition="Applicable note numbers", formalDefinition="The numbers associated with notes below which apply to the adjudication of this item." )
6387        protected List<PositiveIntType> noteNumber;
6388
6389        /**
6390         * The adjudication results.
6391         */
6392        @Child(name = "adjudication", type = {AdjudicationComponent.class}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
6393        @Description(shortDefinition="Subdetail level adjudication details", formalDefinition="The adjudication results." )
6394        protected List<AdjudicationComponent> adjudication;
6395
6396        private static final long serialVersionUID = -579551678L;
6397
6398    /**
6399     * Constructor
6400     */
6401      public SubDetailComponent() {
6402        super();
6403      }
6404
6405    /**
6406     * Constructor
6407     */
6408      public SubDetailComponent(int sequence, CodeableConcept productOrService) {
6409        super();
6410        this.setSequence(sequence);
6411        this.setProductOrService(productOrService);
6412      }
6413
6414        /**
6415         * @return {@link #sequence} (A claim detail line. Either a simple (a product or service) or a 'group' of sub-details which are simple items.). This is the underlying object with id, value and extensions. The accessor "getSequence" gives direct access to the value
6416         */
6417        public PositiveIntType getSequenceElement() { 
6418          if (this.sequence == null)
6419            if (Configuration.errorOnAutoCreate())
6420              throw new Error("Attempt to auto-create SubDetailComponent.sequence");
6421            else if (Configuration.doAutoCreate())
6422              this.sequence = new PositiveIntType(); // bb
6423          return this.sequence;
6424        }
6425
6426        public boolean hasSequenceElement() { 
6427          return this.sequence != null && !this.sequence.isEmpty();
6428        }
6429
6430        public boolean hasSequence() { 
6431          return this.sequence != null && !this.sequence.isEmpty();
6432        }
6433
6434        /**
6435         * @param value {@link #sequence} (A claim detail line. Either a simple (a product or service) or a 'group' of sub-details which are simple items.). This is the underlying object with id, value and extensions. The accessor "getSequence" gives direct access to the value
6436         */
6437        public SubDetailComponent setSequenceElement(PositiveIntType value) { 
6438          this.sequence = value;
6439          return this;
6440        }
6441
6442        /**
6443         * @return A claim detail line. Either a simple (a product or service) or a 'group' of sub-details which are simple items.
6444         */
6445        public int getSequence() { 
6446          return this.sequence == null || this.sequence.isEmpty() ? 0 : this.sequence.getValue();
6447        }
6448
6449        /**
6450         * @param value A claim detail line. Either a simple (a product or service) or a 'group' of sub-details which are simple items.
6451         */
6452        public SubDetailComponent setSequence(int value) { 
6453            if (this.sequence == null)
6454              this.sequence = new PositiveIntType();
6455            this.sequence.setValue(value);
6456          return this;
6457        }
6458
6459        /**
6460         * @return {@link #revenue} (The type of revenue or cost center providing the product and/or service.)
6461         */
6462        public CodeableConcept getRevenue() { 
6463          if (this.revenue == null)
6464            if (Configuration.errorOnAutoCreate())
6465              throw new Error("Attempt to auto-create SubDetailComponent.revenue");
6466            else if (Configuration.doAutoCreate())
6467              this.revenue = new CodeableConcept(); // cc
6468          return this.revenue;
6469        }
6470
6471        public boolean hasRevenue() { 
6472          return this.revenue != null && !this.revenue.isEmpty();
6473        }
6474
6475        /**
6476         * @param value {@link #revenue} (The type of revenue or cost center providing the product and/or service.)
6477         */
6478        public SubDetailComponent setRevenue(CodeableConcept value) { 
6479          this.revenue = value;
6480          return this;
6481        }
6482
6483        /**
6484         * @return {@link #category} (Code to identify the general type of benefits under which products and services are provided.)
6485         */
6486        public CodeableConcept getCategory() { 
6487          if (this.category == null)
6488            if (Configuration.errorOnAutoCreate())
6489              throw new Error("Attempt to auto-create SubDetailComponent.category");
6490            else if (Configuration.doAutoCreate())
6491              this.category = new CodeableConcept(); // cc
6492          return this.category;
6493        }
6494
6495        public boolean hasCategory() { 
6496          return this.category != null && !this.category.isEmpty();
6497        }
6498
6499        /**
6500         * @param value {@link #category} (Code to identify the general type of benefits under which products and services are provided.)
6501         */
6502        public SubDetailComponent setCategory(CodeableConcept value) { 
6503          this.category = value;
6504          return this;
6505        }
6506
6507        /**
6508         * @return {@link #productOrService} (When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.)
6509         */
6510        public CodeableConcept getProductOrService() { 
6511          if (this.productOrService == null)
6512            if (Configuration.errorOnAutoCreate())
6513              throw new Error("Attempt to auto-create SubDetailComponent.productOrService");
6514            else if (Configuration.doAutoCreate())
6515              this.productOrService = new CodeableConcept(); // cc
6516          return this.productOrService;
6517        }
6518
6519        public boolean hasProductOrService() { 
6520          return this.productOrService != null && !this.productOrService.isEmpty();
6521        }
6522
6523        /**
6524         * @param value {@link #productOrService} (When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.)
6525         */
6526        public SubDetailComponent setProductOrService(CodeableConcept value) { 
6527          this.productOrService = value;
6528          return this;
6529        }
6530
6531        /**
6532         * @return {@link #modifier} (Item typification or modifiers codes to convey additional context for the product or service.)
6533         */
6534        public List<CodeableConcept> getModifier() { 
6535          if (this.modifier == null)
6536            this.modifier = new ArrayList<CodeableConcept>();
6537          return this.modifier;
6538        }
6539
6540        /**
6541         * @return Returns a reference to <code>this</code> for easy method chaining
6542         */
6543        public SubDetailComponent setModifier(List<CodeableConcept> theModifier) { 
6544          this.modifier = theModifier;
6545          return this;
6546        }
6547
6548        public boolean hasModifier() { 
6549          if (this.modifier == null)
6550            return false;
6551          for (CodeableConcept item : this.modifier)
6552            if (!item.isEmpty())
6553              return true;
6554          return false;
6555        }
6556
6557        public CodeableConcept addModifier() { //3
6558          CodeableConcept t = new CodeableConcept();
6559          if (this.modifier == null)
6560            this.modifier = new ArrayList<CodeableConcept>();
6561          this.modifier.add(t);
6562          return t;
6563        }
6564
6565        public SubDetailComponent addModifier(CodeableConcept t) { //3
6566          if (t == null)
6567            return this;
6568          if (this.modifier == null)
6569            this.modifier = new ArrayList<CodeableConcept>();
6570          this.modifier.add(t);
6571          return this;
6572        }
6573
6574        /**
6575         * @return The first repetition of repeating field {@link #modifier}, creating it if it does not already exist {3}
6576         */
6577        public CodeableConcept getModifierFirstRep() { 
6578          if (getModifier().isEmpty()) {
6579            addModifier();
6580          }
6581          return getModifier().get(0);
6582        }
6583
6584        /**
6585         * @return {@link #programCode} (Identifies the program under which this may be recovered.)
6586         */
6587        public List<CodeableConcept> getProgramCode() { 
6588          if (this.programCode == null)
6589            this.programCode = new ArrayList<CodeableConcept>();
6590          return this.programCode;
6591        }
6592
6593        /**
6594         * @return Returns a reference to <code>this</code> for easy method chaining
6595         */
6596        public SubDetailComponent setProgramCode(List<CodeableConcept> theProgramCode) { 
6597          this.programCode = theProgramCode;
6598          return this;
6599        }
6600
6601        public boolean hasProgramCode() { 
6602          if (this.programCode == null)
6603            return false;
6604          for (CodeableConcept item : this.programCode)
6605            if (!item.isEmpty())
6606              return true;
6607          return false;
6608        }
6609
6610        public CodeableConcept addProgramCode() { //3
6611          CodeableConcept t = new CodeableConcept();
6612          if (this.programCode == null)
6613            this.programCode = new ArrayList<CodeableConcept>();
6614          this.programCode.add(t);
6615          return t;
6616        }
6617
6618        public SubDetailComponent addProgramCode(CodeableConcept t) { //3
6619          if (t == null)
6620            return this;
6621          if (this.programCode == null)
6622            this.programCode = new ArrayList<CodeableConcept>();
6623          this.programCode.add(t);
6624          return this;
6625        }
6626
6627        /**
6628         * @return The first repetition of repeating field {@link #programCode}, creating it if it does not already exist {3}
6629         */
6630        public CodeableConcept getProgramCodeFirstRep() { 
6631          if (getProgramCode().isEmpty()) {
6632            addProgramCode();
6633          }
6634          return getProgramCode().get(0);
6635        }
6636
6637        /**
6638         * @return {@link #quantity} (The number of repetitions of a service or product.)
6639         */
6640        public Quantity getQuantity() { 
6641          if (this.quantity == null)
6642            if (Configuration.errorOnAutoCreate())
6643              throw new Error("Attempt to auto-create SubDetailComponent.quantity");
6644            else if (Configuration.doAutoCreate())
6645              this.quantity = new Quantity(); // cc
6646          return this.quantity;
6647        }
6648
6649        public boolean hasQuantity() { 
6650          return this.quantity != null && !this.quantity.isEmpty();
6651        }
6652
6653        /**
6654         * @param value {@link #quantity} (The number of repetitions of a service or product.)
6655         */
6656        public SubDetailComponent setQuantity(Quantity value) { 
6657          this.quantity = value;
6658          return this;
6659        }
6660
6661        /**
6662         * @return {@link #unitPrice} (If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.)
6663         */
6664        public Money getUnitPrice() { 
6665          if (this.unitPrice == null)
6666            if (Configuration.errorOnAutoCreate())
6667              throw new Error("Attempt to auto-create SubDetailComponent.unitPrice");
6668            else if (Configuration.doAutoCreate())
6669              this.unitPrice = new Money(); // cc
6670          return this.unitPrice;
6671        }
6672
6673        public boolean hasUnitPrice() { 
6674          return this.unitPrice != null && !this.unitPrice.isEmpty();
6675        }
6676
6677        /**
6678         * @param value {@link #unitPrice} (If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.)
6679         */
6680        public SubDetailComponent setUnitPrice(Money value) { 
6681          this.unitPrice = value;
6682          return this;
6683        }
6684
6685        /**
6686         * @return {@link #factor} (A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.). This is the underlying object with id, value and extensions. The accessor "getFactor" gives direct access to the value
6687         */
6688        public DecimalType getFactorElement() { 
6689          if (this.factor == null)
6690            if (Configuration.errorOnAutoCreate())
6691              throw new Error("Attempt to auto-create SubDetailComponent.factor");
6692            else if (Configuration.doAutoCreate())
6693              this.factor = new DecimalType(); // bb
6694          return this.factor;
6695        }
6696
6697        public boolean hasFactorElement() { 
6698          return this.factor != null && !this.factor.isEmpty();
6699        }
6700
6701        public boolean hasFactor() { 
6702          return this.factor != null && !this.factor.isEmpty();
6703        }
6704
6705        /**
6706         * @param value {@link #factor} (A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.). This is the underlying object with id, value and extensions. The accessor "getFactor" gives direct access to the value
6707         */
6708        public SubDetailComponent setFactorElement(DecimalType value) { 
6709          this.factor = value;
6710          return this;
6711        }
6712
6713        /**
6714         * @return A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
6715         */
6716        public BigDecimal getFactor() { 
6717          return this.factor == null ? null : this.factor.getValue();
6718        }
6719
6720        /**
6721         * @param value A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
6722         */
6723        public SubDetailComponent setFactor(BigDecimal value) { 
6724          if (value == null)
6725            this.factor = null;
6726          else {
6727            if (this.factor == null)
6728              this.factor = new DecimalType();
6729            this.factor.setValue(value);
6730          }
6731          return this;
6732        }
6733
6734        /**
6735         * @param value A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
6736         */
6737        public SubDetailComponent setFactor(long value) { 
6738              this.factor = new DecimalType();
6739            this.factor.setValue(value);
6740          return this;
6741        }
6742
6743        /**
6744         * @param value A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
6745         */
6746        public SubDetailComponent setFactor(double value) { 
6747              this.factor = new DecimalType();
6748            this.factor.setValue(value);
6749          return this;
6750        }
6751
6752        /**
6753         * @return {@link #net} (The quantity times the unit price for an additional service or product or charge.)
6754         */
6755        public Money getNet() { 
6756          if (this.net == null)
6757            if (Configuration.errorOnAutoCreate())
6758              throw new Error("Attempt to auto-create SubDetailComponent.net");
6759            else if (Configuration.doAutoCreate())
6760              this.net = new Money(); // cc
6761          return this.net;
6762        }
6763
6764        public boolean hasNet() { 
6765          return this.net != null && !this.net.isEmpty();
6766        }
6767
6768        /**
6769         * @param value {@link #net} (The quantity times the unit price for an additional service or product or charge.)
6770         */
6771        public SubDetailComponent setNet(Money value) { 
6772          this.net = value;
6773          return this;
6774        }
6775
6776        /**
6777         * @return {@link #udi} (Unique Device Identifiers associated with this line item.)
6778         */
6779        public List<Reference> getUdi() { 
6780          if (this.udi == null)
6781            this.udi = new ArrayList<Reference>();
6782          return this.udi;
6783        }
6784
6785        /**
6786         * @return Returns a reference to <code>this</code> for easy method chaining
6787         */
6788        public SubDetailComponent setUdi(List<Reference> theUdi) { 
6789          this.udi = theUdi;
6790          return this;
6791        }
6792
6793        public boolean hasUdi() { 
6794          if (this.udi == null)
6795            return false;
6796          for (Reference item : this.udi)
6797            if (!item.isEmpty())
6798              return true;
6799          return false;
6800        }
6801
6802        public Reference addUdi() { //3
6803          Reference t = new Reference();
6804          if (this.udi == null)
6805            this.udi = new ArrayList<Reference>();
6806          this.udi.add(t);
6807          return t;
6808        }
6809
6810        public SubDetailComponent addUdi(Reference t) { //3
6811          if (t == null)
6812            return this;
6813          if (this.udi == null)
6814            this.udi = new ArrayList<Reference>();
6815          this.udi.add(t);
6816          return this;
6817        }
6818
6819        /**
6820         * @return The first repetition of repeating field {@link #udi}, creating it if it does not already exist {3}
6821         */
6822        public Reference getUdiFirstRep() { 
6823          if (getUdi().isEmpty()) {
6824            addUdi();
6825          }
6826          return getUdi().get(0);
6827        }
6828
6829        /**
6830         * @return {@link #noteNumber} (The numbers associated with notes below which apply to the adjudication of this item.)
6831         */
6832        public List<PositiveIntType> getNoteNumber() { 
6833          if (this.noteNumber == null)
6834            this.noteNumber = new ArrayList<PositiveIntType>();
6835          return this.noteNumber;
6836        }
6837
6838        /**
6839         * @return Returns a reference to <code>this</code> for easy method chaining
6840         */
6841        public SubDetailComponent setNoteNumber(List<PositiveIntType> theNoteNumber) { 
6842          this.noteNumber = theNoteNumber;
6843          return this;
6844        }
6845
6846        public boolean hasNoteNumber() { 
6847          if (this.noteNumber == null)
6848            return false;
6849          for (PositiveIntType item : this.noteNumber)
6850            if (!item.isEmpty())
6851              return true;
6852          return false;
6853        }
6854
6855        /**
6856         * @return {@link #noteNumber} (The numbers associated with notes below which apply to the adjudication of this item.)
6857         */
6858        public PositiveIntType addNoteNumberElement() {//2 
6859          PositiveIntType t = new PositiveIntType();
6860          if (this.noteNumber == null)
6861            this.noteNumber = new ArrayList<PositiveIntType>();
6862          this.noteNumber.add(t);
6863          return t;
6864        }
6865
6866        /**
6867         * @param value {@link #noteNumber} (The numbers associated with notes below which apply to the adjudication of this item.)
6868         */
6869        public SubDetailComponent addNoteNumber(int value) { //1
6870          PositiveIntType t = new PositiveIntType();
6871          t.setValue(value);
6872          if (this.noteNumber == null)
6873            this.noteNumber = new ArrayList<PositiveIntType>();
6874          this.noteNumber.add(t);
6875          return this;
6876        }
6877
6878        /**
6879         * @param value {@link #noteNumber} (The numbers associated with notes below which apply to the adjudication of this item.)
6880         */
6881        public boolean hasNoteNumber(int value) { 
6882          if (this.noteNumber == null)
6883            return false;
6884          for (PositiveIntType v : this.noteNumber)
6885            if (v.getValue().equals(value)) // positiveInt
6886              return true;
6887          return false;
6888        }
6889
6890        /**
6891         * @return {@link #adjudication} (The adjudication results.)
6892         */
6893        public List<AdjudicationComponent> getAdjudication() { 
6894          if (this.adjudication == null)
6895            this.adjudication = new ArrayList<AdjudicationComponent>();
6896          return this.adjudication;
6897        }
6898
6899        /**
6900         * @return Returns a reference to <code>this</code> for easy method chaining
6901         */
6902        public SubDetailComponent setAdjudication(List<AdjudicationComponent> theAdjudication) { 
6903          this.adjudication = theAdjudication;
6904          return this;
6905        }
6906
6907        public boolean hasAdjudication() { 
6908          if (this.adjudication == null)
6909            return false;
6910          for (AdjudicationComponent item : this.adjudication)
6911            if (!item.isEmpty())
6912              return true;
6913          return false;
6914        }
6915
6916        public AdjudicationComponent addAdjudication() { //3
6917          AdjudicationComponent t = new AdjudicationComponent();
6918          if (this.adjudication == null)
6919            this.adjudication = new ArrayList<AdjudicationComponent>();
6920          this.adjudication.add(t);
6921          return t;
6922        }
6923
6924        public SubDetailComponent addAdjudication(AdjudicationComponent t) { //3
6925          if (t == null)
6926            return this;
6927          if (this.adjudication == null)
6928            this.adjudication = new ArrayList<AdjudicationComponent>();
6929          this.adjudication.add(t);
6930          return this;
6931        }
6932
6933        /**
6934         * @return The first repetition of repeating field {@link #adjudication}, creating it if it does not already exist {3}
6935         */
6936        public AdjudicationComponent getAdjudicationFirstRep() { 
6937          if (getAdjudication().isEmpty()) {
6938            addAdjudication();
6939          }
6940          return getAdjudication().get(0);
6941        }
6942
6943        protected void listChildren(List<Property> children) {
6944          super.listChildren(children);
6945          children.add(new Property("sequence", "positiveInt", "A claim detail line. Either a simple (a product or service) or a 'group' of sub-details which are simple items.", 0, 1, sequence));
6946          children.add(new Property("revenue", "CodeableConcept", "The type of revenue or cost center providing the product and/or service.", 0, 1, revenue));
6947          children.add(new Property("category", "CodeableConcept", "Code to identify the general type of benefits under which products and services are provided.", 0, 1, category));
6948          children.add(new Property("productOrService", "CodeableConcept", "When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.", 0, 1, productOrService));
6949          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));
6950          children.add(new Property("programCode", "CodeableConcept", "Identifies the program under which this may be recovered.", 0, java.lang.Integer.MAX_VALUE, programCode));
6951          children.add(new Property("quantity", "Quantity", "The number of repetitions of a service or product.", 0, 1, quantity));
6952          children.add(new Property("unitPrice", "Money", "If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.", 0, 1, unitPrice));
6953          children.add(new Property("factor", "decimal", "A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.", 0, 1, factor));
6954          children.add(new Property("net", "Money", "The quantity times the unit price for an additional service or product or charge.", 0, 1, net));
6955          children.add(new Property("udi", "Reference(Device)", "Unique Device Identifiers associated with this line item.", 0, java.lang.Integer.MAX_VALUE, udi));
6956          children.add(new Property("noteNumber", "positiveInt", "The numbers associated with notes below which apply to the adjudication of this item.", 0, java.lang.Integer.MAX_VALUE, noteNumber));
6957          children.add(new Property("adjudication", "@ExplanationOfBenefit.item.adjudication", "The adjudication results.", 0, java.lang.Integer.MAX_VALUE, adjudication));
6958        }
6959
6960        @Override
6961        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
6962          switch (_hash) {
6963          case 1349547969: /*sequence*/  return new Property("sequence", "positiveInt", "A claim detail line. Either a simple (a product or service) or a 'group' of sub-details which are simple items.", 0, 1, sequence);
6964          case 1099842588: /*revenue*/  return new Property("revenue", "CodeableConcept", "The type of revenue or cost center providing the product and/or service.", 0, 1, revenue);
6965          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);
6966          case 1957227299: /*productOrService*/  return new Property("productOrService", "CodeableConcept", "When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.", 0, 1, productOrService);
6967          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);
6968          case 1010065041: /*programCode*/  return new Property("programCode", "CodeableConcept", "Identifies the program under which this may be recovered.", 0, java.lang.Integer.MAX_VALUE, programCode);
6969          case -1285004149: /*quantity*/  return new Property("quantity", "Quantity", "The number of repetitions of a service or product.", 0, 1, quantity);
6970          case -486196699: /*unitPrice*/  return new Property("unitPrice", "Money", "If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.", 0, 1, unitPrice);
6971          case -1282148017: /*factor*/  return new Property("factor", "decimal", "A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.", 0, 1, factor);
6972          case 108957: /*net*/  return new Property("net", "Money", "The quantity times the unit price for an additional service or product or charge.", 0, 1, net);
6973          case 115642: /*udi*/  return new Property("udi", "Reference(Device)", "Unique Device Identifiers associated with this line item.", 0, java.lang.Integer.MAX_VALUE, udi);
6974          case -1110033957: /*noteNumber*/  return new Property("noteNumber", "positiveInt", "The numbers associated with notes below which apply to the adjudication of this item.", 0, java.lang.Integer.MAX_VALUE, noteNumber);
6975          case -231349275: /*adjudication*/  return new Property("adjudication", "@ExplanationOfBenefit.item.adjudication", "The adjudication results.", 0, java.lang.Integer.MAX_VALUE, adjudication);
6976          default: return super.getNamedProperty(_hash, _name, _checkValid);
6977          }
6978
6979        }
6980
6981      @Override
6982      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
6983        switch (hash) {
6984        case 1349547969: /*sequence*/ return this.sequence == null ? new Base[0] : new Base[] {this.sequence}; // PositiveIntType
6985        case 1099842588: /*revenue*/ return this.revenue == null ? new Base[0] : new Base[] {this.revenue}; // CodeableConcept
6986        case 50511102: /*category*/ return this.category == null ? new Base[0] : new Base[] {this.category}; // CodeableConcept
6987        case 1957227299: /*productOrService*/ return this.productOrService == null ? new Base[0] : new Base[] {this.productOrService}; // CodeableConcept
6988        case -615513385: /*modifier*/ return this.modifier == null ? new Base[0] : this.modifier.toArray(new Base[this.modifier.size()]); // CodeableConcept
6989        case 1010065041: /*programCode*/ return this.programCode == null ? new Base[0] : this.programCode.toArray(new Base[this.programCode.size()]); // CodeableConcept
6990        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // Quantity
6991        case -486196699: /*unitPrice*/ return this.unitPrice == null ? new Base[0] : new Base[] {this.unitPrice}; // Money
6992        case -1282148017: /*factor*/ return this.factor == null ? new Base[0] : new Base[] {this.factor}; // DecimalType
6993        case 108957: /*net*/ return this.net == null ? new Base[0] : new Base[] {this.net}; // Money
6994        case 115642: /*udi*/ return this.udi == null ? new Base[0] : this.udi.toArray(new Base[this.udi.size()]); // Reference
6995        case -1110033957: /*noteNumber*/ return this.noteNumber == null ? new Base[0] : this.noteNumber.toArray(new Base[this.noteNumber.size()]); // PositiveIntType
6996        case -231349275: /*adjudication*/ return this.adjudication == null ? new Base[0] : this.adjudication.toArray(new Base[this.adjudication.size()]); // AdjudicationComponent
6997        default: return super.getProperty(hash, name, checkValid);
6998        }
6999
7000      }
7001
7002      @Override
7003      public Base setProperty(int hash, String name, Base value) throws FHIRException {
7004        switch (hash) {
7005        case 1349547969: // sequence
7006          this.sequence = TypeConvertor.castToPositiveInt(value); // PositiveIntType
7007          return value;
7008        case 1099842588: // revenue
7009          this.revenue = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
7010          return value;
7011        case 50511102: // category
7012          this.category = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
7013          return value;
7014        case 1957227299: // productOrService
7015          this.productOrService = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
7016          return value;
7017        case -615513385: // modifier
7018          this.getModifier().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
7019          return value;
7020        case 1010065041: // programCode
7021          this.getProgramCode().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
7022          return value;
7023        case -1285004149: // quantity
7024          this.quantity = TypeConvertor.castToQuantity(value); // Quantity
7025          return value;
7026        case -486196699: // unitPrice
7027          this.unitPrice = TypeConvertor.castToMoney(value); // Money
7028          return value;
7029        case -1282148017: // factor
7030          this.factor = TypeConvertor.castToDecimal(value); // DecimalType
7031          return value;
7032        case 108957: // net
7033          this.net = TypeConvertor.castToMoney(value); // Money
7034          return value;
7035        case 115642: // udi
7036          this.getUdi().add(TypeConvertor.castToReference(value)); // Reference
7037          return value;
7038        case -1110033957: // noteNumber
7039          this.getNoteNumber().add(TypeConvertor.castToPositiveInt(value)); // PositiveIntType
7040          return value;
7041        case -231349275: // adjudication
7042          this.getAdjudication().add((AdjudicationComponent) value); // AdjudicationComponent
7043          return value;
7044        default: return super.setProperty(hash, name, value);
7045        }
7046
7047      }
7048
7049      @Override
7050      public Base setProperty(String name, Base value) throws FHIRException {
7051        if (name.equals("sequence")) {
7052          this.sequence = TypeConvertor.castToPositiveInt(value); // PositiveIntType
7053        } else if (name.equals("revenue")) {
7054          this.revenue = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
7055        } else if (name.equals("category")) {
7056          this.category = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
7057        } else if (name.equals("productOrService")) {
7058          this.productOrService = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
7059        } else if (name.equals("modifier")) {
7060          this.getModifier().add(TypeConvertor.castToCodeableConcept(value));
7061        } else if (name.equals("programCode")) {
7062          this.getProgramCode().add(TypeConvertor.castToCodeableConcept(value));
7063        } else if (name.equals("quantity")) {
7064          this.quantity = TypeConvertor.castToQuantity(value); // Quantity
7065        } else if (name.equals("unitPrice")) {
7066          this.unitPrice = TypeConvertor.castToMoney(value); // Money
7067        } else if (name.equals("factor")) {
7068          this.factor = TypeConvertor.castToDecimal(value); // DecimalType
7069        } else if (name.equals("net")) {
7070          this.net = TypeConvertor.castToMoney(value); // Money
7071        } else if (name.equals("udi")) {
7072          this.getUdi().add(TypeConvertor.castToReference(value));
7073        } else if (name.equals("noteNumber")) {
7074          this.getNoteNumber().add(TypeConvertor.castToPositiveInt(value));
7075        } else if (name.equals("adjudication")) {
7076          this.getAdjudication().add((AdjudicationComponent) value);
7077        } else
7078          return super.setProperty(name, value);
7079        return value;
7080      }
7081
7082      @Override
7083      public Base makeProperty(int hash, String name) throws FHIRException {
7084        switch (hash) {
7085        case 1349547969:  return getSequenceElement();
7086        case 1099842588:  return getRevenue();
7087        case 50511102:  return getCategory();
7088        case 1957227299:  return getProductOrService();
7089        case -615513385:  return addModifier(); 
7090        case 1010065041:  return addProgramCode(); 
7091        case -1285004149:  return getQuantity();
7092        case -486196699:  return getUnitPrice();
7093        case -1282148017:  return getFactorElement();
7094        case 108957:  return getNet();
7095        case 115642:  return addUdi(); 
7096        case -1110033957:  return addNoteNumberElement();
7097        case -231349275:  return addAdjudication(); 
7098        default: return super.makeProperty(hash, name);
7099        }
7100
7101      }
7102
7103      @Override
7104      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
7105        switch (hash) {
7106        case 1349547969: /*sequence*/ return new String[] {"positiveInt"};
7107        case 1099842588: /*revenue*/ return new String[] {"CodeableConcept"};
7108        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
7109        case 1957227299: /*productOrService*/ return new String[] {"CodeableConcept"};
7110        case -615513385: /*modifier*/ return new String[] {"CodeableConcept"};
7111        case 1010065041: /*programCode*/ return new String[] {"CodeableConcept"};
7112        case -1285004149: /*quantity*/ return new String[] {"Quantity"};
7113        case -486196699: /*unitPrice*/ return new String[] {"Money"};
7114        case -1282148017: /*factor*/ return new String[] {"decimal"};
7115        case 108957: /*net*/ return new String[] {"Money"};
7116        case 115642: /*udi*/ return new String[] {"Reference"};
7117        case -1110033957: /*noteNumber*/ return new String[] {"positiveInt"};
7118        case -231349275: /*adjudication*/ return new String[] {"@ExplanationOfBenefit.item.adjudication"};
7119        default: return super.getTypesForProperty(hash, name);
7120        }
7121
7122      }
7123
7124      @Override
7125      public Base addChild(String name) throws FHIRException {
7126        if (name.equals("sequence")) {
7127          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.item.detail.subDetail.sequence");
7128        }
7129        else if (name.equals("revenue")) {
7130          this.revenue = new CodeableConcept();
7131          return this.revenue;
7132        }
7133        else if (name.equals("category")) {
7134          this.category = new CodeableConcept();
7135          return this.category;
7136        }
7137        else if (name.equals("productOrService")) {
7138          this.productOrService = new CodeableConcept();
7139          return this.productOrService;
7140        }
7141        else if (name.equals("modifier")) {
7142          return addModifier();
7143        }
7144        else if (name.equals("programCode")) {
7145          return addProgramCode();
7146        }
7147        else if (name.equals("quantity")) {
7148          this.quantity = new Quantity();
7149          return this.quantity;
7150        }
7151        else if (name.equals("unitPrice")) {
7152          this.unitPrice = new Money();
7153          return this.unitPrice;
7154        }
7155        else if (name.equals("factor")) {
7156          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.item.detail.subDetail.factor");
7157        }
7158        else if (name.equals("net")) {
7159          this.net = new Money();
7160          return this.net;
7161        }
7162        else if (name.equals("udi")) {
7163          return addUdi();
7164        }
7165        else if (name.equals("noteNumber")) {
7166          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.item.detail.subDetail.noteNumber");
7167        }
7168        else if (name.equals("adjudication")) {
7169          return addAdjudication();
7170        }
7171        else
7172          return super.addChild(name);
7173      }
7174
7175      public SubDetailComponent copy() {
7176        SubDetailComponent dst = new SubDetailComponent();
7177        copyValues(dst);
7178        return dst;
7179      }
7180
7181      public void copyValues(SubDetailComponent dst) {
7182        super.copyValues(dst);
7183        dst.sequence = sequence == null ? null : sequence.copy();
7184        dst.revenue = revenue == null ? null : revenue.copy();
7185        dst.category = category == null ? null : category.copy();
7186        dst.productOrService = productOrService == null ? null : productOrService.copy();
7187        if (modifier != null) {
7188          dst.modifier = new ArrayList<CodeableConcept>();
7189          for (CodeableConcept i : modifier)
7190            dst.modifier.add(i.copy());
7191        };
7192        if (programCode != null) {
7193          dst.programCode = new ArrayList<CodeableConcept>();
7194          for (CodeableConcept i : programCode)
7195            dst.programCode.add(i.copy());
7196        };
7197        dst.quantity = quantity == null ? null : quantity.copy();
7198        dst.unitPrice = unitPrice == null ? null : unitPrice.copy();
7199        dst.factor = factor == null ? null : factor.copy();
7200        dst.net = net == null ? null : net.copy();
7201        if (udi != null) {
7202          dst.udi = new ArrayList<Reference>();
7203          for (Reference i : udi)
7204            dst.udi.add(i.copy());
7205        };
7206        if (noteNumber != null) {
7207          dst.noteNumber = new ArrayList<PositiveIntType>();
7208          for (PositiveIntType i : noteNumber)
7209            dst.noteNumber.add(i.copy());
7210        };
7211        if (adjudication != null) {
7212          dst.adjudication = new ArrayList<AdjudicationComponent>();
7213          for (AdjudicationComponent i : adjudication)
7214            dst.adjudication.add(i.copy());
7215        };
7216      }
7217
7218      @Override
7219      public boolean equalsDeep(Base other_) {
7220        if (!super.equalsDeep(other_))
7221          return false;
7222        if (!(other_ instanceof SubDetailComponent))
7223          return false;
7224        SubDetailComponent o = (SubDetailComponent) other_;
7225        return compareDeep(sequence, o.sequence, true) && compareDeep(revenue, o.revenue, true) && compareDeep(category, o.category, true)
7226           && compareDeep(productOrService, o.productOrService, true) && compareDeep(modifier, o.modifier, true)
7227           && compareDeep(programCode, o.programCode, true) && compareDeep(quantity, o.quantity, true) && compareDeep(unitPrice, o.unitPrice, true)
7228           && compareDeep(factor, o.factor, true) && compareDeep(net, o.net, true) && compareDeep(udi, o.udi, true)
7229           && compareDeep(noteNumber, o.noteNumber, true) && compareDeep(adjudication, o.adjudication, true)
7230          ;
7231      }
7232
7233      @Override
7234      public boolean equalsShallow(Base other_) {
7235        if (!super.equalsShallow(other_))
7236          return false;
7237        if (!(other_ instanceof SubDetailComponent))
7238          return false;
7239        SubDetailComponent o = (SubDetailComponent) other_;
7240        return compareValues(sequence, o.sequence, true) && compareValues(factor, o.factor, true) && compareValues(noteNumber, o.noteNumber, true)
7241          ;
7242      }
7243
7244      public boolean isEmpty() {
7245        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(sequence, revenue, category
7246          , productOrService, modifier, programCode, quantity, unitPrice, factor, net, udi
7247          , noteNumber, adjudication);
7248      }
7249
7250  public String fhirType() {
7251    return "ExplanationOfBenefit.item.detail.subDetail";
7252
7253  }
7254
7255  }
7256
7257    @Block()
7258    public static class AddedItemComponent extends BackboneElement implements IBaseBackboneElement {
7259        /**
7260         * Claim items which this service line is intended to replace.
7261         */
7262        @Child(name = "itemSequence", type = {PositiveIntType.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
7263        @Description(shortDefinition="Item sequence number", formalDefinition="Claim items which this service line is intended to replace." )
7264        protected List<PositiveIntType> itemSequence;
7265
7266        /**
7267         * The sequence number of the details within the claim item which this line is intended to replace.
7268         */
7269        @Child(name = "detailSequence", type = {PositiveIntType.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
7270        @Description(shortDefinition="Detail sequence number", formalDefinition="The sequence number of the details within the claim item which this line is intended to replace." )
7271        protected List<PositiveIntType> detailSequence;
7272
7273        /**
7274         * The sequence number of the sub-details woithin the details within the claim item which this line is intended to replace.
7275         */
7276        @Child(name = "subDetailSequence", type = {PositiveIntType.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
7277        @Description(shortDefinition="Subdetail sequence number", formalDefinition="The sequence number of the sub-details woithin the details within the claim item which this line is intended to replace." )
7278        protected List<PositiveIntType> subDetailSequence;
7279
7280        /**
7281         * The providers who are authorized for the services rendered to the patient.
7282         */
7283        @Child(name = "provider", type = {Practitioner.class, PractitionerRole.class, Organization.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
7284        @Description(shortDefinition="Authorized providers", formalDefinition="The providers who are authorized for the services rendered to the patient." )
7285        protected List<Reference> provider;
7286
7287        /**
7288         * When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.
7289         */
7290        @Child(name = "productOrService", type = {CodeableConcept.class}, order=5, min=1, max=1, modifier=false, summary=false)
7291        @Description(shortDefinition="Billing, service, product, or drug code", formalDefinition="When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item." )
7292        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/service-uscls")
7293        protected CodeableConcept productOrService;
7294
7295        /**
7296         * Item typification or modifiers codes to convey additional context for the product or service.
7297         */
7298        @Child(name = "modifier", type = {CodeableConcept.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
7299        @Description(shortDefinition="Service/Product billing modifiers", formalDefinition="Item typification or modifiers codes to convey additional context for the product or service." )
7300        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/claim-modifiers")
7301        protected List<CodeableConcept> modifier;
7302
7303        /**
7304         * Identifies the program under which this may be recovered.
7305         */
7306        @Child(name = "programCode", type = {CodeableConcept.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
7307        @Description(shortDefinition="Program the product or service is provided under", formalDefinition="Identifies the program under which this may be recovered." )
7308        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/ex-program-code")
7309        protected List<CodeableConcept> programCode;
7310
7311        /**
7312         * The date or dates when the service or product was supplied, performed or completed.
7313         */
7314        @Child(name = "serviced", type = {DateType.class, Period.class}, order=8, min=0, max=1, modifier=false, summary=false)
7315        @Description(shortDefinition="Date or dates of service or product delivery", formalDefinition="The date or dates when the service or product was supplied, performed or completed." )
7316        protected DataType serviced;
7317
7318        /**
7319         * Where the product or service was provided.
7320         */
7321        @Child(name = "location", type = {CodeableConcept.class, Address.class, Location.class}, order=9, min=0, max=1, modifier=false, summary=false)
7322        @Description(shortDefinition="Place of service or where product was supplied", formalDefinition="Where the product or service was provided." )
7323        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/service-place")
7324        protected DataType location;
7325
7326        /**
7327         * The number of repetitions of a service or product.
7328         */
7329        @Child(name = "quantity", type = {Quantity.class}, order=10, min=0, max=1, modifier=false, summary=false)
7330        @Description(shortDefinition="Count of products or services", formalDefinition="The number of repetitions of a service or product." )
7331        protected Quantity quantity;
7332
7333        /**
7334         * If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.
7335         */
7336        @Child(name = "unitPrice", type = {Money.class}, order=11, min=0, max=1, modifier=false, summary=false)
7337        @Description(shortDefinition="Fee, charge or cost per item", formalDefinition="If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group." )
7338        protected Money unitPrice;
7339
7340        /**
7341         * A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
7342         */
7343        @Child(name = "factor", type = {DecimalType.class}, order=12, min=0, max=1, modifier=false, summary=false)
7344        @Description(shortDefinition="Price scaling factor", formalDefinition="A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount." )
7345        protected DecimalType factor;
7346
7347        /**
7348         * The quantity times the unit price for an additional service or product or charge.
7349         */
7350        @Child(name = "net", type = {Money.class}, order=13, min=0, max=1, modifier=false, summary=false)
7351        @Description(shortDefinition="Total item cost", formalDefinition="The quantity times the unit price for an additional service or product or charge." )
7352        protected Money net;
7353
7354        /**
7355         * Physical service site on the patient (limb, tooth, etc.).
7356         */
7357        @Child(name = "bodySite", type = {CodeableConcept.class}, order=14, min=0, max=1, modifier=false, summary=false)
7358        @Description(shortDefinition="Anatomical location", formalDefinition="Physical service site on the patient (limb, tooth, etc.)." )
7359        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/tooth")
7360        protected CodeableConcept bodySite;
7361
7362        /**
7363         * A region or surface of the bodySite, e.g. limb region or tooth surface(s).
7364         */
7365        @Child(name = "subSite", type = {CodeableConcept.class}, order=15, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
7366        @Description(shortDefinition="Anatomical sub-location", formalDefinition="A region or surface of the bodySite, e.g. limb region or tooth surface(s)." )
7367        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/surface")
7368        protected List<CodeableConcept> subSite;
7369
7370        /**
7371         * The numbers associated with notes below which apply to the adjudication of this item.
7372         */
7373        @Child(name = "noteNumber", type = {PositiveIntType.class}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
7374        @Description(shortDefinition="Applicable note numbers", formalDefinition="The numbers associated with notes below which apply to the adjudication of this item." )
7375        protected List<PositiveIntType> noteNumber;
7376
7377        /**
7378         * The adjudication results.
7379         */
7380        @Child(name = "adjudication", type = {AdjudicationComponent.class}, order=17, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
7381        @Description(shortDefinition="Added items adjudication", formalDefinition="The adjudication results." )
7382        protected List<AdjudicationComponent> adjudication;
7383
7384        /**
7385         * The second-tier service adjudications for payor added services.
7386         */
7387        @Child(name = "detail", type = {}, order=18, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
7388        @Description(shortDefinition="Insurer added line items", formalDefinition="The second-tier service adjudications for payor added services." )
7389        protected List<AddedItemDetailComponent> detail;
7390
7391        private static final long serialVersionUID = 2055842184L;
7392
7393    /**
7394     * Constructor
7395     */
7396      public AddedItemComponent() {
7397        super();
7398      }
7399
7400    /**
7401     * Constructor
7402     */
7403      public AddedItemComponent(CodeableConcept productOrService) {
7404        super();
7405        this.setProductOrService(productOrService);
7406      }
7407
7408        /**
7409         * @return {@link #itemSequence} (Claim items which this service line is intended to replace.)
7410         */
7411        public List<PositiveIntType> getItemSequence() { 
7412          if (this.itemSequence == null)
7413            this.itemSequence = new ArrayList<PositiveIntType>();
7414          return this.itemSequence;
7415        }
7416
7417        /**
7418         * @return Returns a reference to <code>this</code> for easy method chaining
7419         */
7420        public AddedItemComponent setItemSequence(List<PositiveIntType> theItemSequence) { 
7421          this.itemSequence = theItemSequence;
7422          return this;
7423        }
7424
7425        public boolean hasItemSequence() { 
7426          if (this.itemSequence == null)
7427            return false;
7428          for (PositiveIntType item : this.itemSequence)
7429            if (!item.isEmpty())
7430              return true;
7431          return false;
7432        }
7433
7434        /**
7435         * @return {@link #itemSequence} (Claim items which this service line is intended to replace.)
7436         */
7437        public PositiveIntType addItemSequenceElement() {//2 
7438          PositiveIntType t = new PositiveIntType();
7439          if (this.itemSequence == null)
7440            this.itemSequence = new ArrayList<PositiveIntType>();
7441          this.itemSequence.add(t);
7442          return t;
7443        }
7444
7445        /**
7446         * @param value {@link #itemSequence} (Claim items which this service line is intended to replace.)
7447         */
7448        public AddedItemComponent addItemSequence(int value) { //1
7449          PositiveIntType t = new PositiveIntType();
7450          t.setValue(value);
7451          if (this.itemSequence == null)
7452            this.itemSequence = new ArrayList<PositiveIntType>();
7453          this.itemSequence.add(t);
7454          return this;
7455        }
7456
7457        /**
7458         * @param value {@link #itemSequence} (Claim items which this service line is intended to replace.)
7459         */
7460        public boolean hasItemSequence(int value) { 
7461          if (this.itemSequence == null)
7462            return false;
7463          for (PositiveIntType v : this.itemSequence)
7464            if (v.getValue().equals(value)) // positiveInt
7465              return true;
7466          return false;
7467        }
7468
7469        /**
7470         * @return {@link #detailSequence} (The sequence number of the details within the claim item which this line is intended to replace.)
7471         */
7472        public List<PositiveIntType> getDetailSequence() { 
7473          if (this.detailSequence == null)
7474            this.detailSequence = new ArrayList<PositiveIntType>();
7475          return this.detailSequence;
7476        }
7477
7478        /**
7479         * @return Returns a reference to <code>this</code> for easy method chaining
7480         */
7481        public AddedItemComponent setDetailSequence(List<PositiveIntType> theDetailSequence) { 
7482          this.detailSequence = theDetailSequence;
7483          return this;
7484        }
7485
7486        public boolean hasDetailSequence() { 
7487          if (this.detailSequence == null)
7488            return false;
7489          for (PositiveIntType item : this.detailSequence)
7490            if (!item.isEmpty())
7491              return true;
7492          return false;
7493        }
7494
7495        /**
7496         * @return {@link #detailSequence} (The sequence number of the details within the claim item which this line is intended to replace.)
7497         */
7498        public PositiveIntType addDetailSequenceElement() {//2 
7499          PositiveIntType t = new PositiveIntType();
7500          if (this.detailSequence == null)
7501            this.detailSequence = new ArrayList<PositiveIntType>();
7502          this.detailSequence.add(t);
7503          return t;
7504        }
7505
7506        /**
7507         * @param value {@link #detailSequence} (The sequence number of the details within the claim item which this line is intended to replace.)
7508         */
7509        public AddedItemComponent addDetailSequence(int value) { //1
7510          PositiveIntType t = new PositiveIntType();
7511          t.setValue(value);
7512          if (this.detailSequence == null)
7513            this.detailSequence = new ArrayList<PositiveIntType>();
7514          this.detailSequence.add(t);
7515          return this;
7516        }
7517
7518        /**
7519         * @param value {@link #detailSequence} (The sequence number of the details within the claim item which this line is intended to replace.)
7520         */
7521        public boolean hasDetailSequence(int value) { 
7522          if (this.detailSequence == null)
7523            return false;
7524          for (PositiveIntType v : this.detailSequence)
7525            if (v.getValue().equals(value)) // positiveInt
7526              return true;
7527          return false;
7528        }
7529
7530        /**
7531         * @return {@link #subDetailSequence} (The sequence number of the sub-details woithin the details within the claim item which this line is intended to replace.)
7532         */
7533        public List<PositiveIntType> getSubDetailSequence() { 
7534          if (this.subDetailSequence == null)
7535            this.subDetailSequence = new ArrayList<PositiveIntType>();
7536          return this.subDetailSequence;
7537        }
7538
7539        /**
7540         * @return Returns a reference to <code>this</code> for easy method chaining
7541         */
7542        public AddedItemComponent setSubDetailSequence(List<PositiveIntType> theSubDetailSequence) { 
7543          this.subDetailSequence = theSubDetailSequence;
7544          return this;
7545        }
7546
7547        public boolean hasSubDetailSequence() { 
7548          if (this.subDetailSequence == null)
7549            return false;
7550          for (PositiveIntType item : this.subDetailSequence)
7551            if (!item.isEmpty())
7552              return true;
7553          return false;
7554        }
7555
7556        /**
7557         * @return {@link #subDetailSequence} (The sequence number of the sub-details woithin the details within the claim item which this line is intended to replace.)
7558         */
7559        public PositiveIntType addSubDetailSequenceElement() {//2 
7560          PositiveIntType t = new PositiveIntType();
7561          if (this.subDetailSequence == null)
7562            this.subDetailSequence = new ArrayList<PositiveIntType>();
7563          this.subDetailSequence.add(t);
7564          return t;
7565        }
7566
7567        /**
7568         * @param value {@link #subDetailSequence} (The sequence number of the sub-details woithin the details within the claim item which this line is intended to replace.)
7569         */
7570        public AddedItemComponent addSubDetailSequence(int value) { //1
7571          PositiveIntType t = new PositiveIntType();
7572          t.setValue(value);
7573          if (this.subDetailSequence == null)
7574            this.subDetailSequence = new ArrayList<PositiveIntType>();
7575          this.subDetailSequence.add(t);
7576          return this;
7577        }
7578
7579        /**
7580         * @param value {@link #subDetailSequence} (The sequence number of the sub-details woithin the details within the claim item which this line is intended to replace.)
7581         */
7582        public boolean hasSubDetailSequence(int value) { 
7583          if (this.subDetailSequence == null)
7584            return false;
7585          for (PositiveIntType v : this.subDetailSequence)
7586            if (v.getValue().equals(value)) // positiveInt
7587              return true;
7588          return false;
7589        }
7590
7591        /**
7592         * @return {@link #provider} (The providers who are authorized for the services rendered to the patient.)
7593         */
7594        public List<Reference> getProvider() { 
7595          if (this.provider == null)
7596            this.provider = new ArrayList<Reference>();
7597          return this.provider;
7598        }
7599
7600        /**
7601         * @return Returns a reference to <code>this</code> for easy method chaining
7602         */
7603        public AddedItemComponent setProvider(List<Reference> theProvider) { 
7604          this.provider = theProvider;
7605          return this;
7606        }
7607
7608        public boolean hasProvider() { 
7609          if (this.provider == null)
7610            return false;
7611          for (Reference item : this.provider)
7612            if (!item.isEmpty())
7613              return true;
7614          return false;
7615        }
7616
7617        public Reference addProvider() { //3
7618          Reference t = new Reference();
7619          if (this.provider == null)
7620            this.provider = new ArrayList<Reference>();
7621          this.provider.add(t);
7622          return t;
7623        }
7624
7625        public AddedItemComponent addProvider(Reference t) { //3
7626          if (t == null)
7627            return this;
7628          if (this.provider == null)
7629            this.provider = new ArrayList<Reference>();
7630          this.provider.add(t);
7631          return this;
7632        }
7633
7634        /**
7635         * @return The first repetition of repeating field {@link #provider}, creating it if it does not already exist {3}
7636         */
7637        public Reference getProviderFirstRep() { 
7638          if (getProvider().isEmpty()) {
7639            addProvider();
7640          }
7641          return getProvider().get(0);
7642        }
7643
7644        /**
7645         * @return {@link #productOrService} (When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.)
7646         */
7647        public CodeableConcept getProductOrService() { 
7648          if (this.productOrService == null)
7649            if (Configuration.errorOnAutoCreate())
7650              throw new Error("Attempt to auto-create AddedItemComponent.productOrService");
7651            else if (Configuration.doAutoCreate())
7652              this.productOrService = new CodeableConcept(); // cc
7653          return this.productOrService;
7654        }
7655
7656        public boolean hasProductOrService() { 
7657          return this.productOrService != null && !this.productOrService.isEmpty();
7658        }
7659
7660        /**
7661         * @param value {@link #productOrService} (When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.)
7662         */
7663        public AddedItemComponent setProductOrService(CodeableConcept value) { 
7664          this.productOrService = value;
7665          return this;
7666        }
7667
7668        /**
7669         * @return {@link #modifier} (Item typification or modifiers codes to convey additional context for the product or service.)
7670         */
7671        public List<CodeableConcept> getModifier() { 
7672          if (this.modifier == null)
7673            this.modifier = new ArrayList<CodeableConcept>();
7674          return this.modifier;
7675        }
7676
7677        /**
7678         * @return Returns a reference to <code>this</code> for easy method chaining
7679         */
7680        public AddedItemComponent setModifier(List<CodeableConcept> theModifier) { 
7681          this.modifier = theModifier;
7682          return this;
7683        }
7684
7685        public boolean hasModifier() { 
7686          if (this.modifier == null)
7687            return false;
7688          for (CodeableConcept item : this.modifier)
7689            if (!item.isEmpty())
7690              return true;
7691          return false;
7692        }
7693
7694        public CodeableConcept addModifier() { //3
7695          CodeableConcept t = new CodeableConcept();
7696          if (this.modifier == null)
7697            this.modifier = new ArrayList<CodeableConcept>();
7698          this.modifier.add(t);
7699          return t;
7700        }
7701
7702        public AddedItemComponent addModifier(CodeableConcept t) { //3
7703          if (t == null)
7704            return this;
7705          if (this.modifier == null)
7706            this.modifier = new ArrayList<CodeableConcept>();
7707          this.modifier.add(t);
7708          return this;
7709        }
7710
7711        /**
7712         * @return The first repetition of repeating field {@link #modifier}, creating it if it does not already exist {3}
7713         */
7714        public CodeableConcept getModifierFirstRep() { 
7715          if (getModifier().isEmpty()) {
7716            addModifier();
7717          }
7718          return getModifier().get(0);
7719        }
7720
7721        /**
7722         * @return {@link #programCode} (Identifies the program under which this may be recovered.)
7723         */
7724        public List<CodeableConcept> getProgramCode() { 
7725          if (this.programCode == null)
7726            this.programCode = new ArrayList<CodeableConcept>();
7727          return this.programCode;
7728        }
7729
7730        /**
7731         * @return Returns a reference to <code>this</code> for easy method chaining
7732         */
7733        public AddedItemComponent setProgramCode(List<CodeableConcept> theProgramCode) { 
7734          this.programCode = theProgramCode;
7735          return this;
7736        }
7737
7738        public boolean hasProgramCode() { 
7739          if (this.programCode == null)
7740            return false;
7741          for (CodeableConcept item : this.programCode)
7742            if (!item.isEmpty())
7743              return true;
7744          return false;
7745        }
7746
7747        public CodeableConcept addProgramCode() { //3
7748          CodeableConcept t = new CodeableConcept();
7749          if (this.programCode == null)
7750            this.programCode = new ArrayList<CodeableConcept>();
7751          this.programCode.add(t);
7752          return t;
7753        }
7754
7755        public AddedItemComponent addProgramCode(CodeableConcept t) { //3
7756          if (t == null)
7757            return this;
7758          if (this.programCode == null)
7759            this.programCode = new ArrayList<CodeableConcept>();
7760          this.programCode.add(t);
7761          return this;
7762        }
7763
7764        /**
7765         * @return The first repetition of repeating field {@link #programCode}, creating it if it does not already exist {3}
7766         */
7767        public CodeableConcept getProgramCodeFirstRep() { 
7768          if (getProgramCode().isEmpty()) {
7769            addProgramCode();
7770          }
7771          return getProgramCode().get(0);
7772        }
7773
7774        /**
7775         * @return {@link #serviced} (The date or dates when the service or product was supplied, performed or completed.)
7776         */
7777        public DataType getServiced() { 
7778          return this.serviced;
7779        }
7780
7781        /**
7782         * @return {@link #serviced} (The date or dates when the service or product was supplied, performed or completed.)
7783         */
7784        public DateType getServicedDateType() throws FHIRException { 
7785          if (this.serviced == null)
7786            this.serviced = new DateType();
7787          if (!(this.serviced instanceof DateType))
7788            throw new FHIRException("Type mismatch: the type DateType was expected, but "+this.serviced.getClass().getName()+" was encountered");
7789          return (DateType) this.serviced;
7790        }
7791
7792        public boolean hasServicedDateType() { 
7793          return this != null && this.serviced instanceof DateType;
7794        }
7795
7796        /**
7797         * @return {@link #serviced} (The date or dates when the service or product was supplied, performed or completed.)
7798         */
7799        public Period getServicedPeriod() throws FHIRException { 
7800          if (this.serviced == null)
7801            this.serviced = new Period();
7802          if (!(this.serviced instanceof Period))
7803            throw new FHIRException("Type mismatch: the type Period was expected, but "+this.serviced.getClass().getName()+" was encountered");
7804          return (Period) this.serviced;
7805        }
7806
7807        public boolean hasServicedPeriod() { 
7808          return this != null && this.serviced instanceof Period;
7809        }
7810
7811        public boolean hasServiced() { 
7812          return this.serviced != null && !this.serviced.isEmpty();
7813        }
7814
7815        /**
7816         * @param value {@link #serviced} (The date or dates when the service or product was supplied, performed or completed.)
7817         */
7818        public AddedItemComponent setServiced(DataType value) { 
7819          if (value != null && !(value instanceof DateType || value instanceof Period))
7820            throw new Error("Not the right type for ExplanationOfBenefit.addItem.serviced[x]: "+value.fhirType());
7821          this.serviced = value;
7822          return this;
7823        }
7824
7825        /**
7826         * @return {@link #location} (Where the product or service was provided.)
7827         */
7828        public DataType getLocation() { 
7829          return this.location;
7830        }
7831
7832        /**
7833         * @return {@link #location} (Where the product or service was provided.)
7834         */
7835        public CodeableConcept getLocationCodeableConcept() throws FHIRException { 
7836          if (this.location == null)
7837            this.location = new CodeableConcept();
7838          if (!(this.location instanceof CodeableConcept))
7839            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.location.getClass().getName()+" was encountered");
7840          return (CodeableConcept) this.location;
7841        }
7842
7843        public boolean hasLocationCodeableConcept() { 
7844          return this != null && this.location instanceof CodeableConcept;
7845        }
7846
7847        /**
7848         * @return {@link #location} (Where the product or service was provided.)
7849         */
7850        public Address getLocationAddress() throws FHIRException { 
7851          if (this.location == null)
7852            this.location = new Address();
7853          if (!(this.location instanceof Address))
7854            throw new FHIRException("Type mismatch: the type Address was expected, but "+this.location.getClass().getName()+" was encountered");
7855          return (Address) this.location;
7856        }
7857
7858        public boolean hasLocationAddress() { 
7859          return this != null && this.location instanceof Address;
7860        }
7861
7862        /**
7863         * @return {@link #location} (Where the product or service was provided.)
7864         */
7865        public Reference getLocationReference() throws FHIRException { 
7866          if (this.location == null)
7867            this.location = new Reference();
7868          if (!(this.location instanceof Reference))
7869            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.location.getClass().getName()+" was encountered");
7870          return (Reference) this.location;
7871        }
7872
7873        public boolean hasLocationReference() { 
7874          return this != null && this.location instanceof Reference;
7875        }
7876
7877        public boolean hasLocation() { 
7878          return this.location != null && !this.location.isEmpty();
7879        }
7880
7881        /**
7882         * @param value {@link #location} (Where the product or service was provided.)
7883         */
7884        public AddedItemComponent setLocation(DataType value) { 
7885          if (value != null && !(value instanceof CodeableConcept || value instanceof Address || value instanceof Reference))
7886            throw new Error("Not the right type for ExplanationOfBenefit.addItem.location[x]: "+value.fhirType());
7887          this.location = value;
7888          return this;
7889        }
7890
7891        /**
7892         * @return {@link #quantity} (The number of repetitions of a service or product.)
7893         */
7894        public Quantity getQuantity() { 
7895          if (this.quantity == null)
7896            if (Configuration.errorOnAutoCreate())
7897              throw new Error("Attempt to auto-create AddedItemComponent.quantity");
7898            else if (Configuration.doAutoCreate())
7899              this.quantity = new Quantity(); // cc
7900          return this.quantity;
7901        }
7902
7903        public boolean hasQuantity() { 
7904          return this.quantity != null && !this.quantity.isEmpty();
7905        }
7906
7907        /**
7908         * @param value {@link #quantity} (The number of repetitions of a service or product.)
7909         */
7910        public AddedItemComponent setQuantity(Quantity value) { 
7911          this.quantity = value;
7912          return this;
7913        }
7914
7915        /**
7916         * @return {@link #unitPrice} (If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.)
7917         */
7918        public Money getUnitPrice() { 
7919          if (this.unitPrice == null)
7920            if (Configuration.errorOnAutoCreate())
7921              throw new Error("Attempt to auto-create AddedItemComponent.unitPrice");
7922            else if (Configuration.doAutoCreate())
7923              this.unitPrice = new Money(); // cc
7924          return this.unitPrice;
7925        }
7926
7927        public boolean hasUnitPrice() { 
7928          return this.unitPrice != null && !this.unitPrice.isEmpty();
7929        }
7930
7931        /**
7932         * @param value {@link #unitPrice} (If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.)
7933         */
7934        public AddedItemComponent setUnitPrice(Money value) { 
7935          this.unitPrice = value;
7936          return this;
7937        }
7938
7939        /**
7940         * @return {@link #factor} (A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.). This is the underlying object with id, value and extensions. The accessor "getFactor" gives direct access to the value
7941         */
7942        public DecimalType getFactorElement() { 
7943          if (this.factor == null)
7944            if (Configuration.errorOnAutoCreate())
7945              throw new Error("Attempt to auto-create AddedItemComponent.factor");
7946            else if (Configuration.doAutoCreate())
7947              this.factor = new DecimalType(); // bb
7948          return this.factor;
7949        }
7950
7951        public boolean hasFactorElement() { 
7952          return this.factor != null && !this.factor.isEmpty();
7953        }
7954
7955        public boolean hasFactor() { 
7956          return this.factor != null && !this.factor.isEmpty();
7957        }
7958
7959        /**
7960         * @param value {@link #factor} (A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.). This is the underlying object with id, value and extensions. The accessor "getFactor" gives direct access to the value
7961         */
7962        public AddedItemComponent setFactorElement(DecimalType value) { 
7963          this.factor = value;
7964          return this;
7965        }
7966
7967        /**
7968         * @return A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
7969         */
7970        public BigDecimal getFactor() { 
7971          return this.factor == null ? null : this.factor.getValue();
7972        }
7973
7974        /**
7975         * @param value A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
7976         */
7977        public AddedItemComponent setFactor(BigDecimal value) { 
7978          if (value == null)
7979            this.factor = null;
7980          else {
7981            if (this.factor == null)
7982              this.factor = new DecimalType();
7983            this.factor.setValue(value);
7984          }
7985          return this;
7986        }
7987
7988        /**
7989         * @param value A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
7990         */
7991        public AddedItemComponent setFactor(long value) { 
7992              this.factor = new DecimalType();
7993            this.factor.setValue(value);
7994          return this;
7995        }
7996
7997        /**
7998         * @param value A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
7999         */
8000        public AddedItemComponent setFactor(double value) { 
8001              this.factor = new DecimalType();
8002            this.factor.setValue(value);
8003          return this;
8004        }
8005
8006        /**
8007         * @return {@link #net} (The quantity times the unit price for an additional service or product or charge.)
8008         */
8009        public Money getNet() { 
8010          if (this.net == null)
8011            if (Configuration.errorOnAutoCreate())
8012              throw new Error("Attempt to auto-create AddedItemComponent.net");
8013            else if (Configuration.doAutoCreate())
8014              this.net = new Money(); // cc
8015          return this.net;
8016        }
8017
8018        public boolean hasNet() { 
8019          return this.net != null && !this.net.isEmpty();
8020        }
8021
8022        /**
8023         * @param value {@link #net} (The quantity times the unit price for an additional service or product or charge.)
8024         */
8025        public AddedItemComponent setNet(Money value) { 
8026          this.net = value;
8027          return this;
8028        }
8029
8030        /**
8031         * @return {@link #bodySite} (Physical service site on the patient (limb, tooth, etc.).)
8032         */
8033        public CodeableConcept getBodySite() { 
8034          if (this.bodySite == null)
8035            if (Configuration.errorOnAutoCreate())
8036              throw new Error("Attempt to auto-create AddedItemComponent.bodySite");
8037            else if (Configuration.doAutoCreate())
8038              this.bodySite = new CodeableConcept(); // cc
8039          return this.bodySite;
8040        }
8041
8042        public boolean hasBodySite() { 
8043          return this.bodySite != null && !this.bodySite.isEmpty();
8044        }
8045
8046        /**
8047         * @param value {@link #bodySite} (Physical service site on the patient (limb, tooth, etc.).)
8048         */
8049        public AddedItemComponent setBodySite(CodeableConcept value) { 
8050          this.bodySite = value;
8051          return this;
8052        }
8053
8054        /**
8055         * @return {@link #subSite} (A region or surface of the bodySite, e.g. limb region or tooth surface(s).)
8056         */
8057        public List<CodeableConcept> getSubSite() { 
8058          if (this.subSite == null)
8059            this.subSite = new ArrayList<CodeableConcept>();
8060          return this.subSite;
8061        }
8062
8063        /**
8064         * @return Returns a reference to <code>this</code> for easy method chaining
8065         */
8066        public AddedItemComponent setSubSite(List<CodeableConcept> theSubSite) { 
8067          this.subSite = theSubSite;
8068          return this;
8069        }
8070
8071        public boolean hasSubSite() { 
8072          if (this.subSite == null)
8073            return false;
8074          for (CodeableConcept item : this.subSite)
8075            if (!item.isEmpty())
8076              return true;
8077          return false;
8078        }
8079
8080        public CodeableConcept addSubSite() { //3
8081          CodeableConcept t = new CodeableConcept();
8082          if (this.subSite == null)
8083            this.subSite = new ArrayList<CodeableConcept>();
8084          this.subSite.add(t);
8085          return t;
8086        }
8087
8088        public AddedItemComponent addSubSite(CodeableConcept t) { //3
8089          if (t == null)
8090            return this;
8091          if (this.subSite == null)
8092            this.subSite = new ArrayList<CodeableConcept>();
8093          this.subSite.add(t);
8094          return this;
8095        }
8096
8097        /**
8098         * @return The first repetition of repeating field {@link #subSite}, creating it if it does not already exist {3}
8099         */
8100        public CodeableConcept getSubSiteFirstRep() { 
8101          if (getSubSite().isEmpty()) {
8102            addSubSite();
8103          }
8104          return getSubSite().get(0);
8105        }
8106
8107        /**
8108         * @return {@link #noteNumber} (The numbers associated with notes below which apply to the adjudication of this item.)
8109         */
8110        public List<PositiveIntType> getNoteNumber() { 
8111          if (this.noteNumber == null)
8112            this.noteNumber = new ArrayList<PositiveIntType>();
8113          return this.noteNumber;
8114        }
8115
8116        /**
8117         * @return Returns a reference to <code>this</code> for easy method chaining
8118         */
8119        public AddedItemComponent setNoteNumber(List<PositiveIntType> theNoteNumber) { 
8120          this.noteNumber = theNoteNumber;
8121          return this;
8122        }
8123
8124        public boolean hasNoteNumber() { 
8125          if (this.noteNumber == null)
8126            return false;
8127          for (PositiveIntType item : this.noteNumber)
8128            if (!item.isEmpty())
8129              return true;
8130          return false;
8131        }
8132
8133        /**
8134         * @return {@link #noteNumber} (The numbers associated with notes below which apply to the adjudication of this item.)
8135         */
8136        public PositiveIntType addNoteNumberElement() {//2 
8137          PositiveIntType t = new PositiveIntType();
8138          if (this.noteNumber == null)
8139            this.noteNumber = new ArrayList<PositiveIntType>();
8140          this.noteNumber.add(t);
8141          return t;
8142        }
8143
8144        /**
8145         * @param value {@link #noteNumber} (The numbers associated with notes below which apply to the adjudication of this item.)
8146         */
8147        public AddedItemComponent addNoteNumber(int value) { //1
8148          PositiveIntType t = new PositiveIntType();
8149          t.setValue(value);
8150          if (this.noteNumber == null)
8151            this.noteNumber = new ArrayList<PositiveIntType>();
8152          this.noteNumber.add(t);
8153          return this;
8154        }
8155
8156        /**
8157         * @param value {@link #noteNumber} (The numbers associated with notes below which apply to the adjudication of this item.)
8158         */
8159        public boolean hasNoteNumber(int value) { 
8160          if (this.noteNumber == null)
8161            return false;
8162          for (PositiveIntType v : this.noteNumber)
8163            if (v.getValue().equals(value)) // positiveInt
8164              return true;
8165          return false;
8166        }
8167
8168        /**
8169         * @return {@link #adjudication} (The adjudication results.)
8170         */
8171        public List<AdjudicationComponent> getAdjudication() { 
8172          if (this.adjudication == null)
8173            this.adjudication = new ArrayList<AdjudicationComponent>();
8174          return this.adjudication;
8175        }
8176
8177        /**
8178         * @return Returns a reference to <code>this</code> for easy method chaining
8179         */
8180        public AddedItemComponent setAdjudication(List<AdjudicationComponent> theAdjudication) { 
8181          this.adjudication = theAdjudication;
8182          return this;
8183        }
8184
8185        public boolean hasAdjudication() { 
8186          if (this.adjudication == null)
8187            return false;
8188          for (AdjudicationComponent item : this.adjudication)
8189            if (!item.isEmpty())
8190              return true;
8191          return false;
8192        }
8193
8194        public AdjudicationComponent addAdjudication() { //3
8195          AdjudicationComponent t = new AdjudicationComponent();
8196          if (this.adjudication == null)
8197            this.adjudication = new ArrayList<AdjudicationComponent>();
8198          this.adjudication.add(t);
8199          return t;
8200        }
8201
8202        public AddedItemComponent addAdjudication(AdjudicationComponent t) { //3
8203          if (t == null)
8204            return this;
8205          if (this.adjudication == null)
8206            this.adjudication = new ArrayList<AdjudicationComponent>();
8207          this.adjudication.add(t);
8208          return this;
8209        }
8210
8211        /**
8212         * @return The first repetition of repeating field {@link #adjudication}, creating it if it does not already exist {3}
8213         */
8214        public AdjudicationComponent getAdjudicationFirstRep() { 
8215          if (getAdjudication().isEmpty()) {
8216            addAdjudication();
8217          }
8218          return getAdjudication().get(0);
8219        }
8220
8221        /**
8222         * @return {@link #detail} (The second-tier service adjudications for payor added services.)
8223         */
8224        public List<AddedItemDetailComponent> getDetail() { 
8225          if (this.detail == null)
8226            this.detail = new ArrayList<AddedItemDetailComponent>();
8227          return this.detail;
8228        }
8229
8230        /**
8231         * @return Returns a reference to <code>this</code> for easy method chaining
8232         */
8233        public AddedItemComponent setDetail(List<AddedItemDetailComponent> theDetail) { 
8234          this.detail = theDetail;
8235          return this;
8236        }
8237
8238        public boolean hasDetail() { 
8239          if (this.detail == null)
8240            return false;
8241          for (AddedItemDetailComponent item : this.detail)
8242            if (!item.isEmpty())
8243              return true;
8244          return false;
8245        }
8246
8247        public AddedItemDetailComponent addDetail() { //3
8248          AddedItemDetailComponent t = new AddedItemDetailComponent();
8249          if (this.detail == null)
8250            this.detail = new ArrayList<AddedItemDetailComponent>();
8251          this.detail.add(t);
8252          return t;
8253        }
8254
8255        public AddedItemComponent addDetail(AddedItemDetailComponent t) { //3
8256          if (t == null)
8257            return this;
8258          if (this.detail == null)
8259            this.detail = new ArrayList<AddedItemDetailComponent>();
8260          this.detail.add(t);
8261          return this;
8262        }
8263
8264        /**
8265         * @return The first repetition of repeating field {@link #detail}, creating it if it does not already exist {3}
8266         */
8267        public AddedItemDetailComponent getDetailFirstRep() { 
8268          if (getDetail().isEmpty()) {
8269            addDetail();
8270          }
8271          return getDetail().get(0);
8272        }
8273
8274        protected void listChildren(List<Property> children) {
8275          super.listChildren(children);
8276          children.add(new Property("itemSequence", "positiveInt", "Claim items which this service line is intended to replace.", 0, java.lang.Integer.MAX_VALUE, itemSequence));
8277          children.add(new Property("detailSequence", "positiveInt", "The sequence number of the details within the claim item which this line is intended to replace.", 0, java.lang.Integer.MAX_VALUE, detailSequence));
8278          children.add(new Property("subDetailSequence", "positiveInt", "The sequence number of the sub-details woithin the details within the claim item which this line is intended to replace.", 0, java.lang.Integer.MAX_VALUE, subDetailSequence));
8279          children.add(new Property("provider", "Reference(Practitioner|PractitionerRole|Organization)", "The providers who are authorized for the services rendered to the patient.", 0, java.lang.Integer.MAX_VALUE, provider));
8280          children.add(new Property("productOrService", "CodeableConcept", "When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.", 0, 1, productOrService));
8281          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));
8282          children.add(new Property("programCode", "CodeableConcept", "Identifies the program under which this may be recovered.", 0, java.lang.Integer.MAX_VALUE, programCode));
8283          children.add(new Property("serviced[x]", "date|Period", "The date or dates when the service or product was supplied, performed or completed.", 0, 1, serviced));
8284          children.add(new Property("location[x]", "CodeableConcept|Address|Reference(Location)", "Where the product or service was provided.", 0, 1, location));
8285          children.add(new Property("quantity", "Quantity", "The number of repetitions of a service or product.", 0, 1, quantity));
8286          children.add(new Property("unitPrice", "Money", "If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.", 0, 1, unitPrice));
8287          children.add(new Property("factor", "decimal", "A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.", 0, 1, factor));
8288          children.add(new Property("net", "Money", "The quantity times the unit price for an additional service or product or charge.", 0, 1, net));
8289          children.add(new Property("bodySite", "CodeableConcept", "Physical service site on the patient (limb, tooth, etc.).", 0, 1, bodySite));
8290          children.add(new Property("subSite", "CodeableConcept", "A region or surface of the bodySite, e.g. limb region or tooth surface(s).", 0, java.lang.Integer.MAX_VALUE, subSite));
8291          children.add(new Property("noteNumber", "positiveInt", "The numbers associated with notes below which apply to the adjudication of this item.", 0, java.lang.Integer.MAX_VALUE, noteNumber));
8292          children.add(new Property("adjudication", "@ExplanationOfBenefit.item.adjudication", "The adjudication results.", 0, java.lang.Integer.MAX_VALUE, adjudication));
8293          children.add(new Property("detail", "", "The second-tier service adjudications for payor added services.", 0, java.lang.Integer.MAX_VALUE, detail));
8294        }
8295
8296        @Override
8297        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
8298          switch (_hash) {
8299          case 1977979892: /*itemSequence*/  return new Property("itemSequence", "positiveInt", "Claim items which this service line is intended to replace.", 0, java.lang.Integer.MAX_VALUE, itemSequence);
8300          case 1321472818: /*detailSequence*/  return new Property("detailSequence", "positiveInt", "The sequence number of the details within the claim item which this line is intended to replace.", 0, java.lang.Integer.MAX_VALUE, detailSequence);
8301          case -855462510: /*subDetailSequence*/  return new Property("subDetailSequence", "positiveInt", "The sequence number of the sub-details woithin the details within the claim item which this line is intended to replace.", 0, java.lang.Integer.MAX_VALUE, subDetailSequence);
8302          case -987494927: /*provider*/  return new Property("provider", "Reference(Practitioner|PractitionerRole|Organization)", "The providers who are authorized for the services rendered to the patient.", 0, java.lang.Integer.MAX_VALUE, provider);
8303          case 1957227299: /*productOrService*/  return new Property("productOrService", "CodeableConcept", "When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.", 0, 1, productOrService);
8304          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);
8305          case 1010065041: /*programCode*/  return new Property("programCode", "CodeableConcept", "Identifies the program under which this may be recovered.", 0, java.lang.Integer.MAX_VALUE, programCode);
8306          case -1927922223: /*serviced[x]*/  return new Property("serviced[x]", "date|Period", "The date or dates when the service or product was supplied, performed or completed.", 0, 1, serviced);
8307          case 1379209295: /*serviced*/  return new Property("serviced[x]", "date|Period", "The date or dates when the service or product was supplied, performed or completed.", 0, 1, serviced);
8308          case 363246749: /*servicedDate*/  return new Property("serviced[x]", "date", "The date or dates when the service or product was supplied, performed or completed.", 0, 1, serviced);
8309          case 1534966512: /*servicedPeriod*/  return new Property("serviced[x]", "Period", "The date or dates when the service or product was supplied, performed or completed.", 0, 1, serviced);
8310          case 552316075: /*location[x]*/  return new Property("location[x]", "CodeableConcept|Address|Reference(Location)", "Where the product or service was provided.", 0, 1, location);
8311          case 1901043637: /*location*/  return new Property("location[x]", "CodeableConcept|Address|Reference(Location)", "Where the product or service was provided.", 0, 1, location);
8312          case -1224800468: /*locationCodeableConcept*/  return new Property("location[x]", "CodeableConcept", "Where the product or service was provided.", 0, 1, location);
8313          case -1280020865: /*locationAddress*/  return new Property("location[x]", "Address", "Where the product or service was provided.", 0, 1, location);
8314          case 755866390: /*locationReference*/  return new Property("location[x]", "Reference(Location)", "Where the product or service was provided.", 0, 1, location);
8315          case -1285004149: /*quantity*/  return new Property("quantity", "Quantity", "The number of repetitions of a service or product.", 0, 1, quantity);
8316          case -486196699: /*unitPrice*/  return new Property("unitPrice", "Money", "If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.", 0, 1, unitPrice);
8317          case -1282148017: /*factor*/  return new Property("factor", "decimal", "A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.", 0, 1, factor);
8318          case 108957: /*net*/  return new Property("net", "Money", "The quantity times the unit price for an additional service or product or charge.", 0, 1, net);
8319          case 1702620169: /*bodySite*/  return new Property("bodySite", "CodeableConcept", "Physical service site on the patient (limb, tooth, etc.).", 0, 1, bodySite);
8320          case -1868566105: /*subSite*/  return new Property("subSite", "CodeableConcept", "A region or surface of the bodySite, e.g. limb region or tooth surface(s).", 0, java.lang.Integer.MAX_VALUE, subSite);
8321          case -1110033957: /*noteNumber*/  return new Property("noteNumber", "positiveInt", "The numbers associated with notes below which apply to the adjudication of this item.", 0, java.lang.Integer.MAX_VALUE, noteNumber);
8322          case -231349275: /*adjudication*/  return new Property("adjudication", "@ExplanationOfBenefit.item.adjudication", "The adjudication results.", 0, java.lang.Integer.MAX_VALUE, adjudication);
8323          case -1335224239: /*detail*/  return new Property("detail", "", "The second-tier service adjudications for payor added services.", 0, java.lang.Integer.MAX_VALUE, detail);
8324          default: return super.getNamedProperty(_hash, _name, _checkValid);
8325          }
8326
8327        }
8328
8329      @Override
8330      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
8331        switch (hash) {
8332        case 1977979892: /*itemSequence*/ return this.itemSequence == null ? new Base[0] : this.itemSequence.toArray(new Base[this.itemSequence.size()]); // PositiveIntType
8333        case 1321472818: /*detailSequence*/ return this.detailSequence == null ? new Base[0] : this.detailSequence.toArray(new Base[this.detailSequence.size()]); // PositiveIntType
8334        case -855462510: /*subDetailSequence*/ return this.subDetailSequence == null ? new Base[0] : this.subDetailSequence.toArray(new Base[this.subDetailSequence.size()]); // PositiveIntType
8335        case -987494927: /*provider*/ return this.provider == null ? new Base[0] : this.provider.toArray(new Base[this.provider.size()]); // Reference
8336        case 1957227299: /*productOrService*/ return this.productOrService == null ? new Base[0] : new Base[] {this.productOrService}; // CodeableConcept
8337        case -615513385: /*modifier*/ return this.modifier == null ? new Base[0] : this.modifier.toArray(new Base[this.modifier.size()]); // CodeableConcept
8338        case 1010065041: /*programCode*/ return this.programCode == null ? new Base[0] : this.programCode.toArray(new Base[this.programCode.size()]); // CodeableConcept
8339        case 1379209295: /*serviced*/ return this.serviced == null ? new Base[0] : new Base[] {this.serviced}; // DataType
8340        case 1901043637: /*location*/ return this.location == null ? new Base[0] : new Base[] {this.location}; // DataType
8341        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // Quantity
8342        case -486196699: /*unitPrice*/ return this.unitPrice == null ? new Base[0] : new Base[] {this.unitPrice}; // Money
8343        case -1282148017: /*factor*/ return this.factor == null ? new Base[0] : new Base[] {this.factor}; // DecimalType
8344        case 108957: /*net*/ return this.net == null ? new Base[0] : new Base[] {this.net}; // Money
8345        case 1702620169: /*bodySite*/ return this.bodySite == null ? new Base[0] : new Base[] {this.bodySite}; // CodeableConcept
8346        case -1868566105: /*subSite*/ return this.subSite == null ? new Base[0] : this.subSite.toArray(new Base[this.subSite.size()]); // CodeableConcept
8347        case -1110033957: /*noteNumber*/ return this.noteNumber == null ? new Base[0] : this.noteNumber.toArray(new Base[this.noteNumber.size()]); // PositiveIntType
8348        case -231349275: /*adjudication*/ return this.adjudication == null ? new Base[0] : this.adjudication.toArray(new Base[this.adjudication.size()]); // AdjudicationComponent
8349        case -1335224239: /*detail*/ return this.detail == null ? new Base[0] : this.detail.toArray(new Base[this.detail.size()]); // AddedItemDetailComponent
8350        default: return super.getProperty(hash, name, checkValid);
8351        }
8352
8353      }
8354
8355      @Override
8356      public Base setProperty(int hash, String name, Base value) throws FHIRException {
8357        switch (hash) {
8358        case 1977979892: // itemSequence
8359          this.getItemSequence().add(TypeConvertor.castToPositiveInt(value)); // PositiveIntType
8360          return value;
8361        case 1321472818: // detailSequence
8362          this.getDetailSequence().add(TypeConvertor.castToPositiveInt(value)); // PositiveIntType
8363          return value;
8364        case -855462510: // subDetailSequence
8365          this.getSubDetailSequence().add(TypeConvertor.castToPositiveInt(value)); // PositiveIntType
8366          return value;
8367        case -987494927: // provider
8368          this.getProvider().add(TypeConvertor.castToReference(value)); // Reference
8369          return value;
8370        case 1957227299: // productOrService
8371          this.productOrService = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
8372          return value;
8373        case -615513385: // modifier
8374          this.getModifier().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
8375          return value;
8376        case 1010065041: // programCode
8377          this.getProgramCode().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
8378          return value;
8379        case 1379209295: // serviced
8380          this.serviced = TypeConvertor.castToType(value); // DataType
8381          return value;
8382        case 1901043637: // location
8383          this.location = TypeConvertor.castToType(value); // DataType
8384          return value;
8385        case -1285004149: // quantity
8386          this.quantity = TypeConvertor.castToQuantity(value); // Quantity
8387          return value;
8388        case -486196699: // unitPrice
8389          this.unitPrice = TypeConvertor.castToMoney(value); // Money
8390          return value;
8391        case -1282148017: // factor
8392          this.factor = TypeConvertor.castToDecimal(value); // DecimalType
8393          return value;
8394        case 108957: // net
8395          this.net = TypeConvertor.castToMoney(value); // Money
8396          return value;
8397        case 1702620169: // bodySite
8398          this.bodySite = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
8399          return value;
8400        case -1868566105: // subSite
8401          this.getSubSite().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
8402          return value;
8403        case -1110033957: // noteNumber
8404          this.getNoteNumber().add(TypeConvertor.castToPositiveInt(value)); // PositiveIntType
8405          return value;
8406        case -231349275: // adjudication
8407          this.getAdjudication().add((AdjudicationComponent) value); // AdjudicationComponent
8408          return value;
8409        case -1335224239: // detail
8410          this.getDetail().add((AddedItemDetailComponent) value); // AddedItemDetailComponent
8411          return value;
8412        default: return super.setProperty(hash, name, value);
8413        }
8414
8415      }
8416
8417      @Override
8418      public Base setProperty(String name, Base value) throws FHIRException {
8419        if (name.equals("itemSequence")) {
8420          this.getItemSequence().add(TypeConvertor.castToPositiveInt(value));
8421        } else if (name.equals("detailSequence")) {
8422          this.getDetailSequence().add(TypeConvertor.castToPositiveInt(value));
8423        } else if (name.equals("subDetailSequence")) {
8424          this.getSubDetailSequence().add(TypeConvertor.castToPositiveInt(value));
8425        } else if (name.equals("provider")) {
8426          this.getProvider().add(TypeConvertor.castToReference(value));
8427        } else if (name.equals("productOrService")) {
8428          this.productOrService = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
8429        } else if (name.equals("modifier")) {
8430          this.getModifier().add(TypeConvertor.castToCodeableConcept(value));
8431        } else if (name.equals("programCode")) {
8432          this.getProgramCode().add(TypeConvertor.castToCodeableConcept(value));
8433        } else if (name.equals("serviced[x]")) {
8434          this.serviced = TypeConvertor.castToType(value); // DataType
8435        } else if (name.equals("location[x]")) {
8436          this.location = TypeConvertor.castToType(value); // DataType
8437        } else if (name.equals("quantity")) {
8438          this.quantity = TypeConvertor.castToQuantity(value); // Quantity
8439        } else if (name.equals("unitPrice")) {
8440          this.unitPrice = TypeConvertor.castToMoney(value); // Money
8441        } else if (name.equals("factor")) {
8442          this.factor = TypeConvertor.castToDecimal(value); // DecimalType
8443        } else if (name.equals("net")) {
8444          this.net = TypeConvertor.castToMoney(value); // Money
8445        } else if (name.equals("bodySite")) {
8446          this.bodySite = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
8447        } else if (name.equals("subSite")) {
8448          this.getSubSite().add(TypeConvertor.castToCodeableConcept(value));
8449        } else if (name.equals("noteNumber")) {
8450          this.getNoteNumber().add(TypeConvertor.castToPositiveInt(value));
8451        } else if (name.equals("adjudication")) {
8452          this.getAdjudication().add((AdjudicationComponent) value);
8453        } else if (name.equals("detail")) {
8454          this.getDetail().add((AddedItemDetailComponent) value);
8455        } else
8456          return super.setProperty(name, value);
8457        return value;
8458      }
8459
8460      @Override
8461      public Base makeProperty(int hash, String name) throws FHIRException {
8462        switch (hash) {
8463        case 1977979892:  return addItemSequenceElement();
8464        case 1321472818:  return addDetailSequenceElement();
8465        case -855462510:  return addSubDetailSequenceElement();
8466        case -987494927:  return addProvider(); 
8467        case 1957227299:  return getProductOrService();
8468        case -615513385:  return addModifier(); 
8469        case 1010065041:  return addProgramCode(); 
8470        case -1927922223:  return getServiced();
8471        case 1379209295:  return getServiced();
8472        case 552316075:  return getLocation();
8473        case 1901043637:  return getLocation();
8474        case -1285004149:  return getQuantity();
8475        case -486196699:  return getUnitPrice();
8476        case -1282148017:  return getFactorElement();
8477        case 108957:  return getNet();
8478        case 1702620169:  return getBodySite();
8479        case -1868566105:  return addSubSite(); 
8480        case -1110033957:  return addNoteNumberElement();
8481        case -231349275:  return addAdjudication(); 
8482        case -1335224239:  return addDetail(); 
8483        default: return super.makeProperty(hash, name);
8484        }
8485
8486      }
8487
8488      @Override
8489      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
8490        switch (hash) {
8491        case 1977979892: /*itemSequence*/ return new String[] {"positiveInt"};
8492        case 1321472818: /*detailSequence*/ return new String[] {"positiveInt"};
8493        case -855462510: /*subDetailSequence*/ return new String[] {"positiveInt"};
8494        case -987494927: /*provider*/ return new String[] {"Reference"};
8495        case 1957227299: /*productOrService*/ return new String[] {"CodeableConcept"};
8496        case -615513385: /*modifier*/ return new String[] {"CodeableConcept"};
8497        case 1010065041: /*programCode*/ return new String[] {"CodeableConcept"};
8498        case 1379209295: /*serviced*/ return new String[] {"date", "Period"};
8499        case 1901043637: /*location*/ return new String[] {"CodeableConcept", "Address", "Reference"};
8500        case -1285004149: /*quantity*/ return new String[] {"Quantity"};
8501        case -486196699: /*unitPrice*/ return new String[] {"Money"};
8502        case -1282148017: /*factor*/ return new String[] {"decimal"};
8503        case 108957: /*net*/ return new String[] {"Money"};
8504        case 1702620169: /*bodySite*/ return new String[] {"CodeableConcept"};
8505        case -1868566105: /*subSite*/ return new String[] {"CodeableConcept"};
8506        case -1110033957: /*noteNumber*/ return new String[] {"positiveInt"};
8507        case -231349275: /*adjudication*/ return new String[] {"@ExplanationOfBenefit.item.adjudication"};
8508        case -1335224239: /*detail*/ return new String[] {};
8509        default: return super.getTypesForProperty(hash, name);
8510        }
8511
8512      }
8513
8514      @Override
8515      public Base addChild(String name) throws FHIRException {
8516        if (name.equals("itemSequence")) {
8517          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.addItem.itemSequence");
8518        }
8519        else if (name.equals("detailSequence")) {
8520          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.addItem.detailSequence");
8521        }
8522        else if (name.equals("subDetailSequence")) {
8523          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.addItem.subDetailSequence");
8524        }
8525        else if (name.equals("provider")) {
8526          return addProvider();
8527        }
8528        else if (name.equals("productOrService")) {
8529          this.productOrService = new CodeableConcept();
8530          return this.productOrService;
8531        }
8532        else if (name.equals("modifier")) {
8533          return addModifier();
8534        }
8535        else if (name.equals("programCode")) {
8536          return addProgramCode();
8537        }
8538        else if (name.equals("servicedDate")) {
8539          this.serviced = new DateType();
8540          return this.serviced;
8541        }
8542        else if (name.equals("servicedPeriod")) {
8543          this.serviced = new Period();
8544          return this.serviced;
8545        }
8546        else if (name.equals("locationCodeableConcept")) {
8547          this.location = new CodeableConcept();
8548          return this.location;
8549        }
8550        else if (name.equals("locationAddress")) {
8551          this.location = new Address();
8552          return this.location;
8553        }
8554        else if (name.equals("locationReference")) {
8555          this.location = new Reference();
8556          return this.location;
8557        }
8558        else if (name.equals("quantity")) {
8559          this.quantity = new Quantity();
8560          return this.quantity;
8561        }
8562        else if (name.equals("unitPrice")) {
8563          this.unitPrice = new Money();
8564          return this.unitPrice;
8565        }
8566        else if (name.equals("factor")) {
8567          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.addItem.factor");
8568        }
8569        else if (name.equals("net")) {
8570          this.net = new Money();
8571          return this.net;
8572        }
8573        else if (name.equals("bodySite")) {
8574          this.bodySite = new CodeableConcept();
8575          return this.bodySite;
8576        }
8577        else if (name.equals("subSite")) {
8578          return addSubSite();
8579        }
8580        else if (name.equals("noteNumber")) {
8581          throw new FHIRException("Cannot call addChild on a primitive type ExplanationOfBenefit.addItem.noteNumber");
8582        }
8583        else if (name.equals("adjudication")) {
8584          return addAdjudication();
8585        }
8586        else if (name.equals("detail")) {
8587          return addDetail();
8588        }
8589        else
8590          return super.addChild(name);
8591      }
8592
8593      public AddedItemComponent copy() {
8594        AddedItemComponent dst = new AddedItemComponent();
8595        copyValues(dst);
8596        return dst;
8597      }
8598
8599      public void copyValues(AddedItemComponent dst) {
8600        super.copyValues(dst);
8601        if (itemSequence != null) {
8602          dst.itemSequence = new ArrayList<PositiveIntType>();
8603          for (PositiveIntType i : itemSequence)
8604            dst.itemSequence.add(i.copy());
8605        };
8606        if (detailSequence != null) {
8607          dst.detailSequence = new ArrayList<PositiveIntType>();
8608          for (PositiveIntType i : detailSequence)
8609            dst.detailSequence.add(i.copy());
8610        };
8611        if (subDetailSequence != null) {
8612          dst.subDetailSequence = new ArrayList<PositiveIntType>();
8613          for (PositiveIntType i : subDetailSequence)
8614            dst.subDetailSequence.add(i.copy());
8615        };
8616        if (provider != null) {
8617          dst.provider = new ArrayList<Reference>();
8618          for (Reference i : provider)
8619            dst.provider.add(i.copy());
8620        };
8621        dst.productOrService = productOrService == null ? null : productOrService.copy();
8622        if (modifier != null) {
8623          dst.modifier = new ArrayList<CodeableConcept>();
8624          for (CodeableConcept i : modifier)
8625            dst.modifier.add(i.copy());
8626        };
8627        if (programCode != null) {
8628          dst.programCode = new ArrayList<CodeableConcept>();
8629          for (CodeableConcept i : programCode)
8630            dst.programCode.add(i.copy());
8631        };
8632        dst.serviced = serviced == null ? null : serviced.copy();
8633        dst.location = location == null ? null : location.copy();
8634        dst.quantity = quantity == null ? null : quantity.copy();
8635        dst.unitPrice = unitPrice == null ? null : unitPrice.copy();
8636        dst.factor = factor == null ? null : factor.copy();
8637        dst.net = net == null ? null : net.copy();
8638        dst.bodySite = bodySite == null ? null : bodySite.copy();
8639        if (subSite != null) {
8640          dst.subSite = new ArrayList<CodeableConcept>();
8641          for (CodeableConcept i : subSite)
8642            dst.subSite.add(i.copy());
8643        };
8644        if (noteNumber != null) {
8645          dst.noteNumber = new ArrayList<PositiveIntType>();
8646          for (PositiveIntType i : noteNumber)
8647            dst.noteNumber.add(i.copy());
8648        };
8649        if (adjudication != null) {
8650          dst.adjudication = new ArrayList<AdjudicationComponent>();
8651          for (AdjudicationComponent i : adjudication)
8652            dst.adjudication.add(i.copy());
8653        };
8654        if (detail != null) {
8655          dst.detail = new ArrayList<AddedItemDetailComponent>();
8656          for (AddedItemDetailComponent i : detail)
8657            dst.detail.add(i.copy());
8658        };
8659      }
8660
8661      @Override
8662      public boolean equalsDeep(Base other_) {
8663        if (!super.equalsDeep(other_))
8664          return false;
8665        if (!(other_ instanceof AddedItemComponent))
8666          return false;
8667        AddedItemComponent o = (AddedItemComponent) other_;
8668        return compareDeep(itemSequence, o.itemSequence, true) && compareDeep(detailSequence, o.detailSequence, true)
8669           && compareDeep(subDetailSequence, o.subDetailSequence, true) && compareDeep(provider, o.provider, true)
8670           && compareDeep(productOrService, o.productOrService, true) && compareDeep(modifier, o.modifier, true)
8671           && compareDeep(programCode, o.programCode, true) && compareDeep(serviced, o.serviced, true) && compareDeep(location, o.location, true)
8672           && compareDeep(quantity, o.quantity, true) && compareDeep(unitPrice, o.unitPrice, true) && compareDeep(factor, o.factor, true)
8673           && compareDeep(net, o.net, true) && compareDeep(bodySite, o.bodySite, true) && compareDeep(subSite, o.subSite, true)
8674           && compareDeep(noteNumber, o.noteNumber, true) && compareDeep(adjudication, o.adjudication, true)
8675           && compareDeep(detail, o.detail, true);
8676      }
8677
8678      @Override
8679      public boolean equalsShallow(Base other_) {
8680        if (!super.equalsShallow(other_))
8681          return false;
8682        if (!(other_ instanceof AddedItemComponent))
8683          return false;
8684        AddedItemComponent o = (AddedItemComponent) other_;
8685        return compareValues(itemSequence, o.itemSequence, true) && compareValues(detailSequence, o.detailSequence, true)
8686           && compareValues(subDetailSequence, o.subDetailSequence, true) && compareValues(factor, o.factor, true)
8687           && compareValues(noteNumber, o.noteNumber, true);
8688      }
8689
8690      public boolean isEmpty() {
8691        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(itemSequence, detailSequence
8692          , subDetailSequence, provider, productOrService, modifier, programCode, serviced
8693          , location, quantity, unitPrice, factor, net, bodySite, subSite, noteNumber
8694          , adjudication, detail);
8695      }
8696
8697  public String fhirType() {
8698    return "ExplanationOfBenefit.addItem";
8699
8700  }
8701
8702  }
8703
8704    @Block()
8705    public static class AddedItemDetailComponent extends BackboneElement implements IBaseBackboneElement {
8706        /**
8707         * When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.
8708         */
8709        @Child(name = "productOrService", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=false)
8710        @Description(shortDefinition="Billing, service, product, or drug code", formalDefinition="When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item." )
8711        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/service-uscls")
8712        protected CodeableConcept productOrService;
8713
8714        /**
8715         * Item typification or modifiers codes to convey additional context for the product or service.
8716         */
8717        @Child(name = "modifier", type = {CodeableConcept.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
8718        @Description(shortDefinition="Service/Product billing modifiers", formalDefinition="Item typification or modifiers codes to convey additional context for the product or service." )
8719        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/claim-modifiers")
8720        protected List<CodeableConcept> modifier;
8721
8722        /**
8723         * The number of repetitions of a service or product.
8724         */
8725        @Child(name = "quantity", type = {Quantity.class}, order=3, min=0, max=1, modifier=false, summary=false)
8726        @Description(shortDefinition="Count of products or services", formalDefinition="The number of repetitions of a service or product." )
8727        protected Quantity quantity;
8728
8729        /**
8730         * If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.
8731         */
8732        @Child(name = "unitPrice", type = {Money.class}, order=4, min=0, max=1, modifier=false, summary=false)
8733        @Description(shortDefinition="Fee, charge or cost per item", formalDefinition="If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group." )
8734        protected Money unitPrice;
8735
8736        /**
8737         * A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
8738         */
8739        @Child(name = "factor", type = {DecimalType.class}, order=5, min=0, max=1, modifier=false, summary=false)
8740        @Description(shortDefinition="Price scaling factor", formalDefinition="A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount." )
8741        protected DecimalType factor;
8742
8743        /**
8744         * The quantity times the unit price for an additional service or product or charge.
8745         */
8746        @Child(name = "net", type = {Money.class}, order=6, min=0, max=1, modifier=false, summary=false)
8747        @Description(shortDefinition="Total item cost", formalDefinition="The quantity times the unit price for an additional service or product or charge." )
8748        protected Money net;
8749
8750        /**
8751         * The numbers associated with notes below which apply to the adjudication of this item.
8752         */
8753        @Child(name = "noteNumber", type = {PositiveIntType.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
8754        @Description(shortDefinition="Applicable note numbers", formalDefinition="The numbers associated with notes below which apply to the adjudication of this item." )
8755        protected List<PositiveIntType> noteNumber;
8756
8757        /**
8758         * The adjudication results.
8759         */
8760        @Child(name = "adjudication", type = {AdjudicationComponent.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
8761        @Description(shortDefinition="Added items adjudication", formalDefinition="The adjudication results." )
8762        protected List<AdjudicationComponent> adjudication;
8763
8764        /**
8765         * The third-tier service adjudications for payor added services.
8766         */
8767        @Child(name = "subDetail", type = {}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
8768        @Description(shortDefinition="Insurer added line items", formalDefinition="The third-tier service adjudications for payor added services." )
8769        protected List<AddedItemDetailSubDetailComponent> subDetail;
8770
8771        private static final long serialVersionUID = 295910869L;
8772
8773    /**
8774     * Constructor
8775     */
8776      public AddedItemDetailComponent() {
8777        super();
8778      }
8779
8780    /**
8781     * Constructor
8782     */
8783      public AddedItemDetailComponent(CodeableConcept productOrService) {
8784        super();
8785        this.setProductOrService(productOrService);
8786      }
8787
8788        /**
8789         * @return {@link #productOrService} (When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.)
8790         */
8791        public CodeableConcept getProductOrService() { 
8792          if (this.productOrService == null)
8793            if (Configuration.errorOnAutoCreate())
8794              throw new Error("Attempt to auto-create AddedItemDetailComponent.productOrService");
8795            else if (Configuration.doAutoCreate())
8796              this.productOrService = new CodeableConcept(); // cc
8797          return this.productOrService;
8798        }
8799
8800        public boolean hasProductOrService() { 
8801          return this.productOrService != null && !this.productOrService.isEmpty();
8802        }
8803
8804        /**
8805         * @param value {@link #productOrService} (When the value is a group code then this item collects a set of related claim details, otherwise this contains the product, service, drug or other billing code for the item.)
8806         */
8807        public AddedItemDetailComponent setProductOrService(CodeableConcept value) { 
8808          this.productOrService = value;
8809          return this;
8810        }
8811
8812        /**
8813         * @return {@link #modifier} (Item typification or modifiers codes to convey additional context for the product or service.)
8814         */
8815        public List<CodeableConcept> getModifier() { 
8816          if (this.modifier == null)
8817            this.modifier = new ArrayList<CodeableConcept>();
8818          return this.modifier;
8819        }
8820
8821        /**
8822         * @return Returns a reference to <code>this</code> for easy method chaining
8823         */
8824        public AddedItemDetailComponent setModifier(List<CodeableConcept> theModifier) { 
8825          this.modifier = theModifier;
8826          return this;
8827        }
8828
8829        public boolean hasModifier() { 
8830          if (this.modifier == null)
8831            return false;
8832          for (CodeableConcept item : this.modifier)
8833            if (!item.isEmpty())
8834              return true;
8835          return false;
8836        }
8837
8838        public CodeableConcept addModifier() { //3
8839          CodeableConcept t = new CodeableConcept();
8840          if (this.modifier == null)
8841            this.modifier = new ArrayList<CodeableConcept>();
8842          this.modifier.add(t);
8843          return t;
8844        }
8845
8846        public AddedItemDetailComponent addModifier(CodeableConcept t) { //3
8847          if (t == null)
8848            return this;
8849          if (this.modifier == null)
8850            this.modifier = new ArrayList<CodeableConcept>();
8851          this.modifier.add(t);
8852          return this;
8853        }
8854
8855        /**
8856         * @return The first repetition of repeating field {@link #modifier}, creating it if it does not already exist {3}
8857         */
8858        public CodeableConcept getModifierFirstRep() { 
8859          if (getModifier().isEmpty()) {
8860            addModifier();
8861          }
8862          return getModifier().get(0);
8863        }
8864
8865        /**
8866         * @return {@link #quantity} (The number of repetitions of a service or product.)
8867         */
8868        public Quantity getQuantity() { 
8869          if (this.quantity == null)
8870            if (Configuration.errorOnAutoCreate())
8871              throw new Error("Attempt to auto-create AddedItemDetailComponent.quantity");
8872            else if (Configuration.doAutoCreate())
8873              this.quantity = new Quantity(); // cc
8874          return this.quantity;
8875        }
8876
8877        public boolean hasQuantity() { 
8878          return this.quantity != null && !this.quantity.isEmpty();
8879        }
8880
8881        /**
8882         * @param value {@link #quantity} (The number of repetitions of a service or product.)
8883         */
8884        public AddedItemDetailComponent setQuantity(Quantity value) { 
8885          this.quantity = value;
8886          return this;
8887        }
8888
8889        /**
8890         * @return {@link #unitPrice} (If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.)
8891         */
8892        public Money getUnitPrice() { 
8893          if (this.unitPrice == null)
8894            if (Configuration.errorOnAutoCreate())
8895              throw new Error("Attempt to auto-create AddedItemDetailComponent.unitPrice");
8896            else if (Configuration.doAutoCreate())
8897              this.unitPrice = new Money(); // cc
8898          return this.unitPrice;
8899        }
8900
8901        public boolean hasUnitPrice() { 
8902          return this.unitPrice != null && !this.unitPrice.isEmpty();
8903        }
8904
8905        /**
8906         * @param value {@link #unitPrice} (If the item is not a group then this is the fee for the product or service, otherwise this is the total of the fees for the details of the group.)
8907         */
8908        public AddedItemDetailComponent setUnitPrice(Money value) { 
8909          this.unitPrice = value;
8910          return this;
8911        }
8912
8913        /**
8914         * @return {@link #factor} (A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.). This is the underlying object with id, value and extensions. The accessor "getFactor" gives direct access to the value
8915         */
8916        public DecimalType getFactorElement() { 
8917          if (this.factor == null)
8918            if (Configuration.errorOnAutoCreate())
8919              throw new Error("Attempt to auto-create AddedItemDetailComponent.factor");
8920            else if (Configuration.doAutoCreate())
8921              this.factor = new DecimalType(); // bb
8922          return this.factor;
8923        }
8924
8925        public boolean hasFactorElement() { 
8926          return this.factor != null && !this.factor.isEmpty();
8927        }
8928
8929        public boolean hasFactor() { 
8930          return this.factor != null && !this.factor.isEmpty();
8931        }
8932
8933        /**
8934         * @param value {@link #factor} (A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.). This is the underlying object with id, value and extensions. The accessor "getFactor" gives direct access to the value
8935         */
8936        public AddedItemDetailComponent setFactorElement(DecimalType value) { 
8937          this.factor = value;
8938          return this;
8939        }
8940
8941        /**
8942         * @return A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
8943         */
8944        public BigDecimal getFactor() { 
8945          return this.factor == null ? null : this.factor.getValue();
8946        }
8947
8948        /**
8949         * @param value A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
8950         */
8951        public AddedItemDetailComponent setFactor(BigDecimal value) { 
8952          if (value == null)
8953            this.factor = null;
8954          else {
8955            if (this.factor == null)
8956              this.factor = new DecimalType();
8957            this.factor.setValue(value);
8958          }
8959          return this;
8960        }
8961
8962        /**
8963         * @param value A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
8964         */
8965        public AddedItemDetailComponent setFactor(long value) { 
8966              this.factor = new DecimalType();
8967            this.factor.setValue(value);
8968          return this;
8969        }
8970
8971        /**
8972         * @param value A real number that represents a multiplier used in determining the overall value of services delivered and/or goods received. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
8973         */
8974        public AddedItemDetailComponent setFactor(double value) { 
8975              this.factor = new DecimalType();
8976            this.factor.setValue(value);
8977          return this;
8978        }
8979
8980        /**
8981         * @return {@link #net} (The quantity times the unit price for an additional service or product or charge.)
8982         */
8983        public Money getNet() { 
8984          if (this.net == null)
8985            if (Configuration.errorOnAutoCreate())
8986              throw new Error("Attempt to auto-create AddedItemDetailComponent.net");
8987            else if (Configuration.doAutoCreate())
8988              this.net = new Money(); // cc
8989          return this.net;
8990        }
8991
8992        public boolean hasNet() { 
8993          return this.net != null && !this.net.isEmpty();
8994        }
8995
8996        /**
8997         * @param value {@link #net} (The quantity times the unit price for an additional service or product or charge.)
8998         */
8999        public AddedItemDetailComponent setNet(Money value) { 
9000          this.net = value;
9001          return this;
9002        }
9003
9004        /**
9005         * @return {@link #noteNumber} (The numbers associated with notes below which apply to the adjudication of this item.)
9006         */
9007        public List<PositiveIntType> getNoteNumber() { 
9008          if (this.noteNumber == null)
9009            this.noteNumber = new ArrayList<PositiveIntType>();
9010          return this.noteNumber;
9011        }
9012
9013        /**
9014         * @return Returns a reference to <code>this</code> for easy method chaining
9015         */
9016        public AddedItemDetailComponent setNoteNumber(List<PositiveIntType> theNoteNumber) { 
9017          this.noteNumber = theNoteNumber;
9018          return this;
9019        }
9020
9021        public boolean hasNoteNumber() { 
9022          if (this.noteNumber == null)
9023            return false;
9024          for (PositiveIntType item : this.noteNumber)
9025            if (!item.isEmpty())
9026              return true;
9027          return false;
9028        }
9029
9030        /**
9031         * @return {@link #noteNumber} (The numbers associated with notes below which apply to the adjudication of this item.)
9032         */
9033        public PositiveIntType addNoteNumberElement() {//2 
9034          PositiveIntType t = new PositiveIntType();
9035          if (this.noteNumber == null)
9036            this.noteNumber = new ArrayList<PositiveIntType>();
9037          this.noteNumber.add(t);
9038          return t;
9039        }
9040
9041        /**
9042         * @param value {@link #noteNumber} (The numbers associated with notes below which apply to the adjudication of this item.)
9043         */
9044        public AddedItemDetailComponent addNoteNumber(int value) { //1
9045          PositiveIntType t = new PositiveIntType();
9046          t.setValue(value);
9047          if (this.noteNumber == null)
9048            this.noteNumber = new ArrayList<PositiveIntType>();
9049          this.noteNumber.add(t);
9050          return this;
9051        }
9052
9053        /**
9054         * @param value {@link #noteNumber} (The numbers associated with notes below which apply to the adjudication of this item.)
9055         */
9056        public boolean hasNoteNumber(int value) { 
9057