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