001package org.hl7.fhir.dstu2016may.model;
002
003
004
005
006/*
007  Copyright (c) 2011+, HL7, Inc.
008  All rights reserved.
009  
010  Redistribution and use in source and binary forms, with or without modification, 
011  are permitted provided that the following conditions are met:
012  
013   * Redistributions of source code must retain the above copyright notice, this 
014     list of conditions and the following disclaimer.
015   * Redistributions in binary form must reproduce the above copyright notice, 
016     this list of conditions and the following disclaimer in the documentation 
017     and/or other materials provided with the distribution.
018   * Neither the name of HL7 nor the names of its contributors may be used to 
019     endorse or promote products derived from this software without specific 
020     prior written permission.
021  
022  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
023  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
024  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
025  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
026  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
027  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
028  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
029  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
030  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
031  POSSIBILITY OF SUCH DAMAGE.
032  
033*/
034
035// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
036import java.util.ArrayList;
037import java.util.List;
038
039import org.hl7.fhir.exceptions.FHIRException;
040import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
041import org.hl7.fhir.utilities.Utilities;
042
043import ca.uhn.fhir.model.api.annotation.Block;
044import ca.uhn.fhir.model.api.annotation.Child;
045import ca.uhn.fhir.model.api.annotation.Description;
046import ca.uhn.fhir.model.api.annotation.ResourceDef;
047import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
048/**
049 * Represents a defined collection of entities that may be discussed or acted upon collectively but which are not expected to act collectively and are not formally or legally recognized; i.e. a collection of entities that isn't an Organization.
050 */
051@ResourceDef(name="Group", profile="http://hl7.org/fhir/Profile/Group")
052public class Group extends DomainResource {
053
054    public enum GroupType {
055        /**
056         * Group contains "person" Patient resources
057         */
058        PERSON, 
059        /**
060         * Group contains "animal" Patient resources
061         */
062        ANIMAL, 
063        /**
064         * Group contains healthcare practitioner resources
065         */
066        PRACTITIONER, 
067        /**
068         * Group contains Device resources
069         */
070        DEVICE, 
071        /**
072         * Group contains Medication resources
073         */
074        MEDICATION, 
075        /**
076         * Group contains Substance resources
077         */
078        SUBSTANCE, 
079        /**
080         * added to help the parsers
081         */
082        NULL;
083        public static GroupType fromCode(String codeString) throws FHIRException {
084            if (codeString == null || "".equals(codeString))
085                return null;
086        if ("person".equals(codeString))
087          return PERSON;
088        if ("animal".equals(codeString))
089          return ANIMAL;
090        if ("practitioner".equals(codeString))
091          return PRACTITIONER;
092        if ("device".equals(codeString))
093          return DEVICE;
094        if ("medication".equals(codeString))
095          return MEDICATION;
096        if ("substance".equals(codeString))
097          return SUBSTANCE;
098        throw new FHIRException("Unknown GroupType code '"+codeString+"'");
099        }
100        public String toCode() {
101          switch (this) {
102            case PERSON: return "person";
103            case ANIMAL: return "animal";
104            case PRACTITIONER: return "practitioner";
105            case DEVICE: return "device";
106            case MEDICATION: return "medication";
107            case SUBSTANCE: return "substance";
108            case NULL: return null;
109            default: return "?";
110          }
111        }
112        public String getSystem() {
113          switch (this) {
114            case PERSON: return "http://hl7.org/fhir/group-type";
115            case ANIMAL: return "http://hl7.org/fhir/group-type";
116            case PRACTITIONER: return "http://hl7.org/fhir/group-type";
117            case DEVICE: return "http://hl7.org/fhir/group-type";
118            case MEDICATION: return "http://hl7.org/fhir/group-type";
119            case SUBSTANCE: return "http://hl7.org/fhir/group-type";
120            case NULL: return null;
121            default: return "?";
122          }
123        }
124        public String getDefinition() {
125          switch (this) {
126            case PERSON: return "Group contains \"person\" Patient resources";
127            case ANIMAL: return "Group contains \"animal\" Patient resources";
128            case PRACTITIONER: return "Group contains healthcare practitioner resources";
129            case DEVICE: return "Group contains Device resources";
130            case MEDICATION: return "Group contains Medication resources";
131            case SUBSTANCE: return "Group contains Substance resources";
132            case NULL: return null;
133            default: return "?";
134          }
135        }
136        public String getDisplay() {
137          switch (this) {
138            case PERSON: return "Person";
139            case ANIMAL: return "Animal";
140            case PRACTITIONER: return "Practitioner";
141            case DEVICE: return "Device";
142            case MEDICATION: return "Medication";
143            case SUBSTANCE: return "Substance";
144            case NULL: return null;
145            default: return "?";
146          }
147        }
148    }
149
150  public static class GroupTypeEnumFactory implements EnumFactory<GroupType> {
151    public GroupType fromCode(String codeString) throws IllegalArgumentException {
152      if (codeString == null || "".equals(codeString))
153            if (codeString == null || "".equals(codeString))
154                return null;
155        if ("person".equals(codeString))
156          return GroupType.PERSON;
157        if ("animal".equals(codeString))
158          return GroupType.ANIMAL;
159        if ("practitioner".equals(codeString))
160          return GroupType.PRACTITIONER;
161        if ("device".equals(codeString))
162          return GroupType.DEVICE;
163        if ("medication".equals(codeString))
164          return GroupType.MEDICATION;
165        if ("substance".equals(codeString))
166          return GroupType.SUBSTANCE;
167        throw new IllegalArgumentException("Unknown GroupType code '"+codeString+"'");
168        }
169        public Enumeration<GroupType> fromType(Base code) throws FHIRException {
170          if (code == null || code.isEmpty())
171            return null;
172          String codeString = ((PrimitiveType) code).asStringValue();
173          if (codeString == null || "".equals(codeString))
174            return null;
175        if ("person".equals(codeString))
176          return new Enumeration<GroupType>(this, GroupType.PERSON);
177        if ("animal".equals(codeString))
178          return new Enumeration<GroupType>(this, GroupType.ANIMAL);
179        if ("practitioner".equals(codeString))
180          return new Enumeration<GroupType>(this, GroupType.PRACTITIONER);
181        if ("device".equals(codeString))
182          return new Enumeration<GroupType>(this, GroupType.DEVICE);
183        if ("medication".equals(codeString))
184          return new Enumeration<GroupType>(this, GroupType.MEDICATION);
185        if ("substance".equals(codeString))
186          return new Enumeration<GroupType>(this, GroupType.SUBSTANCE);
187        throw new FHIRException("Unknown GroupType code '"+codeString+"'");
188        }
189    public String toCode(GroupType code) {
190      if (code == GroupType.PERSON)
191        return "person";
192      if (code == GroupType.ANIMAL)
193        return "animal";
194      if (code == GroupType.PRACTITIONER)
195        return "practitioner";
196      if (code == GroupType.DEVICE)
197        return "device";
198      if (code == GroupType.MEDICATION)
199        return "medication";
200      if (code == GroupType.SUBSTANCE)
201        return "substance";
202      return "?";
203      }
204    public String toSystem(GroupType code) {
205      return code.getSystem();
206      }
207    }
208
209    @Block()
210    public static class GroupCharacteristicComponent extends BackboneElement implements IBaseBackboneElement {
211        /**
212         * A code that identifies the kind of trait being asserted.
213         */
214        @Child(name = "code", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=false)
215        @Description(shortDefinition="Kind of characteristic", formalDefinition="A code that identifies the kind of trait being asserted." )
216        protected CodeableConcept code;
217
218        /**
219         * The value of the trait that holds (or does not hold - see 'exclude') for members of the group.
220         */
221        @Child(name = "value", type = {CodeableConcept.class, BooleanType.class, Quantity.class, Range.class}, order=2, min=1, max=1, modifier=false, summary=false)
222        @Description(shortDefinition="Value held by characteristic", formalDefinition="The value of the trait that holds (or does not hold - see 'exclude') for members of the group." )
223        protected Type value;
224
225        /**
226         * If true, indicates the characteristic is one that is NOT held by members of the group.
227         */
228        @Child(name = "exclude", type = {BooleanType.class}, order=3, min=1, max=1, modifier=true, summary=false)
229        @Description(shortDefinition="Group includes or excludes", formalDefinition="If true, indicates the characteristic is one that is NOT held by members of the group." )
230        protected BooleanType exclude;
231
232        /**
233         * The period over which the characteristic is tested; e.g. the patient had an operation during the month of June.
234         */
235        @Child(name = "period", type = {Period.class}, order=4, min=0, max=1, modifier=false, summary=false)
236        @Description(shortDefinition="Period over which characteristic is tested", formalDefinition="The period over which the characteristic is tested; e.g. the patient had an operation during the month of June." )
237        protected Period period;
238
239        private static final long serialVersionUID = -1000688967L;
240
241    /**
242     * Constructor
243     */
244      public GroupCharacteristicComponent() {
245        super();
246      }
247
248    /**
249     * Constructor
250     */
251      public GroupCharacteristicComponent(CodeableConcept code, Type value, BooleanType exclude) {
252        super();
253        this.code = code;
254        this.value = value;
255        this.exclude = exclude;
256      }
257
258        /**
259         * @return {@link #code} (A code that identifies the kind of trait being asserted.)
260         */
261        public CodeableConcept getCode() { 
262          if (this.code == null)
263            if (Configuration.errorOnAutoCreate())
264              throw new Error("Attempt to auto-create GroupCharacteristicComponent.code");
265            else if (Configuration.doAutoCreate())
266              this.code = new CodeableConcept(); // cc
267          return this.code;
268        }
269
270        public boolean hasCode() { 
271          return this.code != null && !this.code.isEmpty();
272        }
273
274        /**
275         * @param value {@link #code} (A code that identifies the kind of trait being asserted.)
276         */
277        public GroupCharacteristicComponent setCode(CodeableConcept value) { 
278          this.code = value;
279          return this;
280        }
281
282        /**
283         * @return {@link #value} (The value of the trait that holds (or does not hold - see 'exclude') for members of the group.)
284         */
285        public Type getValue() { 
286          return this.value;
287        }
288
289        /**
290         * @return {@link #value} (The value of the trait that holds (or does not hold - see 'exclude') for members of the group.)
291         */
292        public CodeableConcept getValueCodeableConcept() throws FHIRException { 
293          if (!(this.value instanceof CodeableConcept))
294            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.value.getClass().getName()+" was encountered");
295          return (CodeableConcept) this.value;
296        }
297
298        public boolean hasValueCodeableConcept() { 
299          return this.value instanceof CodeableConcept;
300        }
301
302        /**
303         * @return {@link #value} (The value of the trait that holds (or does not hold - see 'exclude') for members of the group.)
304         */
305        public BooleanType getValueBooleanType() throws FHIRException { 
306          if (!(this.value instanceof BooleanType))
307            throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.value.getClass().getName()+" was encountered");
308          return (BooleanType) this.value;
309        }
310
311        public boolean hasValueBooleanType() { 
312          return this.value instanceof BooleanType;
313        }
314
315        /**
316         * @return {@link #value} (The value of the trait that holds (or does not hold - see 'exclude') for members of the group.)
317         */
318        public Quantity getValueQuantity() throws FHIRException { 
319          if (!(this.value instanceof Quantity))
320            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.value.getClass().getName()+" was encountered");
321          return (Quantity) this.value;
322        }
323
324        public boolean hasValueQuantity() { 
325          return this.value instanceof Quantity;
326        }
327
328        /**
329         * @return {@link #value} (The value of the trait that holds (or does not hold - see 'exclude') for members of the group.)
330         */
331        public Range getValueRange() throws FHIRException { 
332          if (!(this.value instanceof Range))
333            throw new FHIRException("Type mismatch: the type Range was expected, but "+this.value.getClass().getName()+" was encountered");
334          return (Range) this.value;
335        }
336
337        public boolean hasValueRange() { 
338          return this.value instanceof Range;
339        }
340
341        public boolean hasValue() { 
342          return this.value != null && !this.value.isEmpty();
343        }
344
345        /**
346         * @param value {@link #value} (The value of the trait that holds (or does not hold - see 'exclude') for members of the group.)
347         */
348        public GroupCharacteristicComponent setValue(Type value) { 
349          this.value = value;
350          return this;
351        }
352
353        /**
354         * @return {@link #exclude} (If true, indicates the characteristic is one that is NOT held by members of the group.). This is the underlying object with id, value and extensions. The accessor "getExclude" gives direct access to the value
355         */
356        public BooleanType getExcludeElement() { 
357          if (this.exclude == null)
358            if (Configuration.errorOnAutoCreate())
359              throw new Error("Attempt to auto-create GroupCharacteristicComponent.exclude");
360            else if (Configuration.doAutoCreate())
361              this.exclude = new BooleanType(); // bb
362          return this.exclude;
363        }
364
365        public boolean hasExcludeElement() { 
366          return this.exclude != null && !this.exclude.isEmpty();
367        }
368
369        public boolean hasExclude() { 
370          return this.exclude != null && !this.exclude.isEmpty();
371        }
372
373        /**
374         * @param value {@link #exclude} (If true, indicates the characteristic is one that is NOT held by members of the group.). This is the underlying object with id, value and extensions. The accessor "getExclude" gives direct access to the value
375         */
376        public GroupCharacteristicComponent setExcludeElement(BooleanType value) { 
377          this.exclude = value;
378          return this;
379        }
380
381        /**
382         * @return If true, indicates the characteristic is one that is NOT held by members of the group.
383         */
384        public boolean getExclude() { 
385          return this.exclude == null || this.exclude.isEmpty() ? false : this.exclude.getValue();
386        }
387
388        /**
389         * @param value If true, indicates the characteristic is one that is NOT held by members of the group.
390         */
391        public GroupCharacteristicComponent setExclude(boolean value) { 
392            if (this.exclude == null)
393              this.exclude = new BooleanType();
394            this.exclude.setValue(value);
395          return this;
396        }
397
398        /**
399         * @return {@link #period} (The period over which the characteristic is tested; e.g. the patient had an operation during the month of June.)
400         */
401        public Period getPeriod() { 
402          if (this.period == null)
403            if (Configuration.errorOnAutoCreate())
404              throw new Error("Attempt to auto-create GroupCharacteristicComponent.period");
405            else if (Configuration.doAutoCreate())
406              this.period = new Period(); // cc
407          return this.period;
408        }
409
410        public boolean hasPeriod() { 
411          return this.period != null && !this.period.isEmpty();
412        }
413
414        /**
415         * @param value {@link #period} (The period over which the characteristic is tested; e.g. the patient had an operation during the month of June.)
416         */
417        public GroupCharacteristicComponent setPeriod(Period value) { 
418          this.period = value;
419          return this;
420        }
421
422        protected void listChildren(List<Property> childrenList) {
423          super.listChildren(childrenList);
424          childrenList.add(new Property("code", "CodeableConcept", "A code that identifies the kind of trait being asserted.", 0, java.lang.Integer.MAX_VALUE, code));
425          childrenList.add(new Property("value[x]", "CodeableConcept|boolean|Quantity|Range", "The value of the trait that holds (or does not hold - see 'exclude') for members of the group.", 0, java.lang.Integer.MAX_VALUE, value));
426          childrenList.add(new Property("exclude", "boolean", "If true, indicates the characteristic is one that is NOT held by members of the group.", 0, java.lang.Integer.MAX_VALUE, exclude));
427          childrenList.add(new Property("period", "Period", "The period over which the characteristic is tested; e.g. the patient had an operation during the month of June.", 0, java.lang.Integer.MAX_VALUE, period));
428        }
429
430      @Override
431      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
432        switch (hash) {
433        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
434        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // Type
435        case -1321148966: /*exclude*/ return this.exclude == null ? new Base[0] : new Base[] {this.exclude}; // BooleanType
436        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
437        default: return super.getProperty(hash, name, checkValid);
438        }
439
440      }
441
442      @Override
443      public void setProperty(int hash, String name, Base value) throws FHIRException {
444        switch (hash) {
445        case 3059181: // code
446          this.code = castToCodeableConcept(value); // CodeableConcept
447          break;
448        case 111972721: // value
449          this.value = (Type) value; // Type
450          break;
451        case -1321148966: // exclude
452          this.exclude = castToBoolean(value); // BooleanType
453          break;
454        case -991726143: // period
455          this.period = castToPeriod(value); // Period
456          break;
457        default: super.setProperty(hash, name, value);
458        }
459
460      }
461
462      @Override
463      public void setProperty(String name, Base value) throws FHIRException {
464        if (name.equals("code"))
465          this.code = castToCodeableConcept(value); // CodeableConcept
466        else if (name.equals("value[x]"))
467          this.value = (Type) value; // Type
468        else if (name.equals("exclude"))
469          this.exclude = castToBoolean(value); // BooleanType
470        else if (name.equals("period"))
471          this.period = castToPeriod(value); // Period
472        else
473          super.setProperty(name, value);
474      }
475
476      @Override
477      public Base makeProperty(int hash, String name) throws FHIRException {
478        switch (hash) {
479        case 3059181:  return getCode(); // CodeableConcept
480        case -1410166417:  return getValue(); // Type
481        case -1321148966: throw new FHIRException("Cannot make property exclude as it is not a complex type"); // BooleanType
482        case -991726143:  return getPeriod(); // Period
483        default: return super.makeProperty(hash, name);
484        }
485
486      }
487
488      @Override
489      public Base addChild(String name) throws FHIRException {
490        if (name.equals("code")) {
491          this.code = new CodeableConcept();
492          return this.code;
493        }
494        else if (name.equals("valueCodeableConcept")) {
495          this.value = new CodeableConcept();
496          return this.value;
497        }
498        else if (name.equals("valueBoolean")) {
499          this.value = new BooleanType();
500          return this.value;
501        }
502        else if (name.equals("valueQuantity")) {
503          this.value = new Quantity();
504          return this.value;
505        }
506        else if (name.equals("valueRange")) {
507          this.value = new Range();
508          return this.value;
509        }
510        else if (name.equals("exclude")) {
511          throw new FHIRException("Cannot call addChild on a primitive type Group.exclude");
512        }
513        else if (name.equals("period")) {
514          this.period = new Period();
515          return this.period;
516        }
517        else
518          return super.addChild(name);
519      }
520
521      public GroupCharacteristicComponent copy() {
522        GroupCharacteristicComponent dst = new GroupCharacteristicComponent();
523        copyValues(dst);
524        dst.code = code == null ? null : code.copy();
525        dst.value = value == null ? null : value.copy();
526        dst.exclude = exclude == null ? null : exclude.copy();
527        dst.period = period == null ? null : period.copy();
528        return dst;
529      }
530
531      @Override
532      public boolean equalsDeep(Base other) {
533        if (!super.equalsDeep(other))
534          return false;
535        if (!(other instanceof GroupCharacteristicComponent))
536          return false;
537        GroupCharacteristicComponent o = (GroupCharacteristicComponent) other;
538        return compareDeep(code, o.code, true) && compareDeep(value, o.value, true) && compareDeep(exclude, o.exclude, true)
539           && compareDeep(period, o.period, true);
540      }
541
542      @Override
543      public boolean equalsShallow(Base other) {
544        if (!super.equalsShallow(other))
545          return false;
546        if (!(other instanceof GroupCharacteristicComponent))
547          return false;
548        GroupCharacteristicComponent o = (GroupCharacteristicComponent) other;
549        return compareValues(exclude, o.exclude, true);
550      }
551
552      public boolean isEmpty() {
553        return super.isEmpty() && (code == null || code.isEmpty()) && (value == null || value.isEmpty())
554           && (exclude == null || exclude.isEmpty()) && (period == null || period.isEmpty());
555      }
556
557  public String fhirType() {
558    return "Group.characteristic";
559
560  }
561
562  }
563
564    @Block()
565    public static class GroupMemberComponent extends BackboneElement implements IBaseBackboneElement {
566        /**
567         * A reference to the entity that is a member of the group. Must be consistent with Group.type.
568         */
569        @Child(name = "entity", type = {Patient.class, Practitioner.class, Device.class, Medication.class, Substance.class}, order=1, min=1, max=1, modifier=false, summary=false)
570        @Description(shortDefinition="Reference to the group member", formalDefinition="A reference to the entity that is a member of the group. Must be consistent with Group.type." )
571        protected Reference entity;
572
573        /**
574         * The actual object that is the target of the reference (A reference to the entity that is a member of the group. Must be consistent with Group.type.)
575         */
576        protected Resource entityTarget;
577
578        /**
579         * The period that the member was in the group, if known.
580         */
581        @Child(name = "period", type = {Period.class}, order=2, min=0, max=1, modifier=false, summary=false)
582        @Description(shortDefinition="Period member belonged to the group", formalDefinition="The period that the member was in the group, if known." )
583        protected Period period;
584
585        /**
586         * A flag to indicate that the member is no longer in the group, but previously may have been a member.
587         */
588        @Child(name = "inactive", type = {BooleanType.class}, order=3, min=0, max=1, modifier=false, summary=false)
589        @Description(shortDefinition="If member is no longer in group", formalDefinition="A flag to indicate that the member is no longer in the group, but previously may have been a member." )
590        protected BooleanType inactive;
591
592        private static final long serialVersionUID = -333869055L;
593
594    /**
595     * Constructor
596     */
597      public GroupMemberComponent() {
598        super();
599      }
600
601    /**
602     * Constructor
603     */
604      public GroupMemberComponent(Reference entity) {
605        super();
606        this.entity = entity;
607      }
608
609        /**
610         * @return {@link #entity} (A reference to the entity that is a member of the group. Must be consistent with Group.type.)
611         */
612        public Reference getEntity() { 
613          if (this.entity == null)
614            if (Configuration.errorOnAutoCreate())
615              throw new Error("Attempt to auto-create GroupMemberComponent.entity");
616            else if (Configuration.doAutoCreate())
617              this.entity = new Reference(); // cc
618          return this.entity;
619        }
620
621        public boolean hasEntity() { 
622          return this.entity != null && !this.entity.isEmpty();
623        }
624
625        /**
626         * @param value {@link #entity} (A reference to the entity that is a member of the group. Must be consistent with Group.type.)
627         */
628        public GroupMemberComponent setEntity(Reference value) { 
629          this.entity = value;
630          return this;
631        }
632
633        /**
634         * @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. (A reference to the entity that is a member of the group. Must be consistent with Group.type.)
635         */
636        public Resource getEntityTarget() { 
637          return this.entityTarget;
638        }
639
640        /**
641         * @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. (A reference to the entity that is a member of the group. Must be consistent with Group.type.)
642         */
643        public GroupMemberComponent setEntityTarget(Resource value) { 
644          this.entityTarget = value;
645          return this;
646        }
647
648        /**
649         * @return {@link #period} (The period that the member was in the group, if known.)
650         */
651        public Period getPeriod() { 
652          if (this.period == null)
653            if (Configuration.errorOnAutoCreate())
654              throw new Error("Attempt to auto-create GroupMemberComponent.period");
655            else if (Configuration.doAutoCreate())
656              this.period = new Period(); // cc
657          return this.period;
658        }
659
660        public boolean hasPeriod() { 
661          return this.period != null && !this.period.isEmpty();
662        }
663
664        /**
665         * @param value {@link #period} (The period that the member was in the group, if known.)
666         */
667        public GroupMemberComponent setPeriod(Period value) { 
668          this.period = value;
669          return this;
670        }
671
672        /**
673         * @return {@link #inactive} (A flag to indicate that the member is no longer in the group, but previously may have been a member.). This is the underlying object with id, value and extensions. The accessor "getInactive" gives direct access to the value
674         */
675        public BooleanType getInactiveElement() { 
676          if (this.inactive == null)
677            if (Configuration.errorOnAutoCreate())
678              throw new Error("Attempt to auto-create GroupMemberComponent.inactive");
679            else if (Configuration.doAutoCreate())
680              this.inactive = new BooleanType(); // bb
681          return this.inactive;
682        }
683
684        public boolean hasInactiveElement() { 
685          return this.inactive != null && !this.inactive.isEmpty();
686        }
687
688        public boolean hasInactive() { 
689          return this.inactive != null && !this.inactive.isEmpty();
690        }
691
692        /**
693         * @param value {@link #inactive} (A flag to indicate that the member is no longer in the group, but previously may have been a member.). This is the underlying object with id, value and extensions. The accessor "getInactive" gives direct access to the value
694         */
695        public GroupMemberComponent setInactiveElement(BooleanType value) { 
696          this.inactive = value;
697          return this;
698        }
699
700        /**
701         * @return A flag to indicate that the member is no longer in the group, but previously may have been a member.
702         */
703        public boolean getInactive() { 
704          return this.inactive == null || this.inactive.isEmpty() ? false : this.inactive.getValue();
705        }
706
707        /**
708         * @param value A flag to indicate that the member is no longer in the group, but previously may have been a member.
709         */
710        public GroupMemberComponent setInactive(boolean value) { 
711            if (this.inactive == null)
712              this.inactive = new BooleanType();
713            this.inactive.setValue(value);
714          return this;
715        }
716
717        protected void listChildren(List<Property> childrenList) {
718          super.listChildren(childrenList);
719          childrenList.add(new Property("entity", "Reference(Patient|Practitioner|Device|Medication|Substance)", "A reference to the entity that is a member of the group. Must be consistent with Group.type.", 0, java.lang.Integer.MAX_VALUE, entity));
720          childrenList.add(new Property("period", "Period", "The period that the member was in the group, if known.", 0, java.lang.Integer.MAX_VALUE, period));
721          childrenList.add(new Property("inactive", "boolean", "A flag to indicate that the member is no longer in the group, but previously may have been a member.", 0, java.lang.Integer.MAX_VALUE, inactive));
722        }
723
724      @Override
725      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
726        switch (hash) {
727        case -1298275357: /*entity*/ return this.entity == null ? new Base[0] : new Base[] {this.entity}; // Reference
728        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
729        case 24665195: /*inactive*/ return this.inactive == null ? new Base[0] : new Base[] {this.inactive}; // BooleanType
730        default: return super.getProperty(hash, name, checkValid);
731        }
732
733      }
734
735      @Override
736      public void setProperty(int hash, String name, Base value) throws FHIRException {
737        switch (hash) {
738        case -1298275357: // entity
739          this.entity = castToReference(value); // Reference
740          break;
741        case -991726143: // period
742          this.period = castToPeriod(value); // Period
743          break;
744        case 24665195: // inactive
745          this.inactive = castToBoolean(value); // BooleanType
746          break;
747        default: super.setProperty(hash, name, value);
748        }
749
750      }
751
752      @Override
753      public void setProperty(String name, Base value) throws FHIRException {
754        if (name.equals("entity"))
755          this.entity = castToReference(value); // Reference
756        else if (name.equals("period"))
757          this.period = castToPeriod(value); // Period
758        else if (name.equals("inactive"))
759          this.inactive = castToBoolean(value); // BooleanType
760        else
761          super.setProperty(name, value);
762      }
763
764      @Override
765      public Base makeProperty(int hash, String name) throws FHIRException {
766        switch (hash) {
767        case -1298275357:  return getEntity(); // Reference
768        case -991726143:  return getPeriod(); // Period
769        case 24665195: throw new FHIRException("Cannot make property inactive as it is not a complex type"); // BooleanType
770        default: return super.makeProperty(hash, name);
771        }
772
773      }
774
775      @Override
776      public Base addChild(String name) throws FHIRException {
777        if (name.equals("entity")) {
778          this.entity = new Reference();
779          return this.entity;
780        }
781        else if (name.equals("period")) {
782          this.period = new Period();
783          return this.period;
784        }
785        else if (name.equals("inactive")) {
786          throw new FHIRException("Cannot call addChild on a primitive type Group.inactive");
787        }
788        else
789          return super.addChild(name);
790      }
791
792      public GroupMemberComponent copy() {
793        GroupMemberComponent dst = new GroupMemberComponent();
794        copyValues(dst);
795        dst.entity = entity == null ? null : entity.copy();
796        dst.period = period == null ? null : period.copy();
797        dst.inactive = inactive == null ? null : inactive.copy();
798        return dst;
799      }
800
801      @Override
802      public boolean equalsDeep(Base other) {
803        if (!super.equalsDeep(other))
804          return false;
805        if (!(other instanceof GroupMemberComponent))
806          return false;
807        GroupMemberComponent o = (GroupMemberComponent) other;
808        return compareDeep(entity, o.entity, true) && compareDeep(period, o.period, true) && compareDeep(inactive, o.inactive, true)
809          ;
810      }
811
812      @Override
813      public boolean equalsShallow(Base other) {
814        if (!super.equalsShallow(other))
815          return false;
816        if (!(other instanceof GroupMemberComponent))
817          return false;
818        GroupMemberComponent o = (GroupMemberComponent) other;
819        return compareValues(inactive, o.inactive, true);
820      }
821
822      public boolean isEmpty() {
823        return super.isEmpty() && (entity == null || entity.isEmpty()) && (period == null || period.isEmpty())
824           && (inactive == null || inactive.isEmpty());
825      }
826
827  public String fhirType() {
828    return "Group.member";
829
830  }
831
832  }
833
834    /**
835     * A unique business identifier for this group.
836     */
837    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
838    @Description(shortDefinition="Unique id", formalDefinition="A unique business identifier for this group." )
839    protected List<Identifier> identifier;
840
841    /**
842     * Identifies the broad classification of the kind of resources the group includes.
843     */
844    @Child(name = "type", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=true)
845    @Description(shortDefinition="person | animal | practitioner | device | medication | substance", formalDefinition="Identifies the broad classification of the kind of resources the group includes." )
846    protected Enumeration<GroupType> type;
847
848    /**
849     * If true, indicates that the resource refers to a specific group of real individuals.  If false, the group defines a set of intended individuals.
850     */
851    @Child(name = "actual", type = {BooleanType.class}, order=2, min=1, max=1, modifier=false, summary=true)
852    @Description(shortDefinition="Descriptive or actual", formalDefinition="If true, indicates that the resource refers to a specific group of real individuals.  If false, the group defines a set of intended individuals." )
853    protected BooleanType actual;
854
855    /**
856     * Indicates whether the record for the group is available for use or is merely being retained for historical purposes.
857     */
858    @Child(name = "active", type = {BooleanType.class}, order=3, min=0, max=1, modifier=false, summary=true)
859    @Description(shortDefinition="Whether this group's record is in active use", formalDefinition="Indicates whether the record for the group is available for use or is merely being retained for historical purposes." )
860    protected BooleanType active;
861
862    /**
863     * Provides a specific type of resource the group includes; e.g. "cow", "syringe", etc.
864     */
865    @Child(name = "code", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=true)
866    @Description(shortDefinition="Kind of Group members", formalDefinition="Provides a specific type of resource the group includes; e.g. \"cow\", \"syringe\", etc." )
867    protected CodeableConcept code;
868
869    /**
870     * A label assigned to the group for human identification and communication.
871     */
872    @Child(name = "name", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=true)
873    @Description(shortDefinition="Label for Group", formalDefinition="A label assigned to the group for human identification and communication." )
874    protected StringType name;
875
876    /**
877     * A count of the number of resource instances that are part of the group.
878     */
879    @Child(name = "quantity", type = {UnsignedIntType.class}, order=6, min=0, max=1, modifier=false, summary=true)
880    @Description(shortDefinition="Number of members", formalDefinition="A count of the number of resource instances that are part of the group." )
881    protected UnsignedIntType quantity;
882
883    /**
884     * Identifies the traits shared by members of the group.
885     */
886    @Child(name = "characteristic", type = {}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
887    @Description(shortDefinition="Trait of group members", formalDefinition="Identifies the traits shared by members of the group." )
888    protected List<GroupCharacteristicComponent> characteristic;
889
890    /**
891     * Identifies the resource instances that are members of the group.
892     */
893    @Child(name = "member", type = {}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
894    @Description(shortDefinition="Who or what is in group", formalDefinition="Identifies the resource instances that are members of the group." )
895    protected List<GroupMemberComponent> member;
896
897    private static final long serialVersionUID = -437086579L;
898
899  /**
900   * Constructor
901   */
902    public Group() {
903      super();
904    }
905
906  /**
907   * Constructor
908   */
909    public Group(Enumeration<GroupType> type, BooleanType actual) {
910      super();
911      this.type = type;
912      this.actual = actual;
913    }
914
915    /**
916     * @return {@link #identifier} (A unique business identifier for this group.)
917     */
918    public List<Identifier> getIdentifier() { 
919      if (this.identifier == null)
920        this.identifier = new ArrayList<Identifier>();
921      return this.identifier;
922    }
923
924    public boolean hasIdentifier() { 
925      if (this.identifier == null)
926        return false;
927      for (Identifier item : this.identifier)
928        if (!item.isEmpty())
929          return true;
930      return false;
931    }
932
933    /**
934     * @return {@link #identifier} (A unique business identifier for this group.)
935     */
936    // syntactic sugar
937    public Identifier addIdentifier() { //3
938      Identifier t = new Identifier();
939      if (this.identifier == null)
940        this.identifier = new ArrayList<Identifier>();
941      this.identifier.add(t);
942      return t;
943    }
944
945    // syntactic sugar
946    public Group addIdentifier(Identifier t) { //3
947      if (t == null)
948        return this;
949      if (this.identifier == null)
950        this.identifier = new ArrayList<Identifier>();
951      this.identifier.add(t);
952      return this;
953    }
954
955    /**
956     * @return {@link #type} (Identifies the broad classification of the kind of resources the group includes.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
957     */
958    public Enumeration<GroupType> getTypeElement() { 
959      if (this.type == null)
960        if (Configuration.errorOnAutoCreate())
961          throw new Error("Attempt to auto-create Group.type");
962        else if (Configuration.doAutoCreate())
963          this.type = new Enumeration<GroupType>(new GroupTypeEnumFactory()); // bb
964      return this.type;
965    }
966
967    public boolean hasTypeElement() { 
968      return this.type != null && !this.type.isEmpty();
969    }
970
971    public boolean hasType() { 
972      return this.type != null && !this.type.isEmpty();
973    }
974
975    /**
976     * @param value {@link #type} (Identifies the broad classification of the kind of resources the group includes.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
977     */
978    public Group setTypeElement(Enumeration<GroupType> value) { 
979      this.type = value;
980      return this;
981    }
982
983    /**
984     * @return Identifies the broad classification of the kind of resources the group includes.
985     */
986    public GroupType getType() { 
987      return this.type == null ? null : this.type.getValue();
988    }
989
990    /**
991     * @param value Identifies the broad classification of the kind of resources the group includes.
992     */
993    public Group setType(GroupType value) { 
994        if (this.type == null)
995          this.type = new Enumeration<GroupType>(new GroupTypeEnumFactory());
996        this.type.setValue(value);
997      return this;
998    }
999
1000    /**
1001     * @return {@link #actual} (If true, indicates that the resource refers to a specific group of real individuals.  If false, the group defines a set of intended individuals.). This is the underlying object with id, value and extensions. The accessor "getActual" gives direct access to the value
1002     */
1003    public BooleanType getActualElement() { 
1004      if (this.actual == null)
1005        if (Configuration.errorOnAutoCreate())
1006          throw new Error("Attempt to auto-create Group.actual");
1007        else if (Configuration.doAutoCreate())
1008          this.actual = new BooleanType(); // bb
1009      return this.actual;
1010    }
1011
1012    public boolean hasActualElement() { 
1013      return this.actual != null && !this.actual.isEmpty();
1014    }
1015
1016    public boolean hasActual() { 
1017      return this.actual != null && !this.actual.isEmpty();
1018    }
1019
1020    /**
1021     * @param value {@link #actual} (If true, indicates that the resource refers to a specific group of real individuals.  If false, the group defines a set of intended individuals.). This is the underlying object with id, value and extensions. The accessor "getActual" gives direct access to the value
1022     */
1023    public Group setActualElement(BooleanType value) { 
1024      this.actual = value;
1025      return this;
1026    }
1027
1028    /**
1029     * @return If true, indicates that the resource refers to a specific group of real individuals.  If false, the group defines a set of intended individuals.
1030     */
1031    public boolean getActual() { 
1032      return this.actual == null || this.actual.isEmpty() ? false : this.actual.getValue();
1033    }
1034
1035    /**
1036     * @param value If true, indicates that the resource refers to a specific group of real individuals.  If false, the group defines a set of intended individuals.
1037     */
1038    public Group setActual(boolean value) { 
1039        if (this.actual == null)
1040          this.actual = new BooleanType();
1041        this.actual.setValue(value);
1042      return this;
1043    }
1044
1045    /**
1046     * @return {@link #active} (Indicates whether the record for the group is available for use or is merely being retained for historical purposes.). This is the underlying object with id, value and extensions. The accessor "getActive" gives direct access to the value
1047     */
1048    public BooleanType getActiveElement() { 
1049      if (this.active == null)
1050        if (Configuration.errorOnAutoCreate())
1051          throw new Error("Attempt to auto-create Group.active");
1052        else if (Configuration.doAutoCreate())
1053          this.active = new BooleanType(); // bb
1054      return this.active;
1055    }
1056
1057    public boolean hasActiveElement() { 
1058      return this.active != null && !this.active.isEmpty();
1059    }
1060
1061    public boolean hasActive() { 
1062      return this.active != null && !this.active.isEmpty();
1063    }
1064
1065    /**
1066     * @param value {@link #active} (Indicates whether the record for the group is available for use or is merely being retained for historical purposes.). This is the underlying object with id, value and extensions. The accessor "getActive" gives direct access to the value
1067     */
1068    public Group setActiveElement(BooleanType value) { 
1069      this.active = value;
1070      return this;
1071    }
1072
1073    /**
1074     * @return Indicates whether the record for the group is available for use or is merely being retained for historical purposes.
1075     */
1076    public boolean getActive() { 
1077      return this.active == null || this.active.isEmpty() ? false : this.active.getValue();
1078    }
1079
1080    /**
1081     * @param value Indicates whether the record for the group is available for use or is merely being retained for historical purposes.
1082     */
1083    public Group setActive(boolean value) { 
1084        if (this.active == null)
1085          this.active = new BooleanType();
1086        this.active.setValue(value);
1087      return this;
1088    }
1089
1090    /**
1091     * @return {@link #code} (Provides a specific type of resource the group includes; e.g. "cow", "syringe", etc.)
1092     */
1093    public CodeableConcept getCode() { 
1094      if (this.code == null)
1095        if (Configuration.errorOnAutoCreate())
1096          throw new Error("Attempt to auto-create Group.code");
1097        else if (Configuration.doAutoCreate())
1098          this.code = new CodeableConcept(); // cc
1099      return this.code;
1100    }
1101
1102    public boolean hasCode() { 
1103      return this.code != null && !this.code.isEmpty();
1104    }
1105
1106    /**
1107     * @param value {@link #code} (Provides a specific type of resource the group includes; e.g. "cow", "syringe", etc.)
1108     */
1109    public Group setCode(CodeableConcept value) { 
1110      this.code = value;
1111      return this;
1112    }
1113
1114    /**
1115     * @return {@link #name} (A label assigned to the group for human identification and communication.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
1116     */
1117    public StringType getNameElement() { 
1118      if (this.name == null)
1119        if (Configuration.errorOnAutoCreate())
1120          throw new Error("Attempt to auto-create Group.name");
1121        else if (Configuration.doAutoCreate())
1122          this.name = new StringType(); // bb
1123      return this.name;
1124    }
1125
1126    public boolean hasNameElement() { 
1127      return this.name != null && !this.name.isEmpty();
1128    }
1129
1130    public boolean hasName() { 
1131      return this.name != null && !this.name.isEmpty();
1132    }
1133
1134    /**
1135     * @param value {@link #name} (A label assigned to the group for human identification and communication.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
1136     */
1137    public Group setNameElement(StringType value) { 
1138      this.name = value;
1139      return this;
1140    }
1141
1142    /**
1143     * @return A label assigned to the group for human identification and communication.
1144     */
1145    public String getName() { 
1146      return this.name == null ? null : this.name.getValue();
1147    }
1148
1149    /**
1150     * @param value A label assigned to the group for human identification and communication.
1151     */
1152    public Group setName(String value) { 
1153      if (Utilities.noString(value))
1154        this.name = null;
1155      else {
1156        if (this.name == null)
1157          this.name = new StringType();
1158        this.name.setValue(value);
1159      }
1160      return this;
1161    }
1162
1163    /**
1164     * @return {@link #quantity} (A count of the number of resource instances that are part of the group.). This is the underlying object with id, value and extensions. The accessor "getQuantity" gives direct access to the value
1165     */
1166    public UnsignedIntType getQuantityElement() { 
1167      if (this.quantity == null)
1168        if (Configuration.errorOnAutoCreate())
1169          throw new Error("Attempt to auto-create Group.quantity");
1170        else if (Configuration.doAutoCreate())
1171          this.quantity = new UnsignedIntType(); // bb
1172      return this.quantity;
1173    }
1174
1175    public boolean hasQuantityElement() { 
1176      return this.quantity != null && !this.quantity.isEmpty();
1177    }
1178
1179    public boolean hasQuantity() { 
1180      return this.quantity != null && !this.quantity.isEmpty();
1181    }
1182
1183    /**
1184     * @param value {@link #quantity} (A count of the number of resource instances that are part of the group.). This is the underlying object with id, value and extensions. The accessor "getQuantity" gives direct access to the value
1185     */
1186    public Group setQuantityElement(UnsignedIntType value) { 
1187      this.quantity = value;
1188      return this;
1189    }
1190
1191    /**
1192     * @return A count of the number of resource instances that are part of the group.
1193     */
1194    public int getQuantity() { 
1195      return this.quantity == null || this.quantity.isEmpty() ? 0 : this.quantity.getValue();
1196    }
1197
1198    /**
1199     * @param value A count of the number of resource instances that are part of the group.
1200     */
1201    public Group setQuantity(int value) { 
1202        if (this.quantity == null)
1203          this.quantity = new UnsignedIntType();
1204        this.quantity.setValue(value);
1205      return this;
1206    }
1207
1208    /**
1209     * @return {@link #characteristic} (Identifies the traits shared by members of the group.)
1210     */
1211    public List<GroupCharacteristicComponent> getCharacteristic() { 
1212      if (this.characteristic == null)
1213        this.characteristic = new ArrayList<GroupCharacteristicComponent>();
1214      return this.characteristic;
1215    }
1216
1217    public boolean hasCharacteristic() { 
1218      if (this.characteristic == null)
1219        return false;
1220      for (GroupCharacteristicComponent item : this.characteristic)
1221        if (!item.isEmpty())
1222          return true;
1223      return false;
1224    }
1225
1226    /**
1227     * @return {@link #characteristic} (Identifies the traits shared by members of the group.)
1228     */
1229    // syntactic sugar
1230    public GroupCharacteristicComponent addCharacteristic() { //3
1231      GroupCharacteristicComponent t = new GroupCharacteristicComponent();
1232      if (this.characteristic == null)
1233        this.characteristic = new ArrayList<GroupCharacteristicComponent>();
1234      this.characteristic.add(t);
1235      return t;
1236    }
1237
1238    // syntactic sugar
1239    public Group addCharacteristic(GroupCharacteristicComponent t) { //3
1240      if (t == null)
1241        return this;
1242      if (this.characteristic == null)
1243        this.characteristic = new ArrayList<GroupCharacteristicComponent>();
1244      this.characteristic.add(t);
1245      return this;
1246    }
1247
1248    /**
1249     * @return {@link #member} (Identifies the resource instances that are members of the group.)
1250     */
1251    public List<GroupMemberComponent> getMember() { 
1252      if (this.member == null)
1253        this.member = new ArrayList<GroupMemberComponent>();
1254      return this.member;
1255    }
1256
1257    public boolean hasMember() { 
1258      if (this.member == null)
1259        return false;
1260      for (GroupMemberComponent item : this.member)
1261        if (!item.isEmpty())
1262          return true;
1263      return false;
1264    }
1265
1266    /**
1267     * @return {@link #member} (Identifies the resource instances that are members of the group.)
1268     */
1269    // syntactic sugar
1270    public GroupMemberComponent addMember() { //3
1271      GroupMemberComponent t = new GroupMemberComponent();
1272      if (this.member == null)
1273        this.member = new ArrayList<GroupMemberComponent>();
1274      this.member.add(t);
1275      return t;
1276    }
1277
1278    // syntactic sugar
1279    public Group addMember(GroupMemberComponent t) { //3
1280      if (t == null)
1281        return this;
1282      if (this.member == null)
1283        this.member = new ArrayList<GroupMemberComponent>();
1284      this.member.add(t);
1285      return this;
1286    }
1287
1288      protected void listChildren(List<Property> childrenList) {
1289        super.listChildren(childrenList);
1290        childrenList.add(new Property("identifier", "Identifier", "A unique business identifier for this group.", 0, java.lang.Integer.MAX_VALUE, identifier));
1291        childrenList.add(new Property("type", "code", "Identifies the broad classification of the kind of resources the group includes.", 0, java.lang.Integer.MAX_VALUE, type));
1292        childrenList.add(new Property("actual", "boolean", "If true, indicates that the resource refers to a specific group of real individuals.  If false, the group defines a set of intended individuals.", 0, java.lang.Integer.MAX_VALUE, actual));
1293        childrenList.add(new Property("active", "boolean", "Indicates whether the record for the group is available for use or is merely being retained for historical purposes.", 0, java.lang.Integer.MAX_VALUE, active));
1294        childrenList.add(new Property("code", "CodeableConcept", "Provides a specific type of resource the group includes; e.g. \"cow\", \"syringe\", etc.", 0, java.lang.Integer.MAX_VALUE, code));
1295        childrenList.add(new Property("name", "string", "A label assigned to the group for human identification and communication.", 0, java.lang.Integer.MAX_VALUE, name));
1296        childrenList.add(new Property("quantity", "unsignedInt", "A count of the number of resource instances that are part of the group.", 0, java.lang.Integer.MAX_VALUE, quantity));
1297        childrenList.add(new Property("characteristic", "", "Identifies the traits shared by members of the group.", 0, java.lang.Integer.MAX_VALUE, characteristic));
1298        childrenList.add(new Property("member", "", "Identifies the resource instances that are members of the group.", 0, java.lang.Integer.MAX_VALUE, member));
1299      }
1300
1301      @Override
1302      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1303        switch (hash) {
1304        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1305        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // Enumeration<GroupType>
1306        case -1422939762: /*actual*/ return this.actual == null ? new Base[0] : new Base[] {this.actual}; // BooleanType
1307        case -1422950650: /*active*/ return this.active == null ? new Base[0] : new Base[] {this.active}; // BooleanType
1308        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
1309        case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // StringType
1310        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // UnsignedIntType
1311        case 366313883: /*characteristic*/ return this.characteristic == null ? new Base[0] : this.characteristic.toArray(new Base[this.characteristic.size()]); // GroupCharacteristicComponent
1312        case -1077769574: /*member*/ return this.member == null ? new Base[0] : this.member.toArray(new Base[this.member.size()]); // GroupMemberComponent
1313        default: return super.getProperty(hash, name, checkValid);
1314        }
1315
1316      }
1317
1318      @Override
1319      public void setProperty(int hash, String name, Base value) throws FHIRException {
1320        switch (hash) {
1321        case -1618432855: // identifier
1322          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1323          break;
1324        case 3575610: // type
1325          this.type = new GroupTypeEnumFactory().fromType(value); // Enumeration<GroupType>
1326          break;
1327        case -1422939762: // actual
1328          this.actual = castToBoolean(value); // BooleanType
1329          break;
1330        case -1422950650: // active
1331          this.active = castToBoolean(value); // BooleanType
1332          break;
1333        case 3059181: // code
1334          this.code = castToCodeableConcept(value); // CodeableConcept
1335          break;
1336        case 3373707: // name
1337          this.name = castToString(value); // StringType
1338          break;
1339        case -1285004149: // quantity
1340          this.quantity = castToUnsignedInt(value); // UnsignedIntType
1341          break;
1342        case 366313883: // characteristic
1343          this.getCharacteristic().add((GroupCharacteristicComponent) value); // GroupCharacteristicComponent
1344          break;
1345        case -1077769574: // member
1346          this.getMember().add((GroupMemberComponent) value); // GroupMemberComponent
1347          break;
1348        default: super.setProperty(hash, name, value);
1349        }
1350
1351      }
1352
1353      @Override
1354      public void setProperty(String name, Base value) throws FHIRException {
1355        if (name.equals("identifier"))
1356          this.getIdentifier().add(castToIdentifier(value));
1357        else if (name.equals("type"))
1358          this.type = new GroupTypeEnumFactory().fromType(value); // Enumeration<GroupType>
1359        else if (name.equals("actual"))
1360          this.actual = castToBoolean(value); // BooleanType
1361        else if (name.equals("active"))
1362          this.active = castToBoolean(value); // BooleanType
1363        else if (name.equals("code"))
1364          this.code = castToCodeableConcept(value); // CodeableConcept
1365        else if (name.equals("name"))
1366          this.name = castToString(value); // StringType
1367        else if (name.equals("quantity"))
1368          this.quantity = castToUnsignedInt(value); // UnsignedIntType
1369        else if (name.equals("characteristic"))
1370          this.getCharacteristic().add((GroupCharacteristicComponent) value);
1371        else if (name.equals("member"))
1372          this.getMember().add((GroupMemberComponent) value);
1373        else
1374          super.setProperty(name, value);
1375      }
1376
1377      @Override
1378      public Base makeProperty(int hash, String name) throws FHIRException {
1379        switch (hash) {
1380        case -1618432855:  return addIdentifier(); // Identifier
1381        case 3575610: throw new FHIRException("Cannot make property type as it is not a complex type"); // Enumeration<GroupType>
1382        case -1422939762: throw new FHIRException("Cannot make property actual as it is not a complex type"); // BooleanType
1383        case -1422950650: throw new FHIRException("Cannot make property active as it is not a complex type"); // BooleanType
1384        case 3059181:  return getCode(); // CodeableConcept
1385        case 3373707: throw new FHIRException("Cannot make property name as it is not a complex type"); // StringType
1386        case -1285004149: throw new FHIRException("Cannot make property quantity as it is not a complex type"); // UnsignedIntType
1387        case 366313883:  return addCharacteristic(); // GroupCharacteristicComponent
1388        case -1077769574:  return addMember(); // GroupMemberComponent
1389        default: return super.makeProperty(hash, name);
1390        }
1391
1392      }
1393
1394      @Override
1395      public Base addChild(String name) throws FHIRException {
1396        if (name.equals("identifier")) {
1397          return addIdentifier();
1398        }
1399        else if (name.equals("type")) {
1400          throw new FHIRException("Cannot call addChild on a primitive type Group.type");
1401        }
1402        else if (name.equals("actual")) {
1403          throw new FHIRException("Cannot call addChild on a primitive type Group.actual");
1404        }
1405        else if (name.equals("active")) {
1406          throw new FHIRException("Cannot call addChild on a primitive type Group.active");
1407        }
1408        else if (name.equals("code")) {
1409          this.code = new CodeableConcept();
1410          return this.code;
1411        }
1412        else if (name.equals("name")) {
1413          throw new FHIRException("Cannot call addChild on a primitive type Group.name");
1414        }
1415        else if (name.equals("quantity")) {
1416          throw new FHIRException("Cannot call addChild on a primitive type Group.quantity");
1417        }
1418        else if (name.equals("characteristic")) {
1419          return addCharacteristic();
1420        }
1421        else if (name.equals("member")) {
1422          return addMember();
1423        }
1424        else
1425          return super.addChild(name);
1426      }
1427
1428  public String fhirType() {
1429    return "Group";
1430
1431  }
1432
1433      public Group copy() {
1434        Group dst = new Group();
1435        copyValues(dst);
1436        if (identifier != null) {
1437          dst.identifier = new ArrayList<Identifier>();
1438          for (Identifier i : identifier)
1439            dst.identifier.add(i.copy());
1440        };
1441        dst.type = type == null ? null : type.copy();
1442        dst.actual = actual == null ? null : actual.copy();
1443        dst.active = active == null ? null : active.copy();
1444        dst.code = code == null ? null : code.copy();
1445        dst.name = name == null ? null : name.copy();
1446        dst.quantity = quantity == null ? null : quantity.copy();
1447        if (characteristic != null) {
1448          dst.characteristic = new ArrayList<GroupCharacteristicComponent>();
1449          for (GroupCharacteristicComponent i : characteristic)
1450            dst.characteristic.add(i.copy());
1451        };
1452        if (member != null) {
1453          dst.member = new ArrayList<GroupMemberComponent>();
1454          for (GroupMemberComponent i : member)
1455            dst.member.add(i.copy());
1456        };
1457        return dst;
1458      }
1459
1460      protected Group typedCopy() {
1461        return copy();
1462      }
1463
1464      @Override
1465      public boolean equalsDeep(Base other) {
1466        if (!super.equalsDeep(other))
1467          return false;
1468        if (!(other instanceof Group))
1469          return false;
1470        Group o = (Group) other;
1471        return compareDeep(identifier, o.identifier, true) && compareDeep(type, o.type, true) && compareDeep(actual, o.actual, true)
1472           && compareDeep(active, o.active, true) && compareDeep(code, o.code, true) && compareDeep(name, o.name, true)
1473           && compareDeep(quantity, o.quantity, true) && compareDeep(characteristic, o.characteristic, true)
1474           && compareDeep(member, o.member, true);
1475      }
1476
1477      @Override
1478      public boolean equalsShallow(Base other) {
1479        if (!super.equalsShallow(other))
1480          return false;
1481        if (!(other instanceof Group))
1482          return false;
1483        Group o = (Group) other;
1484        return compareValues(type, o.type, true) && compareValues(actual, o.actual, true) && compareValues(active, o.active, true)
1485           && compareValues(name, o.name, true) && compareValues(quantity, o.quantity, true);
1486      }
1487
1488      public boolean isEmpty() {
1489        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (type == null || type.isEmpty())
1490           && (actual == null || actual.isEmpty()) && (active == null || active.isEmpty()) && (code == null || code.isEmpty())
1491           && (name == null || name.isEmpty()) && (quantity == null || quantity.isEmpty()) && (characteristic == null || characteristic.isEmpty())
1492           && (member == null || member.isEmpty());
1493      }
1494
1495  @Override
1496  public ResourceType getResourceType() {
1497    return ResourceType.Group;
1498   }
1499
1500 /**
1501   * Search parameter: <b>member</b>
1502   * <p>
1503   * Description: <b>Reference to the group member</b><br>
1504   * Type: <b>reference</b><br>
1505   * Path: <b>Group.member.entity</b><br>
1506   * </p>
1507   */
1508  @SearchParamDefinition(name="member", path="Group.member.entity", description="Reference to the group member", type="reference" )
1509  public static final String SP_MEMBER = "member";
1510 /**
1511   * <b>Fluent Client</b> search parameter constant for <b>member</b>
1512   * <p>
1513   * Description: <b>Reference to the group member</b><br>
1514   * Type: <b>reference</b><br>
1515   * Path: <b>Group.member.entity</b><br>
1516   * </p>
1517   */
1518  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam MEMBER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_MEMBER);
1519
1520/**
1521   * Constant for fluent queries to be used to add include statements. Specifies
1522   * the path value of "<b>Group:member</b>".
1523   */
1524  public static final ca.uhn.fhir.model.api.Include INCLUDE_MEMBER = new ca.uhn.fhir.model.api.Include("Group:member").toLocked();
1525
1526 /**
1527   * Search parameter: <b>characteristic-value</b>
1528   * <p>
1529   * Description: <b>A composite of both characteristic and value</b><br>
1530   * Type: <b>composite</b><br>
1531   * Path: <b></b><br>
1532   * </p>
1533   */
1534  @SearchParamDefinition(name="characteristic-value", path="", description="A composite of both characteristic and value", type="composite", compositeOf={"characteristic", "value"} )
1535  public static final String SP_CHARACTERISTIC_VALUE = "characteristic-value";
1536 /**
1537   * <b>Fluent Client</b> search parameter constant for <b>characteristic-value</b>
1538   * <p>
1539   * Description: <b>A composite of both characteristic and value</b><br>
1540   * Type: <b>composite</b><br>
1541   * Path: <b></b><br>
1542   * </p>
1543   */
1544  public static final ca.uhn.fhir.rest.gclient.CompositeClientParam<ca.uhn.fhir.rest.gclient.TokenClientParam, ca.uhn.fhir.rest.gclient.TokenClientParam> CHARACTERISTIC_VALUE = new ca.uhn.fhir.rest.gclient.CompositeClientParam<ca.uhn.fhir.rest.gclient.TokenClientParam, ca.uhn.fhir.rest.gclient.TokenClientParam>(SP_CHARACTERISTIC_VALUE);
1545
1546 /**
1547   * Search parameter: <b>value</b>
1548   * <p>
1549   * Description: <b>Value held by characteristic</b><br>
1550   * Type: <b>token</b><br>
1551   * Path: <b>Group.characteristic.value[x]</b><br>
1552   * </p>
1553   */
1554  @SearchParamDefinition(name="value", path="Group.characteristic.value", description="Value held by characteristic", type="token" )
1555  public static final String SP_VALUE = "value";
1556 /**
1557   * <b>Fluent Client</b> search parameter constant for <b>value</b>
1558   * <p>
1559   * Description: <b>Value held by characteristic</b><br>
1560   * Type: <b>token</b><br>
1561   * Path: <b>Group.characteristic.value[x]</b><br>
1562   * </p>
1563   */
1564  public static final ca.uhn.fhir.rest.gclient.TokenClientParam VALUE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_VALUE);
1565
1566 /**
1567   * Search parameter: <b>actual</b>
1568   * <p>
1569   * Description: <b>Descriptive or actual</b><br>
1570   * Type: <b>token</b><br>
1571   * Path: <b>Group.actual</b><br>
1572   * </p>
1573   */
1574  @SearchParamDefinition(name="actual", path="Group.actual", description="Descriptive or actual", type="token" )
1575  public static final String SP_ACTUAL = "actual";
1576 /**
1577   * <b>Fluent Client</b> search parameter constant for <b>actual</b>
1578   * <p>
1579   * Description: <b>Descriptive or actual</b><br>
1580   * Type: <b>token</b><br>
1581   * Path: <b>Group.actual</b><br>
1582   * </p>
1583   */
1584  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ACTUAL = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_ACTUAL);
1585
1586 /**
1587   * Search parameter: <b>exclude</b>
1588   * <p>
1589   * Description: <b>Group includes or excludes</b><br>
1590   * Type: <b>token</b><br>
1591   * Path: <b>Group.characteristic.exclude</b><br>
1592   * </p>
1593   */
1594  @SearchParamDefinition(name="exclude", path="Group.characteristic.exclude", description="Group includes or excludes", type="token" )
1595  public static final String SP_EXCLUDE = "exclude";
1596 /**
1597   * <b>Fluent Client</b> search parameter constant for <b>exclude</b>
1598   * <p>
1599   * Description: <b>Group includes or excludes</b><br>
1600   * Type: <b>token</b><br>
1601   * Path: <b>Group.characteristic.exclude</b><br>
1602   * </p>
1603   */
1604  public static final ca.uhn.fhir.rest.gclient.TokenClientParam EXCLUDE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_EXCLUDE);
1605
1606 /**
1607   * Search parameter: <b>code</b>
1608   * <p>
1609   * Description: <b>The kind of resources contained</b><br>
1610   * Type: <b>token</b><br>
1611   * Path: <b>Group.code</b><br>
1612   * </p>
1613   */
1614  @SearchParamDefinition(name="code", path="Group.code", description="The kind of resources contained", type="token" )
1615  public static final String SP_CODE = "code";
1616 /**
1617   * <b>Fluent Client</b> search parameter constant for <b>code</b>
1618   * <p>
1619   * Description: <b>The kind of resources contained</b><br>
1620   * Type: <b>token</b><br>
1621   * Path: <b>Group.code</b><br>
1622   * </p>
1623   */
1624  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
1625
1626 /**
1627   * Search parameter: <b>characteristic</b>
1628   * <p>
1629   * Description: <b>Kind of characteristic</b><br>
1630   * Type: <b>token</b><br>
1631   * Path: <b>Group.characteristic.code</b><br>
1632   * </p>
1633   */
1634  @SearchParamDefinition(name="characteristic", path="Group.characteristic.code", description="Kind of characteristic", type="token" )
1635  public static final String SP_CHARACTERISTIC = "characteristic";
1636 /**
1637   * <b>Fluent Client</b> search parameter constant for <b>characteristic</b>
1638   * <p>
1639   * Description: <b>Kind of characteristic</b><br>
1640   * Type: <b>token</b><br>
1641   * Path: <b>Group.characteristic.code</b><br>
1642   * </p>
1643   */
1644  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CHARACTERISTIC = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CHARACTERISTIC);
1645
1646 /**
1647   * Search parameter: <b>type</b>
1648   * <p>
1649   * Description: <b>The type of resources the group contains</b><br>
1650   * Type: <b>token</b><br>
1651   * Path: <b>Group.type</b><br>
1652   * </p>
1653   */
1654  @SearchParamDefinition(name="type", path="Group.type", description="The type of resources the group contains", type="token" )
1655  public static final String SP_TYPE = "type";
1656 /**
1657   * <b>Fluent Client</b> search parameter constant for <b>type</b>
1658   * <p>
1659   * Description: <b>The type of resources the group contains</b><br>
1660   * Type: <b>token</b><br>
1661   * Path: <b>Group.type</b><br>
1662   * </p>
1663   */
1664  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
1665
1666 /**
1667   * Search parameter: <b>identifier</b>
1668   * <p>
1669   * Description: <b>Unique id</b><br>
1670   * Type: <b>token</b><br>
1671   * Path: <b>Group.identifier</b><br>
1672   * </p>
1673   */
1674  @SearchParamDefinition(name="identifier", path="Group.identifier", description="Unique id", type="token" )
1675  public static final String SP_IDENTIFIER = "identifier";
1676 /**
1677   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1678   * <p>
1679   * Description: <b>Unique id</b><br>
1680   * Type: <b>token</b><br>
1681   * Path: <b>Group.identifier</b><br>
1682   * </p>
1683   */
1684  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
1685
1686
1687}