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