001package org.hl7.fhir.r5.model;
002
003/*-
004 * #%L
005 * org.hl7.fhir.r5
006 * %%
007 * Copyright (C) 2014 - 2019 Health Level 7
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023/*
024  Copyright (c) 2011+, HL7, Inc.
025  All rights reserved.
026  
027  Redistribution and use in source and binary forms, with or without modification, 
028  are permitted provided that the following conditions are met:
029  
030   * Redistributions of source code must retain the above copyright notice, this 
031     list of conditions and the following disclaimer.
032   * Redistributions in binary form must reproduce the above copyright notice, 
033     this list of conditions and the following disclaimer in the documentation 
034     and/or other materials provided with the distribution.
035   * Neither the name of HL7 nor the names of its contributors may be used to 
036     endorse or promote products derived from this software without specific 
037     prior written permission.
038  
039  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
040  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
041  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
042  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
043  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
044  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
045  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
046  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
047  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
048  POSSIBILITY OF SUCH DAMAGE.
049  
050*/
051
052// Generated on Thu, Dec 13, 2018 14:07+1100 for FHIR v4.0.0
053import java.util.ArrayList;
054import java.util.Date;
055import java.util.List;
056import org.hl7.fhir.exceptions.FHIRException;
057import org.hl7.fhir.instance.model.api.ICompositeType;
058
059import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
060import org.hl7.fhir.utilities.Utilities;
061import ca.uhn.fhir.model.api.annotation.ResourceDef;
062import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
063import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
064import ca.uhn.fhir.model.api.annotation.Child;
065import ca.uhn.fhir.model.api.annotation.ChildOrder;
066import ca.uhn.fhir.model.api.annotation.Description;
067import ca.uhn.fhir.model.api.annotation.Block;
068/**
069 * A specific set of Roles/Locations/specialties/services that a practitioner may perform at an organization for a period of time.
070 */
071@ResourceDef(name="PractitionerRole", profile="http://hl7.org/fhir/StructureDefinition/PractitionerRole")
072public class PractitionerRole extends DomainResource {
073
074    public enum DaysOfWeek {
075        /**
076         * Monday.
077         */
078        MON, 
079        /**
080         * Tuesday.
081         */
082        TUE, 
083        /**
084         * Wednesday.
085         */
086        WED, 
087        /**
088         * Thursday.
089         */
090        THU, 
091        /**
092         * Friday.
093         */
094        FRI, 
095        /**
096         * Saturday.
097         */
098        SAT, 
099        /**
100         * Sunday.
101         */
102        SUN, 
103        /**
104         * added to help the parsers with the generic types
105         */
106        NULL;
107        public static DaysOfWeek fromCode(String codeString) throws FHIRException {
108            if (codeString == null || "".equals(codeString))
109                return null;
110        if ("mon".equals(codeString))
111          return MON;
112        if ("tue".equals(codeString))
113          return TUE;
114        if ("wed".equals(codeString))
115          return WED;
116        if ("thu".equals(codeString))
117          return THU;
118        if ("fri".equals(codeString))
119          return FRI;
120        if ("sat".equals(codeString))
121          return SAT;
122        if ("sun".equals(codeString))
123          return SUN;
124        if (Configuration.isAcceptInvalidEnums())
125          return null;
126        else
127          throw new FHIRException("Unknown DaysOfWeek code '"+codeString+"'");
128        }
129        public String toCode() {
130          switch (this) {
131            case MON: return "mon";
132            case TUE: return "tue";
133            case WED: return "wed";
134            case THU: return "thu";
135            case FRI: return "fri";
136            case SAT: return "sat";
137            case SUN: return "sun";
138            default: return "?";
139          }
140        }
141        public String getSystem() {
142          switch (this) {
143            case MON: return "http://hl7.org/fhir/days-of-week";
144            case TUE: return "http://hl7.org/fhir/days-of-week";
145            case WED: return "http://hl7.org/fhir/days-of-week";
146            case THU: return "http://hl7.org/fhir/days-of-week";
147            case FRI: return "http://hl7.org/fhir/days-of-week";
148            case SAT: return "http://hl7.org/fhir/days-of-week";
149            case SUN: return "http://hl7.org/fhir/days-of-week";
150            default: return "?";
151          }
152        }
153        public String getDefinition() {
154          switch (this) {
155            case MON: return "Monday.";
156            case TUE: return "Tuesday.";
157            case WED: return "Wednesday.";
158            case THU: return "Thursday.";
159            case FRI: return "Friday.";
160            case SAT: return "Saturday.";
161            case SUN: return "Sunday.";
162            default: return "?";
163          }
164        }
165        public String getDisplay() {
166          switch (this) {
167            case MON: return "Monday";
168            case TUE: return "Tuesday";
169            case WED: return "Wednesday";
170            case THU: return "Thursday";
171            case FRI: return "Friday";
172            case SAT: return "Saturday";
173            case SUN: return "Sunday";
174            default: return "?";
175          }
176        }
177    }
178
179  public static class DaysOfWeekEnumFactory implements EnumFactory<DaysOfWeek> {
180    public DaysOfWeek fromCode(String codeString) throws IllegalArgumentException {
181      if (codeString == null || "".equals(codeString))
182            if (codeString == null || "".equals(codeString))
183                return null;
184        if ("mon".equals(codeString))
185          return DaysOfWeek.MON;
186        if ("tue".equals(codeString))
187          return DaysOfWeek.TUE;
188        if ("wed".equals(codeString))
189          return DaysOfWeek.WED;
190        if ("thu".equals(codeString))
191          return DaysOfWeek.THU;
192        if ("fri".equals(codeString))
193          return DaysOfWeek.FRI;
194        if ("sat".equals(codeString))
195          return DaysOfWeek.SAT;
196        if ("sun".equals(codeString))
197          return DaysOfWeek.SUN;
198        throw new IllegalArgumentException("Unknown DaysOfWeek code '"+codeString+"'");
199        }
200        public Enumeration<DaysOfWeek> fromType(Base code) throws FHIRException {
201          if (code == null)
202            return null;
203          if (code.isEmpty())
204            return new Enumeration<DaysOfWeek>(this);
205          String codeString = ((PrimitiveType) code).asStringValue();
206          if (codeString == null || "".equals(codeString))
207            return null;
208        if ("mon".equals(codeString))
209          return new Enumeration<DaysOfWeek>(this, DaysOfWeek.MON);
210        if ("tue".equals(codeString))
211          return new Enumeration<DaysOfWeek>(this, DaysOfWeek.TUE);
212        if ("wed".equals(codeString))
213          return new Enumeration<DaysOfWeek>(this, DaysOfWeek.WED);
214        if ("thu".equals(codeString))
215          return new Enumeration<DaysOfWeek>(this, DaysOfWeek.THU);
216        if ("fri".equals(codeString))
217          return new Enumeration<DaysOfWeek>(this, DaysOfWeek.FRI);
218        if ("sat".equals(codeString))
219          return new Enumeration<DaysOfWeek>(this, DaysOfWeek.SAT);
220        if ("sun".equals(codeString))
221          return new Enumeration<DaysOfWeek>(this, DaysOfWeek.SUN);
222        throw new FHIRException("Unknown DaysOfWeek code '"+codeString+"'");
223        }
224    public String toCode(DaysOfWeek code) {
225      if (code == DaysOfWeek.MON)
226        return "mon";
227      if (code == DaysOfWeek.TUE)
228        return "tue";
229      if (code == DaysOfWeek.WED)
230        return "wed";
231      if (code == DaysOfWeek.THU)
232        return "thu";
233      if (code == DaysOfWeek.FRI)
234        return "fri";
235      if (code == DaysOfWeek.SAT)
236        return "sat";
237      if (code == DaysOfWeek.SUN)
238        return "sun";
239      return "?";
240      }
241    public String toSystem(DaysOfWeek code) {
242      return code.getSystem();
243      }
244    }
245
246    @Block()
247    public static class PractitionerRoleAvailableTimeComponent extends BackboneElement implements IBaseBackboneElement {
248        /**
249         * Indicates which days of the week are available between the start and end Times.
250         */
251        @Child(name = "daysOfWeek", type = {CodeType.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
252        @Description(shortDefinition="mon | tue | wed | thu | fri | sat | sun", formalDefinition="Indicates which days of the week are available between the start and end Times." )
253        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/days-of-week")
254        protected List<Enumeration<DaysOfWeek>> daysOfWeek;
255
256        /**
257         * Is this always available? (hence times are irrelevant) e.g. 24 hour service.
258         */
259        @Child(name = "allDay", type = {BooleanType.class}, order=2, min=0, max=1, modifier=false, summary=false)
260        @Description(shortDefinition="Always available? e.g. 24 hour service", formalDefinition="Is this always available? (hence times are irrelevant) e.g. 24 hour service." )
261        protected BooleanType allDay;
262
263        /**
264         * The opening time of day. Note: If the AllDay flag is set, then this time is ignored.
265         */
266        @Child(name = "availableStartTime", type = {TimeType.class}, order=3, min=0, max=1, modifier=false, summary=false)
267        @Description(shortDefinition="Opening time of day (ignored if allDay = true)", formalDefinition="The opening time of day. Note: If the AllDay flag is set, then this time is ignored." )
268        protected TimeType availableStartTime;
269
270        /**
271         * The closing time of day. Note: If the AllDay flag is set, then this time is ignored.
272         */
273        @Child(name = "availableEndTime", type = {TimeType.class}, order=4, min=0, max=1, modifier=false, summary=false)
274        @Description(shortDefinition="Closing time of day (ignored if allDay = true)", formalDefinition="The closing time of day. Note: If the AllDay flag is set, then this time is ignored." )
275        protected TimeType availableEndTime;
276
277        private static final long serialVersionUID = -2139510127L;
278
279    /**
280     * Constructor
281     */
282      public PractitionerRoleAvailableTimeComponent() {
283        super();
284      }
285
286        /**
287         * @return {@link #daysOfWeek} (Indicates which days of the week are available between the start and end Times.)
288         */
289        public List<Enumeration<DaysOfWeek>> getDaysOfWeek() { 
290          if (this.daysOfWeek == null)
291            this.daysOfWeek = new ArrayList<Enumeration<DaysOfWeek>>();
292          return this.daysOfWeek;
293        }
294
295        /**
296         * @return Returns a reference to <code>this</code> for easy method chaining
297         */
298        public PractitionerRoleAvailableTimeComponent setDaysOfWeek(List<Enumeration<DaysOfWeek>> theDaysOfWeek) { 
299          this.daysOfWeek = theDaysOfWeek;
300          return this;
301        }
302
303        public boolean hasDaysOfWeek() { 
304          if (this.daysOfWeek == null)
305            return false;
306          for (Enumeration<DaysOfWeek> item : this.daysOfWeek)
307            if (!item.isEmpty())
308              return true;
309          return false;
310        }
311
312        /**
313         * @return {@link #daysOfWeek} (Indicates which days of the week are available between the start and end Times.)
314         */
315        public Enumeration<DaysOfWeek> addDaysOfWeekElement() {//2 
316          Enumeration<DaysOfWeek> t = new Enumeration<DaysOfWeek>(new DaysOfWeekEnumFactory());
317          if (this.daysOfWeek == null)
318            this.daysOfWeek = new ArrayList<Enumeration<DaysOfWeek>>();
319          this.daysOfWeek.add(t);
320          return t;
321        }
322
323        /**
324         * @param value {@link #daysOfWeek} (Indicates which days of the week are available between the start and end Times.)
325         */
326        public PractitionerRoleAvailableTimeComponent addDaysOfWeek(DaysOfWeek value) { //1
327          Enumeration<DaysOfWeek> t = new Enumeration<DaysOfWeek>(new DaysOfWeekEnumFactory());
328          t.setValue(value);
329          if (this.daysOfWeek == null)
330            this.daysOfWeek = new ArrayList<Enumeration<DaysOfWeek>>();
331          this.daysOfWeek.add(t);
332          return this;
333        }
334
335        /**
336         * @param value {@link #daysOfWeek} (Indicates which days of the week are available between the start and end Times.)
337         */
338        public boolean hasDaysOfWeek(DaysOfWeek value) { 
339          if (this.daysOfWeek == null)
340            return false;
341          for (Enumeration<DaysOfWeek> v : this.daysOfWeek)
342            if (v.getValue().equals(value)) // code
343              return true;
344          return false;
345        }
346
347        /**
348         * @return {@link #allDay} (Is this always available? (hence times are irrelevant) e.g. 24 hour service.). This is the underlying object with id, value and extensions. The accessor "getAllDay" gives direct access to the value
349         */
350        public BooleanType getAllDayElement() { 
351          if (this.allDay == null)
352            if (Configuration.errorOnAutoCreate())
353              throw new Error("Attempt to auto-create PractitionerRoleAvailableTimeComponent.allDay");
354            else if (Configuration.doAutoCreate())
355              this.allDay = new BooleanType(); // bb
356          return this.allDay;
357        }
358
359        public boolean hasAllDayElement() { 
360          return this.allDay != null && !this.allDay.isEmpty();
361        }
362
363        public boolean hasAllDay() { 
364          return this.allDay != null && !this.allDay.isEmpty();
365        }
366
367        /**
368         * @param value {@link #allDay} (Is this always available? (hence times are irrelevant) e.g. 24 hour service.). This is the underlying object with id, value and extensions. The accessor "getAllDay" gives direct access to the value
369         */
370        public PractitionerRoleAvailableTimeComponent setAllDayElement(BooleanType value) { 
371          this.allDay = value;
372          return this;
373        }
374
375        /**
376         * @return Is this always available? (hence times are irrelevant) e.g. 24 hour service.
377         */
378        public boolean getAllDay() { 
379          return this.allDay == null || this.allDay.isEmpty() ? false : this.allDay.getValue();
380        }
381
382        /**
383         * @param value Is this always available? (hence times are irrelevant) e.g. 24 hour service.
384         */
385        public PractitionerRoleAvailableTimeComponent setAllDay(boolean value) { 
386            if (this.allDay == null)
387              this.allDay = new BooleanType();
388            this.allDay.setValue(value);
389          return this;
390        }
391
392        /**
393         * @return {@link #availableStartTime} (The opening time of day. Note: If the AllDay flag is set, then this time is ignored.). This is the underlying object with id, value and extensions. The accessor "getAvailableStartTime" gives direct access to the value
394         */
395        public TimeType getAvailableStartTimeElement() { 
396          if (this.availableStartTime == null)
397            if (Configuration.errorOnAutoCreate())
398              throw new Error("Attempt to auto-create PractitionerRoleAvailableTimeComponent.availableStartTime");
399            else if (Configuration.doAutoCreate())
400              this.availableStartTime = new TimeType(); // bb
401          return this.availableStartTime;
402        }
403
404        public boolean hasAvailableStartTimeElement() { 
405          return this.availableStartTime != null && !this.availableStartTime.isEmpty();
406        }
407
408        public boolean hasAvailableStartTime() { 
409          return this.availableStartTime != null && !this.availableStartTime.isEmpty();
410        }
411
412        /**
413         * @param value {@link #availableStartTime} (The opening time of day. Note: If the AllDay flag is set, then this time is ignored.). This is the underlying object with id, value and extensions. The accessor "getAvailableStartTime" gives direct access to the value
414         */
415        public PractitionerRoleAvailableTimeComponent setAvailableStartTimeElement(TimeType value) { 
416          this.availableStartTime = value;
417          return this;
418        }
419
420        /**
421         * @return The opening time of day. Note: If the AllDay flag is set, then this time is ignored.
422         */
423        public String getAvailableStartTime() { 
424          return this.availableStartTime == null ? null : this.availableStartTime.getValue();
425        }
426
427        /**
428         * @param value The opening time of day. Note: If the AllDay flag is set, then this time is ignored.
429         */
430        public PractitionerRoleAvailableTimeComponent setAvailableStartTime(String value) { 
431          if (value == null)
432            this.availableStartTime = null;
433          else {
434            if (this.availableStartTime == null)
435              this.availableStartTime = new TimeType();
436            this.availableStartTime.setValue(value);
437          }
438          return this;
439        }
440
441        /**
442         * @return {@link #availableEndTime} (The closing time of day. Note: If the AllDay flag is set, then this time is ignored.). This is the underlying object with id, value and extensions. The accessor "getAvailableEndTime" gives direct access to the value
443         */
444        public TimeType getAvailableEndTimeElement() { 
445          if (this.availableEndTime == null)
446            if (Configuration.errorOnAutoCreate())
447              throw new Error("Attempt to auto-create PractitionerRoleAvailableTimeComponent.availableEndTime");
448            else if (Configuration.doAutoCreate())
449              this.availableEndTime = new TimeType(); // bb
450          return this.availableEndTime;
451        }
452
453        public boolean hasAvailableEndTimeElement() { 
454          return this.availableEndTime != null && !this.availableEndTime.isEmpty();
455        }
456
457        public boolean hasAvailableEndTime() { 
458          return this.availableEndTime != null && !this.availableEndTime.isEmpty();
459        }
460
461        /**
462         * @param value {@link #availableEndTime} (The closing time of day. Note: If the AllDay flag is set, then this time is ignored.). This is the underlying object with id, value and extensions. The accessor "getAvailableEndTime" gives direct access to the value
463         */
464        public PractitionerRoleAvailableTimeComponent setAvailableEndTimeElement(TimeType value) { 
465          this.availableEndTime = value;
466          return this;
467        }
468
469        /**
470         * @return The closing time of day. Note: If the AllDay flag is set, then this time is ignored.
471         */
472        public String getAvailableEndTime() { 
473          return this.availableEndTime == null ? null : this.availableEndTime.getValue();
474        }
475
476        /**
477         * @param value The closing time of day. Note: If the AllDay flag is set, then this time is ignored.
478         */
479        public PractitionerRoleAvailableTimeComponent setAvailableEndTime(String value) { 
480          if (value == null)
481            this.availableEndTime = null;
482          else {
483            if (this.availableEndTime == null)
484              this.availableEndTime = new TimeType();
485            this.availableEndTime.setValue(value);
486          }
487          return this;
488        }
489
490        protected void listChildren(List<Property> children) {
491          super.listChildren(children);
492          children.add(new Property("daysOfWeek", "code", "Indicates which days of the week are available between the start and end Times.", 0, java.lang.Integer.MAX_VALUE, daysOfWeek));
493          children.add(new Property("allDay", "boolean", "Is this always available? (hence times are irrelevant) e.g. 24 hour service.", 0, 1, allDay));
494          children.add(new Property("availableStartTime", "time", "The opening time of day. Note: If the AllDay flag is set, then this time is ignored.", 0, 1, availableStartTime));
495          children.add(new Property("availableEndTime", "time", "The closing time of day. Note: If the AllDay flag is set, then this time is ignored.", 0, 1, availableEndTime));
496        }
497
498        @Override
499        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
500          switch (_hash) {
501          case 68050338: /*daysOfWeek*/  return new Property("daysOfWeek", "code", "Indicates which days of the week are available between the start and end Times.", 0, java.lang.Integer.MAX_VALUE, daysOfWeek);
502          case -1414913477: /*allDay*/  return new Property("allDay", "boolean", "Is this always available? (hence times are irrelevant) e.g. 24 hour service.", 0, 1, allDay);
503          case -1039453818: /*availableStartTime*/  return new Property("availableStartTime", "time", "The opening time of day. Note: If the AllDay flag is set, then this time is ignored.", 0, 1, availableStartTime);
504          case 101151551: /*availableEndTime*/  return new Property("availableEndTime", "time", "The closing time of day. Note: If the AllDay flag is set, then this time is ignored.", 0, 1, availableEndTime);
505          default: return super.getNamedProperty(_hash, _name, _checkValid);
506          }
507
508        }
509
510      @Override
511      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
512        switch (hash) {
513        case 68050338: /*daysOfWeek*/ return this.daysOfWeek == null ? new Base[0] : this.daysOfWeek.toArray(new Base[this.daysOfWeek.size()]); // Enumeration<DaysOfWeek>
514        case -1414913477: /*allDay*/ return this.allDay == null ? new Base[0] : new Base[] {this.allDay}; // BooleanType
515        case -1039453818: /*availableStartTime*/ return this.availableStartTime == null ? new Base[0] : new Base[] {this.availableStartTime}; // TimeType
516        case 101151551: /*availableEndTime*/ return this.availableEndTime == null ? new Base[0] : new Base[] {this.availableEndTime}; // TimeType
517        default: return super.getProperty(hash, name, checkValid);
518        }
519
520      }
521
522      @Override
523      public Base setProperty(int hash, String name, Base value) throws FHIRException {
524        switch (hash) {
525        case 68050338: // daysOfWeek
526          value = new DaysOfWeekEnumFactory().fromType(castToCode(value));
527          this.getDaysOfWeek().add((Enumeration) value); // Enumeration<DaysOfWeek>
528          return value;
529        case -1414913477: // allDay
530          this.allDay = castToBoolean(value); // BooleanType
531          return value;
532        case -1039453818: // availableStartTime
533          this.availableStartTime = castToTime(value); // TimeType
534          return value;
535        case 101151551: // availableEndTime
536          this.availableEndTime = castToTime(value); // TimeType
537          return value;
538        default: return super.setProperty(hash, name, value);
539        }
540
541      }
542
543      @Override
544      public Base setProperty(String name, Base value) throws FHIRException {
545        if (name.equals("daysOfWeek")) {
546          value = new DaysOfWeekEnumFactory().fromType(castToCode(value));
547          this.getDaysOfWeek().add((Enumeration) value);
548        } else if (name.equals("allDay")) {
549          this.allDay = castToBoolean(value); // BooleanType
550        } else if (name.equals("availableStartTime")) {
551          this.availableStartTime = castToTime(value); // TimeType
552        } else if (name.equals("availableEndTime")) {
553          this.availableEndTime = castToTime(value); // TimeType
554        } else
555          return super.setProperty(name, value);
556        return value;
557      }
558
559      @Override
560      public Base makeProperty(int hash, String name) throws FHIRException {
561        switch (hash) {
562        case 68050338:  return addDaysOfWeekElement();
563        case -1414913477:  return getAllDayElement();
564        case -1039453818:  return getAvailableStartTimeElement();
565        case 101151551:  return getAvailableEndTimeElement();
566        default: return super.makeProperty(hash, name);
567        }
568
569      }
570
571      @Override
572      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
573        switch (hash) {
574        case 68050338: /*daysOfWeek*/ return new String[] {"code"};
575        case -1414913477: /*allDay*/ return new String[] {"boolean"};
576        case -1039453818: /*availableStartTime*/ return new String[] {"time"};
577        case 101151551: /*availableEndTime*/ return new String[] {"time"};
578        default: return super.getTypesForProperty(hash, name);
579        }
580
581      }
582
583      @Override
584      public Base addChild(String name) throws FHIRException {
585        if (name.equals("daysOfWeek")) {
586          throw new FHIRException("Cannot call addChild on a primitive type PractitionerRole.daysOfWeek");
587        }
588        else if (name.equals("allDay")) {
589          throw new FHIRException("Cannot call addChild on a primitive type PractitionerRole.allDay");
590        }
591        else if (name.equals("availableStartTime")) {
592          throw new FHIRException("Cannot call addChild on a primitive type PractitionerRole.availableStartTime");
593        }
594        else if (name.equals("availableEndTime")) {
595          throw new FHIRException("Cannot call addChild on a primitive type PractitionerRole.availableEndTime");
596        }
597        else
598          return super.addChild(name);
599      }
600
601      public PractitionerRoleAvailableTimeComponent copy() {
602        PractitionerRoleAvailableTimeComponent dst = new PractitionerRoleAvailableTimeComponent();
603        copyValues(dst);
604        return dst;
605      }
606
607      public void copyValues(PractitionerRoleAvailableTimeComponent dst) {
608        super.copyValues(dst);
609        if (daysOfWeek != null) {
610          dst.daysOfWeek = new ArrayList<Enumeration<DaysOfWeek>>();
611          for (Enumeration<DaysOfWeek> i : daysOfWeek)
612            dst.daysOfWeek.add(i.copy());
613        };
614        dst.allDay = allDay == null ? null : allDay.copy();
615        dst.availableStartTime = availableStartTime == null ? null : availableStartTime.copy();
616        dst.availableEndTime = availableEndTime == null ? null : availableEndTime.copy();
617      }
618
619      @Override
620      public boolean equalsDeep(Base other_) {
621        if (!super.equalsDeep(other_))
622          return false;
623        if (!(other_ instanceof PractitionerRoleAvailableTimeComponent))
624          return false;
625        PractitionerRoleAvailableTimeComponent o = (PractitionerRoleAvailableTimeComponent) other_;
626        return compareDeep(daysOfWeek, o.daysOfWeek, true) && compareDeep(allDay, o.allDay, true) && compareDeep(availableStartTime, o.availableStartTime, true)
627           && compareDeep(availableEndTime, o.availableEndTime, true);
628      }
629
630      @Override
631      public boolean equalsShallow(Base other_) {
632        if (!super.equalsShallow(other_))
633          return false;
634        if (!(other_ instanceof PractitionerRoleAvailableTimeComponent))
635          return false;
636        PractitionerRoleAvailableTimeComponent o = (PractitionerRoleAvailableTimeComponent) other_;
637        return compareValues(daysOfWeek, o.daysOfWeek, true) && compareValues(allDay, o.allDay, true) && compareValues(availableStartTime, o.availableStartTime, true)
638           && compareValues(availableEndTime, o.availableEndTime, true);
639      }
640
641      public boolean isEmpty() {
642        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(daysOfWeek, allDay, availableStartTime
643          , availableEndTime);
644      }
645
646  public String fhirType() {
647    return "PractitionerRole.availableTime";
648
649  }
650
651  }
652
653    @Block()
654    public static class PractitionerRoleNotAvailableComponent extends BackboneElement implements IBaseBackboneElement {
655        /**
656         * The reason that can be presented to the user as to why this time is not available.
657         */
658        @Child(name = "description", type = {StringType.class}, order=1, min=1, max=1, modifier=false, summary=false)
659        @Description(shortDefinition="Reason presented to the user explaining why time not available", formalDefinition="The reason that can be presented to the user as to why this time is not available." )
660        protected StringType description;
661
662        /**
663         * Service is not available (seasonally or for a public holiday) from this date.
664         */
665        @Child(name = "during", type = {Period.class}, order=2, min=0, max=1, modifier=false, summary=false)
666        @Description(shortDefinition="Service not available from this date", formalDefinition="Service is not available (seasonally or for a public holiday) from this date." )
667        protected Period during;
668
669        private static final long serialVersionUID = 310849929L;
670
671    /**
672     * Constructor
673     */
674      public PractitionerRoleNotAvailableComponent() {
675        super();
676      }
677
678    /**
679     * Constructor
680     */
681      public PractitionerRoleNotAvailableComponent(StringType description) {
682        super();
683        this.description = description;
684      }
685
686        /**
687         * @return {@link #description} (The reason that can be presented to the user as to why this time is not available.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
688         */
689        public StringType getDescriptionElement() { 
690          if (this.description == null)
691            if (Configuration.errorOnAutoCreate())
692              throw new Error("Attempt to auto-create PractitionerRoleNotAvailableComponent.description");
693            else if (Configuration.doAutoCreate())
694              this.description = new StringType(); // bb
695          return this.description;
696        }
697
698        public boolean hasDescriptionElement() { 
699          return this.description != null && !this.description.isEmpty();
700        }
701
702        public boolean hasDescription() { 
703          return this.description != null && !this.description.isEmpty();
704        }
705
706        /**
707         * @param value {@link #description} (The reason that can be presented to the user as to why this time is not available.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
708         */
709        public PractitionerRoleNotAvailableComponent setDescriptionElement(StringType value) { 
710          this.description = value;
711          return this;
712        }
713
714        /**
715         * @return The reason that can be presented to the user as to why this time is not available.
716         */
717        public String getDescription() { 
718          return this.description == null ? null : this.description.getValue();
719        }
720
721        /**
722         * @param value The reason that can be presented to the user as to why this time is not available.
723         */
724        public PractitionerRoleNotAvailableComponent setDescription(String value) { 
725            if (this.description == null)
726              this.description = new StringType();
727            this.description.setValue(value);
728          return this;
729        }
730
731        /**
732         * @return {@link #during} (Service is not available (seasonally or for a public holiday) from this date.)
733         */
734        public Period getDuring() { 
735          if (this.during == null)
736            if (Configuration.errorOnAutoCreate())
737              throw new Error("Attempt to auto-create PractitionerRoleNotAvailableComponent.during");
738            else if (Configuration.doAutoCreate())
739              this.during = new Period(); // cc
740          return this.during;
741        }
742
743        public boolean hasDuring() { 
744          return this.during != null && !this.during.isEmpty();
745        }
746
747        /**
748         * @param value {@link #during} (Service is not available (seasonally or for a public holiday) from this date.)
749         */
750        public PractitionerRoleNotAvailableComponent setDuring(Period value) { 
751          this.during = value;
752          return this;
753        }
754
755        protected void listChildren(List<Property> children) {
756          super.listChildren(children);
757          children.add(new Property("description", "string", "The reason that can be presented to the user as to why this time is not available.", 0, 1, description));
758          children.add(new Property("during", "Period", "Service is not available (seasonally or for a public holiday) from this date.", 0, 1, during));
759        }
760
761        @Override
762        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
763          switch (_hash) {
764          case -1724546052: /*description*/  return new Property("description", "string", "The reason that can be presented to the user as to why this time is not available.", 0, 1, description);
765          case -1320499647: /*during*/  return new Property("during", "Period", "Service is not available (seasonally or for a public holiday) from this date.", 0, 1, during);
766          default: return super.getNamedProperty(_hash, _name, _checkValid);
767          }
768
769        }
770
771      @Override
772      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
773        switch (hash) {
774        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
775        case -1320499647: /*during*/ return this.during == null ? new Base[0] : new Base[] {this.during}; // Period
776        default: return super.getProperty(hash, name, checkValid);
777        }
778
779      }
780
781      @Override
782      public Base setProperty(int hash, String name, Base value) throws FHIRException {
783        switch (hash) {
784        case -1724546052: // description
785          this.description = castToString(value); // StringType
786          return value;
787        case -1320499647: // during
788          this.during = castToPeriod(value); // Period
789          return value;
790        default: return super.setProperty(hash, name, value);
791        }
792
793      }
794
795      @Override
796      public Base setProperty(String name, Base value) throws FHIRException {
797        if (name.equals("description")) {
798          this.description = castToString(value); // StringType
799        } else if (name.equals("during")) {
800          this.during = castToPeriod(value); // Period
801        } else
802          return super.setProperty(name, value);
803        return value;
804      }
805
806      @Override
807      public Base makeProperty(int hash, String name) throws FHIRException {
808        switch (hash) {
809        case -1724546052:  return getDescriptionElement();
810        case -1320499647:  return getDuring();
811        default: return super.makeProperty(hash, name);
812        }
813
814      }
815
816      @Override
817      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
818        switch (hash) {
819        case -1724546052: /*description*/ return new String[] {"string"};
820        case -1320499647: /*during*/ return new String[] {"Period"};
821        default: return super.getTypesForProperty(hash, name);
822        }
823
824      }
825
826      @Override
827      public Base addChild(String name) throws FHIRException {
828        if (name.equals("description")) {
829          throw new FHIRException("Cannot call addChild on a primitive type PractitionerRole.description");
830        }
831        else if (name.equals("during")) {
832          this.during = new Period();
833          return this.during;
834        }
835        else
836          return super.addChild(name);
837      }
838
839      public PractitionerRoleNotAvailableComponent copy() {
840        PractitionerRoleNotAvailableComponent dst = new PractitionerRoleNotAvailableComponent();
841        copyValues(dst);
842        return dst;
843      }
844
845      public void copyValues(PractitionerRoleNotAvailableComponent dst) {
846        super.copyValues(dst);
847        dst.description = description == null ? null : description.copy();
848        dst.during = during == null ? null : during.copy();
849      }
850
851      @Override
852      public boolean equalsDeep(Base other_) {
853        if (!super.equalsDeep(other_))
854          return false;
855        if (!(other_ instanceof PractitionerRoleNotAvailableComponent))
856          return false;
857        PractitionerRoleNotAvailableComponent o = (PractitionerRoleNotAvailableComponent) other_;
858        return compareDeep(description, o.description, true) && compareDeep(during, o.during, true);
859      }
860
861      @Override
862      public boolean equalsShallow(Base other_) {
863        if (!super.equalsShallow(other_))
864          return false;
865        if (!(other_ instanceof PractitionerRoleNotAvailableComponent))
866          return false;
867        PractitionerRoleNotAvailableComponent o = (PractitionerRoleNotAvailableComponent) other_;
868        return compareValues(description, o.description, true);
869      }
870
871      public boolean isEmpty() {
872        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(description, during);
873      }
874
875  public String fhirType() {
876    return "PractitionerRole.notAvailable";
877
878  }
879
880  }
881
882    /**
883     * Business Identifiers that are specific to a role/location.
884     */
885    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
886    @Description(shortDefinition="Business Identifiers that are specific to a role/location", formalDefinition="Business Identifiers that are specific to a role/location." )
887    protected List<Identifier> identifier;
888
889    /**
890     * Whether this practitioner role record is in active use.
891     */
892    @Child(name = "active", type = {BooleanType.class}, order=1, min=0, max=1, modifier=false, summary=true)
893    @Description(shortDefinition="Whether this practitioner role record is in active use", formalDefinition="Whether this practitioner role record is in active use." )
894    protected BooleanType active;
895
896    /**
897     * The period during which the person is authorized to act as a practitioner in these role(s) for the organization.
898     */
899    @Child(name = "period", type = {Period.class}, order=2, min=0, max=1, modifier=false, summary=true)
900    @Description(shortDefinition="The period during which the practitioner is authorized to perform in these role(s)", formalDefinition="The period during which the person is authorized to act as a practitioner in these role(s) for the organization." )
901    protected Period period;
902
903    /**
904     * Practitioner that is able to provide the defined services for the organization.
905     */
906    @Child(name = "practitioner", type = {Practitioner.class}, order=3, min=0, max=1, modifier=false, summary=true)
907    @Description(shortDefinition="Practitioner that is able to provide the defined services for the organization", formalDefinition="Practitioner that is able to provide the defined services for the organization." )
908    protected Reference practitioner;
909
910    /**
911     * The organization where the Practitioner performs the roles associated.
912     */
913    @Child(name = "organization", type = {Organization.class}, order=4, min=0, max=1, modifier=false, summary=true)
914    @Description(shortDefinition="Organization where the roles are available", formalDefinition="The organization where the Practitioner performs the roles associated." )
915    protected Reference organization;
916
917    /**
918     * Roles which this practitioner is authorized to perform for the organization.
919     */
920    @Child(name = "code", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
921    @Description(shortDefinition="Roles which this practitioner may perform", formalDefinition="Roles which this practitioner is authorized to perform for the organization." )
922    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/practitioner-role")
923    protected List<CodeableConcept> code;
924
925    /**
926     * Specific specialty of the practitioner.
927     */
928    @Child(name = "specialty", type = {CodeableConcept.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
929    @Description(shortDefinition="Specific specialty of the practitioner", formalDefinition="Specific specialty of the practitioner." )
930    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/c80-practice-codes")
931    protected List<CodeableConcept> specialty;
932
933    /**
934     * The location(s) at which this practitioner provides care.
935     */
936    @Child(name = "location", type = {Location.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
937    @Description(shortDefinition="The location(s) at which this practitioner provides care", formalDefinition="The location(s) at which this practitioner provides care." )
938    protected List<Reference> location;
939
940    /**
941     * The list of healthcare services that this worker provides for this role's Organization/Location(s).
942     */
943    @Child(name = "healthcareService", type = {HealthcareService.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
944    @Description(shortDefinition="The list of healthcare services that this worker provides for this role's Organization/Location(s)", formalDefinition="The list of healthcare services that this worker provides for this role's Organization/Location(s)." )
945    protected List<Reference> healthcareService;
946
947    /**
948     * Contact details that are specific to the role/location/service.
949     */
950    @Child(name = "telecom", type = {ContactPoint.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
951    @Description(shortDefinition="Contact details that are specific to the role/location/service", formalDefinition="Contact details that are specific to the role/location/service." )
952    protected List<ContactPoint> telecom;
953
954    /**
955     * A collection of times the practitioner is available or performing this role at the location and/or healthcareservice.
956     */
957    @Child(name = "availableTime", type = {}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
958    @Description(shortDefinition="Times the Service Site is available", formalDefinition="A collection of times the practitioner is available or performing this role at the location and/or healthcareservice." )
959    protected List<PractitionerRoleAvailableTimeComponent> availableTime;
960
961    /**
962     * The practitioner is not available or performing this role during this period of time due to the provided reason.
963     */
964    @Child(name = "notAvailable", type = {}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
965    @Description(shortDefinition="Not available during this time due to provided reason", formalDefinition="The practitioner is not available or performing this role during this period of time due to the provided reason." )
966    protected List<PractitionerRoleNotAvailableComponent> notAvailable;
967
968    /**
969     * A description of site availability exceptions, e.g. public holiday availability. Succinctly describing all possible exceptions to normal site availability as details in the available Times and not available Times.
970     */
971    @Child(name = "availabilityExceptions", type = {StringType.class}, order=12, min=0, max=1, modifier=false, summary=false)
972    @Description(shortDefinition="Description of availability exceptions", formalDefinition="A description of site availability exceptions, e.g. public holiday availability. Succinctly describing all possible exceptions to normal site availability as details in the available Times and not available Times." )
973    protected StringType availabilityExceptions;
974
975    /**
976     * Technical endpoints providing access to services operated for the practitioner with this role.
977     */
978    @Child(name = "endpoint", type = {Endpoint.class}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
979    @Description(shortDefinition="Technical endpoints providing access to services operated for the practitioner with this role", formalDefinition="Technical endpoints providing access to services operated for the practitioner with this role." )
980    protected List<Reference> endpoint;
981
982    private static final long serialVersionUID = 293775464L;
983
984  /**
985   * Constructor
986   */
987    public PractitionerRole() {
988      super();
989    }
990
991    /**
992     * @return {@link #identifier} (Business Identifiers that are specific to a role/location.)
993     */
994    public List<Identifier> getIdentifier() { 
995      if (this.identifier == null)
996        this.identifier = new ArrayList<Identifier>();
997      return this.identifier;
998    }
999
1000    /**
1001     * @return Returns a reference to <code>this</code> for easy method chaining
1002     */
1003    public PractitionerRole setIdentifier(List<Identifier> theIdentifier) { 
1004      this.identifier = theIdentifier;
1005      return this;
1006    }
1007
1008    public boolean hasIdentifier() { 
1009      if (this.identifier == null)
1010        return false;
1011      for (Identifier item : this.identifier)
1012        if (!item.isEmpty())
1013          return true;
1014      return false;
1015    }
1016
1017    public Identifier addIdentifier() { //3
1018      Identifier t = new Identifier();
1019      if (this.identifier == null)
1020        this.identifier = new ArrayList<Identifier>();
1021      this.identifier.add(t);
1022      return t;
1023    }
1024
1025    public PractitionerRole addIdentifier(Identifier t) { //3
1026      if (t == null)
1027        return this;
1028      if (this.identifier == null)
1029        this.identifier = new ArrayList<Identifier>();
1030      this.identifier.add(t);
1031      return this;
1032    }
1033
1034    /**
1035     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
1036     */
1037    public Identifier getIdentifierFirstRep() { 
1038      if (getIdentifier().isEmpty()) {
1039        addIdentifier();
1040      }
1041      return getIdentifier().get(0);
1042    }
1043
1044    /**
1045     * @return {@link #active} (Whether this practitioner role record is in active use.). This is the underlying object with id, value and extensions. The accessor "getActive" gives direct access to the value
1046     */
1047    public BooleanType getActiveElement() { 
1048      if (this.active == null)
1049        if (Configuration.errorOnAutoCreate())
1050          throw new Error("Attempt to auto-create PractitionerRole.active");
1051        else if (Configuration.doAutoCreate())
1052          this.active = new BooleanType(); // bb
1053      return this.active;
1054    }
1055
1056    public boolean hasActiveElement() { 
1057      return this.active != null && !this.active.isEmpty();
1058    }
1059
1060    public boolean hasActive() { 
1061      return this.active != null && !this.active.isEmpty();
1062    }
1063
1064    /**
1065     * @param value {@link #active} (Whether this practitioner role record is in active use.). This is the underlying object with id, value and extensions. The accessor "getActive" gives direct access to the value
1066     */
1067    public PractitionerRole setActiveElement(BooleanType value) { 
1068      this.active = value;
1069      return this;
1070    }
1071
1072    /**
1073     * @return Whether this practitioner role record is in active use.
1074     */
1075    public boolean getActive() { 
1076      return this.active == null || this.active.isEmpty() ? false : this.active.getValue();
1077    }
1078
1079    /**
1080     * @param value Whether this practitioner role record is in active use.
1081     */
1082    public PractitionerRole setActive(boolean value) { 
1083        if (this.active == null)
1084          this.active = new BooleanType();
1085        this.active.setValue(value);
1086      return this;
1087    }
1088
1089    /**
1090     * @return {@link #period} (The period during which the person is authorized to act as a practitioner in these role(s) for the organization.)
1091     */
1092    public Period getPeriod() { 
1093      if (this.period == null)
1094        if (Configuration.errorOnAutoCreate())
1095          throw new Error("Attempt to auto-create PractitionerRole.period");
1096        else if (Configuration.doAutoCreate())
1097          this.period = new Period(); // cc
1098      return this.period;
1099    }
1100
1101    public boolean hasPeriod() { 
1102      return this.period != null && !this.period.isEmpty();
1103    }
1104
1105    /**
1106     * @param value {@link #period} (The period during which the person is authorized to act as a practitioner in these role(s) for the organization.)
1107     */
1108    public PractitionerRole setPeriod(Period value) { 
1109      this.period = value;
1110      return this;
1111    }
1112
1113    /**
1114     * @return {@link #practitioner} (Practitioner that is able to provide the defined services for the organization.)
1115     */
1116    public Reference getPractitioner() { 
1117      if (this.practitioner == null)
1118        if (Configuration.errorOnAutoCreate())
1119          throw new Error("Attempt to auto-create PractitionerRole.practitioner");
1120        else if (Configuration.doAutoCreate())
1121          this.practitioner = new Reference(); // cc
1122      return this.practitioner;
1123    }
1124
1125    public boolean hasPractitioner() { 
1126      return this.practitioner != null && !this.practitioner.isEmpty();
1127    }
1128
1129    /**
1130     * @param value {@link #practitioner} (Practitioner that is able to provide the defined services for the organization.)
1131     */
1132    public PractitionerRole setPractitioner(Reference value) { 
1133      this.practitioner = value;
1134      return this;
1135    }
1136
1137    /**
1138     * @return {@link #organization} (The organization where the Practitioner performs the roles associated.)
1139     */
1140    public Reference getOrganization() { 
1141      if (this.organization == null)
1142        if (Configuration.errorOnAutoCreate())
1143          throw new Error("Attempt to auto-create PractitionerRole.organization");
1144        else if (Configuration.doAutoCreate())
1145          this.organization = new Reference(); // cc
1146      return this.organization;
1147    }
1148
1149    public boolean hasOrganization() { 
1150      return this.organization != null && !this.organization.isEmpty();
1151    }
1152
1153    /**
1154     * @param value {@link #organization} (The organization where the Practitioner performs the roles associated.)
1155     */
1156    public PractitionerRole setOrganization(Reference value) { 
1157      this.organization = value;
1158      return this;
1159    }
1160
1161    /**
1162     * @return {@link #code} (Roles which this practitioner is authorized to perform for the organization.)
1163     */
1164    public List<CodeableConcept> getCode() { 
1165      if (this.code == null)
1166        this.code = new ArrayList<CodeableConcept>();
1167      return this.code;
1168    }
1169
1170    /**
1171     * @return Returns a reference to <code>this</code> for easy method chaining
1172     */
1173    public PractitionerRole setCode(List<CodeableConcept> theCode) { 
1174      this.code = theCode;
1175      return this;
1176    }
1177
1178    public boolean hasCode() { 
1179      if (this.code == null)
1180        return false;
1181      for (CodeableConcept item : this.code)
1182        if (!item.isEmpty())
1183          return true;
1184      return false;
1185    }
1186
1187    public CodeableConcept addCode() { //3
1188      CodeableConcept t = new CodeableConcept();
1189      if (this.code == null)
1190        this.code = new ArrayList<CodeableConcept>();
1191      this.code.add(t);
1192      return t;
1193    }
1194
1195    public PractitionerRole addCode(CodeableConcept t) { //3
1196      if (t == null)
1197        return this;
1198      if (this.code == null)
1199        this.code = new ArrayList<CodeableConcept>();
1200      this.code.add(t);
1201      return this;
1202    }
1203
1204    /**
1205     * @return The first repetition of repeating field {@link #code}, creating it if it does not already exist
1206     */
1207    public CodeableConcept getCodeFirstRep() { 
1208      if (getCode().isEmpty()) {
1209        addCode();
1210      }
1211      return getCode().get(0);
1212    }
1213
1214    /**
1215     * @return {@link #specialty} (Specific specialty of the practitioner.)
1216     */
1217    public List<CodeableConcept> getSpecialty() { 
1218      if (this.specialty == null)
1219        this.specialty = new ArrayList<CodeableConcept>();
1220      return this.specialty;
1221    }
1222
1223    /**
1224     * @return Returns a reference to <code>this</code> for easy method chaining
1225     */
1226    public PractitionerRole setSpecialty(List<CodeableConcept> theSpecialty) { 
1227      this.specialty = theSpecialty;
1228      return this;
1229    }
1230
1231    public boolean hasSpecialty() { 
1232      if (this.specialty == null)
1233        return false;
1234      for (CodeableConcept item : this.specialty)
1235        if (!item.isEmpty())
1236          return true;
1237      return false;
1238    }
1239
1240    public CodeableConcept addSpecialty() { //3
1241      CodeableConcept t = new CodeableConcept();
1242      if (this.specialty == null)
1243        this.specialty = new ArrayList<CodeableConcept>();
1244      this.specialty.add(t);
1245      return t;
1246    }
1247
1248    public PractitionerRole addSpecialty(CodeableConcept t) { //3
1249      if (t == null)
1250        return this;
1251      if (this.specialty == null)
1252        this.specialty = new ArrayList<CodeableConcept>();
1253      this.specialty.add(t);
1254      return this;
1255    }
1256
1257    /**
1258     * @return The first repetition of repeating field {@link #specialty}, creating it if it does not already exist
1259     */
1260    public CodeableConcept getSpecialtyFirstRep() { 
1261      if (getSpecialty().isEmpty()) {
1262        addSpecialty();
1263      }
1264      return getSpecialty().get(0);
1265    }
1266
1267    /**
1268     * @return {@link #location} (The location(s) at which this practitioner provides care.)
1269     */
1270    public List<Reference> getLocation() { 
1271      if (this.location == null)
1272        this.location = new ArrayList<Reference>();
1273      return this.location;
1274    }
1275
1276    /**
1277     * @return Returns a reference to <code>this</code> for easy method chaining
1278     */
1279    public PractitionerRole setLocation(List<Reference> theLocation) { 
1280      this.location = theLocation;
1281      return this;
1282    }
1283
1284    public boolean hasLocation() { 
1285      if (this.location == null)
1286        return false;
1287      for (Reference item : this.location)
1288        if (!item.isEmpty())
1289          return true;
1290      return false;
1291    }
1292
1293    public Reference addLocation() { //3
1294      Reference t = new Reference();
1295      if (this.location == null)
1296        this.location = new ArrayList<Reference>();
1297      this.location.add(t);
1298      return t;
1299    }
1300
1301    public PractitionerRole addLocation(Reference t) { //3
1302      if (t == null)
1303        return this;
1304      if (this.location == null)
1305        this.location = new ArrayList<Reference>();
1306      this.location.add(t);
1307      return this;
1308    }
1309
1310    /**
1311     * @return The first repetition of repeating field {@link #location}, creating it if it does not already exist
1312     */
1313    public Reference getLocationFirstRep() { 
1314      if (getLocation().isEmpty()) {
1315        addLocation();
1316      }
1317      return getLocation().get(0);
1318    }
1319
1320    /**
1321     * @return {@link #healthcareService} (The list of healthcare services that this worker provides for this role's Organization/Location(s).)
1322     */
1323    public List<Reference> getHealthcareService() { 
1324      if (this.healthcareService == null)
1325        this.healthcareService = new ArrayList<Reference>();
1326      return this.healthcareService;
1327    }
1328
1329    /**
1330     * @return Returns a reference to <code>this</code> for easy method chaining
1331     */
1332    public PractitionerRole setHealthcareService(List<Reference> theHealthcareService) { 
1333      this.healthcareService = theHealthcareService;
1334      return this;
1335    }
1336
1337    public boolean hasHealthcareService() { 
1338      if (this.healthcareService == null)
1339        return false;
1340      for (Reference item : this.healthcareService)
1341        if (!item.isEmpty())
1342          return true;
1343      return false;
1344    }
1345
1346    public Reference addHealthcareService() { //3
1347      Reference t = new Reference();
1348      if (this.healthcareService == null)
1349        this.healthcareService = new ArrayList<Reference>();
1350      this.healthcareService.add(t);
1351      return t;
1352    }
1353
1354    public PractitionerRole addHealthcareService(Reference t) { //3
1355      if (t == null)
1356        return this;
1357      if (this.healthcareService == null)
1358        this.healthcareService = new ArrayList<Reference>();
1359      this.healthcareService.add(t);
1360      return this;
1361    }
1362
1363    /**
1364     * @return The first repetition of repeating field {@link #healthcareService}, creating it if it does not already exist
1365     */
1366    public Reference getHealthcareServiceFirstRep() { 
1367      if (getHealthcareService().isEmpty()) {
1368        addHealthcareService();
1369      }
1370      return getHealthcareService().get(0);
1371    }
1372
1373    /**
1374     * @return {@link #telecom} (Contact details that are specific to the role/location/service.)
1375     */
1376    public List<ContactPoint> getTelecom() { 
1377      if (this.telecom == null)
1378        this.telecom = new ArrayList<ContactPoint>();
1379      return this.telecom;
1380    }
1381
1382    /**
1383     * @return Returns a reference to <code>this</code> for easy method chaining
1384     */
1385    public PractitionerRole setTelecom(List<ContactPoint> theTelecom) { 
1386      this.telecom = theTelecom;
1387      return this;
1388    }
1389
1390    public boolean hasTelecom() { 
1391      if (this.telecom == null)
1392        return false;
1393      for (ContactPoint item : this.telecom)
1394        if (!item.isEmpty())
1395          return true;
1396      return false;
1397    }
1398
1399    public ContactPoint addTelecom() { //3
1400      ContactPoint t = new ContactPoint();
1401      if (this.telecom == null)
1402        this.telecom = new ArrayList<ContactPoint>();
1403      this.telecom.add(t);
1404      return t;
1405    }
1406
1407    public PractitionerRole addTelecom(ContactPoint t) { //3
1408      if (t == null)
1409        return this;
1410      if (this.telecom == null)
1411        this.telecom = new ArrayList<ContactPoint>();
1412      this.telecom.add(t);
1413      return this;
1414    }
1415
1416    /**
1417     * @return The first repetition of repeating field {@link #telecom}, creating it if it does not already exist
1418     */
1419    public ContactPoint getTelecomFirstRep() { 
1420      if (getTelecom().isEmpty()) {
1421        addTelecom();
1422      }
1423      return getTelecom().get(0);
1424    }
1425
1426    /**
1427     * @return {@link #availableTime} (A collection of times the practitioner is available or performing this role at the location and/or healthcareservice.)
1428     */
1429    public List<PractitionerRoleAvailableTimeComponent> getAvailableTime() { 
1430      if (this.availableTime == null)
1431        this.availableTime = new ArrayList<PractitionerRoleAvailableTimeComponent>();
1432      return this.availableTime;
1433    }
1434
1435    /**
1436     * @return Returns a reference to <code>this</code> for easy method chaining
1437     */
1438    public PractitionerRole setAvailableTime(List<PractitionerRoleAvailableTimeComponent> theAvailableTime) { 
1439      this.availableTime = theAvailableTime;
1440      return this;
1441    }
1442
1443    public boolean hasAvailableTime() { 
1444      if (this.availableTime == null)
1445        return false;
1446      for (PractitionerRoleAvailableTimeComponent item : this.availableTime)
1447        if (!item.isEmpty())
1448          return true;
1449      return false;
1450    }
1451
1452    public PractitionerRoleAvailableTimeComponent addAvailableTime() { //3
1453      PractitionerRoleAvailableTimeComponent t = new PractitionerRoleAvailableTimeComponent();
1454      if (this.availableTime == null)
1455        this.availableTime = new ArrayList<PractitionerRoleAvailableTimeComponent>();
1456      this.availableTime.add(t);
1457      return t;
1458    }
1459
1460    public PractitionerRole addAvailableTime(PractitionerRoleAvailableTimeComponent t) { //3
1461      if (t == null)
1462        return this;
1463      if (this.availableTime == null)
1464        this.availableTime = new ArrayList<PractitionerRoleAvailableTimeComponent>();
1465      this.availableTime.add(t);
1466      return this;
1467    }
1468
1469    /**
1470     * @return The first repetition of repeating field {@link #availableTime}, creating it if it does not already exist
1471     */
1472    public PractitionerRoleAvailableTimeComponent getAvailableTimeFirstRep() { 
1473      if (getAvailableTime().isEmpty()) {
1474        addAvailableTime();
1475      }
1476      return getAvailableTime().get(0);
1477    }
1478
1479    /**
1480     * @return {@link #notAvailable} (The practitioner is not available or performing this role during this period of time due to the provided reason.)
1481     */
1482    public List<PractitionerRoleNotAvailableComponent> getNotAvailable() { 
1483      if (this.notAvailable == null)
1484        this.notAvailable = new ArrayList<PractitionerRoleNotAvailableComponent>();
1485      return this.notAvailable;
1486    }
1487
1488    /**
1489     * @return Returns a reference to <code>this</code> for easy method chaining
1490     */
1491    public PractitionerRole setNotAvailable(List<PractitionerRoleNotAvailableComponent> theNotAvailable) { 
1492      this.notAvailable = theNotAvailable;
1493      return this;
1494    }
1495
1496    public boolean hasNotAvailable() { 
1497      if (this.notAvailable == null)
1498        return false;
1499      for (PractitionerRoleNotAvailableComponent item : this.notAvailable)
1500        if (!item.isEmpty())
1501          return true;
1502      return false;
1503    }
1504
1505    public PractitionerRoleNotAvailableComponent addNotAvailable() { //3
1506      PractitionerRoleNotAvailableComponent t = new PractitionerRoleNotAvailableComponent();
1507      if (this.notAvailable == null)
1508        this.notAvailable = new ArrayList<PractitionerRoleNotAvailableComponent>();
1509      this.notAvailable.add(t);
1510      return t;
1511    }
1512
1513    public PractitionerRole addNotAvailable(PractitionerRoleNotAvailableComponent t) { //3
1514      if (t == null)
1515        return this;
1516      if (this.notAvailable == null)
1517        this.notAvailable = new ArrayList<PractitionerRoleNotAvailableComponent>();
1518      this.notAvailable.add(t);
1519      return this;
1520    }
1521
1522    /**
1523     * @return The first repetition of repeating field {@link #notAvailable}, creating it if it does not already exist
1524     */
1525    public PractitionerRoleNotAvailableComponent getNotAvailableFirstRep() { 
1526      if (getNotAvailable().isEmpty()) {
1527        addNotAvailable();
1528      }
1529      return getNotAvailable().get(0);
1530    }
1531
1532    /**
1533     * @return {@link #availabilityExceptions} (A description of site availability exceptions, e.g. public holiday availability. Succinctly describing all possible exceptions to normal site availability as details in the available Times and not available Times.). This is the underlying object with id, value and extensions. The accessor "getAvailabilityExceptions" gives direct access to the value
1534     */
1535    public StringType getAvailabilityExceptionsElement() { 
1536      if (this.availabilityExceptions == null)
1537        if (Configuration.errorOnAutoCreate())
1538          throw new Error("Attempt to auto-create PractitionerRole.availabilityExceptions");
1539        else if (Configuration.doAutoCreate())
1540          this.availabilityExceptions = new StringType(); // bb
1541      return this.availabilityExceptions;
1542    }
1543
1544    public boolean hasAvailabilityExceptionsElement() { 
1545      return this.availabilityExceptions != null && !this.availabilityExceptions.isEmpty();
1546    }
1547
1548    public boolean hasAvailabilityExceptions() { 
1549      return this.availabilityExceptions != null && !this.availabilityExceptions.isEmpty();
1550    }
1551
1552    /**
1553     * @param value {@link #availabilityExceptions} (A description of site availability exceptions, e.g. public holiday availability. Succinctly describing all possible exceptions to normal site availability as details in the available Times and not available Times.). This is the underlying object with id, value and extensions. The accessor "getAvailabilityExceptions" gives direct access to the value
1554     */
1555    public PractitionerRole setAvailabilityExceptionsElement(StringType value) { 
1556      this.availabilityExceptions = value;
1557      return this;
1558    }
1559
1560    /**
1561     * @return A description of site availability exceptions, e.g. public holiday availability. Succinctly describing all possible exceptions to normal site availability as details in the available Times and not available Times.
1562     */
1563    public String getAvailabilityExceptions() { 
1564      return this.availabilityExceptions == null ? null : this.availabilityExceptions.getValue();
1565    }
1566
1567    /**
1568     * @param value A description of site availability exceptions, e.g. public holiday availability. Succinctly describing all possible exceptions to normal site availability as details in the available Times and not available Times.
1569     */
1570    public PractitionerRole setAvailabilityExceptions(String value) { 
1571      if (Utilities.noString(value))
1572        this.availabilityExceptions = null;
1573      else {
1574        if (this.availabilityExceptions == null)
1575          this.availabilityExceptions = new StringType();
1576        this.availabilityExceptions.setValue(value);
1577      }
1578      return this;
1579    }
1580
1581    /**
1582     * @return {@link #endpoint} (Technical endpoints providing access to services operated for the practitioner with this role.)
1583     */
1584    public List<Reference> getEndpoint() { 
1585      if (this.endpoint == null)
1586        this.endpoint = new ArrayList<Reference>();
1587      return this.endpoint;
1588    }
1589
1590    /**
1591     * @return Returns a reference to <code>this</code> for easy method chaining
1592     */
1593    public PractitionerRole setEndpoint(List<Reference> theEndpoint) { 
1594      this.endpoint = theEndpoint;
1595      return this;
1596    }
1597
1598    public boolean hasEndpoint() { 
1599      if (this.endpoint == null)
1600        return false;
1601      for (Reference item : this.endpoint)
1602        if (!item.isEmpty())
1603          return true;
1604      return false;
1605    }
1606
1607    public Reference addEndpoint() { //3
1608      Reference t = new Reference();
1609      if (this.endpoint == null)
1610        this.endpoint = new ArrayList<Reference>();
1611      this.endpoint.add(t);
1612      return t;
1613    }
1614
1615    public PractitionerRole addEndpoint(Reference t) { //3
1616      if (t == null)
1617        return this;
1618      if (this.endpoint == null)
1619        this.endpoint = new ArrayList<Reference>();
1620      this.endpoint.add(t);
1621      return this;
1622    }
1623
1624    /**
1625     * @return The first repetition of repeating field {@link #endpoint}, creating it if it does not already exist
1626     */
1627    public Reference getEndpointFirstRep() { 
1628      if (getEndpoint().isEmpty()) {
1629        addEndpoint();
1630      }
1631      return getEndpoint().get(0);
1632    }
1633
1634      protected void listChildren(List<Property> children) {
1635        super.listChildren(children);
1636        children.add(new Property("identifier", "Identifier", "Business Identifiers that are specific to a role/location.", 0, java.lang.Integer.MAX_VALUE, identifier));
1637        children.add(new Property("active", "boolean", "Whether this practitioner role record is in active use.", 0, 1, active));
1638        children.add(new Property("period", "Period", "The period during which the person is authorized to act as a practitioner in these role(s) for the organization.", 0, 1, period));
1639        children.add(new Property("practitioner", "Reference(Practitioner)", "Practitioner that is able to provide the defined services for the organization.", 0, 1, practitioner));
1640        children.add(new Property("organization", "Reference(Organization)", "The organization where the Practitioner performs the roles associated.", 0, 1, organization));
1641        children.add(new Property("code", "CodeableConcept", "Roles which this practitioner is authorized to perform for the organization.", 0, java.lang.Integer.MAX_VALUE, code));
1642        children.add(new Property("specialty", "CodeableConcept", "Specific specialty of the practitioner.", 0, java.lang.Integer.MAX_VALUE, specialty));
1643        children.add(new Property("location", "Reference(Location)", "The location(s) at which this practitioner provides care.", 0, java.lang.Integer.MAX_VALUE, location));
1644        children.add(new Property("healthcareService", "Reference(HealthcareService)", "The list of healthcare services that this worker provides for this role's Organization/Location(s).", 0, java.lang.Integer.MAX_VALUE, healthcareService));
1645        children.add(new Property("telecom", "ContactPoint", "Contact details that are specific to the role/location/service.", 0, java.lang.Integer.MAX_VALUE, telecom));
1646        children.add(new Property("availableTime", "", "A collection of times the practitioner is available or performing this role at the location and/or healthcareservice.", 0, java.lang.Integer.MAX_VALUE, availableTime));
1647        children.add(new Property("notAvailable", "", "The practitioner is not available or performing this role during this period of time due to the provided reason.", 0, java.lang.Integer.MAX_VALUE, notAvailable));
1648        children.add(new Property("availabilityExceptions", "string", "A description of site availability exceptions, e.g. public holiday availability. Succinctly describing all possible exceptions to normal site availability as details in the available Times and not available Times.", 0, 1, availabilityExceptions));
1649        children.add(new Property("endpoint", "Reference(Endpoint)", "Technical endpoints providing access to services operated for the practitioner with this role.", 0, java.lang.Integer.MAX_VALUE, endpoint));
1650      }
1651
1652      @Override
1653      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1654        switch (_hash) {
1655        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Business Identifiers that are specific to a role/location.", 0, java.lang.Integer.MAX_VALUE, identifier);
1656        case -1422950650: /*active*/  return new Property("active", "boolean", "Whether this practitioner role record is in active use.", 0, 1, active);
1657        case -991726143: /*period*/  return new Property("period", "Period", "The period during which the person is authorized to act as a practitioner in these role(s) for the organization.", 0, 1, period);
1658        case 574573338: /*practitioner*/  return new Property("practitioner", "Reference(Practitioner)", "Practitioner that is able to provide the defined services for the organization.", 0, 1, practitioner);
1659        case 1178922291: /*organization*/  return new Property("organization", "Reference(Organization)", "The organization where the Practitioner performs the roles associated.", 0, 1, organization);
1660        case 3059181: /*code*/  return new Property("code", "CodeableConcept", "Roles which this practitioner is authorized to perform for the organization.", 0, java.lang.Integer.MAX_VALUE, code);
1661        case -1694759682: /*specialty*/  return new Property("specialty", "CodeableConcept", "Specific specialty of the practitioner.", 0, java.lang.Integer.MAX_VALUE, specialty);
1662        case 1901043637: /*location*/  return new Property("location", "Reference(Location)", "The location(s) at which this practitioner provides care.", 0, java.lang.Integer.MAX_VALUE, location);
1663        case 1289661064: /*healthcareService*/  return new Property("healthcareService", "Reference(HealthcareService)", "The list of healthcare services that this worker provides for this role's Organization/Location(s).", 0, java.lang.Integer.MAX_VALUE, healthcareService);
1664        case -1429363305: /*telecom*/  return new Property("telecom", "ContactPoint", "Contact details that are specific to the role/location/service.", 0, java.lang.Integer.MAX_VALUE, telecom);
1665        case 1873069366: /*availableTime*/  return new Property("availableTime", "", "A collection of times the practitioner is available or performing this role at the location and/or healthcareservice.", 0, java.lang.Integer.MAX_VALUE, availableTime);
1666        case -629572298: /*notAvailable*/  return new Property("notAvailable", "", "The practitioner is not available or performing this role during this period of time due to the provided reason.", 0, java.lang.Integer.MAX_VALUE, notAvailable);
1667        case -1149143617: /*availabilityExceptions*/  return new Property("availabilityExceptions", "string", "A description of site availability exceptions, e.g. public holiday availability. Succinctly describing all possible exceptions to normal site availability as details in the available Times and not available Times.", 0, 1, availabilityExceptions);
1668        case 1741102485: /*endpoint*/  return new Property("endpoint", "Reference(Endpoint)", "Technical endpoints providing access to services operated for the practitioner with this role.", 0, java.lang.Integer.MAX_VALUE, endpoint);
1669        default: return super.getNamedProperty(_hash, _name, _checkValid);
1670        }
1671
1672      }
1673
1674      @Override
1675      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1676        switch (hash) {
1677        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1678        case -1422950650: /*active*/ return this.active == null ? new Base[0] : new Base[] {this.active}; // BooleanType
1679        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
1680        case 574573338: /*practitioner*/ return this.practitioner == null ? new Base[0] : new Base[] {this.practitioner}; // Reference
1681        case 1178922291: /*organization*/ return this.organization == null ? new Base[0] : new Base[] {this.organization}; // Reference
1682        case 3059181: /*code*/ return this.code == null ? new Base[0] : this.code.toArray(new Base[this.code.size()]); // CodeableConcept
1683        case -1694759682: /*specialty*/ return this.specialty == null ? new Base[0] : this.specialty.toArray(new Base[this.specialty.size()]); // CodeableConcept
1684        case 1901043637: /*location*/ return this.location == null ? new Base[0] : this.location.toArray(new Base[this.location.size()]); // Reference
1685        case 1289661064: /*healthcareService*/ return this.healthcareService == null ? new Base[0] : this.healthcareService.toArray(new Base[this.healthcareService.size()]); // Reference
1686        case -1429363305: /*telecom*/ return this.telecom == null ? new Base[0] : this.telecom.toArray(new Base[this.telecom.size()]); // ContactPoint
1687        case 1873069366: /*availableTime*/ return this.availableTime == null ? new Base[0] : this.availableTime.toArray(new Base[this.availableTime.size()]); // PractitionerRoleAvailableTimeComponent
1688        case -629572298: /*notAvailable*/ return this.notAvailable == null ? new Base[0] : this.notAvailable.toArray(new Base[this.notAvailable.size()]); // PractitionerRoleNotAvailableComponent
1689        case -1149143617: /*availabilityExceptions*/ return this.availabilityExceptions == null ? new Base[0] : new Base[] {this.availabilityExceptions}; // StringType
1690        case 1741102485: /*endpoint*/ return this.endpoint == null ? new Base[0] : this.endpoint.toArray(new Base[this.endpoint.size()]); // Reference
1691        default: return super.getProperty(hash, name, checkValid);
1692        }
1693
1694      }
1695
1696      @Override
1697      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1698        switch (hash) {
1699        case -1618432855: // identifier
1700          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1701          return value;
1702        case -1422950650: // active
1703          this.active = castToBoolean(value); // BooleanType
1704          return value;
1705        case -991726143: // period
1706          this.period = castToPeriod(value); // Period
1707          return value;
1708        case 574573338: // practitioner
1709          this.practitioner = castToReference(value); // Reference
1710          return value;
1711        case 1178922291: // organization
1712          this.organization = castToReference(value); // Reference
1713          return value;
1714        case 3059181: // code
1715          this.getCode().add(castToCodeableConcept(value)); // CodeableConcept
1716          return value;
1717        case -1694759682: // specialty
1718          this.getSpecialty().add(castToCodeableConcept(value)); // CodeableConcept
1719          return value;
1720        case 1901043637: // location
1721          this.getLocation().add(castToReference(value)); // Reference
1722          return value;
1723        case 1289661064: // healthcareService
1724          this.getHealthcareService().add(castToReference(value)); // Reference
1725          return value;
1726        case -1429363305: // telecom
1727          this.getTelecom().add(castToContactPoint(value)); // ContactPoint
1728          return value;
1729        case 1873069366: // availableTime
1730          this.getAvailableTime().add((PractitionerRoleAvailableTimeComponent) value); // PractitionerRoleAvailableTimeComponent
1731          return value;
1732        case -629572298: // notAvailable
1733          this.getNotAvailable().add((PractitionerRoleNotAvailableComponent) value); // PractitionerRoleNotAvailableComponent
1734          return value;
1735        case -1149143617: // availabilityExceptions
1736          this.availabilityExceptions = castToString(value); // StringType
1737          return value;
1738        case 1741102485: // endpoint
1739          this.getEndpoint().add(castToReference(value)); // Reference
1740          return value;
1741        default: return super.setProperty(hash, name, value);
1742        }
1743
1744      }
1745
1746      @Override
1747      public Base setProperty(String name, Base value) throws FHIRException {
1748        if (name.equals("identifier")) {
1749          this.getIdentifier().add(castToIdentifier(value));
1750        } else if (name.equals("active")) {
1751          this.active = castToBoolean(value); // BooleanType
1752        } else if (name.equals("period")) {
1753          this.period = castToPeriod(value); // Period
1754        } else if (name.equals("practitioner")) {
1755          this.practitioner = castToReference(value); // Reference
1756        } else if (name.equals("organization")) {
1757          this.organization = castToReference(value); // Reference
1758        } else if (name.equals("code")) {
1759          this.getCode().add(castToCodeableConcept(value));
1760        } else if (name.equals("specialty")) {
1761          this.getSpecialty().add(castToCodeableConcept(value));
1762        } else if (name.equals("location")) {
1763          this.getLocation().add(castToReference(value));
1764        } else if (name.equals("healthcareService")) {
1765          this.getHealthcareService().add(castToReference(value));
1766        } else if (name.equals("telecom")) {
1767          this.getTelecom().add(castToContactPoint(value));
1768        } else if (name.equals("availableTime")) {
1769          this.getAvailableTime().add((PractitionerRoleAvailableTimeComponent) value);
1770        } else if (name.equals("notAvailable")) {
1771          this.getNotAvailable().add((PractitionerRoleNotAvailableComponent) value);
1772        } else if (name.equals("availabilityExceptions")) {
1773          this.availabilityExceptions = castToString(value); // StringType
1774        } else if (name.equals("endpoint")) {
1775          this.getEndpoint().add(castToReference(value));
1776        } else
1777          return super.setProperty(name, value);
1778        return value;
1779      }
1780
1781      @Override
1782      public Base makeProperty(int hash, String name) throws FHIRException {
1783        switch (hash) {
1784        case -1618432855:  return addIdentifier(); 
1785        case -1422950650:  return getActiveElement();
1786        case -991726143:  return getPeriod();
1787        case 574573338:  return getPractitioner();
1788        case 1178922291:  return getOrganization();
1789        case 3059181:  return addCode(); 
1790        case -1694759682:  return addSpecialty(); 
1791        case 1901043637:  return addLocation(); 
1792        case 1289661064:  return addHealthcareService(); 
1793        case -1429363305:  return addTelecom(); 
1794        case 1873069366:  return addAvailableTime(); 
1795        case -629572298:  return addNotAvailable(); 
1796        case -1149143617:  return getAvailabilityExceptionsElement();
1797        case 1741102485:  return addEndpoint(); 
1798        default: return super.makeProperty(hash, name);
1799        }
1800
1801      }
1802
1803      @Override
1804      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1805        switch (hash) {
1806        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1807        case -1422950650: /*active*/ return new String[] {"boolean"};
1808        case -991726143: /*period*/ return new String[] {"Period"};
1809        case 574573338: /*practitioner*/ return new String[] {"Reference"};
1810        case 1178922291: /*organization*/ return new String[] {"Reference"};
1811        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
1812        case -1694759682: /*specialty*/ return new String[] {"CodeableConcept"};
1813        case 1901043637: /*location*/ return new String[] {"Reference"};
1814        case 1289661064: /*healthcareService*/ return new String[] {"Reference"};
1815        case -1429363305: /*telecom*/ return new String[] {"ContactPoint"};
1816        case 1873069366: /*availableTime*/ return new String[] {};
1817        case -629572298: /*notAvailable*/ return new String[] {};
1818        case -1149143617: /*availabilityExceptions*/ return new String[] {"string"};
1819        case 1741102485: /*endpoint*/ return new String[] {"Reference"};
1820        default: return super.getTypesForProperty(hash, name);
1821        }
1822
1823      }
1824
1825      @Override
1826      public Base addChild(String name) throws FHIRException {
1827        if (name.equals("identifier")) {
1828          return addIdentifier();
1829        }
1830        else if (name.equals("active")) {
1831          throw new FHIRException("Cannot call addChild on a primitive type PractitionerRole.active");
1832        }
1833        else if (name.equals("period")) {
1834          this.period = new Period();
1835          return this.period;
1836        }
1837        else if (name.equals("practitioner")) {
1838          this.practitioner = new Reference();
1839          return this.practitioner;
1840        }
1841        else if (name.equals("organization")) {
1842          this.organization = new Reference();
1843          return this.organization;
1844        }
1845        else if (name.equals("code")) {
1846          return addCode();
1847        }
1848        else if (name.equals("specialty")) {
1849          return addSpecialty();
1850        }
1851        else if (name.equals("location")) {
1852          return addLocation();
1853        }
1854        else if (name.equals("healthcareService")) {
1855          return addHealthcareService();
1856        }
1857        else if (name.equals("telecom")) {
1858          return addTelecom();
1859        }
1860        else if (name.equals("availableTime")) {
1861          return addAvailableTime();
1862        }
1863        else if (name.equals("notAvailable")) {
1864          return addNotAvailable();
1865        }
1866        else if (name.equals("availabilityExceptions")) {
1867          throw new FHIRException("Cannot call addChild on a primitive type PractitionerRole.availabilityExceptions");
1868        }
1869        else if (name.equals("endpoint")) {
1870          return addEndpoint();
1871        }
1872        else
1873          return super.addChild(name);
1874      }
1875
1876  public String fhirType() {
1877    return "PractitionerRole";
1878
1879  }
1880
1881      public PractitionerRole copy() {
1882        PractitionerRole dst = new PractitionerRole();
1883        copyValues(dst);
1884        return dst;
1885      }
1886
1887      public void copyValues(PractitionerRole dst) {
1888        super.copyValues(dst);
1889        if (identifier != null) {
1890          dst.identifier = new ArrayList<Identifier>();
1891          for (Identifier i : identifier)
1892            dst.identifier.add(i.copy());
1893        };
1894        dst.active = active == null ? null : active.copy();
1895        dst.period = period == null ? null : period.copy();
1896        dst.practitioner = practitioner == null ? null : practitioner.copy();
1897        dst.organization = organization == null ? null : organization.copy();
1898        if (code != null) {
1899          dst.code = new ArrayList<CodeableConcept>();
1900          for (CodeableConcept i : code)
1901            dst.code.add(i.copy());
1902        };
1903        if (specialty != null) {
1904          dst.specialty = new ArrayList<CodeableConcept>();
1905          for (CodeableConcept i : specialty)
1906            dst.specialty.add(i.copy());
1907        };
1908        if (location != null) {
1909          dst.location = new ArrayList<Reference>();
1910          for (Reference i : location)
1911            dst.location.add(i.copy());
1912        };
1913        if (healthcareService != null) {
1914          dst.healthcareService = new ArrayList<Reference>();
1915          for (Reference i : healthcareService)
1916            dst.healthcareService.add(i.copy());
1917        };
1918        if (telecom != null) {
1919          dst.telecom = new ArrayList<ContactPoint>();
1920          for (ContactPoint i : telecom)
1921            dst.telecom.add(i.copy());
1922        };
1923        if (availableTime != null) {
1924          dst.availableTime = new ArrayList<PractitionerRoleAvailableTimeComponent>();
1925          for (PractitionerRoleAvailableTimeComponent i : availableTime)
1926            dst.availableTime.add(i.copy());
1927        };
1928        if (notAvailable != null) {
1929          dst.notAvailable = new ArrayList<PractitionerRoleNotAvailableComponent>();
1930          for (PractitionerRoleNotAvailableComponent i : notAvailable)
1931            dst.notAvailable.add(i.copy());
1932        };
1933        dst.availabilityExceptions = availabilityExceptions == null ? null : availabilityExceptions.copy();
1934        if (endpoint != null) {
1935          dst.endpoint = new ArrayList<Reference>();
1936          for (Reference i : endpoint)
1937            dst.endpoint.add(i.copy());
1938        };
1939      }
1940
1941      protected PractitionerRole typedCopy() {
1942        return copy();
1943      }
1944
1945      @Override
1946      public boolean equalsDeep(Base other_) {
1947        if (!super.equalsDeep(other_))
1948          return false;
1949        if (!(other_ instanceof PractitionerRole))
1950          return false;
1951        PractitionerRole o = (PractitionerRole) other_;
1952        return compareDeep(identifier, o.identifier, true) && compareDeep(active, o.active, true) && compareDeep(period, o.period, true)
1953           && compareDeep(practitioner, o.practitioner, true) && compareDeep(organization, o.organization, true)
1954           && compareDeep(code, o.code, true) && compareDeep(specialty, o.specialty, true) && compareDeep(location, o.location, true)
1955           && compareDeep(healthcareService, o.healthcareService, true) && compareDeep(telecom, o.telecom, true)
1956           && compareDeep(availableTime, o.availableTime, true) && compareDeep(notAvailable, o.notAvailable, true)
1957           && compareDeep(availabilityExceptions, o.availabilityExceptions, true) && compareDeep(endpoint, o.endpoint, true)
1958          ;
1959      }
1960
1961      @Override
1962      public boolean equalsShallow(Base other_) {
1963        if (!super.equalsShallow(other_))
1964          return false;
1965        if (!(other_ instanceof PractitionerRole))
1966          return false;
1967        PractitionerRole o = (PractitionerRole) other_;
1968        return compareValues(active, o.active, true) && compareValues(availabilityExceptions, o.availabilityExceptions, true)
1969          ;
1970      }
1971
1972      public boolean isEmpty() {
1973        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, active, period
1974          , practitioner, organization, code, specialty, location, healthcareService, telecom
1975          , availableTime, notAvailable, availabilityExceptions, endpoint);
1976      }
1977
1978  @Override
1979  public ResourceType getResourceType() {
1980    return ResourceType.PractitionerRole;
1981   }
1982
1983 /**
1984   * Search parameter: <b>date</b>
1985   * <p>
1986   * Description: <b>The period during which the practitioner is authorized to perform in these role(s)</b><br>
1987   * Type: <b>date</b><br>
1988   * Path: <b>PractitionerRole.period</b><br>
1989   * </p>
1990   */
1991  @SearchParamDefinition(name="date", path="PractitionerRole.period", description="The period during which the practitioner is authorized to perform in these role(s)", type="date" )
1992  public static final String SP_DATE = "date";
1993 /**
1994   * <b>Fluent Client</b> search parameter constant for <b>date</b>
1995   * <p>
1996   * Description: <b>The period during which the practitioner is authorized to perform in these role(s)</b><br>
1997   * Type: <b>date</b><br>
1998   * Path: <b>PractitionerRole.period</b><br>
1999   * </p>
2000   */
2001  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
2002
2003 /**
2004   * Search parameter: <b>identifier</b>
2005   * <p>
2006   * Description: <b>A practitioner's Identifier</b><br>
2007   * Type: <b>token</b><br>
2008   * Path: <b>PractitionerRole.identifier</b><br>
2009   * </p>
2010   */
2011  @SearchParamDefinition(name="identifier", path="PractitionerRole.identifier", description="A practitioner's Identifier", type="token" )
2012  public static final String SP_IDENTIFIER = "identifier";
2013 /**
2014   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2015   * <p>
2016   * Description: <b>A practitioner's Identifier</b><br>
2017   * Type: <b>token</b><br>
2018   * Path: <b>PractitionerRole.identifier</b><br>
2019   * </p>
2020   */
2021  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2022
2023 /**
2024   * Search parameter: <b>specialty</b>
2025   * <p>
2026   * Description: <b>The practitioner has this specialty at an organization</b><br>
2027   * Type: <b>token</b><br>
2028   * Path: <b>PractitionerRole.specialty</b><br>
2029   * </p>
2030   */
2031  @SearchParamDefinition(name="specialty", path="PractitionerRole.specialty", description="The practitioner has this specialty at an organization", type="token" )
2032  public static final String SP_SPECIALTY = "specialty";
2033 /**
2034   * <b>Fluent Client</b> search parameter constant for <b>specialty</b>
2035   * <p>
2036   * Description: <b>The practitioner has this specialty at an organization</b><br>
2037   * Type: <b>token</b><br>
2038   * Path: <b>PractitionerRole.specialty</b><br>
2039   * </p>
2040   */
2041  public static final ca.uhn.fhir.rest.gclient.TokenClientParam SPECIALTY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_SPECIALTY);
2042
2043 /**
2044   * Search parameter: <b>role</b>
2045   * <p>
2046   * Description: <b>The practitioner can perform this role at for the organization</b><br>
2047   * Type: <b>token</b><br>
2048   * Path: <b>PractitionerRole.code</b><br>
2049   * </p>
2050   */
2051  @SearchParamDefinition(name="role", path="PractitionerRole.code", description="The practitioner can perform this role at for the organization", type="token" )
2052  public static final String SP_ROLE = "role";
2053 /**
2054   * <b>Fluent Client</b> search parameter constant for <b>role</b>
2055   * <p>
2056   * Description: <b>The practitioner can perform this role at for the organization</b><br>
2057   * Type: <b>token</b><br>
2058   * Path: <b>PractitionerRole.code</b><br>
2059   * </p>
2060   */
2061  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ROLE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_ROLE);
2062
2063 /**
2064   * Search parameter: <b>practitioner</b>
2065   * <p>
2066   * Description: <b>Practitioner that is able to provide the defined services for the organization</b><br>
2067   * Type: <b>reference</b><br>
2068   * Path: <b>PractitionerRole.practitioner</b><br>
2069   * </p>
2070   */
2071  @SearchParamDefinition(name="practitioner", path="PractitionerRole.practitioner", description="Practitioner that is able to provide the defined services for the organization", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={Practitioner.class } )
2072  public static final String SP_PRACTITIONER = "practitioner";
2073 /**
2074   * <b>Fluent Client</b> search parameter constant for <b>practitioner</b>
2075   * <p>
2076   * Description: <b>Practitioner that is able to provide the defined services for the organization</b><br>
2077   * Type: <b>reference</b><br>
2078   * Path: <b>PractitionerRole.practitioner</b><br>
2079   * </p>
2080   */
2081  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PRACTITIONER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PRACTITIONER);
2082
2083/**
2084   * Constant for fluent queries to be used to add include statements. Specifies
2085   * the path value of "<b>PractitionerRole:practitioner</b>".
2086   */
2087  public static final ca.uhn.fhir.model.api.Include INCLUDE_PRACTITIONER = new ca.uhn.fhir.model.api.Include("PractitionerRole:practitioner").toLocked();
2088
2089 /**
2090   * Search parameter: <b>active</b>
2091   * <p>
2092   * Description: <b>Whether this practitioner role record is in active use</b><br>
2093   * Type: <b>token</b><br>
2094   * Path: <b>PractitionerRole.active</b><br>
2095   * </p>
2096   */
2097  @SearchParamDefinition(name="active", path="PractitionerRole.active", description="Whether this practitioner role record is in active use", type="token" )
2098  public static final String SP_ACTIVE = "active";
2099 /**
2100   * <b>Fluent Client</b> search parameter constant for <b>active</b>
2101   * <p>
2102   * Description: <b>Whether this practitioner role record is in active use</b><br>
2103   * Type: <b>token</b><br>
2104   * Path: <b>PractitionerRole.active</b><br>
2105   * </p>
2106   */
2107  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ACTIVE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_ACTIVE);
2108
2109 /**
2110   * Search parameter: <b>endpoint</b>
2111   * <p>
2112   * Description: <b>Technical endpoints providing access to services operated for the practitioner with this role</b><br>
2113   * Type: <b>reference</b><br>
2114   * Path: <b>PractitionerRole.endpoint</b><br>
2115   * </p>
2116   */
2117  @SearchParamDefinition(name="endpoint", path="PractitionerRole.endpoint", description="Technical endpoints providing access to services operated for the practitioner with this role", type="reference", target={Endpoint.class } )
2118  public static final String SP_ENDPOINT = "endpoint";
2119 /**
2120   * <b>Fluent Client</b> search parameter constant for <b>endpoint</b>
2121   * <p>
2122   * Description: <b>Technical endpoints providing access to services operated for the practitioner with this role</b><br>
2123   * Type: <b>reference</b><br>
2124   * Path: <b>PractitionerRole.endpoint</b><br>
2125   * </p>
2126   */
2127  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENDPOINT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENDPOINT);
2128
2129/**
2130   * Constant for fluent queries to be used to add include statements. Specifies
2131   * the path value of "<b>PractitionerRole:endpoint</b>".
2132   */
2133  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENDPOINT = new ca.uhn.fhir.model.api.Include("PractitionerRole:endpoint").toLocked();
2134
2135 /**
2136   * Search parameter: <b>phone</b>
2137   * <p>
2138   * Description: <b>A value in a phone contact</b><br>
2139   * Type: <b>token</b><br>
2140   * Path: <b>PractitionerRole.telecom(system=phone)</b><br>
2141   * </p>
2142   */
2143  @SearchParamDefinition(name="phone", path="PractitionerRole.telecom.where(system='phone')", description="A value in a phone contact", type="token" )
2144  public static final String SP_PHONE = "phone";
2145 /**
2146   * <b>Fluent Client</b> search parameter constant for <b>phone</b>
2147   * <p>
2148   * Description: <b>A value in a phone contact</b><br>
2149   * Type: <b>token</b><br>
2150   * Path: <b>PractitionerRole.telecom(system=phone)</b><br>
2151   * </p>
2152   */
2153  public static final ca.uhn.fhir.rest.gclient.TokenClientParam PHONE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_PHONE);
2154
2155 /**
2156   * Search parameter: <b>service</b>
2157   * <p>
2158   * Description: <b>The list of healthcare services that this worker provides for this role's Organization/Location(s)</b><br>
2159   * Type: <b>reference</b><br>
2160   * Path: <b>PractitionerRole.healthcareService</b><br>
2161   * </p>
2162   */
2163  @SearchParamDefinition(name="service", path="PractitionerRole.healthcareService", description="The list of healthcare services that this worker provides for this role's Organization/Location(s)", type="reference", target={HealthcareService.class } )
2164  public static final String SP_SERVICE = "service";
2165 /**
2166   * <b>Fluent Client</b> search parameter constant for <b>service</b>
2167   * <p>
2168   * Description: <b>The list of healthcare services that this worker provides for this role's Organization/Location(s)</b><br>
2169   * Type: <b>reference</b><br>
2170   * Path: <b>PractitionerRole.healthcareService</b><br>
2171   * </p>
2172   */
2173  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SERVICE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SERVICE);
2174
2175/**
2176   * Constant for fluent queries to be used to add include statements. Specifies
2177   * the path value of "<b>PractitionerRole:service</b>".
2178   */
2179  public static final ca.uhn.fhir.model.api.Include INCLUDE_SERVICE = new ca.uhn.fhir.model.api.Include("PractitionerRole:service").toLocked();
2180
2181 /**
2182   * Search parameter: <b>organization</b>
2183   * <p>
2184   * Description: <b>The identity of the organization the practitioner represents / acts on behalf of</b><br>
2185   * Type: <b>reference</b><br>
2186   * Path: <b>PractitionerRole.organization</b><br>
2187   * </p>
2188   */
2189  @SearchParamDefinition(name="organization", path="PractitionerRole.organization", description="The identity of the organization the practitioner represents / acts on behalf of", type="reference", target={Organization.class } )
2190  public static final String SP_ORGANIZATION = "organization";
2191 /**
2192   * <b>Fluent Client</b> search parameter constant for <b>organization</b>
2193   * <p>
2194   * Description: <b>The identity of the organization the practitioner represents / acts on behalf of</b><br>
2195   * Type: <b>reference</b><br>
2196   * Path: <b>PractitionerRole.organization</b><br>
2197   * </p>
2198   */
2199  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ORGANIZATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ORGANIZATION);
2200
2201/**
2202   * Constant for fluent queries to be used to add include statements. Specifies
2203   * the path value of "<b>PractitionerRole:organization</b>".
2204   */
2205  public static final ca.uhn.fhir.model.api.Include INCLUDE_ORGANIZATION = new ca.uhn.fhir.model.api.Include("PractitionerRole:organization").toLocked();
2206
2207 /**
2208   * Search parameter: <b>telecom</b>
2209   * <p>
2210   * Description: <b>The value in any kind of contact</b><br>
2211   * Type: <b>token</b><br>
2212   * Path: <b>PractitionerRole.telecom</b><br>
2213   * </p>
2214   */
2215  @SearchParamDefinition(name="telecom", path="PractitionerRole.telecom", description="The value in any kind of contact", type="token" )
2216  public static final String SP_TELECOM = "telecom";
2217 /**
2218   * <b>Fluent Client</b> search parameter constant for <b>telecom</b>
2219   * <p>
2220   * Description: <b>The value in any kind of contact</b><br>
2221   * Type: <b>token</b><br>
2222   * Path: <b>PractitionerRole.telecom</b><br>
2223   * </p>
2224   */
2225  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TELECOM = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TELECOM);
2226
2227 /**
2228   * Search parameter: <b>location</b>
2229   * <p>
2230   * Description: <b>One of the locations at which this practitioner provides care</b><br>
2231   * Type: <b>reference</b><br>
2232   * Path: <b>PractitionerRole.location</b><br>
2233   * </p>
2234   */
2235  @SearchParamDefinition(name="location", path="PractitionerRole.location", description="One of the locations at which this practitioner provides care", type="reference", target={Location.class } )
2236  public static final String SP_LOCATION = "location";
2237 /**
2238   * <b>Fluent Client</b> search parameter constant for <b>location</b>
2239   * <p>
2240   * Description: <b>One of the locations at which this practitioner provides care</b><br>
2241   * Type: <b>reference</b><br>
2242   * Path: <b>PractitionerRole.location</b><br>
2243   * </p>
2244   */
2245  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam LOCATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_LOCATION);
2246
2247/**
2248   * Constant for fluent queries to be used to add include statements. Specifies
2249   * the path value of "<b>PractitionerRole:location</b>".
2250   */
2251  public static final ca.uhn.fhir.model.api.Include INCLUDE_LOCATION = new ca.uhn.fhir.model.api.Include("PractitionerRole:location").toLocked();
2252
2253 /**
2254   * Search parameter: <b>email</b>
2255   * <p>
2256   * Description: <b>A value in an email contact</b><br>
2257   * Type: <b>token</b><br>
2258   * Path: <b>PractitionerRole.telecom(system=email)</b><br>
2259   * </p>
2260   */
2261  @SearchParamDefinition(name="email", path="PractitionerRole.telecom.where(system='email')", description="A value in an email contact", type="token" )
2262  public static final String SP_EMAIL = "email";
2263 /**
2264   * <b>Fluent Client</b> search parameter constant for <b>email</b>
2265   * <p>
2266   * Description: <b>A value in an email contact</b><br>
2267   * Type: <b>token</b><br>
2268   * Path: <b>PractitionerRole.telecom(system=email)</b><br>
2269   * </p>
2270   */
2271  public static final ca.uhn.fhir.rest.gclient.TokenClientParam EMAIL = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_EMAIL);
2272
2273
2274}
2275