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.Date;
054import java.util.List;
055
056import org.hl7.fhir.exceptions.FHIRException;
057import org.hl7.fhir.instance.model.api.ICompositeType;
058
059import ca.uhn.fhir.model.api.annotation.Child;
060import ca.uhn.fhir.model.api.annotation.DatatypeDef;
061import ca.uhn.fhir.model.api.annotation.Description;
062/**
063 * The marketing status describes the date when a medicinal product is actually put on the market or the date as of which it is no longer available.
064 */
065@DatatypeDef(name="MarketingStatus")
066public class MarketingStatus extends BackboneType implements ICompositeType {
067
068    /**
069     * The country in which the marketing authorisation has been granted shall be specified It should be specified using the ISO 3166 ‑ 1 alpha-2 code elements.
070     */
071    @Child(name = "country", type = {CodeableConcept.class}, order=0, min=1, max=1, modifier=false, summary=true)
072    @Description(shortDefinition="The country in which the marketing authorisation has been granted shall be specified It should be specified using the ISO 3166 ‑ 1 alpha-2 code elements", formalDefinition="The country in which the marketing authorisation has been granted shall be specified It should be specified using the ISO 3166 ‑ 1 alpha-2 code elements." )
073    protected CodeableConcept country;
074
075    /**
076     * Where a Medicines Regulatory Agency has granted a marketing authorisation for which specific provisions within a jurisdiction apply, the jurisdiction can be specified using an appropriate controlled terminology The controlled term and the controlled term identifier shall be specified.
077     */
078    @Child(name = "jurisdiction", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
079    @Description(shortDefinition="Where a Medicines Regulatory Agency has granted a marketing authorisation for which specific provisions within a jurisdiction apply, the jurisdiction can be specified using an appropriate controlled terminology The controlled term and the controlled term identifier shall be specified", formalDefinition="Where a Medicines Regulatory Agency has granted a marketing authorisation for which specific provisions within a jurisdiction apply, the jurisdiction can be specified using an appropriate controlled terminology The controlled term and the controlled term identifier shall be specified." )
080    protected CodeableConcept jurisdiction;
081
082    /**
083     * This attribute provides information on the status of the marketing of the medicinal product See ISO/TS 20443 for more information and examples.
084     */
085    @Child(name = "status", type = {CodeableConcept.class}, order=2, min=1, max=1, modifier=false, summary=true)
086    @Description(shortDefinition="This attribute provides information on the status of the marketing of the medicinal product See ISO/TS 20443 for more information and examples", formalDefinition="This attribute provides information on the status of the marketing of the medicinal product See ISO/TS 20443 for more information and examples." )
087    protected CodeableConcept status;
088
089    /**
090     * The date when the Medicinal Product is placed on the market by the Marketing Authorisation Holder (or where applicable, the manufacturer/distributor) in a country and/or jurisdiction shall be provided A complete date consisting of day, month and year shall be specified using the ISO 8601 date format NOTE “Placed on the market” refers to the release of the Medicinal Product into the distribution chain.
091     */
092    @Child(name = "dateRange", type = {Period.class}, order=3, min=1, max=1, modifier=false, summary=true)
093    @Description(shortDefinition="The date when the Medicinal Product is placed on the market by the Marketing Authorisation Holder (or where applicable, the manufacturer/distributor) in a country and/or jurisdiction shall be provided A complete date consisting of day, month and year shall be specified using the ISO 8601 date format NOTE “Placed on the market” refers to the release of the Medicinal Product into the distribution chain", formalDefinition="The date when the Medicinal Product is placed on the market by the Marketing Authorisation Holder (or where applicable, the manufacturer/distributor) in a country and/or jurisdiction shall be provided A complete date consisting of day, month and year shall be specified using the ISO 8601 date format NOTE “Placed on the market” refers to the release of the Medicinal Product into the distribution chain." )
094    protected Period dateRange;
095
096    /**
097     * The date when the Medicinal Product is placed on the market by the Marketing Authorisation Holder (or where applicable, the manufacturer/distributor) in a country and/or jurisdiction shall be provided A complete date consisting of day, month and year shall be specified using the ISO 8601 date format NOTE “Placed on the market” refers to the release of the Medicinal Product into the distribution chain.
098     */
099    @Child(name = "restoreDate", type = {DateTimeType.class}, order=4, min=0, max=1, modifier=false, summary=true)
100    @Description(shortDefinition="The date when the Medicinal Product is placed on the market by the Marketing Authorisation Holder (or where applicable, the manufacturer/distributor) in a country and/or jurisdiction shall be provided A complete date consisting of day, month and year shall be specified using the ISO 8601 date format NOTE “Placed on the market” refers to the release of the Medicinal Product into the distribution chain", formalDefinition="The date when the Medicinal Product is placed on the market by the Marketing Authorisation Holder (or where applicable, the manufacturer/distributor) in a country and/or jurisdiction shall be provided A complete date consisting of day, month and year shall be specified using the ISO 8601 date format NOTE “Placed on the market” refers to the release of the Medicinal Product into the distribution chain." )
101    protected DateTimeType restoreDate;
102
103    private static final long serialVersionUID = -1445736863L;
104
105  /**
106   * Constructor
107   */
108    public MarketingStatus() {
109      super();
110    }
111
112  /**
113   * Constructor
114   */
115    public MarketingStatus(CodeableConcept country, CodeableConcept status, Period dateRange) {
116      super();
117      this.country = country;
118      this.status = status;
119      this.dateRange = dateRange;
120    }
121
122    /**
123     * @return {@link #country} (The country in which the marketing authorisation has been granted shall be specified It should be specified using the ISO 3166 ‑ 1 alpha-2 code elements.)
124     */
125    public CodeableConcept getCountry() { 
126      if (this.country == null)
127        if (Configuration.errorOnAutoCreate())
128          throw new Error("Attempt to auto-create MarketingStatus.country");
129        else if (Configuration.doAutoCreate())
130          this.country = new CodeableConcept(); // cc
131      return this.country;
132    }
133
134    public boolean hasCountry() { 
135      return this.country != null && !this.country.isEmpty();
136    }
137
138    /**
139     * @param value {@link #country} (The country in which the marketing authorisation has been granted shall be specified It should be specified using the ISO 3166 ‑ 1 alpha-2 code elements.)
140     */
141    public MarketingStatus setCountry(CodeableConcept value) { 
142      this.country = value;
143      return this;
144    }
145
146    /**
147     * @return {@link #jurisdiction} (Where a Medicines Regulatory Agency has granted a marketing authorisation for which specific provisions within a jurisdiction apply, the jurisdiction can be specified using an appropriate controlled terminology The controlled term and the controlled term identifier shall be specified.)
148     */
149    public CodeableConcept getJurisdiction() { 
150      if (this.jurisdiction == null)
151        if (Configuration.errorOnAutoCreate())
152          throw new Error("Attempt to auto-create MarketingStatus.jurisdiction");
153        else if (Configuration.doAutoCreate())
154          this.jurisdiction = new CodeableConcept(); // cc
155      return this.jurisdiction;
156    }
157
158    public boolean hasJurisdiction() { 
159      return this.jurisdiction != null && !this.jurisdiction.isEmpty();
160    }
161
162    /**
163     * @param value {@link #jurisdiction} (Where a Medicines Regulatory Agency has granted a marketing authorisation for which specific provisions within a jurisdiction apply, the jurisdiction can be specified using an appropriate controlled terminology The controlled term and the controlled term identifier shall be specified.)
164     */
165    public MarketingStatus setJurisdiction(CodeableConcept value) { 
166      this.jurisdiction = value;
167      return this;
168    }
169
170    /**
171     * @return {@link #status} (This attribute provides information on the status of the marketing of the medicinal product See ISO/TS 20443 for more information and examples.)
172     */
173    public CodeableConcept getStatus() { 
174      if (this.status == null)
175        if (Configuration.errorOnAutoCreate())
176          throw new Error("Attempt to auto-create MarketingStatus.status");
177        else if (Configuration.doAutoCreate())
178          this.status = new CodeableConcept(); // cc
179      return this.status;
180    }
181
182    public boolean hasStatus() { 
183      return this.status != null && !this.status.isEmpty();
184    }
185
186    /**
187     * @param value {@link #status} (This attribute provides information on the status of the marketing of the medicinal product See ISO/TS 20443 for more information and examples.)
188     */
189    public MarketingStatus setStatus(CodeableConcept value) { 
190      this.status = value;
191      return this;
192    }
193
194    /**
195     * @return {@link #dateRange} (The date when the Medicinal Product is placed on the market by the Marketing Authorisation Holder (or where applicable, the manufacturer/distributor) in a country and/or jurisdiction shall be provided A complete date consisting of day, month and year shall be specified using the ISO 8601 date format NOTE “Placed on the market” refers to the release of the Medicinal Product into the distribution chain.)
196     */
197    public Period getDateRange() { 
198      if (this.dateRange == null)
199        if (Configuration.errorOnAutoCreate())
200          throw new Error("Attempt to auto-create MarketingStatus.dateRange");
201        else if (Configuration.doAutoCreate())
202          this.dateRange = new Period(); // cc
203      return this.dateRange;
204    }
205
206    public boolean hasDateRange() { 
207      return this.dateRange != null && !this.dateRange.isEmpty();
208    }
209
210    /**
211     * @param value {@link #dateRange} (The date when the Medicinal Product is placed on the market by the Marketing Authorisation Holder (or where applicable, the manufacturer/distributor) in a country and/or jurisdiction shall be provided A complete date consisting of day, month and year shall be specified using the ISO 8601 date format NOTE “Placed on the market” refers to the release of the Medicinal Product into the distribution chain.)
212     */
213    public MarketingStatus setDateRange(Period value) { 
214      this.dateRange = value;
215      return this;
216    }
217
218    /**
219     * @return {@link #restoreDate} (The date when the Medicinal Product is placed on the market by the Marketing Authorisation Holder (or where applicable, the manufacturer/distributor) in a country and/or jurisdiction shall be provided A complete date consisting of day, month and year shall be specified using the ISO 8601 date format NOTE “Placed on the market” refers to the release of the Medicinal Product into the distribution chain.). This is the underlying object with id, value and extensions. The accessor "getRestoreDate" gives direct access to the value
220     */
221    public DateTimeType getRestoreDateElement() { 
222      if (this.restoreDate == null)
223        if (Configuration.errorOnAutoCreate())
224          throw new Error("Attempt to auto-create MarketingStatus.restoreDate");
225        else if (Configuration.doAutoCreate())
226          this.restoreDate = new DateTimeType(); // bb
227      return this.restoreDate;
228    }
229
230    public boolean hasRestoreDateElement() { 
231      return this.restoreDate != null && !this.restoreDate.isEmpty();
232    }
233
234    public boolean hasRestoreDate() { 
235      return this.restoreDate != null && !this.restoreDate.isEmpty();
236    }
237
238    /**
239     * @param value {@link #restoreDate} (The date when the Medicinal Product is placed on the market by the Marketing Authorisation Holder (or where applicable, the manufacturer/distributor) in a country and/or jurisdiction shall be provided A complete date consisting of day, month and year shall be specified using the ISO 8601 date format NOTE “Placed on the market” refers to the release of the Medicinal Product into the distribution chain.). This is the underlying object with id, value and extensions. The accessor "getRestoreDate" gives direct access to the value
240     */
241    public MarketingStatus setRestoreDateElement(DateTimeType value) { 
242      this.restoreDate = value;
243      return this;
244    }
245
246    /**
247     * @return The date when the Medicinal Product is placed on the market by the Marketing Authorisation Holder (or where applicable, the manufacturer/distributor) in a country and/or jurisdiction shall be provided A complete date consisting of day, month and year shall be specified using the ISO 8601 date format NOTE “Placed on the market” refers to the release of the Medicinal Product into the distribution chain.
248     */
249    public Date getRestoreDate() { 
250      return this.restoreDate == null ? null : this.restoreDate.getValue();
251    }
252
253    /**
254     * @param value The date when the Medicinal Product is placed on the market by the Marketing Authorisation Holder (or where applicable, the manufacturer/distributor) in a country and/or jurisdiction shall be provided A complete date consisting of day, month and year shall be specified using the ISO 8601 date format NOTE “Placed on the market” refers to the release of the Medicinal Product into the distribution chain.
255     */
256    public MarketingStatus setRestoreDate(Date value) { 
257      if (value == null)
258        this.restoreDate = null;
259      else {
260        if (this.restoreDate == null)
261          this.restoreDate = new DateTimeType();
262        this.restoreDate.setValue(value);
263      }
264      return this;
265    }
266
267      protected void listChildren(List<Property> children) {
268        super.listChildren(children);
269        children.add(new Property("country", "CodeableConcept", "The country in which the marketing authorisation has been granted shall be specified It should be specified using the ISO 3166 ‑ 1 alpha-2 code elements.", 0, 1, country));
270        children.add(new Property("jurisdiction", "CodeableConcept", "Where a Medicines Regulatory Agency has granted a marketing authorisation for which specific provisions within a jurisdiction apply, the jurisdiction can be specified using an appropriate controlled terminology The controlled term and the controlled term identifier shall be specified.", 0, 1, jurisdiction));
271        children.add(new Property("status", "CodeableConcept", "This attribute provides information on the status of the marketing of the medicinal product See ISO/TS 20443 for more information and examples.", 0, 1, status));
272        children.add(new Property("dateRange", "Period", "The date when the Medicinal Product is placed on the market by the Marketing Authorisation Holder (or where applicable, the manufacturer/distributor) in a country and/or jurisdiction shall be provided A complete date consisting of day, month and year shall be specified using the ISO 8601 date format NOTE “Placed on the market” refers to the release of the Medicinal Product into the distribution chain.", 0, 1, dateRange));
273        children.add(new Property("restoreDate", "dateTime", "The date when the Medicinal Product is placed on the market by the Marketing Authorisation Holder (or where applicable, the manufacturer/distributor) in a country and/or jurisdiction shall be provided A complete date consisting of day, month and year shall be specified using the ISO 8601 date format NOTE “Placed on the market” refers to the release of the Medicinal Product into the distribution chain.", 0, 1, restoreDate));
274      }
275
276      @Override
277      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
278        switch (_hash) {
279        case 957831062: /*country*/  return new Property("country", "CodeableConcept", "The country in which the marketing authorisation has been granted shall be specified It should be specified using the ISO 3166 ‑ 1 alpha-2 code elements.", 0, 1, country);
280        case -507075711: /*jurisdiction*/  return new Property("jurisdiction", "CodeableConcept", "Where a Medicines Regulatory Agency has granted a marketing authorisation for which specific provisions within a jurisdiction apply, the jurisdiction can be specified using an appropriate controlled terminology The controlled term and the controlled term identifier shall be specified.", 0, 1, jurisdiction);
281        case -892481550: /*status*/  return new Property("status", "CodeableConcept", "This attribute provides information on the status of the marketing of the medicinal product See ISO/TS 20443 for more information and examples.", 0, 1, status);
282        case -261425617: /*dateRange*/  return new Property("dateRange", "Period", "The date when the Medicinal Product is placed on the market by the Marketing Authorisation Holder (or where applicable, the manufacturer/distributor) in a country and/or jurisdiction shall be provided A complete date consisting of day, month and year shall be specified using the ISO 8601 date format NOTE “Placed on the market” refers to the release of the Medicinal Product into the distribution chain.", 0, 1, dateRange);
283        case 329465692: /*restoreDate*/  return new Property("restoreDate", "dateTime", "The date when the Medicinal Product is placed on the market by the Marketing Authorisation Holder (or where applicable, the manufacturer/distributor) in a country and/or jurisdiction shall be provided A complete date consisting of day, month and year shall be specified using the ISO 8601 date format NOTE “Placed on the market” refers to the release of the Medicinal Product into the distribution chain.", 0, 1, restoreDate);
284        default: return super.getNamedProperty(_hash, _name, _checkValid);
285        }
286
287      }
288
289      @Override
290      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
291        switch (hash) {
292        case 957831062: /*country*/ return this.country == null ? new Base[0] : new Base[] {this.country}; // CodeableConcept
293        case -507075711: /*jurisdiction*/ return this.jurisdiction == null ? new Base[0] : new Base[] {this.jurisdiction}; // CodeableConcept
294        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // CodeableConcept
295        case -261425617: /*dateRange*/ return this.dateRange == null ? new Base[0] : new Base[] {this.dateRange}; // Period
296        case 329465692: /*restoreDate*/ return this.restoreDate == null ? new Base[0] : new Base[] {this.restoreDate}; // DateTimeType
297        default: return super.getProperty(hash, name, checkValid);
298        }
299
300      }
301
302      @Override
303      public Base setProperty(int hash, String name, Base value) throws FHIRException {
304        switch (hash) {
305        case 957831062: // country
306          this.country = castToCodeableConcept(value); // CodeableConcept
307          return value;
308        case -507075711: // jurisdiction
309          this.jurisdiction = castToCodeableConcept(value); // CodeableConcept
310          return value;
311        case -892481550: // status
312          this.status = castToCodeableConcept(value); // CodeableConcept
313          return value;
314        case -261425617: // dateRange
315          this.dateRange = castToPeriod(value); // Period
316          return value;
317        case 329465692: // restoreDate
318          this.restoreDate = castToDateTime(value); // DateTimeType
319          return value;
320        default: return super.setProperty(hash, name, value);
321        }
322
323      }
324
325      @Override
326      public Base setProperty(String name, Base value) throws FHIRException {
327        if (name.equals("country")) {
328          this.country = castToCodeableConcept(value); // CodeableConcept
329        } else if (name.equals("jurisdiction")) {
330          this.jurisdiction = castToCodeableConcept(value); // CodeableConcept
331        } else if (name.equals("status")) {
332          this.status = castToCodeableConcept(value); // CodeableConcept
333        } else if (name.equals("dateRange")) {
334          this.dateRange = castToPeriod(value); // Period
335        } else if (name.equals("restoreDate")) {
336          this.restoreDate = castToDateTime(value); // DateTimeType
337        } else
338          return super.setProperty(name, value);
339        return value;
340      }
341
342      @Override
343      public Base makeProperty(int hash, String name) throws FHIRException {
344        switch (hash) {
345        case 957831062:  return getCountry(); 
346        case -507075711:  return getJurisdiction(); 
347        case -892481550:  return getStatus(); 
348        case -261425617:  return getDateRange(); 
349        case 329465692:  return getRestoreDateElement();
350        default: return super.makeProperty(hash, name);
351        }
352
353      }
354
355      @Override
356      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
357        switch (hash) {
358        case 957831062: /*country*/ return new String[] {"CodeableConcept"};
359        case -507075711: /*jurisdiction*/ return new String[] {"CodeableConcept"};
360        case -892481550: /*status*/ return new String[] {"CodeableConcept"};
361        case -261425617: /*dateRange*/ return new String[] {"Period"};
362        case 329465692: /*restoreDate*/ return new String[] {"dateTime"};
363        default: return super.getTypesForProperty(hash, name);
364        }
365
366      }
367
368      @Override
369      public Base addChild(String name) throws FHIRException {
370        if (name.equals("country")) {
371          this.country = new CodeableConcept();
372          return this.country;
373        }
374        else if (name.equals("jurisdiction")) {
375          this.jurisdiction = new CodeableConcept();
376          return this.jurisdiction;
377        }
378        else if (name.equals("status")) {
379          this.status = new CodeableConcept();
380          return this.status;
381        }
382        else if (name.equals("dateRange")) {
383          this.dateRange = new Period();
384          return this.dateRange;
385        }
386        else if (name.equals("restoreDate")) {
387          throw new FHIRException("Cannot call addChild on a primitive type MarketingStatus.restoreDate");
388        }
389        else
390          return super.addChild(name);
391      }
392
393  public String fhirType() {
394    return "MarketingStatus";
395
396  }
397
398      public MarketingStatus copy() {
399        MarketingStatus dst = new MarketingStatus();
400        copyValues(dst);
401        dst.country = country == null ? null : country.copy();
402        dst.jurisdiction = jurisdiction == null ? null : jurisdiction.copy();
403        dst.status = status == null ? null : status.copy();
404        dst.dateRange = dateRange == null ? null : dateRange.copy();
405        dst.restoreDate = restoreDate == null ? null : restoreDate.copy();
406        return dst;
407      }
408
409      protected MarketingStatus typedCopy() {
410        return copy();
411      }
412
413      @Override
414      public boolean equalsDeep(Base other_) {
415        if (!super.equalsDeep(other_))
416          return false;
417        if (!(other_ instanceof MarketingStatus))
418          return false;
419        MarketingStatus o = (MarketingStatus) other_;
420        return compareDeep(country, o.country, true) && compareDeep(jurisdiction, o.jurisdiction, true)
421           && compareDeep(status, o.status, true) && compareDeep(dateRange, o.dateRange, true) && compareDeep(restoreDate, o.restoreDate, true)
422          ;
423      }
424
425      @Override
426      public boolean equalsShallow(Base other_) {
427        if (!super.equalsShallow(other_))
428          return false;
429        if (!(other_ instanceof MarketingStatus))
430          return false;
431        MarketingStatus o = (MarketingStatus) other_;
432        return compareValues(restoreDate, o.restoreDate, true);
433      }
434
435      public boolean isEmpty() {
436        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(country, jurisdiction, status
437          , dateRange, restoreDate);
438      }
439
440
441}
442