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