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