001package org.hl7.fhir.dstu3.model;
002
003
004
005
006/*
007  Copyright (c) 2011+, HL7, Inc.
008  All rights reserved.
009  
010  Redistribution and use in source and binary forms, with or without modification, 
011  are permitted provided that the following conditions are met:
012  
013   * Redistributions of source code must retain the above copyright notice, this 
014     list of conditions and the following disclaimer.
015   * Redistributions in binary form must reproduce the above copyright notice, 
016     this list of conditions and the following disclaimer in the documentation 
017     and/or other materials provided with the distribution.
018   * Neither the name of HL7 nor the names of its contributors may be used to 
019     endorse or promote products derived from this software without specific 
020     prior written permission.
021  
022  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
023  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
024  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
025  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
026  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
027  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
028  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
029  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
030  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
031  POSSIBILITY OF SUCH DAMAGE.
032  
033*/
034
035// Generated on Fri, Mar 16, 2018 15:21+1100 for FHIR v3.0.x
036import java.util.ArrayList;
037import java.util.Date;
038import java.util.List;
039
040import org.hl7.fhir.exceptions.FHIRException;
041import org.hl7.fhir.exceptions.FHIRFormatError;
042import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
043import org.hl7.fhir.utilities.Utilities;
044
045import ca.uhn.fhir.model.api.annotation.Block;
046import ca.uhn.fhir.model.api.annotation.Child;
047import ca.uhn.fhir.model.api.annotation.Description;
048import ca.uhn.fhir.model.api.annotation.ResourceDef;
049import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
050/**
051 * Used to record and send details about a request for referral service or transfer of a patient to the care of another provider or provider organization.
052 */
053@ResourceDef(name="ReferralRequest", profile="http://hl7.org/fhir/Profile/ReferralRequest")
054public class ReferralRequest extends DomainResource {
055
056    public enum ReferralRequestStatus {
057        /**
058         * The request has been created but is not yet complete or ready for action
059         */
060        DRAFT, 
061        /**
062         * The request is ready to be acted upon
063         */
064        ACTIVE, 
065        /**
066         * The authorization/request to act has been temporarily withdrawn but is expected to resume in the future
067         */
068        SUSPENDED, 
069        /**
070         * The authorization/request to act has been terminated prior to the full completion of the intended actions.  No further activity should occur.
071         */
072        CANCELLED, 
073        /**
074         * Activity against the request has been sufficiently completed to the satisfaction of the requester
075         */
076        COMPLETED, 
077        /**
078         * This electronic record should never have existed, though it is possible that real-world decisions were based on it.  (If real-world activity has occurred, the status should be "cancelled" rather than "entered-in-error".)
079         */
080        ENTEREDINERROR, 
081        /**
082         * The authoring system does not know which of the status values currently applies for this request.  Note: This concept is not to be used for "other" . One of the listed statuses is presumed to apply,  but the system creating the request doesn't know.
083         */
084        UNKNOWN, 
085        /**
086         * added to help the parsers with the generic types
087         */
088        NULL;
089        public static ReferralRequestStatus fromCode(String codeString) throws FHIRException {
090            if (codeString == null || "".equals(codeString))
091                return null;
092        if ("draft".equals(codeString))
093          return DRAFT;
094        if ("active".equals(codeString))
095          return ACTIVE;
096        if ("suspended".equals(codeString))
097          return SUSPENDED;
098        if ("cancelled".equals(codeString))
099          return CANCELLED;
100        if ("completed".equals(codeString))
101          return COMPLETED;
102        if ("entered-in-error".equals(codeString))
103          return ENTEREDINERROR;
104        if ("unknown".equals(codeString))
105          return UNKNOWN;
106        if (Configuration.isAcceptInvalidEnums())
107          return null;
108        else
109          throw new FHIRException("Unknown ReferralRequestStatus code '"+codeString+"'");
110        }
111        public String toCode() {
112          switch (this) {
113            case DRAFT: return "draft";
114            case ACTIVE: return "active";
115            case SUSPENDED: return "suspended";
116            case CANCELLED: return "cancelled";
117            case COMPLETED: return "completed";
118            case ENTEREDINERROR: return "entered-in-error";
119            case UNKNOWN: return "unknown";
120            case NULL: return null;
121            default: return "?";
122          }
123        }
124        public String getSystem() {
125          switch (this) {
126            case DRAFT: return "http://hl7.org/fhir/request-status";
127            case ACTIVE: return "http://hl7.org/fhir/request-status";
128            case SUSPENDED: return "http://hl7.org/fhir/request-status";
129            case CANCELLED: return "http://hl7.org/fhir/request-status";
130            case COMPLETED: return "http://hl7.org/fhir/request-status";
131            case ENTEREDINERROR: return "http://hl7.org/fhir/request-status";
132            case UNKNOWN: return "http://hl7.org/fhir/request-status";
133            case NULL: return null;
134            default: return "?";
135          }
136        }
137        public String getDefinition() {
138          switch (this) {
139            case DRAFT: return "The request has been created but is not yet complete or ready for action";
140            case ACTIVE: return "The request is ready to be acted upon";
141            case SUSPENDED: return "The authorization/request to act has been temporarily withdrawn but is expected to resume in the future";
142            case CANCELLED: return "The authorization/request to act has been terminated prior to the full completion of the intended actions.  No further activity should occur.";
143            case COMPLETED: return "Activity against the request has been sufficiently completed to the satisfaction of the requester";
144            case ENTEREDINERROR: return "This electronic record should never have existed, though it is possible that real-world decisions were based on it.  (If real-world activity has occurred, the status should be \"cancelled\" rather than \"entered-in-error\".)";
145            case UNKNOWN: return "The authoring system does not know which of the status values currently applies for this request.  Note: This concept is not to be used for \"other\" . One of the listed statuses is presumed to apply,  but the system creating the request doesn't know.";
146            case NULL: return null;
147            default: return "?";
148          }
149        }
150        public String getDisplay() {
151          switch (this) {
152            case DRAFT: return "Draft";
153            case ACTIVE: return "Active";
154            case SUSPENDED: return "Suspended";
155            case CANCELLED: return "Cancelled";
156            case COMPLETED: return "Completed";
157            case ENTEREDINERROR: return "Entered in Error";
158            case UNKNOWN: return "Unknown";
159            case NULL: return null;
160            default: return "?";
161          }
162        }
163    }
164
165  public static class ReferralRequestStatusEnumFactory implements EnumFactory<ReferralRequestStatus> {
166    public ReferralRequestStatus fromCode(String codeString) throws IllegalArgumentException {
167      if (codeString == null || "".equals(codeString))
168            if (codeString == null || "".equals(codeString))
169                return null;
170        if ("draft".equals(codeString))
171          return ReferralRequestStatus.DRAFT;
172        if ("active".equals(codeString))
173          return ReferralRequestStatus.ACTIVE;
174        if ("suspended".equals(codeString))
175          return ReferralRequestStatus.SUSPENDED;
176        if ("cancelled".equals(codeString))
177          return ReferralRequestStatus.CANCELLED;
178        if ("completed".equals(codeString))
179          return ReferralRequestStatus.COMPLETED;
180        if ("entered-in-error".equals(codeString))
181          return ReferralRequestStatus.ENTEREDINERROR;
182        if ("unknown".equals(codeString))
183          return ReferralRequestStatus.UNKNOWN;
184        throw new IllegalArgumentException("Unknown ReferralRequestStatus code '"+codeString+"'");
185        }
186        public Enumeration<ReferralRequestStatus> fromType(PrimitiveType<?> code) throws FHIRException {
187          if (code == null)
188            return null;
189          if (code.isEmpty())
190            return new Enumeration<ReferralRequestStatus>(this);
191          String codeString = code.asStringValue();
192          if (codeString == null || "".equals(codeString))
193            return null;
194        if ("draft".equals(codeString))
195          return new Enumeration<ReferralRequestStatus>(this, ReferralRequestStatus.DRAFT);
196        if ("active".equals(codeString))
197          return new Enumeration<ReferralRequestStatus>(this, ReferralRequestStatus.ACTIVE);
198        if ("suspended".equals(codeString))
199          return new Enumeration<ReferralRequestStatus>(this, ReferralRequestStatus.SUSPENDED);
200        if ("cancelled".equals(codeString))
201          return new Enumeration<ReferralRequestStatus>(this, ReferralRequestStatus.CANCELLED);
202        if ("completed".equals(codeString))
203          return new Enumeration<ReferralRequestStatus>(this, ReferralRequestStatus.COMPLETED);
204        if ("entered-in-error".equals(codeString))
205          return new Enumeration<ReferralRequestStatus>(this, ReferralRequestStatus.ENTEREDINERROR);
206        if ("unknown".equals(codeString))
207          return new Enumeration<ReferralRequestStatus>(this, ReferralRequestStatus.UNKNOWN);
208        throw new FHIRException("Unknown ReferralRequestStatus code '"+codeString+"'");
209        }
210    public String toCode(ReferralRequestStatus code) {
211       if (code == ReferralRequestStatus.NULL)
212           return null;
213       if (code == ReferralRequestStatus.DRAFT)
214        return "draft";
215      if (code == ReferralRequestStatus.ACTIVE)
216        return "active";
217      if (code == ReferralRequestStatus.SUSPENDED)
218        return "suspended";
219      if (code == ReferralRequestStatus.CANCELLED)
220        return "cancelled";
221      if (code == ReferralRequestStatus.COMPLETED)
222        return "completed";
223      if (code == ReferralRequestStatus.ENTEREDINERROR)
224        return "entered-in-error";
225      if (code == ReferralRequestStatus.UNKNOWN)
226        return "unknown";
227      return "?";
228   }
229    public String toSystem(ReferralRequestStatus code) {
230      return code.getSystem();
231      }
232    }
233
234    public enum ReferralCategory {
235        /**
236         * The request is a suggestion made by someone/something that doesn't have an intention to ensure it occurs and without providing an authorization to act
237         */
238        PROPOSAL, 
239        /**
240         * The request represents an intension to ensure something occurs without providing an authorization for others to act
241         */
242        PLAN, 
243        /**
244         * The request represents a request/demand and authorization for action
245         */
246        ORDER, 
247        /**
248         * The request represents an original authorization for action
249         */
250        ORIGINALORDER, 
251        /**
252         * The request represents an automatically generated supplemental authorization for action based on a parent authorization together with initial results of the action taken against that parent authorization
253         */
254        REFLEXORDER, 
255        /**
256         * The request represents the view of an authorization instantiated by a fulfilling system representing the details of the fulfiller's intention to act upon a submitted order
257         */
258        FILLERORDER, 
259        /**
260         * An order created in fulfillment of a broader order that represents the authorization for a single activity occurrence.  E.g. The administration of a single dose of a drug.
261         */
262        INSTANCEORDER, 
263        /**
264         * The request represents a component or option for a RequestGroup that establishes timing, conditionality and/or other constraints among a set of requests.
265
266Refer to [[[RequestGroup]]] for additional information on how this status is used
267         */
268        OPTION, 
269        /**
270         * added to help the parsers with the generic types
271         */
272        NULL;
273        public static ReferralCategory fromCode(String codeString) throws FHIRException {
274            if (codeString == null || "".equals(codeString))
275                return null;
276        if ("proposal".equals(codeString))
277          return PROPOSAL;
278        if ("plan".equals(codeString))
279          return PLAN;
280        if ("order".equals(codeString))
281          return ORDER;
282        if ("original-order".equals(codeString))
283          return ORIGINALORDER;
284        if ("reflex-order".equals(codeString))
285          return REFLEXORDER;
286        if ("filler-order".equals(codeString))
287          return FILLERORDER;
288        if ("instance-order".equals(codeString))
289          return INSTANCEORDER;
290        if ("option".equals(codeString))
291          return OPTION;
292        if (Configuration.isAcceptInvalidEnums())
293          return null;
294        else
295          throw new FHIRException("Unknown ReferralCategory code '"+codeString+"'");
296        }
297        public String toCode() {
298          switch (this) {
299            case PROPOSAL: return "proposal";
300            case PLAN: return "plan";
301            case ORDER: return "order";
302            case ORIGINALORDER: return "original-order";
303            case REFLEXORDER: return "reflex-order";
304            case FILLERORDER: return "filler-order";
305            case INSTANCEORDER: return "instance-order";
306            case OPTION: return "option";
307            case NULL: return null;
308            default: return "?";
309          }
310        }
311        public String getSystem() {
312          switch (this) {
313            case PROPOSAL: return "http://hl7.org/fhir/request-intent";
314            case PLAN: return "http://hl7.org/fhir/request-intent";
315            case ORDER: return "http://hl7.org/fhir/request-intent";
316            case ORIGINALORDER: return "http://hl7.org/fhir/request-intent";
317            case REFLEXORDER: return "http://hl7.org/fhir/request-intent";
318            case FILLERORDER: return "http://hl7.org/fhir/request-intent";
319            case INSTANCEORDER: return "http://hl7.org/fhir/request-intent";
320            case OPTION: return "http://hl7.org/fhir/request-intent";
321            case NULL: return null;
322            default: return "?";
323          }
324        }
325        public String getDefinition() {
326          switch (this) {
327            case PROPOSAL: return "The request is a suggestion made by someone/something that doesn't have an intention to ensure it occurs and without providing an authorization to act";
328            case PLAN: return "The request represents an intension to ensure something occurs without providing an authorization for others to act";
329            case ORDER: return "The request represents a request/demand and authorization for action";
330            case ORIGINALORDER: return "The request represents an original authorization for action";
331            case REFLEXORDER: return "The request represents an automatically generated supplemental authorization for action based on a parent authorization together with initial results of the action taken against that parent authorization";
332            case FILLERORDER: return "The request represents the view of an authorization instantiated by a fulfilling system representing the details of the fulfiller's intention to act upon a submitted order";
333            case INSTANCEORDER: return "An order created in fulfillment of a broader order that represents the authorization for a single activity occurrence.  E.g. The administration of a single dose of a drug.";
334            case OPTION: return "The request represents a component or option for a RequestGroup that establishes timing, conditionality and/or other constraints among a set of requests.\n\nRefer to [[[RequestGroup]]] for additional information on how this status is used";
335            case NULL: return null;
336            default: return "?";
337          }
338        }
339        public String getDisplay() {
340          switch (this) {
341            case PROPOSAL: return "Proposal";
342            case PLAN: return "Plan";
343            case ORDER: return "Order";
344            case ORIGINALORDER: return "Original Order";
345            case REFLEXORDER: return "Reflex Order";
346            case FILLERORDER: return "Filler Order";
347            case INSTANCEORDER: return "Instance Order";
348            case OPTION: return "Option";
349            case NULL: return null;
350            default: return "?";
351          }
352        }
353    }
354
355  public static class ReferralCategoryEnumFactory implements EnumFactory<ReferralCategory> {
356    public ReferralCategory fromCode(String codeString) throws IllegalArgumentException {
357      if (codeString == null || "".equals(codeString))
358            if (codeString == null || "".equals(codeString))
359                return null;
360        if ("proposal".equals(codeString))
361          return ReferralCategory.PROPOSAL;
362        if ("plan".equals(codeString))
363          return ReferralCategory.PLAN;
364        if ("order".equals(codeString))
365          return ReferralCategory.ORDER;
366        if ("original-order".equals(codeString))
367          return ReferralCategory.ORIGINALORDER;
368        if ("reflex-order".equals(codeString))
369          return ReferralCategory.REFLEXORDER;
370        if ("filler-order".equals(codeString))
371          return ReferralCategory.FILLERORDER;
372        if ("instance-order".equals(codeString))
373          return ReferralCategory.INSTANCEORDER;
374        if ("option".equals(codeString))
375          return ReferralCategory.OPTION;
376        throw new IllegalArgumentException("Unknown ReferralCategory code '"+codeString+"'");
377        }
378        public Enumeration<ReferralCategory> fromType(PrimitiveType<?> code) throws FHIRException {
379          if (code == null)
380            return null;
381          if (code.isEmpty())
382            return new Enumeration<ReferralCategory>(this);
383          String codeString = code.asStringValue();
384          if (codeString == null || "".equals(codeString))
385            return null;
386        if ("proposal".equals(codeString))
387          return new Enumeration<ReferralCategory>(this, ReferralCategory.PROPOSAL);
388        if ("plan".equals(codeString))
389          return new Enumeration<ReferralCategory>(this, ReferralCategory.PLAN);
390        if ("order".equals(codeString))
391          return new Enumeration<ReferralCategory>(this, ReferralCategory.ORDER);
392        if ("original-order".equals(codeString))
393          return new Enumeration<ReferralCategory>(this, ReferralCategory.ORIGINALORDER);
394        if ("reflex-order".equals(codeString))
395          return new Enumeration<ReferralCategory>(this, ReferralCategory.REFLEXORDER);
396        if ("filler-order".equals(codeString))
397          return new Enumeration<ReferralCategory>(this, ReferralCategory.FILLERORDER);
398        if ("instance-order".equals(codeString))
399          return new Enumeration<ReferralCategory>(this, ReferralCategory.INSTANCEORDER);
400        if ("option".equals(codeString))
401          return new Enumeration<ReferralCategory>(this, ReferralCategory.OPTION);
402        throw new FHIRException("Unknown ReferralCategory code '"+codeString+"'");
403        }
404    public String toCode(ReferralCategory code) {
405       if (code == ReferralCategory.NULL)
406           return null;
407       if (code == ReferralCategory.PROPOSAL)
408        return "proposal";
409      if (code == ReferralCategory.PLAN)
410        return "plan";
411      if (code == ReferralCategory.ORDER)
412        return "order";
413      if (code == ReferralCategory.ORIGINALORDER)
414        return "original-order";
415      if (code == ReferralCategory.REFLEXORDER)
416        return "reflex-order";
417      if (code == ReferralCategory.FILLERORDER)
418        return "filler-order";
419      if (code == ReferralCategory.INSTANCEORDER)
420        return "instance-order";
421      if (code == ReferralCategory.OPTION)
422        return "option";
423      return "?";
424   }
425    public String toSystem(ReferralCategory code) {
426      return code.getSystem();
427      }
428    }
429
430    public enum ReferralPriority {
431        /**
432         * The request has normal priority
433         */
434        ROUTINE, 
435        /**
436         * The request should be actioned promptly - higher priority than routine
437         */
438        URGENT, 
439        /**
440         * The request should be actioned as soon as possible - higher priority than urgent
441         */
442        ASAP, 
443        /**
444         * The request should be actioned immediately - highest possible priority.  E.g. an emergency
445         */
446        STAT, 
447        /**
448         * added to help the parsers with the generic types
449         */
450        NULL;
451        public static ReferralPriority fromCode(String codeString) throws FHIRException {
452            if (codeString == null || "".equals(codeString))
453                return null;
454        if ("routine".equals(codeString))
455          return ROUTINE;
456        if ("urgent".equals(codeString))
457          return URGENT;
458        if ("asap".equals(codeString))
459          return ASAP;
460        if ("stat".equals(codeString))
461          return STAT;
462        if (Configuration.isAcceptInvalidEnums())
463          return null;
464        else
465          throw new FHIRException("Unknown ReferralPriority code '"+codeString+"'");
466        }
467        public String toCode() {
468          switch (this) {
469            case ROUTINE: return "routine";
470            case URGENT: return "urgent";
471            case ASAP: return "asap";
472            case STAT: return "stat";
473            case NULL: return null;
474            default: return "?";
475          }
476        }
477        public String getSystem() {
478          switch (this) {
479            case ROUTINE: return "http://hl7.org/fhir/request-priority";
480            case URGENT: return "http://hl7.org/fhir/request-priority";
481            case ASAP: return "http://hl7.org/fhir/request-priority";
482            case STAT: return "http://hl7.org/fhir/request-priority";
483            case NULL: return null;
484            default: return "?";
485          }
486        }
487        public String getDefinition() {
488          switch (this) {
489            case ROUTINE: return "The request has normal priority";
490            case URGENT: return "The request should be actioned promptly - higher priority than routine";
491            case ASAP: return "The request should be actioned as soon as possible - higher priority than urgent";
492            case STAT: return "The request should be actioned immediately - highest possible priority.  E.g. an emergency";
493            case NULL: return null;
494            default: return "?";
495          }
496        }
497        public String getDisplay() {
498          switch (this) {
499            case ROUTINE: return "Routine";
500            case URGENT: return "Urgent";
501            case ASAP: return "ASAP";
502            case STAT: return "STAT";
503            case NULL: return null;
504            default: return "?";
505          }
506        }
507    }
508
509  public static class ReferralPriorityEnumFactory implements EnumFactory<ReferralPriority> {
510    public ReferralPriority fromCode(String codeString) throws IllegalArgumentException {
511      if (codeString == null || "".equals(codeString))
512            if (codeString == null || "".equals(codeString))
513                return null;
514        if ("routine".equals(codeString))
515          return ReferralPriority.ROUTINE;
516        if ("urgent".equals(codeString))
517          return ReferralPriority.URGENT;
518        if ("asap".equals(codeString))
519          return ReferralPriority.ASAP;
520        if ("stat".equals(codeString))
521          return ReferralPriority.STAT;
522        throw new IllegalArgumentException("Unknown ReferralPriority code '"+codeString+"'");
523        }
524        public Enumeration<ReferralPriority> fromType(PrimitiveType<?> code) throws FHIRException {
525          if (code == null)
526            return null;
527          if (code.isEmpty())
528            return new Enumeration<ReferralPriority>(this);
529          String codeString = code.asStringValue();
530          if (codeString == null || "".equals(codeString))
531            return null;
532        if ("routine".equals(codeString))
533          return new Enumeration<ReferralPriority>(this, ReferralPriority.ROUTINE);
534        if ("urgent".equals(codeString))
535          return new Enumeration<ReferralPriority>(this, ReferralPriority.URGENT);
536        if ("asap".equals(codeString))
537          return new Enumeration<ReferralPriority>(this, ReferralPriority.ASAP);
538        if ("stat".equals(codeString))
539          return new Enumeration<ReferralPriority>(this, ReferralPriority.STAT);
540        throw new FHIRException("Unknown ReferralPriority code '"+codeString+"'");
541        }
542    public String toCode(ReferralPriority code) {
543       if (code == ReferralPriority.NULL)
544           return null;
545       if (code == ReferralPriority.ROUTINE)
546        return "routine";
547      if (code == ReferralPriority.URGENT)
548        return "urgent";
549      if (code == ReferralPriority.ASAP)
550        return "asap";
551      if (code == ReferralPriority.STAT)
552        return "stat";
553      return "?";
554   }
555    public String toSystem(ReferralPriority code) {
556      return code.getSystem();
557      }
558    }
559
560    @Block()
561    public static class ReferralRequestRequesterComponent extends BackboneElement implements IBaseBackboneElement {
562        /**
563         * The device, practitioner, etc. who initiated the request.
564         */
565        @Child(name = "agent", type = {Practitioner.class, Organization.class, Patient.class, RelatedPerson.class, Device.class}, order=1, min=1, max=1, modifier=false, summary=true)
566        @Description(shortDefinition="Individual making the request", formalDefinition="The device, practitioner, etc. who initiated the request." )
567        protected Reference agent;
568
569        /**
570         * The actual object that is the target of the reference (The device, practitioner, etc. who initiated the request.)
571         */
572        protected Resource agentTarget;
573
574        /**
575         * The organization the device or practitioner was acting on behalf of.
576         */
577        @Child(name = "onBehalfOf", type = {Organization.class}, order=2, min=0, max=1, modifier=false, summary=true)
578        @Description(shortDefinition="Organization agent is acting for", formalDefinition="The organization the device or practitioner was acting on behalf of." )
579        protected Reference onBehalfOf;
580
581        /**
582         * The actual object that is the target of the reference (The organization the device or practitioner was acting on behalf of.)
583         */
584        protected Organization onBehalfOfTarget;
585
586        private static final long serialVersionUID = -71453027L;
587
588    /**
589     * Constructor
590     */
591      public ReferralRequestRequesterComponent() {
592        super();
593      }
594
595    /**
596     * Constructor
597     */
598      public ReferralRequestRequesterComponent(Reference agent) {
599        super();
600        this.agent = agent;
601      }
602
603        /**
604         * @return {@link #agent} (The device, practitioner, etc. who initiated the request.)
605         */
606        public Reference getAgent() { 
607          if (this.agent == null)
608            if (Configuration.errorOnAutoCreate())
609              throw new Error("Attempt to auto-create ReferralRequestRequesterComponent.agent");
610            else if (Configuration.doAutoCreate())
611              this.agent = new Reference(); // cc
612          return this.agent;
613        }
614
615        public boolean hasAgent() { 
616          return this.agent != null && !this.agent.isEmpty();
617        }
618
619        /**
620         * @param value {@link #agent} (The device, practitioner, etc. who initiated the request.)
621         */
622        public ReferralRequestRequesterComponent setAgent(Reference value)  { 
623          this.agent = value;
624          return this;
625        }
626
627        /**
628         * @return {@link #agent} 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 device, practitioner, etc. who initiated the request.)
629         */
630        public Resource getAgentTarget() { 
631          return this.agentTarget;
632        }
633
634        /**
635         * @param value {@link #agent} 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 device, practitioner, etc. who initiated the request.)
636         */
637        public ReferralRequestRequesterComponent setAgentTarget(Resource value) { 
638          this.agentTarget = value;
639          return this;
640        }
641
642        /**
643         * @return {@link #onBehalfOf} (The organization the device or practitioner was acting on behalf of.)
644         */
645        public Reference getOnBehalfOf() { 
646          if (this.onBehalfOf == null)
647            if (Configuration.errorOnAutoCreate())
648              throw new Error("Attempt to auto-create ReferralRequestRequesterComponent.onBehalfOf");
649            else if (Configuration.doAutoCreate())
650              this.onBehalfOf = new Reference(); // cc
651          return this.onBehalfOf;
652        }
653
654        public boolean hasOnBehalfOf() { 
655          return this.onBehalfOf != null && !this.onBehalfOf.isEmpty();
656        }
657
658        /**
659         * @param value {@link #onBehalfOf} (The organization the device or practitioner was acting on behalf of.)
660         */
661        public ReferralRequestRequesterComponent setOnBehalfOf(Reference value)  { 
662          this.onBehalfOf = value;
663          return this;
664        }
665
666        /**
667         * @return {@link #onBehalfOf} 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 the device or practitioner was acting on behalf of.)
668         */
669        public Organization getOnBehalfOfTarget() { 
670          if (this.onBehalfOfTarget == null)
671            if (Configuration.errorOnAutoCreate())
672              throw new Error("Attempt to auto-create ReferralRequestRequesterComponent.onBehalfOf");
673            else if (Configuration.doAutoCreate())
674              this.onBehalfOfTarget = new Organization(); // aa
675          return this.onBehalfOfTarget;
676        }
677
678        /**
679         * @param value {@link #onBehalfOf} 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 the device or practitioner was acting on behalf of.)
680         */
681        public ReferralRequestRequesterComponent setOnBehalfOfTarget(Organization value) { 
682          this.onBehalfOfTarget = value;
683          return this;
684        }
685
686        protected void listChildren(List<Property> children) {
687          super.listChildren(children);
688          children.add(new Property("agent", "Reference(Practitioner|Organization|Patient|RelatedPerson|Device)", "The device, practitioner, etc. who initiated the request.", 0, 1, agent));
689          children.add(new Property("onBehalfOf", "Reference(Organization)", "The organization the device or practitioner was acting on behalf of.", 0, 1, onBehalfOf));
690        }
691
692        @Override
693        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
694          switch (_hash) {
695          case 92750597: /*agent*/  return new Property("agent", "Reference(Practitioner|Organization|Patient|RelatedPerson|Device)", "The device, practitioner, etc. who initiated the request.", 0, 1, agent);
696          case -14402964: /*onBehalfOf*/  return new Property("onBehalfOf", "Reference(Organization)", "The organization the device or practitioner was acting on behalf of.", 0, 1, onBehalfOf);
697          default: return super.getNamedProperty(_hash, _name, _checkValid);
698          }
699
700        }
701
702      @Override
703      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
704        switch (hash) {
705        case 92750597: /*agent*/ return this.agent == null ? new Base[0] : new Base[] {this.agent}; // Reference
706        case -14402964: /*onBehalfOf*/ return this.onBehalfOf == null ? new Base[0] : new Base[] {this.onBehalfOf}; // Reference
707        default: return super.getProperty(hash, name, checkValid);
708        }
709
710      }
711
712      @Override
713      public Base setProperty(int hash, String name, Base value) throws FHIRException {
714        switch (hash) {
715        case 92750597: // agent
716          this.agent = castToReference(value); // Reference
717          return value;
718        case -14402964: // onBehalfOf
719          this.onBehalfOf = castToReference(value); // Reference
720          return value;
721        default: return super.setProperty(hash, name, value);
722        }
723
724      }
725
726      @Override
727      public Base setProperty(String name, Base value) throws FHIRException {
728        if (name.equals("agent")) {
729          this.agent = castToReference(value); // Reference
730        } else if (name.equals("onBehalfOf")) {
731          this.onBehalfOf = castToReference(value); // Reference
732        } else
733          return super.setProperty(name, value);
734        return value;
735      }
736
737      @Override
738      public Base makeProperty(int hash, String name) throws FHIRException {
739        switch (hash) {
740        case 92750597:  return getAgent(); 
741        case -14402964:  return getOnBehalfOf(); 
742        default: return super.makeProperty(hash, name);
743        }
744
745      }
746
747      @Override
748      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
749        switch (hash) {
750        case 92750597: /*agent*/ return new String[] {"Reference"};
751        case -14402964: /*onBehalfOf*/ return new String[] {"Reference"};
752        default: return super.getTypesForProperty(hash, name);
753        }
754
755      }
756
757      @Override
758      public Base addChild(String name) throws FHIRException {
759        if (name.equals("agent")) {
760          this.agent = new Reference();
761          return this.agent;
762        }
763        else if (name.equals("onBehalfOf")) {
764          this.onBehalfOf = new Reference();
765          return this.onBehalfOf;
766        }
767        else
768          return super.addChild(name);
769      }
770
771      public ReferralRequestRequesterComponent copy() {
772        ReferralRequestRequesterComponent dst = new ReferralRequestRequesterComponent();
773        copyValues(dst);
774        dst.agent = agent == null ? null : agent.copy();
775        dst.onBehalfOf = onBehalfOf == null ? null : onBehalfOf.copy();
776        return dst;
777      }
778
779      @Override
780      public boolean equalsDeep(Base other_) {
781        if (!super.equalsDeep(other_))
782          return false;
783        if (!(other_ instanceof ReferralRequestRequesterComponent))
784          return false;
785        ReferralRequestRequesterComponent o = (ReferralRequestRequesterComponent) other_;
786        return compareDeep(agent, o.agent, true) && compareDeep(onBehalfOf, o.onBehalfOf, true);
787      }
788
789      @Override
790      public boolean equalsShallow(Base other_) {
791        if (!super.equalsShallow(other_))
792          return false;
793        if (!(other_ instanceof ReferralRequestRequesterComponent))
794          return false;
795        ReferralRequestRequesterComponent o = (ReferralRequestRequesterComponent) other_;
796        return true;
797      }
798
799      public boolean isEmpty() {
800        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(agent, onBehalfOf);
801      }
802
803  public String fhirType() {
804    return "ReferralRequest.requester";
805
806  }
807
808  }
809
810    /**
811     * Business identifier that uniquely identifies the referral/care transfer request instance.
812     */
813    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
814    @Description(shortDefinition="Business identifier", formalDefinition="Business identifier that uniquely identifies the referral/care transfer request instance." )
815    protected List<Identifier> identifier;
816
817    /**
818     * A protocol, guideline, orderset or other definition that is adhered to in whole or in part by this request.
819     */
820    @Child(name = "definition", type = {ActivityDefinition.class, PlanDefinition.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
821    @Description(shortDefinition="Instantiates protocol or definition", formalDefinition="A protocol, guideline, orderset or other definition that is adhered to in whole or in part by this request." )
822    protected List<Reference> definition;
823    /**
824     * The actual objects that are the target of the reference (A protocol, guideline, orderset or other definition that is adhered to in whole or in part by this request.)
825     */
826    protected List<Resource> definitionTarget;
827
828
829    /**
830     * Indicates any plans, proposals or orders that this request is intended to satisfy - in whole or in part.
831     */
832    @Child(name = "basedOn", type = {ReferralRequest.class, CarePlan.class, ProcedureRequest.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
833    @Description(shortDefinition="Request fulfilled by this request", formalDefinition="Indicates any plans, proposals or orders that this request is intended to satisfy - in whole or in part." )
834    protected List<Reference> basedOn;
835    /**
836     * The actual objects that are the target of the reference (Indicates any plans, proposals or orders that this request is intended to satisfy - in whole or in part.)
837     */
838    protected List<Resource> basedOnTarget;
839
840
841    /**
842     * Completed or terminated request(s) whose function is taken by this new request.
843     */
844    @Child(name = "replaces", type = {ReferralRequest.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
845    @Description(shortDefinition="Request(s) replaced by this request", formalDefinition="Completed or terminated request(s) whose function is taken by this new request." )
846    protected List<Reference> replaces;
847    /**
848     * The actual objects that are the target of the reference (Completed or terminated request(s) whose function is taken by this new request.)
849     */
850    protected List<ReferralRequest> replacesTarget;
851
852
853    /**
854     * The business identifier of the logical "grouping" request/order that this referral is a part of.
855     */
856    @Child(name = "groupIdentifier", type = {Identifier.class}, order=4, min=0, max=1, modifier=false, summary=true)
857    @Description(shortDefinition="Composite request this is part of", formalDefinition="The business identifier of the logical \"grouping\" request/order that this referral is a part of." )
858    protected Identifier groupIdentifier;
859
860    /**
861     * The status of the authorization/intention reflected by the referral request record.
862     */
863    @Child(name = "status", type = {CodeType.class}, order=5, min=1, max=1, modifier=true, summary=true)
864    @Description(shortDefinition="draft | active | suspended | cancelled | completed | entered-in-error | unknown", formalDefinition="The status of the authorization/intention reflected by the referral request record." )
865    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/request-status")
866    protected Enumeration<ReferralRequestStatus> status;
867
868    /**
869     * Distinguishes the "level" of authorization/demand implicit in this request.
870     */
871    @Child(name = "intent", type = {CodeType.class}, order=6, min=1, max=1, modifier=true, summary=true)
872    @Description(shortDefinition="proposal | plan | order", formalDefinition="Distinguishes the \"level\" of authorization/demand implicit in this request." )
873    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/request-intent")
874    protected Enumeration<ReferralCategory> intent;
875
876    /**
877     * An indication of the type of referral (or where applicable the type of transfer of care) request.
878     */
879    @Child(name = "type", type = {CodeableConcept.class}, order=7, min=0, max=1, modifier=false, summary=true)
880    @Description(shortDefinition="Referral/Transition of care request type", formalDefinition="An indication of the type of referral (or where applicable the type of transfer of care) request." )
881    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/referral-type")
882    protected CodeableConcept type;
883
884    /**
885     * An indication of the urgency of referral (or where applicable the type of transfer of care) request.
886     */
887    @Child(name = "priority", type = {CodeType.class}, order=8, min=0, max=1, modifier=false, summary=true)
888    @Description(shortDefinition="Urgency of referral / transfer of care request", formalDefinition="An indication of the urgency of referral (or where applicable the type of transfer of care) request." )
889    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/request-priority")
890    protected Enumeration<ReferralPriority> priority;
891
892    /**
893     * The service(s) that is/are requested to be provided to the patient.  For example: cardiac pacemaker insertion.
894     */
895    @Child(name = "serviceRequested", type = {CodeableConcept.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
896    @Description(shortDefinition="Actions requested as part of the referral", formalDefinition="The service(s) that is/are requested to be provided to the patient.  For example: cardiac pacemaker insertion." )
897    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/c80-practice-codes")
898    protected List<CodeableConcept> serviceRequested;
899
900    /**
901     * The patient who is the subject of a referral or transfer of care request.
902     */
903    @Child(name = "subject", type = {Patient.class, Group.class}, order=10, min=1, max=1, modifier=false, summary=true)
904    @Description(shortDefinition="Patient referred to care or transfer", formalDefinition="The patient who is the subject of a referral or transfer of care request." )
905    protected Reference subject;
906
907    /**
908     * The actual object that is the target of the reference (The patient who is the subject of a referral or transfer of care request.)
909     */
910    protected Resource subjectTarget;
911
912    /**
913     * The encounter at which the request for referral or transfer of care is initiated.
914     */
915    @Child(name = "context", type = {Encounter.class, EpisodeOfCare.class}, order=11, min=0, max=1, modifier=false, summary=true)
916    @Description(shortDefinition="Originating encounter", formalDefinition="The encounter at which the request for referral or transfer of care is initiated." )
917    protected Reference context;
918
919    /**
920     * The actual object that is the target of the reference (The encounter at which the request for referral or transfer of care is initiated.)
921     */
922    protected Resource contextTarget;
923
924    /**
925     * The period of time within which the services identified in the referral/transfer of care is specified or required to occur.
926     */
927    @Child(name = "occurrence", type = {DateTimeType.class, Period.class}, order=12, min=0, max=1, modifier=false, summary=true)
928    @Description(shortDefinition="When the service(s) requested in the referral should occur", formalDefinition="The period of time within which the services identified in the referral/transfer of care is specified or required to occur." )
929    protected Type occurrence;
930
931    /**
932     * Date/DateTime of creation for draft requests and date of activation for active requests.
933     */
934    @Child(name = "authoredOn", type = {DateTimeType.class}, order=13, min=0, max=1, modifier=false, summary=true)
935    @Description(shortDefinition="Date of creation/activation", formalDefinition="Date/DateTime of creation for draft requests and date of activation for active requests." )
936    protected DateTimeType authoredOn;
937
938    /**
939     * The individual who initiated the request and has responsibility for its activation.
940     */
941    @Child(name = "requester", type = {}, order=14, min=0, max=1, modifier=false, summary=true)
942    @Description(shortDefinition="Who/what is requesting service", formalDefinition="The individual who initiated the request and has responsibility for its activation." )
943    protected ReferralRequestRequesterComponent requester;
944
945    /**
946     * Indication of the clinical domain or discipline to which the referral or transfer of care request is sent.  For example: Cardiology Gastroenterology Diabetology.
947     */
948    @Child(name = "specialty", type = {CodeableConcept.class}, order=15, min=0, max=1, modifier=false, summary=false)
949    @Description(shortDefinition="The clinical specialty (discipline) that the referral is requested for", formalDefinition="Indication of the clinical domain or discipline to which the referral or transfer of care request is sent.  For example: Cardiology Gastroenterology Diabetology." )
950    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/practitioner-specialty")
951    protected CodeableConcept specialty;
952
953    /**
954     * The healthcare provider(s) or provider organization(s) who/which is to receive the referral/transfer of care request.
955     */
956    @Child(name = "recipient", type = {Practitioner.class, Organization.class, HealthcareService.class}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
957    @Description(shortDefinition="Receiver of referral / transfer of care request", formalDefinition="The healthcare provider(s) or provider organization(s) who/which is to receive the referral/transfer of care request." )
958    protected List<Reference> recipient;
959    /**
960     * The actual objects that are the target of the reference (The healthcare provider(s) or provider organization(s) who/which is to receive the referral/transfer of care request.)
961     */
962    protected List<Resource> recipientTarget;
963
964
965    /**
966     * Description of clinical condition indicating why referral/transfer of care is requested.  For example:  Pathological Anomalies, Disabled (physical or mental),  Behavioral Management.
967     */
968    @Child(name = "reasonCode", type = {CodeableConcept.class}, order=17, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
969    @Description(shortDefinition="Reason for referral / transfer of care request", formalDefinition="Description of clinical condition indicating why referral/transfer of care is requested.  For example:  Pathological Anomalies, Disabled (physical or mental),  Behavioral Management." )
970    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/clinical-findings")
971    protected List<CodeableConcept> reasonCode;
972
973    /**
974     * Indicates another resource whose existence justifies this request.
975     */
976    @Child(name = "reasonReference", type = {Condition.class, Observation.class}, order=18, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
977    @Description(shortDefinition="Why is service needed?", formalDefinition="Indicates another resource whose existence justifies this request." )
978    protected List<Reference> reasonReference;
979    /**
980     * The actual objects that are the target of the reference (Indicates another resource whose existence justifies this request.)
981     */
982    protected List<Resource> reasonReferenceTarget;
983
984
985    /**
986     * The reason element gives a short description of why the referral is being made, the description expands on this to support a more complete clinical summary.
987     */
988    @Child(name = "description", type = {StringType.class}, order=19, min=0, max=1, modifier=false, summary=false)
989    @Description(shortDefinition="A textual description of the referral", formalDefinition="The reason element gives a short description of why the referral is being made, the description expands on this to support a more complete clinical summary." )
990    protected StringType description;
991
992    /**
993     * Any additional (administrative, financial or clinical) information required to support request for referral or transfer of care.  For example: Presenting problems/chief complaints Medical History Family History Alerts Allergy/Intolerance and Adverse Reactions Medications Observations/Assessments (may include cognitive and fundtional assessments) Diagnostic Reports Care Plan.
994     */
995    @Child(name = "supportingInfo", type = {Reference.class}, order=20, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
996    @Description(shortDefinition="Additonal information to support referral or transfer of care request", formalDefinition="Any additional (administrative, financial or clinical) information required to support request for referral or transfer of care.  For example: Presenting problems/chief complaints Medical History Family History Alerts Allergy/Intolerance and Adverse Reactions Medications Observations/Assessments (may include cognitive and fundtional assessments) Diagnostic Reports Care Plan." )
997    protected List<Reference> supportingInfo;
998    /**
999     * The actual objects that are the target of the reference (Any additional (administrative, financial or clinical) information required to support request for referral or transfer of care.  For example: Presenting problems/chief complaints Medical History Family History Alerts Allergy/Intolerance and Adverse Reactions Medications Observations/Assessments (may include cognitive and fundtional assessments) Diagnostic Reports Care Plan.)
1000     */
1001    protected List<Resource> supportingInfoTarget;
1002
1003
1004    /**
1005     * Comments made about the referral request by any of the participants.
1006     */
1007    @Child(name = "note", type = {Annotation.class}, order=21, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1008    @Description(shortDefinition="Comments made about referral request", formalDefinition="Comments made about the referral request by any of the participants." )
1009    protected List<Annotation> note;
1010
1011    /**
1012     * Links to Provenance records for past versions of this resource or fulfilling request or event resources that identify key state transitions or updates that are likely to be relevant to a user looking at the current version of the resource.
1013     */
1014    @Child(name = "relevantHistory", type = {Provenance.class}, order=22, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1015    @Description(shortDefinition="Key events in history of request", formalDefinition="Links to Provenance records for past versions of this resource or fulfilling request or event resources that identify key state transitions or updates that are likely to be relevant to a user looking at the current version of the resource." )
1016    protected List<Reference> relevantHistory;
1017    /**
1018     * The actual objects that are the target of the reference (Links to Provenance records for past versions of this resource or fulfilling request or event resources that identify key state transitions or updates that are likely to be relevant to a user looking at the current version of the resource.)
1019     */
1020    protected List<Provenance> relevantHistoryTarget;
1021
1022
1023    private static final long serialVersionUID = -404424161L;
1024
1025  /**
1026   * Constructor
1027   */
1028    public ReferralRequest() {
1029      super();
1030    }
1031
1032  /**
1033   * Constructor
1034   */
1035    public ReferralRequest(Enumeration<ReferralRequestStatus> status, Enumeration<ReferralCategory> intent, Reference subject) {
1036      super();
1037      this.status = status;
1038      this.intent = intent;
1039      this.subject = subject;
1040    }
1041
1042    /**
1043     * @return {@link #identifier} (Business identifier that uniquely identifies the referral/care transfer request instance.)
1044     */
1045    public List<Identifier> getIdentifier() { 
1046      if (this.identifier == null)
1047        this.identifier = new ArrayList<Identifier>();
1048      return this.identifier;
1049    }
1050
1051    /**
1052     * @return Returns a reference to <code>this</code> for easy method chaining
1053     */
1054    public ReferralRequest setIdentifier(List<Identifier> theIdentifier) { 
1055      this.identifier = theIdentifier;
1056      return this;
1057    }
1058
1059    public boolean hasIdentifier() { 
1060      if (this.identifier == null)
1061        return false;
1062      for (Identifier item : this.identifier)
1063        if (!item.isEmpty())
1064          return true;
1065      return false;
1066    }
1067
1068    public Identifier addIdentifier() { //3
1069      Identifier t = new Identifier();
1070      if (this.identifier == null)
1071        this.identifier = new ArrayList<Identifier>();
1072      this.identifier.add(t);
1073      return t;
1074    }
1075
1076    public ReferralRequest addIdentifier(Identifier t) { //3
1077      if (t == null)
1078        return this;
1079      if (this.identifier == null)
1080        this.identifier = new ArrayList<Identifier>();
1081      this.identifier.add(t);
1082      return this;
1083    }
1084
1085    /**
1086     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
1087     */
1088    public Identifier getIdentifierFirstRep() { 
1089      if (getIdentifier().isEmpty()) {
1090        addIdentifier();
1091      }
1092      return getIdentifier().get(0);
1093    }
1094
1095    /**
1096     * @return {@link #definition} (A protocol, guideline, orderset or other definition that is adhered to in whole or in part by this request.)
1097     */
1098    public List<Reference> getDefinition() { 
1099      if (this.definition == null)
1100        this.definition = new ArrayList<Reference>();
1101      return this.definition;
1102    }
1103
1104    /**
1105     * @return Returns a reference to <code>this</code> for easy method chaining
1106     */
1107    public ReferralRequest setDefinition(List<Reference> theDefinition) { 
1108      this.definition = theDefinition;
1109      return this;
1110    }
1111
1112    public boolean hasDefinition() { 
1113      if (this.definition == null)
1114        return false;
1115      for (Reference item : this.definition)
1116        if (!item.isEmpty())
1117          return true;
1118      return false;
1119    }
1120
1121    public Reference addDefinition() { //3
1122      Reference t = new Reference();
1123      if (this.definition == null)
1124        this.definition = new ArrayList<Reference>();
1125      this.definition.add(t);
1126      return t;
1127    }
1128
1129    public ReferralRequest addDefinition(Reference t) { //3
1130      if (t == null)
1131        return this;
1132      if (this.definition == null)
1133        this.definition = new ArrayList<Reference>();
1134      this.definition.add(t);
1135      return this;
1136    }
1137
1138    /**
1139     * @return The first repetition of repeating field {@link #definition}, creating it if it does not already exist
1140     */
1141    public Reference getDefinitionFirstRep() { 
1142      if (getDefinition().isEmpty()) {
1143        addDefinition();
1144      }
1145      return getDefinition().get(0);
1146    }
1147
1148    /**
1149     * @return {@link #basedOn} (Indicates any plans, proposals or orders that this request is intended to satisfy - in whole or in part.)
1150     */
1151    public List<Reference> getBasedOn() { 
1152      if (this.basedOn == null)
1153        this.basedOn = new ArrayList<Reference>();
1154      return this.basedOn;
1155    }
1156
1157    /**
1158     * @return Returns a reference to <code>this</code> for easy method chaining
1159     */
1160    public ReferralRequest setBasedOn(List<Reference> theBasedOn) { 
1161      this.basedOn = theBasedOn;
1162      return this;
1163    }
1164
1165    public boolean hasBasedOn() { 
1166      if (this.basedOn == null)
1167        return false;
1168      for (Reference item : this.basedOn)
1169        if (!item.isEmpty())
1170          return true;
1171      return false;
1172    }
1173
1174    public Reference addBasedOn() { //3
1175      Reference t = new Reference();
1176      if (this.basedOn == null)
1177        this.basedOn = new ArrayList<Reference>();
1178      this.basedOn.add(t);
1179      return t;
1180    }
1181
1182    public ReferralRequest addBasedOn(Reference t) { //3
1183      if (t == null)
1184        return this;
1185      if (this.basedOn == null)
1186        this.basedOn = new ArrayList<Reference>();
1187      this.basedOn.add(t);
1188      return this;
1189    }
1190
1191    /**
1192     * @return The first repetition of repeating field {@link #basedOn}, creating it if it does not already exist
1193     */
1194    public Reference getBasedOnFirstRep() { 
1195      if (getBasedOn().isEmpty()) {
1196        addBasedOn();
1197      }
1198      return getBasedOn().get(0);
1199    }
1200
1201    /**
1202     * @return {@link #replaces} (Completed or terminated request(s) whose function is taken by this new request.)
1203     */
1204    public List<Reference> getReplaces() { 
1205      if (this.replaces == null)
1206        this.replaces = new ArrayList<Reference>();
1207      return this.replaces;
1208    }
1209
1210    /**
1211     * @return Returns a reference to <code>this</code> for easy method chaining
1212     */
1213    public ReferralRequest setReplaces(List<Reference> theReplaces) { 
1214      this.replaces = theReplaces;
1215      return this;
1216    }
1217
1218    public boolean hasReplaces() { 
1219      if (this.replaces == null)
1220        return false;
1221      for (Reference item : this.replaces)
1222        if (!item.isEmpty())
1223          return true;
1224      return false;
1225    }
1226
1227    public Reference addReplaces() { //3
1228      Reference t = new Reference();
1229      if (this.replaces == null)
1230        this.replaces = new ArrayList<Reference>();
1231      this.replaces.add(t);
1232      return t;
1233    }
1234
1235    public ReferralRequest addReplaces(Reference t) { //3
1236      if (t == null)
1237        return this;
1238      if (this.replaces == null)
1239        this.replaces = new ArrayList<Reference>();
1240      this.replaces.add(t);
1241      return this;
1242    }
1243
1244    /**
1245     * @return The first repetition of repeating field {@link #replaces}, creating it if it does not already exist
1246     */
1247    public Reference getReplacesFirstRep() { 
1248      if (getReplaces().isEmpty()) {
1249        addReplaces();
1250      }
1251      return getReplaces().get(0);
1252    }
1253
1254    /**
1255     * @return {@link #groupIdentifier} (The business identifier of the logical "grouping" request/order that this referral is a part of.)
1256     */
1257    public Identifier getGroupIdentifier() { 
1258      if (this.groupIdentifier == null)
1259        if (Configuration.errorOnAutoCreate())
1260          throw new Error("Attempt to auto-create ReferralRequest.groupIdentifier");
1261        else if (Configuration.doAutoCreate())
1262          this.groupIdentifier = new Identifier(); // cc
1263      return this.groupIdentifier;
1264    }
1265
1266    public boolean hasGroupIdentifier() { 
1267      return this.groupIdentifier != null && !this.groupIdentifier.isEmpty();
1268    }
1269
1270    /**
1271     * @param value {@link #groupIdentifier} (The business identifier of the logical "grouping" request/order that this referral is a part of.)
1272     */
1273    public ReferralRequest setGroupIdentifier(Identifier value)  { 
1274      this.groupIdentifier = value;
1275      return this;
1276    }
1277
1278    /**
1279     * @return {@link #status} (The status of the authorization/intention reflected by the referral request record.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1280     */
1281    public Enumeration<ReferralRequestStatus> getStatusElement() { 
1282      if (this.status == null)
1283        if (Configuration.errorOnAutoCreate())
1284          throw new Error("Attempt to auto-create ReferralRequest.status");
1285        else if (Configuration.doAutoCreate())
1286          this.status = new Enumeration<ReferralRequestStatus>(new ReferralRequestStatusEnumFactory()); // bb
1287      return this.status;
1288    }
1289
1290    public boolean hasStatusElement() { 
1291      return this.status != null && !this.status.isEmpty();
1292    }
1293
1294    public boolean hasStatus() { 
1295      return this.status != null && !this.status.isEmpty();
1296    }
1297
1298    /**
1299     * @param value {@link #status} (The status of the authorization/intention reflected by the referral request record.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1300     */
1301    public ReferralRequest setStatusElement(Enumeration<ReferralRequestStatus> value) { 
1302      this.status = value;
1303      return this;
1304    }
1305
1306    /**
1307     * @return The status of the authorization/intention reflected by the referral request record.
1308     */
1309    public ReferralRequestStatus getStatus() { 
1310      return this.status == null ? null : this.status.getValue();
1311    }
1312
1313    /**
1314     * @param value The status of the authorization/intention reflected by the referral request record.
1315     */
1316    public ReferralRequest setStatus(ReferralRequestStatus value) { 
1317        if (this.status == null)
1318          this.status = new Enumeration<ReferralRequestStatus>(new ReferralRequestStatusEnumFactory());
1319        this.status.setValue(value);
1320      return this;
1321    }
1322
1323    /**
1324     * @return {@link #intent} (Distinguishes the "level" of authorization/demand implicit in this request.). This is the underlying object with id, value and extensions. The accessor "getIntent" gives direct access to the value
1325     */
1326    public Enumeration<ReferralCategory> getIntentElement() { 
1327      if (this.intent == null)
1328        if (Configuration.errorOnAutoCreate())
1329          throw new Error("Attempt to auto-create ReferralRequest.intent");
1330        else if (Configuration.doAutoCreate())
1331          this.intent = new Enumeration<ReferralCategory>(new ReferralCategoryEnumFactory()); // bb
1332      return this.intent;
1333    }
1334
1335    public boolean hasIntentElement() { 
1336      return this.intent != null && !this.intent.isEmpty();
1337    }
1338
1339    public boolean hasIntent() { 
1340      return this.intent != null && !this.intent.isEmpty();
1341    }
1342
1343    /**
1344     * @param value {@link #intent} (Distinguishes the "level" of authorization/demand implicit in this request.). This is the underlying object with id, value and extensions. The accessor "getIntent" gives direct access to the value
1345     */
1346    public ReferralRequest setIntentElement(Enumeration<ReferralCategory> value) { 
1347      this.intent = value;
1348      return this;
1349    }
1350
1351    /**
1352     * @return Distinguishes the "level" of authorization/demand implicit in this request.
1353     */
1354    public ReferralCategory getIntent() { 
1355      return this.intent == null ? null : this.intent.getValue();
1356    }
1357
1358    /**
1359     * @param value Distinguishes the "level" of authorization/demand implicit in this request.
1360     */
1361    public ReferralRequest setIntent(ReferralCategory value) { 
1362        if (this.intent == null)
1363          this.intent = new Enumeration<ReferralCategory>(new ReferralCategoryEnumFactory());
1364        this.intent.setValue(value);
1365      return this;
1366    }
1367
1368    /**
1369     * @return {@link #type} (An indication of the type of referral (or where applicable the type of transfer of care) request.)
1370     */
1371    public CodeableConcept getType() { 
1372      if (this.type == null)
1373        if (Configuration.errorOnAutoCreate())
1374          throw new Error("Attempt to auto-create ReferralRequest.type");
1375        else if (Configuration.doAutoCreate())
1376          this.type = new CodeableConcept(); // cc
1377      return this.type;
1378    }
1379
1380    public boolean hasType() { 
1381      return this.type != null && !this.type.isEmpty();
1382    }
1383
1384    /**
1385     * @param value {@link #type} (An indication of the type of referral (or where applicable the type of transfer of care) request.)
1386     */
1387    public ReferralRequest setType(CodeableConcept value)  { 
1388      this.type = value;
1389      return this;
1390    }
1391
1392    /**
1393     * @return {@link #priority} (An indication of the urgency of referral (or where applicable the type of transfer of care) request.). This is the underlying object with id, value and extensions. The accessor "getPriority" gives direct access to the value
1394     */
1395    public Enumeration<ReferralPriority> getPriorityElement() { 
1396      if (this.priority == null)
1397        if (Configuration.errorOnAutoCreate())
1398          throw new Error("Attempt to auto-create ReferralRequest.priority");
1399        else if (Configuration.doAutoCreate())
1400          this.priority = new Enumeration<ReferralPriority>(new ReferralPriorityEnumFactory()); // bb
1401      return this.priority;
1402    }
1403
1404    public boolean hasPriorityElement() { 
1405      return this.priority != null && !this.priority.isEmpty();
1406    }
1407
1408    public boolean hasPriority() { 
1409      return this.priority != null && !this.priority.isEmpty();
1410    }
1411
1412    /**
1413     * @param value {@link #priority} (An indication of the urgency of referral (or where applicable the type of transfer of care) request.). This is the underlying object with id, value and extensions. The accessor "getPriority" gives direct access to the value
1414     */
1415    public ReferralRequest setPriorityElement(Enumeration<ReferralPriority> value) { 
1416      this.priority = value;
1417      return this;
1418    }
1419
1420    /**
1421     * @return An indication of the urgency of referral (or where applicable the type of transfer of care) request.
1422     */
1423    public ReferralPriority getPriority() { 
1424      return this.priority == null ? null : this.priority.getValue();
1425    }
1426
1427    /**
1428     * @param value An indication of the urgency of referral (or where applicable the type of transfer of care) request.
1429     */
1430    public ReferralRequest setPriority(ReferralPriority value) { 
1431      if (value == null)
1432        this.priority = null;
1433      else {
1434        if (this.priority == null)
1435          this.priority = new Enumeration<ReferralPriority>(new ReferralPriorityEnumFactory());
1436        this.priority.setValue(value);
1437      }
1438      return this;
1439    }
1440
1441    /**
1442     * @return {@link #serviceRequested} (The service(s) that is/are requested to be provided to the patient.  For example: cardiac pacemaker insertion.)
1443     */
1444    public List<CodeableConcept> getServiceRequested() { 
1445      if (this.serviceRequested == null)
1446        this.serviceRequested = new ArrayList<CodeableConcept>();
1447      return this.serviceRequested;
1448    }
1449
1450    /**
1451     * @return Returns a reference to <code>this</code> for easy method chaining
1452     */
1453    public ReferralRequest setServiceRequested(List<CodeableConcept> theServiceRequested) { 
1454      this.serviceRequested = theServiceRequested;
1455      return this;
1456    }
1457
1458    public boolean hasServiceRequested() { 
1459      if (this.serviceRequested == null)
1460        return false;
1461      for (CodeableConcept item : this.serviceRequested)
1462        if (!item.isEmpty())
1463          return true;
1464      return false;
1465    }
1466
1467    public CodeableConcept addServiceRequested() { //3
1468      CodeableConcept t = new CodeableConcept();
1469      if (this.serviceRequested == null)
1470        this.serviceRequested = new ArrayList<CodeableConcept>();
1471      this.serviceRequested.add(t);
1472      return t;
1473    }
1474
1475    public ReferralRequest addServiceRequested(CodeableConcept t) { //3
1476      if (t == null)
1477        return this;
1478      if (this.serviceRequested == null)
1479        this.serviceRequested = new ArrayList<CodeableConcept>();
1480      this.serviceRequested.add(t);
1481      return this;
1482    }
1483
1484    /**
1485     * @return The first repetition of repeating field {@link #serviceRequested}, creating it if it does not already exist
1486     */
1487    public CodeableConcept getServiceRequestedFirstRep() { 
1488      if (getServiceRequested().isEmpty()) {
1489        addServiceRequested();
1490      }
1491      return getServiceRequested().get(0);
1492    }
1493
1494    /**
1495     * @return {@link #subject} (The patient who is the subject of a referral or transfer of care request.)
1496     */
1497    public Reference getSubject() { 
1498      if (this.subject == null)
1499        if (Configuration.errorOnAutoCreate())
1500          throw new Error("Attempt to auto-create ReferralRequest.subject");
1501        else if (Configuration.doAutoCreate())
1502          this.subject = new Reference(); // cc
1503      return this.subject;
1504    }
1505
1506    public boolean hasSubject() { 
1507      return this.subject != null && !this.subject.isEmpty();
1508    }
1509
1510    /**
1511     * @param value {@link #subject} (The patient who is the subject of a referral or transfer of care request.)
1512     */
1513    public ReferralRequest setSubject(Reference value)  { 
1514      this.subject = value;
1515      return this;
1516    }
1517
1518    /**
1519     * @return {@link #subject} 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 patient who is the subject of a referral or transfer of care request.)
1520     */
1521    public Resource getSubjectTarget() { 
1522      return this.subjectTarget;
1523    }
1524
1525    /**
1526     * @param value {@link #subject} 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 patient who is the subject of a referral or transfer of care request.)
1527     */
1528    public ReferralRequest setSubjectTarget(Resource value) { 
1529      this.subjectTarget = value;
1530      return this;
1531    }
1532
1533    /**
1534     * @return {@link #context} (The encounter at which the request for referral or transfer of care is initiated.)
1535     */
1536    public Reference getContext() { 
1537      if (this.context == null)
1538        if (Configuration.errorOnAutoCreate())
1539          throw new Error("Attempt to auto-create ReferralRequest.context");
1540        else if (Configuration.doAutoCreate())
1541          this.context = new Reference(); // cc
1542      return this.context;
1543    }
1544
1545    public boolean hasContext() { 
1546      return this.context != null && !this.context.isEmpty();
1547    }
1548
1549    /**
1550     * @param value {@link #context} (The encounter at which the request for referral or transfer of care is initiated.)
1551     */
1552    public ReferralRequest setContext(Reference value)  { 
1553      this.context = value;
1554      return this;
1555    }
1556
1557    /**
1558     * @return {@link #context} 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 encounter at which the request for referral or transfer of care is initiated.)
1559     */
1560    public Resource getContextTarget() { 
1561      return this.contextTarget;
1562    }
1563
1564    /**
1565     * @param value {@link #context} 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 encounter at which the request for referral or transfer of care is initiated.)
1566     */
1567    public ReferralRequest setContextTarget(Resource value) { 
1568      this.contextTarget = value;
1569      return this;
1570    }
1571
1572    /**
1573     * @return {@link #occurrence} (The period of time within which the services identified in the referral/transfer of care is specified or required to occur.)
1574     */
1575    public Type getOccurrence() { 
1576      return this.occurrence;
1577    }
1578
1579    /**
1580     * @return {@link #occurrence} (The period of time within which the services identified in the referral/transfer of care is specified or required to occur.)
1581     */
1582    public DateTimeType getOccurrenceDateTimeType() throws FHIRException { 
1583      if (this.occurrence == null)
1584        return null;
1585      if (!(this.occurrence instanceof DateTimeType))
1586        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.occurrence.getClass().getName()+" was encountered");
1587      return (DateTimeType) this.occurrence;
1588    }
1589
1590    public boolean hasOccurrenceDateTimeType() {
1591        return this.occurrence instanceof DateTimeType;
1592    }
1593
1594    /**
1595     * @return {@link #occurrence} (The period of time within which the services identified in the referral/transfer of care is specified or required to occur.)
1596     */
1597    public Period getOccurrencePeriod() throws FHIRException { 
1598      if (this.occurrence == null)
1599        return null;
1600      if (!(this.occurrence instanceof Period))
1601        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.occurrence.getClass().getName()+" was encountered");
1602      return (Period) this.occurrence;
1603    }
1604
1605    public boolean hasOccurrencePeriod() {
1606        return this.occurrence instanceof Period;
1607    }
1608
1609    public boolean hasOccurrence() { 
1610      return this.occurrence != null && !this.occurrence.isEmpty();
1611    }
1612
1613    /**
1614     * @param value {@link #occurrence} (The period of time within which the services identified in the referral/transfer of care is specified or required to occur.)
1615     */
1616    public ReferralRequest setOccurrence(Type value) throws FHIRFormatError { 
1617      if (value != null && !(value instanceof DateTimeType || value instanceof Period))
1618        throw new FHIRFormatError("Not the right type for ReferralRequest.occurrence[x]: "+value.fhirType());
1619      this.occurrence = value;
1620      return this;
1621    }
1622
1623    /**
1624     * @return {@link #authoredOn} (Date/DateTime of creation for draft requests and date of activation for active requests.). This is the underlying object with id, value and extensions. The accessor "getAuthoredOn" gives direct access to the value
1625     */
1626    public DateTimeType getAuthoredOnElement() { 
1627      if (this.authoredOn == null)
1628        if (Configuration.errorOnAutoCreate())
1629          throw new Error("Attempt to auto-create ReferralRequest.authoredOn");
1630        else if (Configuration.doAutoCreate())
1631          this.authoredOn = new DateTimeType(); // bb
1632      return this.authoredOn;
1633    }
1634
1635    public boolean hasAuthoredOnElement() { 
1636      return this.authoredOn != null && !this.authoredOn.isEmpty();
1637    }
1638
1639    public boolean hasAuthoredOn() { 
1640      return this.authoredOn != null && !this.authoredOn.isEmpty();
1641    }
1642
1643    /**
1644     * @param value {@link #authoredOn} (Date/DateTime of creation for draft requests and date of activation for active requests.). This is the underlying object with id, value and extensions. The accessor "getAuthoredOn" gives direct access to the value
1645     */
1646    public ReferralRequest setAuthoredOnElement(DateTimeType value) { 
1647      this.authoredOn = value;
1648      return this;
1649    }
1650
1651    /**
1652     * @return Date/DateTime of creation for draft requests and date of activation for active requests.
1653     */
1654    public Date getAuthoredOn() { 
1655      return this.authoredOn == null ? null : this.authoredOn.getValue();
1656    }
1657
1658    /**
1659     * @param value Date/DateTime of creation for draft requests and date of activation for active requests.
1660     */
1661    public ReferralRequest setAuthoredOn(Date value) { 
1662      if (value == null)
1663        this.authoredOn = null;
1664      else {
1665        if (this.authoredOn == null)
1666          this.authoredOn = new DateTimeType();
1667        this.authoredOn.setValue(value);
1668      }
1669      return this;
1670    }
1671
1672    /**
1673     * @return {@link #requester} (The individual who initiated the request and has responsibility for its activation.)
1674     */
1675    public ReferralRequestRequesterComponent getRequester() { 
1676      if (this.requester == null)
1677        if (Configuration.errorOnAutoCreate())
1678          throw new Error("Attempt to auto-create ReferralRequest.requester");
1679        else if (Configuration.doAutoCreate())
1680          this.requester = new ReferralRequestRequesterComponent(); // cc
1681      return this.requester;
1682    }
1683
1684    public boolean hasRequester() { 
1685      return this.requester != null && !this.requester.isEmpty();
1686    }
1687
1688    /**
1689     * @param value {@link #requester} (The individual who initiated the request and has responsibility for its activation.)
1690     */
1691    public ReferralRequest setRequester(ReferralRequestRequesterComponent value)  { 
1692      this.requester = value;
1693      return this;
1694    }
1695
1696    /**
1697     * @return {@link #specialty} (Indication of the clinical domain or discipline to which the referral or transfer of care request is sent.  For example: Cardiology Gastroenterology Diabetology.)
1698     */
1699    public CodeableConcept getSpecialty() { 
1700      if (this.specialty == null)
1701        if (Configuration.errorOnAutoCreate())
1702          throw new Error("Attempt to auto-create ReferralRequest.specialty");
1703        else if (Configuration.doAutoCreate())
1704          this.specialty = new CodeableConcept(); // cc
1705      return this.specialty;
1706    }
1707
1708    public boolean hasSpecialty() { 
1709      return this.specialty != null && !this.specialty.isEmpty();
1710    }
1711
1712    /**
1713     * @param value {@link #specialty} (Indication of the clinical domain or discipline to which the referral or transfer of care request is sent.  For example: Cardiology Gastroenterology Diabetology.)
1714     */
1715    public ReferralRequest setSpecialty(CodeableConcept value)  { 
1716      this.specialty = value;
1717      return this;
1718    }
1719
1720    /**
1721     * @return {@link #recipient} (The healthcare provider(s) or provider organization(s) who/which is to receive the referral/transfer of care request.)
1722     */
1723    public List<Reference> getRecipient() { 
1724      if (this.recipient == null)
1725        this.recipient = new ArrayList<Reference>();
1726      return this.recipient;
1727    }
1728
1729    /**
1730     * @return Returns a reference to <code>this</code> for easy method chaining
1731     */
1732    public ReferralRequest setRecipient(List<Reference> theRecipient) { 
1733      this.recipient = theRecipient;
1734      return this;
1735    }
1736
1737    public boolean hasRecipient() { 
1738      if (this.recipient == null)
1739        return false;
1740      for (Reference item : this.recipient)
1741        if (!item.isEmpty())
1742          return true;
1743      return false;
1744    }
1745
1746    public Reference addRecipient() { //3
1747      Reference t = new Reference();
1748      if (this.recipient == null)
1749        this.recipient = new ArrayList<Reference>();
1750      this.recipient.add(t);
1751      return t;
1752    }
1753
1754    public ReferralRequest addRecipient(Reference t) { //3
1755      if (t == null)
1756        return this;
1757      if (this.recipient == null)
1758        this.recipient = new ArrayList<Reference>();
1759      this.recipient.add(t);
1760      return this;
1761    }
1762
1763    /**
1764     * @return The first repetition of repeating field {@link #recipient}, creating it if it does not already exist
1765     */
1766    public Reference getRecipientFirstRep() { 
1767      if (getRecipient().isEmpty()) {
1768        addRecipient();
1769      }
1770      return getRecipient().get(0);
1771    }
1772
1773    /**
1774     * @return {@link #reasonCode} (Description of clinical condition indicating why referral/transfer of care is requested.  For example:  Pathological Anomalies, Disabled (physical or mental),  Behavioral Management.)
1775     */
1776    public List<CodeableConcept> getReasonCode() { 
1777      if (this.reasonCode == null)
1778        this.reasonCode = new ArrayList<CodeableConcept>();
1779      return this.reasonCode;
1780    }
1781
1782    /**
1783     * @return Returns a reference to <code>this</code> for easy method chaining
1784     */
1785    public ReferralRequest setReasonCode(List<CodeableConcept> theReasonCode) { 
1786      this.reasonCode = theReasonCode;
1787      return this;
1788    }
1789
1790    public boolean hasReasonCode() { 
1791      if (this.reasonCode == null)
1792        return false;
1793      for (CodeableConcept item : this.reasonCode)
1794        if (!item.isEmpty())
1795          return true;
1796      return false;
1797    }
1798
1799    public CodeableConcept addReasonCode() { //3
1800      CodeableConcept t = new CodeableConcept();
1801      if (this.reasonCode == null)
1802        this.reasonCode = new ArrayList<CodeableConcept>();
1803      this.reasonCode.add(t);
1804      return t;
1805    }
1806
1807    public ReferralRequest addReasonCode(CodeableConcept t) { //3
1808      if (t == null)
1809        return this;
1810      if (this.reasonCode == null)
1811        this.reasonCode = new ArrayList<CodeableConcept>();
1812      this.reasonCode.add(t);
1813      return this;
1814    }
1815
1816    /**
1817     * @return The first repetition of repeating field {@link #reasonCode}, creating it if it does not already exist
1818     */
1819    public CodeableConcept getReasonCodeFirstRep() { 
1820      if (getReasonCode().isEmpty()) {
1821        addReasonCode();
1822      }
1823      return getReasonCode().get(0);
1824    }
1825
1826    /**
1827     * @return {@link #reasonReference} (Indicates another resource whose existence justifies this request.)
1828     */
1829    public List<Reference> getReasonReference() { 
1830      if (this.reasonReference == null)
1831        this.reasonReference = new ArrayList<Reference>();
1832      return this.reasonReference;
1833    }
1834
1835    /**
1836     * @return Returns a reference to <code>this</code> for easy method chaining
1837     */
1838    public ReferralRequest setReasonReference(List<Reference> theReasonReference) { 
1839      this.reasonReference = theReasonReference;
1840      return this;
1841    }
1842
1843    public boolean hasReasonReference() { 
1844      if (this.reasonReference == null)
1845        return false;
1846      for (Reference item : this.reasonReference)
1847        if (!item.isEmpty())
1848          return true;
1849      return false;
1850    }
1851
1852    public Reference addReasonReference() { //3
1853      Reference t = new Reference();
1854      if (this.reasonReference == null)
1855        this.reasonReference = new ArrayList<Reference>();
1856      this.reasonReference.add(t);
1857      return t;
1858    }
1859
1860    public ReferralRequest addReasonReference(Reference t) { //3
1861      if (t == null)
1862        return this;
1863      if (this.reasonReference == null)
1864        this.reasonReference = new ArrayList<Reference>();
1865      this.reasonReference.add(t);
1866      return this;
1867    }
1868
1869    /**
1870     * @return The first repetition of repeating field {@link #reasonReference}, creating it if it does not already exist
1871     */
1872    public Reference getReasonReferenceFirstRep() { 
1873      if (getReasonReference().isEmpty()) {
1874        addReasonReference();
1875      }
1876      return getReasonReference().get(0);
1877    }
1878
1879    /**
1880     * @return {@link #description} (The reason element gives a short description of why the referral is being made, the description expands on this to support a more complete clinical summary.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
1881     */
1882    public StringType getDescriptionElement() { 
1883      if (this.description == null)
1884        if (Configuration.errorOnAutoCreate())
1885          throw new Error("Attempt to auto-create ReferralRequest.description");
1886        else if (Configuration.doAutoCreate())
1887          this.description = new StringType(); // bb
1888      return this.description;
1889    }
1890
1891    public boolean hasDescriptionElement() { 
1892      return this.description != null && !this.description.isEmpty();
1893    }
1894
1895    public boolean hasDescription() { 
1896      return this.description != null && !this.description.isEmpty();
1897    }
1898
1899    /**
1900     * @param value {@link #description} (The reason element gives a short description of why the referral is being made, the description expands on this to support a more complete clinical summary.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
1901     */
1902    public ReferralRequest setDescriptionElement(StringType value) { 
1903      this.description = value;
1904      return this;
1905    }
1906
1907    /**
1908     * @return The reason element gives a short description of why the referral is being made, the description expands on this to support a more complete clinical summary.
1909     */
1910    public String getDescription() { 
1911      return this.description == null ? null : this.description.getValue();
1912    }
1913
1914    /**
1915     * @param value The reason element gives a short description of why the referral is being made, the description expands on this to support a more complete clinical summary.
1916     */
1917    public ReferralRequest setDescription(String value) { 
1918      if (Utilities.noString(value))
1919        this.description = null;
1920      else {
1921        if (this.description == null)
1922          this.description = new StringType();
1923        this.description.setValue(value);
1924      }
1925      return this;
1926    }
1927
1928    /**
1929     * @return {@link #supportingInfo} (Any additional (administrative, financial or clinical) information required to support request for referral or transfer of care.  For example: Presenting problems/chief complaints Medical History Family History Alerts Allergy/Intolerance and Adverse Reactions Medications Observations/Assessments (may include cognitive and fundtional assessments) Diagnostic Reports Care Plan.)
1930     */
1931    public List<Reference> getSupportingInfo() { 
1932      if (this.supportingInfo == null)
1933        this.supportingInfo = new ArrayList<Reference>();
1934      return this.supportingInfo;
1935    }
1936
1937    /**
1938     * @return Returns a reference to <code>this</code> for easy method chaining
1939     */
1940    public ReferralRequest setSupportingInfo(List<Reference> theSupportingInfo) { 
1941      this.supportingInfo = theSupportingInfo;
1942      return this;
1943    }
1944
1945    public boolean hasSupportingInfo() { 
1946      if (this.supportingInfo == null)
1947        return false;
1948      for (Reference item : this.supportingInfo)
1949        if (!item.isEmpty())
1950          return true;
1951      return false;
1952    }
1953
1954    public Reference addSupportingInfo() { //3
1955      Reference t = new Reference();
1956      if (this.supportingInfo == null)
1957        this.supportingInfo = new ArrayList<Reference>();
1958      this.supportingInfo.add(t);
1959      return t;
1960    }
1961
1962    public ReferralRequest addSupportingInfo(Reference t) { //3
1963      if (t == null)
1964        return this;
1965      if (this.supportingInfo == null)
1966        this.supportingInfo = new ArrayList<Reference>();
1967      this.supportingInfo.add(t);
1968      return this;
1969    }
1970
1971    /**
1972     * @return The first repetition of repeating field {@link #supportingInfo}, creating it if it does not already exist
1973     */
1974    public Reference getSupportingInfoFirstRep() { 
1975      if (getSupportingInfo().isEmpty()) {
1976        addSupportingInfo();
1977      }
1978      return getSupportingInfo().get(0);
1979    }
1980
1981    /**
1982     * @return {@link #note} (Comments made about the referral request by any of the participants.)
1983     */
1984    public List<Annotation> getNote() { 
1985      if (this.note == null)
1986        this.note = new ArrayList<Annotation>();
1987      return this.note;
1988    }
1989
1990    /**
1991     * @return Returns a reference to <code>this</code> for easy method chaining
1992     */
1993    public ReferralRequest setNote(List<Annotation> theNote) { 
1994      this.note = theNote;
1995      return this;
1996    }
1997
1998    public boolean hasNote() { 
1999      if (this.note == null)
2000        return false;
2001      for (Annotation item : this.note)
2002        if (!item.isEmpty())
2003          return true;
2004      return false;
2005    }
2006
2007    public Annotation addNote() { //3
2008      Annotation t = new Annotation();
2009      if (this.note == null)
2010        this.note = new ArrayList<Annotation>();
2011      this.note.add(t);
2012      return t;
2013    }
2014
2015    public ReferralRequest addNote(Annotation t) { //3
2016      if (t == null)
2017        return this;
2018      if (this.note == null)
2019        this.note = new ArrayList<Annotation>();
2020      this.note.add(t);
2021      return this;
2022    }
2023
2024    /**
2025     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist
2026     */
2027    public Annotation getNoteFirstRep() { 
2028      if (getNote().isEmpty()) {
2029        addNote();
2030      }
2031      return getNote().get(0);
2032    }
2033
2034    /**
2035     * @return {@link #relevantHistory} (Links to Provenance records for past versions of this resource or fulfilling request or event resources that identify key state transitions or updates that are likely to be relevant to a user looking at the current version of the resource.)
2036     */
2037    public List<Reference> getRelevantHistory() { 
2038      if (this.relevantHistory == null)
2039        this.relevantHistory = new ArrayList<Reference>();
2040      return this.relevantHistory;
2041    }
2042
2043    /**
2044     * @return Returns a reference to <code>this</code> for easy method chaining
2045     */
2046    public ReferralRequest setRelevantHistory(List<Reference> theRelevantHistory) { 
2047      this.relevantHistory = theRelevantHistory;
2048      return this;
2049    }
2050
2051    public boolean hasRelevantHistory() { 
2052      if (this.relevantHistory == null)
2053        return false;
2054      for (Reference item : this.relevantHistory)
2055        if (!item.isEmpty())
2056          return true;
2057      return false;
2058    }
2059
2060    public Reference addRelevantHistory() { //3
2061      Reference t = new Reference();
2062      if (this.relevantHistory == null)
2063        this.relevantHistory = new ArrayList<Reference>();
2064      this.relevantHistory.add(t);
2065      return t;
2066    }
2067
2068    public ReferralRequest addRelevantHistory(Reference t) { //3
2069      if (t == null)
2070        return this;
2071      if (this.relevantHistory == null)
2072        this.relevantHistory = new ArrayList<Reference>();
2073      this.relevantHistory.add(t);
2074      return this;
2075    }
2076
2077    /**
2078     * @return The first repetition of repeating field {@link #relevantHistory}, creating it if it does not already exist
2079     */
2080    public Reference getRelevantHistoryFirstRep() { 
2081      if (getRelevantHistory().isEmpty()) {
2082        addRelevantHistory();
2083      }
2084      return getRelevantHistory().get(0);
2085    }
2086
2087      protected void listChildren(List<Property> children) {
2088        super.listChildren(children);
2089        children.add(new Property("identifier", "Identifier", "Business identifier that uniquely identifies the referral/care transfer request instance.", 0, java.lang.Integer.MAX_VALUE, identifier));
2090        children.add(new Property("definition", "Reference(ActivityDefinition|PlanDefinition)", "A protocol, guideline, orderset or other definition that is adhered to in whole or in part by this request.", 0, java.lang.Integer.MAX_VALUE, definition));
2091        children.add(new Property("basedOn", "Reference(ReferralRequest|CarePlan|ProcedureRequest)", "Indicates any plans, proposals or orders that this request is intended to satisfy - in whole or in part.", 0, java.lang.Integer.MAX_VALUE, basedOn));
2092        children.add(new Property("replaces", "Reference(ReferralRequest)", "Completed or terminated request(s) whose function is taken by this new request.", 0, java.lang.Integer.MAX_VALUE, replaces));
2093        children.add(new Property("groupIdentifier", "Identifier", "The business identifier of the logical \"grouping\" request/order that this referral is a part of.", 0, 1, groupIdentifier));
2094        children.add(new Property("status", "code", "The status of the authorization/intention reflected by the referral request record.", 0, 1, status));
2095        children.add(new Property("intent", "code", "Distinguishes the \"level\" of authorization/demand implicit in this request.", 0, 1, intent));
2096        children.add(new Property("type", "CodeableConcept", "An indication of the type of referral (or where applicable the type of transfer of care) request.", 0, 1, type));
2097        children.add(new Property("priority", "code", "An indication of the urgency of referral (or where applicable the type of transfer of care) request.", 0, 1, priority));
2098        children.add(new Property("serviceRequested", "CodeableConcept", "The service(s) that is/are requested to be provided to the patient.  For example: cardiac pacemaker insertion.", 0, java.lang.Integer.MAX_VALUE, serviceRequested));
2099        children.add(new Property("subject", "Reference(Patient|Group)", "The patient who is the subject of a referral or transfer of care request.", 0, 1, subject));
2100        children.add(new Property("context", "Reference(Encounter|EpisodeOfCare)", "The encounter at which the request for referral or transfer of care is initiated.", 0, 1, context));
2101        children.add(new Property("occurrence[x]", "dateTime|Period", "The period of time within which the services identified in the referral/transfer of care is specified or required to occur.", 0, 1, occurrence));
2102        children.add(new Property("authoredOn", "dateTime", "Date/DateTime of creation for draft requests and date of activation for active requests.", 0, 1, authoredOn));
2103        children.add(new Property("requester", "", "The individual who initiated the request and has responsibility for its activation.", 0, 1, requester));
2104        children.add(new Property("specialty", "CodeableConcept", "Indication of the clinical domain or discipline to which the referral or transfer of care request is sent.  For example: Cardiology Gastroenterology Diabetology.", 0, 1, specialty));
2105        children.add(new Property("recipient", "Reference(Practitioner|Organization|HealthcareService)", "The healthcare provider(s) or provider organization(s) who/which is to receive the referral/transfer of care request.", 0, java.lang.Integer.MAX_VALUE, recipient));
2106        children.add(new Property("reasonCode", "CodeableConcept", "Description of clinical condition indicating why referral/transfer of care is requested.  For example:  Pathological Anomalies, Disabled (physical or mental),  Behavioral Management.", 0, java.lang.Integer.MAX_VALUE, reasonCode));
2107        children.add(new Property("reasonReference", "Reference(Condition|Observation)", "Indicates another resource whose existence justifies this request.", 0, java.lang.Integer.MAX_VALUE, reasonReference));
2108        children.add(new Property("description", "string", "The reason element gives a short description of why the referral is being made, the description expands on this to support a more complete clinical summary.", 0, 1, description));
2109        children.add(new Property("supportingInfo", "Reference(Any)", "Any additional (administrative, financial or clinical) information required to support request for referral or transfer of care.  For example: Presenting problems/chief complaints Medical History Family History Alerts Allergy/Intolerance and Adverse Reactions Medications Observations/Assessments (may include cognitive and fundtional assessments) Diagnostic Reports Care Plan.", 0, java.lang.Integer.MAX_VALUE, supportingInfo));
2110        children.add(new Property("note", "Annotation", "Comments made about the referral request by any of the participants.", 0, java.lang.Integer.MAX_VALUE, note));
2111        children.add(new Property("relevantHistory", "Reference(Provenance)", "Links to Provenance records for past versions of this resource or fulfilling request or event resources that identify key state transitions or updates that are likely to be relevant to a user looking at the current version of the resource.", 0, java.lang.Integer.MAX_VALUE, relevantHistory));
2112      }
2113
2114      @Override
2115      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2116        switch (_hash) {
2117        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Business identifier that uniquely identifies the referral/care transfer request instance.", 0, java.lang.Integer.MAX_VALUE, identifier);
2118        case -1014418093: /*definition*/  return new Property("definition", "Reference(ActivityDefinition|PlanDefinition)", "A protocol, guideline, orderset or other definition that is adhered to in whole or in part by this request.", 0, java.lang.Integer.MAX_VALUE, definition);
2119        case -332612366: /*basedOn*/  return new Property("basedOn", "Reference(ReferralRequest|CarePlan|ProcedureRequest)", "Indicates any plans, proposals or orders that this request is intended to satisfy - in whole or in part.", 0, java.lang.Integer.MAX_VALUE, basedOn);
2120        case -430332865: /*replaces*/  return new Property("replaces", "Reference(ReferralRequest)", "Completed or terminated request(s) whose function is taken by this new request.", 0, java.lang.Integer.MAX_VALUE, replaces);
2121        case -445338488: /*groupIdentifier*/  return new Property("groupIdentifier", "Identifier", "The business identifier of the logical \"grouping\" request/order that this referral is a part of.", 0, 1, groupIdentifier);
2122        case -892481550: /*status*/  return new Property("status", "code", "The status of the authorization/intention reflected by the referral request record.", 0, 1, status);
2123        case -1183762788: /*intent*/  return new Property("intent", "code", "Distinguishes the \"level\" of authorization/demand implicit in this request.", 0, 1, intent);
2124        case 3575610: /*type*/  return new Property("type", "CodeableConcept", "An indication of the type of referral (or where applicable the type of transfer of care) request.", 0, 1, type);
2125        case -1165461084: /*priority*/  return new Property("priority", "code", "An indication of the urgency of referral (or where applicable the type of transfer of care) request.", 0, 1, priority);
2126        case 190229561: /*serviceRequested*/  return new Property("serviceRequested", "CodeableConcept", "The service(s) that is/are requested to be provided to the patient.  For example: cardiac pacemaker insertion.", 0, java.lang.Integer.MAX_VALUE, serviceRequested);
2127        case -1867885268: /*subject*/  return new Property("subject", "Reference(Patient|Group)", "The patient who is the subject of a referral or transfer of care request.", 0, 1, subject);
2128        case 951530927: /*context*/  return new Property("context", "Reference(Encounter|EpisodeOfCare)", "The encounter at which the request for referral or transfer of care is initiated.", 0, 1, context);
2129        case -2022646513: /*occurrence[x]*/  return new Property("occurrence[x]", "dateTime|Period", "The period of time within which the services identified in the referral/transfer of care is specified or required to occur.", 0, 1, occurrence);
2130        case 1687874001: /*occurrence*/  return new Property("occurrence[x]", "dateTime|Period", "The period of time within which the services identified in the referral/transfer of care is specified or required to occur.", 0, 1, occurrence);
2131        case -298443636: /*occurrenceDateTime*/  return new Property("occurrence[x]", "dateTime|Period", "The period of time within which the services identified in the referral/transfer of care is specified or required to occur.", 0, 1, occurrence);
2132        case 1397156594: /*occurrencePeriod*/  return new Property("occurrence[x]", "dateTime|Period", "The period of time within which the services identified in the referral/transfer of care is specified or required to occur.", 0, 1, occurrence);
2133        case -1500852503: /*authoredOn*/  return new Property("authoredOn", "dateTime", "Date/DateTime of creation for draft requests and date of activation for active requests.", 0, 1, authoredOn);
2134        case 693933948: /*requester*/  return new Property("requester", "", "The individual who initiated the request and has responsibility for its activation.", 0, 1, requester);
2135        case -1694759682: /*specialty*/  return new Property("specialty", "CodeableConcept", "Indication of the clinical domain or discipline to which the referral or transfer of care request is sent.  For example: Cardiology Gastroenterology Diabetology.", 0, 1, specialty);
2136        case 820081177: /*recipient*/  return new Property("recipient", "Reference(Practitioner|Organization|HealthcareService)", "The healthcare provider(s) or provider organization(s) who/which is to receive the referral/transfer of care request.", 0, java.lang.Integer.MAX_VALUE, recipient);
2137        case 722137681: /*reasonCode*/  return new Property("reasonCode", "CodeableConcept", "Description of clinical condition indicating why referral/transfer of care is requested.  For example:  Pathological Anomalies, Disabled (physical or mental),  Behavioral Management.", 0, java.lang.Integer.MAX_VALUE, reasonCode);
2138        case -1146218137: /*reasonReference*/  return new Property("reasonReference", "Reference(Condition|Observation)", "Indicates another resource whose existence justifies this request.", 0, java.lang.Integer.MAX_VALUE, reasonReference);
2139        case -1724546052: /*description*/  return new Property("description", "string", "The reason element gives a short description of why the referral is being made, the description expands on this to support a more complete clinical summary.", 0, 1, description);
2140        case 1922406657: /*supportingInfo*/  return new Property("supportingInfo", "Reference(Any)", "Any additional (administrative, financial or clinical) information required to support request for referral or transfer of care.  For example: Presenting problems/chief complaints Medical History Family History Alerts Allergy/Intolerance and Adverse Reactions Medications Observations/Assessments (may include cognitive and fundtional assessments) Diagnostic Reports Care Plan.", 0, java.lang.Integer.MAX_VALUE, supportingInfo);
2141        case 3387378: /*note*/  return new Property("note", "Annotation", "Comments made about the referral request by any of the participants.", 0, java.lang.Integer.MAX_VALUE, note);
2142        case 1538891575: /*relevantHistory*/  return new Property("relevantHistory", "Reference(Provenance)", "Links to Provenance records for past versions of this resource or fulfilling request or event resources that identify key state transitions or updates that are likely to be relevant to a user looking at the current version of the resource.", 0, java.lang.Integer.MAX_VALUE, relevantHistory);
2143        default: return super.getNamedProperty(_hash, _name, _checkValid);
2144        }
2145
2146      }
2147
2148      @Override
2149      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2150        switch (hash) {
2151        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2152        case -1014418093: /*definition*/ return this.definition == null ? new Base[0] : this.definition.toArray(new Base[this.definition.size()]); // Reference
2153        case -332612366: /*basedOn*/ return this.basedOn == null ? new Base[0] : this.basedOn.toArray(new Base[this.basedOn.size()]); // Reference
2154        case -430332865: /*replaces*/ return this.replaces == null ? new Base[0] : this.replaces.toArray(new Base[this.replaces.size()]); // Reference
2155        case -445338488: /*groupIdentifier*/ return this.groupIdentifier == null ? new Base[0] : new Base[] {this.groupIdentifier}; // Identifier
2156        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<ReferralRequestStatus>
2157        case -1183762788: /*intent*/ return this.intent == null ? new Base[0] : new Base[] {this.intent}; // Enumeration<ReferralCategory>
2158        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
2159        case -1165461084: /*priority*/ return this.priority == null ? new Base[0] : new Base[] {this.priority}; // Enumeration<ReferralPriority>
2160        case 190229561: /*serviceRequested*/ return this.serviceRequested == null ? new Base[0] : this.serviceRequested.toArray(new Base[this.serviceRequested.size()]); // CodeableConcept
2161        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
2162        case 951530927: /*context*/ return this.context == null ? new Base[0] : new Base[] {this.context}; // Reference
2163        case 1687874001: /*occurrence*/ return this.occurrence == null ? new Base[0] : new Base[] {this.occurrence}; // Type
2164        case -1500852503: /*authoredOn*/ return this.authoredOn == null ? new Base[0] : new Base[] {this.authoredOn}; // DateTimeType
2165        case 693933948: /*requester*/ return this.requester == null ? new Base[0] : new Base[] {this.requester}; // ReferralRequestRequesterComponent
2166        case -1694759682: /*specialty*/ return this.specialty == null ? new Base[0] : new Base[] {this.specialty}; // CodeableConcept
2167        case 820081177: /*recipient*/ return this.recipient == null ? new Base[0] : this.recipient.toArray(new Base[this.recipient.size()]); // Reference
2168        case 722137681: /*reasonCode*/ return this.reasonCode == null ? new Base[0] : this.reasonCode.toArray(new Base[this.reasonCode.size()]); // CodeableConcept
2169        case -1146218137: /*reasonReference*/ return this.reasonReference == null ? new Base[0] : this.reasonReference.toArray(new Base[this.reasonReference.size()]); // Reference
2170        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
2171        case 1922406657: /*supportingInfo*/ return this.supportingInfo == null ? new Base[0] : this.supportingInfo.toArray(new Base[this.supportingInfo.size()]); // Reference
2172        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
2173        case 1538891575: /*relevantHistory*/ return this.relevantHistory == null ? new Base[0] : this.relevantHistory.toArray(new Base[this.relevantHistory.size()]); // Reference
2174        default: return super.getProperty(hash, name, checkValid);
2175        }
2176
2177      }
2178
2179      @Override
2180      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2181        switch (hash) {
2182        case -1618432855: // identifier
2183          this.getIdentifier().add(castToIdentifier(value)); // Identifier
2184          return value;
2185        case -1014418093: // definition
2186          this.getDefinition().add(castToReference(value)); // Reference
2187          return value;
2188        case -332612366: // basedOn
2189          this.getBasedOn().add(castToReference(value)); // Reference
2190          return value;
2191        case -430332865: // replaces
2192          this.getReplaces().add(castToReference(value)); // Reference
2193          return value;
2194        case -445338488: // groupIdentifier
2195          this.groupIdentifier = castToIdentifier(value); // Identifier
2196          return value;
2197        case -892481550: // status
2198          value = new ReferralRequestStatusEnumFactory().fromType(castToCode(value));
2199          this.status = (Enumeration) value; // Enumeration<ReferralRequestStatus>
2200          return value;
2201        case -1183762788: // intent
2202          value = new ReferralCategoryEnumFactory().fromType(castToCode(value));
2203          this.intent = (Enumeration) value; // Enumeration<ReferralCategory>
2204          return value;
2205        case 3575610: // type
2206          this.type = castToCodeableConcept(value); // CodeableConcept
2207          return value;
2208        case -1165461084: // priority
2209          value = new ReferralPriorityEnumFactory().fromType(castToCode(value));
2210          this.priority = (Enumeration) value; // Enumeration<ReferralPriority>
2211          return value;
2212        case 190229561: // serviceRequested
2213          this.getServiceRequested().add(castToCodeableConcept(value)); // CodeableConcept
2214          return value;
2215        case -1867885268: // subject
2216          this.subject = castToReference(value); // Reference
2217          return value;
2218        case 951530927: // context
2219          this.context = castToReference(value); // Reference
2220          return value;
2221        case 1687874001: // occurrence
2222          this.occurrence = castToType(value); // Type
2223          return value;
2224        case -1500852503: // authoredOn
2225          this.authoredOn = castToDateTime(value); // DateTimeType
2226          return value;
2227        case 693933948: // requester
2228          this.requester = (ReferralRequestRequesterComponent) value; // ReferralRequestRequesterComponent
2229          return value;
2230        case -1694759682: // specialty
2231          this.specialty = castToCodeableConcept(value); // CodeableConcept
2232          return value;
2233        case 820081177: // recipient
2234          this.getRecipient().add(castToReference(value)); // Reference
2235          return value;
2236        case 722137681: // reasonCode
2237          this.getReasonCode().add(castToCodeableConcept(value)); // CodeableConcept
2238          return value;
2239        case -1146218137: // reasonReference
2240          this.getReasonReference().add(castToReference(value)); // Reference
2241          return value;
2242        case -1724546052: // description
2243          this.description = castToString(value); // StringType
2244          return value;
2245        case 1922406657: // supportingInfo
2246          this.getSupportingInfo().add(castToReference(value)); // Reference
2247          return value;
2248        case 3387378: // note
2249          this.getNote().add(castToAnnotation(value)); // Annotation
2250          return value;
2251        case 1538891575: // relevantHistory
2252          this.getRelevantHistory().add(castToReference(value)); // Reference
2253          return value;
2254        default: return super.setProperty(hash, name, value);
2255        }
2256
2257      }
2258
2259      @Override
2260      public Base setProperty(String name, Base value) throws FHIRException {
2261        if (name.equals("identifier")) {
2262          this.getIdentifier().add(castToIdentifier(value));
2263        } else if (name.equals("definition")) {
2264          this.getDefinition().add(castToReference(value));
2265        } else if (name.equals("basedOn")) {
2266          this.getBasedOn().add(castToReference(value));
2267        } else if (name.equals("replaces")) {
2268          this.getReplaces().add(castToReference(value));
2269        } else if (name.equals("groupIdentifier")) {
2270          this.groupIdentifier = castToIdentifier(value); // Identifier
2271        } else if (name.equals("status")) {
2272          value = new ReferralRequestStatusEnumFactory().fromType(castToCode(value));
2273          this.status = (Enumeration) value; // Enumeration<ReferralRequestStatus>
2274        } else if (name.equals("intent")) {
2275          value = new ReferralCategoryEnumFactory().fromType(castToCode(value));
2276          this.intent = (Enumeration) value; // Enumeration<ReferralCategory>
2277        } else if (name.equals("type")) {
2278          this.type = castToCodeableConcept(value); // CodeableConcept
2279        } else if (name.equals("priority")) {
2280          value = new ReferralPriorityEnumFactory().fromType(castToCode(value));
2281          this.priority = (Enumeration) value; // Enumeration<ReferralPriority>
2282        } else if (name.equals("serviceRequested")) {
2283          this.getServiceRequested().add(castToCodeableConcept(value));
2284        } else if (name.equals("subject")) {
2285          this.subject = castToReference(value); // Reference
2286        } else if (name.equals("context")) {
2287          this.context = castToReference(value); // Reference
2288        } else if (name.equals("occurrence[x]")) {
2289          this.occurrence = castToType(value); // Type
2290        } else if (name.equals("authoredOn")) {
2291          this.authoredOn = castToDateTime(value); // DateTimeType
2292        } else if (name.equals("requester")) {
2293          this.requester = (ReferralRequestRequesterComponent) value; // ReferralRequestRequesterComponent
2294        } else if (name.equals("specialty")) {
2295          this.specialty = castToCodeableConcept(value); // CodeableConcept
2296        } else if (name.equals("recipient")) {
2297          this.getRecipient().add(castToReference(value));
2298        } else if (name.equals("reasonCode")) {
2299          this.getReasonCode().add(castToCodeableConcept(value));
2300        } else if (name.equals("reasonReference")) {
2301          this.getReasonReference().add(castToReference(value));
2302        } else if (name.equals("description")) {
2303          this.description = castToString(value); // StringType
2304        } else if (name.equals("supportingInfo")) {
2305          this.getSupportingInfo().add(castToReference(value));
2306        } else if (name.equals("note")) {
2307          this.getNote().add(castToAnnotation(value));
2308        } else if (name.equals("relevantHistory")) {
2309          this.getRelevantHistory().add(castToReference(value));
2310        } else
2311          return super.setProperty(name, value);
2312        return value;
2313      }
2314
2315      @Override
2316      public Base makeProperty(int hash, String name) throws FHIRException {
2317        switch (hash) {
2318        case -1618432855:  return addIdentifier(); 
2319        case -1014418093:  return addDefinition(); 
2320        case -332612366:  return addBasedOn(); 
2321        case -430332865:  return addReplaces(); 
2322        case -445338488:  return getGroupIdentifier(); 
2323        case -892481550:  return getStatusElement();
2324        case -1183762788:  return getIntentElement();
2325        case 3575610:  return getType(); 
2326        case -1165461084:  return getPriorityElement();
2327        case 190229561:  return addServiceRequested(); 
2328        case -1867885268:  return getSubject(); 
2329        case 951530927:  return getContext(); 
2330        case -2022646513:  return getOccurrence(); 
2331        case 1687874001:  return getOccurrence(); 
2332        case -1500852503:  return getAuthoredOnElement();
2333        case 693933948:  return getRequester(); 
2334        case -1694759682:  return getSpecialty(); 
2335        case 820081177:  return addRecipient(); 
2336        case 722137681:  return addReasonCode(); 
2337        case -1146218137:  return addReasonReference(); 
2338        case -1724546052:  return getDescriptionElement();
2339        case 1922406657:  return addSupportingInfo(); 
2340        case 3387378:  return addNote(); 
2341        case 1538891575:  return addRelevantHistory(); 
2342        default: return super.makeProperty(hash, name);
2343        }
2344
2345      }
2346
2347      @Override
2348      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2349        switch (hash) {
2350        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2351        case -1014418093: /*definition*/ return new String[] {"Reference"};
2352        case -332612366: /*basedOn*/ return new String[] {"Reference"};
2353        case -430332865: /*replaces*/ return new String[] {"Reference"};
2354        case -445338488: /*groupIdentifier*/ return new String[] {"Identifier"};
2355        case -892481550: /*status*/ return new String[] {"code"};
2356        case -1183762788: /*intent*/ return new String[] {"code"};
2357        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
2358        case -1165461084: /*priority*/ return new String[] {"code"};
2359        case 190229561: /*serviceRequested*/ return new String[] {"CodeableConcept"};
2360        case -1867885268: /*subject*/ return new String[] {"Reference"};
2361        case 951530927: /*context*/ return new String[] {"Reference"};
2362        case 1687874001: /*occurrence*/ return new String[] {"dateTime", "Period"};
2363        case -1500852503: /*authoredOn*/ return new String[] {"dateTime"};
2364        case 693933948: /*requester*/ return new String[] {};
2365        case -1694759682: /*specialty*/ return new String[] {"CodeableConcept"};
2366        case 820081177: /*recipient*/ return new String[] {"Reference"};
2367        case 722137681: /*reasonCode*/ return new String[] {"CodeableConcept"};
2368        case -1146218137: /*reasonReference*/ return new String[] {"Reference"};
2369        case -1724546052: /*description*/ return new String[] {"string"};
2370        case 1922406657: /*supportingInfo*/ return new String[] {"Reference"};
2371        case 3387378: /*note*/ return new String[] {"Annotation"};
2372        case 1538891575: /*relevantHistory*/ return new String[] {"Reference"};
2373        default: return super.getTypesForProperty(hash, name);
2374        }
2375
2376      }
2377
2378      @Override
2379      public Base addChild(String name) throws FHIRException {
2380        if (name.equals("identifier")) {
2381          return addIdentifier();
2382        }
2383        else if (name.equals("definition")) {
2384          return addDefinition();
2385        }
2386        else if (name.equals("basedOn")) {
2387          return addBasedOn();
2388        }
2389        else if (name.equals("replaces")) {
2390          return addReplaces();
2391        }
2392        else if (name.equals("groupIdentifier")) {
2393          this.groupIdentifier = new Identifier();
2394          return this.groupIdentifier;
2395        }
2396        else if (name.equals("status")) {
2397          throw new FHIRException("Cannot call addChild on a singleton property ReferralRequest.status");
2398        }
2399        else if (name.equals("intent")) {
2400          throw new FHIRException("Cannot call addChild on a singleton property ReferralRequest.intent");
2401        }
2402        else if (name.equals("type")) {
2403          this.type = new CodeableConcept();
2404          return this.type;
2405        }
2406        else if (name.equals("priority")) {
2407          throw new FHIRException("Cannot call addChild on a singleton property ReferralRequest.priority");
2408        }
2409        else if (name.equals("serviceRequested")) {
2410          return addServiceRequested();
2411        }
2412        else if (name.equals("subject")) {
2413          this.subject = new Reference();
2414          return this.subject;
2415        }
2416        else if (name.equals("context")) {
2417          this.context = new Reference();
2418          return this.context;
2419        }
2420        else if (name.equals("occurrenceDateTime")) {
2421          this.occurrence = new DateTimeType();
2422          return this.occurrence;
2423        }
2424        else if (name.equals("occurrencePeriod")) {
2425          this.occurrence = new Period();
2426          return this.occurrence;
2427        }
2428        else if (name.equals("authoredOn")) {
2429          throw new FHIRException("Cannot call addChild on a singleton property ReferralRequest.authoredOn");
2430        }
2431        else if (name.equals("requester")) {
2432          this.requester = new ReferralRequestRequesterComponent();
2433          return this.requester;
2434        }
2435        else if (name.equals("specialty")) {
2436          this.specialty = new CodeableConcept();
2437          return this.specialty;
2438        }
2439        else if (name.equals("recipient")) {
2440          return addRecipient();
2441        }
2442        else if (name.equals("reasonCode")) {
2443          return addReasonCode();
2444        }
2445        else if (name.equals("reasonReference")) {
2446          return addReasonReference();
2447        }
2448        else if (name.equals("description")) {
2449          throw new FHIRException("Cannot call addChild on a singleton property ReferralRequest.description");
2450        }
2451        else if (name.equals("supportingInfo")) {
2452          return addSupportingInfo();
2453        }
2454        else if (name.equals("note")) {
2455          return addNote();
2456        }
2457        else if (name.equals("relevantHistory")) {
2458          return addRelevantHistory();
2459        }
2460        else
2461          return super.addChild(name);
2462      }
2463
2464  public String fhirType() {
2465    return "ReferralRequest";
2466
2467  }
2468
2469      public ReferralRequest copy() {
2470        ReferralRequest dst = new ReferralRequest();
2471        copyValues(dst);
2472        if (identifier != null) {
2473          dst.identifier = new ArrayList<Identifier>();
2474          for (Identifier i : identifier)
2475            dst.identifier.add(i.copy());
2476        };
2477        if (definition != null) {
2478          dst.definition = new ArrayList<Reference>();
2479          for (Reference i : definition)
2480            dst.definition.add(i.copy());
2481        };
2482        if (basedOn != null) {
2483          dst.basedOn = new ArrayList<Reference>();
2484          for (Reference i : basedOn)
2485            dst.basedOn.add(i.copy());
2486        };
2487        if (replaces != null) {
2488          dst.replaces = new ArrayList<Reference>();
2489          for (Reference i : replaces)
2490            dst.replaces.add(i.copy());
2491        };
2492        dst.groupIdentifier = groupIdentifier == null ? null : groupIdentifier.copy();
2493        dst.status = status == null ? null : status.copy();
2494        dst.intent = intent == null ? null : intent.copy();
2495        dst.type = type == null ? null : type.copy();
2496        dst.priority = priority == null ? null : priority.copy();
2497        if (serviceRequested != null) {
2498          dst.serviceRequested = new ArrayList<CodeableConcept>();
2499          for (CodeableConcept i : serviceRequested)
2500            dst.serviceRequested.add(i.copy());
2501        };
2502        dst.subject = subject == null ? null : subject.copy();
2503        dst.context = context == null ? null : context.copy();
2504        dst.occurrence = occurrence == null ? null : occurrence.copy();
2505        dst.authoredOn = authoredOn == null ? null : authoredOn.copy();
2506        dst.requester = requester == null ? null : requester.copy();
2507        dst.specialty = specialty == null ? null : specialty.copy();
2508        if (recipient != null) {
2509          dst.recipient = new ArrayList<Reference>();
2510          for (Reference i : recipient)
2511            dst.recipient.add(i.copy());
2512        };
2513        if (reasonCode != null) {
2514          dst.reasonCode = new ArrayList<CodeableConcept>();
2515          for (CodeableConcept i : reasonCode)
2516            dst.reasonCode.add(i.copy());
2517        };
2518        if (reasonReference != null) {
2519          dst.reasonReference = new ArrayList<Reference>();
2520          for (Reference i : reasonReference)
2521            dst.reasonReference.add(i.copy());
2522        };
2523        dst.description = description == null ? null : description.copy();
2524        if (supportingInfo != null) {
2525          dst.supportingInfo = new ArrayList<Reference>();
2526          for (Reference i : supportingInfo)
2527            dst.supportingInfo.add(i.copy());
2528        };
2529        if (note != null) {
2530          dst.note = new ArrayList<Annotation>();
2531          for (Annotation i : note)
2532            dst.note.add(i.copy());
2533        };
2534        if (relevantHistory != null) {
2535          dst.relevantHistory = new ArrayList<Reference>();
2536          for (Reference i : relevantHistory)
2537            dst.relevantHistory.add(i.copy());
2538        };
2539        return dst;
2540      }
2541
2542      protected ReferralRequest typedCopy() {
2543        return copy();
2544      }
2545
2546      @Override
2547      public boolean equalsDeep(Base other_) {
2548        if (!super.equalsDeep(other_))
2549          return false;
2550        if (!(other_ instanceof ReferralRequest))
2551          return false;
2552        ReferralRequest o = (ReferralRequest) other_;
2553        return compareDeep(identifier, o.identifier, true) && compareDeep(definition, o.definition, true)
2554           && compareDeep(basedOn, o.basedOn, true) && compareDeep(replaces, o.replaces, true) && compareDeep(groupIdentifier, o.groupIdentifier, true)
2555           && compareDeep(status, o.status, true) && compareDeep(intent, o.intent, true) && compareDeep(type, o.type, true)
2556           && compareDeep(priority, o.priority, true) && compareDeep(serviceRequested, o.serviceRequested, true)
2557           && compareDeep(subject, o.subject, true) && compareDeep(context, o.context, true) && compareDeep(occurrence, o.occurrence, true)
2558           && compareDeep(authoredOn, o.authoredOn, true) && compareDeep(requester, o.requester, true) && compareDeep(specialty, o.specialty, true)
2559           && compareDeep(recipient, o.recipient, true) && compareDeep(reasonCode, o.reasonCode, true) && compareDeep(reasonReference, o.reasonReference, true)
2560           && compareDeep(description, o.description, true) && compareDeep(supportingInfo, o.supportingInfo, true)
2561           && compareDeep(note, o.note, true) && compareDeep(relevantHistory, o.relevantHistory, true);
2562      }
2563
2564      @Override
2565      public boolean equalsShallow(Base other_) {
2566        if (!super.equalsShallow(other_))
2567          return false;
2568        if (!(other_ instanceof ReferralRequest))
2569          return false;
2570        ReferralRequest o = (ReferralRequest) other_;
2571        return compareValues(status, o.status, true) && compareValues(intent, o.intent, true) && compareValues(priority, o.priority, true)
2572           && compareValues(authoredOn, o.authoredOn, true) && compareValues(description, o.description, true)
2573          ;
2574      }
2575
2576      public boolean isEmpty() {
2577        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, definition, basedOn
2578          , replaces, groupIdentifier, status, intent, type, priority, serviceRequested
2579          , subject, context, occurrence, authoredOn, requester, specialty, recipient, reasonCode
2580          , reasonReference, description, supportingInfo, note, relevantHistory);
2581      }
2582
2583  @Override
2584  public ResourceType getResourceType() {
2585    return ResourceType.ReferralRequest;
2586   }
2587
2588 /**
2589   * Search parameter: <b>requester</b>
2590   * <p>
2591   * Description: <b>Individual making the request</b><br>
2592   * Type: <b>reference</b><br>
2593   * Path: <b>ReferralRequest.requester.agent</b><br>
2594   * </p>
2595   */
2596  @SearchParamDefinition(name="requester", path="ReferralRequest.requester.agent", description="Individual making the request", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={Device.class, Organization.class, Patient.class, Practitioner.class, RelatedPerson.class } )
2597  public static final String SP_REQUESTER = "requester";
2598 /**
2599   * <b>Fluent Client</b> search parameter constant for <b>requester</b>
2600   * <p>
2601   * Description: <b>Individual making the request</b><br>
2602   * Type: <b>reference</b><br>
2603   * Path: <b>ReferralRequest.requester.agent</b><br>
2604   * </p>
2605   */
2606  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam REQUESTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_REQUESTER);
2607
2608/**
2609   * Constant for fluent queries to be used to add include statements. Specifies
2610   * the path value of "<b>ReferralRequest:requester</b>".
2611   */
2612  public static final ca.uhn.fhir.model.api.Include INCLUDE_REQUESTER = new ca.uhn.fhir.model.api.Include("ReferralRequest:requester").toLocked();
2613
2614 /**
2615   * Search parameter: <b>identifier</b>
2616   * <p>
2617   * Description: <b>Business identifier</b><br>
2618   * Type: <b>token</b><br>
2619   * Path: <b>ReferralRequest.identifier</b><br>
2620   * </p>
2621   */
2622  @SearchParamDefinition(name="identifier", path="ReferralRequest.identifier", description="Business identifier", type="token" )
2623  public static final String SP_IDENTIFIER = "identifier";
2624 /**
2625   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2626   * <p>
2627   * Description: <b>Business identifier</b><br>
2628   * Type: <b>token</b><br>
2629   * Path: <b>ReferralRequest.identifier</b><br>
2630   * </p>
2631   */
2632  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2633
2634 /**
2635   * Search parameter: <b>specialty</b>
2636   * <p>
2637   * Description: <b>The specialty that the referral is for</b><br>
2638   * Type: <b>token</b><br>
2639   * Path: <b>ReferralRequest.specialty</b><br>
2640   * </p>
2641   */
2642  @SearchParamDefinition(name="specialty", path="ReferralRequest.specialty", description="The specialty that the referral is for", type="token" )
2643  public static final String SP_SPECIALTY = "specialty";
2644 /**
2645   * <b>Fluent Client</b> search parameter constant for <b>specialty</b>
2646   * <p>
2647   * Description: <b>The specialty that the referral is for</b><br>
2648   * Type: <b>token</b><br>
2649   * Path: <b>ReferralRequest.specialty</b><br>
2650   * </p>
2651   */
2652  public static final ca.uhn.fhir.rest.gclient.TokenClientParam SPECIALTY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_SPECIALTY);
2653
2654 /**
2655   * Search parameter: <b>replaces</b>
2656   * <p>
2657   * Description: <b>Request(s) replaced by this request</b><br>
2658   * Type: <b>reference</b><br>
2659   * Path: <b>ReferralRequest.replaces</b><br>
2660   * </p>
2661   */
2662  @SearchParamDefinition(name="replaces", path="ReferralRequest.replaces", description="Request(s) replaced by this request", type="reference", target={ReferralRequest.class } )
2663  public static final String SP_REPLACES = "replaces";
2664 /**
2665   * <b>Fluent Client</b> search parameter constant for <b>replaces</b>
2666   * <p>
2667   * Description: <b>Request(s) replaced by this request</b><br>
2668   * Type: <b>reference</b><br>
2669   * Path: <b>ReferralRequest.replaces</b><br>
2670   * </p>
2671   */
2672  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam REPLACES = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_REPLACES);
2673
2674/**
2675   * Constant for fluent queries to be used to add include statements. Specifies
2676   * the path value of "<b>ReferralRequest:replaces</b>".
2677   */
2678  public static final ca.uhn.fhir.model.api.Include INCLUDE_REPLACES = new ca.uhn.fhir.model.api.Include("ReferralRequest:replaces").toLocked();
2679
2680 /**
2681   * Search parameter: <b>subject</b>
2682   * <p>
2683   * Description: <b>Patient referred to care or transfer</b><br>
2684   * Type: <b>reference</b><br>
2685   * Path: <b>ReferralRequest.subject</b><br>
2686   * </p>
2687   */
2688  @SearchParamDefinition(name="subject", path="ReferralRequest.subject", description="Patient referred to care or transfer", type="reference", target={Group.class, Patient.class } )
2689  public static final String SP_SUBJECT = "subject";
2690 /**
2691   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
2692   * <p>
2693   * Description: <b>Patient referred to care or transfer</b><br>
2694   * Type: <b>reference</b><br>
2695   * Path: <b>ReferralRequest.subject</b><br>
2696   * </p>
2697   */
2698  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
2699
2700/**
2701   * Constant for fluent queries to be used to add include statements. Specifies
2702   * the path value of "<b>ReferralRequest:subject</b>".
2703   */
2704  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("ReferralRequest:subject").toLocked();
2705
2706 /**
2707   * Search parameter: <b>encounter</b>
2708   * <p>
2709   * Description: <b>Originating encounter</b><br>
2710   * Type: <b>reference</b><br>
2711   * Path: <b>ReferralRequest.context</b><br>
2712   * </p>
2713   */
2714  @SearchParamDefinition(name="encounter", path="ReferralRequest.context", description="Originating encounter", type="reference", target={Encounter.class } )
2715  public static final String SP_ENCOUNTER = "encounter";
2716 /**
2717   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
2718   * <p>
2719   * Description: <b>Originating encounter</b><br>
2720   * Type: <b>reference</b><br>
2721   * Path: <b>ReferralRequest.context</b><br>
2722   * </p>
2723   */
2724  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
2725
2726/**
2727   * Constant for fluent queries to be used to add include statements. Specifies
2728   * the path value of "<b>ReferralRequest:encounter</b>".
2729   */
2730  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("ReferralRequest:encounter").toLocked();
2731
2732 /**
2733   * Search parameter: <b>authored-on</b>
2734   * <p>
2735   * Description: <b>Creation or activation date</b><br>
2736   * Type: <b>date</b><br>
2737   * Path: <b>ReferralRequest.authoredOn</b><br>
2738   * </p>
2739   */
2740  @SearchParamDefinition(name="authored-on", path="ReferralRequest.authoredOn", description="Creation or activation date", type="date" )
2741  public static final String SP_AUTHORED_ON = "authored-on";
2742 /**
2743   * <b>Fluent Client</b> search parameter constant for <b>authored-on</b>
2744   * <p>
2745   * Description: <b>Creation or activation date</b><br>
2746   * Type: <b>date</b><br>
2747   * Path: <b>ReferralRequest.authoredOn</b><br>
2748   * </p>
2749   */
2750  public static final ca.uhn.fhir.rest.gclient.DateClientParam AUTHORED_ON = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_AUTHORED_ON);
2751
2752 /**
2753   * Search parameter: <b>type</b>
2754   * <p>
2755   * Description: <b>The type of the referral</b><br>
2756   * Type: <b>token</b><br>
2757   * Path: <b>ReferralRequest.type</b><br>
2758   * </p>
2759   */
2760  @SearchParamDefinition(name="type", path="ReferralRequest.type", description="The type of the referral", type="token" )
2761  public static final String SP_TYPE = "type";
2762 /**
2763   * <b>Fluent Client</b> search parameter constant for <b>type</b>
2764   * <p>
2765   * Description: <b>The type of the referral</b><br>
2766   * Type: <b>token</b><br>
2767   * Path: <b>ReferralRequest.type</b><br>
2768   * </p>
2769   */
2770  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
2771
2772 /**
2773   * Search parameter: <b>priority</b>
2774   * <p>
2775   * Description: <b>The priority assigned to the referral</b><br>
2776   * Type: <b>token</b><br>
2777   * Path: <b>ReferralRequest.priority</b><br>
2778   * </p>
2779   */
2780  @SearchParamDefinition(name="priority", path="ReferralRequest.priority", description="The priority assigned to the referral", type="token" )
2781  public static final String SP_PRIORITY = "priority";
2782 /**
2783   * <b>Fluent Client</b> search parameter constant for <b>priority</b>
2784   * <p>
2785   * Description: <b>The priority assigned to the referral</b><br>
2786   * Type: <b>token</b><br>
2787   * Path: <b>ReferralRequest.priority</b><br>
2788   * </p>
2789   */
2790  public static final ca.uhn.fhir.rest.gclient.TokenClientParam PRIORITY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_PRIORITY);
2791
2792 /**
2793   * Search parameter: <b>intent</b>
2794   * <p>
2795   * Description: <b>Proposal, plan or order</b><br>
2796   * Type: <b>token</b><br>
2797   * Path: <b>ReferralRequest.intent</b><br>
2798   * </p>
2799   */
2800  @SearchParamDefinition(name="intent", path="ReferralRequest.intent", description="Proposal, plan or order", type="token" )
2801  public static final String SP_INTENT = "intent";
2802 /**
2803   * <b>Fluent Client</b> search parameter constant for <b>intent</b>
2804   * <p>
2805   * Description: <b>Proposal, plan or order</b><br>
2806   * Type: <b>token</b><br>
2807   * Path: <b>ReferralRequest.intent</b><br>
2808   * </p>
2809   */
2810  public static final ca.uhn.fhir.rest.gclient.TokenClientParam INTENT = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_INTENT);
2811
2812 /**
2813   * Search parameter: <b>group-identifier</b>
2814   * <p>
2815   * Description: <b>Part of common request</b><br>
2816   * Type: <b>token</b><br>
2817   * Path: <b>ReferralRequest.groupIdentifier</b><br>
2818   * </p>
2819   */
2820  @SearchParamDefinition(name="group-identifier", path="ReferralRequest.groupIdentifier", description="Part of common request", type="token" )
2821  public static final String SP_GROUP_IDENTIFIER = "group-identifier";
2822 /**
2823   * <b>Fluent Client</b> search parameter constant for <b>group-identifier</b>
2824   * <p>
2825   * Description: <b>Part of common request</b><br>
2826   * Type: <b>token</b><br>
2827   * Path: <b>ReferralRequest.groupIdentifier</b><br>
2828   * </p>
2829   */
2830  public static final ca.uhn.fhir.rest.gclient.TokenClientParam GROUP_IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_GROUP_IDENTIFIER);
2831
2832 /**
2833   * Search parameter: <b>based-on</b>
2834   * <p>
2835   * Description: <b>Request being fulfilled</b><br>
2836   * Type: <b>reference</b><br>
2837   * Path: <b>ReferralRequest.basedOn</b><br>
2838   * </p>
2839   */
2840  @SearchParamDefinition(name="based-on", path="ReferralRequest.basedOn", description="Request being fulfilled", type="reference", target={CarePlan.class, ProcedureRequest.class, ReferralRequest.class } )
2841  public static final String SP_BASED_ON = "based-on";
2842 /**
2843   * <b>Fluent Client</b> search parameter constant for <b>based-on</b>
2844   * <p>
2845   * Description: <b>Request being fulfilled</b><br>
2846   * Type: <b>reference</b><br>
2847   * Path: <b>ReferralRequest.basedOn</b><br>
2848   * </p>
2849   */
2850  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam BASED_ON = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_BASED_ON);
2851
2852/**
2853   * Constant for fluent queries to be used to add include statements. Specifies
2854   * the path value of "<b>ReferralRequest:based-on</b>".
2855   */
2856  public static final ca.uhn.fhir.model.api.Include INCLUDE_BASED_ON = new ca.uhn.fhir.model.api.Include("ReferralRequest:based-on").toLocked();
2857
2858 /**
2859   * Search parameter: <b>patient</b>
2860   * <p>
2861   * Description: <b>Who the referral is about</b><br>
2862   * Type: <b>reference</b><br>
2863   * Path: <b>ReferralRequest.subject</b><br>
2864   * </p>
2865   */
2866  @SearchParamDefinition(name="patient", path="ReferralRequest.subject", description="Who the referral is about", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Patient.class } )
2867  public static final String SP_PATIENT = "patient";
2868 /**
2869   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2870   * <p>
2871   * Description: <b>Who the referral is about</b><br>
2872   * Type: <b>reference</b><br>
2873   * Path: <b>ReferralRequest.subject</b><br>
2874   * </p>
2875   */
2876  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
2877
2878/**
2879   * Constant for fluent queries to be used to add include statements. Specifies
2880   * the path value of "<b>ReferralRequest:patient</b>".
2881   */
2882  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("ReferralRequest:patient").toLocked();
2883
2884 /**
2885   * Search parameter: <b>service</b>
2886   * <p>
2887   * Description: <b>Actions requested as part of the referral</b><br>
2888   * Type: <b>token</b><br>
2889   * Path: <b>ReferralRequest.serviceRequested</b><br>
2890   * </p>
2891   */
2892  @SearchParamDefinition(name="service", path="ReferralRequest.serviceRequested", description="Actions requested as part of the referral", type="token" )
2893  public static final String SP_SERVICE = "service";
2894 /**
2895   * <b>Fluent Client</b> search parameter constant for <b>service</b>
2896   * <p>
2897   * Description: <b>Actions requested as part of the referral</b><br>
2898   * Type: <b>token</b><br>
2899   * Path: <b>ReferralRequest.serviceRequested</b><br>
2900   * </p>
2901   */
2902  public static final ca.uhn.fhir.rest.gclient.TokenClientParam SERVICE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_SERVICE);
2903
2904 /**
2905   * Search parameter: <b>occurrence-date</b>
2906   * <p>
2907   * Description: <b>When the service(s) requested in the referral should occur</b><br>
2908   * Type: <b>date</b><br>
2909   * Path: <b>ReferralRequest.occurrence[x]</b><br>
2910   * </p>
2911   */
2912  @SearchParamDefinition(name="occurrence-date", path="ReferralRequest.occurrence", description="When the service(s) requested in the referral should occur", type="date" )
2913  public static final String SP_OCCURRENCE_DATE = "occurrence-date";
2914 /**
2915   * <b>Fluent Client</b> search parameter constant for <b>occurrence-date</b>
2916   * <p>
2917   * Description: <b>When the service(s) requested in the referral should occur</b><br>
2918   * Type: <b>date</b><br>
2919   * Path: <b>ReferralRequest.occurrence[x]</b><br>
2920   * </p>
2921   */
2922  public static final ca.uhn.fhir.rest.gclient.DateClientParam OCCURRENCE_DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_OCCURRENCE_DATE);
2923
2924 /**
2925   * Search parameter: <b>recipient</b>
2926   * <p>
2927   * Description: <b>The person that the referral was sent to</b><br>
2928   * Type: <b>reference</b><br>
2929   * Path: <b>ReferralRequest.recipient</b><br>
2930   * </p>
2931   */
2932  @SearchParamDefinition(name="recipient", path="ReferralRequest.recipient", description="The person that the referral was sent to", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={HealthcareService.class, Organization.class, Practitioner.class } )
2933  public static final String SP_RECIPIENT = "recipient";
2934 /**
2935   * <b>Fluent Client</b> search parameter constant for <b>recipient</b>
2936   * <p>
2937   * Description: <b>The person that the referral was sent to</b><br>
2938   * Type: <b>reference</b><br>
2939   * Path: <b>ReferralRequest.recipient</b><br>
2940   * </p>
2941   */
2942  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam RECIPIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_RECIPIENT);
2943
2944/**
2945   * Constant for fluent queries to be used to add include statements. Specifies
2946   * the path value of "<b>ReferralRequest:recipient</b>".
2947   */
2948  public static final ca.uhn.fhir.model.api.Include INCLUDE_RECIPIENT = new ca.uhn.fhir.model.api.Include("ReferralRequest:recipient").toLocked();
2949
2950 /**
2951   * Search parameter: <b>context</b>
2952   * <p>
2953   * Description: <b>Part of encounter or episode of care</b><br>
2954   * Type: <b>reference</b><br>
2955   * Path: <b>ReferralRequest.context</b><br>
2956   * </p>
2957   */
2958  @SearchParamDefinition(name="context", path="ReferralRequest.context", description="Part of encounter or episode of care", type="reference", target={Encounter.class, EpisodeOfCare.class } )
2959  public static final String SP_CONTEXT = "context";
2960 /**
2961   * <b>Fluent Client</b> search parameter constant for <b>context</b>
2962   * <p>
2963   * Description: <b>Part of encounter or episode of care</b><br>
2964   * Type: <b>reference</b><br>
2965   * Path: <b>ReferralRequest.context</b><br>
2966   * </p>
2967   */
2968  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam CONTEXT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_CONTEXT);
2969
2970/**
2971   * Constant for fluent queries to be used to add include statements. Specifies
2972   * the path value of "<b>ReferralRequest:context</b>".
2973   */
2974  public static final ca.uhn.fhir.model.api.Include INCLUDE_CONTEXT = new ca.uhn.fhir.model.api.Include("ReferralRequest:context").toLocked();
2975
2976 /**
2977   * Search parameter: <b>definition</b>
2978   * <p>
2979   * Description: <b>Instantiates protocol or definition</b><br>
2980   * Type: <b>reference</b><br>
2981   * Path: <b>ReferralRequest.definition</b><br>
2982   * </p>
2983   */
2984  @SearchParamDefinition(name="definition", path="ReferralRequest.definition", description="Instantiates protocol or definition", type="reference", target={ActivityDefinition.class, PlanDefinition.class } )
2985  public static final String SP_DEFINITION = "definition";
2986 /**
2987   * <b>Fluent Client</b> search parameter constant for <b>definition</b>
2988   * <p>
2989   * Description: <b>Instantiates protocol or definition</b><br>
2990   * Type: <b>reference</b><br>
2991   * Path: <b>ReferralRequest.definition</b><br>
2992   * </p>
2993   */
2994  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam DEFINITION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_DEFINITION);
2995
2996/**
2997   * Constant for fluent queries to be used to add include statements. Specifies
2998   * the path value of "<b>ReferralRequest:definition</b>".
2999   */
3000  public static final ca.uhn.fhir.model.api.Include INCLUDE_DEFINITION = new ca.uhn.fhir.model.api.Include("ReferralRequest:definition").toLocked();
3001
3002 /**
3003   * Search parameter: <b>status</b>
3004   * <p>
3005   * Description: <b>The status of the referral</b><br>
3006   * Type: <b>token</b><br>
3007   * Path: <b>ReferralRequest.status</b><br>
3008   * </p>
3009   */
3010  @SearchParamDefinition(name="status", path="ReferralRequest.status", description="The status of the referral", type="token" )
3011  public static final String SP_STATUS = "status";
3012 /**
3013   * <b>Fluent Client</b> search parameter constant for <b>status</b>
3014   * <p>
3015   * Description: <b>The status of the referral</b><br>
3016   * Type: <b>token</b><br>
3017   * Path: <b>ReferralRequest.status</b><br>
3018   * </p>
3019   */
3020  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
3021
3022
3023}