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