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