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