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