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