001package org.hl7.fhir.r4.model;
002
003
004
005/*
006  Copyright (c) 2011+, HL7, Inc.
007  All rights reserved.
008  
009  Redistribution and use in source and binary forms, with or without modification, 
010  are permitted provided that the following conditions are met:
011  
012   * Redistributions of source code must retain the above copyright notice, this 
013     list of conditions and the following disclaimer.
014   * Redistributions in binary form must reproduce the above copyright notice, 
015     this list of conditions and the following disclaimer in the documentation 
016     and/or other materials provided with the distribution.
017   * Neither the name of HL7 nor the names of its contributors may be used to 
018     endorse or promote products derived from this software without specific 
019     prior written permission.
020  
021  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
022  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
023  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
024  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
025  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
026  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
027  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
028  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
029  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
030  POSSIBILITY OF SUCH DAMAGE.
031  
032*/
033
034
035// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
036
037import java.util.*;
038
039import org.hl7.fhir.utilities.Utilities;
040import ca.uhn.fhir.model.api.annotation.ResourceDef;
041import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
042import ca.uhn.fhir.model.api.annotation.Child;
043import ca.uhn.fhir.model.api.annotation.ChildOrder;
044import ca.uhn.fhir.model.api.annotation.Description;
045import ca.uhn.fhir.model.api.annotation.Block;
046import org.hl7.fhir.instance.model.api.*;
047import org.hl7.fhir.exceptions.FHIRException;
048/**
049 * A financial tool for tracking value accrued for a particular purpose.  In the healthcare field, used to track charges for a patient, cost centers, etc.
050 */
051@ResourceDef(name="Account", profile="http://hl7.org/fhir/StructureDefinition/Account")
052public class Account extends DomainResource {
053
054    public enum AccountStatus {
055        /**
056         * This account is active and may be used.
057         */
058        ACTIVE, 
059        /**
060         * This account is inactive and should not be used to track financial information.
061         */
062        INACTIVE, 
063        /**
064         * This instance should not have been part of this patient's medical record.
065         */
066        ENTEREDINERROR, 
067        /**
068         * This account is on hold.
069         */
070        ONHOLD, 
071        /**
072         * The account status is unknown.
073         */
074        UNKNOWN, 
075        /**
076         * added to help the parsers with the generic types
077         */
078        NULL;
079        public static AccountStatus fromCode(String codeString) throws FHIRException {
080            if (codeString == null || "".equals(codeString))
081                return null;
082        if ("active".equals(codeString))
083          return ACTIVE;
084        if ("inactive".equals(codeString))
085          return INACTIVE;
086        if ("entered-in-error".equals(codeString))
087          return ENTEREDINERROR;
088        if ("on-hold".equals(codeString))
089          return ONHOLD;
090        if ("unknown".equals(codeString))
091          return UNKNOWN;
092        if (Configuration.isAcceptInvalidEnums())
093          return null;
094        else
095          throw new FHIRException("Unknown AccountStatus code '"+codeString+"'");
096        }
097        public String toCode() {
098          switch (this) {
099            case ACTIVE: return "active";
100            case INACTIVE: return "inactive";
101            case ENTEREDINERROR: return "entered-in-error";
102            case ONHOLD: return "on-hold";
103            case UNKNOWN: return "unknown";
104            default: return "?";
105          }
106        }
107        public String getSystem() {
108          switch (this) {
109            case ACTIVE: return "http://hl7.org/fhir/account-status";
110            case INACTIVE: return "http://hl7.org/fhir/account-status";
111            case ENTEREDINERROR: return "http://hl7.org/fhir/account-status";
112            case ONHOLD: return "http://hl7.org/fhir/account-status";
113            case UNKNOWN: return "http://hl7.org/fhir/account-status";
114            default: return "?";
115          }
116        }
117        public String getDefinition() {
118          switch (this) {
119            case ACTIVE: return "This account is active and may be used.";
120            case INACTIVE: return "This account is inactive and should not be used to track financial information.";
121            case ENTEREDINERROR: return "This instance should not have been part of this patient's medical record.";
122            case ONHOLD: return "This account is on hold.";
123            case UNKNOWN: return "The account status is unknown.";
124            default: return "?";
125          }
126        }
127        public String getDisplay() {
128          switch (this) {
129            case ACTIVE: return "Active";
130            case INACTIVE: return "Inactive";
131            case ENTEREDINERROR: return "Entered in error";
132            case ONHOLD: return "On Hold";
133            case UNKNOWN: return "Unknown";
134            default: return "?";
135          }
136        }
137    }
138
139  public static class AccountStatusEnumFactory implements EnumFactory<AccountStatus> {
140    public AccountStatus fromCode(String codeString) throws IllegalArgumentException {
141      if (codeString == null || "".equals(codeString))
142            if (codeString == null || "".equals(codeString))
143                return null;
144        if ("active".equals(codeString))
145          return AccountStatus.ACTIVE;
146        if ("inactive".equals(codeString))
147          return AccountStatus.INACTIVE;
148        if ("entered-in-error".equals(codeString))
149          return AccountStatus.ENTEREDINERROR;
150        if ("on-hold".equals(codeString))
151          return AccountStatus.ONHOLD;
152        if ("unknown".equals(codeString))
153          return AccountStatus.UNKNOWN;
154        throw new IllegalArgumentException("Unknown AccountStatus code '"+codeString+"'");
155        }
156        public Enumeration<AccountStatus> fromType(Base code) throws FHIRException {
157          if (code == null)
158            return null;
159          if (code.isEmpty())
160            return new Enumeration<AccountStatus>(this);
161          String codeString = ((PrimitiveType) code).asStringValue();
162          if (codeString == null || "".equals(codeString))
163            return null;
164        if ("active".equals(codeString))
165          return new Enumeration<AccountStatus>(this, AccountStatus.ACTIVE);
166        if ("inactive".equals(codeString))
167          return new Enumeration<AccountStatus>(this, AccountStatus.INACTIVE);
168        if ("entered-in-error".equals(codeString))
169          return new Enumeration<AccountStatus>(this, AccountStatus.ENTEREDINERROR);
170        if ("on-hold".equals(codeString))
171          return new Enumeration<AccountStatus>(this, AccountStatus.ONHOLD);
172        if ("unknown".equals(codeString))
173          return new Enumeration<AccountStatus>(this, AccountStatus.UNKNOWN);
174        throw new FHIRException("Unknown AccountStatus code '"+codeString+"'");
175        }
176    public String toCode(AccountStatus code) {
177      if (code == AccountStatus.ACTIVE)
178        return "active";
179      if (code == AccountStatus.INACTIVE)
180        return "inactive";
181      if (code == AccountStatus.ENTEREDINERROR)
182        return "entered-in-error";
183      if (code == AccountStatus.ONHOLD)
184        return "on-hold";
185      if (code == AccountStatus.UNKNOWN)
186        return "unknown";
187      return "?";
188      }
189    public String toSystem(AccountStatus code) {
190      return code.getSystem();
191      }
192    }
193
194    @Block()
195    public static class CoverageComponent extends BackboneElement implements IBaseBackboneElement {
196        /**
197         * The party(s) that contribute to payment (or part of) of the charges applied to this account (including self-pay).
198
199A coverage may only be responsible for specific types of charges, and the sequence of the coverages in the account could be important when processing billing.
200         */
201        @Child(name = "coverage", type = {Coverage.class}, order=1, min=1, max=1, modifier=false, summary=true)
202        @Description(shortDefinition="The party(s), such as insurances, that may contribute to the payment of this account", formalDefinition="The party(s) that contribute to payment (or part of) of the charges applied to this account (including self-pay).\n\nA coverage may only be responsible for specific types of charges, and the sequence of the coverages in the account could be important when processing billing." )
203        protected Reference coverage;
204
205        /**
206         * The actual object that is the target of the reference (The party(s) that contribute to payment (or part of) of the charges applied to this account (including self-pay).
207
208A coverage may only be responsible for specific types of charges, and the sequence of the coverages in the account could be important when processing billing.)
209         */
210        protected Coverage coverageTarget;
211
212        /**
213         * The priority of the coverage in the context of this account.
214         */
215        @Child(name = "priority", type = {PositiveIntType.class}, order=2, min=0, max=1, modifier=false, summary=true)
216        @Description(shortDefinition="The priority of the coverage in the context of this account", formalDefinition="The priority of the coverage in the context of this account." )
217        protected PositiveIntType priority;
218
219        private static final long serialVersionUID = -1046265008L;
220
221    /**
222     * Constructor
223     */
224      public CoverageComponent() {
225        super();
226      }
227
228    /**
229     * Constructor
230     */
231      public CoverageComponent(Reference coverage) {
232        super();
233        this.coverage = coverage;
234      }
235
236        /**
237         * @return {@link #coverage} (The party(s) that contribute to payment (or part of) of the charges applied to this account (including self-pay).
238
239A coverage may only be responsible for specific types of charges, and the sequence of the coverages in the account could be important when processing billing.)
240         */
241        public Reference getCoverage() { 
242          if (this.coverage == null)
243            if (Configuration.errorOnAutoCreate())
244              throw new Error("Attempt to auto-create CoverageComponent.coverage");
245            else if (Configuration.doAutoCreate())
246              this.coverage = new Reference(); // cc
247          return this.coverage;
248        }
249
250        public boolean hasCoverage() { 
251          return this.coverage != null && !this.coverage.isEmpty();
252        }
253
254        /**
255         * @param value {@link #coverage} (The party(s) that contribute to payment (or part of) of the charges applied to this account (including self-pay).
256
257A coverage may only be responsible for specific types of charges, and the sequence of the coverages in the account could be important when processing billing.)
258         */
259        public CoverageComponent setCoverage(Reference value) { 
260          this.coverage = value;
261          return this;
262        }
263
264        /**
265         * @return {@link #coverage} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The party(s) that contribute to payment (or part of) of the charges applied to this account (including self-pay).
266
267A coverage may only be responsible for specific types of charges, and the sequence of the coverages in the account could be important when processing billing.)
268         */
269        public Coverage getCoverageTarget() { 
270          if (this.coverageTarget == null)
271            if (Configuration.errorOnAutoCreate())
272              throw new Error("Attempt to auto-create CoverageComponent.coverage");
273            else if (Configuration.doAutoCreate())
274              this.coverageTarget = new Coverage(); // aa
275          return this.coverageTarget;
276        }
277
278        /**
279         * @param value {@link #coverage} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The party(s) that contribute to payment (or part of) of the charges applied to this account (including self-pay).
280
281A coverage may only be responsible for specific types of charges, and the sequence of the coverages in the account could be important when processing billing.)
282         */
283        public CoverageComponent setCoverageTarget(Coverage value) { 
284          this.coverageTarget = value;
285          return this;
286        }
287
288        /**
289         * @return {@link #priority} (The priority of the coverage in the context of this account.). This is the underlying object with id, value and extensions. The accessor "getPriority" gives direct access to the value
290         */
291        public PositiveIntType getPriorityElement() { 
292          if (this.priority == null)
293            if (Configuration.errorOnAutoCreate())
294              throw new Error("Attempt to auto-create CoverageComponent.priority");
295            else if (Configuration.doAutoCreate())
296              this.priority = new PositiveIntType(); // bb
297          return this.priority;
298        }
299
300        public boolean hasPriorityElement() { 
301          return this.priority != null && !this.priority.isEmpty();
302        }
303
304        public boolean hasPriority() { 
305          return this.priority != null && !this.priority.isEmpty();
306        }
307
308        /**
309         * @param value {@link #priority} (The priority of the coverage in the context of this account.). This is the underlying object with id, value and extensions. The accessor "getPriority" gives direct access to the value
310         */
311        public CoverageComponent setPriorityElement(PositiveIntType value) { 
312          this.priority = value;
313          return this;
314        }
315
316        /**
317         * @return The priority of the coverage in the context of this account.
318         */
319        public int getPriority() { 
320          return this.priority == null || this.priority.isEmpty() ? 0 : this.priority.getValue();
321        }
322
323        /**
324         * @param value The priority of the coverage in the context of this account.
325         */
326        public CoverageComponent setPriority(int value) { 
327            if (this.priority == null)
328              this.priority = new PositiveIntType();
329            this.priority.setValue(value);
330          return this;
331        }
332
333        protected void listChildren(List<Property> children) {
334          super.listChildren(children);
335          children.add(new Property("coverage", "Reference(Coverage)", "The party(s) that contribute to payment (or part of) of the charges applied to this account (including self-pay).\n\nA coverage may only be responsible for specific types of charges, and the sequence of the coverages in the account could be important when processing billing.", 0, 1, coverage));
336          children.add(new Property("priority", "positiveInt", "The priority of the coverage in the context of this account.", 0, 1, priority));
337        }
338
339        @Override
340        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
341          switch (_hash) {
342          case -351767064: /*coverage*/  return new Property("coverage", "Reference(Coverage)", "The party(s) that contribute to payment (or part of) of the charges applied to this account (including self-pay).\n\nA coverage may only be responsible for specific types of charges, and the sequence of the coverages in the account could be important when processing billing.", 0, 1, coverage);
343          case -1165461084: /*priority*/  return new Property("priority", "positiveInt", "The priority of the coverage in the context of this account.", 0, 1, priority);
344          default: return super.getNamedProperty(_hash, _name, _checkValid);
345          }
346
347        }
348
349      @Override
350      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
351        switch (hash) {
352        case -351767064: /*coverage*/ return this.coverage == null ? new Base[0] : new Base[] {this.coverage}; // Reference
353        case -1165461084: /*priority*/ return this.priority == null ? new Base[0] : new Base[] {this.priority}; // PositiveIntType
354        default: return super.getProperty(hash, name, checkValid);
355        }
356
357      }
358
359      @Override
360      public Base setProperty(int hash, String name, Base value) throws FHIRException {
361        switch (hash) {
362        case -351767064: // coverage
363          this.coverage = castToReference(value); // Reference
364          return value;
365        case -1165461084: // priority
366          this.priority = castToPositiveInt(value); // PositiveIntType
367          return value;
368        default: return super.setProperty(hash, name, value);
369        }
370
371      }
372
373      @Override
374      public Base setProperty(String name, Base value) throws FHIRException {
375        if (name.equals("coverage")) {
376          this.coverage = castToReference(value); // Reference
377        } else if (name.equals("priority")) {
378          this.priority = castToPositiveInt(value); // PositiveIntType
379        } else
380          return super.setProperty(name, value);
381        return value;
382      }
383
384      @Override
385      public Base makeProperty(int hash, String name) throws FHIRException {
386        switch (hash) {
387        case -351767064:  return getCoverage(); 
388        case -1165461084:  return getPriorityElement();
389        default: return super.makeProperty(hash, name);
390        }
391
392      }
393
394      @Override
395      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
396        switch (hash) {
397        case -351767064: /*coverage*/ return new String[] {"Reference"};
398        case -1165461084: /*priority*/ return new String[] {"positiveInt"};
399        default: return super.getTypesForProperty(hash, name);
400        }
401
402      }
403
404      @Override
405      public Base addChild(String name) throws FHIRException {
406        if (name.equals("coverage")) {
407          this.coverage = new Reference();
408          return this.coverage;
409        }
410        else if (name.equals("priority")) {
411          throw new FHIRException("Cannot call addChild on a primitive type Account.priority");
412        }
413        else
414          return super.addChild(name);
415      }
416
417      public CoverageComponent copy() {
418        CoverageComponent dst = new CoverageComponent();
419        copyValues(dst);
420        return dst;
421      }
422
423      public void copyValues(CoverageComponent dst) {
424        super.copyValues(dst);
425        dst.coverage = coverage == null ? null : coverage.copy();
426        dst.priority = priority == null ? null : priority.copy();
427      }
428
429      @Override
430      public boolean equalsDeep(Base other_) {
431        if (!super.equalsDeep(other_))
432          return false;
433        if (!(other_ instanceof CoverageComponent))
434          return false;
435        CoverageComponent o = (CoverageComponent) other_;
436        return compareDeep(coverage, o.coverage, true) && compareDeep(priority, o.priority, true);
437      }
438
439      @Override
440      public boolean equalsShallow(Base other_) {
441        if (!super.equalsShallow(other_))
442          return false;
443        if (!(other_ instanceof CoverageComponent))
444          return false;
445        CoverageComponent o = (CoverageComponent) other_;
446        return compareValues(priority, o.priority, true);
447      }
448
449      public boolean isEmpty() {
450        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(coverage, priority);
451      }
452
453  public String fhirType() {
454    return "Account.coverage";
455
456  }
457
458  }
459
460    @Block()
461    public static class GuarantorComponent extends BackboneElement implements IBaseBackboneElement {
462        /**
463         * The entity who is responsible.
464         */
465        @Child(name = "party", type = {Patient.class, RelatedPerson.class, Organization.class}, order=1, min=1, max=1, modifier=false, summary=false)
466        @Description(shortDefinition="Responsible entity", formalDefinition="The entity who is responsible." )
467        protected Reference party;
468
469        /**
470         * The actual object that is the target of the reference (The entity who is responsible.)
471         */
472        protected Resource partyTarget;
473
474        /**
475         * A guarantor may be placed on credit hold or otherwise have their role temporarily suspended.
476         */
477        @Child(name = "onHold", type = {BooleanType.class}, order=2, min=0, max=1, modifier=false, summary=false)
478        @Description(shortDefinition="Credit or other hold applied", formalDefinition="A guarantor may be placed on credit hold or otherwise have their role temporarily suspended." )
479        protected BooleanType onHold;
480
481        /**
482         * The timeframe during which the guarantor accepts responsibility for the account.
483         */
484        @Child(name = "period", type = {Period.class}, order=3, min=0, max=1, modifier=false, summary=false)
485        @Description(shortDefinition="Guarantee account during", formalDefinition="The timeframe during which the guarantor accepts responsibility for the account." )
486        protected Period period;
487
488        private static final long serialVersionUID = -1012345396L;
489
490    /**
491     * Constructor
492     */
493      public GuarantorComponent() {
494        super();
495      }
496
497    /**
498     * Constructor
499     */
500      public GuarantorComponent(Reference party) {
501        super();
502        this.party = party;
503      }
504
505        /**
506         * @return {@link #party} (The entity who is responsible.)
507         */
508        public Reference getParty() { 
509          if (this.party == null)
510            if (Configuration.errorOnAutoCreate())
511              throw new Error("Attempt to auto-create GuarantorComponent.party");
512            else if (Configuration.doAutoCreate())
513              this.party = new Reference(); // cc
514          return this.party;
515        }
516
517        public boolean hasParty() { 
518          return this.party != null && !this.party.isEmpty();
519        }
520
521        /**
522         * @param value {@link #party} (The entity who is responsible.)
523         */
524        public GuarantorComponent setParty(Reference value) { 
525          this.party = value;
526          return this;
527        }
528
529        /**
530         * @return {@link #party} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The entity who is responsible.)
531         */
532        public Resource getPartyTarget() { 
533          return this.partyTarget;
534        }
535
536        /**
537         * @param value {@link #party} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The entity who is responsible.)
538         */
539        public GuarantorComponent setPartyTarget(Resource value) { 
540          this.partyTarget = value;
541          return this;
542        }
543
544        /**
545         * @return {@link #onHold} (A guarantor may be placed on credit hold or otherwise have their role temporarily suspended.). This is the underlying object with id, value and extensions. The accessor "getOnHold" gives direct access to the value
546         */
547        public BooleanType getOnHoldElement() { 
548          if (this.onHold == null)
549            if (Configuration.errorOnAutoCreate())
550              throw new Error("Attempt to auto-create GuarantorComponent.onHold");
551            else if (Configuration.doAutoCreate())
552              this.onHold = new BooleanType(); // bb
553          return this.onHold;
554        }
555
556        public boolean hasOnHoldElement() { 
557          return this.onHold != null && !this.onHold.isEmpty();
558        }
559
560        public boolean hasOnHold() { 
561          return this.onHold != null && !this.onHold.isEmpty();
562        }
563
564        /**
565         * @param value {@link #onHold} (A guarantor may be placed on credit hold or otherwise have their role temporarily suspended.). This is the underlying object with id, value and extensions. The accessor "getOnHold" gives direct access to the value
566         */
567        public GuarantorComponent setOnHoldElement(BooleanType value) { 
568          this.onHold = value;
569          return this;
570        }
571
572        /**
573         * @return A guarantor may be placed on credit hold or otherwise have their role temporarily suspended.
574         */
575        public boolean getOnHold() { 
576          return this.onHold == null || this.onHold.isEmpty() ? false : this.onHold.getValue();
577        }
578
579        /**
580         * @param value A guarantor may be placed on credit hold or otherwise have their role temporarily suspended.
581         */
582        public GuarantorComponent setOnHold(boolean value) { 
583            if (this.onHold == null)
584              this.onHold = new BooleanType();
585            this.onHold.setValue(value);
586          return this;
587        }
588
589        /**
590         * @return {@link #period} (The timeframe during which the guarantor accepts responsibility for the account.)
591         */
592        public Period getPeriod() { 
593          if (this.period == null)
594            if (Configuration.errorOnAutoCreate())
595              throw new Error("Attempt to auto-create GuarantorComponent.period");
596            else if (Configuration.doAutoCreate())
597              this.period = new Period(); // cc
598          return this.period;
599        }
600
601        public boolean hasPeriod() { 
602          return this.period != null && !this.period.isEmpty();
603        }
604
605        /**
606         * @param value {@link #period} (The timeframe during which the guarantor accepts responsibility for the account.)
607         */
608        public GuarantorComponent setPeriod(Period value) { 
609          this.period = value;
610          return this;
611        }
612
613        protected void listChildren(List<Property> children) {
614          super.listChildren(children);
615          children.add(new Property("party", "Reference(Patient|RelatedPerson|Organization)", "The entity who is responsible.", 0, 1, party));
616          children.add(new Property("onHold", "boolean", "A guarantor may be placed on credit hold or otherwise have their role temporarily suspended.", 0, 1, onHold));
617          children.add(new Property("period", "Period", "The timeframe during which the guarantor accepts responsibility for the account.", 0, 1, period));
618        }
619
620        @Override
621        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
622          switch (_hash) {
623          case 106437350: /*party*/  return new Property("party", "Reference(Patient|RelatedPerson|Organization)", "The entity who is responsible.", 0, 1, party);
624          case -1013289154: /*onHold*/  return new Property("onHold", "boolean", "A guarantor may be placed on credit hold or otherwise have their role temporarily suspended.", 0, 1, onHold);
625          case -991726143: /*period*/  return new Property("period", "Period", "The timeframe during which the guarantor accepts responsibility for the account.", 0, 1, period);
626          default: return super.getNamedProperty(_hash, _name, _checkValid);
627          }
628
629        }
630
631      @Override
632      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
633        switch (hash) {
634        case 106437350: /*party*/ return this.party == null ? new Base[0] : new Base[] {this.party}; // Reference
635        case -1013289154: /*onHold*/ return this.onHold == null ? new Base[0] : new Base[] {this.onHold}; // BooleanType
636        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
637        default: return super.getProperty(hash, name, checkValid);
638        }
639
640      }
641
642      @Override
643      public Base setProperty(int hash, String name, Base value) throws FHIRException {
644        switch (hash) {
645        case 106437350: // party
646          this.party = castToReference(value); // Reference
647          return value;
648        case -1013289154: // onHold
649          this.onHold = castToBoolean(value); // BooleanType
650          return value;
651        case -991726143: // period
652          this.period = castToPeriod(value); // Period
653          return value;
654        default: return super.setProperty(hash, name, value);
655        }
656
657      }
658
659      @Override
660      public Base setProperty(String name, Base value) throws FHIRException {
661        if (name.equals("party")) {
662          this.party = castToReference(value); // Reference
663        } else if (name.equals("onHold")) {
664          this.onHold = castToBoolean(value); // BooleanType
665        } else if (name.equals("period")) {
666          this.period = castToPeriod(value); // Period
667        } else
668          return super.setProperty(name, value);
669        return value;
670      }
671
672      @Override
673      public Base makeProperty(int hash, String name) throws FHIRException {
674        switch (hash) {
675        case 106437350:  return getParty(); 
676        case -1013289154:  return getOnHoldElement();
677        case -991726143:  return getPeriod(); 
678        default: return super.makeProperty(hash, name);
679        }
680
681      }
682
683      @Override
684      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
685        switch (hash) {
686        case 106437350: /*party*/ return new String[] {"Reference"};
687        case -1013289154: /*onHold*/ return new String[] {"boolean"};
688        case -991726143: /*period*/ return new String[] {"Period"};
689        default: return super.getTypesForProperty(hash, name);
690        }
691
692      }
693
694      @Override
695      public Base addChild(String name) throws FHIRException {
696        if (name.equals("party")) {
697          this.party = new Reference();
698          return this.party;
699        }
700        else if (name.equals("onHold")) {
701          throw new FHIRException("Cannot call addChild on a primitive type Account.onHold");
702        }
703        else if (name.equals("period")) {
704          this.period = new Period();
705          return this.period;
706        }
707        else
708          return super.addChild(name);
709      }
710
711      public GuarantorComponent copy() {
712        GuarantorComponent dst = new GuarantorComponent();
713        copyValues(dst);
714        return dst;
715      }
716
717      public void copyValues(GuarantorComponent dst) {
718        super.copyValues(dst);
719        dst.party = party == null ? null : party.copy();
720        dst.onHold = onHold == null ? null : onHold.copy();
721        dst.period = period == null ? null : period.copy();
722      }
723
724      @Override
725      public boolean equalsDeep(Base other_) {
726        if (!super.equalsDeep(other_))
727          return false;
728        if (!(other_ instanceof GuarantorComponent))
729          return false;
730        GuarantorComponent o = (GuarantorComponent) other_;
731        return compareDeep(party, o.party, true) && compareDeep(onHold, o.onHold, true) && compareDeep(period, o.period, true)
732          ;
733      }
734
735      @Override
736      public boolean equalsShallow(Base other_) {
737        if (!super.equalsShallow(other_))
738          return false;
739        if (!(other_ instanceof GuarantorComponent))
740          return false;
741        GuarantorComponent o = (GuarantorComponent) other_;
742        return compareValues(onHold, o.onHold, true);
743      }
744
745      public boolean isEmpty() {
746        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(party, onHold, period);
747      }
748
749  public String fhirType() {
750    return "Account.guarantor";
751
752  }
753
754  }
755
756    /**
757     * Unique identifier used to reference the account.  Might or might not be intended for human use (e.g. credit card number).
758     */
759    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
760    @Description(shortDefinition="Account number", formalDefinition="Unique identifier used to reference the account.  Might or might not be intended for human use (e.g. credit card number)." )
761    protected List<Identifier> identifier;
762
763    /**
764     * Indicates whether the account is presently used/usable or not.
765     */
766    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
767    @Description(shortDefinition="active | inactive | entered-in-error | on-hold | unknown", formalDefinition="Indicates whether the account is presently used/usable or not." )
768    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/account-status")
769    protected Enumeration<AccountStatus> status;
770
771    /**
772     * Categorizes the account for reporting and searching purposes.
773     */
774    @Child(name = "type", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
775    @Description(shortDefinition="E.g. patient, expense, depreciation", formalDefinition="Categorizes the account for reporting and searching purposes." )
776    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/account-type")
777    protected CodeableConcept type;
778
779    /**
780     * Name used for the account when displaying it to humans in reports, etc.
781     */
782    @Child(name = "name", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
783    @Description(shortDefinition="Human-readable label", formalDefinition="Name used for the account when displaying it to humans in reports, etc." )
784    protected StringType name;
785
786    /**
787     * Identifies the entity which incurs the expenses. While the immediate recipients of services or goods might be entities related to the subject, the expenses were ultimately incurred by the subject of the Account.
788     */
789    @Child(name = "subject", type = {Patient.class, Device.class, Practitioner.class, PractitionerRole.class, Location.class, HealthcareService.class, Organization.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
790    @Description(shortDefinition="The entity that caused the expenses", formalDefinition="Identifies the entity which incurs the expenses. While the immediate recipients of services or goods might be entities related to the subject, the expenses were ultimately incurred by the subject of the Account." )
791    protected List<Reference> subject;
792    /**
793     * The actual objects that are the target of the reference (Identifies the entity which incurs the expenses. While the immediate recipients of services or goods might be entities related to the subject, the expenses were ultimately incurred by the subject of the Account.)
794     */
795    protected List<Resource> subjectTarget;
796
797
798    /**
799     * The date range of services associated with this account.
800     */
801    @Child(name = "servicePeriod", type = {Period.class}, order=5, min=0, max=1, modifier=false, summary=true)
802    @Description(shortDefinition="Transaction window", formalDefinition="The date range of services associated with this account." )
803    protected Period servicePeriod;
804
805    /**
806     * The party(s) that are responsible for covering the payment of this account, and what order should they be applied to the account.
807     */
808    @Child(name = "coverage", type = {}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
809    @Description(shortDefinition="The party(s) that are responsible for covering the payment of this account, and what order should they be applied to the account", formalDefinition="The party(s) that are responsible for covering the payment of this account, and what order should they be applied to the account." )
810    protected List<CoverageComponent> coverage;
811
812    /**
813     * Indicates the service area, hospital, department, etc. with responsibility for managing the Account.
814     */
815    @Child(name = "owner", type = {Organization.class}, order=7, min=0, max=1, modifier=false, summary=true)
816    @Description(shortDefinition="Entity managing the Account", formalDefinition="Indicates the service area, hospital, department, etc. with responsibility for managing the Account." )
817    protected Reference owner;
818
819    /**
820     * The actual object that is the target of the reference (Indicates the service area, hospital, department, etc. with responsibility for managing the Account.)
821     */
822    protected Organization ownerTarget;
823
824    /**
825     * Provides additional information about what the account tracks and how it is used.
826     */
827    @Child(name = "description", type = {StringType.class}, order=8, min=0, max=1, modifier=false, summary=true)
828    @Description(shortDefinition="Explanation of purpose/use", formalDefinition="Provides additional information about what the account tracks and how it is used." )
829    protected StringType description;
830
831    /**
832     * The parties responsible for balancing the account if other payment options fall short.
833     */
834    @Child(name = "guarantor", type = {}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
835    @Description(shortDefinition="The parties ultimately responsible for balancing the Account", formalDefinition="The parties responsible for balancing the account if other payment options fall short." )
836    protected List<GuarantorComponent> guarantor;
837
838    /**
839     * Reference to a parent Account.
840     */
841    @Child(name = "partOf", type = {Account.class}, order=10, min=0, max=1, modifier=false, summary=false)
842    @Description(shortDefinition="Reference to a parent Account", formalDefinition="Reference to a parent Account." )
843    protected Reference partOf;
844
845    /**
846     * The actual object that is the target of the reference (Reference to a parent Account.)
847     */
848    protected Account partOfTarget;
849
850    private static final long serialVersionUID = 1211238069L;
851
852  /**
853   * Constructor
854   */
855    public Account() {
856      super();
857    }
858
859  /**
860   * Constructor
861   */
862    public Account(Enumeration<AccountStatus> status) {
863      super();
864      this.status = status;
865    }
866
867    /**
868     * @return {@link #identifier} (Unique identifier used to reference the account.  Might or might not be intended for human use (e.g. credit card number).)
869     */
870    public List<Identifier> getIdentifier() { 
871      if (this.identifier == null)
872        this.identifier = new ArrayList<Identifier>();
873      return this.identifier;
874    }
875
876    /**
877     * @return Returns a reference to <code>this</code> for easy method chaining
878     */
879    public Account setIdentifier(List<Identifier> theIdentifier) { 
880      this.identifier = theIdentifier;
881      return this;
882    }
883
884    public boolean hasIdentifier() { 
885      if (this.identifier == null)
886        return false;
887      for (Identifier item : this.identifier)
888        if (!item.isEmpty())
889          return true;
890      return false;
891    }
892
893    public Identifier addIdentifier() { //3
894      Identifier t = new Identifier();
895      if (this.identifier == null)
896        this.identifier = new ArrayList<Identifier>();
897      this.identifier.add(t);
898      return t;
899    }
900
901    public Account addIdentifier(Identifier t) { //3
902      if (t == null)
903        return this;
904      if (this.identifier == null)
905        this.identifier = new ArrayList<Identifier>();
906      this.identifier.add(t);
907      return this;
908    }
909
910    /**
911     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
912     */
913    public Identifier getIdentifierFirstRep() { 
914      if (getIdentifier().isEmpty()) {
915        addIdentifier();
916      }
917      return getIdentifier().get(0);
918    }
919
920    /**
921     * @return {@link #status} (Indicates whether the account is presently used/usable or not.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
922     */
923    public Enumeration<AccountStatus> getStatusElement() { 
924      if (this.status == null)
925        if (Configuration.errorOnAutoCreate())
926          throw new Error("Attempt to auto-create Account.status");
927        else if (Configuration.doAutoCreate())
928          this.status = new Enumeration<AccountStatus>(new AccountStatusEnumFactory()); // bb
929      return this.status;
930    }
931
932    public boolean hasStatusElement() { 
933      return this.status != null && !this.status.isEmpty();
934    }
935
936    public boolean hasStatus() { 
937      return this.status != null && !this.status.isEmpty();
938    }
939
940    /**
941     * @param value {@link #status} (Indicates whether the account is presently used/usable or not.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
942     */
943    public Account setStatusElement(Enumeration<AccountStatus> value) { 
944      this.status = value;
945      return this;
946    }
947
948    /**
949     * @return Indicates whether the account is presently used/usable or not.
950     */
951    public AccountStatus getStatus() { 
952      return this.status == null ? null : this.status.getValue();
953    }
954
955    /**
956     * @param value Indicates whether the account is presently used/usable or not.
957     */
958    public Account setStatus(AccountStatus value) { 
959        if (this.status == null)
960          this.status = new Enumeration<AccountStatus>(new AccountStatusEnumFactory());
961        this.status.setValue(value);
962      return this;
963    }
964
965    /**
966     * @return {@link #type} (Categorizes the account for reporting and searching purposes.)
967     */
968    public CodeableConcept getType() { 
969      if (this.type == null)
970        if (Configuration.errorOnAutoCreate())
971          throw new Error("Attempt to auto-create Account.type");
972        else if (Configuration.doAutoCreate())
973          this.type = new CodeableConcept(); // cc
974      return this.type;
975    }
976
977    public boolean hasType() { 
978      return this.type != null && !this.type.isEmpty();
979    }
980
981    /**
982     * @param value {@link #type} (Categorizes the account for reporting and searching purposes.)
983     */
984    public Account setType(CodeableConcept value) { 
985      this.type = value;
986      return this;
987    }
988
989    /**
990     * @return {@link #name} (Name used for the account when displaying it to humans in reports, etc.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
991     */
992    public StringType getNameElement() { 
993      if (this.name == null)
994        if (Configuration.errorOnAutoCreate())
995          throw new Error("Attempt to auto-create Account.name");
996        else if (Configuration.doAutoCreate())
997          this.name = new StringType(); // bb
998      return this.name;
999    }
1000
1001    public boolean hasNameElement() { 
1002      return this.name != null && !this.name.isEmpty();
1003    }
1004
1005    public boolean hasName() { 
1006      return this.name != null && !this.name.isEmpty();
1007    }
1008
1009    /**
1010     * @param value {@link #name} (Name used for the account when displaying it to humans in reports, etc.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
1011     */
1012    public Account setNameElement(StringType value) { 
1013      this.name = value;
1014      return this;
1015    }
1016
1017    /**
1018     * @return Name used for the account when displaying it to humans in reports, etc.
1019     */
1020    public String getName() { 
1021      return this.name == null ? null : this.name.getValue();
1022    }
1023
1024    /**
1025     * @param value Name used for the account when displaying it to humans in reports, etc.
1026     */
1027    public Account setName(String value) { 
1028      if (Utilities.noString(value))
1029        this.name = null;
1030      else {
1031        if (this.name == null)
1032          this.name = new StringType();
1033        this.name.setValue(value);
1034      }
1035      return this;
1036    }
1037
1038    /**
1039     * @return {@link #subject} (Identifies the entity which incurs the expenses. While the immediate recipients of services or goods might be entities related to the subject, the expenses were ultimately incurred by the subject of the Account.)
1040     */
1041    public List<Reference> getSubject() { 
1042      if (this.subject == null)
1043        this.subject = new ArrayList<Reference>();
1044      return this.subject;
1045    }
1046
1047    /**
1048     * @return Returns a reference to <code>this</code> for easy method chaining
1049     */
1050    public Account setSubject(List<Reference> theSubject) { 
1051      this.subject = theSubject;
1052      return this;
1053    }
1054
1055    public boolean hasSubject() { 
1056      if (this.subject == null)
1057        return false;
1058      for (Reference item : this.subject)
1059        if (!item.isEmpty())
1060          return true;
1061      return false;
1062    }
1063
1064    public Reference addSubject() { //3
1065      Reference t = new Reference();
1066      if (this.subject == null)
1067        this.subject = new ArrayList<Reference>();
1068      this.subject.add(t);
1069      return t;
1070    }
1071
1072    public Account addSubject(Reference t) { //3
1073      if (t == null)
1074        return this;
1075      if (this.subject == null)
1076        this.subject = new ArrayList<Reference>();
1077      this.subject.add(t);
1078      return this;
1079    }
1080
1081    /**
1082     * @return The first repetition of repeating field {@link #subject}, creating it if it does not already exist
1083     */
1084    public Reference getSubjectFirstRep() { 
1085      if (getSubject().isEmpty()) {
1086        addSubject();
1087      }
1088      return getSubject().get(0);
1089    }
1090
1091    /**
1092     * @deprecated Use Reference#setResource(IBaseResource) instead
1093     */
1094    @Deprecated
1095    public List<Resource> getSubjectTarget() { 
1096      if (this.subjectTarget == null)
1097        this.subjectTarget = new ArrayList<Resource>();
1098      return this.subjectTarget;
1099    }
1100
1101    /**
1102     * @return {@link #servicePeriod} (The date range of services associated with this account.)
1103     */
1104    public Period getServicePeriod() { 
1105      if (this.servicePeriod == null)
1106        if (Configuration.errorOnAutoCreate())
1107          throw new Error("Attempt to auto-create Account.servicePeriod");
1108        else if (Configuration.doAutoCreate())
1109          this.servicePeriod = new Period(); // cc
1110      return this.servicePeriod;
1111    }
1112
1113    public boolean hasServicePeriod() { 
1114      return this.servicePeriod != null && !this.servicePeriod.isEmpty();
1115    }
1116
1117    /**
1118     * @param value {@link #servicePeriod} (The date range of services associated with this account.)
1119     */
1120    public Account setServicePeriod(Period value) { 
1121      this.servicePeriod = value;
1122      return this;
1123    }
1124
1125    /**
1126     * @return {@link #coverage} (The party(s) that are responsible for covering the payment of this account, and what order should they be applied to the account.)
1127     */
1128    public List<CoverageComponent> getCoverage() { 
1129      if (this.coverage == null)
1130        this.coverage = new ArrayList<CoverageComponent>();
1131      return this.coverage;
1132    }
1133
1134    /**
1135     * @return Returns a reference to <code>this</code> for easy method chaining
1136     */
1137    public Account setCoverage(List<CoverageComponent> theCoverage) { 
1138      this.coverage = theCoverage;
1139      return this;
1140    }
1141
1142    public boolean hasCoverage() { 
1143      if (this.coverage == null)
1144        return false;
1145      for (CoverageComponent item : this.coverage)
1146        if (!item.isEmpty())
1147          return true;
1148      return false;
1149    }
1150
1151    public CoverageComponent addCoverage() { //3
1152      CoverageComponent t = new CoverageComponent();
1153      if (this.coverage == null)
1154        this.coverage = new ArrayList<CoverageComponent>();
1155      this.coverage.add(t);
1156      return t;
1157    }
1158
1159    public Account addCoverage(CoverageComponent t) { //3
1160      if (t == null)
1161        return this;
1162      if (this.coverage == null)
1163        this.coverage = new ArrayList<CoverageComponent>();
1164      this.coverage.add(t);
1165      return this;
1166    }
1167
1168    /**
1169     * @return The first repetition of repeating field {@link #coverage}, creating it if it does not already exist
1170     */
1171    public CoverageComponent getCoverageFirstRep() { 
1172      if (getCoverage().isEmpty()) {
1173        addCoverage();
1174      }
1175      return getCoverage().get(0);
1176    }
1177
1178    /**
1179     * @return {@link #owner} (Indicates the service area, hospital, department, etc. with responsibility for managing the Account.)
1180     */
1181    public Reference getOwner() { 
1182      if (this.owner == null)
1183        if (Configuration.errorOnAutoCreate())
1184          throw new Error("Attempt to auto-create Account.owner");
1185        else if (Configuration.doAutoCreate())
1186          this.owner = new Reference(); // cc
1187      return this.owner;
1188    }
1189
1190    public boolean hasOwner() { 
1191      return this.owner != null && !this.owner.isEmpty();
1192    }
1193
1194    /**
1195     * @param value {@link #owner} (Indicates the service area, hospital, department, etc. with responsibility for managing the Account.)
1196     */
1197    public Account setOwner(Reference value) { 
1198      this.owner = value;
1199      return this;
1200    }
1201
1202    /**
1203     * @return {@link #owner} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Indicates the service area, hospital, department, etc. with responsibility for managing the Account.)
1204     */
1205    public Organization getOwnerTarget() { 
1206      if (this.ownerTarget == null)
1207        if (Configuration.errorOnAutoCreate())
1208          throw new Error("Attempt to auto-create Account.owner");
1209        else if (Configuration.doAutoCreate())
1210          this.ownerTarget = new Organization(); // aa
1211      return this.ownerTarget;
1212    }
1213
1214    /**
1215     * @param value {@link #owner} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Indicates the service area, hospital, department, etc. with responsibility for managing the Account.)
1216     */
1217    public Account setOwnerTarget(Organization value) { 
1218      this.ownerTarget = value;
1219      return this;
1220    }
1221
1222    /**
1223     * @return {@link #description} (Provides additional information about what the account tracks and how it is used.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
1224     */
1225    public StringType getDescriptionElement() { 
1226      if (this.description == null)
1227        if (Configuration.errorOnAutoCreate())
1228          throw new Error("Attempt to auto-create Account.description");
1229        else if (Configuration.doAutoCreate())
1230          this.description = new StringType(); // bb
1231      return this.description;
1232    }
1233
1234    public boolean hasDescriptionElement() { 
1235      return this.description != null && !this.description.isEmpty();
1236    }
1237
1238    public boolean hasDescription() { 
1239      return this.description != null && !this.description.isEmpty();
1240    }
1241
1242    /**
1243     * @param value {@link #description} (Provides additional information about what the account tracks and how it is used.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
1244     */
1245    public Account setDescriptionElement(StringType value) { 
1246      this.description = value;
1247      return this;
1248    }
1249
1250    /**
1251     * @return Provides additional information about what the account tracks and how it is used.
1252     */
1253    public String getDescription() { 
1254      return this.description == null ? null : this.description.getValue();
1255    }
1256
1257    /**
1258     * @param value Provides additional information about what the account tracks and how it is used.
1259     */
1260    public Account setDescription(String value) { 
1261      if (Utilities.noString(value))
1262        this.description = null;
1263      else {
1264        if (this.description == null)
1265          this.description = new StringType();
1266        this.description.setValue(value);
1267      }
1268      return this;
1269    }
1270
1271    /**
1272     * @return {@link #guarantor} (The parties responsible for balancing the account if other payment options fall short.)
1273     */
1274    public List<GuarantorComponent> getGuarantor() { 
1275      if (this.guarantor == null)
1276        this.guarantor = new ArrayList<GuarantorComponent>();
1277      return this.guarantor;
1278    }
1279
1280    /**
1281     * @return Returns a reference to <code>this</code> for easy method chaining
1282     */
1283    public Account setGuarantor(List<GuarantorComponent> theGuarantor) { 
1284      this.guarantor = theGuarantor;
1285      return this;
1286    }
1287
1288    public boolean hasGuarantor() { 
1289      if (this.guarantor == null)
1290        return false;
1291      for (GuarantorComponent item : this.guarantor)
1292        if (!item.isEmpty())
1293          return true;
1294      return false;
1295    }
1296
1297    public GuarantorComponent addGuarantor() { //3
1298      GuarantorComponent t = new GuarantorComponent();
1299      if (this.guarantor == null)
1300        this.guarantor = new ArrayList<GuarantorComponent>();
1301      this.guarantor.add(t);
1302      return t;
1303    }
1304
1305    public Account addGuarantor(GuarantorComponent t) { //3
1306      if (t == null)
1307        return this;
1308      if (this.guarantor == null)
1309        this.guarantor = new ArrayList<GuarantorComponent>();
1310      this.guarantor.add(t);
1311      return this;
1312    }
1313
1314    /**
1315     * @return The first repetition of repeating field {@link #guarantor}, creating it if it does not already exist
1316     */
1317    public GuarantorComponent getGuarantorFirstRep() { 
1318      if (getGuarantor().isEmpty()) {
1319        addGuarantor();
1320      }
1321      return getGuarantor().get(0);
1322    }
1323
1324    /**
1325     * @return {@link #partOf} (Reference to a parent Account.)
1326     */
1327    public Reference getPartOf() { 
1328      if (this.partOf == null)
1329        if (Configuration.errorOnAutoCreate())
1330          throw new Error("Attempt to auto-create Account.partOf");
1331        else if (Configuration.doAutoCreate())
1332          this.partOf = new Reference(); // cc
1333      return this.partOf;
1334    }
1335
1336    public boolean hasPartOf() { 
1337      return this.partOf != null && !this.partOf.isEmpty();
1338    }
1339
1340    /**
1341     * @param value {@link #partOf} (Reference to a parent Account.)
1342     */
1343    public Account setPartOf(Reference value) { 
1344      this.partOf = value;
1345      return this;
1346    }
1347
1348    /**
1349     * @return {@link #partOf} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Reference to a parent Account.)
1350     */
1351    public Account getPartOfTarget() { 
1352      if (this.partOfTarget == null)
1353        if (Configuration.errorOnAutoCreate())
1354          throw new Error("Attempt to auto-create Account.partOf");
1355        else if (Configuration.doAutoCreate())
1356          this.partOfTarget = new Account(); // aa
1357      return this.partOfTarget;
1358    }
1359
1360    /**
1361     * @param value {@link #partOf} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Reference to a parent Account.)
1362     */
1363    public Account setPartOfTarget(Account value) { 
1364      this.partOfTarget = value;
1365      return this;
1366    }
1367
1368      protected void listChildren(List<Property> children) {
1369        super.listChildren(children);
1370        children.add(new Property("identifier", "Identifier", "Unique identifier used to reference the account.  Might or might not be intended for human use (e.g. credit card number).", 0, java.lang.Integer.MAX_VALUE, identifier));
1371        children.add(new Property("status", "code", "Indicates whether the account is presently used/usable or not.", 0, 1, status));
1372        children.add(new Property("type", "CodeableConcept", "Categorizes the account for reporting and searching purposes.", 0, 1, type));
1373        children.add(new Property("name", "string", "Name used for the account when displaying it to humans in reports, etc.", 0, 1, name));
1374        children.add(new Property("subject", "Reference(Patient|Device|Practitioner|PractitionerRole|Location|HealthcareService|Organization)", "Identifies the entity which incurs the expenses. While the immediate recipients of services or goods might be entities related to the subject, the expenses were ultimately incurred by the subject of the Account.", 0, java.lang.Integer.MAX_VALUE, subject));
1375        children.add(new Property("servicePeriod", "Period", "The date range of services associated with this account.", 0, 1, servicePeriod));
1376        children.add(new Property("coverage", "", "The party(s) that are responsible for covering the payment of this account, and what order should they be applied to the account.", 0, java.lang.Integer.MAX_VALUE, coverage));
1377        children.add(new Property("owner", "Reference(Organization)", "Indicates the service area, hospital, department, etc. with responsibility for managing the Account.", 0, 1, owner));
1378        children.add(new Property("description", "string", "Provides additional information about what the account tracks and how it is used.", 0, 1, description));
1379        children.add(new Property("guarantor", "", "The parties responsible for balancing the account if other payment options fall short.", 0, java.lang.Integer.MAX_VALUE, guarantor));
1380        children.add(new Property("partOf", "Reference(Account)", "Reference to a parent Account.", 0, 1, partOf));
1381      }
1382
1383      @Override
1384      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1385        switch (_hash) {
1386        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Unique identifier used to reference the account.  Might or might not be intended for human use (e.g. credit card number).", 0, java.lang.Integer.MAX_VALUE, identifier);
1387        case -892481550: /*status*/  return new Property("status", "code", "Indicates whether the account is presently used/usable or not.", 0, 1, status);
1388        case 3575610: /*type*/  return new Property("type", "CodeableConcept", "Categorizes the account for reporting and searching purposes.", 0, 1, type);
1389        case 3373707: /*name*/  return new Property("name", "string", "Name used for the account when displaying it to humans in reports, etc.", 0, 1, name);
1390        case -1867885268: /*subject*/  return new Property("subject", "Reference(Patient|Device|Practitioner|PractitionerRole|Location|HealthcareService|Organization)", "Identifies the entity which incurs the expenses. While the immediate recipients of services or goods might be entities related to the subject, the expenses were ultimately incurred by the subject of the Account.", 0, java.lang.Integer.MAX_VALUE, subject);
1391        case 2129104086: /*servicePeriod*/  return new Property("servicePeriod", "Period", "The date range of services associated with this account.", 0, 1, servicePeriod);
1392        case -351767064: /*coverage*/  return new Property("coverage", "", "The party(s) that are responsible for covering the payment of this account, and what order should they be applied to the account.", 0, java.lang.Integer.MAX_VALUE, coverage);
1393        case 106164915: /*owner*/  return new Property("owner", "Reference(Organization)", "Indicates the service area, hospital, department, etc. with responsibility for managing the Account.", 0, 1, owner);
1394        case -1724546052: /*description*/  return new Property("description", "string", "Provides additional information about what the account tracks and how it is used.", 0, 1, description);
1395        case -188629045: /*guarantor*/  return new Property("guarantor", "", "The parties responsible for balancing the account if other payment options fall short.", 0, java.lang.Integer.MAX_VALUE, guarantor);
1396        case -995410646: /*partOf*/  return new Property("partOf", "Reference(Account)", "Reference to a parent Account.", 0, 1, partOf);
1397        default: return super.getNamedProperty(_hash, _name, _checkValid);
1398        }
1399
1400      }
1401
1402      @Override
1403      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1404        switch (hash) {
1405        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1406        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<AccountStatus>
1407        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
1408        case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // StringType
1409        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : this.subject.toArray(new Base[this.subject.size()]); // Reference
1410        case 2129104086: /*servicePeriod*/ return this.servicePeriod == null ? new Base[0] : new Base[] {this.servicePeriod}; // Period
1411        case -351767064: /*coverage*/ return this.coverage == null ? new Base[0] : this.coverage.toArray(new Base[this.coverage.size()]); // CoverageComponent
1412        case 106164915: /*owner*/ return this.owner == null ? new Base[0] : new Base[] {this.owner}; // Reference
1413        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
1414        case -188629045: /*guarantor*/ return this.guarantor == null ? new Base[0] : this.guarantor.toArray(new Base[this.guarantor.size()]); // GuarantorComponent
1415        case -995410646: /*partOf*/ return this.partOf == null ? new Base[0] : new Base[] {this.partOf}; // Reference
1416        default: return super.getProperty(hash, name, checkValid);
1417        }
1418
1419      }
1420
1421      @Override
1422      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1423        switch (hash) {
1424        case -1618432855: // identifier
1425          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1426          return value;
1427        case -892481550: // status
1428          value = new AccountStatusEnumFactory().fromType(castToCode(value));
1429          this.status = (Enumeration) value; // Enumeration<AccountStatus>
1430          return value;
1431        case 3575610: // type
1432          this.type = castToCodeableConcept(value); // CodeableConcept
1433          return value;
1434        case 3373707: // name
1435          this.name = castToString(value); // StringType
1436          return value;
1437        case -1867885268: // subject
1438          this.getSubject().add(castToReference(value)); // Reference
1439          return value;
1440        case 2129104086: // servicePeriod
1441          this.servicePeriod = castToPeriod(value); // Period
1442          return value;
1443        case -351767064: // coverage
1444          this.getCoverage().add((CoverageComponent) value); // CoverageComponent
1445          return value;
1446        case 106164915: // owner
1447          this.owner = castToReference(value); // Reference
1448          return value;
1449        case -1724546052: // description
1450          this.description = castToString(value); // StringType
1451          return value;
1452        case -188629045: // guarantor
1453          this.getGuarantor().add((GuarantorComponent) value); // GuarantorComponent
1454          return value;
1455        case -995410646: // partOf
1456          this.partOf = castToReference(value); // Reference
1457          return value;
1458        default: return super.setProperty(hash, name, value);
1459        }
1460
1461      }
1462
1463      @Override
1464      public Base setProperty(String name, Base value) throws FHIRException {
1465        if (name.equals("identifier")) {
1466          this.getIdentifier().add(castToIdentifier(value));
1467        } else if (name.equals("status")) {
1468          value = new AccountStatusEnumFactory().fromType(castToCode(value));
1469          this.status = (Enumeration) value; // Enumeration<AccountStatus>
1470        } else if (name.equals("type")) {
1471          this.type = castToCodeableConcept(value); // CodeableConcept
1472        } else if (name.equals("name")) {
1473          this.name = castToString(value); // StringType
1474        } else if (name.equals("subject")) {
1475          this.getSubject().add(castToReference(value));
1476        } else if (name.equals("servicePeriod")) {
1477          this.servicePeriod = castToPeriod(value); // Period
1478        } else if (name.equals("coverage")) {
1479          this.getCoverage().add((CoverageComponent) value);
1480        } else if (name.equals("owner")) {
1481          this.owner = castToReference(value); // Reference
1482        } else if (name.equals("description")) {
1483          this.description = castToString(value); // StringType
1484        } else if (name.equals("guarantor")) {
1485          this.getGuarantor().add((GuarantorComponent) value);
1486        } else if (name.equals("partOf")) {
1487          this.partOf = castToReference(value); // Reference
1488        } else
1489          return super.setProperty(name, value);
1490        return value;
1491      }
1492
1493      @Override
1494      public Base makeProperty(int hash, String name) throws FHIRException {
1495        switch (hash) {
1496        case -1618432855:  return addIdentifier(); 
1497        case -892481550:  return getStatusElement();
1498        case 3575610:  return getType(); 
1499        case 3373707:  return getNameElement();
1500        case -1867885268:  return addSubject(); 
1501        case 2129104086:  return getServicePeriod(); 
1502        case -351767064:  return addCoverage(); 
1503        case 106164915:  return getOwner(); 
1504        case -1724546052:  return getDescriptionElement();
1505        case -188629045:  return addGuarantor(); 
1506        case -995410646:  return getPartOf(); 
1507        default: return super.makeProperty(hash, name);
1508        }
1509
1510      }
1511
1512      @Override
1513      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1514        switch (hash) {
1515        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1516        case -892481550: /*status*/ return new String[] {"code"};
1517        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1518        case 3373707: /*name*/ return new String[] {"string"};
1519        case -1867885268: /*subject*/ return new String[] {"Reference"};
1520        case 2129104086: /*servicePeriod*/ return new String[] {"Period"};
1521        case -351767064: /*coverage*/ return new String[] {};
1522        case 106164915: /*owner*/ return new String[] {"Reference"};
1523        case -1724546052: /*description*/ return new String[] {"string"};
1524        case -188629045: /*guarantor*/ return new String[] {};
1525        case -995410646: /*partOf*/ return new String[] {"Reference"};
1526        default: return super.getTypesForProperty(hash, name);
1527        }
1528
1529      }
1530
1531      @Override
1532      public Base addChild(String name) throws FHIRException {
1533        if (name.equals("identifier")) {
1534          return addIdentifier();
1535        }
1536        else if (name.equals("status")) {
1537          throw new FHIRException("Cannot call addChild on a primitive type Account.status");
1538        }
1539        else if (name.equals("type")) {
1540          this.type = new CodeableConcept();
1541          return this.type;
1542        }
1543        else if (name.equals("name")) {
1544          throw new FHIRException("Cannot call addChild on a primitive type Account.name");
1545        }
1546        else if (name.equals("subject")) {
1547          return addSubject();
1548        }
1549        else if (name.equals("servicePeriod")) {
1550          this.servicePeriod = new Period();
1551          return this.servicePeriod;
1552        }
1553        else if (name.equals("coverage")) {
1554          return addCoverage();
1555        }
1556        else if (name.equals("owner")) {
1557          this.owner = new Reference();
1558          return this.owner;
1559        }
1560        else if (name.equals("description")) {
1561          throw new FHIRException("Cannot call addChild on a primitive type Account.description");
1562        }
1563        else if (name.equals("guarantor")) {
1564          return addGuarantor();
1565        }
1566        else if (name.equals("partOf")) {
1567          this.partOf = new Reference();
1568          return this.partOf;
1569        }
1570        else
1571          return super.addChild(name);
1572      }
1573
1574  public String fhirType() {
1575    return "Account";
1576
1577  }
1578
1579      public Account copy() {
1580        Account dst = new Account();
1581        copyValues(dst);
1582        return dst;
1583      }
1584
1585      public void copyValues(Account dst) {
1586        super.copyValues(dst);
1587        if (identifier != null) {
1588          dst.identifier = new ArrayList<Identifier>();
1589          for (Identifier i : identifier)
1590            dst.identifier.add(i.copy());
1591        };
1592        dst.status = status == null ? null : status.copy();
1593        dst.type = type == null ? null : type.copy();
1594        dst.name = name == null ? null : name.copy();
1595        if (subject != null) {
1596          dst.subject = new ArrayList<Reference>();
1597          for (Reference i : subject)
1598            dst.subject.add(i.copy());
1599        };
1600        dst.servicePeriod = servicePeriod == null ? null : servicePeriod.copy();
1601        if (coverage != null) {
1602          dst.coverage = new ArrayList<CoverageComponent>();
1603          for (CoverageComponent i : coverage)
1604            dst.coverage.add(i.copy());
1605        };
1606        dst.owner = owner == null ? null : owner.copy();
1607        dst.description = description == null ? null : description.copy();
1608        if (guarantor != null) {
1609          dst.guarantor = new ArrayList<GuarantorComponent>();
1610          for (GuarantorComponent i : guarantor)
1611            dst.guarantor.add(i.copy());
1612        };
1613        dst.partOf = partOf == null ? null : partOf.copy();
1614      }
1615
1616      protected Account typedCopy() {
1617        return copy();
1618      }
1619
1620      @Override
1621      public boolean equalsDeep(Base other_) {
1622        if (!super.equalsDeep(other_))
1623          return false;
1624        if (!(other_ instanceof Account))
1625          return false;
1626        Account o = (Account) other_;
1627        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(type, o.type, true)
1628           && compareDeep(name, o.name, true) && compareDeep(subject, o.subject, true) && compareDeep(servicePeriod, o.servicePeriod, true)
1629           && compareDeep(coverage, o.coverage, true) && compareDeep(owner, o.owner, true) && compareDeep(description, o.description, true)
1630           && compareDeep(guarantor, o.guarantor, true) && compareDeep(partOf, o.partOf, true);
1631      }
1632
1633      @Override
1634      public boolean equalsShallow(Base other_) {
1635        if (!super.equalsShallow(other_))
1636          return false;
1637        if (!(other_ instanceof Account))
1638          return false;
1639        Account o = (Account) other_;
1640        return compareValues(status, o.status, true) && compareValues(name, o.name, true) && compareValues(description, o.description, true)
1641          ;
1642      }
1643
1644      public boolean isEmpty() {
1645        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, type
1646          , name, subject, servicePeriod, coverage, owner, description, guarantor, partOf
1647          );
1648      }
1649
1650  @Override
1651  public ResourceType getResourceType() {
1652    return ResourceType.Account;
1653   }
1654
1655 /**
1656   * Search parameter: <b>owner</b>
1657   * <p>
1658   * Description: <b>Entity managing the Account</b><br>
1659   * Type: <b>reference</b><br>
1660   * Path: <b>Account.owner</b><br>
1661   * </p>
1662   */
1663  @SearchParamDefinition(name="owner", path="Account.owner", description="Entity managing the Account", type="reference", target={Organization.class } )
1664  public static final String SP_OWNER = "owner";
1665 /**
1666   * <b>Fluent Client</b> search parameter constant for <b>owner</b>
1667   * <p>
1668   * Description: <b>Entity managing the Account</b><br>
1669   * Type: <b>reference</b><br>
1670   * Path: <b>Account.owner</b><br>
1671   * </p>
1672   */
1673  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam OWNER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_OWNER);
1674
1675/**
1676   * Constant for fluent queries to be used to add include statements. Specifies
1677   * the path value of "<b>Account:owner</b>".
1678   */
1679  public static final ca.uhn.fhir.model.api.Include INCLUDE_OWNER = new ca.uhn.fhir.model.api.Include("Account:owner").toLocked();
1680
1681 /**
1682   * Search parameter: <b>identifier</b>
1683   * <p>
1684   * Description: <b>Account number</b><br>
1685   * Type: <b>token</b><br>
1686   * Path: <b>Account.identifier</b><br>
1687   * </p>
1688   */
1689  @SearchParamDefinition(name="identifier", path="Account.identifier", description="Account number", type="token" )
1690  public static final String SP_IDENTIFIER = "identifier";
1691 /**
1692   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1693   * <p>
1694   * Description: <b>Account number</b><br>
1695   * Type: <b>token</b><br>
1696   * Path: <b>Account.identifier</b><br>
1697   * </p>
1698   */
1699  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
1700
1701 /**
1702   * Search parameter: <b>period</b>
1703   * <p>
1704   * Description: <b>Transaction window</b><br>
1705   * Type: <b>date</b><br>
1706   * Path: <b>Account.servicePeriod</b><br>
1707   * </p>
1708   */
1709  @SearchParamDefinition(name="period", path="Account.servicePeriod", description="Transaction window", type="date" )
1710  public static final String SP_PERIOD = "period";
1711 /**
1712   * <b>Fluent Client</b> search parameter constant for <b>period</b>
1713   * <p>
1714   * Description: <b>Transaction window</b><br>
1715   * Type: <b>date</b><br>
1716   * Path: <b>Account.servicePeriod</b><br>
1717   * </p>
1718   */
1719  public static final ca.uhn.fhir.rest.gclient.DateClientParam PERIOD = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_PERIOD);
1720
1721 /**
1722   * Search parameter: <b>subject</b>
1723   * <p>
1724   * Description: <b>The entity that caused the expenses</b><br>
1725   * Type: <b>reference</b><br>
1726   * Path: <b>Account.subject</b><br>
1727   * </p>
1728   */
1729  @SearchParamDefinition(name="subject", path="Account.subject", description="The entity that caused the expenses", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Device"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={Device.class, HealthcareService.class, Location.class, Organization.class, Patient.class, Practitioner.class, PractitionerRole.class } )
1730  public static final String SP_SUBJECT = "subject";
1731 /**
1732   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
1733   * <p>
1734   * Description: <b>The entity that caused the expenses</b><br>
1735   * Type: <b>reference</b><br>
1736   * Path: <b>Account.subject</b><br>
1737   * </p>
1738   */
1739  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
1740
1741/**
1742   * Constant for fluent queries to be used to add include statements. Specifies
1743   * the path value of "<b>Account:subject</b>".
1744   */
1745  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("Account:subject").toLocked();
1746
1747 /**
1748   * Search parameter: <b>patient</b>
1749   * <p>
1750   * Description: <b>The entity that caused the expenses</b><br>
1751   * Type: <b>reference</b><br>
1752   * Path: <b>Account.subject</b><br>
1753   * </p>
1754   */
1755  @SearchParamDefinition(name="patient", path="Account.subject.where(resolve() is Patient)", description="The entity that caused the expenses", type="reference", target={Patient.class } )
1756  public static final String SP_PATIENT = "patient";
1757 /**
1758   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
1759   * <p>
1760   * Description: <b>The entity that caused the expenses</b><br>
1761   * Type: <b>reference</b><br>
1762   * Path: <b>Account.subject</b><br>
1763   * </p>
1764   */
1765  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
1766
1767/**
1768   * Constant for fluent queries to be used to add include statements. Specifies
1769   * the path value of "<b>Account:patient</b>".
1770   */
1771  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("Account:patient").toLocked();
1772
1773 /**
1774   * Search parameter: <b>name</b>
1775   * <p>
1776   * Description: <b>Human-readable label</b><br>
1777   * Type: <b>string</b><br>
1778   * Path: <b>Account.name</b><br>
1779   * </p>
1780   */
1781  @SearchParamDefinition(name="name", path="Account.name", description="Human-readable label", type="string" )
1782  public static final String SP_NAME = "name";
1783 /**
1784   * <b>Fluent Client</b> search parameter constant for <b>name</b>
1785   * <p>
1786   * Description: <b>Human-readable label</b><br>
1787   * Type: <b>string</b><br>
1788   * Path: <b>Account.name</b><br>
1789   * </p>
1790   */
1791  public static final ca.uhn.fhir.rest.gclient.StringClientParam NAME = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_NAME);
1792
1793 /**
1794   * Search parameter: <b>type</b>
1795   * <p>
1796   * Description: <b>E.g. patient, expense, depreciation</b><br>
1797   * Type: <b>token</b><br>
1798   * Path: <b>Account.type</b><br>
1799   * </p>
1800   */
1801  @SearchParamDefinition(name="type", path="Account.type", description="E.g. patient, expense, depreciation", type="token" )
1802  public static final String SP_TYPE = "type";
1803 /**
1804   * <b>Fluent Client</b> search parameter constant for <b>type</b>
1805   * <p>
1806   * Description: <b>E.g. patient, expense, depreciation</b><br>
1807   * Type: <b>token</b><br>
1808   * Path: <b>Account.type</b><br>
1809   * </p>
1810   */
1811  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
1812
1813 /**
1814   * Search parameter: <b>status</b>
1815   * <p>
1816   * Description: <b>active | inactive | entered-in-error | on-hold | unknown</b><br>
1817   * Type: <b>token</b><br>
1818   * Path: <b>Account.status</b><br>
1819   * </p>
1820   */
1821  @SearchParamDefinition(name="status", path="Account.status", description="active | inactive | entered-in-error | on-hold | unknown", type="token" )
1822  public static final String SP_STATUS = "status";
1823 /**
1824   * <b>Fluent Client</b> search parameter constant for <b>status</b>
1825   * <p>
1826   * Description: <b>active | inactive | entered-in-error | on-hold | unknown</b><br>
1827   * Type: <b>token</b><br>
1828   * Path: <b>Account.status</b><br>
1829   * </p>
1830   */
1831  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
1832
1833
1834}