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