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