001package org.hl7.fhir.r4.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
033import java.util.ArrayList;
034import java.util.List;
035
036import org.hl7.fhir.exceptions.FHIRException;
037import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
038
039import ca.uhn.fhir.model.api.annotation.Block;
040import ca.uhn.fhir.model.api.annotation.Child;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.ResourceDef;
043import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
044
045/**
046 * Identifies two or more records (resource instances) that refer to the same
047 * real-world "occurrence".
048 */
049@ResourceDef(name = "Linkage", profile = "http://hl7.org/fhir/StructureDefinition/Linkage")
050public class Linkage extends DomainResource {
051
052  public enum LinkageType {
053    /**
054     * The resource represents the "source of truth" (from the perspective of this
055     * Linkage resource) for the underlying event/condition/etc.
056     */
057    SOURCE,
058    /**
059     * The resource represents an alternative view of the underlying
060     * event/condition/etc. The resource may still be actively maintained, even
061     * though it is not considered to be the source of truth.
062     */
063    ALTERNATE,
064    /**
065     * The resource represents an obsolete record of the underlying
066     * event/condition/etc. It is not expected to be actively maintained.
067     */
068    HISTORICAL,
069    /**
070     * added to help the parsers with the generic types
071     */
072    NULL;
073
074    public static LinkageType fromCode(String codeString) throws FHIRException {
075      if (codeString == null || "".equals(codeString))
076        return null;
077      if ("source".equals(codeString))
078        return SOURCE;
079      if ("alternate".equals(codeString))
080        return ALTERNATE;
081      if ("historical".equals(codeString))
082        return HISTORICAL;
083      if (Configuration.isAcceptInvalidEnums())
084        return null;
085      else
086        throw new FHIRException("Unknown LinkageType code '" + codeString + "'");
087    }
088
089    public String toCode() {
090      switch (this) {
091      case SOURCE:
092        return "source";
093      case ALTERNATE:
094        return "alternate";
095      case HISTORICAL:
096        return "historical";
097      case NULL:
098        return null;
099      default:
100        return "?";
101      }
102    }
103
104    public String getSystem() {
105      switch (this) {
106      case SOURCE:
107        return "http://hl7.org/fhir/linkage-type";
108      case ALTERNATE:
109        return "http://hl7.org/fhir/linkage-type";
110      case HISTORICAL:
111        return "http://hl7.org/fhir/linkage-type";
112      case NULL:
113        return null;
114      default:
115        return "?";
116      }
117    }
118
119    public String getDefinition() {
120      switch (this) {
121      case SOURCE:
122        return "The resource represents the \"source of truth\" (from the perspective of this Linkage resource) for the underlying event/condition/etc.";
123      case ALTERNATE:
124        return "The resource represents an alternative view of the underlying event/condition/etc.  The resource may still be actively maintained, even though it is not considered to be the source of truth.";
125      case HISTORICAL:
126        return "The resource represents an obsolete record of the underlying event/condition/etc.  It is not expected to be actively maintained.";
127      case NULL:
128        return null;
129      default:
130        return "?";
131      }
132    }
133
134    public String getDisplay() {
135      switch (this) {
136      case SOURCE:
137        return "Source of Truth";
138      case ALTERNATE:
139        return "Alternate Record";
140      case HISTORICAL:
141        return "Historical/Obsolete Record";
142      case NULL:
143        return null;
144      default:
145        return "?";
146      }
147    }
148  }
149
150  public static class LinkageTypeEnumFactory implements EnumFactory<LinkageType> {
151    public LinkageType fromCode(String codeString) throws IllegalArgumentException {
152      if (codeString == null || "".equals(codeString))
153        if (codeString == null || "".equals(codeString))
154          return null;
155      if ("source".equals(codeString))
156        return LinkageType.SOURCE;
157      if ("alternate".equals(codeString))
158        return LinkageType.ALTERNATE;
159      if ("historical".equals(codeString))
160        return LinkageType.HISTORICAL;
161      throw new IllegalArgumentException("Unknown LinkageType code '" + codeString + "'");
162    }
163
164    public Enumeration<LinkageType> fromType(PrimitiveType<?> code) throws FHIRException {
165      if (code == null)
166        return null;
167      if (code.isEmpty())
168        return new Enumeration<LinkageType>(this, LinkageType.NULL, code);
169      String codeString = code.asStringValue();
170      if (codeString == null || "".equals(codeString))
171        return new Enumeration<LinkageType>(this, LinkageType.NULL, code);
172      if ("source".equals(codeString))
173        return new Enumeration<LinkageType>(this, LinkageType.SOURCE, code);
174      if ("alternate".equals(codeString))
175        return new Enumeration<LinkageType>(this, LinkageType.ALTERNATE, code);
176      if ("historical".equals(codeString))
177        return new Enumeration<LinkageType>(this, LinkageType.HISTORICAL, code);
178      throw new FHIRException("Unknown LinkageType code '" + codeString + "'");
179    }
180
181    public String toCode(LinkageType code) {
182      if (code == LinkageType.SOURCE)
183        return "source";
184      if (code == LinkageType.ALTERNATE)
185        return "alternate";
186      if (code == LinkageType.HISTORICAL)
187        return "historical";
188      return "?";
189    }
190
191    public String toSystem(LinkageType code) {
192      return code.getSystem();
193    }
194  }
195
196  @Block()
197  public static class LinkageItemComponent extends BackboneElement implements IBaseBackboneElement {
198    /**
199     * Distinguishes which item is "source of truth" (if any) and which items are no
200     * longer considered to be current representations.
201     */
202    @Child(name = "type", type = { CodeType.class }, order = 1, min = 1, max = 1, modifier = false, summary = true)
203    @Description(shortDefinition = "source | alternate | historical", formalDefinition = "Distinguishes which item is \"source of truth\" (if any) and which items are no longer considered to be current representations.")
204    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/linkage-type")
205    protected Enumeration<LinkageType> type;
206
207    /**
208     * The resource instance being linked as part of the group.
209     */
210    @Child(name = "resource", type = { Reference.class }, order = 2, min = 1, max = 1, modifier = false, summary = true)
211    @Description(shortDefinition = "Resource being linked", formalDefinition = "The resource instance being linked as part of the group.")
212    protected Reference resource;
213
214    /**
215     * The actual object that is the target of the reference (The resource instance
216     * being linked as part of the group.)
217     */
218    protected Resource resourceTarget;
219
220    private static final long serialVersionUID = -209332008L;
221
222    /**
223     * Constructor
224     */
225    public LinkageItemComponent() {
226      super();
227    }
228
229    /**
230     * Constructor
231     */
232    public LinkageItemComponent(Enumeration<LinkageType> type, Reference resource) {
233      super();
234      this.type = type;
235      this.resource = resource;
236    }
237
238    /**
239     * @return {@link #type} (Distinguishes which item is "source of truth" (if any)
240     *         and which items are no longer considered to be current
241     *         representations.). This is the underlying object with id, value and
242     *         extensions. The accessor "getType" gives direct access to the value
243     */
244    public Enumeration<LinkageType> getTypeElement() {
245      if (this.type == null)
246        if (Configuration.errorOnAutoCreate())
247          throw new Error("Attempt to auto-create LinkageItemComponent.type");
248        else if (Configuration.doAutoCreate())
249          this.type = new Enumeration<LinkageType>(new LinkageTypeEnumFactory()); // bb
250      return this.type;
251    }
252
253    public boolean hasTypeElement() {
254      return this.type != null && !this.type.isEmpty();
255    }
256
257    public boolean hasType() {
258      return this.type != null && !this.type.isEmpty();
259    }
260
261    /**
262     * @param value {@link #type} (Distinguishes which item is "source of truth" (if
263     *              any) and which items are no longer considered to be current
264     *              representations.). This is the underlying object with id, value
265     *              and extensions. The accessor "getType" gives direct access to
266     *              the value
267     */
268    public LinkageItemComponent setTypeElement(Enumeration<LinkageType> value) {
269      this.type = value;
270      return this;
271    }
272
273    /**
274     * @return Distinguishes which item is "source of truth" (if any) and which
275     *         items are no longer considered to be current representations.
276     */
277    public LinkageType getType() {
278      return this.type == null ? null : this.type.getValue();
279    }
280
281    /**
282     * @param value Distinguishes which item is "source of truth" (if any) and which
283     *              items are no longer considered to be current representations.
284     */
285    public LinkageItemComponent setType(LinkageType value) {
286      if (this.type == null)
287        this.type = new Enumeration<LinkageType>(new LinkageTypeEnumFactory());
288      this.type.setValue(value);
289      return this;
290    }
291
292    /**
293     * @return {@link #resource} (The resource instance being linked as part of the
294     *         group.)
295     */
296    public Reference getResource() {
297      if (this.resource == null)
298        if (Configuration.errorOnAutoCreate())
299          throw new Error("Attempt to auto-create LinkageItemComponent.resource");
300        else if (Configuration.doAutoCreate())
301          this.resource = new Reference(); // cc
302      return this.resource;
303    }
304
305    public boolean hasResource() {
306      return this.resource != null && !this.resource.isEmpty();
307    }
308
309    /**
310     * @param value {@link #resource} (The resource instance being linked as part of
311     *              the group.)
312     */
313    public LinkageItemComponent setResource(Reference value) {
314      this.resource = value;
315      return this;
316    }
317
318    /**
319     * @return {@link #resource} The actual object that is the target of the
320     *         reference. The reference library doesn't populate this, but you can
321     *         use it to hold the resource if you resolve it. (The resource instance
322     *         being linked as part of the group.)
323     */
324    public Resource getResourceTarget() {
325      return this.resourceTarget;
326    }
327
328    /**
329     * @param value {@link #resource} The actual object that is the target of the
330     *              reference. The reference library doesn't use these, but you can
331     *              use it to hold the resource if you resolve it. (The resource
332     *              instance being linked as part of the group.)
333     */
334    public LinkageItemComponent setResourceTarget(Resource value) {
335      this.resourceTarget = value;
336      return this;
337    }
338
339    protected void listChildren(List<Property> children) {
340      super.listChildren(children);
341      children.add(new Property("type", "code",
342          "Distinguishes which item is \"source of truth\" (if any) and which items are no longer considered to be current representations.",
343          0, 1, type));
344      children.add(new Property("resource", "Reference(Any)",
345          "The resource instance being linked as part of the group.", 0, 1, resource));
346    }
347
348    @Override
349    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
350      switch (_hash) {
351      case 3575610:
352        /* type */ return new Property("type", "code",
353            "Distinguishes which item is \"source of truth\" (if any) and which items are no longer considered to be current representations.",
354            0, 1, type);
355      case -341064690:
356        /* resource */ return new Property("resource", "Reference(Any)",
357            "The resource instance being linked as part of the group.", 0, 1, resource);
358      default:
359        return super.getNamedProperty(_hash, _name, _checkValid);
360      }
361
362    }
363
364    @Override
365    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
366      switch (hash) {
367      case 3575610:
368        /* type */ return this.type == null ? new Base[0] : new Base[] { this.type }; // Enumeration<LinkageType>
369      case -341064690:
370        /* resource */ return this.resource == null ? new Base[0] : new Base[] { this.resource }; // Reference
371      default:
372        return super.getProperty(hash, name, checkValid);
373      }
374
375    }
376
377    @Override
378    public Base setProperty(int hash, String name, Base value) throws FHIRException {
379      switch (hash) {
380      case 3575610: // type
381        value = new LinkageTypeEnumFactory().fromType(castToCode(value));
382        this.type = (Enumeration) value; // Enumeration<LinkageType>
383        return value;
384      case -341064690: // resource
385        this.resource = castToReference(value); // Reference
386        return value;
387      default:
388        return super.setProperty(hash, name, value);
389      }
390
391    }
392
393    @Override
394    public Base setProperty(String name, Base value) throws FHIRException {
395      if (name.equals("type")) {
396        value = new LinkageTypeEnumFactory().fromType(castToCode(value));
397        this.type = (Enumeration) value; // Enumeration<LinkageType>
398      } else if (name.equals("resource")) {
399        this.resource = castToReference(value); // Reference
400      } else
401        return super.setProperty(name, value);
402      return value;
403    }
404
405    @Override
406    public Base makeProperty(int hash, String name) throws FHIRException {
407      switch (hash) {
408      case 3575610:
409        return getTypeElement();
410      case -341064690:
411        return getResource();
412      default:
413        return super.makeProperty(hash, name);
414      }
415
416    }
417
418    @Override
419    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
420      switch (hash) {
421      case 3575610:
422        /* type */ return new String[] { "code" };
423      case -341064690:
424        /* resource */ return new String[] { "Reference" };
425      default:
426        return super.getTypesForProperty(hash, name);
427      }
428
429    }
430
431    @Override
432    public Base addChild(String name) throws FHIRException {
433      if (name.equals("type")) {
434        throw new FHIRException("Cannot call addChild on a singleton property Linkage.type");
435      } else if (name.equals("resource")) {
436        this.resource = new Reference();
437        return this.resource;
438      } else
439        return super.addChild(name);
440    }
441
442    public LinkageItemComponent copy() {
443      LinkageItemComponent dst = new LinkageItemComponent();
444      copyValues(dst);
445      return dst;
446    }
447
448    public void copyValues(LinkageItemComponent dst) {
449      super.copyValues(dst);
450      dst.type = type == null ? null : type.copy();
451      dst.resource = resource == null ? null : resource.copy();
452    }
453
454    @Override
455    public boolean equalsDeep(Base other_) {
456      if (!super.equalsDeep(other_))
457        return false;
458      if (!(other_ instanceof LinkageItemComponent))
459        return false;
460      LinkageItemComponent o = (LinkageItemComponent) other_;
461      return compareDeep(type, o.type, true) && compareDeep(resource, o.resource, true);
462    }
463
464    @Override
465    public boolean equalsShallow(Base other_) {
466      if (!super.equalsShallow(other_))
467        return false;
468      if (!(other_ instanceof LinkageItemComponent))
469        return false;
470      LinkageItemComponent o = (LinkageItemComponent) other_;
471      return compareValues(type, o.type, true);
472    }
473
474    public boolean isEmpty() {
475      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, resource);
476    }
477
478    public String fhirType() {
479      return "Linkage.item";
480
481    }
482
483  }
484
485  /**
486   * Indicates whether the asserted set of linkages are considered to be "in
487   * effect".
488   */
489  @Child(name = "active", type = { BooleanType.class }, order = 0, min = 0, max = 1, modifier = false, summary = true)
490  @Description(shortDefinition = "Whether this linkage assertion is active or not", formalDefinition = "Indicates whether the asserted set of linkages are considered to be \"in effect\".")
491  protected BooleanType active;
492
493  /**
494   * Identifies the user or organization responsible for asserting the linkages as
495   * well as the user or organization who establishes the context in which the
496   * nature of each linkage is evaluated.
497   */
498  @Child(name = "author", type = { Practitioner.class, PractitionerRole.class,
499      Organization.class }, order = 1, min = 0, max = 1, modifier = false, summary = true)
500  @Description(shortDefinition = "Who is responsible for linkages", formalDefinition = "Identifies the user or organization responsible for asserting the linkages as well as the user or organization who establishes the context in which the nature of each linkage is evaluated.")
501  protected Reference author;
502
503  /**
504   * The actual object that is the target of the reference (Identifies the user or
505   * organization responsible for asserting the linkages as well as the user or
506   * organization who establishes the context in which the nature of each linkage
507   * is evaluated.)
508   */
509  protected Resource authorTarget;
510
511  /**
512   * Identifies which record considered as the reference to the same real-world
513   * occurrence as well as how the items should be evaluated within the collection
514   * of linked items.
515   */
516  @Child(name = "item", type = {}, order = 2, min = 1, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
517  @Description(shortDefinition = "Item to be linked", formalDefinition = "Identifies which record considered as the reference to the same real-world occurrence as well as how the items should be evaluated within the collection of linked items.")
518  protected List<LinkageItemComponent> item;
519
520  private static final long serialVersionUID = 25900306L;
521
522  /**
523   * Constructor
524   */
525  public Linkage() {
526    super();
527  }
528
529  /**
530   * @return {@link #active} (Indicates whether the asserted set of linkages are
531   *         considered to be "in effect".). This is the underlying object with
532   *         id, value and extensions. The accessor "getActive" gives direct
533   *         access to the value
534   */
535  public BooleanType getActiveElement() {
536    if (this.active == null)
537      if (Configuration.errorOnAutoCreate())
538        throw new Error("Attempt to auto-create Linkage.active");
539      else if (Configuration.doAutoCreate())
540        this.active = new BooleanType(); // bb
541    return this.active;
542  }
543
544  public boolean hasActiveElement() {
545    return this.active != null && !this.active.isEmpty();
546  }
547
548  public boolean hasActive() {
549    return this.active != null && !this.active.isEmpty();
550  }
551
552  /**
553   * @param value {@link #active} (Indicates whether the asserted set of linkages
554   *              are considered to be "in effect".). This is the underlying
555   *              object with id, value and extensions. The accessor "getActive"
556   *              gives direct access to the value
557   */
558  public Linkage setActiveElement(BooleanType value) {
559    this.active = value;
560    return this;
561  }
562
563  /**
564   * @return Indicates whether the asserted set of linkages are considered to be
565   *         "in effect".
566   */
567  public boolean getActive() {
568    return this.active == null || this.active.isEmpty() ? false : this.active.getValue();
569  }
570
571  /**
572   * @param value Indicates whether the asserted set of linkages are considered to
573   *              be "in effect".
574   */
575  public Linkage setActive(boolean value) {
576    if (this.active == null)
577      this.active = new BooleanType();
578    this.active.setValue(value);
579    return this;
580  }
581
582  /**
583   * @return {@link #author} (Identifies the user or organization responsible for
584   *         asserting the linkages as well as the user or organization who
585   *         establishes the context in which the nature of each linkage is
586   *         evaluated.)
587   */
588  public Reference getAuthor() {
589    if (this.author == null)
590      if (Configuration.errorOnAutoCreate())
591        throw new Error("Attempt to auto-create Linkage.author");
592      else if (Configuration.doAutoCreate())
593        this.author = new Reference(); // cc
594    return this.author;
595  }
596
597  public boolean hasAuthor() {
598    return this.author != null && !this.author.isEmpty();
599  }
600
601  /**
602   * @param value {@link #author} (Identifies the user or organization responsible
603   *              for asserting the linkages as well as the user or organization
604   *              who establishes the context in which the nature of each linkage
605   *              is evaluated.)
606   */
607  public Linkage setAuthor(Reference value) {
608    this.author = value;
609    return this;
610  }
611
612  /**
613   * @return {@link #author} The actual object that is the target of the
614   *         reference. The reference library doesn't populate this, but you can
615   *         use it to hold the resource if you resolve it. (Identifies the user
616   *         or organization responsible for asserting the linkages as well as the
617   *         user or organization who establishes the context in which the nature
618   *         of each linkage is evaluated.)
619   */
620  public Resource getAuthorTarget() {
621    return this.authorTarget;
622  }
623
624  /**
625   * @param value {@link #author} The actual object that is the target of the
626   *              reference. The reference library doesn't use these, but you can
627   *              use it to hold the resource if you resolve it. (Identifies the
628   *              user or organization responsible for asserting the linkages as
629   *              well as the user or organization who establishes the context in
630   *              which the nature of each linkage is evaluated.)
631   */
632  public Linkage setAuthorTarget(Resource value) {
633    this.authorTarget = value;
634    return this;
635  }
636
637  /**
638   * @return {@link #item} (Identifies which record considered as the reference to
639   *         the same real-world occurrence as well as how the items should be
640   *         evaluated within the collection of linked items.)
641   */
642  public List<LinkageItemComponent> getItem() {
643    if (this.item == null)
644      this.item = new ArrayList<LinkageItemComponent>();
645    return this.item;
646  }
647
648  /**
649   * @return Returns a reference to <code>this</code> for easy method chaining
650   */
651  public Linkage setItem(List<LinkageItemComponent> theItem) {
652    this.item = theItem;
653    return this;
654  }
655
656  public boolean hasItem() {
657    if (this.item == null)
658      return false;
659    for (LinkageItemComponent item : this.item)
660      if (!item.isEmpty())
661        return true;
662    return false;
663  }
664
665  public LinkageItemComponent addItem() { // 3
666    LinkageItemComponent t = new LinkageItemComponent();
667    if (this.item == null)
668      this.item = new ArrayList<LinkageItemComponent>();
669    this.item.add(t);
670    return t;
671  }
672
673  public Linkage addItem(LinkageItemComponent t) { // 3
674    if (t == null)
675      return this;
676    if (this.item == null)
677      this.item = new ArrayList<LinkageItemComponent>();
678    this.item.add(t);
679    return this;
680  }
681
682  /**
683   * @return The first repetition of repeating field {@link #item}, creating it if
684   *         it does not already exist
685   */
686  public LinkageItemComponent getItemFirstRep() {
687    if (getItem().isEmpty()) {
688      addItem();
689    }
690    return getItem().get(0);
691  }
692
693  protected void listChildren(List<Property> children) {
694    super.listChildren(children);
695    children.add(new Property("active", "boolean",
696        "Indicates whether the asserted set of linkages are considered to be \"in effect\".", 0, 1, active));
697    children.add(new Property("author", "Reference(Practitioner|PractitionerRole|Organization)",
698        "Identifies the user or organization responsible for asserting the linkages as well as the user or organization who establishes the context in which the nature of each linkage is evaluated.",
699        0, 1, author));
700    children.add(new Property("item", "",
701        "Identifies which record considered as the reference to the same real-world occurrence as well as how the items should be evaluated within the collection of linked items.",
702        0, java.lang.Integer.MAX_VALUE, item));
703  }
704
705  @Override
706  public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
707    switch (_hash) {
708    case -1422950650:
709      /* active */ return new Property("active", "boolean",
710          "Indicates whether the asserted set of linkages are considered to be \"in effect\".", 0, 1, active);
711    case -1406328437:
712      /* author */ return new Property("author", "Reference(Practitioner|PractitionerRole|Organization)",
713          "Identifies the user or organization responsible for asserting the linkages as well as the user or organization who establishes the context in which the nature of each linkage is evaluated.",
714          0, 1, author);
715    case 3242771:
716      /* item */ return new Property("item", "",
717          "Identifies which record considered as the reference to the same real-world occurrence as well as how the items should be evaluated within the collection of linked items.",
718          0, java.lang.Integer.MAX_VALUE, item);
719    default:
720      return super.getNamedProperty(_hash, _name, _checkValid);
721    }
722
723  }
724
725  @Override
726  public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
727    switch (hash) {
728    case -1422950650:
729      /* active */ return this.active == null ? new Base[0] : new Base[] { this.active }; // BooleanType
730    case -1406328437:
731      /* author */ return this.author == null ? new Base[0] : new Base[] { this.author }; // Reference
732    case 3242771:
733      /* item */ return this.item == null ? new Base[0] : this.item.toArray(new Base[this.item.size()]); // LinkageItemComponent
734    default:
735      return super.getProperty(hash, name, checkValid);
736    }
737
738  }
739
740  @Override
741  public Base setProperty(int hash, String name, Base value) throws FHIRException {
742    switch (hash) {
743    case -1422950650: // active
744      this.active = castToBoolean(value); // BooleanType
745      return value;
746    case -1406328437: // author
747      this.author = castToReference(value); // Reference
748      return value;
749    case 3242771: // item
750      this.getItem().add((LinkageItemComponent) value); // LinkageItemComponent
751      return value;
752    default:
753      return super.setProperty(hash, name, value);
754    }
755
756  }
757
758  @Override
759  public Base setProperty(String name, Base value) throws FHIRException {
760    if (name.equals("active")) {
761      this.active = castToBoolean(value); // BooleanType
762    } else if (name.equals("author")) {
763      this.author = castToReference(value); // Reference
764    } else if (name.equals("item")) {
765      this.getItem().add((LinkageItemComponent) value);
766    } else
767      return super.setProperty(name, value);
768    return value;
769  }
770
771  @Override
772  public Base makeProperty(int hash, String name) throws FHIRException {
773    switch (hash) {
774    case -1422950650:
775      return getActiveElement();
776    case -1406328437:
777      return getAuthor();
778    case 3242771:
779      return addItem();
780    default:
781      return super.makeProperty(hash, name);
782    }
783
784  }
785
786  @Override
787  public String[] getTypesForProperty(int hash, String name) throws FHIRException {
788    switch (hash) {
789    case -1422950650:
790      /* active */ return new String[] { "boolean" };
791    case -1406328437:
792      /* author */ return new String[] { "Reference" };
793    case 3242771:
794      /* item */ return new String[] {};
795    default:
796      return super.getTypesForProperty(hash, name);
797    }
798
799  }
800
801  @Override
802  public Base addChild(String name) throws FHIRException {
803    if (name.equals("active")) {
804      throw new FHIRException("Cannot call addChild on a singleton property Linkage.active");
805    } else if (name.equals("author")) {
806      this.author = new Reference();
807      return this.author;
808    } else if (name.equals("item")) {
809      return addItem();
810    } else
811      return super.addChild(name);
812  }
813
814  public String fhirType() {
815    return "Linkage";
816
817  }
818
819  public Linkage copy() {
820    Linkage dst = new Linkage();
821    copyValues(dst);
822    return dst;
823  }
824
825  public void copyValues(Linkage dst) {
826    super.copyValues(dst);
827    dst.active = active == null ? null : active.copy();
828    dst.author = author == null ? null : author.copy();
829    if (item != null) {
830      dst.item = new ArrayList<LinkageItemComponent>();
831      for (LinkageItemComponent i : item)
832        dst.item.add(i.copy());
833    }
834    ;
835  }
836
837  protected Linkage typedCopy() {
838    return copy();
839  }
840
841  @Override
842  public boolean equalsDeep(Base other_) {
843    if (!super.equalsDeep(other_))
844      return false;
845    if (!(other_ instanceof Linkage))
846      return false;
847    Linkage o = (Linkage) other_;
848    return compareDeep(active, o.active, true) && compareDeep(author, o.author, true)
849        && compareDeep(item, o.item, true);
850  }
851
852  @Override
853  public boolean equalsShallow(Base other_) {
854    if (!super.equalsShallow(other_))
855      return false;
856    if (!(other_ instanceof Linkage))
857      return false;
858    Linkage o = (Linkage) other_;
859    return compareValues(active, o.active, true);
860  }
861
862  public boolean isEmpty() {
863    return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(active, author, item);
864  }
865
866  @Override
867  public ResourceType getResourceType() {
868    return ResourceType.Linkage;
869  }
870
871  /**
872   * Search parameter: <b>item</b>
873   * <p>
874   * Description: <b>Matches on any item in the Linkage</b><br>
875   * Type: <b>reference</b><br>
876   * Path: <b>Linkage.item.resource</b><br>
877   * </p>
878   */
879  @SearchParamDefinition(name = "item", path = "Linkage.item.resource", description = "Matches on any item in the Linkage", type = "reference")
880  public static final String SP_ITEM = "item";
881  /**
882   * <b>Fluent Client</b> search parameter constant for <b>item</b>
883   * <p>
884   * Description: <b>Matches on any item in the Linkage</b><br>
885   * Type: <b>reference</b><br>
886   * Path: <b>Linkage.item.resource</b><br>
887   * </p>
888   */
889  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ITEM = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
890      SP_ITEM);
891
892  /**
893   * Constant for fluent queries to be used to add include statements. Specifies
894   * the path value of "<b>Linkage:item</b>".
895   */
896  public static final ca.uhn.fhir.model.api.Include INCLUDE_ITEM = new ca.uhn.fhir.model.api.Include("Linkage:item")
897      .toLocked();
898
899  /**
900   * Search parameter: <b>author</b>
901   * <p>
902   * Description: <b>Author of the Linkage</b><br>
903   * Type: <b>reference</b><br>
904   * Path: <b>Linkage.author</b><br>
905   * </p>
906   */
907  @SearchParamDefinition(name = "author", path = "Linkage.author", description = "Author of the Linkage", type = "reference", providesMembershipIn = {
908      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Practitioner") }, target = { Organization.class,
909          Practitioner.class, PractitionerRole.class })
910  public static final String SP_AUTHOR = "author";
911  /**
912   * <b>Fluent Client</b> search parameter constant for <b>author</b>
913   * <p>
914   * Description: <b>Author of the Linkage</b><br>
915   * Type: <b>reference</b><br>
916   * Path: <b>Linkage.author</b><br>
917   * </p>
918   */
919  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam AUTHOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
920      SP_AUTHOR);
921
922  /**
923   * Constant for fluent queries to be used to add include statements. Specifies
924   * the path value of "<b>Linkage:author</b>".
925   */
926  public static final ca.uhn.fhir.model.api.Include INCLUDE_AUTHOR = new ca.uhn.fhir.model.api.Include("Linkage:author")
927      .toLocked();
928
929  /**
930   * Search parameter: <b>source</b>
931   * <p>
932   * Description: <b>Matches on any item in the Linkage with a type of
933   * 'source'</b><br>
934   * Type: <b>reference</b><br>
935   * Path: <b>Linkage.item.resource</b><br>
936   * </p>
937   */
938  @SearchParamDefinition(name = "source", path = "Linkage.item.resource", description = "Matches on any item in the Linkage with a type of 'source'", type = "reference")
939  public static final String SP_SOURCE = "source";
940  /**
941   * <b>Fluent Client</b> search parameter constant for <b>source</b>
942   * <p>
943   * Description: <b>Matches on any item in the Linkage with a type of
944   * 'source'</b><br>
945   * Type: <b>reference</b><br>
946   * Path: <b>Linkage.item.resource</b><br>
947   * </p>
948   */
949  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SOURCE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
950      SP_SOURCE);
951
952  /**
953   * Constant for fluent queries to be used to add include statements. Specifies
954   * the path value of "<b>Linkage:source</b>".
955   */
956  public static final ca.uhn.fhir.model.api.Include INCLUDE_SOURCE = new ca.uhn.fhir.model.api.Include("Linkage:source")
957      .toLocked();
958
959}