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