001package org.hl7.fhir.r4.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Thu, Dec 27, 2018 10:06-0500 for FHIR v4.0.0
033
034import java.util.*;
035
036import ca.uhn.fhir.model.api.annotation.ResourceDef;
037import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
038import ca.uhn.fhir.model.api.annotation.Child;
039import ca.uhn.fhir.model.api.annotation.ChildOrder;
040import ca.uhn.fhir.model.api.annotation.Description;
041import ca.uhn.fhir.model.api.annotation.Block;
042import org.hl7.fhir.instance.model.api.*;
043import org.hl7.fhir.exceptions.FHIRException;
044/**
045 * The clinical particulars - indications, contraindications etc. of a medicinal product, including for regulatory purposes.
046 */
047@ResourceDef(name="MedicinalProductContraindication", profile="http://hl7.org/fhir/StructureDefinition/MedicinalProductContraindication")
048public class MedicinalProductContraindication extends DomainResource {
049
050    @Block()
051    public static class MedicinalProductContraindicationOtherTherapyComponent extends BackboneElement implements IBaseBackboneElement {
052        /**
053         * The type of relationship between the medicinal product indication or contraindication and another therapy.
054         */
055        @Child(name = "therapyRelationshipType", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=true)
056        @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." )
057        protected CodeableConcept therapyRelationshipType;
058
059        /**
060         * Reference to a specific medication (active substance, medicinal product or class of products) as part of an indication or contraindication.
061         */
062        @Child(name = "medication", type = {CodeableConcept.class, MedicinalProduct.class, Medication.class, Substance.class, SubstanceSpecification.class}, order=2, min=1, max=1, modifier=false, summary=true)
063        @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." )
064        protected Type medication;
065
066        private static final long serialVersionUID = 1438478115L;
067
068    /**
069     * Constructor
070     */
071      public MedicinalProductContraindicationOtherTherapyComponent() {
072        super();
073      }
074
075    /**
076     * Constructor
077     */
078      public MedicinalProductContraindicationOtherTherapyComponent(CodeableConcept therapyRelationshipType, Type medication) {
079        super();
080        this.therapyRelationshipType = therapyRelationshipType;
081        this.medication = medication;
082      }
083
084        /**
085         * @return {@link #therapyRelationshipType} (The type of relationship between the medicinal product indication or contraindication and another therapy.)
086         */
087        public CodeableConcept getTherapyRelationshipType() { 
088          if (this.therapyRelationshipType == null)
089            if (Configuration.errorOnAutoCreate())
090              throw new Error("Attempt to auto-create MedicinalProductContraindicationOtherTherapyComponent.therapyRelationshipType");
091            else if (Configuration.doAutoCreate())
092              this.therapyRelationshipType = new CodeableConcept(); // cc
093          return this.therapyRelationshipType;
094        }
095
096        public boolean hasTherapyRelationshipType() { 
097          return this.therapyRelationshipType != null && !this.therapyRelationshipType.isEmpty();
098        }
099
100        /**
101         * @param value {@link #therapyRelationshipType} (The type of relationship between the medicinal product indication or contraindication and another therapy.)
102         */
103        public MedicinalProductContraindicationOtherTherapyComponent setTherapyRelationshipType(CodeableConcept value) { 
104          this.therapyRelationshipType = value;
105          return this;
106        }
107
108        /**
109         * @return {@link #medication} (Reference to a specific medication (active substance, medicinal product or class of products) as part of an indication or contraindication.)
110         */
111        public Type getMedication() { 
112          return this.medication;
113        }
114
115        /**
116         * @return {@link #medication} (Reference to a specific medication (active substance, medicinal product or class of products) as part of an indication or contraindication.)
117         */
118        public CodeableConcept getMedicationCodeableConcept() throws FHIRException { 
119          if (this.medication == null)
120            this.medication = new CodeableConcept();
121          if (!(this.medication instanceof CodeableConcept))
122            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.medication.getClass().getName()+" was encountered");
123          return (CodeableConcept) this.medication;
124        }
125
126        public boolean hasMedicationCodeableConcept() { 
127          return this != null && this.medication instanceof CodeableConcept;
128        }
129
130        /**
131         * @return {@link #medication} (Reference to a specific medication (active substance, medicinal product or class of products) as part of an indication or contraindication.)
132         */
133        public Reference getMedicationReference() throws FHIRException { 
134          if (this.medication == null)
135            this.medication = new Reference();
136          if (!(this.medication instanceof Reference))
137            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.medication.getClass().getName()+" was encountered");
138          return (Reference) this.medication;
139        }
140
141        public boolean hasMedicationReference() { 
142          return this != null && this.medication instanceof Reference;
143        }
144
145        public boolean hasMedication() { 
146          return this.medication != null && !this.medication.isEmpty();
147        }
148
149        /**
150         * @param value {@link #medication} (Reference to a specific medication (active substance, medicinal product or class of products) as part of an indication or contraindication.)
151         */
152        public MedicinalProductContraindicationOtherTherapyComponent setMedication(Type value) { 
153          if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
154            throw new Error("Not the right type for MedicinalProductContraindication.otherTherapy.medication[x]: "+value.fhirType());
155          this.medication = value;
156          return this;
157        }
158
159        protected void listChildren(List<Property> children) {
160          super.listChildren(children);
161          children.add(new Property("therapyRelationshipType", "CodeableConcept", "The type of relationship between the medicinal product indication or contraindication and another therapy.", 0, 1, therapyRelationshipType));
162          children.add(new Property("medication[x]", "CodeableConcept|Reference(MedicinalProduct|Medication|Substance|SubstanceSpecification)", "Reference to a specific medication (active substance, medicinal product or class of products) as part of an indication or contraindication.", 0, 1, medication));
163        }
164
165        @Override
166        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
167          switch (_hash) {
168          case -551658469: /*therapyRelationshipType*/  return new Property("therapyRelationshipType", "CodeableConcept", "The type of relationship between the medicinal product indication or contraindication and another therapy.", 0, 1, therapyRelationshipType);
169          case 1458402129: /*medication[x]*/  return new Property("medication[x]", "CodeableConcept|Reference(MedicinalProduct|Medication|Substance|SubstanceSpecification)", "Reference to a specific medication (active substance, medicinal product or class of products) as part of an indication or contraindication.", 0, 1, medication);
170          case 1998965455: /*medication*/  return new Property("medication[x]", "CodeableConcept|Reference(MedicinalProduct|Medication|Substance|SubstanceSpecification)", "Reference to a specific medication (active substance, medicinal product or class of products) as part of an indication or contraindication.", 0, 1, medication);
171          case -209845038: /*medicationCodeableConcept*/  return new Property("medication[x]", "CodeableConcept|Reference(MedicinalProduct|Medication|Substance|SubstanceSpecification)", "Reference to a specific medication (active substance, medicinal product or class of products) as part of an indication or contraindication.", 0, 1, medication);
172          case 2104315196: /*medicationReference*/  return new Property("medication[x]", "CodeableConcept|Reference(MedicinalProduct|Medication|Substance|SubstanceSpecification)", "Reference to a specific medication (active substance, medicinal product or class of products) as part of an indication or contraindication.", 0, 1, medication);
173          default: return super.getNamedProperty(_hash, _name, _checkValid);
174          }
175
176        }
177
178      @Override
179      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
180        switch (hash) {
181        case -551658469: /*therapyRelationshipType*/ return this.therapyRelationshipType == null ? new Base[0] : new Base[] {this.therapyRelationshipType}; // CodeableConcept
182        case 1998965455: /*medication*/ return this.medication == null ? new Base[0] : new Base[] {this.medication}; // Type
183        default: return super.getProperty(hash, name, checkValid);
184        }
185
186      }
187
188      @Override
189      public Base setProperty(int hash, String name, Base value) throws FHIRException {
190        switch (hash) {
191        case -551658469: // therapyRelationshipType
192          this.therapyRelationshipType = castToCodeableConcept(value); // CodeableConcept
193          return value;
194        case 1998965455: // medication
195          this.medication = castToType(value); // Type
196          return value;
197        default: return super.setProperty(hash, name, value);
198        }
199
200      }
201
202      @Override
203      public Base setProperty(String name, Base value) throws FHIRException {
204        if (name.equals("therapyRelationshipType")) {
205          this.therapyRelationshipType = castToCodeableConcept(value); // CodeableConcept
206        } else if (name.equals("medication[x]")) {
207          this.medication = castToType(value); // Type
208        } else
209          return super.setProperty(name, value);
210        return value;
211      }
212
213      @Override
214      public Base makeProperty(int hash, String name) throws FHIRException {
215        switch (hash) {
216        case -551658469:  return getTherapyRelationshipType(); 
217        case 1458402129:  return getMedication(); 
218        case 1998965455:  return getMedication(); 
219        default: return super.makeProperty(hash, name);
220        }
221
222      }
223
224      @Override
225      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
226        switch (hash) {
227        case -551658469: /*therapyRelationshipType*/ return new String[] {"CodeableConcept"};
228        case 1998965455: /*medication*/ return new String[] {"CodeableConcept", "Reference"};
229        default: return super.getTypesForProperty(hash, name);
230        }
231
232      }
233
234      @Override
235      public Base addChild(String name) throws FHIRException {
236        if (name.equals("therapyRelationshipType")) {
237          this.therapyRelationshipType = new CodeableConcept();
238          return this.therapyRelationshipType;
239        }
240        else if (name.equals("medicationCodeableConcept")) {
241          this.medication = new CodeableConcept();
242          return this.medication;
243        }
244        else if (name.equals("medicationReference")) {
245          this.medication = new Reference();
246          return this.medication;
247        }
248        else
249          return super.addChild(name);
250      }
251
252      public MedicinalProductContraindicationOtherTherapyComponent copy() {
253        MedicinalProductContraindicationOtherTherapyComponent dst = new MedicinalProductContraindicationOtherTherapyComponent();
254        copyValues(dst);
255        dst.therapyRelationshipType = therapyRelationshipType == null ? null : therapyRelationshipType.copy();
256        dst.medication = medication == null ? null : medication.copy();
257        return dst;
258      }
259
260      @Override
261      public boolean equalsDeep(Base other_) {
262        if (!super.equalsDeep(other_))
263          return false;
264        if (!(other_ instanceof MedicinalProductContraindicationOtherTherapyComponent))
265          return false;
266        MedicinalProductContraindicationOtherTherapyComponent o = (MedicinalProductContraindicationOtherTherapyComponent) other_;
267        return compareDeep(therapyRelationshipType, o.therapyRelationshipType, true) && compareDeep(medication, o.medication, true)
268          ;
269      }
270
271      @Override
272      public boolean equalsShallow(Base other_) {
273        if (!super.equalsShallow(other_))
274          return false;
275        if (!(other_ instanceof MedicinalProductContraindicationOtherTherapyComponent))
276          return false;
277        MedicinalProductContraindicationOtherTherapyComponent o = (MedicinalProductContraindicationOtherTherapyComponent) other_;
278        return true;
279      }
280
281      public boolean isEmpty() {
282        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(therapyRelationshipType, medication
283          );
284      }
285
286  public String fhirType() {
287    return "MedicinalProductContraindication.otherTherapy";
288
289  }
290
291  }
292
293    /**
294     * The medication for which this is an indication.
295     */
296    @Child(name = "subject", type = {MedicinalProduct.class, Medication.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
297    @Description(shortDefinition="The medication for which this is an indication", formalDefinition="The medication for which this is an indication." )
298    protected List<Reference> subject;
299    /**
300     * The actual objects that are the target of the reference (The medication for which this is an indication.)
301     */
302    protected List<Resource> subjectTarget;
303
304
305    /**
306     * The disease, symptom or procedure for the contraindication.
307     */
308    @Child(name = "disease", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
309    @Description(shortDefinition="The disease, symptom or procedure for the contraindication", formalDefinition="The disease, symptom or procedure for the contraindication." )
310    protected CodeableConcept disease;
311
312    /**
313     * The status of the disease or symptom for the contraindication.
314     */
315    @Child(name = "diseaseStatus", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
316    @Description(shortDefinition="The status of the disease or symptom for the contraindication", formalDefinition="The status of the disease or symptom for the contraindication." )
317    protected CodeableConcept diseaseStatus;
318
319    /**
320     * A comorbidity (concurrent condition) or coinfection.
321     */
322    @Child(name = "comorbidity", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
323    @Description(shortDefinition="A comorbidity (concurrent condition) or coinfection", formalDefinition="A comorbidity (concurrent condition) or coinfection." )
324    protected List<CodeableConcept> comorbidity;
325
326    /**
327     * Information about the use of the medicinal product in relation to other therapies as part of the indication.
328     */
329    @Child(name = "therapeuticIndication", type = {MedicinalProductIndication.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
330    @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." )
331    protected List<Reference> therapeuticIndication;
332    /**
333     * The actual objects that are the target of the reference (Information about the use of the medicinal product in relation to other therapies as part of the indication.)
334     */
335    protected List<MedicinalProductIndication> therapeuticIndicationTarget;
336
337
338    /**
339     * Information about the use of the medicinal product in relation to other therapies described as part of the indication.
340     */
341    @Child(name = "otherTherapy", type = {}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
342    @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." )
343    protected List<MedicinalProductContraindicationOtherTherapyComponent> otherTherapy;
344
345    /**
346     * The population group to which this applies.
347     */
348    @Child(name = "population", type = {Population.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
349    @Description(shortDefinition="The population group to which this applies", formalDefinition="The population group to which this applies." )
350    protected List<Population> population;
351
352    private static final long serialVersionUID = -1746103034L;
353
354  /**
355   * Constructor
356   */
357    public MedicinalProductContraindication() {
358      super();
359    }
360
361    /**
362     * @return {@link #subject} (The medication for which this is an indication.)
363     */
364    public List<Reference> getSubject() { 
365      if (this.subject == null)
366        this.subject = new ArrayList<Reference>();
367      return this.subject;
368    }
369
370    /**
371     * @return Returns a reference to <code>this</code> for easy method chaining
372     */
373    public MedicinalProductContraindication setSubject(List<Reference> theSubject) { 
374      this.subject = theSubject;
375      return this;
376    }
377
378    public boolean hasSubject() { 
379      if (this.subject == null)
380        return false;
381      for (Reference item : this.subject)
382        if (!item.isEmpty())
383          return true;
384      return false;
385    }
386
387    public Reference addSubject() { //3
388      Reference t = new Reference();
389      if (this.subject == null)
390        this.subject = new ArrayList<Reference>();
391      this.subject.add(t);
392      return t;
393    }
394
395    public MedicinalProductContraindication addSubject(Reference t) { //3
396      if (t == null)
397        return this;
398      if (this.subject == null)
399        this.subject = new ArrayList<Reference>();
400      this.subject.add(t);
401      return this;
402    }
403
404    /**
405     * @return The first repetition of repeating field {@link #subject}, creating it if it does not already exist
406     */
407    public Reference getSubjectFirstRep() { 
408      if (getSubject().isEmpty()) {
409        addSubject();
410      }
411      return getSubject().get(0);
412    }
413
414    /**
415     * @deprecated Use Reference#setResource(IBaseResource) instead
416     */
417    @Deprecated
418    public List<Resource> getSubjectTarget() { 
419      if (this.subjectTarget == null)
420        this.subjectTarget = new ArrayList<Resource>();
421      return this.subjectTarget;
422    }
423
424    /**
425     * @return {@link #disease} (The disease, symptom or procedure for the contraindication.)
426     */
427    public CodeableConcept getDisease() { 
428      if (this.disease == null)
429        if (Configuration.errorOnAutoCreate())
430          throw new Error("Attempt to auto-create MedicinalProductContraindication.disease");
431        else if (Configuration.doAutoCreate())
432          this.disease = new CodeableConcept(); // cc
433      return this.disease;
434    }
435
436    public boolean hasDisease() { 
437      return this.disease != null && !this.disease.isEmpty();
438    }
439
440    /**
441     * @param value {@link #disease} (The disease, symptom or procedure for the contraindication.)
442     */
443    public MedicinalProductContraindication setDisease(CodeableConcept value) { 
444      this.disease = value;
445      return this;
446    }
447
448    /**
449     * @return {@link #diseaseStatus} (The status of the disease or symptom for the contraindication.)
450     */
451    public CodeableConcept getDiseaseStatus() { 
452      if (this.diseaseStatus == null)
453        if (Configuration.errorOnAutoCreate())
454          throw new Error("Attempt to auto-create MedicinalProductContraindication.diseaseStatus");
455        else if (Configuration.doAutoCreate())
456          this.diseaseStatus = new CodeableConcept(); // cc
457      return this.diseaseStatus;
458    }
459
460    public boolean hasDiseaseStatus() { 
461      return this.diseaseStatus != null && !this.diseaseStatus.isEmpty();
462    }
463
464    /**
465     * @param value {@link #diseaseStatus} (The status of the disease or symptom for the contraindication.)
466     */
467    public MedicinalProductContraindication setDiseaseStatus(CodeableConcept value) { 
468      this.diseaseStatus = value;
469      return this;
470    }
471
472    /**
473     * @return {@link #comorbidity} (A comorbidity (concurrent condition) or coinfection.)
474     */
475    public List<CodeableConcept> getComorbidity() { 
476      if (this.comorbidity == null)
477        this.comorbidity = new ArrayList<CodeableConcept>();
478      return this.comorbidity;
479    }
480
481    /**
482     * @return Returns a reference to <code>this</code> for easy method chaining
483     */
484    public MedicinalProductContraindication setComorbidity(List<CodeableConcept> theComorbidity) { 
485      this.comorbidity = theComorbidity;
486      return this;
487    }
488
489    public boolean hasComorbidity() { 
490      if (this.comorbidity == null)
491        return false;
492      for (CodeableConcept item : this.comorbidity)
493        if (!item.isEmpty())
494          return true;
495      return false;
496    }
497
498    public CodeableConcept addComorbidity() { //3
499      CodeableConcept t = new CodeableConcept();
500      if (this.comorbidity == null)
501        this.comorbidity = new ArrayList<CodeableConcept>();
502      this.comorbidity.add(t);
503      return t;
504    }
505
506    public MedicinalProductContraindication addComorbidity(CodeableConcept t) { //3
507      if (t == null)
508        return this;
509      if (this.comorbidity == null)
510        this.comorbidity = new ArrayList<CodeableConcept>();
511      this.comorbidity.add(t);
512      return this;
513    }
514
515    /**
516     * @return The first repetition of repeating field {@link #comorbidity}, creating it if it does not already exist
517     */
518    public CodeableConcept getComorbidityFirstRep() { 
519      if (getComorbidity().isEmpty()) {
520        addComorbidity();
521      }
522      return getComorbidity().get(0);
523    }
524
525    /**
526     * @return {@link #therapeuticIndication} (Information about the use of the medicinal product in relation to other therapies as part of the indication.)
527     */
528    public List<Reference> getTherapeuticIndication() { 
529      if (this.therapeuticIndication == null)
530        this.therapeuticIndication = new ArrayList<Reference>();
531      return this.therapeuticIndication;
532    }
533
534    /**
535     * @return Returns a reference to <code>this</code> for easy method chaining
536     */
537    public MedicinalProductContraindication setTherapeuticIndication(List<Reference> theTherapeuticIndication) { 
538      this.therapeuticIndication = theTherapeuticIndication;
539      return this;
540    }
541
542    public boolean hasTherapeuticIndication() { 
543      if (this.therapeuticIndication == null)
544        return false;
545      for (Reference item : this.therapeuticIndication)
546        if (!item.isEmpty())
547          return true;
548      return false;
549    }
550
551    public Reference addTherapeuticIndication() { //3
552      Reference t = new Reference();
553      if (this.therapeuticIndication == null)
554        this.therapeuticIndication = new ArrayList<Reference>();
555      this.therapeuticIndication.add(t);
556      return t;
557    }
558
559    public MedicinalProductContraindication addTherapeuticIndication(Reference t) { //3
560      if (t == null)
561        return this;
562      if (this.therapeuticIndication == null)
563        this.therapeuticIndication = new ArrayList<Reference>();
564      this.therapeuticIndication.add(t);
565      return this;
566    }
567
568    /**
569     * @return The first repetition of repeating field {@link #therapeuticIndication}, creating it if it does not already exist
570     */
571    public Reference getTherapeuticIndicationFirstRep() { 
572      if (getTherapeuticIndication().isEmpty()) {
573        addTherapeuticIndication();
574      }
575      return getTherapeuticIndication().get(0);
576    }
577
578    /**
579     * @deprecated Use Reference#setResource(IBaseResource) instead
580     */
581    @Deprecated
582    public List<MedicinalProductIndication> getTherapeuticIndicationTarget() { 
583      if (this.therapeuticIndicationTarget == null)
584        this.therapeuticIndicationTarget = new ArrayList<MedicinalProductIndication>();
585      return this.therapeuticIndicationTarget;
586    }
587
588    /**
589     * @deprecated Use Reference#setResource(IBaseResource) instead
590     */
591    @Deprecated
592    public MedicinalProductIndication addTherapeuticIndicationTarget() { 
593      MedicinalProductIndication r = new MedicinalProductIndication();
594      if (this.therapeuticIndicationTarget == null)
595        this.therapeuticIndicationTarget = new ArrayList<MedicinalProductIndication>();
596      this.therapeuticIndicationTarget.add(r);
597      return r;
598    }
599
600    /**
601     * @return {@link #otherTherapy} (Information about the use of the medicinal product in relation to other therapies described as part of the indication.)
602     */
603    public List<MedicinalProductContraindicationOtherTherapyComponent> getOtherTherapy() { 
604      if (this.otherTherapy == null)
605        this.otherTherapy = new ArrayList<MedicinalProductContraindicationOtherTherapyComponent>();
606      return this.otherTherapy;
607    }
608
609    /**
610     * @return Returns a reference to <code>this</code> for easy method chaining
611     */
612    public MedicinalProductContraindication setOtherTherapy(List<MedicinalProductContraindicationOtherTherapyComponent> theOtherTherapy) { 
613      this.otherTherapy = theOtherTherapy;
614      return this;
615    }
616
617    public boolean hasOtherTherapy() { 
618      if (this.otherTherapy == null)
619        return false;
620      for (MedicinalProductContraindicationOtherTherapyComponent item : this.otherTherapy)
621        if (!item.isEmpty())
622          return true;
623      return false;
624    }
625
626    public MedicinalProductContraindicationOtherTherapyComponent addOtherTherapy() { //3
627      MedicinalProductContraindicationOtherTherapyComponent t = new MedicinalProductContraindicationOtherTherapyComponent();
628      if (this.otherTherapy == null)
629        this.otherTherapy = new ArrayList<MedicinalProductContraindicationOtherTherapyComponent>();
630      this.otherTherapy.add(t);
631      return t;
632    }
633
634    public MedicinalProductContraindication addOtherTherapy(MedicinalProductContraindicationOtherTherapyComponent t) { //3
635      if (t == null)
636        return this;
637      if (this.otherTherapy == null)
638        this.otherTherapy = new ArrayList<MedicinalProductContraindicationOtherTherapyComponent>();
639      this.otherTherapy.add(t);
640      return this;
641    }
642
643    /**
644     * @return The first repetition of repeating field {@link #otherTherapy}, creating it if it does not already exist
645     */
646    public MedicinalProductContraindicationOtherTherapyComponent getOtherTherapyFirstRep() { 
647      if (getOtherTherapy().isEmpty()) {
648        addOtherTherapy();
649      }
650      return getOtherTherapy().get(0);
651    }
652
653    /**
654     * @return {@link #population} (The population group to which this applies.)
655     */
656    public List<Population> getPopulation() { 
657      if (this.population == null)
658        this.population = new ArrayList<Population>();
659      return this.population;
660    }
661
662    /**
663     * @return Returns a reference to <code>this</code> for easy method chaining
664     */
665    public MedicinalProductContraindication setPopulation(List<Population> thePopulation) { 
666      this.population = thePopulation;
667      return this;
668    }
669
670    public boolean hasPopulation() { 
671      if (this.population == null)
672        return false;
673      for (Population item : this.population)
674        if (!item.isEmpty())
675          return true;
676      return false;
677    }
678
679    public Population addPopulation() { //3
680      Population t = new Population();
681      if (this.population == null)
682        this.population = new ArrayList<Population>();
683      this.population.add(t);
684      return t;
685    }
686
687    public MedicinalProductContraindication addPopulation(Population t) { //3
688      if (t == null)
689        return this;
690      if (this.population == null)
691        this.population = new ArrayList<Population>();
692      this.population.add(t);
693      return this;
694    }
695
696    /**
697     * @return The first repetition of repeating field {@link #population}, creating it if it does not already exist
698     */
699    public Population getPopulationFirstRep() { 
700      if (getPopulation().isEmpty()) {
701        addPopulation();
702      }
703      return getPopulation().get(0);
704    }
705
706      protected void listChildren(List<Property> children) {
707        super.listChildren(children);
708        children.add(new Property("subject", "Reference(MedicinalProduct|Medication)", "The medication for which this is an indication.", 0, java.lang.Integer.MAX_VALUE, subject));
709        children.add(new Property("disease", "CodeableConcept", "The disease, symptom or procedure for the contraindication.", 0, 1, disease));
710        children.add(new Property("diseaseStatus", "CodeableConcept", "The status of the disease or symptom for the contraindication.", 0, 1, diseaseStatus));
711        children.add(new Property("comorbidity", "CodeableConcept", "A comorbidity (concurrent condition) or coinfection.", 0, java.lang.Integer.MAX_VALUE, comorbidity));
712        children.add(new Property("therapeuticIndication", "Reference(MedicinalProductIndication)", "Information about the use of the medicinal product in relation to other therapies as part of the indication.", 0, java.lang.Integer.MAX_VALUE, therapeuticIndication));
713        children.add(new Property("otherTherapy", "", "Information about the use of the medicinal product in relation to other therapies described as part of the indication.", 0, java.lang.Integer.MAX_VALUE, otherTherapy));
714        children.add(new Property("population", "Population", "The population group to which this applies.", 0, java.lang.Integer.MAX_VALUE, population));
715      }
716
717      @Override
718      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
719        switch (_hash) {
720        case -1867885268: /*subject*/  return new Property("subject", "Reference(MedicinalProduct|Medication)", "The medication for which this is an indication.", 0, java.lang.Integer.MAX_VALUE, subject);
721        case 1671426428: /*disease*/  return new Property("disease", "CodeableConcept", "The disease, symptom or procedure for the contraindication.", 0, 1, disease);
722        case -505503602: /*diseaseStatus*/  return new Property("diseaseStatus", "CodeableConcept", "The status of the disease or symptom for the contraindication.", 0, 1, diseaseStatus);
723        case -406395211: /*comorbidity*/  return new Property("comorbidity", "CodeableConcept", "A comorbidity (concurrent condition) or coinfection.", 0, java.lang.Integer.MAX_VALUE, comorbidity);
724        case -1925150262: /*therapeuticIndication*/  return new Property("therapeuticIndication", "Reference(MedicinalProductIndication)", "Information about the use of the medicinal product in relation to other therapies as part of the indication.", 0, java.lang.Integer.MAX_VALUE, therapeuticIndication);
725        case -544509127: /*otherTherapy*/  return new Property("otherTherapy", "", "Information about the use of the medicinal product in relation to other therapies described as part of the indication.", 0, java.lang.Integer.MAX_VALUE, otherTherapy);
726        case -2023558323: /*population*/  return new Property("population", "Population", "The population group to which this applies.", 0, java.lang.Integer.MAX_VALUE, population);
727        default: return super.getNamedProperty(_hash, _name, _checkValid);
728        }
729
730      }
731
732      @Override
733      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
734        switch (hash) {
735        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : this.subject.toArray(new Base[this.subject.size()]); // Reference
736        case 1671426428: /*disease*/ return this.disease == null ? new Base[0] : new Base[] {this.disease}; // CodeableConcept
737        case -505503602: /*diseaseStatus*/ return this.diseaseStatus == null ? new Base[0] : new Base[] {this.diseaseStatus}; // CodeableConcept
738        case -406395211: /*comorbidity*/ return this.comorbidity == null ? new Base[0] : this.comorbidity.toArray(new Base[this.comorbidity.size()]); // CodeableConcept
739        case -1925150262: /*therapeuticIndication*/ return this.therapeuticIndication == null ? new Base[0] : this.therapeuticIndication.toArray(new Base[this.therapeuticIndication.size()]); // Reference
740        case -544509127: /*otherTherapy*/ return this.otherTherapy == null ? new Base[0] : this.otherTherapy.toArray(new Base[this.otherTherapy.size()]); // MedicinalProductContraindicationOtherTherapyComponent
741        case -2023558323: /*population*/ return this.population == null ? new Base[0] : this.population.toArray(new Base[this.population.size()]); // Population
742        default: return super.getProperty(hash, name, checkValid);
743        }
744
745      }
746
747      @Override
748      public Base setProperty(int hash, String name, Base value) throws FHIRException {
749        switch (hash) {
750        case -1867885268: // subject
751          this.getSubject().add(castToReference(value)); // Reference
752          return value;
753        case 1671426428: // disease
754          this.disease = castToCodeableConcept(value); // CodeableConcept
755          return value;
756        case -505503602: // diseaseStatus
757          this.diseaseStatus = castToCodeableConcept(value); // CodeableConcept
758          return value;
759        case -406395211: // comorbidity
760          this.getComorbidity().add(castToCodeableConcept(value)); // CodeableConcept
761          return value;
762        case -1925150262: // therapeuticIndication
763          this.getTherapeuticIndication().add(castToReference(value)); // Reference
764          return value;
765        case -544509127: // otherTherapy
766          this.getOtherTherapy().add((MedicinalProductContraindicationOtherTherapyComponent) value); // MedicinalProductContraindicationOtherTherapyComponent
767          return value;
768        case -2023558323: // population
769          this.getPopulation().add(castToPopulation(value)); // Population
770          return value;
771        default: return super.setProperty(hash, name, value);
772        }
773
774      }
775
776      @Override
777      public Base setProperty(String name, Base value) throws FHIRException {
778        if (name.equals("subject")) {
779          this.getSubject().add(castToReference(value));
780        } else if (name.equals("disease")) {
781          this.disease = castToCodeableConcept(value); // CodeableConcept
782        } else if (name.equals("diseaseStatus")) {
783          this.diseaseStatus = castToCodeableConcept(value); // CodeableConcept
784        } else if (name.equals("comorbidity")) {
785          this.getComorbidity().add(castToCodeableConcept(value));
786        } else if (name.equals("therapeuticIndication")) {
787          this.getTherapeuticIndication().add(castToReference(value));
788        } else if (name.equals("otherTherapy")) {
789          this.getOtherTherapy().add((MedicinalProductContraindicationOtherTherapyComponent) value);
790        } else if (name.equals("population")) {
791          this.getPopulation().add(castToPopulation(value));
792        } else
793          return super.setProperty(name, value);
794        return value;
795      }
796
797      @Override
798      public Base makeProperty(int hash, String name) throws FHIRException {
799        switch (hash) {
800        case -1867885268:  return addSubject(); 
801        case 1671426428:  return getDisease(); 
802        case -505503602:  return getDiseaseStatus(); 
803        case -406395211:  return addComorbidity(); 
804        case -1925150262:  return addTherapeuticIndication(); 
805        case -544509127:  return addOtherTherapy(); 
806        case -2023558323:  return addPopulation(); 
807        default: return super.makeProperty(hash, name);
808        }
809
810      }
811
812      @Override
813      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
814        switch (hash) {
815        case -1867885268: /*subject*/ return new String[] {"Reference"};
816        case 1671426428: /*disease*/ return new String[] {"CodeableConcept"};
817        case -505503602: /*diseaseStatus*/ return new String[] {"CodeableConcept"};
818        case -406395211: /*comorbidity*/ return new String[] {"CodeableConcept"};
819        case -1925150262: /*therapeuticIndication*/ return new String[] {"Reference"};
820        case -544509127: /*otherTherapy*/ return new String[] {};
821        case -2023558323: /*population*/ return new String[] {"Population"};
822        default: return super.getTypesForProperty(hash, name);
823        }
824
825      }
826
827      @Override
828      public Base addChild(String name) throws FHIRException {
829        if (name.equals("subject")) {
830          return addSubject();
831        }
832        else if (name.equals("disease")) {
833          this.disease = new CodeableConcept();
834          return this.disease;
835        }
836        else if (name.equals("diseaseStatus")) {
837          this.diseaseStatus = new CodeableConcept();
838          return this.diseaseStatus;
839        }
840        else if (name.equals("comorbidity")) {
841          return addComorbidity();
842        }
843        else if (name.equals("therapeuticIndication")) {
844          return addTherapeuticIndication();
845        }
846        else if (name.equals("otherTherapy")) {
847          return addOtherTherapy();
848        }
849        else if (name.equals("population")) {
850          return addPopulation();
851        }
852        else
853          return super.addChild(name);
854      }
855
856  public String fhirType() {
857    return "MedicinalProductContraindication";
858
859  }
860
861      public MedicinalProductContraindication copy() {
862        MedicinalProductContraindication dst = new MedicinalProductContraindication();
863        copyValues(dst);
864        if (subject != null) {
865          dst.subject = new ArrayList<Reference>();
866          for (Reference i : subject)
867            dst.subject.add(i.copy());
868        };
869        dst.disease = disease == null ? null : disease.copy();
870        dst.diseaseStatus = diseaseStatus == null ? null : diseaseStatus.copy();
871        if (comorbidity != null) {
872          dst.comorbidity = new ArrayList<CodeableConcept>();
873          for (CodeableConcept i : comorbidity)
874            dst.comorbidity.add(i.copy());
875        };
876        if (therapeuticIndication != null) {
877          dst.therapeuticIndication = new ArrayList<Reference>();
878          for (Reference i : therapeuticIndication)
879            dst.therapeuticIndication.add(i.copy());
880        };
881        if (otherTherapy != null) {
882          dst.otherTherapy = new ArrayList<MedicinalProductContraindicationOtherTherapyComponent>();
883          for (MedicinalProductContraindicationOtherTherapyComponent i : otherTherapy)
884            dst.otherTherapy.add(i.copy());
885        };
886        if (population != null) {
887          dst.population = new ArrayList<Population>();
888          for (Population i : population)
889            dst.population.add(i.copy());
890        };
891        return dst;
892      }
893
894      protected MedicinalProductContraindication typedCopy() {
895        return copy();
896      }
897
898      @Override
899      public boolean equalsDeep(Base other_) {
900        if (!super.equalsDeep(other_))
901          return false;
902        if (!(other_ instanceof MedicinalProductContraindication))
903          return false;
904        MedicinalProductContraindication o = (MedicinalProductContraindication) other_;
905        return compareDeep(subject, o.subject, true) && compareDeep(disease, o.disease, true) && compareDeep(diseaseStatus, o.diseaseStatus, true)
906           && compareDeep(comorbidity, o.comorbidity, true) && compareDeep(therapeuticIndication, o.therapeuticIndication, true)
907           && compareDeep(otherTherapy, o.otherTherapy, true) && compareDeep(population, o.population, true)
908          ;
909      }
910
911      @Override
912      public boolean equalsShallow(Base other_) {
913        if (!super.equalsShallow(other_))
914          return false;
915        if (!(other_ instanceof MedicinalProductContraindication))
916          return false;
917        MedicinalProductContraindication o = (MedicinalProductContraindication) other_;
918        return true;
919      }
920
921      public boolean isEmpty() {
922        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(subject, disease, diseaseStatus
923          , comorbidity, therapeuticIndication, otherTherapy, population);
924      }
925
926  @Override
927  public ResourceType getResourceType() {
928    return ResourceType.MedicinalProductContraindication;
929   }
930
931 /**
932   * Search parameter: <b>subject</b>
933   * <p>
934   * Description: <b>The medication for which this is an contraindication</b><br>
935   * Type: <b>reference</b><br>
936   * Path: <b>MedicinalProductContraindication.subject</b><br>
937   * </p>
938   */
939  @SearchParamDefinition(name="subject", path="MedicinalProductContraindication.subject", description="The medication for which this is an contraindication", type="reference", target={Medication.class, MedicinalProduct.class } )
940  public static final String SP_SUBJECT = "subject";
941 /**
942   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
943   * <p>
944   * Description: <b>The medication for which this is an contraindication</b><br>
945   * Type: <b>reference</b><br>
946   * Path: <b>MedicinalProductContraindication.subject</b><br>
947   * </p>
948   */
949  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
950
951/**
952   * Constant for fluent queries to be used to add include statements. Specifies
953   * the path value of "<b>MedicinalProductContraindication:subject</b>".
954   */
955  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("MedicinalProductContraindication:subject").toLocked();
956
957
958}
959