001package org.hl7.fhir.r5.model;
002
003/*-
004 * #%L
005 * org.hl7.fhir.r5
006 * %%
007 * Copyright (C) 2014 - 2019 Health Level 7
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023/*
024  Copyright (c) 2011+, HL7, Inc.
025  All rights reserved.
026  
027  Redistribution and use in source and binary forms, with or without modification, 
028  are permitted provided that the following conditions are met:
029  
030   * Redistributions of source code must retain the above copyright notice, this 
031     list of conditions and the following disclaimer.
032   * Redistributions in binary form must reproduce the above copyright notice, 
033     this list of conditions and the following disclaimer in the documentation 
034     and/or other materials provided with the distribution.
035   * Neither the name of HL7 nor the names of its contributors may be used to 
036     endorse or promote products derived from this software without specific 
037     prior written permission.
038  
039  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
040  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
041  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
042  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
043  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
044  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
045  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
046  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
047  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
048  POSSIBILITY OF SUCH DAMAGE.
049  
050*/
051
052// Generated on Thu, Dec 13, 2018 14:07+1100 for FHIR v4.0.0
053import java.util.ArrayList;
054import java.util.Date;
055import java.util.List;
056import org.hl7.fhir.exceptions.FHIRException;
057import org.hl7.fhir.instance.model.api.ICompositeType;
058
059import java.math.*;
060import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
061import org.hl7.fhir.utilities.Utilities;
062import ca.uhn.fhir.model.api.annotation.ResourceDef;
063import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
064import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
065import ca.uhn.fhir.model.api.annotation.Child;
066import ca.uhn.fhir.model.api.annotation.ChildOrder;
067import ca.uhn.fhir.model.api.annotation.Description;
068import ca.uhn.fhir.model.api.annotation.Block;
069/**
070 * Invoice containing collected ChargeItems from an Account with calculated individual and total price for Billing purpose.
071 */
072@ResourceDef(name="Invoice", profile="http://hl7.org/fhir/StructureDefinition/Invoice")
073public class Invoice extends DomainResource {
074
075    public enum InvoiceStatus {
076        /**
077         * the invoice has been prepared but not yet finalized.
078         */
079        DRAFT, 
080        /**
081         * the invoice has been finalized and sent to the recipient.
082         */
083        ISSUED, 
084        /**
085         * the invoice has been balaced / completely paid.
086         */
087        BALANCED, 
088        /**
089         * the invoice was cancelled.
090         */
091        CANCELLED, 
092        /**
093         * the invoice was determined as entered in error before it was issued.
094         */
095        ENTEREDINERROR, 
096        /**
097         * added to help the parsers with the generic types
098         */
099        NULL;
100        public static InvoiceStatus fromCode(String codeString) throws FHIRException {
101            if (codeString == null || "".equals(codeString))
102                return null;
103        if ("draft".equals(codeString))
104          return DRAFT;
105        if ("issued".equals(codeString))
106          return ISSUED;
107        if ("balanced".equals(codeString))
108          return BALANCED;
109        if ("cancelled".equals(codeString))
110          return CANCELLED;
111        if ("entered-in-error".equals(codeString))
112          return ENTEREDINERROR;
113        if (Configuration.isAcceptInvalidEnums())
114          return null;
115        else
116          throw new FHIRException("Unknown InvoiceStatus code '"+codeString+"'");
117        }
118        public String toCode() {
119          switch (this) {
120            case DRAFT: return "draft";
121            case ISSUED: return "issued";
122            case BALANCED: return "balanced";
123            case CANCELLED: return "cancelled";
124            case ENTEREDINERROR: return "entered-in-error";
125            default: return "?";
126          }
127        }
128        public String getSystem() {
129          switch (this) {
130            case DRAFT: return "http://hl7.org/fhir/invoice-status";
131            case ISSUED: return "http://hl7.org/fhir/invoice-status";
132            case BALANCED: return "http://hl7.org/fhir/invoice-status";
133            case CANCELLED: return "http://hl7.org/fhir/invoice-status";
134            case ENTEREDINERROR: return "http://hl7.org/fhir/invoice-status";
135            default: return "?";
136          }
137        }
138        public String getDefinition() {
139          switch (this) {
140            case DRAFT: return "the invoice has been prepared but not yet finalized.";
141            case ISSUED: return "the invoice has been finalized and sent to the recipient.";
142            case BALANCED: return "the invoice has been balaced / completely paid.";
143            case CANCELLED: return "the invoice was cancelled.";
144            case ENTEREDINERROR: return "the invoice was determined as entered in error before it was issued.";
145            default: return "?";
146          }
147        }
148        public String getDisplay() {
149          switch (this) {
150            case DRAFT: return "draft";
151            case ISSUED: return "issued";
152            case BALANCED: return "balanced";
153            case CANCELLED: return "cancelled";
154            case ENTEREDINERROR: return "entered in error";
155            default: return "?";
156          }
157        }
158    }
159
160  public static class InvoiceStatusEnumFactory implements EnumFactory<InvoiceStatus> {
161    public InvoiceStatus fromCode(String codeString) throws IllegalArgumentException {
162      if (codeString == null || "".equals(codeString))
163            if (codeString == null || "".equals(codeString))
164                return null;
165        if ("draft".equals(codeString))
166          return InvoiceStatus.DRAFT;
167        if ("issued".equals(codeString))
168          return InvoiceStatus.ISSUED;
169        if ("balanced".equals(codeString))
170          return InvoiceStatus.BALANCED;
171        if ("cancelled".equals(codeString))
172          return InvoiceStatus.CANCELLED;
173        if ("entered-in-error".equals(codeString))
174          return InvoiceStatus.ENTEREDINERROR;
175        throw new IllegalArgumentException("Unknown InvoiceStatus code '"+codeString+"'");
176        }
177        public Enumeration<InvoiceStatus> fromType(Base code) throws FHIRException {
178          if (code == null)
179            return null;
180          if (code.isEmpty())
181            return new Enumeration<InvoiceStatus>(this);
182          String codeString = ((PrimitiveType) code).asStringValue();
183          if (codeString == null || "".equals(codeString))
184            return null;
185        if ("draft".equals(codeString))
186          return new Enumeration<InvoiceStatus>(this, InvoiceStatus.DRAFT);
187        if ("issued".equals(codeString))
188          return new Enumeration<InvoiceStatus>(this, InvoiceStatus.ISSUED);
189        if ("balanced".equals(codeString))
190          return new Enumeration<InvoiceStatus>(this, InvoiceStatus.BALANCED);
191        if ("cancelled".equals(codeString))
192          return new Enumeration<InvoiceStatus>(this, InvoiceStatus.CANCELLED);
193        if ("entered-in-error".equals(codeString))
194          return new Enumeration<InvoiceStatus>(this, InvoiceStatus.ENTEREDINERROR);
195        throw new FHIRException("Unknown InvoiceStatus code '"+codeString+"'");
196        }
197    public String toCode(InvoiceStatus code) {
198      if (code == InvoiceStatus.DRAFT)
199        return "draft";
200      if (code == InvoiceStatus.ISSUED)
201        return "issued";
202      if (code == InvoiceStatus.BALANCED)
203        return "balanced";
204      if (code == InvoiceStatus.CANCELLED)
205        return "cancelled";
206      if (code == InvoiceStatus.ENTEREDINERROR)
207        return "entered-in-error";
208      return "?";
209      }
210    public String toSystem(InvoiceStatus code) {
211      return code.getSystem();
212      }
213    }
214
215    public enum InvoicePriceComponentType {
216        /**
217         * the amount is the base price used for calculating the total price before applying surcharges, discount or taxes.
218         */
219        BASE, 
220        /**
221         * the amount is a surcharge applied on the base price.
222         */
223        SURCHARGE, 
224        /**
225         * the amount is a deduction applied on the base price.
226         */
227        DEDUCTION, 
228        /**
229         * the amount is a discount applied on the base price.
230         */
231        DISCOUNT, 
232        /**
233         * the amount is the tax component of the total price.
234         */
235        TAX, 
236        /**
237         * the amount is of informational character, it has not been applied in the calculation of the total price.
238         */
239        INFORMATIONAL, 
240        /**
241         * added to help the parsers with the generic types
242         */
243        NULL;
244        public static InvoicePriceComponentType fromCode(String codeString) throws FHIRException {
245            if (codeString == null || "".equals(codeString))
246                return null;
247        if ("base".equals(codeString))
248          return BASE;
249        if ("surcharge".equals(codeString))
250          return SURCHARGE;
251        if ("deduction".equals(codeString))
252          return DEDUCTION;
253        if ("discount".equals(codeString))
254          return DISCOUNT;
255        if ("tax".equals(codeString))
256          return TAX;
257        if ("informational".equals(codeString))
258          return INFORMATIONAL;
259        if (Configuration.isAcceptInvalidEnums())
260          return null;
261        else
262          throw new FHIRException("Unknown InvoicePriceComponentType code '"+codeString+"'");
263        }
264        public String toCode() {
265          switch (this) {
266            case BASE: return "base";
267            case SURCHARGE: return "surcharge";
268            case DEDUCTION: return "deduction";
269            case DISCOUNT: return "discount";
270            case TAX: return "tax";
271            case INFORMATIONAL: return "informational";
272            default: return "?";
273          }
274        }
275        public String getSystem() {
276          switch (this) {
277            case BASE: return "http://hl7.org/fhir/invoice-priceComponentType";
278            case SURCHARGE: return "http://hl7.org/fhir/invoice-priceComponentType";
279            case DEDUCTION: return "http://hl7.org/fhir/invoice-priceComponentType";
280            case DISCOUNT: return "http://hl7.org/fhir/invoice-priceComponentType";
281            case TAX: return "http://hl7.org/fhir/invoice-priceComponentType";
282            case INFORMATIONAL: return "http://hl7.org/fhir/invoice-priceComponentType";
283            default: return "?";
284          }
285        }
286        public String getDefinition() {
287          switch (this) {
288            case BASE: return "the amount is the base price used for calculating the total price before applying surcharges, discount or taxes.";
289            case SURCHARGE: return "the amount is a surcharge applied on the base price.";
290            case DEDUCTION: return "the amount is a deduction applied on the base price.";
291            case DISCOUNT: return "the amount is a discount applied on the base price.";
292            case TAX: return "the amount is the tax component of the total price.";
293            case INFORMATIONAL: return "the amount is of informational character, it has not been applied in the calculation of the total price.";
294            default: return "?";
295          }
296        }
297        public String getDisplay() {
298          switch (this) {
299            case BASE: return "base price";
300            case SURCHARGE: return "surcharge";
301            case DEDUCTION: return "deduction";
302            case DISCOUNT: return "discount";
303            case TAX: return "tax";
304            case INFORMATIONAL: return "informational";
305            default: return "?";
306          }
307        }
308    }
309
310  public static class InvoicePriceComponentTypeEnumFactory implements EnumFactory<InvoicePriceComponentType> {
311    public InvoicePriceComponentType fromCode(String codeString) throws IllegalArgumentException {
312      if (codeString == null || "".equals(codeString))
313            if (codeString == null || "".equals(codeString))
314                return null;
315        if ("base".equals(codeString))
316          return InvoicePriceComponentType.BASE;
317        if ("surcharge".equals(codeString))
318          return InvoicePriceComponentType.SURCHARGE;
319        if ("deduction".equals(codeString))
320          return InvoicePriceComponentType.DEDUCTION;
321        if ("discount".equals(codeString))
322          return InvoicePriceComponentType.DISCOUNT;
323        if ("tax".equals(codeString))
324          return InvoicePriceComponentType.TAX;
325        if ("informational".equals(codeString))
326          return InvoicePriceComponentType.INFORMATIONAL;
327        throw new IllegalArgumentException("Unknown InvoicePriceComponentType code '"+codeString+"'");
328        }
329        public Enumeration<InvoicePriceComponentType> fromType(Base code) throws FHIRException {
330          if (code == null)
331            return null;
332          if (code.isEmpty())
333            return new Enumeration<InvoicePriceComponentType>(this);
334          String codeString = ((PrimitiveType) code).asStringValue();
335          if (codeString == null || "".equals(codeString))
336            return null;
337        if ("base".equals(codeString))
338          return new Enumeration<InvoicePriceComponentType>(this, InvoicePriceComponentType.BASE);
339        if ("surcharge".equals(codeString))
340          return new Enumeration<InvoicePriceComponentType>(this, InvoicePriceComponentType.SURCHARGE);
341        if ("deduction".equals(codeString))
342          return new Enumeration<InvoicePriceComponentType>(this, InvoicePriceComponentType.DEDUCTION);
343        if ("discount".equals(codeString))
344          return new Enumeration<InvoicePriceComponentType>(this, InvoicePriceComponentType.DISCOUNT);
345        if ("tax".equals(codeString))
346          return new Enumeration<InvoicePriceComponentType>(this, InvoicePriceComponentType.TAX);
347        if ("informational".equals(codeString))
348          return new Enumeration<InvoicePriceComponentType>(this, InvoicePriceComponentType.INFORMATIONAL);
349        throw new FHIRException("Unknown InvoicePriceComponentType code '"+codeString+"'");
350        }
351    public String toCode(InvoicePriceComponentType code) {
352      if (code == InvoicePriceComponentType.BASE)
353        return "base";
354      if (code == InvoicePriceComponentType.SURCHARGE)
355        return "surcharge";
356      if (code == InvoicePriceComponentType.DEDUCTION)
357        return "deduction";
358      if (code == InvoicePriceComponentType.DISCOUNT)
359        return "discount";
360      if (code == InvoicePriceComponentType.TAX)
361        return "tax";
362      if (code == InvoicePriceComponentType.INFORMATIONAL)
363        return "informational";
364      return "?";
365      }
366    public String toSystem(InvoicePriceComponentType code) {
367      return code.getSystem();
368      }
369    }
370
371    @Block()
372    public static class InvoiceParticipantComponent extends BackboneElement implements IBaseBackboneElement {
373        /**
374         * Describes the type of involvement (e.g. transcriptionist, creator etc.). If the invoice has been created automatically, the Participant may be a billing engine or another kind of device.
375         */
376        @Child(name = "role", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
377        @Description(shortDefinition="Type of involvement in creation of this Invoice", formalDefinition="Describes the type of involvement (e.g. transcriptionist, creator etc.). If the invoice has been created automatically, the Participant may be a billing engine or another kind of device." )
378        protected CodeableConcept role;
379
380        /**
381         * The device, practitioner, etc. who performed or participated in the service.
382         */
383        @Child(name = "actor", type = {Practitioner.class, Organization.class, Patient.class, PractitionerRole.class, Device.class, RelatedPerson.class}, order=2, min=1, max=1, modifier=false, summary=false)
384        @Description(shortDefinition="Individual who was involved", formalDefinition="The device, practitioner, etc. who performed or participated in the service." )
385        protected Reference actor;
386
387        private static final long serialVersionUID = -1684441509L;
388
389    /**
390     * Constructor
391     */
392      public InvoiceParticipantComponent() {
393        super();
394      }
395
396    /**
397     * Constructor
398     */
399      public InvoiceParticipantComponent(Reference actor) {
400        super();
401        this.actor = actor;
402      }
403
404        /**
405         * @return {@link #role} (Describes the type of involvement (e.g. transcriptionist, creator etc.). If the invoice has been created automatically, the Participant may be a billing engine or another kind of device.)
406         */
407        public CodeableConcept getRole() { 
408          if (this.role == null)
409            if (Configuration.errorOnAutoCreate())
410              throw new Error("Attempt to auto-create InvoiceParticipantComponent.role");
411            else if (Configuration.doAutoCreate())
412              this.role = new CodeableConcept(); // cc
413          return this.role;
414        }
415
416        public boolean hasRole() { 
417          return this.role != null && !this.role.isEmpty();
418        }
419
420        /**
421         * @param value {@link #role} (Describes the type of involvement (e.g. transcriptionist, creator etc.). If the invoice has been created automatically, the Participant may be a billing engine or another kind of device.)
422         */
423        public InvoiceParticipantComponent setRole(CodeableConcept value) { 
424          this.role = value;
425          return this;
426        }
427
428        /**
429         * @return {@link #actor} (The device, practitioner, etc. who performed or participated in the service.)
430         */
431        public Reference getActor() { 
432          if (this.actor == null)
433            if (Configuration.errorOnAutoCreate())
434              throw new Error("Attempt to auto-create InvoiceParticipantComponent.actor");
435            else if (Configuration.doAutoCreate())
436              this.actor = new Reference(); // cc
437          return this.actor;
438        }
439
440        public boolean hasActor() { 
441          return this.actor != null && !this.actor.isEmpty();
442        }
443
444        /**
445         * @param value {@link #actor} (The device, practitioner, etc. who performed or participated in the service.)
446         */
447        public InvoiceParticipantComponent setActor(Reference value) { 
448          this.actor = value;
449          return this;
450        }
451
452        protected void listChildren(List<Property> children) {
453          super.listChildren(children);
454          children.add(new Property("role", "CodeableConcept", "Describes the type of involvement (e.g. transcriptionist, creator etc.). If the invoice has been created automatically, the Participant may be a billing engine or another kind of device.", 0, 1, role));
455          children.add(new Property("actor", "Reference(Practitioner|Organization|Patient|PractitionerRole|Device|RelatedPerson)", "The device, practitioner, etc. who performed or participated in the service.", 0, 1, actor));
456        }
457
458        @Override
459        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
460          switch (_hash) {
461          case 3506294: /*role*/  return new Property("role", "CodeableConcept", "Describes the type of involvement (e.g. transcriptionist, creator etc.). If the invoice has been created automatically, the Participant may be a billing engine or another kind of device.", 0, 1, role);
462          case 92645877: /*actor*/  return new Property("actor", "Reference(Practitioner|Organization|Patient|PractitionerRole|Device|RelatedPerson)", "The device, practitioner, etc. who performed or participated in the service.", 0, 1, actor);
463          default: return super.getNamedProperty(_hash, _name, _checkValid);
464          }
465
466        }
467
468      @Override
469      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
470        switch (hash) {
471        case 3506294: /*role*/ return this.role == null ? new Base[0] : new Base[] {this.role}; // CodeableConcept
472        case 92645877: /*actor*/ return this.actor == null ? new Base[0] : new Base[] {this.actor}; // Reference
473        default: return super.getProperty(hash, name, checkValid);
474        }
475
476      }
477
478      @Override
479      public Base setProperty(int hash, String name, Base value) throws FHIRException {
480        switch (hash) {
481        case 3506294: // role
482          this.role = castToCodeableConcept(value); // CodeableConcept
483          return value;
484        case 92645877: // actor
485          this.actor = castToReference(value); // Reference
486          return value;
487        default: return super.setProperty(hash, name, value);
488        }
489
490      }
491
492      @Override
493      public Base setProperty(String name, Base value) throws FHIRException {
494        if (name.equals("role")) {
495          this.role = castToCodeableConcept(value); // CodeableConcept
496        } else if (name.equals("actor")) {
497          this.actor = castToReference(value); // Reference
498        } else
499          return super.setProperty(name, value);
500        return value;
501      }
502
503      @Override
504      public Base makeProperty(int hash, String name) throws FHIRException {
505        switch (hash) {
506        case 3506294:  return getRole();
507        case 92645877:  return getActor();
508        default: return super.makeProperty(hash, name);
509        }
510
511      }
512
513      @Override
514      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
515        switch (hash) {
516        case 3506294: /*role*/ return new String[] {"CodeableConcept"};
517        case 92645877: /*actor*/ return new String[] {"Reference"};
518        default: return super.getTypesForProperty(hash, name);
519        }
520
521      }
522
523      @Override
524      public Base addChild(String name) throws FHIRException {
525        if (name.equals("role")) {
526          this.role = new CodeableConcept();
527          return this.role;
528        }
529        else if (name.equals("actor")) {
530          this.actor = new Reference();
531          return this.actor;
532        }
533        else
534          return super.addChild(name);
535      }
536
537      public InvoiceParticipantComponent copy() {
538        InvoiceParticipantComponent dst = new InvoiceParticipantComponent();
539        copyValues(dst);
540        return dst;
541      }
542
543      public void copyValues(InvoiceParticipantComponent dst) {
544        super.copyValues(dst);
545        dst.role = role == null ? null : role.copy();
546        dst.actor = actor == null ? null : actor.copy();
547      }
548
549      @Override
550      public boolean equalsDeep(Base other_) {
551        if (!super.equalsDeep(other_))
552          return false;
553        if (!(other_ instanceof InvoiceParticipantComponent))
554          return false;
555        InvoiceParticipantComponent o = (InvoiceParticipantComponent) other_;
556        return compareDeep(role, o.role, true) && compareDeep(actor, o.actor, true);
557      }
558
559      @Override
560      public boolean equalsShallow(Base other_) {
561        if (!super.equalsShallow(other_))
562          return false;
563        if (!(other_ instanceof InvoiceParticipantComponent))
564          return false;
565        InvoiceParticipantComponent o = (InvoiceParticipantComponent) other_;
566        return true;
567      }
568
569      public boolean isEmpty() {
570        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(role, actor);
571      }
572
573  public String fhirType() {
574    return "Invoice.participant";
575
576  }
577
578  }
579
580    @Block()
581    public static class InvoiceLineItemComponent extends BackboneElement implements IBaseBackboneElement {
582        /**
583         * Sequence in which the items appear on the invoice.
584         */
585        @Child(name = "sequence", type = {PositiveIntType.class}, order=1, min=0, max=1, modifier=false, summary=false)
586        @Description(shortDefinition="Sequence number of line item", formalDefinition="Sequence in which the items appear on the invoice." )
587        protected PositiveIntType sequence;
588
589        /**
590         * The ChargeItem contains information such as the billing code, date, amount etc. If no further details are required for the lineItem, inline billing codes can be added using the CodeableConcept data type instead of the Reference.
591         */
592        @Child(name = "chargeItem", type = {ChargeItem.class, CodeableConcept.class}, order=2, min=1, max=1, modifier=false, summary=false)
593        @Description(shortDefinition="Reference to ChargeItem containing details of this line item or an inline billing code", formalDefinition="The ChargeItem contains information such as the billing code, date, amount etc. If no further details are required for the lineItem, inline billing codes can be added using the CodeableConcept data type instead of the Reference." )
594        protected Type chargeItem;
595
596        /**
597         * The price for a ChargeItem may be calculated as a base price with surcharges/deductions that apply in certain conditions. A ChargeItemDefinition resource that defines the prices, factors and conditions that apply to a billing code is currently under development. The priceComponent element can be used to offer transparency to the recipient of the Invoice as to how the prices have been calculated.
598         */
599        @Child(name = "priceComponent", type = {}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
600        @Description(shortDefinition="Components of total line item price", formalDefinition="The price for a ChargeItem may be calculated as a base price with surcharges/deductions that apply in certain conditions. A ChargeItemDefinition resource that defines the prices, factors and conditions that apply to a billing code is currently under development. The priceComponent element can be used to offer transparency to the recipient of the Invoice as to how the prices have been calculated." )
601        protected List<InvoiceLineItemPriceComponentComponent> priceComponent;
602
603        private static final long serialVersionUID = -1013610189L;
604
605    /**
606     * Constructor
607     */
608      public InvoiceLineItemComponent() {
609        super();
610      }
611
612    /**
613     * Constructor
614     */
615      public InvoiceLineItemComponent(Type chargeItem) {
616        super();
617        this.chargeItem = chargeItem;
618      }
619
620        /**
621         * @return {@link #sequence} (Sequence in which the items appear on the invoice.). This is the underlying object with id, value and extensions. The accessor "getSequence" gives direct access to the value
622         */
623        public PositiveIntType getSequenceElement() { 
624          if (this.sequence == null)
625            if (Configuration.errorOnAutoCreate())
626              throw new Error("Attempt to auto-create InvoiceLineItemComponent.sequence");
627            else if (Configuration.doAutoCreate())
628              this.sequence = new PositiveIntType(); // bb
629          return this.sequence;
630        }
631
632        public boolean hasSequenceElement() { 
633          return this.sequence != null && !this.sequence.isEmpty();
634        }
635
636        public boolean hasSequence() { 
637          return this.sequence != null && !this.sequence.isEmpty();
638        }
639
640        /**
641         * @param value {@link #sequence} (Sequence in which the items appear on the invoice.). This is the underlying object with id, value and extensions. The accessor "getSequence" gives direct access to the value
642         */
643        public InvoiceLineItemComponent setSequenceElement(PositiveIntType value) { 
644          this.sequence = value;
645          return this;
646        }
647
648        /**
649         * @return Sequence in which the items appear on the invoice.
650         */
651        public int getSequence() { 
652          return this.sequence == null || this.sequence.isEmpty() ? 0 : this.sequence.getValue();
653        }
654
655        /**
656         * @param value Sequence in which the items appear on the invoice.
657         */
658        public InvoiceLineItemComponent setSequence(int value) { 
659            if (this.sequence == null)
660              this.sequence = new PositiveIntType();
661            this.sequence.setValue(value);
662          return this;
663        }
664
665        /**
666         * @return {@link #chargeItem} (The ChargeItem contains information such as the billing code, date, amount etc. If no further details are required for the lineItem, inline billing codes can be added using the CodeableConcept data type instead of the Reference.)
667         */
668        public Type getChargeItem() { 
669          return this.chargeItem;
670        }
671
672        /**
673         * @return {@link #chargeItem} (The ChargeItem contains information such as the billing code, date, amount etc. If no further details are required for the lineItem, inline billing codes can be added using the CodeableConcept data type instead of the Reference.)
674         */
675        public Reference getChargeItemReference() throws FHIRException { 
676          if (this.chargeItem == null)
677            this.chargeItem = new Reference();
678          if (!(this.chargeItem instanceof Reference))
679            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.chargeItem.getClass().getName()+" was encountered");
680          return (Reference) this.chargeItem;
681        }
682
683        public boolean hasChargeItemReference() { 
684          return this != null && this.chargeItem instanceof Reference;
685        }
686
687        /**
688         * @return {@link #chargeItem} (The ChargeItem contains information such as the billing code, date, amount etc. If no further details are required for the lineItem, inline billing codes can be added using the CodeableConcept data type instead of the Reference.)
689         */
690        public CodeableConcept getChargeItemCodeableConcept() throws FHIRException { 
691          if (this.chargeItem == null)
692            this.chargeItem = new CodeableConcept();
693          if (!(this.chargeItem instanceof CodeableConcept))
694            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.chargeItem.getClass().getName()+" was encountered");
695          return (CodeableConcept) this.chargeItem;
696        }
697
698        public boolean hasChargeItemCodeableConcept() { 
699          return this != null && this.chargeItem instanceof CodeableConcept;
700        }
701
702        public boolean hasChargeItem() { 
703          return this.chargeItem != null && !this.chargeItem.isEmpty();
704        }
705
706        /**
707         * @param value {@link #chargeItem} (The ChargeItem contains information such as the billing code, date, amount etc. If no further details are required for the lineItem, inline billing codes can be added using the CodeableConcept data type instead of the Reference.)
708         */
709        public InvoiceLineItemComponent setChargeItem(Type value) { 
710          if (value != null && !(value instanceof Reference || value instanceof CodeableConcept))
711            throw new Error("Not the right type for Invoice.lineItem.chargeItem[x]: "+value.fhirType());
712          this.chargeItem = value;
713          return this;
714        }
715
716        /**
717         * @return {@link #priceComponent} (The price for a ChargeItem may be calculated as a base price with surcharges/deductions that apply in certain conditions. A ChargeItemDefinition resource that defines the prices, factors and conditions that apply to a billing code is currently under development. The priceComponent element can be used to offer transparency to the recipient of the Invoice as to how the prices have been calculated.)
718         */
719        public List<InvoiceLineItemPriceComponentComponent> getPriceComponent() { 
720          if (this.priceComponent == null)
721            this.priceComponent = new ArrayList<InvoiceLineItemPriceComponentComponent>();
722          return this.priceComponent;
723        }
724
725        /**
726         * @return Returns a reference to <code>this</code> for easy method chaining
727         */
728        public InvoiceLineItemComponent setPriceComponent(List<InvoiceLineItemPriceComponentComponent> thePriceComponent) { 
729          this.priceComponent = thePriceComponent;
730          return this;
731        }
732
733        public boolean hasPriceComponent() { 
734          if (this.priceComponent == null)
735            return false;
736          for (InvoiceLineItemPriceComponentComponent item : this.priceComponent)
737            if (!item.isEmpty())
738              return true;
739          return false;
740        }
741
742        public InvoiceLineItemPriceComponentComponent addPriceComponent() { //3
743          InvoiceLineItemPriceComponentComponent t = new InvoiceLineItemPriceComponentComponent();
744          if (this.priceComponent == null)
745            this.priceComponent = new ArrayList<InvoiceLineItemPriceComponentComponent>();
746          this.priceComponent.add(t);
747          return t;
748        }
749
750        public InvoiceLineItemComponent addPriceComponent(InvoiceLineItemPriceComponentComponent t) { //3
751          if (t == null)
752            return this;
753          if (this.priceComponent == null)
754            this.priceComponent = new ArrayList<InvoiceLineItemPriceComponentComponent>();
755          this.priceComponent.add(t);
756          return this;
757        }
758
759        /**
760         * @return The first repetition of repeating field {@link #priceComponent}, creating it if it does not already exist
761         */
762        public InvoiceLineItemPriceComponentComponent getPriceComponentFirstRep() { 
763          if (getPriceComponent().isEmpty()) {
764            addPriceComponent();
765          }
766          return getPriceComponent().get(0);
767        }
768
769        protected void listChildren(List<Property> children) {
770          super.listChildren(children);
771          children.add(new Property("sequence", "positiveInt", "Sequence in which the items appear on the invoice.", 0, 1, sequence));
772          children.add(new Property("chargeItem[x]", "Reference(ChargeItem)|CodeableConcept", "The ChargeItem contains information such as the billing code, date, amount etc. If no further details are required for the lineItem, inline billing codes can be added using the CodeableConcept data type instead of the Reference.", 0, 1, chargeItem));
773          children.add(new Property("priceComponent", "", "The price for a ChargeItem may be calculated as a base price with surcharges/deductions that apply in certain conditions. A ChargeItemDefinition resource that defines the prices, factors and conditions that apply to a billing code is currently under development. The priceComponent element can be used to offer transparency to the recipient of the Invoice as to how the prices have been calculated.", 0, java.lang.Integer.MAX_VALUE, priceComponent));
774        }
775
776        @Override
777        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
778          switch (_hash) {
779          case 1349547969: /*sequence*/  return new Property("sequence", "positiveInt", "Sequence in which the items appear on the invoice.", 0, 1, sequence);
780          case 351104825: /*chargeItem[x]*/  return new Property("chargeItem[x]", "Reference(ChargeItem)|CodeableConcept", "The ChargeItem contains information such as the billing code, date, amount etc. If no further details are required for the lineItem, inline billing codes can be added using the CodeableConcept data type instead of the Reference.", 0, 1, chargeItem);
781          case 1417779175: /*chargeItem*/  return new Property("chargeItem[x]", "Reference(ChargeItem)|CodeableConcept", "The ChargeItem contains information such as the billing code, date, amount etc. If no further details are required for the lineItem, inline billing codes can be added using the CodeableConcept data type instead of the Reference.", 0, 1, chargeItem);
782          case 753580836: /*chargeItemReference*/  return new Property("chargeItem[x]", "Reference(ChargeItem)|CodeableConcept", "The ChargeItem contains information such as the billing code, date, amount etc. If no further details are required for the lineItem, inline billing codes can be added using the CodeableConcept data type instead of the Reference.", 0, 1, chargeItem);
783          case 1226532026: /*chargeItemCodeableConcept*/  return new Property("chargeItem[x]", "Reference(ChargeItem)|CodeableConcept", "The ChargeItem contains information such as the billing code, date, amount etc. If no further details are required for the lineItem, inline billing codes can be added using the CodeableConcept data type instead of the Reference.", 0, 1, chargeItem);
784          case 1219095988: /*priceComponent*/  return new Property("priceComponent", "", "The price for a ChargeItem may be calculated as a base price with surcharges/deductions that apply in certain conditions. A ChargeItemDefinition resource that defines the prices, factors and conditions that apply to a billing code is currently under development. The priceComponent element can be used to offer transparency to the recipient of the Invoice as to how the prices have been calculated.", 0, java.lang.Integer.MAX_VALUE, priceComponent);
785          default: return super.getNamedProperty(_hash, _name, _checkValid);
786          }
787
788        }
789
790      @Override
791      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
792        switch (hash) {
793        case 1349547969: /*sequence*/ return this.sequence == null ? new Base[0] : new Base[] {this.sequence}; // PositiveIntType
794        case 1417779175: /*chargeItem*/ return this.chargeItem == null ? new Base[0] : new Base[] {this.chargeItem}; // Type
795        case 1219095988: /*priceComponent*/ return this.priceComponent == null ? new Base[0] : this.priceComponent.toArray(new Base[this.priceComponent.size()]); // InvoiceLineItemPriceComponentComponent
796        default: return super.getProperty(hash, name, checkValid);
797        }
798
799      }
800
801      @Override
802      public Base setProperty(int hash, String name, Base value) throws FHIRException {
803        switch (hash) {
804        case 1349547969: // sequence
805          this.sequence = castToPositiveInt(value); // PositiveIntType
806          return value;
807        case 1417779175: // chargeItem
808          this.chargeItem = castToType(value); // Type
809          return value;
810        case 1219095988: // priceComponent
811          this.getPriceComponent().add((InvoiceLineItemPriceComponentComponent) value); // InvoiceLineItemPriceComponentComponent
812          return value;
813        default: return super.setProperty(hash, name, value);
814        }
815
816      }
817
818      @Override
819      public Base setProperty(String name, Base value) throws FHIRException {
820        if (name.equals("sequence")) {
821          this.sequence = castToPositiveInt(value); // PositiveIntType
822        } else if (name.equals("chargeItem[x]")) {
823          this.chargeItem = castToType(value); // Type
824        } else if (name.equals("priceComponent")) {
825          this.getPriceComponent().add((InvoiceLineItemPriceComponentComponent) value);
826        } else
827          return super.setProperty(name, value);
828        return value;
829      }
830
831      @Override
832      public Base makeProperty(int hash, String name) throws FHIRException {
833        switch (hash) {
834        case 1349547969:  return getSequenceElement();
835        case 351104825:  return getChargeItem();
836        case 1417779175:  return getChargeItem();
837        case 1219095988:  return addPriceComponent(); 
838        default: return super.makeProperty(hash, name);
839        }
840
841      }
842
843      @Override
844      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
845        switch (hash) {
846        case 1349547969: /*sequence*/ return new String[] {"positiveInt"};
847        case 1417779175: /*chargeItem*/ return new String[] {"Reference", "CodeableConcept"};
848        case 1219095988: /*priceComponent*/ return new String[] {};
849        default: return super.getTypesForProperty(hash, name);
850        }
851
852      }
853
854      @Override
855      public Base addChild(String name) throws FHIRException {
856        if (name.equals("sequence")) {
857          throw new FHIRException("Cannot call addChild on a primitive type Invoice.sequence");
858        }
859        else if (name.equals("chargeItemReference")) {
860          this.chargeItem = new Reference();
861          return this.chargeItem;
862        }
863        else if (name.equals("chargeItemCodeableConcept")) {
864          this.chargeItem = new CodeableConcept();
865          return this.chargeItem;
866        }
867        else if (name.equals("priceComponent")) {
868          return addPriceComponent();
869        }
870        else
871          return super.addChild(name);
872      }
873
874      public InvoiceLineItemComponent copy() {
875        InvoiceLineItemComponent dst = new InvoiceLineItemComponent();
876        copyValues(dst);
877        return dst;
878      }
879
880      public void copyValues(InvoiceLineItemComponent dst) {
881        super.copyValues(dst);
882        dst.sequence = sequence == null ? null : sequence.copy();
883        dst.chargeItem = chargeItem == null ? null : chargeItem.copy();
884        if (priceComponent != null) {
885          dst.priceComponent = new ArrayList<InvoiceLineItemPriceComponentComponent>();
886          for (InvoiceLineItemPriceComponentComponent i : priceComponent)
887            dst.priceComponent.add(i.copy());
888        };
889      }
890
891      @Override
892      public boolean equalsDeep(Base other_) {
893        if (!super.equalsDeep(other_))
894          return false;
895        if (!(other_ instanceof InvoiceLineItemComponent))
896          return false;
897        InvoiceLineItemComponent o = (InvoiceLineItemComponent) other_;
898        return compareDeep(sequence, o.sequence, true) && compareDeep(chargeItem, o.chargeItem, true) && compareDeep(priceComponent, o.priceComponent, true)
899          ;
900      }
901
902      @Override
903      public boolean equalsShallow(Base other_) {
904        if (!super.equalsShallow(other_))
905          return false;
906        if (!(other_ instanceof InvoiceLineItemComponent))
907          return false;
908        InvoiceLineItemComponent o = (InvoiceLineItemComponent) other_;
909        return compareValues(sequence, o.sequence, true);
910      }
911
912      public boolean isEmpty() {
913        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(sequence, chargeItem, priceComponent
914          );
915      }
916
917  public String fhirType() {
918    return "Invoice.lineItem";
919
920  }
921
922  }
923
924    @Block()
925    public static class InvoiceLineItemPriceComponentComponent extends BackboneElement implements IBaseBackboneElement {
926        /**
927         * This code identifies the type of the component.
928         */
929        @Child(name = "type", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=false)
930        @Description(shortDefinition="base | surcharge | deduction | discount | tax | informational", formalDefinition="This code identifies the type of the component." )
931        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/invoice-priceComponentType")
932        protected Enumeration<InvoicePriceComponentType> type;
933
934        /**
935         * A code that identifies the component. Codes may be used to differentiate between kinds of taxes, surcharges, discounts etc.
936         */
937        @Child(name = "code", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
938        @Description(shortDefinition="Code identifying the specific component", formalDefinition="A code that identifies the component. Codes may be used to differentiate between kinds of taxes, surcharges, discounts etc." )
939        protected CodeableConcept code;
940
941        /**
942         * The factor that has been applied on the base price for calculating this component.
943         */
944        @Child(name = "factor", type = {DecimalType.class}, order=3, min=0, max=1, modifier=false, summary=false)
945        @Description(shortDefinition="Factor used for calculating this component", formalDefinition="The factor that has been applied on the base price for calculating this component." )
946        protected DecimalType factor;
947
948        /**
949         * The amount calculated for this component.
950         */
951        @Child(name = "amount", type = {Money.class}, order=4, min=0, max=1, modifier=false, summary=false)
952        @Description(shortDefinition="Monetary amount associated with this component", formalDefinition="The amount calculated for this component." )
953        protected Money amount;
954
955        private static final long serialVersionUID = 1223988958L;
956
957    /**
958     * Constructor
959     */
960      public InvoiceLineItemPriceComponentComponent() {
961        super();
962      }
963
964    /**
965     * Constructor
966     */
967      public InvoiceLineItemPriceComponentComponent(Enumeration<InvoicePriceComponentType> type) {
968        super();
969        this.type = type;
970      }
971
972        /**
973         * @return {@link #type} (This code identifies the type of the component.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
974         */
975        public Enumeration<InvoicePriceComponentType> getTypeElement() { 
976          if (this.type == null)
977            if (Configuration.errorOnAutoCreate())
978              throw new Error("Attempt to auto-create InvoiceLineItemPriceComponentComponent.type");
979            else if (Configuration.doAutoCreate())
980              this.type = new Enumeration<InvoicePriceComponentType>(new InvoicePriceComponentTypeEnumFactory()); // bb
981          return this.type;
982        }
983
984        public boolean hasTypeElement() { 
985          return this.type != null && !this.type.isEmpty();
986        }
987
988        public boolean hasType() { 
989          return this.type != null && !this.type.isEmpty();
990        }
991
992        /**
993         * @param value {@link #type} (This code identifies the type of the component.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
994         */
995        public InvoiceLineItemPriceComponentComponent setTypeElement(Enumeration<InvoicePriceComponentType> value) { 
996          this.type = value;
997          return this;
998        }
999
1000        /**
1001         * @return This code identifies the type of the component.
1002         */
1003        public InvoicePriceComponentType getType() { 
1004          return this.type == null ? null : this.type.getValue();
1005        }
1006
1007        /**
1008         * @param value This code identifies the type of the component.
1009         */
1010        public InvoiceLineItemPriceComponentComponent setType(InvoicePriceComponentType value) { 
1011            if (this.type == null)
1012              this.type = new Enumeration<InvoicePriceComponentType>(new InvoicePriceComponentTypeEnumFactory());
1013            this.type.setValue(value);
1014          return this;
1015        }
1016
1017        /**
1018         * @return {@link #code} (A code that identifies the component. Codes may be used to differentiate between kinds of taxes, surcharges, discounts etc.)
1019         */
1020        public CodeableConcept getCode() { 
1021          if (this.code == null)
1022            if (Configuration.errorOnAutoCreate())
1023              throw new Error("Attempt to auto-create InvoiceLineItemPriceComponentComponent.code");
1024            else if (Configuration.doAutoCreate())
1025              this.code = new CodeableConcept(); // cc
1026          return this.code;
1027        }
1028
1029        public boolean hasCode() { 
1030          return this.code != null && !this.code.isEmpty();
1031        }
1032
1033        /**
1034         * @param value {@link #code} (A code that identifies the component. Codes may be used to differentiate between kinds of taxes, surcharges, discounts etc.)
1035         */
1036        public InvoiceLineItemPriceComponentComponent setCode(CodeableConcept value) { 
1037          this.code = value;
1038          return this;
1039        }
1040
1041        /**
1042         * @return {@link #factor} (The factor that has been applied on the base price for calculating this component.). This is the underlying object with id, value and extensions. The accessor "getFactor" gives direct access to the value
1043         */
1044        public DecimalType getFactorElement() { 
1045          if (this.factor == null)
1046            if (Configuration.errorOnAutoCreate())
1047              throw new Error("Attempt to auto-create InvoiceLineItemPriceComponentComponent.factor");
1048            else if (Configuration.doAutoCreate())
1049              this.factor = new DecimalType(); // bb
1050          return this.factor;
1051        }
1052
1053        public boolean hasFactorElement() { 
1054          return this.factor != null && !this.factor.isEmpty();
1055        }
1056
1057        public boolean hasFactor() { 
1058          return this.factor != null && !this.factor.isEmpty();
1059        }
1060
1061        /**
1062         * @param value {@link #factor} (The factor that has been applied on the base price for calculating this component.). This is the underlying object with id, value and extensions. The accessor "getFactor" gives direct access to the value
1063         */
1064        public InvoiceLineItemPriceComponentComponent setFactorElement(DecimalType value) { 
1065          this.factor = value;
1066          return this;
1067        }
1068
1069        /**
1070         * @return The factor that has been applied on the base price for calculating this component.
1071         */
1072        public BigDecimal getFactor() { 
1073          return this.factor == null ? null : this.factor.getValue();
1074        }
1075
1076        /**
1077         * @param value The factor that has been applied on the base price for calculating this component.
1078         */
1079        public InvoiceLineItemPriceComponentComponent setFactor(BigDecimal value) { 
1080          if (value == null)
1081            this.factor = null;
1082          else {
1083            if (this.factor == null)
1084              this.factor = new DecimalType();
1085            this.factor.setValue(value);
1086          }
1087          return this;
1088        }
1089
1090        /**
1091         * @param value The factor that has been applied on the base price for calculating this component.
1092         */
1093        public InvoiceLineItemPriceComponentComponent setFactor(long value) { 
1094              this.factor = new DecimalType();
1095            this.factor.setValue(value);
1096          return this;
1097        }
1098
1099        /**
1100         * @param value The factor that has been applied on the base price for calculating this component.
1101         */
1102        public InvoiceLineItemPriceComponentComponent setFactor(double value) { 
1103              this.factor = new DecimalType();
1104            this.factor.setValue(value);
1105          return this;
1106        }
1107
1108        /**
1109         * @return {@link #amount} (The amount calculated for this component.)
1110         */
1111        public Money getAmount() { 
1112          if (this.amount == null)
1113            if (Configuration.errorOnAutoCreate())
1114              throw new Error("Attempt to auto-create InvoiceLineItemPriceComponentComponent.amount");
1115            else if (Configuration.doAutoCreate())
1116              this.amount = new Money(); // cc
1117          return this.amount;
1118        }
1119
1120        public boolean hasAmount() { 
1121          return this.amount != null && !this.amount.isEmpty();
1122        }
1123
1124        /**
1125         * @param value {@link #amount} (The amount calculated for this component.)
1126         */
1127        public InvoiceLineItemPriceComponentComponent setAmount(Money value) { 
1128          this.amount = value;
1129          return this;
1130        }
1131
1132        protected void listChildren(List<Property> children) {
1133          super.listChildren(children);
1134          children.add(new Property("type", "code", "This code identifies the type of the component.", 0, 1, type));
1135          children.add(new Property("code", "CodeableConcept", "A code that identifies the component. Codes may be used to differentiate between kinds of taxes, surcharges, discounts etc.", 0, 1, code));
1136          children.add(new Property("factor", "decimal", "The factor that has been applied on the base price for calculating this component.", 0, 1, factor));
1137          children.add(new Property("amount", "Money", "The amount calculated for this component.", 0, 1, amount));
1138        }
1139
1140        @Override
1141        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1142          switch (_hash) {
1143          case 3575610: /*type*/  return new Property("type", "code", "This code identifies the type of the component.", 0, 1, type);
1144          case 3059181: /*code*/  return new Property("code", "CodeableConcept", "A code that identifies the component. Codes may be used to differentiate between kinds of taxes, surcharges, discounts etc.", 0, 1, code);
1145          case -1282148017: /*factor*/  return new Property("factor", "decimal", "The factor that has been applied on the base price for calculating this component.", 0, 1, factor);
1146          case -1413853096: /*amount*/  return new Property("amount", "Money", "The amount calculated for this component.", 0, 1, amount);
1147          default: return super.getNamedProperty(_hash, _name, _checkValid);
1148          }
1149
1150        }
1151
1152      @Override
1153      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1154        switch (hash) {
1155        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // Enumeration<InvoicePriceComponentType>
1156        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
1157        case -1282148017: /*factor*/ return this.factor == null ? new Base[0] : new Base[] {this.factor}; // DecimalType
1158        case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // Money
1159        default: return super.getProperty(hash, name, checkValid);
1160        }
1161
1162      }
1163
1164      @Override
1165      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1166        switch (hash) {
1167        case 3575610: // type
1168          value = new InvoicePriceComponentTypeEnumFactory().fromType(castToCode(value));
1169          this.type = (Enumeration) value; // Enumeration<InvoicePriceComponentType>
1170          return value;
1171        case 3059181: // code
1172          this.code = castToCodeableConcept(value); // CodeableConcept
1173          return value;
1174        case -1282148017: // factor
1175          this.factor = castToDecimal(value); // DecimalType
1176          return value;
1177        case -1413853096: // amount
1178          this.amount = castToMoney(value); // Money
1179          return value;
1180        default: return super.setProperty(hash, name, value);
1181        }
1182
1183      }
1184
1185      @Override
1186      public Base setProperty(String name, Base value) throws FHIRException {
1187        if (name.equals("type")) {
1188          value = new InvoicePriceComponentTypeEnumFactory().fromType(castToCode(value));
1189          this.type = (Enumeration) value; // Enumeration<InvoicePriceComponentType>
1190        } else if (name.equals("code")) {
1191          this.code = castToCodeableConcept(value); // CodeableConcept
1192        } else if (name.equals("factor")) {
1193          this.factor = castToDecimal(value); // DecimalType
1194        } else if (name.equals("amount")) {
1195          this.amount = castToMoney(value); // Money
1196        } else
1197          return super.setProperty(name, value);
1198        return value;
1199      }
1200
1201      @Override
1202      public Base makeProperty(int hash, String name) throws FHIRException {
1203        switch (hash) {
1204        case 3575610:  return getTypeElement();
1205        case 3059181:  return getCode();
1206        case -1282148017:  return getFactorElement();
1207        case -1413853096:  return getAmount();
1208        default: return super.makeProperty(hash, name);
1209        }
1210
1211      }
1212
1213      @Override
1214      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1215        switch (hash) {
1216        case 3575610: /*type*/ return new String[] {"code"};
1217        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
1218        case -1282148017: /*factor*/ return new String[] {"decimal"};
1219        case -1413853096: /*amount*/ return new String[] {"Money"};
1220        default: return super.getTypesForProperty(hash, name);
1221        }
1222
1223      }
1224
1225      @Override
1226      public Base addChild(String name) throws FHIRException {
1227        if (name.equals("type")) {
1228          throw new FHIRException("Cannot call addChild on a primitive type Invoice.type");
1229        }
1230        else if (name.equals("code")) {
1231          this.code = new CodeableConcept();
1232          return this.code;
1233        }
1234        else if (name.equals("factor")) {
1235          throw new FHIRException("Cannot call addChild on a primitive type Invoice.factor");
1236        }
1237        else if (name.equals("amount")) {
1238          this.amount = new Money();
1239          return this.amount;
1240        }
1241        else
1242          return super.addChild(name);
1243      }
1244
1245      public InvoiceLineItemPriceComponentComponent copy() {
1246        InvoiceLineItemPriceComponentComponent dst = new InvoiceLineItemPriceComponentComponent();
1247        copyValues(dst);
1248        return dst;
1249      }
1250
1251      public void copyValues(InvoiceLineItemPriceComponentComponent dst) {
1252        super.copyValues(dst);
1253        dst.type = type == null ? null : type.copy();
1254        dst.code = code == null ? null : code.copy();
1255        dst.factor = factor == null ? null : factor.copy();
1256        dst.amount = amount == null ? null : amount.copy();
1257      }
1258
1259      @Override
1260      public boolean equalsDeep(Base other_) {
1261        if (!super.equalsDeep(other_))
1262          return false;
1263        if (!(other_ instanceof InvoiceLineItemPriceComponentComponent))
1264          return false;
1265        InvoiceLineItemPriceComponentComponent o = (InvoiceLineItemPriceComponentComponent) other_;
1266        return compareDeep(type, o.type, true) && compareDeep(code, o.code, true) && compareDeep(factor, o.factor, true)
1267           && compareDeep(amount, o.amount, true);
1268      }
1269
1270      @Override
1271      public boolean equalsShallow(Base other_) {
1272        if (!super.equalsShallow(other_))
1273          return false;
1274        if (!(other_ instanceof InvoiceLineItemPriceComponentComponent))
1275          return false;
1276        InvoiceLineItemPriceComponentComponent o = (InvoiceLineItemPriceComponentComponent) other_;
1277        return compareValues(type, o.type, true) && compareValues(factor, o.factor, true);
1278      }
1279
1280      public boolean isEmpty() {
1281        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, code, factor, amount
1282          );
1283      }
1284
1285  public String fhirType() {
1286    return "Invoice.lineItem.priceComponent";
1287
1288  }
1289
1290  }
1291
1292    /**
1293     * Identifier of this Invoice, often used for reference in correspondence about this invoice or for tracking of payments.
1294     */
1295    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1296    @Description(shortDefinition="Business Identifier for item", formalDefinition="Identifier of this Invoice, often used for reference in correspondence about this invoice or for tracking of payments." )
1297    protected List<Identifier> identifier;
1298
1299    /**
1300     * The current state of the Invoice.
1301     */
1302    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
1303    @Description(shortDefinition="draft | issued | balanced | cancelled | entered-in-error", formalDefinition="The current state of the Invoice." )
1304    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/invoice-status")
1305    protected Enumeration<InvoiceStatus> status;
1306
1307    /**
1308     * In case of Invoice cancellation a reason must be given (entered in error, superseded by corrected invoice etc.).
1309     */
1310    @Child(name = "cancelledReason", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=false)
1311    @Description(shortDefinition="Reason for cancellation of this Invoice", formalDefinition="In case of Invoice cancellation a reason must be given (entered in error, superseded by corrected invoice etc.)." )
1312    protected StringType cancelledReason;
1313
1314    /**
1315     * Type of Invoice depending on domain, realm an usage (e.g. internal/external, dental, preliminary).
1316     */
1317    @Child(name = "type", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
1318    @Description(shortDefinition="Type of Invoice", formalDefinition="Type of Invoice depending on domain, realm an usage (e.g. internal/external, dental, preliminary)." )
1319    protected CodeableConcept type;
1320
1321    /**
1322     * The individual or set of individuals receiving the goods and services billed in this invoice.
1323     */
1324    @Child(name = "subject", type = {Patient.class, Group.class}, order=4, min=0, max=1, modifier=false, summary=true)
1325    @Description(shortDefinition="Recipient(s) of goods and services", formalDefinition="The individual or set of individuals receiving the goods and services billed in this invoice." )
1326    protected Reference subject;
1327
1328    /**
1329     * The individual or Organization responsible for balancing of this invoice.
1330     */
1331    @Child(name = "recipient", type = {Organization.class, Patient.class, RelatedPerson.class}, order=5, min=0, max=1, modifier=false, summary=true)
1332    @Description(shortDefinition="Recipient of this invoice", formalDefinition="The individual or Organization responsible for balancing of this invoice." )
1333    protected Reference recipient;
1334
1335    /**
1336     * Date/time(s) of when this Invoice was posted.
1337     */
1338    @Child(name = "date", type = {DateTimeType.class}, order=6, min=0, max=1, modifier=false, summary=true)
1339    @Description(shortDefinition="Invoice date / posting date", formalDefinition="Date/time(s) of when this Invoice was posted." )
1340    protected DateTimeType date;
1341
1342    /**
1343     * Indicates who or what performed or participated in the charged service.
1344     */
1345    @Child(name = "participant", type = {}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1346    @Description(shortDefinition="Participant in creation of this Invoice", formalDefinition="Indicates who or what performed or participated in the charged service." )
1347    protected List<InvoiceParticipantComponent> participant;
1348
1349    /**
1350     * The organizationissuing the Invoice.
1351     */
1352    @Child(name = "issuer", type = {Organization.class}, order=8, min=0, max=1, modifier=false, summary=false)
1353    @Description(shortDefinition="Issuing Organization of Invoice", formalDefinition="The organizationissuing the Invoice." )
1354    protected Reference issuer;
1355
1356    /**
1357     * Account which is supposed to be balanced with this Invoice.
1358     */
1359    @Child(name = "account", type = {Account.class}, order=9, min=0, max=1, modifier=false, summary=false)
1360    @Description(shortDefinition="Account that is being balanced", formalDefinition="Account which is supposed to be balanced with this Invoice." )
1361    protected Reference account;
1362
1363    /**
1364     * Each line item represents one charge for goods and services rendered. Details such as date, code and amount are found in the referenced ChargeItem resource.
1365     */
1366    @Child(name = "lineItem", type = {}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1367    @Description(shortDefinition="Line items of this Invoice", formalDefinition="Each line item represents one charge for goods and services rendered. Details such as date, code and amount are found in the referenced ChargeItem resource." )
1368    protected List<InvoiceLineItemComponent> lineItem;
1369
1370    /**
1371     * The total amount for the Invoice may be calculated as the sum of the line items with surcharges/deductions that apply in certain conditions.  The priceComponent element can be used to offer transparency to the recipient of the Invoice of how the total price was calculated.
1372     */
1373    @Child(name = "totalPriceComponent", type = {InvoiceLineItemPriceComponentComponent.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1374    @Description(shortDefinition="Components of Invoice total", formalDefinition="The total amount for the Invoice may be calculated as the sum of the line items with surcharges/deductions that apply in certain conditions.  The priceComponent element can be used to offer transparency to the recipient of the Invoice of how the total price was calculated." )
1375    protected List<InvoiceLineItemPriceComponentComponent> totalPriceComponent;
1376
1377    /**
1378     * Invoice total , taxes excluded.
1379     */
1380    @Child(name = "totalNet", type = {Money.class}, order=12, min=0, max=1, modifier=false, summary=true)
1381    @Description(shortDefinition="Net total of this Invoice", formalDefinition="Invoice total , taxes excluded." )
1382    protected Money totalNet;
1383
1384    /**
1385     * Invoice total, tax included.
1386     */
1387    @Child(name = "totalGross", type = {Money.class}, order=13, min=0, max=1, modifier=false, summary=true)
1388    @Description(shortDefinition="Gross total of this Invoice", formalDefinition="Invoice total, tax included." )
1389    protected Money totalGross;
1390
1391    /**
1392     * Payment details such as banking details, period of payment, deductibles, methods of payment.
1393     */
1394    @Child(name = "paymentTerms", type = {MarkdownType.class}, order=14, min=0, max=1, modifier=false, summary=false)
1395    @Description(shortDefinition="Payment details", formalDefinition="Payment details such as banking details, period of payment, deductibles, methods of payment." )
1396    protected MarkdownType paymentTerms;
1397
1398    /**
1399     * Comments made about the invoice by the issuer, subject, or other participants.
1400     */
1401    @Child(name = "note", type = {Annotation.class}, order=15, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1402    @Description(shortDefinition="Comments made about the invoice", formalDefinition="Comments made about the invoice by the issuer, subject, or other participants." )
1403    protected List<Annotation> note;
1404
1405    private static final long serialVersionUID = -841380390L;
1406
1407  /**
1408   * Constructor
1409   */
1410    public Invoice() {
1411      super();
1412    }
1413
1414  /**
1415   * Constructor
1416   */
1417    public Invoice(Enumeration<InvoiceStatus> status) {
1418      super();
1419      this.status = status;
1420    }
1421
1422    /**
1423     * @return {@link #identifier} (Identifier of this Invoice, often used for reference in correspondence about this invoice or for tracking of payments.)
1424     */
1425    public List<Identifier> getIdentifier() { 
1426      if (this.identifier == null)
1427        this.identifier = new ArrayList<Identifier>();
1428      return this.identifier;
1429    }
1430
1431    /**
1432     * @return Returns a reference to <code>this</code> for easy method chaining
1433     */
1434    public Invoice setIdentifier(List<Identifier> theIdentifier) { 
1435      this.identifier = theIdentifier;
1436      return this;
1437    }
1438
1439    public boolean hasIdentifier() { 
1440      if (this.identifier == null)
1441        return false;
1442      for (Identifier item : this.identifier)
1443        if (!item.isEmpty())
1444          return true;
1445      return false;
1446    }
1447
1448    public Identifier addIdentifier() { //3
1449      Identifier t = new Identifier();
1450      if (this.identifier == null)
1451        this.identifier = new ArrayList<Identifier>();
1452      this.identifier.add(t);
1453      return t;
1454    }
1455
1456    public Invoice addIdentifier(Identifier t) { //3
1457      if (t == null)
1458        return this;
1459      if (this.identifier == null)
1460        this.identifier = new ArrayList<Identifier>();
1461      this.identifier.add(t);
1462      return this;
1463    }
1464
1465    /**
1466     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
1467     */
1468    public Identifier getIdentifierFirstRep() { 
1469      if (getIdentifier().isEmpty()) {
1470        addIdentifier();
1471      }
1472      return getIdentifier().get(0);
1473    }
1474
1475    /**
1476     * @return {@link #status} (The current state of the Invoice.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1477     */
1478    public Enumeration<InvoiceStatus> getStatusElement() { 
1479      if (this.status == null)
1480        if (Configuration.errorOnAutoCreate())
1481          throw new Error("Attempt to auto-create Invoice.status");
1482        else if (Configuration.doAutoCreate())
1483          this.status = new Enumeration<InvoiceStatus>(new InvoiceStatusEnumFactory()); // bb
1484      return this.status;
1485    }
1486
1487    public boolean hasStatusElement() { 
1488      return this.status != null && !this.status.isEmpty();
1489    }
1490
1491    public boolean hasStatus() { 
1492      return this.status != null && !this.status.isEmpty();
1493    }
1494
1495    /**
1496     * @param value {@link #status} (The current state of the Invoice.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1497     */
1498    public Invoice setStatusElement(Enumeration<InvoiceStatus> value) { 
1499      this.status = value;
1500      return this;
1501    }
1502
1503    /**
1504     * @return The current state of the Invoice.
1505     */
1506    public InvoiceStatus getStatus() { 
1507      return this.status == null ? null : this.status.getValue();
1508    }
1509
1510    /**
1511     * @param value The current state of the Invoice.
1512     */
1513    public Invoice setStatus(InvoiceStatus value) { 
1514        if (this.status == null)
1515          this.status = new Enumeration<InvoiceStatus>(new InvoiceStatusEnumFactory());
1516        this.status.setValue(value);
1517      return this;
1518    }
1519
1520    /**
1521     * @return {@link #cancelledReason} (In case of Invoice cancellation a reason must be given (entered in error, superseded by corrected invoice etc.).). This is the underlying object with id, value and extensions. The accessor "getCancelledReason" gives direct access to the value
1522     */
1523    public StringType getCancelledReasonElement() { 
1524      if (this.cancelledReason == null)
1525        if (Configuration.errorOnAutoCreate())
1526          throw new Error("Attempt to auto-create Invoice.cancelledReason");
1527        else if (Configuration.doAutoCreate())
1528          this.cancelledReason = new StringType(); // bb
1529      return this.cancelledReason;
1530    }
1531
1532    public boolean hasCancelledReasonElement() { 
1533      return this.cancelledReason != null && !this.cancelledReason.isEmpty();
1534    }
1535
1536    public boolean hasCancelledReason() { 
1537      return this.cancelledReason != null && !this.cancelledReason.isEmpty();
1538    }
1539
1540    /**
1541     * @param value {@link #cancelledReason} (In case of Invoice cancellation a reason must be given (entered in error, superseded by corrected invoice etc.).). This is the underlying object with id, value and extensions. The accessor "getCancelledReason" gives direct access to the value
1542     */
1543    public Invoice setCancelledReasonElement(StringType value) { 
1544      this.cancelledReason = value;
1545      return this;
1546    }
1547
1548    /**
1549     * @return In case of Invoice cancellation a reason must be given (entered in error, superseded by corrected invoice etc.).
1550     */
1551    public String getCancelledReason() { 
1552      return this.cancelledReason == null ? null : this.cancelledReason.getValue();
1553    }
1554
1555    /**
1556     * @param value In case of Invoice cancellation a reason must be given (entered in error, superseded by corrected invoice etc.).
1557     */
1558    public Invoice setCancelledReason(String value) { 
1559      if (Utilities.noString(value))
1560        this.cancelledReason = null;
1561      else {
1562        if (this.cancelledReason == null)
1563          this.cancelledReason = new StringType();
1564        this.cancelledReason.setValue(value);
1565      }
1566      return this;
1567    }
1568
1569    /**
1570     * @return {@link #type} (Type of Invoice depending on domain, realm an usage (e.g. internal/external, dental, preliminary).)
1571     */
1572    public CodeableConcept getType() { 
1573      if (this.type == null)
1574        if (Configuration.errorOnAutoCreate())
1575          throw new Error("Attempt to auto-create Invoice.type");
1576        else if (Configuration.doAutoCreate())
1577          this.type = new CodeableConcept(); // cc
1578      return this.type;
1579    }
1580
1581    public boolean hasType() { 
1582      return this.type != null && !this.type.isEmpty();
1583    }
1584
1585    /**
1586     * @param value {@link #type} (Type of Invoice depending on domain, realm an usage (e.g. internal/external, dental, preliminary).)
1587     */
1588    public Invoice setType(CodeableConcept value) { 
1589      this.type = value;
1590      return this;
1591    }
1592
1593    /**
1594     * @return {@link #subject} (The individual or set of individuals receiving the goods and services billed in this invoice.)
1595     */
1596    public Reference getSubject() { 
1597      if (this.subject == null)
1598        if (Configuration.errorOnAutoCreate())
1599          throw new Error("Attempt to auto-create Invoice.subject");
1600        else if (Configuration.doAutoCreate())
1601          this.subject = new Reference(); // cc
1602      return this.subject;
1603    }
1604
1605    public boolean hasSubject() { 
1606      return this.subject != null && !this.subject.isEmpty();
1607    }
1608
1609    /**
1610     * @param value {@link #subject} (The individual or set of individuals receiving the goods and services billed in this invoice.)
1611     */
1612    public Invoice setSubject(Reference value) { 
1613      this.subject = value;
1614      return this;
1615    }
1616
1617    /**
1618     * @return {@link #recipient} (The individual or Organization responsible for balancing of this invoice.)
1619     */
1620    public Reference getRecipient() { 
1621      if (this.recipient == null)
1622        if (Configuration.errorOnAutoCreate())
1623          throw new Error("Attempt to auto-create Invoice.recipient");
1624        else if (Configuration.doAutoCreate())
1625          this.recipient = new Reference(); // cc
1626      return this.recipient;
1627    }
1628
1629    public boolean hasRecipient() { 
1630      return this.recipient != null && !this.recipient.isEmpty();
1631    }
1632
1633    /**
1634     * @param value {@link #recipient} (The individual or Organization responsible for balancing of this invoice.)
1635     */
1636    public Invoice setRecipient(Reference value) { 
1637      this.recipient = value;
1638      return this;
1639    }
1640
1641    /**
1642     * @return {@link #date} (Date/time(s) of when this Invoice was posted.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
1643     */
1644    public DateTimeType getDateElement() { 
1645      if (this.date == null)
1646        if (Configuration.errorOnAutoCreate())
1647          throw new Error("Attempt to auto-create Invoice.date");
1648        else if (Configuration.doAutoCreate())
1649          this.date = new DateTimeType(); // bb
1650      return this.date;
1651    }
1652
1653    public boolean hasDateElement() { 
1654      return this.date != null && !this.date.isEmpty();
1655    }
1656
1657    public boolean hasDate() { 
1658      return this.date != null && !this.date.isEmpty();
1659    }
1660
1661    /**
1662     * @param value {@link #date} (Date/time(s) of when this Invoice was posted.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
1663     */
1664    public Invoice setDateElement(DateTimeType value) { 
1665      this.date = value;
1666      return this;
1667    }
1668
1669    /**
1670     * @return Date/time(s) of when this Invoice was posted.
1671     */
1672    public Date getDate() { 
1673      return this.date == null ? null : this.date.getValue();
1674    }
1675
1676    /**
1677     * @param value Date/time(s) of when this Invoice was posted.
1678     */
1679    public Invoice setDate(Date value) { 
1680      if (value == null)
1681        this.date = null;
1682      else {
1683        if (this.date == null)
1684          this.date = new DateTimeType();
1685        this.date.setValue(value);
1686      }
1687      return this;
1688    }
1689
1690    /**
1691     * @return {@link #participant} (Indicates who or what performed or participated in the charged service.)
1692     */
1693    public List<InvoiceParticipantComponent> getParticipant() { 
1694      if (this.participant == null)
1695        this.participant = new ArrayList<InvoiceParticipantComponent>();
1696      return this.participant;
1697    }
1698
1699    /**
1700     * @return Returns a reference to <code>this</code> for easy method chaining
1701     */
1702    public Invoice setParticipant(List<InvoiceParticipantComponent> theParticipant) { 
1703      this.participant = theParticipant;
1704      return this;
1705    }
1706
1707    public boolean hasParticipant() { 
1708      if (this.participant == null)
1709        return false;
1710      for (InvoiceParticipantComponent item : this.participant)
1711        if (!item.isEmpty())
1712          return true;
1713      return false;
1714    }
1715
1716    public InvoiceParticipantComponent addParticipant() { //3
1717      InvoiceParticipantComponent t = new InvoiceParticipantComponent();
1718      if (this.participant == null)
1719        this.participant = new ArrayList<InvoiceParticipantComponent>();
1720      this.participant.add(t);
1721      return t;
1722    }
1723
1724    public Invoice addParticipant(InvoiceParticipantComponent t) { //3
1725      if (t == null)
1726        return this;
1727      if (this.participant == null)
1728        this.participant = new ArrayList<InvoiceParticipantComponent>();
1729      this.participant.add(t);
1730      return this;
1731    }
1732
1733    /**
1734     * @return The first repetition of repeating field {@link #participant}, creating it if it does not already exist
1735     */
1736    public InvoiceParticipantComponent getParticipantFirstRep() { 
1737      if (getParticipant().isEmpty()) {
1738        addParticipant();
1739      }
1740      return getParticipant().get(0);
1741    }
1742
1743    /**
1744     * @return {@link #issuer} (The organizationissuing the Invoice.)
1745     */
1746    public Reference getIssuer() { 
1747      if (this.issuer == null)
1748        if (Configuration.errorOnAutoCreate())
1749          throw new Error("Attempt to auto-create Invoice.issuer");
1750        else if (Configuration.doAutoCreate())
1751          this.issuer = new Reference(); // cc
1752      return this.issuer;
1753    }
1754
1755    public boolean hasIssuer() { 
1756      return this.issuer != null && !this.issuer.isEmpty();
1757    }
1758
1759    /**
1760     * @param value {@link #issuer} (The organizationissuing the Invoice.)
1761     */
1762    public Invoice setIssuer(Reference value) { 
1763      this.issuer = value;
1764      return this;
1765    }
1766
1767    /**
1768     * @return {@link #account} (Account which is supposed to be balanced with this Invoice.)
1769     */
1770    public Reference getAccount() { 
1771      if (this.account == null)
1772        if (Configuration.errorOnAutoCreate())
1773          throw new Error("Attempt to auto-create Invoice.account");
1774        else if (Configuration.doAutoCreate())
1775          this.account = new Reference(); // cc
1776      return this.account;
1777    }
1778
1779    public boolean hasAccount() { 
1780      return this.account != null && !this.account.isEmpty();
1781    }
1782
1783    /**
1784     * @param value {@link #account} (Account which is supposed to be balanced with this Invoice.)
1785     */
1786    public Invoice setAccount(Reference value) { 
1787      this.account = value;
1788      return this;
1789    }
1790
1791    /**
1792     * @return {@link #lineItem} (Each line item represents one charge for goods and services rendered. Details such as date, code and amount are found in the referenced ChargeItem resource.)
1793     */
1794    public List<InvoiceLineItemComponent> getLineItem() { 
1795      if (this.lineItem == null)
1796        this.lineItem = new ArrayList<InvoiceLineItemComponent>();
1797      return this.lineItem;
1798    }
1799
1800    /**
1801     * @return Returns a reference to <code>this</code> for easy method chaining
1802     */
1803    public Invoice setLineItem(List<InvoiceLineItemComponent> theLineItem) { 
1804      this.lineItem = theLineItem;
1805      return this;
1806    }
1807
1808    public boolean hasLineItem() { 
1809      if (this.lineItem == null)
1810        return false;
1811      for (InvoiceLineItemComponent item : this.lineItem)
1812        if (!item.isEmpty())
1813          return true;
1814      return false;
1815    }
1816
1817    public InvoiceLineItemComponent addLineItem() { //3
1818      InvoiceLineItemComponent t = new InvoiceLineItemComponent();
1819      if (this.lineItem == null)
1820        this.lineItem = new ArrayList<InvoiceLineItemComponent>();
1821      this.lineItem.add(t);
1822      return t;
1823    }
1824
1825    public Invoice addLineItem(InvoiceLineItemComponent t) { //3
1826      if (t == null)
1827        return this;
1828      if (this.lineItem == null)
1829        this.lineItem = new ArrayList<InvoiceLineItemComponent>();
1830      this.lineItem.add(t);
1831      return this;
1832    }
1833
1834    /**
1835     * @return The first repetition of repeating field {@link #lineItem}, creating it if it does not already exist
1836     */
1837    public InvoiceLineItemComponent getLineItemFirstRep() { 
1838      if (getLineItem().isEmpty()) {
1839        addLineItem();
1840      }
1841      return getLineItem().get(0);
1842    }
1843
1844    /**
1845     * @return {@link #totalPriceComponent} (The total amount for the Invoice may be calculated as the sum of the line items with surcharges/deductions that apply in certain conditions.  The priceComponent element can be used to offer transparency to the recipient of the Invoice of how the total price was calculated.)
1846     */
1847    public List<InvoiceLineItemPriceComponentComponent> getTotalPriceComponent() { 
1848      if (this.totalPriceComponent == null)
1849        this.totalPriceComponent = new ArrayList<InvoiceLineItemPriceComponentComponent>();
1850      return this.totalPriceComponent;
1851    }
1852
1853    /**
1854     * @return Returns a reference to <code>this</code> for easy method chaining
1855     */
1856    public Invoice setTotalPriceComponent(List<InvoiceLineItemPriceComponentComponent> theTotalPriceComponent) { 
1857      this.totalPriceComponent = theTotalPriceComponent;
1858      return this;
1859    }
1860
1861    public boolean hasTotalPriceComponent() { 
1862      if (this.totalPriceComponent == null)
1863        return false;
1864      for (InvoiceLineItemPriceComponentComponent item : this.totalPriceComponent)
1865        if (!item.isEmpty())
1866          return true;
1867      return false;
1868    }
1869
1870    public InvoiceLineItemPriceComponentComponent addTotalPriceComponent() { //3
1871      InvoiceLineItemPriceComponentComponent t = new InvoiceLineItemPriceComponentComponent();
1872      if (this.totalPriceComponent == null)
1873        this.totalPriceComponent = new ArrayList<InvoiceLineItemPriceComponentComponent>();
1874      this.totalPriceComponent.add(t);
1875      return t;
1876    }
1877
1878    public Invoice addTotalPriceComponent(InvoiceLineItemPriceComponentComponent t) { //3
1879      if (t == null)
1880        return this;
1881      if (this.totalPriceComponent == null)
1882        this.totalPriceComponent = new ArrayList<InvoiceLineItemPriceComponentComponent>();
1883      this.totalPriceComponent.add(t);
1884      return this;
1885    }
1886
1887    /**
1888     * @return The first repetition of repeating field {@link #totalPriceComponent}, creating it if it does not already exist
1889     */
1890    public InvoiceLineItemPriceComponentComponent getTotalPriceComponentFirstRep() { 
1891      if (getTotalPriceComponent().isEmpty()) {
1892        addTotalPriceComponent();
1893      }
1894      return getTotalPriceComponent().get(0);
1895    }
1896
1897    /**
1898     * @return {@link #totalNet} (Invoice total , taxes excluded.)
1899     */
1900    public Money getTotalNet() { 
1901      if (this.totalNet == null)
1902        if (Configuration.errorOnAutoCreate())
1903          throw new Error("Attempt to auto-create Invoice.totalNet");
1904        else if (Configuration.doAutoCreate())
1905          this.totalNet = new Money(); // cc
1906      return this.totalNet;
1907    }
1908
1909    public boolean hasTotalNet() { 
1910      return this.totalNet != null && !this.totalNet.isEmpty();
1911    }
1912
1913    /**
1914     * @param value {@link #totalNet} (Invoice total , taxes excluded.)
1915     */
1916    public Invoice setTotalNet(Money value) { 
1917      this.totalNet = value;
1918      return this;
1919    }
1920
1921    /**
1922     * @return {@link #totalGross} (Invoice total, tax included.)
1923     */
1924    public Money getTotalGross() { 
1925      if (this.totalGross == null)
1926        if (Configuration.errorOnAutoCreate())
1927          throw new Error("Attempt to auto-create Invoice.totalGross");
1928        else if (Configuration.doAutoCreate())
1929          this.totalGross = new Money(); // cc
1930      return this.totalGross;
1931    }
1932
1933    public boolean hasTotalGross() { 
1934      return this.totalGross != null && !this.totalGross.isEmpty();
1935    }
1936
1937    /**
1938     * @param value {@link #totalGross} (Invoice total, tax included.)
1939     */
1940    public Invoice setTotalGross(Money value) { 
1941      this.totalGross = value;
1942      return this;
1943    }
1944
1945    /**
1946     * @return {@link #paymentTerms} (Payment details such as banking details, period of payment, deductibles, methods of payment.). This is the underlying object with id, value and extensions. The accessor "getPaymentTerms" gives direct access to the value
1947     */
1948    public MarkdownType getPaymentTermsElement() { 
1949      if (this.paymentTerms == null)
1950        if (Configuration.errorOnAutoCreate())
1951          throw new Error("Attempt to auto-create Invoice.paymentTerms");
1952        else if (Configuration.doAutoCreate())
1953          this.paymentTerms = new MarkdownType(); // bb
1954      return this.paymentTerms;
1955    }
1956
1957    public boolean hasPaymentTermsElement() { 
1958      return this.paymentTerms != null && !this.paymentTerms.isEmpty();
1959    }
1960
1961    public boolean hasPaymentTerms() { 
1962      return this.paymentTerms != null && !this.paymentTerms.isEmpty();
1963    }
1964
1965    /**
1966     * @param value {@link #paymentTerms} (Payment details such as banking details, period of payment, deductibles, methods of payment.). This is the underlying object with id, value and extensions. The accessor "getPaymentTerms" gives direct access to the value
1967     */
1968    public Invoice setPaymentTermsElement(MarkdownType value) { 
1969      this.paymentTerms = value;
1970      return this;
1971    }
1972
1973    /**
1974     * @return Payment details such as banking details, period of payment, deductibles, methods of payment.
1975     */
1976    public String getPaymentTerms() { 
1977      return this.paymentTerms == null ? null : this.paymentTerms.getValue();
1978    }
1979
1980    /**
1981     * @param value Payment details such as banking details, period of payment, deductibles, methods of payment.
1982     */
1983    public Invoice setPaymentTerms(String value) { 
1984      if (value == null)
1985        this.paymentTerms = null;
1986      else {
1987        if (this.paymentTerms == null)
1988          this.paymentTerms = new MarkdownType();
1989        this.paymentTerms.setValue(value);
1990      }
1991      return this;
1992    }
1993
1994    /**
1995     * @return {@link #note} (Comments made about the invoice by the issuer, subject, or other participants.)
1996     */
1997    public List<Annotation> getNote() { 
1998      if (this.note == null)
1999        this.note = new ArrayList<Annotation>();
2000      return this.note;
2001    }
2002
2003    /**
2004     * @return Returns a reference to <code>this</code> for easy method chaining
2005     */
2006    public Invoice setNote(List<Annotation> theNote) { 
2007      this.note = theNote;
2008      return this;
2009    }
2010
2011    public boolean hasNote() { 
2012      if (this.note == null)
2013        return false;
2014      for (Annotation item : this.note)
2015        if (!item.isEmpty())
2016          return true;
2017      return false;
2018    }
2019
2020    public Annotation addNote() { //3
2021      Annotation t = new Annotation();
2022      if (this.note == null)
2023        this.note = new ArrayList<Annotation>();
2024      this.note.add(t);
2025      return t;
2026    }
2027
2028    public Invoice addNote(Annotation t) { //3
2029      if (t == null)
2030        return this;
2031      if (this.note == null)
2032        this.note = new ArrayList<Annotation>();
2033      this.note.add(t);
2034      return this;
2035    }
2036
2037    /**
2038     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist
2039     */
2040    public Annotation getNoteFirstRep() { 
2041      if (getNote().isEmpty()) {
2042        addNote();
2043      }
2044      return getNote().get(0);
2045    }
2046
2047      protected void listChildren(List<Property> children) {
2048        super.listChildren(children);
2049        children.add(new Property("identifier", "Identifier", "Identifier of this Invoice, often used for reference in correspondence about this invoice or for tracking of payments.", 0, java.lang.Integer.MAX_VALUE, identifier));
2050        children.add(new Property("status", "code", "The current state of the Invoice.", 0, 1, status));
2051        children.add(new Property("cancelledReason", "string", "In case of Invoice cancellation a reason must be given (entered in error, superseded by corrected invoice etc.).", 0, 1, cancelledReason));
2052        children.add(new Property("type", "CodeableConcept", "Type of Invoice depending on domain, realm an usage (e.g. internal/external, dental, preliminary).", 0, 1, type));
2053        children.add(new Property("subject", "Reference(Patient|Group)", "The individual or set of individuals receiving the goods and services billed in this invoice.", 0, 1, subject));
2054        children.add(new Property("recipient", "Reference(Organization|Patient|RelatedPerson)", "The individual or Organization responsible for balancing of this invoice.", 0, 1, recipient));
2055        children.add(new Property("date", "dateTime", "Date/time(s) of when this Invoice was posted.", 0, 1, date));
2056        children.add(new Property("participant", "", "Indicates who or what performed or participated in the charged service.", 0, java.lang.Integer.MAX_VALUE, participant));
2057        children.add(new Property("issuer", "Reference(Organization)", "The organizationissuing the Invoice.", 0, 1, issuer));
2058        children.add(new Property("account", "Reference(Account)", "Account which is supposed to be balanced with this Invoice.", 0, 1, account));
2059        children.add(new Property("lineItem", "", "Each line item represents one charge for goods and services rendered. Details such as date, code and amount are found in the referenced ChargeItem resource.", 0, java.lang.Integer.MAX_VALUE, lineItem));
2060        children.add(new Property("totalPriceComponent", "@Invoice.lineItem.priceComponent", "The total amount for the Invoice may be calculated as the sum of the line items with surcharges/deductions that apply in certain conditions.  The priceComponent element can be used to offer transparency to the recipient of the Invoice of how the total price was calculated.", 0, java.lang.Integer.MAX_VALUE, totalPriceComponent));
2061        children.add(new Property("totalNet", "Money", "Invoice total , taxes excluded.", 0, 1, totalNet));
2062        children.add(new Property("totalGross", "Money", "Invoice total, tax included.", 0, 1, totalGross));
2063        children.add(new Property("paymentTerms", "markdown", "Payment details such as banking details, period of payment, deductibles, methods of payment.", 0, 1, paymentTerms));
2064        children.add(new Property("note", "Annotation", "Comments made about the invoice by the issuer, subject, or other participants.", 0, java.lang.Integer.MAX_VALUE, note));
2065      }
2066
2067      @Override
2068      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2069        switch (_hash) {
2070        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Identifier of this Invoice, often used for reference in correspondence about this invoice or for tracking of payments.", 0, java.lang.Integer.MAX_VALUE, identifier);
2071        case -892481550: /*status*/  return new Property("status", "code", "The current state of the Invoice.", 0, 1, status);
2072        case 1550362357: /*cancelledReason*/  return new Property("cancelledReason", "string", "In case of Invoice cancellation a reason must be given (entered in error, superseded by corrected invoice etc.).", 0, 1, cancelledReason);
2073        case 3575610: /*type*/  return new Property("type", "CodeableConcept", "Type of Invoice depending on domain, realm an usage (e.g. internal/external, dental, preliminary).", 0, 1, type);
2074        case -1867885268: /*subject*/  return new Property("subject", "Reference(Patient|Group)", "The individual or set of individuals receiving the goods and services billed in this invoice.", 0, 1, subject);
2075        case 820081177: /*recipient*/  return new Property("recipient", "Reference(Organization|Patient|RelatedPerson)", "The individual or Organization responsible for balancing of this invoice.", 0, 1, recipient);
2076        case 3076014: /*date*/  return new Property("date", "dateTime", "Date/time(s) of when this Invoice was posted.", 0, 1, date);
2077        case 767422259: /*participant*/  return new Property("participant", "", "Indicates who or what performed or participated in the charged service.", 0, java.lang.Integer.MAX_VALUE, participant);
2078        case -1179159879: /*issuer*/  return new Property("issuer", "Reference(Organization)", "The organizationissuing the Invoice.", 0, 1, issuer);
2079        case -1177318867: /*account*/  return new Property("account", "Reference(Account)", "Account which is supposed to be balanced with this Invoice.", 0, 1, account);
2080        case 1188332839: /*lineItem*/  return new Property("lineItem", "", "Each line item represents one charge for goods and services rendered. Details such as date, code and amount are found in the referenced ChargeItem resource.", 0, java.lang.Integer.MAX_VALUE, lineItem);
2081        case 1731497496: /*totalPriceComponent*/  return new Property("totalPriceComponent", "@Invoice.lineItem.priceComponent", "The total amount for the Invoice may be calculated as the sum of the line items with surcharges/deductions that apply in certain conditions.  The priceComponent element can be used to offer transparency to the recipient of the Invoice of how the total price was calculated.", 0, java.lang.Integer.MAX_VALUE, totalPriceComponent);
2082        case -849911879: /*totalNet*/  return new Property("totalNet", "Money", "Invoice total , taxes excluded.", 0, 1, totalNet);
2083        case -727607968: /*totalGross*/  return new Property("totalGross", "Money", "Invoice total, tax included.", 0, 1, totalGross);
2084        case -507544799: /*paymentTerms*/  return new Property("paymentTerms", "markdown", "Payment details such as banking details, period of payment, deductibles, methods of payment.", 0, 1, paymentTerms);
2085        case 3387378: /*note*/  return new Property("note", "Annotation", "Comments made about the invoice by the issuer, subject, or other participants.", 0, java.lang.Integer.MAX_VALUE, note);
2086        default: return super.getNamedProperty(_hash, _name, _checkValid);
2087        }
2088
2089      }
2090
2091      @Override
2092      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2093        switch (hash) {
2094        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2095        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<InvoiceStatus>
2096        case 1550362357: /*cancelledReason*/ return this.cancelledReason == null ? new Base[0] : new Base[] {this.cancelledReason}; // StringType
2097        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
2098        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
2099        case 820081177: /*recipient*/ return this.recipient == null ? new Base[0] : new Base[] {this.recipient}; // Reference
2100        case 3076014: /*date*/ return this.date == null ? new Base[0] : new Base[] {this.date}; // DateTimeType
2101        case 767422259: /*participant*/ return this.participant == null ? new Base[0] : this.participant.toArray(new Base[this.participant.size()]); // InvoiceParticipantComponent
2102        case -1179159879: /*issuer*/ return this.issuer == null ? new Base[0] : new Base[] {this.issuer}; // Reference
2103        case -1177318867: /*account*/ return this.account == null ? new Base[0] : new Base[] {this.account}; // Reference
2104        case 1188332839: /*lineItem*/ return this.lineItem == null ? new Base[0] : this.lineItem.toArray(new Base[this.lineItem.size()]); // InvoiceLineItemComponent
2105        case 1731497496: /*totalPriceComponent*/ return this.totalPriceComponent == null ? new Base[0] : this.totalPriceComponent.toArray(new Base[this.totalPriceComponent.size()]); // InvoiceLineItemPriceComponentComponent
2106        case -849911879: /*totalNet*/ return this.totalNet == null ? new Base[0] : new Base[] {this.totalNet}; // Money
2107        case -727607968: /*totalGross*/ return this.totalGross == null ? new Base[0] : new Base[] {this.totalGross}; // Money
2108        case -507544799: /*paymentTerms*/ return this.paymentTerms == null ? new Base[0] : new Base[] {this.paymentTerms}; // MarkdownType
2109        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
2110        default: return super.getProperty(hash, name, checkValid);
2111        }
2112
2113      }
2114
2115      @Override
2116      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2117        switch (hash) {
2118        case -1618432855: // identifier
2119          this.getIdentifier().add(castToIdentifier(value)); // Identifier
2120          return value;
2121        case -892481550: // status
2122          value = new InvoiceStatusEnumFactory().fromType(castToCode(value));
2123          this.status = (Enumeration) value; // Enumeration<InvoiceStatus>
2124          return value;
2125        case 1550362357: // cancelledReason
2126          this.cancelledReason = castToString(value); // StringType
2127          return value;
2128        case 3575610: // type
2129          this.type = castToCodeableConcept(value); // CodeableConcept
2130          return value;
2131        case -1867885268: // subject
2132          this.subject = castToReference(value); // Reference
2133          return value;
2134        case 820081177: // recipient
2135          this.recipient = castToReference(value); // Reference
2136          return value;
2137        case 3076014: // date
2138          this.date = castToDateTime(value); // DateTimeType
2139          return value;
2140        case 767422259: // participant
2141          this.getParticipant().add((InvoiceParticipantComponent) value); // InvoiceParticipantComponent
2142          return value;
2143        case -1179159879: // issuer
2144          this.issuer = castToReference(value); // Reference
2145          return value;
2146        case -1177318867: // account
2147          this.account = castToReference(value); // Reference
2148          return value;
2149        case 1188332839: // lineItem
2150          this.getLineItem().add((InvoiceLineItemComponent) value); // InvoiceLineItemComponent
2151          return value;
2152        case 1731497496: // totalPriceComponent
2153          this.getTotalPriceComponent().add((InvoiceLineItemPriceComponentComponent) value); // InvoiceLineItemPriceComponentComponent
2154          return value;
2155        case -849911879: // totalNet
2156          this.totalNet = castToMoney(value); // Money
2157          return value;
2158        case -727607968: // totalGross
2159          this.totalGross = castToMoney(value); // Money
2160          return value;
2161        case -507544799: // paymentTerms
2162          this.paymentTerms = castToMarkdown(value); // MarkdownType
2163          return value;
2164        case 3387378: // note
2165          this.getNote().add(castToAnnotation(value)); // Annotation
2166          return value;
2167        default: return super.setProperty(hash, name, value);
2168        }
2169
2170      }
2171
2172      @Override
2173      public Base setProperty(String name, Base value) throws FHIRException {
2174        if (name.equals("identifier")) {
2175          this.getIdentifier().add(castToIdentifier(value));
2176        } else if (name.equals("status")) {
2177          value = new InvoiceStatusEnumFactory().fromType(castToCode(value));
2178          this.status = (Enumeration) value; // Enumeration<InvoiceStatus>
2179        } else if (name.equals("cancelledReason")) {
2180          this.cancelledReason = castToString(value); // StringType
2181        } else if (name.equals("type")) {
2182          this.type = castToCodeableConcept(value); // CodeableConcept
2183        } else if (name.equals("subject")) {
2184          this.subject = castToReference(value); // Reference
2185        } else if (name.equals("recipient")) {
2186          this.recipient = castToReference(value); // Reference
2187        } else if (name.equals("date")) {
2188          this.date = castToDateTime(value); // DateTimeType
2189        } else if (name.equals("participant")) {
2190          this.getParticipant().add((InvoiceParticipantComponent) value);
2191        } else if (name.equals("issuer")) {
2192          this.issuer = castToReference(value); // Reference
2193        } else if (name.equals("account")) {
2194          this.account = castToReference(value); // Reference
2195        } else if (name.equals("lineItem")) {
2196          this.getLineItem().add((InvoiceLineItemComponent) value);
2197        } else if (name.equals("totalPriceComponent")) {
2198          this.getTotalPriceComponent().add((InvoiceLineItemPriceComponentComponent) value);
2199        } else if (name.equals("totalNet")) {
2200          this.totalNet = castToMoney(value); // Money
2201        } else if (name.equals("totalGross")) {
2202          this.totalGross = castToMoney(value); // Money
2203        } else if (name.equals("paymentTerms")) {
2204          this.paymentTerms = castToMarkdown(value); // MarkdownType
2205        } else if (name.equals("note")) {
2206          this.getNote().add(castToAnnotation(value));
2207        } else
2208          return super.setProperty(name, value);
2209        return value;
2210      }
2211
2212      @Override
2213      public Base makeProperty(int hash, String name) throws FHIRException {
2214        switch (hash) {
2215        case -1618432855:  return addIdentifier(); 
2216        case -892481550:  return getStatusElement();
2217        case 1550362357:  return getCancelledReasonElement();
2218        case 3575610:  return getType();
2219        case -1867885268:  return getSubject();
2220        case 820081177:  return getRecipient();
2221        case 3076014:  return getDateElement();
2222        case 767422259:  return addParticipant(); 
2223        case -1179159879:  return getIssuer();
2224        case -1177318867:  return getAccount();
2225        case 1188332839:  return addLineItem(); 
2226        case 1731497496:  return addTotalPriceComponent(); 
2227        case -849911879:  return getTotalNet();
2228        case -727607968:  return getTotalGross();
2229        case -507544799:  return getPaymentTermsElement();
2230        case 3387378:  return addNote(); 
2231        default: return super.makeProperty(hash, name);
2232        }
2233
2234      }
2235
2236      @Override
2237      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2238        switch (hash) {
2239        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2240        case -892481550: /*status*/ return new String[] {"code"};
2241        case 1550362357: /*cancelledReason*/ return new String[] {"string"};
2242        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
2243        case -1867885268: /*subject*/ return new String[] {"Reference"};
2244        case 820081177: /*recipient*/ return new String[] {"Reference"};
2245        case 3076014: /*date*/ return new String[] {"dateTime"};
2246        case 767422259: /*participant*/ return new String[] {};
2247        case -1179159879: /*issuer*/ return new String[] {"Reference"};
2248        case -1177318867: /*account*/ return new String[] {"Reference"};
2249        case 1188332839: /*lineItem*/ return new String[] {};
2250        case 1731497496: /*totalPriceComponent*/ return new String[] {"@Invoice.lineItem.priceComponent"};
2251        case -849911879: /*totalNet*/ return new String[] {"Money"};
2252        case -727607968: /*totalGross*/ return new String[] {"Money"};
2253        case -507544799: /*paymentTerms*/ return new String[] {"markdown"};
2254        case 3387378: /*note*/ return new String[] {"Annotation"};
2255        default: return super.getTypesForProperty(hash, name);
2256        }
2257
2258      }
2259
2260      @Override
2261      public Base addChild(String name) throws FHIRException {
2262        if (name.equals("identifier")) {
2263          return addIdentifier();
2264        }
2265        else if (name.equals("status")) {
2266          throw new FHIRException("Cannot call addChild on a primitive type Invoice.status");
2267        }
2268        else if (name.equals("cancelledReason")) {
2269          throw new FHIRException("Cannot call addChild on a primitive type Invoice.cancelledReason");
2270        }
2271        else if (name.equals("type")) {
2272          this.type = new CodeableConcept();
2273          return this.type;
2274        }
2275        else if (name.equals("subject")) {
2276          this.subject = new Reference();
2277          return this.subject;
2278        }
2279        else if (name.equals("recipient")) {
2280          this.recipient = new Reference();
2281          return this.recipient;
2282        }
2283        else if (name.equals("date")) {
2284          throw new FHIRException("Cannot call addChild on a primitive type Invoice.date");
2285        }
2286        else if (name.equals("participant")) {
2287          return addParticipant();
2288        }
2289        else if (name.equals("issuer")) {
2290          this.issuer = new Reference();
2291          return this.issuer;
2292        }
2293        else if (name.equals("account")) {
2294          this.account = new Reference();
2295          return this.account;
2296        }
2297        else if (name.equals("lineItem")) {
2298          return addLineItem();
2299        }
2300        else if (name.equals("totalPriceComponent")) {
2301          return addTotalPriceComponent();
2302        }
2303        else if (name.equals("totalNet")) {
2304          this.totalNet = new Money();
2305          return this.totalNet;
2306        }
2307        else if (name.equals("totalGross")) {
2308          this.totalGross = new Money();
2309          return this.totalGross;
2310        }
2311        else if (name.equals("paymentTerms")) {
2312          throw new FHIRException("Cannot call addChild on a primitive type Invoice.paymentTerms");
2313        }
2314        else if (name.equals("note")) {
2315          return addNote();
2316        }
2317        else
2318          return super.addChild(name);
2319      }
2320
2321  public String fhirType() {
2322    return "Invoice";
2323
2324  }
2325
2326      public Invoice copy() {
2327        Invoice dst = new Invoice();
2328        copyValues(dst);
2329        return dst;
2330      }
2331
2332      public void copyValues(Invoice dst) {
2333        super.copyValues(dst);
2334        if (identifier != null) {
2335          dst.identifier = new ArrayList<Identifier>();
2336          for (Identifier i : identifier)
2337            dst.identifier.add(i.copy());
2338        };
2339        dst.status = status == null ? null : status.copy();
2340        dst.cancelledReason = cancelledReason == null ? null : cancelledReason.copy();
2341        dst.type = type == null ? null : type.copy();
2342        dst.subject = subject == null ? null : subject.copy();
2343        dst.recipient = recipient == null ? null : recipient.copy();
2344        dst.date = date == null ? null : date.copy();
2345        if (participant != null) {
2346          dst.participant = new ArrayList<InvoiceParticipantComponent>();
2347          for (InvoiceParticipantComponent i : participant)
2348            dst.participant.add(i.copy());
2349        };
2350        dst.issuer = issuer == null ? null : issuer.copy();
2351        dst.account = account == null ? null : account.copy();
2352        if (lineItem != null) {
2353          dst.lineItem = new ArrayList<InvoiceLineItemComponent>();
2354          for (InvoiceLineItemComponent i : lineItem)
2355            dst.lineItem.add(i.copy());
2356        };
2357        if (totalPriceComponent != null) {
2358          dst.totalPriceComponent = new ArrayList<InvoiceLineItemPriceComponentComponent>();
2359          for (InvoiceLineItemPriceComponentComponent i : totalPriceComponent)
2360            dst.totalPriceComponent.add(i.copy());
2361        };
2362        dst.totalNet = totalNet == null ? null : totalNet.copy();
2363        dst.totalGross = totalGross == null ? null : totalGross.copy();
2364        dst.paymentTerms = paymentTerms == null ? null : paymentTerms.copy();
2365        if (note != null) {
2366          dst.note = new ArrayList<Annotation>();
2367          for (Annotation i : note)
2368            dst.note.add(i.copy());
2369        };
2370      }
2371
2372      protected Invoice typedCopy() {
2373        return copy();
2374      }
2375
2376      @Override
2377      public boolean equalsDeep(Base other_) {
2378        if (!super.equalsDeep(other_))
2379          return false;
2380        if (!(other_ instanceof Invoice))
2381          return false;
2382        Invoice o = (Invoice) other_;
2383        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(cancelledReason, o.cancelledReason, true)
2384           && compareDeep(type, o.type, true) && compareDeep(subject, o.subject, true) && compareDeep(recipient, o.recipient, true)
2385           && compareDeep(date, o.date, true) && compareDeep(participant, o.participant, true) && compareDeep(issuer, o.issuer, true)
2386           && compareDeep(account, o.account, true) && compareDeep(lineItem, o.lineItem, true) && compareDeep(totalPriceComponent, o.totalPriceComponent, true)
2387           && compareDeep(totalNet, o.totalNet, true) && compareDeep(totalGross, o.totalGross, true) && compareDeep(paymentTerms, o.paymentTerms, true)
2388           && compareDeep(note, o.note, true);
2389      }
2390
2391      @Override
2392      public boolean equalsShallow(Base other_) {
2393        if (!super.equalsShallow(other_))
2394          return false;
2395        if (!(other_ instanceof Invoice))
2396          return false;
2397        Invoice o = (Invoice) other_;
2398        return compareValues(status, o.status, true) && compareValues(cancelledReason, o.cancelledReason, true)
2399           && compareValues(date, o.date, true) && compareValues(paymentTerms, o.paymentTerms, true);
2400      }
2401
2402      public boolean isEmpty() {
2403        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, cancelledReason
2404          , type, subject, recipient, date, participant, issuer, account, lineItem, totalPriceComponent
2405          , totalNet, totalGross, paymentTerms, note);
2406      }
2407
2408  @Override
2409  public ResourceType getResourceType() {
2410    return ResourceType.Invoice;
2411   }
2412
2413 /**
2414   * Search parameter: <b>date</b>
2415   * <p>
2416   * Description: <b>Invoice date / posting date</b><br>
2417   * Type: <b>date</b><br>
2418   * Path: <b>Invoice.date</b><br>
2419   * </p>
2420   */
2421  @SearchParamDefinition(name="date", path="Invoice.date", description="Invoice date / posting date", type="date" )
2422  public static final String SP_DATE = "date";
2423 /**
2424   * <b>Fluent Client</b> search parameter constant for <b>date</b>
2425   * <p>
2426   * Description: <b>Invoice date / posting date</b><br>
2427   * Type: <b>date</b><br>
2428   * Path: <b>Invoice.date</b><br>
2429   * </p>
2430   */
2431  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
2432
2433 /**
2434   * Search parameter: <b>identifier</b>
2435   * <p>
2436   * Description: <b>Business Identifier for item</b><br>
2437   * Type: <b>token</b><br>
2438   * Path: <b>Invoice.identifier</b><br>
2439   * </p>
2440   */
2441  @SearchParamDefinition(name="identifier", path="Invoice.identifier", description="Business Identifier for item", type="token" )
2442  public static final String SP_IDENTIFIER = "identifier";
2443 /**
2444   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2445   * <p>
2446   * Description: <b>Business Identifier for item</b><br>
2447   * Type: <b>token</b><br>
2448   * Path: <b>Invoice.identifier</b><br>
2449   * </p>
2450   */
2451  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2452
2453 /**
2454   * Search parameter: <b>totalgross</b>
2455   * <p>
2456   * Description: <b>Gross total of this Invoice</b><br>
2457   * Type: <b>quantity</b><br>
2458   * Path: <b>Invoice.totalGross</b><br>
2459   * </p>
2460   */
2461  @SearchParamDefinition(name="totalgross", path="Invoice.totalGross", description="Gross total of this Invoice", type="quantity" )
2462  public static final String SP_TOTALGROSS = "totalgross";
2463 /**
2464   * <b>Fluent Client</b> search parameter constant for <b>totalgross</b>
2465   * <p>
2466   * Description: <b>Gross total of this Invoice</b><br>
2467   * Type: <b>quantity</b><br>
2468   * Path: <b>Invoice.totalGross</b><br>
2469   * </p>
2470   */
2471  public static final ca.uhn.fhir.rest.gclient.QuantityClientParam TOTALGROSS = new ca.uhn.fhir.rest.gclient.QuantityClientParam(SP_TOTALGROSS);
2472
2473 /**
2474   * Search parameter: <b>subject</b>
2475   * <p>
2476   * Description: <b>Recipient(s) of goods and services</b><br>
2477   * Type: <b>reference</b><br>
2478   * Path: <b>Invoice.subject</b><br>
2479   * </p>
2480   */
2481  @SearchParamDefinition(name="subject", path="Invoice.subject", description="Recipient(s) of goods and services", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Group.class, Patient.class } )
2482  public static final String SP_SUBJECT = "subject";
2483 /**
2484   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
2485   * <p>
2486   * Description: <b>Recipient(s) of goods and services</b><br>
2487   * Type: <b>reference</b><br>
2488   * Path: <b>Invoice.subject</b><br>
2489   * </p>
2490   */
2491  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
2492
2493/**
2494   * Constant for fluent queries to be used to add include statements. Specifies
2495   * the path value of "<b>Invoice:subject</b>".
2496   */
2497  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("Invoice:subject").toLocked();
2498
2499 /**
2500   * Search parameter: <b>participant-role</b>
2501   * <p>
2502   * Description: <b>Type of involvement in creation of this Invoice</b><br>
2503   * Type: <b>token</b><br>
2504   * Path: <b>Invoice.participant.role</b><br>
2505   * </p>
2506   */
2507  @SearchParamDefinition(name="participant-role", path="Invoice.participant.role", description="Type of involvement in creation of this Invoice", type="token" )
2508  public static final String SP_PARTICIPANT_ROLE = "participant-role";
2509 /**
2510   * <b>Fluent Client</b> search parameter constant for <b>participant-role</b>
2511   * <p>
2512   * Description: <b>Type of involvement in creation of this Invoice</b><br>
2513   * Type: <b>token</b><br>
2514   * Path: <b>Invoice.participant.role</b><br>
2515   * </p>
2516   */
2517  public static final ca.uhn.fhir.rest.gclient.TokenClientParam PARTICIPANT_ROLE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_PARTICIPANT_ROLE);
2518
2519 /**
2520   * Search parameter: <b>type</b>
2521   * <p>
2522   * Description: <b>Type of Invoice</b><br>
2523   * Type: <b>token</b><br>
2524   * Path: <b>Invoice.type</b><br>
2525   * </p>
2526   */
2527  @SearchParamDefinition(name="type", path="Invoice.type", description="Type of Invoice", type="token" )
2528  public static final String SP_TYPE = "type";
2529 /**
2530   * <b>Fluent Client</b> search parameter constant for <b>type</b>
2531   * <p>
2532   * Description: <b>Type of Invoice</b><br>
2533   * Type: <b>token</b><br>
2534   * Path: <b>Invoice.type</b><br>
2535   * </p>
2536   */
2537  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
2538
2539 /**
2540   * Search parameter: <b>issuer</b>
2541   * <p>
2542   * Description: <b>Issuing Organization of Invoice</b><br>
2543   * Type: <b>reference</b><br>
2544   * Path: <b>Invoice.issuer</b><br>
2545   * </p>
2546   */
2547  @SearchParamDefinition(name="issuer", path="Invoice.issuer", description="Issuing Organization of Invoice", type="reference", target={Organization.class } )
2548  public static final String SP_ISSUER = "issuer";
2549 /**
2550   * <b>Fluent Client</b> search parameter constant for <b>issuer</b>
2551   * <p>
2552   * Description: <b>Issuing Organization of Invoice</b><br>
2553   * Type: <b>reference</b><br>
2554   * Path: <b>Invoice.issuer</b><br>
2555   * </p>
2556   */
2557  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ISSUER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ISSUER);
2558
2559/**
2560   * Constant for fluent queries to be used to add include statements. Specifies
2561   * the path value of "<b>Invoice:issuer</b>".
2562   */
2563  public static final ca.uhn.fhir.model.api.Include INCLUDE_ISSUER = new ca.uhn.fhir.model.api.Include("Invoice:issuer").toLocked();
2564
2565 /**
2566   * Search parameter: <b>participant</b>
2567   * <p>
2568   * Description: <b>Individual who was involved</b><br>
2569   * Type: <b>reference</b><br>
2570   * Path: <b>Invoice.participant.actor</b><br>
2571   * </p>
2572   */
2573  @SearchParamDefinition(name="participant", path="Invoice.participant.actor", description="Individual who was involved", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Device"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={Device.class, Organization.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class } )
2574  public static final String SP_PARTICIPANT = "participant";
2575 /**
2576   * <b>Fluent Client</b> search parameter constant for <b>participant</b>
2577   * <p>
2578   * Description: <b>Individual who was involved</b><br>
2579   * Type: <b>reference</b><br>
2580   * Path: <b>Invoice.participant.actor</b><br>
2581   * </p>
2582   */
2583  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PARTICIPANT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PARTICIPANT);
2584
2585/**
2586   * Constant for fluent queries to be used to add include statements. Specifies
2587   * the path value of "<b>Invoice:participant</b>".
2588   */
2589  public static final ca.uhn.fhir.model.api.Include INCLUDE_PARTICIPANT = new ca.uhn.fhir.model.api.Include("Invoice:participant").toLocked();
2590
2591 /**
2592   * Search parameter: <b>totalnet</b>
2593   * <p>
2594   * Description: <b>Net total of this Invoice</b><br>
2595   * Type: <b>quantity</b><br>
2596   * Path: <b>Invoice.totalNet</b><br>
2597   * </p>
2598   */
2599  @SearchParamDefinition(name="totalnet", path="Invoice.totalNet", description="Net total of this Invoice", type="quantity" )
2600  public static final String SP_TOTALNET = "totalnet";
2601 /**
2602   * <b>Fluent Client</b> search parameter constant for <b>totalnet</b>
2603   * <p>
2604   * Description: <b>Net total of this Invoice</b><br>
2605   * Type: <b>quantity</b><br>
2606   * Path: <b>Invoice.totalNet</b><br>
2607   * </p>
2608   */
2609  public static final ca.uhn.fhir.rest.gclient.QuantityClientParam TOTALNET = new ca.uhn.fhir.rest.gclient.QuantityClientParam(SP_TOTALNET);
2610
2611 /**
2612   * Search parameter: <b>patient</b>
2613   * <p>
2614   * Description: <b>Recipient(s) of goods and services</b><br>
2615   * Type: <b>reference</b><br>
2616   * Path: <b>Invoice.subject</b><br>
2617   * </p>
2618   */
2619  @SearchParamDefinition(name="patient", path="Invoice.subject.where(resolve() is Patient)", description="Recipient(s) of goods and services", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Patient.class } )
2620  public static final String SP_PATIENT = "patient";
2621 /**
2622   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2623   * <p>
2624   * Description: <b>Recipient(s) of goods and services</b><br>
2625   * Type: <b>reference</b><br>
2626   * Path: <b>Invoice.subject</b><br>
2627   * </p>
2628   */
2629  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
2630
2631/**
2632   * Constant for fluent queries to be used to add include statements. Specifies
2633   * the path value of "<b>Invoice:patient</b>".
2634   */
2635  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("Invoice:patient").toLocked();
2636
2637 /**
2638   * Search parameter: <b>recipient</b>
2639   * <p>
2640   * Description: <b>Recipient of this invoice</b><br>
2641   * Type: <b>reference</b><br>
2642   * Path: <b>Invoice.recipient</b><br>
2643   * </p>
2644   */
2645  @SearchParamDefinition(name="recipient", path="Invoice.recipient", description="Recipient of this invoice", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient"), @ca.uhn.fhir.model.api.annotation.Compartment(name="RelatedPerson") }, target={Organization.class, Patient.class, RelatedPerson.class } )
2646  public static final String SP_RECIPIENT = "recipient";
2647 /**
2648   * <b>Fluent Client</b> search parameter constant for <b>recipient</b>
2649   * <p>
2650   * Description: <b>Recipient of this invoice</b><br>
2651   * Type: <b>reference</b><br>
2652   * Path: <b>Invoice.recipient</b><br>
2653   * </p>
2654   */
2655  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam RECIPIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_RECIPIENT);
2656
2657/**
2658   * Constant for fluent queries to be used to add include statements. Specifies
2659   * the path value of "<b>Invoice:recipient</b>".
2660   */
2661  public static final ca.uhn.fhir.model.api.Include INCLUDE_RECIPIENT = new ca.uhn.fhir.model.api.Include("Invoice:recipient").toLocked();
2662
2663 /**
2664   * Search parameter: <b>account</b>
2665   * <p>
2666   * Description: <b>Account that is being balanced</b><br>
2667   * Type: <b>reference</b><br>
2668   * Path: <b>Invoice.account</b><br>
2669   * </p>
2670   */
2671  @SearchParamDefinition(name="account", path="Invoice.account", description="Account that is being balanced", type="reference", target={Account.class } )
2672  public static final String SP_ACCOUNT = "account";
2673 /**
2674   * <b>Fluent Client</b> search parameter constant for <b>account</b>
2675   * <p>
2676   * Description: <b>Account that is being balanced</b><br>
2677   * Type: <b>reference</b><br>
2678   * Path: <b>Invoice.account</b><br>
2679   * </p>
2680   */
2681  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ACCOUNT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ACCOUNT);
2682
2683/**
2684   * Constant for fluent queries to be used to add include statements. Specifies
2685   * the path value of "<b>Invoice:account</b>".
2686   */
2687  public static final ca.uhn.fhir.model.api.Include INCLUDE_ACCOUNT = new ca.uhn.fhir.model.api.Include("Invoice:account").toLocked();
2688
2689 /**
2690   * Search parameter: <b>status</b>
2691   * <p>
2692   * Description: <b>draft | issued | balanced | cancelled | entered-in-error</b><br>
2693   * Type: <b>token</b><br>
2694   * Path: <b>Invoice.status</b><br>
2695   * </p>
2696   */
2697  @SearchParamDefinition(name="status", path="Invoice.status", description="draft | issued | balanced | cancelled | entered-in-error", type="token" )
2698  public static final String SP_STATUS = "status";
2699 /**
2700   * <b>Fluent Client</b> search parameter constant for <b>status</b>
2701   * <p>
2702   * Description: <b>draft | issued | balanced | cancelled | entered-in-error</b><br>
2703   * Type: <b>token</b><br>
2704   * Path: <b>Invoice.status</b><br>
2705   * </p>
2706   */
2707  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
2708
2709
2710}
2711