001package org.hl7.fhir.dstu2.model;
002
003
004
005
006import java.math.BigDecimal;
007
008/*
009  Copyright (c) 2011+, HL7, Inc.
010  All rights reserved.
011  
012  Redistribution and use in source and binary forms, with or without modification, 
013  are permitted provided that the following conditions are met:
014  
015   * Redistributions of source code must retain the above copyright notice, this 
016     list of conditions and the following disclaimer.
017   * Redistributions in binary form must reproduce the above copyright notice, 
018     this list of conditions and the following disclaimer in the documentation 
019     and/or other materials provided with the distribution.
020   * Neither the name of HL7 nor the names of its contributors may be used to 
021     endorse or promote products derived from this software without specific 
022     prior written permission.
023  
024  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
025  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
026  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
027  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
028  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
029  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
030  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
031  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
032  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
033  POSSIBILITY OF SUCH DAMAGE.
034  
035*/
036
037// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
038import java.util.ArrayList;
039import java.util.Date;
040import java.util.List;
041
042import ca.uhn.fhir.model.api.annotation.Block;
043import ca.uhn.fhir.model.api.annotation.Child;
044import ca.uhn.fhir.model.api.annotation.Description;
045import ca.uhn.fhir.model.api.annotation.ResourceDef;
046import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
047import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
048import org.hl7.fhir.exceptions.FHIRException;
049import org.hl7.fhir.utilities.Utilities;
050/**
051 * An authorization for the supply of glasses and/or contact lenses to a patient.
052 */
053@ResourceDef(name="VisionPrescription", profile="http://hl7.org/fhir/Profile/VisionPrescription")
054public class VisionPrescription extends DomainResource {
055
056    public enum VisionEyes {
057        /**
058         * Right Eye
059         */
060        RIGHT, 
061        /**
062         * Left Eye
063         */
064        LEFT, 
065        /**
066         * added to help the parsers
067         */
068        NULL;
069        public static VisionEyes fromCode(String codeString) throws FHIRException {
070            if (codeString == null || "".equals(codeString))
071                return null;
072        if ("right".equals(codeString))
073          return RIGHT;
074        if ("left".equals(codeString))
075          return LEFT;
076        throw new FHIRException("Unknown VisionEyes code '"+codeString+"'");
077        }
078        public String toCode() {
079          switch (this) {
080            case RIGHT: return "right";
081            case LEFT: return "left";
082            default: return "?";
083          }
084        }
085        public String getSystem() {
086          switch (this) {
087            case RIGHT: return "http://hl7.org/fhir/vision-eye-codes";
088            case LEFT: return "http://hl7.org/fhir/vision-eye-codes";
089            default: return "?";
090          }
091        }
092        public String getDefinition() {
093          switch (this) {
094            case RIGHT: return "Right Eye";
095            case LEFT: return "Left Eye";
096            default: return "?";
097          }
098        }
099        public String getDisplay() {
100          switch (this) {
101            case RIGHT: return "Right Eye";
102            case LEFT: return "Left Eye";
103            default: return "?";
104          }
105        }
106    }
107
108  public static class VisionEyesEnumFactory implements EnumFactory<VisionEyes> {
109    public VisionEyes fromCode(String codeString) throws IllegalArgumentException {
110      if (codeString == null || "".equals(codeString))
111            if (codeString == null || "".equals(codeString))
112                return null;
113        if ("right".equals(codeString))
114          return VisionEyes.RIGHT;
115        if ("left".equals(codeString))
116          return VisionEyes.LEFT;
117        throw new IllegalArgumentException("Unknown VisionEyes code '"+codeString+"'");
118        }
119        public Enumeration<VisionEyes> fromType(Base code) throws FHIRException {
120          if (code == null || code.isEmpty())
121            return null;
122          String codeString = ((PrimitiveType) code).asStringValue();
123          if (codeString == null || "".equals(codeString))
124            return null;
125        if ("right".equals(codeString))
126          return new Enumeration<VisionEyes>(this, VisionEyes.RIGHT);
127        if ("left".equals(codeString))
128          return new Enumeration<VisionEyes>(this, VisionEyes.LEFT);
129        throw new FHIRException("Unknown VisionEyes code '"+codeString+"'");
130        }
131    public String toCode(VisionEyes code) {
132      if (code == VisionEyes.RIGHT)
133        return "right";
134      if (code == VisionEyes.LEFT)
135        return "left";
136      return "?";
137      }
138    }
139
140    public enum VisionBase {
141        /**
142         * top
143         */
144        UP, 
145        /**
146         * bottom
147         */
148        DOWN, 
149        /**
150         * inner edge
151         */
152        IN, 
153        /**
154         * outer edge
155         */
156        OUT, 
157        /**
158         * added to help the parsers
159         */
160        NULL;
161        public static VisionBase fromCode(String codeString) throws FHIRException {
162            if (codeString == null || "".equals(codeString))
163                return null;
164        if ("up".equals(codeString))
165          return UP;
166        if ("down".equals(codeString))
167          return DOWN;
168        if ("in".equals(codeString))
169          return IN;
170        if ("out".equals(codeString))
171          return OUT;
172        throw new FHIRException("Unknown VisionBase code '"+codeString+"'");
173        }
174        public String toCode() {
175          switch (this) {
176            case UP: return "up";
177            case DOWN: return "down";
178            case IN: return "in";
179            case OUT: return "out";
180            default: return "?";
181          }
182        }
183        public String getSystem() {
184          switch (this) {
185            case UP: return "http://hl7.org/fhir/vision-base-codes";
186            case DOWN: return "http://hl7.org/fhir/vision-base-codes";
187            case IN: return "http://hl7.org/fhir/vision-base-codes";
188            case OUT: return "http://hl7.org/fhir/vision-base-codes";
189            default: return "?";
190          }
191        }
192        public String getDefinition() {
193          switch (this) {
194            case UP: return "top";
195            case DOWN: return "bottom";
196            case IN: return "inner edge";
197            case OUT: return "outer edge";
198            default: return "?";
199          }
200        }
201        public String getDisplay() {
202          switch (this) {
203            case UP: return "Up";
204            case DOWN: return "Down";
205            case IN: return "In";
206            case OUT: return "Out";
207            default: return "?";
208          }
209        }
210    }
211
212  public static class VisionBaseEnumFactory implements EnumFactory<VisionBase> {
213    public VisionBase fromCode(String codeString) throws IllegalArgumentException {
214      if (codeString == null || "".equals(codeString))
215            if (codeString == null || "".equals(codeString))
216                return null;
217        if ("up".equals(codeString))
218          return VisionBase.UP;
219        if ("down".equals(codeString))
220          return VisionBase.DOWN;
221        if ("in".equals(codeString))
222          return VisionBase.IN;
223        if ("out".equals(codeString))
224          return VisionBase.OUT;
225        throw new IllegalArgumentException("Unknown VisionBase code '"+codeString+"'");
226        }
227        public Enumeration<VisionBase> fromType(Base code) throws FHIRException {
228          if (code == null || code.isEmpty())
229            return null;
230          String codeString = ((PrimitiveType) code).asStringValue();
231          if (codeString == null || "".equals(codeString))
232            return null;
233        if ("up".equals(codeString))
234          return new Enumeration<VisionBase>(this, VisionBase.UP);
235        if ("down".equals(codeString))
236          return new Enumeration<VisionBase>(this, VisionBase.DOWN);
237        if ("in".equals(codeString))
238          return new Enumeration<VisionBase>(this, VisionBase.IN);
239        if ("out".equals(codeString))
240          return new Enumeration<VisionBase>(this, VisionBase.OUT);
241        throw new FHIRException("Unknown VisionBase code '"+codeString+"'");
242        }
243    public String toCode(VisionBase code) {
244      if (code == VisionBase.UP)
245        return "up";
246      if (code == VisionBase.DOWN)
247        return "down";
248      if (code == VisionBase.IN)
249        return "in";
250      if (code == VisionBase.OUT)
251        return "out";
252      return "?";
253      }
254    }
255
256    @Block()
257    public static class VisionPrescriptionDispenseComponent extends BackboneElement implements IBaseBackboneElement {
258        /**
259         * Identifies the type of vision correction product which is required for the patient.
260         */
261        @Child(name = "product", type = {Coding.class}, order=1, min=1, max=1, modifier=false, summary=true)
262        @Description(shortDefinition="Product to be supplied", formalDefinition="Identifies the type of vision correction product which is required for the patient." )
263        protected Coding product;
264
265        /**
266         * The eye for which the lens applies.
267         */
268        @Child(name = "eye", type = {CodeType.class}, order=2, min=0, max=1, modifier=false, summary=true)
269        @Description(shortDefinition="right | left", formalDefinition="The eye for which the lens applies." )
270        protected Enumeration<VisionEyes> eye;
271
272        /**
273         * Lens power measured in diopters (0.25 units).
274         */
275        @Child(name = "sphere", type = {DecimalType.class}, order=3, min=0, max=1, modifier=false, summary=true)
276        @Description(shortDefinition="Lens sphere", formalDefinition="Lens power measured in diopters (0.25 units)." )
277        protected DecimalType sphere;
278
279        /**
280         * Power adjustment for astigmatism measured in diopters (0.25 units).
281         */
282        @Child(name = "cylinder", type = {DecimalType.class}, order=4, min=0, max=1, modifier=false, summary=true)
283        @Description(shortDefinition="Lens cylinder", formalDefinition="Power adjustment for astigmatism measured in diopters (0.25 units)." )
284        protected DecimalType cylinder;
285
286        /**
287         * Adjustment for astigmatism measured in integer degrees.
288         */
289        @Child(name = "axis", type = {IntegerType.class}, order=5, min=0, max=1, modifier=false, summary=true)
290        @Description(shortDefinition="Lens axis", formalDefinition="Adjustment for astigmatism measured in integer degrees." )
291        protected IntegerType axis;
292
293        /**
294         * Amount of prism to compensate for eye alignment in fractional units.
295         */
296        @Child(name = "prism", type = {DecimalType.class}, order=6, min=0, max=1, modifier=false, summary=true)
297        @Description(shortDefinition="Lens prism", formalDefinition="Amount of prism to compensate for eye alignment in fractional units." )
298        protected DecimalType prism;
299
300        /**
301         * The relative base, or reference lens edge, for the prism.
302         */
303        @Child(name = "base", type = {CodeType.class}, order=7, min=0, max=1, modifier=false, summary=true)
304        @Description(shortDefinition="up | down | in | out", formalDefinition="The relative base, or reference lens edge, for the prism." )
305        protected Enumeration<VisionBase> base;
306
307        /**
308         * Power adjustment for multifocal lenses measured in diopters (0.25 units).
309         */
310        @Child(name = "add", type = {DecimalType.class}, order=8, min=0, max=1, modifier=false, summary=true)
311        @Description(shortDefinition="Lens add", formalDefinition="Power adjustment for multifocal lenses measured in diopters (0.25 units)." )
312        protected DecimalType add;
313
314        /**
315         * Contact lens power measured in diopters (0.25 units).
316         */
317        @Child(name = "power", type = {DecimalType.class}, order=9, min=0, max=1, modifier=false, summary=true)
318        @Description(shortDefinition="Contact lens power", formalDefinition="Contact lens power measured in diopters (0.25 units)." )
319        protected DecimalType power;
320
321        /**
322         * Back curvature measured in millimeters.
323         */
324        @Child(name = "backCurve", type = {DecimalType.class}, order=10, min=0, max=1, modifier=false, summary=true)
325        @Description(shortDefinition="Contact lens back curvature", formalDefinition="Back curvature measured in millimeters." )
326        protected DecimalType backCurve;
327
328        /**
329         * Contact lens diameter measured in millimeters.
330         */
331        @Child(name = "diameter", type = {DecimalType.class}, order=11, min=0, max=1, modifier=false, summary=true)
332        @Description(shortDefinition="Contact lens diameter", formalDefinition="Contact lens diameter measured in millimeters." )
333        protected DecimalType diameter;
334
335        /**
336         * The recommended maximum wear period for the lens.
337         */
338        @Child(name = "duration", type = {SimpleQuantity.class}, order=12, min=0, max=1, modifier=false, summary=true)
339        @Description(shortDefinition="Lens wear duration", formalDefinition="The recommended maximum wear period for the lens." )
340        protected SimpleQuantity duration;
341
342        /**
343         * Special color or pattern.
344         */
345        @Child(name = "color", type = {StringType.class}, order=13, min=0, max=1, modifier=false, summary=true)
346        @Description(shortDefinition="Lens add", formalDefinition="Special color or pattern." )
347        protected StringType color;
348
349        /**
350         * Brand recommendations or restrictions.
351         */
352        @Child(name = "brand", type = {StringType.class}, order=14, min=0, max=1, modifier=false, summary=true)
353        @Description(shortDefinition="Lens add", formalDefinition="Brand recommendations or restrictions." )
354        protected StringType brand;
355
356        /**
357         * Notes for special requirements such as coatings and lens materials.
358         */
359        @Child(name = "notes", type = {StringType.class}, order=15, min=0, max=1, modifier=false, summary=true)
360        @Description(shortDefinition="Notes for coatings", formalDefinition="Notes for special requirements such as coatings and lens materials." )
361        protected StringType notes;
362
363        private static final long serialVersionUID = -1586392610L;
364
365    /*
366     * Constructor
367     */
368      public VisionPrescriptionDispenseComponent() {
369        super();
370      }
371
372    /*
373     * Constructor
374     */
375      public VisionPrescriptionDispenseComponent(Coding product) {
376        super();
377        this.product = product;
378      }
379
380        /**
381         * @return {@link #product} (Identifies the type of vision correction product which is required for the patient.)
382         */
383        public Coding getProduct() { 
384          if (this.product == null)
385            if (Configuration.errorOnAutoCreate())
386              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.product");
387            else if (Configuration.doAutoCreate())
388              this.product = new Coding(); // cc
389          return this.product;
390        }
391
392        public boolean hasProduct() { 
393          return this.product != null && !this.product.isEmpty();
394        }
395
396        /**
397         * @param value {@link #product} (Identifies the type of vision correction product which is required for the patient.)
398         */
399        public VisionPrescriptionDispenseComponent setProduct(Coding value) { 
400          this.product = value;
401          return this;
402        }
403
404        /**
405         * @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
406         */
407        public Enumeration<VisionEyes> getEyeElement() { 
408          if (this.eye == null)
409            if (Configuration.errorOnAutoCreate())
410              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.eye");
411            else if (Configuration.doAutoCreate())
412              this.eye = new Enumeration<VisionEyes>(new VisionEyesEnumFactory()); // bb
413          return this.eye;
414        }
415
416        public boolean hasEyeElement() { 
417          return this.eye != null && !this.eye.isEmpty();
418        }
419
420        public boolean hasEye() { 
421          return this.eye != null && !this.eye.isEmpty();
422        }
423
424        /**
425         * @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
426         */
427        public VisionPrescriptionDispenseComponent setEyeElement(Enumeration<VisionEyes> value) { 
428          this.eye = value;
429          return this;
430        }
431
432        /**
433         * @return The eye for which the lens applies.
434         */
435        public VisionEyes getEye() { 
436          return this.eye == null ? null : this.eye.getValue();
437        }
438
439        /**
440         * @param value The eye for which the lens applies.
441         */
442        public VisionPrescriptionDispenseComponent setEye(VisionEyes value) { 
443          if (value == null)
444            this.eye = null;
445          else {
446            if (this.eye == null)
447              this.eye = new Enumeration<VisionEyes>(new VisionEyesEnumFactory());
448            this.eye.setValue(value);
449          }
450          return this;
451        }
452
453        /**
454         * @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
455         */
456        public DecimalType getSphereElement() { 
457          if (this.sphere == null)
458            if (Configuration.errorOnAutoCreate())
459              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.sphere");
460            else if (Configuration.doAutoCreate())
461              this.sphere = new DecimalType(); // bb
462          return this.sphere;
463        }
464
465        public boolean hasSphereElement() { 
466          return this.sphere != null && !this.sphere.isEmpty();
467        }
468
469        public boolean hasSphere() { 
470          return this.sphere != null && !this.sphere.isEmpty();
471        }
472
473        /**
474         * @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
475         */
476        public VisionPrescriptionDispenseComponent setSphereElement(DecimalType value) { 
477          this.sphere = value;
478          return this;
479        }
480
481        /**
482         * @return Lens power measured in diopters (0.25 units).
483         */
484        public BigDecimal getSphere() { 
485          return this.sphere == null ? null : this.sphere.getValue();
486        }
487
488        /**
489         * @param value Lens power measured in diopters (0.25 units).
490         */
491        public VisionPrescriptionDispenseComponent setSphere(BigDecimal value) { 
492          if (value == null)
493            this.sphere = null;
494          else {
495            if (this.sphere == null)
496              this.sphere = new DecimalType();
497            this.sphere.setValue(value);
498          }
499          return this;
500        }
501
502        /**
503         * @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
504         */
505        public DecimalType getCylinderElement() { 
506          if (this.cylinder == null)
507            if (Configuration.errorOnAutoCreate())
508              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.cylinder");
509            else if (Configuration.doAutoCreate())
510              this.cylinder = new DecimalType(); // bb
511          return this.cylinder;
512        }
513
514        public boolean hasCylinderElement() { 
515          return this.cylinder != null && !this.cylinder.isEmpty();
516        }
517
518        public boolean hasCylinder() { 
519          return this.cylinder != null && !this.cylinder.isEmpty();
520        }
521
522        /**
523         * @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
524         */
525        public VisionPrescriptionDispenseComponent setCylinderElement(DecimalType value) { 
526          this.cylinder = value;
527          return this;
528        }
529
530        /**
531         * @return Power adjustment for astigmatism measured in diopters (0.25 units).
532         */
533        public BigDecimal getCylinder() { 
534          return this.cylinder == null ? null : this.cylinder.getValue();
535        }
536
537        /**
538         * @param value Power adjustment for astigmatism measured in diopters (0.25 units).
539         */
540        public VisionPrescriptionDispenseComponent setCylinder(BigDecimal value) { 
541          if (value == null)
542            this.cylinder = null;
543          else {
544            if (this.cylinder == null)
545              this.cylinder = new DecimalType();
546            this.cylinder.setValue(value);
547          }
548          return this;
549        }
550
551        /**
552         * @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
553         */
554        public IntegerType getAxisElement() { 
555          if (this.axis == null)
556            if (Configuration.errorOnAutoCreate())
557              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.axis");
558            else if (Configuration.doAutoCreate())
559              this.axis = new IntegerType(); // bb
560          return this.axis;
561        }
562
563        public boolean hasAxisElement() { 
564          return this.axis != null && !this.axis.isEmpty();
565        }
566
567        public boolean hasAxis() { 
568          return this.axis != null && !this.axis.isEmpty();
569        }
570
571        /**
572         * @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
573         */
574        public VisionPrescriptionDispenseComponent setAxisElement(IntegerType value) { 
575          this.axis = value;
576          return this;
577        }
578
579        /**
580         * @return Adjustment for astigmatism measured in integer degrees.
581         */
582        public int getAxis() { 
583          return this.axis == null || this.axis.isEmpty() ? 0 : this.axis.getValue();
584        }
585
586        /**
587         * @param value Adjustment for astigmatism measured in integer degrees.
588         */
589        public VisionPrescriptionDispenseComponent setAxis(int value) { 
590            if (this.axis == null)
591              this.axis = new IntegerType();
592            this.axis.setValue(value);
593          return this;
594        }
595
596        /**
597         * @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
598         */
599        public DecimalType getPrismElement() { 
600          if (this.prism == null)
601            if (Configuration.errorOnAutoCreate())
602              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.prism");
603            else if (Configuration.doAutoCreate())
604              this.prism = new DecimalType(); // bb
605          return this.prism;
606        }
607
608        public boolean hasPrismElement() { 
609          return this.prism != null && !this.prism.isEmpty();
610        }
611
612        public boolean hasPrism() { 
613          return this.prism != null && !this.prism.isEmpty();
614        }
615
616        /**
617         * @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
618         */
619        public VisionPrescriptionDispenseComponent setPrismElement(DecimalType value) { 
620          this.prism = value;
621          return this;
622        }
623
624        /**
625         * @return Amount of prism to compensate for eye alignment in fractional units.
626         */
627        public BigDecimal getPrism() { 
628          return this.prism == null ? null : this.prism.getValue();
629        }
630
631        /**
632         * @param value Amount of prism to compensate for eye alignment in fractional units.
633         */
634        public VisionPrescriptionDispenseComponent setPrism(BigDecimal value) { 
635          if (value == null)
636            this.prism = null;
637          else {
638            if (this.prism == null)
639              this.prism = new DecimalType();
640            this.prism.setValue(value);
641          }
642          return this;
643        }
644
645        /**
646         * @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
647         */
648        public Enumeration<VisionBase> getBaseElement() { 
649          if (this.base == null)
650            if (Configuration.errorOnAutoCreate())
651              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.base");
652            else if (Configuration.doAutoCreate())
653              this.base = new Enumeration<VisionBase>(new VisionBaseEnumFactory()); // bb
654          return this.base;
655        }
656
657        public boolean hasBaseElement() { 
658          return this.base != null && !this.base.isEmpty();
659        }
660
661        public boolean hasBase() { 
662          return this.base != null && !this.base.isEmpty();
663        }
664
665        /**
666         * @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
667         */
668        public VisionPrescriptionDispenseComponent setBaseElement(Enumeration<VisionBase> value) { 
669          this.base = value;
670          return this;
671        }
672
673        /**
674         * @return The relative base, or reference lens edge, for the prism.
675         */
676        public VisionBase getBase() { 
677          return this.base == null ? null : this.base.getValue();
678        }
679
680        /**
681         * @param value The relative base, or reference lens edge, for the prism.
682         */
683        public VisionPrescriptionDispenseComponent setBase(VisionBase value) { 
684          if (value == null)
685            this.base = null;
686          else {
687            if (this.base == null)
688              this.base = new Enumeration<VisionBase>(new VisionBaseEnumFactory());
689            this.base.setValue(value);
690          }
691          return this;
692        }
693
694        /**
695         * @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
696         */
697        public DecimalType getAddElement() { 
698          if (this.add == null)
699            if (Configuration.errorOnAutoCreate())
700              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.add");
701            else if (Configuration.doAutoCreate())
702              this.add = new DecimalType(); // bb
703          return this.add;
704        }
705
706        public boolean hasAddElement() { 
707          return this.add != null && !this.add.isEmpty();
708        }
709
710        public boolean hasAdd() { 
711          return this.add != null && !this.add.isEmpty();
712        }
713
714        /**
715         * @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
716         */
717        public VisionPrescriptionDispenseComponent setAddElement(DecimalType value) { 
718          this.add = value;
719          return this;
720        }
721
722        /**
723         * @return Power adjustment for multifocal lenses measured in diopters (0.25 units).
724         */
725        public BigDecimal getAdd() { 
726          return this.add == null ? null : this.add.getValue();
727        }
728
729        /**
730         * @param value Power adjustment for multifocal lenses measured in diopters (0.25 units).
731         */
732        public VisionPrescriptionDispenseComponent setAdd(BigDecimal value) { 
733          if (value == null)
734            this.add = null;
735          else {
736            if (this.add == null)
737              this.add = new DecimalType();
738            this.add.setValue(value);
739          }
740          return this;
741        }
742
743        /**
744         * @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
745         */
746        public DecimalType getPowerElement() { 
747          if (this.power == null)
748            if (Configuration.errorOnAutoCreate())
749              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.power");
750            else if (Configuration.doAutoCreate())
751              this.power = new DecimalType(); // bb
752          return this.power;
753        }
754
755        public boolean hasPowerElement() { 
756          return this.power != null && !this.power.isEmpty();
757        }
758
759        public boolean hasPower() { 
760          return this.power != null && !this.power.isEmpty();
761        }
762
763        /**
764         * @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
765         */
766        public VisionPrescriptionDispenseComponent setPowerElement(DecimalType value) { 
767          this.power = value;
768          return this;
769        }
770
771        /**
772         * @return Contact lens power measured in diopters (0.25 units).
773         */
774        public BigDecimal getPower() { 
775          return this.power == null ? null : this.power.getValue();
776        }
777
778        /**
779         * @param value Contact lens power measured in diopters (0.25 units).
780         */
781        public VisionPrescriptionDispenseComponent setPower(BigDecimal value) { 
782          if (value == null)
783            this.power = null;
784          else {
785            if (this.power == null)
786              this.power = new DecimalType();
787            this.power.setValue(value);
788          }
789          return this;
790        }
791
792        /**
793         * @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
794         */
795        public DecimalType getBackCurveElement() { 
796          if (this.backCurve == null)
797            if (Configuration.errorOnAutoCreate())
798              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.backCurve");
799            else if (Configuration.doAutoCreate())
800              this.backCurve = new DecimalType(); // bb
801          return this.backCurve;
802        }
803
804        public boolean hasBackCurveElement() { 
805          return this.backCurve != null && !this.backCurve.isEmpty();
806        }
807
808        public boolean hasBackCurve() { 
809          return this.backCurve != null && !this.backCurve.isEmpty();
810        }
811
812        /**
813         * @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
814         */
815        public VisionPrescriptionDispenseComponent setBackCurveElement(DecimalType value) { 
816          this.backCurve = value;
817          return this;
818        }
819
820        /**
821         * @return Back curvature measured in millimeters.
822         */
823        public BigDecimal getBackCurve() { 
824          return this.backCurve == null ? null : this.backCurve.getValue();
825        }
826
827        /**
828         * @param value Back curvature measured in millimeters.
829         */
830        public VisionPrescriptionDispenseComponent setBackCurve(BigDecimal value) { 
831          if (value == null)
832            this.backCurve = null;
833          else {
834            if (this.backCurve == null)
835              this.backCurve = new DecimalType();
836            this.backCurve.setValue(value);
837          }
838          return this;
839        }
840
841        /**
842         * @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
843         */
844        public DecimalType getDiameterElement() { 
845          if (this.diameter == null)
846            if (Configuration.errorOnAutoCreate())
847              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.diameter");
848            else if (Configuration.doAutoCreate())
849              this.diameter = new DecimalType(); // bb
850          return this.diameter;
851        }
852
853        public boolean hasDiameterElement() { 
854          return this.diameter != null && !this.diameter.isEmpty();
855        }
856
857        public boolean hasDiameter() { 
858          return this.diameter != null && !this.diameter.isEmpty();
859        }
860
861        /**
862         * @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
863         */
864        public VisionPrescriptionDispenseComponent setDiameterElement(DecimalType value) { 
865          this.diameter = value;
866          return this;
867        }
868
869        /**
870         * @return Contact lens diameter measured in millimeters.
871         */
872        public BigDecimal getDiameter() { 
873          return this.diameter == null ? null : this.diameter.getValue();
874        }
875
876        /**
877         * @param value Contact lens diameter measured in millimeters.
878         */
879        public VisionPrescriptionDispenseComponent setDiameter(BigDecimal value) { 
880          if (value == null)
881            this.diameter = null;
882          else {
883            if (this.diameter == null)
884              this.diameter = new DecimalType();
885            this.diameter.setValue(value);
886          }
887          return this;
888        }
889
890        /**
891         * @return {@link #duration} (The recommended maximum wear period for the lens.)
892         */
893        public SimpleQuantity getDuration() { 
894          if (this.duration == null)
895            if (Configuration.errorOnAutoCreate())
896              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.duration");
897            else if (Configuration.doAutoCreate())
898              this.duration = new SimpleQuantity(); // cc
899          return this.duration;
900        }
901
902        public boolean hasDuration() { 
903          return this.duration != null && !this.duration.isEmpty();
904        }
905
906        /**
907         * @param value {@link #duration} (The recommended maximum wear period for the lens.)
908         */
909        public VisionPrescriptionDispenseComponent setDuration(SimpleQuantity value) { 
910          this.duration = value;
911          return this;
912        }
913
914        /**
915         * @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
916         */
917        public StringType getColorElement() { 
918          if (this.color == null)
919            if (Configuration.errorOnAutoCreate())
920              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.color");
921            else if (Configuration.doAutoCreate())
922              this.color = new StringType(); // bb
923          return this.color;
924        }
925
926        public boolean hasColorElement() { 
927          return this.color != null && !this.color.isEmpty();
928        }
929
930        public boolean hasColor() { 
931          return this.color != null && !this.color.isEmpty();
932        }
933
934        /**
935         * @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
936         */
937        public VisionPrescriptionDispenseComponent setColorElement(StringType value) { 
938          this.color = value;
939          return this;
940        }
941
942        /**
943         * @return Special color or pattern.
944         */
945        public String getColor() { 
946          return this.color == null ? null : this.color.getValue();
947        }
948
949        /**
950         * @param value Special color or pattern.
951         */
952        public VisionPrescriptionDispenseComponent setColor(String value) { 
953          if (Utilities.noString(value))
954            this.color = null;
955          else {
956            if (this.color == null)
957              this.color = new StringType();
958            this.color.setValue(value);
959          }
960          return this;
961        }
962
963        /**
964         * @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
965         */
966        public StringType getBrandElement() { 
967          if (this.brand == null)
968            if (Configuration.errorOnAutoCreate())
969              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.brand");
970            else if (Configuration.doAutoCreate())
971              this.brand = new StringType(); // bb
972          return this.brand;
973        }
974
975        public boolean hasBrandElement() { 
976          return this.brand != null && !this.brand.isEmpty();
977        }
978
979        public boolean hasBrand() { 
980          return this.brand != null && !this.brand.isEmpty();
981        }
982
983        /**
984         * @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
985         */
986        public VisionPrescriptionDispenseComponent setBrandElement(StringType value) { 
987          this.brand = value;
988          return this;
989        }
990
991        /**
992         * @return Brand recommendations or restrictions.
993         */
994        public String getBrand() { 
995          return this.brand == null ? null : this.brand.getValue();
996        }
997
998        /**
999         * @param value Brand recommendations or restrictions.
1000         */
1001        public VisionPrescriptionDispenseComponent setBrand(String value) { 
1002          if (Utilities.noString(value))
1003            this.brand = null;
1004          else {
1005            if (this.brand == null)
1006              this.brand = new StringType();
1007            this.brand.setValue(value);
1008          }
1009          return this;
1010        }
1011
1012        /**
1013         * @return {@link #notes} (Notes for special requirements such as coatings and lens materials.). This is the underlying object with id, value and extensions. The accessor "getNotes" gives direct access to the value
1014         */
1015        public StringType getNotesElement() { 
1016          if (this.notes == null)
1017            if (Configuration.errorOnAutoCreate())
1018              throw new Error("Attempt to auto-create VisionPrescriptionDispenseComponent.notes");
1019            else if (Configuration.doAutoCreate())
1020              this.notes = new StringType(); // bb
1021          return this.notes;
1022        }
1023
1024        public boolean hasNotesElement() { 
1025          return this.notes != null && !this.notes.isEmpty();
1026        }
1027
1028        public boolean hasNotes() { 
1029          return this.notes != null && !this.notes.isEmpty();
1030        }
1031
1032        /**
1033         * @param value {@link #notes} (Notes for special requirements such as coatings and lens materials.). This is the underlying object with id, value and extensions. The accessor "getNotes" gives direct access to the value
1034         */
1035        public VisionPrescriptionDispenseComponent setNotesElement(StringType value) { 
1036          this.notes = value;
1037          return this;
1038        }
1039
1040        /**
1041         * @return Notes for special requirements such as coatings and lens materials.
1042         */
1043        public String getNotes() { 
1044          return this.notes == null ? null : this.notes.getValue();
1045        }
1046
1047        /**
1048         * @param value Notes for special requirements such as coatings and lens materials.
1049         */
1050        public VisionPrescriptionDispenseComponent setNotes(String value) { 
1051          if (Utilities.noString(value))
1052            this.notes = null;
1053          else {
1054            if (this.notes == null)
1055              this.notes = new StringType();
1056            this.notes.setValue(value);
1057          }
1058          return this;
1059        }
1060
1061        protected void listChildren(List<Property> childrenList) {
1062          super.listChildren(childrenList);
1063          childrenList.add(new Property("product", "Coding", "Identifies the type of vision correction product which is required for the patient.", 0, java.lang.Integer.MAX_VALUE, product));
1064          childrenList.add(new Property("eye", "code", "The eye for which the lens applies.", 0, java.lang.Integer.MAX_VALUE, eye));
1065          childrenList.add(new Property("sphere", "decimal", "Lens power measured in diopters (0.25 units).", 0, java.lang.Integer.MAX_VALUE, sphere));
1066          childrenList.add(new Property("cylinder", "decimal", "Power adjustment for astigmatism measured in diopters (0.25 units).", 0, java.lang.Integer.MAX_VALUE, cylinder));
1067          childrenList.add(new Property("axis", "integer", "Adjustment for astigmatism measured in integer degrees.", 0, java.lang.Integer.MAX_VALUE, axis));
1068          childrenList.add(new Property("prism", "decimal", "Amount of prism to compensate for eye alignment in fractional units.", 0, java.lang.Integer.MAX_VALUE, prism));
1069          childrenList.add(new Property("base", "code", "The relative base, or reference lens edge, for the prism.", 0, java.lang.Integer.MAX_VALUE, base));
1070          childrenList.add(new Property("add", "decimal", "Power adjustment for multifocal lenses measured in diopters (0.25 units).", 0, java.lang.Integer.MAX_VALUE, add));
1071          childrenList.add(new Property("power", "decimal", "Contact lens power measured in diopters (0.25 units).", 0, java.lang.Integer.MAX_VALUE, power));
1072          childrenList.add(new Property("backCurve", "decimal", "Back curvature measured in millimeters.", 0, java.lang.Integer.MAX_VALUE, backCurve));
1073          childrenList.add(new Property("diameter", "decimal", "Contact lens diameter measured in millimeters.", 0, java.lang.Integer.MAX_VALUE, diameter));
1074          childrenList.add(new Property("duration", "SimpleQuantity", "The recommended maximum wear period for the lens.", 0, java.lang.Integer.MAX_VALUE, duration));
1075          childrenList.add(new Property("color", "string", "Special color or pattern.", 0, java.lang.Integer.MAX_VALUE, color));
1076          childrenList.add(new Property("brand", "string", "Brand recommendations or restrictions.", 0, java.lang.Integer.MAX_VALUE, brand));
1077          childrenList.add(new Property("notes", "string", "Notes for special requirements such as coatings and lens materials.", 0, java.lang.Integer.MAX_VALUE, notes));
1078        }
1079
1080      @Override
1081      public void setProperty(String name, Base value) throws FHIRException {
1082        if (name.equals("product"))
1083          this.product = castToCoding(value); // Coding
1084        else if (name.equals("eye"))
1085          this.eye = new VisionEyesEnumFactory().fromType(value); // Enumeration<VisionEyes>
1086        else if (name.equals("sphere"))
1087          this.sphere = castToDecimal(value); // DecimalType
1088        else if (name.equals("cylinder"))
1089          this.cylinder = castToDecimal(value); // DecimalType
1090        else if (name.equals("axis"))
1091          this.axis = castToInteger(value); // IntegerType
1092        else if (name.equals("prism"))
1093          this.prism = castToDecimal(value); // DecimalType
1094        else if (name.equals("base"))
1095          this.base = new VisionBaseEnumFactory().fromType(value); // Enumeration<VisionBase>
1096        else if (name.equals("add"))
1097          this.add = castToDecimal(value); // DecimalType
1098        else if (name.equals("power"))
1099          this.power = castToDecimal(value); // DecimalType
1100        else if (name.equals("backCurve"))
1101          this.backCurve = castToDecimal(value); // DecimalType
1102        else if (name.equals("diameter"))
1103          this.diameter = castToDecimal(value); // DecimalType
1104        else if (name.equals("duration"))
1105          this.duration = castToSimpleQuantity(value); // SimpleQuantity
1106        else if (name.equals("color"))
1107          this.color = castToString(value); // StringType
1108        else if (name.equals("brand"))
1109          this.brand = castToString(value); // StringType
1110        else if (name.equals("notes"))
1111          this.notes = castToString(value); // StringType
1112        else
1113          super.setProperty(name, value);
1114      }
1115
1116      @Override
1117      public Base addChild(String name) throws FHIRException {
1118        if (name.equals("product")) {
1119          this.product = new Coding();
1120          return this.product;
1121        }
1122        else if (name.equals("eye")) {
1123          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.eye");
1124        }
1125        else if (name.equals("sphere")) {
1126          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.sphere");
1127        }
1128        else if (name.equals("cylinder")) {
1129          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.cylinder");
1130        }
1131        else if (name.equals("axis")) {
1132          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.axis");
1133        }
1134        else if (name.equals("prism")) {
1135          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.prism");
1136        }
1137        else if (name.equals("base")) {
1138          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.base");
1139        }
1140        else if (name.equals("add")) {
1141          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.add");
1142        }
1143        else if (name.equals("power")) {
1144          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.power");
1145        }
1146        else if (name.equals("backCurve")) {
1147          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.backCurve");
1148        }
1149        else if (name.equals("diameter")) {
1150          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.diameter");
1151        }
1152        else if (name.equals("duration")) {
1153          this.duration = new SimpleQuantity();
1154          return this.duration;
1155        }
1156        else if (name.equals("color")) {
1157          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.color");
1158        }
1159        else if (name.equals("brand")) {
1160          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.brand");
1161        }
1162        else if (name.equals("notes")) {
1163          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.notes");
1164        }
1165        else
1166          return super.addChild(name);
1167      }
1168
1169      public VisionPrescriptionDispenseComponent copy() {
1170        VisionPrescriptionDispenseComponent dst = new VisionPrescriptionDispenseComponent();
1171        copyValues(dst);
1172        dst.product = product == null ? null : product.copy();
1173        dst.eye = eye == null ? null : eye.copy();
1174        dst.sphere = sphere == null ? null : sphere.copy();
1175        dst.cylinder = cylinder == null ? null : cylinder.copy();
1176        dst.axis = axis == null ? null : axis.copy();
1177        dst.prism = prism == null ? null : prism.copy();
1178        dst.base = base == null ? null : base.copy();
1179        dst.add = add == null ? null : add.copy();
1180        dst.power = power == null ? null : power.copy();
1181        dst.backCurve = backCurve == null ? null : backCurve.copy();
1182        dst.diameter = diameter == null ? null : diameter.copy();
1183        dst.duration = duration == null ? null : duration.copy();
1184        dst.color = color == null ? null : color.copy();
1185        dst.brand = brand == null ? null : brand.copy();
1186        dst.notes = notes == null ? null : notes.copy();
1187        return dst;
1188      }
1189
1190      @Override
1191      public boolean equalsDeep(Base other) {
1192        if (!super.equalsDeep(other))
1193          return false;
1194        if (!(other instanceof VisionPrescriptionDispenseComponent))
1195          return false;
1196        VisionPrescriptionDispenseComponent o = (VisionPrescriptionDispenseComponent) other;
1197        return compareDeep(product, o.product, true) && compareDeep(eye, o.eye, true) && compareDeep(sphere, o.sphere, true)
1198           && compareDeep(cylinder, o.cylinder, true) && compareDeep(axis, o.axis, true) && compareDeep(prism, o.prism, true)
1199           && compareDeep(base, o.base, true) && compareDeep(add, o.add, true) && compareDeep(power, o.power, true)
1200           && compareDeep(backCurve, o.backCurve, true) && compareDeep(diameter, o.diameter, true) && compareDeep(duration, o.duration, true)
1201           && compareDeep(color, o.color, true) && compareDeep(brand, o.brand, true) && compareDeep(notes, o.notes, true)
1202          ;
1203      }
1204
1205      @Override
1206      public boolean equalsShallow(Base other) {
1207        if (!super.equalsShallow(other))
1208          return false;
1209        if (!(other instanceof VisionPrescriptionDispenseComponent))
1210          return false;
1211        VisionPrescriptionDispenseComponent o = (VisionPrescriptionDispenseComponent) other;
1212        return compareValues(eye, o.eye, true) && compareValues(sphere, o.sphere, true) && compareValues(cylinder, o.cylinder, true)
1213           && compareValues(axis, o.axis, true) && compareValues(prism, o.prism, true) && compareValues(base, o.base, true)
1214           && compareValues(add, o.add, true) && compareValues(power, o.power, true) && compareValues(backCurve, o.backCurve, true)
1215           && compareValues(diameter, o.diameter, true) && compareValues(color, o.color, true) && compareValues(brand, o.brand, true)
1216           && compareValues(notes, o.notes, true);
1217      }
1218
1219      public boolean isEmpty() {
1220        return super.isEmpty() && (product == null || product.isEmpty()) && (eye == null || eye.isEmpty())
1221           && (sphere == null || sphere.isEmpty()) && (cylinder == null || cylinder.isEmpty()) && (axis == null || axis.isEmpty())
1222           && (prism == null || prism.isEmpty()) && (base == null || base.isEmpty()) && (add == null || add.isEmpty())
1223           && (power == null || power.isEmpty()) && (backCurve == null || backCurve.isEmpty()) && (diameter == null || diameter.isEmpty())
1224           && (duration == null || duration.isEmpty()) && (color == null || color.isEmpty()) && (brand == null || brand.isEmpty())
1225           && (notes == null || notes.isEmpty());
1226      }
1227
1228  public String fhirType() {
1229    return "VisionPrescription.dispense";
1230
1231  }
1232
1233  }
1234
1235    /**
1236     * Business identifier which may be used by other parties to reference or identify the prescription.
1237     */
1238    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1239    @Description(shortDefinition="Business identifier", formalDefinition="Business identifier which may be used by other parties to reference or identify the prescription." )
1240    protected List<Identifier> identifier;
1241
1242    /**
1243     * The date (and perhaps time) when the prescription was written.
1244     */
1245    @Child(name = "dateWritten", type = {DateTimeType.class}, order=1, min=0, max=1, modifier=false, summary=true)
1246    @Description(shortDefinition="When prescription was authorized", formalDefinition="The date (and perhaps time) when the prescription was written." )
1247    protected DateTimeType dateWritten;
1248
1249    /**
1250     * A link to a resource representing the person to whom the vision products will be supplied.
1251     */
1252    @Child(name = "patient", type = {Patient.class}, order=2, min=0, max=1, modifier=false, summary=true)
1253    @Description(shortDefinition="Who prescription is for", formalDefinition="A link to a resource representing the person to whom the vision products will be supplied." )
1254    protected Reference patient;
1255
1256    /**
1257     * 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.)
1258     */
1259    protected Patient patientTarget;
1260
1261    /**
1262     * The healthcare professional responsible for authorizing the prescription.
1263     */
1264    @Child(name = "prescriber", type = {Practitioner.class}, order=3, min=0, max=1, modifier=false, summary=true)
1265    @Description(shortDefinition="Who authorizes the vision product", formalDefinition="The healthcare professional responsible for authorizing the prescription." )
1266    protected Reference prescriber;
1267
1268    /**
1269     * The actual object that is the target of the reference (The healthcare professional responsible for authorizing the prescription.)
1270     */
1271    protected Practitioner prescriberTarget;
1272
1273    /**
1274     * A link to a resource that identifies the particular occurrence of contact between patient and health care provider.
1275     */
1276    @Child(name = "encounter", type = {Encounter.class}, order=4, min=0, max=1, modifier=false, summary=true)
1277    @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." )
1278    protected Reference encounter;
1279
1280    /**
1281     * 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.)
1282     */
1283    protected Encounter encounterTarget;
1284
1285    /**
1286     * Can be the reason or the indication for writing the prescription.
1287     */
1288    @Child(name = "reason", type = {CodeableConcept.class, Condition.class}, order=5, min=0, max=1, modifier=false, summary=true)
1289    @Description(shortDefinition="Reason or indication for writing the prescription", formalDefinition="Can be the reason or the indication for writing the prescription." )
1290    protected Type reason;
1291
1292    /**
1293     * Deals with details of the dispense part of the supply specification.
1294     */
1295    @Child(name = "dispense", type = {}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1296    @Description(shortDefinition="Vision supply authorization", formalDefinition="Deals with details of the dispense part of the supply specification." )
1297    protected List<VisionPrescriptionDispenseComponent> dispense;
1298
1299    private static final long serialVersionUID = -1108276057L;
1300
1301  /*
1302   * Constructor
1303   */
1304    public VisionPrescription() {
1305      super();
1306    }
1307
1308    /**
1309     * @return {@link #identifier} (Business identifier which may be used by other parties to reference or identify the prescription.)
1310     */
1311    public List<Identifier> getIdentifier() { 
1312      if (this.identifier == null)
1313        this.identifier = new ArrayList<Identifier>();
1314      return this.identifier;
1315    }
1316
1317    public boolean hasIdentifier() { 
1318      if (this.identifier == null)
1319        return false;
1320      for (Identifier item : this.identifier)
1321        if (!item.isEmpty())
1322          return true;
1323      return false;
1324    }
1325
1326    /**
1327     * @return {@link #identifier} (Business identifier which may be used by other parties to reference or identify the prescription.)
1328     */
1329    // syntactic sugar
1330    public Identifier addIdentifier() { //3
1331      Identifier t = new Identifier();
1332      if (this.identifier == null)
1333        this.identifier = new ArrayList<Identifier>();
1334      this.identifier.add(t);
1335      return t;
1336    }
1337
1338    // syntactic sugar
1339    public VisionPrescription addIdentifier(Identifier t) { //3
1340      if (t == null)
1341        return this;
1342      if (this.identifier == null)
1343        this.identifier = new ArrayList<Identifier>();
1344      this.identifier.add(t);
1345      return this;
1346    }
1347
1348    /**
1349     * @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
1350     */
1351    public DateTimeType getDateWrittenElement() { 
1352      if (this.dateWritten == null)
1353        if (Configuration.errorOnAutoCreate())
1354          throw new Error("Attempt to auto-create VisionPrescription.dateWritten");
1355        else if (Configuration.doAutoCreate())
1356          this.dateWritten = new DateTimeType(); // bb
1357      return this.dateWritten;
1358    }
1359
1360    public boolean hasDateWrittenElement() { 
1361      return this.dateWritten != null && !this.dateWritten.isEmpty();
1362    }
1363
1364    public boolean hasDateWritten() { 
1365      return this.dateWritten != null && !this.dateWritten.isEmpty();
1366    }
1367
1368    /**
1369     * @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
1370     */
1371    public VisionPrescription setDateWrittenElement(DateTimeType value) { 
1372      this.dateWritten = value;
1373      return this;
1374    }
1375
1376    /**
1377     * @return The date (and perhaps time) when the prescription was written.
1378     */
1379    public Date getDateWritten() { 
1380      return this.dateWritten == null ? null : this.dateWritten.getValue();
1381    }
1382
1383    /**
1384     * @param value The date (and perhaps time) when the prescription was written.
1385     */
1386    public VisionPrescription setDateWritten(Date value) { 
1387      if (value == null)
1388        this.dateWritten = null;
1389      else {
1390        if (this.dateWritten == null)
1391          this.dateWritten = new DateTimeType();
1392        this.dateWritten.setValue(value);
1393      }
1394      return this;
1395    }
1396
1397    /**
1398     * @return {@link #patient} (A link to a resource representing the person to whom the vision products will be supplied.)
1399     */
1400    public Reference getPatient() { 
1401      if (this.patient == null)
1402        if (Configuration.errorOnAutoCreate())
1403          throw new Error("Attempt to auto-create VisionPrescription.patient");
1404        else if (Configuration.doAutoCreate())
1405          this.patient = new Reference(); // cc
1406      return this.patient;
1407    }
1408
1409    public boolean hasPatient() { 
1410      return this.patient != null && !this.patient.isEmpty();
1411    }
1412
1413    /**
1414     * @param value {@link #patient} (A link to a resource representing the person to whom the vision products will be supplied.)
1415     */
1416    public VisionPrescription setPatient(Reference value) { 
1417      this.patient = value;
1418      return this;
1419    }
1420
1421    /**
1422     * @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.)
1423     */
1424    public Patient getPatientTarget() { 
1425      if (this.patientTarget == null)
1426        if (Configuration.errorOnAutoCreate())
1427          throw new Error("Attempt to auto-create VisionPrescription.patient");
1428        else if (Configuration.doAutoCreate())
1429          this.patientTarget = new Patient(); // aa
1430      return this.patientTarget;
1431    }
1432
1433    /**
1434     * @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.)
1435     */
1436    public VisionPrescription setPatientTarget(Patient value) { 
1437      this.patientTarget = value;
1438      return this;
1439    }
1440
1441    /**
1442     * @return {@link #prescriber} (The healthcare professional responsible for authorizing the prescription.)
1443     */
1444    public Reference getPrescriber() { 
1445      if (this.prescriber == null)
1446        if (Configuration.errorOnAutoCreate())
1447          throw new Error("Attempt to auto-create VisionPrescription.prescriber");
1448        else if (Configuration.doAutoCreate())
1449          this.prescriber = new Reference(); // cc
1450      return this.prescriber;
1451    }
1452
1453    public boolean hasPrescriber() { 
1454      return this.prescriber != null && !this.prescriber.isEmpty();
1455    }
1456
1457    /**
1458     * @param value {@link #prescriber} (The healthcare professional responsible for authorizing the prescription.)
1459     */
1460    public VisionPrescription setPrescriber(Reference value) { 
1461      this.prescriber = value;
1462      return this;
1463    }
1464
1465    /**
1466     * @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.)
1467     */
1468    public Practitioner getPrescriberTarget() { 
1469      if (this.prescriberTarget == null)
1470        if (Configuration.errorOnAutoCreate())
1471          throw new Error("Attempt to auto-create VisionPrescription.prescriber");
1472        else if (Configuration.doAutoCreate())
1473          this.prescriberTarget = new Practitioner(); // aa
1474      return this.prescriberTarget;
1475    }
1476
1477    /**
1478     * @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.)
1479     */
1480    public VisionPrescription setPrescriberTarget(Practitioner value) { 
1481      this.prescriberTarget = value;
1482      return this;
1483    }
1484
1485    /**
1486     * @return {@link #encounter} (A link to a resource that identifies the particular occurrence of contact between patient and health care provider.)
1487     */
1488    public Reference getEncounter() { 
1489      if (this.encounter == null)
1490        if (Configuration.errorOnAutoCreate())
1491          throw new Error("Attempt to auto-create VisionPrescription.encounter");
1492        else if (Configuration.doAutoCreate())
1493          this.encounter = new Reference(); // cc
1494      return this.encounter;
1495    }
1496
1497    public boolean hasEncounter() { 
1498      return this.encounter != null && !this.encounter.isEmpty();
1499    }
1500
1501    /**
1502     * @param value {@link #encounter} (A link to a resource that identifies the particular occurrence of contact between patient and health care provider.)
1503     */
1504    public VisionPrescription setEncounter(Reference value) { 
1505      this.encounter = value;
1506      return this;
1507    }
1508
1509    /**
1510     * @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.)
1511     */
1512    public Encounter getEncounterTarget() { 
1513      if (this.encounterTarget == null)
1514        if (Configuration.errorOnAutoCreate())
1515          throw new Error("Attempt to auto-create VisionPrescription.encounter");
1516        else if (Configuration.doAutoCreate())
1517          this.encounterTarget = new Encounter(); // aa
1518      return this.encounterTarget;
1519    }
1520
1521    /**
1522     * @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.)
1523     */
1524    public VisionPrescription setEncounterTarget(Encounter value) { 
1525      this.encounterTarget = value;
1526      return this;
1527    }
1528
1529    /**
1530     * @return {@link #reason} (Can be the reason or the indication for writing the prescription.)
1531     */
1532    public Type getReason() { 
1533      return this.reason;
1534    }
1535
1536    /**
1537     * @return {@link #reason} (Can be the reason or the indication for writing the prescription.)
1538     */
1539    public CodeableConcept getReasonCodeableConcept() throws FHIRException { 
1540      if (!(this.reason instanceof CodeableConcept))
1541        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.reason.getClass().getName()+" was encountered");
1542      return (CodeableConcept) this.reason;
1543    }
1544
1545    public boolean hasReasonCodeableConcept() { 
1546      return this.reason instanceof CodeableConcept;
1547    }
1548
1549    /**
1550     * @return {@link #reason} (Can be the reason or the indication for writing the prescription.)
1551     */
1552    public Reference getReasonReference() throws FHIRException { 
1553      if (!(this.reason instanceof Reference))
1554        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.reason.getClass().getName()+" was encountered");
1555      return (Reference) this.reason;
1556    }
1557
1558    public boolean hasReasonReference() { 
1559      return this.reason instanceof Reference;
1560    }
1561
1562    public boolean hasReason() { 
1563      return this.reason != null && !this.reason.isEmpty();
1564    }
1565
1566    /**
1567     * @param value {@link #reason} (Can be the reason or the indication for writing the prescription.)
1568     */
1569    public VisionPrescription setReason(Type value) { 
1570      this.reason = value;
1571      return this;
1572    }
1573
1574    /**
1575     * @return {@link #dispense} (Deals with details of the dispense part of the supply specification.)
1576     */
1577    public List<VisionPrescriptionDispenseComponent> getDispense() { 
1578      if (this.dispense == null)
1579        this.dispense = new ArrayList<VisionPrescriptionDispenseComponent>();
1580      return this.dispense;
1581    }
1582
1583    public boolean hasDispense() { 
1584      if (this.dispense == null)
1585        return false;
1586      for (VisionPrescriptionDispenseComponent item : this.dispense)
1587        if (!item.isEmpty())
1588          return true;
1589      return false;
1590    }
1591
1592    /**
1593     * @return {@link #dispense} (Deals with details of the dispense part of the supply specification.)
1594     */
1595    // syntactic sugar
1596    public VisionPrescriptionDispenseComponent addDispense() { //3
1597      VisionPrescriptionDispenseComponent t = new VisionPrescriptionDispenseComponent();
1598      if (this.dispense == null)
1599        this.dispense = new ArrayList<VisionPrescriptionDispenseComponent>();
1600      this.dispense.add(t);
1601      return t;
1602    }
1603
1604    // syntactic sugar
1605    public VisionPrescription addDispense(VisionPrescriptionDispenseComponent t) { //3
1606      if (t == null)
1607        return this;
1608      if (this.dispense == null)
1609        this.dispense = new ArrayList<VisionPrescriptionDispenseComponent>();
1610      this.dispense.add(t);
1611      return this;
1612    }
1613
1614      protected void listChildren(List<Property> childrenList) {
1615        super.listChildren(childrenList);
1616        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));
1617        childrenList.add(new Property("dateWritten", "dateTime", "The date (and perhaps time) when the prescription was written.", 0, java.lang.Integer.MAX_VALUE, dateWritten));
1618        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));
1619        childrenList.add(new Property("prescriber", "Reference(Practitioner)", "The healthcare professional responsible for authorizing the prescription.", 0, java.lang.Integer.MAX_VALUE, prescriber));
1620        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));
1621        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));
1622        childrenList.add(new Property("dispense", "", "Deals with details of the dispense part of the supply specification.", 0, java.lang.Integer.MAX_VALUE, dispense));
1623      }
1624
1625      @Override
1626      public void setProperty(String name, Base value) throws FHIRException {
1627        if (name.equals("identifier"))
1628          this.getIdentifier().add(castToIdentifier(value));
1629        else if (name.equals("dateWritten"))
1630          this.dateWritten = castToDateTime(value); // DateTimeType
1631        else if (name.equals("patient"))
1632          this.patient = castToReference(value); // Reference
1633        else if (name.equals("prescriber"))
1634          this.prescriber = castToReference(value); // Reference
1635        else if (name.equals("encounter"))
1636          this.encounter = castToReference(value); // Reference
1637        else if (name.equals("reason[x]"))
1638          this.reason = (Type) value; // Type
1639        else if (name.equals("dispense"))
1640          this.getDispense().add((VisionPrescriptionDispenseComponent) value);
1641        else
1642          super.setProperty(name, value);
1643      }
1644
1645      @Override
1646      public Base addChild(String name) throws FHIRException {
1647        if (name.equals("identifier")) {
1648          return addIdentifier();
1649        }
1650        else if (name.equals("dateWritten")) {
1651          throw new FHIRException("Cannot call addChild on a primitive type VisionPrescription.dateWritten");
1652        }
1653        else if (name.equals("patient")) {
1654          this.patient = new Reference();
1655          return this.patient;
1656        }
1657        else if (name.equals("prescriber")) {
1658          this.prescriber = new Reference();
1659          return this.prescriber;
1660        }
1661        else if (name.equals("encounter")) {
1662          this.encounter = new Reference();
1663          return this.encounter;
1664        }
1665        else if (name.equals("reasonCodeableConcept")) {
1666          this.reason = new CodeableConcept();
1667          return this.reason;
1668        }
1669        else if (name.equals("reasonReference")) {
1670          this.reason = new Reference();
1671          return this.reason;
1672        }
1673        else if (name.equals("dispense")) {
1674          return addDispense();
1675        }
1676        else
1677          return super.addChild(name);
1678      }
1679
1680  public String fhirType() {
1681    return "VisionPrescription";
1682
1683  }
1684
1685      public VisionPrescription copy() {
1686        VisionPrescription dst = new VisionPrescription();
1687        copyValues(dst);
1688        if (identifier != null) {
1689          dst.identifier = new ArrayList<Identifier>();
1690          for (Identifier i : identifier)
1691            dst.identifier.add(i.copy());
1692        };
1693        dst.dateWritten = dateWritten == null ? null : dateWritten.copy();
1694        dst.patient = patient == null ? null : patient.copy();
1695        dst.prescriber = prescriber == null ? null : prescriber.copy();
1696        dst.encounter = encounter == null ? null : encounter.copy();
1697        dst.reason = reason == null ? null : reason.copy();
1698        if (dispense != null) {
1699          dst.dispense = new ArrayList<VisionPrescriptionDispenseComponent>();
1700          for (VisionPrescriptionDispenseComponent i : dispense)
1701            dst.dispense.add(i.copy());
1702        };
1703        return dst;
1704      }
1705
1706      protected VisionPrescription typedCopy() {
1707        return copy();
1708      }
1709
1710      @Override
1711      public boolean equalsDeep(Base other) {
1712        if (!super.equalsDeep(other))
1713          return false;
1714        if (!(other instanceof VisionPrescription))
1715          return false;
1716        VisionPrescription o = (VisionPrescription) other;
1717        return compareDeep(identifier, o.identifier, true) && compareDeep(dateWritten, o.dateWritten, true)
1718           && compareDeep(patient, o.patient, true) && compareDeep(prescriber, o.prescriber, true) && compareDeep(encounter, o.encounter, true)
1719           && compareDeep(reason, o.reason, true) && compareDeep(dispense, o.dispense, true);
1720      }
1721
1722      @Override
1723      public boolean equalsShallow(Base other) {
1724        if (!super.equalsShallow(other))
1725          return false;
1726        if (!(other instanceof VisionPrescription))
1727          return false;
1728        VisionPrescription o = (VisionPrescription) other;
1729        return compareValues(dateWritten, o.dateWritten, true);
1730      }
1731
1732      public boolean isEmpty() {
1733        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (dateWritten == null || dateWritten.isEmpty())
1734           && (patient == null || patient.isEmpty()) && (prescriber == null || prescriber.isEmpty())
1735           && (encounter == null || encounter.isEmpty()) && (reason == null || reason.isEmpty()) && (dispense == null || dispense.isEmpty())
1736          ;
1737      }
1738
1739  @Override
1740  public ResourceType getResourceType() {
1741    return ResourceType.VisionPrescription;
1742   }
1743
1744  @SearchParamDefinition(name="prescriber", path="VisionPrescription.prescriber", description="Who authorizes the vision product", type="reference" )
1745  public static final String SP_PRESCRIBER = "prescriber";
1746  @SearchParamDefinition(name="identifier", path="VisionPrescription.identifier", description="Return prescriptions with this external identifier", type="token" )
1747  public static final String SP_IDENTIFIER = "identifier";
1748  @SearchParamDefinition(name="patient", path="VisionPrescription.patient", description="The identity of a patient to list dispenses for", type="reference" )
1749  public static final String SP_PATIENT = "patient";
1750  @SearchParamDefinition(name="datewritten", path="VisionPrescription.dateWritten", description="Return prescriptions written on this date", type="date" )
1751  public static final String SP_DATEWRITTEN = "datewritten";
1752  @SearchParamDefinition(name="encounter", path="VisionPrescription.encounter", description="Return prescriptions with this encounter identifier", type="reference" )
1753  public static final String SP_ENCOUNTER = "encounter";
1754
1755}