001package org.hl7.fhir.dstu2.model;
002
003/*-
004 * #%L
005 * org.hl7.fhir.dstu2
006 * %%
007 * Copyright (C) 2014 - 2019 Health Level 7
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023
024/*
025  Copyright (c) 2011+, HL7, Inc.
026  All rights reserved.
027  
028  Redistribution and use in source and binary forms, with or without modification, 
029  are permitted provided that the following conditions are met:
030  
031   * Redistributions of source code must retain the above copyright notice, this 
032     list of conditions and the following disclaimer.
033   * Redistributions in binary form must reproduce the above copyright notice, 
034     this list of conditions and the following disclaimer in the documentation 
035     and/or other materials provided with the distribution.
036   * Neither the name of HL7 nor the names of its contributors may be used to 
037     endorse or promote products derived from this software without specific 
038     prior written permission.
039  
040  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
041  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
042  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
043  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
044  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
045  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
046  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
047  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
048  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
049  POSSIBILITY OF SUCH DAMAGE.
050  
051*/
052
053// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
054import java.util.ArrayList;
055import java.util.Date;
056import java.util.List;
057
058import ca.uhn.fhir.model.api.annotation.Child;
059import ca.uhn.fhir.model.api.annotation.Description;
060import ca.uhn.fhir.model.api.annotation.ResourceDef;
061import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
062import org.hl7.fhir.exceptions.FHIRException;
063import org.hl7.fhir.utilities.Utilities;
064/**
065 * 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.
066 */
067@ResourceDef(name="ReferralRequest", profile="http://hl7.org/fhir/Profile/ReferralRequest")
068public class ReferralRequest extends DomainResource {
069
070    public enum ReferralStatus {
071        /**
072         * A draft referral that has yet to be send.
073         */
074        DRAFT, 
075        /**
076         * The referral has been transmitted, but not yet acknowledged by the recipient.
077         */
078        REQUESTED, 
079        /**
080         * The referral has been acknowledged by the recipient, and is in the process of being actioned.
081         */
082        ACTIVE, 
083        /**
084         * The referral has been cancelled without being completed. For example it is no longer needed.
085         */
086        CANCELLED, 
087        /**
088         * The recipient has agreed to deliver the care requested by the referral.
089         */
090        ACCEPTED, 
091        /**
092         * The recipient has declined to accept the referral.
093         */
094        REJECTED, 
095        /**
096         * The referral has been completely actioned.
097         */
098        COMPLETED, 
099        /**
100         * added to help the parsers
101         */
102        NULL;
103        public static ReferralStatus fromCode(String codeString) throws FHIRException {
104            if (codeString == null || "".equals(codeString))
105                return null;
106        if ("draft".equals(codeString))
107          return DRAFT;
108        if ("requested".equals(codeString))
109          return REQUESTED;
110        if ("active".equals(codeString))
111          return ACTIVE;
112        if ("cancelled".equals(codeString))
113          return CANCELLED;
114        if ("accepted".equals(codeString))
115          return ACCEPTED;
116        if ("rejected".equals(codeString))
117          return REJECTED;
118        if ("completed".equals(codeString))
119          return COMPLETED;
120        throw new FHIRException("Unknown ReferralStatus code '"+codeString+"'");
121        }
122        public String toCode() {
123          switch (this) {
124            case DRAFT: return "draft";
125            case REQUESTED: return "requested";
126            case ACTIVE: return "active";
127            case CANCELLED: return "cancelled";
128            case ACCEPTED: return "accepted";
129            case REJECTED: return "rejected";
130            case COMPLETED: return "completed";
131            default: return "?";
132          }
133        }
134        public String getSystem() {
135          switch (this) {
136            case DRAFT: return "http://hl7.org/fhir/referralstatus";
137            case REQUESTED: return "http://hl7.org/fhir/referralstatus";
138            case ACTIVE: return "http://hl7.org/fhir/referralstatus";
139            case CANCELLED: return "http://hl7.org/fhir/referralstatus";
140            case ACCEPTED: return "http://hl7.org/fhir/referralstatus";
141            case REJECTED: return "http://hl7.org/fhir/referralstatus";
142            case COMPLETED: return "http://hl7.org/fhir/referralstatus";
143            default: return "?";
144          }
145        }
146        public String getDefinition() {
147          switch (this) {
148            case DRAFT: return "A draft referral that has yet to be send.";
149            case REQUESTED: return "The referral has been transmitted, but not yet acknowledged by the recipient.";
150            case ACTIVE: return "The referral has been acknowledged by the recipient, and is in the process of being actioned.";
151            case CANCELLED: return "The referral has been cancelled without being completed. For example it is no longer needed.";
152            case ACCEPTED: return "The recipient has agreed to deliver the care requested by the referral.";
153            case REJECTED: return "The recipient has declined to accept the referral.";
154            case COMPLETED: return "The referral has been completely actioned.";
155            default: return "?";
156          }
157        }
158        public String getDisplay() {
159          switch (this) {
160            case DRAFT: return "Draft";
161            case REQUESTED: return "Requested";
162            case ACTIVE: return "Active";
163            case CANCELLED: return "Cancelled";
164            case ACCEPTED: return "Accepted";
165            case REJECTED: return "Rejected";
166            case COMPLETED: return "Completed";
167            default: return "?";
168          }
169        }
170    }
171
172  public static class ReferralStatusEnumFactory implements EnumFactory<ReferralStatus> {
173    public ReferralStatus fromCode(String codeString) throws IllegalArgumentException {
174      if (codeString == null || "".equals(codeString))
175            if (codeString == null || "".equals(codeString))
176                return null;
177        if ("draft".equals(codeString))
178          return ReferralStatus.DRAFT;
179        if ("requested".equals(codeString))
180          return ReferralStatus.REQUESTED;
181        if ("active".equals(codeString))
182          return ReferralStatus.ACTIVE;
183        if ("cancelled".equals(codeString))
184          return ReferralStatus.CANCELLED;
185        if ("accepted".equals(codeString))
186          return ReferralStatus.ACCEPTED;
187        if ("rejected".equals(codeString))
188          return ReferralStatus.REJECTED;
189        if ("completed".equals(codeString))
190          return ReferralStatus.COMPLETED;
191        throw new IllegalArgumentException("Unknown ReferralStatus code '"+codeString+"'");
192        }
193        public Enumeration<ReferralStatus> fromType(Base code) throws FHIRException {
194          if (code == null || code.isEmpty())
195            return null;
196          String codeString = ((PrimitiveType) code).asStringValue();
197          if (codeString == null || "".equals(codeString))
198            return null;
199        if ("draft".equals(codeString))
200          return new Enumeration<ReferralStatus>(this, ReferralStatus.DRAFT);
201        if ("requested".equals(codeString))
202          return new Enumeration<ReferralStatus>(this, ReferralStatus.REQUESTED);
203        if ("active".equals(codeString))
204          return new Enumeration<ReferralStatus>(this, ReferralStatus.ACTIVE);
205        if ("cancelled".equals(codeString))
206          return new Enumeration<ReferralStatus>(this, ReferralStatus.CANCELLED);
207        if ("accepted".equals(codeString))
208          return new Enumeration<ReferralStatus>(this, ReferralStatus.ACCEPTED);
209        if ("rejected".equals(codeString))
210          return new Enumeration<ReferralStatus>(this, ReferralStatus.REJECTED);
211        if ("completed".equals(codeString))
212          return new Enumeration<ReferralStatus>(this, ReferralStatus.COMPLETED);
213        throw new FHIRException("Unknown ReferralStatus code '"+codeString+"'");
214        }
215    public String toCode(ReferralStatus code) {
216      if (code == ReferralStatus.DRAFT)
217        return "draft";
218      if (code == ReferralStatus.REQUESTED)
219        return "requested";
220      if (code == ReferralStatus.ACTIVE)
221        return "active";
222      if (code == ReferralStatus.CANCELLED)
223        return "cancelled";
224      if (code == ReferralStatus.ACCEPTED)
225        return "accepted";
226      if (code == ReferralStatus.REJECTED)
227        return "rejected";
228      if (code == ReferralStatus.COMPLETED)
229        return "completed";
230      return "?";
231      }
232    }
233
234    /**
235     * The workflow status of the referral or transfer of care request.
236     */
237    @Child(name = "status", type = {CodeType.class}, order=0, min=1, max=1, modifier=true, summary=true)
238    @Description(shortDefinition="draft | requested | active | cancelled | accepted | rejected | completed", formalDefinition="The workflow status of the referral or transfer of care request." )
239    protected Enumeration<ReferralStatus> status;
240
241    /**
242     * Business identifier that uniquely identifies the referral/care transfer request instance.
243     */
244    @Child(name = "identifier", type = {Identifier.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
245    @Description(shortDefinition="Business identifier", formalDefinition="Business identifier that uniquely identifies the referral/care transfer request instance." )
246    protected List<Identifier> identifier;
247
248    /**
249     * Date/DateTime of creation for draft requests and date of activation for active requests.
250     */
251    @Child(name = "date", type = {DateTimeType.class}, order=2, min=0, max=1, modifier=false, summary=true)
252    @Description(shortDefinition="Date of creation/activation", formalDefinition="Date/DateTime of creation for draft requests and date of activation for active requests." )
253    protected DateTimeType date;
254
255    /**
256     * An indication of the type of referral (or where applicable the type of transfer of care) request.
257     */
258    @Child(name = "type", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
259    @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." )
260    protected CodeableConcept type;
261
262    /**
263     * Indication of the clinical domain or discipline to which the referral or transfer of care request is sent.  For example: Cardiology Gastroenterology Diabetology.
264     */
265    @Child(name = "specialty", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=false)
266    @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." )
267    protected CodeableConcept specialty;
268
269    /**
270     * An indication of the urgency of referral (or where applicable the type of transfer of care) request.
271     */
272    @Child(name = "priority", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=true)
273    @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." )
274    protected CodeableConcept priority;
275
276    /**
277     * The patient who is the subject of a referral or transfer of care request.
278     */
279    @Child(name = "patient", type = {Patient.class}, order=6, min=0, max=1, modifier=false, summary=true)
280    @Description(shortDefinition="Patient referred to care or transfer", formalDefinition="The patient who is the subject of a referral or transfer of care request." )
281    protected Reference patient;
282
283    /**
284     * The actual object that is the target of the reference (The patient who is the subject of a referral or transfer of care request.)
285     */
286    protected Patient patientTarget;
287
288    /**
289     * The healthcare provider or provider organization who/which initiated the referral/transfer of care request. Can also be  Patient (a self referral).
290     */
291    @Child(name = "requester", type = {Practitioner.class, Organization.class, Patient.class}, order=7, min=0, max=1, modifier=false, summary=true)
292    @Description(shortDefinition="Requester of referral / transfer of care", formalDefinition="The healthcare provider or provider organization who/which initiated the referral/transfer of care request. Can also be  Patient (a self referral)." )
293    protected Reference requester;
294
295    /**
296     * The actual object that is the target of the reference (The healthcare provider or provider organization who/which initiated the referral/transfer of care request. Can also be  Patient (a self referral).)
297     */
298    protected Resource requesterTarget;
299
300    /**
301     * The healthcare provider(s) or provider organization(s) who/which is to receive the referral/transfer of care request.
302     */
303    @Child(name = "recipient", type = {Practitioner.class, Organization.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
304    @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." )
305    protected List<Reference> recipient;
306    /**
307     * 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.)
308     */
309    protected List<Resource> recipientTarget;
310
311
312    /**
313     * The encounter at which the request for referral or transfer of care is initiated.
314     */
315    @Child(name = "encounter", type = {Encounter.class}, order=9, min=0, max=1, modifier=false, summary=false)
316    @Description(shortDefinition="Originating encounter", formalDefinition="The encounter at which the request for referral or transfer of care is initiated." )
317    protected Reference encounter;
318
319    /**
320     * The actual object that is the target of the reference (The encounter at which the request for referral or transfer of care is initiated.)
321     */
322    protected Encounter encounterTarget;
323
324    /**
325     * Date/DateTime the request for referral or transfer of care is sent by the author.
326     */
327    @Child(name = "dateSent", type = {DateTimeType.class}, order=10, min=0, max=1, modifier=false, summary=true)
328    @Description(shortDefinition="Date referral/transfer of care request is sent", formalDefinition="Date/DateTime the request for referral or transfer of care is sent by the author." )
329    protected DateTimeType dateSent;
330
331    /**
332     * Description of clinical condition indicating why referral/transfer of care is requested.  For example:  Pathological Anomalies, Disabled (physical or mental),  Behavioral Management.
333     */
334    @Child(name = "reason", type = {CodeableConcept.class}, order=11, min=0, max=1, modifier=false, summary=true)
335    @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." )
336    protected CodeableConcept reason;
337
338    /**
339     * 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.
340     */
341    @Child(name = "description", type = {StringType.class}, order=12, min=0, max=1, modifier=false, summary=false)
342    @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." )
343    protected StringType description;
344
345    /**
346     * The service(s) that is/are requested to be provided to the patient.  For example: cardiac pacemaker insertion.
347     */
348    @Child(name = "serviceRequested", type = {CodeableConcept.class}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
349    @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." )
350    protected List<CodeableConcept> serviceRequested;
351
352    /**
353     * 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.
354     */
355    @Child(name = "supportingInformation", type = {}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
356    @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." )
357    protected List<Reference> supportingInformation;
358    /**
359     * 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.)
360     */
361    protected List<Resource> supportingInformationTarget;
362
363
364    /**
365     * The period of time within which the services identified in the referral/transfer of care is specified or required to occur.
366     */
367    @Child(name = "fulfillmentTime", type = {Period.class}, order=15, min=0, max=1, modifier=false, summary=true)
368    @Description(shortDefinition="Requested service(s) fulfillment time", formalDefinition="The period of time within which the services identified in the referral/transfer of care is specified or required to occur." )
369    protected Period fulfillmentTime;
370
371    private static final long serialVersionUID = 1948652599L;
372
373  /*
374   * Constructor
375   */
376    public ReferralRequest() {
377      super();
378    }
379
380  /*
381   * Constructor
382   */
383    public ReferralRequest(Enumeration<ReferralStatus> status) {
384      super();
385      this.status = status;
386    }
387
388    /**
389     * @return {@link #status} (The workflow status of the referral or transfer of care request.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
390     */
391    public Enumeration<ReferralStatus> getStatusElement() { 
392      if (this.status == null)
393        if (Configuration.errorOnAutoCreate())
394          throw new Error("Attempt to auto-create ReferralRequest.status");
395        else if (Configuration.doAutoCreate())
396          this.status = new Enumeration<ReferralStatus>(new ReferralStatusEnumFactory()); // bb
397      return this.status;
398    }
399
400    public boolean hasStatusElement() { 
401      return this.status != null && !this.status.isEmpty();
402    }
403
404    public boolean hasStatus() { 
405      return this.status != null && !this.status.isEmpty();
406    }
407
408    /**
409     * @param value {@link #status} (The workflow status of the referral or transfer of care request.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
410     */
411    public ReferralRequest setStatusElement(Enumeration<ReferralStatus> value) { 
412      this.status = value;
413      return this;
414    }
415
416    /**
417     * @return The workflow status of the referral or transfer of care request.
418     */
419    public ReferralStatus getStatus() { 
420      return this.status == null ? null : this.status.getValue();
421    }
422
423    /**
424     * @param value The workflow status of the referral or transfer of care request.
425     */
426    public ReferralRequest setStatus(ReferralStatus value) { 
427        if (this.status == null)
428          this.status = new Enumeration<ReferralStatus>(new ReferralStatusEnumFactory());
429        this.status.setValue(value);
430      return this;
431    }
432
433    /**
434     * @return {@link #identifier} (Business identifier that uniquely identifies the referral/care transfer request instance.)
435     */
436    public List<Identifier> getIdentifier() { 
437      if (this.identifier == null)
438        this.identifier = new ArrayList<Identifier>();
439      return this.identifier;
440    }
441
442    public boolean hasIdentifier() { 
443      if (this.identifier == null)
444        return false;
445      for (Identifier item : this.identifier)
446        if (!item.isEmpty())
447          return true;
448      return false;
449    }
450
451    /**
452     * @return {@link #identifier} (Business identifier that uniquely identifies the referral/care transfer request instance.)
453     */
454    // syntactic sugar
455    public Identifier addIdentifier() { //3
456      Identifier t = new Identifier();
457      if (this.identifier == null)
458        this.identifier = new ArrayList<Identifier>();
459      this.identifier.add(t);
460      return t;
461    }
462
463    // syntactic sugar
464    public ReferralRequest addIdentifier(Identifier t) { //3
465      if (t == null)
466        return this;
467      if (this.identifier == null)
468        this.identifier = new ArrayList<Identifier>();
469      this.identifier.add(t);
470      return this;
471    }
472
473    /**
474     * @return {@link #date} (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 "getDate" gives direct access to the value
475     */
476    public DateTimeType getDateElement() { 
477      if (this.date == null)
478        if (Configuration.errorOnAutoCreate())
479          throw new Error("Attempt to auto-create ReferralRequest.date");
480        else if (Configuration.doAutoCreate())
481          this.date = new DateTimeType(); // bb
482      return this.date;
483    }
484
485    public boolean hasDateElement() { 
486      return this.date != null && !this.date.isEmpty();
487    }
488
489    public boolean hasDate() { 
490      return this.date != null && !this.date.isEmpty();
491    }
492
493    /**
494     * @param value {@link #date} (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 "getDate" gives direct access to the value
495     */
496    public ReferralRequest setDateElement(DateTimeType value) { 
497      this.date = value;
498      return this;
499    }
500
501    /**
502     * @return Date/DateTime of creation for draft requests and date of activation for active requests.
503     */
504    public Date getDate() { 
505      return this.date == null ? null : this.date.getValue();
506    }
507
508    /**
509     * @param value Date/DateTime of creation for draft requests and date of activation for active requests.
510     */
511    public ReferralRequest setDate(Date value) { 
512      if (value == null)
513        this.date = null;
514      else {
515        if (this.date == null)
516          this.date = new DateTimeType();
517        this.date.setValue(value);
518      }
519      return this;
520    }
521
522    /**
523     * @return {@link #type} (An indication of the type of referral (or where applicable the type of transfer of care) request.)
524     */
525    public CodeableConcept getType() { 
526      if (this.type == null)
527        if (Configuration.errorOnAutoCreate())
528          throw new Error("Attempt to auto-create ReferralRequest.type");
529        else if (Configuration.doAutoCreate())
530          this.type = new CodeableConcept(); // cc
531      return this.type;
532    }
533
534    public boolean hasType() { 
535      return this.type != null && !this.type.isEmpty();
536    }
537
538    /**
539     * @param value {@link #type} (An indication of the type of referral (or where applicable the type of transfer of care) request.)
540     */
541    public ReferralRequest setType(CodeableConcept value) { 
542      this.type = value;
543      return this;
544    }
545
546    /**
547     * @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.)
548     */
549    public CodeableConcept getSpecialty() { 
550      if (this.specialty == null)
551        if (Configuration.errorOnAutoCreate())
552          throw new Error("Attempt to auto-create ReferralRequest.specialty");
553        else if (Configuration.doAutoCreate())
554          this.specialty = new CodeableConcept(); // cc
555      return this.specialty;
556    }
557
558    public boolean hasSpecialty() { 
559      return this.specialty != null && !this.specialty.isEmpty();
560    }
561
562    /**
563     * @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.)
564     */
565    public ReferralRequest setSpecialty(CodeableConcept value) { 
566      this.specialty = value;
567      return this;
568    }
569
570    /**
571     * @return {@link #priority} (An indication of the urgency of referral (or where applicable the type of transfer of care) request.)
572     */
573    public CodeableConcept getPriority() { 
574      if (this.priority == null)
575        if (Configuration.errorOnAutoCreate())
576          throw new Error("Attempt to auto-create ReferralRequest.priority");
577        else if (Configuration.doAutoCreate())
578          this.priority = new CodeableConcept(); // cc
579      return this.priority;
580    }
581
582    public boolean hasPriority() { 
583      return this.priority != null && !this.priority.isEmpty();
584    }
585
586    /**
587     * @param value {@link #priority} (An indication of the urgency of referral (or where applicable the type of transfer of care) request.)
588     */
589    public ReferralRequest setPriority(CodeableConcept value) { 
590      this.priority = value;
591      return this;
592    }
593
594    /**
595     * @return {@link #patient} (The patient who is the subject of a referral or transfer of care request.)
596     */
597    public Reference getPatient() { 
598      if (this.patient == null)
599        if (Configuration.errorOnAutoCreate())
600          throw new Error("Attempt to auto-create ReferralRequest.patient");
601        else if (Configuration.doAutoCreate())
602          this.patient = new Reference(); // cc
603      return this.patient;
604    }
605
606    public boolean hasPatient() { 
607      return this.patient != null && !this.patient.isEmpty();
608    }
609
610    /**
611     * @param value {@link #patient} (The patient who is the subject of a referral or transfer of care request.)
612     */
613    public ReferralRequest setPatient(Reference value) { 
614      this.patient = value;
615      return this;
616    }
617
618    /**
619     * @return {@link #patient} 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.)
620     */
621    public Patient getPatientTarget() { 
622      if (this.patientTarget == null)
623        if (Configuration.errorOnAutoCreate())
624          throw new Error("Attempt to auto-create ReferralRequest.patient");
625        else if (Configuration.doAutoCreate())
626          this.patientTarget = new Patient(); // aa
627      return this.patientTarget;
628    }
629
630    /**
631     * @param value {@link #patient} 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.)
632     */
633    public ReferralRequest setPatientTarget(Patient value) { 
634      this.patientTarget = value;
635      return this;
636    }
637
638    /**
639     * @return {@link #requester} (The healthcare provider or provider organization who/which initiated the referral/transfer of care request. Can also be  Patient (a self referral).)
640     */
641    public Reference getRequester() { 
642      if (this.requester == null)
643        if (Configuration.errorOnAutoCreate())
644          throw new Error("Attempt to auto-create ReferralRequest.requester");
645        else if (Configuration.doAutoCreate())
646          this.requester = new Reference(); // cc
647      return this.requester;
648    }
649
650    public boolean hasRequester() { 
651      return this.requester != null && !this.requester.isEmpty();
652    }
653
654    /**
655     * @param value {@link #requester} (The healthcare provider or provider organization who/which initiated the referral/transfer of care request. Can also be  Patient (a self referral).)
656     */
657    public ReferralRequest setRequester(Reference value) { 
658      this.requester = value;
659      return this;
660    }
661
662    /**
663     * @return {@link #requester} 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 healthcare provider or provider organization who/which initiated the referral/transfer of care request. Can also be  Patient (a self referral).)
664     */
665    public Resource getRequesterTarget() { 
666      return this.requesterTarget;
667    }
668
669    /**
670     * @param value {@link #requester} 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 healthcare provider or provider organization who/which initiated the referral/transfer of care request. Can also be  Patient (a self referral).)
671     */
672    public ReferralRequest setRequesterTarget(Resource value) { 
673      this.requesterTarget = value;
674      return this;
675    }
676
677    /**
678     * @return {@link #recipient} (The healthcare provider(s) or provider organization(s) who/which is to receive the referral/transfer of care request.)
679     */
680    public List<Reference> getRecipient() { 
681      if (this.recipient == null)
682        this.recipient = new ArrayList<Reference>();
683      return this.recipient;
684    }
685
686    public boolean hasRecipient() { 
687      if (this.recipient == null)
688        return false;
689      for (Reference item : this.recipient)
690        if (!item.isEmpty())
691          return true;
692      return false;
693    }
694
695    /**
696     * @return {@link #recipient} (The healthcare provider(s) or provider organization(s) who/which is to receive the referral/transfer of care request.)
697     */
698    // syntactic sugar
699    public Reference addRecipient() { //3
700      Reference t = new Reference();
701      if (this.recipient == null)
702        this.recipient = new ArrayList<Reference>();
703      this.recipient.add(t);
704      return t;
705    }
706
707    // syntactic sugar
708    public ReferralRequest addRecipient(Reference t) { //3
709      if (t == null)
710        return this;
711      if (this.recipient == null)
712        this.recipient = new ArrayList<Reference>();
713      this.recipient.add(t);
714      return this;
715    }
716
717    /**
718     * @return {@link #recipient} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. The healthcare provider(s) or provider organization(s) who/which is to receive the referral/transfer of care request.)
719     */
720    public List<Resource> getRecipientTarget() { 
721      if (this.recipientTarget == null)
722        this.recipientTarget = new ArrayList<Resource>();
723      return this.recipientTarget;
724    }
725
726    /**
727     * @return {@link #encounter} (The encounter at which the request for referral or transfer of care is initiated.)
728     */
729    public Reference getEncounter() { 
730      if (this.encounter == null)
731        if (Configuration.errorOnAutoCreate())
732          throw new Error("Attempt to auto-create ReferralRequest.encounter");
733        else if (Configuration.doAutoCreate())
734          this.encounter = new Reference(); // cc
735      return this.encounter;
736    }
737
738    public boolean hasEncounter() { 
739      return this.encounter != null && !this.encounter.isEmpty();
740    }
741
742    /**
743     * @param value {@link #encounter} (The encounter at which the request for referral or transfer of care is initiated.)
744     */
745    public ReferralRequest setEncounter(Reference value) { 
746      this.encounter = value;
747      return this;
748    }
749
750    /**
751     * @return {@link #encounter} 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.)
752     */
753    public Encounter getEncounterTarget() { 
754      if (this.encounterTarget == null)
755        if (Configuration.errorOnAutoCreate())
756          throw new Error("Attempt to auto-create ReferralRequest.encounter");
757        else if (Configuration.doAutoCreate())
758          this.encounterTarget = new Encounter(); // aa
759      return this.encounterTarget;
760    }
761
762    /**
763     * @param value {@link #encounter} 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.)
764     */
765    public ReferralRequest setEncounterTarget(Encounter value) { 
766      this.encounterTarget = value;
767      return this;
768    }
769
770    /**
771     * @return {@link #dateSent} (Date/DateTime the request for referral or transfer of care is sent by the author.). This is the underlying object with id, value and extensions. The accessor "getDateSent" gives direct access to the value
772     */
773    public DateTimeType getDateSentElement() { 
774      if (this.dateSent == null)
775        if (Configuration.errorOnAutoCreate())
776          throw new Error("Attempt to auto-create ReferralRequest.dateSent");
777        else if (Configuration.doAutoCreate())
778          this.dateSent = new DateTimeType(); // bb
779      return this.dateSent;
780    }
781
782    public boolean hasDateSentElement() { 
783      return this.dateSent != null && !this.dateSent.isEmpty();
784    }
785
786    public boolean hasDateSent() { 
787      return this.dateSent != null && !this.dateSent.isEmpty();
788    }
789
790    /**
791     * @param value {@link #dateSent} (Date/DateTime the request for referral or transfer of care is sent by the author.). This is the underlying object with id, value and extensions. The accessor "getDateSent" gives direct access to the value
792     */
793    public ReferralRequest setDateSentElement(DateTimeType value) { 
794      this.dateSent = value;
795      return this;
796    }
797
798    /**
799     * @return Date/DateTime the request for referral or transfer of care is sent by the author.
800     */
801    public Date getDateSent() { 
802      return this.dateSent == null ? null : this.dateSent.getValue();
803    }
804
805    /**
806     * @param value Date/DateTime the request for referral or transfer of care is sent by the author.
807     */
808    public ReferralRequest setDateSent(Date value) { 
809      if (value == null)
810        this.dateSent = null;
811      else {
812        if (this.dateSent == null)
813          this.dateSent = new DateTimeType();
814        this.dateSent.setValue(value);
815      }
816      return this;
817    }
818
819    /**
820     * @return {@link #reason} (Description of clinical condition indicating why referral/transfer of care is requested.  For example:  Pathological Anomalies, Disabled (physical or mental),  Behavioral Management.)
821     */
822    public CodeableConcept getReason() { 
823      if (this.reason == null)
824        if (Configuration.errorOnAutoCreate())
825          throw new Error("Attempt to auto-create ReferralRequest.reason");
826        else if (Configuration.doAutoCreate())
827          this.reason = new CodeableConcept(); // cc
828      return this.reason;
829    }
830
831    public boolean hasReason() { 
832      return this.reason != null && !this.reason.isEmpty();
833    }
834
835    /**
836     * @param value {@link #reason} (Description of clinical condition indicating why referral/transfer of care is requested.  For example:  Pathological Anomalies, Disabled (physical or mental),  Behavioral Management.)
837     */
838    public ReferralRequest setReason(CodeableConcept value) { 
839      this.reason = value;
840      return this;
841    }
842
843    /**
844     * @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
845     */
846    public StringType getDescriptionElement() { 
847      if (this.description == null)
848        if (Configuration.errorOnAutoCreate())
849          throw new Error("Attempt to auto-create ReferralRequest.description");
850        else if (Configuration.doAutoCreate())
851          this.description = new StringType(); // bb
852      return this.description;
853    }
854
855    public boolean hasDescriptionElement() { 
856      return this.description != null && !this.description.isEmpty();
857    }
858
859    public boolean hasDescription() { 
860      return this.description != null && !this.description.isEmpty();
861    }
862
863    /**
864     * @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
865     */
866    public ReferralRequest setDescriptionElement(StringType value) { 
867      this.description = value;
868      return this;
869    }
870
871    /**
872     * @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.
873     */
874    public String getDescription() { 
875      return this.description == null ? null : this.description.getValue();
876    }
877
878    /**
879     * @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.
880     */
881    public ReferralRequest setDescription(String value) { 
882      if (Utilities.noString(value))
883        this.description = null;
884      else {
885        if (this.description == null)
886          this.description = new StringType();
887        this.description.setValue(value);
888      }
889      return this;
890    }
891
892    /**
893     * @return {@link #serviceRequested} (The service(s) that is/are requested to be provided to the patient.  For example: cardiac pacemaker insertion.)
894     */
895    public List<CodeableConcept> getServiceRequested() { 
896      if (this.serviceRequested == null)
897        this.serviceRequested = new ArrayList<CodeableConcept>();
898      return this.serviceRequested;
899    }
900
901    public boolean hasServiceRequested() { 
902      if (this.serviceRequested == null)
903        return false;
904      for (CodeableConcept item : this.serviceRequested)
905        if (!item.isEmpty())
906          return true;
907      return false;
908    }
909
910    /**
911     * @return {@link #serviceRequested} (The service(s) that is/are requested to be provided to the patient.  For example: cardiac pacemaker insertion.)
912     */
913    // syntactic sugar
914    public CodeableConcept addServiceRequested() { //3
915      CodeableConcept t = new CodeableConcept();
916      if (this.serviceRequested == null)
917        this.serviceRequested = new ArrayList<CodeableConcept>();
918      this.serviceRequested.add(t);
919      return t;
920    }
921
922    // syntactic sugar
923    public ReferralRequest addServiceRequested(CodeableConcept t) { //3
924      if (t == null)
925        return this;
926      if (this.serviceRequested == null)
927        this.serviceRequested = new ArrayList<CodeableConcept>();
928      this.serviceRequested.add(t);
929      return this;
930    }
931
932    /**
933     * @return {@link #supportingInformation} (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.)
934     */
935    public List<Reference> getSupportingInformation() { 
936      if (this.supportingInformation == null)
937        this.supportingInformation = new ArrayList<Reference>();
938      return this.supportingInformation;
939    }
940
941    public boolean hasSupportingInformation() { 
942      if (this.supportingInformation == null)
943        return false;
944      for (Reference item : this.supportingInformation)
945        if (!item.isEmpty())
946          return true;
947      return false;
948    }
949
950    /**
951     * @return {@link #supportingInformation} (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.)
952     */
953    // syntactic sugar
954    public Reference addSupportingInformation() { //3
955      Reference t = new Reference();
956      if (this.supportingInformation == null)
957        this.supportingInformation = new ArrayList<Reference>();
958      this.supportingInformation.add(t);
959      return t;
960    }
961
962    // syntactic sugar
963    public ReferralRequest addSupportingInformation(Reference t) { //3
964      if (t == null)
965        return this;
966      if (this.supportingInformation == null)
967        this.supportingInformation = new ArrayList<Reference>();
968      this.supportingInformation.add(t);
969      return this;
970    }
971
972    /**
973     * @return {@link #supportingInformation} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. 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.)
974     */
975    public List<Resource> getSupportingInformationTarget() { 
976      if (this.supportingInformationTarget == null)
977        this.supportingInformationTarget = new ArrayList<Resource>();
978      return this.supportingInformationTarget;
979    }
980
981    /**
982     * @return {@link #fulfillmentTime} (The period of time within which the services identified in the referral/transfer of care is specified or required to occur.)
983     */
984    public Period getFulfillmentTime() { 
985      if (this.fulfillmentTime == null)
986        if (Configuration.errorOnAutoCreate())
987          throw new Error("Attempt to auto-create ReferralRequest.fulfillmentTime");
988        else if (Configuration.doAutoCreate())
989          this.fulfillmentTime = new Period(); // cc
990      return this.fulfillmentTime;
991    }
992
993    public boolean hasFulfillmentTime() { 
994      return this.fulfillmentTime != null && !this.fulfillmentTime.isEmpty();
995    }
996
997    /**
998     * @param value {@link #fulfillmentTime} (The period of time within which the services identified in the referral/transfer of care is specified or required to occur.)
999     */
1000    public ReferralRequest setFulfillmentTime(Period value) { 
1001      this.fulfillmentTime = value;
1002      return this;
1003    }
1004
1005      protected void listChildren(List<Property> childrenList) {
1006        super.listChildren(childrenList);
1007        childrenList.add(new Property("status", "code", "The workflow status of the referral or transfer of care request.", 0, java.lang.Integer.MAX_VALUE, status));
1008        childrenList.add(new Property("identifier", "Identifier", "Business identifier that uniquely identifies the referral/care transfer request instance.", 0, java.lang.Integer.MAX_VALUE, identifier));
1009        childrenList.add(new Property("date", "dateTime", "Date/DateTime of creation for draft requests and date of activation for active requests.", 0, java.lang.Integer.MAX_VALUE, date));
1010        childrenList.add(new Property("type", "CodeableConcept", "An indication of the type of referral (or where applicable the type of transfer of care) request.", 0, java.lang.Integer.MAX_VALUE, type));
1011        childrenList.add(new Property("specialty", "CodeableConcept", "Indication of the clinical domain or discipline to which the referral or transfer of care request is sent.  For example: Cardiology Gastroenterology Diabetology.", 0, java.lang.Integer.MAX_VALUE, specialty));
1012        childrenList.add(new Property("priority", "CodeableConcept", "An indication of the urgency of referral (or where applicable the type of transfer of care) request.", 0, java.lang.Integer.MAX_VALUE, priority));
1013        childrenList.add(new Property("patient", "Reference(Patient)", "The patient who is the subject of a referral or transfer of care request.", 0, java.lang.Integer.MAX_VALUE, patient));
1014        childrenList.add(new Property("requester", "Reference(Practitioner|Organization|Patient)", "The healthcare provider or provider organization who/which initiated the referral/transfer of care request. Can also be  Patient (a self referral).", 0, java.lang.Integer.MAX_VALUE, requester));
1015        childrenList.add(new Property("recipient", "Reference(Practitioner|Organization)", "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));
1016        childrenList.add(new Property("encounter", "Reference(Encounter)", "The encounter at which the request for referral or transfer of care is initiated.", 0, java.lang.Integer.MAX_VALUE, encounter));
1017        childrenList.add(new Property("dateSent", "dateTime", "Date/DateTime the request for referral or transfer of care is sent by the author.", 0, java.lang.Integer.MAX_VALUE, dateSent));
1018        childrenList.add(new Property("reason", "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, reason));
1019        childrenList.add(new Property("description", "string", "The reason element gives a short description of why the referral is being made, the description expands on this to support a more complete clinical summary.", 0, java.lang.Integer.MAX_VALUE, description));
1020        childrenList.add(new Property("serviceRequested", "CodeableConcept", "The service(s) that is/are requested to be provided to the patient.  For example: cardiac pacemaker insertion.", 0, java.lang.Integer.MAX_VALUE, serviceRequested));
1021        childrenList.add(new Property("supportingInformation", "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, supportingInformation));
1022        childrenList.add(new Property("fulfillmentTime", "Period", "The period of time within which the services identified in the referral/transfer of care is specified or required to occur.", 0, java.lang.Integer.MAX_VALUE, fulfillmentTime));
1023      }
1024
1025      @Override
1026      public void setProperty(String name, Base value) throws FHIRException {
1027        if (name.equals("status"))
1028          this.status = new ReferralStatusEnumFactory().fromType(value); // Enumeration<ReferralStatus>
1029        else if (name.equals("identifier"))
1030          this.getIdentifier().add(castToIdentifier(value));
1031        else if (name.equals("date"))
1032          this.date = castToDateTime(value); // DateTimeType
1033        else if (name.equals("type"))
1034          this.type = castToCodeableConcept(value); // CodeableConcept
1035        else if (name.equals("specialty"))
1036          this.specialty = castToCodeableConcept(value); // CodeableConcept
1037        else if (name.equals("priority"))
1038          this.priority = castToCodeableConcept(value); // CodeableConcept
1039        else if (name.equals("patient"))
1040          this.patient = castToReference(value); // Reference
1041        else if (name.equals("requester"))
1042          this.requester = castToReference(value); // Reference
1043        else if (name.equals("recipient"))
1044          this.getRecipient().add(castToReference(value));
1045        else if (name.equals("encounter"))
1046          this.encounter = castToReference(value); // Reference
1047        else if (name.equals("dateSent"))
1048          this.dateSent = castToDateTime(value); // DateTimeType
1049        else if (name.equals("reason"))
1050          this.reason = castToCodeableConcept(value); // CodeableConcept
1051        else if (name.equals("description"))
1052          this.description = castToString(value); // StringType
1053        else if (name.equals("serviceRequested"))
1054          this.getServiceRequested().add(castToCodeableConcept(value));
1055        else if (name.equals("supportingInformation"))
1056          this.getSupportingInformation().add(castToReference(value));
1057        else if (name.equals("fulfillmentTime"))
1058          this.fulfillmentTime = castToPeriod(value); // Period
1059        else
1060          super.setProperty(name, value);
1061      }
1062
1063      @Override
1064      public Base addChild(String name) throws FHIRException {
1065        if (name.equals("status")) {
1066          throw new FHIRException("Cannot call addChild on a primitive type ReferralRequest.status");
1067        }
1068        else if (name.equals("identifier")) {
1069          return addIdentifier();
1070        }
1071        else if (name.equals("date")) {
1072          throw new FHIRException("Cannot call addChild on a primitive type ReferralRequest.date");
1073        }
1074        else if (name.equals("type")) {
1075          this.type = new CodeableConcept();
1076          return this.type;
1077        }
1078        else if (name.equals("specialty")) {
1079          this.specialty = new CodeableConcept();
1080          return this.specialty;
1081        }
1082        else if (name.equals("priority")) {
1083          this.priority = new CodeableConcept();
1084          return this.priority;
1085        }
1086        else if (name.equals("patient")) {
1087          this.patient = new Reference();
1088          return this.patient;
1089        }
1090        else if (name.equals("requester")) {
1091          this.requester = new Reference();
1092          return this.requester;
1093        }
1094        else if (name.equals("recipient")) {
1095          return addRecipient();
1096        }
1097        else if (name.equals("encounter")) {
1098          this.encounter = new Reference();
1099          return this.encounter;
1100        }
1101        else if (name.equals("dateSent")) {
1102          throw new FHIRException("Cannot call addChild on a primitive type ReferralRequest.dateSent");
1103        }
1104        else if (name.equals("reason")) {
1105          this.reason = new CodeableConcept();
1106          return this.reason;
1107        }
1108        else if (name.equals("description")) {
1109          throw new FHIRException("Cannot call addChild on a primitive type ReferralRequest.description");
1110        }
1111        else if (name.equals("serviceRequested")) {
1112          return addServiceRequested();
1113        }
1114        else if (name.equals("supportingInformation")) {
1115          return addSupportingInformation();
1116        }
1117        else if (name.equals("fulfillmentTime")) {
1118          this.fulfillmentTime = new Period();
1119          return this.fulfillmentTime;
1120        }
1121        else
1122          return super.addChild(name);
1123      }
1124
1125  public String fhirType() {
1126    return "ReferralRequest";
1127
1128  }
1129
1130      public ReferralRequest copy() {
1131        ReferralRequest dst = new ReferralRequest();
1132        copyValues(dst);
1133        dst.status = status == null ? null : status.copy();
1134        if (identifier != null) {
1135          dst.identifier = new ArrayList<Identifier>();
1136          for (Identifier i : identifier)
1137            dst.identifier.add(i.copy());
1138        };
1139        dst.date = date == null ? null : date.copy();
1140        dst.type = type == null ? null : type.copy();
1141        dst.specialty = specialty == null ? null : specialty.copy();
1142        dst.priority = priority == null ? null : priority.copy();
1143        dst.patient = patient == null ? null : patient.copy();
1144        dst.requester = requester == null ? null : requester.copy();
1145        if (recipient != null) {
1146          dst.recipient = new ArrayList<Reference>();
1147          for (Reference i : recipient)
1148            dst.recipient.add(i.copy());
1149        };
1150        dst.encounter = encounter == null ? null : encounter.copy();
1151        dst.dateSent = dateSent == null ? null : dateSent.copy();
1152        dst.reason = reason == null ? null : reason.copy();
1153        dst.description = description == null ? null : description.copy();
1154        if (serviceRequested != null) {
1155          dst.serviceRequested = new ArrayList<CodeableConcept>();
1156          for (CodeableConcept i : serviceRequested)
1157            dst.serviceRequested.add(i.copy());
1158        };
1159        if (supportingInformation != null) {
1160          dst.supportingInformation = new ArrayList<Reference>();
1161          for (Reference i : supportingInformation)
1162            dst.supportingInformation.add(i.copy());
1163        };
1164        dst.fulfillmentTime = fulfillmentTime == null ? null : fulfillmentTime.copy();
1165        return dst;
1166      }
1167
1168      protected ReferralRequest typedCopy() {
1169        return copy();
1170      }
1171
1172      @Override
1173      public boolean equalsDeep(Base other) {
1174        if (!super.equalsDeep(other))
1175          return false;
1176        if (!(other instanceof ReferralRequest))
1177          return false;
1178        ReferralRequest o = (ReferralRequest) other;
1179        return compareDeep(status, o.status, true) && compareDeep(identifier, o.identifier, true) && compareDeep(date, o.date, true)
1180           && compareDeep(type, o.type, true) && compareDeep(specialty, o.specialty, true) && compareDeep(priority, o.priority, true)
1181           && compareDeep(patient, o.patient, true) && compareDeep(requester, o.requester, true) && compareDeep(recipient, o.recipient, true)
1182           && compareDeep(encounter, o.encounter, true) && compareDeep(dateSent, o.dateSent, true) && compareDeep(reason, o.reason, true)
1183           && compareDeep(description, o.description, true) && compareDeep(serviceRequested, o.serviceRequested, true)
1184           && compareDeep(supportingInformation, o.supportingInformation, true) && compareDeep(fulfillmentTime, o.fulfillmentTime, true)
1185          ;
1186      }
1187
1188      @Override
1189      public boolean equalsShallow(Base other) {
1190        if (!super.equalsShallow(other))
1191          return false;
1192        if (!(other instanceof ReferralRequest))
1193          return false;
1194        ReferralRequest o = (ReferralRequest) other;
1195        return compareValues(status, o.status, true) && compareValues(date, o.date, true) && compareValues(dateSent, o.dateSent, true)
1196           && compareValues(description, o.description, true);
1197      }
1198
1199      public boolean isEmpty() {
1200        return super.isEmpty() && (status == null || status.isEmpty()) && (identifier == null || identifier.isEmpty())
1201           && (date == null || date.isEmpty()) && (type == null || type.isEmpty()) && (specialty == null || specialty.isEmpty())
1202           && (priority == null || priority.isEmpty()) && (patient == null || patient.isEmpty()) && (requester == null || requester.isEmpty())
1203           && (recipient == null || recipient.isEmpty()) && (encounter == null || encounter.isEmpty())
1204           && (dateSent == null || dateSent.isEmpty()) && (reason == null || reason.isEmpty()) && (description == null || description.isEmpty())
1205           && (serviceRequested == null || serviceRequested.isEmpty()) && (supportingInformation == null || supportingInformation.isEmpty())
1206           && (fulfillmentTime == null || fulfillmentTime.isEmpty());
1207      }
1208
1209  @Override
1210  public ResourceType getResourceType() {
1211    return ResourceType.ReferralRequest;
1212   }
1213
1214  @SearchParamDefinition(name="date", path="ReferralRequest.date", description="Creation or activation date", type="date" )
1215  public static final String SP_DATE = "date";
1216  @SearchParamDefinition(name="requester", path="ReferralRequest.requester", description="Requester of referral / transfer of care", type="reference" )
1217  public static final String SP_REQUESTER = "requester";
1218  @SearchParamDefinition(name="specialty", path="ReferralRequest.specialty", description="The specialty that the referral is for", type="token" )
1219  public static final String SP_SPECIALTY = "specialty";
1220  @SearchParamDefinition(name="patient", path="ReferralRequest.patient", description="Who the referral is about", type="reference" )
1221  public static final String SP_PATIENT = "patient";
1222  @SearchParamDefinition(name="recipient", path="ReferralRequest.recipient", description="The person that the referral was sent to", type="reference" )
1223  public static final String SP_RECIPIENT = "recipient";
1224  @SearchParamDefinition(name="type", path="ReferralRequest.type", description="The type of the referral", type="token" )
1225  public static final String SP_TYPE = "type";
1226  @SearchParamDefinition(name="priority", path="ReferralRequest.priority", description="The priority assigned to the referral", type="token" )
1227  public static final String SP_PRIORITY = "priority";
1228  @SearchParamDefinition(name="status", path="ReferralRequest.status", description="The status of the referral", type="token" )
1229  public static final String SP_STATUS = "status";
1230
1231}
1232