001package org.hl7.fhir.dstu2.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 Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
036import java.util.ArrayList;
037import java.util.Date;
038import java.util.List;
039
040import org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus;
041import org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatusEnumFactory;
042import ca.uhn.fhir.model.api.annotation.Block;
043import ca.uhn.fhir.model.api.annotation.Child;
044import ca.uhn.fhir.model.api.annotation.Description;
045import ca.uhn.fhir.model.api.annotation.ResourceDef;
046import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
047import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
048import org.hl7.fhir.exceptions.FHIRException;
049import org.hl7.fhir.utilities.Utilities;
050/**
051 * A definition of a FHIR structure. This resource is used to describe the underlying resources, data types defined in FHIR, and also for describing extensions, and constraints on resources and data types.
052 */
053@ResourceDef(name="StructureDefinition", profile="http://hl7.org/fhir/Profile/StructureDefinition")
054public class StructureDefinition extends DomainResource {
055
056    public enum StructureDefinitionKind {
057        /**
058         * A data type - either a primitive or complex structure that defines a set of data elements. These can be used throughout Resource and extension definitions.
059         */
060        DATATYPE, 
061        /**
062         * A resource defined by the FHIR specification.
063         */
064        RESOURCE, 
065        /**
066         * A logical model - a conceptual package of data that will be mapped to resources for implementation.
067         */
068        LOGICAL, 
069        /**
070         * added to help the parsers
071         */
072        NULL;
073        public static StructureDefinitionKind fromCode(String codeString) throws FHIRException {
074            if (codeString == null || "".equals(codeString))
075                return null;
076        if ("datatype".equals(codeString))
077          return DATATYPE;
078        if ("resource".equals(codeString))
079          return RESOURCE;
080        if ("logical".equals(codeString))
081          return LOGICAL;
082        throw new FHIRException("Unknown StructureDefinitionKind code '"+codeString+"'");
083        }
084        public String toCode() {
085          switch (this) {
086            case DATATYPE: return "datatype";
087            case RESOURCE: return "resource";
088            case LOGICAL: return "logical";
089            default: return "?";
090          }
091        }
092        public String getSystem() {
093          switch (this) {
094            case DATATYPE: return "http://hl7.org/fhir/structure-definition-kind";
095            case RESOURCE: return "http://hl7.org/fhir/structure-definition-kind";
096            case LOGICAL: return "http://hl7.org/fhir/structure-definition-kind";
097            default: return "?";
098          }
099        }
100        public String getDefinition() {
101          switch (this) {
102            case DATATYPE: return "A data type - either a primitive or complex structure that defines a set of data elements. These can be used throughout Resource and extension definitions.";
103            case RESOURCE: return "A resource defined by the FHIR specification.";
104            case LOGICAL: return "A logical model - a conceptual package of data that will be mapped to resources for implementation.";
105            default: return "?";
106          }
107        }
108        public String getDisplay() {
109          switch (this) {
110            case DATATYPE: return "Data Type";
111            case RESOURCE: return "Resource";
112            case LOGICAL: return "Logical Model";
113            default: return "?";
114          }
115        }
116    }
117
118  public static class StructureDefinitionKindEnumFactory implements EnumFactory<StructureDefinitionKind> {
119    public StructureDefinitionKind fromCode(String codeString) throws IllegalArgumentException {
120      if (codeString == null || "".equals(codeString))
121            if (codeString == null || "".equals(codeString))
122                return null;
123        if ("datatype".equals(codeString))
124          return StructureDefinitionKind.DATATYPE;
125        if ("resource".equals(codeString))
126          return StructureDefinitionKind.RESOURCE;
127        if ("logical".equals(codeString))
128          return StructureDefinitionKind.LOGICAL;
129        throw new IllegalArgumentException("Unknown StructureDefinitionKind code '"+codeString+"'");
130        }
131        public Enumeration<StructureDefinitionKind> fromType(Base code) throws FHIRException {
132          if (code == null || code.isEmpty())
133            return null;
134          String codeString = ((PrimitiveType) code).asStringValue();
135          if (codeString == null || "".equals(codeString))
136            return null;
137        if ("datatype".equals(codeString))
138          return new Enumeration<StructureDefinitionKind>(this, StructureDefinitionKind.DATATYPE);
139        if ("resource".equals(codeString))
140          return new Enumeration<StructureDefinitionKind>(this, StructureDefinitionKind.RESOURCE);
141        if ("logical".equals(codeString))
142          return new Enumeration<StructureDefinitionKind>(this, StructureDefinitionKind.LOGICAL);
143        throw new FHIRException("Unknown StructureDefinitionKind code '"+codeString+"'");
144        }
145    public String toCode(StructureDefinitionKind code) {
146      if (code == StructureDefinitionKind.DATATYPE)
147        return "datatype";
148      if (code == StructureDefinitionKind.RESOURCE)
149        return "resource";
150      if (code == StructureDefinitionKind.LOGICAL)
151        return "logical";
152      return "?";
153      }
154    }
155
156    public enum ExtensionContext {
157        /**
158         * The context is all elements matching a particular resource element path.
159         */
160        RESOURCE, 
161        /**
162         * The context is all nodes matching a particular data type element path (root or repeating element) or all elements referencing a particular primitive data type (expressed as the datatype name).
163         */
164        DATATYPE, 
165        /**
166         * The context is all nodes whose mapping to a specified reference model corresponds to a particular mapping structure.  The context identifies the mapping target. The mapping should clearly identify where such an extension could be used.
167         */
168        MAPPING, 
169        /**
170         * The context is a particular extension from a particular profile, a uri that identifies the extension definition.
171         */
172        EXTENSION, 
173        /**
174         * added to help the parsers
175         */
176        NULL;
177        public static ExtensionContext fromCode(String codeString) throws FHIRException {
178            if (codeString == null || "".equals(codeString))
179                return null;
180        if ("resource".equals(codeString))
181          return RESOURCE;
182        if ("datatype".equals(codeString))
183          return DATATYPE;
184        if ("mapping".equals(codeString))
185          return MAPPING;
186        if ("extension".equals(codeString))
187          return EXTENSION;
188        throw new FHIRException("Unknown ExtensionContext code '"+codeString+"'");
189        }
190        public String toCode() {
191          switch (this) {
192            case RESOURCE: return "resource";
193            case DATATYPE: return "datatype";
194            case MAPPING: return "mapping";
195            case EXTENSION: return "extension";
196            default: return "?";
197          }
198        }
199        public String getSystem() {
200          switch (this) {
201            case RESOURCE: return "http://hl7.org/fhir/extension-context";
202            case DATATYPE: return "http://hl7.org/fhir/extension-context";
203            case MAPPING: return "http://hl7.org/fhir/extension-context";
204            case EXTENSION: return "http://hl7.org/fhir/extension-context";
205            default: return "?";
206          }
207        }
208        public String getDefinition() {
209          switch (this) {
210            case RESOURCE: return "The context is all elements matching a particular resource element path.";
211            case DATATYPE: return "The context is all nodes matching a particular data type element path (root or repeating element) or all elements referencing a particular primitive data type (expressed as the datatype name).";
212            case MAPPING: return "The context is all nodes whose mapping to a specified reference model corresponds to a particular mapping structure.  The context identifies the mapping target. The mapping should clearly identify where such an extension could be used.";
213            case EXTENSION: return "The context is a particular extension from a particular profile, a uri that identifies the extension definition.";
214            default: return "?";
215          }
216        }
217        public String getDisplay() {
218          switch (this) {
219            case RESOURCE: return "Resource";
220            case DATATYPE: return "Datatype";
221            case MAPPING: return "Mapping";
222            case EXTENSION: return "Extension";
223            default: return "?";
224          }
225        }
226    }
227
228  public static class ExtensionContextEnumFactory implements EnumFactory<ExtensionContext> {
229    public ExtensionContext fromCode(String codeString) throws IllegalArgumentException {
230      if (codeString == null || "".equals(codeString))
231            if (codeString == null || "".equals(codeString))
232                return null;
233        if ("resource".equals(codeString))
234          return ExtensionContext.RESOURCE;
235        if ("datatype".equals(codeString))
236          return ExtensionContext.DATATYPE;
237        if ("mapping".equals(codeString))
238          return ExtensionContext.MAPPING;
239        if ("extension".equals(codeString))
240          return ExtensionContext.EXTENSION;
241        throw new IllegalArgumentException("Unknown ExtensionContext code '"+codeString+"'");
242        }
243        public Enumeration<ExtensionContext> fromType(Base code) throws FHIRException {
244          if (code == null || code.isEmpty())
245            return null;
246          String codeString = ((PrimitiveType) code).asStringValue();
247          if (codeString == null || "".equals(codeString))
248            return null;
249        if ("resource".equals(codeString))
250          return new Enumeration<ExtensionContext>(this, ExtensionContext.RESOURCE);
251        if ("datatype".equals(codeString))
252          return new Enumeration<ExtensionContext>(this, ExtensionContext.DATATYPE);
253        if ("mapping".equals(codeString))
254          return new Enumeration<ExtensionContext>(this, ExtensionContext.MAPPING);
255        if ("extension".equals(codeString))
256          return new Enumeration<ExtensionContext>(this, ExtensionContext.EXTENSION);
257        throw new FHIRException("Unknown ExtensionContext code '"+codeString+"'");
258        }
259    public String toCode(ExtensionContext code) {
260      if (code == ExtensionContext.RESOURCE)
261        return "resource";
262      if (code == ExtensionContext.DATATYPE)
263        return "datatype";
264      if (code == ExtensionContext.MAPPING)
265        return "mapping";
266      if (code == ExtensionContext.EXTENSION)
267        return "extension";
268      return "?";
269      }
270    }
271
272    @Block()
273    public static class StructureDefinitionContactComponent extends BackboneElement implements IBaseBackboneElement {
274        /**
275         * The name of an individual to contact regarding the structure definition.
276         */
277        @Child(name = "name", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
278        @Description(shortDefinition="Name of a individual to contact", formalDefinition="The name of an individual to contact regarding the structure definition." )
279        protected StringType name;
280
281        /**
282         * Contact details for individual (if a name was provided) or the publisher.
283         */
284        @Child(name = "telecom", type = {ContactPoint.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
285        @Description(shortDefinition="Contact details for individual or publisher", formalDefinition="Contact details for individual (if a name was provided) or the publisher." )
286        protected List<ContactPoint> telecom;
287
288        private static final long serialVersionUID = -1179697803L;
289
290    /*
291     * Constructor
292     */
293      public StructureDefinitionContactComponent() {
294        super();
295      }
296
297        /**
298         * @return {@link #name} (The name of an individual to contact regarding the structure definition.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
299         */
300        public StringType getNameElement() { 
301          if (this.name == null)
302            if (Configuration.errorOnAutoCreate())
303              throw new Error("Attempt to auto-create StructureDefinitionContactComponent.name");
304            else if (Configuration.doAutoCreate())
305              this.name = new StringType(); // bb
306          return this.name;
307        }
308
309        public boolean hasNameElement() { 
310          return this.name != null && !this.name.isEmpty();
311        }
312
313        public boolean hasName() { 
314          return this.name != null && !this.name.isEmpty();
315        }
316
317        /**
318         * @param value {@link #name} (The name of an individual to contact regarding the structure definition.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
319         */
320        public StructureDefinitionContactComponent setNameElement(StringType value) { 
321          this.name = value;
322          return this;
323        }
324
325        /**
326         * @return The name of an individual to contact regarding the structure definition.
327         */
328        public String getName() { 
329          return this.name == null ? null : this.name.getValue();
330        }
331
332        /**
333         * @param value The name of an individual to contact regarding the structure definition.
334         */
335        public StructureDefinitionContactComponent setName(String value) { 
336          if (Utilities.noString(value))
337            this.name = null;
338          else {
339            if (this.name == null)
340              this.name = new StringType();
341            this.name.setValue(value);
342          }
343          return this;
344        }
345
346        /**
347         * @return {@link #telecom} (Contact details for individual (if a name was provided) or the publisher.)
348         */
349        public List<ContactPoint> getTelecom() { 
350          if (this.telecom == null)
351            this.telecom = new ArrayList<ContactPoint>();
352          return this.telecom;
353        }
354
355        public boolean hasTelecom() { 
356          if (this.telecom == null)
357            return false;
358          for (ContactPoint item : this.telecom)
359            if (!item.isEmpty())
360              return true;
361          return false;
362        }
363
364        /**
365         * @return {@link #telecom} (Contact details for individual (if a name was provided) or the publisher.)
366         */
367    // syntactic sugar
368        public ContactPoint addTelecom() { //3
369          ContactPoint t = new ContactPoint();
370          if (this.telecom == null)
371            this.telecom = new ArrayList<ContactPoint>();
372          this.telecom.add(t);
373          return t;
374        }
375
376    // syntactic sugar
377        public StructureDefinitionContactComponent addTelecom(ContactPoint t) { //3
378          if (t == null)
379            return this;
380          if (this.telecom == null)
381            this.telecom = new ArrayList<ContactPoint>();
382          this.telecom.add(t);
383          return this;
384        }
385
386        protected void listChildren(List<Property> childrenList) {
387          super.listChildren(childrenList);
388          childrenList.add(new Property("name", "string", "The name of an individual to contact regarding the structure definition.", 0, java.lang.Integer.MAX_VALUE, name));
389          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));
390        }
391
392      @Override
393      public void setProperty(String name, Base value) throws FHIRException {
394        if (name.equals("name"))
395          this.name = castToString(value); // StringType
396        else if (name.equals("telecom"))
397          this.getTelecom().add(castToContactPoint(value));
398        else
399          super.setProperty(name, value);
400      }
401
402      @Override
403      public Base addChild(String name) throws FHIRException {
404        if (name.equals("name")) {
405          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.name");
406        }
407        else if (name.equals("telecom")) {
408          return addTelecom();
409        }
410        else
411          return super.addChild(name);
412      }
413
414      public StructureDefinitionContactComponent copy() {
415        StructureDefinitionContactComponent dst = new StructureDefinitionContactComponent();
416        copyValues(dst);
417        dst.name = name == null ? null : name.copy();
418        if (telecom != null) {
419          dst.telecom = new ArrayList<ContactPoint>();
420          for (ContactPoint i : telecom)
421            dst.telecom.add(i.copy());
422        };
423        return dst;
424      }
425
426      @Override
427      public boolean equalsDeep(Base other) {
428        if (!super.equalsDeep(other))
429          return false;
430        if (!(other instanceof StructureDefinitionContactComponent))
431          return false;
432        StructureDefinitionContactComponent o = (StructureDefinitionContactComponent) other;
433        return compareDeep(name, o.name, true) && compareDeep(telecom, o.telecom, true);
434      }
435
436      @Override
437      public boolean equalsShallow(Base other) {
438        if (!super.equalsShallow(other))
439          return false;
440        if (!(other instanceof StructureDefinitionContactComponent))
441          return false;
442        StructureDefinitionContactComponent o = (StructureDefinitionContactComponent) other;
443        return compareValues(name, o.name, true);
444      }
445
446      public boolean isEmpty() {
447        return super.isEmpty() && (name == null || name.isEmpty()) && (telecom == null || telecom.isEmpty())
448          ;
449      }
450
451  public String fhirType() {
452    return "StructureDefinition.contact";
453
454  }
455
456  }
457
458    @Block()
459    public static class StructureDefinitionMappingComponent extends BackboneElement implements IBaseBackboneElement {
460        /**
461         * An Internal id that is used to identify this mapping set when specific mappings are made.
462         */
463        @Child(name = "identity", type = {IdType.class}, order=1, min=1, max=1, modifier=false, summary=false)
464        @Description(shortDefinition="Internal id when this mapping is used", formalDefinition="An Internal id that is used to identify this mapping set when specific mappings are made." )
465        protected IdType identity;
466
467        /**
468         * An absolute URI that identifies the specification that this mapping is expressed to.
469         */
470        @Child(name = "uri", type = {UriType.class}, order=2, min=0, max=1, modifier=false, summary=false)
471        @Description(shortDefinition="Identifies what this mapping refers to", formalDefinition="An absolute URI that identifies the specification that this mapping is expressed to." )
472        protected UriType uri;
473
474        /**
475         * A name for the specification that is being mapped to.
476         */
477        @Child(name = "name", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=false)
478        @Description(shortDefinition="Names what this mapping refers to", formalDefinition="A name for the specification that is being mapped to." )
479        protected StringType name;
480
481        /**
482         * Comments about this mapping, including version notes, issues, scope limitations, and other important notes for usage.
483         */
484        @Child(name = "comments", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=false)
485        @Description(shortDefinition="Versions, Issues, Scope limitations etc.", formalDefinition="Comments about this mapping, including version notes, issues, scope limitations, and other important notes for usage." )
486        protected StringType comments;
487
488        private static final long serialVersionUID = 299630820L;
489
490    /*
491     * Constructor
492     */
493      public StructureDefinitionMappingComponent() {
494        super();
495      }
496
497    /*
498     * Constructor
499     */
500      public StructureDefinitionMappingComponent(IdType identity) {
501        super();
502        this.identity = identity;
503      }
504
505        /**
506         * @return {@link #identity} (An Internal id that is used to identify this mapping set when specific mappings are made.). This is the underlying object with id, value and extensions. The accessor "getIdentity" gives direct access to the value
507         */
508        public IdType getIdentityElement() { 
509          if (this.identity == null)
510            if (Configuration.errorOnAutoCreate())
511              throw new Error("Attempt to auto-create StructureDefinitionMappingComponent.identity");
512            else if (Configuration.doAutoCreate())
513              this.identity = new IdType(); // bb
514          return this.identity;
515        }
516
517        public boolean hasIdentityElement() { 
518          return this.identity != null && !this.identity.isEmpty();
519        }
520
521        public boolean hasIdentity() { 
522          return this.identity != null && !this.identity.isEmpty();
523        }
524
525        /**
526         * @param value {@link #identity} (An Internal id that is used to identify this mapping set when specific mappings are made.). This is the underlying object with id, value and extensions. The accessor "getIdentity" gives direct access to the value
527         */
528        public StructureDefinitionMappingComponent setIdentityElement(IdType value) { 
529          this.identity = value;
530          return this;
531        }
532
533        /**
534         * @return An Internal id that is used to identify this mapping set when specific mappings are made.
535         */
536        public String getIdentity() { 
537          return this.identity == null ? null : this.identity.getValue();
538        }
539
540        /**
541         * @param value An Internal id that is used to identify this mapping set when specific mappings are made.
542         */
543        public StructureDefinitionMappingComponent setIdentity(String value) { 
544            if (this.identity == null)
545              this.identity = new IdType();
546            this.identity.setValue(value);
547          return this;
548        }
549
550        /**
551         * @return {@link #uri} (An absolute URI that identifies the specification that this mapping is expressed to.). This is the underlying object with id, value and extensions. The accessor "getUri" gives direct access to the value
552         */
553        public UriType getUriElement() { 
554          if (this.uri == null)
555            if (Configuration.errorOnAutoCreate())
556              throw new Error("Attempt to auto-create StructureDefinitionMappingComponent.uri");
557            else if (Configuration.doAutoCreate())
558              this.uri = new UriType(); // bb
559          return this.uri;
560        }
561
562        public boolean hasUriElement() { 
563          return this.uri != null && !this.uri.isEmpty();
564        }
565
566        public boolean hasUri() { 
567          return this.uri != null && !this.uri.isEmpty();
568        }
569
570        /**
571         * @param value {@link #uri} (An absolute URI that identifies the specification that this mapping is expressed to.). This is the underlying object with id, value and extensions. The accessor "getUri" gives direct access to the value
572         */
573        public StructureDefinitionMappingComponent setUriElement(UriType value) { 
574          this.uri = value;
575          return this;
576        }
577
578        /**
579         * @return An absolute URI that identifies the specification that this mapping is expressed to.
580         */
581        public String getUri() { 
582          return this.uri == null ? null : this.uri.getValue();
583        }
584
585        /**
586         * @param value An absolute URI that identifies the specification that this mapping is expressed to.
587         */
588        public StructureDefinitionMappingComponent setUri(String value) { 
589          if (Utilities.noString(value))
590            this.uri = null;
591          else {
592            if (this.uri == null)
593              this.uri = new UriType();
594            this.uri.setValue(value);
595          }
596          return this;
597        }
598
599        /**
600         * @return {@link #name} (A name for the specification that is being mapped to.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
601         */
602        public StringType getNameElement() { 
603          if (this.name == null)
604            if (Configuration.errorOnAutoCreate())
605              throw new Error("Attempt to auto-create StructureDefinitionMappingComponent.name");
606            else if (Configuration.doAutoCreate())
607              this.name = new StringType(); // bb
608          return this.name;
609        }
610
611        public boolean hasNameElement() { 
612          return this.name != null && !this.name.isEmpty();
613        }
614
615        public boolean hasName() { 
616          return this.name != null && !this.name.isEmpty();
617        }
618
619        /**
620         * @param value {@link #name} (A name for the specification that is being mapped to.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
621         */
622        public StructureDefinitionMappingComponent setNameElement(StringType value) { 
623          this.name = value;
624          return this;
625        }
626
627        /**
628         * @return A name for the specification that is being mapped to.
629         */
630        public String getName() { 
631          return this.name == null ? null : this.name.getValue();
632        }
633
634        /**
635         * @param value A name for the specification that is being mapped to.
636         */
637        public StructureDefinitionMappingComponent setName(String value) { 
638          if (Utilities.noString(value))
639            this.name = null;
640          else {
641            if (this.name == null)
642              this.name = new StringType();
643            this.name.setValue(value);
644          }
645          return this;
646        }
647
648        /**
649         * @return {@link #comments} (Comments about this mapping, including version notes, issues, scope limitations, and other important notes for usage.). This is the underlying object with id, value and extensions. The accessor "getComments" gives direct access to the value
650         */
651        public StringType getCommentsElement() { 
652          if (this.comments == null)
653            if (Configuration.errorOnAutoCreate())
654              throw new Error("Attempt to auto-create StructureDefinitionMappingComponent.comments");
655            else if (Configuration.doAutoCreate())
656              this.comments = new StringType(); // bb
657          return this.comments;
658        }
659
660        public boolean hasCommentsElement() { 
661          return this.comments != null && !this.comments.isEmpty();
662        }
663
664        public boolean hasComments() { 
665          return this.comments != null && !this.comments.isEmpty();
666        }
667
668        /**
669         * @param value {@link #comments} (Comments about this mapping, including version notes, issues, scope limitations, and other important notes for usage.). This is the underlying object with id, value and extensions. The accessor "getComments" gives direct access to the value
670         */
671        public StructureDefinitionMappingComponent setCommentsElement(StringType value) { 
672          this.comments = value;
673          return this;
674        }
675
676        /**
677         * @return Comments about this mapping, including version notes, issues, scope limitations, and other important notes for usage.
678         */
679        public String getComments() { 
680          return this.comments == null ? null : this.comments.getValue();
681        }
682
683        /**
684         * @param value Comments about this mapping, including version notes, issues, scope limitations, and other important notes for usage.
685         */
686        public StructureDefinitionMappingComponent setComments(String value) { 
687          if (Utilities.noString(value))
688            this.comments = null;
689          else {
690            if (this.comments == null)
691              this.comments = new StringType();
692            this.comments.setValue(value);
693          }
694          return this;
695        }
696
697        protected void listChildren(List<Property> childrenList) {
698          super.listChildren(childrenList);
699          childrenList.add(new Property("identity", "id", "An Internal id that is used to identify this mapping set when specific mappings are made.", 0, java.lang.Integer.MAX_VALUE, identity));
700          childrenList.add(new Property("uri", "uri", "An absolute URI that identifies the specification that this mapping is expressed to.", 0, java.lang.Integer.MAX_VALUE, uri));
701          childrenList.add(new Property("name", "string", "A name for the specification that is being mapped to.", 0, java.lang.Integer.MAX_VALUE, name));
702          childrenList.add(new Property("comments", "string", "Comments about this mapping, including version notes, issues, scope limitations, and other important notes for usage.", 0, java.lang.Integer.MAX_VALUE, comments));
703        }
704
705      @Override
706      public void setProperty(String name, Base value) throws FHIRException {
707        if (name.equals("identity"))
708          this.identity = castToId(value); // IdType
709        else if (name.equals("uri"))
710          this.uri = castToUri(value); // UriType
711        else if (name.equals("name"))
712          this.name = castToString(value); // StringType
713        else if (name.equals("comments"))
714          this.comments = castToString(value); // StringType
715        else
716          super.setProperty(name, value);
717      }
718
719      @Override
720      public Base addChild(String name) throws FHIRException {
721        if (name.equals("identity")) {
722          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.identity");
723        }
724        else if (name.equals("uri")) {
725          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.uri");
726        }
727        else if (name.equals("name")) {
728          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.name");
729        }
730        else if (name.equals("comments")) {
731          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.comments");
732        }
733        else
734          return super.addChild(name);
735      }
736
737      public StructureDefinitionMappingComponent copy() {
738        StructureDefinitionMappingComponent dst = new StructureDefinitionMappingComponent();
739        copyValues(dst);
740        dst.identity = identity == null ? null : identity.copy();
741        dst.uri = uri == null ? null : uri.copy();
742        dst.name = name == null ? null : name.copy();
743        dst.comments = comments == null ? null : comments.copy();
744        return dst;
745      }
746
747      @Override
748      public boolean equalsDeep(Base other) {
749        if (!super.equalsDeep(other))
750          return false;
751        if (!(other instanceof StructureDefinitionMappingComponent))
752          return false;
753        StructureDefinitionMappingComponent o = (StructureDefinitionMappingComponent) other;
754        return compareDeep(identity, o.identity, true) && compareDeep(uri, o.uri, true) && compareDeep(name, o.name, true)
755           && compareDeep(comments, o.comments, true);
756      }
757
758      @Override
759      public boolean equalsShallow(Base other) {
760        if (!super.equalsShallow(other))
761          return false;
762        if (!(other instanceof StructureDefinitionMappingComponent))
763          return false;
764        StructureDefinitionMappingComponent o = (StructureDefinitionMappingComponent) other;
765        return compareValues(identity, o.identity, true) && compareValues(uri, o.uri, true) && compareValues(name, o.name, true)
766           && compareValues(comments, o.comments, true);
767      }
768
769      public boolean isEmpty() {
770        return super.isEmpty() && (identity == null || identity.isEmpty()) && (uri == null || uri.isEmpty())
771           && (name == null || name.isEmpty()) && (comments == null || comments.isEmpty());
772      }
773
774  public String fhirType() {
775    return "StructureDefinition.mapping";
776
777  }
778
779  }
780
781    @Block()
782    public static class StructureDefinitionSnapshotComponent extends BackboneElement implements IBaseBackboneElement {
783        /**
784         * Captures constraints on each element within the resource.
785         */
786        @Child(name = "element", type = {ElementDefinition.class}, order=1, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
787        @Description(shortDefinition="Definition of elements in the resource (if no StructureDefinition)", formalDefinition="Captures constraints on each element within the resource." )
788        protected List<ElementDefinition> element;
789
790        private static final long serialVersionUID = 53896641L;
791
792    /*
793     * Constructor
794     */
795      public StructureDefinitionSnapshotComponent() {
796        super();
797      }
798
799        /**
800         * @return {@link #element} (Captures constraints on each element within the resource.)
801         */
802        public List<ElementDefinition> getElement() { 
803          if (this.element == null)
804            this.element = new ArrayList<ElementDefinition>();
805          return this.element;
806        }
807
808        public boolean hasElement() { 
809          if (this.element == null)
810            return false;
811          for (ElementDefinition item : this.element)
812            if (!item.isEmpty())
813              return true;
814          return false;
815        }
816
817        /**
818         * @return {@link #element} (Captures constraints on each element within the resource.)
819         */
820    // syntactic sugar
821        public ElementDefinition addElement() { //3
822          ElementDefinition t = new ElementDefinition();
823          if (this.element == null)
824            this.element = new ArrayList<ElementDefinition>();
825          this.element.add(t);
826          return t;
827        }
828
829    // syntactic sugar
830        public StructureDefinitionSnapshotComponent addElement(ElementDefinition t) { //3
831          if (t == null)
832            return this;
833          if (this.element == null)
834            this.element = new ArrayList<ElementDefinition>();
835          this.element.add(t);
836          return this;
837        }
838
839        protected void listChildren(List<Property> childrenList) {
840          super.listChildren(childrenList);
841          childrenList.add(new Property("element", "ElementDefinition", "Captures constraints on each element within the resource.", 0, java.lang.Integer.MAX_VALUE, element));
842        }
843
844      @Override
845      public void setProperty(String name, Base value) throws FHIRException {
846        if (name.equals("element"))
847          this.getElement().add(castToElementDefinition(value));
848        else
849          super.setProperty(name, value);
850      }
851
852      @Override
853      public Base addChild(String name) throws FHIRException {
854        if (name.equals("element")) {
855          return addElement();
856        }
857        else
858          return super.addChild(name);
859      }
860
861      public StructureDefinitionSnapshotComponent copy() {
862        StructureDefinitionSnapshotComponent dst = new StructureDefinitionSnapshotComponent();
863        copyValues(dst);
864        if (element != null) {
865          dst.element = new ArrayList<ElementDefinition>();
866          for (ElementDefinition i : element)
867            dst.element.add(i.copy());
868        };
869        return dst;
870      }
871
872      @Override
873      public boolean equalsDeep(Base other) {
874        if (!super.equalsDeep(other))
875          return false;
876        if (!(other instanceof StructureDefinitionSnapshotComponent))
877          return false;
878        StructureDefinitionSnapshotComponent o = (StructureDefinitionSnapshotComponent) other;
879        return compareDeep(element, o.element, true);
880      }
881
882      @Override
883      public boolean equalsShallow(Base other) {
884        if (!super.equalsShallow(other))
885          return false;
886        if (!(other instanceof StructureDefinitionSnapshotComponent))
887          return false;
888        StructureDefinitionSnapshotComponent o = (StructureDefinitionSnapshotComponent) other;
889        return true;
890      }
891
892      public boolean isEmpty() {
893        return super.isEmpty() && (element == null || element.isEmpty());
894      }
895
896  public String fhirType() {
897    return "StructureDefinition.snapshot";
898
899  }
900
901  }
902
903    @Block()
904    public static class StructureDefinitionDifferentialComponent extends BackboneElement implements IBaseBackboneElement {
905        /**
906         * Captures constraints on each element within the resource.
907         */
908        @Child(name = "element", type = {ElementDefinition.class}, order=1, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
909        @Description(shortDefinition="Definition of elements in the resource (if no StructureDefinition)", formalDefinition="Captures constraints on each element within the resource." )
910        protected List<ElementDefinition> element;
911
912        private static final long serialVersionUID = 53896641L;
913
914    /*
915     * Constructor
916     */
917      public StructureDefinitionDifferentialComponent() {
918        super();
919      }
920
921        /**
922         * @return {@link #element} (Captures constraints on each element within the resource.)
923         */
924        public List<ElementDefinition> getElement() { 
925          if (this.element == null)
926            this.element = new ArrayList<ElementDefinition>();
927          return this.element;
928        }
929
930        public boolean hasElement() { 
931          if (this.element == null)
932            return false;
933          for (ElementDefinition item : this.element)
934            if (!item.isEmpty())
935              return true;
936          return false;
937        }
938
939        /**
940         * @return {@link #element} (Captures constraints on each element within the resource.)
941         */
942    // syntactic sugar
943        public ElementDefinition addElement() { //3
944          ElementDefinition t = new ElementDefinition();
945          if (this.element == null)
946            this.element = new ArrayList<ElementDefinition>();
947          this.element.add(t);
948          return t;
949        }
950
951    // syntactic sugar
952        public StructureDefinitionDifferentialComponent addElement(ElementDefinition t) { //3
953          if (t == null)
954            return this;
955          if (this.element == null)
956            this.element = new ArrayList<ElementDefinition>();
957          this.element.add(t);
958          return this;
959        }
960
961        protected void listChildren(List<Property> childrenList) {
962          super.listChildren(childrenList);
963          childrenList.add(new Property("element", "ElementDefinition", "Captures constraints on each element within the resource.", 0, java.lang.Integer.MAX_VALUE, element));
964        }
965
966      @Override
967      public void setProperty(String name, Base value) throws FHIRException {
968        if (name.equals("element"))
969          this.getElement().add(castToElementDefinition(value));
970        else
971          super.setProperty(name, value);
972      }
973
974      @Override
975      public Base addChild(String name) throws FHIRException {
976        if (name.equals("element")) {
977          return addElement();
978        }
979        else
980          return super.addChild(name);
981      }
982
983      public StructureDefinitionDifferentialComponent copy() {
984        StructureDefinitionDifferentialComponent dst = new StructureDefinitionDifferentialComponent();
985        copyValues(dst);
986        if (element != null) {
987          dst.element = new ArrayList<ElementDefinition>();
988          for (ElementDefinition i : element)
989            dst.element.add(i.copy());
990        };
991        return dst;
992      }
993
994      @Override
995      public boolean equalsDeep(Base other) {
996        if (!super.equalsDeep(other))
997          return false;
998        if (!(other instanceof StructureDefinitionDifferentialComponent))
999          return false;
1000        StructureDefinitionDifferentialComponent o = (StructureDefinitionDifferentialComponent) other;
1001        return compareDeep(element, o.element, true);
1002      }
1003
1004      @Override
1005      public boolean equalsShallow(Base other) {
1006        if (!super.equalsShallow(other))
1007          return false;
1008        if (!(other instanceof StructureDefinitionDifferentialComponent))
1009          return false;
1010        StructureDefinitionDifferentialComponent o = (StructureDefinitionDifferentialComponent) other;
1011        return true;
1012      }
1013
1014      public boolean isEmpty() {
1015        return super.isEmpty() && (element == null || element.isEmpty());
1016      }
1017
1018  public String fhirType() {
1019    return "StructureDefinition.differential";
1020
1021  }
1022
1023  }
1024
1025    /**
1026     * An absolute URL that is used to identify this structure 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 structure definition is (or will be) published.
1027     */
1028    @Child(name = "url", type = {UriType.class}, order=0, min=1, max=1, modifier=false, summary=true)
1029    @Description(shortDefinition="Absolute URL used to reference this StructureDefinition", formalDefinition="An absolute URL that is used to identify this structure 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 structure definition is (or will be) published." )
1030    protected UriType url;
1031
1032    /**
1033     * Formal identifier that is used to identify this StructureDefinition when it is represented in other formats, or referenced in a specification, model, design or an instance  (should be globally unique OID, UUID, or URI), (if it's not possible to use the literal URI).
1034     */
1035    @Child(name = "identifier", type = {Identifier.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1036    @Description(shortDefinition="Other identifiers for the StructureDefinition", formalDefinition="Formal identifier that is used to identify this StructureDefinition when it is represented in other formats, or referenced in a specification, model, design or an instance  (should be globally unique OID, UUID, or URI), (if it's not possible to use the literal URI)." )
1037    protected List<Identifier> identifier;
1038
1039    /**
1040     * The identifier that is used to identify this version of the StructureDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the StructureDefinition author manually.
1041     */
1042    @Child(name = "version", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true)
1043    @Description(shortDefinition="Logical id for this version of the StructureDefinition", formalDefinition="The identifier that is used to identify this version of the StructureDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the StructureDefinition author manually." )
1044    protected StringType version;
1045
1046    /**
1047     * A free text natural language name identifying the StructureDefinition.
1048     */
1049    @Child(name = "name", type = {StringType.class}, order=3, min=1, max=1, modifier=false, summary=true)
1050    @Description(shortDefinition="Informal name for this StructureDefinition", formalDefinition="A free text natural language name identifying the StructureDefinition." )
1051    protected StringType name;
1052
1053    /**
1054     * Defined so that applications can use this name when displaying the value of the extension to the user.
1055     */
1056    @Child(name = "display", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=true)
1057    @Description(shortDefinition="Use this name when displaying the value", formalDefinition="Defined so that applications can use this name when displaying the value of the extension to the user." )
1058    protected StringType display;
1059
1060    /**
1061     * The status of the StructureDefinition.
1062     */
1063    @Child(name = "status", type = {CodeType.class}, order=5, min=1, max=1, modifier=true, summary=true)
1064    @Description(shortDefinition="draft | active | retired", formalDefinition="The status of the StructureDefinition." )
1065    protected Enumeration<ConformanceResourceStatus> status;
1066
1067    /**
1068     * This StructureDefinition was authored for testing purposes (or education/evaluation/marketing), and is not intended to be used for genuine usage.
1069     */
1070    @Child(name = "experimental", type = {BooleanType.class}, order=6, min=0, max=1, modifier=false, summary=true)
1071    @Description(shortDefinition="If for testing purposes, not real usage", formalDefinition="This StructureDefinition was authored for testing purposes (or education/evaluation/marketing), and is not intended to be used for genuine usage." )
1072    protected BooleanType experimental;
1073
1074    /**
1075     * The name of the individual or organization that published the structure definition.
1076     */
1077    @Child(name = "publisher", type = {StringType.class}, order=7, min=0, max=1, modifier=false, summary=true)
1078    @Description(shortDefinition="Name of the publisher (Organization or individual)", formalDefinition="The name of the individual or organization that published the structure definition." )
1079    protected StringType publisher;
1080
1081    /**
1082     * Contacts to assist a user in finding and communicating with the publisher.
1083     */
1084    @Child(name = "contact", type = {}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1085    @Description(shortDefinition="Contact details of the publisher", formalDefinition="Contacts to assist a user in finding and communicating with the publisher." )
1086    protected List<StructureDefinitionContactComponent> contact;
1087
1088    /**
1089     * The date this version of the structure 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 structure definition changes.
1090     */
1091    @Child(name = "date", type = {DateTimeType.class}, order=9, min=0, max=1, modifier=false, summary=true)
1092    @Description(shortDefinition="Date for this version of the StructureDefinition", formalDefinition="The date this version of the structure 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 structure definition changes." )
1093    protected DateTimeType date;
1094
1095    /**
1096     * A free text natural language description of the StructureDefinition and its use.
1097     */
1098    @Child(name = "description", type = {StringType.class}, order=10, min=0, max=1, modifier=false, summary=true)
1099    @Description(shortDefinition="Natural language description of the StructureDefinition", formalDefinition="A free text natural language description of the StructureDefinition and its use." )
1100    protected StringType description;
1101
1102    /**
1103     * The content was developed with a focus and intent of supporting the contexts that are listed. These terms may be used to assist with indexing and searching of structure definitions.
1104     */
1105    @Child(name = "useContext", type = {CodeableConcept.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1106    @Description(shortDefinition="Content intends to support these contexts", formalDefinition="The content was developed with a focus and intent of supporting the contexts that are listed. These terms may be used to assist with indexing and searching of structure definitions." )
1107    protected List<CodeableConcept> useContext;
1108
1109    /**
1110     * Explains why this structure definition is needed and why it's been constrained as it has.
1111     */
1112    @Child(name = "requirements", type = {StringType.class}, order=12, min=0, max=1, modifier=false, summary=false)
1113    @Description(shortDefinition="Scope and Usage this structure definition is for", formalDefinition="Explains why this structure definition is needed and why it's been constrained as it has." )
1114    protected StringType requirements;
1115
1116    /**
1117     * A copyright statement relating to the structure definition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the details of the constraints and mappings.
1118     */
1119    @Child(name = "copyright", type = {StringType.class}, order=13, min=0, max=1, modifier=false, summary=false)
1120    @Description(shortDefinition="Use and/or publishing restrictions", formalDefinition="A copyright statement relating to the structure definition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the details of the constraints and mappings." )
1121    protected StringType copyright;
1122
1123    /**
1124     * A set of terms from external terminologies that may be used to assist with indexing and searching of templates.
1125     */
1126    @Child(name = "code", type = {Coding.class}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1127    @Description(shortDefinition="Assist with indexing and finding", formalDefinition="A set of terms from external terminologies that may be used to assist with indexing and searching of templates." )
1128    protected List<Coding> code;
1129
1130    /**
1131     * The version of the FHIR specification on which this StructureDefinition is based - this is the formal version of the specification, without the revision number, e.g. [publication].[major].[minor], which is 1.0.2 for this version.
1132     */
1133    @Child(name = "fhirVersion", type = {IdType.class}, order=15, min=0, max=1, modifier=false, summary=true)
1134    @Description(shortDefinition="FHIR Version this StructureDefinition targets", formalDefinition="The version of the FHIR specification on which this StructureDefinition is based - this is the formal version of the specification, without the revision number, e.g. [publication].[major].[minor], which is 1.0.2 for this version." )
1135    protected IdType fhirVersion;
1136
1137    /**
1138     * An external specification that the content is mapped to.
1139     */
1140    @Child(name = "mapping", type = {}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1141    @Description(shortDefinition="External specification that the content is mapped to", formalDefinition="An external specification that the content is mapped to." )
1142    protected List<StructureDefinitionMappingComponent> mapping;
1143
1144    /**
1145     * Defines the kind of structure that this definition is describing.
1146     */
1147    @Child(name = "kind", type = {CodeType.class}, order=17, min=1, max=1, modifier=false, summary=true)
1148    @Description(shortDefinition="datatype | resource | logical", formalDefinition="Defines the kind of structure that this definition is describing." )
1149    protected Enumeration<StructureDefinitionKind> kind;
1150
1151    /**
1152     * The type of type that is being constrained - a data type, an extension, a resource, including abstract ones. If this field is present, it indicates that the structure definition is a constraint. If it is not present, then the structure definition is the definition of a base structure.
1153     */
1154    @Child(name = "constrainedType", type = {CodeType.class}, order=18, min=0, max=1, modifier=false, summary=true)
1155    @Description(shortDefinition="Any datatype or resource, including abstract ones", formalDefinition="The type of type that is being constrained - a data type, an extension, a resource, including abstract ones. If this field is present, it indicates that the structure definition is a constraint. If it is not present, then the structure definition is the definition of a base structure." )
1156    protected CodeType constrainedType;
1157
1158    /**
1159     * Whether structure this definition describes is abstract or not  - that is, whether an actual exchanged item can ever be of this type.
1160     */
1161    @Child(name = "abstract", type = {BooleanType.class}, order=19, min=1, max=1, modifier=false, summary=true)
1162    @Description(shortDefinition="Whether the structure is abstract", formalDefinition="Whether structure this definition describes is abstract or not  - that is, whether an actual exchanged item can ever be of this type." )
1163    protected BooleanType abstract_;
1164
1165    /**
1166     * If this is an extension, Identifies the context within FHIR resources where the extension can be used.
1167     */
1168    @Child(name = "contextType", type = {CodeType.class}, order=20, min=0, max=1, modifier=false, summary=true)
1169    @Description(shortDefinition="resource | datatype | mapping | extension", formalDefinition="If this is an extension, Identifies the context within FHIR resources where the extension can be used." )
1170    protected Enumeration<ExtensionContext> contextType;
1171
1172    /**
1173     * Identifies the types of resource or data type elements to which the extension can be applied.
1174     */
1175    @Child(name = "context", type = {StringType.class}, order=21, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1176    @Description(shortDefinition="Where the extension can be used in instances", formalDefinition="Identifies the types of resource or data type elements to which the extension can be applied." )
1177    protected List<StringType> context;
1178
1179    /**
1180     * An absolute URI that is the base structure from which this set of constraints is derived.
1181     */
1182    @Child(name = "base", type = {UriType.class}, order=22, min=0, max=1, modifier=false, summary=true)
1183    @Description(shortDefinition="Structure that this set of constraints applies to", formalDefinition="An absolute URI that is the base structure from which this set of constraints is derived." )
1184    protected UriType base;
1185
1186    /**
1187     * A snapshot view is expressed in a stand alone form that can be used and interpreted without considering the base StructureDefinition.
1188     */
1189    @Child(name = "snapshot", type = {}, order=23, min=0, max=1, modifier=false, summary=false)
1190    @Description(shortDefinition="Snapshot view of the structure", formalDefinition="A snapshot view is expressed in a stand alone form that can be used and interpreted without considering the base StructureDefinition." )
1191    protected StructureDefinitionSnapshotComponent snapshot;
1192
1193    /**
1194     * A differential view is expressed relative to the base StructureDefinition - a statement of differences that it applies.
1195     */
1196    @Child(name = "differential", type = {}, order=24, min=0, max=1, modifier=false, summary=false)
1197    @Description(shortDefinition="Differential view of the structure", formalDefinition="A differential view is expressed relative to the base StructureDefinition - a statement of differences that it applies." )
1198    protected StructureDefinitionDifferentialComponent differential;
1199
1200    private static final long serialVersionUID = -580779569L;
1201
1202  /*
1203   * Constructor
1204   */
1205    public StructureDefinition() {
1206      super();
1207    }
1208
1209  /*
1210   * Constructor
1211   */
1212    public StructureDefinition(UriType url, StringType name, Enumeration<ConformanceResourceStatus> status, Enumeration<StructureDefinitionKind> kind, BooleanType abstract_) {
1213      super();
1214      this.url = url;
1215      this.name = name;
1216      this.status = status;
1217      this.kind = kind;
1218      this.abstract_ = abstract_;
1219    }
1220
1221    /**
1222     * @return {@link #url} (An absolute URL that is used to identify this structure 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 structure 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
1223     */
1224    public UriType getUrlElement() { 
1225      if (this.url == null)
1226        if (Configuration.errorOnAutoCreate())
1227          throw new Error("Attempt to auto-create StructureDefinition.url");
1228        else if (Configuration.doAutoCreate())
1229          this.url = new UriType(); // bb
1230      return this.url;
1231    }
1232
1233    public boolean hasUrlElement() { 
1234      return this.url != null && !this.url.isEmpty();
1235    }
1236
1237    public boolean hasUrl() { 
1238      return this.url != null && !this.url.isEmpty();
1239    }
1240
1241    /**
1242     * @param value {@link #url} (An absolute URL that is used to identify this structure 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 structure 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
1243     */
1244    public StructureDefinition setUrlElement(UriType value) { 
1245      this.url = value;
1246      return this;
1247    }
1248
1249    /**
1250     * @return An absolute URL that is used to identify this structure 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 structure definition is (or will be) published.
1251     */
1252    public String getUrl() { 
1253      return this.url == null ? null : this.url.getValue();
1254    }
1255
1256    /**
1257     * @param value An absolute URL that is used to identify this structure 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 structure definition is (or will be) published.
1258     */
1259    public StructureDefinition setUrl(String value) { 
1260        if (this.url == null)
1261          this.url = new UriType();
1262        this.url.setValue(value);
1263      return this;
1264    }
1265
1266    /**
1267     * @return {@link #identifier} (Formal identifier that is used to identify this StructureDefinition when it is represented in other formats, or referenced in a specification, model, design or an instance  (should be globally unique OID, UUID, or URI), (if it's not possible to use the literal URI).)
1268     */
1269    public List<Identifier> getIdentifier() { 
1270      if (this.identifier == null)
1271        this.identifier = new ArrayList<Identifier>();
1272      return this.identifier;
1273    }
1274
1275    public boolean hasIdentifier() { 
1276      if (this.identifier == null)
1277        return false;
1278      for (Identifier item : this.identifier)
1279        if (!item.isEmpty())
1280          return true;
1281      return false;
1282    }
1283
1284    /**
1285     * @return {@link #identifier} (Formal identifier that is used to identify this StructureDefinition when it is represented in other formats, or referenced in a specification, model, design or an instance  (should be globally unique OID, UUID, or URI), (if it's not possible to use the literal URI).)
1286     */
1287    // syntactic sugar
1288    public Identifier addIdentifier() { //3
1289      Identifier t = new Identifier();
1290      if (this.identifier == null)
1291        this.identifier = new ArrayList<Identifier>();
1292      this.identifier.add(t);
1293      return t;
1294    }
1295
1296    // syntactic sugar
1297    public StructureDefinition addIdentifier(Identifier t) { //3
1298      if (t == null)
1299        return this;
1300      if (this.identifier == null)
1301        this.identifier = new ArrayList<Identifier>();
1302      this.identifier.add(t);
1303      return this;
1304    }
1305
1306    /**
1307     * @return {@link #version} (The identifier that is used to identify this version of the StructureDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the StructureDefinition author manually.). This is the underlying object with id, value and extensions. The accessor "getVersion" gives direct access to the value
1308     */
1309    public StringType getVersionElement() { 
1310      if (this.version == null)
1311        if (Configuration.errorOnAutoCreate())
1312          throw new Error("Attempt to auto-create StructureDefinition.version");
1313        else if (Configuration.doAutoCreate())
1314          this.version = new StringType(); // bb
1315      return this.version;
1316    }
1317
1318    public boolean hasVersionElement() { 
1319      return this.version != null && !this.version.isEmpty();
1320    }
1321
1322    public boolean hasVersion() { 
1323      return this.version != null && !this.version.isEmpty();
1324    }
1325
1326    /**
1327     * @param value {@link #version} (The identifier that is used to identify this version of the StructureDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the StructureDefinition author manually.). This is the underlying object with id, value and extensions. The accessor "getVersion" gives direct access to the value
1328     */
1329    public StructureDefinition setVersionElement(StringType value) { 
1330      this.version = value;
1331      return this;
1332    }
1333
1334    /**
1335     * @return The identifier that is used to identify this version of the StructureDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the StructureDefinition author manually.
1336     */
1337    public String getVersion() { 
1338      return this.version == null ? null : this.version.getValue();
1339    }
1340
1341    /**
1342     * @param value The identifier that is used to identify this version of the StructureDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the StructureDefinition author manually.
1343     */
1344    public StructureDefinition setVersion(String value) { 
1345      if (Utilities.noString(value))
1346        this.version = null;
1347      else {
1348        if (this.version == null)
1349          this.version = new StringType();
1350        this.version.setValue(value);
1351      }
1352      return this;
1353    }
1354
1355    /**
1356     * @return {@link #name} (A free text natural language name identifying the StructureDefinition.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
1357     */
1358    public StringType getNameElement() { 
1359      if (this.name == null)
1360        if (Configuration.errorOnAutoCreate())
1361          throw new Error("Attempt to auto-create StructureDefinition.name");
1362        else if (Configuration.doAutoCreate())
1363          this.name = new StringType(); // bb
1364      return this.name;
1365    }
1366
1367    public boolean hasNameElement() { 
1368      return this.name != null && !this.name.isEmpty();
1369    }
1370
1371    public boolean hasName() { 
1372      return this.name != null && !this.name.isEmpty();
1373    }
1374
1375    /**
1376     * @param value {@link #name} (A free text natural language name identifying the StructureDefinition.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
1377     */
1378    public StructureDefinition setNameElement(StringType value) { 
1379      this.name = value;
1380      return this;
1381    }
1382
1383    /**
1384     * @return A free text natural language name identifying the StructureDefinition.
1385     */
1386    public String getName() { 
1387      return this.name == null ? null : this.name.getValue();
1388    }
1389
1390    /**
1391     * @param value A free text natural language name identifying the StructureDefinition.
1392     */
1393    public StructureDefinition setName(String value) { 
1394        if (this.name == null)
1395          this.name = new StringType();
1396        this.name.setValue(value);
1397      return this;
1398    }
1399
1400    /**
1401     * @return {@link #display} (Defined so that applications can use this name when displaying the value of the extension to the user.). This is the underlying object with id, value and extensions. The accessor "getDisplay" gives direct access to the value
1402     */
1403    public StringType getDisplayElement() { 
1404      if (this.display == null)
1405        if (Configuration.errorOnAutoCreate())
1406          throw new Error("Attempt to auto-create StructureDefinition.display");
1407        else if (Configuration.doAutoCreate())
1408          this.display = new StringType(); // bb
1409      return this.display;
1410    }
1411
1412    public boolean hasDisplayElement() { 
1413      return this.display != null && !this.display.isEmpty();
1414    }
1415
1416    public boolean hasDisplay() { 
1417      return this.display != null && !this.display.isEmpty();
1418    }
1419
1420    /**
1421     * @param value {@link #display} (Defined so that applications can use this name when displaying the value of the extension to the user.). This is the underlying object with id, value and extensions. The accessor "getDisplay" gives direct access to the value
1422     */
1423    public StructureDefinition setDisplayElement(StringType value) { 
1424      this.display = value;
1425      return this;
1426    }
1427
1428    /**
1429     * @return Defined so that applications can use this name when displaying the value of the extension to the user.
1430     */
1431    public String getDisplay() { 
1432      return this.display == null ? null : this.display.getValue();
1433    }
1434
1435    /**
1436     * @param value Defined so that applications can use this name when displaying the value of the extension to the user.
1437     */
1438    public StructureDefinition setDisplay(String value) { 
1439      if (Utilities.noString(value))
1440        this.display = null;
1441      else {
1442        if (this.display == null)
1443          this.display = new StringType();
1444        this.display.setValue(value);
1445      }
1446      return this;
1447    }
1448
1449    /**
1450     * @return {@link #status} (The status of the StructureDefinition.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1451     */
1452    public Enumeration<ConformanceResourceStatus> getStatusElement() { 
1453      if (this.status == null)
1454        if (Configuration.errorOnAutoCreate())
1455          throw new Error("Attempt to auto-create StructureDefinition.status");
1456        else if (Configuration.doAutoCreate())
1457          this.status = new Enumeration<ConformanceResourceStatus>(new ConformanceResourceStatusEnumFactory()); // bb
1458      return this.status;
1459    }
1460
1461    public boolean hasStatusElement() { 
1462      return this.status != null && !this.status.isEmpty();
1463    }
1464
1465    public boolean hasStatus() { 
1466      return this.status != null && !this.status.isEmpty();
1467    }
1468
1469    /**
1470     * @param value {@link #status} (The status of the StructureDefinition.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1471     */
1472    public StructureDefinition setStatusElement(Enumeration<ConformanceResourceStatus> value) { 
1473      this.status = value;
1474      return this;
1475    }
1476
1477    /**
1478     * @return The status of the StructureDefinition.
1479     */
1480    public ConformanceResourceStatus getStatus() { 
1481      return this.status == null ? null : this.status.getValue();
1482    }
1483
1484    /**
1485     * @param value The status of the StructureDefinition.
1486     */
1487    public StructureDefinition setStatus(ConformanceResourceStatus value) { 
1488        if (this.status == null)
1489          this.status = new Enumeration<ConformanceResourceStatus>(new ConformanceResourceStatusEnumFactory());
1490        this.status.setValue(value);
1491      return this;
1492    }
1493
1494    /**
1495     * @return {@link #experimental} (This StructureDefinition was 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
1496     */
1497    public BooleanType getExperimentalElement() { 
1498      if (this.experimental == null)
1499        if (Configuration.errorOnAutoCreate())
1500          throw new Error("Attempt to auto-create StructureDefinition.experimental");
1501        else if (Configuration.doAutoCreate())
1502          this.experimental = new BooleanType(); // bb
1503      return this.experimental;
1504    }
1505
1506    public boolean hasExperimentalElement() { 
1507      return this.experimental != null && !this.experimental.isEmpty();
1508    }
1509
1510    public boolean hasExperimental() { 
1511      return this.experimental != null && !this.experimental.isEmpty();
1512    }
1513
1514    /**
1515     * @param value {@link #experimental} (This StructureDefinition was 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
1516     */
1517    public StructureDefinition setExperimentalElement(BooleanType value) { 
1518      this.experimental = value;
1519      return this;
1520    }
1521
1522    /**
1523     * @return This StructureDefinition was authored for testing purposes (or education/evaluation/marketing), and is not intended to be used for genuine usage.
1524     */
1525    public boolean getExperimental() { 
1526      return this.experimental == null || this.experimental.isEmpty() ? false : this.experimental.getValue();
1527    }
1528
1529    /**
1530     * @param value This StructureDefinition was authored for testing purposes (or education/evaluation/marketing), and is not intended to be used for genuine usage.
1531     */
1532    public StructureDefinition setExperimental(boolean value) { 
1533        if (this.experimental == null)
1534          this.experimental = new BooleanType();
1535        this.experimental.setValue(value);
1536      return this;
1537    }
1538
1539    /**
1540     * @return {@link #publisher} (The name of the individual or organization that published the structure definition.). This is the underlying object with id, value and extensions. The accessor "getPublisher" gives direct access to the value
1541     */
1542    public StringType getPublisherElement() { 
1543      if (this.publisher == null)
1544        if (Configuration.errorOnAutoCreate())
1545          throw new Error("Attempt to auto-create StructureDefinition.publisher");
1546        else if (Configuration.doAutoCreate())
1547          this.publisher = new StringType(); // bb
1548      return this.publisher;
1549    }
1550
1551    public boolean hasPublisherElement() { 
1552      return this.publisher != null && !this.publisher.isEmpty();
1553    }
1554
1555    public boolean hasPublisher() { 
1556      return this.publisher != null && !this.publisher.isEmpty();
1557    }
1558
1559    /**
1560     * @param value {@link #publisher} (The name of the individual or organization that published the structure definition.). This is the underlying object with id, value and extensions. The accessor "getPublisher" gives direct access to the value
1561     */
1562    public StructureDefinition setPublisherElement(StringType value) { 
1563      this.publisher = value;
1564      return this;
1565    }
1566
1567    /**
1568     * @return The name of the individual or organization that published the structure definition.
1569     */
1570    public String getPublisher() { 
1571      return this.publisher == null ? null : this.publisher.getValue();
1572    }
1573
1574    /**
1575     * @param value The name of the individual or organization that published the structure definition.
1576     */
1577    public StructureDefinition setPublisher(String value) { 
1578      if (Utilities.noString(value))
1579        this.publisher = null;
1580      else {
1581        if (this.publisher == null)
1582          this.publisher = new StringType();
1583        this.publisher.setValue(value);
1584      }
1585      return this;
1586    }
1587
1588    /**
1589     * @return {@link #contact} (Contacts to assist a user in finding and communicating with the publisher.)
1590     */
1591    public List<StructureDefinitionContactComponent> getContact() { 
1592      if (this.contact == null)
1593        this.contact = new ArrayList<StructureDefinitionContactComponent>();
1594      return this.contact;
1595    }
1596
1597    public boolean hasContact() { 
1598      if (this.contact == null)
1599        return false;
1600      for (StructureDefinitionContactComponent item : this.contact)
1601        if (!item.isEmpty())
1602          return true;
1603      return false;
1604    }
1605
1606    /**
1607     * @return {@link #contact} (Contacts to assist a user in finding and communicating with the publisher.)
1608     */
1609    // syntactic sugar
1610    public StructureDefinitionContactComponent addContact() { //3
1611      StructureDefinitionContactComponent t = new StructureDefinitionContactComponent();
1612      if (this.contact == null)
1613        this.contact = new ArrayList<StructureDefinitionContactComponent>();
1614      this.contact.add(t);
1615      return t;
1616    }
1617
1618    // syntactic sugar
1619    public StructureDefinition addContact(StructureDefinitionContactComponent t) { //3
1620      if (t == null)
1621        return this;
1622      if (this.contact == null)
1623        this.contact = new ArrayList<StructureDefinitionContactComponent>();
1624      this.contact.add(t);
1625      return this;
1626    }
1627
1628    /**
1629     * @return {@link #date} (The date this version of the structure 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 structure definition changes.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
1630     */
1631    public DateTimeType getDateElement() { 
1632      if (this.date == null)
1633        if (Configuration.errorOnAutoCreate())
1634          throw new Error("Attempt to auto-create StructureDefinition.date");
1635        else if (Configuration.doAutoCreate())
1636          this.date = new DateTimeType(); // bb
1637      return this.date;
1638    }
1639
1640    public boolean hasDateElement() { 
1641      return this.date != null && !this.date.isEmpty();
1642    }
1643
1644    public boolean hasDate() { 
1645      return this.date != null && !this.date.isEmpty();
1646    }
1647
1648    /**
1649     * @param value {@link #date} (The date this version of the structure 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 structure definition changes.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
1650     */
1651    public StructureDefinition setDateElement(DateTimeType value) { 
1652      this.date = value;
1653      return this;
1654    }
1655
1656    /**
1657     * @return The date this version of the structure 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 structure definition changes.
1658     */
1659    public Date getDate() { 
1660      return this.date == null ? null : this.date.getValue();
1661    }
1662
1663    /**
1664     * @param value The date this version of the structure 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 structure definition changes.
1665     */
1666    public StructureDefinition setDate(Date value) { 
1667      if (value == null)
1668        this.date = null;
1669      else {
1670        if (this.date == null)
1671          this.date = new DateTimeType();
1672        this.date.setValue(value);
1673      }
1674      return this;
1675    }
1676
1677    /**
1678     * @return {@link #description} (A free text natural language description of the StructureDefinition and its use.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
1679     */
1680    public StringType getDescriptionElement() { 
1681      if (this.description == null)
1682        if (Configuration.errorOnAutoCreate())
1683          throw new Error("Attempt to auto-create StructureDefinition.description");
1684        else if (Configuration.doAutoCreate())
1685          this.description = new StringType(); // bb
1686      return this.description;
1687    }
1688
1689    public boolean hasDescriptionElement() { 
1690      return this.description != null && !this.description.isEmpty();
1691    }
1692
1693    public boolean hasDescription() { 
1694      return this.description != null && !this.description.isEmpty();
1695    }
1696
1697    /**
1698     * @param value {@link #description} (A free text natural language description of the StructureDefinition and its use.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
1699     */
1700    public StructureDefinition setDescriptionElement(StringType value) { 
1701      this.description = value;
1702      return this;
1703    }
1704
1705    /**
1706     * @return A free text natural language description of the StructureDefinition and its use.
1707     */
1708    public String getDescription() { 
1709      return this.description == null ? null : this.description.getValue();
1710    }
1711
1712    /**
1713     * @param value A free text natural language description of the StructureDefinition and its use.
1714     */
1715    public StructureDefinition setDescription(String value) { 
1716      if (Utilities.noString(value))
1717        this.description = null;
1718      else {
1719        if (this.description == null)
1720          this.description = new StringType();
1721        this.description.setValue(value);
1722      }
1723      return this;
1724    }
1725
1726    /**
1727     * @return {@link #useContext} (The content was developed with a focus and intent of supporting the contexts that are listed. These terms may be used to assist with indexing and searching of structure definitions.)
1728     */
1729    public List<CodeableConcept> getUseContext() { 
1730      if (this.useContext == null)
1731        this.useContext = new ArrayList<CodeableConcept>();
1732      return this.useContext;
1733    }
1734
1735    public boolean hasUseContext() { 
1736      if (this.useContext == null)
1737        return false;
1738      for (CodeableConcept item : this.useContext)
1739        if (!item.isEmpty())
1740          return true;
1741      return false;
1742    }
1743
1744    /**
1745     * @return {@link #useContext} (The content was developed with a focus and intent of supporting the contexts that are listed. These terms may be used to assist with indexing and searching of structure definitions.)
1746     */
1747    // syntactic sugar
1748    public CodeableConcept addUseContext() { //3
1749      CodeableConcept t = new CodeableConcept();
1750      if (this.useContext == null)
1751        this.useContext = new ArrayList<CodeableConcept>();
1752      this.useContext.add(t);
1753      return t;
1754    }
1755
1756    // syntactic sugar
1757    public StructureDefinition addUseContext(CodeableConcept t) { //3
1758      if (t == null)
1759        return this;
1760      if (this.useContext == null)
1761        this.useContext = new ArrayList<CodeableConcept>();
1762      this.useContext.add(t);
1763      return this;
1764    }
1765
1766    /**
1767     * @return {@link #requirements} (Explains why this structure definition is needed and why it's been constrained as it has.). This is the underlying object with id, value and extensions. The accessor "getRequirements" gives direct access to the value
1768     */
1769    public StringType getRequirementsElement() { 
1770      if (this.requirements == null)
1771        if (Configuration.errorOnAutoCreate())
1772          throw new Error("Attempt to auto-create StructureDefinition.requirements");
1773        else if (Configuration.doAutoCreate())
1774          this.requirements = new StringType(); // bb
1775      return this.requirements;
1776    }
1777
1778    public boolean hasRequirementsElement() { 
1779      return this.requirements != null && !this.requirements.isEmpty();
1780    }
1781
1782    public boolean hasRequirements() { 
1783      return this.requirements != null && !this.requirements.isEmpty();
1784    }
1785
1786    /**
1787     * @param value {@link #requirements} (Explains why this structure definition is needed and why it's been constrained as it has.). This is the underlying object with id, value and extensions. The accessor "getRequirements" gives direct access to the value
1788     */
1789    public StructureDefinition setRequirementsElement(StringType value) { 
1790      this.requirements = value;
1791      return this;
1792    }
1793
1794    /**
1795     * @return Explains why this structure definition is needed and why it's been constrained as it has.
1796     */
1797    public String getRequirements() { 
1798      return this.requirements == null ? null : this.requirements.getValue();
1799    }
1800
1801    /**
1802     * @param value Explains why this structure definition is needed and why it's been constrained as it has.
1803     */
1804    public StructureDefinition setRequirements(String value) { 
1805      if (Utilities.noString(value))
1806        this.requirements = null;
1807      else {
1808        if (this.requirements == null)
1809          this.requirements = new StringType();
1810        this.requirements.setValue(value);
1811      }
1812      return this;
1813    }
1814
1815    /**
1816     * @return {@link #copyright} (A copyright statement relating to the structure definition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the details of the constraints and mappings.). This is the underlying object with id, value and extensions. The accessor "getCopyright" gives direct access to the value
1817     */
1818    public StringType getCopyrightElement() { 
1819      if (this.copyright == null)
1820        if (Configuration.errorOnAutoCreate())
1821          throw new Error("Attempt to auto-create StructureDefinition.copyright");
1822        else if (Configuration.doAutoCreate())
1823          this.copyright = new StringType(); // bb
1824      return this.copyright;
1825    }
1826
1827    public boolean hasCopyrightElement() { 
1828      return this.copyright != null && !this.copyright.isEmpty();
1829    }
1830
1831    public boolean hasCopyright() { 
1832      return this.copyright != null && !this.copyright.isEmpty();
1833    }
1834
1835    /**
1836     * @param value {@link #copyright} (A copyright statement relating to the structure definition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the details of the constraints and mappings.). This is the underlying object with id, value and extensions. The accessor "getCopyright" gives direct access to the value
1837     */
1838    public StructureDefinition setCopyrightElement(StringType value) { 
1839      this.copyright = value;
1840      return this;
1841    }
1842
1843    /**
1844     * @return A copyright statement relating to the structure definition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the details of the constraints and mappings.
1845     */
1846    public String getCopyright() { 
1847      return this.copyright == null ? null : this.copyright.getValue();
1848    }
1849
1850    /**
1851     * @param value A copyright statement relating to the structure definition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the details of the constraints and mappings.
1852     */
1853    public StructureDefinition setCopyright(String value) { 
1854      if (Utilities.noString(value))
1855        this.copyright = null;
1856      else {
1857        if (this.copyright == null)
1858          this.copyright = new StringType();
1859        this.copyright.setValue(value);
1860      }
1861      return this;
1862    }
1863
1864    /**
1865     * @return {@link #code} (A set of terms from external terminologies that may be used to assist with indexing and searching of templates.)
1866     */
1867    public List<Coding> getCode() { 
1868      if (this.code == null)
1869        this.code = new ArrayList<Coding>();
1870      return this.code;
1871    }
1872
1873    public boolean hasCode() { 
1874      if (this.code == null)
1875        return false;
1876      for (Coding item : this.code)
1877        if (!item.isEmpty())
1878          return true;
1879      return false;
1880    }
1881
1882    /**
1883     * @return {@link #code} (A set of terms from external terminologies that may be used to assist with indexing and searching of templates.)
1884     */
1885    // syntactic sugar
1886    public Coding addCode() { //3
1887      Coding t = new Coding();
1888      if (this.code == null)
1889        this.code = new ArrayList<Coding>();
1890      this.code.add(t);
1891      return t;
1892    }
1893
1894    // syntactic sugar
1895    public StructureDefinition addCode(Coding t) { //3
1896      if (t == null)
1897        return this;
1898      if (this.code == null)
1899        this.code = new ArrayList<Coding>();
1900      this.code.add(t);
1901      return this;
1902    }
1903
1904    /**
1905     * @return {@link #fhirVersion} (The version of the FHIR specification on which this StructureDefinition is based - this is the formal version of the specification, without the revision number, e.g. [publication].[major].[minor], which is 1.0.2 for this version.). This is the underlying object with id, value and extensions. The accessor "getFhirVersion" gives direct access to the value
1906     */
1907    public IdType getFhirVersionElement() { 
1908      if (this.fhirVersion == null)
1909        if (Configuration.errorOnAutoCreate())
1910          throw new Error("Attempt to auto-create StructureDefinition.fhirVersion");
1911        else if (Configuration.doAutoCreate())
1912          this.fhirVersion = new IdType(); // bb
1913      return this.fhirVersion;
1914    }
1915
1916    public boolean hasFhirVersionElement() { 
1917      return this.fhirVersion != null && !this.fhirVersion.isEmpty();
1918    }
1919
1920    public boolean hasFhirVersion() { 
1921      return this.fhirVersion != null && !this.fhirVersion.isEmpty();
1922    }
1923
1924    /**
1925     * @param value {@link #fhirVersion} (The version of the FHIR specification on which this StructureDefinition is based - this is the formal version of the specification, without the revision number, e.g. [publication].[major].[minor], which is 1.0.2 for this version.). This is the underlying object with id, value and extensions. The accessor "getFhirVersion" gives direct access to the value
1926     */
1927    public StructureDefinition setFhirVersionElement(IdType value) { 
1928      this.fhirVersion = value;
1929      return this;
1930    }
1931
1932    /**
1933     * @return The version of the FHIR specification on which this StructureDefinition is based - this is the formal version of the specification, without the revision number, e.g. [publication].[major].[minor], which is 1.0.2 for this version.
1934     */
1935    public String getFhirVersion() { 
1936      return this.fhirVersion == null ? null : this.fhirVersion.getValue();
1937    }
1938
1939    /**
1940     * @param value The version of the FHIR specification on which this StructureDefinition is based - this is the formal version of the specification, without the revision number, e.g. [publication].[major].[minor], which is 1.0.2 for this version.
1941     */
1942    public StructureDefinition setFhirVersion(String value) { 
1943      if (Utilities.noString(value))
1944        this.fhirVersion = null;
1945      else {
1946        if (this.fhirVersion == null)
1947          this.fhirVersion = new IdType();
1948        this.fhirVersion.setValue(value);
1949      }
1950      return this;
1951    }
1952
1953    /**
1954     * @return {@link #mapping} (An external specification that the content is mapped to.)
1955     */
1956    public List<StructureDefinitionMappingComponent> getMapping() { 
1957      if (this.mapping == null)
1958        this.mapping = new ArrayList<StructureDefinitionMappingComponent>();
1959      return this.mapping;
1960    }
1961
1962    public boolean hasMapping() { 
1963      if (this.mapping == null)
1964        return false;
1965      for (StructureDefinitionMappingComponent item : this.mapping)
1966        if (!item.isEmpty())
1967          return true;
1968      return false;
1969    }
1970
1971    /**
1972     * @return {@link #mapping} (An external specification that the content is mapped to.)
1973     */
1974    // syntactic sugar
1975    public StructureDefinitionMappingComponent addMapping() { //3
1976      StructureDefinitionMappingComponent t = new StructureDefinitionMappingComponent();
1977      if (this.mapping == null)
1978        this.mapping = new ArrayList<StructureDefinitionMappingComponent>();
1979      this.mapping.add(t);
1980      return t;
1981    }
1982
1983    // syntactic sugar
1984    public StructureDefinition addMapping(StructureDefinitionMappingComponent t) { //3
1985      if (t == null)
1986        return this;
1987      if (this.mapping == null)
1988        this.mapping = new ArrayList<StructureDefinitionMappingComponent>();
1989      this.mapping.add(t);
1990      return this;
1991    }
1992
1993    /**
1994     * @return {@link #kind} (Defines the kind of structure that this definition is describing.). This is the underlying object with id, value and extensions. The accessor "getKind" gives direct access to the value
1995     */
1996    public Enumeration<StructureDefinitionKind> getKindElement() { 
1997      if (this.kind == null)
1998        if (Configuration.errorOnAutoCreate())
1999          throw new Error("Attempt to auto-create StructureDefinition.kind");
2000        else if (Configuration.doAutoCreate())
2001          this.kind = new Enumeration<StructureDefinitionKind>(new StructureDefinitionKindEnumFactory()); // bb
2002      return this.kind;
2003    }
2004
2005    public boolean hasKindElement() { 
2006      return this.kind != null && !this.kind.isEmpty();
2007    }
2008
2009    public boolean hasKind() { 
2010      return this.kind != null && !this.kind.isEmpty();
2011    }
2012
2013    /**
2014     * @param value {@link #kind} (Defines the kind of structure that this definition is describing.). This is the underlying object with id, value and extensions. The accessor "getKind" gives direct access to the value
2015     */
2016    public StructureDefinition setKindElement(Enumeration<StructureDefinitionKind> value) { 
2017      this.kind = value;
2018      return this;
2019    }
2020
2021    /**
2022     * @return Defines the kind of structure that this definition is describing.
2023     */
2024    public StructureDefinitionKind getKind() { 
2025      return this.kind == null ? null : this.kind.getValue();
2026    }
2027
2028    /**
2029     * @param value Defines the kind of structure that this definition is describing.
2030     */
2031    public StructureDefinition setKind(StructureDefinitionKind value) { 
2032        if (this.kind == null)
2033          this.kind = new Enumeration<StructureDefinitionKind>(new StructureDefinitionKindEnumFactory());
2034        this.kind.setValue(value);
2035      return this;
2036    }
2037
2038    /**
2039     * @return {@link #constrainedType} (The type of type that is being constrained - a data type, an extension, a resource, including abstract ones. If this field is present, it indicates that the structure definition is a constraint. If it is not present, then the structure definition is the definition of a base structure.). This is the underlying object with id, value and extensions. The accessor "getConstrainedType" gives direct access to the value
2040     */
2041    public CodeType getConstrainedTypeElement() { 
2042      if (this.constrainedType == null)
2043        if (Configuration.errorOnAutoCreate())
2044          throw new Error("Attempt to auto-create StructureDefinition.constrainedType");
2045        else if (Configuration.doAutoCreate())
2046          this.constrainedType = new CodeType(); // bb
2047      return this.constrainedType;
2048    }
2049
2050    public boolean hasConstrainedTypeElement() { 
2051      return this.constrainedType != null && !this.constrainedType.isEmpty();
2052    }
2053
2054    public boolean hasConstrainedType() { 
2055      return this.constrainedType != null && !this.constrainedType.isEmpty();
2056    }
2057
2058    /**
2059     * @param value {@link #constrainedType} (The type of type that is being constrained - a data type, an extension, a resource, including abstract ones. If this field is present, it indicates that the structure definition is a constraint. If it is not present, then the structure definition is the definition of a base structure.). This is the underlying object with id, value and extensions. The accessor "getConstrainedType" gives direct access to the value
2060     */
2061    public StructureDefinition setConstrainedTypeElement(CodeType value) { 
2062      this.constrainedType = value;
2063      return this;
2064    }
2065
2066    /**
2067     * @return The type of type that is being constrained - a data type, an extension, a resource, including abstract ones. If this field is present, it indicates that the structure definition is a constraint. If it is not present, then the structure definition is the definition of a base structure.
2068     */
2069    public String getConstrainedType() { 
2070      return this.constrainedType == null ? null : this.constrainedType.getValue();
2071    }
2072
2073    /**
2074     * @param value The type of type that is being constrained - a data type, an extension, a resource, including abstract ones. If this field is present, it indicates that the structure definition is a constraint. If it is not present, then the structure definition is the definition of a base structure.
2075     */
2076    public StructureDefinition setConstrainedType(String value) { 
2077      if (Utilities.noString(value))
2078        this.constrainedType = null;
2079      else {
2080        if (this.constrainedType == null)
2081          this.constrainedType = new CodeType();
2082        this.constrainedType.setValue(value);
2083      }
2084      return this;
2085    }
2086
2087    /**
2088     * @return {@link #abstract_} (Whether structure this definition describes is abstract or not  - that is, whether an actual exchanged item can ever be of this type.). This is the underlying object with id, value and extensions. The accessor "getAbstract" gives direct access to the value
2089     */
2090    public BooleanType getAbstractElement() { 
2091      if (this.abstract_ == null)
2092        if (Configuration.errorOnAutoCreate())
2093          throw new Error("Attempt to auto-create StructureDefinition.abstract_");
2094        else if (Configuration.doAutoCreate())
2095          this.abstract_ = new BooleanType(); // bb
2096      return this.abstract_;
2097    }
2098
2099    public boolean hasAbstractElement() { 
2100      return this.abstract_ != null && !this.abstract_.isEmpty();
2101    }
2102
2103    public boolean hasAbstract() { 
2104      return this.abstract_ != null && !this.abstract_.isEmpty();
2105    }
2106
2107    /**
2108     * @param value {@link #abstract_} (Whether structure this definition describes is abstract or not  - that is, whether an actual exchanged item can ever be of this type.). This is the underlying object with id, value and extensions. The accessor "getAbstract" gives direct access to the value
2109     */
2110    public StructureDefinition setAbstractElement(BooleanType value) { 
2111      this.abstract_ = value;
2112      return this;
2113    }
2114
2115    /**
2116     * @return Whether structure this definition describes is abstract or not  - that is, whether an actual exchanged item can ever be of this type.
2117     */
2118    public boolean getAbstract() { 
2119      return this.abstract_ == null || this.abstract_.isEmpty() ? false : this.abstract_.getValue();
2120    }
2121
2122    /**
2123     * @param value Whether structure this definition describes is abstract or not  - that is, whether an actual exchanged item can ever be of this type.
2124     */
2125    public StructureDefinition setAbstract(boolean value) { 
2126        if (this.abstract_ == null)
2127          this.abstract_ = new BooleanType();
2128        this.abstract_.setValue(value);
2129      return this;
2130    }
2131
2132    /**
2133     * @return {@link #contextType} (If this is an extension, Identifies the context within FHIR resources where the extension can be used.). This is the underlying object with id, value and extensions. The accessor "getContextType" gives direct access to the value
2134     */
2135    public Enumeration<ExtensionContext> getContextTypeElement() { 
2136      if (this.contextType == null)
2137        if (Configuration.errorOnAutoCreate())
2138          throw new Error("Attempt to auto-create StructureDefinition.contextType");
2139        else if (Configuration.doAutoCreate())
2140          this.contextType = new Enumeration<ExtensionContext>(new ExtensionContextEnumFactory()); // bb
2141      return this.contextType;
2142    }
2143
2144    public boolean hasContextTypeElement() { 
2145      return this.contextType != null && !this.contextType.isEmpty();
2146    }
2147
2148    public boolean hasContextType() { 
2149      return this.contextType != null && !this.contextType.isEmpty();
2150    }
2151
2152    /**
2153     * @param value {@link #contextType} (If this is an extension, Identifies the context within FHIR resources where the extension can be used.). This is the underlying object with id, value and extensions. The accessor "getContextType" gives direct access to the value
2154     */
2155    public StructureDefinition setContextTypeElement(Enumeration<ExtensionContext> value) { 
2156      this.contextType = value;
2157      return this;
2158    }
2159
2160    /**
2161     * @return If this is an extension, Identifies the context within FHIR resources where the extension can be used.
2162     */
2163    public ExtensionContext getContextType() { 
2164      return this.contextType == null ? null : this.contextType.getValue();
2165    }
2166
2167    /**
2168     * @param value If this is an extension, Identifies the context within FHIR resources where the extension can be used.
2169     */
2170    public StructureDefinition setContextType(ExtensionContext value) { 
2171      if (value == null)
2172        this.contextType = null;
2173      else {
2174        if (this.contextType == null)
2175          this.contextType = new Enumeration<ExtensionContext>(new ExtensionContextEnumFactory());
2176        this.contextType.setValue(value);
2177      }
2178      return this;
2179    }
2180
2181    /**
2182     * @return {@link #context} (Identifies the types of resource or data type elements to which the extension can be applied.)
2183     */
2184    public List<StringType> getContext() { 
2185      if (this.context == null)
2186        this.context = new ArrayList<StringType>();
2187      return this.context;
2188    }
2189
2190    public boolean hasContext() { 
2191      if (this.context == null)
2192        return false;
2193      for (StringType item : this.context)
2194        if (!item.isEmpty())
2195          return true;
2196      return false;
2197    }
2198
2199    /**
2200     * @return {@link #context} (Identifies the types of resource or data type elements to which the extension can be applied.)
2201     */
2202    // syntactic sugar
2203    public StringType addContextElement() {//2 
2204      StringType t = new StringType();
2205      if (this.context == null)
2206        this.context = new ArrayList<StringType>();
2207      this.context.add(t);
2208      return t;
2209    }
2210
2211    /**
2212     * @param value {@link #context} (Identifies the types of resource or data type elements to which the extension can be applied.)
2213     */
2214    public StructureDefinition addContext(String value) { //1
2215      StringType t = new StringType();
2216      t.setValue(value);
2217      if (this.context == null)
2218        this.context = new ArrayList<StringType>();
2219      this.context.add(t);
2220      return this;
2221    }
2222
2223    /**
2224     * @param value {@link #context} (Identifies the types of resource or data type elements to which the extension can be applied.)
2225     */
2226    public boolean hasContext(String value) { 
2227      if (this.context == null)
2228        return false;
2229      for (StringType v : this.context)
2230        if (v.equals(value)) // string
2231          return true;
2232      return false;
2233    }
2234
2235    /**
2236     * @return {@link #base} (An absolute URI that is the base structure from which this set of constraints is derived.). This is the underlying object with id, value and extensions. The accessor "getBase" gives direct access to the value
2237     */
2238    public UriType getBaseElement() { 
2239      if (this.base == null)
2240        if (Configuration.errorOnAutoCreate())
2241          throw new Error("Attempt to auto-create StructureDefinition.base");
2242        else if (Configuration.doAutoCreate())
2243          this.base = new UriType(); // bb
2244      return this.base;
2245    }
2246
2247    public boolean hasBaseElement() { 
2248      return this.base != null && !this.base.isEmpty();
2249    }
2250
2251    public boolean hasBase() { 
2252      return this.base != null && !this.base.isEmpty();
2253    }
2254
2255    /**
2256     * @param value {@link #base} (An absolute URI that is the base structure from which this set of constraints is derived.). This is the underlying object with id, value and extensions. The accessor "getBase" gives direct access to the value
2257     */
2258    public StructureDefinition setBaseElement(UriType value) { 
2259      this.base = value;
2260      return this;
2261    }
2262
2263    /**
2264     * @return An absolute URI that is the base structure from which this set of constraints is derived.
2265     */
2266    public String getBase() { 
2267      return this.base == null ? null : this.base.getValue();
2268    }
2269
2270    /**
2271     * @param value An absolute URI that is the base structure from which this set of constraints is derived.
2272     */
2273    public StructureDefinition setBase(String value) { 
2274      if (Utilities.noString(value))
2275        this.base = null;
2276      else {
2277        if (this.base == null)
2278          this.base = new UriType();
2279        this.base.setValue(value);
2280      }
2281      return this;
2282    }
2283
2284    /**
2285     * @return {@link #snapshot} (A snapshot view is expressed in a stand alone form that can be used and interpreted without considering the base StructureDefinition.)
2286     */
2287    public StructureDefinitionSnapshotComponent getSnapshot() { 
2288      if (this.snapshot == null)
2289        if (Configuration.errorOnAutoCreate())
2290          throw new Error("Attempt to auto-create StructureDefinition.snapshot");
2291        else if (Configuration.doAutoCreate())
2292          this.snapshot = new StructureDefinitionSnapshotComponent(); // cc
2293      return this.snapshot;
2294    }
2295
2296    public boolean hasSnapshot() { 
2297      return this.snapshot != null && !this.snapshot.isEmpty();
2298    }
2299
2300    /**
2301     * @param value {@link #snapshot} (A snapshot view is expressed in a stand alone form that can be used and interpreted without considering the base StructureDefinition.)
2302     */
2303    public StructureDefinition setSnapshot(StructureDefinitionSnapshotComponent value) { 
2304      this.snapshot = value;
2305      return this;
2306    }
2307
2308    /**
2309     * @return {@link #differential} (A differential view is expressed relative to the base StructureDefinition - a statement of differences that it applies.)
2310     */
2311    public StructureDefinitionDifferentialComponent getDifferential() { 
2312      if (this.differential == null)
2313        if (Configuration.errorOnAutoCreate())
2314          throw new Error("Attempt to auto-create StructureDefinition.differential");
2315        else if (Configuration.doAutoCreate())
2316          this.differential = new StructureDefinitionDifferentialComponent(); // cc
2317      return this.differential;
2318    }
2319
2320    public boolean hasDifferential() { 
2321      return this.differential != null && !this.differential.isEmpty();
2322    }
2323
2324    /**
2325     * @param value {@link #differential} (A differential view is expressed relative to the base StructureDefinition - a statement of differences that it applies.)
2326     */
2327    public StructureDefinition setDifferential(StructureDefinitionDifferentialComponent value) { 
2328      this.differential = value;
2329      return this;
2330    }
2331
2332      protected void listChildren(List<Property> childrenList) {
2333        super.listChildren(childrenList);
2334        childrenList.add(new Property("url", "uri", "An absolute URL that is used to identify this structure 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 structure definition is (or will be) published.", 0, java.lang.Integer.MAX_VALUE, url));
2335        childrenList.add(new Property("identifier", "Identifier", "Formal identifier that is used to identify this StructureDefinition when it is represented in other formats, or referenced in a specification, model, design or an instance  (should be globally unique OID, UUID, or URI), (if it's not possible to use the literal URI).", 0, java.lang.Integer.MAX_VALUE, identifier));
2336        childrenList.add(new Property("version", "string", "The identifier that is used to identify this version of the StructureDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the StructureDefinition author manually.", 0, java.lang.Integer.MAX_VALUE, version));
2337        childrenList.add(new Property("name", "string", "A free text natural language name identifying the StructureDefinition.", 0, java.lang.Integer.MAX_VALUE, name));
2338        childrenList.add(new Property("display", "string", "Defined so that applications can use this name when displaying the value of the extension to the user.", 0, java.lang.Integer.MAX_VALUE, display));
2339        childrenList.add(new Property("status", "code", "The status of the StructureDefinition.", 0, java.lang.Integer.MAX_VALUE, status));
2340        childrenList.add(new Property("experimental", "boolean", "This StructureDefinition was 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));
2341        childrenList.add(new Property("publisher", "string", "The name of the individual or organization that published the structure definition.", 0, java.lang.Integer.MAX_VALUE, publisher));
2342        childrenList.add(new Property("contact", "", "Contacts to assist a user in finding and communicating with the publisher.", 0, java.lang.Integer.MAX_VALUE, contact));
2343        childrenList.add(new Property("date", "dateTime", "The date this version of the structure 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 structure definition changes.", 0, java.lang.Integer.MAX_VALUE, date));
2344        childrenList.add(new Property("description", "string", "A free text natural language description of the StructureDefinition and its use.", 0, java.lang.Integer.MAX_VALUE, description));
2345        childrenList.add(new Property("useContext", "CodeableConcept", "The content was developed with a focus and intent of supporting the contexts that are listed. These terms may be used to assist with indexing and searching of structure definitions.", 0, java.lang.Integer.MAX_VALUE, useContext));
2346        childrenList.add(new Property("requirements", "string", "Explains why this structure definition is needed and why it's been constrained as it has.", 0, java.lang.Integer.MAX_VALUE, requirements));
2347        childrenList.add(new Property("copyright", "string", "A copyright statement relating to the structure definition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the details of the constraints and mappings.", 0, java.lang.Integer.MAX_VALUE, copyright));
2348        childrenList.add(new Property("code", "Coding", "A set of terms from external terminologies that may be used to assist with indexing and searching of templates.", 0, java.lang.Integer.MAX_VALUE, code));
2349        childrenList.add(new Property("fhirVersion", "id", "The version of the FHIR specification on which this StructureDefinition is based - this is the formal version of the specification, without the revision number, e.g. [publication].[major].[minor], which is 1.0.2 for this version.", 0, java.lang.Integer.MAX_VALUE, fhirVersion));
2350        childrenList.add(new Property("mapping", "", "An external specification that the content is mapped to.", 0, java.lang.Integer.MAX_VALUE, mapping));
2351        childrenList.add(new Property("kind", "code", "Defines the kind of structure that this definition is describing.", 0, java.lang.Integer.MAX_VALUE, kind));
2352        childrenList.add(new Property("constrainedType", "code", "The type of type that is being constrained - a data type, an extension, a resource, including abstract ones. If this field is present, it indicates that the structure definition is a constraint. If it is not present, then the structure definition is the definition of a base structure.", 0, java.lang.Integer.MAX_VALUE, constrainedType));
2353        childrenList.add(new Property("abstract", "boolean", "Whether structure this definition describes is abstract or not  - that is, whether an actual exchanged item can ever be of this type.", 0, java.lang.Integer.MAX_VALUE, abstract_));
2354        childrenList.add(new Property("contextType", "code", "If this is an extension, Identifies the context within FHIR resources where the extension can be used.", 0, java.lang.Integer.MAX_VALUE, contextType));
2355        childrenList.add(new Property("context", "string", "Identifies the types of resource or data type elements to which the extension can be applied.", 0, java.lang.Integer.MAX_VALUE, context));
2356        childrenList.add(new Property("base", "uri", "An absolute URI that is the base structure from which this set of constraints is derived.", 0, java.lang.Integer.MAX_VALUE, base));
2357        childrenList.add(new Property("snapshot", "", "A snapshot view is expressed in a stand alone form that can be used and interpreted without considering the base StructureDefinition.", 0, java.lang.Integer.MAX_VALUE, snapshot));
2358        childrenList.add(new Property("differential", "", "A differential view is expressed relative to the base StructureDefinition - a statement of differences that it applies.", 0, java.lang.Integer.MAX_VALUE, differential));
2359      }
2360
2361      @Override
2362      public void setProperty(String name, Base value) throws FHIRException {
2363        if (name.equals("url"))
2364          this.url = castToUri(value); // UriType
2365        else if (name.equals("identifier"))
2366          this.getIdentifier().add(castToIdentifier(value));
2367        else if (name.equals("version"))
2368          this.version = castToString(value); // StringType
2369        else if (name.equals("name"))
2370          this.name = castToString(value); // StringType
2371        else if (name.equals("display"))
2372          this.display = castToString(value); // StringType
2373        else if (name.equals("status"))
2374          this.status = new ConformanceResourceStatusEnumFactory().fromType(value); // Enumeration<ConformanceResourceStatus>
2375        else if (name.equals("experimental"))
2376          this.experimental = castToBoolean(value); // BooleanType
2377        else if (name.equals("publisher"))
2378          this.publisher = castToString(value); // StringType
2379        else if (name.equals("contact"))
2380          this.getContact().add((StructureDefinitionContactComponent) value);
2381        else if (name.equals("date"))
2382          this.date = castToDateTime(value); // DateTimeType
2383        else if (name.equals("description"))
2384          this.description = castToString(value); // StringType
2385        else if (name.equals("useContext"))
2386          this.getUseContext().add(castToCodeableConcept(value));
2387        else if (name.equals("requirements"))
2388          this.requirements = castToString(value); // StringType
2389        else if (name.equals("copyright"))
2390          this.copyright = castToString(value); // StringType
2391        else if (name.equals("code"))
2392          this.getCode().add(castToCoding(value));
2393        else if (name.equals("fhirVersion"))
2394          this.fhirVersion = castToId(value); // IdType
2395        else if (name.equals("mapping"))
2396          this.getMapping().add((StructureDefinitionMappingComponent) value);
2397        else if (name.equals("kind"))
2398          this.kind = new StructureDefinitionKindEnumFactory().fromType(value); // Enumeration<StructureDefinitionKind>
2399        else if (name.equals("constrainedType"))
2400          this.constrainedType = castToCode(value); // CodeType
2401        else if (name.equals("abstract"))
2402          this.abstract_ = castToBoolean(value); // BooleanType
2403        else if (name.equals("contextType"))
2404          this.contextType = new ExtensionContextEnumFactory().fromType(value); // Enumeration<ExtensionContext>
2405        else if (name.equals("context"))
2406          this.getContext().add(castToString(value));
2407        else if (name.equals("base"))
2408          this.base = castToUri(value); // UriType
2409        else if (name.equals("snapshot"))
2410          this.snapshot = (StructureDefinitionSnapshotComponent) value; // StructureDefinitionSnapshotComponent
2411        else if (name.equals("differential"))
2412          this.differential = (StructureDefinitionDifferentialComponent) value; // StructureDefinitionDifferentialComponent
2413        else
2414          super.setProperty(name, value);
2415      }
2416
2417      @Override
2418      public Base addChild(String name) throws FHIRException {
2419        if (name.equals("url")) {
2420          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.url");
2421        }
2422        else if (name.equals("identifier")) {
2423          return addIdentifier();
2424        }
2425        else if (name.equals("version")) {
2426          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.version");
2427        }
2428        else if (name.equals("name")) {
2429          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.name");
2430        }
2431        else if (name.equals("display")) {
2432          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.display");
2433        }
2434        else if (name.equals("status")) {
2435          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.status");
2436        }
2437        else if (name.equals("experimental")) {
2438          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.experimental");
2439        }
2440        else if (name.equals("publisher")) {
2441          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.publisher");
2442        }
2443        else if (name.equals("contact")) {
2444          return addContact();
2445        }
2446        else if (name.equals("date")) {
2447          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.date");
2448        }
2449        else if (name.equals("description")) {
2450          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.description");
2451        }
2452        else if (name.equals("useContext")) {
2453          return addUseContext();
2454        }
2455        else if (name.equals("requirements")) {
2456          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.requirements");
2457        }
2458        else if (name.equals("copyright")) {
2459          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.copyright");
2460        }
2461        else if (name.equals("code")) {
2462          return addCode();
2463        }
2464        else if (name.equals("fhirVersion")) {
2465          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.fhirVersion");
2466        }
2467        else if (name.equals("mapping")) {
2468          return addMapping();
2469        }
2470        else if (name.equals("kind")) {
2471          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.kind");
2472        }
2473        else if (name.equals("constrainedType")) {
2474          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.constrainedType");
2475        }
2476        else if (name.equals("abstract")) {
2477          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.abstract");
2478        }
2479        else if (name.equals("contextType")) {
2480          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.contextType");
2481        }
2482        else if (name.equals("context")) {
2483          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.context");
2484        }
2485        else if (name.equals("base")) {
2486          throw new FHIRException("Cannot call addChild on a primitive type StructureDefinition.base");
2487        }
2488        else if (name.equals("snapshot")) {
2489          this.snapshot = new StructureDefinitionSnapshotComponent();
2490          return this.snapshot;
2491        }
2492        else if (name.equals("differential")) {
2493          this.differential = new StructureDefinitionDifferentialComponent();
2494          return this.differential;
2495        }
2496        else
2497          return super.addChild(name);
2498      }
2499
2500  public String fhirType() {
2501    return "StructureDefinition";
2502
2503  }
2504
2505      public StructureDefinition copy() {
2506        StructureDefinition dst = new StructureDefinition();
2507        copyValues(dst);
2508        dst.url = url == null ? null : url.copy();
2509        if (identifier != null) {
2510          dst.identifier = new ArrayList<Identifier>();
2511          for (Identifier i : identifier)
2512            dst.identifier.add(i.copy());
2513        };
2514        dst.version = version == null ? null : version.copy();
2515        dst.name = name == null ? null : name.copy();
2516        dst.display = display == null ? null : display.copy();
2517        dst.status = status == null ? null : status.copy();
2518        dst.experimental = experimental == null ? null : experimental.copy();
2519        dst.publisher = publisher == null ? null : publisher.copy();
2520        if (contact != null) {
2521          dst.contact = new ArrayList<StructureDefinitionContactComponent>();
2522          for (StructureDefinitionContactComponent i : contact)
2523            dst.contact.add(i.copy());
2524        };
2525        dst.date = date == null ? null : date.copy();
2526        dst.description = description == null ? null : description.copy();
2527        if (useContext != null) {
2528          dst.useContext = new ArrayList<CodeableConcept>();
2529          for (CodeableConcept i : useContext)
2530            dst.useContext.add(i.copy());
2531        };
2532        dst.requirements = requirements == null ? null : requirements.copy();
2533        dst.copyright = copyright == null ? null : copyright.copy();
2534        if (code != null) {
2535          dst.code = new ArrayList<Coding>();
2536          for (Coding i : code)
2537            dst.code.add(i.copy());
2538        };
2539        dst.fhirVersion = fhirVersion == null ? null : fhirVersion.copy();
2540        if (mapping != null) {
2541          dst.mapping = new ArrayList<StructureDefinitionMappingComponent>();
2542          for (StructureDefinitionMappingComponent i : mapping)
2543            dst.mapping.add(i.copy());
2544        };
2545        dst.kind = kind == null ? null : kind.copy();
2546        dst.constrainedType = constrainedType == null ? null : constrainedType.copy();
2547        dst.abstract_ = abstract_ == null ? null : abstract_.copy();
2548        dst.contextType = contextType == null ? null : contextType.copy();
2549        if (context != null) {
2550          dst.context = new ArrayList<StringType>();
2551          for (StringType i : context)
2552            dst.context.add(i.copy());
2553        };
2554        dst.base = base == null ? null : base.copy();
2555        dst.snapshot = snapshot == null ? null : snapshot.copy();
2556        dst.differential = differential == null ? null : differential.copy();
2557        return dst;
2558      }
2559
2560      protected StructureDefinition typedCopy() {
2561        return copy();
2562      }
2563
2564      @Override
2565      public boolean equalsDeep(Base other) {
2566        if (!super.equalsDeep(other))
2567          return false;
2568        if (!(other instanceof StructureDefinition))
2569          return false;
2570        StructureDefinition o = (StructureDefinition) other;
2571        return compareDeep(url, o.url, true) && compareDeep(identifier, o.identifier, true) && compareDeep(version, o.version, true)
2572           && compareDeep(name, o.name, true) && compareDeep(display, o.display, true) && compareDeep(status, o.status, true)
2573           && compareDeep(experimental, o.experimental, true) && compareDeep(publisher, o.publisher, true)
2574           && compareDeep(contact, o.contact, true) && compareDeep(date, o.date, true) && compareDeep(description, o.description, true)
2575           && compareDeep(useContext, o.useContext, true) && compareDeep(requirements, o.requirements, true)
2576           && compareDeep(copyright, o.copyright, true) && compareDeep(code, o.code, true) && compareDeep(fhirVersion, o.fhirVersion, true)
2577           && compareDeep(mapping, o.mapping, true) && compareDeep(kind, o.kind, true) && compareDeep(constrainedType, o.constrainedType, true)
2578           && compareDeep(abstract_, o.abstract_, true) && compareDeep(contextType, o.contextType, true) && compareDeep(context, o.context, true)
2579           && compareDeep(base, o.base, true) && compareDeep(snapshot, o.snapshot, true) && compareDeep(differential, o.differential, true)
2580          ;
2581      }
2582
2583      @Override
2584      public boolean equalsShallow(Base other) {
2585        if (!super.equalsShallow(other))
2586          return false;
2587        if (!(other instanceof StructureDefinition))
2588          return false;
2589        StructureDefinition o = (StructureDefinition) other;
2590        return compareValues(url, o.url, true) && compareValues(version, o.version, true) && compareValues(name, o.name, true)
2591           && compareValues(display, o.display, true) && compareValues(status, o.status, true) && compareValues(experimental, o.experimental, true)
2592           && compareValues(publisher, o.publisher, true) && compareValues(date, o.date, true) && compareValues(description, o.description, true)
2593           && compareValues(requirements, o.requirements, true) && compareValues(copyright, o.copyright, true)
2594           && compareValues(fhirVersion, o.fhirVersion, true) && compareValues(kind, o.kind, true) && compareValues(constrainedType, o.constrainedType, true)
2595           && compareValues(abstract_, o.abstract_, true) && compareValues(contextType, o.contextType, true) && compareValues(context, o.context, true)
2596           && compareValues(base, o.base, true);
2597      }
2598
2599      public boolean isEmpty() {
2600        return super.isEmpty() && (url == null || url.isEmpty()) && (identifier == null || identifier.isEmpty())
2601           && (version == null || version.isEmpty()) && (name == null || name.isEmpty()) && (display == null || display.isEmpty())
2602           && (status == null || status.isEmpty()) && (experimental == null || experimental.isEmpty())
2603           && (publisher == null || publisher.isEmpty()) && (contact == null || contact.isEmpty()) && (date == null || date.isEmpty())
2604           && (description == null || description.isEmpty()) && (useContext == null || useContext.isEmpty())
2605           && (requirements == null || requirements.isEmpty()) && (copyright == null || copyright.isEmpty())
2606           && (code == null || code.isEmpty()) && (fhirVersion == null || fhirVersion.isEmpty()) && (mapping == null || mapping.isEmpty())
2607           && (kind == null || kind.isEmpty()) && (constrainedType == null || constrainedType.isEmpty())
2608           && (abstract_ == null || abstract_.isEmpty()) && (contextType == null || contextType.isEmpty())
2609           && (context == null || context.isEmpty()) && (base == null || base.isEmpty()) && (snapshot == null || snapshot.isEmpty())
2610           && (differential == null || differential.isEmpty());
2611      }
2612
2613  @Override
2614  public ResourceType getResourceType() {
2615    return ResourceType.StructureDefinition;
2616   }
2617
2618  @SearchParamDefinition(name="date", path="StructureDefinition.date", description="The profile publication date", type="date" )
2619  public static final String SP_DATE = "date";
2620  @SearchParamDefinition(name="identifier", path="StructureDefinition.identifier", description="The identifier of the profile", type="token" )
2621  public static final String SP_IDENTIFIER = "identifier";
2622  @SearchParamDefinition(name="code", path="StructureDefinition.code", description="A code for the profile", type="token" )
2623  public static final String SP_CODE = "code";
2624  @SearchParamDefinition(name="valueset", path="StructureDefinition.snapshot.element.binding.valueSet[x]", description="A vocabulary binding reference", type="reference" )
2625  public static final String SP_VALUESET = "valueset";
2626  @SearchParamDefinition(name="kind", path="StructureDefinition.kind", description="datatype | resource | logical", type="token" )
2627  public static final String SP_KIND = "kind";
2628  @SearchParamDefinition(name="display", path="StructureDefinition.display", description="Use this name when displaying the value", type="string" )
2629  public static final String SP_DISPLAY = "display";
2630  @SearchParamDefinition(name="description", path="StructureDefinition.description", description="Text search in the description of the profile", type="string" )
2631  public static final String SP_DESCRIPTION = "description";
2632  @SearchParamDefinition(name="experimental", path="StructureDefinition.experimental", description="If for testing purposes, not real usage", type="token" )
2633  public static final String SP_EXPERIMENTAL = "experimental";
2634  @SearchParamDefinition(name="context-type", path="StructureDefinition.contextType", description="resource | datatype | mapping | extension", type="token" )
2635  public static final String SP_CONTEXTTYPE = "context-type";
2636  @SearchParamDefinition(name="abstract", path="StructureDefinition.abstract", description="Whether the structure is abstract", type="token" )
2637  public static final String SP_ABSTRACT = "abstract";
2638  @SearchParamDefinition(name="type", path="StructureDefinition.constrainedType", description="Any datatype or resource, including abstract ones", type="token" )
2639  public static final String SP_TYPE = "type";
2640  @SearchParamDefinition(name="version", path="StructureDefinition.version", description="The version identifier of the profile", type="token" )
2641  public static final String SP_VERSION = "version";
2642  @SearchParamDefinition(name="url", path="StructureDefinition.url", description="Absolute URL used to reference this StructureDefinition", type="uri" )
2643  public static final String SP_URL = "url";
2644  @SearchParamDefinition(name="path", path="StructureDefinition.snapshot.element.path | StructureDefinition.differential.element.path", description="A path that is constrained in the profile", type="token" )
2645  public static final String SP_PATH = "path";
2646  @SearchParamDefinition(name="ext-context", path="StructureDefinition.context", description="Where the extension can be used in instances", type="string" )
2647  public static final String SP_EXTCONTEXT = "ext-context";
2648  @SearchParamDefinition(name="name", path="StructureDefinition.name", description="Name of the profile", type="string" )
2649  public static final String SP_NAME = "name";
2650  @SearchParamDefinition(name="context", path="StructureDefinition.useContext", description="A use context assigned to the structure", type="token" )
2651  public static final String SP_CONTEXT = "context";
2652  @SearchParamDefinition(name="base-path", path="StructureDefinition.snapshot.element.base.path | StructureDefinition.differential.element.base.path", description="Path that identifies the base element", type="token" )
2653  public static final String SP_BASEPATH = "base-path";
2654  @SearchParamDefinition(name="publisher", path="StructureDefinition.publisher", description="Name of the publisher of the profile", type="string" )
2655  public static final String SP_PUBLISHER = "publisher";
2656  @SearchParamDefinition(name="status", path="StructureDefinition.status", description="The current status of the profile", type="token" )
2657  public static final String SP_STATUS = "status";
2658  @SearchParamDefinition(name="base", path="StructureDefinition.base", description="Structure that this set of constraints applies to", type="uri" )
2659  public static final String SP_BASE = "base";
2660
2661}