001package org.hl7.fhir.instance.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
033import java.util.*;
034
035import org.hl7.fhir.exceptions.FHIRException;
036import org.hl7.fhir.instance.model.Enumerations.ConformanceResourceStatus;
037import org.hl7.fhir.instance.model.Enumerations.ConformanceResourceStatusEnumFactory;
038import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
039import org.hl7.fhir.utilities.Utilities;
040
041import ca.uhn.fhir.model.api.annotation.*;
042/**
043 * A curated namespace that issues unique symbols within that namespace for the identification of concepts, people, devices, etc.  Represents a "System" used within the Identifier and Coding data types.
044 */
045@ResourceDef(name="NamingSystem", profile="http://hl7.org/fhir/Profile/NamingSystem")
046public class NamingSystem extends DomainResource {
047
048    public enum NamingSystemType {
049        /**
050         * The naming system is used to define concepts and symbols to represent those concepts; e.g. UCUM, LOINC, NDC code, local lab codes, etc.
051         */
052        CODESYSTEM, 
053        /**
054         * The naming system is used to manage identifiers (e.g. license numbers, order numbers, etc.).
055         */
056        IDENTIFIER, 
057        /**
058         * The naming system is used as the root for other identifiers and naming systems.
059         */
060        ROOT, 
061        /**
062         * added to help the parsers
063         */
064        NULL;
065        public static NamingSystemType fromCode(String codeString) throws FHIRException {
066            if (codeString == null || "".equals(codeString))
067                return null;
068        if ("codesystem".equals(codeString))
069          return CODESYSTEM;
070        if ("identifier".equals(codeString))
071          return IDENTIFIER;
072        if ("root".equals(codeString))
073          return ROOT;
074        throw new FHIRException("Unknown NamingSystemType code '"+codeString+"'");
075        }
076        public String toCode() {
077          switch (this) {
078            case CODESYSTEM: return "codesystem";
079            case IDENTIFIER: return "identifier";
080            case ROOT: return "root";
081            default: return "?";
082          }
083        }
084        public String getSystem() {
085          switch (this) {
086            case CODESYSTEM: return "http://hl7.org/fhir/namingsystem-type";
087            case IDENTIFIER: return "http://hl7.org/fhir/namingsystem-type";
088            case ROOT: return "http://hl7.org/fhir/namingsystem-type";
089            default: return "?";
090          }
091        }
092        public String getDefinition() {
093          switch (this) {
094            case CODESYSTEM: return "The naming system is used to define concepts and symbols to represent those concepts; e.g. UCUM, LOINC, NDC code, local lab codes, etc.";
095            case IDENTIFIER: return "The naming system is used to manage identifiers (e.g. license numbers, order numbers, etc.).";
096            case ROOT: return "The naming system is used as the root for other identifiers and naming systems.";
097            default: return "?";
098          }
099        }
100        public String getDisplay() {
101          switch (this) {
102            case CODESYSTEM: return "Code System";
103            case IDENTIFIER: return "Identifier";
104            case ROOT: return "Root";
105            default: return "?";
106          }
107        }
108    }
109
110  public static class NamingSystemTypeEnumFactory implements EnumFactory<NamingSystemType> {
111    public NamingSystemType fromCode(String codeString) throws IllegalArgumentException {
112      if (codeString == null || "".equals(codeString))
113            if (codeString == null || "".equals(codeString))
114                return null;
115        if ("codesystem".equals(codeString))
116          return NamingSystemType.CODESYSTEM;
117        if ("identifier".equals(codeString))
118          return NamingSystemType.IDENTIFIER;
119        if ("root".equals(codeString))
120          return NamingSystemType.ROOT;
121        throw new IllegalArgumentException("Unknown NamingSystemType code '"+codeString+"'");
122        }
123        public Enumeration<NamingSystemType> fromType(Base code) throws FHIRException {
124          if (code == null || code.isEmpty())
125            return null;
126          String codeString = ((PrimitiveType) code).asStringValue();
127          if (codeString == null || "".equals(codeString))
128            return null;
129        if ("codesystem".equals(codeString))
130          return new Enumeration<NamingSystemType>(this, NamingSystemType.CODESYSTEM);
131        if ("identifier".equals(codeString))
132          return new Enumeration<NamingSystemType>(this, NamingSystemType.IDENTIFIER);
133        if ("root".equals(codeString))
134          return new Enumeration<NamingSystemType>(this, NamingSystemType.ROOT);
135        throw new FHIRException("Unknown NamingSystemType code '"+codeString+"'");
136        }
137    public String toCode(NamingSystemType code) {
138      if (code == NamingSystemType.CODESYSTEM)
139        return "codesystem";
140      if (code == NamingSystemType.IDENTIFIER)
141        return "identifier";
142      if (code == NamingSystemType.ROOT)
143        return "root";
144      return "?";
145      }
146    }
147
148    public enum NamingSystemIdentifierType {
149        /**
150         * An ISO object identifier; e.g. 1.2.3.4.5.
151         */
152        OID, 
153        /**
154         * A universally unique identifier of the form a5afddf4-e880-459b-876e-e4591b0acc11.
155         */
156        UUID, 
157        /**
158         * A uniform resource identifier (ideally a URL - uniform resource locator); e.g. http://unitsofmeasure.org.
159         */
160        URI, 
161        /**
162         * Some other type of unique identifier; e.g. HL7-assigned reserved string such as LN for LOINC.
163         */
164        OTHER, 
165        /**
166         * added to help the parsers
167         */
168        NULL;
169        public static NamingSystemIdentifierType fromCode(String codeString) throws FHIRException {
170            if (codeString == null || "".equals(codeString))
171                return null;
172        if ("oid".equals(codeString))
173          return OID;
174        if ("uuid".equals(codeString))
175          return UUID;
176        if ("uri".equals(codeString))
177          return URI;
178        if ("other".equals(codeString))
179          return OTHER;
180        throw new FHIRException("Unknown NamingSystemIdentifierType code '"+codeString+"'");
181        }
182        public String toCode() {
183          switch (this) {
184            case OID: return "oid";
185            case UUID: return "uuid";
186            case URI: return "uri";
187            case OTHER: return "other";
188            default: return "?";
189          }
190        }
191        public String getSystem() {
192          switch (this) {
193            case OID: return "http://hl7.org/fhir/namingsystem-identifier-type";
194            case UUID: return "http://hl7.org/fhir/namingsystem-identifier-type";
195            case URI: return "http://hl7.org/fhir/namingsystem-identifier-type";
196            case OTHER: return "http://hl7.org/fhir/namingsystem-identifier-type";
197            default: return "?";
198          }
199        }
200        public String getDefinition() {
201          switch (this) {
202            case OID: return "An ISO object identifier; e.g. 1.2.3.4.5.";
203            case UUID: return "A universally unique identifier of the form a5afddf4-e880-459b-876e-e4591b0acc11.";
204            case URI: return "A uniform resource identifier (ideally a URL - uniform resource locator); e.g. http://unitsofmeasure.org.";
205            case OTHER: return "Some other type of unique identifier; e.g. HL7-assigned reserved string such as LN for LOINC.";
206            default: return "?";
207          }
208        }
209        public String getDisplay() {
210          switch (this) {
211            case OID: return "OID";
212            case UUID: return "UUID";
213            case URI: return "URI";
214            case OTHER: return "Other";
215            default: return "?";
216          }
217        }
218    }
219
220  public static class NamingSystemIdentifierTypeEnumFactory implements EnumFactory<NamingSystemIdentifierType> {
221    public NamingSystemIdentifierType fromCode(String codeString) throws IllegalArgumentException {
222      if (codeString == null || "".equals(codeString))
223            if (codeString == null || "".equals(codeString))
224                return null;
225        if ("oid".equals(codeString))
226          return NamingSystemIdentifierType.OID;
227        if ("uuid".equals(codeString))
228          return NamingSystemIdentifierType.UUID;
229        if ("uri".equals(codeString))
230          return NamingSystemIdentifierType.URI;
231        if ("other".equals(codeString))
232          return NamingSystemIdentifierType.OTHER;
233        throw new IllegalArgumentException("Unknown NamingSystemIdentifierType code '"+codeString+"'");
234        }
235        public Enumeration<NamingSystemIdentifierType> fromType(Base code) throws FHIRException {
236          if (code == null || code.isEmpty())
237            return null;
238          String codeString = ((PrimitiveType) code).asStringValue();
239          if (codeString == null || "".equals(codeString))
240            return null;
241        if ("oid".equals(codeString))
242          return new Enumeration<NamingSystemIdentifierType>(this, NamingSystemIdentifierType.OID);
243        if ("uuid".equals(codeString))
244          return new Enumeration<NamingSystemIdentifierType>(this, NamingSystemIdentifierType.UUID);
245        if ("uri".equals(codeString))
246          return new Enumeration<NamingSystemIdentifierType>(this, NamingSystemIdentifierType.URI);
247        if ("other".equals(codeString))
248          return new Enumeration<NamingSystemIdentifierType>(this, NamingSystemIdentifierType.OTHER);
249        throw new FHIRException("Unknown NamingSystemIdentifierType code '"+codeString+"'");
250        }
251    public String toCode(NamingSystemIdentifierType code) {
252      if (code == NamingSystemIdentifierType.OID)
253        return "oid";
254      if (code == NamingSystemIdentifierType.UUID)
255        return "uuid";
256      if (code == NamingSystemIdentifierType.URI)
257        return "uri";
258      if (code == NamingSystemIdentifierType.OTHER)
259        return "other";
260      return "?";
261      }
262    }
263
264    @Block()
265    public static class NamingSystemContactComponent extends BackboneElement implements IBaseBackboneElement {
266        /**
267         * The name of an individual to contact regarding the naming system.
268         */
269        @Child(name = "name", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
270        @Description(shortDefinition="Name of a individual to contact", formalDefinition="The name of an individual to contact regarding the naming system." )
271        protected StringType name;
272
273        /**
274         * Contact details for individual (if a name was provided) or the publisher.
275         */
276        @Child(name = "telecom", type = {ContactPoint.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
277        @Description(shortDefinition="Contact details for individual or publisher", formalDefinition="Contact details for individual (if a name was provided) or the publisher." )
278        protected List<ContactPoint> telecom;
279
280        private static final long serialVersionUID = -1179697803L;
281
282    /*
283     * Constructor
284     */
285      public NamingSystemContactComponent() {
286        super();
287      }
288
289        /**
290         * @return {@link #name} (The name of an individual to contact regarding the naming system.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
291         */
292        public StringType getNameElement() { 
293          if (this.name == null)
294            if (Configuration.errorOnAutoCreate())
295              throw new Error("Attempt to auto-create NamingSystemContactComponent.name");
296            else if (Configuration.doAutoCreate())
297              this.name = new StringType(); // bb
298          return this.name;
299        }
300
301        public boolean hasNameElement() { 
302          return this.name != null && !this.name.isEmpty();
303        }
304
305        public boolean hasName() { 
306          return this.name != null && !this.name.isEmpty();
307        }
308
309        /**
310         * @param value {@link #name} (The name of an individual to contact regarding the naming system.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
311         */
312        public NamingSystemContactComponent setNameElement(StringType value) { 
313          this.name = value;
314          return this;
315        }
316
317        /**
318         * @return The name of an individual to contact regarding the naming system.
319         */
320        public String getName() { 
321          return this.name == null ? null : this.name.getValue();
322        }
323
324        /**
325         * @param value The name of an individual to contact regarding the naming system.
326         */
327        public NamingSystemContactComponent setName(String value) { 
328          if (Utilities.noString(value))
329            this.name = null;
330          else {
331            if (this.name == null)
332              this.name = new StringType();
333            this.name.setValue(value);
334          }
335          return this;
336        }
337
338        /**
339         * @return {@link #telecom} (Contact details for individual (if a name was provided) or the publisher.)
340         */
341        public List<ContactPoint> getTelecom() { 
342          if (this.telecom == null)
343            this.telecom = new ArrayList<ContactPoint>();
344          return this.telecom;
345        }
346
347        public boolean hasTelecom() { 
348          if (this.telecom == null)
349            return false;
350          for (ContactPoint item : this.telecom)
351            if (!item.isEmpty())
352              return true;
353          return false;
354        }
355
356        /**
357         * @return {@link #telecom} (Contact details for individual (if a name was provided) or the publisher.)
358         */
359    // syntactic sugar
360        public ContactPoint addTelecom() { //3
361          ContactPoint t = new ContactPoint();
362          if (this.telecom == null)
363            this.telecom = new ArrayList<ContactPoint>();
364          this.telecom.add(t);
365          return t;
366        }
367
368    // syntactic sugar
369        public NamingSystemContactComponent addTelecom(ContactPoint t) { //3
370          if (t == null)
371            return this;
372          if (this.telecom == null)
373            this.telecom = new ArrayList<ContactPoint>();
374          this.telecom.add(t);
375          return this;
376        }
377
378        protected void listChildren(List<Property> childrenList) {
379          super.listChildren(childrenList);
380          childrenList.add(new Property("name", "string", "The name of an individual to contact regarding the naming system.", 0, java.lang.Integer.MAX_VALUE, name));
381          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));
382        }
383
384      @Override
385      public void setProperty(String name, Base value) throws FHIRException {
386        if (name.equals("name"))
387          this.name = castToString(value); // StringType
388        else if (name.equals("telecom"))
389          this.getTelecom().add(castToContactPoint(value));
390        else
391          super.setProperty(name, value);
392      }
393
394      @Override
395      public Base addChild(String name) throws FHIRException {
396        if (name.equals("name")) {
397          throw new FHIRException("Cannot call addChild on a primitive type NamingSystem.name");
398        }
399        else if (name.equals("telecom")) {
400          return addTelecom();
401        }
402        else
403          return super.addChild(name);
404      }
405
406      public NamingSystemContactComponent copy() {
407        NamingSystemContactComponent dst = new NamingSystemContactComponent();
408        copyValues(dst);
409        dst.name = name == null ? null : name.copy();
410        if (telecom != null) {
411          dst.telecom = new ArrayList<ContactPoint>();
412          for (ContactPoint i : telecom)
413            dst.telecom.add(i.copy());
414        };
415        return dst;
416      }
417
418      @Override
419      public boolean equalsDeep(Base other) {
420        if (!super.equalsDeep(other))
421          return false;
422        if (!(other instanceof NamingSystemContactComponent))
423          return false;
424        NamingSystemContactComponent o = (NamingSystemContactComponent) other;
425        return compareDeep(name, o.name, true) && compareDeep(telecom, o.telecom, true);
426      }
427
428      @Override
429      public boolean equalsShallow(Base other) {
430        if (!super.equalsShallow(other))
431          return false;
432        if (!(other instanceof NamingSystemContactComponent))
433          return false;
434        NamingSystemContactComponent o = (NamingSystemContactComponent) other;
435        return compareValues(name, o.name, true);
436      }
437
438      public boolean isEmpty() {
439        return super.isEmpty() && (name == null || name.isEmpty()) && (telecom == null || telecom.isEmpty())
440          ;
441      }
442
443  public String fhirType() {
444    return "NamingSystem.contact";
445
446  }
447
448  }
449
450    @Block()
451    public static class NamingSystemUniqueIdComponent extends BackboneElement implements IBaseBackboneElement {
452        /**
453         * Identifies the unique identifier scheme used for this particular identifier.
454         */
455        @Child(name = "type", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=false)
456        @Description(shortDefinition="oid | uuid | uri | other", formalDefinition="Identifies the unique identifier scheme used for this particular identifier." )
457        protected Enumeration<NamingSystemIdentifierType> type;
458
459        /**
460         * The string that should be sent over the wire to identify the code system or identifier system.
461         */
462        @Child(name = "value", type = {StringType.class}, order=2, min=1, max=1, modifier=false, summary=false)
463        @Description(shortDefinition="The unique identifier", formalDefinition="The string that should be sent over the wire to identify the code system or identifier system." )
464        protected StringType value;
465
466        /**
467         * Indicates whether this identifier is the "preferred" identifier of this type.
468         */
469        @Child(name = "preferred", type = {BooleanType.class}, order=3, min=0, max=1, modifier=false, summary=false)
470        @Description(shortDefinition="Is this the id that should be used for this type", formalDefinition="Indicates whether this identifier is the \"preferred\" identifier of this type." )
471        protected BooleanType preferred;
472
473        /**
474         * Identifies the period of time over which this identifier is considered appropriate to refer to the naming system.  Outside of this window, the identifier might be non-deterministic.
475         */
476        @Child(name = "period", type = {Period.class}, order=4, min=0, max=1, modifier=false, summary=false)
477        @Description(shortDefinition="When is identifier valid?", formalDefinition="Identifies the period of time over which this identifier is considered appropriate to refer to the naming system.  Outside of this window, the identifier might be non-deterministic." )
478        protected Period period;
479
480        private static final long serialVersionUID = -193711840L;
481
482    /*
483     * Constructor
484     */
485      public NamingSystemUniqueIdComponent() {
486        super();
487      }
488
489    /*
490     * Constructor
491     */
492      public NamingSystemUniqueIdComponent(Enumeration<NamingSystemIdentifierType> type, StringType value) {
493        super();
494        this.type = type;
495        this.value = value;
496      }
497
498        /**
499         * @return {@link #type} (Identifies the unique identifier scheme used for this particular identifier.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
500         */
501        public Enumeration<NamingSystemIdentifierType> getTypeElement() { 
502          if (this.type == null)
503            if (Configuration.errorOnAutoCreate())
504              throw new Error("Attempt to auto-create NamingSystemUniqueIdComponent.type");
505            else if (Configuration.doAutoCreate())
506              this.type = new Enumeration<NamingSystemIdentifierType>(new NamingSystemIdentifierTypeEnumFactory()); // bb
507          return this.type;
508        }
509
510        public boolean hasTypeElement() { 
511          return this.type != null && !this.type.isEmpty();
512        }
513
514        public boolean hasType() { 
515          return this.type != null && !this.type.isEmpty();
516        }
517
518        /**
519         * @param value {@link #type} (Identifies the unique identifier scheme used for this particular identifier.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
520         */
521        public NamingSystemUniqueIdComponent setTypeElement(Enumeration<NamingSystemIdentifierType> value) { 
522          this.type = value;
523          return this;
524        }
525
526        /**
527         * @return Identifies the unique identifier scheme used for this particular identifier.
528         */
529        public NamingSystemIdentifierType getType() { 
530          return this.type == null ? null : this.type.getValue();
531        }
532
533        /**
534         * @param value Identifies the unique identifier scheme used for this particular identifier.
535         */
536        public NamingSystemUniqueIdComponent setType(NamingSystemIdentifierType value) { 
537            if (this.type == null)
538              this.type = new Enumeration<NamingSystemIdentifierType>(new NamingSystemIdentifierTypeEnumFactory());
539            this.type.setValue(value);
540          return this;
541        }
542
543        /**
544         * @return {@link #value} (The string that should be sent over the wire to identify the code system or identifier system.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
545         */
546        public StringType getValueElement() { 
547          if (this.value == null)
548            if (Configuration.errorOnAutoCreate())
549              throw new Error("Attempt to auto-create NamingSystemUniqueIdComponent.value");
550            else if (Configuration.doAutoCreate())
551              this.value = new StringType(); // bb
552          return this.value;
553        }
554
555        public boolean hasValueElement() { 
556          return this.value != null && !this.value.isEmpty();
557        }
558
559        public boolean hasValue() { 
560          return this.value != null && !this.value.isEmpty();
561        }
562
563        /**
564         * @param value {@link #value} (The string that should be sent over the wire to identify the code system or identifier system.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
565         */
566        public NamingSystemUniqueIdComponent setValueElement(StringType value) { 
567          this.value = value;
568          return this;
569        }
570
571        /**
572         * @return The string that should be sent over the wire to identify the code system or identifier system.
573         */
574        public String getValue() { 
575          return this.value == null ? null : this.value.getValue();
576        }
577
578        /**
579         * @param value The string that should be sent over the wire to identify the code system or identifier system.
580         */
581        public NamingSystemUniqueIdComponent setValue(String value) { 
582            if (this.value == null)
583              this.value = new StringType();
584            this.value.setValue(value);
585          return this;
586        }
587
588        /**
589         * @return {@link #preferred} (Indicates whether this identifier is the "preferred" identifier of this type.). This is the underlying object with id, value and extensions. The accessor "getPreferred" gives direct access to the value
590         */
591        public BooleanType getPreferredElement() { 
592          if (this.preferred == null)
593            if (Configuration.errorOnAutoCreate())
594              throw new Error("Attempt to auto-create NamingSystemUniqueIdComponent.preferred");
595            else if (Configuration.doAutoCreate())
596              this.preferred = new BooleanType(); // bb
597          return this.preferred;
598        }
599
600        public boolean hasPreferredElement() { 
601          return this.preferred != null && !this.preferred.isEmpty();
602        }
603
604        public boolean hasPreferred() { 
605          return this.preferred != null && !this.preferred.isEmpty();
606        }
607
608        /**
609         * @param value {@link #preferred} (Indicates whether this identifier is the "preferred" identifier of this type.). This is the underlying object with id, value and extensions. The accessor "getPreferred" gives direct access to the value
610         */
611        public NamingSystemUniqueIdComponent setPreferredElement(BooleanType value) { 
612          this.preferred = value;
613          return this;
614        }
615
616        /**
617         * @return Indicates whether this identifier is the "preferred" identifier of this type.
618         */
619        public boolean getPreferred() { 
620          return this.preferred == null || this.preferred.isEmpty() ? false : this.preferred.getValue();
621        }
622
623        /**
624         * @param value Indicates whether this identifier is the "preferred" identifier of this type.
625         */
626        public NamingSystemUniqueIdComponent setPreferred(boolean value) { 
627            if (this.preferred == null)
628              this.preferred = new BooleanType();
629            this.preferred.setValue(value);
630          return this;
631        }
632
633        /**
634         * @return {@link #period} (Identifies the period of time over which this identifier is considered appropriate to refer to the naming system.  Outside of this window, the identifier might be non-deterministic.)
635         */
636        public Period getPeriod() { 
637          if (this.period == null)
638            if (Configuration.errorOnAutoCreate())
639              throw new Error("Attempt to auto-create NamingSystemUniqueIdComponent.period");
640            else if (Configuration.doAutoCreate())
641              this.period = new Period(); // cc
642          return this.period;
643        }
644
645        public boolean hasPeriod() { 
646          return this.period != null && !this.period.isEmpty();
647        }
648
649        /**
650         * @param value {@link #period} (Identifies the period of time over which this identifier is considered appropriate to refer to the naming system.  Outside of this window, the identifier might be non-deterministic.)
651         */
652        public NamingSystemUniqueIdComponent setPeriod(Period value) { 
653          this.period = value;
654          return this;
655        }
656
657        protected void listChildren(List<Property> childrenList) {
658          super.listChildren(childrenList);
659          childrenList.add(new Property("type", "code", "Identifies the unique identifier scheme used for this particular identifier.", 0, java.lang.Integer.MAX_VALUE, type));
660          childrenList.add(new Property("value", "string", "The string that should be sent over the wire to identify the code system or identifier system.", 0, java.lang.Integer.MAX_VALUE, value));
661          childrenList.add(new Property("preferred", "boolean", "Indicates whether this identifier is the \"preferred\" identifier of this type.", 0, java.lang.Integer.MAX_VALUE, preferred));
662          childrenList.add(new Property("period", "Period", "Identifies the period of time over which this identifier is considered appropriate to refer to the naming system.  Outside of this window, the identifier might be non-deterministic.", 0, java.lang.Integer.MAX_VALUE, period));
663        }
664
665      @Override
666      public void setProperty(String name, Base value) throws FHIRException {
667        if (name.equals("type"))
668          this.type = new NamingSystemIdentifierTypeEnumFactory().fromType(value); // Enumeration<NamingSystemIdentifierType>
669        else if (name.equals("value"))
670          this.value = castToString(value); // StringType
671        else if (name.equals("preferred"))
672          this.preferred = castToBoolean(value); // BooleanType
673        else if (name.equals("period"))
674          this.period = castToPeriod(value); // Period
675        else
676          super.setProperty(name, value);
677      }
678
679      @Override
680      public Base addChild(String name) throws FHIRException {
681        if (name.equals("type")) {
682          throw new FHIRException("Cannot call addChild on a primitive type NamingSystem.type");
683        }
684        else if (name.equals("value")) {
685          throw new FHIRException("Cannot call addChild on a primitive type NamingSystem.value");
686        }
687        else if (name.equals("preferred")) {
688          throw new FHIRException("Cannot call addChild on a primitive type NamingSystem.preferred");
689        }
690        else if (name.equals("period")) {
691          this.period = new Period();
692          return this.period;
693        }
694        else
695          return super.addChild(name);
696      }
697
698      public NamingSystemUniqueIdComponent copy() {
699        NamingSystemUniqueIdComponent dst = new NamingSystemUniqueIdComponent();
700        copyValues(dst);
701        dst.type = type == null ? null : type.copy();
702        dst.value = value == null ? null : value.copy();
703        dst.preferred = preferred == null ? null : preferred.copy();
704        dst.period = period == null ? null : period.copy();
705        return dst;
706      }
707
708      @Override
709      public boolean equalsDeep(Base other) {
710        if (!super.equalsDeep(other))
711          return false;
712        if (!(other instanceof NamingSystemUniqueIdComponent))
713          return false;
714        NamingSystemUniqueIdComponent o = (NamingSystemUniqueIdComponent) other;
715        return compareDeep(type, o.type, true) && compareDeep(value, o.value, true) && compareDeep(preferred, o.preferred, true)
716           && compareDeep(period, o.period, true);
717      }
718
719      @Override
720      public boolean equalsShallow(Base other) {
721        if (!super.equalsShallow(other))
722          return false;
723        if (!(other instanceof NamingSystemUniqueIdComponent))
724          return false;
725        NamingSystemUniqueIdComponent o = (NamingSystemUniqueIdComponent) other;
726        return compareValues(type, o.type, true) && compareValues(value, o.value, true) && compareValues(preferred, o.preferred, true)
727          ;
728      }
729
730      public boolean isEmpty() {
731        return super.isEmpty() && (type == null || type.isEmpty()) && (value == null || value.isEmpty())
732           && (preferred == null || preferred.isEmpty()) && (period == null || period.isEmpty());
733      }
734
735  public String fhirType() {
736    return "NamingSystem.uniqueId";
737
738  }
739
740  }
741
742    /**
743     * The descriptive name of this particular identifier type or code system.
744     */
745    @Child(name = "name", type = {StringType.class}, order=0, min=1, max=1, modifier=false, summary=false)
746    @Description(shortDefinition="Human-readable label", formalDefinition="The descriptive name of this particular identifier type or code system." )
747    protected StringType name;
748
749    /**
750     * Indicates whether the naming system is "ready for use" or not.
751     */
752    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=false)
753    @Description(shortDefinition="draft | active | retired", formalDefinition="Indicates whether the naming system is \"ready for use\" or not." )
754    protected Enumeration<ConformanceResourceStatus> status;
755
756    /**
757     * Indicates the purpose for the naming system - what kinds of things does it make unique?
758     */
759    @Child(name = "kind", type = {CodeType.class}, order=2, min=1, max=1, modifier=false, summary=false)
760    @Description(shortDefinition="codesystem | identifier | root", formalDefinition="Indicates the purpose for the naming system - what kinds of things does it make unique?" )
761    protected Enumeration<NamingSystemType> kind;
762
763    /**
764     * The name of the individual or organization that published the naming system.
765     */
766    @Child(name = "publisher", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
767    @Description(shortDefinition="Name of the publisher (Organization or individual)", formalDefinition="The name of the individual or organization that published the naming system." )
768    protected StringType publisher;
769
770    /**
771     * Contacts to assist a user in finding and communicating with the publisher.
772     */
773    @Child(name = "contact", type = {}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
774    @Description(shortDefinition="Contact details of the publisher", formalDefinition="Contacts to assist a user in finding and communicating with the publisher." )
775    protected List<NamingSystemContactComponent> contact;
776
777    /**
778     * The name of the organization that is responsible for issuing identifiers or codes for this namespace and ensuring their non-collision.
779     */
780    @Child(name = "responsible", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=false)
781    @Description(shortDefinition="Who maintains system namespace?", formalDefinition="The name of the organization that is responsible for issuing identifiers or codes for this namespace and ensuring their non-collision." )
782    protected StringType responsible;
783
784    /**
785     * The date  (and optionally time) when the system was registered or 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 registration changes.
786     */
787    @Child(name = "date", type = {DateTimeType.class}, order=6, min=1, max=1, modifier=false, summary=true)
788    @Description(shortDefinition="Publication Date(/time)", formalDefinition="The date  (and optionally time) when the system was registered or 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 registration changes." )
789    protected DateTimeType date;
790
791    /**
792     * Categorizes a naming system for easier search by grouping related naming systems.
793     */
794    @Child(name = "type", type = {CodeableConcept.class}, order=7, min=0, max=1, modifier=false, summary=false)
795    @Description(shortDefinition="e.g. driver,  provider,  patient, bank etc.", formalDefinition="Categorizes a naming system for easier search by grouping related naming systems." )
796    protected CodeableConcept type;
797
798    /**
799     * Details about what the namespace identifies including scope, granularity, version labeling, etc.
800     */
801    @Child(name = "description", type = {StringType.class}, order=8, min=0, max=1, modifier=false, summary=false)
802    @Description(shortDefinition="What does naming system identify?", formalDefinition="Details about what the namespace identifies including scope, granularity, version labeling, etc." )
803    protected StringType description;
804
805    /**
806     * 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 naming systems.
807     */
808    @Child(name = "useContext", type = {CodeableConcept.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
809    @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 naming systems." )
810    protected List<CodeableConcept> useContext;
811
812    /**
813     * Provides guidance on the use of the namespace, including the handling of formatting characters, use of upper vs. lower case, etc.
814     */
815    @Child(name = "usage", type = {StringType.class}, order=10, min=0, max=1, modifier=false, summary=false)
816    @Description(shortDefinition="How/where is it used", formalDefinition="Provides guidance on the use of the namespace, including the handling of formatting characters, use of upper vs. lower case, etc." )
817    protected StringType usage;
818
819    /**
820     * Indicates how the system may be identified when referenced in electronic exchange.
821     */
822    @Child(name = "uniqueId", type = {}, order=11, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
823    @Description(shortDefinition="Unique identifiers used for system", formalDefinition="Indicates how the system may be identified when referenced in electronic exchange." )
824    protected List<NamingSystemUniqueIdComponent> uniqueId;
825
826    /**
827     * For naming systems that are retired, indicates the naming system that should be used in their place (if any).
828     */
829    @Child(name = "replacedBy", type = {NamingSystem.class}, order=12, min=0, max=1, modifier=false, summary=false)
830    @Description(shortDefinition="Use this instead", formalDefinition="For naming systems that are retired, indicates the naming system that should be used in their place (if any)." )
831    protected Reference replacedBy;
832
833    /**
834     * The actual object that is the target of the reference (For naming systems that are retired, indicates the naming system that should be used in their place (if any).)
835     */
836    protected NamingSystem replacedByTarget;
837
838    private static final long serialVersionUID = -1337110053L;
839
840  /*
841   * Constructor
842   */
843    public NamingSystem() {
844      super();
845    }
846
847  /*
848   * Constructor
849   */
850    public NamingSystem(StringType name, Enumeration<ConformanceResourceStatus> status, Enumeration<NamingSystemType> kind, DateTimeType date) {
851      super();
852      this.name = name;
853      this.status = status;
854      this.kind = kind;
855      this.date = date;
856    }
857
858    /**
859     * @return {@link #name} (The descriptive name of this particular identifier type or code system.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
860     */
861    public StringType getNameElement() { 
862      if (this.name == null)
863        if (Configuration.errorOnAutoCreate())
864          throw new Error("Attempt to auto-create NamingSystem.name");
865        else if (Configuration.doAutoCreate())
866          this.name = new StringType(); // bb
867      return this.name;
868    }
869
870    public boolean hasNameElement() { 
871      return this.name != null && !this.name.isEmpty();
872    }
873
874    public boolean hasName() { 
875      return this.name != null && !this.name.isEmpty();
876    }
877
878    /**
879     * @param value {@link #name} (The descriptive name of this particular identifier type or code system.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
880     */
881    public NamingSystem setNameElement(StringType value) { 
882      this.name = value;
883      return this;
884    }
885
886    /**
887     * @return The descriptive name of this particular identifier type or code system.
888     */
889    public String getName() { 
890      return this.name == null ? null : this.name.getValue();
891    }
892
893    /**
894     * @param value The descriptive name of this particular identifier type or code system.
895     */
896    public NamingSystem setName(String value) { 
897        if (this.name == null)
898          this.name = new StringType();
899        this.name.setValue(value);
900      return this;
901    }
902
903    /**
904     * @return {@link #status} (Indicates whether the naming system is "ready for use" or not.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
905     */
906    public Enumeration<ConformanceResourceStatus> getStatusElement() { 
907      if (this.status == null)
908        if (Configuration.errorOnAutoCreate())
909          throw new Error("Attempt to auto-create NamingSystem.status");
910        else if (Configuration.doAutoCreate())
911          this.status = new Enumeration<ConformanceResourceStatus>(new ConformanceResourceStatusEnumFactory()); // bb
912      return this.status;
913    }
914
915    public boolean hasStatusElement() { 
916      return this.status != null && !this.status.isEmpty();
917    }
918
919    public boolean hasStatus() { 
920      return this.status != null && !this.status.isEmpty();
921    }
922
923    /**
924     * @param value {@link #status} (Indicates whether the naming system is "ready for use" or not.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
925     */
926    public NamingSystem setStatusElement(Enumeration<ConformanceResourceStatus> value) { 
927      this.status = value;
928      return this;
929    }
930
931    /**
932     * @return Indicates whether the naming system is "ready for use" or not.
933     */
934    public ConformanceResourceStatus getStatus() { 
935      return this.status == null ? null : this.status.getValue();
936    }
937
938    /**
939     * @param value Indicates whether the naming system is "ready for use" or not.
940     */
941    public NamingSystem setStatus(ConformanceResourceStatus value) { 
942        if (this.status == null)
943          this.status = new Enumeration<ConformanceResourceStatus>(new ConformanceResourceStatusEnumFactory());
944        this.status.setValue(value);
945      return this;
946    }
947
948    /**
949     * @return {@link #kind} (Indicates the purpose for the naming system - what kinds of things does it make unique?). This is the underlying object with id, value and extensions. The accessor "getKind" gives direct access to the value
950     */
951    public Enumeration<NamingSystemType> getKindElement() { 
952      if (this.kind == null)
953        if (Configuration.errorOnAutoCreate())
954          throw new Error("Attempt to auto-create NamingSystem.kind");
955        else if (Configuration.doAutoCreate())
956          this.kind = new Enumeration<NamingSystemType>(new NamingSystemTypeEnumFactory()); // bb
957      return this.kind;
958    }
959
960    public boolean hasKindElement() { 
961      return this.kind != null && !this.kind.isEmpty();
962    }
963
964    public boolean hasKind() { 
965      return this.kind != null && !this.kind.isEmpty();
966    }
967
968    /**
969     * @param value {@link #kind} (Indicates the purpose for the naming system - what kinds of things does it make unique?). This is the underlying object with id, value and extensions. The accessor "getKind" gives direct access to the value
970     */
971    public NamingSystem setKindElement(Enumeration<NamingSystemType> value) { 
972      this.kind = value;
973      return this;
974    }
975
976    /**
977     * @return Indicates the purpose for the naming system - what kinds of things does it make unique?
978     */
979    public NamingSystemType getKind() { 
980      return this.kind == null ? null : this.kind.getValue();
981    }
982
983    /**
984     * @param value Indicates the purpose for the naming system - what kinds of things does it make unique?
985     */
986    public NamingSystem setKind(NamingSystemType value) { 
987        if (this.kind == null)
988          this.kind = new Enumeration<NamingSystemType>(new NamingSystemTypeEnumFactory());
989        this.kind.setValue(value);
990      return this;
991    }
992
993    /**
994     * @return {@link #publisher} (The name of the individual or organization that published the naming system.). This is the underlying object with id, value and extensions. The accessor "getPublisher" gives direct access to the value
995     */
996    public StringType getPublisherElement() { 
997      if (this.publisher == null)
998        if (Configuration.errorOnAutoCreate())
999          throw new Error("Attempt to auto-create NamingSystem.publisher");
1000        else if (Configuration.doAutoCreate())
1001          this.publisher = new StringType(); // bb
1002      return this.publisher;
1003    }
1004
1005    public boolean hasPublisherElement() { 
1006      return this.publisher != null && !this.publisher.isEmpty();
1007    }
1008
1009    public boolean hasPublisher() { 
1010      return this.publisher != null && !this.publisher.isEmpty();
1011    }
1012
1013    /**
1014     * @param value {@link #publisher} (The name of the individual or organization that published the naming system.). This is the underlying object with id, value and extensions. The accessor "getPublisher" gives direct access to the value
1015     */
1016    public NamingSystem setPublisherElement(StringType value) { 
1017      this.publisher = value;
1018      return this;
1019    }
1020
1021    /**
1022     * @return The name of the individual or organization that published the naming system.
1023     */
1024    public String getPublisher() { 
1025      return this.publisher == null ? null : this.publisher.getValue();
1026    }
1027
1028    /**
1029     * @param value The name of the individual or organization that published the naming system.
1030     */
1031    public NamingSystem setPublisher(String value) { 
1032      if (Utilities.noString(value))
1033        this.publisher = null;
1034      else {
1035        if (this.publisher == null)
1036          this.publisher = new StringType();
1037        this.publisher.setValue(value);
1038      }
1039      return this;
1040    }
1041
1042    /**
1043     * @return {@link #contact} (Contacts to assist a user in finding and communicating with the publisher.)
1044     */
1045    public List<NamingSystemContactComponent> getContact() { 
1046      if (this.contact == null)
1047        this.contact = new ArrayList<NamingSystemContactComponent>();
1048      return this.contact;
1049    }
1050
1051    public boolean hasContact() { 
1052      if (this.contact == null)
1053        return false;
1054      for (NamingSystemContactComponent item : this.contact)
1055        if (!item.isEmpty())
1056          return true;
1057      return false;
1058    }
1059
1060    /**
1061     * @return {@link #contact} (Contacts to assist a user in finding and communicating with the publisher.)
1062     */
1063    // syntactic sugar
1064    public NamingSystemContactComponent addContact() { //3
1065      NamingSystemContactComponent t = new NamingSystemContactComponent();
1066      if (this.contact == null)
1067        this.contact = new ArrayList<NamingSystemContactComponent>();
1068      this.contact.add(t);
1069      return t;
1070    }
1071
1072    // syntactic sugar
1073    public NamingSystem addContact(NamingSystemContactComponent t) { //3
1074      if (t == null)
1075        return this;
1076      if (this.contact == null)
1077        this.contact = new ArrayList<NamingSystemContactComponent>();
1078      this.contact.add(t);
1079      return this;
1080    }
1081
1082    /**
1083     * @return {@link #responsible} (The name of the organization that is responsible for issuing identifiers or codes for this namespace and ensuring their non-collision.). This is the underlying object with id, value and extensions. The accessor "getResponsible" gives direct access to the value
1084     */
1085    public StringType getResponsibleElement() { 
1086      if (this.responsible == null)
1087        if (Configuration.errorOnAutoCreate())
1088          throw new Error("Attempt to auto-create NamingSystem.responsible");
1089        else if (Configuration.doAutoCreate())
1090          this.responsible = new StringType(); // bb
1091      return this.responsible;
1092    }
1093
1094    public boolean hasResponsibleElement() { 
1095      return this.responsible != null && !this.responsible.isEmpty();
1096    }
1097
1098    public boolean hasResponsible() { 
1099      return this.responsible != null && !this.responsible.isEmpty();
1100    }
1101
1102    /**
1103     * @param value {@link #responsible} (The name of the organization that is responsible for issuing identifiers or codes for this namespace and ensuring their non-collision.). This is the underlying object with id, value and extensions. The accessor "getResponsible" gives direct access to the value
1104     */
1105    public NamingSystem setResponsibleElement(StringType value) { 
1106      this.responsible = value;
1107      return this;
1108    }
1109
1110    /**
1111     * @return The name of the organization that is responsible for issuing identifiers or codes for this namespace and ensuring their non-collision.
1112     */
1113    public String getResponsible() { 
1114      return this.responsible == null ? null : this.responsible.getValue();
1115    }
1116
1117    /**
1118     * @param value The name of the organization that is responsible for issuing identifiers or codes for this namespace and ensuring their non-collision.
1119     */
1120    public NamingSystem setResponsible(String value) { 
1121      if (Utilities.noString(value))
1122        this.responsible = null;
1123      else {
1124        if (this.responsible == null)
1125          this.responsible = new StringType();
1126        this.responsible.setValue(value);
1127      }
1128      return this;
1129    }
1130
1131    /**
1132     * @return {@link #date} (The date  (and optionally time) when the system was registered or 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 registration changes.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
1133     */
1134    public DateTimeType getDateElement() { 
1135      if (this.date == null)
1136        if (Configuration.errorOnAutoCreate())
1137          throw new Error("Attempt to auto-create NamingSystem.date");
1138        else if (Configuration.doAutoCreate())
1139          this.date = new DateTimeType(); // bb
1140      return this.date;
1141    }
1142
1143    public boolean hasDateElement() { 
1144      return this.date != null && !this.date.isEmpty();
1145    }
1146
1147    public boolean hasDate() { 
1148      return this.date != null && !this.date.isEmpty();
1149    }
1150
1151    /**
1152     * @param value {@link #date} (The date  (and optionally time) when the system was registered or 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 registration changes.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
1153     */
1154    public NamingSystem setDateElement(DateTimeType value) { 
1155      this.date = value;
1156      return this;
1157    }
1158
1159    /**
1160     * @return The date  (and optionally time) when the system was registered or 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 registration changes.
1161     */
1162    public Date getDate() { 
1163      return this.date == null ? null : this.date.getValue();
1164    }
1165
1166    /**
1167     * @param value The date  (and optionally time) when the system was registered or 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 registration changes.
1168     */
1169    public NamingSystem setDate(Date value) { 
1170        if (this.date == null)
1171          this.date = new DateTimeType();
1172        this.date.setValue(value);
1173      return this;
1174    }
1175
1176    /**
1177     * @return {@link #type} (Categorizes a naming system for easier search by grouping related naming systems.)
1178     */
1179    public CodeableConcept getType() { 
1180      if (this.type == null)
1181        if (Configuration.errorOnAutoCreate())
1182          throw new Error("Attempt to auto-create NamingSystem.type");
1183        else if (Configuration.doAutoCreate())
1184          this.type = new CodeableConcept(); // cc
1185      return this.type;
1186    }
1187
1188    public boolean hasType() { 
1189      return this.type != null && !this.type.isEmpty();
1190    }
1191
1192    /**
1193     * @param value {@link #type} (Categorizes a naming system for easier search by grouping related naming systems.)
1194     */
1195    public NamingSystem setType(CodeableConcept value) { 
1196      this.type = value;
1197      return this;
1198    }
1199
1200    /**
1201     * @return {@link #description} (Details about what the namespace identifies including scope, granularity, version labeling, etc.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
1202     */
1203    public StringType getDescriptionElement() { 
1204      if (this.description == null)
1205        if (Configuration.errorOnAutoCreate())
1206          throw new Error("Attempt to auto-create NamingSystem.description");
1207        else if (Configuration.doAutoCreate())
1208          this.description = new StringType(); // bb
1209      return this.description;
1210    }
1211
1212    public boolean hasDescriptionElement() { 
1213      return this.description != null && !this.description.isEmpty();
1214    }
1215
1216    public boolean hasDescription() { 
1217      return this.description != null && !this.description.isEmpty();
1218    }
1219
1220    /**
1221     * @param value {@link #description} (Details about what the namespace identifies including scope, granularity, version labeling, etc.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
1222     */
1223    public NamingSystem setDescriptionElement(StringType value) { 
1224      this.description = value;
1225      return this;
1226    }
1227
1228    /**
1229     * @return Details about what the namespace identifies including scope, granularity, version labeling, etc.
1230     */
1231    public String getDescription() { 
1232      return this.description == null ? null : this.description.getValue();
1233    }
1234
1235    /**
1236     * @param value Details about what the namespace identifies including scope, granularity, version labeling, etc.
1237     */
1238    public NamingSystem setDescription(String value) { 
1239      if (Utilities.noString(value))
1240        this.description = null;
1241      else {
1242        if (this.description == null)
1243          this.description = new StringType();
1244        this.description.setValue(value);
1245      }
1246      return this;
1247    }
1248
1249    /**
1250     * @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 naming systems.)
1251     */
1252    public List<CodeableConcept> getUseContext() { 
1253      if (this.useContext == null)
1254        this.useContext = new ArrayList<CodeableConcept>();
1255      return this.useContext;
1256    }
1257
1258    public boolean hasUseContext() { 
1259      if (this.useContext == null)
1260        return false;
1261      for (CodeableConcept item : this.useContext)
1262        if (!item.isEmpty())
1263          return true;
1264      return false;
1265    }
1266
1267    /**
1268     * @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 naming systems.)
1269     */
1270    // syntactic sugar
1271    public CodeableConcept addUseContext() { //3
1272      CodeableConcept t = new CodeableConcept();
1273      if (this.useContext == null)
1274        this.useContext = new ArrayList<CodeableConcept>();
1275      this.useContext.add(t);
1276      return t;
1277    }
1278
1279    // syntactic sugar
1280    public NamingSystem addUseContext(CodeableConcept t) { //3
1281      if (t == null)
1282        return this;
1283      if (this.useContext == null)
1284        this.useContext = new ArrayList<CodeableConcept>();
1285      this.useContext.add(t);
1286      return this;
1287    }
1288
1289    /**
1290     * @return {@link #usage} (Provides guidance on the use of the namespace, including the handling of formatting characters, use of upper vs. lower case, etc.). This is the underlying object with id, value and extensions. The accessor "getUsage" gives direct access to the value
1291     */
1292    public StringType getUsageElement() { 
1293      if (this.usage == null)
1294        if (Configuration.errorOnAutoCreate())
1295          throw new Error("Attempt to auto-create NamingSystem.usage");
1296        else if (Configuration.doAutoCreate())
1297          this.usage = new StringType(); // bb
1298      return this.usage;
1299    }
1300
1301    public boolean hasUsageElement() { 
1302      return this.usage != null && !this.usage.isEmpty();
1303    }
1304
1305    public boolean hasUsage() { 
1306      return this.usage != null && !this.usage.isEmpty();
1307    }
1308
1309    /**
1310     * @param value {@link #usage} (Provides guidance on the use of the namespace, including the handling of formatting characters, use of upper vs. lower case, etc.). This is the underlying object with id, value and extensions. The accessor "getUsage" gives direct access to the value
1311     */
1312    public NamingSystem setUsageElement(StringType value) { 
1313      this.usage = value;
1314      return this;
1315    }
1316
1317    /**
1318     * @return Provides guidance on the use of the namespace, including the handling of formatting characters, use of upper vs. lower case, etc.
1319     */
1320    public String getUsage() { 
1321      return this.usage == null ? null : this.usage.getValue();
1322    }
1323
1324    /**
1325     * @param value Provides guidance on the use of the namespace, including the handling of formatting characters, use of upper vs. lower case, etc.
1326     */
1327    public NamingSystem setUsage(String value) { 
1328      if (Utilities.noString(value))
1329        this.usage = null;
1330      else {
1331        if (this.usage == null)
1332          this.usage = new StringType();
1333        this.usage.setValue(value);
1334      }
1335      return this;
1336    }
1337
1338    /**
1339     * @return {@link #uniqueId} (Indicates how the system may be identified when referenced in electronic exchange.)
1340     */
1341    public List<NamingSystemUniqueIdComponent> getUniqueId() { 
1342      if (this.uniqueId == null)
1343        this.uniqueId = new ArrayList<NamingSystemUniqueIdComponent>();
1344      return this.uniqueId;
1345    }
1346
1347    public boolean hasUniqueId() { 
1348      if (this.uniqueId == null)
1349        return false;
1350      for (NamingSystemUniqueIdComponent item : this.uniqueId)
1351        if (!item.isEmpty())
1352          return true;
1353      return false;
1354    }
1355
1356    /**
1357     * @return {@link #uniqueId} (Indicates how the system may be identified when referenced in electronic exchange.)
1358     */
1359    // syntactic sugar
1360    public NamingSystemUniqueIdComponent addUniqueId() { //3
1361      NamingSystemUniqueIdComponent t = new NamingSystemUniqueIdComponent();
1362      if (this.uniqueId == null)
1363        this.uniqueId = new ArrayList<NamingSystemUniqueIdComponent>();
1364      this.uniqueId.add(t);
1365      return t;
1366    }
1367
1368    // syntactic sugar
1369    public NamingSystem addUniqueId(NamingSystemUniqueIdComponent t) { //3
1370      if (t == null)
1371        return this;
1372      if (this.uniqueId == null)
1373        this.uniqueId = new ArrayList<NamingSystemUniqueIdComponent>();
1374      this.uniqueId.add(t);
1375      return this;
1376    }
1377
1378    /**
1379     * @return {@link #replacedBy} (For naming systems that are retired, indicates the naming system that should be used in their place (if any).)
1380     */
1381    public Reference getReplacedBy() { 
1382      if (this.replacedBy == null)
1383        if (Configuration.errorOnAutoCreate())
1384          throw new Error("Attempt to auto-create NamingSystem.replacedBy");
1385        else if (Configuration.doAutoCreate())
1386          this.replacedBy = new Reference(); // cc
1387      return this.replacedBy;
1388    }
1389
1390    public boolean hasReplacedBy() { 
1391      return this.replacedBy != null && !this.replacedBy.isEmpty();
1392    }
1393
1394    /**
1395     * @param value {@link #replacedBy} (For naming systems that are retired, indicates the naming system that should be used in their place (if any).)
1396     */
1397    public NamingSystem setReplacedBy(Reference value) { 
1398      this.replacedBy = value;
1399      return this;
1400    }
1401
1402    /**
1403     * @return {@link #replacedBy} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (For naming systems that are retired, indicates the naming system that should be used in their place (if any).)
1404     */
1405    public NamingSystem getReplacedByTarget() { 
1406      if (this.replacedByTarget == null)
1407        if (Configuration.errorOnAutoCreate())
1408          throw new Error("Attempt to auto-create NamingSystem.replacedBy");
1409        else if (Configuration.doAutoCreate())
1410          this.replacedByTarget = new NamingSystem(); // aa
1411      return this.replacedByTarget;
1412    }
1413
1414    /**
1415     * @param value {@link #replacedBy} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (For naming systems that are retired, indicates the naming system that should be used in their place (if any).)
1416     */
1417    public NamingSystem setReplacedByTarget(NamingSystem value) { 
1418      this.replacedByTarget = value;
1419      return this;
1420    }
1421
1422      protected void listChildren(List<Property> childrenList) {
1423        super.listChildren(childrenList);
1424        childrenList.add(new Property("name", "string", "The descriptive name of this particular identifier type or code system.", 0, java.lang.Integer.MAX_VALUE, name));
1425        childrenList.add(new Property("status", "code", "Indicates whether the naming system is \"ready for use\" or not.", 0, java.lang.Integer.MAX_VALUE, status));
1426        childrenList.add(new Property("kind", "code", "Indicates the purpose for the naming system - what kinds of things does it make unique?", 0, java.lang.Integer.MAX_VALUE, kind));
1427        childrenList.add(new Property("publisher", "string", "The name of the individual or organization that published the naming system.", 0, java.lang.Integer.MAX_VALUE, publisher));
1428        childrenList.add(new Property("contact", "", "Contacts to assist a user in finding and communicating with the publisher.", 0, java.lang.Integer.MAX_VALUE, contact));
1429        childrenList.add(new Property("responsible", "string", "The name of the organization that is responsible for issuing identifiers or codes for this namespace and ensuring their non-collision.", 0, java.lang.Integer.MAX_VALUE, responsible));
1430        childrenList.add(new Property("date", "dateTime", "The date  (and optionally time) when the system was registered or 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 registration changes.", 0, java.lang.Integer.MAX_VALUE, date));
1431        childrenList.add(new Property("type", "CodeableConcept", "Categorizes a naming system for easier search by grouping related naming systems.", 0, java.lang.Integer.MAX_VALUE, type));
1432        childrenList.add(new Property("description", "string", "Details about what the namespace identifies including scope, granularity, version labeling, etc.", 0, java.lang.Integer.MAX_VALUE, description));
1433        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 naming systems.", 0, java.lang.Integer.MAX_VALUE, useContext));
1434        childrenList.add(new Property("usage", "string", "Provides guidance on the use of the namespace, including the handling of formatting characters, use of upper vs. lower case, etc.", 0, java.lang.Integer.MAX_VALUE, usage));
1435        childrenList.add(new Property("uniqueId", "", "Indicates how the system may be identified when referenced in electronic exchange.", 0, java.lang.Integer.MAX_VALUE, uniqueId));
1436        childrenList.add(new Property("replacedBy", "Reference(NamingSystem)", "For naming systems that are retired, indicates the naming system that should be used in their place (if any).", 0, java.lang.Integer.MAX_VALUE, replacedBy));
1437      }
1438
1439      @Override
1440      public void setProperty(String name, Base value) throws FHIRException {
1441        if (name.equals("name"))
1442          this.name = castToString(value); // StringType
1443        else if (name.equals("status"))
1444          this.status = new ConformanceResourceStatusEnumFactory().fromType(value); // Enumeration<ConformanceResourceStatus>
1445        else if (name.equals("kind"))
1446          this.kind = new NamingSystemTypeEnumFactory().fromType(value); // Enumeration<NamingSystemType>
1447        else if (name.equals("publisher"))
1448          this.publisher = castToString(value); // StringType
1449        else if (name.equals("contact"))
1450          this.getContact().add((NamingSystemContactComponent) value);
1451        else if (name.equals("responsible"))
1452          this.responsible = castToString(value); // StringType
1453        else if (name.equals("date"))
1454          this.date = castToDateTime(value); // DateTimeType
1455        else if (name.equals("type"))
1456          this.type = castToCodeableConcept(value); // CodeableConcept
1457        else if (name.equals("description"))
1458          this.description = castToString(value); // StringType
1459        else if (name.equals("useContext"))
1460          this.getUseContext().add(castToCodeableConcept(value));
1461        else if (name.equals("usage"))
1462          this.usage = castToString(value); // StringType
1463        else if (name.equals("uniqueId"))
1464          this.getUniqueId().add((NamingSystemUniqueIdComponent) value);
1465        else if (name.equals("replacedBy"))
1466          this.replacedBy = castToReference(value); // Reference
1467        else
1468          super.setProperty(name, value);
1469      }
1470
1471      @Override
1472      public Base addChild(String name) throws FHIRException {
1473        if (name.equals("name")) {
1474          throw new FHIRException("Cannot call addChild on a primitive type NamingSystem.name");
1475        }
1476        else if (name.equals("status")) {
1477          throw new FHIRException("Cannot call addChild on a primitive type NamingSystem.status");
1478        }
1479        else if (name.equals("kind")) {
1480          throw new FHIRException("Cannot call addChild on a primitive type NamingSystem.kind");
1481        }
1482        else if (name.equals("publisher")) {
1483          throw new FHIRException("Cannot call addChild on a primitive type NamingSystem.publisher");
1484        }
1485        else if (name.equals("contact")) {
1486          return addContact();
1487        }
1488        else if (name.equals("responsible")) {
1489          throw new FHIRException("Cannot call addChild on a primitive type NamingSystem.responsible");
1490        }
1491        else if (name.equals("date")) {
1492          throw new FHIRException("Cannot call addChild on a primitive type NamingSystem.date");
1493        }
1494        else if (name.equals("type")) {
1495          this.type = new CodeableConcept();
1496          return this.type;
1497        }
1498        else if (name.equals("description")) {
1499          throw new FHIRException("Cannot call addChild on a primitive type NamingSystem.description");
1500        }
1501        else if (name.equals("useContext")) {
1502          return addUseContext();
1503        }
1504        else if (name.equals("usage")) {
1505          throw new FHIRException("Cannot call addChild on a primitive type NamingSystem.usage");
1506        }
1507        else if (name.equals("uniqueId")) {
1508          return addUniqueId();
1509        }
1510        else if (name.equals("replacedBy")) {
1511          this.replacedBy = new Reference();
1512          return this.replacedBy;
1513        }
1514        else
1515          return super.addChild(name);
1516      }
1517
1518  public String fhirType() {
1519    return "NamingSystem";
1520
1521  }
1522
1523      public NamingSystem copy() {
1524        NamingSystem dst = new NamingSystem();
1525        copyValues(dst);
1526        dst.name = name == null ? null : name.copy();
1527        dst.status = status == null ? null : status.copy();
1528        dst.kind = kind == null ? null : kind.copy();
1529        dst.publisher = publisher == null ? null : publisher.copy();
1530        if (contact != null) {
1531          dst.contact = new ArrayList<NamingSystemContactComponent>();
1532          for (NamingSystemContactComponent i : contact)
1533            dst.contact.add(i.copy());
1534        };
1535        dst.responsible = responsible == null ? null : responsible.copy();
1536        dst.date = date == null ? null : date.copy();
1537        dst.type = type == null ? null : type.copy();
1538        dst.description = description == null ? null : description.copy();
1539        if (useContext != null) {
1540          dst.useContext = new ArrayList<CodeableConcept>();
1541          for (CodeableConcept i : useContext)
1542            dst.useContext.add(i.copy());
1543        };
1544        dst.usage = usage == null ? null : usage.copy();
1545        if (uniqueId != null) {
1546          dst.uniqueId = new ArrayList<NamingSystemUniqueIdComponent>();
1547          for (NamingSystemUniqueIdComponent i : uniqueId)
1548            dst.uniqueId.add(i.copy());
1549        };
1550        dst.replacedBy = replacedBy == null ? null : replacedBy.copy();
1551        return dst;
1552      }
1553
1554      protected NamingSystem typedCopy() {
1555        return copy();
1556      }
1557
1558      @Override
1559      public boolean equalsDeep(Base other) {
1560        if (!super.equalsDeep(other))
1561          return false;
1562        if (!(other instanceof NamingSystem))
1563          return false;
1564        NamingSystem o = (NamingSystem) other;
1565        return compareDeep(name, o.name, true) && compareDeep(status, o.status, true) && compareDeep(kind, o.kind, true)
1566           && compareDeep(publisher, o.publisher, true) && compareDeep(contact, o.contact, true) && compareDeep(responsible, o.responsible, true)
1567           && compareDeep(date, o.date, true) && compareDeep(type, o.type, true) && compareDeep(description, o.description, true)
1568           && compareDeep(useContext, o.useContext, true) && compareDeep(usage, o.usage, true) && compareDeep(uniqueId, o.uniqueId, true)
1569           && compareDeep(replacedBy, o.replacedBy, true);
1570      }
1571
1572      @Override
1573      public boolean equalsShallow(Base other) {
1574        if (!super.equalsShallow(other))
1575          return false;
1576        if (!(other instanceof NamingSystem))
1577          return false;
1578        NamingSystem o = (NamingSystem) other;
1579        return compareValues(name, o.name, true) && compareValues(status, o.status, true) && compareValues(kind, o.kind, true)
1580           && compareValues(publisher, o.publisher, true) && compareValues(responsible, o.responsible, true) && compareValues(date, o.date, true)
1581           && compareValues(description, o.description, true) && compareValues(usage, o.usage, true);
1582      }
1583
1584      public boolean isEmpty() {
1585        return super.isEmpty() && (name == null || name.isEmpty()) && (status == null || status.isEmpty())
1586           && (kind == null || kind.isEmpty()) && (publisher == null || publisher.isEmpty()) && (contact == null || contact.isEmpty())
1587           && (responsible == null || responsible.isEmpty()) && (date == null || date.isEmpty()) && (type == null || type.isEmpty())
1588           && (description == null || description.isEmpty()) && (useContext == null || useContext.isEmpty())
1589           && (usage == null || usage.isEmpty()) && (uniqueId == null || uniqueId.isEmpty()) && (replacedBy == null || replacedBy.isEmpty())
1590          ;
1591      }
1592
1593  @Override
1594  public ResourceType getResourceType() {
1595    return ResourceType.NamingSystem;
1596   }
1597
1598  @SearchParamDefinition(name="date", path="NamingSystem.date", description="Publication Date(/time)", type="date" )
1599  public static final String SP_DATE = "date";
1600  @SearchParamDefinition(name="period", path="NamingSystem.uniqueId.period", description="When is identifier valid?", type="date" )
1601  public static final String SP_PERIOD = "period";
1602  @SearchParamDefinition(name="kind", path="NamingSystem.kind", description="codesystem | identifier | root", type="token" )
1603  public static final String SP_KIND = "kind";
1604  @SearchParamDefinition(name="type", path="NamingSystem.type", description="e.g. driver,  provider,  patient, bank etc.", type="token" )
1605  public static final String SP_TYPE = "type";
1606  @SearchParamDefinition(name="id-type", path="NamingSystem.uniqueId.type", description="oid | uuid | uri | other", type="token" )
1607  public static final String SP_IDTYPE = "id-type";
1608  @SearchParamDefinition(name="responsible", path="NamingSystem.responsible", description="Who maintains system namespace?", type="string" )
1609  public static final String SP_RESPONSIBLE = "responsible";
1610  @SearchParamDefinition(name="contact", path="NamingSystem.contact.name", description="Name of a individual to contact", type="string" )
1611  public static final String SP_CONTACT = "contact";
1612  @SearchParamDefinition(name="name", path="NamingSystem.name", description="Human-readable label", type="string" )
1613  public static final String SP_NAME = "name";
1614  @SearchParamDefinition(name="context", path="NamingSystem.useContext", description="Content intends to support these contexts", type="token" )
1615  public static final String SP_CONTEXT = "context";
1616  @SearchParamDefinition(name="publisher", path="NamingSystem.publisher", description="Name of the publisher (Organization or individual)", type="string" )
1617  public static final String SP_PUBLISHER = "publisher";
1618  @SearchParamDefinition(name="telecom", path="NamingSystem.contact.telecom", description="Contact details for individual or publisher", type="token" )
1619  public static final String SP_TELECOM = "telecom";
1620  @SearchParamDefinition(name="value", path="NamingSystem.uniqueId.value", description="The unique identifier", type="string" )
1621  public static final String SP_VALUE = "value";
1622  @SearchParamDefinition(name="replaced-by", path="NamingSystem.replacedBy", description="Use this instead", type="reference" )
1623  public static final String SP_REPLACEDBY = "replaced-by";
1624  @SearchParamDefinition(name="status", path="NamingSystem.status", description="draft | active | retired", type="token" )
1625  public static final String SP_STATUS = "status";
1626
1627}
1628