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