001package org.hl7.fhir.r4.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
033import java.util.ArrayList;
034import java.util.List;
035
036import org.hl7.fhir.exceptions.FHIRException;
037
038import ca.uhn.fhir.model.api.annotation.Child;
039import ca.uhn.fhir.model.api.annotation.Description;
040import ca.uhn.fhir.model.api.annotation.ResourceDef;
041import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
042
043/**
044 * Describe the undesirable effects of the medicinal product.
045 */
046@ResourceDef(name = "MedicinalProductUndesirableEffect", profile = "http://hl7.org/fhir/StructureDefinition/MedicinalProductUndesirableEffect")
047public class MedicinalProductUndesirableEffect extends DomainResource {
048
049  /**
050   * The medication for which this is an indication.
051   */
052  @Child(name = "subject", type = { MedicinalProduct.class,
053      Medication.class }, order = 0, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
054  @Description(shortDefinition = "The medication for which this is an indication", formalDefinition = "The medication for which this is an indication.")
055  protected List<Reference> subject;
056  /**
057   * The actual objects that are the target of the reference (The medication for
058   * which this is an indication.)
059   */
060  protected List<Resource> subjectTarget;
061
062  /**
063   * The symptom, condition or undesirable effect.
064   */
065  @Child(name = "symptomConditionEffect", type = {
066      CodeableConcept.class }, order = 1, min = 0, max = 1, modifier = false, summary = true)
067  @Description(shortDefinition = "The symptom, condition or undesirable effect", formalDefinition = "The symptom, condition or undesirable effect.")
068  protected CodeableConcept symptomConditionEffect;
069
070  /**
071   * Classification of the effect.
072   */
073  @Child(name = "classification", type = {
074      CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
075  @Description(shortDefinition = "Classification of the effect", formalDefinition = "Classification of the effect.")
076  protected CodeableConcept classification;
077
078  /**
079   * The frequency of occurrence of the effect.
080   */
081  @Child(name = "frequencyOfOccurrence", type = {
082      CodeableConcept.class }, order = 3, min = 0, max = 1, modifier = false, summary = true)
083  @Description(shortDefinition = "The frequency of occurrence of the effect", formalDefinition = "The frequency of occurrence of the effect.")
084  protected CodeableConcept frequencyOfOccurrence;
085
086  /**
087   * The population group to which this applies.
088   */
089  @Child(name = "population", type = {
090      Population.class }, order = 4, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
091  @Description(shortDefinition = "The population group to which this applies", formalDefinition = "The population group to which this applies.")
092  protected List<Population> population;
093
094  private static final long serialVersionUID = -1960253956L;
095
096  /**
097   * Constructor
098   */
099  public MedicinalProductUndesirableEffect() {
100    super();
101  }
102
103  /**
104   * @return {@link #subject} (The medication for which this is an indication.)
105   */
106  public List<Reference> getSubject() {
107    if (this.subject == null)
108      this.subject = new ArrayList<Reference>();
109    return this.subject;
110  }
111
112  /**
113   * @return Returns a reference to <code>this</code> for easy method chaining
114   */
115  public MedicinalProductUndesirableEffect setSubject(List<Reference> theSubject) {
116    this.subject = theSubject;
117    return this;
118  }
119
120  public boolean hasSubject() {
121    if (this.subject == null)
122      return false;
123    for (Reference item : this.subject)
124      if (!item.isEmpty())
125        return true;
126    return false;
127  }
128
129  public Reference addSubject() { // 3
130    Reference t = new Reference();
131    if (this.subject == null)
132      this.subject = new ArrayList<Reference>();
133    this.subject.add(t);
134    return t;
135  }
136
137  public MedicinalProductUndesirableEffect addSubject(Reference t) { // 3
138    if (t == null)
139      return this;
140    if (this.subject == null)
141      this.subject = new ArrayList<Reference>();
142    this.subject.add(t);
143    return this;
144  }
145
146  /**
147   * @return The first repetition of repeating field {@link #subject}, creating it
148   *         if it does not already exist
149   */
150  public Reference getSubjectFirstRep() {
151    if (getSubject().isEmpty()) {
152      addSubject();
153    }
154    return getSubject().get(0);
155  }
156
157  /**
158   * @return {@link #symptomConditionEffect} (The symptom, condition or
159   *         undesirable effect.)
160   */
161  public CodeableConcept getSymptomConditionEffect() {
162    if (this.symptomConditionEffect == null)
163      if (Configuration.errorOnAutoCreate())
164        throw new Error("Attempt to auto-create MedicinalProductUndesirableEffect.symptomConditionEffect");
165      else if (Configuration.doAutoCreate())
166        this.symptomConditionEffect = new CodeableConcept(); // cc
167    return this.symptomConditionEffect;
168  }
169
170  public boolean hasSymptomConditionEffect() {
171    return this.symptomConditionEffect != null && !this.symptomConditionEffect.isEmpty();
172  }
173
174  /**
175   * @param value {@link #symptomConditionEffect} (The symptom, condition or
176   *              undesirable effect.)
177   */
178  public MedicinalProductUndesirableEffect setSymptomConditionEffect(CodeableConcept value) {
179    this.symptomConditionEffect = value;
180    return this;
181  }
182
183  /**
184   * @return {@link #classification} (Classification of the effect.)
185   */
186  public CodeableConcept getClassification() {
187    if (this.classification == null)
188      if (Configuration.errorOnAutoCreate())
189        throw new Error("Attempt to auto-create MedicinalProductUndesirableEffect.classification");
190      else if (Configuration.doAutoCreate())
191        this.classification = new CodeableConcept(); // cc
192    return this.classification;
193  }
194
195  public boolean hasClassification() {
196    return this.classification != null && !this.classification.isEmpty();
197  }
198
199  /**
200   * @param value {@link #classification} (Classification of the effect.)
201   */
202  public MedicinalProductUndesirableEffect setClassification(CodeableConcept value) {
203    this.classification = value;
204    return this;
205  }
206
207  /**
208   * @return {@link #frequencyOfOccurrence} (The frequency of occurrence of the
209   *         effect.)
210   */
211  public CodeableConcept getFrequencyOfOccurrence() {
212    if (this.frequencyOfOccurrence == null)
213      if (Configuration.errorOnAutoCreate())
214        throw new Error("Attempt to auto-create MedicinalProductUndesirableEffect.frequencyOfOccurrence");
215      else if (Configuration.doAutoCreate())
216        this.frequencyOfOccurrence = new CodeableConcept(); // cc
217    return this.frequencyOfOccurrence;
218  }
219
220  public boolean hasFrequencyOfOccurrence() {
221    return this.frequencyOfOccurrence != null && !this.frequencyOfOccurrence.isEmpty();
222  }
223
224  /**
225   * @param value {@link #frequencyOfOccurrence} (The frequency of occurrence of
226   *              the effect.)
227   */
228  public MedicinalProductUndesirableEffect setFrequencyOfOccurrence(CodeableConcept value) {
229    this.frequencyOfOccurrence = value;
230    return this;
231  }
232
233  /**
234   * @return {@link #population} (The population group to which this applies.)
235   */
236  public List<Population> getPopulation() {
237    if (this.population == null)
238      this.population = new ArrayList<Population>();
239    return this.population;
240  }
241
242  /**
243   * @return Returns a reference to <code>this</code> for easy method chaining
244   */
245  public MedicinalProductUndesirableEffect setPopulation(List<Population> thePopulation) {
246    this.population = thePopulation;
247    return this;
248  }
249
250  public boolean hasPopulation() {
251    if (this.population == null)
252      return false;
253    for (Population item : this.population)
254      if (!item.isEmpty())
255        return true;
256    return false;
257  }
258
259  public Population addPopulation() { // 3
260    Population t = new Population();
261    if (this.population == null)
262      this.population = new ArrayList<Population>();
263    this.population.add(t);
264    return t;
265  }
266
267  public MedicinalProductUndesirableEffect addPopulation(Population t) { // 3
268    if (t == null)
269      return this;
270    if (this.population == null)
271      this.population = new ArrayList<Population>();
272    this.population.add(t);
273    return this;
274  }
275
276  /**
277   * @return The first repetition of repeating field {@link #population}, creating
278   *         it if it does not already exist
279   */
280  public Population getPopulationFirstRep() {
281    if (getPopulation().isEmpty()) {
282      addPopulation();
283    }
284    return getPopulation().get(0);
285  }
286
287  protected void listChildren(List<Property> children) {
288    super.listChildren(children);
289    children.add(new Property("subject", "Reference(MedicinalProduct|Medication)",
290        "The medication for which this is an indication.", 0, java.lang.Integer.MAX_VALUE, subject));
291    children.add(new Property("symptomConditionEffect", "CodeableConcept",
292        "The symptom, condition or undesirable effect.", 0, 1, symptomConditionEffect));
293    children
294        .add(new Property("classification", "CodeableConcept", "Classification of the effect.", 0, 1, classification));
295    children.add(new Property("frequencyOfOccurrence", "CodeableConcept", "The frequency of occurrence of the effect.",
296        0, 1, frequencyOfOccurrence));
297    children.add(new Property("population", "Population", "The population group to which this applies.", 0,
298        java.lang.Integer.MAX_VALUE, population));
299  }
300
301  @Override
302  public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
303    switch (_hash) {
304    case -1867885268:
305      /* subject */ return new Property("subject", "Reference(MedicinalProduct|Medication)",
306          "The medication for which this is an indication.", 0, java.lang.Integer.MAX_VALUE, subject);
307    case -650549981:
308      /* symptomConditionEffect */ return new Property("symptomConditionEffect", "CodeableConcept",
309          "The symptom, condition or undesirable effect.", 0, 1, symptomConditionEffect);
310    case 382350310:
311      /* classification */ return new Property("classification", "CodeableConcept", "Classification of the effect.", 0,
312          1, classification);
313    case 791175812:
314      /* frequencyOfOccurrence */ return new Property("frequencyOfOccurrence", "CodeableConcept",
315          "The frequency of occurrence of the effect.", 0, 1, frequencyOfOccurrence);
316    case -2023558323:
317      /* population */ return new Property("population", "Population", "The population group to which this applies.", 0,
318          java.lang.Integer.MAX_VALUE, population);
319    default:
320      return super.getNamedProperty(_hash, _name, _checkValid);
321    }
322
323  }
324
325  @Override
326  public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
327    switch (hash) {
328    case -1867885268:
329      /* subject */ return this.subject == null ? new Base[0] : this.subject.toArray(new Base[this.subject.size()]); // Reference
330    case -650549981:
331      /* symptomConditionEffect */ return this.symptomConditionEffect == null ? new Base[0]
332          : new Base[] { this.symptomConditionEffect }; // CodeableConcept
333    case 382350310:
334      /* classification */ return this.classification == null ? new Base[0] : new Base[] { this.classification }; // CodeableConcept
335    case 791175812:
336      /* frequencyOfOccurrence */ return this.frequencyOfOccurrence == null ? new Base[0]
337          : new Base[] { this.frequencyOfOccurrence }; // CodeableConcept
338    case -2023558323:
339      /* population */ return this.population == null ? new Base[0]
340          : this.population.toArray(new Base[this.population.size()]); // Population
341    default:
342      return super.getProperty(hash, name, checkValid);
343    }
344
345  }
346
347  @Override
348  public Base setProperty(int hash, String name, Base value) throws FHIRException {
349    switch (hash) {
350    case -1867885268: // subject
351      this.getSubject().add(castToReference(value)); // Reference
352      return value;
353    case -650549981: // symptomConditionEffect
354      this.symptomConditionEffect = castToCodeableConcept(value); // CodeableConcept
355      return value;
356    case 382350310: // classification
357      this.classification = castToCodeableConcept(value); // CodeableConcept
358      return value;
359    case 791175812: // frequencyOfOccurrence
360      this.frequencyOfOccurrence = castToCodeableConcept(value); // CodeableConcept
361      return value;
362    case -2023558323: // population
363      this.getPopulation().add(castToPopulation(value)); // Population
364      return value;
365    default:
366      return super.setProperty(hash, name, value);
367    }
368
369  }
370
371  @Override
372  public Base setProperty(String name, Base value) throws FHIRException {
373    if (name.equals("subject")) {
374      this.getSubject().add(castToReference(value));
375    } else if (name.equals("symptomConditionEffect")) {
376      this.symptomConditionEffect = castToCodeableConcept(value); // CodeableConcept
377    } else if (name.equals("classification")) {
378      this.classification = castToCodeableConcept(value); // CodeableConcept
379    } else if (name.equals("frequencyOfOccurrence")) {
380      this.frequencyOfOccurrence = castToCodeableConcept(value); // CodeableConcept
381    } else if (name.equals("population")) {
382      this.getPopulation().add(castToPopulation(value));
383    } else
384      return super.setProperty(name, value);
385    return value;
386  }
387
388  @Override
389  public void removeChild(String name, Base value) throws FHIRException {
390    if (name.equals("subject")) {
391      this.getSubject().remove(castToReference(value));
392    } else if (name.equals("symptomConditionEffect")) {
393      this.symptomConditionEffect = null;
394    } else if (name.equals("classification")) {
395      this.classification = null;
396    } else if (name.equals("frequencyOfOccurrence")) {
397      this.frequencyOfOccurrence = null;
398    } else if (name.equals("population")) {
399      this.getPopulation().remove(castToPopulation(value));
400    } else
401      super.removeChild(name, value);
402    
403  }
404
405  @Override
406  public Base makeProperty(int hash, String name) throws FHIRException {
407    switch (hash) {
408    case -1867885268:
409      return addSubject();
410    case -650549981:
411      return getSymptomConditionEffect();
412    case 382350310:
413      return getClassification();
414    case 791175812:
415      return getFrequencyOfOccurrence();
416    case -2023558323:
417      return addPopulation();
418    default:
419      return super.makeProperty(hash, name);
420    }
421
422  }
423
424  @Override
425  public String[] getTypesForProperty(int hash, String name) throws FHIRException {
426    switch (hash) {
427    case -1867885268:
428      /* subject */ return new String[] { "Reference" };
429    case -650549981:
430      /* symptomConditionEffect */ return new String[] { "CodeableConcept" };
431    case 382350310:
432      /* classification */ return new String[] { "CodeableConcept" };
433    case 791175812:
434      /* frequencyOfOccurrence */ return new String[] { "CodeableConcept" };
435    case -2023558323:
436      /* population */ return new String[] { "Population" };
437    default:
438      return super.getTypesForProperty(hash, name);
439    }
440
441  }
442
443  @Override
444  public Base addChild(String name) throws FHIRException {
445    if (name.equals("subject")) {
446      return addSubject();
447    } else if (name.equals("symptomConditionEffect")) {
448      this.symptomConditionEffect = new CodeableConcept();
449      return this.symptomConditionEffect;
450    } else if (name.equals("classification")) {
451      this.classification = new CodeableConcept();
452      return this.classification;
453    } else if (name.equals("frequencyOfOccurrence")) {
454      this.frequencyOfOccurrence = new CodeableConcept();
455      return this.frequencyOfOccurrence;
456    } else if (name.equals("population")) {
457      return addPopulation();
458    } else
459      return super.addChild(name);
460  }
461
462  public String fhirType() {
463    return "MedicinalProductUndesirableEffect";
464
465  }
466
467  public MedicinalProductUndesirableEffect copy() {
468    MedicinalProductUndesirableEffect dst = new MedicinalProductUndesirableEffect();
469    copyValues(dst);
470    return dst;
471  }
472
473  public void copyValues(MedicinalProductUndesirableEffect dst) {
474    super.copyValues(dst);
475    if (subject != null) {
476      dst.subject = new ArrayList<Reference>();
477      for (Reference i : subject)
478        dst.subject.add(i.copy());
479    }
480    ;
481    dst.symptomConditionEffect = symptomConditionEffect == null ? null : symptomConditionEffect.copy();
482    dst.classification = classification == null ? null : classification.copy();
483    dst.frequencyOfOccurrence = frequencyOfOccurrence == null ? null : frequencyOfOccurrence.copy();
484    if (population != null) {
485      dst.population = new ArrayList<Population>();
486      for (Population i : population)
487        dst.population.add(i.copy());
488    }
489    ;
490  }
491
492  protected MedicinalProductUndesirableEffect typedCopy() {
493    return copy();
494  }
495
496  @Override
497  public boolean equalsDeep(Base other_) {
498    if (!super.equalsDeep(other_))
499      return false;
500    if (!(other_ instanceof MedicinalProductUndesirableEffect))
501      return false;
502    MedicinalProductUndesirableEffect o = (MedicinalProductUndesirableEffect) other_;
503    return compareDeep(subject, o.subject, true) && compareDeep(symptomConditionEffect, o.symptomConditionEffect, true)
504        && compareDeep(classification, o.classification, true)
505        && compareDeep(frequencyOfOccurrence, o.frequencyOfOccurrence, true)
506        && compareDeep(population, o.population, true);
507  }
508
509  @Override
510  public boolean equalsShallow(Base other_) {
511    if (!super.equalsShallow(other_))
512      return false;
513    if (!(other_ instanceof MedicinalProductUndesirableEffect))
514      return false;
515    MedicinalProductUndesirableEffect o = (MedicinalProductUndesirableEffect) other_;
516    return true;
517  }
518
519  public boolean isEmpty() {
520    return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(subject, symptomConditionEffect, classification,
521        frequencyOfOccurrence, population);
522  }
523
524  @Override
525  public ResourceType getResourceType() {
526    return ResourceType.MedicinalProductUndesirableEffect;
527  }
528
529  /**
530   * Search parameter: <b>subject</b>
531   * <p>
532   * Description: <b>The medication for which this is an undesirable
533   * effect</b><br>
534   * Type: <b>reference</b><br>
535   * Path: <b>MedicinalProductUndesirableEffect.subject</b><br>
536   * </p>
537   */
538  @SearchParamDefinition(name = "subject", path = "MedicinalProductUndesirableEffect.subject", description = "The medication for which this is an undesirable effect", type = "reference", target = {
539      Medication.class, MedicinalProduct.class })
540  public static final String SP_SUBJECT = "subject";
541  /**
542   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
543   * <p>
544   * Description: <b>The medication for which this is an undesirable
545   * effect</b><br>
546   * Type: <b>reference</b><br>
547   * Path: <b>MedicinalProductUndesirableEffect.subject</b><br>
548   * </p>
549   */
550  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
551      SP_SUBJECT);
552
553  /**
554   * Constant for fluent queries to be used to add include statements. Specifies
555   * the path value of "<b>MedicinalProductUndesirableEffect:subject</b>".
556   */
557  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include(
558      "MedicinalProductUndesirableEffect:subject").toLocked();
559
560}