001package org.hl7.fhir.dstu2.model;
002
003/*-
004 * #%L
005 * org.hl7.fhir.dstu2
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
024import java.math.BigDecimal;
025
026/*
027  Copyright (c) 2011+, HL7, Inc.
028  All rights reserved.
029  
030  Redistribution and use in source and binary forms, with or without modification, 
031  are permitted provided that the following conditions are met:
032  
033   * Redistributions of source code must retain the above copyright notice, this 
034     list of conditions and the following disclaimer.
035   * Redistributions in binary form must reproduce the above copyright notice, 
036     this list of conditions and the following disclaimer in the documentation 
037     and/or other materials provided with the distribution.
038   * Neither the name of HL7 nor the names of its contributors may be used to 
039     endorse or promote products derived from this software without specific 
040     prior written permission.
041  
042  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
043  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
044  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
045  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
046  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
047  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
048  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
049  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
050  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
051  POSSIBILITY OF SUCH DAMAGE.
052  
053*/
054
055// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
056import java.util.ArrayList;
057import java.util.Date;
058import java.util.List;
059
060import ca.uhn.fhir.model.api.annotation.Block;
061import ca.uhn.fhir.model.api.annotation.Child;
062import ca.uhn.fhir.model.api.annotation.Description;
063import ca.uhn.fhir.model.api.annotation.ResourceDef;
064import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
065import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
066import org.hl7.fhir.exceptions.FHIRException;
067import org.hl7.fhir.utilities.Utilities;
068/**
069 * A formal agreement between parties regarding the conduct of business, exchange of information or other matters.
070 */
071@ResourceDef(name="Contract", profile="http://hl7.org/fhir/Profile/Contract")
072public class Contract extends DomainResource {
073
074    @Block()
075    public static class ActorComponent extends BackboneElement implements IBaseBackboneElement {
076        /**
077         * Who or what actors are assigned roles in this Contract.
078         */
079        @Child(name = "entity", type = {Contract.class, Device.class, Group.class, Location.class, Organization.class, Patient.class, Practitioner.class, RelatedPerson.class, Substance.class}, order=1, min=1, max=1, modifier=false, summary=false)
080        @Description(shortDefinition="Contract Actor Type", formalDefinition="Who or what actors are assigned roles in this Contract." )
081        protected Reference entity;
082
083        /**
084         * The actual object that is the target of the reference (Who or what actors are assigned roles in this Contract.)
085         */
086        protected Resource entityTarget;
087
088        /**
089         * Role type of actors assigned roles in this Contract.
090         */
091        @Child(name = "role", type = {CodeableConcept.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
092        @Description(shortDefinition="Contract  Actor Role", formalDefinition="Role type of actors assigned roles in this Contract." )
093        protected List<CodeableConcept> role;
094
095        private static final long serialVersionUID = 1371245689L;
096
097    /*
098     * Constructor
099     */
100      public ActorComponent() {
101        super();
102      }
103
104    /*
105     * Constructor
106     */
107      public ActorComponent(Reference entity) {
108        super();
109        this.entity = entity;
110      }
111
112        /**
113         * @return {@link #entity} (Who or what actors are assigned roles in this Contract.)
114         */
115        public Reference getEntity() { 
116          if (this.entity == null)
117            if (Configuration.errorOnAutoCreate())
118              throw new Error("Attempt to auto-create ActorComponent.entity");
119            else if (Configuration.doAutoCreate())
120              this.entity = new Reference(); // cc
121          return this.entity;
122        }
123
124        public boolean hasEntity() { 
125          return this.entity != null && !this.entity.isEmpty();
126        }
127
128        /**
129         * @param value {@link #entity} (Who or what actors are assigned roles in this Contract.)
130         */
131        public ActorComponent setEntity(Reference value) { 
132          this.entity = value;
133          return this;
134        }
135
136        /**
137         * @return {@link #entity} 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. (Who or what actors are assigned roles in this Contract.)
138         */
139        public Resource getEntityTarget() { 
140          return this.entityTarget;
141        }
142
143        /**
144         * @param value {@link #entity} 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. (Who or what actors are assigned roles in this Contract.)
145         */
146        public ActorComponent setEntityTarget(Resource value) { 
147          this.entityTarget = value;
148          return this;
149        }
150
151        /**
152         * @return {@link #role} (Role type of actors assigned roles in this Contract.)
153         */
154        public List<CodeableConcept> getRole() { 
155          if (this.role == null)
156            this.role = new ArrayList<CodeableConcept>();
157          return this.role;
158        }
159
160        public boolean hasRole() { 
161          if (this.role == null)
162            return false;
163          for (CodeableConcept item : this.role)
164            if (!item.isEmpty())
165              return true;
166          return false;
167        }
168
169        /**
170         * @return {@link #role} (Role type of actors assigned roles in this Contract.)
171         */
172    // syntactic sugar
173        public CodeableConcept addRole() { //3
174          CodeableConcept t = new CodeableConcept();
175          if (this.role == null)
176            this.role = new ArrayList<CodeableConcept>();
177          this.role.add(t);
178          return t;
179        }
180
181    // syntactic sugar
182        public ActorComponent addRole(CodeableConcept t) { //3
183          if (t == null)
184            return this;
185          if (this.role == null)
186            this.role = new ArrayList<CodeableConcept>();
187          this.role.add(t);
188          return this;
189        }
190
191        protected void listChildren(List<Property> childrenList) {
192          super.listChildren(childrenList);
193          childrenList.add(new Property("entity", "Reference(Contract|Device|Group|Location|Organization|Patient|Practitioner|RelatedPerson|Substance)", "Who or what actors are assigned roles in this Contract.", 0, java.lang.Integer.MAX_VALUE, entity));
194          childrenList.add(new Property("role", "CodeableConcept", "Role type of actors assigned roles in this Contract.", 0, java.lang.Integer.MAX_VALUE, role));
195        }
196
197      @Override
198      public void setProperty(String name, Base value) throws FHIRException {
199        if (name.equals("entity"))
200          this.entity = castToReference(value); // Reference
201        else if (name.equals("role"))
202          this.getRole().add(castToCodeableConcept(value));
203        else
204          super.setProperty(name, value);
205      }
206
207      @Override
208      public Base addChild(String name) throws FHIRException {
209        if (name.equals("entity")) {
210          this.entity = new Reference();
211          return this.entity;
212        }
213        else if (name.equals("role")) {
214          return addRole();
215        }
216        else
217          return super.addChild(name);
218      }
219
220      public ActorComponent copy() {
221        ActorComponent dst = new ActorComponent();
222        copyValues(dst);
223        dst.entity = entity == null ? null : entity.copy();
224        if (role != null) {
225          dst.role = new ArrayList<CodeableConcept>();
226          for (CodeableConcept i : role)
227            dst.role.add(i.copy());
228        };
229        return dst;
230      }
231
232      @Override
233      public boolean equalsDeep(Base other) {
234        if (!super.equalsDeep(other))
235          return false;
236        if (!(other instanceof ActorComponent))
237          return false;
238        ActorComponent o = (ActorComponent) other;
239        return compareDeep(entity, o.entity, true) && compareDeep(role, o.role, true);
240      }
241
242      @Override
243      public boolean equalsShallow(Base other) {
244        if (!super.equalsShallow(other))
245          return false;
246        if (!(other instanceof ActorComponent))
247          return false;
248        ActorComponent o = (ActorComponent) other;
249        return true;
250      }
251
252      public boolean isEmpty() {
253        return super.isEmpty() && (entity == null || entity.isEmpty()) && (role == null || role.isEmpty())
254          ;
255      }
256
257  public String fhirType() {
258    return "Contract.actor";
259
260  }
261
262  }
263
264    @Block()
265    public static class ValuedItemComponent extends BackboneElement implements IBaseBackboneElement {
266        /**
267         * Specific type of Contract Valued Item that may be priced.
268         */
269        @Child(name = "entity", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
270        @Description(shortDefinition="Contract Valued Item Type", formalDefinition="Specific type of Contract Valued Item that may be priced." )
271        protected Type entity;
272
273        /**
274         * Identifies a Contract Valued Item instance.
275         */
276        @Child(name = "identifier", type = {Identifier.class}, order=2, min=0, max=1, modifier=false, summary=false)
277        @Description(shortDefinition="Contract Valued Item Identifier", formalDefinition="Identifies a Contract Valued Item instance." )
278        protected Identifier identifier;
279
280        /**
281         * Indicates the time during which this Contract ValuedItem information is effective.
282         */
283        @Child(name = "effectiveTime", type = {DateTimeType.class}, order=3, min=0, max=1, modifier=false, summary=false)
284        @Description(shortDefinition="Contract Valued Item Effective Tiem", formalDefinition="Indicates the time during which this Contract ValuedItem information is effective." )
285        protected DateTimeType effectiveTime;
286
287        /**
288         * Specifies the units by which the Contract Valued Item is measured or counted, and quantifies the countable or measurable Contract Valued Item instances.
289         */
290        @Child(name = "quantity", type = {SimpleQuantity.class}, order=4, min=0, max=1, modifier=false, summary=false)
291        @Description(shortDefinition="Count of Contract Valued Items", formalDefinition="Specifies the units by which the Contract Valued Item is measured or counted, and quantifies the countable or measurable Contract Valued Item instances." )
292        protected SimpleQuantity quantity;
293
294        /**
295         * A Contract Valued Item unit valuation measure.
296         */
297        @Child(name = "unitPrice", type = {Money.class}, order=5, min=0, max=1, modifier=false, summary=false)
298        @Description(shortDefinition="Contract Valued Item fee, charge, or cost", formalDefinition="A Contract Valued Item unit valuation measure." )
299        protected Money unitPrice;
300
301        /**
302         * A real number that represents a multiplier used in determining the overall value of the Contract Valued Item delivered. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
303         */
304        @Child(name = "factor", type = {DecimalType.class}, order=6, min=0, max=1, modifier=false, summary=false)
305        @Description(shortDefinition="Contract Valued Item Price Scaling Factor", formalDefinition="A real number that represents a multiplier used in determining the overall value of the Contract Valued Item delivered. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount." )
306        protected DecimalType factor;
307
308        /**
309         * An amount that expresses the weighting (based on difficulty, cost and/or resource intensiveness) associated with the Contract Valued Item delivered. The concept of Points allows for assignment of point values for a Contract Valued Item, such that a monetary amount can be assigned to each point.
310         */
311        @Child(name = "points", type = {DecimalType.class}, order=7, min=0, max=1, modifier=false, summary=false)
312        @Description(shortDefinition="Contract Valued Item Difficulty Scaling Factor", formalDefinition="An amount that expresses the weighting (based on difficulty, cost and/or resource intensiveness) associated with the Contract Valued Item delivered. The concept of Points allows for assignment of point values for a Contract Valued Item, such that a monetary amount can be assigned to each point." )
313        protected DecimalType points;
314
315        /**
316         * Expresses the product of the Contract Valued Item unitQuantity and the unitPriceAmt. For example, the formula: unit Quantity * unit Price (Cost per Point) * factor Number  * points = net Amount. Quantity, factor and points are assumed to be 1 if not supplied.
317         */
318        @Child(name = "net", type = {Money.class}, order=8, min=0, max=1, modifier=false, summary=false)
319        @Description(shortDefinition="Total Contract Valued Item Value", formalDefinition="Expresses the product of the Contract Valued Item unitQuantity and the unitPriceAmt. For example, the formula: unit Quantity * unit Price (Cost per Point) * factor Number  * points = net Amount. Quantity, factor and points are assumed to be 1 if not supplied." )
320        protected Money net;
321
322        private static final long serialVersionUID = 1782449516L;
323
324    /*
325     * Constructor
326     */
327      public ValuedItemComponent() {
328        super();
329      }
330
331        /**
332         * @return {@link #entity} (Specific type of Contract Valued Item that may be priced.)
333         */
334        public Type getEntity() { 
335          return this.entity;
336        }
337
338        /**
339         * @return {@link #entity} (Specific type of Contract Valued Item that may be priced.)
340         */
341        public CodeableConcept getEntityCodeableConcept() throws FHIRException { 
342          if (!(this.entity instanceof CodeableConcept))
343            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.entity.getClass().getName()+" was encountered");
344          return (CodeableConcept) this.entity;
345        }
346
347        public boolean hasEntityCodeableConcept() { 
348          return this.entity instanceof CodeableConcept;
349        }
350
351        /**
352         * @return {@link #entity} (Specific type of Contract Valued Item that may be priced.)
353         */
354        public Reference getEntityReference() throws FHIRException { 
355          if (!(this.entity instanceof Reference))
356            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.entity.getClass().getName()+" was encountered");
357          return (Reference) this.entity;
358        }
359
360        public boolean hasEntityReference() { 
361          return this.entity instanceof Reference;
362        }
363
364        public boolean hasEntity() { 
365          return this.entity != null && !this.entity.isEmpty();
366        }
367
368        /**
369         * @param value {@link #entity} (Specific type of Contract Valued Item that may be priced.)
370         */
371        public ValuedItemComponent setEntity(Type value) { 
372          this.entity = value;
373          return this;
374        }
375
376        /**
377         * @return {@link #identifier} (Identifies a Contract Valued Item instance.)
378         */
379        public Identifier getIdentifier() { 
380          if (this.identifier == null)
381            if (Configuration.errorOnAutoCreate())
382              throw new Error("Attempt to auto-create ValuedItemComponent.identifier");
383            else if (Configuration.doAutoCreate())
384              this.identifier = new Identifier(); // cc
385          return this.identifier;
386        }
387
388        public boolean hasIdentifier() { 
389          return this.identifier != null && !this.identifier.isEmpty();
390        }
391
392        /**
393         * @param value {@link #identifier} (Identifies a Contract Valued Item instance.)
394         */
395        public ValuedItemComponent setIdentifier(Identifier value) { 
396          this.identifier = value;
397          return this;
398        }
399
400        /**
401         * @return {@link #effectiveTime} (Indicates the time during which this Contract ValuedItem information is effective.). This is the underlying object with id, value and extensions. The accessor "getEffectiveTime" gives direct access to the value
402         */
403        public DateTimeType getEffectiveTimeElement() { 
404          if (this.effectiveTime == null)
405            if (Configuration.errorOnAutoCreate())
406              throw new Error("Attempt to auto-create ValuedItemComponent.effectiveTime");
407            else if (Configuration.doAutoCreate())
408              this.effectiveTime = new DateTimeType(); // bb
409          return this.effectiveTime;
410        }
411
412        public boolean hasEffectiveTimeElement() { 
413          return this.effectiveTime != null && !this.effectiveTime.isEmpty();
414        }
415
416        public boolean hasEffectiveTime() { 
417          return this.effectiveTime != null && !this.effectiveTime.isEmpty();
418        }
419
420        /**
421         * @param value {@link #effectiveTime} (Indicates the time during which this Contract ValuedItem information is effective.). This is the underlying object with id, value and extensions. The accessor "getEffectiveTime" gives direct access to the value
422         */
423        public ValuedItemComponent setEffectiveTimeElement(DateTimeType value) { 
424          this.effectiveTime = value;
425          return this;
426        }
427
428        /**
429         * @return Indicates the time during which this Contract ValuedItem information is effective.
430         */
431        public Date getEffectiveTime() { 
432          return this.effectiveTime == null ? null : this.effectiveTime.getValue();
433        }
434
435        /**
436         * @param value Indicates the time during which this Contract ValuedItem information is effective.
437         */
438        public ValuedItemComponent setEffectiveTime(Date value) { 
439          if (value == null)
440            this.effectiveTime = null;
441          else {
442            if (this.effectiveTime == null)
443              this.effectiveTime = new DateTimeType();
444            this.effectiveTime.setValue(value);
445          }
446          return this;
447        }
448
449        /**
450         * @return {@link #quantity} (Specifies the units by which the Contract Valued Item is measured or counted, and quantifies the countable or measurable Contract Valued Item instances.)
451         */
452        public SimpleQuantity getQuantity() { 
453          if (this.quantity == null)
454            if (Configuration.errorOnAutoCreate())
455              throw new Error("Attempt to auto-create ValuedItemComponent.quantity");
456            else if (Configuration.doAutoCreate())
457              this.quantity = new SimpleQuantity(); // cc
458          return this.quantity;
459        }
460
461        public boolean hasQuantity() { 
462          return this.quantity != null && !this.quantity.isEmpty();
463        }
464
465        /**
466         * @param value {@link #quantity} (Specifies the units by which the Contract Valued Item is measured or counted, and quantifies the countable or measurable Contract Valued Item instances.)
467         */
468        public ValuedItemComponent setQuantity(SimpleQuantity value) { 
469          this.quantity = value;
470          return this;
471        }
472
473        /**
474         * @return {@link #unitPrice} (A Contract Valued Item unit valuation measure.)
475         */
476        public Money getUnitPrice() { 
477          if (this.unitPrice == null)
478            if (Configuration.errorOnAutoCreate())
479              throw new Error("Attempt to auto-create ValuedItemComponent.unitPrice");
480            else if (Configuration.doAutoCreate())
481              this.unitPrice = new Money(); // cc
482          return this.unitPrice;
483        }
484
485        public boolean hasUnitPrice() { 
486          return this.unitPrice != null && !this.unitPrice.isEmpty();
487        }
488
489        /**
490         * @param value {@link #unitPrice} (A Contract Valued Item unit valuation measure.)
491         */
492        public ValuedItemComponent setUnitPrice(Money value) { 
493          this.unitPrice = value;
494          return this;
495        }
496
497        /**
498         * @return {@link #factor} (A real number that represents a multiplier used in determining the overall value of the Contract Valued Item delivered. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.). This is the underlying object with id, value and extensions. The accessor "getFactor" gives direct access to the value
499         */
500        public DecimalType getFactorElement() { 
501          if (this.factor == null)
502            if (Configuration.errorOnAutoCreate())
503              throw new Error("Attempt to auto-create ValuedItemComponent.factor");
504            else if (Configuration.doAutoCreate())
505              this.factor = new DecimalType(); // bb
506          return this.factor;
507        }
508
509        public boolean hasFactorElement() { 
510          return this.factor != null && !this.factor.isEmpty();
511        }
512
513        public boolean hasFactor() { 
514          return this.factor != null && !this.factor.isEmpty();
515        }
516
517        /**
518         * @param value {@link #factor} (A real number that represents a multiplier used in determining the overall value of the Contract Valued Item delivered. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.). This is the underlying object with id, value and extensions. The accessor "getFactor" gives direct access to the value
519         */
520        public ValuedItemComponent setFactorElement(DecimalType value) { 
521          this.factor = value;
522          return this;
523        }
524
525        /**
526         * @return A real number that represents a multiplier used in determining the overall value of the Contract Valued Item delivered. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
527         */
528        public BigDecimal getFactor() { 
529          return this.factor == null ? null : this.factor.getValue();
530        }
531
532        /**
533         * @param value A real number that represents a multiplier used in determining the overall value of the Contract Valued Item delivered. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
534         */
535        public ValuedItemComponent setFactor(BigDecimal value) { 
536          if (value == null)
537            this.factor = null;
538          else {
539            if (this.factor == null)
540              this.factor = new DecimalType();
541            this.factor.setValue(value);
542          }
543          return this;
544        }
545
546        /**
547         * @return {@link #points} (An amount that expresses the weighting (based on difficulty, cost and/or resource intensiveness) associated with the Contract Valued Item delivered. The concept of Points allows for assignment of point values for a Contract Valued Item, such that a monetary amount can be assigned to each point.). This is the underlying object with id, value and extensions. The accessor "getPoints" gives direct access to the value
548         */
549        public DecimalType getPointsElement() { 
550          if (this.points == null)
551            if (Configuration.errorOnAutoCreate())
552              throw new Error("Attempt to auto-create ValuedItemComponent.points");
553            else if (Configuration.doAutoCreate())
554              this.points = new DecimalType(); // bb
555          return this.points;
556        }
557
558        public boolean hasPointsElement() { 
559          return this.points != null && !this.points.isEmpty();
560        }
561
562        public boolean hasPoints() { 
563          return this.points != null && !this.points.isEmpty();
564        }
565
566        /**
567         * @param value {@link #points} (An amount that expresses the weighting (based on difficulty, cost and/or resource intensiveness) associated with the Contract Valued Item delivered. The concept of Points allows for assignment of point values for a Contract Valued Item, such that a monetary amount can be assigned to each point.). This is the underlying object with id, value and extensions. The accessor "getPoints" gives direct access to the value
568         */
569        public ValuedItemComponent setPointsElement(DecimalType value) { 
570          this.points = value;
571          return this;
572        }
573
574        /**
575         * @return An amount that expresses the weighting (based on difficulty, cost and/or resource intensiveness) associated with the Contract Valued Item delivered. The concept of Points allows for assignment of point values for a Contract Valued Item, such that a monetary amount can be assigned to each point.
576         */
577        public BigDecimal getPoints() { 
578          return this.points == null ? null : this.points.getValue();
579        }
580
581        /**
582         * @param value An amount that expresses the weighting (based on difficulty, cost and/or resource intensiveness) associated with the Contract Valued Item delivered. The concept of Points allows for assignment of point values for a Contract Valued Item, such that a monetary amount can be assigned to each point.
583         */
584        public ValuedItemComponent setPoints(BigDecimal value) { 
585          if (value == null)
586            this.points = null;
587          else {
588            if (this.points == null)
589              this.points = new DecimalType();
590            this.points.setValue(value);
591          }
592          return this;
593        }
594
595        /**
596         * @return {@link #net} (Expresses the product of the Contract Valued Item unitQuantity and the unitPriceAmt. For example, the formula: unit Quantity * unit Price (Cost per Point) * factor Number  * points = net Amount. Quantity, factor and points are assumed to be 1 if not supplied.)
597         */
598        public Money getNet() { 
599          if (this.net == null)
600            if (Configuration.errorOnAutoCreate())
601              throw new Error("Attempt to auto-create ValuedItemComponent.net");
602            else if (Configuration.doAutoCreate())
603              this.net = new Money(); // cc
604          return this.net;
605        }
606
607        public boolean hasNet() { 
608          return this.net != null && !this.net.isEmpty();
609        }
610
611        /**
612         * @param value {@link #net} (Expresses the product of the Contract Valued Item unitQuantity and the unitPriceAmt. For example, the formula: unit Quantity * unit Price (Cost per Point) * factor Number  * points = net Amount. Quantity, factor and points are assumed to be 1 if not supplied.)
613         */
614        public ValuedItemComponent setNet(Money value) { 
615          this.net = value;
616          return this;
617        }
618
619        protected void listChildren(List<Property> childrenList) {
620          super.listChildren(childrenList);
621          childrenList.add(new Property("entity[x]", "CodeableConcept|Reference(Any)", "Specific type of Contract Valued Item that may be priced.", 0, java.lang.Integer.MAX_VALUE, entity));
622          childrenList.add(new Property("identifier", "Identifier", "Identifies a Contract Valued Item instance.", 0, java.lang.Integer.MAX_VALUE, identifier));
623          childrenList.add(new Property("effectiveTime", "dateTime", "Indicates the time during which this Contract ValuedItem information is effective.", 0, java.lang.Integer.MAX_VALUE, effectiveTime));
624          childrenList.add(new Property("quantity", "SimpleQuantity", "Specifies the units by which the Contract Valued Item is measured or counted, and quantifies the countable or measurable Contract Valued Item instances.", 0, java.lang.Integer.MAX_VALUE, quantity));
625          childrenList.add(new Property("unitPrice", "Money", "A Contract Valued Item unit valuation measure.", 0, java.lang.Integer.MAX_VALUE, unitPrice));
626          childrenList.add(new Property("factor", "decimal", "A real number that represents a multiplier used in determining the overall value of the Contract Valued Item delivered. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.", 0, java.lang.Integer.MAX_VALUE, factor));
627          childrenList.add(new Property("points", "decimal", "An amount that expresses the weighting (based on difficulty, cost and/or resource intensiveness) associated with the Contract Valued Item delivered. The concept of Points allows for assignment of point values for a Contract Valued Item, such that a monetary amount can be assigned to each point.", 0, java.lang.Integer.MAX_VALUE, points));
628          childrenList.add(new Property("net", "Money", "Expresses the product of the Contract Valued Item unitQuantity and the unitPriceAmt. For example, the formula: unit Quantity * unit Price (Cost per Point) * factor Number  * points = net Amount. Quantity, factor and points are assumed to be 1 if not supplied.", 0, java.lang.Integer.MAX_VALUE, net));
629        }
630
631      @Override
632      public void setProperty(String name, Base value) throws FHIRException {
633        if (name.equals("entity[x]"))
634          this.entity = (Type) value; // Type
635        else if (name.equals("identifier"))
636          this.identifier = castToIdentifier(value); // Identifier
637        else if (name.equals("effectiveTime"))
638          this.effectiveTime = castToDateTime(value); // DateTimeType
639        else if (name.equals("quantity"))
640          this.quantity = castToSimpleQuantity(value); // SimpleQuantity
641        else if (name.equals("unitPrice"))
642          this.unitPrice = castToMoney(value); // Money
643        else if (name.equals("factor"))
644          this.factor = castToDecimal(value); // DecimalType
645        else if (name.equals("points"))
646          this.points = castToDecimal(value); // DecimalType
647        else if (name.equals("net"))
648          this.net = castToMoney(value); // Money
649        else
650          super.setProperty(name, value);
651      }
652
653      @Override
654      public Base addChild(String name) throws FHIRException {
655        if (name.equals("entityCodeableConcept")) {
656          this.entity = new CodeableConcept();
657          return this.entity;
658        }
659        else if (name.equals("entityReference")) {
660          this.entity = new Reference();
661          return this.entity;
662        }
663        else if (name.equals("identifier")) {
664          this.identifier = new Identifier();
665          return this.identifier;
666        }
667        else if (name.equals("effectiveTime")) {
668          throw new FHIRException("Cannot call addChild on a primitive type Contract.effectiveTime");
669        }
670        else if (name.equals("quantity")) {
671          this.quantity = new SimpleQuantity();
672          return this.quantity;
673        }
674        else if (name.equals("unitPrice")) {
675          this.unitPrice = new Money();
676          return this.unitPrice;
677        }
678        else if (name.equals("factor")) {
679          throw new FHIRException("Cannot call addChild on a primitive type Contract.factor");
680        }
681        else if (name.equals("points")) {
682          throw new FHIRException("Cannot call addChild on a primitive type Contract.points");
683        }
684        else if (name.equals("net")) {
685          this.net = new Money();
686          return this.net;
687        }
688        else
689          return super.addChild(name);
690      }
691
692      public ValuedItemComponent copy() {
693        ValuedItemComponent dst = new ValuedItemComponent();
694        copyValues(dst);
695        dst.entity = entity == null ? null : entity.copy();
696        dst.identifier = identifier == null ? null : identifier.copy();
697        dst.effectiveTime = effectiveTime == null ? null : effectiveTime.copy();
698        dst.quantity = quantity == null ? null : quantity.copy();
699        dst.unitPrice = unitPrice == null ? null : unitPrice.copy();
700        dst.factor = factor == null ? null : factor.copy();
701        dst.points = points == null ? null : points.copy();
702        dst.net = net == null ? null : net.copy();
703        return dst;
704      }
705
706      @Override
707      public boolean equalsDeep(Base other) {
708        if (!super.equalsDeep(other))
709          return false;
710        if (!(other instanceof ValuedItemComponent))
711          return false;
712        ValuedItemComponent o = (ValuedItemComponent) other;
713        return compareDeep(entity, o.entity, true) && compareDeep(identifier, o.identifier, true) && compareDeep(effectiveTime, o.effectiveTime, true)
714           && compareDeep(quantity, o.quantity, true) && compareDeep(unitPrice, o.unitPrice, true) && compareDeep(factor, o.factor, true)
715           && compareDeep(points, o.points, true) && compareDeep(net, o.net, true);
716      }
717
718      @Override
719      public boolean equalsShallow(Base other) {
720        if (!super.equalsShallow(other))
721          return false;
722        if (!(other instanceof ValuedItemComponent))
723          return false;
724        ValuedItemComponent o = (ValuedItemComponent) other;
725        return compareValues(effectiveTime, o.effectiveTime, true) && compareValues(factor, o.factor, true)
726           && compareValues(points, o.points, true);
727      }
728
729      public boolean isEmpty() {
730        return super.isEmpty() && (entity == null || entity.isEmpty()) && (identifier == null || identifier.isEmpty())
731           && (effectiveTime == null || effectiveTime.isEmpty()) && (quantity == null || quantity.isEmpty())
732           && (unitPrice == null || unitPrice.isEmpty()) && (factor == null || factor.isEmpty()) && (points == null || points.isEmpty())
733           && (net == null || net.isEmpty());
734      }
735
736  public String fhirType() {
737    return "Contract.valuedItem";
738
739  }
740
741  }
742
743    @Block()
744    public static class SignatoryComponent extends BackboneElement implements IBaseBackboneElement {
745        /**
746         * Role of this Contract signer, e.g. notary, grantee.
747         */
748        @Child(name = "type", type = {Coding.class}, order=1, min=1, max=1, modifier=false, summary=false)
749        @Description(shortDefinition="Contract Signer Type", formalDefinition="Role of this Contract signer, e.g. notary, grantee." )
750        protected Coding type;
751
752        /**
753         * Party which is a signator to this Contract.
754         */
755        @Child(name = "party", type = {Organization.class, Patient.class, Practitioner.class, RelatedPerson.class}, order=2, min=1, max=1, modifier=false, summary=false)
756        @Description(shortDefinition="Contract Signatory Party", formalDefinition="Party which is a signator to this Contract." )
757        protected Reference party;
758
759        /**
760         * The actual object that is the target of the reference (Party which is a signator to this Contract.)
761         */
762        protected Resource partyTarget;
763
764        /**
765         * Legally binding Contract DSIG signature contents in Base64.
766         */
767        @Child(name = "signature", type = {StringType.class}, order=3, min=1, max=1, modifier=false, summary=false)
768        @Description(shortDefinition="Contract Documentation Signature", formalDefinition="Legally binding Contract DSIG signature contents in Base64." )
769        protected StringType signature;
770
771        private static final long serialVersionUID = -1870392043L;
772
773    /*
774     * Constructor
775     */
776      public SignatoryComponent() {
777        super();
778      }
779
780    /*
781     * Constructor
782     */
783      public SignatoryComponent(Coding type, Reference party, StringType signature) {
784        super();
785        this.type = type;
786        this.party = party;
787        this.signature = signature;
788      }
789
790        /**
791         * @return {@link #type} (Role of this Contract signer, e.g. notary, grantee.)
792         */
793        public Coding getType() { 
794          if (this.type == null)
795            if (Configuration.errorOnAutoCreate())
796              throw new Error("Attempt to auto-create SignatoryComponent.type");
797            else if (Configuration.doAutoCreate())
798              this.type = new Coding(); // cc
799          return this.type;
800        }
801
802        public boolean hasType() { 
803          return this.type != null && !this.type.isEmpty();
804        }
805
806        /**
807         * @param value {@link #type} (Role of this Contract signer, e.g. notary, grantee.)
808         */
809        public SignatoryComponent setType(Coding value) { 
810          this.type = value;
811          return this;
812        }
813
814        /**
815         * @return {@link #party} (Party which is a signator to this Contract.)
816         */
817        public Reference getParty() { 
818          if (this.party == null)
819            if (Configuration.errorOnAutoCreate())
820              throw new Error("Attempt to auto-create SignatoryComponent.party");
821            else if (Configuration.doAutoCreate())
822              this.party = new Reference(); // cc
823          return this.party;
824        }
825
826        public boolean hasParty() { 
827          return this.party != null && !this.party.isEmpty();
828        }
829
830        /**
831         * @param value {@link #party} (Party which is a signator to this Contract.)
832         */
833        public SignatoryComponent setParty(Reference value) { 
834          this.party = value;
835          return this;
836        }
837
838        /**
839         * @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. (Party which is a signator to this Contract.)
840         */
841        public Resource getPartyTarget() { 
842          return this.partyTarget;
843        }
844
845        /**
846         * @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. (Party which is a signator to this Contract.)
847         */
848        public SignatoryComponent setPartyTarget(Resource value) { 
849          this.partyTarget = value;
850          return this;
851        }
852
853        /**
854         * @return {@link #signature} (Legally binding Contract DSIG signature contents in Base64.). This is the underlying object with id, value and extensions. The accessor "getSignature" gives direct access to the value
855         */
856        public StringType getSignatureElement() { 
857          if (this.signature == null)
858            if (Configuration.errorOnAutoCreate())
859              throw new Error("Attempt to auto-create SignatoryComponent.signature");
860            else if (Configuration.doAutoCreate())
861              this.signature = new StringType(); // bb
862          return this.signature;
863        }
864
865        public boolean hasSignatureElement() { 
866          return this.signature != null && !this.signature.isEmpty();
867        }
868
869        public boolean hasSignature() { 
870          return this.signature != null && !this.signature.isEmpty();
871        }
872
873        /**
874         * @param value {@link #signature} (Legally binding Contract DSIG signature contents in Base64.). This is the underlying object with id, value and extensions. The accessor "getSignature" gives direct access to the value
875         */
876        public SignatoryComponent setSignatureElement(StringType value) { 
877          this.signature = value;
878          return this;
879        }
880
881        /**
882         * @return Legally binding Contract DSIG signature contents in Base64.
883         */
884        public String getSignature() { 
885          return this.signature == null ? null : this.signature.getValue();
886        }
887
888        /**
889         * @param value Legally binding Contract DSIG signature contents in Base64.
890         */
891        public SignatoryComponent setSignature(String value) { 
892            if (this.signature == null)
893              this.signature = new StringType();
894            this.signature.setValue(value);
895          return this;
896        }
897
898        protected void listChildren(List<Property> childrenList) {
899          super.listChildren(childrenList);
900          childrenList.add(new Property("type", "Coding", "Role of this Contract signer, e.g. notary, grantee.", 0, java.lang.Integer.MAX_VALUE, type));
901          childrenList.add(new Property("party", "Reference(Organization|Patient|Practitioner|RelatedPerson)", "Party which is a signator to this Contract.", 0, java.lang.Integer.MAX_VALUE, party));
902          childrenList.add(new Property("signature", "string", "Legally binding Contract DSIG signature contents in Base64.", 0, java.lang.Integer.MAX_VALUE, signature));
903        }
904
905      @Override
906      public void setProperty(String name, Base value) throws FHIRException {
907        if (name.equals("type"))
908          this.type = castToCoding(value); // Coding
909        else if (name.equals("party"))
910          this.party = castToReference(value); // Reference
911        else if (name.equals("signature"))
912          this.signature = castToString(value); // StringType
913        else
914          super.setProperty(name, value);
915      }
916
917      @Override
918      public Base addChild(String name) throws FHIRException {
919        if (name.equals("type")) {
920          this.type = new Coding();
921          return this.type;
922        }
923        else if (name.equals("party")) {
924          this.party = new Reference();
925          return this.party;
926        }
927        else if (name.equals("signature")) {
928          throw new FHIRException("Cannot call addChild on a primitive type Contract.signature");
929        }
930        else
931          return super.addChild(name);
932      }
933
934      public SignatoryComponent copy() {
935        SignatoryComponent dst = new SignatoryComponent();
936        copyValues(dst);
937        dst.type = type == null ? null : type.copy();
938        dst.party = party == null ? null : party.copy();
939        dst.signature = signature == null ? null : signature.copy();
940        return dst;
941      }
942
943      @Override
944      public boolean equalsDeep(Base other) {
945        if (!super.equalsDeep(other))
946          return false;
947        if (!(other instanceof SignatoryComponent))
948          return false;
949        SignatoryComponent o = (SignatoryComponent) other;
950        return compareDeep(type, o.type, true) && compareDeep(party, o.party, true) && compareDeep(signature, o.signature, true)
951          ;
952      }
953
954      @Override
955      public boolean equalsShallow(Base other) {
956        if (!super.equalsShallow(other))
957          return false;
958        if (!(other instanceof SignatoryComponent))
959          return false;
960        SignatoryComponent o = (SignatoryComponent) other;
961        return compareValues(signature, o.signature, true);
962      }
963
964      public boolean isEmpty() {
965        return super.isEmpty() && (type == null || type.isEmpty()) && (party == null || party.isEmpty())
966           && (signature == null || signature.isEmpty());
967      }
968
969  public String fhirType() {
970    return "Contract.signer";
971
972  }
973
974  }
975
976    @Block()
977    public static class TermComponent extends BackboneElement implements IBaseBackboneElement {
978        /**
979         * Unique identifier for this particular Contract Provision.
980         */
981        @Child(name = "identifier", type = {Identifier.class}, order=1, min=0, max=1, modifier=false, summary=true)
982        @Description(shortDefinition="Contract Term identifier", formalDefinition="Unique identifier for this particular Contract Provision." )
983        protected Identifier identifier;
984
985        /**
986         * When this Contract Provision was issued.
987         */
988        @Child(name = "issued", type = {DateTimeType.class}, order=2, min=0, max=1, modifier=false, summary=true)
989        @Description(shortDefinition="Contract Term Issue Date Time", formalDefinition="When this Contract Provision was issued." )
990        protected DateTimeType issued;
991
992        /**
993         * Relevant time or time-period when this Contract Provision is applicable.
994         */
995        @Child(name = "applies", type = {Period.class}, order=3, min=0, max=1, modifier=false, summary=true)
996        @Description(shortDefinition="Contract Term Effective Time", formalDefinition="Relevant time or time-period when this Contract Provision is applicable." )
997        protected Period applies;
998
999        /**
1000         * Type of Contract Provision such as specific requirements, purposes for actions, obligations, prohibitions, e.g. life time maximum benefit.
1001         */
1002        @Child(name = "type", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=false)
1003        @Description(shortDefinition="Contract Term Type", formalDefinition="Type of Contract Provision such as specific requirements, purposes for actions, obligations, prohibitions, e.g. life time maximum benefit." )
1004        protected CodeableConcept type;
1005
1006        /**
1007         * Subtype of this Contract Provision, e.g. life time maximum payment for a contract term for specific valued item, e.g. disability payment.
1008         */
1009        @Child(name = "subType", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=false)
1010        @Description(shortDefinition="Contract Term Subtype", formalDefinition="Subtype of this Contract Provision, e.g. life time maximum payment for a contract term for specific valued item, e.g. disability payment." )
1011        protected CodeableConcept subType;
1012
1013        /**
1014         * Who or what this Contract Provision is about.
1015         */
1016        @Child(name = "subject", type = {}, order=6, min=0, max=1, modifier=false, summary=false)
1017        @Description(shortDefinition="Subject of this Contract Term", formalDefinition="Who or what this Contract Provision is about." )
1018        protected Reference subject;
1019
1020        /**
1021         * The actual object that is the target of the reference (Who or what this Contract Provision is about.)
1022         */
1023        protected Resource subjectTarget;
1024
1025        /**
1026         * Action stipulated by this Contract Provision.
1027         */
1028        @Child(name = "action", type = {CodeableConcept.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1029        @Description(shortDefinition="Contract Term Action", formalDefinition="Action stipulated by this Contract Provision." )
1030        protected List<CodeableConcept> action;
1031
1032        /**
1033         * Reason or purpose for the action stipulated by this Contract Provision.
1034         */
1035        @Child(name = "actionReason", type = {CodeableConcept.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1036        @Description(shortDefinition="Contract Term Action Reason", formalDefinition="Reason or purpose for the action stipulated by this Contract Provision." )
1037        protected List<CodeableConcept> actionReason;
1038
1039        /**
1040         * List of actors participating in this Contract Provision.
1041         */
1042        @Child(name = "actor", type = {}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1043        @Description(shortDefinition="Contract Term Actor List", formalDefinition="List of actors participating in this Contract Provision." )
1044        protected List<TermActorComponent> actor;
1045
1046        /**
1047         * Human readable form of this Contract Provision.
1048         */
1049        @Child(name = "text", type = {StringType.class}, order=10, min=0, max=1, modifier=false, summary=false)
1050        @Description(shortDefinition="Human readable Contract term text", formalDefinition="Human readable form of this Contract Provision." )
1051        protected StringType text;
1052
1053        /**
1054         * Contract Provision Valued Item List.
1055         */
1056        @Child(name = "valuedItem", type = {}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1057        @Description(shortDefinition="Contract Term Valued Item", formalDefinition="Contract Provision Valued Item List." )
1058        protected List<TermValuedItemComponent> valuedItem;
1059
1060        /**
1061         * Nested group of Contract Provisions.
1062         */
1063        @Child(name = "group", type = {TermComponent.class}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1064        @Description(shortDefinition="Nested Contract Term Group", formalDefinition="Nested group of Contract Provisions." )
1065        protected List<TermComponent> group;
1066
1067        private static final long serialVersionUID = -1137577465L;
1068
1069    /*
1070     * Constructor
1071     */
1072      public TermComponent() {
1073        super();
1074      }
1075
1076        /**
1077         * @return {@link #identifier} (Unique identifier for this particular Contract Provision.)
1078         */
1079        public Identifier getIdentifier() { 
1080          if (this.identifier == null)
1081            if (Configuration.errorOnAutoCreate())
1082              throw new Error("Attempt to auto-create TermComponent.identifier");
1083            else if (Configuration.doAutoCreate())
1084              this.identifier = new Identifier(); // cc
1085          return this.identifier;
1086        }
1087
1088        public boolean hasIdentifier() { 
1089          return this.identifier != null && !this.identifier.isEmpty();
1090        }
1091
1092        /**
1093         * @param value {@link #identifier} (Unique identifier for this particular Contract Provision.)
1094         */
1095        public TermComponent setIdentifier(Identifier value) { 
1096          this.identifier = value;
1097          return this;
1098        }
1099
1100        /**
1101         * @return {@link #issued} (When this Contract Provision was issued.). This is the underlying object with id, value and extensions. The accessor "getIssued" gives direct access to the value
1102         */
1103        public DateTimeType getIssuedElement() { 
1104          if (this.issued == null)
1105            if (Configuration.errorOnAutoCreate())
1106              throw new Error("Attempt to auto-create TermComponent.issued");
1107            else if (Configuration.doAutoCreate())
1108              this.issued = new DateTimeType(); // bb
1109          return this.issued;
1110        }
1111
1112        public boolean hasIssuedElement() { 
1113          return this.issued != null && !this.issued.isEmpty();
1114        }
1115
1116        public boolean hasIssued() { 
1117          return this.issued != null && !this.issued.isEmpty();
1118        }
1119
1120        /**
1121         * @param value {@link #issued} (When this Contract Provision was issued.). This is the underlying object with id, value and extensions. The accessor "getIssued" gives direct access to the value
1122         */
1123        public TermComponent setIssuedElement(DateTimeType value) { 
1124          this.issued = value;
1125          return this;
1126        }
1127
1128        /**
1129         * @return When this Contract Provision was issued.
1130         */
1131        public Date getIssued() { 
1132          return this.issued == null ? null : this.issued.getValue();
1133        }
1134
1135        /**
1136         * @param value When this Contract Provision was issued.
1137         */
1138        public TermComponent setIssued(Date value) { 
1139          if (value == null)
1140            this.issued = null;
1141          else {
1142            if (this.issued == null)
1143              this.issued = new DateTimeType();
1144            this.issued.setValue(value);
1145          }
1146          return this;
1147        }
1148
1149        /**
1150         * @return {@link #applies} (Relevant time or time-period when this Contract Provision is applicable.)
1151         */
1152        public Period getApplies() { 
1153          if (this.applies == null)
1154            if (Configuration.errorOnAutoCreate())
1155              throw new Error("Attempt to auto-create TermComponent.applies");
1156            else if (Configuration.doAutoCreate())
1157              this.applies = new Period(); // cc
1158          return this.applies;
1159        }
1160
1161        public boolean hasApplies() { 
1162          return this.applies != null && !this.applies.isEmpty();
1163        }
1164
1165        /**
1166         * @param value {@link #applies} (Relevant time or time-period when this Contract Provision is applicable.)
1167         */
1168        public TermComponent setApplies(Period value) { 
1169          this.applies = value;
1170          return this;
1171        }
1172
1173        /**
1174         * @return {@link #type} (Type of Contract Provision such as specific requirements, purposes for actions, obligations, prohibitions, e.g. life time maximum benefit.)
1175         */
1176        public CodeableConcept getType() { 
1177          if (this.type == null)
1178            if (Configuration.errorOnAutoCreate())
1179              throw new Error("Attempt to auto-create TermComponent.type");
1180            else if (Configuration.doAutoCreate())
1181              this.type = new CodeableConcept(); // cc
1182          return this.type;
1183        }
1184
1185        public boolean hasType() { 
1186          return this.type != null && !this.type.isEmpty();
1187        }
1188
1189        /**
1190         * @param value {@link #type} (Type of Contract Provision such as specific requirements, purposes for actions, obligations, prohibitions, e.g. life time maximum benefit.)
1191         */
1192        public TermComponent setType(CodeableConcept value) { 
1193          this.type = value;
1194          return this;
1195        }
1196
1197        /**
1198         * @return {@link #subType} (Subtype of this Contract Provision, e.g. life time maximum payment for a contract term for specific valued item, e.g. disability payment.)
1199         */
1200        public CodeableConcept getSubType() { 
1201          if (this.subType == null)
1202            if (Configuration.errorOnAutoCreate())
1203              throw new Error("Attempt to auto-create TermComponent.subType");
1204            else if (Configuration.doAutoCreate())
1205              this.subType = new CodeableConcept(); // cc
1206          return this.subType;
1207        }
1208
1209        public boolean hasSubType() { 
1210          return this.subType != null && !this.subType.isEmpty();
1211        }
1212
1213        /**
1214         * @param value {@link #subType} (Subtype of this Contract Provision, e.g. life time maximum payment for a contract term for specific valued item, e.g. disability payment.)
1215         */
1216        public TermComponent setSubType(CodeableConcept value) { 
1217          this.subType = value;
1218          return this;
1219        }
1220
1221        /**
1222         * @return {@link #subject} (Who or what this Contract Provision is about.)
1223         */
1224        public Reference getSubject() { 
1225          if (this.subject == null)
1226            if (Configuration.errorOnAutoCreate())
1227              throw new Error("Attempt to auto-create TermComponent.subject");
1228            else if (Configuration.doAutoCreate())
1229              this.subject = new Reference(); // cc
1230          return this.subject;
1231        }
1232
1233        public boolean hasSubject() { 
1234          return this.subject != null && !this.subject.isEmpty();
1235        }
1236
1237        /**
1238         * @param value {@link #subject} (Who or what this Contract Provision is about.)
1239         */
1240        public TermComponent setSubject(Reference value) { 
1241          this.subject = value;
1242          return this;
1243        }
1244
1245        /**
1246         * @return {@link #subject} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Who or what this Contract Provision is about.)
1247         */
1248        public Resource getSubjectTarget() { 
1249          return this.subjectTarget;
1250        }
1251
1252        /**
1253         * @param value {@link #subject} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Who or what this Contract Provision is about.)
1254         */
1255        public TermComponent setSubjectTarget(Resource value) { 
1256          this.subjectTarget = value;
1257          return this;
1258        }
1259
1260        /**
1261         * @return {@link #action} (Action stipulated by this Contract Provision.)
1262         */
1263        public List<CodeableConcept> getAction() { 
1264          if (this.action == null)
1265            this.action = new ArrayList<CodeableConcept>();
1266          return this.action;
1267        }
1268
1269        public boolean hasAction() { 
1270          if (this.action == null)
1271            return false;
1272          for (CodeableConcept item : this.action)
1273            if (!item.isEmpty())
1274              return true;
1275          return false;
1276        }
1277
1278        /**
1279         * @return {@link #action} (Action stipulated by this Contract Provision.)
1280         */
1281    // syntactic sugar
1282        public CodeableConcept addAction() { //3
1283          CodeableConcept t = new CodeableConcept();
1284          if (this.action == null)
1285            this.action = new ArrayList<CodeableConcept>();
1286          this.action.add(t);
1287          return t;
1288        }
1289
1290    // syntactic sugar
1291        public TermComponent addAction(CodeableConcept t) { //3
1292          if (t == null)
1293            return this;
1294          if (this.action == null)
1295            this.action = new ArrayList<CodeableConcept>();
1296          this.action.add(t);
1297          return this;
1298        }
1299
1300        /**
1301         * @return {@link #actionReason} (Reason or purpose for the action stipulated by this Contract Provision.)
1302         */
1303        public List<CodeableConcept> getActionReason() { 
1304          if (this.actionReason == null)
1305            this.actionReason = new ArrayList<CodeableConcept>();
1306          return this.actionReason;
1307        }
1308
1309        public boolean hasActionReason() { 
1310          if (this.actionReason == null)
1311            return false;
1312          for (CodeableConcept item : this.actionReason)
1313            if (!item.isEmpty())
1314              return true;
1315          return false;
1316        }
1317
1318        /**
1319         * @return {@link #actionReason} (Reason or purpose for the action stipulated by this Contract Provision.)
1320         */
1321    // syntactic sugar
1322        public CodeableConcept addActionReason() { //3
1323          CodeableConcept t = new CodeableConcept();
1324          if (this.actionReason == null)
1325            this.actionReason = new ArrayList<CodeableConcept>();
1326          this.actionReason.add(t);
1327          return t;
1328        }
1329
1330    // syntactic sugar
1331        public TermComponent addActionReason(CodeableConcept t) { //3
1332          if (t == null)
1333            return this;
1334          if (this.actionReason == null)
1335            this.actionReason = new ArrayList<CodeableConcept>();
1336          this.actionReason.add(t);
1337          return this;
1338        }
1339
1340        /**
1341         * @return {@link #actor} (List of actors participating in this Contract Provision.)
1342         */
1343        public List<TermActorComponent> getActor() { 
1344          if (this.actor == null)
1345            this.actor = new ArrayList<TermActorComponent>();
1346          return this.actor;
1347        }
1348
1349        public boolean hasActor() { 
1350          if (this.actor == null)
1351            return false;
1352          for (TermActorComponent item : this.actor)
1353            if (!item.isEmpty())
1354              return true;
1355          return false;
1356        }
1357
1358        /**
1359         * @return {@link #actor} (List of actors participating in this Contract Provision.)
1360         */
1361    // syntactic sugar
1362        public TermActorComponent addActor() { //3
1363          TermActorComponent t = new TermActorComponent();
1364          if (this.actor == null)
1365            this.actor = new ArrayList<TermActorComponent>();
1366          this.actor.add(t);
1367          return t;
1368        }
1369
1370    // syntactic sugar
1371        public TermComponent addActor(TermActorComponent t) { //3
1372          if (t == null)
1373            return this;
1374          if (this.actor == null)
1375            this.actor = new ArrayList<TermActorComponent>();
1376          this.actor.add(t);
1377          return this;
1378        }
1379
1380        /**
1381         * @return {@link #text} (Human readable form of this Contract Provision.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value
1382         */
1383        public StringType getTextElement() { 
1384          if (this.text == null)
1385            if (Configuration.errorOnAutoCreate())
1386              throw new Error("Attempt to auto-create TermComponent.text");
1387            else if (Configuration.doAutoCreate())
1388              this.text = new StringType(); // bb
1389          return this.text;
1390        }
1391
1392        public boolean hasTextElement() { 
1393          return this.text != null && !this.text.isEmpty();
1394        }
1395
1396        public boolean hasText() { 
1397          return this.text != null && !this.text.isEmpty();
1398        }
1399
1400        /**
1401         * @param value {@link #text} (Human readable form of this Contract Provision.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value
1402         */
1403        public TermComponent setTextElement(StringType value) { 
1404          this.text = value;
1405          return this;
1406        }
1407
1408        /**
1409         * @return Human readable form of this Contract Provision.
1410         */
1411        public String getText() { 
1412          return this.text == null ? null : this.text.getValue();
1413        }
1414
1415        /**
1416         * @param value Human readable form of this Contract Provision.
1417         */
1418        public TermComponent setText(String value) { 
1419          if (Utilities.noString(value))
1420            this.text = null;
1421          else {
1422            if (this.text == null)
1423              this.text = new StringType();
1424            this.text.setValue(value);
1425          }
1426          return this;
1427        }
1428
1429        /**
1430         * @return {@link #valuedItem} (Contract Provision Valued Item List.)
1431         */
1432        public List<TermValuedItemComponent> getValuedItem() { 
1433          if (this.valuedItem == null)
1434            this.valuedItem = new ArrayList<TermValuedItemComponent>();
1435          return this.valuedItem;
1436        }
1437
1438        public boolean hasValuedItem() { 
1439          if (this.valuedItem == null)
1440            return false;
1441          for (TermValuedItemComponent item : this.valuedItem)
1442            if (!item.isEmpty())
1443              return true;
1444          return false;
1445        }
1446
1447        /**
1448         * @return {@link #valuedItem} (Contract Provision Valued Item List.)
1449         */
1450    // syntactic sugar
1451        public TermValuedItemComponent addValuedItem() { //3
1452          TermValuedItemComponent t = new TermValuedItemComponent();
1453          if (this.valuedItem == null)
1454            this.valuedItem = new ArrayList<TermValuedItemComponent>();
1455          this.valuedItem.add(t);
1456          return t;
1457        }
1458
1459    // syntactic sugar
1460        public TermComponent addValuedItem(TermValuedItemComponent t) { //3
1461          if (t == null)
1462            return this;
1463          if (this.valuedItem == null)
1464            this.valuedItem = new ArrayList<TermValuedItemComponent>();
1465          this.valuedItem.add(t);
1466          return this;
1467        }
1468
1469        /**
1470         * @return {@link #group} (Nested group of Contract Provisions.)
1471         */
1472        public List<TermComponent> getGroup() { 
1473          if (this.group == null)
1474            this.group = new ArrayList<TermComponent>();
1475          return this.group;
1476        }
1477
1478        public boolean hasGroup() { 
1479          if (this.group == null)
1480            return false;
1481          for (TermComponent item : this.group)
1482            if (!item.isEmpty())
1483              return true;
1484          return false;
1485        }
1486
1487        /**
1488         * @return {@link #group} (Nested group of Contract Provisions.)
1489         */
1490    // syntactic sugar
1491        public TermComponent addGroup() { //3
1492          TermComponent t = new TermComponent();
1493          if (this.group == null)
1494            this.group = new ArrayList<TermComponent>();
1495          this.group.add(t);
1496          return t;
1497        }
1498
1499    // syntactic sugar
1500        public TermComponent addGroup(TermComponent t) { //3
1501          if (t == null)
1502            return this;
1503          if (this.group == null)
1504            this.group = new ArrayList<TermComponent>();
1505          this.group.add(t);
1506          return this;
1507        }
1508
1509        protected void listChildren(List<Property> childrenList) {
1510          super.listChildren(childrenList);
1511          childrenList.add(new Property("identifier", "Identifier", "Unique identifier for this particular Contract Provision.", 0, java.lang.Integer.MAX_VALUE, identifier));
1512          childrenList.add(new Property("issued", "dateTime", "When this Contract Provision was issued.", 0, java.lang.Integer.MAX_VALUE, issued));
1513          childrenList.add(new Property("applies", "Period", "Relevant time or time-period when this Contract Provision is applicable.", 0, java.lang.Integer.MAX_VALUE, applies));
1514          childrenList.add(new Property("type", "CodeableConcept", "Type of Contract Provision such as specific requirements, purposes for actions, obligations, prohibitions, e.g. life time maximum benefit.", 0, java.lang.Integer.MAX_VALUE, type));
1515          childrenList.add(new Property("subType", "CodeableConcept", "Subtype of this Contract Provision, e.g. life time maximum payment for a contract term for specific valued item, e.g. disability payment.", 0, java.lang.Integer.MAX_VALUE, subType));
1516          childrenList.add(new Property("subject", "Reference(Any)", "Who or what this Contract Provision is about.", 0, java.lang.Integer.MAX_VALUE, subject));
1517          childrenList.add(new Property("action", "CodeableConcept", "Action stipulated by this Contract Provision.", 0, java.lang.Integer.MAX_VALUE, action));
1518          childrenList.add(new Property("actionReason", "CodeableConcept", "Reason or purpose for the action stipulated by this Contract Provision.", 0, java.lang.Integer.MAX_VALUE, actionReason));
1519          childrenList.add(new Property("actor", "", "List of actors participating in this Contract Provision.", 0, java.lang.Integer.MAX_VALUE, actor));
1520          childrenList.add(new Property("text", "string", "Human readable form of this Contract Provision.", 0, java.lang.Integer.MAX_VALUE, text));
1521          childrenList.add(new Property("valuedItem", "", "Contract Provision Valued Item List.", 0, java.lang.Integer.MAX_VALUE, valuedItem));
1522          childrenList.add(new Property("group", "@Contract.term", "Nested group of Contract Provisions.", 0, java.lang.Integer.MAX_VALUE, group));
1523        }
1524
1525      @Override
1526      public void setProperty(String name, Base value) throws FHIRException {
1527        if (name.equals("identifier"))
1528          this.identifier = castToIdentifier(value); // Identifier
1529        else if (name.equals("issued"))
1530          this.issued = castToDateTime(value); // DateTimeType
1531        else if (name.equals("applies"))
1532          this.applies = castToPeriod(value); // Period
1533        else if (name.equals("type"))
1534          this.type = castToCodeableConcept(value); // CodeableConcept
1535        else if (name.equals("subType"))
1536          this.subType = castToCodeableConcept(value); // CodeableConcept
1537        else if (name.equals("subject"))
1538          this.subject = castToReference(value); // Reference
1539        else if (name.equals("action"))
1540          this.getAction().add(castToCodeableConcept(value));
1541        else if (name.equals("actionReason"))
1542          this.getActionReason().add(castToCodeableConcept(value));
1543        else if (name.equals("actor"))
1544          this.getActor().add((TermActorComponent) value);
1545        else if (name.equals("text"))
1546          this.text = castToString(value); // StringType
1547        else if (name.equals("valuedItem"))
1548          this.getValuedItem().add((TermValuedItemComponent) value);
1549        else if (name.equals("group"))
1550          this.getGroup().add((TermComponent) value);
1551        else
1552          super.setProperty(name, value);
1553      }
1554
1555      @Override
1556      public Base addChild(String name) throws FHIRException {
1557        if (name.equals("identifier")) {
1558          this.identifier = new Identifier();
1559          return this.identifier;
1560        }
1561        else if (name.equals("issued")) {
1562          throw new FHIRException("Cannot call addChild on a primitive type Contract.issued");
1563        }
1564        else if (name.equals("applies")) {
1565          this.applies = new Period();
1566          return this.applies;
1567        }
1568        else if (name.equals("type")) {
1569          this.type = new CodeableConcept();
1570          return this.type;
1571        }
1572        else if (name.equals("subType")) {
1573          this.subType = new CodeableConcept();
1574          return this.subType;
1575        }
1576        else if (name.equals("subject")) {
1577          this.subject = new Reference();
1578          return this.subject;
1579        }
1580        else if (name.equals("action")) {
1581          return addAction();
1582        }
1583        else if (name.equals("actionReason")) {
1584          return addActionReason();
1585        }
1586        else if (name.equals("actor")) {
1587          return addActor();
1588        }
1589        else if (name.equals("text")) {
1590          throw new FHIRException("Cannot call addChild on a primitive type Contract.text");
1591        }
1592        else if (name.equals("valuedItem")) {
1593          return addValuedItem();
1594        }
1595        else if (name.equals("group")) {
1596          return addGroup();
1597        }
1598        else
1599          return super.addChild(name);
1600      }
1601
1602      public TermComponent copy() {
1603        TermComponent dst = new TermComponent();
1604        copyValues(dst);
1605        dst.identifier = identifier == null ? null : identifier.copy();
1606        dst.issued = issued == null ? null : issued.copy();
1607        dst.applies = applies == null ? null : applies.copy();
1608        dst.type = type == null ? null : type.copy();
1609        dst.subType = subType == null ? null : subType.copy();
1610        dst.subject = subject == null ? null : subject.copy();
1611        if (action != null) {
1612          dst.action = new ArrayList<CodeableConcept>();
1613          for (CodeableConcept i : action)
1614            dst.action.add(i.copy());
1615        };
1616        if (actionReason != null) {
1617          dst.actionReason = new ArrayList<CodeableConcept>();
1618          for (CodeableConcept i : actionReason)
1619            dst.actionReason.add(i.copy());
1620        };
1621        if (actor != null) {
1622          dst.actor = new ArrayList<TermActorComponent>();
1623          for (TermActorComponent i : actor)
1624            dst.actor.add(i.copy());
1625        };
1626        dst.text = text == null ? null : text.copy();
1627        if (valuedItem != null) {
1628          dst.valuedItem = new ArrayList<TermValuedItemComponent>();
1629          for (TermValuedItemComponent i : valuedItem)
1630            dst.valuedItem.add(i.copy());
1631        };
1632        if (group != null) {
1633          dst.group = new ArrayList<TermComponent>();
1634          for (TermComponent i : group)
1635            dst.group.add(i.copy());
1636        };
1637        return dst;
1638      }
1639
1640      @Override
1641      public boolean equalsDeep(Base other) {
1642        if (!super.equalsDeep(other))
1643          return false;
1644        if (!(other instanceof TermComponent))
1645          return false;
1646        TermComponent o = (TermComponent) other;
1647        return compareDeep(identifier, o.identifier, true) && compareDeep(issued, o.issued, true) && compareDeep(applies, o.applies, true)
1648           && compareDeep(type, o.type, true) && compareDeep(subType, o.subType, true) && compareDeep(subject, o.subject, true)
1649           && compareDeep(action, o.action, true) && compareDeep(actionReason, o.actionReason, true) && compareDeep(actor, o.actor, true)
1650           && compareDeep(text, o.text, true) && compareDeep(valuedItem, o.valuedItem, true) && compareDeep(group, o.group, true)
1651          ;
1652      }
1653
1654      @Override
1655      public boolean equalsShallow(Base other) {
1656        if (!super.equalsShallow(other))
1657          return false;
1658        if (!(other instanceof TermComponent))
1659          return false;
1660        TermComponent o = (TermComponent) other;
1661        return compareValues(issued, o.issued, true) && compareValues(text, o.text, true);
1662      }
1663
1664      public boolean isEmpty() {
1665        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (issued == null || issued.isEmpty())
1666           && (applies == null || applies.isEmpty()) && (type == null || type.isEmpty()) && (subType == null || subType.isEmpty())
1667           && (subject == null || subject.isEmpty()) && (action == null || action.isEmpty()) && (actionReason == null || actionReason.isEmpty())
1668           && (actor == null || actor.isEmpty()) && (text == null || text.isEmpty()) && (valuedItem == null || valuedItem.isEmpty())
1669           && (group == null || group.isEmpty());
1670      }
1671
1672  public String fhirType() {
1673    return "Contract.term";
1674
1675  }
1676
1677  }
1678
1679    @Block()
1680    public static class TermActorComponent extends BackboneElement implements IBaseBackboneElement {
1681        /**
1682         * The actor assigned a role in this Contract Provision.
1683         */
1684        @Child(name = "entity", type = {Contract.class, Device.class, Group.class, Location.class, Organization.class, Patient.class, Practitioner.class, RelatedPerson.class, Substance.class}, order=1, min=1, max=1, modifier=false, summary=false)
1685        @Description(shortDefinition="Contract Term Actor", formalDefinition="The actor assigned a role in this Contract Provision." )
1686        protected Reference entity;
1687
1688        /**
1689         * The actual object that is the target of the reference (The actor assigned a role in this Contract Provision.)
1690         */
1691        protected Resource entityTarget;
1692
1693        /**
1694         * Role played by the actor assigned this role in this Contract Provision.
1695         */
1696        @Child(name = "role", type = {CodeableConcept.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1697        @Description(shortDefinition="Contract Term Actor Role", formalDefinition="Role played by the actor assigned this role in this Contract Provision." )
1698        protected List<CodeableConcept> role;
1699
1700        private static final long serialVersionUID = 1371245689L;
1701
1702    /*
1703     * Constructor
1704     */
1705      public TermActorComponent() {
1706        super();
1707      }
1708
1709    /*
1710     * Constructor
1711     */
1712      public TermActorComponent(Reference entity) {
1713        super();
1714        this.entity = entity;
1715      }
1716
1717        /**
1718         * @return {@link #entity} (The actor assigned a role in this Contract Provision.)
1719         */
1720        public Reference getEntity() { 
1721          if (this.entity == null)
1722            if (Configuration.errorOnAutoCreate())
1723              throw new Error("Attempt to auto-create TermActorComponent.entity");
1724            else if (Configuration.doAutoCreate())
1725              this.entity = new Reference(); // cc
1726          return this.entity;
1727        }
1728
1729        public boolean hasEntity() { 
1730          return this.entity != null && !this.entity.isEmpty();
1731        }
1732
1733        /**
1734         * @param value {@link #entity} (The actor assigned a role in this Contract Provision.)
1735         */
1736        public TermActorComponent setEntity(Reference value) { 
1737          this.entity = value;
1738          return this;
1739        }
1740
1741        /**
1742         * @return {@link #entity} 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 actor assigned a role in this Contract Provision.)
1743         */
1744        public Resource getEntityTarget() { 
1745          return this.entityTarget;
1746        }
1747
1748        /**
1749         * @param value {@link #entity} 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 actor assigned a role in this Contract Provision.)
1750         */
1751        public TermActorComponent setEntityTarget(Resource value) { 
1752          this.entityTarget = value;
1753          return this;
1754        }
1755
1756        /**
1757         * @return {@link #role} (Role played by the actor assigned this role in this Contract Provision.)
1758         */
1759        public List<CodeableConcept> getRole() { 
1760          if (this.role == null)
1761            this.role = new ArrayList<CodeableConcept>();
1762          return this.role;
1763        }
1764
1765        public boolean hasRole() { 
1766          if (this.role == null)
1767            return false;
1768          for (CodeableConcept item : this.role)
1769            if (!item.isEmpty())
1770              return true;
1771          return false;
1772        }
1773
1774        /**
1775         * @return {@link #role} (Role played by the actor assigned this role in this Contract Provision.)
1776         */
1777    // syntactic sugar
1778        public CodeableConcept addRole() { //3
1779          CodeableConcept t = new CodeableConcept();
1780          if (this.role == null)
1781            this.role = new ArrayList<CodeableConcept>();
1782          this.role.add(t);
1783          return t;
1784        }
1785
1786    // syntactic sugar
1787        public TermActorComponent addRole(CodeableConcept t) { //3
1788          if (t == null)
1789            return this;
1790          if (this.role == null)
1791            this.role = new ArrayList<CodeableConcept>();
1792          this.role.add(t);
1793          return this;
1794        }
1795
1796        protected void listChildren(List<Property> childrenList) {
1797          super.listChildren(childrenList);
1798          childrenList.add(new Property("entity", "Reference(Contract|Device|Group|Location|Organization|Patient|Practitioner|RelatedPerson|Substance)", "The actor assigned a role in this Contract Provision.", 0, java.lang.Integer.MAX_VALUE, entity));
1799          childrenList.add(new Property("role", "CodeableConcept", "Role played by the actor assigned this role in this Contract Provision.", 0, java.lang.Integer.MAX_VALUE, role));
1800        }
1801
1802      @Override
1803      public void setProperty(String name, Base value) throws FHIRException {
1804        if (name.equals("entity"))
1805          this.entity = castToReference(value); // Reference
1806        else if (name.equals("role"))
1807          this.getRole().add(castToCodeableConcept(value));
1808        else
1809          super.setProperty(name, value);
1810      }
1811
1812      @Override
1813      public Base addChild(String name) throws FHIRException {
1814        if (name.equals("entity")) {
1815          this.entity = new Reference();
1816          return this.entity;
1817        }
1818        else if (name.equals("role")) {
1819          return addRole();
1820        }
1821        else
1822          return super.addChild(name);
1823      }
1824
1825      public TermActorComponent copy() {
1826        TermActorComponent dst = new TermActorComponent();
1827        copyValues(dst);
1828        dst.entity = entity == null ? null : entity.copy();
1829        if (role != null) {
1830          dst.role = new ArrayList<CodeableConcept>();
1831          for (CodeableConcept i : role)
1832            dst.role.add(i.copy());
1833        };
1834        return dst;
1835      }
1836
1837      @Override
1838      public boolean equalsDeep(Base other) {
1839        if (!super.equalsDeep(other))
1840          return false;
1841        if (!(other instanceof TermActorComponent))
1842          return false;
1843        TermActorComponent o = (TermActorComponent) other;
1844        return compareDeep(entity, o.entity, true) && compareDeep(role, o.role, true);
1845      }
1846
1847      @Override
1848      public boolean equalsShallow(Base other) {
1849        if (!super.equalsShallow(other))
1850          return false;
1851        if (!(other instanceof TermActorComponent))
1852          return false;
1853        TermActorComponent o = (TermActorComponent) other;
1854        return true;
1855      }
1856
1857      public boolean isEmpty() {
1858        return super.isEmpty() && (entity == null || entity.isEmpty()) && (role == null || role.isEmpty())
1859          ;
1860      }
1861
1862  public String fhirType() {
1863    return "Contract.term.actor";
1864
1865  }
1866
1867  }
1868
1869    @Block()
1870    public static class TermValuedItemComponent extends BackboneElement implements IBaseBackboneElement {
1871        /**
1872         * Specific type of Contract Provision Valued Item that may be priced.
1873         */
1874        @Child(name = "entity", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
1875        @Description(shortDefinition="Contract Term Valued Item Type", formalDefinition="Specific type of Contract Provision Valued Item that may be priced." )
1876        protected Type entity;
1877
1878        /**
1879         * Identifies a Contract Provision Valued Item instance.
1880         */
1881        @Child(name = "identifier", type = {Identifier.class}, order=2, min=0, max=1, modifier=false, summary=false)
1882        @Description(shortDefinition="Contract Term Valued Item Identifier", formalDefinition="Identifies a Contract Provision Valued Item instance." )
1883        protected Identifier identifier;
1884
1885        /**
1886         * Indicates the time during which this Contract Term ValuedItem information is effective.
1887         */
1888        @Child(name = "effectiveTime", type = {DateTimeType.class}, order=3, min=0, max=1, modifier=false, summary=false)
1889        @Description(shortDefinition="Contract Term Valued Item Effective Tiem", formalDefinition="Indicates the time during which this Contract Term ValuedItem information is effective." )
1890        protected DateTimeType effectiveTime;
1891
1892        /**
1893         * Specifies the units by which the Contract Provision Valued Item is measured or counted, and quantifies the countable or measurable Contract Term Valued Item instances.
1894         */
1895        @Child(name = "quantity", type = {SimpleQuantity.class}, order=4, min=0, max=1, modifier=false, summary=false)
1896        @Description(shortDefinition="Contract Term Valued Item Count", formalDefinition="Specifies the units by which the Contract Provision Valued Item is measured or counted, and quantifies the countable or measurable Contract Term Valued Item instances." )
1897        protected SimpleQuantity quantity;
1898
1899        /**
1900         * A Contract Provision Valued Item unit valuation measure.
1901         */
1902        @Child(name = "unitPrice", type = {Money.class}, order=5, min=0, max=1, modifier=false, summary=false)
1903        @Description(shortDefinition="Contract Term Valued Item fee, charge, or cost", formalDefinition="A Contract Provision Valued Item unit valuation measure." )
1904        protected Money unitPrice;
1905
1906        /**
1907         * A real number that represents a multiplier used in determining the overall value of the Contract Provision Valued Item delivered. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
1908         */
1909        @Child(name = "factor", type = {DecimalType.class}, order=6, min=0, max=1, modifier=false, summary=false)
1910        @Description(shortDefinition="Contract Term Valued Item Price Scaling Factor", formalDefinition="A real number that represents a multiplier used in determining the overall value of the Contract Provision Valued Item delivered. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount." )
1911        protected DecimalType factor;
1912
1913        /**
1914         * An amount that expresses the weighting (based on difficulty, cost and/or resource intensiveness) associated with the Contract Provision Valued Item delivered. The concept of Points allows for assignment of point values for a Contract ProvisionValued Item, such that a monetary amount can be assigned to each point.
1915         */
1916        @Child(name = "points", type = {DecimalType.class}, order=7, min=0, max=1, modifier=false, summary=false)
1917        @Description(shortDefinition="Contract Term Valued Item Difficulty Scaling Factor", formalDefinition="An amount that expresses the weighting (based on difficulty, cost and/or resource intensiveness) associated with the Contract Provision Valued Item delivered. The concept of Points allows for assignment of point values for a Contract ProvisionValued Item, such that a monetary amount can be assigned to each point." )
1918        protected DecimalType points;
1919
1920        /**
1921         * Expresses the product of the Contract Provision Valued Item unitQuantity and the unitPriceAmt. For example, the formula: unit Quantity * unit Price (Cost per Point) * factor Number  * points = net Amount. Quantity, factor and points are assumed to be 1 if not supplied.
1922         */
1923        @Child(name = "net", type = {Money.class}, order=8, min=0, max=1, modifier=false, summary=false)
1924        @Description(shortDefinition="Total Contract Term Valued Item Value", formalDefinition="Expresses the product of the Contract Provision Valued Item unitQuantity and the unitPriceAmt. For example, the formula: unit Quantity * unit Price (Cost per Point) * factor Number  * points = net Amount. Quantity, factor and points are assumed to be 1 if not supplied." )
1925        protected Money net;
1926
1927        private static final long serialVersionUID = 1782449516L;
1928
1929    /*
1930     * Constructor
1931     */
1932      public TermValuedItemComponent() {
1933        super();
1934      }
1935
1936        /**
1937         * @return {@link #entity} (Specific type of Contract Provision Valued Item that may be priced.)
1938         */
1939        public Type getEntity() { 
1940          return this.entity;
1941        }
1942
1943        /**
1944         * @return {@link #entity} (Specific type of Contract Provision Valued Item that may be priced.)
1945         */
1946        public CodeableConcept getEntityCodeableConcept() throws FHIRException { 
1947          if (!(this.entity instanceof CodeableConcept))
1948            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.entity.getClass().getName()+" was encountered");
1949          return (CodeableConcept) this.entity;
1950        }
1951
1952        public boolean hasEntityCodeableConcept() { 
1953          return this.entity instanceof CodeableConcept;
1954        }
1955
1956        /**
1957         * @return {@link #entity} (Specific type of Contract Provision Valued Item that may be priced.)
1958         */
1959        public Reference getEntityReference() throws FHIRException { 
1960          if (!(this.entity instanceof Reference))
1961            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.entity.getClass().getName()+" was encountered");
1962          return (Reference) this.entity;
1963        }
1964
1965        public boolean hasEntityReference() { 
1966          return this.entity instanceof Reference;
1967        }
1968
1969        public boolean hasEntity() { 
1970          return this.entity != null && !this.entity.isEmpty();
1971        }
1972
1973        /**
1974         * @param value {@link #entity} (Specific type of Contract Provision Valued Item that may be priced.)
1975         */
1976        public TermValuedItemComponent setEntity(Type value) { 
1977          this.entity = value;
1978          return this;
1979        }
1980
1981        /**
1982         * @return {@link #identifier} (Identifies a Contract Provision Valued Item instance.)
1983         */
1984        public Identifier getIdentifier() { 
1985          if (this.identifier == null)
1986            if (Configuration.errorOnAutoCreate())
1987              throw new Error("Attempt to auto-create TermValuedItemComponent.identifier");
1988            else if (Configuration.doAutoCreate())
1989              this.identifier = new Identifier(); // cc
1990          return this.identifier;
1991        }
1992
1993        public boolean hasIdentifier() { 
1994          return this.identifier != null && !this.identifier.isEmpty();
1995        }
1996
1997        /**
1998         * @param value {@link #identifier} (Identifies a Contract Provision Valued Item instance.)
1999         */
2000        public TermValuedItemComponent setIdentifier(Identifier value) { 
2001          this.identifier = value;
2002          return this;
2003        }
2004
2005        /**
2006         * @return {@link #effectiveTime} (Indicates the time during which this Contract Term ValuedItem information is effective.). This is the underlying object with id, value and extensions. The accessor "getEffectiveTime" gives direct access to the value
2007         */
2008        public DateTimeType getEffectiveTimeElement() { 
2009          if (this.effectiveTime == null)
2010            if (Configuration.errorOnAutoCreate())
2011              throw new Error("Attempt to auto-create TermValuedItemComponent.effectiveTime");
2012            else if (Configuration.doAutoCreate())
2013              this.effectiveTime = new DateTimeType(); // bb
2014          return this.effectiveTime;
2015        }
2016
2017        public boolean hasEffectiveTimeElement() { 
2018          return this.effectiveTime != null && !this.effectiveTime.isEmpty();
2019        }
2020
2021        public boolean hasEffectiveTime() { 
2022          return this.effectiveTime != null && !this.effectiveTime.isEmpty();
2023        }
2024
2025        /**
2026         * @param value {@link #effectiveTime} (Indicates the time during which this Contract Term ValuedItem information is effective.). This is the underlying object with id, value and extensions. The accessor "getEffectiveTime" gives direct access to the value
2027         */
2028        public TermValuedItemComponent setEffectiveTimeElement(DateTimeType value) { 
2029          this.effectiveTime = value;
2030          return this;
2031        }
2032
2033        /**
2034         * @return Indicates the time during which this Contract Term ValuedItem information is effective.
2035         */
2036        public Date getEffectiveTime() { 
2037          return this.effectiveTime == null ? null : this.effectiveTime.getValue();
2038        }
2039
2040        /**
2041         * @param value Indicates the time during which this Contract Term ValuedItem information is effective.
2042         */
2043        public TermValuedItemComponent setEffectiveTime(Date value) { 
2044          if (value == null)
2045            this.effectiveTime = null;
2046          else {
2047            if (this.effectiveTime == null)
2048              this.effectiveTime = new DateTimeType();
2049            this.effectiveTime.setValue(value);
2050          }
2051          return this;
2052        }
2053
2054        /**
2055         * @return {@link #quantity} (Specifies the units by which the Contract Provision Valued Item is measured or counted, and quantifies the countable or measurable Contract Term Valued Item instances.)
2056         */
2057        public SimpleQuantity getQuantity() { 
2058          if (this.quantity == null)
2059            if (Configuration.errorOnAutoCreate())
2060              throw new Error("Attempt to auto-create TermValuedItemComponent.quantity");
2061            else if (Configuration.doAutoCreate())
2062              this.quantity = new SimpleQuantity(); // cc
2063          return this.quantity;
2064        }
2065
2066        public boolean hasQuantity() { 
2067          return this.quantity != null && !this.quantity.isEmpty();
2068        }
2069
2070        /**
2071         * @param value {@link #quantity} (Specifies the units by which the Contract Provision Valued Item is measured or counted, and quantifies the countable or measurable Contract Term Valued Item instances.)
2072         */
2073        public TermValuedItemComponent setQuantity(SimpleQuantity value) { 
2074          this.quantity = value;
2075          return this;
2076        }
2077
2078        /**
2079         * @return {@link #unitPrice} (A Contract Provision Valued Item unit valuation measure.)
2080         */
2081        public Money getUnitPrice() { 
2082          if (this.unitPrice == null)
2083            if (Configuration.errorOnAutoCreate())
2084              throw new Error("Attempt to auto-create TermValuedItemComponent.unitPrice");
2085            else if (Configuration.doAutoCreate())
2086              this.unitPrice = new Money(); // cc
2087          return this.unitPrice;
2088        }
2089
2090        public boolean hasUnitPrice() { 
2091          return this.unitPrice != null && !this.unitPrice.isEmpty();
2092        }
2093
2094        /**
2095         * @param value {@link #unitPrice} (A Contract Provision Valued Item unit valuation measure.)
2096         */
2097        public TermValuedItemComponent setUnitPrice(Money value) { 
2098          this.unitPrice = value;
2099          return this;
2100        }
2101
2102        /**
2103         * @return {@link #factor} (A real number that represents a multiplier used in determining the overall value of the Contract Provision Valued Item delivered. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.). This is the underlying object with id, value and extensions. The accessor "getFactor" gives direct access to the value
2104         */
2105        public DecimalType getFactorElement() { 
2106          if (this.factor == null)
2107            if (Configuration.errorOnAutoCreate())
2108              throw new Error("Attempt to auto-create TermValuedItemComponent.factor");
2109            else if (Configuration.doAutoCreate())
2110              this.factor = new DecimalType(); // bb
2111          return this.factor;
2112        }
2113
2114        public boolean hasFactorElement() { 
2115          return this.factor != null && !this.factor.isEmpty();
2116        }
2117
2118        public boolean hasFactor() { 
2119          return this.factor != null && !this.factor.isEmpty();
2120        }
2121
2122        /**
2123         * @param value {@link #factor} (A real number that represents a multiplier used in determining the overall value of the Contract Provision Valued Item delivered. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.). This is the underlying object with id, value and extensions. The accessor "getFactor" gives direct access to the value
2124         */
2125        public TermValuedItemComponent setFactorElement(DecimalType value) { 
2126          this.factor = value;
2127          return this;
2128        }
2129
2130        /**
2131         * @return A real number that represents a multiplier used in determining the overall value of the Contract Provision Valued Item delivered. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
2132         */
2133        public BigDecimal getFactor() { 
2134          return this.factor == null ? null : this.factor.getValue();
2135        }
2136
2137        /**
2138         * @param value A real number that represents a multiplier used in determining the overall value of the Contract Provision Valued Item delivered. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.
2139         */
2140        public TermValuedItemComponent setFactor(BigDecimal value) { 
2141          if (value == null)
2142            this.factor = null;
2143          else {
2144            if (this.factor == null)
2145              this.factor = new DecimalType();
2146            this.factor.setValue(value);
2147          }
2148          return this;
2149        }
2150
2151        /**
2152         * @return {@link #points} (An amount that expresses the weighting (based on difficulty, cost and/or resource intensiveness) associated with the Contract Provision Valued Item delivered. The concept of Points allows for assignment of point values for a Contract ProvisionValued Item, such that a monetary amount can be assigned to each point.). This is the underlying object with id, value and extensions. The accessor "getPoints" gives direct access to the value
2153         */
2154        public DecimalType getPointsElement() { 
2155          if (this.points == null)
2156            if (Configuration.errorOnAutoCreate())
2157              throw new Error("Attempt to auto-create TermValuedItemComponent.points");
2158            else if (Configuration.doAutoCreate())
2159              this.points = new DecimalType(); // bb
2160          return this.points;
2161        }
2162
2163        public boolean hasPointsElement() { 
2164          return this.points != null && !this.points.isEmpty();
2165        }
2166
2167        public boolean hasPoints() { 
2168          return this.points != null && !this.points.isEmpty();
2169        }
2170
2171        /**
2172         * @param value {@link #points} (An amount that expresses the weighting (based on difficulty, cost and/or resource intensiveness) associated with the Contract Provision Valued Item delivered. The concept of Points allows for assignment of point values for a Contract ProvisionValued Item, such that a monetary amount can be assigned to each point.). This is the underlying object with id, value and extensions. The accessor "getPoints" gives direct access to the value
2173         */
2174        public TermValuedItemComponent setPointsElement(DecimalType value) { 
2175          this.points = value;
2176          return this;
2177        }
2178
2179        /**
2180         * @return An amount that expresses the weighting (based on difficulty, cost and/or resource intensiveness) associated with the Contract Provision Valued Item delivered. The concept of Points allows for assignment of point values for a Contract ProvisionValued Item, such that a monetary amount can be assigned to each point.
2181         */
2182        public BigDecimal getPoints() { 
2183          return this.points == null ? null : this.points.getValue();
2184        }
2185
2186        /**
2187         * @param value An amount that expresses the weighting (based on difficulty, cost and/or resource intensiveness) associated with the Contract Provision Valued Item delivered. The concept of Points allows for assignment of point values for a Contract ProvisionValued Item, such that a monetary amount can be assigned to each point.
2188         */
2189        public TermValuedItemComponent setPoints(BigDecimal value) { 
2190          if (value == null)
2191            this.points = null;
2192          else {
2193            if (this.points == null)
2194              this.points = new DecimalType();
2195            this.points.setValue(value);
2196          }
2197          return this;
2198        }
2199
2200        /**
2201         * @return {@link #net} (Expresses the product of the Contract Provision Valued Item unitQuantity and the unitPriceAmt. For example, the formula: unit Quantity * unit Price (Cost per Point) * factor Number  * points = net Amount. Quantity, factor and points are assumed to be 1 if not supplied.)
2202         */
2203        public Money getNet() { 
2204          if (this.net == null)
2205            if (Configuration.errorOnAutoCreate())
2206              throw new Error("Attempt to auto-create TermValuedItemComponent.net");
2207            else if (Configuration.doAutoCreate())
2208              this.net = new Money(); // cc
2209          return this.net;
2210        }
2211
2212        public boolean hasNet() { 
2213          return this.net != null && !this.net.isEmpty();
2214        }
2215
2216        /**
2217         * @param value {@link #net} (Expresses the product of the Contract Provision Valued Item unitQuantity and the unitPriceAmt. For example, the formula: unit Quantity * unit Price (Cost per Point) * factor Number  * points = net Amount. Quantity, factor and points are assumed to be 1 if not supplied.)
2218         */
2219        public TermValuedItemComponent setNet(Money value) { 
2220          this.net = value;
2221          return this;
2222        }
2223
2224        protected void listChildren(List<Property> childrenList) {
2225          super.listChildren(childrenList);
2226          childrenList.add(new Property("entity[x]", "CodeableConcept|Reference(Any)", "Specific type of Contract Provision Valued Item that may be priced.", 0, java.lang.Integer.MAX_VALUE, entity));
2227          childrenList.add(new Property("identifier", "Identifier", "Identifies a Contract Provision Valued Item instance.", 0, java.lang.Integer.MAX_VALUE, identifier));
2228          childrenList.add(new Property("effectiveTime", "dateTime", "Indicates the time during which this Contract Term ValuedItem information is effective.", 0, java.lang.Integer.MAX_VALUE, effectiveTime));
2229          childrenList.add(new Property("quantity", "SimpleQuantity", "Specifies the units by which the Contract Provision Valued Item is measured or counted, and quantifies the countable or measurable Contract Term Valued Item instances.", 0, java.lang.Integer.MAX_VALUE, quantity));
2230          childrenList.add(new Property("unitPrice", "Money", "A Contract Provision Valued Item unit valuation measure.", 0, java.lang.Integer.MAX_VALUE, unitPrice));
2231          childrenList.add(new Property("factor", "decimal", "A real number that represents a multiplier used in determining the overall value of the Contract Provision Valued Item delivered. The concept of a Factor allows for a discount or surcharge multiplier to be applied to a monetary amount.", 0, java.lang.Integer.MAX_VALUE, factor));
2232          childrenList.add(new Property("points", "decimal", "An amount that expresses the weighting (based on difficulty, cost and/or resource intensiveness) associated with the Contract Provision Valued Item delivered. The concept of Points allows for assignment of point values for a Contract ProvisionValued Item, such that a monetary amount can be assigned to each point.", 0, java.lang.Integer.MAX_VALUE, points));
2233          childrenList.add(new Property("net", "Money", "Expresses the product of the Contract Provision Valued Item unitQuantity and the unitPriceAmt. For example, the formula: unit Quantity * unit Price (Cost per Point) * factor Number  * points = net Amount. Quantity, factor and points are assumed to be 1 if not supplied.", 0, java.lang.Integer.MAX_VALUE, net));
2234        }
2235
2236      @Override
2237      public void setProperty(String name, Base value) throws FHIRException {
2238        if (name.equals("entity[x]"))
2239          this.entity = (Type) value; // Type
2240        else if (name.equals("identifier"))
2241          this.identifier = castToIdentifier(value); // Identifier
2242        else if (name.equals("effectiveTime"))
2243          this.effectiveTime = castToDateTime(value); // DateTimeType
2244        else if (name.equals("quantity"))
2245          this.quantity = castToSimpleQuantity(value); // SimpleQuantity
2246        else if (name.equals("unitPrice"))
2247          this.unitPrice = castToMoney(value); // Money
2248        else if (name.equals("factor"))
2249          this.factor = castToDecimal(value); // DecimalType
2250        else if (name.equals("points"))
2251          this.points = castToDecimal(value); // DecimalType
2252        else if (name.equals("net"))
2253          this.net = castToMoney(value); // Money
2254        else
2255          super.setProperty(name, value);
2256      }
2257
2258      @Override
2259      public Base addChild(String name) throws FHIRException {
2260        if (name.equals("entityCodeableConcept")) {
2261          this.entity = new CodeableConcept();
2262          return this.entity;
2263        }
2264        else if (name.equals("entityReference")) {
2265          this.entity = new Reference();
2266          return this.entity;
2267        }
2268        else if (name.equals("identifier")) {
2269          this.identifier = new Identifier();
2270          return this.identifier;
2271        }
2272        else if (name.equals("effectiveTime")) {
2273          throw new FHIRException("Cannot call addChild on a primitive type Contract.effectiveTime");
2274        }
2275        else if (name.equals("quantity")) {
2276          this.quantity = new SimpleQuantity();
2277          return this.quantity;
2278        }
2279        else if (name.equals("unitPrice")) {
2280          this.unitPrice = new Money();
2281          return this.unitPrice;
2282        }
2283        else if (name.equals("factor")) {
2284          throw new FHIRException("Cannot call addChild on a primitive type Contract.factor");
2285        }
2286        else if (name.equals("points")) {
2287          throw new FHIRException("Cannot call addChild on a primitive type Contract.points");
2288        }
2289        else if (name.equals("net")) {
2290          this.net = new Money();
2291          return this.net;
2292        }
2293        else
2294          return super.addChild(name);
2295      }
2296
2297      public TermValuedItemComponent copy() {
2298        TermValuedItemComponent dst = new TermValuedItemComponent();
2299        copyValues(dst);
2300        dst.entity = entity == null ? null : entity.copy();
2301        dst.identifier = identifier == null ? null : identifier.copy();
2302        dst.effectiveTime = effectiveTime == null ? null : effectiveTime.copy();
2303        dst.quantity = quantity == null ? null : quantity.copy();
2304        dst.unitPrice = unitPrice == null ? null : unitPrice.copy();
2305        dst.factor = factor == null ? null : factor.copy();
2306        dst.points = points == null ? null : points.copy();
2307        dst.net = net == null ? null : net.copy();
2308        return dst;
2309      }
2310
2311      @Override
2312      public boolean equalsDeep(Base other) {
2313        if (!super.equalsDeep(other))
2314          return false;
2315        if (!(other instanceof TermValuedItemComponent))
2316          return false;
2317        TermValuedItemComponent o = (TermValuedItemComponent) other;
2318        return compareDeep(entity, o.entity, true) && compareDeep(identifier, o.identifier, true) && compareDeep(effectiveTime, o.effectiveTime, true)
2319           && compareDeep(quantity, o.quantity, true) && compareDeep(unitPrice, o.unitPrice, true) && compareDeep(factor, o.factor, true)
2320           && compareDeep(points, o.points, true) && compareDeep(net, o.net, true);
2321      }
2322
2323      @Override
2324      public boolean equalsShallow(Base other) {
2325        if (!super.equalsShallow(other))
2326          return false;
2327        if (!(other instanceof TermValuedItemComponent))
2328          return false;
2329        TermValuedItemComponent o = (TermValuedItemComponent) other;
2330        return compareValues(effectiveTime, o.effectiveTime, true) && compareValues(factor, o.factor, true)
2331           && compareValues(points, o.points, true);
2332      }
2333
2334      public boolean isEmpty() {
2335        return super.isEmpty() && (entity == null || entity.isEmpty()) && (identifier == null || identifier.isEmpty())
2336           && (effectiveTime == null || effectiveTime.isEmpty()) && (quantity == null || quantity.isEmpty())
2337           && (unitPrice == null || unitPrice.isEmpty()) && (factor == null || factor.isEmpty()) && (points == null || points.isEmpty())
2338           && (net == null || net.isEmpty());
2339      }
2340
2341  public String fhirType() {
2342    return "Contract.term.valuedItem";
2343
2344  }
2345
2346  }
2347
2348    @Block()
2349    public static class FriendlyLanguageComponent extends BackboneElement implements IBaseBackboneElement {
2350        /**
2351         * Human readable rendering of this Contract in a format and representation intended to enhance comprehension and ensure understandability.
2352         */
2353        @Child(name = "content", type = {Attachment.class, Composition.class, DocumentReference.class, QuestionnaireResponse.class}, order=1, min=1, max=1, modifier=false, summary=false)
2354        @Description(shortDefinition="Easily comprehended representation of this Contract", formalDefinition="Human readable rendering of this Contract in a format and representation intended to enhance comprehension and ensure understandability." )
2355        protected Type content;
2356
2357        private static final long serialVersionUID = -1763459053L;
2358
2359    /*
2360     * Constructor
2361     */
2362      public FriendlyLanguageComponent() {
2363        super();
2364      }
2365
2366    /*
2367     * Constructor
2368     */
2369      public FriendlyLanguageComponent(Type content) {
2370        super();
2371        this.content = content;
2372      }
2373
2374        /**
2375         * @return {@link #content} (Human readable rendering of this Contract in a format and representation intended to enhance comprehension and ensure understandability.)
2376         */
2377        public Type getContent() { 
2378          return this.content;
2379        }
2380
2381        /**
2382         * @return {@link #content} (Human readable rendering of this Contract in a format and representation intended to enhance comprehension and ensure understandability.)
2383         */
2384        public Attachment getContentAttachment() throws FHIRException { 
2385          if (!(this.content instanceof Attachment))
2386            throw new FHIRException("Type mismatch: the type Attachment was expected, but "+this.content.getClass().getName()+" was encountered");
2387          return (Attachment) this.content;
2388        }
2389
2390        public boolean hasContentAttachment() { 
2391          return this.content instanceof Attachment;
2392        }
2393
2394        /**
2395         * @return {@link #content} (Human readable rendering of this Contract in a format and representation intended to enhance comprehension and ensure understandability.)
2396         */
2397        public Reference getContentReference() throws FHIRException { 
2398          if (!(this.content instanceof Reference))
2399            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.content.getClass().getName()+" was encountered");
2400          return (Reference) this.content;
2401        }
2402
2403        public boolean hasContentReference() { 
2404          return this.content instanceof Reference;
2405        }
2406
2407        public boolean hasContent() { 
2408          return this.content != null && !this.content.isEmpty();
2409        }
2410
2411        /**
2412         * @param value {@link #content} (Human readable rendering of this Contract in a format and representation intended to enhance comprehension and ensure understandability.)
2413         */
2414        public FriendlyLanguageComponent setContent(Type value) { 
2415          this.content = value;
2416          return this;
2417        }
2418
2419        protected void listChildren(List<Property> childrenList) {
2420          super.listChildren(childrenList);
2421          childrenList.add(new Property("content[x]", "Attachment|Reference(Composition|DocumentReference|QuestionnaireResponse)", "Human readable rendering of this Contract in a format and representation intended to enhance comprehension and ensure understandability.", 0, java.lang.Integer.MAX_VALUE, content));
2422        }
2423
2424      @Override
2425      public void setProperty(String name, Base value) throws FHIRException {
2426        if (name.equals("content[x]"))
2427          this.content = (Type) value; // Type
2428        else
2429          super.setProperty(name, value);
2430      }
2431
2432      @Override
2433      public Base addChild(String name) throws FHIRException {
2434        if (name.equals("contentAttachment")) {
2435          this.content = new Attachment();
2436          return this.content;
2437        }
2438        else if (name.equals("contentReference")) {
2439          this.content = new Reference();
2440          return this.content;
2441        }
2442        else
2443          return super.addChild(name);
2444      }
2445
2446      public FriendlyLanguageComponent copy() {
2447        FriendlyLanguageComponent dst = new FriendlyLanguageComponent();
2448        copyValues(dst);
2449        dst.content = content == null ? null : content.copy();
2450        return dst;
2451      }
2452
2453      @Override
2454      public boolean equalsDeep(Base other) {
2455        if (!super.equalsDeep(other))
2456          return false;
2457        if (!(other instanceof FriendlyLanguageComponent))
2458          return false;
2459        FriendlyLanguageComponent o = (FriendlyLanguageComponent) other;
2460        return compareDeep(content, o.content, true);
2461      }
2462
2463      @Override
2464      public boolean equalsShallow(Base other) {
2465        if (!super.equalsShallow(other))
2466          return false;
2467        if (!(other instanceof FriendlyLanguageComponent))
2468          return false;
2469        FriendlyLanguageComponent o = (FriendlyLanguageComponent) other;
2470        return true;
2471      }
2472
2473      public boolean isEmpty() {
2474        return super.isEmpty() && (content == null || content.isEmpty());
2475      }
2476
2477  public String fhirType() {
2478    return "Contract.friendly";
2479
2480  }
2481
2482  }
2483
2484    @Block()
2485    public static class LegalLanguageComponent extends BackboneElement implements IBaseBackboneElement {
2486        /**
2487         * Contract legal text in human renderable form.
2488         */
2489        @Child(name = "content", type = {Attachment.class, Composition.class, DocumentReference.class, QuestionnaireResponse.class}, order=1, min=1, max=1, modifier=false, summary=false)
2490        @Description(shortDefinition="Contract Legal Text", formalDefinition="Contract legal text in human renderable form." )
2491        protected Type content;
2492
2493        private static final long serialVersionUID = -1763459053L;
2494
2495    /*
2496     * Constructor
2497     */
2498      public LegalLanguageComponent() {
2499        super();
2500      }
2501
2502    /*
2503     * Constructor
2504     */
2505      public LegalLanguageComponent(Type content) {
2506        super();
2507        this.content = content;
2508      }
2509
2510        /**
2511         * @return {@link #content} (Contract legal text in human renderable form.)
2512         */
2513        public Type getContent() { 
2514          return this.content;
2515        }
2516
2517        /**
2518         * @return {@link #content} (Contract legal text in human renderable form.)
2519         */
2520        public Attachment getContentAttachment() throws FHIRException { 
2521          if (!(this.content instanceof Attachment))
2522            throw new FHIRException("Type mismatch: the type Attachment was expected, but "+this.content.getClass().getName()+" was encountered");
2523          return (Attachment) this.content;
2524        }
2525
2526        public boolean hasContentAttachment() { 
2527          return this.content instanceof Attachment;
2528        }
2529
2530        /**
2531         * @return {@link #content} (Contract legal text in human renderable form.)
2532         */
2533        public Reference getContentReference() throws FHIRException { 
2534          if (!(this.content instanceof Reference))
2535            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.content.getClass().getName()+" was encountered");
2536          return (Reference) this.content;
2537        }
2538
2539        public boolean hasContentReference() { 
2540          return this.content instanceof Reference;
2541        }
2542
2543        public boolean hasContent() { 
2544          return this.content != null && !this.content.isEmpty();
2545        }
2546
2547        /**
2548         * @param value {@link #content} (Contract legal text in human renderable form.)
2549         */
2550        public LegalLanguageComponent setContent(Type value) { 
2551          this.content = value;
2552          return this;
2553        }
2554
2555        protected void listChildren(List<Property> childrenList) {
2556          super.listChildren(childrenList);
2557          childrenList.add(new Property("content[x]", "Attachment|Reference(Composition|DocumentReference|QuestionnaireResponse)", "Contract legal text in human renderable form.", 0, java.lang.Integer.MAX_VALUE, content));
2558        }
2559
2560      @Override
2561      public void setProperty(String name, Base value) throws FHIRException {
2562        if (name.equals("content[x]"))
2563          this.content = (Type) value; // Type
2564        else
2565          super.setProperty(name, value);
2566      }
2567
2568      @Override
2569      public Base addChild(String name) throws FHIRException {
2570        if (name.equals("contentAttachment")) {
2571          this.content = new Attachment();
2572          return this.content;
2573        }
2574        else if (name.equals("contentReference")) {
2575          this.content = new Reference();
2576          return this.content;
2577        }
2578        else
2579          return super.addChild(name);
2580      }
2581
2582      public LegalLanguageComponent copy() {
2583        LegalLanguageComponent dst = new LegalLanguageComponent();
2584        copyValues(dst);
2585        dst.content = content == null ? null : content.copy();
2586        return dst;
2587      }
2588
2589      @Override
2590      public boolean equalsDeep(Base other) {
2591        if (!super.equalsDeep(other))
2592          return false;
2593        if (!(other instanceof LegalLanguageComponent))
2594          return false;
2595        LegalLanguageComponent o = (LegalLanguageComponent) other;
2596        return compareDeep(content, o.content, true);
2597      }
2598
2599      @Override
2600      public boolean equalsShallow(Base other) {
2601        if (!super.equalsShallow(other))
2602          return false;
2603        if (!(other instanceof LegalLanguageComponent))
2604          return false;
2605        LegalLanguageComponent o = (LegalLanguageComponent) other;
2606        return true;
2607      }
2608
2609      public boolean isEmpty() {
2610        return super.isEmpty() && (content == null || content.isEmpty());
2611      }
2612
2613  public String fhirType() {
2614    return "Contract.legal";
2615
2616  }
2617
2618  }
2619
2620    @Block()
2621    public static class ComputableLanguageComponent extends BackboneElement implements IBaseBackboneElement {
2622        /**
2623         * Computable Contract conveyed using a policy rule language (e.g. XACML, DKAL, SecPal).
2624         */
2625        @Child(name = "content", type = {Attachment.class, DocumentReference.class}, order=1, min=1, max=1, modifier=false, summary=false)
2626        @Description(shortDefinition="Computable Contract Rules", formalDefinition="Computable Contract conveyed using a policy rule language (e.g. XACML, DKAL, SecPal)." )
2627        protected Type content;
2628
2629        private static final long serialVersionUID = -1763459053L;
2630
2631    /*
2632     * Constructor
2633     */
2634      public ComputableLanguageComponent() {
2635        super();
2636      }
2637
2638    /*
2639     * Constructor
2640     */
2641      public ComputableLanguageComponent(Type content) {
2642        super();
2643        this.content = content;
2644      }
2645
2646        /**
2647         * @return {@link #content} (Computable Contract conveyed using a policy rule language (e.g. XACML, DKAL, SecPal).)
2648         */
2649        public Type getContent() { 
2650          return this.content;
2651        }
2652
2653        /**
2654         * @return {@link #content} (Computable Contract conveyed using a policy rule language (e.g. XACML, DKAL, SecPal).)
2655         */
2656        public Attachment getContentAttachment() throws FHIRException { 
2657          if (!(this.content instanceof Attachment))
2658            throw new FHIRException("Type mismatch: the type Attachment was expected, but "+this.content.getClass().getName()+" was encountered");
2659          return (Attachment) this.content;
2660        }
2661
2662        public boolean hasContentAttachment() { 
2663          return this.content instanceof Attachment;
2664        }
2665
2666        /**
2667         * @return {@link #content} (Computable Contract conveyed using a policy rule language (e.g. XACML, DKAL, SecPal).)
2668         */
2669        public Reference getContentReference() throws FHIRException { 
2670          if (!(this.content instanceof Reference))
2671            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.content.getClass().getName()+" was encountered");
2672          return (Reference) this.content;
2673        }
2674
2675        public boolean hasContentReference() { 
2676          return this.content instanceof Reference;
2677        }
2678
2679        public boolean hasContent() { 
2680          return this.content != null && !this.content.isEmpty();
2681        }
2682
2683        /**
2684         * @param value {@link #content} (Computable Contract conveyed using a policy rule language (e.g. XACML, DKAL, SecPal).)
2685         */
2686        public ComputableLanguageComponent setContent(Type value) { 
2687          this.content = value;
2688          return this;
2689        }
2690
2691        protected void listChildren(List<Property> childrenList) {
2692          super.listChildren(childrenList);
2693          childrenList.add(new Property("content[x]", "Attachment|Reference(DocumentReference)", "Computable Contract conveyed using a policy rule language (e.g. XACML, DKAL, SecPal).", 0, java.lang.Integer.MAX_VALUE, content));
2694        }
2695
2696      @Override
2697      public void setProperty(String name, Base value) throws FHIRException {
2698        if (name.equals("content[x]"))
2699          this.content = (Type) value; // Type
2700        else
2701          super.setProperty(name, value);
2702      }
2703
2704      @Override
2705      public Base addChild(String name) throws FHIRException {
2706        if (name.equals("contentAttachment")) {
2707          this.content = new Attachment();
2708          return this.content;
2709        }
2710        else if (name.equals("contentReference")) {
2711          this.content = new Reference();
2712          return this.content;
2713        }
2714        else
2715          return super.addChild(name);
2716      }
2717
2718      public ComputableLanguageComponent copy() {
2719        ComputableLanguageComponent dst = new ComputableLanguageComponent();
2720        copyValues(dst);
2721        dst.content = content == null ? null : content.copy();
2722        return dst;
2723      }
2724
2725      @Override
2726      public boolean equalsDeep(Base other) {
2727        if (!super.equalsDeep(other))
2728          return false;
2729        if (!(other instanceof ComputableLanguageComponent))
2730          return false;
2731        ComputableLanguageComponent o = (ComputableLanguageComponent) other;
2732        return compareDeep(content, o.content, true);
2733      }
2734
2735      @Override
2736      public boolean equalsShallow(Base other) {
2737        if (!super.equalsShallow(other))
2738          return false;
2739        if (!(other instanceof ComputableLanguageComponent))
2740          return false;
2741        ComputableLanguageComponent o = (ComputableLanguageComponent) other;
2742        return true;
2743      }
2744
2745      public boolean isEmpty() {
2746        return super.isEmpty() && (content == null || content.isEmpty());
2747      }
2748
2749  public String fhirType() {
2750    return "Contract.rule";
2751
2752  }
2753
2754  }
2755
2756    /**
2757     * Unique identifier for this Contract.
2758     */
2759    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=1, modifier=false, summary=true)
2760    @Description(shortDefinition="Contract identifier", formalDefinition="Unique identifier for this Contract." )
2761    protected Identifier identifier;
2762
2763    /**
2764     * When this  Contract was issued.
2765     */
2766    @Child(name = "issued", type = {DateTimeType.class}, order=1, min=0, max=1, modifier=false, summary=true)
2767    @Description(shortDefinition="When this Contract was issued", formalDefinition="When this  Contract was issued." )
2768    protected DateTimeType issued;
2769
2770    /**
2771     * Relevant time or time-period when this Contract is applicable.
2772     */
2773    @Child(name = "applies", type = {Period.class}, order=2, min=0, max=1, modifier=false, summary=true)
2774    @Description(shortDefinition="Effective time", formalDefinition="Relevant time or time-period when this Contract is applicable." )
2775    protected Period applies;
2776
2777    /**
2778     * Who and/or what this Contract is about: typically a Patient, Organization, or valued items such as goods and services.
2779     */
2780    @Child(name = "subject", type = {}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2781    @Description(shortDefinition="Subject of this Contract", formalDefinition="Who and/or what this Contract is about: typically a Patient, Organization, or valued items such as goods and services." )
2782    protected List<Reference> subject;
2783    /**
2784     * The actual objects that are the target of the reference (Who and/or what this Contract is about: typically a Patient, Organization, or valued items such as goods and services.)
2785     */
2786    protected List<Resource> subjectTarget;
2787
2788
2789    /**
2790     * A formally or informally recognized grouping of people, principals, organizations, or jurisdictions formed for the purpose of achieving some form of collective action such as the promulgation, administration and enforcement of contracts and policies.
2791     */
2792    @Child(name = "authority", type = {Organization.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2793    @Description(shortDefinition="Authority under which this Contract has standing", formalDefinition="A formally or informally recognized grouping of people, principals, organizations, or jurisdictions formed for the purpose of achieving some form of collective action such as the promulgation, administration and enforcement of contracts and policies." )
2794    protected List<Reference> authority;
2795    /**
2796     * The actual objects that are the target of the reference (A formally or informally recognized grouping of people, principals, organizations, or jurisdictions formed for the purpose of achieving some form of collective action such as the promulgation, administration and enforcement of contracts and policies.)
2797     */
2798    protected List<Organization> authorityTarget;
2799
2800
2801    /**
2802     * Recognized governance framework or system operating with a circumscribed scope in accordance with specified principles, policies, processes or procedures for managing rights, actions, or behaviors of parties or principals relative to resources.
2803     */
2804    @Child(name = "domain", type = {Location.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2805    @Description(shortDefinition="Domain in which this Contract applies", formalDefinition="Recognized governance framework or system operating with a circumscribed scope in accordance with specified principles, policies, processes or procedures for managing rights, actions, or behaviors of parties or principals relative to resources." )
2806    protected List<Reference> domain;
2807    /**
2808     * The actual objects that are the target of the reference (Recognized governance framework or system operating with a circumscribed scope in accordance with specified principles, policies, processes or procedures for managing rights, actions, or behaviors of parties or principals relative to resources.)
2809     */
2810    protected List<Location> domainTarget;
2811
2812
2813    /**
2814     * Type of Contract such as an insurance policy, real estate contract, a will, power of attorny, Privacy or Security policy , trust framework agreement, etc.
2815     */
2816    @Child(name = "type", type = {CodeableConcept.class}, order=6, min=0, max=1, modifier=false, summary=true)
2817    @Description(shortDefinition="Contract Tyoe", formalDefinition="Type of Contract such as an insurance policy, real estate contract, a will, power of attorny, Privacy or Security policy , trust framework agreement, etc." )
2818    protected CodeableConcept type;
2819
2820    /**
2821     * More specific type or specialization of an overarching or more general contract such as auto insurance, home owner  insurance, prenupial agreement, Advanced-Directive, or privacy consent.
2822     */
2823    @Child(name = "subType", type = {CodeableConcept.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2824    @Description(shortDefinition="Contract Subtype", formalDefinition="More specific type or specialization of an overarching or more general contract such as auto insurance, home owner  insurance, prenupial agreement, Advanced-Directive, or privacy consent." )
2825    protected List<CodeableConcept> subType;
2826
2827    /**
2828     * Action stipulated by this Contract.
2829     */
2830    @Child(name = "action", type = {CodeableConcept.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2831    @Description(shortDefinition="Contract Action", formalDefinition="Action stipulated by this Contract." )
2832    protected List<CodeableConcept> action;
2833
2834    /**
2835     * Reason for action stipulated by this Contract.
2836     */
2837    @Child(name = "actionReason", type = {CodeableConcept.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2838    @Description(shortDefinition="Contract Action Reason", formalDefinition="Reason for action stipulated by this Contract." )
2839    protected List<CodeableConcept> actionReason;
2840
2841    /**
2842     * List of Contract actors.
2843     */
2844    @Child(name = "actor", type = {}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2845    @Description(shortDefinition="Contract Actor", formalDefinition="List of Contract actors." )
2846    protected List<ActorComponent> actor;
2847
2848    /**
2849     * Contract Valued Item List.
2850     */
2851    @Child(name = "valuedItem", type = {}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2852    @Description(shortDefinition="Contract Valued Item", formalDefinition="Contract Valued Item List." )
2853    protected List<ValuedItemComponent> valuedItem;
2854
2855    /**
2856     * Party signing this Contract.
2857     */
2858    @Child(name = "signer", type = {}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2859    @Description(shortDefinition="Contract Signer", formalDefinition="Party signing this Contract." )
2860    protected List<SignatoryComponent> signer;
2861
2862    /**
2863     * One or more Contract Provisions, which may be related and conveyed as a group, and may contain nested groups.
2864     */
2865    @Child(name = "term", type = {}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2866    @Description(shortDefinition="Contract Term List", formalDefinition="One or more Contract Provisions, which may be related and conveyed as a group, and may contain nested groups." )
2867    protected List<TermComponent> term;
2868
2869    /**
2870     * Legally binding Contract: This is the signed and legally recognized representation of the Contract, which is considered the "source of truth" and which would be the basis for legal action related to enforcement of this Contract.
2871     */
2872    @Child(name = "binding", type = {Attachment.class, Composition.class, DocumentReference.class, QuestionnaireResponse.class}, order=14, min=0, max=1, modifier=false, summary=false)
2873    @Description(shortDefinition="Binding Contract", formalDefinition="Legally binding Contract: This is the signed and legally recognized representation of the Contract, which is considered the \"source of truth\" and which would be the basis for legal action related to enforcement of this Contract." )
2874    protected Type binding;
2875
2876    /**
2877     * The "patient friendly language" versionof the Contract in whole or in parts. "Patient friendly language" means the representation of the Contract and Contract Provisions in a manner that is readily accessible and understandable by a layperson in accordance with best practices for communication styles that ensure that those agreeing to or signing the Contract understand the roles, actions, obligations, responsibilities, and implication of the agreement.
2878     */
2879    @Child(name = "friendly", type = {}, order=15, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2880    @Description(shortDefinition="Contract Friendly Language", formalDefinition="The \"patient friendly language\" versionof the Contract in whole or in parts. \"Patient friendly language\" means the representation of the Contract and Contract Provisions in a manner that is readily accessible and understandable by a layperson in accordance with best practices for communication styles that ensure that those agreeing to or signing the Contract understand the roles, actions, obligations, responsibilities, and implication of the agreement." )
2881    protected List<FriendlyLanguageComponent> friendly;
2882
2883    /**
2884     * List of Legal expressions or representations of this Contract.
2885     */
2886    @Child(name = "legal", type = {}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2887    @Description(shortDefinition="Contract Legal Language", formalDefinition="List of Legal expressions or representations of this Contract." )
2888    protected List<LegalLanguageComponent> legal;
2889
2890    /**
2891     * List of Computable Policy Rule Language Representations of this Contract.
2892     */
2893    @Child(name = "rule", type = {}, order=17, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2894    @Description(shortDefinition="Computable Contract Language", formalDefinition="List of Computable Policy Rule Language Representations of this Contract." )
2895    protected List<ComputableLanguageComponent> rule;
2896
2897    private static final long serialVersionUID = -1785608373L;
2898
2899  /*
2900   * Constructor
2901   */
2902    public Contract() {
2903      super();
2904    }
2905
2906    /**
2907     * @return {@link #identifier} (Unique identifier for this Contract.)
2908     */
2909    public Identifier getIdentifier() { 
2910      if (this.identifier == null)
2911        if (Configuration.errorOnAutoCreate())
2912          throw new Error("Attempt to auto-create Contract.identifier");
2913        else if (Configuration.doAutoCreate())
2914          this.identifier = new Identifier(); // cc
2915      return this.identifier;
2916    }
2917
2918    public boolean hasIdentifier() { 
2919      return this.identifier != null && !this.identifier.isEmpty();
2920    }
2921
2922    /**
2923     * @param value {@link #identifier} (Unique identifier for this Contract.)
2924     */
2925    public Contract setIdentifier(Identifier value) { 
2926      this.identifier = value;
2927      return this;
2928    }
2929
2930    /**
2931     * @return {@link #issued} (When this  Contract was issued.). This is the underlying object with id, value and extensions. The accessor "getIssued" gives direct access to the value
2932     */
2933    public DateTimeType getIssuedElement() { 
2934      if (this.issued == null)
2935        if (Configuration.errorOnAutoCreate())
2936          throw new Error("Attempt to auto-create Contract.issued");
2937        else if (Configuration.doAutoCreate())
2938          this.issued = new DateTimeType(); // bb
2939      return this.issued;
2940    }
2941
2942    public boolean hasIssuedElement() { 
2943      return this.issued != null && !this.issued.isEmpty();
2944    }
2945
2946    public boolean hasIssued() { 
2947      return this.issued != null && !this.issued.isEmpty();
2948    }
2949
2950    /**
2951     * @param value {@link #issued} (When this  Contract was issued.). This is the underlying object with id, value and extensions. The accessor "getIssued" gives direct access to the value
2952     */
2953    public Contract setIssuedElement(DateTimeType value) { 
2954      this.issued = value;
2955      return this;
2956    }
2957
2958    /**
2959     * @return When this  Contract was issued.
2960     */
2961    public Date getIssued() { 
2962      return this.issued == null ? null : this.issued.getValue();
2963    }
2964
2965    /**
2966     * @param value When this  Contract was issued.
2967     */
2968    public Contract setIssued(Date value) { 
2969      if (value == null)
2970        this.issued = null;
2971      else {
2972        if (this.issued == null)
2973          this.issued = new DateTimeType();
2974        this.issued.setValue(value);
2975      }
2976      return this;
2977    }
2978
2979    /**
2980     * @return {@link #applies} (Relevant time or time-period when this Contract is applicable.)
2981     */
2982    public Period getApplies() { 
2983      if (this.applies == null)
2984        if (Configuration.errorOnAutoCreate())
2985          throw new Error("Attempt to auto-create Contract.applies");
2986        else if (Configuration.doAutoCreate())
2987          this.applies = new Period(); // cc
2988      return this.applies;
2989    }
2990
2991    public boolean hasApplies() { 
2992      return this.applies != null && !this.applies.isEmpty();
2993    }
2994
2995    /**
2996     * @param value {@link #applies} (Relevant time or time-period when this Contract is applicable.)
2997     */
2998    public Contract setApplies(Period value) { 
2999      this.applies = value;
3000      return this;
3001    }
3002
3003    /**
3004     * @return {@link #subject} (Who and/or what this Contract is about: typically a Patient, Organization, or valued items such as goods and services.)
3005     */
3006    public List<Reference> getSubject() { 
3007      if (this.subject == null)
3008        this.subject = new ArrayList<Reference>();
3009      return this.subject;
3010    }
3011
3012    public boolean hasSubject() { 
3013      if (this.subject == null)
3014        return false;
3015      for (Reference item : this.subject)
3016        if (!item.isEmpty())
3017          return true;
3018      return false;
3019    }
3020
3021    /**
3022     * @return {@link #subject} (Who and/or what this Contract is about: typically a Patient, Organization, or valued items such as goods and services.)
3023     */
3024    // syntactic sugar
3025    public Reference addSubject() { //3
3026      Reference t = new Reference();
3027      if (this.subject == null)
3028        this.subject = new ArrayList<Reference>();
3029      this.subject.add(t);
3030      return t;
3031    }
3032
3033    // syntactic sugar
3034    public Contract addSubject(Reference t) { //3
3035      if (t == null)
3036        return this;
3037      if (this.subject == null)
3038        this.subject = new ArrayList<Reference>();
3039      this.subject.add(t);
3040      return this;
3041    }
3042
3043    /**
3044     * @return {@link #subject} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. Who and/or what this Contract is about: typically a Patient, Organization, or valued items such as goods and services.)
3045     */
3046    public List<Resource> getSubjectTarget() { 
3047      if (this.subjectTarget == null)
3048        this.subjectTarget = new ArrayList<Resource>();
3049      return this.subjectTarget;
3050    }
3051
3052    /**
3053     * @return {@link #authority} (A formally or informally recognized grouping of people, principals, organizations, or jurisdictions formed for the purpose of achieving some form of collective action such as the promulgation, administration and enforcement of contracts and policies.)
3054     */
3055    public List<Reference> getAuthority() { 
3056      if (this.authority == null)
3057        this.authority = new ArrayList<Reference>();
3058      return this.authority;
3059    }
3060
3061    public boolean hasAuthority() { 
3062      if (this.authority == null)
3063        return false;
3064      for (Reference item : this.authority)
3065        if (!item.isEmpty())
3066          return true;
3067      return false;
3068    }
3069
3070    /**
3071     * @return {@link #authority} (A formally or informally recognized grouping of people, principals, organizations, or jurisdictions formed for the purpose of achieving some form of collective action such as the promulgation, administration and enforcement of contracts and policies.)
3072     */
3073    // syntactic sugar
3074    public Reference addAuthority() { //3
3075      Reference t = new Reference();
3076      if (this.authority == null)
3077        this.authority = new ArrayList<Reference>();
3078      this.authority.add(t);
3079      return t;
3080    }
3081
3082    // syntactic sugar
3083    public Contract addAuthority(Reference t) { //3
3084      if (t == null)
3085        return this;
3086      if (this.authority == null)
3087        this.authority = new ArrayList<Reference>();
3088      this.authority.add(t);
3089      return this;
3090    }
3091
3092    /**
3093     * @return {@link #authority} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. A formally or informally recognized grouping of people, principals, organizations, or jurisdictions formed for the purpose of achieving some form of collective action such as the promulgation, administration and enforcement of contracts and policies.)
3094     */
3095    public List<Organization> getAuthorityTarget() { 
3096      if (this.authorityTarget == null)
3097        this.authorityTarget = new ArrayList<Organization>();
3098      return this.authorityTarget;
3099    }
3100
3101    // syntactic sugar
3102    /**
3103     * @return {@link #authority} (Add an actual object that is the target of the reference. The reference library doesn't use these, but you can use this to hold the resources if you resolvethemt. A formally or informally recognized grouping of people, principals, organizations, or jurisdictions formed for the purpose of achieving some form of collective action such as the promulgation, administration and enforcement of contracts and policies.)
3104     */
3105    public Organization addAuthorityTarget() { 
3106      Organization r = new Organization();
3107      if (this.authorityTarget == null)
3108        this.authorityTarget = new ArrayList<Organization>();
3109      this.authorityTarget.add(r);
3110      return r;
3111    }
3112
3113    /**
3114     * @return {@link #domain} (Recognized governance framework or system operating with a circumscribed scope in accordance with specified principles, policies, processes or procedures for managing rights, actions, or behaviors of parties or principals relative to resources.)
3115     */
3116    public List<Reference> getDomain() { 
3117      if (this.domain == null)
3118        this.domain = new ArrayList<Reference>();
3119      return this.domain;
3120    }
3121
3122    public boolean hasDomain() { 
3123      if (this.domain == null)
3124        return false;
3125      for (Reference item : this.domain)
3126        if (!item.isEmpty())
3127          return true;
3128      return false;
3129    }
3130
3131    /**
3132     * @return {@link #domain} (Recognized governance framework or system operating with a circumscribed scope in accordance with specified principles, policies, processes or procedures for managing rights, actions, or behaviors of parties or principals relative to resources.)
3133     */
3134    // syntactic sugar
3135    public Reference addDomain() { //3
3136      Reference t = new Reference();
3137      if (this.domain == null)
3138        this.domain = new ArrayList<Reference>();
3139      this.domain.add(t);
3140      return t;
3141    }
3142
3143    // syntactic sugar
3144    public Contract addDomain(Reference t) { //3
3145      if (t == null)
3146        return this;
3147      if (this.domain == null)
3148        this.domain = new ArrayList<Reference>();
3149      this.domain.add(t);
3150      return this;
3151    }
3152
3153    /**
3154     * @return {@link #domain} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. Recognized governance framework or system operating with a circumscribed scope in accordance with specified principles, policies, processes or procedures for managing rights, actions, or behaviors of parties or principals relative to resources.)
3155     */
3156    public List<Location> getDomainTarget() { 
3157      if (this.domainTarget == null)
3158        this.domainTarget = new ArrayList<Location>();
3159      return this.domainTarget;
3160    }
3161
3162    // syntactic sugar
3163    /**
3164     * @return {@link #domain} (Add an actual object that is the target of the reference. The reference library doesn't use these, but you can use this to hold the resources if you resolvethemt. Recognized governance framework or system operating with a circumscribed scope in accordance with specified principles, policies, processes or procedures for managing rights, actions, or behaviors of parties or principals relative to resources.)
3165     */
3166    public Location addDomainTarget() { 
3167      Location r = new Location();
3168      if (this.domainTarget == null)
3169        this.domainTarget = new ArrayList<Location>();
3170      this.domainTarget.add(r);
3171      return r;
3172    }
3173
3174    /**
3175     * @return {@link #type} (Type of Contract such as an insurance policy, real estate contract, a will, power of attorny, Privacy or Security policy , trust framework agreement, etc.)
3176     */
3177    public CodeableConcept getType() { 
3178      if (this.type == null)
3179        if (Configuration.errorOnAutoCreate())
3180          throw new Error("Attempt to auto-create Contract.type");
3181        else if (Configuration.doAutoCreate())
3182          this.type = new CodeableConcept(); // cc
3183      return this.type;
3184    }
3185
3186    public boolean hasType() { 
3187      return this.type != null && !this.type.isEmpty();
3188    }
3189
3190    /**
3191     * @param value {@link #type} (Type of Contract such as an insurance policy, real estate contract, a will, power of attorny, Privacy or Security policy , trust framework agreement, etc.)
3192     */
3193    public Contract setType(CodeableConcept value) { 
3194      this.type = value;
3195      return this;
3196    }
3197
3198    /**
3199     * @return {@link #subType} (More specific type or specialization of an overarching or more general contract such as auto insurance, home owner  insurance, prenupial agreement, Advanced-Directive, or privacy consent.)
3200     */
3201    public List<CodeableConcept> getSubType() { 
3202      if (this.subType == null)
3203        this.subType = new ArrayList<CodeableConcept>();
3204      return this.subType;
3205    }
3206
3207    public boolean hasSubType() { 
3208      if (this.subType == null)
3209        return false;
3210      for (CodeableConcept item : this.subType)
3211        if (!item.isEmpty())
3212          return true;
3213      return false;
3214    }
3215
3216    /**
3217     * @return {@link #subType} (More specific type or specialization of an overarching or more general contract such as auto insurance, home owner  insurance, prenupial agreement, Advanced-Directive, or privacy consent.)
3218     */
3219    // syntactic sugar
3220    public CodeableConcept addSubType() { //3
3221      CodeableConcept t = new CodeableConcept();
3222      if (this.subType == null)
3223        this.subType = new ArrayList<CodeableConcept>();
3224      this.subType.add(t);
3225      return t;
3226    }
3227
3228    // syntactic sugar
3229    public Contract addSubType(CodeableConcept t) { //3
3230      if (t == null)
3231        return this;
3232      if (this.subType == null)
3233        this.subType = new ArrayList<CodeableConcept>();
3234      this.subType.add(t);
3235      return this;
3236    }
3237
3238    /**
3239     * @return {@link #action} (Action stipulated by this Contract.)
3240     */
3241    public List<CodeableConcept> getAction() { 
3242      if (this.action == null)
3243        this.action = new ArrayList<CodeableConcept>();
3244      return this.action;
3245    }
3246
3247    public boolean hasAction() { 
3248      if (this.action == null)
3249        return false;
3250      for (CodeableConcept item : this.action)
3251        if (!item.isEmpty())
3252          return true;
3253      return false;
3254    }
3255
3256    /**
3257     * @return {@link #action} (Action stipulated by this Contract.)
3258     */
3259    // syntactic sugar
3260    public CodeableConcept addAction() { //3
3261      CodeableConcept t = new CodeableConcept();
3262      if (this.action == null)
3263        this.action = new ArrayList<CodeableConcept>();
3264      this.action.add(t);
3265      return t;
3266    }
3267
3268    // syntactic sugar
3269    public Contract addAction(CodeableConcept t) { //3
3270      if (t == null)
3271        return this;
3272      if (this.action == null)
3273        this.action = new ArrayList<CodeableConcept>();
3274      this.action.add(t);
3275      return this;
3276    }
3277
3278    /**
3279     * @return {@link #actionReason} (Reason for action stipulated by this Contract.)
3280     */
3281    public List<CodeableConcept> getActionReason() { 
3282      if (this.actionReason == null)
3283        this.actionReason = new ArrayList<CodeableConcept>();
3284      return this.actionReason;
3285    }
3286
3287    public boolean hasActionReason() { 
3288      if (this.actionReason == null)
3289        return false;
3290      for (CodeableConcept item : this.actionReason)
3291        if (!item.isEmpty())
3292          return true;
3293      return false;
3294    }
3295
3296    /**
3297     * @return {@link #actionReason} (Reason for action stipulated by this Contract.)
3298     */
3299    // syntactic sugar
3300    public CodeableConcept addActionReason() { //3
3301      CodeableConcept t = new CodeableConcept();
3302      if (this.actionReason == null)
3303        this.actionReason = new ArrayList<CodeableConcept>();
3304      this.actionReason.add(t);
3305      return t;
3306    }
3307
3308    // syntactic sugar
3309    public Contract addActionReason(CodeableConcept t) { //3
3310      if (t == null)
3311        return this;
3312      if (this.actionReason == null)
3313        this.actionReason = new ArrayList<CodeableConcept>();
3314      this.actionReason.add(t);
3315      return this;
3316    }
3317
3318    /**
3319     * @return {@link #actor} (List of Contract actors.)
3320     */
3321    public List<ActorComponent> getActor() { 
3322      if (this.actor == null)
3323        this.actor = new ArrayList<ActorComponent>();
3324      return this.actor;
3325    }
3326
3327    public boolean hasActor() { 
3328      if (this.actor == null)
3329        return false;
3330      for (ActorComponent item : this.actor)
3331        if (!item.isEmpty())
3332          return true;
3333      return false;
3334    }
3335
3336    /**
3337     * @return {@link #actor} (List of Contract actors.)
3338     */
3339    // syntactic sugar
3340    public ActorComponent addActor() { //3
3341      ActorComponent t = new ActorComponent();
3342      if (this.actor == null)
3343        this.actor = new ArrayList<ActorComponent>();
3344      this.actor.add(t);
3345      return t;
3346    }
3347
3348    // syntactic sugar
3349    public Contract addActor(ActorComponent t) { //3
3350      if (t == null)
3351        return this;
3352      if (this.actor == null)
3353        this.actor = new ArrayList<ActorComponent>();
3354      this.actor.add(t);
3355      return this;
3356    }
3357
3358    /**
3359     * @return {@link #valuedItem} (Contract Valued Item List.)
3360     */
3361    public List<ValuedItemComponent> getValuedItem() { 
3362      if (this.valuedItem == null)
3363        this.valuedItem = new ArrayList<ValuedItemComponent>();
3364      return this.valuedItem;
3365    }
3366
3367    public boolean hasValuedItem() { 
3368      if (this.valuedItem == null)
3369        return false;
3370      for (ValuedItemComponent item : this.valuedItem)
3371        if (!item.isEmpty())
3372          return true;
3373      return false;
3374    }
3375
3376    /**
3377     * @return {@link #valuedItem} (Contract Valued Item List.)
3378     */
3379    // syntactic sugar
3380    public ValuedItemComponent addValuedItem() { //3
3381      ValuedItemComponent t = new ValuedItemComponent();
3382      if (this.valuedItem == null)
3383        this.valuedItem = new ArrayList<ValuedItemComponent>();
3384      this.valuedItem.add(t);
3385      return t;
3386    }
3387
3388    // syntactic sugar
3389    public Contract addValuedItem(ValuedItemComponent t) { //3
3390      if (t == null)
3391        return this;
3392      if (this.valuedItem == null)
3393        this.valuedItem = new ArrayList<ValuedItemComponent>();
3394      this.valuedItem.add(t);
3395      return this;
3396    }
3397
3398    /**
3399     * @return {@link #signer} (Party signing this Contract.)
3400     */
3401    public List<SignatoryComponent> getSigner() { 
3402      if (this.signer == null)
3403        this.signer = new ArrayList<SignatoryComponent>();
3404      return this.signer;
3405    }
3406
3407    public boolean hasSigner() { 
3408      if (this.signer == null)
3409        return false;
3410      for (SignatoryComponent item : this.signer)
3411        if (!item.isEmpty())
3412          return true;
3413      return false;
3414    }
3415
3416    /**
3417     * @return {@link #signer} (Party signing this Contract.)
3418     */
3419    // syntactic sugar
3420    public SignatoryComponent addSigner() { //3
3421      SignatoryComponent t = new SignatoryComponent();
3422      if (this.signer == null)
3423        this.signer = new ArrayList<SignatoryComponent>();
3424      this.signer.add(t);
3425      return t;
3426    }
3427
3428    // syntactic sugar
3429    public Contract addSigner(SignatoryComponent t) { //3
3430      if (t == null)
3431        return this;
3432      if (this.signer == null)
3433        this.signer = new ArrayList<SignatoryComponent>();
3434      this.signer.add(t);
3435      return this;
3436    }
3437
3438    /**
3439     * @return {@link #term} (One or more Contract Provisions, which may be related and conveyed as a group, and may contain nested groups.)
3440     */
3441    public List<TermComponent> getTerm() { 
3442      if (this.term == null)
3443        this.term = new ArrayList<TermComponent>();
3444      return this.term;
3445    }
3446
3447    public boolean hasTerm() { 
3448      if (this.term == null)
3449        return false;
3450      for (TermComponent item : this.term)
3451        if (!item.isEmpty())
3452          return true;
3453      return false;
3454    }
3455
3456    /**
3457     * @return {@link #term} (One or more Contract Provisions, which may be related and conveyed as a group, and may contain nested groups.)
3458     */
3459    // syntactic sugar
3460    public TermComponent addTerm() { //3
3461      TermComponent t = new TermComponent();
3462      if (this.term == null)
3463        this.term = new ArrayList<TermComponent>();
3464      this.term.add(t);
3465      return t;
3466    }
3467
3468    // syntactic sugar
3469    public Contract addTerm(TermComponent t) { //3
3470      if (t == null)
3471        return this;
3472      if (this.term == null)
3473        this.term = new ArrayList<TermComponent>();
3474      this.term.add(t);
3475      return this;
3476    }
3477
3478    /**
3479     * @return {@link #binding} (Legally binding Contract: This is the signed and legally recognized representation of the Contract, which is considered the "source of truth" and which would be the basis for legal action related to enforcement of this Contract.)
3480     */
3481    public Type getBinding() { 
3482      return this.binding;
3483    }
3484
3485    /**
3486     * @return {@link #binding} (Legally binding Contract: This is the signed and legally recognized representation of the Contract, which is considered the "source of truth" and which would be the basis for legal action related to enforcement of this Contract.)
3487     */
3488    public Attachment getBindingAttachment() throws FHIRException { 
3489      if (!(this.binding instanceof Attachment))
3490        throw new FHIRException("Type mismatch: the type Attachment was expected, but "+this.binding.getClass().getName()+" was encountered");
3491      return (Attachment) this.binding;
3492    }
3493
3494    public boolean hasBindingAttachment() { 
3495      return this.binding instanceof Attachment;
3496    }
3497
3498    /**
3499     * @return {@link #binding} (Legally binding Contract: This is the signed and legally recognized representation of the Contract, which is considered the "source of truth" and which would be the basis for legal action related to enforcement of this Contract.)
3500     */
3501    public Reference getBindingReference() throws FHIRException { 
3502      if (!(this.binding instanceof Reference))
3503        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.binding.getClass().getName()+" was encountered");
3504      return (Reference) this.binding;
3505    }
3506
3507    public boolean hasBindingReference() { 
3508      return this.binding instanceof Reference;
3509    }
3510
3511    public boolean hasBinding() { 
3512      return this.binding != null && !this.binding.isEmpty();
3513    }
3514
3515    /**
3516     * @param value {@link #binding} (Legally binding Contract: This is the signed and legally recognized representation of the Contract, which is considered the "source of truth" and which would be the basis for legal action related to enforcement of this Contract.)
3517     */
3518    public Contract setBinding(Type value) { 
3519      this.binding = value;
3520      return this;
3521    }
3522
3523    /**
3524     * @return {@link #friendly} (The "patient friendly language" versionof the Contract in whole or in parts. "Patient friendly language" means the representation of the Contract and Contract Provisions in a manner that is readily accessible and understandable by a layperson in accordance with best practices for communication styles that ensure that those agreeing to or signing the Contract understand the roles, actions, obligations, responsibilities, and implication of the agreement.)
3525     */
3526    public List<FriendlyLanguageComponent> getFriendly() { 
3527      if (this.friendly == null)
3528        this.friendly = new ArrayList<FriendlyLanguageComponent>();
3529      return this.friendly;
3530    }
3531
3532    public boolean hasFriendly() { 
3533      if (this.friendly == null)
3534        return false;
3535      for (FriendlyLanguageComponent item : this.friendly)
3536        if (!item.isEmpty())
3537          return true;
3538      return false;
3539    }
3540
3541    /**
3542     * @return {@link #friendly} (The "patient friendly language" versionof the Contract in whole or in parts. "Patient friendly language" means the representation of the Contract and Contract Provisions in a manner that is readily accessible and understandable by a layperson in accordance with best practices for communication styles that ensure that those agreeing to or signing the Contract understand the roles, actions, obligations, responsibilities, and implication of the agreement.)
3543     */
3544    // syntactic sugar
3545    public FriendlyLanguageComponent addFriendly() { //3
3546      FriendlyLanguageComponent t = new FriendlyLanguageComponent();
3547      if (this.friendly == null)
3548        this.friendly = new ArrayList<FriendlyLanguageComponent>();
3549      this.friendly.add(t);
3550      return t;
3551    }
3552
3553    // syntactic sugar
3554    public Contract addFriendly(FriendlyLanguageComponent t) { //3
3555      if (t == null)
3556        return this;
3557      if (this.friendly == null)
3558        this.friendly = new ArrayList<FriendlyLanguageComponent>();
3559      this.friendly.add(t);
3560      return this;
3561    }
3562
3563    /**
3564     * @return {@link #legal} (List of Legal expressions or representations of this Contract.)
3565     */
3566    public List<LegalLanguageComponent> getLegal() { 
3567      if (this.legal == null)
3568        this.legal = new ArrayList<LegalLanguageComponent>();
3569      return this.legal;
3570    }
3571
3572    public boolean hasLegal() { 
3573      if (this.legal == null)
3574        return false;
3575      for (LegalLanguageComponent item : this.legal)
3576        if (!item.isEmpty())
3577          return true;
3578      return false;
3579    }
3580
3581    /**
3582     * @return {@link #legal} (List of Legal expressions or representations of this Contract.)
3583     */
3584    // syntactic sugar
3585    public LegalLanguageComponent addLegal() { //3
3586      LegalLanguageComponent t = new LegalLanguageComponent();
3587      if (this.legal == null)
3588        this.legal = new ArrayList<LegalLanguageComponent>();
3589      this.legal.add(t);
3590      return t;
3591    }
3592
3593    // syntactic sugar
3594    public Contract addLegal(LegalLanguageComponent t) { //3
3595      if (t == null)
3596        return this;
3597      if (this.legal == null)
3598        this.legal = new ArrayList<LegalLanguageComponent>();
3599      this.legal.add(t);
3600      return this;
3601    }
3602
3603    /**
3604     * @return {@link #rule} (List of Computable Policy Rule Language Representations of this Contract.)
3605     */
3606    public List<ComputableLanguageComponent> getRule() { 
3607      if (this.rule == null)
3608        this.rule = new ArrayList<ComputableLanguageComponent>();
3609      return this.rule;
3610    }
3611
3612    public boolean hasRule() { 
3613      if (this.rule == null)
3614        return false;
3615      for (ComputableLanguageComponent item : this.rule)
3616        if (!item.isEmpty())
3617          return true;
3618      return false;
3619    }
3620
3621    /**
3622     * @return {@link #rule} (List of Computable Policy Rule Language Representations of this Contract.)
3623     */
3624    // syntactic sugar
3625    public ComputableLanguageComponent addRule() { //3
3626      ComputableLanguageComponent t = new ComputableLanguageComponent();
3627      if (this.rule == null)
3628        this.rule = new ArrayList<ComputableLanguageComponent>();
3629      this.rule.add(t);
3630      return t;
3631    }
3632
3633    // syntactic sugar
3634    public Contract addRule(ComputableLanguageComponent t) { //3
3635      if (t == null)
3636        return this;
3637      if (this.rule == null)
3638        this.rule = new ArrayList<ComputableLanguageComponent>();
3639      this.rule.add(t);
3640      return this;
3641    }
3642
3643      protected void listChildren(List<Property> childrenList) {
3644        super.listChildren(childrenList);
3645        childrenList.add(new Property("identifier", "Identifier", "Unique identifier for this Contract.", 0, java.lang.Integer.MAX_VALUE, identifier));
3646        childrenList.add(new Property("issued", "dateTime", "When this  Contract was issued.", 0, java.lang.Integer.MAX_VALUE, issued));
3647        childrenList.add(new Property("applies", "Period", "Relevant time or time-period when this Contract is applicable.", 0, java.lang.Integer.MAX_VALUE, applies));
3648        childrenList.add(new Property("subject", "Reference(Any)", "Who and/or what this Contract is about: typically a Patient, Organization, or valued items such as goods and services.", 0, java.lang.Integer.MAX_VALUE, subject));
3649        childrenList.add(new Property("authority", "Reference(Organization)", "A formally or informally recognized grouping of people, principals, organizations, or jurisdictions formed for the purpose of achieving some form of collective action such as the promulgation, administration and enforcement of contracts and policies.", 0, java.lang.Integer.MAX_VALUE, authority));
3650        childrenList.add(new Property("domain", "Reference(Location)", "Recognized governance framework or system operating with a circumscribed scope in accordance with specified principles, policies, processes or procedures for managing rights, actions, or behaviors of parties or principals relative to resources.", 0, java.lang.Integer.MAX_VALUE, domain));
3651        childrenList.add(new Property("type", "CodeableConcept", "Type of Contract such as an insurance policy, real estate contract, a will, power of attorny, Privacy or Security policy , trust framework agreement, etc.", 0, java.lang.Integer.MAX_VALUE, type));
3652        childrenList.add(new Property("subType", "CodeableConcept", "More specific type or specialization of an overarching or more general contract such as auto insurance, home owner  insurance, prenupial agreement, Advanced-Directive, or privacy consent.", 0, java.lang.Integer.MAX_VALUE, subType));
3653        childrenList.add(new Property("action", "CodeableConcept", "Action stipulated by this Contract.", 0, java.lang.Integer.MAX_VALUE, action));
3654        childrenList.add(new Property("actionReason", "CodeableConcept", "Reason for action stipulated by this Contract.", 0, java.lang.Integer.MAX_VALUE, actionReason));
3655        childrenList.add(new Property("actor", "", "List of Contract actors.", 0, java.lang.Integer.MAX_VALUE, actor));
3656        childrenList.add(new Property("valuedItem", "", "Contract Valued Item List.", 0, java.lang.Integer.MAX_VALUE, valuedItem));
3657        childrenList.add(new Property("signer", "", "Party signing this Contract.", 0, java.lang.Integer.MAX_VALUE, signer));
3658        childrenList.add(new Property("term", "", "One or more Contract Provisions, which may be related and conveyed as a group, and may contain nested groups.", 0, java.lang.Integer.MAX_VALUE, term));
3659        childrenList.add(new Property("binding[x]", "Attachment|Reference(Composition|DocumentReference|QuestionnaireResponse)", "Legally binding Contract: This is the signed and legally recognized representation of the Contract, which is considered the \"source of truth\" and which would be the basis for legal action related to enforcement of this Contract.", 0, java.lang.Integer.MAX_VALUE, binding));
3660        childrenList.add(new Property("friendly", "", "The \"patient friendly language\" versionof the Contract in whole or in parts. \"Patient friendly language\" means the representation of the Contract and Contract Provisions in a manner that is readily accessible and understandable by a layperson in accordance with best practices for communication styles that ensure that those agreeing to or signing the Contract understand the roles, actions, obligations, responsibilities, and implication of the agreement.", 0, java.lang.Integer.MAX_VALUE, friendly));
3661        childrenList.add(new Property("legal", "", "List of Legal expressions or representations of this Contract.", 0, java.lang.Integer.MAX_VALUE, legal));
3662        childrenList.add(new Property("rule", "", "List of Computable Policy Rule Language Representations of this Contract.", 0, java.lang.Integer.MAX_VALUE, rule));
3663      }
3664
3665      @Override
3666      public void setProperty(String name, Base value) throws FHIRException {
3667        if (name.equals("identifier"))
3668          this.identifier = castToIdentifier(value); // Identifier
3669        else if (name.equals("issued"))
3670          this.issued = castToDateTime(value); // DateTimeType
3671        else if (name.equals("applies"))
3672          this.applies = castToPeriod(value); // Period
3673        else if (name.equals("subject"))
3674          this.getSubject().add(castToReference(value));
3675        else if (name.equals("authority"))
3676          this.getAuthority().add(castToReference(value));
3677        else if (name.equals("domain"))
3678          this.getDomain().add(castToReference(value));
3679        else if (name.equals("type"))
3680          this.type = castToCodeableConcept(value); // CodeableConcept
3681        else if (name.equals("subType"))
3682          this.getSubType().add(castToCodeableConcept(value));
3683        else if (name.equals("action"))
3684          this.getAction().add(castToCodeableConcept(value));
3685        else if (name.equals("actionReason"))
3686          this.getActionReason().add(castToCodeableConcept(value));
3687        else if (name.equals("actor"))
3688          this.getActor().add((ActorComponent) value);
3689        else if (name.equals("valuedItem"))
3690          this.getValuedItem().add((ValuedItemComponent) value);
3691        else if (name.equals("signer"))
3692          this.getSigner().add((SignatoryComponent) value);
3693        else if (name.equals("term"))
3694          this.getTerm().add((TermComponent) value);
3695        else if (name.equals("binding[x]"))
3696          this.binding = (Type) value; // Type
3697        else if (name.equals("friendly"))
3698          this.getFriendly().add((FriendlyLanguageComponent) value);
3699        else if (name.equals("legal"))
3700          this.getLegal().add((LegalLanguageComponent) value);
3701        else if (name.equals("rule"))
3702          this.getRule().add((ComputableLanguageComponent) value);
3703        else
3704          super.setProperty(name, value);
3705      }
3706
3707      @Override
3708      public Base addChild(String name) throws FHIRException {
3709        if (name.equals("identifier")) {
3710          this.identifier = new Identifier();
3711          return this.identifier;
3712        }
3713        else if (name.equals("issued")) {
3714          throw new FHIRException("Cannot call addChild on a primitive type Contract.issued");
3715        }
3716        else if (name.equals("applies")) {
3717          this.applies = new Period();
3718          return this.applies;
3719        }
3720        else if (name.equals("subject")) {
3721          return addSubject();
3722        }
3723        else if (name.equals("authority")) {
3724          return addAuthority();
3725        }
3726        else if (name.equals("domain")) {
3727          return addDomain();
3728        }
3729        else if (name.equals("type")) {
3730          this.type = new CodeableConcept();
3731          return this.type;
3732        }
3733        else if (name.equals("subType")) {
3734          return addSubType();
3735        }
3736        else if (name.equals("action")) {
3737          return addAction();
3738        }
3739        else if (name.equals("actionReason")) {
3740          return addActionReason();
3741        }
3742        else if (name.equals("actor")) {
3743          return addActor();
3744        }
3745        else if (name.equals("valuedItem")) {
3746          return addValuedItem();
3747        }
3748        else if (name.equals("signer")) {
3749          return addSigner();
3750        }
3751        else if (name.equals("term")) {
3752          return addTerm();
3753        }
3754        else if (name.equals("bindingAttachment")) {
3755          this.binding = new Attachment();
3756          return this.binding;
3757        }
3758        else if (name.equals("bindingReference")) {
3759          this.binding = new Reference();
3760          return this.binding;
3761        }
3762        else if (name.equals("friendly")) {
3763          return addFriendly();
3764        }
3765        else if (name.equals("legal")) {
3766          return addLegal();
3767        }
3768        else if (name.equals("rule")) {
3769          return addRule();
3770        }
3771        else
3772          return super.addChild(name);
3773      }
3774
3775  public String fhirType() {
3776    return "Contract";
3777
3778  }
3779
3780      public Contract copy() {
3781        Contract dst = new Contract();
3782        copyValues(dst);
3783        dst.identifier = identifier == null ? null : identifier.copy();
3784        dst.issued = issued == null ? null : issued.copy();
3785        dst.applies = applies == null ? null : applies.copy();
3786        if (subject != null) {
3787          dst.subject = new ArrayList<Reference>();
3788          for (Reference i : subject)
3789            dst.subject.add(i.copy());
3790        };
3791        if (authority != null) {
3792          dst.authority = new ArrayList<Reference>();
3793          for (Reference i : authority)
3794            dst.authority.add(i.copy());
3795        };
3796        if (domain != null) {
3797          dst.domain = new ArrayList<Reference>();
3798          for (Reference i : domain)
3799            dst.domain.add(i.copy());
3800        };
3801        dst.type = type == null ? null : type.copy();
3802        if (subType != null) {
3803          dst.subType = new ArrayList<CodeableConcept>();
3804          for (CodeableConcept i : subType)
3805            dst.subType.add(i.copy());
3806        };
3807        if (action != null) {
3808          dst.action = new ArrayList<CodeableConcept>();
3809          for (CodeableConcept i : action)
3810            dst.action.add(i.copy());
3811        };
3812        if (actionReason != null) {
3813          dst.actionReason = new ArrayList<CodeableConcept>();
3814          for (CodeableConcept i : actionReason)
3815            dst.actionReason.add(i.copy());
3816        };
3817        if (actor != null) {
3818          dst.actor = new ArrayList<ActorComponent>();
3819          for (ActorComponent i : actor)
3820            dst.actor.add(i.copy());
3821        };
3822        if (valuedItem != null) {
3823          dst.valuedItem = new ArrayList<ValuedItemComponent>();
3824          for (ValuedItemComponent i : valuedItem)
3825            dst.valuedItem.add(i.copy());
3826        };
3827        if (signer != null) {
3828          dst.signer = new ArrayList<SignatoryComponent>();
3829          for (SignatoryComponent i : signer)
3830            dst.signer.add(i.copy());
3831        };
3832        if (term != null) {
3833          dst.term = new ArrayList<TermComponent>();
3834          for (TermComponent i : term)
3835            dst.term.add(i.copy());
3836        };
3837        dst.binding = binding == null ? null : binding.copy();
3838        if (friendly != null) {
3839          dst.friendly = new ArrayList<FriendlyLanguageComponent>();
3840          for (FriendlyLanguageComponent i : friendly)
3841            dst.friendly.add(i.copy());
3842        };
3843        if (legal != null) {
3844          dst.legal = new ArrayList<LegalLanguageComponent>();
3845          for (LegalLanguageComponent i : legal)
3846            dst.legal.add(i.copy());
3847        };
3848        if (rule != null) {
3849          dst.rule = new ArrayList<ComputableLanguageComponent>();
3850          for (ComputableLanguageComponent i : rule)
3851            dst.rule.add(i.copy());
3852        };
3853        return dst;
3854      }
3855
3856      protected Contract typedCopy() {
3857        return copy();
3858      }
3859
3860      @Override
3861      public boolean equalsDeep(Base other) {
3862        if (!super.equalsDeep(other))
3863          return false;
3864        if (!(other instanceof Contract))
3865          return false;
3866        Contract o = (Contract) other;
3867        return compareDeep(identifier, o.identifier, true) && compareDeep(issued, o.issued, true) && compareDeep(applies, o.applies, true)
3868           && compareDeep(subject, o.subject, true) && compareDeep(authority, o.authority, true) && compareDeep(domain, o.domain, true)
3869           && compareDeep(type, o.type, true) && compareDeep(subType, o.subType, true) && compareDeep(action, o.action, true)
3870           && compareDeep(actionReason, o.actionReason, true) && compareDeep(actor, o.actor, true) && compareDeep(valuedItem, o.valuedItem, true)
3871           && compareDeep(signer, o.signer, true) && compareDeep(term, o.term, true) && compareDeep(binding, o.binding, true)
3872           && compareDeep(friendly, o.friendly, true) && compareDeep(legal, o.legal, true) && compareDeep(rule, o.rule, true)
3873          ;
3874      }
3875
3876      @Override
3877      public boolean equalsShallow(Base other) {
3878        if (!super.equalsShallow(other))
3879          return false;
3880        if (!(other instanceof Contract))
3881          return false;
3882        Contract o = (Contract) other;
3883        return compareValues(issued, o.issued, true);
3884      }
3885
3886      public boolean isEmpty() {
3887        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (issued == null || issued.isEmpty())
3888           && (applies == null || applies.isEmpty()) && (subject == null || subject.isEmpty()) && (authority == null || authority.isEmpty())
3889           && (domain == null || domain.isEmpty()) && (type == null || type.isEmpty()) && (subType == null || subType.isEmpty())
3890           && (action == null || action.isEmpty()) && (actionReason == null || actionReason.isEmpty())
3891           && (actor == null || actor.isEmpty()) && (valuedItem == null || valuedItem.isEmpty()) && (signer == null || signer.isEmpty())
3892           && (term == null || term.isEmpty()) && (binding == null || binding.isEmpty()) && (friendly == null || friendly.isEmpty())
3893           && (legal == null || legal.isEmpty()) && (rule == null || rule.isEmpty());
3894      }
3895
3896  @Override
3897  public ResourceType getResourceType() {
3898    return ResourceType.Contract;
3899   }
3900
3901  @SearchParamDefinition(name="actor", path="Contract.actor.entity", description="Contract Actor Type", type="reference" )
3902  public static final String SP_ACTOR = "actor";
3903  @SearchParamDefinition(name="identifier", path="Contract.identifier", description="The identity of the contract", type="token" )
3904  public static final String SP_IDENTIFIER = "identifier";
3905  @SearchParamDefinition(name="subject", path="Contract.subject", description="The identity of the target of the contract", type="reference" )
3906  public static final String SP_SUBJECT = "subject";
3907  @SearchParamDefinition(name="patient", path="Contract.subject", description="The identity of the target of the contract (if a patient)", type="reference" )
3908  public static final String SP_PATIENT = "patient";
3909  @SearchParamDefinition(name="signer", path="Contract.signer.party", description="Contract Signatory Party", type="reference" )
3910  public static final String SP_SIGNER = "signer";
3911
3912}
3913