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