001package org.hl7.fhir.r5.model;
002
003
004/*
005  Copyright (c) 2011+, HL7, Inc.
006  All rights reserved.
007  
008  Redistribution and use in source and binary forms, with or without modification, \
009  are permitted provided that the following conditions are met:
010  
011   * Redistributions of source code must retain the above copyright notice, this \
012     list of conditions and the following disclaimer.
013   * Redistributions in binary form must reproduce the above copyright notice, \
014     this list of conditions and the following disclaimer in the documentation \
015     and/or other materials provided with the distribution.
016   * Neither the name of HL7 nor the names of its contributors may be used to 
017     endorse or promote products derived from this software without specific 
018     prior written permission.
019  
020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
021  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
022  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
023  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
024  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
025  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
026  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
027  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
028  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
029  POSSIBILITY OF SUCH DAMAGE.
030  */
031
032// Generated on Tue, May 4, 2021 07:17+1000 for FHIR v5.0.0-snapshot2
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import org.hl7.fhir.utilities.Utilities;
038import org.hl7.fhir.r5.model.Enumerations.*;
039import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
040import org.hl7.fhir.exceptions.FHIRException;
041import org.hl7.fhir.instance.model.api.ICompositeType;
042import ca.uhn.fhir.model.api.annotation.Child;
043import ca.uhn.fhir.model.api.annotation.ChildOrder;
044import ca.uhn.fhir.model.api.annotation.DatatypeDef;
045import ca.uhn.fhir.model.api.annotation.Description;
046import ca.uhn.fhir.model.api.annotation.Block;
047
048/**
049 * Base StructureDefinition for OrderedDistribution Type: An ordered list (distribution) of statistics.
050 */
051@DatatypeDef(name="OrderedDistribution")
052public class OrderedDistribution extends BackboneType implements ICompositeType {
053
054    @Block()
055    public static class OrderedDistributionIntervalComponent extends Element implements IBaseDatatypeElement {
056        /**
057         * Relative order of interval.
058         */
059        @Child(name = "rankOrder", type = {IntegerType.class}, order=1, min=1, max=1, modifier=false, summary=true)
060        @Description(shortDefinition="Relative order of interval", formalDefinition="Relative order of interval." )
061        protected IntegerType rankOrder;
062
063        /**
064         * Values and parameters for a single statistic related to the interval.
065         */
066        @Child(name = "intervalStatistic", type = {Statistic.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
067        @Description(shortDefinition="Values and parameters for a single statistic related to the interval", formalDefinition="Values and parameters for a single statistic related to the interval." )
068        protected List<Statistic> intervalStatistic;
069
070        private static final long serialVersionUID = 1714817635L;
071
072    /**
073     * Constructor
074     */
075      public OrderedDistributionIntervalComponent() {
076        super();
077      }
078
079    /**
080     * Constructor
081     */
082      public OrderedDistributionIntervalComponent(int rankOrder) {
083        super();
084        this.setRankOrder(rankOrder);
085      }
086
087        /**
088         * @return {@link #rankOrder} (Relative order of interval.). This is the underlying object with id, value and extensions. The accessor "getRankOrder" gives direct access to the value
089         */
090        public IntegerType getRankOrderElement() { 
091          if (this.rankOrder == null)
092            if (Configuration.errorOnAutoCreate())
093              throw new Error("Attempt to auto-create OrderedDistributionIntervalComponent.rankOrder");
094            else if (Configuration.doAutoCreate())
095              this.rankOrder = new IntegerType(); // bb
096          return this.rankOrder;
097        }
098
099        public boolean hasRankOrderElement() { 
100          return this.rankOrder != null && !this.rankOrder.isEmpty();
101        }
102
103        public boolean hasRankOrder() { 
104          return this.rankOrder != null && !this.rankOrder.isEmpty();
105        }
106
107        /**
108         * @param value {@link #rankOrder} (Relative order of interval.). This is the underlying object with id, value and extensions. The accessor "getRankOrder" gives direct access to the value
109         */
110        public OrderedDistributionIntervalComponent setRankOrderElement(IntegerType value) { 
111          this.rankOrder = value;
112          return this;
113        }
114
115        /**
116         * @return Relative order of interval.
117         */
118        public int getRankOrder() { 
119          return this.rankOrder == null || this.rankOrder.isEmpty() ? 0 : this.rankOrder.getValue();
120        }
121
122        /**
123         * @param value Relative order of interval.
124         */
125        public OrderedDistributionIntervalComponent setRankOrder(int value) { 
126            if (this.rankOrder == null)
127              this.rankOrder = new IntegerType();
128            this.rankOrder.setValue(value);
129          return this;
130        }
131
132        /**
133         * @return {@link #intervalStatistic} (Values and parameters for a single statistic related to the interval.)
134         */
135        public List<Statistic> getIntervalStatistic() { 
136          if (this.intervalStatistic == null)
137            this.intervalStatistic = new ArrayList<Statistic>();
138          return this.intervalStatistic;
139        }
140
141        /**
142         * @return Returns a reference to <code>this</code> for easy method chaining
143         */
144        public OrderedDistributionIntervalComponent setIntervalStatistic(List<Statistic> theIntervalStatistic) { 
145          this.intervalStatistic = theIntervalStatistic;
146          return this;
147        }
148
149        public boolean hasIntervalStatistic() { 
150          if (this.intervalStatistic == null)
151            return false;
152          for (Statistic item : this.intervalStatistic)
153            if (!item.isEmpty())
154              return true;
155          return false;
156        }
157
158        public Statistic addIntervalStatistic() { //3
159          Statistic t = new Statistic();
160          if (this.intervalStatistic == null)
161            this.intervalStatistic = new ArrayList<Statistic>();
162          this.intervalStatistic.add(t);
163          return t;
164        }
165
166        public OrderedDistributionIntervalComponent addIntervalStatistic(Statistic t) { //3
167          if (t == null)
168            return this;
169          if (this.intervalStatistic == null)
170            this.intervalStatistic = new ArrayList<Statistic>();
171          this.intervalStatistic.add(t);
172          return this;
173        }
174
175        /**
176         * @return The first repetition of repeating field {@link #intervalStatistic}, creating it if it does not already exist {3}
177         */
178        public Statistic getIntervalStatisticFirstRep() { 
179          if (getIntervalStatistic().isEmpty()) {
180            addIntervalStatistic();
181          }
182          return getIntervalStatistic().get(0);
183        }
184
185        protected void listChildren(List<Property> children) {
186          super.listChildren(children);
187          children.add(new Property("rankOrder", "integer", "Relative order of interval.", 0, 1, rankOrder));
188          children.add(new Property("intervalStatistic", "Statistic", "Values and parameters for a single statistic related to the interval.", 0, java.lang.Integer.MAX_VALUE, intervalStatistic));
189        }
190
191        @Override
192        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
193          switch (_hash) {
194          case -656537982: /*rankOrder*/  return new Property("rankOrder", "integer", "Relative order of interval.", 0, 1, rankOrder);
195          case 227099147: /*intervalStatistic*/  return new Property("intervalStatistic", "Statistic", "Values and parameters for a single statistic related to the interval.", 0, java.lang.Integer.MAX_VALUE, intervalStatistic);
196          default: return super.getNamedProperty(_hash, _name, _checkValid);
197          }
198
199        }
200
201      @Override
202      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
203        switch (hash) {
204        case -656537982: /*rankOrder*/ return this.rankOrder == null ? new Base[0] : new Base[] {this.rankOrder}; // IntegerType
205        case 227099147: /*intervalStatistic*/ return this.intervalStatistic == null ? new Base[0] : this.intervalStatistic.toArray(new Base[this.intervalStatistic.size()]); // Statistic
206        default: return super.getProperty(hash, name, checkValid);
207        }
208
209      }
210
211      @Override
212      public Base setProperty(int hash, String name, Base value) throws FHIRException {
213        switch (hash) {
214        case -656537982: // rankOrder
215          this.rankOrder = TypeConvertor.castToInteger(value); // IntegerType
216          return value;
217        case 227099147: // intervalStatistic
218          this.getIntervalStatistic().add(TypeConvertor.castToStatistic(value)); // Statistic
219          return value;
220        default: return super.setProperty(hash, name, value);
221        }
222
223      }
224
225      @Override
226      public Base setProperty(String name, Base value) throws FHIRException {
227        if (name.equals("rankOrder")) {
228          this.rankOrder = TypeConvertor.castToInteger(value); // IntegerType
229        } else if (name.equals("intervalStatistic")) {
230          this.getIntervalStatistic().add(TypeConvertor.castToStatistic(value));
231        } else
232          return super.setProperty(name, value);
233        return value;
234      }
235
236      @Override
237      public Base makeProperty(int hash, String name) throws FHIRException {
238        switch (hash) {
239        case -656537982:  return getRankOrderElement();
240        case 227099147:  return addIntervalStatistic(); 
241        default: return super.makeProperty(hash, name);
242        }
243
244      }
245
246      @Override
247      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
248        switch (hash) {
249        case -656537982: /*rankOrder*/ return new String[] {"integer"};
250        case 227099147: /*intervalStatistic*/ return new String[] {"Statistic"};
251        default: return super.getTypesForProperty(hash, name);
252        }
253
254      }
255
256      @Override
257      public Base addChild(String name) throws FHIRException {
258        if (name.equals("rankOrder")) {
259          throw new FHIRException("Cannot call addChild on a primitive type OrderedDistribution.interval.rankOrder");
260        }
261        else if (name.equals("intervalStatistic")) {
262          return addIntervalStatistic();
263        }
264        else
265          return super.addChild(name);
266      }
267
268      public OrderedDistributionIntervalComponent copy() {
269        OrderedDistributionIntervalComponent dst = new OrderedDistributionIntervalComponent();
270        copyValues(dst);
271        return dst;
272      }
273
274      public void copyValues(OrderedDistributionIntervalComponent dst) {
275        super.copyValues(dst);
276        dst.rankOrder = rankOrder == null ? null : rankOrder.copy();
277        if (intervalStatistic != null) {
278          dst.intervalStatistic = new ArrayList<Statistic>();
279          for (Statistic i : intervalStatistic)
280            dst.intervalStatistic.add(i.copy());
281        };
282      }
283
284      @Override
285      public boolean equalsDeep(Base other_) {
286        if (!super.equalsDeep(other_))
287          return false;
288        if (!(other_ instanceof OrderedDistributionIntervalComponent))
289          return false;
290        OrderedDistributionIntervalComponent o = (OrderedDistributionIntervalComponent) other_;
291        return compareDeep(rankOrder, o.rankOrder, true) && compareDeep(intervalStatistic, o.intervalStatistic, true)
292          ;
293      }
294
295      @Override
296      public boolean equalsShallow(Base other_) {
297        if (!super.equalsShallow(other_))
298          return false;
299        if (!(other_ instanceof OrderedDistributionIntervalComponent))
300          return false;
301        OrderedDistributionIntervalComponent o = (OrderedDistributionIntervalComponent) other_;
302        return compareValues(rankOrder, o.rankOrder, true);
303      }
304
305      public boolean isEmpty() {
306        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(rankOrder, intervalStatistic
307          );
308      }
309
310  public String fhirType() {
311    return "OrderedDistribution.interval";
312
313  }
314
315  }
316
317    /**
318     * A description of the content and value of the statistic.
319     */
320    @Child(name = "description", type = {StringType.class}, order=0, min=0, max=1, modifier=false, summary=false)
321    @Description(shortDefinition="A description of the content and value of the statistic", formalDefinition="A description of the content and value of the statistic." )
322    protected StringType description;
323
324    /**
325     * Footnotes and/or explanatory notes.
326     */
327    @Child(name = "note", type = {Annotation.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
328    @Description(shortDefinition="Footnotes and/or explanatory notes", formalDefinition="Footnotes and/or explanatory notes." )
329    protected List<Annotation> note;
330
331    /**
332     * Number of intervals in an array, eg 4 for quartiles.
333     */
334    @Child(name = "numberOfIntervals", type = {IntegerType.class}, order=2, min=1, max=1, modifier=false, summary=true)
335    @Description(shortDefinition="Number of intervals in an array, eg 4 for quartiles", formalDefinition="Number of intervals in an array, eg 4 for quartiles." )
336    protected IntegerType numberOfIntervals;
337
338    /**
339     * Bottom of first interval.
340     */
341    @Child(name = "bottomOfFirstInterval", type = {Quantity.class}, order=3, min=0, max=1, modifier=false, summary=false)
342    @Description(shortDefinition="Bottom of first interval", formalDefinition="Bottom of first interval." )
343    protected Quantity bottomOfFirstInterval;
344
345    /**
346     * Interval.
347     */
348    @Child(name = "interval", type = {}, order=4, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
349    @Description(shortDefinition="Interval", formalDefinition="Interval." )
350    protected List<OrderedDistributionIntervalComponent> interval;
351
352    /**
353     * Singular value of the statistic at the upper bound of the interval.
354     */
355    @Child(name = "topOfInterval", type = {Quantity.class}, order=5, min=0, max=1, modifier=false, summary=false)
356    @Description(shortDefinition="Singular value of the statistic at the upper bound of the interval", formalDefinition="Singular value of the statistic at the upper bound of the interval." )
357    protected Quantity topOfInterval;
358
359    private static final long serialVersionUID = -1559333328L;
360
361  /**
362   * Constructor
363   */
364    public OrderedDistribution() {
365      super();
366    }
367
368  /**
369   * Constructor
370   */
371    public OrderedDistribution(int numberOfIntervals, OrderedDistributionIntervalComponent interval) {
372      super();
373      this.setNumberOfIntervals(numberOfIntervals);
374      this.addInterval(interval);
375    }
376
377    /**
378     * @return {@link #description} (A description of the content and value of the statistic.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
379     */
380    public StringType getDescriptionElement() { 
381      if (this.description == null)
382        if (Configuration.errorOnAutoCreate())
383          throw new Error("Attempt to auto-create OrderedDistribution.description");
384        else if (Configuration.doAutoCreate())
385          this.description = new StringType(); // bb
386      return this.description;
387    }
388
389    public boolean hasDescriptionElement() { 
390      return this.description != null && !this.description.isEmpty();
391    }
392
393    public boolean hasDescription() { 
394      return this.description != null && !this.description.isEmpty();
395    }
396
397    /**
398     * @param value {@link #description} (A description of the content and value of the statistic.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
399     */
400    public OrderedDistribution setDescriptionElement(StringType value) { 
401      this.description = value;
402      return this;
403    }
404
405    /**
406     * @return A description of the content and value of the statistic.
407     */
408    public String getDescription() { 
409      return this.description == null ? null : this.description.getValue();
410    }
411
412    /**
413     * @param value A description of the content and value of the statistic.
414     */
415    public OrderedDistribution setDescription(String value) { 
416      if (Utilities.noString(value))
417        this.description = null;
418      else {
419        if (this.description == null)
420          this.description = new StringType();
421        this.description.setValue(value);
422      }
423      return this;
424    }
425
426    /**
427     * @return {@link #note} (Footnotes and/or explanatory notes.)
428     */
429    public List<Annotation> getNote() { 
430      if (this.note == null)
431        this.note = new ArrayList<Annotation>();
432      return this.note;
433    }
434
435    /**
436     * @return Returns a reference to <code>this</code> for easy method chaining
437     */
438    public OrderedDistribution setNote(List<Annotation> theNote) { 
439      this.note = theNote;
440      return this;
441    }
442
443    public boolean hasNote() { 
444      if (this.note == null)
445        return false;
446      for (Annotation item : this.note)
447        if (!item.isEmpty())
448          return true;
449      return false;
450    }
451
452    public Annotation addNote() { //3
453      Annotation t = new Annotation();
454      if (this.note == null)
455        this.note = new ArrayList<Annotation>();
456      this.note.add(t);
457      return t;
458    }
459
460    public OrderedDistribution addNote(Annotation t) { //3
461      if (t == null)
462        return this;
463      if (this.note == null)
464        this.note = new ArrayList<Annotation>();
465      this.note.add(t);
466      return this;
467    }
468
469    /**
470     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist {3}
471     */
472    public Annotation getNoteFirstRep() { 
473      if (getNote().isEmpty()) {
474        addNote();
475      }
476      return getNote().get(0);
477    }
478
479    /**
480     * @return {@link #numberOfIntervals} (Number of intervals in an array, eg 4 for quartiles.). This is the underlying object with id, value and extensions. The accessor "getNumberOfIntervals" gives direct access to the value
481     */
482    public IntegerType getNumberOfIntervalsElement() { 
483      if (this.numberOfIntervals == null)
484        if (Configuration.errorOnAutoCreate())
485          throw new Error("Attempt to auto-create OrderedDistribution.numberOfIntervals");
486        else if (Configuration.doAutoCreate())
487          this.numberOfIntervals = new IntegerType(); // bb
488      return this.numberOfIntervals;
489    }
490
491    public boolean hasNumberOfIntervalsElement() { 
492      return this.numberOfIntervals != null && !this.numberOfIntervals.isEmpty();
493    }
494
495    public boolean hasNumberOfIntervals() { 
496      return this.numberOfIntervals != null && !this.numberOfIntervals.isEmpty();
497    }
498
499    /**
500     * @param value {@link #numberOfIntervals} (Number of intervals in an array, eg 4 for quartiles.). This is the underlying object with id, value and extensions. The accessor "getNumberOfIntervals" gives direct access to the value
501     */
502    public OrderedDistribution setNumberOfIntervalsElement(IntegerType value) { 
503      this.numberOfIntervals = value;
504      return this;
505    }
506
507    /**
508     * @return Number of intervals in an array, eg 4 for quartiles.
509     */
510    public int getNumberOfIntervals() { 
511      return this.numberOfIntervals == null || this.numberOfIntervals.isEmpty() ? 0 : this.numberOfIntervals.getValue();
512    }
513
514    /**
515     * @param value Number of intervals in an array, eg 4 for quartiles.
516     */
517    public OrderedDistribution setNumberOfIntervals(int value) { 
518        if (this.numberOfIntervals == null)
519          this.numberOfIntervals = new IntegerType();
520        this.numberOfIntervals.setValue(value);
521      return this;
522    }
523
524    /**
525     * @return {@link #bottomOfFirstInterval} (Bottom of first interval.)
526     */
527    public Quantity getBottomOfFirstInterval() { 
528      if (this.bottomOfFirstInterval == null)
529        if (Configuration.errorOnAutoCreate())
530          throw new Error("Attempt to auto-create OrderedDistribution.bottomOfFirstInterval");
531        else if (Configuration.doAutoCreate())
532          this.bottomOfFirstInterval = new Quantity(); // cc
533      return this.bottomOfFirstInterval;
534    }
535
536    public boolean hasBottomOfFirstInterval() { 
537      return this.bottomOfFirstInterval != null && !this.bottomOfFirstInterval.isEmpty();
538    }
539
540    /**
541     * @param value {@link #bottomOfFirstInterval} (Bottom of first interval.)
542     */
543    public OrderedDistribution setBottomOfFirstInterval(Quantity value) { 
544      this.bottomOfFirstInterval = value;
545      return this;
546    }
547
548    /**
549     * @return {@link #interval} (Interval.)
550     */
551    public List<OrderedDistributionIntervalComponent> getInterval() { 
552      if (this.interval == null)
553        this.interval = new ArrayList<OrderedDistributionIntervalComponent>();
554      return this.interval;
555    }
556
557    /**
558     * @return Returns a reference to <code>this</code> for easy method chaining
559     */
560    public OrderedDistribution setInterval(List<OrderedDistributionIntervalComponent> theInterval) { 
561      this.interval = theInterval;
562      return this;
563    }
564
565    public boolean hasInterval() { 
566      if (this.interval == null)
567        return false;
568      for (OrderedDistributionIntervalComponent item : this.interval)
569        if (!item.isEmpty())
570          return true;
571      return false;
572    }
573
574    public OrderedDistributionIntervalComponent addInterval() { //3
575      OrderedDistributionIntervalComponent t = new OrderedDistributionIntervalComponent();
576      if (this.interval == null)
577        this.interval = new ArrayList<OrderedDistributionIntervalComponent>();
578      this.interval.add(t);
579      return t;
580    }
581
582    public OrderedDistribution addInterval(OrderedDistributionIntervalComponent t) { //3
583      if (t == null)
584        return this;
585      if (this.interval == null)
586        this.interval = new ArrayList<OrderedDistributionIntervalComponent>();
587      this.interval.add(t);
588      return this;
589    }
590
591    /**
592     * @return The first repetition of repeating field {@link #interval}, creating it if it does not already exist {3}
593     */
594    public OrderedDistributionIntervalComponent getIntervalFirstRep() { 
595      if (getInterval().isEmpty()) {
596        addInterval();
597      }
598      return getInterval().get(0);
599    }
600
601    /**
602     * @return {@link #topOfInterval} (Singular value of the statistic at the upper bound of the interval.)
603     */
604    public Quantity getTopOfInterval() { 
605      if (this.topOfInterval == null)
606        if (Configuration.errorOnAutoCreate())
607          throw new Error("Attempt to auto-create OrderedDistribution.topOfInterval");
608        else if (Configuration.doAutoCreate())
609          this.topOfInterval = new Quantity(); // cc
610      return this.topOfInterval;
611    }
612
613    public boolean hasTopOfInterval() { 
614      return this.topOfInterval != null && !this.topOfInterval.isEmpty();
615    }
616
617    /**
618     * @param value {@link #topOfInterval} (Singular value of the statistic at the upper bound of the interval.)
619     */
620    public OrderedDistribution setTopOfInterval(Quantity value) { 
621      this.topOfInterval = value;
622      return this;
623    }
624
625      protected void listChildren(List<Property> children) {
626        super.listChildren(children);
627        children.add(new Property("description", "string", "A description of the content and value of the statistic.", 0, 1, description));
628        children.add(new Property("note", "Annotation", "Footnotes and/or explanatory notes.", 0, java.lang.Integer.MAX_VALUE, note));
629        children.add(new Property("numberOfIntervals", "integer", "Number of intervals in an array, eg 4 for quartiles.", 0, 1, numberOfIntervals));
630        children.add(new Property("bottomOfFirstInterval", "Quantity", "Bottom of first interval.", 0, 1, bottomOfFirstInterval));
631        children.add(new Property("interval", "", "Interval.", 0, java.lang.Integer.MAX_VALUE, interval));
632        children.add(new Property("topOfInterval", "Quantity", "Singular value of the statistic at the upper bound of the interval.", 0, 1, topOfInterval));
633      }
634
635      @Override
636      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
637        switch (_hash) {
638        case -1724546052: /*description*/  return new Property("description", "string", "A description of the content and value of the statistic.", 0, 1, description);
639        case 3387378: /*note*/  return new Property("note", "Annotation", "Footnotes and/or explanatory notes.", 0, java.lang.Integer.MAX_VALUE, note);
640        case -569541330: /*numberOfIntervals*/  return new Property("numberOfIntervals", "integer", "Number of intervals in an array, eg 4 for quartiles.", 0, 1, numberOfIntervals);
641        case 37889363: /*bottomOfFirstInterval*/  return new Property("bottomOfFirstInterval", "Quantity", "Bottom of first interval.", 0, 1, bottomOfFirstInterval);
642        case 570418373: /*interval*/  return new Property("interval", "", "Interval.", 0, java.lang.Integer.MAX_VALUE, interval);
643        case 691816177: /*topOfInterval*/  return new Property("topOfInterval", "Quantity", "Singular value of the statistic at the upper bound of the interval.", 0, 1, topOfInterval);
644        default: return super.getNamedProperty(_hash, _name, _checkValid);
645        }
646
647      }
648
649      @Override
650      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
651        switch (hash) {
652        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
653        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
654        case -569541330: /*numberOfIntervals*/ return this.numberOfIntervals == null ? new Base[0] : new Base[] {this.numberOfIntervals}; // IntegerType
655        case 37889363: /*bottomOfFirstInterval*/ return this.bottomOfFirstInterval == null ? new Base[0] : new Base[] {this.bottomOfFirstInterval}; // Quantity
656        case 570418373: /*interval*/ return this.interval == null ? new Base[0] : this.interval.toArray(new Base[this.interval.size()]); // OrderedDistributionIntervalComponent
657        case 691816177: /*topOfInterval*/ return this.topOfInterval == null ? new Base[0] : new Base[] {this.topOfInterval}; // Quantity
658        default: return super.getProperty(hash, name, checkValid);
659        }
660
661      }
662
663      @Override
664      public Base setProperty(int hash, String name, Base value) throws FHIRException {
665        switch (hash) {
666        case -1724546052: // description
667          this.description = TypeConvertor.castToString(value); // StringType
668          return value;
669        case 3387378: // note
670          this.getNote().add(TypeConvertor.castToAnnotation(value)); // Annotation
671          return value;
672        case -569541330: // numberOfIntervals
673          this.numberOfIntervals = TypeConvertor.castToInteger(value); // IntegerType
674          return value;
675        case 37889363: // bottomOfFirstInterval
676          this.bottomOfFirstInterval = TypeConvertor.castToQuantity(value); // Quantity
677          return value;
678        case 570418373: // interval
679          this.getInterval().add((OrderedDistributionIntervalComponent) value); // OrderedDistributionIntervalComponent
680          return value;
681        case 691816177: // topOfInterval
682          this.topOfInterval = TypeConvertor.castToQuantity(value); // Quantity
683          return value;
684        default: return super.setProperty(hash, name, value);
685        }
686
687      }
688
689      @Override
690      public Base setProperty(String name, Base value) throws FHIRException {
691        if (name.equals("description")) {
692          this.description = TypeConvertor.castToString(value); // StringType
693        } else if (name.equals("note")) {
694          this.getNote().add(TypeConvertor.castToAnnotation(value));
695        } else if (name.equals("numberOfIntervals")) {
696          this.numberOfIntervals = TypeConvertor.castToInteger(value); // IntegerType
697        } else if (name.equals("bottomOfFirstInterval")) {
698          this.bottomOfFirstInterval = TypeConvertor.castToQuantity(value); // Quantity
699        } else if (name.equals("interval")) {
700          this.getInterval().add((OrderedDistributionIntervalComponent) value);
701        } else if (name.equals("topOfInterval")) {
702          this.topOfInterval = TypeConvertor.castToQuantity(value); // Quantity
703        } else
704          return super.setProperty(name, value);
705        return value;
706      }
707
708      @Override
709      public Base makeProperty(int hash, String name) throws FHIRException {
710        switch (hash) {
711        case -1724546052:  return getDescriptionElement();
712        case 3387378:  return addNote(); 
713        case -569541330:  return getNumberOfIntervalsElement();
714        case 37889363:  return getBottomOfFirstInterval();
715        case 570418373:  return addInterval(); 
716        case 691816177:  return getTopOfInterval();
717        default: return super.makeProperty(hash, name);
718        }
719
720      }
721
722      @Override
723      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
724        switch (hash) {
725        case -1724546052: /*description*/ return new String[] {"string"};
726        case 3387378: /*note*/ return new String[] {"Annotation"};
727        case -569541330: /*numberOfIntervals*/ return new String[] {"integer"};
728        case 37889363: /*bottomOfFirstInterval*/ return new String[] {"Quantity"};
729        case 570418373: /*interval*/ return new String[] {};
730        case 691816177: /*topOfInterval*/ return new String[] {"Quantity"};
731        default: return super.getTypesForProperty(hash, name);
732        }
733
734      }
735
736      @Override
737      public Base addChild(String name) throws FHIRException {
738        if (name.equals("description")) {
739          throw new FHIRException("Cannot call addChild on a primitive type OrderedDistribution.description");
740        }
741        else if (name.equals("note")) {
742          return addNote();
743        }
744        else if (name.equals("numberOfIntervals")) {
745          throw new FHIRException("Cannot call addChild on a primitive type OrderedDistribution.numberOfIntervals");
746        }
747        else if (name.equals("bottomOfFirstInterval")) {
748          this.bottomOfFirstInterval = new Quantity();
749          return this.bottomOfFirstInterval;
750        }
751        else if (name.equals("interval")) {
752          return addInterval();
753        }
754        else if (name.equals("topOfInterval")) {
755          this.topOfInterval = new Quantity();
756          return this.topOfInterval;
757        }
758        else
759          return super.addChild(name);
760      }
761
762  public String fhirType() {
763    return "OrderedDistribution";
764
765  }
766
767      public OrderedDistribution copy() {
768        OrderedDistribution dst = new OrderedDistribution();
769        copyValues(dst);
770        return dst;
771      }
772
773      public void copyValues(OrderedDistribution dst) {
774        super.copyValues(dst);
775        dst.description = description == null ? null : description.copy();
776        if (note != null) {
777          dst.note = new ArrayList<Annotation>();
778          for (Annotation i : note)
779            dst.note.add(i.copy());
780        };
781        dst.numberOfIntervals = numberOfIntervals == null ? null : numberOfIntervals.copy();
782        dst.bottomOfFirstInterval = bottomOfFirstInterval == null ? null : bottomOfFirstInterval.copy();
783        if (interval != null) {
784          dst.interval = new ArrayList<OrderedDistributionIntervalComponent>();
785          for (OrderedDistributionIntervalComponent i : interval)
786            dst.interval.add(i.copy());
787        };
788        dst.topOfInterval = topOfInterval == null ? null : topOfInterval.copy();
789      }
790
791      protected OrderedDistribution typedCopy() {
792        return copy();
793      }
794
795      @Override
796      public boolean equalsDeep(Base other_) {
797        if (!super.equalsDeep(other_))
798          return false;
799        if (!(other_ instanceof OrderedDistribution))
800          return false;
801        OrderedDistribution o = (OrderedDistribution) other_;
802        return compareDeep(description, o.description, true) && compareDeep(note, o.note, true) && compareDeep(numberOfIntervals, o.numberOfIntervals, true)
803           && compareDeep(bottomOfFirstInterval, o.bottomOfFirstInterval, true) && compareDeep(interval, o.interval, true)
804           && compareDeep(topOfInterval, o.topOfInterval, true);
805      }
806
807      @Override
808      public boolean equalsShallow(Base other_) {
809        if (!super.equalsShallow(other_))
810          return false;
811        if (!(other_ instanceof OrderedDistribution))
812          return false;
813        OrderedDistribution o = (OrderedDistribution) other_;
814        return compareValues(description, o.description, true) && compareValues(numberOfIntervals, o.numberOfIntervals, true)
815          ;
816      }
817
818      public boolean isEmpty() {
819        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(description, note, numberOfIntervals
820          , bottomOfFirstInterval, interval, topOfInterval);
821      }
822
823
824}
825