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