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 * Indication for the Medicinal Product.
047 */
048@ResourceDef(name = "MedicinalProductIndication", profile = "http://hl7.org/fhir/StructureDefinition/MedicinalProductIndication")
049public class MedicinalProductIndication extends DomainResource {
050
051  @Block()
052  public static class MedicinalProductIndicationOtherTherapyComponent extends BackboneElement
053      implements IBaseBackboneElement {
054    /**
055     * The type of relationship between the medicinal product indication or
056     * contraindication and another therapy.
057     */
058    @Child(name = "therapyRelationshipType", type = {
059        CodeableConcept.class }, order = 1, min = 1, max = 1, modifier = false, summary = true)
060    @Description(shortDefinition = "The type of relationship between the medicinal product indication or contraindication and another therapy", formalDefinition = "The type of relationship between the medicinal product indication or contraindication and another therapy.")
061    protected CodeableConcept therapyRelationshipType;
062
063    /**
064     * Reference to a specific medication (active substance, medicinal product or
065     * class of products) as part of an indication or contraindication.
066     */
067    @Child(name = "medication", type = { CodeableConcept.class, MedicinalProduct.class, Medication.class,
068        Substance.class, SubstanceSpecification.class }, order = 2, min = 1, max = 1, modifier = false, summary = true)
069    @Description(shortDefinition = "Reference to a specific medication (active substance, medicinal product or class of products) as part of an indication or contraindication", formalDefinition = "Reference to a specific medication (active substance, medicinal product or class of products) as part of an indication or contraindication.")
070    protected Type medication;
071
072    private static final long serialVersionUID = 1438478115L;
073
074    /**
075     * Constructor
076     */
077    public MedicinalProductIndicationOtherTherapyComponent() {
078      super();
079    }
080
081    /**
082     * Constructor
083     */
084    public MedicinalProductIndicationOtherTherapyComponent(CodeableConcept therapyRelationshipType, Type medication) {
085      super();
086      this.therapyRelationshipType = therapyRelationshipType;
087      this.medication = medication;
088    }
089
090    /**
091     * @return {@link #therapyRelationshipType} (The type of relationship between
092     *         the medicinal product indication or contraindication and another
093     *         therapy.)
094     */
095    public CodeableConcept getTherapyRelationshipType() {
096      if (this.therapyRelationshipType == null)
097        if (Configuration.errorOnAutoCreate())
098          throw new Error(
099              "Attempt to auto-create MedicinalProductIndicationOtherTherapyComponent.therapyRelationshipType");
100        else if (Configuration.doAutoCreate())
101          this.therapyRelationshipType = new CodeableConcept(); // cc
102      return this.therapyRelationshipType;
103    }
104
105    public boolean hasTherapyRelationshipType() {
106      return this.therapyRelationshipType != null && !this.therapyRelationshipType.isEmpty();
107    }
108
109    /**
110     * @param value {@link #therapyRelationshipType} (The type of relationship
111     *              between the medicinal product indication or contraindication and
112     *              another therapy.)
113     */
114    public MedicinalProductIndicationOtherTherapyComponent setTherapyRelationshipType(CodeableConcept value) {
115      this.therapyRelationshipType = value;
116      return this;
117    }
118
119    /**
120     * @return {@link #medication} (Reference to a specific medication (active
121     *         substance, medicinal product or class of products) as part of an
122     *         indication or contraindication.)
123     */
124    public Type getMedication() {
125      return this.medication;
126    }
127
128    /**
129     * @return {@link #medication} (Reference to a specific medication (active
130     *         substance, medicinal product or class of products) as part of an
131     *         indication or contraindication.)
132     */
133    public CodeableConcept getMedicationCodeableConcept() throws FHIRException {
134      if (this.medication == null)
135        this.medication = new CodeableConcept();
136      if (!(this.medication instanceof CodeableConcept))
137        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "
138            + this.medication.getClass().getName() + " was encountered");
139      return (CodeableConcept) this.medication;
140    }
141
142    public boolean hasMedicationCodeableConcept() {
143        return this.medication instanceof CodeableConcept;
144    }
145
146    /**
147     * @return {@link #medication} (Reference to a specific medication (active
148     *         substance, medicinal product or class of products) as part of an
149     *         indication or contraindication.)
150     */
151    public Reference getMedicationReference() throws FHIRException {
152      if (this.medication == null)
153        this.medication = new Reference();
154      if (!(this.medication instanceof Reference))
155        throw new FHIRException("Type mismatch: the type Reference was expected, but "
156            + this.medication.getClass().getName() + " was encountered");
157      return (Reference) this.medication;
158    }
159
160    public boolean hasMedicationReference() {
161        return this.medication instanceof Reference;
162    }
163
164    public boolean hasMedication() {
165      return this.medication != null && !this.medication.isEmpty();
166    }
167
168    /**
169     * @param value {@link #medication} (Reference to a specific medication (active
170     *              substance, medicinal product or class of products) as part of an
171     *              indication or contraindication.)
172     */
173    public MedicinalProductIndicationOtherTherapyComponent setMedication(Type value) {
174      if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
175        throw new Error(
176            "Not the right type for MedicinalProductIndication.otherTherapy.medication[x]: " + value.fhirType());
177      this.medication = value;
178      return this;
179    }
180
181    protected void listChildren(List<Property> children) {
182      super.listChildren(children);
183      children.add(new Property("therapyRelationshipType", "CodeableConcept",
184          "The type of relationship between the medicinal product indication or contraindication and another therapy.",
185          0, 1, therapyRelationshipType));
186      children.add(new Property("medication[x]",
187          "CodeableConcept|Reference(MedicinalProduct|Medication|Substance|SubstanceSpecification)",
188          "Reference to a specific medication (active substance, medicinal product or class of products) as part of an indication or contraindication.",
189          0, 1, medication));
190    }
191
192    @Override
193    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
194      switch (_hash) {
195      case -551658469:
196        /* therapyRelationshipType */ return new Property("therapyRelationshipType", "CodeableConcept",
197            "The type of relationship between the medicinal product indication or contraindication and another therapy.",
198            0, 1, therapyRelationshipType);
199      case 1458402129:
200        /* medication[x] */ return new Property("medication[x]",
201            "CodeableConcept|Reference(MedicinalProduct|Medication|Substance|SubstanceSpecification)",
202            "Reference to a specific medication (active substance, medicinal product or class of products) as part of an indication or contraindication.",
203            0, 1, medication);
204      case 1998965455:
205        /* medication */ return new Property("medication[x]",
206            "CodeableConcept|Reference(MedicinalProduct|Medication|Substance|SubstanceSpecification)",
207            "Reference to a specific medication (active substance, medicinal product or class of products) as part of an indication or contraindication.",
208            0, 1, medication);
209      case -209845038:
210        /* medicationCodeableConcept */ return new Property("medication[x]",
211            "CodeableConcept|Reference(MedicinalProduct|Medication|Substance|SubstanceSpecification)",
212            "Reference to a specific medication (active substance, medicinal product or class of products) as part of an indication or contraindication.",
213            0, 1, medication);
214      case 2104315196:
215        /* medicationReference */ return new Property("medication[x]",
216            "CodeableConcept|Reference(MedicinalProduct|Medication|Substance|SubstanceSpecification)",
217            "Reference to a specific medication (active substance, medicinal product or class of products) as part of an indication or contraindication.",
218            0, 1, medication);
219      default:
220        return super.getNamedProperty(_hash, _name, _checkValid);
221      }
222
223    }
224
225    @Override
226    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
227      switch (hash) {
228      case -551658469:
229        /* therapyRelationshipType */ return this.therapyRelationshipType == null ? new Base[0]
230            : new Base[] { this.therapyRelationshipType }; // CodeableConcept
231      case 1998965455:
232        /* medication */ return this.medication == null ? new Base[0] : new Base[] { this.medication }; // Type
233      default:
234        return super.getProperty(hash, name, checkValid);
235      }
236
237    }
238
239    @Override
240    public Base setProperty(int hash, String name, Base value) throws FHIRException {
241      switch (hash) {
242      case -551658469: // therapyRelationshipType
243        this.therapyRelationshipType = castToCodeableConcept(value); // CodeableConcept
244        return value;
245      case 1998965455: // medication
246        this.medication = castToType(value); // Type
247        return value;
248      default:
249        return super.setProperty(hash, name, value);
250      }
251
252    }
253
254    @Override
255    public Base setProperty(String name, Base value) throws FHIRException {
256      if (name.equals("therapyRelationshipType")) {
257        this.therapyRelationshipType = castToCodeableConcept(value); // CodeableConcept
258      } else if (name.equals("medication[x]")) {
259        this.medication = castToType(value); // Type
260      } else
261        return super.setProperty(name, value);
262      return value;
263    }
264
265  @Override
266  public void removeChild(String name, Base value) throws FHIRException {
267      if (name.equals("therapyRelationshipType")) {
268        this.therapyRelationshipType = null;
269      } else if (name.equals("medication[x]")) {
270        this.medication = null;
271      } else
272        super.removeChild(name, value);
273      
274    }
275
276    @Override
277    public Base makeProperty(int hash, String name) throws FHIRException {
278      switch (hash) {
279      case -551658469:
280        return getTherapyRelationshipType();
281      case 1458402129:
282        return getMedication();
283      case 1998965455:
284        return getMedication();
285      default:
286        return super.makeProperty(hash, name);
287      }
288
289    }
290
291    @Override
292    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
293      switch (hash) {
294      case -551658469:
295        /* therapyRelationshipType */ return new String[] { "CodeableConcept" };
296      case 1998965455:
297        /* medication */ return new String[] { "CodeableConcept", "Reference" };
298      default:
299        return super.getTypesForProperty(hash, name);
300      }
301
302    }
303
304    @Override
305    public Base addChild(String name) throws FHIRException {
306      if (name.equals("therapyRelationshipType")) {
307        this.therapyRelationshipType = new CodeableConcept();
308        return this.therapyRelationshipType;
309      } else if (name.equals("medicationCodeableConcept")) {
310        this.medication = new CodeableConcept();
311        return this.medication;
312      } else if (name.equals("medicationReference")) {
313        this.medication = new Reference();
314        return this.medication;
315      } else
316        return super.addChild(name);
317    }
318
319    public MedicinalProductIndicationOtherTherapyComponent copy() {
320      MedicinalProductIndicationOtherTherapyComponent dst = new MedicinalProductIndicationOtherTherapyComponent();
321      copyValues(dst);
322      return dst;
323    }
324
325    public void copyValues(MedicinalProductIndicationOtherTherapyComponent dst) {
326      super.copyValues(dst);
327      dst.therapyRelationshipType = therapyRelationshipType == null ? null : therapyRelationshipType.copy();
328      dst.medication = medication == null ? null : medication.copy();
329    }
330
331    @Override
332    public boolean equalsDeep(Base other_) {
333      if (!super.equalsDeep(other_))
334        return false;
335      if (!(other_ instanceof MedicinalProductIndicationOtherTherapyComponent))
336        return false;
337      MedicinalProductIndicationOtherTherapyComponent o = (MedicinalProductIndicationOtherTherapyComponent) other_;
338      return compareDeep(therapyRelationshipType, o.therapyRelationshipType, true)
339          && compareDeep(medication, o.medication, true);
340    }
341
342    @Override
343    public boolean equalsShallow(Base other_) {
344      if (!super.equalsShallow(other_))
345        return false;
346      if (!(other_ instanceof MedicinalProductIndicationOtherTherapyComponent))
347        return false;
348      MedicinalProductIndicationOtherTherapyComponent o = (MedicinalProductIndicationOtherTherapyComponent) other_;
349      return true;
350    }
351
352    public boolean isEmpty() {
353      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(therapyRelationshipType, medication);
354    }
355
356    public String fhirType() {
357      return "MedicinalProductIndication.otherTherapy";
358
359    }
360
361  }
362
363  /**
364   * The medication for which this is an indication.
365   */
366  @Child(name = "subject", type = { MedicinalProduct.class,
367      Medication.class }, order = 0, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
368  @Description(shortDefinition = "The medication for which this is an indication", formalDefinition = "The medication for which this is an indication.")
369  protected List<Reference> subject;
370  /**
371   * The actual objects that are the target of the reference (The medication for
372   * which this is an indication.)
373   */
374  protected List<Resource> subjectTarget;
375
376  /**
377   * The disease, symptom or procedure that is the indication for treatment.
378   */
379  @Child(name = "diseaseSymptomProcedure", type = {
380      CodeableConcept.class }, order = 1, min = 0, max = 1, modifier = false, summary = true)
381  @Description(shortDefinition = "The disease, symptom or procedure that is the indication for treatment", formalDefinition = "The disease, symptom or procedure that is the indication for treatment.")
382  protected CodeableConcept diseaseSymptomProcedure;
383
384  /**
385   * The status of the disease or symptom for which the indication applies.
386   */
387  @Child(name = "diseaseStatus", type = {
388      CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
389  @Description(shortDefinition = "The status of the disease or symptom for which the indication applies", formalDefinition = "The status of the disease or symptom for which the indication applies.")
390  protected CodeableConcept diseaseStatus;
391
392  /**
393   * Comorbidity (concurrent condition) or co-infection as part of the indication.
394   */
395  @Child(name = "comorbidity", type = {
396      CodeableConcept.class }, order = 3, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
397  @Description(shortDefinition = "Comorbidity (concurrent condition) or co-infection as part of the indication", formalDefinition = "Comorbidity (concurrent condition) or co-infection as part of the indication.")
398  protected List<CodeableConcept> comorbidity;
399
400  /**
401   * The intended effect, aim or strategy to be achieved by the indication.
402   */
403  @Child(name = "intendedEffect", type = {
404      CodeableConcept.class }, order = 4, min = 0, max = 1, modifier = false, summary = true)
405  @Description(shortDefinition = "The intended effect, aim or strategy to be achieved by the indication", formalDefinition = "The intended effect, aim or strategy to be achieved by the indication.")
406  protected CodeableConcept intendedEffect;
407
408  /**
409   * Timing or duration information as part of the indication.
410   */
411  @Child(name = "duration", type = { Quantity.class }, order = 5, min = 0, max = 1, modifier = false, summary = true)
412  @Description(shortDefinition = "Timing or duration information as part of the indication", formalDefinition = "Timing or duration information as part of the indication.")
413  protected Quantity duration;
414
415  /**
416   * Information about the use of the medicinal product in relation to other
417   * therapies described as part of the indication.
418   */
419  @Child(name = "otherTherapy", type = {}, order = 6, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
420  @Description(shortDefinition = "Information about the use of the medicinal product in relation to other therapies described as part of the indication", formalDefinition = "Information about the use of the medicinal product in relation to other therapies described as part of the indication.")
421  protected List<MedicinalProductIndicationOtherTherapyComponent> otherTherapy;
422
423  /**
424   * Describe the undesirable effects of the medicinal product.
425   */
426  @Child(name = "undesirableEffect", type = {
427      MedicinalProductUndesirableEffect.class }, order = 7, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
428  @Description(shortDefinition = "Describe the undesirable effects of the medicinal product", formalDefinition = "Describe the undesirable effects of the medicinal product.")
429  protected List<Reference> undesirableEffect;
430  /**
431   * The actual objects that are the target of the reference (Describe the
432   * undesirable effects of the medicinal product.)
433   */
434  protected List<MedicinalProductUndesirableEffect> undesirableEffectTarget;
435
436  /**
437   * The population group to which this applies.
438   */
439  @Child(name = "population", type = {
440      Population.class }, order = 8, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
441  @Description(shortDefinition = "The population group to which this applies", formalDefinition = "The population group to which this applies.")
442  protected List<Population> population;
443
444  private static final long serialVersionUID = 1205519664L;
445
446  /**
447   * Constructor
448   */
449  public MedicinalProductIndication() {
450    super();
451  }
452
453  /**
454   * @return {@link #subject} (The medication for which this is an indication.)
455   */
456  public List<Reference> getSubject() {
457    if (this.subject == null)
458      this.subject = new ArrayList<Reference>();
459    return this.subject;
460  }
461
462  /**
463   * @return Returns a reference to <code>this</code> for easy method chaining
464   */
465  public MedicinalProductIndication setSubject(List<Reference> theSubject) {
466    this.subject = theSubject;
467    return this;
468  }
469
470  public boolean hasSubject() {
471    if (this.subject == null)
472      return false;
473    for (Reference item : this.subject)
474      if (!item.isEmpty())
475        return true;
476    return false;
477  }
478
479  public Reference addSubject() { // 3
480    Reference t = new Reference();
481    if (this.subject == null)
482      this.subject = new ArrayList<Reference>();
483    this.subject.add(t);
484    return t;
485  }
486
487  public MedicinalProductIndication addSubject(Reference t) { // 3
488    if (t == null)
489      return this;
490    if (this.subject == null)
491      this.subject = new ArrayList<Reference>();
492    this.subject.add(t);
493    return this;
494  }
495
496  /**
497   * @return The first repetition of repeating field {@link #subject}, creating it
498   *         if it does not already exist
499   */
500  public Reference getSubjectFirstRep() {
501    if (getSubject().isEmpty()) {
502      addSubject();
503    }
504    return getSubject().get(0);
505  }
506
507  /**
508   * @return {@link #diseaseSymptomProcedure} (The disease, symptom or procedure
509   *         that is the indication for treatment.)
510   */
511  public CodeableConcept getDiseaseSymptomProcedure() {
512    if (this.diseaseSymptomProcedure == null)
513      if (Configuration.errorOnAutoCreate())
514        throw new Error("Attempt to auto-create MedicinalProductIndication.diseaseSymptomProcedure");
515      else if (Configuration.doAutoCreate())
516        this.diseaseSymptomProcedure = new CodeableConcept(); // cc
517    return this.diseaseSymptomProcedure;
518  }
519
520  public boolean hasDiseaseSymptomProcedure() {
521    return this.diseaseSymptomProcedure != null && !this.diseaseSymptomProcedure.isEmpty();
522  }
523
524  /**
525   * @param value {@link #diseaseSymptomProcedure} (The disease, symptom or
526   *              procedure that is the indication for treatment.)
527   */
528  public MedicinalProductIndication setDiseaseSymptomProcedure(CodeableConcept value) {
529    this.diseaseSymptomProcedure = value;
530    return this;
531  }
532
533  /**
534   * @return {@link #diseaseStatus} (The status of the disease or symptom for
535   *         which the indication applies.)
536   */
537  public CodeableConcept getDiseaseStatus() {
538    if (this.diseaseStatus == null)
539      if (Configuration.errorOnAutoCreate())
540        throw new Error("Attempt to auto-create MedicinalProductIndication.diseaseStatus");
541      else if (Configuration.doAutoCreate())
542        this.diseaseStatus = new CodeableConcept(); // cc
543    return this.diseaseStatus;
544  }
545
546  public boolean hasDiseaseStatus() {
547    return this.diseaseStatus != null && !this.diseaseStatus.isEmpty();
548  }
549
550  /**
551   * @param value {@link #diseaseStatus} (The status of the disease or symptom for
552   *              which the indication applies.)
553   */
554  public MedicinalProductIndication setDiseaseStatus(CodeableConcept value) {
555    this.diseaseStatus = value;
556    return this;
557  }
558
559  /**
560   * @return {@link #comorbidity} (Comorbidity (concurrent condition) or
561   *         co-infection as part of the indication.)
562   */
563  public List<CodeableConcept> getComorbidity() {
564    if (this.comorbidity == null)
565      this.comorbidity = new ArrayList<CodeableConcept>();
566    return this.comorbidity;
567  }
568
569  /**
570   * @return Returns a reference to <code>this</code> for easy method chaining
571   */
572  public MedicinalProductIndication setComorbidity(List<CodeableConcept> theComorbidity) {
573    this.comorbidity = theComorbidity;
574    return this;
575  }
576
577  public boolean hasComorbidity() {
578    if (this.comorbidity == null)
579      return false;
580    for (CodeableConcept item : this.comorbidity)
581      if (!item.isEmpty())
582        return true;
583    return false;
584  }
585
586  public CodeableConcept addComorbidity() { // 3
587    CodeableConcept t = new CodeableConcept();
588    if (this.comorbidity == null)
589      this.comorbidity = new ArrayList<CodeableConcept>();
590    this.comorbidity.add(t);
591    return t;
592  }
593
594  public MedicinalProductIndication addComorbidity(CodeableConcept t) { // 3
595    if (t == null)
596      return this;
597    if (this.comorbidity == null)
598      this.comorbidity = new ArrayList<CodeableConcept>();
599    this.comorbidity.add(t);
600    return this;
601  }
602
603  /**
604   * @return The first repetition of repeating field {@link #comorbidity},
605   *         creating it if it does not already exist
606   */
607  public CodeableConcept getComorbidityFirstRep() {
608    if (getComorbidity().isEmpty()) {
609      addComorbidity();
610    }
611    return getComorbidity().get(0);
612  }
613
614  /**
615   * @return {@link #intendedEffect} (The intended effect, aim or strategy to be
616   *         achieved by the indication.)
617   */
618  public CodeableConcept getIntendedEffect() {
619    if (this.intendedEffect == null)
620      if (Configuration.errorOnAutoCreate())
621        throw new Error("Attempt to auto-create MedicinalProductIndication.intendedEffect");
622      else if (Configuration.doAutoCreate())
623        this.intendedEffect = new CodeableConcept(); // cc
624    return this.intendedEffect;
625  }
626
627  public boolean hasIntendedEffect() {
628    return this.intendedEffect != null && !this.intendedEffect.isEmpty();
629  }
630
631  /**
632   * @param value {@link #intendedEffect} (The intended effect, aim or strategy to
633   *              be achieved by the indication.)
634   */
635  public MedicinalProductIndication setIntendedEffect(CodeableConcept value) {
636    this.intendedEffect = value;
637    return this;
638  }
639
640  /**
641   * @return {@link #duration} (Timing or duration information as part of the
642   *         indication.)
643   */
644  public Quantity getDuration() {
645    if (this.duration == null)
646      if (Configuration.errorOnAutoCreate())
647        throw new Error("Attempt to auto-create MedicinalProductIndication.duration");
648      else if (Configuration.doAutoCreate())
649        this.duration = new Quantity(); // cc
650    return this.duration;
651  }
652
653  public boolean hasDuration() {
654    return this.duration != null && !this.duration.isEmpty();
655  }
656
657  /**
658   * @param value {@link #duration} (Timing or duration information as part of the
659   *              indication.)
660   */
661  public MedicinalProductIndication setDuration(Quantity value) {
662    this.duration = value;
663    return this;
664  }
665
666  /**
667   * @return {@link #otherTherapy} (Information about the use of the medicinal
668   *         product in relation to other therapies described as part of the
669   *         indication.)
670   */
671  public List<MedicinalProductIndicationOtherTherapyComponent> getOtherTherapy() {
672    if (this.otherTherapy == null)
673      this.otherTherapy = new ArrayList<MedicinalProductIndicationOtherTherapyComponent>();
674    return this.otherTherapy;
675  }
676
677  /**
678   * @return Returns a reference to <code>this</code> for easy method chaining
679   */
680  public MedicinalProductIndication setOtherTherapy(
681      List<MedicinalProductIndicationOtherTherapyComponent> theOtherTherapy) {
682    this.otherTherapy = theOtherTherapy;
683    return this;
684  }
685
686  public boolean hasOtherTherapy() {
687    if (this.otherTherapy == null)
688      return false;
689    for (MedicinalProductIndicationOtherTherapyComponent item : this.otherTherapy)
690      if (!item.isEmpty())
691        return true;
692    return false;
693  }
694
695  public MedicinalProductIndicationOtherTherapyComponent addOtherTherapy() { // 3
696    MedicinalProductIndicationOtherTherapyComponent t = new MedicinalProductIndicationOtherTherapyComponent();
697    if (this.otherTherapy == null)
698      this.otherTherapy = new ArrayList<MedicinalProductIndicationOtherTherapyComponent>();
699    this.otherTherapy.add(t);
700    return t;
701  }
702
703  public MedicinalProductIndication addOtherTherapy(MedicinalProductIndicationOtherTherapyComponent t) { // 3
704    if (t == null)
705      return this;
706    if (this.otherTherapy == null)
707      this.otherTherapy = new ArrayList<MedicinalProductIndicationOtherTherapyComponent>();
708    this.otherTherapy.add(t);
709    return this;
710  }
711
712  /**
713   * @return The first repetition of repeating field {@link #otherTherapy},
714   *         creating it if it does not already exist
715   */
716  public MedicinalProductIndicationOtherTherapyComponent getOtherTherapyFirstRep() {
717    if (getOtherTherapy().isEmpty()) {
718      addOtherTherapy();
719    }
720    return getOtherTherapy().get(0);
721  }
722
723  /**
724   * @return {@link #undesirableEffect} (Describe the undesirable effects of the
725   *         medicinal product.)
726   */
727  public List<Reference> getUndesirableEffect() {
728    if (this.undesirableEffect == null)
729      this.undesirableEffect = new ArrayList<Reference>();
730    return this.undesirableEffect;
731  }
732
733  /**
734   * @return Returns a reference to <code>this</code> for easy method chaining
735   */
736  public MedicinalProductIndication setUndesirableEffect(List<Reference> theUndesirableEffect) {
737    this.undesirableEffect = theUndesirableEffect;
738    return this;
739  }
740
741  public boolean hasUndesirableEffect() {
742    if (this.undesirableEffect == null)
743      return false;
744    for (Reference item : this.undesirableEffect)
745      if (!item.isEmpty())
746        return true;
747    return false;
748  }
749
750  public Reference addUndesirableEffect() { // 3
751    Reference t = new Reference();
752    if (this.undesirableEffect == null)
753      this.undesirableEffect = new ArrayList<Reference>();
754    this.undesirableEffect.add(t);
755    return t;
756  }
757
758  public MedicinalProductIndication addUndesirableEffect(Reference t) { // 3
759    if (t == null)
760      return this;
761    if (this.undesirableEffect == null)
762      this.undesirableEffect = new ArrayList<Reference>();
763    this.undesirableEffect.add(t);
764    return this;
765  }
766
767  /**
768   * @return The first repetition of repeating field {@link #undesirableEffect},
769   *         creating it if it does not already exist
770   */
771  public Reference getUndesirableEffectFirstRep() {
772    if (getUndesirableEffect().isEmpty()) {
773      addUndesirableEffect();
774    }
775    return getUndesirableEffect().get(0);
776  }
777
778  /**
779   * @return {@link #population} (The population group to which this applies.)
780   */
781  public List<Population> getPopulation() {
782    if (this.population == null)
783      this.population = new ArrayList<Population>();
784    return this.population;
785  }
786
787  /**
788   * @return Returns a reference to <code>this</code> for easy method chaining
789   */
790  public MedicinalProductIndication setPopulation(List<Population> thePopulation) {
791    this.population = thePopulation;
792    return this;
793  }
794
795  public boolean hasPopulation() {
796    if (this.population == null)
797      return false;
798    for (Population item : this.population)
799      if (!item.isEmpty())
800        return true;
801    return false;
802  }
803
804  public Population addPopulation() { // 3
805    Population t = new Population();
806    if (this.population == null)
807      this.population = new ArrayList<Population>();
808    this.population.add(t);
809    return t;
810  }
811
812  public MedicinalProductIndication addPopulation(Population t) { // 3
813    if (t == null)
814      return this;
815    if (this.population == null)
816      this.population = new ArrayList<Population>();
817    this.population.add(t);
818    return this;
819  }
820
821  /**
822   * @return The first repetition of repeating field {@link #population}, creating
823   *         it if it does not already exist
824   */
825  public Population getPopulationFirstRep() {
826    if (getPopulation().isEmpty()) {
827      addPopulation();
828    }
829    return getPopulation().get(0);
830  }
831
832  protected void listChildren(List<Property> children) {
833    super.listChildren(children);
834    children.add(new Property("subject", "Reference(MedicinalProduct|Medication)",
835        "The medication for which this is an indication.", 0, java.lang.Integer.MAX_VALUE, subject));
836    children.add(new Property("diseaseSymptomProcedure", "CodeableConcept",
837        "The disease, symptom or procedure that is the indication for treatment.", 0, 1, diseaseSymptomProcedure));
838    children.add(new Property("diseaseStatus", "CodeableConcept",
839        "The status of the disease or symptom for which the indication applies.", 0, 1, diseaseStatus));
840    children.add(new Property("comorbidity", "CodeableConcept",
841        "Comorbidity (concurrent condition) or co-infection as part of the indication.", 0, java.lang.Integer.MAX_VALUE,
842        comorbidity));
843    children.add(new Property("intendedEffect", "CodeableConcept",
844        "The intended effect, aim or strategy to be achieved by the indication.", 0, 1, intendedEffect));
845    children.add(new Property("duration", "Quantity", "Timing or duration information as part of the indication.", 0, 1,
846        duration));
847    children.add(new Property("otherTherapy", "",
848        "Information about the use of the medicinal product in relation to other therapies described as part of the indication.",
849        0, java.lang.Integer.MAX_VALUE, otherTherapy));
850    children.add(new Property("undesirableEffect", "Reference(MedicinalProductUndesirableEffect)",
851        "Describe the undesirable effects of the medicinal product.", 0, java.lang.Integer.MAX_VALUE,
852        undesirableEffect));
853    children.add(new Property("population", "Population", "The population group to which this applies.", 0,
854        java.lang.Integer.MAX_VALUE, population));
855  }
856
857  @Override
858  public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
859    switch (_hash) {
860    case -1867885268:
861      /* subject */ return new Property("subject", "Reference(MedicinalProduct|Medication)",
862          "The medication for which this is an indication.", 0, java.lang.Integer.MAX_VALUE, subject);
863    case -1497395130:
864      /* diseaseSymptomProcedure */ return new Property("diseaseSymptomProcedure", "CodeableConcept",
865          "The disease, symptom or procedure that is the indication for treatment.", 0, 1, diseaseSymptomProcedure);
866    case -505503602:
867      /* diseaseStatus */ return new Property("diseaseStatus", "CodeableConcept",
868          "The status of the disease or symptom for which the indication applies.", 0, 1, diseaseStatus);
869    case -406395211:
870      /* comorbidity */ return new Property("comorbidity", "CodeableConcept",
871          "Comorbidity (concurrent condition) or co-infection as part of the indication.", 0,
872          java.lang.Integer.MAX_VALUE, comorbidity);
873    case 1587112348:
874      /* intendedEffect */ return new Property("intendedEffect", "CodeableConcept",
875          "The intended effect, aim or strategy to be achieved by the indication.", 0, 1, intendedEffect);
876    case -1992012396:
877      /* duration */ return new Property("duration", "Quantity",
878          "Timing or duration information as part of the indication.", 0, 1, duration);
879    case -544509127:
880      /* otherTherapy */ return new Property("otherTherapy", "",
881          "Information about the use of the medicinal product in relation to other therapies described as part of the indication.",
882          0, java.lang.Integer.MAX_VALUE, otherTherapy);
883    case 444367565:
884      /* undesirableEffect */ return new Property("undesirableEffect", "Reference(MedicinalProductUndesirableEffect)",
885          "Describe the undesirable effects of the medicinal product.", 0, java.lang.Integer.MAX_VALUE,
886          undesirableEffect);
887    case -2023558323:
888      /* population */ return new Property("population", "Population", "The population group to which this applies.", 0,
889          java.lang.Integer.MAX_VALUE, population);
890    default:
891      return super.getNamedProperty(_hash, _name, _checkValid);
892    }
893
894  }
895
896  @Override
897  public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
898    switch (hash) {
899    case -1867885268:
900      /* subject */ return this.subject == null ? new Base[0] : this.subject.toArray(new Base[this.subject.size()]); // Reference
901    case -1497395130:
902      /* diseaseSymptomProcedure */ return this.diseaseSymptomProcedure == null ? new Base[0]
903          : new Base[] { this.diseaseSymptomProcedure }; // CodeableConcept
904    case -505503602:
905      /* diseaseStatus */ return this.diseaseStatus == null ? new Base[0] : new Base[] { this.diseaseStatus }; // CodeableConcept
906    case -406395211:
907      /* comorbidity */ return this.comorbidity == null ? new Base[0]
908          : this.comorbidity.toArray(new Base[this.comorbidity.size()]); // CodeableConcept
909    case 1587112348:
910      /* intendedEffect */ return this.intendedEffect == null ? new Base[0] : new Base[] { this.intendedEffect }; // CodeableConcept
911    case -1992012396:
912      /* duration */ return this.duration == null ? new Base[0] : new Base[] { this.duration }; // Quantity
913    case -544509127:
914      /* otherTherapy */ return this.otherTherapy == null ? new Base[0]
915          : this.otherTherapy.toArray(new Base[this.otherTherapy.size()]); // MedicinalProductIndicationOtherTherapyComponent
916    case 444367565:
917      /* undesirableEffect */ return this.undesirableEffect == null ? new Base[0]
918          : this.undesirableEffect.toArray(new Base[this.undesirableEffect.size()]); // Reference
919    case -2023558323:
920      /* population */ return this.population == null ? new Base[0]
921          : this.population.toArray(new Base[this.population.size()]); // Population
922    default:
923      return super.getProperty(hash, name, checkValid);
924    }
925
926  }
927
928  @Override
929  public Base setProperty(int hash, String name, Base value) throws FHIRException {
930    switch (hash) {
931    case -1867885268: // subject
932      this.getSubject().add(castToReference(value)); // Reference
933      return value;
934    case -1497395130: // diseaseSymptomProcedure
935      this.diseaseSymptomProcedure = castToCodeableConcept(value); // CodeableConcept
936      return value;
937    case -505503602: // diseaseStatus
938      this.diseaseStatus = castToCodeableConcept(value); // CodeableConcept
939      return value;
940    case -406395211: // comorbidity
941      this.getComorbidity().add(castToCodeableConcept(value)); // CodeableConcept
942      return value;
943    case 1587112348: // intendedEffect
944      this.intendedEffect = castToCodeableConcept(value); // CodeableConcept
945      return value;
946    case -1992012396: // duration
947      this.duration = castToQuantity(value); // Quantity
948      return value;
949    case -544509127: // otherTherapy
950      this.getOtherTherapy().add((MedicinalProductIndicationOtherTherapyComponent) value); // MedicinalProductIndicationOtherTherapyComponent
951      return value;
952    case 444367565: // undesirableEffect
953      this.getUndesirableEffect().add(castToReference(value)); // Reference
954      return value;
955    case -2023558323: // population
956      this.getPopulation().add(castToPopulation(value)); // Population
957      return value;
958    default:
959      return super.setProperty(hash, name, value);
960    }
961
962  }
963
964  @Override
965  public Base setProperty(String name, Base value) throws FHIRException {
966    if (name.equals("subject")) {
967      this.getSubject().add(castToReference(value));
968    } else if (name.equals("diseaseSymptomProcedure")) {
969      this.diseaseSymptomProcedure = castToCodeableConcept(value); // CodeableConcept
970    } else if (name.equals("diseaseStatus")) {
971      this.diseaseStatus = castToCodeableConcept(value); // CodeableConcept
972    } else if (name.equals("comorbidity")) {
973      this.getComorbidity().add(castToCodeableConcept(value));
974    } else if (name.equals("intendedEffect")) {
975      this.intendedEffect = castToCodeableConcept(value); // CodeableConcept
976    } else if (name.equals("duration")) {
977      this.duration = castToQuantity(value); // Quantity
978    } else if (name.equals("otherTherapy")) {
979      this.getOtherTherapy().add((MedicinalProductIndicationOtherTherapyComponent) value);
980    } else if (name.equals("undesirableEffect")) {
981      this.getUndesirableEffect().add(castToReference(value));
982    } else if (name.equals("population")) {
983      this.getPopulation().add(castToPopulation(value));
984    } else
985      return super.setProperty(name, value);
986    return value;
987  }
988
989  @Override
990  public void removeChild(String name, Base value) throws FHIRException {
991    if (name.equals("subject")) {
992      this.getSubject().remove(castToReference(value));
993    } else if (name.equals("diseaseSymptomProcedure")) {
994      this.diseaseSymptomProcedure = null;
995    } else if (name.equals("diseaseStatus")) {
996      this.diseaseStatus = null;
997    } else if (name.equals("comorbidity")) {
998      this.getComorbidity().remove(castToCodeableConcept(value));
999    } else if (name.equals("intendedEffect")) {
1000      this.intendedEffect = null;
1001    } else if (name.equals("duration")) {
1002      this.duration = null;
1003    } else if (name.equals("otherTherapy")) {
1004      this.getOtherTherapy().remove((MedicinalProductIndicationOtherTherapyComponent) value);
1005    } else if (name.equals("undesirableEffect")) {
1006      this.getUndesirableEffect().remove(castToReference(value));
1007    } else if (name.equals("population")) {
1008      this.getPopulation().remove(castToPopulation(value));
1009    } else
1010      super.removeChild(name, value);
1011    
1012  }
1013
1014  @Override
1015  public Base makeProperty(int hash, String name) throws FHIRException {
1016    switch (hash) {
1017    case -1867885268:
1018      return addSubject();
1019    case -1497395130:
1020      return getDiseaseSymptomProcedure();
1021    case -505503602:
1022      return getDiseaseStatus();
1023    case -406395211:
1024      return addComorbidity();
1025    case 1587112348:
1026      return getIntendedEffect();
1027    case -1992012396:
1028      return getDuration();
1029    case -544509127:
1030      return addOtherTherapy();
1031    case 444367565:
1032      return addUndesirableEffect();
1033    case -2023558323:
1034      return addPopulation();
1035    default:
1036      return super.makeProperty(hash, name);
1037    }
1038
1039  }
1040
1041  @Override
1042  public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1043    switch (hash) {
1044    case -1867885268:
1045      /* subject */ return new String[] { "Reference" };
1046    case -1497395130:
1047      /* diseaseSymptomProcedure */ return new String[] { "CodeableConcept" };
1048    case -505503602:
1049      /* diseaseStatus */ return new String[] { "CodeableConcept" };
1050    case -406395211:
1051      /* comorbidity */ return new String[] { "CodeableConcept" };
1052    case 1587112348:
1053      /* intendedEffect */ return new String[] { "CodeableConcept" };
1054    case -1992012396:
1055      /* duration */ return new String[] { "Quantity" };
1056    case -544509127:
1057      /* otherTherapy */ return new String[] {};
1058    case 444367565:
1059      /* undesirableEffect */ return new String[] { "Reference" };
1060    case -2023558323:
1061      /* population */ return new String[] { "Population" };
1062    default:
1063      return super.getTypesForProperty(hash, name);
1064    }
1065
1066  }
1067
1068  @Override
1069  public Base addChild(String name) throws FHIRException {
1070    if (name.equals("subject")) {
1071      return addSubject();
1072    } else if (name.equals("diseaseSymptomProcedure")) {
1073      this.diseaseSymptomProcedure = new CodeableConcept();
1074      return this.diseaseSymptomProcedure;
1075    } else if (name.equals("diseaseStatus")) {
1076      this.diseaseStatus = new CodeableConcept();
1077      return this.diseaseStatus;
1078    } else if (name.equals("comorbidity")) {
1079      return addComorbidity();
1080    } else if (name.equals("intendedEffect")) {
1081      this.intendedEffect = new CodeableConcept();
1082      return this.intendedEffect;
1083    } else if (name.equals("duration")) {
1084      this.duration = new Quantity();
1085      return this.duration;
1086    } else if (name.equals("otherTherapy")) {
1087      return addOtherTherapy();
1088    } else if (name.equals("undesirableEffect")) {
1089      return addUndesirableEffect();
1090    } else if (name.equals("population")) {
1091      return addPopulation();
1092    } else
1093      return super.addChild(name);
1094  }
1095
1096  public String fhirType() {
1097    return "MedicinalProductIndication";
1098
1099  }
1100
1101  public MedicinalProductIndication copy() {
1102    MedicinalProductIndication dst = new MedicinalProductIndication();
1103    copyValues(dst);
1104    return dst;
1105  }
1106
1107  public void copyValues(MedicinalProductIndication dst) {
1108    super.copyValues(dst);
1109    if (subject != null) {
1110      dst.subject = new ArrayList<Reference>();
1111      for (Reference i : subject)
1112        dst.subject.add(i.copy());
1113    }
1114    ;
1115    dst.diseaseSymptomProcedure = diseaseSymptomProcedure == null ? null : diseaseSymptomProcedure.copy();
1116    dst.diseaseStatus = diseaseStatus == null ? null : diseaseStatus.copy();
1117    if (comorbidity != null) {
1118      dst.comorbidity = new ArrayList<CodeableConcept>();
1119      for (CodeableConcept i : comorbidity)
1120        dst.comorbidity.add(i.copy());
1121    }
1122    ;
1123    dst.intendedEffect = intendedEffect == null ? null : intendedEffect.copy();
1124    dst.duration = duration == null ? null : duration.copy();
1125    if (otherTherapy != null) {
1126      dst.otherTherapy = new ArrayList<MedicinalProductIndicationOtherTherapyComponent>();
1127      for (MedicinalProductIndicationOtherTherapyComponent i : otherTherapy)
1128        dst.otherTherapy.add(i.copy());
1129    }
1130    ;
1131    if (undesirableEffect != null) {
1132      dst.undesirableEffect = new ArrayList<Reference>();
1133      for (Reference i : undesirableEffect)
1134        dst.undesirableEffect.add(i.copy());
1135    }
1136    ;
1137    if (population != null) {
1138      dst.population = new ArrayList<Population>();
1139      for (Population i : population)
1140        dst.population.add(i.copy());
1141    }
1142    ;
1143  }
1144
1145  protected MedicinalProductIndication typedCopy() {
1146    return copy();
1147  }
1148
1149  @Override
1150  public boolean equalsDeep(Base other_) {
1151    if (!super.equalsDeep(other_))
1152      return false;
1153    if (!(other_ instanceof MedicinalProductIndication))
1154      return false;
1155    MedicinalProductIndication o = (MedicinalProductIndication) other_;
1156    return compareDeep(subject, o.subject, true)
1157        && compareDeep(diseaseSymptomProcedure, o.diseaseSymptomProcedure, true)
1158        && compareDeep(diseaseStatus, o.diseaseStatus, true) && compareDeep(comorbidity, o.comorbidity, true)
1159        && compareDeep(intendedEffect, o.intendedEffect, true) && compareDeep(duration, o.duration, true)
1160        && compareDeep(otherTherapy, o.otherTherapy, true) && compareDeep(undesirableEffect, o.undesirableEffect, true)
1161        && compareDeep(population, o.population, true);
1162  }
1163
1164  @Override
1165  public boolean equalsShallow(Base other_) {
1166    if (!super.equalsShallow(other_))
1167      return false;
1168    if (!(other_ instanceof MedicinalProductIndication))
1169      return false;
1170    MedicinalProductIndication o = (MedicinalProductIndication) other_;
1171    return true;
1172  }
1173
1174  public boolean isEmpty() {
1175    return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(subject, diseaseSymptomProcedure, diseaseStatus,
1176        comorbidity, intendedEffect, duration, otherTherapy, undesirableEffect, population);
1177  }
1178
1179  @Override
1180  public ResourceType getResourceType() {
1181    return ResourceType.MedicinalProductIndication;
1182  }
1183
1184  /**
1185   * Search parameter: <b>subject</b>
1186   * <p>
1187   * Description: <b>The medication for which this is an indication</b><br>
1188   * Type: <b>reference</b><br>
1189   * Path: <b>MedicinalProductIndication.subject</b><br>
1190   * </p>
1191   */
1192  @SearchParamDefinition(name = "subject", path = "MedicinalProductIndication.subject", description = "The medication for which this is an indication", type = "reference", target = {
1193      Medication.class, MedicinalProduct.class })
1194  public static final String SP_SUBJECT = "subject";
1195  /**
1196   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
1197   * <p>
1198   * Description: <b>The medication for which this is an indication</b><br>
1199   * Type: <b>reference</b><br>
1200   * Path: <b>MedicinalProductIndication.subject</b><br>
1201   * </p>
1202   */
1203  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
1204      SP_SUBJECT);
1205
1206  /**
1207   * Constant for fluent queries to be used to add include statements. Specifies
1208   * the path value of "<b>MedicinalProductIndication:subject</b>".
1209   */
1210  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include(
1211      "MedicinalProductIndication:subject").toLocked();
1212
1213}