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