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