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