001package org.hl7.fhir.r4b.model;
002
003
004/*
005  Copyright (c) 2011+, HL7, Inc.
006  All rights reserved.
007  
008  Redistribution and use in source and binary forms, with or without modification, \
009  are permitted provided that the following conditions are met:
010  
011   * Redistributions of source code must retain the above copyright notice, this \
012     list of conditions and the following disclaimer.
013   * Redistributions in binary form must reproduce the above copyright notice, \
014     this list of conditions and the following disclaimer in the documentation \
015     and/or other materials provided with the distribution.
016   * Neither the name of HL7 nor the names of its contributors may be used to 
017     endorse or promote products derived from this software without specific 
018     prior written permission.
019  
020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
021  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
022  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
023  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
024  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
025  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
026  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
027  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
028  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
029  POSSIBILITY OF SUCH DAMAGE.
030  */
031
032// Generated on Fri, Dec 31, 2021 05:58+1100 for FHIR v4.3.0-snapshot1
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import org.hl7.fhir.utilities.Utilities;
038import org.hl7.fhir.r4b.model.Enumerations.*;
039import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
040import org.hl7.fhir.exceptions.FHIRException;
041import org.hl7.fhir.instance.model.api.ICompositeType;
042import ca.uhn.fhir.model.api.annotation.Child;
043import ca.uhn.fhir.model.api.annotation.ChildOrder;
044import ca.uhn.fhir.model.api.annotation.DatatypeDef;
045import ca.uhn.fhir.model.api.annotation.Description;
046import ca.uhn.fhir.model.api.annotation.Block;
047
048/**
049 * Base StructureDefinition for RelatedArtifact Type: Related artifacts such as additional documentation, justification, or bibliographic references.
050 */
051@DatatypeDef(name="RelatedArtifact")
052public class RelatedArtifact extends DataType implements ICompositeType {
053
054    public enum RelatedArtifactType {
055        /**
056         * Additional documentation for the knowledge resource. This would include additional instructions on usage as well as additional information on clinical context or appropriateness.
057         */
058        DOCUMENTATION, 
059        /**
060         * A summary of the justification for the knowledge resource including supporting evidence, relevant guidelines, or other clinically important information. This information is intended to provide a way to make the justification for the knowledge resource available to the consumer of interventions or results produced by the knowledge resource.
061         */
062        JUSTIFICATION, 
063        /**
064         * Bibliographic citation for papers, references, or other relevant material for the knowledge resource. This is intended to allow for citation of related material, but that was not necessarily specifically prepared in connection with this knowledge resource.
065         */
066        CITATION, 
067        /**
068         * The previous version of the knowledge resource.
069         */
070        PREDECESSOR, 
071        /**
072         * The next version of the knowledge resource.
073         */
074        SUCCESSOR, 
075        /**
076         * The knowledge resource is derived from the related artifact. This is intended to capture the relationship in which a particular knowledge resource is based on the content of another artifact, but is modified to capture either a different set of overall requirements, or a more specific set of requirements such as those involved in a particular institution or clinical setting.
077         */
078        DERIVEDFROM, 
079        /**
080         * The knowledge resource depends on the given related artifact.
081         */
082        DEPENDSON, 
083        /**
084         * The knowledge resource is composed of the given related artifact.
085         */
086        COMPOSEDOF, 
087        /**
088         * added to help the parsers with the generic types
089         */
090        NULL;
091        public static RelatedArtifactType fromCode(String codeString) throws FHIRException {
092            if (codeString == null || "".equals(codeString))
093                return null;
094        if ("documentation".equals(codeString))
095          return DOCUMENTATION;
096        if ("justification".equals(codeString))
097          return JUSTIFICATION;
098        if ("citation".equals(codeString))
099          return CITATION;
100        if ("predecessor".equals(codeString))
101          return PREDECESSOR;
102        if ("successor".equals(codeString))
103          return SUCCESSOR;
104        if ("derived-from".equals(codeString))
105          return DERIVEDFROM;
106        if ("depends-on".equals(codeString))
107          return DEPENDSON;
108        if ("composed-of".equals(codeString))
109          return COMPOSEDOF;
110        if (Configuration.isAcceptInvalidEnums())
111          return null;
112        else
113          throw new FHIRException("Unknown RelatedArtifactType code '"+codeString+"'");
114        }
115        public String toCode() {
116          switch (this) {
117            case DOCUMENTATION: return "documentation";
118            case JUSTIFICATION: return "justification";
119            case CITATION: return "citation";
120            case PREDECESSOR: return "predecessor";
121            case SUCCESSOR: return "successor";
122            case DERIVEDFROM: return "derived-from";
123            case DEPENDSON: return "depends-on";
124            case COMPOSEDOF: return "composed-of";
125            case NULL: return null;
126            default: return "?";
127          }
128        }
129        public String getSystem() {
130          switch (this) {
131            case DOCUMENTATION: return "http://hl7.org/fhir/related-artifact-type";
132            case JUSTIFICATION: return "http://hl7.org/fhir/related-artifact-type";
133            case CITATION: return "http://hl7.org/fhir/related-artifact-type";
134            case PREDECESSOR: return "http://hl7.org/fhir/related-artifact-type";
135            case SUCCESSOR: return "http://hl7.org/fhir/related-artifact-type";
136            case DERIVEDFROM: return "http://hl7.org/fhir/related-artifact-type";
137            case DEPENDSON: return "http://hl7.org/fhir/related-artifact-type";
138            case COMPOSEDOF: return "http://hl7.org/fhir/related-artifact-type";
139            case NULL: return null;
140            default: return "?";
141          }
142        }
143        public String getDefinition() {
144          switch (this) {
145            case DOCUMENTATION: return "Additional documentation for the knowledge resource. This would include additional instructions on usage as well as additional information on clinical context or appropriateness.";
146            case JUSTIFICATION: return "A summary of the justification for the knowledge resource including supporting evidence, relevant guidelines, or other clinically important information. This information is intended to provide a way to make the justification for the knowledge resource available to the consumer of interventions or results produced by the knowledge resource.";
147            case CITATION: return "Bibliographic citation for papers, references, or other relevant material for the knowledge resource. This is intended to allow for citation of related material, but that was not necessarily specifically prepared in connection with this knowledge resource.";
148            case PREDECESSOR: return "The previous version of the knowledge resource.";
149            case SUCCESSOR: return "The next version of the knowledge resource.";
150            case DERIVEDFROM: return "The knowledge resource is derived from the related artifact. This is intended to capture the relationship in which a particular knowledge resource is based on the content of another artifact, but is modified to capture either a different set of overall requirements, or a more specific set of requirements such as those involved in a particular institution or clinical setting.";
151            case DEPENDSON: return "The knowledge resource depends on the given related artifact.";
152            case COMPOSEDOF: return "The knowledge resource is composed of the given related artifact.";
153            case NULL: return null;
154            default: return "?";
155          }
156        }
157        public String getDisplay() {
158          switch (this) {
159            case DOCUMENTATION: return "Documentation";
160            case JUSTIFICATION: return "Justification";
161            case CITATION: return "Citation";
162            case PREDECESSOR: return "Predecessor";
163            case SUCCESSOR: return "Successor";
164            case DERIVEDFROM: return "Derived From";
165            case DEPENDSON: return "Depends On";
166            case COMPOSEDOF: return "Composed Of";
167            case NULL: return null;
168            default: return "?";
169          }
170        }
171    }
172
173  public static class RelatedArtifactTypeEnumFactory implements EnumFactory<RelatedArtifactType> {
174    public RelatedArtifactType fromCode(String codeString) throws IllegalArgumentException {
175      if (codeString == null || "".equals(codeString))
176            if (codeString == null || "".equals(codeString))
177                return null;
178        if ("documentation".equals(codeString))
179          return RelatedArtifactType.DOCUMENTATION;
180        if ("justification".equals(codeString))
181          return RelatedArtifactType.JUSTIFICATION;
182        if ("citation".equals(codeString))
183          return RelatedArtifactType.CITATION;
184        if ("predecessor".equals(codeString))
185          return RelatedArtifactType.PREDECESSOR;
186        if ("successor".equals(codeString))
187          return RelatedArtifactType.SUCCESSOR;
188        if ("derived-from".equals(codeString))
189          return RelatedArtifactType.DERIVEDFROM;
190        if ("depends-on".equals(codeString))
191          return RelatedArtifactType.DEPENDSON;
192        if ("composed-of".equals(codeString))
193          return RelatedArtifactType.COMPOSEDOF;
194        throw new IllegalArgumentException("Unknown RelatedArtifactType code '"+codeString+"'");
195        }
196        public Enumeration<RelatedArtifactType> fromType(Base code) throws FHIRException {
197          if (code == null)
198            return null;
199          if (code.isEmpty())
200            return new Enumeration<RelatedArtifactType>(this);
201          String codeString = ((PrimitiveType) code).asStringValue();
202          if (codeString == null || "".equals(codeString))
203            return null;
204        if ("documentation".equals(codeString))
205          return new Enumeration<RelatedArtifactType>(this, RelatedArtifactType.DOCUMENTATION);
206        if ("justification".equals(codeString))
207          return new Enumeration<RelatedArtifactType>(this, RelatedArtifactType.JUSTIFICATION);
208        if ("citation".equals(codeString))
209          return new Enumeration<RelatedArtifactType>(this, RelatedArtifactType.CITATION);
210        if ("predecessor".equals(codeString))
211          return new Enumeration<RelatedArtifactType>(this, RelatedArtifactType.PREDECESSOR);
212        if ("successor".equals(codeString))
213          return new Enumeration<RelatedArtifactType>(this, RelatedArtifactType.SUCCESSOR);
214        if ("derived-from".equals(codeString))
215          return new Enumeration<RelatedArtifactType>(this, RelatedArtifactType.DERIVEDFROM);
216        if ("depends-on".equals(codeString))
217          return new Enumeration<RelatedArtifactType>(this, RelatedArtifactType.DEPENDSON);
218        if ("composed-of".equals(codeString))
219          return new Enumeration<RelatedArtifactType>(this, RelatedArtifactType.COMPOSEDOF);
220        throw new FHIRException("Unknown RelatedArtifactType code '"+codeString+"'");
221        }
222    public String toCode(RelatedArtifactType code) {
223      if (code == RelatedArtifactType.DOCUMENTATION)
224        return "documentation";
225      if (code == RelatedArtifactType.JUSTIFICATION)
226        return "justification";
227      if (code == RelatedArtifactType.CITATION)
228        return "citation";
229      if (code == RelatedArtifactType.PREDECESSOR)
230        return "predecessor";
231      if (code == RelatedArtifactType.SUCCESSOR)
232        return "successor";
233      if (code == RelatedArtifactType.DERIVEDFROM)
234        return "derived-from";
235      if (code == RelatedArtifactType.DEPENDSON)
236        return "depends-on";
237      if (code == RelatedArtifactType.COMPOSEDOF)
238        return "composed-of";
239      return "?";
240      }
241    public String toSystem(RelatedArtifactType code) {
242      return code.getSystem();
243      }
244    }
245
246    /**
247     * The type of relationship to the related artifact.
248     */
249    @Child(name = "type", type = {CodeType.class}, order=0, min=1, max=1, modifier=false, summary=true)
250    @Description(shortDefinition="documentation | justification | citation | predecessor | successor | derived-from | depends-on | composed-of", formalDefinition="The type of relationship to the related artifact." )
251    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/related-artifact-type")
252    protected Enumeration<RelatedArtifactType> type;
253
254    /**
255     * A short label that can be used to reference the citation from elsewhere in the containing artifact, such as a footnote index.
256     */
257    @Child(name = "label", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
258    @Description(shortDefinition="Short label", formalDefinition="A short label that can be used to reference the citation from elsewhere in the containing artifact, such as a footnote index." )
259    protected StringType label;
260
261    /**
262     * A brief description of the document or knowledge resource being referenced, suitable for display to a consumer.
263     */
264    @Child(name = "display", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true)
265    @Description(shortDefinition="Brief description of the related artifact", formalDefinition="A brief description of the document or knowledge resource being referenced, suitable for display to a consumer." )
266    protected StringType display;
267
268    /**
269     * A bibliographic citation for the related artifact. This text SHOULD be formatted according to an accepted citation format.
270     */
271    @Child(name = "citation", type = {MarkdownType.class}, order=3, min=0, max=1, modifier=false, summary=true)
272    @Description(shortDefinition="Bibliographic citation for the artifact", formalDefinition="A bibliographic citation for the related artifact. This text SHOULD be formatted according to an accepted citation format." )
273    protected MarkdownType citation;
274
275    /**
276     * A url for the artifact that can be followed to access the actual content.
277     */
278    @Child(name = "url", type = {UrlType.class}, order=4, min=0, max=1, modifier=false, summary=true)
279    @Description(shortDefinition="Where the artifact can be accessed", formalDefinition="A url for the artifact that can be followed to access the actual content." )
280    protected UrlType url;
281
282    /**
283     * The document being referenced, represented as an attachment. This is exclusive with the resource element.
284     */
285    @Child(name = "document", type = {Attachment.class}, order=5, min=0, max=1, modifier=false, summary=true)
286    @Description(shortDefinition="What document is being referenced", formalDefinition="The document being referenced, represented as an attachment. This is exclusive with the resource element." )
287    protected Attachment document;
288
289    /**
290     * The related resource, such as a library, value set, profile, or other knowledge resource.
291     */
292    @Child(name = "resource", type = {CanonicalType.class}, order=6, min=0, max=1, modifier=false, summary=true)
293    @Description(shortDefinition="What resource is being referenced", formalDefinition="The related resource, such as a library, value set, profile, or other knowledge resource." )
294    protected CanonicalType resource;
295
296    private static final long serialVersionUID = -695743528L;
297
298  /**
299   * Constructor
300   */
301    public RelatedArtifact() {
302      super();
303    }
304
305  /**
306   * Constructor
307   */
308    public RelatedArtifact(RelatedArtifactType type) {
309      super();
310      this.setType(type);
311    }
312
313    /**
314     * @return {@link #type} (The type of relationship to the related artifact.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
315     */
316    public Enumeration<RelatedArtifactType> getTypeElement() { 
317      if (this.type == null)
318        if (Configuration.errorOnAutoCreate())
319          throw new Error("Attempt to auto-create RelatedArtifact.type");
320        else if (Configuration.doAutoCreate())
321          this.type = new Enumeration<RelatedArtifactType>(new RelatedArtifactTypeEnumFactory()); // bb
322      return this.type;
323    }
324
325    public boolean hasTypeElement() { 
326      return this.type != null && !this.type.isEmpty();
327    }
328
329    public boolean hasType() { 
330      return this.type != null && !this.type.isEmpty();
331    }
332
333    /**
334     * @param value {@link #type} (The type of relationship to the related artifact.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
335     */
336    public RelatedArtifact setTypeElement(Enumeration<RelatedArtifactType> value) { 
337      this.type = value;
338      return this;
339    }
340
341    /**
342     * @return The type of relationship to the related artifact.
343     */
344    public RelatedArtifactType getType() { 
345      return this.type == null ? null : this.type.getValue();
346    }
347
348    /**
349     * @param value The type of relationship to the related artifact.
350     */
351    public RelatedArtifact setType(RelatedArtifactType value) { 
352        if (this.type == null)
353          this.type = new Enumeration<RelatedArtifactType>(new RelatedArtifactTypeEnumFactory());
354        this.type.setValue(value);
355      return this;
356    }
357
358    /**
359     * @return {@link #label} (A short label that can be used to reference the citation from elsewhere in the containing artifact, such as a footnote index.). This is the underlying object with id, value and extensions. The accessor "getLabel" gives direct access to the value
360     */
361    public StringType getLabelElement() { 
362      if (this.label == null)
363        if (Configuration.errorOnAutoCreate())
364          throw new Error("Attempt to auto-create RelatedArtifact.label");
365        else if (Configuration.doAutoCreate())
366          this.label = new StringType(); // bb
367      return this.label;
368    }
369
370    public boolean hasLabelElement() { 
371      return this.label != null && !this.label.isEmpty();
372    }
373
374    public boolean hasLabel() { 
375      return this.label != null && !this.label.isEmpty();
376    }
377
378    /**
379     * @param value {@link #label} (A short label that can be used to reference the citation from elsewhere in the containing artifact, such as a footnote index.). This is the underlying object with id, value and extensions. The accessor "getLabel" gives direct access to the value
380     */
381    public RelatedArtifact setLabelElement(StringType value) { 
382      this.label = value;
383      return this;
384    }
385
386    /**
387     * @return A short label that can be used to reference the citation from elsewhere in the containing artifact, such as a footnote index.
388     */
389    public String getLabel() { 
390      return this.label == null ? null : this.label.getValue();
391    }
392
393    /**
394     * @param value A short label that can be used to reference the citation from elsewhere in the containing artifact, such as a footnote index.
395     */
396    public RelatedArtifact setLabel(String value) { 
397      if (Utilities.noString(value))
398        this.label = null;
399      else {
400        if (this.label == null)
401          this.label = new StringType();
402        this.label.setValue(value);
403      }
404      return this;
405    }
406
407    /**
408     * @return {@link #display} (A brief description of the document or knowledge resource being referenced, suitable for display to a consumer.). This is the underlying object with id, value and extensions. The accessor "getDisplay" gives direct access to the value
409     */
410    public StringType getDisplayElement() { 
411      if (this.display == null)
412        if (Configuration.errorOnAutoCreate())
413          throw new Error("Attempt to auto-create RelatedArtifact.display");
414        else if (Configuration.doAutoCreate())
415          this.display = new StringType(); // bb
416      return this.display;
417    }
418
419    public boolean hasDisplayElement() { 
420      return this.display != null && !this.display.isEmpty();
421    }
422
423    public boolean hasDisplay() { 
424      return this.display != null && !this.display.isEmpty();
425    }
426
427    /**
428     * @param value {@link #display} (A brief description of the document or knowledge resource being referenced, suitable for display to a consumer.). This is the underlying object with id, value and extensions. The accessor "getDisplay" gives direct access to the value
429     */
430    public RelatedArtifact setDisplayElement(StringType value) { 
431      this.display = value;
432      return this;
433    }
434
435    /**
436     * @return A brief description of the document or knowledge resource being referenced, suitable for display to a consumer.
437     */
438    public String getDisplay() { 
439      return this.display == null ? null : this.display.getValue();
440    }
441
442    /**
443     * @param value A brief description of the document or knowledge resource being referenced, suitable for display to a consumer.
444     */
445    public RelatedArtifact setDisplay(String value) { 
446      if (Utilities.noString(value))
447        this.display = null;
448      else {
449        if (this.display == null)
450          this.display = new StringType();
451        this.display.setValue(value);
452      }
453      return this;
454    }
455
456    /**
457     * @return {@link #citation} (A bibliographic citation for the related artifact. This text SHOULD be formatted according to an accepted citation format.). This is the underlying object with id, value and extensions. The accessor "getCitation" gives direct access to the value
458     */
459    public MarkdownType getCitationElement() { 
460      if (this.citation == null)
461        if (Configuration.errorOnAutoCreate())
462          throw new Error("Attempt to auto-create RelatedArtifact.citation");
463        else if (Configuration.doAutoCreate())
464          this.citation = new MarkdownType(); // bb
465      return this.citation;
466    }
467
468    public boolean hasCitationElement() { 
469      return this.citation != null && !this.citation.isEmpty();
470    }
471
472    public boolean hasCitation() { 
473      return this.citation != null && !this.citation.isEmpty();
474    }
475
476    /**
477     * @param value {@link #citation} (A bibliographic citation for the related artifact. This text SHOULD be formatted according to an accepted citation format.). This is the underlying object with id, value and extensions. The accessor "getCitation" gives direct access to the value
478     */
479    public RelatedArtifact setCitationElement(MarkdownType value) { 
480      this.citation = value;
481      return this;
482    }
483
484    /**
485     * @return A bibliographic citation for the related artifact. This text SHOULD be formatted according to an accepted citation format.
486     */
487    public String getCitation() { 
488      return this.citation == null ? null : this.citation.getValue();
489    }
490
491    /**
492     * @param value A bibliographic citation for the related artifact. This text SHOULD be formatted according to an accepted citation format.
493     */
494    public RelatedArtifact setCitation(String value) { 
495      if (value == null)
496        this.citation = null;
497      else {
498        if (this.citation == null)
499          this.citation = new MarkdownType();
500        this.citation.setValue(value);
501      }
502      return this;
503    }
504
505    /**
506     * @return {@link #url} (A url for the artifact that can be followed to access the actual content.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
507     */
508    public UrlType getUrlElement() { 
509      if (this.url == null)
510        if (Configuration.errorOnAutoCreate())
511          throw new Error("Attempt to auto-create RelatedArtifact.url");
512        else if (Configuration.doAutoCreate())
513          this.url = new UrlType(); // bb
514      return this.url;
515    }
516
517    public boolean hasUrlElement() { 
518      return this.url != null && !this.url.isEmpty();
519    }
520
521    public boolean hasUrl() { 
522      return this.url != null && !this.url.isEmpty();
523    }
524
525    /**
526     * @param value {@link #url} (A url for the artifact that can be followed to access the actual content.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
527     */
528    public RelatedArtifact setUrlElement(UrlType value) { 
529      this.url = value;
530      return this;
531    }
532
533    /**
534     * @return A url for the artifact that can be followed to access the actual content.
535     */
536    public String getUrl() { 
537      return this.url == null ? null : this.url.getValue();
538    }
539
540    /**
541     * @param value A url for the artifact that can be followed to access the actual content.
542     */
543    public RelatedArtifact setUrl(String value) { 
544      if (Utilities.noString(value))
545        this.url = null;
546      else {
547        if (this.url == null)
548          this.url = new UrlType();
549        this.url.setValue(value);
550      }
551      return this;
552    }
553
554    /**
555     * @return {@link #document} (The document being referenced, represented as an attachment. This is exclusive with the resource element.)
556     */
557    public Attachment getDocument() { 
558      if (this.document == null)
559        if (Configuration.errorOnAutoCreate())
560          throw new Error("Attempt to auto-create RelatedArtifact.document");
561        else if (Configuration.doAutoCreate())
562          this.document = new Attachment(); // cc
563      return this.document;
564    }
565
566    public boolean hasDocument() { 
567      return this.document != null && !this.document.isEmpty();
568    }
569
570    /**
571     * @param value {@link #document} (The document being referenced, represented as an attachment. This is exclusive with the resource element.)
572     */
573    public RelatedArtifact setDocument(Attachment value) { 
574      this.document = value;
575      return this;
576    }
577
578    /**
579     * @return {@link #resource} (The related resource, such as a library, value set, profile, or other knowledge resource.). This is the underlying object with id, value and extensions. The accessor "getResource" gives direct access to the value
580     */
581    public CanonicalType getResourceElement() { 
582      if (this.resource == null)
583        if (Configuration.errorOnAutoCreate())
584          throw new Error("Attempt to auto-create RelatedArtifact.resource");
585        else if (Configuration.doAutoCreate())
586          this.resource = new CanonicalType(); // bb
587      return this.resource;
588    }
589
590    public boolean hasResourceElement() { 
591      return this.resource != null && !this.resource.isEmpty();
592    }
593
594    public boolean hasResource() { 
595      return this.resource != null && !this.resource.isEmpty();
596    }
597
598    /**
599     * @param value {@link #resource} (The related resource, such as a library, value set, profile, or other knowledge resource.). This is the underlying object with id, value and extensions. The accessor "getResource" gives direct access to the value
600     */
601    public RelatedArtifact setResourceElement(CanonicalType value) { 
602      this.resource = value;
603      return this;
604    }
605
606    /**
607     * @return The related resource, such as a library, value set, profile, or other knowledge resource.
608     */
609    public String getResource() { 
610      return this.resource == null ? null : this.resource.getValue();
611    }
612
613    /**
614     * @param value The related resource, such as a library, value set, profile, or other knowledge resource.
615     */
616    public RelatedArtifact setResource(String value) { 
617      if (Utilities.noString(value))
618        this.resource = null;
619      else {
620        if (this.resource == null)
621          this.resource = new CanonicalType();
622        this.resource.setValue(value);
623      }
624      return this;
625    }
626
627      protected void listChildren(List<Property> children) {
628        super.listChildren(children);
629        children.add(new Property("type", "code", "The type of relationship to the related artifact.", 0, 1, type));
630        children.add(new Property("label", "string", "A short label that can be used to reference the citation from elsewhere in the containing artifact, such as a footnote index.", 0, 1, label));
631        children.add(new Property("display", "string", "A brief description of the document or knowledge resource being referenced, suitable for display to a consumer.", 0, 1, display));
632        children.add(new Property("citation", "markdown", "A bibliographic citation for the related artifact. This text SHOULD be formatted according to an accepted citation format.", 0, 1, citation));
633        children.add(new Property("url", "url", "A url for the artifact that can be followed to access the actual content.", 0, 1, url));
634        children.add(new Property("document", "Attachment", "The document being referenced, represented as an attachment. This is exclusive with the resource element.", 0, 1, document));
635        children.add(new Property("resource", "canonical(Any)", "The related resource, such as a library, value set, profile, or other knowledge resource.", 0, 1, resource));
636      }
637
638      @Override
639      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
640        switch (_hash) {
641        case 3575610: /*type*/  return new Property("type", "code", "The type of relationship to the related artifact.", 0, 1, type);
642        case 102727412: /*label*/  return new Property("label", "string", "A short label that can be used to reference the citation from elsewhere in the containing artifact, such as a footnote index.", 0, 1, label);
643        case 1671764162: /*display*/  return new Property("display", "string", "A brief description of the document or knowledge resource being referenced, suitable for display to a consumer.", 0, 1, display);
644        case -1442706713: /*citation*/  return new Property("citation", "markdown", "A bibliographic citation for the related artifact. This text SHOULD be formatted according to an accepted citation format.", 0, 1, citation);
645        case 116079: /*url*/  return new Property("url", "url", "A url for the artifact that can be followed to access the actual content.", 0, 1, url);
646        case 861720859: /*document*/  return new Property("document", "Attachment", "The document being referenced, represented as an attachment. This is exclusive with the resource element.", 0, 1, document);
647        case -341064690: /*resource*/  return new Property("resource", "canonical(Any)", "The related resource, such as a library, value set, profile, or other knowledge resource.", 0, 1, resource);
648        default: return super.getNamedProperty(_hash, _name, _checkValid);
649        }
650
651      }
652
653      @Override
654      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
655        switch (hash) {
656        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // Enumeration<RelatedArtifactType>
657        case 102727412: /*label*/ return this.label == null ? new Base[0] : new Base[] {this.label}; // StringType
658        case 1671764162: /*display*/ return this.display == null ? new Base[0] : new Base[] {this.display}; // StringType
659        case -1442706713: /*citation*/ return this.citation == null ? new Base[0] : new Base[] {this.citation}; // MarkdownType
660        case 116079: /*url*/ return this.url == null ? new Base[0] : new Base[] {this.url}; // UrlType
661        case 861720859: /*document*/ return this.document == null ? new Base[0] : new Base[] {this.document}; // Attachment
662        case -341064690: /*resource*/ return this.resource == null ? new Base[0] : new Base[] {this.resource}; // CanonicalType
663        default: return super.getProperty(hash, name, checkValid);
664        }
665
666      }
667
668      @Override
669      public Base setProperty(int hash, String name, Base value) throws FHIRException {
670        switch (hash) {
671        case 3575610: // type
672          value = new RelatedArtifactTypeEnumFactory().fromType(TypeConvertor.castToCode(value));
673          this.type = (Enumeration) value; // Enumeration<RelatedArtifactType>
674          return value;
675        case 102727412: // label
676          this.label = TypeConvertor.castToString(value); // StringType
677          return value;
678        case 1671764162: // display
679          this.display = TypeConvertor.castToString(value); // StringType
680          return value;
681        case -1442706713: // citation
682          this.citation = TypeConvertor.castToMarkdown(value); // MarkdownType
683          return value;
684        case 116079: // url
685          this.url = TypeConvertor.castToUrl(value); // UrlType
686          return value;
687        case 861720859: // document
688          this.document = TypeConvertor.castToAttachment(value); // Attachment
689          return value;
690        case -341064690: // resource
691          this.resource = TypeConvertor.castToCanonical(value); // CanonicalType
692          return value;
693        default: return super.setProperty(hash, name, value);
694        }
695
696      }
697
698      @Override
699      public Base setProperty(String name, Base value) throws FHIRException {
700        if (name.equals("type")) {
701          value = new RelatedArtifactTypeEnumFactory().fromType(TypeConvertor.castToCode(value));
702          this.type = (Enumeration) value; // Enumeration<RelatedArtifactType>
703        } else if (name.equals("label")) {
704          this.label = TypeConvertor.castToString(value); // StringType
705        } else if (name.equals("display")) {
706          this.display = TypeConvertor.castToString(value); // StringType
707        } else if (name.equals("citation")) {
708          this.citation = TypeConvertor.castToMarkdown(value); // MarkdownType
709        } else if (name.equals("url")) {
710          this.url = TypeConvertor.castToUrl(value); // UrlType
711        } else if (name.equals("document")) {
712          this.document = TypeConvertor.castToAttachment(value); // Attachment
713        } else if (name.equals("resource")) {
714          this.resource = TypeConvertor.castToCanonical(value); // CanonicalType
715        } else
716          return super.setProperty(name, value);
717        return value;
718      }
719
720      @Override
721      public Base makeProperty(int hash, String name) throws FHIRException {
722        switch (hash) {
723        case 3575610:  return getTypeElement();
724        case 102727412:  return getLabelElement();
725        case 1671764162:  return getDisplayElement();
726        case -1442706713:  return getCitationElement();
727        case 116079:  return getUrlElement();
728        case 861720859:  return getDocument();
729        case -341064690:  return getResourceElement();
730        default: return super.makeProperty(hash, name);
731        }
732
733      }
734
735      @Override
736      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
737        switch (hash) {
738        case 3575610: /*type*/ return new String[] {"code"};
739        case 102727412: /*label*/ return new String[] {"string"};
740        case 1671764162: /*display*/ return new String[] {"string"};
741        case -1442706713: /*citation*/ return new String[] {"markdown"};
742        case 116079: /*url*/ return new String[] {"url"};
743        case 861720859: /*document*/ return new String[] {"Attachment"};
744        case -341064690: /*resource*/ return new String[] {"canonical"};
745        default: return super.getTypesForProperty(hash, name);
746        }
747
748      }
749
750      @Override
751      public Base addChild(String name) throws FHIRException {
752        if (name.equals("type")) {
753          throw new FHIRException("Cannot call addChild on a primitive type RelatedArtifact.type");
754        }
755        else if (name.equals("label")) {
756          throw new FHIRException("Cannot call addChild on a primitive type RelatedArtifact.label");
757        }
758        else if (name.equals("display")) {
759          throw new FHIRException("Cannot call addChild on a primitive type RelatedArtifact.display");
760        }
761        else if (name.equals("citation")) {
762          throw new FHIRException("Cannot call addChild on a primitive type RelatedArtifact.citation");
763        }
764        else if (name.equals("url")) {
765          throw new FHIRException("Cannot call addChild on a primitive type RelatedArtifact.url");
766        }
767        else if (name.equals("document")) {
768          this.document = new Attachment();
769          return this.document;
770        }
771        else if (name.equals("resource")) {
772          throw new FHIRException("Cannot call addChild on a primitive type RelatedArtifact.resource");
773        }
774        else
775          return super.addChild(name);
776      }
777
778  public String fhirType() {
779    return "RelatedArtifact";
780
781  }
782
783      public RelatedArtifact copy() {
784        RelatedArtifact dst = new RelatedArtifact();
785        copyValues(dst);
786        return dst;
787      }
788
789      public void copyValues(RelatedArtifact dst) {
790        super.copyValues(dst);
791        dst.type = type == null ? null : type.copy();
792        dst.label = label == null ? null : label.copy();
793        dst.display = display == null ? null : display.copy();
794        dst.citation = citation == null ? null : citation.copy();
795        dst.url = url == null ? null : url.copy();
796        dst.document = document == null ? null : document.copy();
797        dst.resource = resource == null ? null : resource.copy();
798      }
799
800      protected RelatedArtifact typedCopy() {
801        return copy();
802      }
803
804      @Override
805      public boolean equalsDeep(Base other_) {
806        if (!super.equalsDeep(other_))
807          return false;
808        if (!(other_ instanceof RelatedArtifact))
809          return false;
810        RelatedArtifact o = (RelatedArtifact) other_;
811        return compareDeep(type, o.type, true) && compareDeep(label, o.label, true) && compareDeep(display, o.display, true)
812           && compareDeep(citation, o.citation, true) && compareDeep(url, o.url, true) && compareDeep(document, o.document, true)
813           && compareDeep(resource, o.resource, true);
814      }
815
816      @Override
817      public boolean equalsShallow(Base other_) {
818        if (!super.equalsShallow(other_))
819          return false;
820        if (!(other_ instanceof RelatedArtifact))
821          return false;
822        RelatedArtifact o = (RelatedArtifact) other_;
823        return compareValues(type, o.type, true) && compareValues(label, o.label, true) && compareValues(display, o.display, true)
824           && compareValues(citation, o.citation, true) && compareValues(url, o.url, true) && compareValues(resource, o.resource, true)
825          ;
826      }
827
828      public boolean isEmpty() {
829        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, label, display, citation
830          , url, document, resource);
831      }
832
833
834}
835