001package org.hl7.fhir.dstu3.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 Mon, Apr 17, 2017 17:38-0400 for FHIR v3.0.1
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/Profile/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 diopters (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 diopters (0.25 units)." )
415        protected DecimalType sphere;
416
417        /**
418         * Power adjustment for astigmatism measured in diopters (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 diopters (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         * Amount of prism to compensate for eye alignment in fractional units.
433         */
434        @Child(name = "prism", type = {DecimalType.class}, order=6, min=0, max=1, modifier=false, summary=false)
435        @Description(shortDefinition="Lens prism", formalDefinition="Amount of prism to compensate for eye alignment in fractional units." )
436        protected DecimalType prism;
437
438        /**
439         * The relative base, or reference lens edge, for the prism.
440         */
441        @Child(name = "base", type = {CodeType.class}, order=7, min=0, max=1, modifier=false, summary=false)
442        @Description(shortDefinition="up | down | in | out", formalDefinition="The relative base, or reference lens edge, for the prism." )
443        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/vision-base-codes")
444        protected Enumeration<VisionBase> base;
445
446        /**
447         * Power adjustment for multifocal lenses measured in diopters (0.25 units).
448         */
449        @Child(name = "add", type = {DecimalType.class}, order=8, min=0, max=1, modifier=false, summary=false)
450        @Description(shortDefinition="Lens add", formalDefinition="Power adjustment for multifocal lenses measured in diopters (0.25 units)." )
451        protected DecimalType add;
452
453        /**
454         * Contact lens power measured in diopters (0.25 units).
455         */
456        @Child(name = "power", type = {DecimalType.class}, order=9, min=0, max=1, modifier=false, summary=false)
457        @Description(shortDefinition="Contact lens power", formalDefinition="Contact lens power measured in diopters (0.25 units)." )
458        protected DecimalType power;
459
460        /**
461         * Back curvature measured in millimeters.
462         */
463        @Child(name = "backCurve", type = {DecimalType.class}, order=10, min=0, max=1, modifier=false, summary=false)
464        @Description(shortDefinition="Contact lens back curvature", formalDefinition="Back curvature measured in millimeters." )
465        protected DecimalType backCurve;
466
467        /**
468         * Contact lens diameter measured in millimeters.
469         */
470        @Child(name = "diameter", type = {DecimalType.class}, order=11, min=0, max=1, modifier=false, summary=false)
471        @Description(shortDefinition="Contact lens diameter", formalDefinition="Contact lens diameter measured in millimeters." )
472        protected DecimalType diameter;
473
474        /**
475         * The recommended maximum wear period for the lens.
476         */
477        @Child(name = "duration", type = {SimpleQuantity.class}, order=12, min=0, max=1, modifier=false, summary=false)
478        @Description(shortDefinition="Lens wear duration", formalDefinition="The recommended maximum wear period for the lens." )
479        protected SimpleQuantity duration;
480
481        /**
482         * Special color or pattern.
483         */
484        @Child(name = "color", type = {StringType.class}, order=13, min=0, max=1, modifier=false, summary=false)
485        @Description(shortDefinition="Color required", formalDefinition="Special color or pattern." )
486        protected StringType color;
487
488        /**
489         * Brand recommendations or restrictions.
490         */
491        @Child(name = "brand", type = {StringType.class}, order=14, min=0, max=1, modifier=false, summary=false)
492        @Description(shortDefinition="Brand required", formalDefinition="Brand recommendations or restrictions." )
493        protected StringType brand;
494
495        /**
496         * Notes for special requirements such as coatings and lens materials.
497         */
498        @Child(name = "note", type = {Annotation.class}, order=15, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
499        @Description(shortDefinition="Notes for coatings", formalDefinition="Notes for special requirements such as coatings and lens materials." )
500        protected List<Annotation> note;
501
502        private static final long serialVersionUID = 400998008L;
503
504    /**
505     * Constructor
506     */
507      public VisionPrescriptionDispenseComponent() {
508        super();
509      }
510
511        /**
512         * @return {@link #product} (Identifies the type of vision correction product which is required for the patient.)
513         */
514        public CodeableConcept getProduct() { 
515          if (this.product == null)
516            if (Configuration.errorOnAutoCreate())
517              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.product");
518            else if (Configuration.doAutoCreate())
519              this.product = new CodeableConcept(); // cc
520          return this.product;
521        }
522
523        public boolean hasProduct() { 
524          return this.product != null && !this.product.isEmpty();
525        }
526
527        /**
528         * @param value {@link #product} (Identifies the type of vision correction product which is required for the patient.)
529         */
530        public VisionPrescriptionDispenseComponent setProduct(CodeableConcept value) { 
531          this.product = value;
532          return this;
533        }
534
535        /**
536         * @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
537         */
538        public Enumeration<VisionEyes> getEyeElement() { 
539          if (this.eye == null)
540            if (Configuration.errorOnAutoCreate())
541              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.eye");
542            else if (Configuration.doAutoCreate())
543              this.eye = new Enumeration<VisionEyes>(new VisionEyesEnumFactory()); // bb
544          return this.eye;
545        }
546
547        public boolean hasEyeElement() { 
548          return this.eye != null && !this.eye.isEmpty();
549        }
550
551        public boolean hasEye() { 
552          return this.eye != null && !this.eye.isEmpty();
553        }
554
555        /**
556         * @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
557         */
558        public VisionPrescriptionDispenseComponent setEyeElement(Enumeration<VisionEyes> value) { 
559          this.eye = value;
560          return this;
561        }
562
563        /**
564         * @return The eye for which the lens applies.
565         */
566        public VisionEyes getEye() { 
567          return this.eye == null ? null : this.eye.getValue();
568        }
569
570        /**
571         * @param value The eye for which the lens applies.
572         */
573        public VisionPrescriptionDispenseComponent setEye(VisionEyes value) { 
574          if (value == null)
575            this.eye = null;
576          else {
577            if (this.eye == null)
578              this.eye = new Enumeration<VisionEyes>(new VisionEyesEnumFactory());
579            this.eye.setValue(value);
580          }
581          return this;
582        }
583
584        /**
585         * @return {@link #sphere} (Lens power measured in diopters (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getSphere" gives direct access to the value
586         */
587        public DecimalType getSphereElement() { 
588          if (this.sphere == null)
589            if (Configuration.errorOnAutoCreate())
590              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.sphere");
591            else if (Configuration.doAutoCreate())
592              this.sphere = new DecimalType(); // bb
593          return this.sphere;
594        }
595
596        public boolean hasSphereElement() { 
597          return this.sphere != null && !this.sphere.isEmpty();
598        }
599
600        public boolean hasSphere() { 
601          return this.sphere != null && !this.sphere.isEmpty();
602        }
603
604        /**
605         * @param value {@link #sphere} (Lens power measured in diopters (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getSphere" gives direct access to the value
606         */
607        public VisionPrescriptionDispenseComponent setSphereElement(DecimalType value) { 
608          this.sphere = value;
609          return this;
610        }
611
612        /**
613         * @return Lens power measured in diopters (0.25 units).
614         */
615        public BigDecimal getSphere() { 
616          return this.sphere == null ? null : this.sphere.getValue();
617        }
618
619        /**
620         * @param value Lens power measured in diopters (0.25 units).
621         */
622        public VisionPrescriptionDispenseComponent setSphere(BigDecimal value) { 
623          if (value == null)
624            this.sphere = null;
625          else {
626            if (this.sphere == null)
627              this.sphere = new DecimalType();
628            this.sphere.setValue(value);
629          }
630          return this;
631        }
632
633        /**
634         * @param value Lens power measured in diopters (0.25 units).
635         */
636        public VisionPrescriptionDispenseComponent setSphere(long value) { 
637              this.sphere = new DecimalType();
638            this.sphere.setValue(value);
639          return this;
640        }
641
642        /**
643         * @param value Lens power measured in diopters (0.25 units).
644         */
645        public VisionPrescriptionDispenseComponent setSphere(double value) { 
646              this.sphere = new DecimalType();
647            this.sphere.setValue(value);
648          return this;
649        }
650
651        /**
652         * @return {@link #cylinder} (Power adjustment for astigmatism measured in diopters (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getCylinder" gives direct access to the value
653         */
654        public DecimalType getCylinderElement() { 
655          if (this.cylinder == null)
656            if (Configuration.errorOnAutoCreate())
657              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.cylinder");
658            else if (Configuration.doAutoCreate())
659              this.cylinder = new DecimalType(); // bb
660          return this.cylinder;
661        }
662
663        public boolean hasCylinderElement() { 
664          return this.cylinder != null && !this.cylinder.isEmpty();
665        }
666
667        public boolean hasCylinder() { 
668          return this.cylinder != null && !this.cylinder.isEmpty();
669        }
670
671        /**
672         * @param value {@link #cylinder} (Power adjustment for astigmatism measured in diopters (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getCylinder" gives direct access to the value
673         */
674        public VisionPrescriptionDispenseComponent setCylinderElement(DecimalType value) { 
675          this.cylinder = value;
676          return this;
677        }
678
679        /**
680         * @return Power adjustment for astigmatism measured in diopters (0.25 units).
681         */
682        public BigDecimal getCylinder() { 
683          return this.cylinder == null ? null : this.cylinder.getValue();
684        }
685
686        /**
687         * @param value Power adjustment for astigmatism measured in diopters (0.25 units).
688         */
689        public VisionPrescriptionDispenseComponent setCylinder(BigDecimal value) { 
690          if (value == null)
691            this.cylinder = null;
692          else {
693            if (this.cylinder == null)
694              this.cylinder = new DecimalType();
695            this.cylinder.setValue(value);
696          }
697          return this;
698        }
699
700        /**
701         * @param value Power adjustment for astigmatism measured in diopters (0.25 units).
702         */
703        public VisionPrescriptionDispenseComponent setCylinder(long value) { 
704              this.cylinder = new DecimalType();
705            this.cylinder.setValue(value);
706          return this;
707        }
708
709        /**
710         * @param value Power adjustment for astigmatism measured in diopters (0.25 units).
711         */
712        public VisionPrescriptionDispenseComponent setCylinder(double value) { 
713              this.cylinder = new DecimalType();
714            this.cylinder.setValue(value);
715          return this;
716        }
717
718        /**
719         * @return {@link #axis} (Adjustment for astigmatism measured in integer degrees.). This is the underlying object with id, value and extensions. The accessor "getAxis" gives direct access to the value
720         */
721        public IntegerType getAxisElement() { 
722          if (this.axis == null)
723            if (Configuration.errorOnAutoCreate())
724              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.axis");
725            else if (Configuration.doAutoCreate())
726              this.axis = new IntegerType(); // bb
727          return this.axis;
728        }
729
730        public boolean hasAxisElement() { 
731          return this.axis != null && !this.axis.isEmpty();
732        }
733
734        public boolean hasAxis() { 
735          return this.axis != null && !this.axis.isEmpty();
736        }
737
738        /**
739         * @param value {@link #axis} (Adjustment for astigmatism measured in integer degrees.). This is the underlying object with id, value and extensions. The accessor "getAxis" gives direct access to the value
740         */
741        public VisionPrescriptionDispenseComponent setAxisElement(IntegerType value) { 
742          this.axis = value;
743          return this;
744        }
745
746        /**
747         * @return Adjustment for astigmatism measured in integer degrees.
748         */
749        public int getAxis() { 
750          return this.axis == null || this.axis.isEmpty() ? 0 : this.axis.getValue();
751        }
752
753        /**
754         * @param value Adjustment for astigmatism measured in integer degrees.
755         */
756        public VisionPrescriptionDispenseComponent setAxis(int value) { 
757            if (this.axis == null)
758              this.axis = new IntegerType();
759            this.axis.setValue(value);
760          return this;
761        }
762
763        /**
764         * @return {@link #prism} (Amount of prism to compensate for eye alignment in fractional units.). This is the underlying object with id, value and extensions. The accessor "getPrism" gives direct access to the value
765         */
766        public DecimalType getPrismElement() { 
767          if (this.prism == null)
768            if (Configuration.errorOnAutoCreate())
769              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.prism");
770            else if (Configuration.doAutoCreate())
771              this.prism = new DecimalType(); // bb
772          return this.prism;
773        }
774
775        public boolean hasPrismElement() { 
776          return this.prism != null && !this.prism.isEmpty();
777        }
778
779        public boolean hasPrism() { 
780          return this.prism != null && !this.prism.isEmpty();
781        }
782
783        /**
784         * @param value {@link #prism} (Amount of prism to compensate for eye alignment in fractional units.). This is the underlying object with id, value and extensions. The accessor "getPrism" gives direct access to the value
785         */
786        public VisionPrescriptionDispenseComponent setPrismElement(DecimalType value) { 
787          this.prism = value;
788          return this;
789        }
790
791        /**
792         * @return Amount of prism to compensate for eye alignment in fractional units.
793         */
794        public BigDecimal getPrism() { 
795          return this.prism == null ? null : this.prism.getValue();
796        }
797
798        /**
799         * @param value Amount of prism to compensate for eye alignment in fractional units.
800         */
801        public VisionPrescriptionDispenseComponent setPrism(BigDecimal value) { 
802          if (value == null)
803            this.prism = null;
804          else {
805            if (this.prism == null)
806              this.prism = new DecimalType();
807            this.prism.setValue(value);
808          }
809          return this;
810        }
811
812        /**
813         * @param value Amount of prism to compensate for eye alignment in fractional units.
814         */
815        public VisionPrescriptionDispenseComponent setPrism(long value) { 
816              this.prism = new DecimalType();
817            this.prism.setValue(value);
818          return this;
819        }
820
821        /**
822         * @param value Amount of prism to compensate for eye alignment in fractional units.
823         */
824        public VisionPrescriptionDispenseComponent setPrism(double value) { 
825              this.prism = new DecimalType();
826            this.prism.setValue(value);
827          return this;
828        }
829
830        /**
831         * @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
832         */
833        public Enumeration<VisionBase> getBaseElement() { 
834          if (this.base == null)
835            if (Configuration.errorOnAutoCreate())
836              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.base");
837            else if (Configuration.doAutoCreate())
838              this.base = new Enumeration<VisionBase>(new VisionBaseEnumFactory()); // bb
839          return this.base;
840        }
841
842        public boolean hasBaseElement() { 
843          return this.base != null && !this.base.isEmpty();
844        }
845
846        public boolean hasBase() { 
847          return this.base != null && !this.base.isEmpty();
848        }
849
850        /**
851         * @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
852         */
853        public VisionPrescriptionDispenseComponent setBaseElement(Enumeration<VisionBase> value) { 
854          this.base = value;
855          return this;
856        }
857
858        /**
859         * @return The relative base, or reference lens edge, for the prism.
860         */
861        public VisionBase getBase() { 
862          return this.base == null ? null : this.base.getValue();
863        }
864
865        /**
866         * @param value The relative base, or reference lens edge, for the prism.
867         */
868        public VisionPrescriptionDispenseComponent setBase(VisionBase value) { 
869          if (value == null)
870            this.base = null;
871          else {
872            if (this.base == null)
873              this.base = new Enumeration<VisionBase>(new VisionBaseEnumFactory());
874            this.base.setValue(value);
875          }
876          return this;
877        }
878
879        /**
880         * @return {@link #add} (Power adjustment for multifocal lenses measured in diopters (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getAdd" gives direct access to the value
881         */
882        public DecimalType getAddElement() { 
883          if (this.add == null)
884            if (Configuration.errorOnAutoCreate())
885              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.add");
886            else if (Configuration.doAutoCreate())
887              this.add = new DecimalType(); // bb
888          return this.add;
889        }
890
891        public boolean hasAddElement() { 
892          return this.add != null && !this.add.isEmpty();
893        }
894
895        public boolean hasAdd() { 
896          return this.add != null && !this.add.isEmpty();
897        }
898
899        /**
900         * @param value {@link #add} (Power adjustment for multifocal lenses measured in diopters (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getAdd" gives direct access to the value
901         */
902        public VisionPrescriptionDispenseComponent setAddElement(DecimalType value) { 
903          this.add = value;
904          return this;
905        }
906
907        /**
908         * @return Power adjustment for multifocal lenses measured in diopters (0.25 units).
909         */
910        public BigDecimal getAdd() { 
911          return this.add == null ? null : this.add.getValue();
912        }
913
914        /**
915         * @param value Power adjustment for multifocal lenses measured in diopters (0.25 units).
916         */
917        public VisionPrescriptionDispenseComponent setAdd(BigDecimal value) { 
918          if (value == null)
919            this.add = null;
920          else {
921            if (this.add == null)
922              this.add = new DecimalType();
923            this.add.setValue(value);
924          }
925          return this;
926        }
927
928        /**
929         * @param value Power adjustment for multifocal lenses measured in diopters (0.25 units).
930         */
931        public VisionPrescriptionDispenseComponent setAdd(long value) { 
932              this.add = new DecimalType();
933            this.add.setValue(value);
934          return this;
935        }
936
937        /**
938         * @param value Power adjustment for multifocal lenses measured in diopters (0.25 units).
939         */
940        public VisionPrescriptionDispenseComponent setAdd(double value) { 
941              this.add = new DecimalType();
942            this.add.setValue(value);
943          return this;
944        }
945
946        /**
947         * @return {@link #power} (Contact lens power measured in diopters (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getPower" gives direct access to the value
948         */
949        public DecimalType getPowerElement() { 
950          if (this.power == null)
951            if (Configuration.errorOnAutoCreate())
952              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.power");
953            else if (Configuration.doAutoCreate())
954              this.power = new DecimalType(); // bb
955          return this.power;
956        }
957
958        public boolean hasPowerElement() { 
959          return this.power != null && !this.power.isEmpty();
960        }
961
962        public boolean hasPower() { 
963          return this.power != null && !this.power.isEmpty();
964        }
965
966        /**
967         * @param value {@link #power} (Contact lens power measured in diopters (0.25 units).). This is the underlying object with id, value and extensions. The accessor "getPower" gives direct access to the value
968         */
969        public VisionPrescriptionDispenseComponent setPowerElement(DecimalType value) { 
970          this.power = value;
971          return this;
972        }
973
974        /**
975         * @return Contact lens power measured in diopters (0.25 units).
976         */
977        public BigDecimal getPower() { 
978          return this.power == null ? null : this.power.getValue();
979        }
980
981        /**
982         * @param value Contact lens power measured in diopters (0.25 units).
983         */
984        public VisionPrescriptionDispenseComponent setPower(BigDecimal value) { 
985          if (value == null)
986            this.power = null;
987          else {
988            if (this.power == null)
989              this.power = new DecimalType();
990            this.power.setValue(value);
991          }
992          return this;
993        }
994
995        /**
996         * @param value Contact lens power measured in diopters (0.25 units).
997         */
998        public VisionPrescriptionDispenseComponent setPower(long value) { 
999              this.power = new DecimalType();
1000            this.power.setValue(value);
1001          return this;
1002        }
1003
1004        /**
1005         * @param value Contact lens power measured in diopters (0.25 units).
1006         */
1007        public VisionPrescriptionDispenseComponent setPower(double value) { 
1008              this.power = new DecimalType();
1009            this.power.setValue(value);
1010          return this;
1011        }
1012
1013        /**
1014         * @return {@link #backCurve} (Back curvature measured in millimeters.). This is the underlying object with id, value and extensions. The accessor "getBackCurve" gives direct access to the value
1015         */
1016        public DecimalType getBackCurveElement() { 
1017          if (this.backCurve == null)
1018            if (Configuration.errorOnAutoCreate())
1019              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.backCurve");
1020            else if (Configuration.doAutoCreate())
1021              this.backCurve = new DecimalType(); // bb
1022          return this.backCurve;
1023        }
1024
1025        public boolean hasBackCurveElement() { 
1026          return this.backCurve != null && !this.backCurve.isEmpty();
1027        }
1028
1029        public boolean hasBackCurve() { 
1030          return this.backCurve != null && !this.backCurve.isEmpty();
1031        }
1032
1033        /**
1034         * @param value {@link #backCurve} (Back curvature measured in millimeters.). This is the underlying object with id, value and extensions. The accessor "getBackCurve" gives direct access to the value
1035         */
1036        public VisionPrescriptionDispenseComponent setBackCurveElement(DecimalType value) { 
1037          this.backCurve = value;
1038          return this;
1039        }
1040
1041        /**
1042         * @return Back curvature measured in millimeters.
1043         */
1044        public BigDecimal getBackCurve() { 
1045          return this.backCurve == null ? null : this.backCurve.getValue();
1046        }
1047
1048        /**
1049         * @param value Back curvature measured in millimeters.
1050         */
1051        public VisionPrescriptionDispenseComponent setBackCurve(BigDecimal value) { 
1052          if (value == null)
1053            this.backCurve = null;
1054          else {
1055            if (this.backCurve == null)
1056              this.backCurve = new DecimalType();
1057            this.backCurve.setValue(value);
1058          }
1059          return this;
1060        }
1061
1062        /**
1063         * @param value Back curvature measured in millimeters.
1064         */
1065        public VisionPrescriptionDispenseComponent setBackCurve(long value) { 
1066              this.backCurve = new DecimalType();
1067            this.backCurve.setValue(value);
1068          return this;
1069        }
1070
1071        /**
1072         * @param value Back curvature measured in millimeters.
1073         */
1074        public VisionPrescriptionDispenseComponent setBackCurve(double value) { 
1075              this.backCurve = new DecimalType();
1076            this.backCurve.setValue(value);
1077          return this;
1078        }
1079
1080        /**
1081         * @return {@link #diameter} (Contact lens diameter measured in millimeters.). This is the underlying object with id, value and extensions. The accessor "getDiameter" gives direct access to the value
1082         */
1083        public DecimalType getDiameterElement() { 
1084          if (this.diameter == null)
1085            if (Configuration.errorOnAutoCreate())
1086              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.diameter");
1087            else if (Configuration.doAutoCreate())
1088              this.diameter = new DecimalType(); // bb
1089          return this.diameter;
1090        }
1091
1092        public boolean hasDiameterElement() { 
1093          return this.diameter != null && !this.diameter.isEmpty();
1094        }
1095
1096        public boolean hasDiameter() { 
1097          return this.diameter != null && !this.diameter.isEmpty();
1098        }
1099
1100        /**
1101         * @param value {@link #diameter} (Contact lens diameter measured in millimeters.). This is the underlying object with id, value and extensions. The accessor "getDiameter" gives direct access to the value
1102         */
1103        public VisionPrescriptionDispenseComponent setDiameterElement(DecimalType value) { 
1104          this.diameter = value;
1105          return this;
1106        }
1107
1108        /**
1109         * @return Contact lens diameter measured in millimeters.
1110         */
1111        public BigDecimal getDiameter() { 
1112          return this.diameter == null ? null : this.diameter.getValue();
1113        }
1114
1115        /**
1116         * @param value Contact lens diameter measured in millimeters.
1117         */
1118        public VisionPrescriptionDispenseComponent setDiameter(BigDecimal value) { 
1119          if (value == null)
1120            this.diameter = null;
1121          else {
1122            if (this.diameter == null)
1123              this.diameter = new DecimalType();
1124            this.diameter.setValue(value);
1125          }
1126          return this;
1127        }
1128
1129        /**
1130         * @param value Contact lens diameter measured in millimeters.
1131         */
1132        public VisionPrescriptionDispenseComponent setDiameter(long value) { 
1133              this.diameter = new DecimalType();
1134            this.diameter.setValue(value);
1135          return this;
1136        }
1137
1138        /**
1139         * @param value Contact lens diameter measured in millimeters.
1140         */
1141        public VisionPrescriptionDispenseComponent setDiameter(double value) { 
1142              this.diameter = new DecimalType();
1143            this.diameter.setValue(value);
1144          return this;
1145        }
1146
1147        /**
1148         * @return {@link #duration} (The recommended maximum wear period for the lens.)
1149         */
1150        public SimpleQuantity getDuration() { 
1151          if (this.duration == null)
1152            if (Configuration.errorOnAutoCreate())
1153              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.duration");
1154            else if (Configuration.doAutoCreate())
1155              this.duration = new SimpleQuantity(); // cc
1156          return this.duration;
1157        }
1158
1159        public boolean hasDuration() { 
1160          return this.duration != null && !this.duration.isEmpty();
1161        }
1162
1163        /**
1164         * @param value {@link #duration} (The recommended maximum wear period for the lens.)
1165         */
1166        public VisionPrescriptionDispenseComponent setDuration(SimpleQuantity value) { 
1167          this.duration = value;
1168          return this;
1169        }
1170
1171        /**
1172         * @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
1173         */
1174        public StringType getColorElement() { 
1175          if (this.color == null)
1176            if (Configuration.errorOnAutoCreate())
1177              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.color");
1178            else if (Configuration.doAutoCreate())
1179              this.color = new StringType(); // bb
1180          return this.color;
1181        }
1182
1183        public boolean hasColorElement() { 
1184          return this.color != null && !this.color.isEmpty();
1185        }
1186
1187        public boolean hasColor() { 
1188          return this.color != null && !this.color.isEmpty();
1189        }
1190
1191        /**
1192         * @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
1193         */
1194        public VisionPrescriptionDispenseComponent setColorElement(StringType value) { 
1195          this.color = value;
1196          return this;
1197        }
1198
1199        /**
1200         * @return Special color or pattern.
1201         */
1202        public String getColor() { 
1203          return this.color == null ? null : this.color.getValue();
1204        }
1205
1206        /**
1207         * @param value Special color or pattern.
1208         */
1209        public VisionPrescriptionDispenseComponent setColor(String value) { 
1210          if (Utilities.noString(value))
1211            this.color = null;
1212          else {
1213            if (this.color == null)
1214              this.color = new StringType();
1215            this.color.setValue(value);
1216          }
1217          return this;
1218        }
1219
1220        /**
1221         * @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
1222         */
1223        public StringType getBrandElement() { 
1224          if (this.brand == null)
1225            if (Configuration.errorOnAutoCreate())
1226              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.brand");
1227            else if (Configuration.doAutoCreate())
1228              this.brand = new StringType(); // bb
1229          return this.brand;
1230        }
1231
1232        public boolean hasBrandElement() { 
1233          return this.brand != null && !this.brand.isEmpty();
1234        }
1235
1236        public boolean hasBrand() { 
1237          return this.brand != null && !this.brand.isEmpty();
1238        }
1239
1240        /**
1241         * @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
1242         */
1243        public VisionPrescriptionDispenseComponent setBrandElement(StringType value) { 
1244          this.brand = value;
1245          return this;
1246        }
1247
1248        /**
1249         * @return Brand recommendations or restrictions.
1250         */
1251        public String getBrand() { 
1252          return this.brand == null ? null : this.brand.getValue();
1253        }
1254
1255        /**
1256         * @param value Brand recommendations or restrictions.
1257         */
1258        public VisionPrescriptionDispenseComponent setBrand(String value) { 
1259          if (Utilities.noString(value))
1260            this.brand = null;
1261          else {
1262            if (this.brand == null)
1263              this.brand = new StringType();
1264            this.brand.setValue(value);
1265          }
1266          return this;
1267        }
1268
1269        /**
1270         * @return {@link #note} (Notes for special requirements such as coatings and lens materials.)
1271         */
1272        public List<Annotation> getNote() { 
1273          if (this.note == null)
1274            this.note = new ArrayList<Annotation>();
1275          return this.note;
1276        }
1277
1278        /**
1279         * @return Returns a reference to <code>this</code> for easy method chaining
1280         */
1281        public VisionPrescriptionDispenseComponent setNote(List<Annotation> theNote) { 
1282          this.note = theNote;
1283          return this;
1284        }
1285
1286        public boolean hasNote() { 
1287          if (this.note == null)
1288            return false;
1289          for (Annotation item : this.note)
1290            if (!item.isEmpty())
1291              return true;
1292          return false;
1293        }
1294
1295        public Annotation addNote() { //3
1296          Annotation t = new Annotation();
1297          if (this.note == null)
1298            this.note = new ArrayList<Annotation>();
1299          this.note.add(t);
1300          return t;
1301        }
1302
1303        public VisionPrescriptionDispenseComponent addNote(Annotation t) { //3
1304          if (t == null)
1305            return this;
1306          if (this.note == null)
1307            this.note = new ArrayList<Annotation>();
1308          this.note.add(t);
1309          return this;
1310        }
1311
1312        /**
1313         * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist
1314         */
1315        public Annotation getNoteFirstRep() { 
1316          if (getNote().isEmpty()) {
1317            addNote();
1318          }
1319          return getNote().get(0);
1320        }
1321
1322        protected void listChildren(List<Property> childrenList) {
1323          super.listChildren(childrenList);
1324          childrenList.add(new Property("product", "CodeableConcept", "Identifies the type of vision correction product which is required for the patient.", 0, java.lang.Integer.MAX_VALUE, product));
1325          childrenList.add(new Property("eye", "code", "The eye for which the lens applies.", 0, java.lang.Integer.MAX_VALUE, eye));
1326          childrenList.add(new Property("sphere", "decimal", "Lens power measured in diopters (0.25 units).", 0, java.lang.Integer.MAX_VALUE, sphere));
1327          childrenList.add(new Property("cylinder", "decimal", "Power adjustment for astigmatism measured in diopters (0.25 units).", 0, java.lang.Integer.MAX_VALUE, cylinder));
1328          childrenList.add(new Property("axis", "integer", "Adjustment for astigmatism measured in integer degrees.", 0, java.lang.Integer.MAX_VALUE, axis));
1329          childrenList.add(new Property("prism", "decimal", "Amount of prism to compensate for eye alignment in fractional units.", 0, java.lang.Integer.MAX_VALUE, prism));
1330          childrenList.add(new Property("base", "code", "The relative base, or reference lens edge, for the prism.", 0, java.lang.Integer.MAX_VALUE, base));
1331          childrenList.add(new Property("add", "decimal", "Power adjustment for multifocal lenses measured in diopters (0.25 units).", 0, java.lang.Integer.MAX_VALUE, add));
1332          childrenList.add(new Property("power", "decimal", "Contact lens power measured in diopters (0.25 units).", 0, java.lang.Integer.MAX_VALUE, power));
1333          childrenList.add(new Property("backCurve", "decimal", "Back curvature measured in millimeters.", 0, java.lang.Integer.MAX_VALUE, backCurve));
1334          childrenList.add(new Property("diameter", "decimal", "Contact lens diameter measured in millimeters.", 0, java.lang.Integer.MAX_VALUE, diameter));
1335          childrenList.add(new Property("duration", "SimpleQuantity", "The recommended maximum wear period for the lens.", 0, java.lang.Integer.MAX_VALUE, duration));
1336          childrenList.add(new Property("color", "string", "Special color or pattern.", 0, java.lang.Integer.MAX_VALUE, color));
1337          childrenList.add(new Property("brand", "string", "Brand recommendations or restrictions.", 0, java.lang.Integer.MAX_VALUE, brand));
1338          childrenList.add(new Property("note", "Annotation", "Notes for special requirements such as coatings and lens materials.", 0, java.lang.Integer.MAX_VALUE, note));
1339        }
1340
1341      @Override
1342      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1343        switch (hash) {
1344        case -309474065: /*product*/ return this.product == null ? new Base[0] : new Base[] {this.product}; // CodeableConcept
1345        case 100913: /*eye*/ return this.eye == null ? new Base[0] : new Base[] {this.eye}; // Enumeration<VisionEyes>
1346        case -895981619: /*sphere*/ return this.sphere == null ? new Base[0] : new Base[] {this.sphere}; // DecimalType
1347        case -349378602: /*cylinder*/ return this.cylinder == null ? new Base[0] : new Base[] {this.cylinder}; // DecimalType
1348        case 3008417: /*axis*/ return this.axis == null ? new Base[0] : new Base[] {this.axis}; // IntegerType
1349        case 106935105: /*prism*/ return this.prism == null ? new Base[0] : new Base[] {this.prism}; // DecimalType
1350        case 3016401: /*base*/ return this.base == null ? new Base[0] : new Base[] {this.base}; // Enumeration<VisionBase>
1351        case 96417: /*add*/ return this.add == null ? new Base[0] : new Base[] {this.add}; // DecimalType
1352        case 106858757: /*power*/ return this.power == null ? new Base[0] : new Base[] {this.power}; // DecimalType
1353        case 1309344840: /*backCurve*/ return this.backCurve == null ? new Base[0] : new Base[] {this.backCurve}; // DecimalType
1354        case -233204595: /*diameter*/ return this.diameter == null ? new Base[0] : new Base[] {this.diameter}; // DecimalType
1355        case -1992012396: /*duration*/ return this.duration == null ? new Base[0] : new Base[] {this.duration}; // SimpleQuantity
1356        case 94842723: /*color*/ return this.color == null ? new Base[0] : new Base[] {this.color}; // StringType
1357        case 93997959: /*brand*/ return this.brand == null ? new Base[0] : new Base[] {this.brand}; // StringType
1358        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
1359        default: return super.getProperty(hash, name, checkValid);
1360        }
1361
1362      }
1363
1364      @Override
1365      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1366        switch (hash) {
1367        case -309474065: // product
1368          this.product = castToCodeableConcept(value); // CodeableConcept
1369          return value;
1370        case 100913: // eye
1371          value = new VisionEyesEnumFactory().fromType(castToCode(value));
1372          this.eye = (Enumeration) value; // Enumeration<VisionEyes>
1373          return value;
1374        case -895981619: // sphere
1375          this.sphere = castToDecimal(value); // DecimalType
1376          return value;
1377        case -349378602: // cylinder
1378          this.cylinder = castToDecimal(value); // DecimalType
1379          return value;
1380        case 3008417: // axis
1381          this.axis = castToInteger(value); // IntegerType
1382          return value;
1383        case 106935105: // prism
1384          this.prism = castToDecimal(value); // DecimalType
1385          return value;
1386        case 3016401: // base
1387          value = new VisionBaseEnumFactory().fromType(castToCode(value));
1388          this.base = (Enumeration) value; // Enumeration<VisionBase>
1389          return value;
1390        case 96417: // add
1391          this.add = castToDecimal(value); // DecimalType
1392          return value;
1393        case 106858757: // power
1394          this.power = castToDecimal(value); // DecimalType
1395          return value;
1396        case 1309344840: // backCurve
1397          this.backCurve = castToDecimal(value); // DecimalType
1398          return value;
1399        case -233204595: // diameter
1400          this.diameter = castToDecimal(value); // DecimalType
1401          return value;
1402        case -1992012396: // duration
1403          this.duration = castToSimpleQuantity(value); // SimpleQuantity
1404          return value;
1405        case 94842723: // color
1406          this.color = castToString(value); // StringType
1407          return value;
1408        case 93997959: // brand
1409          this.brand = castToString(value); // StringType
1410          return value;
1411        case 3387378: // note
1412          this.getNote().add(castToAnnotation(value)); // Annotation
1413          return value;
1414        default: return super.setProperty(hash, name, value);
1415        }
1416
1417      }
1418
1419      @Override
1420      public Base setProperty(String name, Base value) throws FHIRException {
1421        if (name.equals("product")) {
1422          this.product = castToCodeableConcept(value); // CodeableConcept
1423        } else if (name.equals("eye")) {
1424          value = new VisionEyesEnumFactory().fromType(castToCode(value));
1425          this.eye = (Enumeration) value; // Enumeration<VisionEyes>
1426        } else if (name.equals("sphere")) {
1427          this.sphere = castToDecimal(value); // DecimalType
1428        } else if (name.equals("cylinder")) {
1429          this.cylinder = castToDecimal(value); // DecimalType
1430        } else if (name.equals("axis")) {
1431          this.axis = castToInteger(value); // IntegerType
1432        } else if (name.equals("prism")) {
1433          this.prism = castToDecimal(value); // DecimalType
1434        } else if (name.equals("base")) {
1435          value = new VisionBaseEnumFactory().fromType(castToCode(value));
1436          this.base = (Enumeration) value; // Enumeration<VisionBase>
1437        } else if (name.equals("add")) {
1438          this.add = castToDecimal(value); // DecimalType
1439        } else if (name.equals("power")) {
1440          this.power = castToDecimal(value); // DecimalType
1441        } else if (name.equals("backCurve")) {
1442          this.backCurve = castToDecimal(value); // DecimalType
1443        } else if (name.equals("diameter")) {
1444          this.diameter = castToDecimal(value); // DecimalType
1445        } else if (name.equals("duration")) {
1446          this.duration = castToSimpleQuantity(value); // SimpleQuantity
1447        } else if (name.equals("color")) {
1448          this.color = castToString(value); // StringType
1449        } else if (name.equals("brand")) {
1450          this.brand = castToString(value); // StringType
1451        } else if (name.equals("note")) {
1452          this.getNote().add(castToAnnotation(value));
1453        } else
1454          return super.setProperty(name, value);
1455        return value;
1456      }
1457
1458      @Override
1459      public Base makeProperty(int hash, String name) throws FHIRException {
1460        switch (hash) {
1461        case -309474065:  return getProduct(); 
1462        case 100913:  return getEyeElement();
1463        case -895981619:  return getSphereElement();
1464        case -349378602:  return getCylinderElement();
1465        case 3008417:  return getAxisElement();
1466        case 106935105:  return getPrismElement();
1467        case 3016401:  return getBaseElement();
1468        case 96417:  return getAddElement();
1469        case 106858757:  return getPowerElement();
1470        case 1309344840:  return getBackCurveElement();
1471        case -233204595:  return getDiameterElement();
1472        case -1992012396:  return getDuration(); 
1473        case 94842723:  return getColorElement();
1474        case 93997959:  return getBrandElement();
1475        case 3387378:  return addNote(); 
1476        default: return super.makeProperty(hash, name);
1477        }
1478
1479      }
1480
1481      @Override
1482      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1483        switch (hash) {
1484        case -309474065: /*product*/ return new String[] {"CodeableConcept"};
1485        case 100913: /*eye*/ return new String[] {"code"};
1486        case -895981619: /*sphere*/ return new String[] {"decimal"};
1487        case -349378602: /*cylinder*/ return new String[] {"decimal"};
1488        case 3008417: /*axis*/ return new String[] {"integer"};
1489        case 106935105: /*prism*/ return new String[] {"decimal"};
1490        case 3016401: /*base*/ return new String[] {"code"};
1491        case 96417: /*add*/ return new String[] {"decimal"};
1492        case 106858757: /*power*/ return new String[] {"decimal"};
1493        case 1309344840: /*backCurve*/ return new String[] {"decimal"};
1494        case -233204595: /*diameter*/ return new String[] {"decimal"};
1495        case -1992012396: /*duration*/ return new String[] {"SimpleQuantity"};
1496        case 94842723: /*color*/ return new String[] {"string"};
1497        case 93997959: /*brand*/ return new String[] {"string"};
1498        case 3387378: /*note*/ return new String[] {"Annotation"};
1499        default: return super.getTypesForProperty(hash, name);
1500        }
1501
1502      }
1503
1504      @Override
1505      public Base addChild(String name) throws FHIRException {
1506        if (name.equals("product")) {
1507          this.product = new CodeableConcept();
1508          return this.product;
1509        }
1510        else if (name.equals("eye")) {
1511          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.eye");
1512        }
1513        else if (name.equals("sphere")) {
1514          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.sphere");
1515        }
1516        else if (name.equals("cylinder")) {
1517          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.cylinder");
1518        }
1519        else if (name.equals("axis")) {
1520          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.axis");
1521        }
1522        else if (name.equals("prism")) {
1523          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.prism");
1524        }
1525        else if (name.equals("base")) {
1526          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.base");
1527        }
1528        else if (name.equals("add")) {
1529          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.add");
1530        }
1531        else if (name.equals("power")) {
1532          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.power");
1533        }
1534        else if (name.equals("backCurve")) {
1535          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.backCurve");
1536        }
1537        else if (name.equals("diameter")) {
1538          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.diameter");
1539        }
1540        else if (name.equals("duration")) {
1541          this.duration = new SimpleQuantity();
1542          return this.duration;
1543        }
1544        else if (name.equals("color")) {
1545          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.color");
1546        }
1547        else if (name.equals("brand")) {
1548          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.brand");
1549        }
1550        else if (name.equals("note")) {
1551          return addNote();
1552        }
1553        else
1554          return super.addChild(name);
1555      }
1556
1557      public VisionPrescriptionDispenseComponent copy() {
1558        VisionPrescriptionDispenseComponent dst = new VisionPrescriptionDispenseComponent();
1559        copyValues(dst);
1560        dst.product = product == null ? null : product.copy();
1561        dst.eye = eye == null ? null : eye.copy();
1562        dst.sphere = sphere == null ? null : sphere.copy();
1563        dst.cylinder = cylinder == null ? null : cylinder.copy();
1564        dst.axis = axis == null ? null : axis.copy();
1565        dst.prism = prism == null ? null : prism.copy();
1566        dst.base = base == null ? null : base.copy();
1567        dst.add = add == null ? null : add.copy();
1568        dst.power = power == null ? null : power.copy();
1569        dst.backCurve = backCurve == null ? null : backCurve.copy();
1570        dst.diameter = diameter == null ? null : diameter.copy();
1571        dst.duration = duration == null ? null : duration.copy();
1572        dst.color = color == null ? null : color.copy();
1573        dst.brand = brand == null ? null : brand.copy();
1574        if (note != null) {
1575          dst.note = new ArrayList<Annotation>();
1576          for (Annotation i : note)
1577            dst.note.add(i.copy());
1578        };
1579        return dst;
1580      }
1581
1582      @Override
1583      public boolean equalsDeep(Base other) {
1584        if (!super.equalsDeep(other))
1585          return false;
1586        if (!(other instanceof VisionPrescriptionDispenseComponent))
1587          return false;
1588        VisionPrescriptionDispenseComponent o = (VisionPrescriptionDispenseComponent) other;
1589        return compareDeep(product, o.product, true) && compareDeep(eye, o.eye, true) && compareDeep(sphere, o.sphere, true)
1590           && compareDeep(cylinder, o.cylinder, true) && compareDeep(axis, o.axis, true) && compareDeep(prism, o.prism, true)
1591           && compareDeep(base, o.base, true) && compareDeep(add, o.add, true) && compareDeep(power, o.power, true)
1592           && compareDeep(backCurve, o.backCurve, true) && compareDeep(diameter, o.diameter, true) && compareDeep(duration, o.duration, true)
1593           && compareDeep(color, o.color, true) && compareDeep(brand, o.brand, true) && compareDeep(note, o.note, true)
1594          ;
1595      }
1596
1597      @Override
1598      public boolean equalsShallow(Base other) {
1599        if (!super.equalsShallow(other))
1600          return false;
1601        if (!(other instanceof VisionPrescriptionDispenseComponent))
1602          return false;
1603        VisionPrescriptionDispenseComponent o = (VisionPrescriptionDispenseComponent) other;
1604        return compareValues(eye, o.eye, true) && compareValues(sphere, o.sphere, true) && compareValues(cylinder, o.cylinder, true)
1605           && compareValues(axis, o.axis, true) && compareValues(prism, o.prism, true) && compareValues(base, o.base, true)
1606           && compareValues(add, o.add, true) && compareValues(power, o.power, true) && compareValues(backCurve, o.backCurve, true)
1607           && compareValues(diameter, o.diameter, true) && compareValues(color, o.color, true) && compareValues(brand, o.brand, true)
1608          ;
1609      }
1610
1611      public boolean isEmpty() {
1612        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(product, eye, sphere, cylinder
1613          , axis, prism, base, add, power, backCurve, diameter, duration, color, brand
1614          , note);
1615      }
1616
1617  public String fhirType() {
1618    return "VisionPrescription.dispense";
1619
1620  }
1621
1622  }
1623
1624    /**
1625     * Business identifier which may be used by other parties to reference or identify the prescription.
1626     */
1627    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1628    @Description(shortDefinition="Business identifier", formalDefinition="Business identifier which may be used by other parties to reference or identify the prescription." )
1629    protected List<Identifier> identifier;
1630
1631    /**
1632     * The status of the resource instance.
1633     */
1634    @Child(name = "status", type = {CodeType.class}, order=1, min=0, max=1, modifier=true, summary=true)
1635    @Description(shortDefinition="active | cancelled | draft | entered-in-error", formalDefinition="The status of the resource instance." )
1636    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/fm-status")
1637    protected Enumeration<VisionStatus> status;
1638
1639    /**
1640     * A link to a resource representing the person to whom the vision products will be supplied.
1641     */
1642    @Child(name = "patient", type = {Patient.class}, order=2, min=0, max=1, modifier=false, summary=false)
1643    @Description(shortDefinition="Who prescription is for", formalDefinition="A link to a resource representing the person to whom the vision products will be supplied." )
1644    protected Reference patient;
1645
1646    /**
1647     * 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.)
1648     */
1649    protected Patient patientTarget;
1650
1651    /**
1652     * A link to a resource that identifies the particular occurrence of contact between patient and health care provider.
1653     */
1654    @Child(name = "encounter", type = {Encounter.class}, order=3, min=0, max=1, modifier=false, summary=false)
1655    @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." )
1656    protected Reference encounter;
1657
1658    /**
1659     * 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.)
1660     */
1661    protected Encounter encounterTarget;
1662
1663    /**
1664     * The date (and perhaps time) when the prescription was written.
1665     */
1666    @Child(name = "dateWritten", type = {DateTimeType.class}, order=4, min=0, max=1, modifier=false, summary=false)
1667    @Description(shortDefinition="When prescription was authorized", formalDefinition="The date (and perhaps time) when the prescription was written." )
1668    protected DateTimeType dateWritten;
1669
1670    /**
1671     * The healthcare professional responsible for authorizing the prescription.
1672     */
1673    @Child(name = "prescriber", type = {Practitioner.class}, order=5, min=0, max=1, modifier=false, summary=false)
1674    @Description(shortDefinition="Who authorizes the vision product", formalDefinition="The healthcare professional responsible for authorizing the prescription." )
1675    protected Reference prescriber;
1676
1677    /**
1678     * The actual object that is the target of the reference (The healthcare professional responsible for authorizing the prescription.)
1679     */
1680    protected Practitioner prescriberTarget;
1681
1682    /**
1683     * Can be the reason or the indication for writing the prescription.
1684     */
1685    @Child(name = "reason", type = {CodeableConcept.class, Condition.class}, order=6, min=0, max=1, modifier=false, summary=false)
1686    @Description(shortDefinition="Reason or indication for writing the prescription", formalDefinition="Can be the reason or the indication for writing the prescription." )
1687    protected Type reason;
1688
1689    /**
1690     * Deals with details of the dispense part of the supply specification.
1691     */
1692    @Child(name = "dispense", type = {}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1693    @Description(shortDefinition="Vision supply authorization", formalDefinition="Deals with details of the dispense part of the supply specification." )
1694    protected List<VisionPrescriptionDispenseComponent> dispense;
1695
1696    private static final long serialVersionUID = 603347490L;
1697
1698  /**
1699   * Constructor
1700   */
1701    public VisionPrescription() {
1702      super();
1703    }
1704
1705    /**
1706     * @return {@link #identifier} (Business identifier which may be used by other parties to reference or identify the prescription.)
1707     */
1708    public List<Identifier> getIdentifier() { 
1709      if (this.identifier == null)
1710        this.identifier = new ArrayList<Identifier>();
1711      return this.identifier;
1712    }
1713
1714    /**
1715     * @return Returns a reference to <code>this</code> for easy method chaining
1716     */
1717    public VisionPrescription setIdentifier(List<Identifier> theIdentifier) { 
1718      this.identifier = theIdentifier;
1719      return this;
1720    }
1721
1722    public boolean hasIdentifier() { 
1723      if (this.identifier == null)
1724        return false;
1725      for (Identifier item : this.identifier)
1726        if (!item.isEmpty())
1727          return true;
1728      return false;
1729    }
1730
1731    public Identifier addIdentifier() { //3
1732      Identifier t = new Identifier();
1733      if (this.identifier == null)
1734        this.identifier = new ArrayList<Identifier>();
1735      this.identifier.add(t);
1736      return t;
1737    }
1738
1739    public VisionPrescription addIdentifier(Identifier t) { //3
1740      if (t == null)
1741        return this;
1742      if (this.identifier == null)
1743        this.identifier = new ArrayList<Identifier>();
1744      this.identifier.add(t);
1745      return this;
1746    }
1747
1748    /**
1749     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
1750     */
1751    public Identifier getIdentifierFirstRep() { 
1752      if (getIdentifier().isEmpty()) {
1753        addIdentifier();
1754      }
1755      return getIdentifier().get(0);
1756    }
1757
1758    /**
1759     * @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
1760     */
1761    public Enumeration<VisionStatus> getStatusElement() { 
1762      if (this.status == null)
1763        if (Configuration.errorOnAutoCreate())
1764          throw new Error("Attempt to auto-create VisionPrescription.status");
1765        else if (Configuration.doAutoCreate())
1766          this.status = new Enumeration<VisionStatus>(new VisionStatusEnumFactory()); // bb
1767      return this.status;
1768    }
1769
1770    public boolean hasStatusElement() { 
1771      return this.status != null && !this.status.isEmpty();
1772    }
1773
1774    public boolean hasStatus() { 
1775      return this.status != null && !this.status.isEmpty();
1776    }
1777
1778    /**
1779     * @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
1780     */
1781    public VisionPrescription setStatusElement(Enumeration<VisionStatus> value) { 
1782      this.status = value;
1783      return this;
1784    }
1785
1786    /**
1787     * @return The status of the resource instance.
1788     */
1789    public VisionStatus getStatus() { 
1790      return this.status == null ? null : this.status.getValue();
1791    }
1792
1793    /**
1794     * @param value The status of the resource instance.
1795     */
1796    public VisionPrescription setStatus(VisionStatus value) { 
1797      if (value == null)
1798        this.status = null;
1799      else {
1800        if (this.status == null)
1801          this.status = new Enumeration<VisionStatus>(new VisionStatusEnumFactory());
1802        this.status.setValue(value);
1803      }
1804      return this;
1805    }
1806
1807    /**
1808     * @return {@link #patient} (A link to a resource representing the person to whom the vision products will be supplied.)
1809     */
1810    public Reference getPatient() { 
1811      if (this.patient == null)
1812        if (Configuration.errorOnAutoCreate())
1813          throw new Error("Attempt to auto-create VisionPrescription.patient");
1814        else if (Configuration.doAutoCreate())
1815          this.patient = new Reference(); // cc
1816      return this.patient;
1817    }
1818
1819    public boolean hasPatient() { 
1820      return this.patient != null && !this.patient.isEmpty();
1821    }
1822
1823    /**
1824     * @param value {@link #patient} (A link to a resource representing the person to whom the vision products will be supplied.)
1825     */
1826    public VisionPrescription setPatient(Reference value) { 
1827      this.patient = value;
1828      return this;
1829    }
1830
1831    /**
1832     * @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.)
1833     */
1834    public Patient getPatientTarget() { 
1835      if (this.patientTarget == null)
1836        if (Configuration.errorOnAutoCreate())
1837          throw new Error("Attempt to auto-create VisionPrescription.patient");
1838        else if (Configuration.doAutoCreate())
1839          this.patientTarget = new Patient(); // aa
1840      return this.patientTarget;
1841    }
1842
1843    /**
1844     * @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.)
1845     */
1846    public VisionPrescription setPatientTarget(Patient value) { 
1847      this.patientTarget = value;
1848      return this;
1849    }
1850
1851    /**
1852     * @return {@link #encounter} (A link to a resource that identifies the particular occurrence of contact between patient and health care provider.)
1853     */
1854    public Reference getEncounter() { 
1855      if (this.encounter == null)
1856        if (Configuration.errorOnAutoCreate())
1857          throw new Error("Attempt to auto-create VisionPrescription.encounter");
1858        else if (Configuration.doAutoCreate())
1859          this.encounter = new Reference(); // cc
1860      return this.encounter;
1861    }
1862
1863    public boolean hasEncounter() { 
1864      return this.encounter != null && !this.encounter.isEmpty();
1865    }
1866
1867    /**
1868     * @param value {@link #encounter} (A link to a resource that identifies the particular occurrence of contact between patient and health care provider.)
1869     */
1870    public VisionPrescription setEncounter(Reference value) { 
1871      this.encounter = value;
1872      return this;
1873    }
1874
1875    /**
1876     * @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.)
1877     */
1878    public Encounter getEncounterTarget() { 
1879      if (this.encounterTarget == null)
1880        if (Configuration.errorOnAutoCreate())
1881          throw new Error("Attempt to auto-create VisionPrescription.encounter");
1882        else if (Configuration.doAutoCreate())
1883          this.encounterTarget = new Encounter(); // aa
1884      return this.encounterTarget;
1885    }
1886
1887    /**
1888     * @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.)
1889     */
1890    public VisionPrescription setEncounterTarget(Encounter value) { 
1891      this.encounterTarget = value;
1892      return this;
1893    }
1894
1895    /**
1896     * @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
1897     */
1898    public DateTimeType getDateWrittenElement() { 
1899      if (this.dateWritten == null)
1900        if (Configuration.errorOnAutoCreate())
1901          throw new Error("Attempt to auto-create VisionPrescription.dateWritten");
1902        else if (Configuration.doAutoCreate())
1903          this.dateWritten = new DateTimeType(); // bb
1904      return this.dateWritten;
1905    }
1906
1907    public boolean hasDateWrittenElement() { 
1908      return this.dateWritten != null && !this.dateWritten.isEmpty();
1909    }
1910
1911    public boolean hasDateWritten() { 
1912      return this.dateWritten != null && !this.dateWritten.isEmpty();
1913    }
1914
1915    /**
1916     * @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
1917     */
1918    public VisionPrescription setDateWrittenElement(DateTimeType value) { 
1919      this.dateWritten = value;
1920      return this;
1921    }
1922
1923    /**
1924     * @return The date (and perhaps time) when the prescription was written.
1925     */
1926    public Date getDateWritten() { 
1927      return this.dateWritten == null ? null : this.dateWritten.getValue();
1928    }
1929
1930    /**
1931     * @param value The date (and perhaps time) when the prescription was written.
1932     */
1933    public VisionPrescription setDateWritten(Date value) { 
1934      if (value == null)
1935        this.dateWritten = null;
1936      else {
1937        if (this.dateWritten == null)
1938          this.dateWritten = new DateTimeType();
1939        this.dateWritten.setValue(value);
1940      }
1941      return this;
1942    }
1943
1944    /**
1945     * @return {@link #prescriber} (The healthcare professional responsible for authorizing the prescription.)
1946     */
1947    public Reference getPrescriber() { 
1948      if (this.prescriber == null)
1949        if (Configuration.errorOnAutoCreate())
1950          throw new Error("Attempt to auto-create VisionPrescription.prescriber");
1951        else if (Configuration.doAutoCreate())
1952          this.prescriber = new Reference(); // cc
1953      return this.prescriber;
1954    }
1955
1956    public boolean hasPrescriber() { 
1957      return this.prescriber != null && !this.prescriber.isEmpty();
1958    }
1959
1960    /**
1961     * @param value {@link #prescriber} (The healthcare professional responsible for authorizing the prescription.)
1962     */
1963    public VisionPrescription setPrescriber(Reference value) { 
1964      this.prescriber = value;
1965      return this;
1966    }
1967
1968    /**
1969     * @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.)
1970     */
1971    public Practitioner getPrescriberTarget() { 
1972      if (this.prescriberTarget == null)
1973        if (Configuration.errorOnAutoCreate())
1974          throw new Error("Attempt to auto-create VisionPrescription.prescriber");
1975        else if (Configuration.doAutoCreate())
1976          this.prescriberTarget = new Practitioner(); // aa
1977      return this.prescriberTarget;
1978    }
1979
1980    /**
1981     * @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.)
1982     */
1983    public VisionPrescription setPrescriberTarget(Practitioner value) { 
1984      this.prescriberTarget = value;
1985      return this;
1986    }
1987
1988    /**
1989     * @return {@link #reason} (Can be the reason or the indication for writing the prescription.)
1990     */
1991    public Type getReason() { 
1992      return this.reason;
1993    }
1994
1995    /**
1996     * @return {@link #reason} (Can be the reason or the indication for writing the prescription.)
1997     */
1998    public CodeableConcept getReasonCodeableConcept() throws FHIRException { 
1999      if (!(this.reason instanceof CodeableConcept))
2000        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.reason.getClass().getName()+" was encountered");
2001      return (CodeableConcept) this.reason;
2002    }
2003
2004    public boolean hasReasonCodeableConcept() { 
2005      return this.reason instanceof CodeableConcept;
2006    }
2007
2008    /**
2009     * @return {@link #reason} (Can be the reason or the indication for writing the prescription.)
2010     */
2011    public Reference getReasonReference() throws FHIRException { 
2012      if (!(this.reason instanceof Reference))
2013        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.reason.getClass().getName()+" was encountered");
2014      return (Reference) this.reason;
2015    }
2016
2017    public boolean hasReasonReference() { 
2018      return this.reason instanceof Reference;
2019    }
2020
2021    public boolean hasReason() { 
2022      return this.reason != null && !this.reason.isEmpty();
2023    }
2024
2025    /**
2026     * @param value {@link #reason} (Can be the reason or the indication for writing the prescription.)
2027     */
2028    public VisionPrescription setReason(Type value) { 
2029      this.reason = value;
2030      return this;
2031    }
2032
2033    /**
2034     * @return {@link #dispense} (Deals with details of the dispense part of the supply specification.)
2035     */
2036    public List<VisionPrescriptionDispenseComponent> getDispense() { 
2037      if (this.dispense == null)
2038        this.dispense = new ArrayList<VisionPrescriptionDispenseComponent>();
2039      return this.dispense;
2040    }
2041
2042    /**
2043     * @return Returns a reference to <code>this</code> for easy method chaining
2044     */
2045    public VisionPrescription setDispense(List<VisionPrescriptionDispenseComponent> theDispense) { 
2046      this.dispense = theDispense;
2047      return this;
2048    }
2049
2050    public boolean hasDispense() { 
2051      if (this.dispense == null)
2052        return false;
2053      for (VisionPrescriptionDispenseComponent item : this.dispense)
2054        if (!item.isEmpty())
2055          return true;
2056      return false;
2057    }
2058
2059    public VisionPrescriptionDispenseComponent addDispense() { //3
2060      VisionPrescriptionDispenseComponent t = new VisionPrescriptionDispenseComponent();
2061      if (this.dispense == null)
2062        this.dispense = new ArrayList<VisionPrescriptionDispenseComponent>();
2063      this.dispense.add(t);
2064      return t;
2065    }
2066
2067    public VisionPrescription addDispense(VisionPrescriptionDispenseComponent t) { //3
2068      if (t == null)
2069        return this;
2070      if (this.dispense == null)
2071        this.dispense = new ArrayList<VisionPrescriptionDispenseComponent>();
2072      this.dispense.add(t);
2073      return this;
2074    }
2075
2076    /**
2077     * @return The first repetition of repeating field {@link #dispense}, creating it if it does not already exist
2078     */
2079    public VisionPrescriptionDispenseComponent getDispenseFirstRep() { 
2080      if (getDispense().isEmpty()) {
2081        addDispense();
2082      }
2083      return getDispense().get(0);
2084    }
2085
2086      protected void listChildren(List<Property> childrenList) {
2087        super.listChildren(childrenList);
2088        childrenList.add(new Property("identifier", "Identifier", "Business identifier which may be used by other parties to reference or identify the prescription.", 0, java.lang.Integer.MAX_VALUE, identifier));
2089        childrenList.add(new Property("status", "code", "The status of the resource instance.", 0, java.lang.Integer.MAX_VALUE, status));
2090        childrenList.add(new Property("patient", "Reference(Patient)", "A link to a resource representing the person to whom the vision products will be supplied.", 0, java.lang.Integer.MAX_VALUE, patient));
2091        childrenList.add(new Property("encounter", "Reference(Encounter)", "A link to a resource that identifies the particular occurrence of contact between patient and health care provider.", 0, java.lang.Integer.MAX_VALUE, encounter));
2092        childrenList.add(new Property("dateWritten", "dateTime", "The date (and perhaps time) when the prescription was written.", 0, java.lang.Integer.MAX_VALUE, dateWritten));
2093        childrenList.add(new Property("prescriber", "Reference(Practitioner)", "The healthcare professional responsible for authorizing the prescription.", 0, java.lang.Integer.MAX_VALUE, prescriber));
2094        childrenList.add(new Property("reason[x]", "CodeableConcept|Reference(Condition)", "Can be the reason or the indication for writing the prescription.", 0, java.lang.Integer.MAX_VALUE, reason));
2095        childrenList.add(new Property("dispense", "", "Deals with details of the dispense part of the supply specification.", 0, java.lang.Integer.MAX_VALUE, dispense));
2096      }
2097
2098      @Override
2099      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2100        switch (hash) {
2101        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2102        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<VisionStatus>
2103        case -791418107: /*patient*/ return this.patient == null ? new Base[0] : new Base[] {this.patient}; // Reference
2104        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : new Base[] {this.encounter}; // Reference
2105        case -1496880759: /*dateWritten*/ return this.dateWritten == null ? new Base[0] : new Base[] {this.dateWritten}; // DateTimeType
2106        case 1430631077: /*prescriber*/ return this.prescriber == null ? new Base[0] : new Base[] {this.prescriber}; // Reference
2107        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : new Base[] {this.reason}; // Type
2108        case 284885341: /*dispense*/ return this.dispense == null ? new Base[0] : this.dispense.toArray(new Base[this.dispense.size()]); // VisionPrescriptionDispenseComponent
2109        default: return super.getProperty(hash, name, checkValid);
2110        }
2111
2112      }
2113
2114      @Override
2115      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2116        switch (hash) {
2117        case -1618432855: // identifier
2118          this.getIdentifier().add(castToIdentifier(value)); // Identifier
2119          return value;
2120        case -892481550: // status
2121          value = new VisionStatusEnumFactory().fromType(castToCode(value));
2122          this.status = (Enumeration) value; // Enumeration<VisionStatus>
2123          return value;
2124        case -791418107: // patient
2125          this.patient = castToReference(value); // Reference
2126          return value;
2127        case 1524132147: // encounter
2128          this.encounter = castToReference(value); // Reference
2129          return value;
2130        case -1496880759: // dateWritten
2131          this.dateWritten = castToDateTime(value); // DateTimeType
2132          return value;
2133        case 1430631077: // prescriber
2134          this.prescriber = castToReference(value); // Reference
2135          return value;
2136        case -934964668: // reason
2137          this.reason = castToType(value); // Type
2138          return value;
2139        case 284885341: // dispense
2140          this.getDispense().add((VisionPrescriptionDispenseComponent) value); // VisionPrescriptionDispenseComponent
2141          return value;
2142        default: return super.setProperty(hash, name, value);
2143        }
2144
2145      }
2146
2147      @Override
2148      public Base setProperty(String name, Base value) throws FHIRException {
2149        if (name.equals("identifier")) {
2150          this.getIdentifier().add(castToIdentifier(value));
2151        } else if (name.equals("status")) {
2152          value = new VisionStatusEnumFactory().fromType(castToCode(value));
2153          this.status = (Enumeration) value; // Enumeration<VisionStatus>
2154        } else if (name.equals("patient")) {
2155          this.patient = castToReference(value); // Reference
2156        } else if (name.equals("encounter")) {
2157          this.encounter = castToReference(value); // Reference
2158        } else if (name.equals("dateWritten")) {
2159          this.dateWritten = castToDateTime(value); // DateTimeType
2160        } else if (name.equals("prescriber")) {
2161          this.prescriber = castToReference(value); // Reference
2162        } else if (name.equals("reason[x]")) {
2163          this.reason = castToType(value); // Type
2164        } else if (name.equals("dispense")) {
2165          this.getDispense().add((VisionPrescriptionDispenseComponent) value);
2166        } else
2167          return super.setProperty(name, value);
2168        return value;
2169      }
2170
2171      @Override
2172      public Base makeProperty(int hash, String name) throws FHIRException {
2173        switch (hash) {
2174        case -1618432855:  return addIdentifier(); 
2175        case -892481550:  return getStatusElement();
2176        case -791418107:  return getPatient(); 
2177        case 1524132147:  return getEncounter(); 
2178        case -1496880759:  return getDateWrittenElement();
2179        case 1430631077:  return getPrescriber(); 
2180        case -669418564:  return getReason(); 
2181        case -934964668:  return getReason(); 
2182        case 284885341:  return addDispense(); 
2183        default: return super.makeProperty(hash, name);
2184        }
2185
2186      }
2187
2188      @Override
2189      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2190        switch (hash) {
2191        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2192        case -892481550: /*status*/ return new String[] {"code"};
2193        case -791418107: /*patient*/ return new String[] {"Reference"};
2194        case 1524132147: /*encounter*/ return new String[] {"Reference"};
2195        case -1496880759: /*dateWritten*/ return new String[] {"dateTime"};
2196        case 1430631077: /*prescriber*/ return new String[] {"Reference"};
2197        case -934964668: /*reason*/ return new String[] {"CodeableConcept", "Reference"};
2198        case 284885341: /*dispense*/ return new String[] {};
2199        default: return super.getTypesForProperty(hash, name);
2200        }
2201
2202      }
2203
2204      @Override
2205      public Base addChild(String name) throws FHIRException {
2206        if (name.equals("identifier")) {
2207          return addIdentifier();
2208        }
2209        else if (name.equals("status")) {
2210          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.status");
2211        }
2212        else if (name.equals("patient")) {
2213          this.patient = new Reference();
2214          return this.patient;
2215        }
2216        else if (name.equals("encounter")) {
2217          this.encounter = new Reference();
2218          return this.encounter;
2219        }
2220        else if (name.equals("dateWritten")) {
2221          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.dateWritten");
2222        }
2223        else if (name.equals("prescriber")) {
2224          this.prescriber = new Reference();
2225          return this.prescriber;
2226        }
2227        else if (name.equals("reasonCodeableConcept")) {
2228          this.reason = new CodeableConcept();
2229          return this.reason;
2230        }
2231        else if (name.equals("reasonReference")) {
2232          this.reason = new Reference();
2233          return this.reason;
2234        }
2235        else if (name.equals("dispense")) {
2236          return addDispense();
2237        }
2238        else
2239          return super.addChild(name);
2240      }
2241
2242  public String fhirType() {
2243    return "VisionPrescription";
2244
2245  }
2246
2247      public VisionPrescription copy() {
2248        VisionPrescription dst = new VisionPrescription();
2249        copyValues(dst);
2250        if (identifier != null) {
2251          dst.identifier = new ArrayList<Identifier>();
2252          for (Identifier i : identifier)
2253            dst.identifier.add(i.copy());
2254        };
2255        dst.status = status == null ? null : status.copy();
2256        dst.patient = patient == null ? null : patient.copy();
2257        dst.encounter = encounter == null ? null : encounter.copy();
2258        dst.dateWritten = dateWritten == null ? null : dateWritten.copy();
2259        dst.prescriber = prescriber == null ? null : prescriber.copy();
2260        dst.reason = reason == null ? null : reason.copy();
2261        if (dispense != null) {
2262          dst.dispense = new ArrayList<VisionPrescriptionDispenseComponent>();
2263          for (VisionPrescriptionDispenseComponent i : dispense)
2264            dst.dispense.add(i.copy());
2265        };
2266        return dst;
2267      }
2268
2269      protected VisionPrescription typedCopy() {
2270        return copy();
2271      }
2272
2273      @Override
2274      public boolean equalsDeep(Base other) {
2275        if (!super.equalsDeep(other))
2276          return false;
2277        if (!(other instanceof VisionPrescription))
2278          return false;
2279        VisionPrescription o = (VisionPrescription) other;
2280        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(patient, o.patient, true)
2281           && compareDeep(encounter, o.encounter, true) && compareDeep(dateWritten, o.dateWritten, true) && compareDeep(prescriber, o.prescriber, true)
2282           && compareDeep(reason, o.reason, true) && compareDeep(dispense, o.dispense, true);
2283      }
2284
2285      @Override
2286      public boolean equalsShallow(Base other) {
2287        if (!super.equalsShallow(other))
2288          return false;
2289        if (!(other instanceof VisionPrescription))
2290          return false;
2291        VisionPrescription o = (VisionPrescription) other;
2292        return compareValues(status, o.status, true) && compareValues(dateWritten, o.dateWritten, true);
2293      }
2294
2295      public boolean isEmpty() {
2296        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, patient
2297          , encounter, dateWritten, prescriber, reason, dispense);
2298      }
2299
2300  @Override
2301  public ResourceType getResourceType() {
2302    return ResourceType.VisionPrescription;
2303   }
2304
2305 /**
2306   * Search parameter: <b>prescriber</b>
2307   * <p>
2308   * Description: <b>Who authorizes the vision product</b><br>
2309   * Type: <b>reference</b><br>
2310   * Path: <b>VisionPrescription.prescriber</b><br>
2311   * </p>
2312   */
2313  @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 } )
2314  public static final String SP_PRESCRIBER = "prescriber";
2315 /**
2316   * <b>Fluent Client</b> search parameter constant for <b>prescriber</b>
2317   * <p>
2318   * Description: <b>Who authorizes the vision product</b><br>
2319   * Type: <b>reference</b><br>
2320   * Path: <b>VisionPrescription.prescriber</b><br>
2321   * </p>
2322   */
2323  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PRESCRIBER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PRESCRIBER);
2324
2325/**
2326   * Constant for fluent queries to be used to add include statements. Specifies
2327   * the path value of "<b>VisionPrescription:prescriber</b>".
2328   */
2329  public static final ca.uhn.fhir.model.api.Include INCLUDE_PRESCRIBER = new ca.uhn.fhir.model.api.Include("VisionPrescription:prescriber").toLocked();
2330
2331 /**
2332   * Search parameter: <b>identifier</b>
2333   * <p>
2334   * Description: <b>Return prescriptions with this external identifier</b><br>
2335   * Type: <b>token</b><br>
2336   * Path: <b>VisionPrescription.identifier</b><br>
2337   * </p>
2338   */
2339  @SearchParamDefinition(name="identifier", path="VisionPrescription.identifier", description="Return prescriptions with this external identifier", type="token" )
2340  public static final String SP_IDENTIFIER = "identifier";
2341 /**
2342   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2343   * <p>
2344   * Description: <b>Return prescriptions with this external identifier</b><br>
2345   * Type: <b>token</b><br>
2346   * Path: <b>VisionPrescription.identifier</b><br>
2347   * </p>
2348   */
2349  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2350
2351 /**
2352   * Search parameter: <b>patient</b>
2353   * <p>
2354   * Description: <b>The identity of a patient to list dispenses for</b><br>
2355   * Type: <b>reference</b><br>
2356   * Path: <b>VisionPrescription.patient</b><br>
2357   * </p>
2358   */
2359  @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 } )
2360  public static final String SP_PATIENT = "patient";
2361 /**
2362   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2363   * <p>
2364   * Description: <b>The identity of a patient to list dispenses for</b><br>
2365   * Type: <b>reference</b><br>
2366   * Path: <b>VisionPrescription.patient</b><br>
2367   * </p>
2368   */
2369  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
2370
2371/**
2372   * Constant for fluent queries to be used to add include statements. Specifies
2373   * the path value of "<b>VisionPrescription:patient</b>".
2374   */
2375  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("VisionPrescription:patient").toLocked();
2376
2377 /**
2378   * Search parameter: <b>datewritten</b>
2379   * <p>
2380   * Description: <b>Return prescriptions written on this date</b><br>
2381   * Type: <b>date</b><br>
2382   * Path: <b>VisionPrescription.dateWritten</b><br>
2383   * </p>
2384   */
2385  @SearchParamDefinition(name="datewritten", path="VisionPrescription.dateWritten", description="Return prescriptions written on this date", type="date" )
2386  public static final String SP_DATEWRITTEN = "datewritten";
2387 /**
2388   * <b>Fluent Client</b> search parameter constant for <b>datewritten</b>
2389   * <p>
2390   * Description: <b>Return prescriptions written on this date</b><br>
2391   * Type: <b>date</b><br>
2392   * Path: <b>VisionPrescription.dateWritten</b><br>
2393   * </p>
2394   */
2395  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATEWRITTEN = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATEWRITTEN);
2396
2397 /**
2398   * Search parameter: <b>encounter</b>
2399   * <p>
2400   * Description: <b>Return prescriptions with this encounter identifier</b><br>
2401   * Type: <b>reference</b><br>
2402   * Path: <b>VisionPrescription.encounter</b><br>
2403   * </p>
2404   */
2405  @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 } )
2406  public static final String SP_ENCOUNTER = "encounter";
2407 /**
2408   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
2409   * <p>
2410   * Description: <b>Return prescriptions with this encounter identifier</b><br>
2411   * Type: <b>reference</b><br>
2412   * Path: <b>VisionPrescription.encounter</b><br>
2413   * </p>
2414   */
2415  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
2416
2417/**
2418   * Constant for fluent queries to be used to add include statements. Specifies
2419   * the path value of "<b>VisionPrescription:encounter</b>".
2420   */
2421  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("VisionPrescription:encounter").toLocked();
2422
2423
2424}
2425