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