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 Thu, Sep 13, 2018 09:04-0400 for FHIR v3.5.0
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import ca.uhn.fhir.model.api.annotation.ResourceDef;
038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.Block;
043import org.hl7.fhir.instance.model.api.*;
044import org.hl7.fhir.exceptions.FHIRException;
045/**
046 * Identifies two or more records (resource instances) that are referring to the same real-world "occurrence".
047 */
048@ResourceDef(name="Linkage", profile="http://hl7.org/fhir/StructureDefinition/Linkage")
049public class Linkage extends DomainResource {
050
051    public enum LinkageType {
052        /**
053         * The record represents the "source of truth" (from the perspective of this Linkage resource) for the underlying event/condition/etc.
054         */
055        SOURCE, 
056        /**
057         * The record represents the alternative view of the underlying event/condition/etc.  The record may still be actively maintained, even though it is not considered to be the source of truth.
058         */
059        ALTERNATE, 
060        /**
061         * The record represents an obsolete record of the underlying event/condition/etc.  It is not expected to be actively maintained.
062         */
063        HISTORICAL, 
064        /**
065         * added to help the parsers with the generic types
066         */
067        NULL;
068        public static LinkageType fromCode(String codeString) throws FHIRException {
069            if (codeString == null || "".equals(codeString))
070                return null;
071        if ("source".equals(codeString))
072          return SOURCE;
073        if ("alternate".equals(codeString))
074          return ALTERNATE;
075        if ("historical".equals(codeString))
076          return HISTORICAL;
077        if (Configuration.isAcceptInvalidEnums())
078          return null;
079        else
080          throw new FHIRException("Unknown LinkageType code '"+codeString+"'");
081        }
082        public String toCode() {
083          switch (this) {
084            case SOURCE: return "source";
085            case ALTERNATE: return "alternate";
086            case HISTORICAL: return "historical";
087            default: return "?";
088          }
089        }
090        public String getSystem() {
091          switch (this) {
092            case SOURCE: return "http://hl7.org/fhir/linkage-type";
093            case ALTERNATE: return "http://hl7.org/fhir/linkage-type";
094            case HISTORICAL: return "http://hl7.org/fhir/linkage-type";
095            default: return "?";
096          }
097        }
098        public String getDefinition() {
099          switch (this) {
100            case SOURCE: return "The record represents the \"source of truth\" (from the perspective of this Linkage resource) for the underlying event/condition/etc.";
101            case ALTERNATE: return "The record represents the alternative view of the underlying event/condition/etc.  The record may still be actively maintained, even though it is not considered to be the source of truth.";
102            case HISTORICAL: return "The record represents an obsolete record of the underlying event/condition/etc.  It is not expected to be actively maintained.";
103            default: return "?";
104          }
105        }
106        public String getDisplay() {
107          switch (this) {
108            case SOURCE: return "Source of truth";
109            case ALTERNATE: return "Alternate record";
110            case HISTORICAL: return "Historical/obsolete record";
111            default: return "?";
112          }
113        }
114    }
115
116  public static class LinkageTypeEnumFactory implements EnumFactory<LinkageType> {
117    public LinkageType fromCode(String codeString) throws IllegalArgumentException {
118      if (codeString == null || "".equals(codeString))
119            if (codeString == null || "".equals(codeString))
120                return null;
121        if ("source".equals(codeString))
122          return LinkageType.SOURCE;
123        if ("alternate".equals(codeString))
124          return LinkageType.ALTERNATE;
125        if ("historical".equals(codeString))
126          return LinkageType.HISTORICAL;
127        throw new IllegalArgumentException("Unknown LinkageType code '"+codeString+"'");
128        }
129        public Enumeration<LinkageType> fromType(Base code) throws FHIRException {
130          if (code == null)
131            return null;
132          if (code.isEmpty())
133            return new Enumeration<LinkageType>(this);
134          String codeString = ((PrimitiveType) code).asStringValue();
135          if (codeString == null || "".equals(codeString))
136            return null;
137        if ("source".equals(codeString))
138          return new Enumeration<LinkageType>(this, LinkageType.SOURCE);
139        if ("alternate".equals(codeString))
140          return new Enumeration<LinkageType>(this, LinkageType.ALTERNATE);
141        if ("historical".equals(codeString))
142          return new Enumeration<LinkageType>(this, LinkageType.HISTORICAL);
143        throw new FHIRException("Unknown LinkageType code '"+codeString+"'");
144        }
145    public String toCode(LinkageType code) {
146      if (code == LinkageType.SOURCE)
147        return "source";
148      if (code == LinkageType.ALTERNATE)
149        return "alternate";
150      if (code == LinkageType.HISTORICAL)
151        return "historical";
152      return "?";
153      }
154    public String toSystem(LinkageType code) {
155      return code.getSystem();
156      }
157    }
158
159    @Block()
160    public static class LinkageItemComponent extends BackboneElement implements IBaseBackboneElement {
161        /**
162         * Distinguishes which item is "source of truth" (if any) and which items are no longer considered to be current representations.
163         */
164        @Child(name = "type", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=true)
165        @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." )
166        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/linkage-type")
167        protected Enumeration<LinkageType> type;
168
169        /**
170         * The resource instance being linked as part of the group.
171         */
172        @Child(name = "resource", type = {Reference.class}, order=2, min=1, max=1, modifier=false, summary=true)
173        @Description(shortDefinition="Resource being linked", formalDefinition="The resource instance being linked as part of the group." )
174        protected Reference resource;
175
176        /**
177         * The actual object that is the target of the reference (The resource instance being linked as part of the group.)
178         */
179        protected Resource resourceTarget;
180
181        private static final long serialVersionUID = -209332008L;
182
183    /**
184     * Constructor
185     */
186      public LinkageItemComponent() {
187        super();
188      }
189
190    /**
191     * Constructor
192     */
193      public LinkageItemComponent(Enumeration<LinkageType> type, Reference resource) {
194        super();
195        this.type = type;
196        this.resource = resource;
197      }
198
199        /**
200         * @return {@link #type} (Distinguishes which item is "source of truth" (if any) and which items are no longer considered to be current representations.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
201         */
202        public Enumeration<LinkageType> getTypeElement() { 
203          if (this.type == null)
204            if (Configuration.errorOnAutoCreate())
205              throw new Error("Attempt to auto-create LinkageItemComponent.type");
206            else if (Configuration.doAutoCreate())
207              this.type = new Enumeration<LinkageType>(new LinkageTypeEnumFactory()); // bb
208          return this.type;
209        }
210
211        public boolean hasTypeElement() { 
212          return this.type != null && !this.type.isEmpty();
213        }
214
215        public boolean hasType() { 
216          return this.type != null && !this.type.isEmpty();
217        }
218
219        /**
220         * @param value {@link #type} (Distinguishes which item is "source of truth" (if any) and which items are no longer considered to be current representations.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
221         */
222        public LinkageItemComponent setTypeElement(Enumeration<LinkageType> value) { 
223          this.type = value;
224          return this;
225        }
226
227        /**
228         * @return Distinguishes which item is "source of truth" (if any) and which items are no longer considered to be current representations.
229         */
230        public LinkageType getType() { 
231          return this.type == null ? null : this.type.getValue();
232        }
233
234        /**
235         * @param value Distinguishes which item is "source of truth" (if any) and which items are no longer considered to be current representations.
236         */
237        public LinkageItemComponent setType(LinkageType value) { 
238            if (this.type == null)
239              this.type = new Enumeration<LinkageType>(new LinkageTypeEnumFactory());
240            this.type.setValue(value);
241          return this;
242        }
243
244        /**
245         * @return {@link #resource} (The resource instance being linked as part of the group.)
246         */
247        public Reference getResource() { 
248          if (this.resource == null)
249            if (Configuration.errorOnAutoCreate())
250              throw new Error("Attempt to auto-create LinkageItemComponent.resource");
251            else if (Configuration.doAutoCreate())
252              this.resource = new Reference(); // cc
253          return this.resource;
254        }
255
256        public boolean hasResource() { 
257          return this.resource != null && !this.resource.isEmpty();
258        }
259
260        /**
261         * @param value {@link #resource} (The resource instance being linked as part of the group.)
262         */
263        public LinkageItemComponent setResource(Reference value) { 
264          this.resource = value;
265          return this;
266        }
267
268        /**
269         * @return {@link #resource} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The resource instance being linked as part of the group.)
270         */
271        public Resource getResourceTarget() { 
272          return this.resourceTarget;
273        }
274
275        /**
276         * @param value {@link #resource} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The resource instance being linked as part of the group.)
277         */
278        public LinkageItemComponent setResourceTarget(Resource value) { 
279          this.resourceTarget = value;
280          return this;
281        }
282
283        protected void listChildren(List<Property> children) {
284          super.listChildren(children);
285          children.add(new Property("type", "code", "Distinguishes which item is \"source of truth\" (if any) and which items are no longer considered to be current representations.", 0, 1, type));
286          children.add(new Property("resource", "Reference(Any)", "The resource instance being linked as part of the group.", 0, 1, resource));
287        }
288
289        @Override
290        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
291          switch (_hash) {
292          case 3575610: /*type*/  return new Property("type", "code", "Distinguishes which item is \"source of truth\" (if any) and which items are no longer considered to be current representations.", 0, 1, type);
293          case -341064690: /*resource*/  return new Property("resource", "Reference(Any)", "The resource instance being linked as part of the group.", 0, 1, resource);
294          default: return super.getNamedProperty(_hash, _name, _checkValid);
295          }
296
297        }
298
299      @Override
300      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
301        switch (hash) {
302        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // Enumeration<LinkageType>
303        case -341064690: /*resource*/ return this.resource == null ? new Base[0] : new Base[] {this.resource}; // Reference
304        default: return super.getProperty(hash, name, checkValid);
305        }
306
307      }
308
309      @Override
310      public Base setProperty(int hash, String name, Base value) throws FHIRException {
311        switch (hash) {
312        case 3575610: // type
313          value = new LinkageTypeEnumFactory().fromType(castToCode(value));
314          this.type = (Enumeration) value; // Enumeration<LinkageType>
315          return value;
316        case -341064690: // resource
317          this.resource = castToReference(value); // Reference
318          return value;
319        default: return super.setProperty(hash, name, value);
320        }
321
322      }
323
324      @Override
325      public Base setProperty(String name, Base value) throws FHIRException {
326        if (name.equals("type")) {
327          value = new LinkageTypeEnumFactory().fromType(castToCode(value));
328          this.type = (Enumeration) value; // Enumeration<LinkageType>
329        } else if (name.equals("resource")) {
330          this.resource = castToReference(value); // Reference
331        } else
332          return super.setProperty(name, value);
333        return value;
334      }
335
336      @Override
337      public Base makeProperty(int hash, String name) throws FHIRException {
338        switch (hash) {
339        case 3575610:  return getTypeElement();
340        case -341064690:  return getResource(); 
341        default: return super.makeProperty(hash, name);
342        }
343
344      }
345
346      @Override
347      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
348        switch (hash) {
349        case 3575610: /*type*/ return new String[] {"code"};
350        case -341064690: /*resource*/ return new String[] {"Reference"};
351        default: return super.getTypesForProperty(hash, name);
352        }
353
354      }
355
356      @Override
357      public Base addChild(String name) throws FHIRException {
358        if (name.equals("type")) {
359          throw new FHIRException("Cannot call addChild on a primitive type Linkage.type");
360        }
361        else if (name.equals("resource")) {
362          this.resource = new Reference();
363          return this.resource;
364        }
365        else
366          return super.addChild(name);
367      }
368
369      public LinkageItemComponent copy() {
370        LinkageItemComponent dst = new LinkageItemComponent();
371        copyValues(dst);
372        dst.type = type == null ? null : type.copy();
373        dst.resource = resource == null ? null : resource.copy();
374        return dst;
375      }
376
377      @Override
378      public boolean equalsDeep(Base other_) {
379        if (!super.equalsDeep(other_))
380          return false;
381        if (!(other_ instanceof LinkageItemComponent))
382          return false;
383        LinkageItemComponent o = (LinkageItemComponent) other_;
384        return compareDeep(type, o.type, true) && compareDeep(resource, o.resource, true);
385      }
386
387      @Override
388      public boolean equalsShallow(Base other_) {
389        if (!super.equalsShallow(other_))
390          return false;
391        if (!(other_ instanceof LinkageItemComponent))
392          return false;
393        LinkageItemComponent o = (LinkageItemComponent) other_;
394        return compareValues(type, o.type, true);
395      }
396
397      public boolean isEmpty() {
398        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, resource);
399      }
400
401  public String fhirType() {
402    return "Linkage.item";
403
404  }
405
406  }
407
408    /**
409     * Indicates whether the asserted set of linkages are considered to be "in effect".
410     */
411    @Child(name = "active", type = {BooleanType.class}, order=0, min=0, max=1, modifier=false, summary=true)
412    @Description(shortDefinition="Whether this linkage assertion is active or not", formalDefinition="Indicates whether the asserted set of linkages are considered to be \"in effect\"." )
413    protected BooleanType active;
414
415    /**
416     * Identifies the user or organization responsible for asserting the linkages and who establishes the context for evaluating the nature of each linkage.
417     */
418    @Child(name = "author", type = {Practitioner.class, Organization.class}, order=1, min=0, max=1, modifier=false, summary=true)
419    @Description(shortDefinition="Who is responsible for linkages", formalDefinition="Identifies the user or organization responsible for asserting the linkages and who establishes the context for evaluating the nature of each linkage." )
420    protected Reference author;
421
422    /**
423     * The actual object that is the target of the reference (Identifies the user or organization responsible for asserting the linkages and who establishes the context for evaluating the nature of each linkage.)
424     */
425    protected Resource authorTarget;
426
427    /**
428     * Identifies one of the records that is considered to refer to the same real-world occurrence as well as how the items should be evaluated within the collection of linked items.
429     */
430    @Child(name = "item", type = {}, order=2, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
431    @Description(shortDefinition="Item to be linked", formalDefinition="Identifies one of the records that is considered to refer to the same real-world occurrence as well as how the items should be evaluated within the collection of linked items." )
432    protected List<LinkageItemComponent> item;
433
434    private static final long serialVersionUID = 25900306L;
435
436  /**
437   * Constructor
438   */
439    public Linkage() {
440      super();
441    }
442
443    /**
444     * @return {@link #active} (Indicates whether the asserted set of linkages are considered to be "in effect".). This is the underlying object with id, value and extensions. The accessor "getActive" gives direct access to the value
445     */
446    public BooleanType getActiveElement() { 
447      if (this.active == null)
448        if (Configuration.errorOnAutoCreate())
449          throw new Error("Attempt to auto-create Linkage.active");
450        else if (Configuration.doAutoCreate())
451          this.active = new BooleanType(); // bb
452      return this.active;
453    }
454
455    public boolean hasActiveElement() { 
456      return this.active != null && !this.active.isEmpty();
457    }
458
459    public boolean hasActive() { 
460      return this.active != null && !this.active.isEmpty();
461    }
462
463    /**
464     * @param value {@link #active} (Indicates whether the asserted set of linkages are considered to be "in effect".). This is the underlying object with id, value and extensions. The accessor "getActive" gives direct access to the value
465     */
466    public Linkage setActiveElement(BooleanType value) { 
467      this.active = value;
468      return this;
469    }
470
471    /**
472     * @return Indicates whether the asserted set of linkages are considered to be "in effect".
473     */
474    public boolean getActive() { 
475      return this.active == null || this.active.isEmpty() ? false : this.active.getValue();
476    }
477
478    /**
479     * @param value Indicates whether the asserted set of linkages are considered to be "in effect".
480     */
481    public Linkage setActive(boolean value) { 
482        if (this.active == null)
483          this.active = new BooleanType();
484        this.active.setValue(value);
485      return this;
486    }
487
488    /**
489     * @return {@link #author} (Identifies the user or organization responsible for asserting the linkages and who establishes the context for evaluating the nature of each linkage.)
490     */
491    public Reference getAuthor() { 
492      if (this.author == null)
493        if (Configuration.errorOnAutoCreate())
494          throw new Error("Attempt to auto-create Linkage.author");
495        else if (Configuration.doAutoCreate())
496          this.author = new Reference(); // cc
497      return this.author;
498    }
499
500    public boolean hasAuthor() { 
501      return this.author != null && !this.author.isEmpty();
502    }
503
504    /**
505     * @param value {@link #author} (Identifies the user or organization responsible for asserting the linkages and who establishes the context for evaluating the nature of each linkage.)
506     */
507    public Linkage setAuthor(Reference value) { 
508      this.author = value;
509      return this;
510    }
511
512    /**
513     * @return {@link #author} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Identifies the user or organization responsible for asserting the linkages and who establishes the context for evaluating the nature of each linkage.)
514     */
515    public Resource getAuthorTarget() { 
516      return this.authorTarget;
517    }
518
519    /**
520     * @param value {@link #author} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Identifies the user or organization responsible for asserting the linkages and who establishes the context for evaluating the nature of each linkage.)
521     */
522    public Linkage setAuthorTarget(Resource value) { 
523      this.authorTarget = value;
524      return this;
525    }
526
527    /**
528     * @return {@link #item} (Identifies one of the records that is considered to refer to the same real-world occurrence as well as how the items should be evaluated within the collection of linked items.)
529     */
530    public List<LinkageItemComponent> getItem() { 
531      if (this.item == null)
532        this.item = new ArrayList<LinkageItemComponent>();
533      return this.item;
534    }
535
536    /**
537     * @return Returns a reference to <code>this</code> for easy method chaining
538     */
539    public Linkage setItem(List<LinkageItemComponent> theItem) { 
540      this.item = theItem;
541      return this;
542    }
543
544    public boolean hasItem() { 
545      if (this.item == null)
546        return false;
547      for (LinkageItemComponent item : this.item)
548        if (!item.isEmpty())
549          return true;
550      return false;
551    }
552
553    public LinkageItemComponent addItem() { //3
554      LinkageItemComponent t = new LinkageItemComponent();
555      if (this.item == null)
556        this.item = new ArrayList<LinkageItemComponent>();
557      this.item.add(t);
558      return t;
559    }
560
561    public Linkage addItem(LinkageItemComponent t) { //3
562      if (t == null)
563        return this;
564      if (this.item == null)
565        this.item = new ArrayList<LinkageItemComponent>();
566      this.item.add(t);
567      return this;
568    }
569
570    /**
571     * @return The first repetition of repeating field {@link #item}, creating it if it does not already exist
572     */
573    public LinkageItemComponent getItemFirstRep() { 
574      if (getItem().isEmpty()) {
575        addItem();
576      }
577      return getItem().get(0);
578    }
579
580      protected void listChildren(List<Property> children) {
581        super.listChildren(children);
582        children.add(new Property("active", "boolean", "Indicates whether the asserted set of linkages are considered to be \"in effect\".", 0, 1, active));
583        children.add(new Property("author", "Reference(Practitioner|Organization)", "Identifies the user or organization responsible for asserting the linkages and who establishes the context for evaluating the nature of each linkage.", 0, 1, author));
584        children.add(new Property("item", "", "Identifies one of the records that is considered to refer to the same real-world occurrence as well as how the items should be evaluated within the collection of linked items.", 0, java.lang.Integer.MAX_VALUE, item));
585      }
586
587      @Override
588      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
589        switch (_hash) {
590        case -1422950650: /*active*/  return new Property("active", "boolean", "Indicates whether the asserted set of linkages are considered to be \"in effect\".", 0, 1, active);
591        case -1406328437: /*author*/  return new Property("author", "Reference(Practitioner|Organization)", "Identifies the user or organization responsible for asserting the linkages and who establishes the context for evaluating the nature of each linkage.", 0, 1, author);
592        case 3242771: /*item*/  return new Property("item", "", "Identifies one of the records that is considered to refer to the same real-world occurrence as well as how the items should be evaluated within the collection of linked items.", 0, java.lang.Integer.MAX_VALUE, item);
593        default: return super.getNamedProperty(_hash, _name, _checkValid);
594        }
595
596      }
597
598      @Override
599      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
600        switch (hash) {
601        case -1422950650: /*active*/ return this.active == null ? new Base[0] : new Base[] {this.active}; // BooleanType
602        case -1406328437: /*author*/ return this.author == null ? new Base[0] : new Base[] {this.author}; // Reference
603        case 3242771: /*item*/ return this.item == null ? new Base[0] : this.item.toArray(new Base[this.item.size()]); // LinkageItemComponent
604        default: return super.getProperty(hash, name, checkValid);
605        }
606
607      }
608
609      @Override
610      public Base setProperty(int hash, String name, Base value) throws FHIRException {
611        switch (hash) {
612        case -1422950650: // active
613          this.active = castToBoolean(value); // BooleanType
614          return value;
615        case -1406328437: // author
616          this.author = castToReference(value); // Reference
617          return value;
618        case 3242771: // item
619          this.getItem().add((LinkageItemComponent) value); // LinkageItemComponent
620          return value;
621        default: return super.setProperty(hash, name, value);
622        }
623
624      }
625
626      @Override
627      public Base setProperty(String name, Base value) throws FHIRException {
628        if (name.equals("active")) {
629          this.active = castToBoolean(value); // BooleanType
630        } else if (name.equals("author")) {
631          this.author = castToReference(value); // Reference
632        } else if (name.equals("item")) {
633          this.getItem().add((LinkageItemComponent) value);
634        } else
635          return super.setProperty(name, value);
636        return value;
637      }
638
639      @Override
640      public Base makeProperty(int hash, String name) throws FHIRException {
641        switch (hash) {
642        case -1422950650:  return getActiveElement();
643        case -1406328437:  return getAuthor(); 
644        case 3242771:  return addItem(); 
645        default: return super.makeProperty(hash, name);
646        }
647
648      }
649
650      @Override
651      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
652        switch (hash) {
653        case -1422950650: /*active*/ return new String[] {"boolean"};
654        case -1406328437: /*author*/ return new String[] {"Reference"};
655        case 3242771: /*item*/ return new String[] {};
656        default: return super.getTypesForProperty(hash, name);
657        }
658
659      }
660
661      @Override
662      public Base addChild(String name) throws FHIRException {
663        if (name.equals("active")) {
664          throw new FHIRException("Cannot call addChild on a primitive type Linkage.active");
665        }
666        else if (name.equals("author")) {
667          this.author = new Reference();
668          return this.author;
669        }
670        else if (name.equals("item")) {
671          return addItem();
672        }
673        else
674          return super.addChild(name);
675      }
676
677  public String fhirType() {
678    return "Linkage";
679
680  }
681
682      public Linkage copy() {
683        Linkage dst = new Linkage();
684        copyValues(dst);
685        dst.active = active == null ? null : active.copy();
686        dst.author = author == null ? null : author.copy();
687        if (item != null) {
688          dst.item = new ArrayList<LinkageItemComponent>();
689          for (LinkageItemComponent i : item)
690            dst.item.add(i.copy());
691        };
692        return dst;
693      }
694
695      protected Linkage typedCopy() {
696        return copy();
697      }
698
699      @Override
700      public boolean equalsDeep(Base other_) {
701        if (!super.equalsDeep(other_))
702          return false;
703        if (!(other_ instanceof Linkage))
704          return false;
705        Linkage o = (Linkage) other_;
706        return compareDeep(active, o.active, true) && compareDeep(author, o.author, true) && compareDeep(item, o.item, true)
707          ;
708      }
709
710      @Override
711      public boolean equalsShallow(Base other_) {
712        if (!super.equalsShallow(other_))
713          return false;
714        if (!(other_ instanceof Linkage))
715          return false;
716        Linkage o = (Linkage) other_;
717        return compareValues(active, o.active, true);
718      }
719
720      public boolean isEmpty() {
721        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(active, author, item);
722      }
723
724  @Override
725  public ResourceType getResourceType() {
726    return ResourceType.Linkage;
727   }
728
729 /**
730   * Search parameter: <b>item</b>
731   * <p>
732   * Description: <b>Matches on any item in the Linkage</b><br>
733   * Type: <b>reference</b><br>
734   * Path: <b>Linkage.item.resource</b><br>
735   * </p>
736   */
737  @SearchParamDefinition(name="item", path="Linkage.item.resource", description="Matches on any item in the Linkage", type="reference" )
738  public static final String SP_ITEM = "item";
739 /**
740   * <b>Fluent Client</b> search parameter constant for <b>item</b>
741   * <p>
742   * Description: <b>Matches on any item in the Linkage</b><br>
743   * Type: <b>reference</b><br>
744   * Path: <b>Linkage.item.resource</b><br>
745   * </p>
746   */
747  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ITEM = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ITEM);
748
749/**
750   * Constant for fluent queries to be used to add include statements. Specifies
751   * the path value of "<b>Linkage:item</b>".
752   */
753  public static final ca.uhn.fhir.model.api.Include INCLUDE_ITEM = new ca.uhn.fhir.model.api.Include("Linkage:item").toLocked();
754
755 /**
756   * Search parameter: <b>author</b>
757   * <p>
758   * Description: <b>Author of the Linkage</b><br>
759   * Type: <b>reference</b><br>
760   * Path: <b>Linkage.author</b><br>
761   * </p>
762   */
763  @SearchParamDefinition(name="author", path="Linkage.author", description="Author of the Linkage", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={Organization.class, Practitioner.class } )
764  public static final String SP_AUTHOR = "author";
765 /**
766   * <b>Fluent Client</b> search parameter constant for <b>author</b>
767   * <p>
768   * Description: <b>Author of the Linkage</b><br>
769   * Type: <b>reference</b><br>
770   * Path: <b>Linkage.author</b><br>
771   * </p>
772   */
773  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam AUTHOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_AUTHOR);
774
775/**
776   * Constant for fluent queries to be used to add include statements. Specifies
777   * the path value of "<b>Linkage:author</b>".
778   */
779  public static final ca.uhn.fhir.model.api.Include INCLUDE_AUTHOR = new ca.uhn.fhir.model.api.Include("Linkage:author").toLocked();
780
781 /**
782   * Search parameter: <b>source</b>
783   * <p>
784   * Description: <b>Matches on any item in the Linkage with a type of 'source'</b><br>
785   * Type: <b>reference</b><br>
786   * Path: <b>Linkage.item.resource</b><br>
787   * </p>
788   */
789  @SearchParamDefinition(name="source", path="Linkage.item.resource", description="Matches on any item in the Linkage with a type of 'source'", type="reference" )
790  public static final String SP_SOURCE = "source";
791 /**
792   * <b>Fluent Client</b> search parameter constant for <b>source</b>
793   * <p>
794   * Description: <b>Matches on any item in the Linkage with a type of 'source'</b><br>
795   * Type: <b>reference</b><br>
796   * Path: <b>Linkage.item.resource</b><br>
797   * </p>
798   */
799  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SOURCE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SOURCE);
800
801/**
802   * Constant for fluent queries to be used to add include statements. Specifies
803   * the path value of "<b>Linkage:source</b>".
804   */
805  public static final ca.uhn.fhir.model.api.Include INCLUDE_SOURCE = new ca.uhn.fhir.model.api.Include("Linkage:source").toLocked();
806
807
808}
809