001package org.hl7.fhir.dstu2016may.model;
002
003import java.math.BigDecimal;
004
005/*
006  Copyright (c) 2011+, HL7, Inc.
007  All rights reserved.
008  
009  Redistribution and use in source and binary forms, with or without modification, 
010  are permitted provided that the following conditions are met:
011  
012   * Redistributions of source code must retain the above copyright notice, this 
013     list of conditions and the following disclaimer.
014   * Redistributions in binary form must reproduce the above copyright notice, 
015     this list of conditions and the following disclaimer in the documentation 
016     and/or other materials provided with the distribution.
017   * Neither the name of HL7 nor the names of its contributors may be used to 
018     endorse or promote products derived from this software without specific 
019     prior written permission.
020  
021  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
022  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
023  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
024  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
025  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
026  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
027  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
028  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
029  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
030  POSSIBILITY OF SUCH DAMAGE.
031  
032*/
033
034// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
035import java.util.ArrayList;
036import java.util.Date;
037import java.util.List;
038
039import org.hl7.fhir.exceptions.FHIRException;
040import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
041import org.hl7.fhir.utilities.Utilities;
042
043import ca.uhn.fhir.model.api.annotation.Block;
044import ca.uhn.fhir.model.api.annotation.Child;
045import ca.uhn.fhir.model.api.annotation.Description;
046import ca.uhn.fhir.model.api.annotation.ResourceDef;
047import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
048/**
049 * An authorization for the supply of glasses and/or contact lenses to a patient.
050 */
051@ResourceDef(name="VisionPrescription", profile="http://hl7.org/fhir/Profile/VisionPrescription")
052public class VisionPrescription extends DomainResource {
053
054    public enum VisionEyes {
055        /**
056         * Right Eye
057         */
058        RIGHT, 
059        /**
060         * Left Eye
061         */
062        LEFT, 
063        /**
064         * added to help the parsers
065         */
066        NULL;
067        public static VisionEyes fromCode(String codeString) throws FHIRException {
068            if (codeString == null || "".equals(codeString))
069                return null;
070        if ("right".equals(codeString))
071          return RIGHT;
072        if ("left".equals(codeString))
073          return LEFT;
074        throw new FHIRException("Unknown VisionEyes code '"+codeString+"'");
075        }
076        public String toCode() {
077          switch (this) {
078            case RIGHT: return "right";
079            case LEFT: return "left";
080            default: return "?";
081          }
082        }
083        public String getSystem() {
084          switch (this) {
085            case RIGHT: return "http://hl7.org/fhir/vision-eye-codes";
086            case LEFT: return "http://hl7.org/fhir/vision-eye-codes";
087            default: return "?";
088          }
089        }
090        public String getDefinition() {
091          switch (this) {
092            case RIGHT: return "Right Eye";
093            case LEFT: return "Left Eye";
094            default: return "?";
095          }
096        }
097        public String getDisplay() {
098          switch (this) {
099            case RIGHT: return "Right Eye";
100            case LEFT: return "Left Eye";
101            default: return "?";
102          }
103        }
104    }
105
106  public static class VisionEyesEnumFactory implements EnumFactory<VisionEyes> {
107    public VisionEyes fromCode(String codeString) throws IllegalArgumentException {
108      if (codeString == null || "".equals(codeString))
109            if (codeString == null || "".equals(codeString))
110                return null;
111        if ("right".equals(codeString))
112          return VisionEyes.RIGHT;
113        if ("left".equals(codeString))
114          return VisionEyes.LEFT;
115        throw new IllegalArgumentException("Unknown VisionEyes code '"+codeString+"'");
116        }
117        public Enumeration<VisionEyes> fromType(Base code) throws FHIRException {
118          if (code == null || code.isEmpty())
119            return null;
120          String codeString = ((PrimitiveType) code).asStringValue();
121          if (codeString == null || "".equals(codeString))
122            return null;
123        if ("right".equals(codeString))
124          return new Enumeration<VisionEyes>(this, VisionEyes.RIGHT);
125        if ("left".equals(codeString))
126          return new Enumeration<VisionEyes>(this, VisionEyes.LEFT);
127        throw new FHIRException("Unknown VisionEyes code '"+codeString+"'");
128        }
129    public String toCode(VisionEyes code) {
130      if (code == VisionEyes.RIGHT)
131        return "right";
132      if (code == VisionEyes.LEFT)
133        return "left";
134      return "?";
135      }
136    public String toSystem(VisionEyes code) {
137      return code.getSystem();
138      }
139    }
140
141    public enum VisionBase {
142        /**
143         * top
144         */
145        UP, 
146        /**
147         * bottom
148         */
149        DOWN, 
150        /**
151         * inner edge
152         */
153        IN, 
154        /**
155         * outer edge
156         */
157        OUT, 
158        /**
159         * added to help the parsers
160         */
161        NULL;
162        public static VisionBase fromCode(String codeString) throws FHIRException {
163            if (codeString == null || "".equals(codeString))
164                return null;
165        if ("up".equals(codeString))
166          return UP;
167        if ("down".equals(codeString))
168          return DOWN;
169        if ("in".equals(codeString))
170          return IN;
171        if ("out".equals(codeString))
172          return OUT;
173        throw new FHIRException("Unknown VisionBase code '"+codeString+"'");
174        }
175        public String toCode() {
176          switch (this) {
177            case UP: return "up";
178            case DOWN: return "down";
179            case IN: return "in";
180            case OUT: return "out";
181            default: return "?";
182          }
183        }
184        public String getSystem() {
185          switch (this) {
186            case UP: return "http://hl7.org/fhir/vision-base-codes";
187            case DOWN: return "http://hl7.org/fhir/vision-base-codes";
188            case IN: return "http://hl7.org/fhir/vision-base-codes";
189            case OUT: return "http://hl7.org/fhir/vision-base-codes";
190            default: return "?";
191          }
192        }
193        public String getDefinition() {
194          switch (this) {
195            case UP: return "top";
196            case DOWN: return "bottom";
197            case IN: return "inner edge";
198            case OUT: return "outer edge";
199            default: return "?";
200          }
201        }
202        public String getDisplay() {
203          switch (this) {
204            case UP: return "Up";
205            case DOWN: return "Down";
206            case IN: return "In";
207            case OUT: return "Out";
208            default: return "?";
209          }
210        }
211    }
212
213  public static class VisionBaseEnumFactory implements EnumFactory<VisionBase> {
214    public VisionBase fromCode(String codeString) throws IllegalArgumentException {
215      if (codeString == null || "".equals(codeString))
216            if (codeString == null || "".equals(codeString))
217                return null;
218        if ("up".equals(codeString))
219          return VisionBase.UP;
220        if ("down".equals(codeString))
221          return VisionBase.DOWN;
222        if ("in".equals(codeString))
223          return VisionBase.IN;
224        if ("out".equals(codeString))
225          return VisionBase.OUT;
226        throw new IllegalArgumentException("Unknown VisionBase code '"+codeString+"'");
227        }
228        public Enumeration<VisionBase> fromType(Base code) throws FHIRException {
229          if (code == null || code.isEmpty())
230            return null;
231          String codeString = ((PrimitiveType) code).asStringValue();
232          if (codeString == null || "".equals(codeString))
233            return null;
234        if ("up".equals(codeString))
235          return new Enumeration<VisionBase>(this, VisionBase.UP);
236        if ("down".equals(codeString))
237          return new Enumeration<VisionBase>(this, VisionBase.DOWN);
238        if ("in".equals(codeString))
239          return new Enumeration<VisionBase>(this, VisionBase.IN);
240        if ("out".equals(codeString))
241          return new Enumeration<VisionBase>(this, VisionBase.OUT);
242        throw new FHIRException("Unknown VisionBase code '"+codeString+"'");
243        }
244    public String toCode(VisionBase code) {
245      if (code == VisionBase.UP)
246        return "up";
247      if (code == VisionBase.DOWN)
248        return "down";
249      if (code == VisionBase.IN)
250        return "in";
251      if (code == VisionBase.OUT)
252        return "out";
253      return "?";
254      }
255    public String toSystem(VisionBase code) {
256      return code.getSystem();
257      }
258    }
259
260    @Block()
261    public static class VisionPrescriptionDispenseComponent extends BackboneElement implements IBaseBackboneElement {
262        /**
263         * Identifies the type of vision correction product which is required for the patient.
264         */
265        @Child(name = "product", type = {Coding.class}, order=1, min=1, max=1, modifier=false, summary=true)
266        @Description(shortDefinition="Product to be supplied", formalDefinition="Identifies the type of vision correction product which is required for the patient." )
267        protected Coding product;
268
269        /**
270         * The eye for which the lens applies.
271         */
272        @Child(name = "eye", type = {CodeType.class}, order=2, min=0, max=1, modifier=false, summary=true)
273        @Description(shortDefinition="right | left", formalDefinition="The eye for which the lens applies." )
274        protected Enumeration<VisionEyes> eye;
275
276        /**
277         * Lens power measured in diopters (0.25 units).
278         */
279        @Child(name = "sphere", type = {DecimalType.class}, order=3, min=0, max=1, modifier=false, summary=true)
280        @Description(shortDefinition="Lens sphere", formalDefinition="Lens power measured in diopters (0.25 units)." )
281        protected DecimalType sphere;
282
283        /**
284         * Power adjustment for astigmatism measured in diopters (0.25 units).
285         */
286        @Child(name = "cylinder", type = {DecimalType.class}, order=4, min=0, max=1, modifier=false, summary=true)
287        @Description(shortDefinition="Lens cylinder", formalDefinition="Power adjustment for astigmatism measured in diopters (0.25 units)." )
288        protected DecimalType cylinder;
289
290        /**
291         * Adjustment for astigmatism measured in integer degrees.
292         */
293        @Child(name = "axis", type = {IntegerType.class}, order=5, min=0, max=1, modifier=false, summary=true)
294        @Description(shortDefinition="Lens axis", formalDefinition="Adjustment for astigmatism measured in integer degrees." )
295        protected IntegerType axis;
296
297        /**
298         * Amount of prism to compensate for eye alignment in fractional units.
299         */
300        @Child(name = "prism", type = {DecimalType.class}, order=6, min=0, max=1, modifier=false, summary=true)
301        @Description(shortDefinition="Lens prism", formalDefinition="Amount of prism to compensate for eye alignment in fractional units." )
302        protected DecimalType prism;
303
304        /**
305         * The relative base, or reference lens edge, for the prism.
306         */
307        @Child(name = "base", type = {CodeType.class}, order=7, min=0, max=1, modifier=false, summary=true)
308        @Description(shortDefinition="up | down | in | out", formalDefinition="The relative base, or reference lens edge, for the prism." )
309        protected Enumeration<VisionBase> base;
310
311        /**
312         * Power adjustment for multifocal lenses measured in diopters (0.25 units).
313         */
314        @Child(name = "add", type = {DecimalType.class}, order=8, min=0, max=1, modifier=false, summary=true)
315        @Description(shortDefinition="Lens add", formalDefinition="Power adjustment for multifocal lenses measured in diopters (0.25 units)." )
316        protected DecimalType add;
317
318        /**
319         * Contact lens power measured in diopters (0.25 units).
320         */
321        @Child(name = "power", type = {DecimalType.class}, order=9, min=0, max=1, modifier=false, summary=true)
322        @Description(shortDefinition="Contact lens power", formalDefinition="Contact lens power measured in diopters (0.25 units)." )
323        protected DecimalType power;
324
325        /**
326         * Back curvature measured in millimeters.
327         */
328        @Child(name = "backCurve", type = {DecimalType.class}, order=10, min=0, max=1, modifier=false, summary=true)
329        @Description(shortDefinition="Contact lens back curvature", formalDefinition="Back curvature measured in millimeters." )
330        protected DecimalType backCurve;
331
332        /**
333         * Contact lens diameter measured in millimeters.
334         */
335        @Child(name = "diameter", type = {DecimalType.class}, order=11, min=0, max=1, modifier=false, summary=true)
336        @Description(shortDefinition="Contact lens diameter", formalDefinition="Contact lens diameter measured in millimeters." )
337        protected DecimalType diameter;
338
339        /**
340         * The recommended maximum wear period for the lens.
341         */
342        @Child(name = "duration", type = {SimpleQuantity.class}, order=12, min=0, max=1, modifier=false, summary=true)
343        @Description(shortDefinition="Lens wear duration", formalDefinition="The recommended maximum wear period for the lens." )
344        protected SimpleQuantity duration;
345
346        /**
347         * Special color or pattern.
348         */
349        @Child(name = "color", type = {StringType.class}, order=13, min=0, max=1, modifier=false, summary=true)
350        @Description(shortDefinition="Lens add", formalDefinition="Special color or pattern." )
351        protected StringType color;
352
353        /**
354         * Brand recommendations or restrictions.
355         */
356        @Child(name = "brand", type = {StringType.class}, order=14, min=0, max=1, modifier=false, summary=true)
357        @Description(shortDefinition="Lens add", formalDefinition="Brand recommendations or restrictions." )
358        protected StringType brand;
359
360        /**
361         * Notes for special requirements such as coatings and lens materials.
362         */
363        @Child(name = "notes", type = {StringType.class}, order=15, min=0, max=1, modifier=false, summary=true)
364        @Description(shortDefinition="Notes for coatings", formalDefinition="Notes for special requirements such as coatings and lens materials." )
365        protected StringType notes;
366
367        private static final long serialVersionUID = -1586392610L;
368
369    /**
370     * Constructor
371     */
372      public VisionPrescriptionDispenseComponent() {
373        super();
374      }
375
376    /**
377     * Constructor
378     */
379      public VisionPrescriptionDispenseComponent(Coding product) {
380        super();
381        this.product = product;
382      }
383
384        /**
385         * @return {@link #product} (Identifies the type of vision correction product which is required for the patient.)
386         */
387        public Coding getProduct() { 
388          if (this.product == null)
389            if (Configuration.errorOnAutoCreate())
390              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.product");
391            else if (Configuration.doAutoCreate())
392              this.product = new Coding(); // cc
393          return this.product;
394        }
395
396        public boolean hasProduct() { 
397          return this.product != null && !this.product.isEmpty();
398        }
399
400        /**
401         * @param value {@link #product} (Identifies the type of vision correction product which is required for the patient.)
402         */
403        public VisionPrescriptionDispenseComponent setProduct(Coding value) { 
404          this.product = value;
405          return this;
406        }
407
408        /**
409         * @return {@link #eye} (The eye for which the lens applies.). This is the underlying object with id, value and extensions. The accessor "getEye" gives direct access to the value
410         */
411        public Enumeration<VisionEyes> getEyeElement() { 
412          if (this.eye == null)
413            if (Configuration.errorOnAutoCreate())
414              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.eye");
415            else if (Configuration.doAutoCreate())
416              this.eye = new Enumeration<VisionEyes>(new VisionEyesEnumFactory()); // bb
417          return this.eye;
418        }
419
420        public boolean hasEyeElement() { 
421          return this.eye != null && !this.eye.isEmpty();
422        }
423
424        public boolean hasEye() { 
425          return this.eye != null && !this.eye.isEmpty();
426        }
427
428        /**
429         * @param value {@link #eye} (The eye for which the lens applies.). This is the underlying object with id, value and extensions. The accessor "getEye" gives direct access to the value
430         */
431        public VisionPrescriptionDispenseComponent setEyeElement(Enumeration<VisionEyes> value) { 
432          this.eye = value;
433          return this;
434        }
435
436        /**
437         * @return The eye for which the lens applies.
438         */
439        public VisionEyes getEye() { 
440          return this.eye == null ? null : this.eye.getValue();
441        }
442
443        /**
444         * @param value The eye for which the lens applies.
445         */
446        public VisionPrescriptionDispenseComponent setEye(VisionEyes value) { 
447          if (value == null)
448            this.eye = null;
449          else {
450            if (this.eye == null)
451              this.eye = new Enumeration<VisionEyes>(new VisionEyesEnumFactory());
452            this.eye.setValue(value);
453          }
454          return this;
455        }
456
457        /**
458         * @return {@link #sphere} (Lens power measured in diopters (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getSphere" gives direct access to the value
459         */
460        public DecimalType getSphereElement() { 
461          if (this.sphere == null)
462            if (Configuration.errorOnAutoCreate())
463              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.sphere");
464            else if (Configuration.doAutoCreate())
465              this.sphere = new DecimalType(); // bb
466          return this.sphere;
467        }
468
469        public boolean hasSphereElement() { 
470          return this.sphere != null && !this.sphere.isEmpty();
471        }
472
473        public boolean hasSphere() { 
474          return this.sphere != null && !this.sphere.isEmpty();
475        }
476
477        /**
478         * @param value {@link #sphere} (Lens power measured in diopters (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getSphere" gives direct access to the value
479         */
480        public VisionPrescriptionDispenseComponent setSphereElement(DecimalType value) { 
481          this.sphere = value;
482          return this;
483        }
484
485        /**
486         * @return Lens power measured in diopters (0.25 units).
487         */
488        public BigDecimal getSphere() { 
489          return this.sphere == null ? null : this.sphere.getValue();
490        }
491
492        /**
493         * @param value Lens power measured in diopters (0.25 units).
494         */
495        public VisionPrescriptionDispenseComponent setSphere(BigDecimal value) { 
496          if (value == null)
497            this.sphere = null;
498          else {
499            if (this.sphere == null)
500              this.sphere = new DecimalType();
501            this.sphere.setValue(value);
502          }
503          return this;
504        }
505
506        /**
507         * @param value Lens power measured in diopters (0.25 units).
508         */
509        public VisionPrescriptionDispenseComponent setSphere(long value) { 
510              this.sphere = new DecimalType();
511            this.sphere.setValue(value);
512          return this;
513        }
514
515        /**
516         * @param value Lens power measured in diopters (0.25 units).
517         */
518        public VisionPrescriptionDispenseComponent setSphere(double value) { 
519              this.sphere = new DecimalType();
520            this.sphere.setValue(value);
521          return this;
522        }
523
524        /**
525         * @return {@link #cylinder} (Power adjustment for astigmatism measured in diopters (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getCylinder" gives direct access to the value
526         */
527        public DecimalType getCylinderElement() { 
528          if (this.cylinder == null)
529            if (Configuration.errorOnAutoCreate())
530              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.cylinder");
531            else if (Configuration.doAutoCreate())
532              this.cylinder = new DecimalType(); // bb
533          return this.cylinder;
534        }
535
536        public boolean hasCylinderElement() { 
537          return this.cylinder != null && !this.cylinder.isEmpty();
538        }
539
540        public boolean hasCylinder() { 
541          return this.cylinder != null && !this.cylinder.isEmpty();
542        }
543
544        /**
545         * @param value {@link #cylinder} (Power adjustment for astigmatism measured in diopters (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getCylinder" gives direct access to the value
546         */
547        public VisionPrescriptionDispenseComponent setCylinderElement(DecimalType value) { 
548          this.cylinder = value;
549          return this;
550        }
551
552        /**
553         * @return Power adjustment for astigmatism measured in diopters (0.25 units).
554         */
555        public BigDecimal getCylinder() { 
556          return this.cylinder == null ? null : this.cylinder.getValue();
557        }
558
559        /**
560         * @param value Power adjustment for astigmatism measured in diopters (0.25 units).
561         */
562        public VisionPrescriptionDispenseComponent setCylinder(BigDecimal value) { 
563          if (value == null)
564            this.cylinder = null;
565          else {
566            if (this.cylinder == null)
567              this.cylinder = new DecimalType();
568            this.cylinder.setValue(value);
569          }
570          return this;
571        }
572
573        /**
574         * @param value Power adjustment for astigmatism measured in diopters (0.25 units).
575         */
576        public VisionPrescriptionDispenseComponent setCylinder(long value) { 
577              this.cylinder = new DecimalType();
578            this.cylinder.setValue(value);
579          return this;
580        }
581
582        /**
583         * @param value Power adjustment for astigmatism measured in diopters (0.25 units).
584         */
585        public VisionPrescriptionDispenseComponent setCylinder(double value) { 
586              this.cylinder = new DecimalType();
587            this.cylinder.setValue(value);
588          return this;
589        }
590
591        /**
592         * @return {@link #axis} (Adjustment for astigmatism measured in integer degrees.). This is the underlying object with id, value and extensions. The accessor "getAxis" gives direct access to the value
593         */
594        public IntegerType getAxisElement() { 
595          if (this.axis == null)
596            if (Configuration.errorOnAutoCreate())
597              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.axis");
598            else if (Configuration.doAutoCreate())
599              this.axis = new IntegerType(); // bb
600          return this.axis;
601        }
602
603        public boolean hasAxisElement() { 
604          return this.axis != null && !this.axis.isEmpty();
605        }
606
607        public boolean hasAxis() { 
608          return this.axis != null && !this.axis.isEmpty();
609        }
610
611        /**
612         * @param value {@link #axis} (Adjustment for astigmatism measured in integer degrees.). This is the underlying object with id, value and extensions. The accessor "getAxis" gives direct access to the value
613         */
614        public VisionPrescriptionDispenseComponent setAxisElement(IntegerType value) { 
615          this.axis = value;
616          return this;
617        }
618
619        /**
620         * @return Adjustment for astigmatism measured in integer degrees.
621         */
622        public int getAxis() { 
623          return this.axis == null || this.axis.isEmpty() ? 0 : this.axis.getValue();
624        }
625
626        /**
627         * @param value Adjustment for astigmatism measured in integer degrees.
628         */
629        public VisionPrescriptionDispenseComponent setAxis(int value) { 
630            if (this.axis == null)
631              this.axis = new IntegerType();
632            this.axis.setValue(value);
633          return this;
634        }
635
636        /**
637         * @return {@link #prism} (Amount of prism to compensate for eye alignment in fractional units.). This is the underlying object with id, value and extensions. The accessor "getPrism" gives direct access to the value
638         */
639        public DecimalType getPrismElement() { 
640          if (this.prism == null)
641            if (Configuration.errorOnAutoCreate())
642              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.prism");
643            else if (Configuration.doAutoCreate())
644              this.prism = new DecimalType(); // bb
645          return this.prism;
646        }
647
648        public boolean hasPrismElement() { 
649          return this.prism != null && !this.prism.isEmpty();
650        }
651
652        public boolean hasPrism() { 
653          return this.prism != null && !this.prism.isEmpty();
654        }
655
656        /**
657         * @param value {@link #prism} (Amount of prism to compensate for eye alignment in fractional units.). This is the underlying object with id, value and extensions. The accessor "getPrism" gives direct access to the value
658         */
659        public VisionPrescriptionDispenseComponent setPrismElement(DecimalType value) { 
660          this.prism = value;
661          return this;
662        }
663
664        /**
665         * @return Amount of prism to compensate for eye alignment in fractional units.
666         */
667        public BigDecimal getPrism() { 
668          return this.prism == null ? null : this.prism.getValue();
669        }
670
671        /**
672         * @param value Amount of prism to compensate for eye alignment in fractional units.
673         */
674        public VisionPrescriptionDispenseComponent setPrism(BigDecimal value) { 
675          if (value == null)
676            this.prism = null;
677          else {
678            if (this.prism == null)
679              this.prism = new DecimalType();
680            this.prism.setValue(value);
681          }
682          return this;
683        }
684
685        /**
686         * @param value Amount of prism to compensate for eye alignment in fractional units.
687         */
688        public VisionPrescriptionDispenseComponent setPrism(long value) { 
689              this.prism = new DecimalType();
690            this.prism.setValue(value);
691          return this;
692        }
693
694        /**
695         * @param value Amount of prism to compensate for eye alignment in fractional units.
696         */
697        public VisionPrescriptionDispenseComponent setPrism(double value) { 
698              this.prism = new DecimalType();
699            this.prism.setValue(value);
700          return this;
701        }
702
703        /**
704         * @return {@link #base} (The relative base, or reference lens edge, for the prism.). This is the underlying object with id, value and extensions. The accessor "getBase" gives direct access to the value
705         */
706        public Enumeration<VisionBase> getBaseElement() { 
707          if (this.base == null)
708            if (Configuration.errorOnAutoCreate())
709              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.base");
710            else if (Configuration.doAutoCreate())
711              this.base = new Enumeration<VisionBase>(new VisionBaseEnumFactory()); // bb
712          return this.base;
713        }
714
715        public boolean hasBaseElement() { 
716          return this.base != null && !this.base.isEmpty();
717        }
718
719        public boolean hasBase() { 
720          return this.base != null && !this.base.isEmpty();
721        }
722
723        /**
724         * @param value {@link #base} (The relative base, or reference lens edge, for the prism.). This is the underlying object with id, value and extensions. The accessor "getBase" gives direct access to the value
725         */
726        public VisionPrescriptionDispenseComponent setBaseElement(Enumeration<VisionBase> value) { 
727          this.base = value;
728          return this;
729        }
730
731        /**
732         * @return The relative base, or reference lens edge, for the prism.
733         */
734        public VisionBase getBase() { 
735          return this.base == null ? null : this.base.getValue();
736        }
737
738        /**
739         * @param value The relative base, or reference lens edge, for the prism.
740         */
741        public VisionPrescriptionDispenseComponent setBase(VisionBase value) { 
742          if (value == null)
743            this.base = null;
744          else {
745            if (this.base == null)
746              this.base = new Enumeration<VisionBase>(new VisionBaseEnumFactory());
747            this.base.setValue(value);
748          }
749          return this;
750        }
751
752        /**
753         * @return {@link #add} (Power adjustment for multifocal lenses measured in diopters (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getAdd" gives direct access to the value
754         */
755        public DecimalType getAddElement() { 
756          if (this.add == null)
757            if (Configuration.errorOnAutoCreate())
758              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.add");
759            else if (Configuration.doAutoCreate())
760              this.add = new DecimalType(); // bb
761          return this.add;
762        }
763
764        public boolean hasAddElement() { 
765          return this.add != null && !this.add.isEmpty();
766        }
767
768        public boolean hasAdd() { 
769          return this.add != null && !this.add.isEmpty();
770        }
771
772        /**
773         * @param value {@link #add} (Power adjustment for multifocal lenses measured in diopters (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getAdd" gives direct access to the value
774         */
775        public VisionPrescriptionDispenseComponent setAddElement(DecimalType value) { 
776          this.add = value;
777          return this;
778        }
779
780        /**
781         * @return Power adjustment for multifocal lenses measured in diopters (0.25 units).
782         */
783        public BigDecimal getAdd() { 
784          return this.add == null ? null : this.add.getValue();
785        }
786
787        /**
788         * @param value Power adjustment for multifocal lenses measured in diopters (0.25 units).
789         */
790        public VisionPrescriptionDispenseComponent setAdd(BigDecimal value) { 
791          if (value == null)
792            this.add = null;
793          else {
794            if (this.add == null)
795              this.add = new DecimalType();
796            this.add.setValue(value);
797          }
798          return this;
799        }
800
801        /**
802         * @param value Power adjustment for multifocal lenses measured in diopters (0.25 units).
803         */
804        public VisionPrescriptionDispenseComponent setAdd(long value) { 
805              this.add = new DecimalType();
806            this.add.setValue(value);
807          return this;
808        }
809
810        /**
811         * @param value Power adjustment for multifocal lenses measured in diopters (0.25 units).
812         */
813        public VisionPrescriptionDispenseComponent setAdd(double value) { 
814              this.add = new DecimalType();
815            this.add.setValue(value);
816          return this;
817        }
818
819        /**
820         * @return {@link #power} (Contact lens power measured in diopters (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getPower" gives direct access to the value
821         */
822        public DecimalType getPowerElement() { 
823          if (this.power == null)
824            if (Configuration.errorOnAutoCreate())
825              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.power");
826            else if (Configuration.doAutoCreate())
827              this.power = new DecimalType(); // bb
828          return this.power;
829        }
830
831        public boolean hasPowerElement() { 
832          return this.power != null && !this.power.isEmpty();
833        }
834
835        public boolean hasPower() { 
836          return this.power != null && !this.power.isEmpty();
837        }
838
839        /**
840         * @param value {@link #power} (Contact lens power measured in diopters (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getPower" gives direct access to the value
841         */
842        public VisionPrescriptionDispenseComponent setPowerElement(DecimalType value) { 
843          this.power = value;
844          return this;
845        }
846
847        /**
848         * @return Contact lens power measured in diopters (0.25 units).
849         */
850        public BigDecimal getPower() { 
851          return this.power == null ? null : this.power.getValue();
852        }
853
854        /**
855         * @param value Contact lens power measured in diopters (0.25 units).
856         */
857        public VisionPrescriptionDispenseComponent setPower(BigDecimal value) { 
858          if (value == null)
859            this.power = null;
860          else {
861            if (this.power == null)
862              this.power = new DecimalType();
863            this.power.setValue(value);
864          }
865          return this;
866        }
867
868        /**
869         * @param value Contact lens power measured in diopters (0.25 units).
870         */
871        public VisionPrescriptionDispenseComponent setPower(long value) { 
872              this.power = new DecimalType();
873            this.power.setValue(value);
874          return this;
875        }
876
877        /**
878         * @param value Contact lens power measured in diopters (0.25 units).
879         */
880        public VisionPrescriptionDispenseComponent setPower(double value) { 
881              this.power = new DecimalType();
882            this.power.setValue(value);
883          return this;
884        }
885
886        /**
887         * @return {@link #backCurve} (Back curvature measured in millimeters.). This is the underlying object with id, value and extensions. The accessor "getBackCurve" gives direct access to the value
888         */
889        public DecimalType getBackCurveElement() { 
890          if (this.backCurve == null)
891            if (Configuration.errorOnAutoCreate())
892              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.backCurve");
893            else if (Configuration.doAutoCreate())
894              this.backCurve = new DecimalType(); // bb
895          return this.backCurve;
896        }
897
898        public boolean hasBackCurveElement() { 
899          return this.backCurve != null && !this.backCurve.isEmpty();
900        }
901
902        public boolean hasBackCurve() { 
903          return this.backCurve != null && !this.backCurve.isEmpty();
904        }
905
906        /**
907         * @param value {@link #backCurve} (Back curvature measured in millimeters.). This is the underlying object with id, value and extensions. The accessor "getBackCurve" gives direct access to the value
908         */
909        public VisionPrescriptionDispenseComponent setBackCurveElement(DecimalType value) { 
910          this.backCurve = value;
911          return this;
912        }
913
914        /**
915         * @return Back curvature measured in millimeters.
916         */
917        public BigDecimal getBackCurve() { 
918          return this.backCurve == null ? null : this.backCurve.getValue();
919        }
920
921        /**
922         * @param value Back curvature measured in millimeters.
923         */
924        public VisionPrescriptionDispenseComponent setBackCurve(BigDecimal value) { 
925          if (value == null)
926            this.backCurve = null;
927          else {
928            if (this.backCurve == null)
929              this.backCurve = new DecimalType();
930            this.backCurve.setValue(value);
931          }
932          return this;
933        }
934
935        /**
936         * @param value Back curvature measured in millimeters.
937         */
938        public VisionPrescriptionDispenseComponent setBackCurve(long value) { 
939              this.backCurve = new DecimalType();
940            this.backCurve.setValue(value);
941          return this;
942        }
943
944        /**
945         * @param value Back curvature measured in millimeters.
946         */
947        public VisionPrescriptionDispenseComponent setBackCurve(double value) { 
948              this.backCurve = new DecimalType();
949            this.backCurve.setValue(value);
950          return this;
951        }
952
953        /**
954         * @return {@link #diameter} (Contact lens diameter measured in millimeters.). This is the underlying object with id, value and extensions. The accessor "getDiameter" gives direct access to the value
955         */
956        public DecimalType getDiameterElement() { 
957          if (this.diameter == null)
958            if (Configuration.errorOnAutoCreate())
959              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.diameter");
960            else if (Configuration.doAutoCreate())
961              this.diameter = new DecimalType(); // bb
962          return this.diameter;
963        }
964
965        public boolean hasDiameterElement() { 
966          return this.diameter != null && !this.diameter.isEmpty();
967        }
968
969        public boolean hasDiameter() { 
970          return this.diameter != null && !this.diameter.isEmpty();
971        }
972
973        /**
974         * @param value {@link #diameter} (Contact lens diameter measured in millimeters.). This is the underlying object with id, value and extensions. The accessor "getDiameter" gives direct access to the value
975         */
976        public VisionPrescriptionDispenseComponent setDiameterElement(DecimalType value) { 
977          this.diameter = value;
978          return this;
979        }
980
981        /**
982         * @return Contact lens diameter measured in millimeters.
983         */
984        public BigDecimal getDiameter() { 
985          return this.diameter == null ? null : this.diameter.getValue();
986        }
987
988        /**
989         * @param value Contact lens diameter measured in millimeters.
990         */
991        public VisionPrescriptionDispenseComponent setDiameter(BigDecimal value) { 
992          if (value == null)
993            this.diameter = null;
994          else {
995            if (this.diameter == null)
996              this.diameter = new DecimalType();
997            this.diameter.setValue(value);
998          }
999          return this;
1000        }
1001
1002        /**
1003         * @param value Contact lens diameter measured in millimeters.
1004         */
1005        public VisionPrescriptionDispenseComponent setDiameter(long value) { 
1006              this.diameter = new DecimalType();
1007            this.diameter.setValue(value);
1008          return this;
1009        }
1010
1011        /**
1012         * @param value Contact lens diameter measured in millimeters.
1013         */
1014        public VisionPrescriptionDispenseComponent setDiameter(double value) { 
1015              this.diameter = new DecimalType();
1016            this.diameter.setValue(value);
1017          return this;
1018        }
1019
1020        /**
1021         * @return {@link #duration} (The recommended maximum wear period for the lens.)
1022         */
1023        public SimpleQuantity getDuration() { 
1024          if (this.duration == null)
1025            if (Configuration.errorOnAutoCreate())
1026              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.duration");
1027            else if (Configuration.doAutoCreate())
1028              this.duration = new SimpleQuantity(); // cc
1029          return this.duration;
1030        }
1031
1032        public boolean hasDuration() { 
1033          return this.duration != null && !this.duration.isEmpty();
1034        }
1035
1036        /**
1037         * @param value {@link #duration} (The recommended maximum wear period for the lens.)
1038         */
1039        public VisionPrescriptionDispenseComponent setDuration(SimpleQuantity value) { 
1040          this.duration = value;
1041          return this;
1042        }
1043
1044        /**
1045         * @return {@link #color} (Special color or pattern.). This is the underlying object with id, value and extensions. The accessor "getColor" gives direct access to the value
1046         */
1047        public StringType getColorElement() { 
1048          if (this.color == null)
1049            if (Configuration.errorOnAutoCreate())
1050              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.color");
1051            else if (Configuration.doAutoCreate())
1052              this.color = new StringType(); // bb
1053          return this.color;
1054        }
1055
1056        public boolean hasColorElement() { 
1057          return this.color != null && !this.color.isEmpty();
1058        }
1059
1060        public boolean hasColor() { 
1061          return this.color != null && !this.color.isEmpty();
1062        }
1063
1064        /**
1065         * @param value {@link #color} (Special color or pattern.). This is the underlying object with id, value and extensions. The accessor "getColor" gives direct access to the value
1066         */
1067        public VisionPrescriptionDispenseComponent setColorElement(StringType value) { 
1068          this.color = value;
1069          return this;
1070        }
1071
1072        /**
1073         * @return Special color or pattern.
1074         */
1075        public String getColor() { 
1076          return this.color == null ? null : this.color.getValue();
1077        }
1078
1079        /**
1080         * @param value Special color or pattern.
1081         */
1082        public VisionPrescriptionDispenseComponent setColor(String value) { 
1083          if (Utilities.noString(value))
1084            this.color = null;
1085          else {
1086            if (this.color == null)
1087              this.color = new StringType();
1088            this.color.setValue(value);
1089          }
1090          return this;
1091        }
1092
1093        /**
1094         * @return {@link #brand} (Brand recommendations or restrictions.). This is the underlying object with id, value and extensions. The accessor "getBrand" gives direct access to the value
1095         */
1096        public StringType getBrandElement() { 
1097          if (this.brand == null)
1098            if (Configuration.errorOnAutoCreate())
1099              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.brand");
1100            else if (Configuration.doAutoCreate())
1101              this.brand = new StringType(); // bb
1102          return this.brand;
1103        }
1104
1105        public boolean hasBrandElement() { 
1106          return this.brand != null && !this.brand.isEmpty();
1107        }
1108
1109        public boolean hasBrand() { 
1110          return this.brand != null && !this.brand.isEmpty();
1111        }
1112
1113        /**
1114         * @param value {@link #brand} (Brand recommendations or restrictions.). This is the underlying object with id, value and extensions. The accessor "getBrand" gives direct access to the value
1115         */
1116        public VisionPrescriptionDispenseComponent setBrandElement(StringType value) { 
1117          this.brand = value;
1118          return this;
1119        }
1120
1121        /**
1122         * @return Brand recommendations or restrictions.
1123         */
1124        public String getBrand() { 
1125          return this.brand == null ? null : this.brand.getValue();
1126        }
1127
1128        /**
1129         * @param value Brand recommendations or restrictions.
1130         */
1131        public VisionPrescriptionDispenseComponent setBrand(String value) { 
1132          if (Utilities.noString(value))
1133            this.brand = null;
1134          else {
1135            if (this.brand == null)
1136              this.brand = new StringType();
1137            this.brand.setValue(value);
1138          }
1139          return this;
1140        }
1141
1142        /**
1143         * @return {@link #notes} (Notes for special requirements such as coatings and lens materials.). This is the underlying object with id, value and extensions. The accessor "getNotes" gives direct access to the value
1144         */
1145        public StringType getNotesElement() { 
1146          if (this.notes == null)
1147            if (Configuration.errorOnAutoCreate())
1148              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.notes");
1149            else if (Configuration.doAutoCreate())
1150              this.notes = new StringType(); // bb
1151          return this.notes;
1152        }
1153
1154        public boolean hasNotesElement() { 
1155          return this.notes != null && !this.notes.isEmpty();
1156        }
1157
1158        public boolean hasNotes() { 
1159          return this.notes != null && !this.notes.isEmpty();
1160        }
1161
1162        /**
1163         * @param value {@link #notes} (Notes for special requirements such as coatings and lens materials.). This is the underlying object with id, value and extensions. The accessor "getNotes" gives direct access to the value
1164         */
1165        public VisionPrescriptionDispenseComponent setNotesElement(StringType value) { 
1166          this.notes = value;
1167          return this;
1168        }
1169
1170        /**
1171         * @return Notes for special requirements such as coatings and lens materials.
1172         */
1173        public String getNotes() { 
1174          return this.notes == null ? null : this.notes.getValue();
1175        }
1176
1177        /**
1178         * @param value Notes for special requirements such as coatings and lens materials.
1179         */
1180        public VisionPrescriptionDispenseComponent setNotes(String value) { 
1181          if (Utilities.noString(value))
1182            this.notes = null;
1183          else {
1184            if (this.notes == null)
1185              this.notes = new StringType();
1186            this.notes.setValue(value);
1187          }
1188          return this;
1189        }
1190
1191        protected void listChildren(List<Property> childrenList) {
1192          super.listChildren(childrenList);
1193          childrenList.add(new Property("product", "Coding", "Identifies the type of vision correction product which is required for the patient.", 0, java.lang.Integer.MAX_VALUE, product));
1194          childrenList.add(new Property("eye", "code", "The eye for which the lens applies.", 0, java.lang.Integer.MAX_VALUE, eye));
1195          childrenList.add(new Property("sphere", "decimal", "Lens power measured in diopters (0.25 units).", 0, java.lang.Integer.MAX_VALUE, sphere));
1196          childrenList.add(new Property("cylinder", "decimal", "Power adjustment for astigmatism measured in diopters (0.25 units).", 0, java.lang.Integer.MAX_VALUE, cylinder));
1197          childrenList.add(new Property("axis", "integer", "Adjustment for astigmatism measured in integer degrees.", 0, java.lang.Integer.MAX_VALUE, axis));
1198          childrenList.add(new Property("prism", "decimal", "Amount of prism to compensate for eye alignment in fractional units.", 0, java.lang.Integer.MAX_VALUE, prism));
1199          childrenList.add(new Property("base", "code", "The relative base, or reference lens edge, for the prism.", 0, java.lang.Integer.MAX_VALUE, base));
1200          childrenList.add(new Property("add", "decimal", "Power adjustment for multifocal lenses measured in diopters (0.25 units).", 0, java.lang.Integer.MAX_VALUE, add));
1201          childrenList.add(new Property("power", "decimal", "Contact lens power measured in diopters (0.25 units).", 0, java.lang.Integer.MAX_VALUE, power));
1202          childrenList.add(new Property("backCurve", "decimal", "Back curvature measured in millimeters.", 0, java.lang.Integer.MAX_VALUE, backCurve));
1203          childrenList.add(new Property("diameter", "decimal", "Contact lens diameter measured in millimeters.", 0, java.lang.Integer.MAX_VALUE, diameter));
1204          childrenList.add(new Property("duration", "SimpleQuantity", "The recommended maximum wear period for the lens.", 0, java.lang.Integer.MAX_VALUE, duration));
1205          childrenList.add(new Property("color", "string", "Special color or pattern.", 0, java.lang.Integer.MAX_VALUE, color));
1206          childrenList.add(new Property("brand", "string", "Brand recommendations or restrictions.", 0, java.lang.Integer.MAX_VALUE, brand));
1207          childrenList.add(new Property("notes", "string", "Notes for special requirements such as coatings and lens materials.", 0, java.lang.Integer.MAX_VALUE, notes));
1208        }
1209
1210      @Override
1211      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1212        switch (hash) {
1213        case -309474065: /*product*/ return this.product == null ? new Base[0] : new Base[] {this.product}; // Coding
1214        case 100913: /*eye*/ return this.eye == null ? new Base[0] : new Base[] {this.eye}; // Enumeration<VisionEyes>
1215        case -895981619: /*sphere*/ return this.sphere == null ? new Base[0] : new Base[] {this.sphere}; // DecimalType
1216        case -349378602: /*cylinder*/ return this.cylinder == null ? new Base[0] : new Base[] {this.cylinder}; // DecimalType
1217        case 3008417: /*axis*/ return this.axis == null ? new Base[0] : new Base[] {this.axis}; // IntegerType
1218        case 106935105: /*prism*/ return this.prism == null ? new Base[0] : new Base[] {this.prism}; // DecimalType
1219        case 3016401: /*base*/ return this.base == null ? new Base[0] : new Base[] {this.base}; // Enumeration<VisionBase>
1220        case 96417: /*add*/ return this.add == null ? new Base[0] : new Base[] {this.add}; // DecimalType
1221        case 106858757: /*power*/ return this.power == null ? new Base[0] : new Base[] {this.power}; // DecimalType
1222        case 1309344840: /*backCurve*/ return this.backCurve == null ? new Base[0] : new Base[] {this.backCurve}; // DecimalType
1223        case -233204595: /*diameter*/ return this.diameter == null ? new Base[0] : new Base[] {this.diameter}; // DecimalType
1224        case -1992012396: /*duration*/ return this.duration == null ? new Base[0] : new Base[] {this.duration}; // SimpleQuantity
1225        case 94842723: /*color*/ return this.color == null ? new Base[0] : new Base[] {this.color}; // StringType
1226        case 93997959: /*brand*/ return this.brand == null ? new Base[0] : new Base[] {this.brand}; // StringType
1227        case 105008833: /*notes*/ return this.notes == null ? new Base[0] : new Base[] {this.notes}; // StringType
1228        default: return super.getProperty(hash, name, checkValid);
1229        }
1230
1231      }
1232
1233      @Override
1234      public void setProperty(int hash, String name, Base value) throws FHIRException {
1235        switch (hash) {
1236        case -309474065: // product
1237          this.product = castToCoding(value); // Coding
1238          break;
1239        case 100913: // eye
1240          this.eye = new VisionEyesEnumFactory().fromType(value); // Enumeration<VisionEyes>
1241          break;
1242        case -895981619: // sphere
1243          this.sphere = castToDecimal(value); // DecimalType
1244          break;
1245        case -349378602: // cylinder
1246          this.cylinder = castToDecimal(value); // DecimalType
1247          break;
1248        case 3008417: // axis
1249          this.axis = castToInteger(value); // IntegerType
1250          break;
1251        case 106935105: // prism
1252          this.prism = castToDecimal(value); // DecimalType
1253          break;
1254        case 3016401: // base
1255          this.base = new VisionBaseEnumFactory().fromType(value); // Enumeration<VisionBase>
1256          break;
1257        case 96417: // add
1258          this.add = castToDecimal(value); // DecimalType
1259          break;
1260        case 106858757: // power
1261          this.power = castToDecimal(value); // DecimalType
1262          break;
1263        case 1309344840: // backCurve
1264          this.backCurve = castToDecimal(value); // DecimalType
1265          break;
1266        case -233204595: // diameter
1267          this.diameter = castToDecimal(value); // DecimalType
1268          break;
1269        case -1992012396: // duration
1270          this.duration = castToSimpleQuantity(value); // SimpleQuantity
1271          break;
1272        case 94842723: // color
1273          this.color = castToString(value); // StringType
1274          break;
1275        case 93997959: // brand
1276          this.brand = castToString(value); // StringType
1277          break;
1278        case 105008833: // notes
1279          this.notes = castToString(value); // StringType
1280          break;
1281        default: super.setProperty(hash, name, value);
1282        }
1283
1284      }
1285
1286      @Override
1287      public void setProperty(String name, Base value) throws FHIRException {
1288        if (name.equals("product"))
1289          this.product = castToCoding(value); // Coding
1290        else if (name.equals("eye"))
1291          this.eye = new VisionEyesEnumFactory().fromType(value); // Enumeration<VisionEyes>
1292        else if (name.equals("sphere"))
1293          this.sphere = castToDecimal(value); // DecimalType
1294        else if (name.equals("cylinder"))
1295          this.cylinder = castToDecimal(value); // DecimalType
1296        else if (name.equals("axis"))
1297          this.axis = castToInteger(value); // IntegerType
1298        else if (name.equals("prism"))
1299          this.prism = castToDecimal(value); // DecimalType
1300        else if (name.equals("base"))
1301          this.base = new VisionBaseEnumFactory().fromType(value); // Enumeration<VisionBase>
1302        else if (name.equals("add"))
1303          this.add = castToDecimal(value); // DecimalType
1304        else if (name.equals("power"))
1305          this.power = castToDecimal(value); // DecimalType
1306        else if (name.equals("backCurve"))
1307          this.backCurve = castToDecimal(value); // DecimalType
1308        else if (name.equals("diameter"))
1309          this.diameter = castToDecimal(value); // DecimalType
1310        else if (name.equals("duration"))
1311          this.duration = castToSimpleQuantity(value); // SimpleQuantity
1312        else if (name.equals("color"))
1313          this.color = castToString(value); // StringType
1314        else if (name.equals("brand"))
1315          this.brand = castToString(value); // StringType
1316        else if (name.equals("notes"))
1317          this.notes = castToString(value); // StringType
1318        else
1319          super.setProperty(name, value);
1320      }
1321
1322      @Override
1323      public Base makeProperty(int hash, String name) throws FHIRException {
1324        switch (hash) {
1325        case -309474065:  return getProduct(); // Coding
1326        case 100913: throw new FHIRException("Cannot make property eye as it is not a complex type"); // Enumeration<VisionEyes>
1327        case -895981619: throw new FHIRException("Cannot make property sphere as it is not a complex type"); // DecimalType
1328        case -349378602: throw new FHIRException("Cannot make property cylinder as it is not a complex type"); // DecimalType
1329        case 3008417: throw new FHIRException("Cannot make property axis as it is not a complex type"); // IntegerType
1330        case 106935105: throw new FHIRException("Cannot make property prism as it is not a complex type"); // DecimalType
1331        case 3016401: throw new FHIRException("Cannot make property base as it is not a complex type"); // Enumeration<VisionBase>
1332        case 96417: throw new FHIRException("Cannot make property add as it is not a complex type"); // DecimalType
1333        case 106858757: throw new FHIRException("Cannot make property power as it is not a complex type"); // DecimalType
1334        case 1309344840: throw new FHIRException("Cannot make property backCurve as it is not a complex type"); // DecimalType
1335        case -233204595: throw new FHIRException("Cannot make property diameter as it is not a complex type"); // DecimalType
1336        case -1992012396:  return getDuration(); // SimpleQuantity
1337        case 94842723: throw new FHIRException("Cannot make property color as it is not a complex type"); // StringType
1338        case 93997959: throw new FHIRException("Cannot make property brand as it is not a complex type"); // StringType
1339        case 105008833: throw new FHIRException("Cannot make property notes as it is not a complex type"); // StringType
1340        default: return super.makeProperty(hash, name);
1341        }
1342
1343      }
1344
1345      @Override
1346      public Base addChild(String name) throws FHIRException {
1347        if (name.equals("product")) {
1348          this.product = new Coding();
1349          return this.product;
1350        }
1351        else if (name.equals("eye")) {
1352          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.eye");
1353        }
1354        else if (name.equals("sphere")) {
1355          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.sphere");
1356        }
1357        else if (name.equals("cylinder")) {
1358          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.cylinder");
1359        }
1360        else if (name.equals("axis")) {
1361          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.axis");
1362        }
1363        else if (name.equals("prism")) {
1364          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.prism");
1365        }
1366        else if (name.equals("base")) {
1367          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.base");
1368        }
1369        else if (name.equals("add")) {
1370          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.add");
1371        }
1372        else if (name.equals("power")) {
1373          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.power");
1374        }
1375        else if (name.equals("backCurve")) {
1376          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.backCurve");
1377        }
1378        else if (name.equals("diameter")) {
1379          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.diameter");
1380        }
1381        else if (name.equals("duration")) {
1382          this.duration = new SimpleQuantity();
1383          return this.duration;
1384        }
1385        else if (name.equals("color")) {
1386          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.color");
1387        }
1388        else if (name.equals("brand")) {
1389          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.brand");
1390        }
1391        else if (name.equals("notes")) {
1392          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.notes");
1393        }
1394        else
1395          return super.addChild(name);
1396      }
1397
1398      public VisionPrescriptionDispenseComponent copy() {
1399        VisionPrescriptionDispenseComponent dst = new VisionPrescriptionDispenseComponent();
1400        copyValues(dst);
1401        dst.product = product == null ? null : product.copy();
1402        dst.eye = eye == null ? null : eye.copy();
1403        dst.sphere = sphere == null ? null : sphere.copy();
1404        dst.cylinder = cylinder == null ? null : cylinder.copy();
1405        dst.axis = axis == null ? null : axis.copy();
1406        dst.prism = prism == null ? null : prism.copy();
1407        dst.base = base == null ? null : base.copy();
1408        dst.add = add == null ? null : add.copy();
1409        dst.power = power == null ? null : power.copy();
1410        dst.backCurve = backCurve == null ? null : backCurve.copy();
1411        dst.diameter = diameter == null ? null : diameter.copy();
1412        dst.duration = duration == null ? null : duration.copy();
1413        dst.color = color == null ? null : color.copy();
1414        dst.brand = brand == null ? null : brand.copy();
1415        dst.notes = notes == null ? null : notes.copy();
1416        return dst;
1417      }
1418
1419      @Override
1420      public boolean equalsDeep(Base other) {
1421        if (!super.equalsDeep(other))
1422          return false;
1423        if (!(other instanceof VisionPrescriptionDispenseComponent))
1424          return false;
1425        VisionPrescriptionDispenseComponent o = (VisionPrescriptionDispenseComponent) other;
1426        return compareDeep(product, o.product, true) && compareDeep(eye, o.eye, true) && compareDeep(sphere, o.sphere, true)
1427           && compareDeep(cylinder, o.cylinder, true) && compareDeep(axis, o.axis, true) && compareDeep(prism, o.prism, true)
1428           && compareDeep(base, o.base, true) && compareDeep(add, o.add, true) && compareDeep(power, o.power, true)
1429           && compareDeep(backCurve, o.backCurve, true) && compareDeep(diameter, o.diameter, true) && compareDeep(duration, o.duration, true)
1430           && compareDeep(color, o.color, true) && compareDeep(brand, o.brand, true) && compareDeep(notes, o.notes, true)
1431          ;
1432      }
1433
1434      @Override
1435      public boolean equalsShallow(Base other) {
1436        if (!super.equalsShallow(other))
1437          return false;
1438        if (!(other instanceof VisionPrescriptionDispenseComponent))
1439          return false;
1440        VisionPrescriptionDispenseComponent o = (VisionPrescriptionDispenseComponent) other;
1441        return compareValues(eye, o.eye, true) && compareValues(sphere, o.sphere, true) && compareValues(cylinder, o.cylinder, true)
1442           && compareValues(axis, o.axis, true) && compareValues(prism, o.prism, true) && compareValues(base, o.base, true)
1443           && compareValues(add, o.add, true) && compareValues(power, o.power, true) && compareValues(backCurve, o.backCurve, true)
1444           && compareValues(diameter, o.diameter, true) && compareValues(color, o.color, true) && compareValues(brand, o.brand, true)
1445           && compareValues(notes, o.notes, true);
1446      }
1447
1448      public boolean isEmpty() {
1449        return super.isEmpty() && (product == null || product.isEmpty()) && (eye == null || eye.isEmpty())
1450           && (sphere == null || sphere.isEmpty()) && (cylinder == null || cylinder.isEmpty()) && (axis == null || axis.isEmpty())
1451           && (prism == null || prism.isEmpty()) && (base == null || base.isEmpty()) && (add == null || add.isEmpty())
1452           && (power == null || power.isEmpty()) && (backCurve == null || backCurve.isEmpty()) && (diameter == null || diameter.isEmpty())
1453           && (duration == null || duration.isEmpty()) && (color == null || color.isEmpty()) && (brand == null || brand.isEmpty())
1454           && (notes == null || notes.isEmpty());
1455      }
1456
1457  public String fhirType() {
1458    return "VisionPrescription.dispense";
1459
1460  }
1461
1462  }
1463
1464    /**
1465     * Business identifier which may be used by other parties to reference or identify the prescription.
1466     */
1467    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1468    @Description(shortDefinition="Business identifier", formalDefinition="Business identifier which may be used by other parties to reference or identify the prescription." )
1469    protected List<Identifier> identifier;
1470
1471    /**
1472     * The date (and perhaps time) when the prescription was written.
1473     */
1474    @Child(name = "dateWritten", type = {DateTimeType.class}, order=1, min=0, max=1, modifier=false, summary=true)
1475    @Description(shortDefinition="When prescription was authorized", formalDefinition="The date (and perhaps time) when the prescription was written." )
1476    protected DateTimeType dateWritten;
1477
1478    /**
1479     * A link to a resource representing the person to whom the vision products will be supplied.
1480     */
1481    @Child(name = "patient", type = {Patient.class}, order=2, min=0, max=1, modifier=false, summary=true)
1482    @Description(shortDefinition="Who prescription is for", formalDefinition="A link to a resource representing the person to whom the vision products will be supplied." )
1483    protected Reference patient;
1484
1485    /**
1486     * The actual object that is the target of the reference (A link to a resource representing the person to whom the vision products will be supplied.)
1487     */
1488    protected Patient patientTarget;
1489
1490    /**
1491     * The healthcare professional responsible for authorizing the prescription.
1492     */
1493    @Child(name = "prescriber", type = {Practitioner.class}, order=3, min=0, max=1, modifier=false, summary=true)
1494    @Description(shortDefinition="Who authorizes the vision product", formalDefinition="The healthcare professional responsible for authorizing the prescription." )
1495    protected Reference prescriber;
1496
1497    /**
1498     * The actual object that is the target of the reference (The healthcare professional responsible for authorizing the prescription.)
1499     */
1500    protected Practitioner prescriberTarget;
1501
1502    /**
1503     * A link to a resource that identifies the particular occurrence of contact between patient and health care provider.
1504     */
1505    @Child(name = "encounter", type = {Encounter.class}, order=4, min=0, max=1, modifier=false, summary=true)
1506    @Description(shortDefinition="Created during encounter / admission / stay", formalDefinition="A link to a resource that identifies the particular occurrence of contact between patient and health care provider." )
1507    protected Reference encounter;
1508
1509    /**
1510     * The actual object that is the target of the reference (A link to a resource that identifies the particular occurrence of contact between patient and health care provider.)
1511     */
1512    protected Encounter encounterTarget;
1513
1514    /**
1515     * Can be the reason or the indication for writing the prescription.
1516     */
1517    @Child(name = "reason", type = {CodeableConcept.class, Condition.class}, order=5, min=0, max=1, modifier=false, summary=true)
1518    @Description(shortDefinition="Reason or indication for writing the prescription", formalDefinition="Can be the reason or the indication for writing the prescription." )
1519    protected Type reason;
1520
1521    /**
1522     * Deals with details of the dispense part of the supply specification.
1523     */
1524    @Child(name = "dispense", type = {}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1525    @Description(shortDefinition="Vision supply authorization", formalDefinition="Deals with details of the dispense part of the supply specification." )
1526    protected List<VisionPrescriptionDispenseComponent> dispense;
1527
1528    private static final long serialVersionUID = -1108276057L;
1529
1530  /**
1531   * Constructor
1532   */
1533    public VisionPrescription() {
1534      super();
1535    }
1536
1537    /**
1538     * @return {@link #identifier} (Business identifier which may be used by other parties to reference or identify the prescription.)
1539     */
1540    public List<Identifier> getIdentifier() { 
1541      if (this.identifier == null)
1542        this.identifier = new ArrayList<Identifier>();
1543      return this.identifier;
1544    }
1545
1546    public boolean hasIdentifier() { 
1547      if (this.identifier == null)
1548        return false;
1549      for (Identifier item : this.identifier)
1550        if (!item.isEmpty())
1551          return true;
1552      return false;
1553    }
1554
1555    /**
1556     * @return {@link #identifier} (Business identifier which may be used by other parties to reference or identify the prescription.)
1557     */
1558    // syntactic sugar
1559    public Identifier addIdentifier() { //3
1560      Identifier t = new Identifier();
1561      if (this.identifier == null)
1562        this.identifier = new ArrayList<Identifier>();
1563      this.identifier.add(t);
1564      return t;
1565    }
1566
1567    // syntactic sugar
1568    public VisionPrescription addIdentifier(Identifier t) { //3
1569      if (t == null)
1570        return this;
1571      if (this.identifier == null)
1572        this.identifier = new ArrayList<Identifier>();
1573      this.identifier.add(t);
1574      return this;
1575    }
1576
1577    /**
1578     * @return {@link #dateWritten} (The date (and perhaps time) when the prescription was written.). This is the underlying object with id, value and extensions. The accessor "getDateWritten" gives direct access to the value
1579     */
1580    public DateTimeType getDateWrittenElement() { 
1581      if (this.dateWritten == null)
1582        if (Configuration.errorOnAutoCreate())
1583          throw new Error("Attempt to auto-create VisionPrescription.dateWritten");
1584        else if (Configuration.doAutoCreate())
1585          this.dateWritten = new DateTimeType(); // bb
1586      return this.dateWritten;
1587    }
1588
1589    public boolean hasDateWrittenElement() { 
1590      return this.dateWritten != null && !this.dateWritten.isEmpty();
1591    }
1592
1593    public boolean hasDateWritten() { 
1594      return this.dateWritten != null && !this.dateWritten.isEmpty();
1595    }
1596
1597    /**
1598     * @param value {@link #dateWritten} (The date (and perhaps time) when the prescription was written.). This is the underlying object with id, value and extensions. The accessor "getDateWritten" gives direct access to the value
1599     */
1600    public VisionPrescription setDateWrittenElement(DateTimeType value) { 
1601      this.dateWritten = value;
1602      return this;
1603    }
1604
1605    /**
1606     * @return The date (and perhaps time) when the prescription was written.
1607     */
1608    public Date getDateWritten() { 
1609      return this.dateWritten == null ? null : this.dateWritten.getValue();
1610    }
1611
1612    /**
1613     * @param value The date (and perhaps time) when the prescription was written.
1614     */
1615    public VisionPrescription setDateWritten(Date value) { 
1616      if (value == null)
1617        this.dateWritten = null;
1618      else {
1619        if (this.dateWritten == null)
1620          this.dateWritten = new DateTimeType();
1621        this.dateWritten.setValue(value);
1622      }
1623      return this;
1624    }
1625
1626    /**
1627     * @return {@link #patient} (A link to a resource representing the person to whom the vision products will be supplied.)
1628     */
1629    public Reference getPatient() { 
1630      if (this.patient == null)
1631        if (Configuration.errorOnAutoCreate())
1632          throw new Error("Attempt to auto-create VisionPrescription.patient");
1633        else if (Configuration.doAutoCreate())
1634          this.patient = new Reference(); // cc
1635      return this.patient;
1636    }
1637
1638    public boolean hasPatient() { 
1639      return this.patient != null && !this.patient.isEmpty();
1640    }
1641
1642    /**
1643     * @param value {@link #patient} (A link to a resource representing the person to whom the vision products will be supplied.)
1644     */
1645    public VisionPrescription setPatient(Reference value) { 
1646      this.patient = value;
1647      return this;
1648    }
1649
1650    /**
1651     * @return {@link #patient} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (A link to a resource representing the person to whom the vision products will be supplied.)
1652     */
1653    public Patient getPatientTarget() { 
1654      if (this.patientTarget == null)
1655        if (Configuration.errorOnAutoCreate())
1656          throw new Error("Attempt to auto-create VisionPrescription.patient");
1657        else if (Configuration.doAutoCreate())
1658          this.patientTarget = new Patient(); // aa
1659      return this.patientTarget;
1660    }
1661
1662    /**
1663     * @param value {@link #patient} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (A link to a resource representing the person to whom the vision products will be supplied.)
1664     */
1665    public VisionPrescription setPatientTarget(Patient value) { 
1666      this.patientTarget = value;
1667      return this;
1668    }
1669
1670    /**
1671     * @return {@link #prescriber} (The healthcare professional responsible for authorizing the prescription.)
1672     */
1673    public Reference getPrescriber() { 
1674      if (this.prescriber == null)
1675        if (Configuration.errorOnAutoCreate())
1676          throw new Error("Attempt to auto-create VisionPrescription.prescriber");
1677        else if (Configuration.doAutoCreate())
1678          this.prescriber = new Reference(); // cc
1679      return this.prescriber;
1680    }
1681
1682    public boolean hasPrescriber() { 
1683      return this.prescriber != null && !this.prescriber.isEmpty();
1684    }
1685
1686    /**
1687     * @param value {@link #prescriber} (The healthcare professional responsible for authorizing the prescription.)
1688     */
1689    public VisionPrescription setPrescriber(Reference value) { 
1690      this.prescriber = value;
1691      return this;
1692    }
1693
1694    /**
1695     * @return {@link #prescriber} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The healthcare professional responsible for authorizing the prescription.)
1696     */
1697    public Practitioner getPrescriberTarget() { 
1698      if (this.prescriberTarget == null)
1699        if (Configuration.errorOnAutoCreate())
1700          throw new Error("Attempt to auto-create VisionPrescription.prescriber");
1701        else if (Configuration.doAutoCreate())
1702          this.prescriberTarget = new Practitioner(); // aa
1703      return this.prescriberTarget;
1704    }
1705
1706    /**
1707     * @param value {@link #prescriber} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The healthcare professional responsible for authorizing the prescription.)
1708     */
1709    public VisionPrescription setPrescriberTarget(Practitioner value) { 
1710      this.prescriberTarget = value;
1711      return this;
1712    }
1713
1714    /**
1715     * @return {@link #encounter} (A link to a resource that identifies the particular occurrence of contact between patient and health care provider.)
1716     */
1717    public Reference getEncounter() { 
1718      if (this.encounter == null)
1719        if (Configuration.errorOnAutoCreate())
1720          throw new Error("Attempt to auto-create VisionPrescription.encounter");
1721        else if (Configuration.doAutoCreate())
1722          this.encounter = new Reference(); // cc
1723      return this.encounter;
1724    }
1725
1726    public boolean hasEncounter() { 
1727      return this.encounter != null && !this.encounter.isEmpty();
1728    }
1729
1730    /**
1731     * @param value {@link #encounter} (A link to a resource that identifies the particular occurrence of contact between patient and health care provider.)
1732     */
1733    public VisionPrescription setEncounter(Reference value) { 
1734      this.encounter = value;
1735      return this;
1736    }
1737
1738    /**
1739     * @return {@link #encounter} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (A link to a resource that identifies the particular occurrence of contact between patient and health care provider.)
1740     */
1741    public Encounter getEncounterTarget() { 
1742      if (this.encounterTarget == null)
1743        if (Configuration.errorOnAutoCreate())
1744          throw new Error("Attempt to auto-create VisionPrescription.encounter");
1745        else if (Configuration.doAutoCreate())
1746          this.encounterTarget = new Encounter(); // aa
1747      return this.encounterTarget;
1748    }
1749
1750    /**
1751     * @param value {@link #encounter} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (A link to a resource that identifies the particular occurrence of contact between patient and health care provider.)
1752     */
1753    public VisionPrescription setEncounterTarget(Encounter value) { 
1754      this.encounterTarget = value;
1755      return this;
1756    }
1757
1758    /**
1759     * @return {@link #reason} (Can be the reason or the indication for writing the prescription.)
1760     */
1761    public Type getReason() { 
1762      return this.reason;
1763    }
1764
1765    /**
1766     * @return {@link #reason} (Can be the reason or the indication for writing the prescription.)
1767     */
1768    public CodeableConcept getReasonCodeableConcept() throws FHIRException { 
1769      if (!(this.reason instanceof CodeableConcept))
1770        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.reason.getClass().getName()+" was encountered");
1771      return (CodeableConcept) this.reason;
1772    }
1773
1774    public boolean hasReasonCodeableConcept() { 
1775      return this.reason instanceof CodeableConcept;
1776    }
1777
1778    /**
1779     * @return {@link #reason} (Can be the reason or the indication for writing the prescription.)
1780     */
1781    public Reference getReasonReference() throws FHIRException { 
1782      if (!(this.reason instanceof Reference))
1783        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.reason.getClass().getName()+" was encountered");
1784      return (Reference) this.reason;
1785    }
1786
1787    public boolean hasReasonReference() { 
1788      return this.reason instanceof Reference;
1789    }
1790
1791    public boolean hasReason() { 
1792      return this.reason != null && !this.reason.isEmpty();
1793    }
1794
1795    /**
1796     * @param value {@link #reason} (Can be the reason or the indication for writing the prescription.)
1797     */
1798    public VisionPrescription setReason(Type value) { 
1799      this.reason = value;
1800      return this;
1801    }
1802
1803    /**
1804     * @return {@link #dispense} (Deals with details of the dispense part of the supply specification.)
1805     */
1806    public List<VisionPrescriptionDispenseComponent> getDispense() { 
1807      if (this.dispense == null)
1808        this.dispense = new ArrayList<VisionPrescriptionDispenseComponent>();
1809      return this.dispense;
1810    }
1811
1812    public boolean hasDispense() { 
1813      if (this.dispense == null)
1814        return false;
1815      for (VisionPrescriptionDispenseComponent item : this.dispense)
1816        if (!item.isEmpty())
1817          return true;
1818      return false;
1819    }
1820
1821    /**
1822     * @return {@link #dispense} (Deals with details of the dispense part of the supply specification.)
1823     */
1824    // syntactic sugar
1825    public VisionPrescriptionDispenseComponent addDispense() { //3
1826      VisionPrescriptionDispenseComponent t = new VisionPrescriptionDispenseComponent();
1827      if (this.dispense == null)
1828        this.dispense = new ArrayList<VisionPrescriptionDispenseComponent>();
1829      this.dispense.add(t);
1830      return t;
1831    }
1832
1833    // syntactic sugar
1834    public VisionPrescription addDispense(VisionPrescriptionDispenseComponent t) { //3
1835      if (t == null)
1836        return this;
1837      if (this.dispense == null)
1838        this.dispense = new ArrayList<VisionPrescriptionDispenseComponent>();
1839      this.dispense.add(t);
1840      return this;
1841    }
1842
1843      protected void listChildren(List<Property> childrenList) {
1844        super.listChildren(childrenList);
1845        childrenList.add(new Property("identifier", "Identifier", "Business identifier which may be used by other parties to reference or identify the prescription.", 0, java.lang.Integer.MAX_VALUE, identifier));
1846        childrenList.add(new Property("dateWritten", "dateTime", "The date (and perhaps time) when the prescription was written.", 0, java.lang.Integer.MAX_VALUE, dateWritten));
1847        childrenList.add(new Property("patient", "Reference(Patient)", "A link to a resource representing the person to whom the vision products will be supplied.", 0, java.lang.Integer.MAX_VALUE, patient));
1848        childrenList.add(new Property("prescriber", "Reference(Practitioner)", "The healthcare professional responsible for authorizing the prescription.", 0, java.lang.Integer.MAX_VALUE, prescriber));
1849        childrenList.add(new Property("encounter", "Reference(Encounter)", "A link to a resource that identifies the particular occurrence of contact between patient and health care provider.", 0, java.lang.Integer.MAX_VALUE, encounter));
1850        childrenList.add(new Property("reason[x]", "CodeableConcept|Reference(Condition)", "Can be the reason or the indication for writing the prescription.", 0, java.lang.Integer.MAX_VALUE, reason));
1851        childrenList.add(new Property("dispense", "", "Deals with details of the dispense part of the supply specification.", 0, java.lang.Integer.MAX_VALUE, dispense));
1852      }
1853
1854      @Override
1855      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1856        switch (hash) {
1857        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1858        case -1496880759: /*dateWritten*/ return this.dateWritten == null ? new Base[0] : new Base[] {this.dateWritten}; // DateTimeType
1859        case -791418107: /*patient*/ return this.patient == null ? new Base[0] : new Base[] {this.patient}; // Reference
1860        case 1430631077: /*prescriber*/ return this.prescriber == null ? new Base[0] : new Base[] {this.prescriber}; // Reference
1861        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : new Base[] {this.encounter}; // Reference
1862        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : new Base[] {this.reason}; // Type
1863        case 284885341: /*dispense*/ return this.dispense == null ? new Base[0] : this.dispense.toArray(new Base[this.dispense.size()]); // VisionPrescriptionDispenseComponent
1864        default: return super.getProperty(hash, name, checkValid);
1865        }
1866
1867      }
1868
1869      @Override
1870      public void setProperty(int hash, String name, Base value) throws FHIRException {
1871        switch (hash) {
1872        case -1618432855: // identifier
1873          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1874          break;
1875        case -1496880759: // dateWritten
1876          this.dateWritten = castToDateTime(value); // DateTimeType
1877          break;
1878        case -791418107: // patient
1879          this.patient = castToReference(value); // Reference
1880          break;
1881        case 1430631077: // prescriber
1882          this.prescriber = castToReference(value); // Reference
1883          break;
1884        case 1524132147: // encounter
1885          this.encounter = castToReference(value); // Reference
1886          break;
1887        case -934964668: // reason
1888          this.reason = (Type) value; // Type
1889          break;
1890        case 284885341: // dispense
1891          this.getDispense().add((VisionPrescriptionDispenseComponent) value); // VisionPrescriptionDispenseComponent
1892          break;
1893        default: super.setProperty(hash, name, value);
1894        }
1895
1896      }
1897
1898      @Override
1899      public void setProperty(String name, Base value) throws FHIRException {
1900        if (name.equals("identifier"))
1901          this.getIdentifier().add(castToIdentifier(value));
1902        else if (name.equals("dateWritten"))
1903          this.dateWritten = castToDateTime(value); // DateTimeType
1904        else if (name.equals("patient"))
1905          this.patient = castToReference(value); // Reference
1906        else if (name.equals("prescriber"))
1907          this.prescriber = castToReference(value); // Reference
1908        else if (name.equals("encounter"))
1909          this.encounter = castToReference(value); // Reference
1910        else if (name.equals("reason[x]"))
1911          this.reason = (Type) value; // Type
1912        else if (name.equals("dispense"))
1913          this.getDispense().add((VisionPrescriptionDispenseComponent) value);
1914        else
1915          super.setProperty(name, value);
1916      }
1917
1918      @Override
1919      public Base makeProperty(int hash, String name) throws FHIRException {
1920        switch (hash) {
1921        case -1618432855:  return addIdentifier(); // Identifier
1922        case -1496880759: throw new FHIRException("Cannot make property dateWritten as it is not a complex type"); // DateTimeType
1923        case -791418107:  return getPatient(); // Reference
1924        case 1430631077:  return getPrescriber(); // Reference
1925        case 1524132147:  return getEncounter(); // Reference
1926        case -669418564:  return getReason(); // Type
1927        case 284885341:  return addDispense(); // VisionPrescriptionDispenseComponent
1928        default: return super.makeProperty(hash, name);
1929        }
1930
1931      }
1932
1933      @Override
1934      public Base addChild(String name) throws FHIRException {
1935        if (name.equals("identifier")) {
1936          return addIdentifier();
1937        }
1938        else if (name.equals("dateWritten")) {
1939          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.dateWritten");
1940        }
1941        else if (name.equals("patient")) {
1942          this.patient = new Reference();
1943          return this.patient;
1944        }
1945        else if (name.equals("prescriber")) {
1946          this.prescriber = new Reference();
1947          return this.prescriber;
1948        }
1949        else if (name.equals("encounter")) {
1950          this.encounter = new Reference();
1951          return this.encounter;
1952        }
1953        else if (name.equals("reasonCodeableConcept")) {
1954          this.reason = new CodeableConcept();
1955          return this.reason;
1956        }
1957        else if (name.equals("reasonReference")) {
1958          this.reason = new Reference();
1959          return this.reason;
1960        }
1961        else if (name.equals("dispense")) {
1962          return addDispense();
1963        }
1964        else
1965          return super.addChild(name);
1966      }
1967
1968  public String fhirType() {
1969    return "VisionPrescription";
1970
1971  }
1972
1973      public VisionPrescription copy() {
1974        VisionPrescription dst = new VisionPrescription();
1975        copyValues(dst);
1976        if (identifier != null) {
1977          dst.identifier = new ArrayList<Identifier>();
1978          for (Identifier i : identifier)
1979            dst.identifier.add(i.copy());
1980        };
1981        dst.dateWritten = dateWritten == null ? null : dateWritten.copy();
1982        dst.patient = patient == null ? null : patient.copy();
1983        dst.prescriber = prescriber == null ? null : prescriber.copy();
1984        dst.encounter = encounter == null ? null : encounter.copy();
1985        dst.reason = reason == null ? null : reason.copy();
1986        if (dispense != null) {
1987          dst.dispense = new ArrayList<VisionPrescriptionDispenseComponent>();
1988          for (VisionPrescriptionDispenseComponent i : dispense)
1989            dst.dispense.add(i.copy());
1990        };
1991        return dst;
1992      }
1993
1994      protected VisionPrescription typedCopy() {
1995        return copy();
1996      }
1997
1998      @Override
1999      public boolean equalsDeep(Base other) {
2000        if (!super.equalsDeep(other))
2001          return false;
2002        if (!(other instanceof VisionPrescription))
2003          return false;
2004        VisionPrescription o = (VisionPrescription) other;
2005        return compareDeep(identifier, o.identifier, true) && compareDeep(dateWritten, o.dateWritten, true)
2006           && compareDeep(patient, o.patient, true) && compareDeep(prescriber, o.prescriber, true) && compareDeep(encounter, o.encounter, true)
2007           && compareDeep(reason, o.reason, true) && compareDeep(dispense, o.dispense, true);
2008      }
2009
2010      @Override
2011      public boolean equalsShallow(Base other) {
2012        if (!super.equalsShallow(other))
2013          return false;
2014        if (!(other instanceof VisionPrescription))
2015          return false;
2016        VisionPrescription o = (VisionPrescription) other;
2017        return compareValues(dateWritten, o.dateWritten, true);
2018      }
2019
2020      public boolean isEmpty() {
2021        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (dateWritten == null || dateWritten.isEmpty())
2022           && (patient == null || patient.isEmpty()) && (prescriber == null || prescriber.isEmpty())
2023           && (encounter == null || encounter.isEmpty()) && (reason == null || reason.isEmpty()) && (dispense == null || dispense.isEmpty())
2024          ;
2025      }
2026
2027  @Override
2028  public ResourceType getResourceType() {
2029    return ResourceType.VisionPrescription;
2030   }
2031
2032 /**
2033   * Search parameter: <b>datewritten</b>
2034   * <p>
2035   * Description: <b>Return prescriptions written on this date</b><br>
2036   * Type: <b>date</b><br>
2037   * Path: <b>VisionPrescription.dateWritten</b><br>
2038   * </p>
2039   */
2040  @SearchParamDefinition(name="datewritten", path="VisionPrescription.dateWritten", description="Return prescriptions written on this date", type="date" )
2041  public static final String SP_DATEWRITTEN = "datewritten";
2042 /**
2043   * <b>Fluent Client</b> search parameter constant for <b>datewritten</b>
2044   * <p>
2045   * Description: <b>Return prescriptions written on this date</b><br>
2046   * Type: <b>date</b><br>
2047   * Path: <b>VisionPrescription.dateWritten</b><br>
2048   * </p>
2049   */
2050  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATEWRITTEN = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATEWRITTEN);
2051
2052 /**
2053   * Search parameter: <b>patient</b>
2054   * <p>
2055   * Description: <b>The identity of a patient to list dispenses for</b><br>
2056   * Type: <b>reference</b><br>
2057   * Path: <b>VisionPrescription.patient</b><br>
2058   * </p>
2059   */
2060  @SearchParamDefinition(name="patient", path="VisionPrescription.patient", description="The identity of a patient to list dispenses for", type="reference" )
2061  public static final String SP_PATIENT = "patient";
2062 /**
2063   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2064   * <p>
2065   * Description: <b>The identity of a patient to list dispenses for</b><br>
2066   * Type: <b>reference</b><br>
2067   * Path: <b>VisionPrescription.patient</b><br>
2068   * </p>
2069   */
2070  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
2071
2072/**
2073   * Constant for fluent queries to be used to add include statements. Specifies
2074   * the path value of "<b>VisionPrescription:patient</b>".
2075   */
2076  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("VisionPrescription:patient").toLocked();
2077
2078 /**
2079   * Search parameter: <b>prescriber</b>
2080   * <p>
2081   * Description: <b>Who authorizes the vision product</b><br>
2082   * Type: <b>reference</b><br>
2083   * Path: <b>VisionPrescription.prescriber</b><br>
2084   * </p>
2085   */
2086  @SearchParamDefinition(name="prescriber", path="VisionPrescription.prescriber", description="Who authorizes the vision product", type="reference" )
2087  public static final String SP_PRESCRIBER = "prescriber";
2088 /**
2089   * <b>Fluent Client</b> search parameter constant for <b>prescriber</b>
2090   * <p>
2091   * Description: <b>Who authorizes the vision product</b><br>
2092   * Type: <b>reference</b><br>
2093   * Path: <b>VisionPrescription.prescriber</b><br>
2094   * </p>
2095   */
2096  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PRESCRIBER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PRESCRIBER);
2097
2098/**
2099   * Constant for fluent queries to be used to add include statements. Specifies
2100   * the path value of "<b>VisionPrescription:prescriber</b>".
2101   */
2102  public static final ca.uhn.fhir.model.api.Include INCLUDE_PRESCRIBER = new ca.uhn.fhir.model.api.Include("VisionPrescription:prescriber").toLocked();
2103
2104 /**
2105   * Search parameter: <b>encounter</b>
2106   * <p>
2107   * Description: <b>Return prescriptions with this encounter identifier</b><br>
2108   * Type: <b>reference</b><br>
2109   * Path: <b>VisionPrescription.encounter</b><br>
2110   * </p>
2111   */
2112  @SearchParamDefinition(name="encounter", path="VisionPrescription.encounter", description="Return prescriptions with this encounter identifier", type="reference" )
2113  public static final String SP_ENCOUNTER = "encounter";
2114 /**
2115   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
2116   * <p>
2117   * Description: <b>Return prescriptions with this encounter identifier</b><br>
2118   * Type: <b>reference</b><br>
2119   * Path: <b>VisionPrescription.encounter</b><br>
2120   * </p>
2121   */
2122  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
2123
2124/**
2125   * Constant for fluent queries to be used to add include statements. Specifies
2126   * the path value of "<b>VisionPrescription:encounter</b>".
2127   */
2128  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("VisionPrescription:encounter").toLocked();
2129
2130 /**
2131   * Search parameter: <b>identifier</b>
2132   * <p>
2133   * Description: <b>Return prescriptions with this external identifier</b><br>
2134   * Type: <b>token</b><br>
2135   * Path: <b>VisionPrescription.identifier</b><br>
2136   * </p>
2137   */
2138  @SearchParamDefinition(name="identifier", path="VisionPrescription.identifier", description="Return prescriptions with this external identifier", type="token" )
2139  public static final String SP_IDENTIFIER = "identifier";
2140 /**
2141   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2142   * <p>
2143   * Description: <b>Return prescriptions with this external identifier</b><br>
2144   * Type: <b>token</b><br>
2145   * Path: <b>VisionPrescription.identifier</b><br>
2146   * </p>
2147   */
2148  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2149
2150
2151}
2152