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