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