001package org.hl7.fhir.r5.model;
002
003
004/*
005 * #%L
006 * org.hl7.fhir.r5
007 * %%
008 * Copyright (C) 2014 - 2019 Health Level 7
009 * %%
010 * Licensed under the Apache License, Version 2.0 (the \"License\");
011 * you may not use this file except in compliance with the License.
012 * You may obtain a copy of the License at
013 * 
014 *      http://www.apache.org/licenses/LICENSE-2.0
015 * 
016 * Unless required by applicable law or agreed to in writing, software
017 * distributed under the License is distributed on an \"AS IS\" BASIS,
018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
019 * See the License for the specific language governing permissions and
020 * limitations under the License.
021 * #L%
022 */
023
024/*
025  Copyright (c) 2011+, HL7, Inc.
026  All rights reserved.
027  
028  Redistribution and use in source and binary forms, with or without modification, \
029  are permitted provided that the following conditions are met:
030  
031   * Redistributions of source code must retain the above copyright notice, this \
032     list of conditions and the following disclaimer.
033   * Redistributions in binary form must reproduce the above copyright notice, \
034     this list of conditions and the following disclaimer in the documentation \
035     and/or other materials provided with the distribution.
036   * Neither the name of HL7 nor the names of its contributors may be used to 
037     endorse or promote products derived from this software without specific 
038     prior written permission.
039  
040  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
041  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
042  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
043  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
044  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
045  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
046  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
047  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
048  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
049  POSSIBILITY OF SUCH DAMAGE.
050  */
051
052// Generated on Tue, Dec 31, 2019 12:12+1100 for FHIR vcurrent
053
054import java.util.ArrayList;
055import java.util.Date;
056import java.util.List;
057import org.hl7.fhir.utilities.Utilities;
058import org.hl7.fhir.r5.model.Enumerations.*;
059import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
060import org.hl7.fhir.exceptions.FHIRException;
061import org.hl7.fhir.instance.model.api.ICompositeType;
062import ca.uhn.fhir.model.api.annotation.ResourceDef;
063import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
064import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
065import ca.uhn.fhir.model.api.annotation.Child;
066import ca.uhn.fhir.model.api.annotation.ChildOrder;
067import ca.uhn.fhir.model.api.annotation.Description;
068import ca.uhn.fhir.model.api.annotation.Block;
069
070/**
071 * Identifies two or more records (resource instances) that refer to the same real-world "occurrence".
072 */
073@ResourceDef(name="Linkage", profile="http://hl7.org/fhir/StructureDefinition/Linkage")
074public class Linkage extends DomainResource {
075
076    public enum LinkageType {
077        /**
078         * The resource represents the \"source of truth\" (from the perspective of this Linkage resource) for the underlying event/condition/etc.
079         */
080        SOURCE, 
081        /**
082         * 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.
083         */
084        ALTERNATE, 
085        /**
086         * The resource represents an obsolete record of the underlying event/condition/etc.  It is not expected to be actively maintained.
087         */
088        HISTORICAL, 
089        /**
090         * added to help the parsers with the generic types
091         */
092        NULL;
093        public static LinkageType fromCode(String codeString) throws FHIRException {
094            if (codeString == null || "".equals(codeString))
095                return null;
096        if ("source".equals(codeString))
097          return SOURCE;
098        if ("alternate".equals(codeString))
099          return ALTERNATE;
100        if ("historical".equals(codeString))
101          return HISTORICAL;
102        if (Configuration.isAcceptInvalidEnums())
103          return null;
104        else
105          throw new FHIRException("Unknown LinkageType code '"+codeString+"'");
106        }
107        public String toCode() {
108          switch (this) {
109            case SOURCE: return "source";
110            case ALTERNATE: return "alternate";
111            case HISTORICAL: return "historical";
112            default: return "?";
113          }
114        }
115        public String getSystem() {
116          switch (this) {
117            case SOURCE: return "http://hl7.org/fhir/linkage-type";
118            case ALTERNATE: return "http://hl7.org/fhir/linkage-type";
119            case HISTORICAL: return "http://hl7.org/fhir/linkage-type";
120            default: return "?";
121          }
122        }
123        public String getDefinition() {
124          switch (this) {
125            case SOURCE: return "The resource represents the \"source of truth\" (from the perspective of this Linkage resource) for the underlying event/condition/etc.";
126            case ALTERNATE: 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.";
127            case HISTORICAL: return "The resource represents an obsolete record of the underlying event/condition/etc.  It is not expected to be actively maintained.";
128            default: return "?";
129          }
130        }
131        public String getDisplay() {
132          switch (this) {
133            case SOURCE: return "Source of Truth";
134            case ALTERNATE: return "Alternate Record";
135            case HISTORICAL: return "Historical/Obsolete Record";
136            default: return "?";
137          }
138        }
139    }
140
141  public static class LinkageTypeEnumFactory implements EnumFactory<LinkageType> {
142    public LinkageType fromCode(String codeString) throws IllegalArgumentException {
143      if (codeString == null || "".equals(codeString))
144            if (codeString == null || "".equals(codeString))
145                return null;
146        if ("source".equals(codeString))
147          return LinkageType.SOURCE;
148        if ("alternate".equals(codeString))
149          return LinkageType.ALTERNATE;
150        if ("historical".equals(codeString))
151          return LinkageType.HISTORICAL;
152        throw new IllegalArgumentException("Unknown LinkageType code '"+codeString+"'");
153        }
154        public Enumeration<LinkageType> fromType(Base code) throws FHIRException {
155          if (code == null)
156            return null;
157          if (code.isEmpty())
158            return new Enumeration<LinkageType>(this);
159          String codeString = ((PrimitiveType) code).asStringValue();
160          if (codeString == null || "".equals(codeString))
161            return null;
162        if ("source".equals(codeString))
163          return new Enumeration<LinkageType>(this, LinkageType.SOURCE);
164        if ("alternate".equals(codeString))
165          return new Enumeration<LinkageType>(this, LinkageType.ALTERNATE);
166        if ("historical".equals(codeString))
167          return new Enumeration<LinkageType>(this, LinkageType.HISTORICAL);
168        throw new FHIRException("Unknown LinkageType code '"+codeString+"'");
169        }
170    public String toCode(LinkageType code) {
171      if (code == LinkageType.SOURCE)
172        return "source";
173      if (code == LinkageType.ALTERNATE)
174        return "alternate";
175      if (code == LinkageType.HISTORICAL)
176        return "historical";
177      return "?";
178      }
179    public String toSystem(LinkageType code) {
180      return code.getSystem();
181      }
182    }
183
184    @Block()
185    public static class LinkageItemComponent extends BackboneElement implements IBaseBackboneElement {
186        /**
187         * Distinguishes which item is "source of truth" (if any) and which items are no longer considered to be current representations.
188         */
189        @Child(name = "type", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=true)
190        @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." )
191        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/linkage-type")
192        protected Enumeration<LinkageType> type;
193
194        /**
195         * The resource instance being linked as part of the group.
196         */
197        @Child(name = "resource", type = {Reference.class}, order=2, min=1, max=1, modifier=false, summary=true)
198        @Description(shortDefinition="Resource being linked", formalDefinition="The resource instance being linked as part of the group." )
199        protected Reference resource;
200
201        private static final long serialVersionUID = 527428511L;
202
203    /**
204     * Constructor
205     */
206      public LinkageItemComponent() {
207        super();
208      }
209
210    /**
211     * Constructor
212     */
213      public LinkageItemComponent(LinkageType type, Reference resource) {
214        super();
215        this.setType(type);
216        this.setResource(resource);
217      }
218
219        /**
220         * @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
221         */
222        public Enumeration<LinkageType> getTypeElement() { 
223          if (this.type == null)
224            if (Configuration.errorOnAutoCreate())
225              throw new Error("Attempt to auto-create LinkageItemComponent.type");
226            else if (Configuration.doAutoCreate())
227              this.type = new Enumeration<LinkageType>(new LinkageTypeEnumFactory()); // bb
228          return this.type;
229        }
230
231        public boolean hasTypeElement() { 
232          return this.type != null && !this.type.isEmpty();
233        }
234
235        public boolean hasType() { 
236          return this.type != null && !this.type.isEmpty();
237        }
238
239        /**
240         * @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
241         */
242        public LinkageItemComponent setTypeElement(Enumeration<LinkageType> value) { 
243          this.type = value;
244          return this;
245        }
246
247        /**
248         * @return Distinguishes which item is "source of truth" (if any) and which items are no longer considered to be current representations.
249         */
250        public LinkageType getType() { 
251          return this.type == null ? null : this.type.getValue();
252        }
253
254        /**
255         * @param value Distinguishes which item is "source of truth" (if any) and which items are no longer considered to be current representations.
256         */
257        public LinkageItemComponent setType(LinkageType value) { 
258            if (this.type == null)
259              this.type = new Enumeration<LinkageType>(new LinkageTypeEnumFactory());
260            this.type.setValue(value);
261          return this;
262        }
263
264        /**
265         * @return {@link #resource} (The resource instance being linked as part of the group.)
266         */
267        public Reference getResource() { 
268          if (this.resource == null)
269            if (Configuration.errorOnAutoCreate())
270              throw new Error("Attempt to auto-create LinkageItemComponent.resource");
271            else if (Configuration.doAutoCreate())
272              this.resource = new Reference(); // cc
273          return this.resource;
274        }
275
276        public boolean hasResource() { 
277          return this.resource != null && !this.resource.isEmpty();
278        }
279
280        /**
281         * @param value {@link #resource} (The resource instance being linked as part of the group.)
282         */
283        public LinkageItemComponent setResource(Reference value) { 
284          this.resource = value;
285          return this;
286        }
287
288        protected void listChildren(List<Property> children) {
289          super.listChildren(children);
290          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));
291          children.add(new Property("resource", "Reference(Any)", "The resource instance being linked as part of the group.", 0, 1, resource));
292        }
293
294        @Override
295        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
296          switch (_hash) {
297          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);
298          case -341064690: /*resource*/  return new Property("resource", "Reference(Any)", "The resource instance being linked as part of the group.", 0, 1, resource);
299          default: return super.getNamedProperty(_hash, _name, _checkValid);
300          }
301
302        }
303
304      @Override
305      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
306        switch (hash) {
307        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // Enumeration<LinkageType>
308        case -341064690: /*resource*/ return this.resource == null ? new Base[0] : new Base[] {this.resource}; // Reference
309        default: return super.getProperty(hash, name, checkValid);
310        }
311
312      }
313
314      @Override
315      public Base setProperty(int hash, String name, Base value) throws FHIRException {
316        switch (hash) {
317        case 3575610: // type
318          value = new LinkageTypeEnumFactory().fromType(TypeConvertor.castToCode(value));
319          this.type = (Enumeration) value; // Enumeration<LinkageType>
320          return value;
321        case -341064690: // resource
322          this.resource = TypeConvertor.castToReference(value); // Reference
323          return value;
324        default: return super.setProperty(hash, name, value);
325        }
326
327      }
328
329      @Override
330      public Base setProperty(String name, Base value) throws FHIRException {
331        if (name.equals("type")) {
332          value = new LinkageTypeEnumFactory().fromType(TypeConvertor.castToCode(value));
333          this.type = (Enumeration) value; // Enumeration<LinkageType>
334        } else if (name.equals("resource")) {
335          this.resource = TypeConvertor.castToReference(value); // Reference
336        } else
337          return super.setProperty(name, value);
338        return value;
339      }
340
341      @Override
342      public Base makeProperty(int hash, String name) throws FHIRException {
343        switch (hash) {
344        case 3575610:  return getTypeElement();
345        case -341064690:  return getResource();
346        default: return super.makeProperty(hash, name);
347        }
348
349      }
350
351      @Override
352      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
353        switch (hash) {
354        case 3575610: /*type*/ return new String[] {"code"};
355        case -341064690: /*resource*/ return new String[] {"Reference"};
356        default: return super.getTypesForProperty(hash, name);
357        }
358
359      }
360
361      @Override
362      public Base addChild(String name) throws FHIRException {
363        if (name.equals("type")) {
364          throw new FHIRException("Cannot call addChild on a primitive type Linkage.item.type");
365        }
366        else if (name.equals("resource")) {
367          this.resource = new Reference();
368          return this.resource;
369        }
370        else
371          return super.addChild(name);
372      }
373
374      public LinkageItemComponent copy() {
375        LinkageItemComponent dst = new LinkageItemComponent();
376        copyValues(dst);
377        return dst;
378      }
379
380      public void copyValues(LinkageItemComponent dst) {
381        super.copyValues(dst);
382        dst.type = type == null ? null : type.copy();
383        dst.resource = resource == null ? null : resource.copy();
384      }
385
386      @Override
387      public boolean equalsDeep(Base other_) {
388        if (!super.equalsDeep(other_))
389          return false;
390        if (!(other_ instanceof LinkageItemComponent))
391          return false;
392        LinkageItemComponent o = (LinkageItemComponent) other_;
393        return compareDeep(type, o.type, true) && compareDeep(resource, o.resource, true);
394      }
395
396      @Override
397      public boolean equalsShallow(Base other_) {
398        if (!super.equalsShallow(other_))
399          return false;
400        if (!(other_ instanceof LinkageItemComponent))
401          return false;
402        LinkageItemComponent o = (LinkageItemComponent) other_;
403        return compareValues(type, o.type, true);
404      }
405
406      public boolean isEmpty() {
407        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, resource);
408      }
409
410  public String fhirType() {
411    return "Linkage.item";
412
413  }
414
415  }
416
417    /**
418     * Indicates whether the asserted set of linkages are considered to be "in effect".
419     */
420    @Child(name = "active", type = {BooleanType.class}, order=0, min=0, max=1, modifier=false, summary=true)
421    @Description(shortDefinition="Whether this linkage assertion is active or not", formalDefinition="Indicates whether the asserted set of linkages are considered to be \"in effect\"." )
422    protected BooleanType active;
423
424    /**
425     * 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.
426     */
427    @Child(name = "author", type = {Practitioner.class, PractitionerRole.class, Organization.class}, order=1, min=0, max=1, modifier=false, summary=true)
428    @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." )
429    protected Reference author;
430
431    /**
432     * 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.
433     */
434    @Child(name = "item", type = {}, order=2, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
435    @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." )
436    protected List<LinkageItemComponent> item;
437
438    private static final long serialVersionUID = 810520886L;
439
440  /**
441   * Constructor
442   */
443    public Linkage() {
444      super();
445    }
446
447  /**
448   * Constructor
449   */
450    public Linkage(LinkageItemComponent item) {
451      super();
452      this.addItem(item);
453    }
454
455    /**
456     * @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
457     */
458    public BooleanType getActiveElement() { 
459      if (this.active == null)
460        if (Configuration.errorOnAutoCreate())
461          throw new Error("Attempt to auto-create Linkage.active");
462        else if (Configuration.doAutoCreate())
463          this.active = new BooleanType(); // bb
464      return this.active;
465    }
466
467    public boolean hasActiveElement() { 
468      return this.active != null && !this.active.isEmpty();
469    }
470
471    public boolean hasActive() { 
472      return this.active != null && !this.active.isEmpty();
473    }
474
475    /**
476     * @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
477     */
478    public Linkage setActiveElement(BooleanType value) { 
479      this.active = value;
480      return this;
481    }
482
483    /**
484     * @return Indicates whether the asserted set of linkages are considered to be "in effect".
485     */
486    public boolean getActive() { 
487      return this.active == null || this.active.isEmpty() ? false : this.active.getValue();
488    }
489
490    /**
491     * @param value Indicates whether the asserted set of linkages are considered to be "in effect".
492     */
493    public Linkage setActive(boolean value) { 
494        if (this.active == null)
495          this.active = new BooleanType();
496        this.active.setValue(value);
497      return this;
498    }
499
500    /**
501     * @return {@link #author} (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.)
502     */
503    public Reference getAuthor() { 
504      if (this.author == null)
505        if (Configuration.errorOnAutoCreate())
506          throw new Error("Attempt to auto-create Linkage.author");
507        else if (Configuration.doAutoCreate())
508          this.author = new Reference(); // cc
509      return this.author;
510    }
511
512    public boolean hasAuthor() { 
513      return this.author != null && !this.author.isEmpty();
514    }
515
516    /**
517     * @param value {@link #author} (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.)
518     */
519    public Linkage setAuthor(Reference value) { 
520      this.author = value;
521      return this;
522    }
523
524    /**
525     * @return {@link #item} (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.)
526     */
527    public List<LinkageItemComponent> getItem() { 
528      if (this.item == null)
529        this.item = new ArrayList<LinkageItemComponent>();
530      return this.item;
531    }
532
533    /**
534     * @return Returns a reference to <code>this</code> for easy method chaining
535     */
536    public Linkage setItem(List<LinkageItemComponent> theItem) { 
537      this.item = theItem;
538      return this;
539    }
540
541    public boolean hasItem() { 
542      if (this.item == null)
543        return false;
544      for (LinkageItemComponent item : this.item)
545        if (!item.isEmpty())
546          return true;
547      return false;
548    }
549
550    public LinkageItemComponent addItem() { //3
551      LinkageItemComponent t = new LinkageItemComponent();
552      if (this.item == null)
553        this.item = new ArrayList<LinkageItemComponent>();
554      this.item.add(t);
555      return t;
556    }
557
558    public Linkage addItem(LinkageItemComponent t) { //3
559      if (t == null)
560        return this;
561      if (this.item == null)
562        this.item = new ArrayList<LinkageItemComponent>();
563      this.item.add(t);
564      return this;
565    }
566
567    /**
568     * @return The first repetition of repeating field {@link #item}, creating it if it does not already exist {3}
569     */
570    public LinkageItemComponent getItemFirstRep() { 
571      if (getItem().isEmpty()) {
572        addItem();
573      }
574      return getItem().get(0);
575    }
576
577      protected void listChildren(List<Property> children) {
578        super.listChildren(children);
579        children.add(new Property("active", "boolean", "Indicates whether the asserted set of linkages are considered to be \"in effect\".", 0, 1, active));
580        children.add(new Property("author", "Reference(Practitioner|PractitionerRole|Organization)", "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.", 0, 1, author));
581        children.add(new Property("item", "", "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.", 0, java.lang.Integer.MAX_VALUE, item));
582      }
583
584      @Override
585      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
586        switch (_hash) {
587        case -1422950650: /*active*/  return new Property("active", "boolean", "Indicates whether the asserted set of linkages are considered to be \"in effect\".", 0, 1, active);
588        case -1406328437: /*author*/  return new Property("author", "Reference(Practitioner|PractitionerRole|Organization)", "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.", 0, 1, author);
589        case 3242771: /*item*/  return new Property("item", "", "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.", 0, java.lang.Integer.MAX_VALUE, item);
590        default: return super.getNamedProperty(_hash, _name, _checkValid);
591        }
592
593      }
594
595      @Override
596      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
597        switch (hash) {
598        case -1422950650: /*active*/ return this.active == null ? new Base[0] : new Base[] {this.active}; // BooleanType
599        case -1406328437: /*author*/ return this.author == null ? new Base[0] : new Base[] {this.author}; // Reference
600        case 3242771: /*item*/ return this.item == null ? new Base[0] : this.item.toArray(new Base[this.item.size()]); // LinkageItemComponent
601        default: return super.getProperty(hash, name, checkValid);
602        }
603
604      }
605
606      @Override
607      public Base setProperty(int hash, String name, Base value) throws FHIRException {
608        switch (hash) {
609        case -1422950650: // active
610          this.active = TypeConvertor.castToBoolean(value); // BooleanType
611          return value;
612        case -1406328437: // author
613          this.author = TypeConvertor.castToReference(value); // Reference
614          return value;
615        case 3242771: // item
616          this.getItem().add((LinkageItemComponent) value); // LinkageItemComponent
617          return value;
618        default: return super.setProperty(hash, name, value);
619        }
620
621      }
622
623      @Override
624      public Base setProperty(String name, Base value) throws FHIRException {
625        if (name.equals("active")) {
626          this.active = TypeConvertor.castToBoolean(value); // BooleanType
627        } else if (name.equals("author")) {
628          this.author = TypeConvertor.castToReference(value); // Reference
629        } else if (name.equals("item")) {
630          this.getItem().add((LinkageItemComponent) value);
631        } else
632          return super.setProperty(name, value);
633        return value;
634      }
635
636      @Override
637      public Base makeProperty(int hash, String name) throws FHIRException {
638        switch (hash) {
639        case -1422950650:  return getActiveElement();
640        case -1406328437:  return getAuthor();
641        case 3242771:  return addItem(); 
642        default: return super.makeProperty(hash, name);
643        }
644
645      }
646
647      @Override
648      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
649        switch (hash) {
650        case -1422950650: /*active*/ return new String[] {"boolean"};
651        case -1406328437: /*author*/ return new String[] {"Reference"};
652        case 3242771: /*item*/ return new String[] {};
653        default: return super.getTypesForProperty(hash, name);
654        }
655
656      }
657
658      @Override
659      public Base addChild(String name) throws FHIRException {
660        if (name.equals("active")) {
661          throw new FHIRException("Cannot call addChild on a primitive type Linkage.active");
662        }
663        else if (name.equals("author")) {
664          this.author = new Reference();
665          return this.author;
666        }
667        else if (name.equals("item")) {
668          return addItem();
669        }
670        else
671          return super.addChild(name);
672      }
673
674  public String fhirType() {
675    return "Linkage";
676
677  }
678
679      public Linkage copy() {
680        Linkage dst = new Linkage();
681        copyValues(dst);
682        return dst;
683      }
684
685      public void copyValues(Linkage dst) {
686        super.copyValues(dst);
687        dst.active = active == null ? null : active.copy();
688        dst.author = author == null ? null : author.copy();
689        if (item != null) {
690          dst.item = new ArrayList<LinkageItemComponent>();
691          for (LinkageItemComponent i : item)
692            dst.item.add(i.copy());
693        };
694      }
695
696      protected Linkage typedCopy() {
697        return copy();
698      }
699
700      @Override
701      public boolean equalsDeep(Base other_) {
702        if (!super.equalsDeep(other_))
703          return false;
704        if (!(other_ instanceof Linkage))
705          return false;
706        Linkage o = (Linkage) other_;
707        return compareDeep(active, o.active, true) && compareDeep(author, o.author, true) && compareDeep(item, o.item, true)
708          ;
709      }
710
711      @Override
712      public boolean equalsShallow(Base other_) {
713        if (!super.equalsShallow(other_))
714          return false;
715        if (!(other_ instanceof Linkage))
716          return false;
717        Linkage o = (Linkage) other_;
718        return compareValues(active, o.active, true);
719      }
720
721      public boolean isEmpty() {
722        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(active, author, item);
723      }
724
725  @Override
726  public ResourceType getResourceType() {
727    return ResourceType.Linkage;
728   }
729
730 /**
731   * Search parameter: <b>author</b>
732   * <p>
733   * Description: <b>Author of the Linkage</b><br>
734   * Type: <b>reference</b><br>
735   * Path: <b>Linkage.author</b><br>
736   * </p>
737   */
738  @SearchParamDefinition(name="author", path="Linkage.author", description="Author of the Linkage", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Practitioner") }, target={Organization.class, Practitioner.class, PractitionerRole.class } )
739  public static final String SP_AUTHOR = "author";
740 /**
741   * <b>Fluent Client</b> search parameter constant for <b>author</b>
742   * <p>
743   * Description: <b>Author of the Linkage</b><br>
744   * Type: <b>reference</b><br>
745   * Path: <b>Linkage.author</b><br>
746   * </p>
747   */
748  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam AUTHOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_AUTHOR);
749
750/**
751   * Constant for fluent queries to be used to add include statements. Specifies
752   * the path value of "<b>Linkage:author</b>".
753   */
754  public static final ca.uhn.fhir.model.api.Include INCLUDE_AUTHOR = new ca.uhn.fhir.model.api.Include("Linkage:author").toLocked();
755
756 /**
757   * Search parameter: <b>item</b>
758   * <p>
759   * Description: <b>Matches on any item in the Linkage</b><br>
760   * Type: <b>reference</b><br>
761   * Path: <b>Linkage.item.resource</b><br>
762   * </p>
763   */
764  @SearchParamDefinition(name="item", path="Linkage.item.resource", description="Matches on any item in the Linkage", type="reference", target={Account.class, ActivityDefinition.class, AdministrableProductDefinition.class, AdverseEvent.class, AllergyIntolerance.class, Appointment.class, AppointmentResponse.class, AuditEvent.class, Basic.class, Binary.class, BiologicallyDerivedProduct.class, BodyStructure.class, Bundle.class, CapabilityStatement.class, CapabilityStatement2.class, CarePlan.class, CareTeam.class, CatalogEntry.class, ChargeItem.class, ChargeItemDefinition.class, Claim.class, ClaimResponse.class, ClinicalImpression.class, ClinicalUseIssue.class, CodeSystem.class, Communication.class, CommunicationRequest.class, CompartmentDefinition.class, Composition.class, ConceptMap.class, Condition.class, ConditionDefinition.class, Consent.class, Contract.class, Coverage.class, CoverageEligibilityRequest.class, CoverageEligibilityResponse.class, DetectedIssue.class, Device.class, DeviceDefinition.class, DeviceMetric.class, DeviceRequest.class, DeviceUseStatement.class, DiagnosticReport.class, DocumentManifest.class, DocumentReference.class, Encounter.class, Endpoint.class, EnrollmentRequest.class, EnrollmentResponse.class, EpisodeOfCare.class, EventDefinition.class, Evidence.class, EvidenceVariable.class, ExampleScenario.class, ExplanationOfBenefit.class, FamilyMemberHistory.class, Flag.class, Goal.class, GraphDefinition.class, Group.class, GuidanceResponse.class, HealthcareService.class, ImagingStudy.class, Immunization.class, ImmunizationEvaluation.class, ImmunizationRecommendation.class, ImplementationGuide.class, Ingredient.class, InsurancePlan.class, Invoice.class, Library.class, Linkage.class, ListResource.class, Location.class, ManufacturedItemDefinition.class, Measure.class, MeasureReport.class, Medication.class, MedicationAdministration.class, MedicationDispense.class, MedicationKnowledge.class, MedicationRequest.class, MedicationUsage.class, MedicinalProductDefinition.class, MessageDefinition.class, MessageHeader.class, MolecularSequence.class, NamingSystem.class, NutritionIntake.class, NutritionOrder.class, Observation.class, ObservationDefinition.class, OperationDefinition.class, OperationOutcome.class, Organization.class, OrganizationAffiliation.class, PackagedProductDefinition.class, Patient.class, PaymentNotice.class, PaymentReconciliation.class, Person.class, PlanDefinition.class, Practitioner.class, PractitionerRole.class, Procedure.class, Provenance.class, Questionnaire.class, QuestionnaireResponse.class, RegulatedAuthorization.class, RelatedPerson.class, RequestGroup.class, ResearchStudy.class, ResearchSubject.class, RiskAssessment.class, Schedule.class, SearchParameter.class, ServiceRequest.class, Slot.class, Specimen.class, SpecimenDefinition.class, StructureDefinition.class, StructureMap.class, Subscription.class, Substance.class, SubstanceDefinition.class, SubstanceNucleicAcid.class, SubstancePolymer.class, SubstanceProtein.class, SubstanceReferenceInformation.class, SubstanceSourceMaterial.class, SupplyDelivery.class, SupplyRequest.class, Task.class, TerminologyCapabilities.class, TestReport.class, TestScript.class, Topic.class, ValueSet.class, VerificationResult.class, VisionPrescription.class } )
765  public static final String SP_ITEM = "item";
766 /**
767   * <b>Fluent Client</b> search parameter constant for <b>item</b>
768   * <p>
769   * Description: <b>Matches on any item in the Linkage</b><br>
770   * Type: <b>reference</b><br>
771   * Path: <b>Linkage.item.resource</b><br>
772   * </p>
773   */
774  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ITEM = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ITEM);
775
776/**
777   * Constant for fluent queries to be used to add include statements. Specifies
778   * the path value of "<b>Linkage:item</b>".
779   */
780  public static final ca.uhn.fhir.model.api.Include INCLUDE_ITEM = new ca.uhn.fhir.model.api.Include("Linkage:item").toLocked();
781
782 /**
783   * Search parameter: <b>source</b>
784   * <p>
785   * Description: <b>Matches on any item in the Linkage with a type of 'source'</b><br>
786   * Type: <b>reference</b><br>
787   * Path: <b>Linkage.item.resource</b><br>
788   * </p>
789   */
790  @SearchParamDefinition(name="source", path="Linkage.item.resource", description="Matches on any item in the Linkage with a type of 'source'", type="reference", target={Account.class, ActivityDefinition.class, AdministrableProductDefinition.class, AdverseEvent.class, AllergyIntolerance.class, Appointment.class, AppointmentResponse.class, AuditEvent.class, Basic.class, Binary.class, BiologicallyDerivedProduct.class, BodyStructure.class, Bundle.class, CapabilityStatement.class, CapabilityStatement2.class, CarePlan.class, CareTeam.class, CatalogEntry.class, ChargeItem.class, ChargeItemDefinition.class, Claim.class, ClaimResponse.class, ClinicalImpression.class, ClinicalUseIssue.class, CodeSystem.class, Communication.class, CommunicationRequest.class, CompartmentDefinition.class, Composition.class, ConceptMap.class, Condition.class, ConditionDefinition.class, Consent.class, Contract.class, Coverage.class, CoverageEligibilityRequest.class, CoverageEligibilityResponse.class, DetectedIssue.class, Device.class, DeviceDefinition.class, DeviceMetric.class, DeviceRequest.class, DeviceUseStatement.class, DiagnosticReport.class, DocumentManifest.class, DocumentReference.class, Encounter.class, Endpoint.class, EnrollmentRequest.class, EnrollmentResponse.class, EpisodeOfCare.class, EventDefinition.class, Evidence.class, EvidenceVariable.class, ExampleScenario.class, ExplanationOfBenefit.class, FamilyMemberHistory.class, Flag.class, Goal.class, GraphDefinition.class, Group.class, GuidanceResponse.class, HealthcareService.class, ImagingStudy.class, Immunization.class, ImmunizationEvaluation.class, ImmunizationRecommendation.class, ImplementationGuide.class, Ingredient.class, InsurancePlan.class, Invoice.class, Library.class, Linkage.class, ListResource.class, Location.class, ManufacturedItemDefinition.class, Measure.class, MeasureReport.class, Medication.class, MedicationAdministration.class, MedicationDispense.class, MedicationKnowledge.class, MedicationRequest.class, MedicationUsage.class, MedicinalProductDefinition.class, MessageDefinition.class, MessageHeader.class, MolecularSequence.class, NamingSystem.class, NutritionIntake.class, NutritionOrder.class, Observation.class, ObservationDefinition.class, OperationDefinition.class, OperationOutcome.class, Organization.class, OrganizationAffiliation.class, PackagedProductDefinition.class, Patient.class, PaymentNotice.class, PaymentReconciliation.class, Person.class, PlanDefinition.class, Practitioner.class, PractitionerRole.class, Procedure.class, Provenance.class, Questionnaire.class, QuestionnaireResponse.class, RegulatedAuthorization.class, RelatedPerson.class, RequestGroup.class, ResearchStudy.class, ResearchSubject.class, RiskAssessment.class, Schedule.class, SearchParameter.class, ServiceRequest.class, Slot.class, Specimen.class, SpecimenDefinition.class, StructureDefinition.class, StructureMap.class, Subscription.class, Substance.class, SubstanceDefinition.class, SubstanceNucleicAcid.class, SubstancePolymer.class, SubstanceProtein.class, SubstanceReferenceInformation.class, SubstanceSourceMaterial.class, SupplyDelivery.class, SupplyRequest.class, Task.class, TerminologyCapabilities.class, TestReport.class, TestScript.class, Topic.class, ValueSet.class, VerificationResult.class, VisionPrescription.class } )
791  public static final String SP_SOURCE = "source";
792 /**
793   * <b>Fluent Client</b> search parameter constant for <b>source</b>
794   * <p>
795   * Description: <b>Matches on any item in the Linkage with a type of 'source'</b><br>
796   * Type: <b>reference</b><br>
797   * Path: <b>Linkage.item.resource</b><br>
798   * </p>
799   */
800  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SOURCE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SOURCE);
801
802/**
803   * Constant for fluent queries to be used to add include statements. Specifies
804   * the path value of "<b>Linkage:source</b>".
805   */
806  public static final ca.uhn.fhir.model.api.Include INCLUDE_SOURCE = new ca.uhn.fhir.model.api.Include("Linkage:source").toLocked();
807
808
809}
810