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