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