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