001package org.hl7.fhir.r4.model;
002
003
004
005/*
006  Copyright (c) 2011+, HL7, Inc.
007  All rights reserved.
008  
009  Redistribution and use in source and binary forms, with or without modification, 
010  are permitted provided that the following conditions are met:
011  
012   * Redistributions of source code must retain the above copyright notice, this 
013     list of conditions and the following disclaimer.
014   * Redistributions in binary form must reproduce the above copyright notice, 
015     this list of conditions and the following disclaimer in the documentation 
016     and/or other materials provided with the distribution.
017   * Neither the name of HL7 nor the names of its contributors may be used to 
018     endorse or promote products derived from this software without specific 
019     prior written permission.
020  
021  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
022  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
023  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
024  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
025  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
026  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
027  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
028  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
029  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
030  POSSIBILITY OF SUCH DAMAGE.
031  
032*/
033
034
035// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
036
037import java.util.*;
038
039import java.math.*;
040import org.hl7.fhir.utilities.Utilities;
041import ca.uhn.fhir.model.api.annotation.ResourceDef;
042import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
043import ca.uhn.fhir.model.api.annotation.Child;
044import ca.uhn.fhir.model.api.annotation.ChildOrder;
045import ca.uhn.fhir.model.api.annotation.Description;
046import ca.uhn.fhir.model.api.annotation.Block;
047import org.hl7.fhir.instance.model.api.*;
048import org.hl7.fhir.exceptions.FHIRException;
049/**
050 * An authorization for the provision of glasses and/or contact lenses to a patient.
051 */
052@ResourceDef(name="VisionPrescription", profile="http://hl7.org/fhir/StructureDefinition/VisionPrescription")
053public class VisionPrescription extends DomainResource {
054
055    public enum VisionStatus {
056        /**
057         * The instance is currently in-force.
058         */
059        ACTIVE, 
060        /**
061         * The instance is withdrawn, rescinded or reversed.
062         */
063        CANCELLED, 
064        /**
065         * A new instance the contents of which is not complete.
066         */
067        DRAFT, 
068        /**
069         * The instance was entered in error.
070         */
071        ENTEREDINERROR, 
072        /**
073         * added to help the parsers with the generic types
074         */
075        NULL;
076        public static VisionStatus fromCode(String codeString) throws FHIRException {
077            if (codeString == null || "".equals(codeString))
078                return null;
079        if ("active".equals(codeString))
080          return ACTIVE;
081        if ("cancelled".equals(codeString))
082          return CANCELLED;
083        if ("draft".equals(codeString))
084          return DRAFT;
085        if ("entered-in-error".equals(codeString))
086          return ENTEREDINERROR;
087        if (Configuration.isAcceptInvalidEnums())
088          return null;
089        else
090          throw new FHIRException("Unknown VisionStatus code '"+codeString+"'");
091        }
092        public String toCode() {
093          switch (this) {
094            case ACTIVE: return "active";
095            case CANCELLED: return "cancelled";
096            case DRAFT: return "draft";
097            case ENTEREDINERROR: return "entered-in-error";
098            case NULL: return null;
099            default: return "?";
100          }
101        }
102        public String getSystem() {
103          switch (this) {
104            case ACTIVE: return "http://hl7.org/fhir/fm-status";
105            case CANCELLED: return "http://hl7.org/fhir/fm-status";
106            case DRAFT: return "http://hl7.org/fhir/fm-status";
107            case ENTEREDINERROR: return "http://hl7.org/fhir/fm-status";
108            case NULL: return null;
109            default: return "?";
110          }
111        }
112        public String getDefinition() {
113          switch (this) {
114            case ACTIVE: return "The instance is currently in-force.";
115            case CANCELLED: return "The instance is withdrawn, rescinded or reversed.";
116            case DRAFT: return "A new instance the contents of which is not complete.";
117            case ENTEREDINERROR: return "The instance was entered in error.";
118            case NULL: return null;
119            default: return "?";
120          }
121        }
122        public String getDisplay() {
123          switch (this) {
124            case ACTIVE: return "Active";
125            case CANCELLED: return "Cancelled";
126            case DRAFT: return "Draft";
127            case ENTEREDINERROR: return "Entered in Error";
128            case NULL: return null;
129            default: return "?";
130          }
131        }
132    }
133
134  public static class VisionStatusEnumFactory implements EnumFactory<VisionStatus> {
135    public VisionStatus fromCode(String codeString) throws IllegalArgumentException {
136      if (codeString == null || "".equals(codeString))
137            if (codeString == null || "".equals(codeString))
138                return null;
139        if ("active".equals(codeString))
140          return VisionStatus.ACTIVE;
141        if ("cancelled".equals(codeString))
142          return VisionStatus.CANCELLED;
143        if ("draft".equals(codeString))
144          return VisionStatus.DRAFT;
145        if ("entered-in-error".equals(codeString))
146          return VisionStatus.ENTEREDINERROR;
147        throw new IllegalArgumentException("Unknown VisionStatus code '"+codeString+"'");
148        }
149        public Enumeration<VisionStatus> fromType(Base code) throws FHIRException {
150          if (code == null)
151            return null;
152          if (code.isEmpty())
153            return new Enumeration<VisionStatus>(this);
154          String codeString = ((PrimitiveType) code).asStringValue();
155          if (codeString == null || "".equals(codeString))
156            return null;
157        if ("active".equals(codeString))
158          return new Enumeration<VisionStatus>(this, VisionStatus.ACTIVE);
159        if ("cancelled".equals(codeString))
160          return new Enumeration<VisionStatus>(this, VisionStatus.CANCELLED);
161        if ("draft".equals(codeString))
162          return new Enumeration<VisionStatus>(this, VisionStatus.DRAFT);
163        if ("entered-in-error".equals(codeString))
164          return new Enumeration<VisionStatus>(this, VisionStatus.ENTEREDINERROR);
165        throw new FHIRException("Unknown VisionStatus code '"+codeString+"'");
166        }
167    public String toCode(VisionStatus code) {
168      if (code == VisionStatus.ACTIVE)
169        return "active";
170      if (code == VisionStatus.CANCELLED)
171        return "cancelled";
172      if (code == VisionStatus.DRAFT)
173        return "draft";
174      if (code == VisionStatus.ENTEREDINERROR)
175        return "entered-in-error";
176      return "?";
177      }
178    public String toSystem(VisionStatus code) {
179      return code.getSystem();
180      }
181    }
182
183    public enum VisionEyes {
184        /**
185         * Right Eye.
186         */
187        RIGHT, 
188        /**
189         * Left Eye.
190         */
191        LEFT, 
192        /**
193         * added to help the parsers with the generic types
194         */
195        NULL;
196        public static VisionEyes fromCode(String codeString) throws FHIRException {
197            if (codeString == null || "".equals(codeString))
198                return null;
199        if ("right".equals(codeString))
200          return RIGHT;
201        if ("left".equals(codeString))
202          return LEFT;
203        if (Configuration.isAcceptInvalidEnums())
204          return null;
205        else
206          throw new FHIRException("Unknown VisionEyes code '"+codeString+"'");
207        }
208        public String toCode() {
209          switch (this) {
210            case RIGHT: return "right";
211            case LEFT: return "left";
212            case NULL: return null;
213            default: return "?";
214          }
215        }
216        public String getSystem() {
217          switch (this) {
218            case RIGHT: return "http://hl7.org/fhir/vision-eye-codes";
219            case LEFT: return "http://hl7.org/fhir/vision-eye-codes";
220            case NULL: return null;
221            default: return "?";
222          }
223        }
224        public String getDefinition() {
225          switch (this) {
226            case RIGHT: return "Right Eye.";
227            case LEFT: return "Left Eye.";
228            case NULL: return null;
229            default: return "?";
230          }
231        }
232        public String getDisplay() {
233          switch (this) {
234            case RIGHT: return "Right Eye";
235            case LEFT: return "Left Eye";
236            case NULL: return null;
237            default: return "?";
238          }
239        }
240    }
241
242  public static class VisionEyesEnumFactory implements EnumFactory<VisionEyes> {
243    public VisionEyes fromCode(String codeString) throws IllegalArgumentException {
244      if (codeString == null || "".equals(codeString))
245            if (codeString == null || "".equals(codeString))
246                return null;
247        if ("right".equals(codeString))
248          return VisionEyes.RIGHT;
249        if ("left".equals(codeString))
250          return VisionEyes.LEFT;
251        throw new IllegalArgumentException("Unknown VisionEyes code '"+codeString+"'");
252        }
253        public Enumeration<VisionEyes> fromType(Base code) throws FHIRException {
254          if (code == null)
255            return null;
256          if (code.isEmpty())
257            return new Enumeration<VisionEyes>(this);
258          String codeString = ((PrimitiveType) code).asStringValue();
259          if (codeString == null || "".equals(codeString))
260            return null;
261        if ("right".equals(codeString))
262          return new Enumeration<VisionEyes>(this, VisionEyes.RIGHT);
263        if ("left".equals(codeString))
264          return new Enumeration<VisionEyes>(this, VisionEyes.LEFT);
265        throw new FHIRException("Unknown VisionEyes code '"+codeString+"'");
266        }
267    public String toCode(VisionEyes code) {
268      if (code == VisionEyes.RIGHT)
269        return "right";
270      if (code == VisionEyes.LEFT)
271        return "left";
272      return "?";
273      }
274    public String toSystem(VisionEyes code) {
275      return code.getSystem();
276      }
277    }
278
279    public enum VisionBase {
280        /**
281         * top.
282         */
283        UP, 
284        /**
285         * bottom.
286         */
287        DOWN, 
288        /**
289         * inner edge.
290         */
291        IN, 
292        /**
293         * outer edge.
294         */
295        OUT, 
296        /**
297         * added to help the parsers with the generic types
298         */
299        NULL;
300        public static VisionBase fromCode(String codeString) throws FHIRException {
301            if (codeString == null || "".equals(codeString))
302                return null;
303        if ("up".equals(codeString))
304          return UP;
305        if ("down".equals(codeString))
306          return DOWN;
307        if ("in".equals(codeString))
308          return IN;
309        if ("out".equals(codeString))
310          return OUT;
311        if (Configuration.isAcceptInvalidEnums())
312          return null;
313        else
314          throw new FHIRException("Unknown VisionBase code '"+codeString+"'");
315        }
316        public String toCode() {
317          switch (this) {
318            case UP: return "up";
319            case DOWN: return "down";
320            case IN: return "in";
321            case OUT: return "out";
322            case NULL: return null;
323            default: return "?";
324          }
325        }
326        public String getSystem() {
327          switch (this) {
328            case UP: return "http://hl7.org/fhir/vision-base-codes";
329            case DOWN: return "http://hl7.org/fhir/vision-base-codes";
330            case IN: return "http://hl7.org/fhir/vision-base-codes";
331            case OUT: return "http://hl7.org/fhir/vision-base-codes";
332            case NULL: return null;
333            default: return "?";
334          }
335        }
336        public String getDefinition() {
337          switch (this) {
338            case UP: return "top.";
339            case DOWN: return "bottom.";
340            case IN: return "inner edge.";
341            case OUT: return "outer edge.";
342            case NULL: return null;
343            default: return "?";
344          }
345        }
346        public String getDisplay() {
347          switch (this) {
348            case UP: return "Up";
349            case DOWN: return "Down";
350            case IN: return "In";
351            case OUT: return "Out";
352            case NULL: return null;
353            default: return "?";
354          }
355        }
356    }
357
358  public static class VisionBaseEnumFactory implements EnumFactory<VisionBase> {
359    public VisionBase fromCode(String codeString) throws IllegalArgumentException {
360      if (codeString == null || "".equals(codeString))
361            if (codeString == null || "".equals(codeString))
362                return null;
363        if ("up".equals(codeString))
364          return VisionBase.UP;
365        if ("down".equals(codeString))
366          return VisionBase.DOWN;
367        if ("in".equals(codeString))
368          return VisionBase.IN;
369        if ("out".equals(codeString))
370          return VisionBase.OUT;
371        throw new IllegalArgumentException("Unknown VisionBase code '"+codeString+"'");
372        }
373        public Enumeration<VisionBase> fromType(Base code) throws FHIRException {
374          if (code == null)
375            return null;
376          if (code.isEmpty())
377            return new Enumeration<VisionBase>(this);
378          String codeString = ((PrimitiveType) code).asStringValue();
379          if (codeString == null || "".equals(codeString))
380            return null;
381        if ("up".equals(codeString))
382          return new Enumeration<VisionBase>(this, VisionBase.UP);
383        if ("down".equals(codeString))
384          return new Enumeration<VisionBase>(this, VisionBase.DOWN);
385        if ("in".equals(codeString))
386          return new Enumeration<VisionBase>(this, VisionBase.IN);
387        if ("out".equals(codeString))
388          return new Enumeration<VisionBase>(this, VisionBase.OUT);
389        throw new FHIRException("Unknown VisionBase code '"+codeString+"'");
390        }
391    public String toCode(VisionBase code) {
392      if (code == VisionBase.UP)
393        return "up";
394      if (code == VisionBase.DOWN)
395        return "down";
396      if (code == VisionBase.IN)
397        return "in";
398      if (code == VisionBase.OUT)
399        return "out";
400      return "?";
401      }
402    public String toSystem(VisionBase code) {
403      return code.getSystem();
404      }
405    }
406
407    @Block()
408    public static class VisionPrescriptionLensSpecificationComponent extends BackboneElement implements IBaseBackboneElement {
409        /**
410         * Identifies the type of vision correction product which is required for the patient.
411         */
412        @Child(name = "product", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=true)
413        @Description(shortDefinition="Product to be supplied", formalDefinition="Identifies the type of vision correction product which is required for the patient." )
414        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/vision-product")
415        protected CodeableConcept product;
416
417        /**
418         * The eye for which the lens specification applies.
419         */
420        @Child(name = "eye", type = {CodeType.class}, order=2, min=1, max=1, modifier=false, summary=true)
421        @Description(shortDefinition="right | left", formalDefinition="The eye for which the lens specification applies." )
422        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/vision-eye-codes")
423        protected Enumeration<VisionEyes> eye;
424
425        /**
426         * Lens power measured in dioptres (0.25 units).
427         */
428        @Child(name = "sphere", type = {DecimalType.class}, order=3, min=0, max=1, modifier=false, summary=false)
429        @Description(shortDefinition="Power of the lens", formalDefinition="Lens power measured in dioptres (0.25 units)." )
430        protected DecimalType sphere;
431
432        /**
433         * Power adjustment for astigmatism measured in dioptres (0.25 units).
434         */
435        @Child(name = "cylinder", type = {DecimalType.class}, order=4, min=0, max=1, modifier=false, summary=false)
436        @Description(shortDefinition="Lens power for astigmatism", formalDefinition="Power adjustment for astigmatism measured in dioptres (0.25 units)." )
437        protected DecimalType cylinder;
438
439        /**
440         * Adjustment for astigmatism measured in integer degrees.
441         */
442        @Child(name = "axis", type = {IntegerType.class}, order=5, min=0, max=1, modifier=false, summary=false)
443        @Description(shortDefinition="Lens meridian which contain no power for astigmatism", formalDefinition="Adjustment for astigmatism measured in integer degrees." )
444        protected IntegerType axis;
445
446        /**
447         * Allows for adjustment on two axis.
448         */
449        @Child(name = "prism", type = {}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
450        @Description(shortDefinition="Eye alignment compensation", formalDefinition="Allows for adjustment on two axis." )
451        protected List<PrismComponent> prism;
452
453        /**
454         * Power adjustment for multifocal lenses measured in dioptres (0.25 units).
455         */
456        @Child(name = "add", type = {DecimalType.class}, order=7, min=0, max=1, modifier=false, summary=false)
457        @Description(shortDefinition="Added power for multifocal levels", formalDefinition="Power adjustment for multifocal lenses measured in dioptres (0.25 units)." )
458        protected DecimalType add;
459
460        /**
461         * Contact lens power measured in dioptres (0.25 units).
462         */
463        @Child(name = "power", type = {DecimalType.class}, order=8, min=0, max=1, modifier=false, summary=false)
464        @Description(shortDefinition="Contact lens power", formalDefinition="Contact lens power measured in dioptres (0.25 units)." )
465        protected DecimalType power;
466
467        /**
468         * Back curvature measured in millimetres.
469         */
470        @Child(name = "backCurve", type = {DecimalType.class}, order=9, min=0, max=1, modifier=false, summary=false)
471        @Description(shortDefinition="Contact lens back curvature", formalDefinition="Back curvature measured in millimetres." )
472        protected DecimalType backCurve;
473
474        /**
475         * Contact lens diameter measured in millimetres.
476         */
477        @Child(name = "diameter", type = {DecimalType.class}, order=10, min=0, max=1, modifier=false, summary=false)
478        @Description(shortDefinition="Contact lens diameter", formalDefinition="Contact lens diameter measured in millimetres." )
479        protected DecimalType diameter;
480
481        /**
482         * The recommended maximum wear period for the lens.
483         */
484        @Child(name = "duration", type = {Quantity.class}, order=11, min=0, max=1, modifier=false, summary=false)
485        @Description(shortDefinition="Lens wear duration", formalDefinition="The recommended maximum wear period for the lens." )
486        protected Quantity duration;
487
488        /**
489         * Special color or pattern.
490         */
491        @Child(name = "color", type = {StringType.class}, order=12, min=0, max=1, modifier=false, summary=false)
492        @Description(shortDefinition="Color required", formalDefinition="Special color or pattern." )
493        protected StringType color;
494
495        /**
496         * Brand recommendations or restrictions.
497         */
498        @Child(name = "brand", type = {StringType.class}, order=13, min=0, max=1, modifier=false, summary=false)
499        @Description(shortDefinition="Brand required", formalDefinition="Brand recommendations or restrictions." )
500        protected StringType brand;
501
502        /**
503         * Notes for special requirements such as coatings and lens materials.
504         */
505        @Child(name = "note", type = {Annotation.class}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
506        @Description(shortDefinition="Notes for coatings", formalDefinition="Notes for special requirements such as coatings and lens materials." )
507        protected List<Annotation> note;
508
509        private static final long serialVersionUID = 688924460L;
510
511    /**
512     * Constructor
513     */
514      public VisionPrescriptionLensSpecificationComponent() {
515        super();
516      }
517
518    /**
519     * Constructor
520     */
521      public VisionPrescriptionLensSpecificationComponent(CodeableConcept product, Enumeration<VisionEyes> eye) {
522        super();
523        this.product = product;
524        this.eye = eye;
525      }
526
527        /**
528         * @return {@link #product} (Identifies the type of vision correction product which is required for the patient.)
529         */
530        public CodeableConcept getProduct() { 
531          if (this.product == null)
532            if (Configuration.errorOnAutoCreate())
533              throw new Error("Attempt to auto-create VisionPrescriptionLensSpecificationComponent.product");
534            else if (Configuration.doAutoCreate())
535              this.product = new CodeableConcept(); // cc
536          return this.product;
537        }
538
539        public boolean hasProduct() { 
540          return this.product != null && !this.product.isEmpty();
541        }
542
543        /**
544         * @param value {@link #product} (Identifies the type of vision correction product which is required for the patient.)
545         */
546        public VisionPrescriptionLensSpecificationComponent setProduct(CodeableConcept value) { 
547          this.product = value;
548          return this;
549        }
550
551        /**
552         * @return {@link #eye} (The eye for which the lens specification applies.). This is the underlying object with id, value and extensions. The accessor "getEye" gives direct access to the value
553         */
554        public Enumeration<VisionEyes> getEyeElement() { 
555          if (this.eye == null)
556            if (Configuration.errorOnAutoCreate())
557              throw new Error("Attempt to auto-create VisionPrescriptionLensSpecificationComponent.eye");
558            else if (Configuration.doAutoCreate())
559              this.eye = new Enumeration<VisionEyes>(new VisionEyesEnumFactory()); // bb
560          return this.eye;
561        }
562
563        public boolean hasEyeElement() { 
564          return this.eye != null && !this.eye.isEmpty();
565        }
566
567        public boolean hasEye() { 
568          return this.eye != null && !this.eye.isEmpty();
569        }
570
571        /**
572         * @param value {@link #eye} (The eye for which the lens specification applies.). This is the underlying object with id, value and extensions. The accessor "getEye" gives direct access to the value
573         */
574        public VisionPrescriptionLensSpecificationComponent setEyeElement(Enumeration<VisionEyes> value) { 
575          this.eye = value;
576          return this;
577        }
578
579        /**
580         * @return The eye for which the lens specification applies.
581         */
582        public VisionEyes getEye() { 
583          return this.eye == null ? null : this.eye.getValue();
584        }
585
586        /**
587         * @param value The eye for which the lens specification applies.
588         */
589        public VisionPrescriptionLensSpecificationComponent setEye(VisionEyes value) { 
590            if (this.eye == null)
591              this.eye = new Enumeration<VisionEyes>(new VisionEyesEnumFactory());
592            this.eye.setValue(value);
593          return this;
594        }
595
596        /**
597         * @return {@link #sphere} (Lens power measured in dioptres (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getSphere" gives direct access to the value
598         */
599        public DecimalType getSphereElement() { 
600          if (this.sphere == null)
601            if (Configuration.errorOnAutoCreate())
602              throw new Error("Attempt to auto-create VisionPrescriptionLensSpecificationComponent.sphere");
603            else if (Configuration.doAutoCreate())
604              this.sphere = new DecimalType(); // bb
605          return this.sphere;
606        }
607
608        public boolean hasSphereElement() { 
609          return this.sphere != null && !this.sphere.isEmpty();
610        }
611
612        public boolean hasSphere() { 
613          return this.sphere != null && !this.sphere.isEmpty();
614        }
615
616        /**
617         * @param value {@link #sphere} (Lens power measured in dioptres (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getSphere" gives direct access to the value
618         */
619        public VisionPrescriptionLensSpecificationComponent setSphereElement(DecimalType value) { 
620          this.sphere = value;
621          return this;
622        }
623
624        /**
625         * @return Lens power measured in dioptres (0.25 units).
626         */
627        public BigDecimal getSphere() { 
628          return this.sphere == null ? null : this.sphere.getValue();
629        }
630
631        /**
632         * @param value Lens power measured in dioptres (0.25 units).
633         */
634        public VisionPrescriptionLensSpecificationComponent setSphere(BigDecimal value) { 
635          if (value == null)
636            this.sphere = null;
637          else {
638            if (this.sphere == null)
639              this.sphere = new DecimalType();
640            this.sphere.setValue(value);
641          }
642          return this;
643        }
644
645        /**
646         * @param value Lens power measured in dioptres (0.25 units).
647         */
648        public VisionPrescriptionLensSpecificationComponent setSphere(long value) { 
649              this.sphere = new DecimalType();
650            this.sphere.setValue(value);
651          return this;
652        }
653
654        /**
655         * @param value Lens power measured in dioptres (0.25 units).
656         */
657        public VisionPrescriptionLensSpecificationComponent setSphere(double value) { 
658              this.sphere = new DecimalType();
659            this.sphere.setValue(value);
660          return this;
661        }
662
663        /**
664         * @return {@link #cylinder} (Power adjustment for astigmatism measured in dioptres (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getCylinder" gives direct access to the value
665         */
666        public DecimalType getCylinderElement() { 
667          if (this.cylinder == null)
668            if (Configuration.errorOnAutoCreate())
669              throw new Error("Attempt to auto-create VisionPrescriptionLensSpecificationComponent.cylinder");
670            else if (Configuration.doAutoCreate())
671              this.cylinder = new DecimalType(); // bb
672          return this.cylinder;
673        }
674
675        public boolean hasCylinderElement() { 
676          return this.cylinder != null && !this.cylinder.isEmpty();
677        }
678
679        public boolean hasCylinder() { 
680          return this.cylinder != null && !this.cylinder.isEmpty();
681        }
682
683        /**
684         * @param value {@link #cylinder} (Power adjustment for astigmatism measured in dioptres (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getCylinder" gives direct access to the value
685         */
686        public VisionPrescriptionLensSpecificationComponent setCylinderElement(DecimalType value) { 
687          this.cylinder = value;
688          return this;
689        }
690
691        /**
692         * @return Power adjustment for astigmatism measured in dioptres (0.25 units).
693         */
694        public BigDecimal getCylinder() { 
695          return this.cylinder == null ? null : this.cylinder.getValue();
696        }
697
698        /**
699         * @param value Power adjustment for astigmatism measured in dioptres (0.25 units).
700         */
701        public VisionPrescriptionLensSpecificationComponent setCylinder(BigDecimal value) { 
702          if (value == null)
703            this.cylinder = null;
704          else {
705            if (this.cylinder == null)
706              this.cylinder = new DecimalType();
707            this.cylinder.setValue(value);
708          }
709          return this;
710        }
711
712        /**
713         * @param value Power adjustment for astigmatism measured in dioptres (0.25 units).
714         */
715        public VisionPrescriptionLensSpecificationComponent setCylinder(long value) { 
716              this.cylinder = new DecimalType();
717            this.cylinder.setValue(value);
718          return this;
719        }
720
721        /**
722         * @param value Power adjustment for astigmatism measured in dioptres (0.25 units).
723         */
724        public VisionPrescriptionLensSpecificationComponent setCylinder(double value) { 
725              this.cylinder = new DecimalType();
726            this.cylinder.setValue(value);
727          return this;
728        }
729
730        /**
731         * @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
732         */
733        public IntegerType getAxisElement() { 
734          if (this.axis == null)
735            if (Configuration.errorOnAutoCreate())
736              throw new Error("Attempt to auto-create VisionPrescriptionLensSpecificationComponent.axis");
737            else if (Configuration.doAutoCreate())
738              this.axis = new IntegerType(); // bb
739          return this.axis;
740        }
741
742        public boolean hasAxisElement() { 
743          return this.axis != null && !this.axis.isEmpty();
744        }
745
746        public boolean hasAxis() { 
747          return this.axis != null && !this.axis.isEmpty();
748        }
749
750        /**
751         * @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
752         */
753        public VisionPrescriptionLensSpecificationComponent setAxisElement(IntegerType value) { 
754          this.axis = value;
755          return this;
756        }
757
758        /**
759         * @return Adjustment for astigmatism measured in integer degrees.
760         */
761        public int getAxis() { 
762          return this.axis == null || this.axis.isEmpty() ? 0 : this.axis.getValue();
763        }
764
765        /**
766         * @param value Adjustment for astigmatism measured in integer degrees.
767         */
768        public VisionPrescriptionLensSpecificationComponent setAxis(int value) { 
769            if (this.axis == null)
770              this.axis = new IntegerType();
771            this.axis.setValue(value);
772          return this;
773        }
774
775        /**
776         * @return {@link #prism} (Allows for adjustment on two axis.)
777         */
778        public List<PrismComponent> getPrism() { 
779          if (this.prism == null)
780            this.prism = new ArrayList<PrismComponent>();
781          return this.prism;
782        }
783
784        /**
785         * @return Returns a reference to <code>this</code> for easy method chaining
786         */
787        public VisionPrescriptionLensSpecificationComponent setPrism(List<PrismComponent> thePrism) { 
788          this.prism = thePrism;
789          return this;
790        }
791
792        public boolean hasPrism() { 
793          if (this.prism == null)
794            return false;
795          for (PrismComponent item : this.prism)
796            if (!item.isEmpty())
797              return true;
798          return false;
799        }
800
801        public PrismComponent addPrism() { //3
802          PrismComponent t = new PrismComponent();
803          if (this.prism == null)
804            this.prism = new ArrayList<PrismComponent>();
805          this.prism.add(t);
806          return t;
807        }
808
809        public VisionPrescriptionLensSpecificationComponent addPrism(PrismComponent t) { //3
810          if (t == null)
811            return this;
812          if (this.prism == null)
813            this.prism = new ArrayList<PrismComponent>();
814          this.prism.add(t);
815          return this;
816        }
817
818        /**
819         * @return The first repetition of repeating field {@link #prism}, creating it if it does not already exist
820         */
821        public PrismComponent getPrismFirstRep() { 
822          if (getPrism().isEmpty()) {
823            addPrism();
824          }
825          return getPrism().get(0);
826        }
827
828        /**
829         * @return {@link #add} (Power adjustment for multifocal lenses measured in dioptres (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getAdd" gives direct access to the value
830         */
831        public DecimalType getAddElement() { 
832          if (this.add == null)
833            if (Configuration.errorOnAutoCreate())
834              throw new Error("Attempt to auto-create VisionPrescriptionLensSpecificationComponent.add");
835            else if (Configuration.doAutoCreate())
836              this.add = new DecimalType(); // bb
837          return this.add;
838        }
839
840        public boolean hasAddElement() { 
841          return this.add != null && !this.add.isEmpty();
842        }
843
844        public boolean hasAdd() { 
845          return this.add != null && !this.add.isEmpty();
846        }
847
848        /**
849         * @param value {@link #add} (Power adjustment for multifocal lenses measured in dioptres (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getAdd" gives direct access to the value
850         */
851        public VisionPrescriptionLensSpecificationComponent setAddElement(DecimalType value) { 
852          this.add = value;
853          return this;
854        }
855
856        /**
857         * @return Power adjustment for multifocal lenses measured in dioptres (0.25 units).
858         */
859        public BigDecimal getAdd() { 
860          return this.add == null ? null : this.add.getValue();
861        }
862
863        /**
864         * @param value Power adjustment for multifocal lenses measured in dioptres (0.25 units).
865         */
866        public VisionPrescriptionLensSpecificationComponent setAdd(BigDecimal value) { 
867          if (value == null)
868            this.add = null;
869          else {
870            if (this.add == null)
871              this.add = new DecimalType();
872            this.add.setValue(value);
873          }
874          return this;
875        }
876
877        /**
878         * @param value Power adjustment for multifocal lenses measured in dioptres (0.25 units).
879         */
880        public VisionPrescriptionLensSpecificationComponent setAdd(long value) { 
881              this.add = new DecimalType();
882            this.add.setValue(value);
883          return this;
884        }
885
886        /**
887         * @param value Power adjustment for multifocal lenses measured in dioptres (0.25 units).
888         */
889        public VisionPrescriptionLensSpecificationComponent setAdd(double value) { 
890              this.add = new DecimalType();
891            this.add.setValue(value);
892          return this;
893        }
894
895        /**
896         * @return {@link #power} (Contact lens power measured in dioptres (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getPower" gives direct access to the value
897         */
898        public DecimalType getPowerElement() { 
899          if (this.power == null)
900            if (Configuration.errorOnAutoCreate())
901              throw new Error("Attempt to auto-create VisionPrescriptionLensSpecificationComponent.power");
902            else if (Configuration.doAutoCreate())
903              this.power = new DecimalType(); // bb
904          return this.power;
905        }
906
907        public boolean hasPowerElement() { 
908          return this.power != null && !this.power.isEmpty();
909        }
910
911        public boolean hasPower() { 
912          return this.power != null && !this.power.isEmpty();
913        }
914
915        /**
916         * @param value {@link #power} (Contact lens power measured in dioptres (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getPower" gives direct access to the value
917         */
918        public VisionPrescriptionLensSpecificationComponent setPowerElement(DecimalType value) { 
919          this.power = value;
920          return this;
921        }
922
923        /**
924         * @return Contact lens power measured in dioptres (0.25 units).
925         */
926        public BigDecimal getPower() { 
927          return this.power == null ? null : this.power.getValue();
928        }
929
930        /**
931         * @param value Contact lens power measured in dioptres (0.25 units).
932         */
933        public VisionPrescriptionLensSpecificationComponent setPower(BigDecimal value) { 
934          if (value == null)
935            this.power = null;
936          else {
937            if (this.power == null)
938              this.power = new DecimalType();
939            this.power.setValue(value);
940          }
941          return this;
942        }
943
944        /**
945         * @param value Contact lens power measured in dioptres (0.25 units).
946         */
947        public VisionPrescriptionLensSpecificationComponent setPower(long value) { 
948              this.power = new DecimalType();
949            this.power.setValue(value);
950          return this;
951        }
952
953        /**
954         * @param value Contact lens power measured in dioptres (0.25 units).
955         */
956        public VisionPrescriptionLensSpecificationComponent setPower(double value) { 
957              this.power = new DecimalType();
958            this.power.setValue(value);
959          return this;
960        }
961
962        /**
963         * @return {@link #backCurve} (Back curvature measured in millimetres.). This is the underlying object with id, value and extensions. The accessor "getBackCurve" gives direct access to the value
964         */
965        public DecimalType getBackCurveElement() { 
966          if (this.backCurve == null)
967            if (Configuration.errorOnAutoCreate())
968              throw new Error("Attempt to auto-create VisionPrescriptionLensSpecificationComponent.backCurve");
969            else if (Configuration.doAutoCreate())
970              this.backCurve = new DecimalType(); // bb
971          return this.backCurve;
972        }
973
974        public boolean hasBackCurveElement() { 
975          return this.backCurve != null && !this.backCurve.isEmpty();
976        }
977
978        public boolean hasBackCurve() { 
979          return this.backCurve != null && !this.backCurve.isEmpty();
980        }
981
982        /**
983         * @param value {@link #backCurve} (Back curvature measured in millimetres.). This is the underlying object with id, value and extensions. The accessor "getBackCurve" gives direct access to the value
984         */
985        public VisionPrescriptionLensSpecificationComponent setBackCurveElement(DecimalType value) { 
986          this.backCurve = value;
987          return this;
988        }
989
990        /**
991         * @return Back curvature measured in millimetres.
992         */
993        public BigDecimal getBackCurve() { 
994          return this.backCurve == null ? null : this.backCurve.getValue();
995        }
996
997        /**
998         * @param value Back curvature measured in millimetres.
999         */
1000        public VisionPrescriptionLensSpecificationComponent setBackCurve(BigDecimal value) { 
1001          if (value == null)
1002            this.backCurve = null;
1003          else {
1004            if (this.backCurve == null)
1005              this.backCurve = new DecimalType();
1006            this.backCurve.setValue(value);
1007          }
1008          return this;
1009        }
1010
1011        /**
1012         * @param value Back curvature measured in millimetres.
1013         */
1014        public VisionPrescriptionLensSpecificationComponent setBackCurve(long value) { 
1015              this.backCurve = new DecimalType();
1016            this.backCurve.setValue(value);
1017          return this;
1018        }
1019
1020        /**
1021         * @param value Back curvature measured in millimetres.
1022         */
1023        public VisionPrescriptionLensSpecificationComponent setBackCurve(double value) { 
1024              this.backCurve = new DecimalType();
1025            this.backCurve.setValue(value);
1026          return this;
1027        }
1028
1029        /**
1030         * @return {@link #diameter} (Contact lens diameter measured in millimetres.). This is the underlying object with id, value and extensions. The accessor "getDiameter" gives direct access to the value
1031         */
1032        public DecimalType getDiameterElement() { 
1033          if (this.diameter == null)
1034            if (Configuration.errorOnAutoCreate())
1035              throw new Error("Attempt to auto-create VisionPrescriptionLensSpecificationComponent.diameter");
1036            else if (Configuration.doAutoCreate())
1037              this.diameter = new DecimalType(); // bb
1038          return this.diameter;
1039        }
1040
1041        public boolean hasDiameterElement() { 
1042          return this.diameter != null && !this.diameter.isEmpty();
1043        }
1044
1045        public boolean hasDiameter() { 
1046          return this.diameter != null && !this.diameter.isEmpty();
1047        }
1048
1049        /**
1050         * @param value {@link #diameter} (Contact lens diameter measured in millimetres.). This is the underlying object with id, value and extensions. The accessor "getDiameter" gives direct access to the value
1051         */
1052        public VisionPrescriptionLensSpecificationComponent setDiameterElement(DecimalType value) { 
1053          this.diameter = value;
1054          return this;
1055        }
1056
1057        /**
1058         * @return Contact lens diameter measured in millimetres.
1059         */
1060        public BigDecimal getDiameter() { 
1061          return this.diameter == null ? null : this.diameter.getValue();
1062        }
1063
1064        /**
1065         * @param value Contact lens diameter measured in millimetres.
1066         */
1067        public VisionPrescriptionLensSpecificationComponent setDiameter(BigDecimal value) { 
1068          if (value == null)
1069            this.diameter = null;
1070          else {
1071            if (this.diameter == null)
1072              this.diameter = new DecimalType();
1073            this.diameter.setValue(value);
1074          }
1075          return this;
1076        }
1077
1078        /**
1079         * @param value Contact lens diameter measured in millimetres.
1080         */
1081        public VisionPrescriptionLensSpecificationComponent setDiameter(long value) { 
1082              this.diameter = new DecimalType();
1083            this.diameter.setValue(value);
1084          return this;
1085        }
1086
1087        /**
1088         * @param value Contact lens diameter measured in millimetres.
1089         */
1090        public VisionPrescriptionLensSpecificationComponent setDiameter(double value) { 
1091              this.diameter = new DecimalType();
1092            this.diameter.setValue(value);
1093          return this;
1094        }
1095
1096        /**
1097         * @return {@link #duration} (The recommended maximum wear period for the lens.)
1098         */
1099        public Quantity getDuration() { 
1100          if (this.duration == null)
1101            if (Configuration.errorOnAutoCreate())
1102              throw new Error("Attempt to auto-create VisionPrescriptionLensSpecificationComponent.duration");
1103            else if (Configuration.doAutoCreate())
1104              this.duration = new Quantity(); // cc
1105          return this.duration;
1106        }
1107
1108        public boolean hasDuration() { 
1109          return this.duration != null && !this.duration.isEmpty();
1110        }
1111
1112        /**
1113         * @param value {@link #duration} (The recommended maximum wear period for the lens.)
1114         */
1115        public VisionPrescriptionLensSpecificationComponent setDuration(Quantity value) { 
1116          this.duration = value;
1117          return this;
1118        }
1119
1120        /**
1121         * @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
1122         */
1123        public StringType getColorElement() { 
1124          if (this.color == null)
1125            if (Configuration.errorOnAutoCreate())
1126              throw new Error("Attempt to auto-create VisionPrescriptionLensSpecificationComponent.color");
1127            else if (Configuration.doAutoCreate())
1128              this.color = new StringType(); // bb
1129          return this.color;
1130        }
1131
1132        public boolean hasColorElement() { 
1133          return this.color != null && !this.color.isEmpty();
1134        }
1135
1136        public boolean hasColor() { 
1137          return this.color != null && !this.color.isEmpty();
1138        }
1139
1140        /**
1141         * @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
1142         */
1143        public VisionPrescriptionLensSpecificationComponent setColorElement(StringType value) { 
1144          this.color = value;
1145          return this;
1146        }
1147
1148        /**
1149         * @return Special color or pattern.
1150         */
1151        public String getColor() { 
1152          return this.color == null ? null : this.color.getValue();
1153        }
1154
1155        /**
1156         * @param value Special color or pattern.
1157         */
1158        public VisionPrescriptionLensSpecificationComponent setColor(String value) { 
1159          if (Utilities.noString(value))
1160            this.color = null;
1161          else {
1162            if (this.color == null)
1163              this.color = new StringType();
1164            this.color.setValue(value);
1165          }
1166          return this;
1167        }
1168
1169        /**
1170         * @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
1171         */
1172        public StringType getBrandElement() { 
1173          if (this.brand == null)
1174            if (Configuration.errorOnAutoCreate())
1175              throw new Error("Attempt to auto-create VisionPrescriptionLensSpecificationComponent.brand");
1176            else if (Configuration.doAutoCreate())
1177              this.brand = new StringType(); // bb
1178          return this.brand;
1179        }
1180
1181        public boolean hasBrandElement() { 
1182          return this.brand != null && !this.brand.isEmpty();
1183        }
1184
1185        public boolean hasBrand() { 
1186          return this.brand != null && !this.brand.isEmpty();
1187        }
1188
1189        /**
1190         * @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
1191         */
1192        public VisionPrescriptionLensSpecificationComponent setBrandElement(StringType value) { 
1193          this.brand = value;
1194          return this;
1195        }
1196
1197        /**
1198         * @return Brand recommendations or restrictions.
1199         */
1200        public String getBrand() { 
1201          return this.brand == null ? null : this.brand.getValue();
1202        }
1203
1204        /**
1205         * @param value Brand recommendations or restrictions.
1206         */
1207        public VisionPrescriptionLensSpecificationComponent setBrand(String value) { 
1208          if (Utilities.noString(value))
1209            this.brand = null;
1210          else {
1211            if (this.brand == null)
1212              this.brand = new StringType();
1213            this.brand.setValue(value);
1214          }
1215          return this;
1216        }
1217
1218        /**
1219         * @return {@link #note} (Notes for special requirements such as coatings and lens materials.)
1220         */
1221        public List<Annotation> getNote() { 
1222          if (this.note == null)
1223            this.note = new ArrayList<Annotation>();
1224          return this.note;
1225        }
1226
1227        /**
1228         * @return Returns a reference to <code>this</code> for easy method chaining
1229         */
1230        public VisionPrescriptionLensSpecificationComponent setNote(List<Annotation> theNote) { 
1231          this.note = theNote;
1232          return this;
1233        }
1234
1235        public boolean hasNote() { 
1236          if (this.note == null)
1237            return false;
1238          for (Annotation item : this.note)
1239            if (!item.isEmpty())
1240              return true;
1241          return false;
1242        }
1243
1244        public Annotation addNote() { //3
1245          Annotation t = new Annotation();
1246          if (this.note == null)
1247            this.note = new ArrayList<Annotation>();
1248          this.note.add(t);
1249          return t;
1250        }
1251
1252        public VisionPrescriptionLensSpecificationComponent addNote(Annotation t) { //3
1253          if (t == null)
1254            return this;
1255          if (this.note == null)
1256            this.note = new ArrayList<Annotation>();
1257          this.note.add(t);
1258          return this;
1259        }
1260
1261        /**
1262         * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist
1263         */
1264        public Annotation getNoteFirstRep() { 
1265          if (getNote().isEmpty()) {
1266            addNote();
1267          }
1268          return getNote().get(0);
1269        }
1270
1271        protected void listChildren(List<Property> children) {
1272          super.listChildren(children);
1273          children.add(new Property("product", "CodeableConcept", "Identifies the type of vision correction product which is required for the patient.", 0, 1, product));
1274          children.add(new Property("eye", "code", "The eye for which the lens specification applies.", 0, 1, eye));
1275          children.add(new Property("sphere", "decimal", "Lens power measured in dioptres (0.25 units).", 0, 1, sphere));
1276          children.add(new Property("cylinder", "decimal", "Power adjustment for astigmatism measured in dioptres (0.25 units).", 0, 1, cylinder));
1277          children.add(new Property("axis", "integer", "Adjustment for astigmatism measured in integer degrees.", 0, 1, axis));
1278          children.add(new Property("prism", "", "Allows for adjustment on two axis.", 0, java.lang.Integer.MAX_VALUE, prism));
1279          children.add(new Property("add", "decimal", "Power adjustment for multifocal lenses measured in dioptres (0.25 units).", 0, 1, add));
1280          children.add(new Property("power", "decimal", "Contact lens power measured in dioptres (0.25 units).", 0, 1, power));
1281          children.add(new Property("backCurve", "decimal", "Back curvature measured in millimetres.", 0, 1, backCurve));
1282          children.add(new Property("diameter", "decimal", "Contact lens diameter measured in millimetres.", 0, 1, diameter));
1283          children.add(new Property("duration", "SimpleQuantity", "The recommended maximum wear period for the lens.", 0, 1, duration));
1284          children.add(new Property("color", "string", "Special color or pattern.", 0, 1, color));
1285          children.add(new Property("brand", "string", "Brand recommendations or restrictions.", 0, 1, brand));
1286          children.add(new Property("note", "Annotation", "Notes for special requirements such as coatings and lens materials.", 0, java.lang.Integer.MAX_VALUE, note));
1287        }
1288
1289        @Override
1290        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1291          switch (_hash) {
1292          case -309474065: /*product*/  return new Property("product", "CodeableConcept", "Identifies the type of vision correction product which is required for the patient.", 0, 1, product);
1293          case 100913: /*eye*/  return new Property("eye", "code", "The eye for which the lens specification applies.", 0, 1, eye);
1294          case -895981619: /*sphere*/  return new Property("sphere", "decimal", "Lens power measured in dioptres (0.25 units).", 0, 1, sphere);
1295          case -349378602: /*cylinder*/  return new Property("cylinder", "decimal", "Power adjustment for astigmatism measured in dioptres (0.25 units).", 0, 1, cylinder);
1296          case 3008417: /*axis*/  return new Property("axis", "integer", "Adjustment for astigmatism measured in integer degrees.", 0, 1, axis);
1297          case 106935105: /*prism*/  return new Property("prism", "", "Allows for adjustment on two axis.", 0, java.lang.Integer.MAX_VALUE, prism);
1298          case 96417: /*add*/  return new Property("add", "decimal", "Power adjustment for multifocal lenses measured in dioptres (0.25 units).", 0, 1, add);
1299          case 106858757: /*power*/  return new Property("power", "decimal", "Contact lens power measured in dioptres (0.25 units).", 0, 1, power);
1300          case 1309344840: /*backCurve*/  return new Property("backCurve", "decimal", "Back curvature measured in millimetres.", 0, 1, backCurve);
1301          case -233204595: /*diameter*/  return new Property("diameter", "decimal", "Contact lens diameter measured in millimetres.", 0, 1, diameter);
1302          case -1992012396: /*duration*/  return new Property("duration", "SimpleQuantity", "The recommended maximum wear period for the lens.", 0, 1, duration);
1303          case 94842723: /*color*/  return new Property("color", "string", "Special color or pattern.", 0, 1, color);
1304          case 93997959: /*brand*/  return new Property("brand", "string", "Brand recommendations or restrictions.", 0, 1, brand);
1305          case 3387378: /*note*/  return new Property("note", "Annotation", "Notes for special requirements such as coatings and lens materials.", 0, java.lang.Integer.MAX_VALUE, note);
1306          default: return super.getNamedProperty(_hash, _name, _checkValid);
1307          }
1308
1309        }
1310
1311      @Override
1312      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1313        switch (hash) {
1314        case -309474065: /*product*/ return this.product == null ? new Base[0] : new Base[] {this.product}; // CodeableConcept
1315        case 100913: /*eye*/ return this.eye == null ? new Base[0] : new Base[] {this.eye}; // Enumeration<VisionEyes>
1316        case -895981619: /*sphere*/ return this.sphere == null ? new Base[0] : new Base[] {this.sphere}; // DecimalType
1317        case -349378602: /*cylinder*/ return this.cylinder == null ? new Base[0] : new Base[] {this.cylinder}; // DecimalType
1318        case 3008417: /*axis*/ return this.axis == null ? new Base[0] : new Base[] {this.axis}; // IntegerType
1319        case 106935105: /*prism*/ return this.prism == null ? new Base[0] : this.prism.toArray(new Base[this.prism.size()]); // PrismComponent
1320        case 96417: /*add*/ return this.add == null ? new Base[0] : new Base[] {this.add}; // DecimalType
1321        case 106858757: /*power*/ return this.power == null ? new Base[0] : new Base[] {this.power}; // DecimalType
1322        case 1309344840: /*backCurve*/ return this.backCurve == null ? new Base[0] : new Base[] {this.backCurve}; // DecimalType
1323        case -233204595: /*diameter*/ return this.diameter == null ? new Base[0] : new Base[] {this.diameter}; // DecimalType
1324        case -1992012396: /*duration*/ return this.duration == null ? new Base[0] : new Base[] {this.duration}; // Quantity
1325        case 94842723: /*color*/ return this.color == null ? new Base[0] : new Base[] {this.color}; // StringType
1326        case 93997959: /*brand*/ return this.brand == null ? new Base[0] : new Base[] {this.brand}; // StringType
1327        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
1328        default: return super.getProperty(hash, name, checkValid);
1329        }
1330
1331      }
1332
1333      @Override
1334      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1335        switch (hash) {
1336        case -309474065: // product
1337          this.product = castToCodeableConcept(value); // CodeableConcept
1338          return value;
1339        case 100913: // eye
1340          value = new VisionEyesEnumFactory().fromType(castToCode(value));
1341          this.eye = (Enumeration) value; // Enumeration<VisionEyes>
1342          return value;
1343        case -895981619: // sphere
1344          this.sphere = castToDecimal(value); // DecimalType
1345          return value;
1346        case -349378602: // cylinder
1347          this.cylinder = castToDecimal(value); // DecimalType
1348          return value;
1349        case 3008417: // axis
1350          this.axis = castToInteger(value); // IntegerType
1351          return value;
1352        case 106935105: // prism
1353          this.getPrism().add((PrismComponent) value); // PrismComponent
1354          return value;
1355        case 96417: // add
1356          this.add = castToDecimal(value); // DecimalType
1357          return value;
1358        case 106858757: // power
1359          this.power = castToDecimal(value); // DecimalType
1360          return value;
1361        case 1309344840: // backCurve
1362          this.backCurve = castToDecimal(value); // DecimalType
1363          return value;
1364        case -233204595: // diameter
1365          this.diameter = castToDecimal(value); // DecimalType
1366          return value;
1367        case -1992012396: // duration
1368          this.duration = castToQuantity(value); // Quantity
1369          return value;
1370        case 94842723: // color
1371          this.color = castToString(value); // StringType
1372          return value;
1373        case 93997959: // brand
1374          this.brand = castToString(value); // StringType
1375          return value;
1376        case 3387378: // note
1377          this.getNote().add(castToAnnotation(value)); // Annotation
1378          return value;
1379        default: return super.setProperty(hash, name, value);
1380        }
1381
1382      }
1383
1384      @Override
1385      public Base setProperty(String name, Base value) throws FHIRException {
1386        if (name.equals("product")) {
1387          this.product = castToCodeableConcept(value); // CodeableConcept
1388        } else if (name.equals("eye")) {
1389          value = new VisionEyesEnumFactory().fromType(castToCode(value));
1390          this.eye = (Enumeration) value; // Enumeration<VisionEyes>
1391        } else if (name.equals("sphere")) {
1392          this.sphere = castToDecimal(value); // DecimalType
1393        } else if (name.equals("cylinder")) {
1394          this.cylinder = castToDecimal(value); // DecimalType
1395        } else if (name.equals("axis")) {
1396          this.axis = castToInteger(value); // IntegerType
1397        } else if (name.equals("prism")) {
1398          this.getPrism().add((PrismComponent) value);
1399        } else if (name.equals("add")) {
1400          this.add = castToDecimal(value); // DecimalType
1401        } else if (name.equals("power")) {
1402          this.power = castToDecimal(value); // DecimalType
1403        } else if (name.equals("backCurve")) {
1404          this.backCurve = castToDecimal(value); // DecimalType
1405        } else if (name.equals("diameter")) {
1406          this.diameter = castToDecimal(value); // DecimalType
1407        } else if (name.equals("duration")) {
1408          this.duration = castToQuantity(value); // Quantity
1409        } else if (name.equals("color")) {
1410          this.color = castToString(value); // StringType
1411        } else if (name.equals("brand")) {
1412          this.brand = castToString(value); // StringType
1413        } else if (name.equals("note")) {
1414          this.getNote().add(castToAnnotation(value));
1415        } else
1416          return super.setProperty(name, value);
1417        return value;
1418      }
1419
1420      @Override
1421      public Base makeProperty(int hash, String name) throws FHIRException {
1422        switch (hash) {
1423        case -309474065:  return getProduct(); 
1424        case 100913:  return getEyeElement();
1425        case -895981619:  return getSphereElement();
1426        case -349378602:  return getCylinderElement();
1427        case 3008417:  return getAxisElement();
1428        case 106935105:  return addPrism(); 
1429        case 96417:  return getAddElement();
1430        case 106858757:  return getPowerElement();
1431        case 1309344840:  return getBackCurveElement();
1432        case -233204595:  return getDiameterElement();
1433        case -1992012396:  return getDuration(); 
1434        case 94842723:  return getColorElement();
1435        case 93997959:  return getBrandElement();
1436        case 3387378:  return addNote(); 
1437        default: return super.makeProperty(hash, name);
1438        }
1439
1440      }
1441
1442      @Override
1443      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1444        switch (hash) {
1445        case -309474065: /*product*/ return new String[] {"CodeableConcept"};
1446        case 100913: /*eye*/ return new String[] {"code"};
1447        case -895981619: /*sphere*/ return new String[] {"decimal"};
1448        case -349378602: /*cylinder*/ return new String[] {"decimal"};
1449        case 3008417: /*axis*/ return new String[] {"integer"};
1450        case 106935105: /*prism*/ return new String[] {};
1451        case 96417: /*add*/ return new String[] {"decimal"};
1452        case 106858757: /*power*/ return new String[] {"decimal"};
1453        case 1309344840: /*backCurve*/ return new String[] {"decimal"};
1454        case -233204595: /*diameter*/ return new String[] {"decimal"};
1455        case -1992012396: /*duration*/ return new String[] {"SimpleQuantity"};
1456        case 94842723: /*color*/ return new String[] {"string"};
1457        case 93997959: /*brand*/ return new String[] {"string"};
1458        case 3387378: /*note*/ return new String[] {"Annotation"};
1459        default: return super.getTypesForProperty(hash, name);
1460        }
1461
1462      }
1463
1464      @Override
1465      public Base addChild(String name) throws FHIRException {
1466        if (name.equals("product")) {
1467          this.product = new CodeableConcept();
1468          return this.product;
1469        }
1470        else if (name.equals("eye")) {
1471          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.eye");
1472        }
1473        else if (name.equals("sphere")) {
1474          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.sphere");
1475        }
1476        else if (name.equals("cylinder")) {
1477          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.cylinder");
1478        }
1479        else if (name.equals("axis")) {
1480          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.axis");
1481        }
1482        else if (name.equals("prism")) {
1483          return addPrism();
1484        }
1485        else if (name.equals("add")) {
1486          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.add");
1487        }
1488        else if (name.equals("power")) {
1489          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.power");
1490        }
1491        else if (name.equals("backCurve")) {
1492          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.backCurve");
1493        }
1494        else if (name.equals("diameter")) {
1495          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.diameter");
1496        }
1497        else if (name.equals("duration")) {
1498          this.duration = new Quantity();
1499          return this.duration;
1500        }
1501        else if (name.equals("color")) {
1502          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.color");
1503        }
1504        else if (name.equals("brand")) {
1505          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.brand");
1506        }
1507        else if (name.equals("note")) {
1508          return addNote();
1509        }
1510        else
1511          return super.addChild(name);
1512      }
1513
1514      public VisionPrescriptionLensSpecificationComponent copy() {
1515        VisionPrescriptionLensSpecificationComponent dst = new VisionPrescriptionLensSpecificationComponent();
1516        copyValues(dst);
1517        return dst;
1518      }
1519
1520      public void copyValues(VisionPrescriptionLensSpecificationComponent dst) {
1521        super.copyValues(dst);
1522        dst.product = product == null ? null : product.copy();
1523        dst.eye = eye == null ? null : eye.copy();
1524        dst.sphere = sphere == null ? null : sphere.copy();
1525        dst.cylinder = cylinder == null ? null : cylinder.copy();
1526        dst.axis = axis == null ? null : axis.copy();
1527        if (prism != null) {
1528          dst.prism = new ArrayList<PrismComponent>();
1529          for (PrismComponent i : prism)
1530            dst.prism.add(i.copy());
1531        };
1532        dst.add = add == null ? null : add.copy();
1533        dst.power = power == null ? null : power.copy();
1534        dst.backCurve = backCurve == null ? null : backCurve.copy();
1535        dst.diameter = diameter == null ? null : diameter.copy();
1536        dst.duration = duration == null ? null : duration.copy();
1537        dst.color = color == null ? null : color.copy();
1538        dst.brand = brand == null ? null : brand.copy();
1539        if (note != null) {
1540          dst.note = new ArrayList<Annotation>();
1541          for (Annotation i : note)
1542            dst.note.add(i.copy());
1543        };
1544      }
1545
1546      @Override
1547      public boolean equalsDeep(Base other_) {
1548        if (!super.equalsDeep(other_))
1549          return false;
1550        if (!(other_ instanceof VisionPrescriptionLensSpecificationComponent))
1551          return false;
1552        VisionPrescriptionLensSpecificationComponent o = (VisionPrescriptionLensSpecificationComponent) other_;
1553        return compareDeep(product, o.product, true) && compareDeep(eye, o.eye, true) && compareDeep(sphere, o.sphere, true)
1554           && compareDeep(cylinder, o.cylinder, true) && compareDeep(axis, o.axis, true) && compareDeep(prism, o.prism, true)
1555           && compareDeep(add, o.add, true) && compareDeep(power, o.power, true) && compareDeep(backCurve, o.backCurve, true)
1556           && compareDeep(diameter, o.diameter, true) && compareDeep(duration, o.duration, true) && compareDeep(color, o.color, true)
1557           && compareDeep(brand, o.brand, true) && compareDeep(note, o.note, true);
1558      }
1559
1560      @Override
1561      public boolean equalsShallow(Base other_) {
1562        if (!super.equalsShallow(other_))
1563          return false;
1564        if (!(other_ instanceof VisionPrescriptionLensSpecificationComponent))
1565          return false;
1566        VisionPrescriptionLensSpecificationComponent o = (VisionPrescriptionLensSpecificationComponent) other_;
1567        return compareValues(eye, o.eye, true) && compareValues(sphere, o.sphere, true) && compareValues(cylinder, o.cylinder, true)
1568           && compareValues(axis, o.axis, true) && compareValues(add, o.add, true) && compareValues(power, o.power, true)
1569           && compareValues(backCurve, o.backCurve, true) && compareValues(diameter, o.diameter, true) && compareValues(color, o.color, true)
1570           && compareValues(brand, o.brand, true);
1571      }
1572
1573      public boolean isEmpty() {
1574        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(product, eye, sphere, cylinder
1575          , axis, prism, add, power, backCurve, diameter, duration, color, brand, note
1576          );
1577      }
1578
1579  public String fhirType() {
1580    return "VisionPrescription.lensSpecification";
1581
1582  }
1583
1584  }
1585
1586    @Block()
1587    public static class PrismComponent extends BackboneElement implements IBaseBackboneElement {
1588        /**
1589         * Amount of prism to compensate for eye alignment in fractional units.
1590         */
1591        @Child(name = "amount", type = {DecimalType.class}, order=1, min=1, max=1, modifier=false, summary=false)
1592        @Description(shortDefinition="Amount of adjustment", formalDefinition="Amount of prism to compensate for eye alignment in fractional units." )
1593        protected DecimalType amount;
1594
1595        /**
1596         * The relative base, or reference lens edge, for the prism.
1597         */
1598        @Child(name = "base", type = {CodeType.class}, order=2, min=1, max=1, modifier=false, summary=false)
1599        @Description(shortDefinition="up | down | in | out", formalDefinition="The relative base, or reference lens edge, for the prism." )
1600        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/vision-base-codes")
1601        protected Enumeration<VisionBase> base;
1602
1603        private static final long serialVersionUID = 1677247628L;
1604
1605    /**
1606     * Constructor
1607     */
1608      public PrismComponent() {
1609        super();
1610      }
1611
1612    /**
1613     * Constructor
1614     */
1615      public PrismComponent(DecimalType amount, Enumeration<VisionBase> base) {
1616        super();
1617        this.amount = amount;
1618        this.base = base;
1619      }
1620
1621        /**
1622         * @return {@link #amount} (Amount of prism to compensate for eye alignment in fractional units.). This is the underlying object with id, value and extensions. The accessor "getAmount" gives direct access to the value
1623         */
1624        public DecimalType getAmountElement() { 
1625          if (this.amount == null)
1626            if (Configuration.errorOnAutoCreate())
1627              throw new Error("Attempt to auto-create PrismComponent.amount");
1628            else if (Configuration.doAutoCreate())
1629              this.amount = new DecimalType(); // bb
1630          return this.amount;
1631        }
1632
1633        public boolean hasAmountElement() { 
1634          return this.amount != null && !this.amount.isEmpty();
1635        }
1636
1637        public boolean hasAmount() { 
1638          return this.amount != null && !this.amount.isEmpty();
1639        }
1640
1641        /**
1642         * @param value {@link #amount} (Amount of prism to compensate for eye alignment in fractional units.). This is the underlying object with id, value and extensions. The accessor "getAmount" gives direct access to the value
1643         */
1644        public PrismComponent setAmountElement(DecimalType value) { 
1645          this.amount = value;
1646          return this;
1647        }
1648
1649        /**
1650         * @return Amount of prism to compensate for eye alignment in fractional units.
1651         */
1652        public BigDecimal getAmount() { 
1653          return this.amount == null ? null : this.amount.getValue();
1654        }
1655
1656        /**
1657         * @param value Amount of prism to compensate for eye alignment in fractional units.
1658         */
1659        public PrismComponent setAmount(BigDecimal value) { 
1660            if (this.amount == null)
1661              this.amount = new DecimalType();
1662            this.amount.setValue(value);
1663          return this;
1664        }
1665
1666        /**
1667         * @param value Amount of prism to compensate for eye alignment in fractional units.
1668         */
1669        public PrismComponent setAmount(long value) { 
1670              this.amount = new DecimalType();
1671            this.amount.setValue(value);
1672          return this;
1673        }
1674
1675        /**
1676         * @param value Amount of prism to compensate for eye alignment in fractional units.
1677         */
1678        public PrismComponent setAmount(double value) { 
1679              this.amount = new DecimalType();
1680            this.amount.setValue(value);
1681          return this;
1682        }
1683
1684        /**
1685         * @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
1686         */
1687        public Enumeration<VisionBase> getBaseElement() { 
1688          if (this.base == null)
1689            if (Configuration.errorOnAutoCreate())
1690              throw new Error("Attempt to auto-create PrismComponent.base");
1691            else if (Configuration.doAutoCreate())
1692              this.base = new Enumeration<VisionBase>(new VisionBaseEnumFactory()); // bb
1693          return this.base;
1694        }
1695
1696        public boolean hasBaseElement() { 
1697          return this.base != null && !this.base.isEmpty();
1698        }
1699
1700        public boolean hasBase() { 
1701          return this.base != null && !this.base.isEmpty();
1702        }
1703
1704        /**
1705         * @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
1706         */
1707        public PrismComponent setBaseElement(Enumeration<VisionBase> value) { 
1708          this.base = value;
1709          return this;
1710        }
1711
1712        /**
1713         * @return The relative base, or reference lens edge, for the prism.
1714         */
1715        public VisionBase getBase() { 
1716          return this.base == null ? null : this.base.getValue();
1717        }
1718
1719        /**
1720         * @param value The relative base, or reference lens edge, for the prism.
1721         */
1722        public PrismComponent setBase(VisionBase value) { 
1723            if (this.base == null)
1724              this.base = new Enumeration<VisionBase>(new VisionBaseEnumFactory());
1725            this.base.setValue(value);
1726          return this;
1727        }
1728
1729        protected void listChildren(List<Property> children) {
1730          super.listChildren(children);
1731          children.add(new Property("amount", "decimal", "Amount of prism to compensate for eye alignment in fractional units.", 0, 1, amount));
1732          children.add(new Property("base", "code", "The relative base, or reference lens edge, for the prism.", 0, 1, base));
1733        }
1734
1735        @Override
1736        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1737          switch (_hash) {
1738          case -1413853096: /*amount*/  return new Property("amount", "decimal", "Amount of prism to compensate for eye alignment in fractional units.", 0, 1, amount);
1739          case 3016401: /*base*/  return new Property("base", "code", "The relative base, or reference lens edge, for the prism.", 0, 1, base);
1740          default: return super.getNamedProperty(_hash, _name, _checkValid);
1741          }
1742
1743        }
1744
1745      @Override
1746      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1747        switch (hash) {
1748        case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // DecimalType
1749        case 3016401: /*base*/ return this.base == null ? new Base[0] : new Base[] {this.base}; // Enumeration<VisionBase>
1750        default: return super.getProperty(hash, name, checkValid);
1751        }
1752
1753      }
1754
1755      @Override
1756      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1757        switch (hash) {
1758        case -1413853096: // amount
1759          this.amount = castToDecimal(value); // DecimalType
1760          return value;
1761        case 3016401: // base
1762          value = new VisionBaseEnumFactory().fromType(castToCode(value));
1763          this.base = (Enumeration) value; // Enumeration<VisionBase>
1764          return value;
1765        default: return super.setProperty(hash, name, value);
1766        }
1767
1768      }
1769
1770      @Override
1771      public Base setProperty(String name, Base value) throws FHIRException {
1772        if (name.equals("amount")) {
1773          this.amount = castToDecimal(value); // DecimalType
1774        } else if (name.equals("base")) {
1775          value = new VisionBaseEnumFactory().fromType(castToCode(value));
1776          this.base = (Enumeration) value; // Enumeration<VisionBase>
1777        } else
1778          return super.setProperty(name, value);
1779        return value;
1780      }
1781
1782      @Override
1783      public Base makeProperty(int hash, String name) throws FHIRException {
1784        switch (hash) {
1785        case -1413853096:  return getAmountElement();
1786        case 3016401:  return getBaseElement();
1787        default: return super.makeProperty(hash, name);
1788        }
1789
1790      }
1791
1792      @Override
1793      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1794        switch (hash) {
1795        case -1413853096: /*amount*/ return new String[] {"decimal"};
1796        case 3016401: /*base*/ return new String[] {"code"};
1797        default: return super.getTypesForProperty(hash, name);
1798        }
1799
1800      }
1801
1802      @Override
1803      public Base addChild(String name) throws FHIRException {
1804        if (name.equals("amount")) {
1805          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.amount");
1806        }
1807        else if (name.equals("base")) {
1808          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.base");
1809        }
1810        else
1811          return super.addChild(name);
1812      }
1813
1814      public PrismComponent copy() {
1815        PrismComponent dst = new PrismComponent();
1816        copyValues(dst);
1817        return dst;
1818      }
1819
1820      public void copyValues(PrismComponent dst) {
1821        super.copyValues(dst);
1822        dst.amount = amount == null ? null : amount.copy();
1823        dst.base = base == null ? null : base.copy();
1824      }
1825
1826      @Override
1827      public boolean equalsDeep(Base other_) {
1828        if (!super.equalsDeep(other_))
1829          return false;
1830        if (!(other_ instanceof PrismComponent))
1831          return false;
1832        PrismComponent o = (PrismComponent) other_;
1833        return compareDeep(amount, o.amount, true) && compareDeep(base, o.base, true);
1834      }
1835
1836      @Override
1837      public boolean equalsShallow(Base other_) {
1838        if (!super.equalsShallow(other_))
1839          return false;
1840        if (!(other_ instanceof PrismComponent))
1841          return false;
1842        PrismComponent o = (PrismComponent) other_;
1843        return compareValues(amount, o.amount, true) && compareValues(base, o.base, true);
1844      }
1845
1846      public boolean isEmpty() {
1847        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(amount, base);
1848      }
1849
1850  public String fhirType() {
1851    return "VisionPrescription.lensSpecification.prism";
1852
1853  }
1854
1855  }
1856
1857    /**
1858     * A unique identifier assigned to this vision prescription.
1859     */
1860    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1861    @Description(shortDefinition="Business Identifier for vision prescription", formalDefinition="A unique identifier assigned to this vision prescription." )
1862    protected List<Identifier> identifier;
1863
1864    /**
1865     * The status of the resource instance.
1866     */
1867    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
1868    @Description(shortDefinition="active | cancelled | draft | entered-in-error", formalDefinition="The status of the resource instance." )
1869    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/fm-status")
1870    protected Enumeration<VisionStatus> status;
1871
1872    /**
1873     * The date this resource was created.
1874     */
1875    @Child(name = "created", type = {DateTimeType.class}, order=2, min=1, max=1, modifier=false, summary=true)
1876    @Description(shortDefinition="Response creation date", formalDefinition="The date this resource was created." )
1877    protected DateTimeType created;
1878
1879    /**
1880     * A resource reference to the person to whom the vision prescription applies.
1881     */
1882    @Child(name = "patient", type = {Patient.class}, order=3, min=1, max=1, modifier=false, summary=true)
1883    @Description(shortDefinition="Who prescription is for", formalDefinition="A resource reference to the person to whom the vision prescription applies." )
1884    protected Reference patient;
1885
1886    /**
1887     * The actual object that is the target of the reference (A resource reference to the person to whom the vision prescription applies.)
1888     */
1889    protected Patient patientTarget;
1890
1891    /**
1892     * A reference to a resource that identifies the particular occurrence of contact between patient and health care provider during which the prescription was issued.
1893     */
1894    @Child(name = "encounter", type = {Encounter.class}, order=4, min=0, max=1, modifier=false, summary=false)
1895    @Description(shortDefinition="Created during encounter / admission / stay", formalDefinition="A reference to a resource that identifies the particular occurrence of contact between patient and health care provider during which the prescription was issued." )
1896    protected Reference encounter;
1897
1898    /**
1899     * The actual object that is the target of the reference (A reference to a resource that identifies the particular occurrence of contact between patient and health care provider during which the prescription was issued.)
1900     */
1901    protected Encounter encounterTarget;
1902
1903    /**
1904     * The date (and perhaps time) when the prescription was written.
1905     */
1906    @Child(name = "dateWritten", type = {DateTimeType.class}, order=5, min=1, max=1, modifier=false, summary=true)
1907    @Description(shortDefinition="When prescription was authorized", formalDefinition="The date (and perhaps time) when the prescription was written." )
1908    protected DateTimeType dateWritten;
1909
1910    /**
1911     * The healthcare professional responsible for authorizing the prescription.
1912     */
1913    @Child(name = "prescriber", type = {Practitioner.class, PractitionerRole.class}, order=6, min=1, max=1, modifier=false, summary=true)
1914    @Description(shortDefinition="Who authorized the vision prescription", formalDefinition="The healthcare professional responsible for authorizing the prescription." )
1915    protected Reference prescriber;
1916
1917    /**
1918     * The actual object that is the target of the reference (The healthcare professional responsible for authorizing the prescription.)
1919     */
1920    protected Resource prescriberTarget;
1921
1922    /**
1923     * Contain the details of  the individual lens specifications and serves as the authorization for the fullfillment by certified professionals.
1924     */
1925    @Child(name = "lensSpecification", type = {}, order=7, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1926    @Description(shortDefinition="Vision lens authorization", formalDefinition="Contain the details of  the individual lens specifications and serves as the authorization for the fullfillment by certified professionals." )
1927    protected List<VisionPrescriptionLensSpecificationComponent> lensSpecification;
1928
1929    private static final long serialVersionUID = 988021071L;
1930
1931  /**
1932   * Constructor
1933   */
1934    public VisionPrescription() {
1935      super();
1936    }
1937
1938  /**
1939   * Constructor
1940   */
1941    public VisionPrescription(Enumeration<VisionStatus> status, DateTimeType created, Reference patient, DateTimeType dateWritten, Reference prescriber) {
1942      super();
1943      this.status = status;
1944      this.created = created;
1945      this.patient = patient;
1946      this.dateWritten = dateWritten;
1947      this.prescriber = prescriber;
1948    }
1949
1950    /**
1951     * @return {@link #identifier} (A unique identifier assigned to this vision prescription.)
1952     */
1953    public List<Identifier> getIdentifier() { 
1954      if (this.identifier == null)
1955        this.identifier = new ArrayList<Identifier>();
1956      return this.identifier;
1957    }
1958
1959    /**
1960     * @return Returns a reference to <code>this</code> for easy method chaining
1961     */
1962    public VisionPrescription setIdentifier(List<Identifier> theIdentifier) { 
1963      this.identifier = theIdentifier;
1964      return this;
1965    }
1966
1967    public boolean hasIdentifier() { 
1968      if (this.identifier == null)
1969        return false;
1970      for (Identifier item : this.identifier)
1971        if (!item.isEmpty())
1972          return true;
1973      return false;
1974    }
1975
1976    public Identifier addIdentifier() { //3
1977      Identifier t = new Identifier();
1978      if (this.identifier == null)
1979        this.identifier = new ArrayList<Identifier>();
1980      this.identifier.add(t);
1981      return t;
1982    }
1983
1984    public VisionPrescription addIdentifier(Identifier t) { //3
1985      if (t == null)
1986        return this;
1987      if (this.identifier == null)
1988        this.identifier = new ArrayList<Identifier>();
1989      this.identifier.add(t);
1990      return this;
1991    }
1992
1993    /**
1994     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
1995     */
1996    public Identifier getIdentifierFirstRep() { 
1997      if (getIdentifier().isEmpty()) {
1998        addIdentifier();
1999      }
2000      return getIdentifier().get(0);
2001    }
2002
2003    /**
2004     * @return {@link #status} (The status of the resource instance.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2005     */
2006    public Enumeration<VisionStatus> getStatusElement() { 
2007      if (this.status == null)
2008        if (Configuration.errorOnAutoCreate())
2009          throw new Error("Attempt to auto-create VisionPrescription.status");
2010        else if (Configuration.doAutoCreate())
2011          this.status = new Enumeration<VisionStatus>(new VisionStatusEnumFactory()); // bb
2012      return this.status;
2013    }
2014
2015    public boolean hasStatusElement() { 
2016      return this.status != null && !this.status.isEmpty();
2017    }
2018
2019    public boolean hasStatus() { 
2020      return this.status != null && !this.status.isEmpty();
2021    }
2022
2023    /**
2024     * @param value {@link #status} (The status of the resource instance.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2025     */
2026    public VisionPrescription setStatusElement(Enumeration<VisionStatus> value) { 
2027      this.status = value;
2028      return this;
2029    }
2030
2031    /**
2032     * @return The status of the resource instance.
2033     */
2034    public VisionStatus getStatus() { 
2035      return this.status == null ? null : this.status.getValue();
2036    }
2037
2038    /**
2039     * @param value The status of the resource instance.
2040     */
2041    public VisionPrescription setStatus(VisionStatus value) { 
2042        if (this.status == null)
2043          this.status = new Enumeration<VisionStatus>(new VisionStatusEnumFactory());
2044        this.status.setValue(value);
2045      return this;
2046    }
2047
2048    /**
2049     * @return {@link #created} (The date this resource was created.). This is the underlying object with id, value and extensions. The accessor "getCreated" gives direct access to the value
2050     */
2051    public DateTimeType getCreatedElement() { 
2052      if (this.created == null)
2053        if (Configuration.errorOnAutoCreate())
2054          throw new Error("Attempt to auto-create VisionPrescription.created");
2055        else if (Configuration.doAutoCreate())
2056          this.created = new DateTimeType(); // bb
2057      return this.created;
2058    }
2059
2060    public boolean hasCreatedElement() { 
2061      return this.created != null && !this.created.isEmpty();
2062    }
2063
2064    public boolean hasCreated() { 
2065      return this.created != null && !this.created.isEmpty();
2066    }
2067
2068    /**
2069     * @param value {@link #created} (The date this resource was created.). This is the underlying object with id, value and extensions. The accessor "getCreated" gives direct access to the value
2070     */
2071    public VisionPrescription setCreatedElement(DateTimeType value) { 
2072      this.created = value;
2073      return this;
2074    }
2075
2076    /**
2077     * @return The date this resource was created.
2078     */
2079    public Date getCreated() { 
2080      return this.created == null ? null : this.created.getValue();
2081    }
2082
2083    /**
2084     * @param value The date this resource was created.
2085     */
2086    public VisionPrescription setCreated(Date value) { 
2087        if (this.created == null)
2088          this.created = new DateTimeType();
2089        this.created.setValue(value);
2090      return this;
2091    }
2092
2093    /**
2094     * @return {@link #patient} (A resource reference to the person to whom the vision prescription applies.)
2095     */
2096    public Reference getPatient() { 
2097      if (this.patient == null)
2098        if (Configuration.errorOnAutoCreate())
2099          throw new Error("Attempt to auto-create VisionPrescription.patient");
2100        else if (Configuration.doAutoCreate())
2101          this.patient = new Reference(); // cc
2102      return this.patient;
2103    }
2104
2105    public boolean hasPatient() { 
2106      return this.patient != null && !this.patient.isEmpty();
2107    }
2108
2109    /**
2110     * @param value {@link #patient} (A resource reference to the person to whom the vision prescription applies.)
2111     */
2112    public VisionPrescription setPatient(Reference value) { 
2113      this.patient = value;
2114      return this;
2115    }
2116
2117    /**
2118     * @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 resource reference to the person to whom the vision prescription applies.)
2119     */
2120    public Patient getPatientTarget() { 
2121      if (this.patientTarget == null)
2122        if (Configuration.errorOnAutoCreate())
2123          throw new Error("Attempt to auto-create VisionPrescription.patient");
2124        else if (Configuration.doAutoCreate())
2125          this.patientTarget = new Patient(); // aa
2126      return this.patientTarget;
2127    }
2128
2129    /**
2130     * @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 resource reference to the person to whom the vision prescription applies.)
2131     */
2132    public VisionPrescription setPatientTarget(Patient value) { 
2133      this.patientTarget = value;
2134      return this;
2135    }
2136
2137    /**
2138     * @return {@link #encounter} (A reference to a resource that identifies the particular occurrence of contact between patient and health care provider during which the prescription was issued.)
2139     */
2140    public Reference getEncounter() { 
2141      if (this.encounter == null)
2142        if (Configuration.errorOnAutoCreate())
2143          throw new Error("Attempt to auto-create VisionPrescription.encounter");
2144        else if (Configuration.doAutoCreate())
2145          this.encounter = new Reference(); // cc
2146      return this.encounter;
2147    }
2148
2149    public boolean hasEncounter() { 
2150      return this.encounter != null && !this.encounter.isEmpty();
2151    }
2152
2153    /**
2154     * @param value {@link #encounter} (A reference to a resource that identifies the particular occurrence of contact between patient and health care provider during which the prescription was issued.)
2155     */
2156    public VisionPrescription setEncounter(Reference value) { 
2157      this.encounter = value;
2158      return this;
2159    }
2160
2161    /**
2162     * @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 reference to a resource that identifies the particular occurrence of contact between patient and health care provider during which the prescription was issued.)
2163     */
2164    public Encounter getEncounterTarget() { 
2165      if (this.encounterTarget == null)
2166        if (Configuration.errorOnAutoCreate())
2167          throw new Error("Attempt to auto-create VisionPrescription.encounter");
2168        else if (Configuration.doAutoCreate())
2169          this.encounterTarget = new Encounter(); // aa
2170      return this.encounterTarget;
2171    }
2172
2173    /**
2174     * @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 reference to a resource that identifies the particular occurrence of contact between patient and health care provider during which the prescription was issued.)
2175     */
2176    public VisionPrescription setEncounterTarget(Encounter value) { 
2177      this.encounterTarget = value;
2178      return this;
2179    }
2180
2181    /**
2182     * @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
2183     */
2184    public DateTimeType getDateWrittenElement() { 
2185      if (this.dateWritten == null)
2186        if (Configuration.errorOnAutoCreate())
2187          throw new Error("Attempt to auto-create VisionPrescription.dateWritten");
2188        else if (Configuration.doAutoCreate())
2189          this.dateWritten = new DateTimeType(); // bb
2190      return this.dateWritten;
2191    }
2192
2193    public boolean hasDateWrittenElement() { 
2194      return this.dateWritten != null && !this.dateWritten.isEmpty();
2195    }
2196
2197    public boolean hasDateWritten() { 
2198      return this.dateWritten != null && !this.dateWritten.isEmpty();
2199    }
2200
2201    /**
2202     * @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
2203     */
2204    public VisionPrescription setDateWrittenElement(DateTimeType value) { 
2205      this.dateWritten = value;
2206      return this;
2207    }
2208
2209    /**
2210     * @return The date (and perhaps time) when the prescription was written.
2211     */
2212    public Date getDateWritten() { 
2213      return this.dateWritten == null ? null : this.dateWritten.getValue();
2214    }
2215
2216    /**
2217     * @param value The date (and perhaps time) when the prescription was written.
2218     */
2219    public VisionPrescription setDateWritten(Date value) { 
2220        if (this.dateWritten == null)
2221          this.dateWritten = new DateTimeType();
2222        this.dateWritten.setValue(value);
2223      return this;
2224    }
2225
2226    /**
2227     * @return {@link #prescriber} (The healthcare professional responsible for authorizing the prescription.)
2228     */
2229    public Reference getPrescriber() { 
2230      if (this.prescriber == null)
2231        if (Configuration.errorOnAutoCreate())
2232          throw new Error("Attempt to auto-create VisionPrescription.prescriber");
2233        else if (Configuration.doAutoCreate())
2234          this.prescriber = new Reference(); // cc
2235      return this.prescriber;
2236    }
2237
2238    public boolean hasPrescriber() { 
2239      return this.prescriber != null && !this.prescriber.isEmpty();
2240    }
2241
2242    /**
2243     * @param value {@link #prescriber} (The healthcare professional responsible for authorizing the prescription.)
2244     */
2245    public VisionPrescription setPrescriber(Reference value) { 
2246      this.prescriber = value;
2247      return this;
2248    }
2249
2250    /**
2251     * @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.)
2252     */
2253    public Resource getPrescriberTarget() { 
2254      return this.prescriberTarget;
2255    }
2256
2257    /**
2258     * @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.)
2259     */
2260    public VisionPrescription setPrescriberTarget(Resource value) { 
2261      this.prescriberTarget = value;
2262      return this;
2263    }
2264
2265    /**
2266     * @return {@link #lensSpecification} (Contain the details of  the individual lens specifications and serves as the authorization for the fullfillment by certified professionals.)
2267     */
2268    public List<VisionPrescriptionLensSpecificationComponent> getLensSpecification() { 
2269      if (this.lensSpecification == null)
2270        this.lensSpecification = new ArrayList<VisionPrescriptionLensSpecificationComponent>();
2271      return this.lensSpecification;
2272    }
2273
2274    /**
2275     * @return Returns a reference to <code>this</code> for easy method chaining
2276     */
2277    public VisionPrescription setLensSpecification(List<VisionPrescriptionLensSpecificationComponent> theLensSpecification) { 
2278      this.lensSpecification = theLensSpecification;
2279      return this;
2280    }
2281
2282    public boolean hasLensSpecification() { 
2283      if (this.lensSpecification == null)
2284        return false;
2285      for (VisionPrescriptionLensSpecificationComponent item : this.lensSpecification)
2286        if (!item.isEmpty())
2287          return true;
2288      return false;
2289    }
2290
2291    public VisionPrescriptionLensSpecificationComponent addLensSpecification() { //3
2292      VisionPrescriptionLensSpecificationComponent t = new VisionPrescriptionLensSpecificationComponent();
2293      if (this.lensSpecification == null)
2294        this.lensSpecification = new ArrayList<VisionPrescriptionLensSpecificationComponent>();
2295      this.lensSpecification.add(t);
2296      return t;
2297    }
2298
2299    public VisionPrescription addLensSpecification(VisionPrescriptionLensSpecificationComponent t) { //3
2300      if (t == null)
2301        return this;
2302      if (this.lensSpecification == null)
2303        this.lensSpecification = new ArrayList<VisionPrescriptionLensSpecificationComponent>();
2304      this.lensSpecification.add(t);
2305      return this;
2306    }
2307
2308    /**
2309     * @return The first repetition of repeating field {@link #lensSpecification}, creating it if it does not already exist
2310     */
2311    public VisionPrescriptionLensSpecificationComponent getLensSpecificationFirstRep() { 
2312      if (getLensSpecification().isEmpty()) {
2313        addLensSpecification();
2314      }
2315      return getLensSpecification().get(0);
2316    }
2317
2318      protected void listChildren(List<Property> children) {
2319        super.listChildren(children);
2320        children.add(new Property("identifier", "Identifier", "A unique identifier assigned to this vision prescription.", 0, java.lang.Integer.MAX_VALUE, identifier));
2321        children.add(new Property("status", "code", "The status of the resource instance.", 0, 1, status));
2322        children.add(new Property("created", "dateTime", "The date this resource was created.", 0, 1, created));
2323        children.add(new Property("patient", "Reference(Patient)", "A resource reference to the person to whom the vision prescription applies.", 0, 1, patient));
2324        children.add(new Property("encounter", "Reference(Encounter)", "A reference to a resource that identifies the particular occurrence of contact between patient and health care provider during which the prescription was issued.", 0, 1, encounter));
2325        children.add(new Property("dateWritten", "dateTime", "The date (and perhaps time) when the prescription was written.", 0, 1, dateWritten));
2326        children.add(new Property("prescriber", "Reference(Practitioner|PractitionerRole)", "The healthcare professional responsible for authorizing the prescription.", 0, 1, prescriber));
2327        children.add(new Property("lensSpecification", "", "Contain the details of  the individual lens specifications and serves as the authorization for the fullfillment by certified professionals.", 0, java.lang.Integer.MAX_VALUE, lensSpecification));
2328      }
2329
2330      @Override
2331      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2332        switch (_hash) {
2333        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "A unique identifier assigned to this vision prescription.", 0, java.lang.Integer.MAX_VALUE, identifier);
2334        case -892481550: /*status*/  return new Property("status", "code", "The status of the resource instance.", 0, 1, status);
2335        case 1028554472: /*created*/  return new Property("created", "dateTime", "The date this resource was created.", 0, 1, created);
2336        case -791418107: /*patient*/  return new Property("patient", "Reference(Patient)", "A resource reference to the person to whom the vision prescription applies.", 0, 1, patient);
2337        case 1524132147: /*encounter*/  return new Property("encounter", "Reference(Encounter)", "A reference to a resource that identifies the particular occurrence of contact between patient and health care provider during which the prescription was issued.", 0, 1, encounter);
2338        case -1496880759: /*dateWritten*/  return new Property("dateWritten", "dateTime", "The date (and perhaps time) when the prescription was written.", 0, 1, dateWritten);
2339        case 1430631077: /*prescriber*/  return new Property("prescriber", "Reference(Practitioner|PractitionerRole)", "The healthcare professional responsible for authorizing the prescription.", 0, 1, prescriber);
2340        case -1767318363: /*lensSpecification*/  return new Property("lensSpecification", "", "Contain the details of  the individual lens specifications and serves as the authorization for the fullfillment by certified professionals.", 0, java.lang.Integer.MAX_VALUE, lensSpecification);
2341        default: return super.getNamedProperty(_hash, _name, _checkValid);
2342        }
2343
2344      }
2345
2346      @Override
2347      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2348        switch (hash) {
2349        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2350        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<VisionStatus>
2351        case 1028554472: /*created*/ return this.created == null ? new Base[0] : new Base[] {this.created}; // DateTimeType
2352        case -791418107: /*patient*/ return this.patient == null ? new Base[0] : new Base[] {this.patient}; // Reference
2353        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : new Base[] {this.encounter}; // Reference
2354        case -1496880759: /*dateWritten*/ return this.dateWritten == null ? new Base[0] : new Base[] {this.dateWritten}; // DateTimeType
2355        case 1430631077: /*prescriber*/ return this.prescriber == null ? new Base[0] : new Base[] {this.prescriber}; // Reference
2356        case -1767318363: /*lensSpecification*/ return this.lensSpecification == null ? new Base[0] : this.lensSpecification.toArray(new Base[this.lensSpecification.size()]); // VisionPrescriptionLensSpecificationComponent
2357        default: return super.getProperty(hash, name, checkValid);
2358        }
2359
2360      }
2361
2362      @Override
2363      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2364        switch (hash) {
2365        case -1618432855: // identifier
2366          this.getIdentifier().add(castToIdentifier(value)); // Identifier
2367          return value;
2368        case -892481550: // status
2369          value = new VisionStatusEnumFactory().fromType(castToCode(value));
2370          this.status = (Enumeration) value; // Enumeration<VisionStatus>
2371          return value;
2372        case 1028554472: // created
2373          this.created = castToDateTime(value); // DateTimeType
2374          return value;
2375        case -791418107: // patient
2376          this.patient = castToReference(value); // Reference
2377          return value;
2378        case 1524132147: // encounter
2379          this.encounter = castToReference(value); // Reference
2380          return value;
2381        case -1496880759: // dateWritten
2382          this.dateWritten = castToDateTime(value); // DateTimeType
2383          return value;
2384        case 1430631077: // prescriber
2385          this.prescriber = castToReference(value); // Reference
2386          return value;
2387        case -1767318363: // lensSpecification
2388          this.getLensSpecification().add((VisionPrescriptionLensSpecificationComponent) value); // VisionPrescriptionLensSpecificationComponent
2389          return value;
2390        default: return super.setProperty(hash, name, value);
2391        }
2392
2393      }
2394
2395      @Override
2396      public Base setProperty(String name, Base value) throws FHIRException {
2397        if (name.equals("identifier")) {
2398          this.getIdentifier().add(castToIdentifier(value));
2399        } else if (name.equals("status")) {
2400          value = new VisionStatusEnumFactory().fromType(castToCode(value));
2401          this.status = (Enumeration) value; // Enumeration<VisionStatus>
2402        } else if (name.equals("created")) {
2403          this.created = castToDateTime(value); // DateTimeType
2404        } else if (name.equals("patient")) {
2405          this.patient = castToReference(value); // Reference
2406        } else if (name.equals("encounter")) {
2407          this.encounter = castToReference(value); // Reference
2408        } else if (name.equals("dateWritten")) {
2409          this.dateWritten = castToDateTime(value); // DateTimeType
2410        } else if (name.equals("prescriber")) {
2411          this.prescriber = castToReference(value); // Reference
2412        } else if (name.equals("lensSpecification")) {
2413          this.getLensSpecification().add((VisionPrescriptionLensSpecificationComponent) value);
2414        } else
2415          return super.setProperty(name, value);
2416        return value;
2417      }
2418
2419      @Override
2420      public Base makeProperty(int hash, String name) throws FHIRException {
2421        switch (hash) {
2422        case -1618432855:  return addIdentifier(); 
2423        case -892481550:  return getStatusElement();
2424        case 1028554472:  return getCreatedElement();
2425        case -791418107:  return getPatient(); 
2426        case 1524132147:  return getEncounter(); 
2427        case -1496880759:  return getDateWrittenElement();
2428        case 1430631077:  return getPrescriber(); 
2429        case -1767318363:  return addLensSpecification(); 
2430        default: return super.makeProperty(hash, name);
2431        }
2432
2433      }
2434
2435      @Override
2436      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2437        switch (hash) {
2438        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2439        case -892481550: /*status*/ return new String[] {"code"};
2440        case 1028554472: /*created*/ return new String[] {"dateTime"};
2441        case -791418107: /*patient*/ return new String[] {"Reference"};
2442        case 1524132147: /*encounter*/ return new String[] {"Reference"};
2443        case -1496880759: /*dateWritten*/ return new String[] {"dateTime"};
2444        case 1430631077: /*prescriber*/ return new String[] {"Reference"};
2445        case -1767318363: /*lensSpecification*/ return new String[] {};
2446        default: return super.getTypesForProperty(hash, name);
2447        }
2448
2449      }
2450
2451      @Override
2452      public Base addChild(String name) throws FHIRException {
2453        if (name.equals("identifier")) {
2454          return addIdentifier();
2455        }
2456        else if (name.equals("status")) {
2457          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.status");
2458        }
2459        else if (name.equals("created")) {
2460          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.created");
2461        }
2462        else if (name.equals("patient")) {
2463          this.patient = new Reference();
2464          return this.patient;
2465        }
2466        else if (name.equals("encounter")) {
2467          this.encounter = new Reference();
2468          return this.encounter;
2469        }
2470        else if (name.equals("dateWritten")) {
2471          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.dateWritten");
2472        }
2473        else if (name.equals("prescriber")) {
2474          this.prescriber = new Reference();
2475          return this.prescriber;
2476        }
2477        else if (name.equals("lensSpecification")) {
2478          return addLensSpecification();
2479        }
2480        else
2481          return super.addChild(name);
2482      }
2483
2484  public String fhirType() {
2485    return "VisionPrescription";
2486
2487  }
2488
2489      public VisionPrescription copy() {
2490        VisionPrescription dst = new VisionPrescription();
2491        copyValues(dst);
2492        return dst;
2493      }
2494
2495      public void copyValues(VisionPrescription dst) {
2496        super.copyValues(dst);
2497        if (identifier != null) {
2498          dst.identifier = new ArrayList<Identifier>();
2499          for (Identifier i : identifier)
2500            dst.identifier.add(i.copy());
2501        };
2502        dst.status = status == null ? null : status.copy();
2503        dst.created = created == null ? null : created.copy();
2504        dst.patient = patient == null ? null : patient.copy();
2505        dst.encounter = encounter == null ? null : encounter.copy();
2506        dst.dateWritten = dateWritten == null ? null : dateWritten.copy();
2507        dst.prescriber = prescriber == null ? null : prescriber.copy();
2508        if (lensSpecification != null) {
2509          dst.lensSpecification = new ArrayList<VisionPrescriptionLensSpecificationComponent>();
2510          for (VisionPrescriptionLensSpecificationComponent i : lensSpecification)
2511            dst.lensSpecification.add(i.copy());
2512        };
2513      }
2514
2515      protected VisionPrescription typedCopy() {
2516        return copy();
2517      }
2518
2519      @Override
2520      public boolean equalsDeep(Base other_) {
2521        if (!super.equalsDeep(other_))
2522          return false;
2523        if (!(other_ instanceof VisionPrescription))
2524          return false;
2525        VisionPrescription o = (VisionPrescription) other_;
2526        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(created, o.created, true)
2527           && compareDeep(patient, o.patient, true) && compareDeep(encounter, o.encounter, true) && compareDeep(dateWritten, o.dateWritten, true)
2528           && compareDeep(prescriber, o.prescriber, true) && compareDeep(lensSpecification, o.lensSpecification, true)
2529          ;
2530      }
2531
2532      @Override
2533      public boolean equalsShallow(Base other_) {
2534        if (!super.equalsShallow(other_))
2535          return false;
2536        if (!(other_ instanceof VisionPrescription))
2537          return false;
2538        VisionPrescription o = (VisionPrescription) other_;
2539        return compareValues(status, o.status, true) && compareValues(created, o.created, true) && compareValues(dateWritten, o.dateWritten, true)
2540          ;
2541      }
2542
2543      public boolean isEmpty() {
2544        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, created
2545          , patient, encounter, dateWritten, prescriber, lensSpecification);
2546      }
2547
2548  @Override
2549  public ResourceType getResourceType() {
2550    return ResourceType.VisionPrescription;
2551   }
2552
2553 /**
2554   * Search parameter: <b>prescriber</b>
2555   * <p>
2556   * Description: <b>Who authorized the vision prescription</b><br>
2557   * Type: <b>reference</b><br>
2558   * Path: <b>VisionPrescription.prescriber</b><br>
2559   * </p>
2560   */
2561  @SearchParamDefinition(name="prescriber", path="VisionPrescription.prescriber", description="Who authorized the vision prescription", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={Practitioner.class, PractitionerRole.class } )
2562  public static final String SP_PRESCRIBER = "prescriber";
2563 /**
2564   * <b>Fluent Client</b> search parameter constant for <b>prescriber</b>
2565   * <p>
2566   * Description: <b>Who authorized the vision prescription</b><br>
2567   * Type: <b>reference</b><br>
2568   * Path: <b>VisionPrescription.prescriber</b><br>
2569   * </p>
2570   */
2571  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PRESCRIBER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PRESCRIBER);
2572
2573/**
2574   * Constant for fluent queries to be used to add include statements. Specifies
2575   * the path value of "<b>VisionPrescription:prescriber</b>".
2576   */
2577  public static final ca.uhn.fhir.model.api.Include INCLUDE_PRESCRIBER = new ca.uhn.fhir.model.api.Include("VisionPrescription:prescriber").toLocked();
2578
2579 /**
2580   * Search parameter: <b>identifier</b>
2581   * <p>
2582   * Description: <b>Return prescriptions with this external identifier</b><br>
2583   * Type: <b>token</b><br>
2584   * Path: <b>VisionPrescription.identifier</b><br>
2585   * </p>
2586   */
2587  @SearchParamDefinition(name="identifier", path="VisionPrescription.identifier", description="Return prescriptions with this external identifier", type="token" )
2588  public static final String SP_IDENTIFIER = "identifier";
2589 /**
2590   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2591   * <p>
2592   * Description: <b>Return prescriptions with this external identifier</b><br>
2593   * Type: <b>token</b><br>
2594   * Path: <b>VisionPrescription.identifier</b><br>
2595   * </p>
2596   */
2597  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2598
2599 /**
2600   * Search parameter: <b>patient</b>
2601   * <p>
2602   * Description: <b>The identity of a patient to list dispenses for</b><br>
2603   * Type: <b>reference</b><br>
2604   * Path: <b>VisionPrescription.patient</b><br>
2605   * </p>
2606   */
2607  @SearchParamDefinition(name="patient", path="VisionPrescription.patient", description="The identity of a patient to list dispenses for", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Patient.class } )
2608  public static final String SP_PATIENT = "patient";
2609 /**
2610   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2611   * <p>
2612   * Description: <b>The identity of a patient to list dispenses for</b><br>
2613   * Type: <b>reference</b><br>
2614   * Path: <b>VisionPrescription.patient</b><br>
2615   * </p>
2616   */
2617  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
2618
2619/**
2620   * Constant for fluent queries to be used to add include statements. Specifies
2621   * the path value of "<b>VisionPrescription:patient</b>".
2622   */
2623  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("VisionPrescription:patient").toLocked();
2624
2625 /**
2626   * Search parameter: <b>datewritten</b>
2627   * <p>
2628   * Description: <b>Return prescriptions written on this date</b><br>
2629   * Type: <b>date</b><br>
2630   * Path: <b>VisionPrescription.dateWritten</b><br>
2631   * </p>
2632   */
2633  @SearchParamDefinition(name="datewritten", path="VisionPrescription.dateWritten", description="Return prescriptions written on this date", type="date" )
2634  public static final String SP_DATEWRITTEN = "datewritten";
2635 /**
2636   * <b>Fluent Client</b> search parameter constant for <b>datewritten</b>
2637   * <p>
2638   * Description: <b>Return prescriptions written on this date</b><br>
2639   * Type: <b>date</b><br>
2640   * Path: <b>VisionPrescription.dateWritten</b><br>
2641   * </p>
2642   */
2643  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATEWRITTEN = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATEWRITTEN);
2644
2645 /**
2646   * Search parameter: <b>encounter</b>
2647   * <p>
2648   * Description: <b>Return prescriptions with this encounter identifier</b><br>
2649   * Type: <b>reference</b><br>
2650   * Path: <b>VisionPrescription.encounter</b><br>
2651   * </p>
2652   */
2653  @SearchParamDefinition(name="encounter", path="VisionPrescription.encounter", description="Return prescriptions with this encounter identifier", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Encounter") }, target={Encounter.class } )
2654  public static final String SP_ENCOUNTER = "encounter";
2655 /**
2656   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
2657   * <p>
2658   * Description: <b>Return prescriptions with this encounter identifier</b><br>
2659   * Type: <b>reference</b><br>
2660   * Path: <b>VisionPrescription.encounter</b><br>
2661   * </p>
2662   */
2663  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
2664
2665/**
2666   * Constant for fluent queries to be used to add include statements. Specifies
2667   * the path value of "<b>VisionPrescription:encounter</b>".
2668   */
2669  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("VisionPrescription:encounter").toLocked();
2670
2671 /**
2672   * Search parameter: <b>status</b>
2673   * <p>
2674   * Description: <b>The status of the vision prescription</b><br>
2675   * Type: <b>token</b><br>
2676   * Path: <b>VisionPrescription.status</b><br>
2677   * </p>
2678   */
2679  @SearchParamDefinition(name="status", path="VisionPrescription.status", description="The status of the vision prescription", type="token" )
2680  public static final String SP_STATUS = "status";
2681 /**
2682   * <b>Fluent Client</b> search parameter constant for <b>status</b>
2683   * <p>
2684   * Description: <b>The status of the vision prescription</b><br>
2685   * Type: <b>token</b><br>
2686   * Path: <b>VisionPrescription.status</b><br>
2687   * </p>
2688   */
2689  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
2690
2691
2692}