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