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