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