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