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