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.Date;
035import java.util.List;
036
037import org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus;
038import org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatusEnumFactory;
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 * A compartment definition that defines how resources are accessed on a server.
050 */
051@ResourceDef(name="CompartmentDefinition", profile="http://hl7.org/fhir/Profile/CompartmentDefinition")
052public class CompartmentDefinition extends DomainResource {
053
054    public enum CompartmentType {
055        /**
056         * The compartment definition is for the patient compartment
057         */
058        PATIENT, 
059        /**
060         * The compartment definition is for the encounter compartment
061         */
062        ENCOUNTER, 
063        /**
064         * The compartment definition is for the related-person compartment
065         */
066        RELATEDPERSON, 
067        /**
068         * The compartment definition is for the practitioner compartment
069         */
070        PRACTITIONER, 
071        /**
072         * The compartment definition is for the device compartment
073         */
074        DEVICE, 
075        /**
076         * added to help the parsers
077         */
078        NULL;
079        public static CompartmentType fromCode(String codeString) throws FHIRException {
080            if (codeString == null || "".equals(codeString))
081                return null;
082        if ("Patient".equals(codeString))
083          return PATIENT;
084        if ("Encounter".equals(codeString))
085          return ENCOUNTER;
086        if ("RelatedPerson".equals(codeString))
087          return RELATEDPERSON;
088        if ("Practitioner".equals(codeString))
089          return PRACTITIONER;
090        if ("Device".equals(codeString))
091          return DEVICE;
092        throw new FHIRException("Unknown CompartmentType code '"+codeString+"'");
093        }
094        public String toCode() {
095          switch (this) {
096            case PATIENT: return "Patient";
097            case ENCOUNTER: return "Encounter";
098            case RELATEDPERSON: return "RelatedPerson";
099            case PRACTITIONER: return "Practitioner";
100            case DEVICE: return "Device";
101            default: return "?";
102          }
103        }
104        public String getSystem() {
105          switch (this) {
106            case PATIENT: return "http://hl7.org/fhir/compartment-type";
107            case ENCOUNTER: return "http://hl7.org/fhir/compartment-type";
108            case RELATEDPERSON: return "http://hl7.org/fhir/compartment-type";
109            case PRACTITIONER: return "http://hl7.org/fhir/compartment-type";
110            case DEVICE: return "http://hl7.org/fhir/compartment-type";
111            default: return "?";
112          }
113        }
114        public String getDefinition() {
115          switch (this) {
116            case PATIENT: return "The compartment definition is for the patient compartment";
117            case ENCOUNTER: return "The compartment definition is for the encounter compartment";
118            case RELATEDPERSON: return "The compartment definition is for the related-person compartment";
119            case PRACTITIONER: return "The compartment definition is for the practitioner compartment";
120            case DEVICE: return "The compartment definition is for the device compartment";
121            default: return "?";
122          }
123        }
124        public String getDisplay() {
125          switch (this) {
126            case PATIENT: return "Patient";
127            case ENCOUNTER: return "Encounter";
128            case RELATEDPERSON: return "RelatedPerson";
129            case PRACTITIONER: return "Practitioner";
130            case DEVICE: return "Device";
131            default: return "?";
132          }
133        }
134    }
135
136  public static class CompartmentTypeEnumFactory implements EnumFactory<CompartmentType> {
137    public CompartmentType fromCode(String codeString) throws IllegalArgumentException {
138      if (codeString == null || "".equals(codeString))
139            if (codeString == null || "".equals(codeString))
140                return null;
141        if ("Patient".equals(codeString))
142          return CompartmentType.PATIENT;
143        if ("Encounter".equals(codeString))
144          return CompartmentType.ENCOUNTER;
145        if ("RelatedPerson".equals(codeString))
146          return CompartmentType.RELATEDPERSON;
147        if ("Practitioner".equals(codeString))
148          return CompartmentType.PRACTITIONER;
149        if ("Device".equals(codeString))
150          return CompartmentType.DEVICE;
151        throw new IllegalArgumentException("Unknown CompartmentType code '"+codeString+"'");
152        }
153        public Enumeration<CompartmentType> fromType(Base code) throws FHIRException {
154          if (code == null || code.isEmpty())
155            return null;
156          String codeString = ((PrimitiveType) code).asStringValue();
157          if (codeString == null || "".equals(codeString))
158            return null;
159        if ("Patient".equals(codeString))
160          return new Enumeration<CompartmentType>(this, CompartmentType.PATIENT);
161        if ("Encounter".equals(codeString))
162          return new Enumeration<CompartmentType>(this, CompartmentType.ENCOUNTER);
163        if ("RelatedPerson".equals(codeString))
164          return new Enumeration<CompartmentType>(this, CompartmentType.RELATEDPERSON);
165        if ("Practitioner".equals(codeString))
166          return new Enumeration<CompartmentType>(this, CompartmentType.PRACTITIONER);
167        if ("Device".equals(codeString))
168          return new Enumeration<CompartmentType>(this, CompartmentType.DEVICE);
169        throw new FHIRException("Unknown CompartmentType code '"+codeString+"'");
170        }
171    public String toCode(CompartmentType code) {
172      if (code == CompartmentType.PATIENT)
173        return "Patient";
174      if (code == CompartmentType.ENCOUNTER)
175        return "Encounter";
176      if (code == CompartmentType.RELATEDPERSON)
177        return "RelatedPerson";
178      if (code == CompartmentType.PRACTITIONER)
179        return "Practitioner";
180      if (code == CompartmentType.DEVICE)
181        return "Device";
182      return "?";
183      }
184    public String toSystem(CompartmentType code) {
185      return code.getSystem();
186      }
187    }
188
189    @Block()
190    public static class CompartmentDefinitionContactComponent extends BackboneElement implements IBaseBackboneElement {
191        /**
192         * The name of an individual to contact regarding the compartment definition.
193         */
194        @Child(name = "name", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
195        @Description(shortDefinition="Name of an individual to contact", formalDefinition="The name of an individual to contact regarding the compartment definition." )
196        protected StringType name;
197
198        /**
199         * Contact details for individual (if a name was provided) or the publisher.
200         */
201        @Child(name = "telecom", type = {ContactPoint.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
202        @Description(shortDefinition="Contact details for individual or publisher", formalDefinition="Contact details for individual (if a name was provided) or the publisher." )
203        protected List<ContactPoint> telecom;
204
205        private static final long serialVersionUID = -1179697803L;
206
207    /**
208     * Constructor
209     */
210      public CompartmentDefinitionContactComponent() {
211        super();
212      }
213
214        /**
215         * @return {@link #name} (The name of an individual to contact regarding the compartment definition.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
216         */
217        public StringType getNameElement() { 
218          if (this.name == null)
219            if (Configuration.errorOnAutoCreate())
220              throw new Error("Attempt to auto-create CompartmentDefinitionContactComponent.name");
221            else if (Configuration.doAutoCreate())
222              this.name = new StringType(); // bb
223          return this.name;
224        }
225
226        public boolean hasNameElement() { 
227          return this.name != null && !this.name.isEmpty();
228        }
229
230        public boolean hasName() { 
231          return this.name != null && !this.name.isEmpty();
232        }
233
234        /**
235         * @param value {@link #name} (The name of an individual to contact regarding the compartment definition.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
236         */
237        public CompartmentDefinitionContactComponent setNameElement(StringType value) { 
238          this.name = value;
239          return this;
240        }
241
242        /**
243         * @return The name of an individual to contact regarding the compartment definition.
244         */
245        public String getName() { 
246          return this.name == null ? null : this.name.getValue();
247        }
248
249        /**
250         * @param value The name of an individual to contact regarding the compartment definition.
251         */
252        public CompartmentDefinitionContactComponent setName(String value) { 
253          if (Utilities.noString(value))
254            this.name = null;
255          else {
256            if (this.name == null)
257              this.name = new StringType();
258            this.name.setValue(value);
259          }
260          return this;
261        }
262
263        /**
264         * @return {@link #telecom} (Contact details for individual (if a name was provided) or the publisher.)
265         */
266        public List<ContactPoint> getTelecom() { 
267          if (this.telecom == null)
268            this.telecom = new ArrayList<ContactPoint>();
269          return this.telecom;
270        }
271
272        public boolean hasTelecom() { 
273          if (this.telecom == null)
274            return false;
275          for (ContactPoint item : this.telecom)
276            if (!item.isEmpty())
277              return true;
278          return false;
279        }
280
281        /**
282         * @return {@link #telecom} (Contact details for individual (if a name was provided) or the publisher.)
283         */
284    // syntactic sugar
285        public ContactPoint addTelecom() { //3
286          ContactPoint t = new ContactPoint();
287          if (this.telecom == null)
288            this.telecom = new ArrayList<ContactPoint>();
289          this.telecom.add(t);
290          return t;
291        }
292
293    // syntactic sugar
294        public CompartmentDefinitionContactComponent addTelecom(ContactPoint t) { //3
295          if (t == null)
296            return this;
297          if (this.telecom == null)
298            this.telecom = new ArrayList<ContactPoint>();
299          this.telecom.add(t);
300          return this;
301        }
302
303        protected void listChildren(List<Property> childrenList) {
304          super.listChildren(childrenList);
305          childrenList.add(new Property("name", "string", "The name of an individual to contact regarding the compartment definition.", 0, java.lang.Integer.MAX_VALUE, name));
306          childrenList.add(new Property("telecom", "ContactPoint", "Contact details for individual (if a name was provided) or the publisher.", 0, java.lang.Integer.MAX_VALUE, telecom));
307        }
308
309      @Override
310      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
311        switch (hash) {
312        case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // StringType
313        case -1429363305: /*telecom*/ return this.telecom == null ? new Base[0] : this.telecom.toArray(new Base[this.telecom.size()]); // ContactPoint
314        default: return super.getProperty(hash, name, checkValid);
315        }
316
317      }
318
319      @Override
320      public void setProperty(int hash, String name, Base value) throws FHIRException {
321        switch (hash) {
322        case 3373707: // name
323          this.name = castToString(value); // StringType
324          break;
325        case -1429363305: // telecom
326          this.getTelecom().add(castToContactPoint(value)); // ContactPoint
327          break;
328        default: super.setProperty(hash, name, value);
329        }
330
331      }
332
333      @Override
334      public void setProperty(String name, Base value) throws FHIRException {
335        if (name.equals("name"))
336          this.name = castToString(value); // StringType
337        else if (name.equals("telecom"))
338          this.getTelecom().add(castToContactPoint(value));
339        else
340          super.setProperty(name, value);
341      }
342
343      @Override
344      public Base makeProperty(int hash, String name) throws FHIRException {
345        switch (hash) {
346        case 3373707: throw new FHIRException("Cannot make property name as it is not a complex type"); // StringType
347        case -1429363305:  return addTelecom(); // ContactPoint
348        default: return super.makeProperty(hash, name);
349        }
350
351      }
352
353      @Override
354      public Base addChild(String name) throws FHIRException {
355        if (name.equals("name")) {
356          throw new FHIRException("Cannot call addChild on a primitive type CompartmentDefinition.name");
357        }
358        else if (name.equals("telecom")) {
359          return addTelecom();
360        }
361        else
362          return super.addChild(name);
363      }
364
365      public CompartmentDefinitionContactComponent copy() {
366        CompartmentDefinitionContactComponent dst = new CompartmentDefinitionContactComponent();
367        copyValues(dst);
368        dst.name = name == null ? null : name.copy();
369        if (telecom != null) {
370          dst.telecom = new ArrayList<ContactPoint>();
371          for (ContactPoint i : telecom)
372            dst.telecom.add(i.copy());
373        };
374        return dst;
375      }
376
377      @Override
378      public boolean equalsDeep(Base other) {
379        if (!super.equalsDeep(other))
380          return false;
381        if (!(other instanceof CompartmentDefinitionContactComponent))
382          return false;
383        CompartmentDefinitionContactComponent o = (CompartmentDefinitionContactComponent) other;
384        return compareDeep(name, o.name, true) && compareDeep(telecom, o.telecom, true);
385      }
386
387      @Override
388      public boolean equalsShallow(Base other) {
389        if (!super.equalsShallow(other))
390          return false;
391        if (!(other instanceof CompartmentDefinitionContactComponent))
392          return false;
393        CompartmentDefinitionContactComponent o = (CompartmentDefinitionContactComponent) other;
394        return compareValues(name, o.name, true);
395      }
396
397      public boolean isEmpty() {
398        return super.isEmpty() && (name == null || name.isEmpty()) && (telecom == null || telecom.isEmpty())
399          ;
400      }
401
402  public String fhirType() {
403    return "CompartmentDefinition.contact";
404
405  }
406
407  }
408
409    @Block()
410    public static class CompartmentDefinitionResourceComponent extends BackboneElement implements IBaseBackboneElement {
411        /**
412         * The name of a resource supported by the server.
413         */
414        @Child(name = "code", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=true)
415        @Description(shortDefinition="Name of resource type", formalDefinition="The name of a resource supported by the server." )
416        protected CodeType code;
417
418        /**
419         * The name of a search parameter that represents the link to the compartment. More than one may be listed because a resource may be linked to a compartment more than one way.
420         */
421        @Child(name = "param", type = {StringType.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
422        @Description(shortDefinition="Search Parameter Name, or chained params", formalDefinition="The name of a search parameter that represents the link to the compartment. More than one may be listed because a resource may be linked to a compartment more than one way." )
423        protected List<StringType> param;
424
425        /**
426         * Additional doco about the resource and compartment.
427         */
428        @Child(name = "documentation", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=false)
429        @Description(shortDefinition="Additional doco about the resource and compartment", formalDefinition="Additional doco about the resource and compartment." )
430        protected StringType documentation;
431
432        private static final long serialVersionUID = 988080897L;
433
434    /**
435     * Constructor
436     */
437      public CompartmentDefinitionResourceComponent() {
438        super();
439      }
440
441    /**
442     * Constructor
443     */
444      public CompartmentDefinitionResourceComponent(CodeType code) {
445        super();
446        this.code = code;
447      }
448
449        /**
450         * @return {@link #code} (The name of a resource supported by the server.). This is the underlying object with id, value and extensions. The accessor "getCode" gives direct access to the value
451         */
452        public CodeType getCodeElement() { 
453          if (this.code == null)
454            if (Configuration.errorOnAutoCreate())
455              throw new Error("Attempt to auto-create CompartmentDefinitionResourceComponent.code");
456            else if (Configuration.doAutoCreate())
457              this.code = new CodeType(); // bb
458          return this.code;
459        }
460
461        public boolean hasCodeElement() { 
462          return this.code != null && !this.code.isEmpty();
463        }
464
465        public boolean hasCode() { 
466          return this.code != null && !this.code.isEmpty();
467        }
468
469        /**
470         * @param value {@link #code} (The name of a resource supported by the server.). This is the underlying object with id, value and extensions. The accessor "getCode" gives direct access to the value
471         */
472        public CompartmentDefinitionResourceComponent setCodeElement(CodeType value) { 
473          this.code = value;
474          return this;
475        }
476
477        /**
478         * @return The name of a resource supported by the server.
479         */
480        public String getCode() { 
481          return this.code == null ? null : this.code.getValue();
482        }
483
484        /**
485         * @param value The name of a resource supported by the server.
486         */
487        public CompartmentDefinitionResourceComponent setCode(String value) { 
488            if (this.code == null)
489              this.code = new CodeType();
490            this.code.setValue(value);
491          return this;
492        }
493
494        /**
495         * @return {@link #param} (The name of a search parameter that represents the link to the compartment. More than one may be listed because a resource may be linked to a compartment more than one way.)
496         */
497        public List<StringType> getParam() { 
498          if (this.param == null)
499            this.param = new ArrayList<StringType>();
500          return this.param;
501        }
502
503        public boolean hasParam() { 
504          if (this.param == null)
505            return false;
506          for (StringType item : this.param)
507            if (!item.isEmpty())
508              return true;
509          return false;
510        }
511
512        /**
513         * @return {@link #param} (The name of a search parameter that represents the link to the compartment. More than one may be listed because a resource may be linked to a compartment more than one way.)
514         */
515    // syntactic sugar
516        public StringType addParamElement() {//2 
517          StringType t = new StringType();
518          if (this.param == null)
519            this.param = new ArrayList<StringType>();
520          this.param.add(t);
521          return t;
522        }
523
524        /**
525         * @param value {@link #param} (The name of a search parameter that represents the link to the compartment. More than one may be listed because a resource may be linked to a compartment more than one way.)
526         */
527        public CompartmentDefinitionResourceComponent addParam(String value) { //1
528          StringType t = new StringType();
529          t.setValue(value);
530          if (this.param == null)
531            this.param = new ArrayList<StringType>();
532          this.param.add(t);
533          return this;
534        }
535
536        /**
537         * @param value {@link #param} (The name of a search parameter that represents the link to the compartment. More than one may be listed because a resource may be linked to a compartment more than one way.)
538         */
539        public boolean hasParam(String value) { 
540          if (this.param == null)
541            return false;
542          for (StringType v : this.param)
543            if (v.equals(value)) // string
544              return true;
545          return false;
546        }
547
548        /**
549         * @return {@link #documentation} (Additional doco about the resource and compartment.). This is the underlying object with id, value and extensions. The accessor "getDocumentation" gives direct access to the value
550         */
551        public StringType getDocumentationElement() { 
552          if (this.documentation == null)
553            if (Configuration.errorOnAutoCreate())
554              throw new Error("Attempt to auto-create CompartmentDefinitionResourceComponent.documentation");
555            else if (Configuration.doAutoCreate())
556              this.documentation = new StringType(); // bb
557          return this.documentation;
558        }
559
560        public boolean hasDocumentationElement() { 
561          return this.documentation != null && !this.documentation.isEmpty();
562        }
563
564        public boolean hasDocumentation() { 
565          return this.documentation != null && !this.documentation.isEmpty();
566        }
567
568        /**
569         * @param value {@link #documentation} (Additional doco about the resource and compartment.). This is the underlying object with id, value and extensions. The accessor "getDocumentation" gives direct access to the value
570         */
571        public CompartmentDefinitionResourceComponent setDocumentationElement(StringType value) { 
572          this.documentation = value;
573          return this;
574        }
575
576        /**
577         * @return Additional doco about the resource and compartment.
578         */
579        public String getDocumentation() { 
580          return this.documentation == null ? null : this.documentation.getValue();
581        }
582
583        /**
584         * @param value Additional doco about the resource and compartment.
585         */
586        public CompartmentDefinitionResourceComponent setDocumentation(String value) { 
587          if (Utilities.noString(value))
588            this.documentation = null;
589          else {
590            if (this.documentation == null)
591              this.documentation = new StringType();
592            this.documentation.setValue(value);
593          }
594          return this;
595        }
596
597        protected void listChildren(List<Property> childrenList) {
598          super.listChildren(childrenList);
599          childrenList.add(new Property("code", "code", "The name of a resource supported by the server.", 0, java.lang.Integer.MAX_VALUE, code));
600          childrenList.add(new Property("param", "string", "The name of a search parameter that represents the link to the compartment. More than one may be listed because a resource may be linked to a compartment more than one way.", 0, java.lang.Integer.MAX_VALUE, param));
601          childrenList.add(new Property("documentation", "string", "Additional doco about the resource and compartment.", 0, java.lang.Integer.MAX_VALUE, documentation));
602        }
603
604      @Override
605      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
606        switch (hash) {
607        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeType
608        case 106436749: /*param*/ return this.param == null ? new Base[0] : this.param.toArray(new Base[this.param.size()]); // StringType
609        case 1587405498: /*documentation*/ return this.documentation == null ? new Base[0] : new Base[] {this.documentation}; // StringType
610        default: return super.getProperty(hash, name, checkValid);
611        }
612
613      }
614
615      @Override
616      public void setProperty(int hash, String name, Base value) throws FHIRException {
617        switch (hash) {
618        case 3059181: // code
619          this.code = castToCode(value); // CodeType
620          break;
621        case 106436749: // param
622          this.getParam().add(castToString(value)); // StringType
623          break;
624        case 1587405498: // documentation
625          this.documentation = castToString(value); // StringType
626          break;
627        default: super.setProperty(hash, name, value);
628        }
629
630      }
631
632      @Override
633      public void setProperty(String name, Base value) throws FHIRException {
634        if (name.equals("code"))
635          this.code = castToCode(value); // CodeType
636        else if (name.equals("param"))
637          this.getParam().add(castToString(value));
638        else if (name.equals("documentation"))
639          this.documentation = castToString(value); // StringType
640        else
641          super.setProperty(name, value);
642      }
643
644      @Override
645      public Base makeProperty(int hash, String name) throws FHIRException {
646        switch (hash) {
647        case 3059181: throw new FHIRException("Cannot make property code as it is not a complex type"); // CodeType
648        case 106436749: throw new FHIRException("Cannot make property param as it is not a complex type"); // StringType
649        case 1587405498: throw new FHIRException("Cannot make property documentation as it is not a complex type"); // StringType
650        default: return super.makeProperty(hash, name);
651        }
652
653      }
654
655      @Override
656      public Base addChild(String name) throws FHIRException {
657        if (name.equals("code")) {
658          throw new FHIRException("Cannot call addChild on a primitive type CompartmentDefinition.code");
659        }
660        else if (name.equals("param")) {
661          throw new FHIRException("Cannot call addChild on a primitive type CompartmentDefinition.param");
662        }
663        else if (name.equals("documentation")) {
664          throw new FHIRException("Cannot call addChild on a primitive type CompartmentDefinition.documentation");
665        }
666        else
667          return super.addChild(name);
668      }
669
670      public CompartmentDefinitionResourceComponent copy() {
671        CompartmentDefinitionResourceComponent dst = new CompartmentDefinitionResourceComponent();
672        copyValues(dst);
673        dst.code = code == null ? null : code.copy();
674        if (param != null) {
675          dst.param = new ArrayList<StringType>();
676          for (StringType i : param)
677            dst.param.add(i.copy());
678        };
679        dst.documentation = documentation == null ? null : documentation.copy();
680        return dst;
681      }
682
683      @Override
684      public boolean equalsDeep(Base other) {
685        if (!super.equalsDeep(other))
686          return false;
687        if (!(other instanceof CompartmentDefinitionResourceComponent))
688          return false;
689        CompartmentDefinitionResourceComponent o = (CompartmentDefinitionResourceComponent) other;
690        return compareDeep(code, o.code, true) && compareDeep(param, o.param, true) && compareDeep(documentation, o.documentation, true)
691          ;
692      }
693
694      @Override
695      public boolean equalsShallow(Base other) {
696        if (!super.equalsShallow(other))
697          return false;
698        if (!(other instanceof CompartmentDefinitionResourceComponent))
699          return false;
700        CompartmentDefinitionResourceComponent o = (CompartmentDefinitionResourceComponent) other;
701        return compareValues(code, o.code, true) && compareValues(param, o.param, true) && compareValues(documentation, o.documentation, true)
702          ;
703      }
704
705      public boolean isEmpty() {
706        return super.isEmpty() && (code == null || code.isEmpty()) && (param == null || param.isEmpty())
707           && (documentation == null || documentation.isEmpty());
708      }
709
710  public String fhirType() {
711    return "CompartmentDefinition.resource";
712
713  }
714
715  }
716
717    /**
718     * An absolute URL that is used to identify this compartment definition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this compartment definition is (or will be) published.
719     */
720    @Child(name = "url", type = {UriType.class}, order=0, min=1, max=1, modifier=false, summary=true)
721    @Description(shortDefinition="Absolute URL used to reference this compartment definition", formalDefinition="An absolute URL that is used to identify this compartment definition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this compartment definition is (or will be) published." )
722    protected UriType url;
723
724    /**
725     * A free text natural language name identifying the compartment definition.
726     */
727    @Child(name = "name", type = {StringType.class}, order=1, min=1, max=1, modifier=false, summary=true)
728    @Description(shortDefinition="Informal name for this compartment definition", formalDefinition="A free text natural language name identifying the compartment definition." )
729    protected StringType name;
730
731    /**
732     * The status of this compartment definition definition.
733     */
734    @Child(name = "status", type = {CodeType.class}, order=2, min=0, max=1, modifier=true, summary=true)
735    @Description(shortDefinition="draft | active | retired", formalDefinition="The status of this compartment definition definition." )
736    protected Enumeration<ConformanceResourceStatus> status;
737
738    /**
739     * A flag to indicate that this compartment definition definition is authored for testing purposes (or education/evaluation/marketing), and is not intended to be used for genuine usage.
740     */
741    @Child(name = "experimental", type = {BooleanType.class}, order=3, min=0, max=1, modifier=false, summary=true)
742    @Description(shortDefinition="If for testing purposes, not real usage", formalDefinition="A flag to indicate that this compartment definition definition is authored for testing purposes (or education/evaluation/marketing), and is not intended to be used for genuine usage." )
743    protected BooleanType experimental;
744
745    /**
746     * The name of the individual or organization that published the compartment definition.
747     */
748    @Child(name = "publisher", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=true)
749    @Description(shortDefinition="Name of the publisher (Organization or individual)", formalDefinition="The name of the individual or organization that published the compartment definition." )
750    protected StringType publisher;
751
752    /**
753     * Contacts to assist a user in finding and communicating with the publisher.
754     */
755    @Child(name = "contact", type = {}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
756    @Description(shortDefinition="Contact details of the publisher", formalDefinition="Contacts to assist a user in finding and communicating with the publisher." )
757    protected List<CompartmentDefinitionContactComponent> contact;
758
759    /**
760     * The date  (and optionally time) when the compartment definition definition was published. The date must change when the business version changes, if it does, and it must change if the status code changes. In addition, it should change when the substantive content of the compartment definition changes.
761     */
762    @Child(name = "date", type = {DateTimeType.class}, order=6, min=0, max=1, modifier=false, summary=true)
763    @Description(shortDefinition="Publication Date(/time)", formalDefinition="The date  (and optionally time) when the compartment definition definition was published. The date must change when the business version changes, if it does, and it must change if the status code changes. In addition, it should change when the substantive content of the compartment definition changes." )
764    protected DateTimeType date;
765
766    /**
767     * A free text natural language description of the CompartmentDefinition and its use.
768     */
769    @Child(name = "description", type = {StringType.class}, order=7, min=0, max=1, modifier=false, summary=true)
770    @Description(shortDefinition="Natural language description of the CompartmentDefinition", formalDefinition="A free text natural language description of the CompartmentDefinition and its use." )
771    protected StringType description;
772
773    /**
774     * The Scope and Usage that this compartment definition was created to meet.
775     */
776    @Child(name = "requirements", type = {StringType.class}, order=8, min=0, max=1, modifier=false, summary=false)
777    @Description(shortDefinition="Why this compartment definition is defined", formalDefinition="The Scope and Usage that this compartment definition was created to meet." )
778    protected StringType requirements;
779
780    /**
781     * Which compartment this definition describes.
782     */
783    @Child(name = "code", type = {CodeType.class}, order=9, min=1, max=1, modifier=false, summary=true)
784    @Description(shortDefinition="Patient | Encounter | RelatedPerson | Practitioner | Device", formalDefinition="Which compartment this definition describes." )
785    protected Enumeration<CompartmentType> code;
786
787    /**
788     * Whether the search syntax is supported.
789     */
790    @Child(name = "search", type = {BooleanType.class}, order=10, min=1, max=1, modifier=false, summary=true)
791    @Description(shortDefinition="Whether the search syntax is supported", formalDefinition="Whether the search syntax is supported." )
792    protected BooleanType search;
793
794    /**
795     * Information about how a resource it related to the compartment.
796     */
797    @Child(name = "resource", type = {}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
798    @Description(shortDefinition="How resource is related to the compartment", formalDefinition="Information about how a resource it related to the compartment." )
799    protected List<CompartmentDefinitionResourceComponent> resource;
800
801    private static final long serialVersionUID = -1431357313L;
802
803  /**
804   * Constructor
805   */
806    public CompartmentDefinition() {
807      super();
808    }
809
810  /**
811   * Constructor
812   */
813    public CompartmentDefinition(UriType url, StringType name, Enumeration<CompartmentType> code, BooleanType search) {
814      super();
815      this.url = url;
816      this.name = name;
817      this.code = code;
818      this.search = search;
819    }
820
821    /**
822     * @return {@link #url} (An absolute URL that is used to identify this compartment definition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this compartment definition is (or will be) published.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
823     */
824    public UriType getUrlElement() { 
825      if (this.url == null)
826        if (Configuration.errorOnAutoCreate())
827          throw new Error("Attempt to auto-create CompartmentDefinition.url");
828        else if (Configuration.doAutoCreate())
829          this.url = new UriType(); // bb
830      return this.url;
831    }
832
833    public boolean hasUrlElement() { 
834      return this.url != null && !this.url.isEmpty();
835    }
836
837    public boolean hasUrl() { 
838      return this.url != null && !this.url.isEmpty();
839    }
840
841    /**
842     * @param value {@link #url} (An absolute URL that is used to identify this compartment definition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this compartment definition is (or will be) published.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
843     */
844    public CompartmentDefinition setUrlElement(UriType value) { 
845      this.url = value;
846      return this;
847    }
848
849    /**
850     * @return An absolute URL that is used to identify this compartment definition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this compartment definition is (or will be) published.
851     */
852    public String getUrl() { 
853      return this.url == null ? null : this.url.getValue();
854    }
855
856    /**
857     * @param value An absolute URL that is used to identify this compartment definition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this compartment definition is (or will be) published.
858     */
859    public CompartmentDefinition setUrl(String value) { 
860        if (this.url == null)
861          this.url = new UriType();
862        this.url.setValue(value);
863      return this;
864    }
865
866    /**
867     * @return {@link #name} (A free text natural language name identifying the compartment definition.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
868     */
869    public StringType getNameElement() { 
870      if (this.name == null)
871        if (Configuration.errorOnAutoCreate())
872          throw new Error("Attempt to auto-create CompartmentDefinition.name");
873        else if (Configuration.doAutoCreate())
874          this.name = new StringType(); // bb
875      return this.name;
876    }
877
878    public boolean hasNameElement() { 
879      return this.name != null && !this.name.isEmpty();
880    }
881
882    public boolean hasName() { 
883      return this.name != null && !this.name.isEmpty();
884    }
885
886    /**
887     * @param value {@link #name} (A free text natural language name identifying the compartment definition.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
888     */
889    public CompartmentDefinition setNameElement(StringType value) { 
890      this.name = value;
891      return this;
892    }
893
894    /**
895     * @return A free text natural language name identifying the compartment definition.
896     */
897    public String getName() { 
898      return this.name == null ? null : this.name.getValue();
899    }
900
901    /**
902     * @param value A free text natural language name identifying the compartment definition.
903     */
904    public CompartmentDefinition setName(String value) { 
905        if (this.name == null)
906          this.name = new StringType();
907        this.name.setValue(value);
908      return this;
909    }
910
911    /**
912     * @return {@link #status} (The status of this compartment definition definition.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
913     */
914    public Enumeration<ConformanceResourceStatus> getStatusElement() { 
915      if (this.status == null)
916        if (Configuration.errorOnAutoCreate())
917          throw new Error("Attempt to auto-create CompartmentDefinition.status");
918        else if (Configuration.doAutoCreate())
919          this.status = new Enumeration<ConformanceResourceStatus>(new ConformanceResourceStatusEnumFactory()); // bb
920      return this.status;
921    }
922
923    public boolean hasStatusElement() { 
924      return this.status != null && !this.status.isEmpty();
925    }
926
927    public boolean hasStatus() { 
928      return this.status != null && !this.status.isEmpty();
929    }
930
931    /**
932     * @param value {@link #status} (The status of this compartment definition definition.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
933     */
934    public CompartmentDefinition setStatusElement(Enumeration<ConformanceResourceStatus> value) { 
935      this.status = value;
936      return this;
937    }
938
939    /**
940     * @return The status of this compartment definition definition.
941     */
942    public ConformanceResourceStatus getStatus() { 
943      return this.status == null ? null : this.status.getValue();
944    }
945
946    /**
947     * @param value The status of this compartment definition definition.
948     */
949    public CompartmentDefinition setStatus(ConformanceResourceStatus value) { 
950      if (value == null)
951        this.status = null;
952      else {
953        if (this.status == null)
954          this.status = new Enumeration<ConformanceResourceStatus>(new ConformanceResourceStatusEnumFactory());
955        this.status.setValue(value);
956      }
957      return this;
958    }
959
960    /**
961     * @return {@link #experimental} (A flag to indicate that this compartment definition definition is authored for testing purposes (or education/evaluation/marketing), and is not intended to be used for genuine usage.). This is the underlying object with id, value and extensions. The accessor "getExperimental" gives direct access to the value
962     */
963    public BooleanType getExperimentalElement() { 
964      if (this.experimental == null)
965        if (Configuration.errorOnAutoCreate())
966          throw new Error("Attempt to auto-create CompartmentDefinition.experimental");
967        else if (Configuration.doAutoCreate())
968          this.experimental = new BooleanType(); // bb
969      return this.experimental;
970    }
971
972    public boolean hasExperimentalElement() { 
973      return this.experimental != null && !this.experimental.isEmpty();
974    }
975
976    public boolean hasExperimental() { 
977      return this.experimental != null && !this.experimental.isEmpty();
978    }
979
980    /**
981     * @param value {@link #experimental} (A flag to indicate that this compartment definition definition is authored for testing purposes (or education/evaluation/marketing), and is not intended to be used for genuine usage.). This is the underlying object with id, value and extensions. The accessor "getExperimental" gives direct access to the value
982     */
983    public CompartmentDefinition setExperimentalElement(BooleanType value) { 
984      this.experimental = value;
985      return this;
986    }
987
988    /**
989     * @return A flag to indicate that this compartment definition definition is authored for testing purposes (or education/evaluation/marketing), and is not intended to be used for genuine usage.
990     */
991    public boolean getExperimental() { 
992      return this.experimental == null || this.experimental.isEmpty() ? false : this.experimental.getValue();
993    }
994
995    /**
996     * @param value A flag to indicate that this compartment definition definition is authored for testing purposes (or education/evaluation/marketing), and is not intended to be used for genuine usage.
997     */
998    public CompartmentDefinition setExperimental(boolean value) { 
999        if (this.experimental == null)
1000          this.experimental = new BooleanType();
1001        this.experimental.setValue(value);
1002      return this;
1003    }
1004
1005    /**
1006     * @return {@link #publisher} (The name of the individual or organization that published the compartment definition.). This is the underlying object with id, value and extensions. The accessor "getPublisher" gives direct access to the value
1007     */
1008    public StringType getPublisherElement() { 
1009      if (this.publisher == null)
1010        if (Configuration.errorOnAutoCreate())
1011          throw new Error("Attempt to auto-create CompartmentDefinition.publisher");
1012        else if (Configuration.doAutoCreate())
1013          this.publisher = new StringType(); // bb
1014      return this.publisher;
1015    }
1016
1017    public boolean hasPublisherElement() { 
1018      return this.publisher != null && !this.publisher.isEmpty();
1019    }
1020
1021    public boolean hasPublisher() { 
1022      return this.publisher != null && !this.publisher.isEmpty();
1023    }
1024
1025    /**
1026     * @param value {@link #publisher} (The name of the individual or organization that published the compartment definition.). This is the underlying object with id, value and extensions. The accessor "getPublisher" gives direct access to the value
1027     */
1028    public CompartmentDefinition setPublisherElement(StringType value) { 
1029      this.publisher = value;
1030      return this;
1031    }
1032
1033    /**
1034     * @return The name of the individual or organization that published the compartment definition.
1035     */
1036    public String getPublisher() { 
1037      return this.publisher == null ? null : this.publisher.getValue();
1038    }
1039
1040    /**
1041     * @param value The name of the individual or organization that published the compartment definition.
1042     */
1043    public CompartmentDefinition setPublisher(String value) { 
1044      if (Utilities.noString(value))
1045        this.publisher = null;
1046      else {
1047        if (this.publisher == null)
1048          this.publisher = new StringType();
1049        this.publisher.setValue(value);
1050      }
1051      return this;
1052    }
1053
1054    /**
1055     * @return {@link #contact} (Contacts to assist a user in finding and communicating with the publisher.)
1056     */
1057    public List<CompartmentDefinitionContactComponent> getContact() { 
1058      if (this.contact == null)
1059        this.contact = new ArrayList<CompartmentDefinitionContactComponent>();
1060      return this.contact;
1061    }
1062
1063    public boolean hasContact() { 
1064      if (this.contact == null)
1065        return false;
1066      for (CompartmentDefinitionContactComponent item : this.contact)
1067        if (!item.isEmpty())
1068          return true;
1069      return false;
1070    }
1071
1072    /**
1073     * @return {@link #contact} (Contacts to assist a user in finding and communicating with the publisher.)
1074     */
1075    // syntactic sugar
1076    public CompartmentDefinitionContactComponent addContact() { //3
1077      CompartmentDefinitionContactComponent t = new CompartmentDefinitionContactComponent();
1078      if (this.contact == null)
1079        this.contact = new ArrayList<CompartmentDefinitionContactComponent>();
1080      this.contact.add(t);
1081      return t;
1082    }
1083
1084    // syntactic sugar
1085    public CompartmentDefinition addContact(CompartmentDefinitionContactComponent t) { //3
1086      if (t == null)
1087        return this;
1088      if (this.contact == null)
1089        this.contact = new ArrayList<CompartmentDefinitionContactComponent>();
1090      this.contact.add(t);
1091      return this;
1092    }
1093
1094    /**
1095     * @return {@link #date} (The date  (and optionally time) when the compartment definition definition was published. The date must change when the business version changes, if it does, and it must change if the status code changes. In addition, it should change when the substantive content of the compartment definition changes.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
1096     */
1097    public DateTimeType getDateElement() { 
1098      if (this.date == null)
1099        if (Configuration.errorOnAutoCreate())
1100          throw new Error("Attempt to auto-create CompartmentDefinition.date");
1101        else if (Configuration.doAutoCreate())
1102          this.date = new DateTimeType(); // bb
1103      return this.date;
1104    }
1105
1106    public boolean hasDateElement() { 
1107      return this.date != null && !this.date.isEmpty();
1108    }
1109
1110    public boolean hasDate() { 
1111      return this.date != null && !this.date.isEmpty();
1112    }
1113
1114    /**
1115     * @param value {@link #date} (The date  (and optionally time) when the compartment definition definition was published. The date must change when the business version changes, if it does, and it must change if the status code changes. In addition, it should change when the substantive content of the compartment definition changes.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
1116     */
1117    public CompartmentDefinition setDateElement(DateTimeType value) { 
1118      this.date = value;
1119      return this;
1120    }
1121
1122    /**
1123     * @return The date  (and optionally time) when the compartment definition definition was published. The date must change when the business version changes, if it does, and it must change if the status code changes. In addition, it should change when the substantive content of the compartment definition changes.
1124     */
1125    public Date getDate() { 
1126      return this.date == null ? null : this.date.getValue();
1127    }
1128
1129    /**
1130     * @param value The date  (and optionally time) when the compartment definition definition was published. The date must change when the business version changes, if it does, and it must change if the status code changes. In addition, it should change when the substantive content of the compartment definition changes.
1131     */
1132    public CompartmentDefinition setDate(Date value) { 
1133      if (value == null)
1134        this.date = null;
1135      else {
1136        if (this.date == null)
1137          this.date = new DateTimeType();
1138        this.date.setValue(value);
1139      }
1140      return this;
1141    }
1142
1143    /**
1144     * @return {@link #description} (A free text natural language description of the CompartmentDefinition and its use.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
1145     */
1146    public StringType getDescriptionElement() { 
1147      if (this.description == null)
1148        if (Configuration.errorOnAutoCreate())
1149          throw new Error("Attempt to auto-create CompartmentDefinition.description");
1150        else if (Configuration.doAutoCreate())
1151          this.description = new StringType(); // bb
1152      return this.description;
1153    }
1154
1155    public boolean hasDescriptionElement() { 
1156      return this.description != null && !this.description.isEmpty();
1157    }
1158
1159    public boolean hasDescription() { 
1160      return this.description != null && !this.description.isEmpty();
1161    }
1162
1163    /**
1164     * @param value {@link #description} (A free text natural language description of the CompartmentDefinition and its use.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
1165     */
1166    public CompartmentDefinition setDescriptionElement(StringType value) { 
1167      this.description = value;
1168      return this;
1169    }
1170
1171    /**
1172     * @return A free text natural language description of the CompartmentDefinition and its use.
1173     */
1174    public String getDescription() { 
1175      return this.description == null ? null : this.description.getValue();
1176    }
1177
1178    /**
1179     * @param value A free text natural language description of the CompartmentDefinition and its use.
1180     */
1181    public CompartmentDefinition setDescription(String value) { 
1182      if (Utilities.noString(value))
1183        this.description = null;
1184      else {
1185        if (this.description == null)
1186          this.description = new StringType();
1187        this.description.setValue(value);
1188      }
1189      return this;
1190    }
1191
1192    /**
1193     * @return {@link #requirements} (The Scope and Usage that this compartment definition was created to meet.). This is the underlying object with id, value and extensions. The accessor "getRequirements" gives direct access to the value
1194     */
1195    public StringType getRequirementsElement() { 
1196      if (this.requirements == null)
1197        if (Configuration.errorOnAutoCreate())
1198          throw new Error("Attempt to auto-create CompartmentDefinition.requirements");
1199        else if (Configuration.doAutoCreate())
1200          this.requirements = new StringType(); // bb
1201      return this.requirements;
1202    }
1203
1204    public boolean hasRequirementsElement() { 
1205      return this.requirements != null && !this.requirements.isEmpty();
1206    }
1207
1208    public boolean hasRequirements() { 
1209      return this.requirements != null && !this.requirements.isEmpty();
1210    }
1211
1212    /**
1213     * @param value {@link #requirements} (The Scope and Usage that this compartment definition was created to meet.). This is the underlying object with id, value and extensions. The accessor "getRequirements" gives direct access to the value
1214     */
1215    public CompartmentDefinition setRequirementsElement(StringType value) { 
1216      this.requirements = value;
1217      return this;
1218    }
1219
1220    /**
1221     * @return The Scope and Usage that this compartment definition was created to meet.
1222     */
1223    public String getRequirements() { 
1224      return this.requirements == null ? null : this.requirements.getValue();
1225    }
1226
1227    /**
1228     * @param value The Scope and Usage that this compartment definition was created to meet.
1229     */
1230    public CompartmentDefinition setRequirements(String value) { 
1231      if (Utilities.noString(value))
1232        this.requirements = null;
1233      else {
1234        if (this.requirements == null)
1235          this.requirements = new StringType();
1236        this.requirements.setValue(value);
1237      }
1238      return this;
1239    }
1240
1241    /**
1242     * @return {@link #code} (Which compartment this definition describes.). This is the underlying object with id, value and extensions. The accessor "getCode" gives direct access to the value
1243     */
1244    public Enumeration<CompartmentType> getCodeElement() { 
1245      if (this.code == null)
1246        if (Configuration.errorOnAutoCreate())
1247          throw new Error("Attempt to auto-create CompartmentDefinition.code");
1248        else if (Configuration.doAutoCreate())
1249          this.code = new Enumeration<CompartmentType>(new CompartmentTypeEnumFactory()); // bb
1250      return this.code;
1251    }
1252
1253    public boolean hasCodeElement() { 
1254      return this.code != null && !this.code.isEmpty();
1255    }
1256
1257    public boolean hasCode() { 
1258      return this.code != null && !this.code.isEmpty();
1259    }
1260
1261    /**
1262     * @param value {@link #code} (Which compartment this definition describes.). This is the underlying object with id, value and extensions. The accessor "getCode" gives direct access to the value
1263     */
1264    public CompartmentDefinition setCodeElement(Enumeration<CompartmentType> value) { 
1265      this.code = value;
1266      return this;
1267    }
1268
1269    /**
1270     * @return Which compartment this definition describes.
1271     */
1272    public CompartmentType getCode() { 
1273      return this.code == null ? null : this.code.getValue();
1274    }
1275
1276    /**
1277     * @param value Which compartment this definition describes.
1278     */
1279    public CompartmentDefinition setCode(CompartmentType value) { 
1280        if (this.code == null)
1281          this.code = new Enumeration<CompartmentType>(new CompartmentTypeEnumFactory());
1282        this.code.setValue(value);
1283      return this;
1284    }
1285
1286    /**
1287     * @return {@link #search} (Whether the search syntax is supported.). This is the underlying object with id, value and extensions. The accessor "getSearch" gives direct access to the value
1288     */
1289    public BooleanType getSearchElement() { 
1290      if (this.search == null)
1291        if (Configuration.errorOnAutoCreate())
1292          throw new Error("Attempt to auto-create CompartmentDefinition.search");
1293        else if (Configuration.doAutoCreate())
1294          this.search = new BooleanType(); // bb
1295      return this.search;
1296    }
1297
1298    public boolean hasSearchElement() { 
1299      return this.search != null && !this.search.isEmpty();
1300    }
1301
1302    public boolean hasSearch() { 
1303      return this.search != null && !this.search.isEmpty();
1304    }
1305
1306    /**
1307     * @param value {@link #search} (Whether the search syntax is supported.). This is the underlying object with id, value and extensions. The accessor "getSearch" gives direct access to the value
1308     */
1309    public CompartmentDefinition setSearchElement(BooleanType value) { 
1310      this.search = value;
1311      return this;
1312    }
1313
1314    /**
1315     * @return Whether the search syntax is supported.
1316     */
1317    public boolean getSearch() { 
1318      return this.search == null || this.search.isEmpty() ? false : this.search.getValue();
1319    }
1320
1321    /**
1322     * @param value Whether the search syntax is supported.
1323     */
1324    public CompartmentDefinition setSearch(boolean value) { 
1325        if (this.search == null)
1326          this.search = new BooleanType();
1327        this.search.setValue(value);
1328      return this;
1329    }
1330
1331    /**
1332     * @return {@link #resource} (Information about how a resource it related to the compartment.)
1333     */
1334    public List<CompartmentDefinitionResourceComponent> getResource() { 
1335      if (this.resource == null)
1336        this.resource = new ArrayList<CompartmentDefinitionResourceComponent>();
1337      return this.resource;
1338    }
1339
1340    public boolean hasResource() { 
1341      if (this.resource == null)
1342        return false;
1343      for (CompartmentDefinitionResourceComponent item : this.resource)
1344        if (!item.isEmpty())
1345          return true;
1346      return false;
1347    }
1348
1349    /**
1350     * @return {@link #resource} (Information about how a resource it related to the compartment.)
1351     */
1352    // syntactic sugar
1353    public CompartmentDefinitionResourceComponent addResource() { //3
1354      CompartmentDefinitionResourceComponent t = new CompartmentDefinitionResourceComponent();
1355      if (this.resource == null)
1356        this.resource = new ArrayList<CompartmentDefinitionResourceComponent>();
1357      this.resource.add(t);
1358      return t;
1359    }
1360
1361    // syntactic sugar
1362    public CompartmentDefinition addResource(CompartmentDefinitionResourceComponent t) { //3
1363      if (t == null)
1364        return this;
1365      if (this.resource == null)
1366        this.resource = new ArrayList<CompartmentDefinitionResourceComponent>();
1367      this.resource.add(t);
1368      return this;
1369    }
1370
1371      protected void listChildren(List<Property> childrenList) {
1372        super.listChildren(childrenList);
1373        childrenList.add(new Property("url", "uri", "An absolute URL that is used to identify this compartment definition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this compartment definition is (or will be) published.", 0, java.lang.Integer.MAX_VALUE, url));
1374        childrenList.add(new Property("name", "string", "A free text natural language name identifying the compartment definition.", 0, java.lang.Integer.MAX_VALUE, name));
1375        childrenList.add(new Property("status", "code", "The status of this compartment definition definition.", 0, java.lang.Integer.MAX_VALUE, status));
1376        childrenList.add(new Property("experimental", "boolean", "A flag to indicate that this compartment definition definition is authored for testing purposes (or education/evaluation/marketing), and is not intended to be used for genuine usage.", 0, java.lang.Integer.MAX_VALUE, experimental));
1377        childrenList.add(new Property("publisher", "string", "The name of the individual or organization that published the compartment definition.", 0, java.lang.Integer.MAX_VALUE, publisher));
1378        childrenList.add(new Property("contact", "", "Contacts to assist a user in finding and communicating with the publisher.", 0, java.lang.Integer.MAX_VALUE, contact));
1379        childrenList.add(new Property("date", "dateTime", "The date  (and optionally time) when the compartment definition definition was published. The date must change when the business version changes, if it does, and it must change if the status code changes. In addition, it should change when the substantive content of the compartment definition changes.", 0, java.lang.Integer.MAX_VALUE, date));
1380        childrenList.add(new Property("description", "string", "A free text natural language description of the CompartmentDefinition and its use.", 0, java.lang.Integer.MAX_VALUE, description));
1381        childrenList.add(new Property("requirements", "string", "The Scope and Usage that this compartment definition was created to meet.", 0, java.lang.Integer.MAX_VALUE, requirements));
1382        childrenList.add(new Property("code", "code", "Which compartment this definition describes.", 0, java.lang.Integer.MAX_VALUE, code));
1383        childrenList.add(new Property("search", "boolean", "Whether the search syntax is supported.", 0, java.lang.Integer.MAX_VALUE, search));
1384        childrenList.add(new Property("resource", "", "Information about how a resource it related to the compartment.", 0, java.lang.Integer.MAX_VALUE, resource));
1385      }
1386
1387      @Override
1388      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1389        switch (hash) {
1390        case 116079: /*url*/ return this.url == null ? new Base[0] : new Base[] {this.url}; // UriType
1391        case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // StringType
1392        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<ConformanceResourceStatus>
1393        case -404562712: /*experimental*/ return this.experimental == null ? new Base[0] : new Base[] {this.experimental}; // BooleanType
1394        case 1447404028: /*publisher*/ return this.publisher == null ? new Base[0] : new Base[] {this.publisher}; // StringType
1395        case 951526432: /*contact*/ return this.contact == null ? new Base[0] : this.contact.toArray(new Base[this.contact.size()]); // CompartmentDefinitionContactComponent
1396        case 3076014: /*date*/ return this.date == null ? new Base[0] : new Base[] {this.date}; // DateTimeType
1397        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
1398        case -1619874672: /*requirements*/ return this.requirements == null ? new Base[0] : new Base[] {this.requirements}; // StringType
1399        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // Enumeration<CompartmentType>
1400        case -906336856: /*search*/ return this.search == null ? new Base[0] : new Base[] {this.search}; // BooleanType
1401        case -341064690: /*resource*/ return this.resource == null ? new Base[0] : this.resource.toArray(new Base[this.resource.size()]); // CompartmentDefinitionResourceComponent
1402        default: return super.getProperty(hash, name, checkValid);
1403        }
1404
1405      }
1406
1407      @Override
1408      public void setProperty(int hash, String name, Base value) throws FHIRException {
1409        switch (hash) {
1410        case 116079: // url
1411          this.url = castToUri(value); // UriType
1412          break;
1413        case 3373707: // name
1414          this.name = castToString(value); // StringType
1415          break;
1416        case -892481550: // status
1417          this.status = new ConformanceResourceStatusEnumFactory().fromType(value); // Enumeration<ConformanceResourceStatus>
1418          break;
1419        case -404562712: // experimental
1420          this.experimental = castToBoolean(value); // BooleanType
1421          break;
1422        case 1447404028: // publisher
1423          this.publisher = castToString(value); // StringType
1424          break;
1425        case 951526432: // contact
1426          this.getContact().add((CompartmentDefinitionContactComponent) value); // CompartmentDefinitionContactComponent
1427          break;
1428        case 3076014: // date
1429          this.date = castToDateTime(value); // DateTimeType
1430          break;
1431        case -1724546052: // description
1432          this.description = castToString(value); // StringType
1433          break;
1434        case -1619874672: // requirements
1435          this.requirements = castToString(value); // StringType
1436          break;
1437        case 3059181: // code
1438          this.code = new CompartmentTypeEnumFactory().fromType(value); // Enumeration<CompartmentType>
1439          break;
1440        case -906336856: // search
1441          this.search = castToBoolean(value); // BooleanType
1442          break;
1443        case -341064690: // resource
1444          this.getResource().add((CompartmentDefinitionResourceComponent) value); // CompartmentDefinitionResourceComponent
1445          break;
1446        default: super.setProperty(hash, name, value);
1447        }
1448
1449      }
1450
1451      @Override
1452      public void setProperty(String name, Base value) throws FHIRException {
1453        if (name.equals("url"))
1454          this.url = castToUri(value); // UriType
1455        else if (name.equals("name"))
1456          this.name = castToString(value); // StringType
1457        else if (name.equals("status"))
1458          this.status = new ConformanceResourceStatusEnumFactory().fromType(value); // Enumeration<ConformanceResourceStatus>
1459        else if (name.equals("experimental"))
1460          this.experimental = castToBoolean(value); // BooleanType
1461        else if (name.equals("publisher"))
1462          this.publisher = castToString(value); // StringType
1463        else if (name.equals("contact"))
1464          this.getContact().add((CompartmentDefinitionContactComponent) value);
1465        else if (name.equals("date"))
1466          this.date = castToDateTime(value); // DateTimeType
1467        else if (name.equals("description"))
1468          this.description = castToString(value); // StringType
1469        else if (name.equals("requirements"))
1470          this.requirements = castToString(value); // StringType
1471        else if (name.equals("code"))
1472          this.code = new CompartmentTypeEnumFactory().fromType(value); // Enumeration<CompartmentType>
1473        else if (name.equals("search"))
1474          this.search = castToBoolean(value); // BooleanType
1475        else if (name.equals("resource"))
1476          this.getResource().add((CompartmentDefinitionResourceComponent) value);
1477        else
1478          super.setProperty(name, value);
1479      }
1480
1481      @Override
1482      public Base makeProperty(int hash, String name) throws FHIRException {
1483        switch (hash) {
1484        case 116079: throw new FHIRException("Cannot make property url as it is not a complex type"); // UriType
1485        case 3373707: throw new FHIRException("Cannot make property name as it is not a complex type"); // StringType
1486        case -892481550: throw new FHIRException("Cannot make property status as it is not a complex type"); // Enumeration<ConformanceResourceStatus>
1487        case -404562712: throw new FHIRException("Cannot make property experimental as it is not a complex type"); // BooleanType
1488        case 1447404028: throw new FHIRException("Cannot make property publisher as it is not a complex type"); // StringType
1489        case 951526432:  return addContact(); // CompartmentDefinitionContactComponent
1490        case 3076014: throw new FHIRException("Cannot make property date as it is not a complex type"); // DateTimeType
1491        case -1724546052: throw new FHIRException("Cannot make property description as it is not a complex type"); // StringType
1492        case -1619874672: throw new FHIRException("Cannot make property requirements as it is not a complex type"); // StringType
1493        case 3059181: throw new FHIRException("Cannot make property code as it is not a complex type"); // Enumeration<CompartmentType>
1494        case -906336856: throw new FHIRException("Cannot make property search as it is not a complex type"); // BooleanType
1495        case -341064690:  return addResource(); // CompartmentDefinitionResourceComponent
1496        default: return super.makeProperty(hash, name);
1497        }
1498
1499      }
1500
1501      @Override
1502      public Base addChild(String name) throws FHIRException {
1503        if (name.equals("url")) {
1504          throw new FHIRException("Cannot call addChild on a primitive type CompartmentDefinition.url");
1505        }
1506        else if (name.equals("name")) {
1507          throw new FHIRException("Cannot call addChild on a primitive type CompartmentDefinition.name");
1508        }
1509        else if (name.equals("status")) {
1510          throw new FHIRException("Cannot call addChild on a primitive type CompartmentDefinition.status");
1511        }
1512        else if (name.equals("experimental")) {
1513          throw new FHIRException("Cannot call addChild on a primitive type CompartmentDefinition.experimental");
1514        }
1515        else if (name.equals("publisher")) {
1516          throw new FHIRException("Cannot call addChild on a primitive type CompartmentDefinition.publisher");
1517        }
1518        else if (name.equals("contact")) {
1519          return addContact();
1520        }
1521        else if (name.equals("date")) {
1522          throw new FHIRException("Cannot call addChild on a primitive type CompartmentDefinition.date");
1523        }
1524        else if (name.equals("description")) {
1525          throw new FHIRException("Cannot call addChild on a primitive type CompartmentDefinition.description");
1526        }
1527        else if (name.equals("requirements")) {
1528          throw new FHIRException("Cannot call addChild on a primitive type CompartmentDefinition.requirements");
1529        }
1530        else if (name.equals("code")) {
1531          throw new FHIRException("Cannot call addChild on a primitive type CompartmentDefinition.code");
1532        }
1533        else if (name.equals("search")) {
1534          throw new FHIRException("Cannot call addChild on a primitive type CompartmentDefinition.search");
1535        }
1536        else if (name.equals("resource")) {
1537          return addResource();
1538        }
1539        else
1540          return super.addChild(name);
1541      }
1542
1543  public String fhirType() {
1544    return "CompartmentDefinition";
1545
1546  }
1547
1548      public CompartmentDefinition copy() {
1549        CompartmentDefinition dst = new CompartmentDefinition();
1550        copyValues(dst);
1551        dst.url = url == null ? null : url.copy();
1552        dst.name = name == null ? null : name.copy();
1553        dst.status = status == null ? null : status.copy();
1554        dst.experimental = experimental == null ? null : experimental.copy();
1555        dst.publisher = publisher == null ? null : publisher.copy();
1556        if (contact != null) {
1557          dst.contact = new ArrayList<CompartmentDefinitionContactComponent>();
1558          for (CompartmentDefinitionContactComponent i : contact)
1559            dst.contact.add(i.copy());
1560        };
1561        dst.date = date == null ? null : date.copy();
1562        dst.description = description == null ? null : description.copy();
1563        dst.requirements = requirements == null ? null : requirements.copy();
1564        dst.code = code == null ? null : code.copy();
1565        dst.search = search == null ? null : search.copy();
1566        if (resource != null) {
1567          dst.resource = new ArrayList<CompartmentDefinitionResourceComponent>();
1568          for (CompartmentDefinitionResourceComponent i : resource)
1569            dst.resource.add(i.copy());
1570        };
1571        return dst;
1572      }
1573
1574      protected CompartmentDefinition typedCopy() {
1575        return copy();
1576      }
1577
1578      @Override
1579      public boolean equalsDeep(Base other) {
1580        if (!super.equalsDeep(other))
1581          return false;
1582        if (!(other instanceof CompartmentDefinition))
1583          return false;
1584        CompartmentDefinition o = (CompartmentDefinition) other;
1585        return compareDeep(url, o.url, true) && compareDeep(name, o.name, true) && compareDeep(status, o.status, true)
1586           && compareDeep(experimental, o.experimental, true) && compareDeep(publisher, o.publisher, true)
1587           && compareDeep(contact, o.contact, true) && compareDeep(date, o.date, true) && compareDeep(description, o.description, true)
1588           && compareDeep(requirements, o.requirements, true) && compareDeep(code, o.code, true) && compareDeep(search, o.search, true)
1589           && compareDeep(resource, o.resource, true);
1590      }
1591
1592      @Override
1593      public boolean equalsShallow(Base other) {
1594        if (!super.equalsShallow(other))
1595          return false;
1596        if (!(other instanceof CompartmentDefinition))
1597          return false;
1598        CompartmentDefinition o = (CompartmentDefinition) other;
1599        return compareValues(url, o.url, true) && compareValues(name, o.name, true) && compareValues(status, o.status, true)
1600           && compareValues(experimental, o.experimental, true) && compareValues(publisher, o.publisher, true)
1601           && compareValues(date, o.date, true) && compareValues(description, o.description, true) && compareValues(requirements, o.requirements, true)
1602           && compareValues(code, o.code, true) && compareValues(search, o.search, true);
1603      }
1604
1605      public boolean isEmpty() {
1606        return super.isEmpty() && (url == null || url.isEmpty()) && (name == null || name.isEmpty())
1607           && (status == null || status.isEmpty()) && (experimental == null || experimental.isEmpty())
1608           && (publisher == null || publisher.isEmpty()) && (contact == null || contact.isEmpty()) && (date == null || date.isEmpty())
1609           && (description == null || description.isEmpty()) && (requirements == null || requirements.isEmpty())
1610           && (code == null || code.isEmpty()) && (search == null || search.isEmpty()) && (resource == null || resource.isEmpty())
1611          ;
1612      }
1613
1614  @Override
1615  public ResourceType getResourceType() {
1616    return ResourceType.CompartmentDefinition;
1617   }
1618
1619 /**
1620   * Search parameter: <b>status</b>
1621   * <p>
1622   * Description: <b>draft | active | retired</b><br>
1623   * Type: <b>token</b><br>
1624   * Path: <b>CompartmentDefinition.status</b><br>
1625   * </p>
1626   */
1627  @SearchParamDefinition(name="status", path="CompartmentDefinition.status", description="draft | active | retired", type="token" )
1628  public static final String SP_STATUS = "status";
1629 /**
1630   * <b>Fluent Client</b> search parameter constant for <b>status</b>
1631   * <p>
1632   * Description: <b>draft | active | retired</b><br>
1633   * Type: <b>token</b><br>
1634   * Path: <b>CompartmentDefinition.status</b><br>
1635   * </p>
1636   */
1637  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
1638
1639 /**
1640   * Search parameter: <b>name</b>
1641   * <p>
1642   * Description: <b>Informal name for this compartment definition</b><br>
1643   * Type: <b>string</b><br>
1644   * Path: <b>CompartmentDefinition.name</b><br>
1645   * </p>
1646   */
1647  @SearchParamDefinition(name="name", path="CompartmentDefinition.name", description="Informal name for this compartment definition", type="string" )
1648  public static final String SP_NAME = "name";
1649 /**
1650   * <b>Fluent Client</b> search parameter constant for <b>name</b>
1651   * <p>
1652   * Description: <b>Informal name for this compartment definition</b><br>
1653   * Type: <b>string</b><br>
1654   * Path: <b>CompartmentDefinition.name</b><br>
1655   * </p>
1656   */
1657  public static final ca.uhn.fhir.rest.gclient.StringClientParam NAME = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_NAME);
1658
1659 /**
1660   * Search parameter: <b>resource</b>
1661   * <p>
1662   * Description: <b>Name of resource type</b><br>
1663   * Type: <b>token</b><br>
1664   * Path: <b>CompartmentDefinition.resource.code</b><br>
1665   * </p>
1666   */
1667  @SearchParamDefinition(name="resource", path="CompartmentDefinition.resource.code", description="Name of resource type", type="token" )
1668  public static final String SP_RESOURCE = "resource";
1669 /**
1670   * <b>Fluent Client</b> search parameter constant for <b>resource</b>
1671   * <p>
1672   * Description: <b>Name of resource type</b><br>
1673   * Type: <b>token</b><br>
1674   * Path: <b>CompartmentDefinition.resource.code</b><br>
1675   * </p>
1676   */
1677  public static final ca.uhn.fhir.rest.gclient.TokenClientParam RESOURCE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_RESOURCE);
1678
1679 /**
1680   * Search parameter: <b>code</b>
1681   * <p>
1682   * Description: <b>Patient | Encounter | RelatedPerson | Practitioner | Device</b><br>
1683   * Type: <b>token</b><br>
1684   * Path: <b>CompartmentDefinition.code</b><br>
1685   * </p>
1686   */
1687  @SearchParamDefinition(name="code", path="CompartmentDefinition.code", description="Patient | Encounter | RelatedPerson | Practitioner | Device", type="token" )
1688  public static final String SP_CODE = "code";
1689 /**
1690   * <b>Fluent Client</b> search parameter constant for <b>code</b>
1691   * <p>
1692   * Description: <b>Patient | Encounter | RelatedPerson | Practitioner | Device</b><br>
1693   * Type: <b>token</b><br>
1694   * Path: <b>CompartmentDefinition.code</b><br>
1695   * </p>
1696   */
1697  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
1698
1699 /**
1700   * Search parameter: <b>date</b>
1701   * <p>
1702   * Description: <b>Publication Date(/time)</b><br>
1703   * Type: <b>date</b><br>
1704   * Path: <b>CompartmentDefinition.date</b><br>
1705   * </p>
1706   */
1707  @SearchParamDefinition(name="date", path="CompartmentDefinition.date", description="Publication Date(/time)", type="date" )
1708  public static final String SP_DATE = "date";
1709 /**
1710   * <b>Fluent Client</b> search parameter constant for <b>date</b>
1711   * <p>
1712   * Description: <b>Publication Date(/time)</b><br>
1713   * Type: <b>date</b><br>
1714   * Path: <b>CompartmentDefinition.date</b><br>
1715   * </p>
1716   */
1717  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
1718
1719 /**
1720   * Search parameter: <b>url</b>
1721   * <p>
1722   * Description: <b>Absolute URL used to reference this compartment definition</b><br>
1723   * Type: <b>uri</b><br>
1724   * Path: <b>CompartmentDefinition.url</b><br>
1725   * </p>
1726   */
1727  @SearchParamDefinition(name="url", path="CompartmentDefinition.url", description="Absolute URL used to reference this compartment definition", type="uri" )
1728  public static final String SP_URL = "url";
1729 /**
1730   * <b>Fluent Client</b> search parameter constant for <b>url</b>
1731   * <p>
1732   * Description: <b>Absolute URL used to reference this compartment definition</b><br>
1733   * Type: <b>uri</b><br>
1734   * Path: <b>CompartmentDefinition.url</b><br>
1735   * </p>
1736   */
1737  public static final ca.uhn.fhir.rest.gclient.UriClientParam URL = new ca.uhn.fhir.rest.gclient.UriClientParam(SP_URL);
1738
1739
1740}
1741