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.instance.model.api.IBaseBackboneElement;
037
038import ca.uhn.fhir.model.api.annotation.*;
039/**
040 * A request to convey information; e.g. the CDS system proposes that an alert be sent to a responsible provider, the CDS system proposes that the public health agency be notified about a reportable condition.
041 */
042@ResourceDef(name="CommunicationRequest", profile="http://hl7.org/fhir/Profile/CommunicationRequest")
043public class CommunicationRequest extends DomainResource {
044
045    public enum CommunicationRequestStatus {
046        /**
047         * The request has been proposed.
048         */
049        PROPOSED, 
050        /**
051         * The request has been planned.
052         */
053        PLANNED, 
054        /**
055         * The request has been placed.
056         */
057        REQUESTED, 
058        /**
059         * The receiving system has received the request but not yet decided whether it will be performed.
060         */
061        RECEIVED, 
062        /**
063         * The receiving system has accepted the order, but work has not yet commenced.
064         */
065        ACCEPTED, 
066        /**
067         * The work to fulfill the order is happening.
068         */
069        INPROGRESS, 
070        /**
071         * The work has been complete, the report(s) released, and no further work is planned.
072         */
073        COMPLETED, 
074        /**
075         * The request has been held by originating system/user request.
076         */
077        SUSPENDED, 
078        /**
079         * The receiving system has declined to fulfill the request
080         */
081        REJECTED, 
082        /**
083         * The communication was attempted, but due to some procedural error, it could not be completed.
084         */
085        FAILED, 
086        /**
087         * added to help the parsers
088         */
089        NULL;
090        public static CommunicationRequestStatus fromCode(String codeString) throws FHIRException {
091            if (codeString == null || "".equals(codeString))
092                return null;
093        if ("proposed".equals(codeString))
094          return PROPOSED;
095        if ("planned".equals(codeString))
096          return PLANNED;
097        if ("requested".equals(codeString))
098          return REQUESTED;
099        if ("received".equals(codeString))
100          return RECEIVED;
101        if ("accepted".equals(codeString))
102          return ACCEPTED;
103        if ("in-progress".equals(codeString))
104          return INPROGRESS;
105        if ("completed".equals(codeString))
106          return COMPLETED;
107        if ("suspended".equals(codeString))
108          return SUSPENDED;
109        if ("rejected".equals(codeString))
110          return REJECTED;
111        if ("failed".equals(codeString))
112          return FAILED;
113        throw new FHIRException("Unknown CommunicationRequestStatus code '"+codeString+"'");
114        }
115        public String toCode() {
116          switch (this) {
117            case PROPOSED: return "proposed";
118            case PLANNED: return "planned";
119            case REQUESTED: return "requested";
120            case RECEIVED: return "received";
121            case ACCEPTED: return "accepted";
122            case INPROGRESS: return "in-progress";
123            case COMPLETED: return "completed";
124            case SUSPENDED: return "suspended";
125            case REJECTED: return "rejected";
126            case FAILED: return "failed";
127            default: return "?";
128          }
129        }
130        public String getSystem() {
131          switch (this) {
132            case PROPOSED: return "http://hl7.org/fhir/communication-request-status";
133            case PLANNED: return "http://hl7.org/fhir/communication-request-status";
134            case REQUESTED: return "http://hl7.org/fhir/communication-request-status";
135            case RECEIVED: return "http://hl7.org/fhir/communication-request-status";
136            case ACCEPTED: return "http://hl7.org/fhir/communication-request-status";
137            case INPROGRESS: return "http://hl7.org/fhir/communication-request-status";
138            case COMPLETED: return "http://hl7.org/fhir/communication-request-status";
139            case SUSPENDED: return "http://hl7.org/fhir/communication-request-status";
140            case REJECTED: return "http://hl7.org/fhir/communication-request-status";
141            case FAILED: return "http://hl7.org/fhir/communication-request-status";
142            default: return "?";
143          }
144        }
145        public String getDefinition() {
146          switch (this) {
147            case PROPOSED: return "The request has been proposed.";
148            case PLANNED: return "The request has been planned.";
149            case REQUESTED: return "The request has been placed.";
150            case RECEIVED: return "The receiving system has received the request but not yet decided whether it will be performed.";
151            case ACCEPTED: return "The receiving system has accepted the order, but work has not yet commenced.";
152            case INPROGRESS: return "The work to fulfill the order is happening.";
153            case COMPLETED: return "The work has been complete, the report(s) released, and no further work is planned.";
154            case SUSPENDED: return "The request has been held by originating system/user request.";
155            case REJECTED: return "The receiving system has declined to fulfill the request";
156            case FAILED: return "The communication was attempted, but due to some procedural error, it could not be completed.";
157            default: return "?";
158          }
159        }
160        public String getDisplay() {
161          switch (this) {
162            case PROPOSED: return "Proposed";
163            case PLANNED: return "Planned";
164            case REQUESTED: return "Requested";
165            case RECEIVED: return "Received";
166            case ACCEPTED: return "Accepted";
167            case INPROGRESS: return "In Progress";
168            case COMPLETED: return "Completed";
169            case SUSPENDED: return "Suspended";
170            case REJECTED: return "Rejected";
171            case FAILED: return "Failed";
172            default: return "?";
173          }
174        }
175    }
176
177  public static class CommunicationRequestStatusEnumFactory implements EnumFactory<CommunicationRequestStatus> {
178    public CommunicationRequestStatus fromCode(String codeString) throws IllegalArgumentException {
179      if (codeString == null || "".equals(codeString))
180            if (codeString == null || "".equals(codeString))
181                return null;
182        if ("proposed".equals(codeString))
183          return CommunicationRequestStatus.PROPOSED;
184        if ("planned".equals(codeString))
185          return CommunicationRequestStatus.PLANNED;
186        if ("requested".equals(codeString))
187          return CommunicationRequestStatus.REQUESTED;
188        if ("received".equals(codeString))
189          return CommunicationRequestStatus.RECEIVED;
190        if ("accepted".equals(codeString))
191          return CommunicationRequestStatus.ACCEPTED;
192        if ("in-progress".equals(codeString))
193          return CommunicationRequestStatus.INPROGRESS;
194        if ("completed".equals(codeString))
195          return CommunicationRequestStatus.COMPLETED;
196        if ("suspended".equals(codeString))
197          return CommunicationRequestStatus.SUSPENDED;
198        if ("rejected".equals(codeString))
199          return CommunicationRequestStatus.REJECTED;
200        if ("failed".equals(codeString))
201          return CommunicationRequestStatus.FAILED;
202        throw new IllegalArgumentException("Unknown CommunicationRequestStatus code '"+codeString+"'");
203        }
204        public Enumeration<CommunicationRequestStatus> fromType(Base code) throws FHIRException {
205          if (code == null || code.isEmpty())
206            return null;
207          String codeString = ((PrimitiveType) code).asStringValue();
208          if (codeString == null || "".equals(codeString))
209            return null;
210        if ("proposed".equals(codeString))
211          return new Enumeration<CommunicationRequestStatus>(this, CommunicationRequestStatus.PROPOSED);
212        if ("planned".equals(codeString))
213          return new Enumeration<CommunicationRequestStatus>(this, CommunicationRequestStatus.PLANNED);
214        if ("requested".equals(codeString))
215          return new Enumeration<CommunicationRequestStatus>(this, CommunicationRequestStatus.REQUESTED);
216        if ("received".equals(codeString))
217          return new Enumeration<CommunicationRequestStatus>(this, CommunicationRequestStatus.RECEIVED);
218        if ("accepted".equals(codeString))
219          return new Enumeration<CommunicationRequestStatus>(this, CommunicationRequestStatus.ACCEPTED);
220        if ("in-progress".equals(codeString))
221          return new Enumeration<CommunicationRequestStatus>(this, CommunicationRequestStatus.INPROGRESS);
222        if ("completed".equals(codeString))
223          return new Enumeration<CommunicationRequestStatus>(this, CommunicationRequestStatus.COMPLETED);
224        if ("suspended".equals(codeString))
225          return new Enumeration<CommunicationRequestStatus>(this, CommunicationRequestStatus.SUSPENDED);
226        if ("rejected".equals(codeString))
227          return new Enumeration<CommunicationRequestStatus>(this, CommunicationRequestStatus.REJECTED);
228        if ("failed".equals(codeString))
229          return new Enumeration<CommunicationRequestStatus>(this, CommunicationRequestStatus.FAILED);
230        throw new FHIRException("Unknown CommunicationRequestStatus code '"+codeString+"'");
231        }
232    public String toCode(CommunicationRequestStatus code) {
233      if (code == CommunicationRequestStatus.PROPOSED)
234        return "proposed";
235      if (code == CommunicationRequestStatus.PLANNED)
236        return "planned";
237      if (code == CommunicationRequestStatus.REQUESTED)
238        return "requested";
239      if (code == CommunicationRequestStatus.RECEIVED)
240        return "received";
241      if (code == CommunicationRequestStatus.ACCEPTED)
242        return "accepted";
243      if (code == CommunicationRequestStatus.INPROGRESS)
244        return "in-progress";
245      if (code == CommunicationRequestStatus.COMPLETED)
246        return "completed";
247      if (code == CommunicationRequestStatus.SUSPENDED)
248        return "suspended";
249      if (code == CommunicationRequestStatus.REJECTED)
250        return "rejected";
251      if (code == CommunicationRequestStatus.FAILED)
252        return "failed";
253      return "?";
254      }
255    }
256
257    @Block()
258    public static class CommunicationRequestPayloadComponent extends BackboneElement implements IBaseBackboneElement {
259        /**
260         * The communicated content (or for multi-part communications, one portion of the communication).
261         */
262        @Child(name = "content", type = {StringType.class, Attachment.class}, order=1, min=1, max=1, modifier=false, summary=true)
263        @Description(shortDefinition="Message part content", formalDefinition="The communicated content (or for multi-part communications, one portion of the communication)." )
264        protected Type content;
265
266        private static final long serialVersionUID = -1763459053L;
267
268    /*
269     * Constructor
270     */
271      public CommunicationRequestPayloadComponent() {
272        super();
273      }
274
275    /*
276     * Constructor
277     */
278      public CommunicationRequestPayloadComponent(Type content) {
279        super();
280        this.content = content;
281      }
282
283        /**
284         * @return {@link #content} (The communicated content (or for multi-part communications, one portion of the communication).)
285         */
286        public Type getContent() { 
287          return this.content;
288        }
289
290        /**
291         * @return {@link #content} (The communicated content (or for multi-part communications, one portion of the communication).)
292         */
293        public StringType getContentStringType() throws FHIRException { 
294          if (!(this.content instanceof StringType))
295            throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.content.getClass().getName()+" was encountered");
296          return (StringType) this.content;
297        }
298
299        public boolean hasContentStringType() { 
300          return this.content instanceof StringType;
301        }
302
303        /**
304         * @return {@link #content} (The communicated content (or for multi-part communications, one portion of the communication).)
305         */
306        public Attachment getContentAttachment() throws FHIRException { 
307          if (!(this.content instanceof Attachment))
308            throw new FHIRException("Type mismatch: the type Attachment was expected, but "+this.content.getClass().getName()+" was encountered");
309          return (Attachment) this.content;
310        }
311
312        public boolean hasContentAttachment() { 
313          return this.content instanceof Attachment;
314        }
315
316        /**
317         * @return {@link #content} (The communicated content (or for multi-part communications, one portion of the communication).)
318         */
319        public Reference getContentReference() throws FHIRException { 
320          if (!(this.content instanceof Reference))
321            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.content.getClass().getName()+" was encountered");
322          return (Reference) this.content;
323        }
324
325        public boolean hasContentReference() { 
326          return this.content instanceof Reference;
327        }
328
329        public boolean hasContent() { 
330          return this.content != null && !this.content.isEmpty();
331        }
332
333        /**
334         * @param value {@link #content} (The communicated content (or for multi-part communications, one portion of the communication).)
335         */
336        public CommunicationRequestPayloadComponent setContent(Type value) { 
337          this.content = value;
338          return this;
339        }
340
341        protected void listChildren(List<Property> childrenList) {
342          super.listChildren(childrenList);
343          childrenList.add(new Property("content[x]", "string|Attachment|Reference(Any)", "The communicated content (or for multi-part communications, one portion of the communication).", 0, java.lang.Integer.MAX_VALUE, content));
344        }
345
346      @Override
347      public void setProperty(String name, Base value) throws FHIRException {
348        if (name.equals("content[x]"))
349          this.content = (Type) value; // Type
350        else
351          super.setProperty(name, value);
352      }
353
354      @Override
355      public Base addChild(String name) throws FHIRException {
356        if (name.equals("contentString")) {
357          this.content = new StringType();
358          return this.content;
359        }
360        else if (name.equals("contentAttachment")) {
361          this.content = new Attachment();
362          return this.content;
363        }
364        else if (name.equals("contentReference")) {
365          this.content = new Reference();
366          return this.content;
367        }
368        else
369          return super.addChild(name);
370      }
371
372      public CommunicationRequestPayloadComponent copy() {
373        CommunicationRequestPayloadComponent dst = new CommunicationRequestPayloadComponent();
374        copyValues(dst);
375        dst.content = content == null ? null : content.copy();
376        return dst;
377      }
378
379      @Override
380      public boolean equalsDeep(Base other) {
381        if (!super.equalsDeep(other))
382          return false;
383        if (!(other instanceof CommunicationRequestPayloadComponent))
384          return false;
385        CommunicationRequestPayloadComponent o = (CommunicationRequestPayloadComponent) other;
386        return compareDeep(content, o.content, true);
387      }
388
389      @Override
390      public boolean equalsShallow(Base other) {
391        if (!super.equalsShallow(other))
392          return false;
393        if (!(other instanceof CommunicationRequestPayloadComponent))
394          return false;
395        CommunicationRequestPayloadComponent o = (CommunicationRequestPayloadComponent) other;
396        return true;
397      }
398
399      public boolean isEmpty() {
400        return super.isEmpty() && (content == null || content.isEmpty());
401      }
402
403  public String fhirType() {
404    return "CommunicationRequest.payload";
405
406  }
407
408  }
409
410    /**
411     * A unique ID of this request for reference purposes. It must be provided if user wants it returned as part of any output, otherwise it will be autogenerated, if needed, by CDS system. Does not need to be the actual ID of the source system.
412     */
413    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
414    @Description(shortDefinition="Unique identifier", formalDefinition="A unique ID of this request for reference purposes. It must be provided if user wants it returned as part of any output, otherwise it will be autogenerated, if needed, by CDS system. Does not need to be the actual ID of the source system." )
415    protected List<Identifier> identifier;
416
417    /**
418     * The type of message to be sent such as alert, notification, reminder, instruction, etc.
419     */
420    @Child(name = "category", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
421    @Description(shortDefinition="Message category", formalDefinition="The type of message to be sent such as alert, notification, reminder, instruction, etc." )
422    protected CodeableConcept category;
423
424    /**
425     * The entity (e.g. person, organization, clinical information system, or device) which is to be the source of the communication.
426     */
427    @Child(name = "sender", type = {Device.class, Organization.class, Patient.class, Practitioner.class, RelatedPerson.class}, order=2, min=0, max=1, modifier=false, summary=true)
428    @Description(shortDefinition="Message sender", formalDefinition="The entity (e.g. person, organization, clinical information system, or device) which is to be the source of the communication." )
429    protected Reference sender;
430
431    /**
432     * The actual object that is the target of the reference (The entity (e.g. person, organization, clinical information system, or device) which is to be the source of the communication.)
433     */
434    protected Resource senderTarget;
435
436    /**
437     * The entity (e.g. person, organization, clinical information system, or device) which is the intended target of the communication.
438     */
439    @Child(name = "recipient", type = {Device.class, Organization.class, Patient.class, Practitioner.class, RelatedPerson.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
440    @Description(shortDefinition="Message recipient", formalDefinition="The entity (e.g. person, organization, clinical information system, or device) which is the intended target of the communication." )
441    protected List<Reference> recipient;
442    /**
443     * The actual objects that are the target of the reference (The entity (e.g. person, organization, clinical information system, or device) which is the intended target of the communication.)
444     */
445    protected List<Resource> recipientTarget;
446
447
448    /**
449     * Text, attachment(s), or resource(s) to be communicated to the recipient.
450     */
451    @Child(name = "payload", type = {}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
452    @Description(shortDefinition="Message payload", formalDefinition="Text, attachment(s), or resource(s) to be communicated to the recipient." )
453    protected List<CommunicationRequestPayloadComponent> payload;
454
455    /**
456     * A channel that was used for this communication (e.g. email, fax).
457     */
458    @Child(name = "medium", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
459    @Description(shortDefinition="A channel of communication", formalDefinition="A channel that was used for this communication (e.g. email, fax)." )
460    protected List<CodeableConcept> medium;
461
462    /**
463     * The responsible person who authorizes this order, e.g. physician. This may be different than the author of the order statement, e.g. clerk, who may have entered the statement into the order entry application.
464     */
465    @Child(name = "requester", type = {Practitioner.class, Patient.class, RelatedPerson.class}, order=6, min=0, max=1, modifier=false, summary=true)
466    @Description(shortDefinition="An individual who requested a communication", formalDefinition="The responsible person who authorizes this order, e.g. physician. This may be different than the author of the order statement, e.g. clerk, who may have entered the statement into the order entry application." )
467    protected Reference requester;
468
469    /**
470     * The actual object that is the target of the reference (The responsible person who authorizes this order, e.g. physician. This may be different than the author of the order statement, e.g. clerk, who may have entered the statement into the order entry application.)
471     */
472    protected Resource requesterTarget;
473
474    /**
475     * The status of the proposal or order.
476     */
477    @Child(name = "status", type = {CodeType.class}, order=7, min=0, max=1, modifier=true, summary=true)
478    @Description(shortDefinition="proposed | planned | requested | received | accepted | in-progress | completed | suspended | rejected | failed", formalDefinition="The status of the proposal or order." )
479    protected Enumeration<CommunicationRequestStatus> status;
480
481    /**
482     * The encounter within which the communication request was created.
483     */
484    @Child(name = "encounter", type = {Encounter.class}, order=8, min=0, max=1, modifier=false, summary=true)
485    @Description(shortDefinition="Encounter leading to message", formalDefinition="The encounter within which the communication request was created." )
486    protected Reference encounter;
487
488    /**
489     * The actual object that is the target of the reference (The encounter within which the communication request was created.)
490     */
491    protected Encounter encounterTarget;
492
493    /**
494     * The time when this communication is to occur.
495     */
496    @Child(name = "scheduled", type = {DateTimeType.class, Period.class}, order=9, min=0, max=1, modifier=false, summary=true)
497    @Description(shortDefinition="When scheduled", formalDefinition="The time when this communication is to occur." )
498    protected Type scheduled;
499
500    /**
501     * The reason or justification for the communication request.
502     */
503    @Child(name = "reason", type = {CodeableConcept.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
504    @Description(shortDefinition="Indication for message", formalDefinition="The reason or justification for the communication request." )
505    protected List<CodeableConcept> reason;
506
507    /**
508     * The time when the request was made.
509     */
510    @Child(name = "requestedOn", type = {DateTimeType.class}, order=11, min=0, max=1, modifier=false, summary=true)
511    @Description(shortDefinition="When ordered or proposed", formalDefinition="The time when the request was made." )
512    protected DateTimeType requestedOn;
513
514    /**
515     * The patient who is the focus of this communication request.
516     */
517    @Child(name = "subject", type = {Patient.class}, order=12, min=0, max=1, modifier=false, summary=true)
518    @Description(shortDefinition="Focus of message", formalDefinition="The patient who is the focus of this communication request." )
519    protected Reference subject;
520
521    /**
522     * The actual object that is the target of the reference (The patient who is the focus of this communication request.)
523     */
524    protected Patient subjectTarget;
525
526    /**
527     * Characterizes how quickly the proposed act must be initiated. Includes concepts such as stat, urgent, routine.
528     */
529    @Child(name = "priority", type = {CodeableConcept.class}, order=13, min=0, max=1, modifier=false, summary=true)
530    @Description(shortDefinition="Message urgency", formalDefinition="Characterizes how quickly the proposed act must be initiated. Includes concepts such as stat, urgent, routine." )
531    protected CodeableConcept priority;
532
533    private static final long serialVersionUID = 146906020L;
534
535  /*
536   * Constructor
537   */
538    public CommunicationRequest() {
539      super();
540    }
541
542    /**
543     * @return {@link #identifier} (A unique ID of this request for reference purposes. It must be provided if user wants it returned as part of any output, otherwise it will be autogenerated, if needed, by CDS system. Does not need to be the actual ID of the source system.)
544     */
545    public List<Identifier> getIdentifier() { 
546      if (this.identifier == null)
547        this.identifier = new ArrayList<Identifier>();
548      return this.identifier;
549    }
550
551    public boolean hasIdentifier() { 
552      if (this.identifier == null)
553        return false;
554      for (Identifier item : this.identifier)
555        if (!item.isEmpty())
556          return true;
557      return false;
558    }
559
560    /**
561     * @return {@link #identifier} (A unique ID of this request for reference purposes. It must be provided if user wants it returned as part of any output, otherwise it will be autogenerated, if needed, by CDS system. Does not need to be the actual ID of the source system.)
562     */
563    // syntactic sugar
564    public Identifier addIdentifier() { //3
565      Identifier t = new Identifier();
566      if (this.identifier == null)
567        this.identifier = new ArrayList<Identifier>();
568      this.identifier.add(t);
569      return t;
570    }
571
572    // syntactic sugar
573    public CommunicationRequest addIdentifier(Identifier t) { //3
574      if (t == null)
575        return this;
576      if (this.identifier == null)
577        this.identifier = new ArrayList<Identifier>();
578      this.identifier.add(t);
579      return this;
580    }
581
582    /**
583     * @return {@link #category} (The type of message to be sent such as alert, notification, reminder, instruction, etc.)
584     */
585    public CodeableConcept getCategory() { 
586      if (this.category == null)
587        if (Configuration.errorOnAutoCreate())
588          throw new Error("Attempt to auto-create CommunicationRequest.category");
589        else if (Configuration.doAutoCreate())
590          this.category = new CodeableConcept(); // cc
591      return this.category;
592    }
593
594    public boolean hasCategory() { 
595      return this.category != null && !this.category.isEmpty();
596    }
597
598    /**
599     * @param value {@link #category} (The type of message to be sent such as alert, notification, reminder, instruction, etc.)
600     */
601    public CommunicationRequest setCategory(CodeableConcept value) { 
602      this.category = value;
603      return this;
604    }
605
606    /**
607     * @return {@link #sender} (The entity (e.g. person, organization, clinical information system, or device) which is to be the source of the communication.)
608     */
609    public Reference getSender() { 
610      if (this.sender == null)
611        if (Configuration.errorOnAutoCreate())
612          throw new Error("Attempt to auto-create CommunicationRequest.sender");
613        else if (Configuration.doAutoCreate())
614          this.sender = new Reference(); // cc
615      return this.sender;
616    }
617
618    public boolean hasSender() { 
619      return this.sender != null && !this.sender.isEmpty();
620    }
621
622    /**
623     * @param value {@link #sender} (The entity (e.g. person, organization, clinical information system, or device) which is to be the source of the communication.)
624     */
625    public CommunicationRequest setSender(Reference value) { 
626      this.sender = value;
627      return this;
628    }
629
630    /**
631     * @return {@link #sender} 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 entity (e.g. person, organization, clinical information system, or device) which is to be the source of the communication.)
632     */
633    public Resource getSenderTarget() { 
634      return this.senderTarget;
635    }
636
637    /**
638     * @param value {@link #sender} 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 entity (e.g. person, organization, clinical information system, or device) which is to be the source of the communication.)
639     */
640    public CommunicationRequest setSenderTarget(Resource value) { 
641      this.senderTarget = value;
642      return this;
643    }
644
645    /**
646     * @return {@link #recipient} (The entity (e.g. person, organization, clinical information system, or device) which is the intended target of the communication.)
647     */
648    public List<Reference> getRecipient() { 
649      if (this.recipient == null)
650        this.recipient = new ArrayList<Reference>();
651      return this.recipient;
652    }
653
654    public boolean hasRecipient() { 
655      if (this.recipient == null)
656        return false;
657      for (Reference item : this.recipient)
658        if (!item.isEmpty())
659          return true;
660      return false;
661    }
662
663    /**
664     * @return {@link #recipient} (The entity (e.g. person, organization, clinical information system, or device) which is the intended target of the communication.)
665     */
666    // syntactic sugar
667    public Reference addRecipient() { //3
668      Reference t = new Reference();
669      if (this.recipient == null)
670        this.recipient = new ArrayList<Reference>();
671      this.recipient.add(t);
672      return t;
673    }
674
675    // syntactic sugar
676    public CommunicationRequest addRecipient(Reference t) { //3
677      if (t == null)
678        return this;
679      if (this.recipient == null)
680        this.recipient = new ArrayList<Reference>();
681      this.recipient.add(t);
682      return this;
683    }
684
685    /**
686     * @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 entity (e.g. person, organization, clinical information system, or device) which is the intended target of the communication.)
687     */
688    public List<Resource> getRecipientTarget() { 
689      if (this.recipientTarget == null)
690        this.recipientTarget = new ArrayList<Resource>();
691      return this.recipientTarget;
692    }
693
694    /**
695     * @return {@link #payload} (Text, attachment(s), or resource(s) to be communicated to the recipient.)
696     */
697    public List<CommunicationRequestPayloadComponent> getPayload() { 
698      if (this.payload == null)
699        this.payload = new ArrayList<CommunicationRequestPayloadComponent>();
700      return this.payload;
701    }
702
703    public boolean hasPayload() { 
704      if (this.payload == null)
705        return false;
706      for (CommunicationRequestPayloadComponent item : this.payload)
707        if (!item.isEmpty())
708          return true;
709      return false;
710    }
711
712    /**
713     * @return {@link #payload} (Text, attachment(s), or resource(s) to be communicated to the recipient.)
714     */
715    // syntactic sugar
716    public CommunicationRequestPayloadComponent addPayload() { //3
717      CommunicationRequestPayloadComponent t = new CommunicationRequestPayloadComponent();
718      if (this.payload == null)
719        this.payload = new ArrayList<CommunicationRequestPayloadComponent>();
720      this.payload.add(t);
721      return t;
722    }
723
724    // syntactic sugar
725    public CommunicationRequest addPayload(CommunicationRequestPayloadComponent t) { //3
726      if (t == null)
727        return this;
728      if (this.payload == null)
729        this.payload = new ArrayList<CommunicationRequestPayloadComponent>();
730      this.payload.add(t);
731      return this;
732    }
733
734    /**
735     * @return {@link #medium} (A channel that was used for this communication (e.g. email, fax).)
736     */
737    public List<CodeableConcept> getMedium() { 
738      if (this.medium == null)
739        this.medium = new ArrayList<CodeableConcept>();
740      return this.medium;
741    }
742
743    public boolean hasMedium() { 
744      if (this.medium == null)
745        return false;
746      for (CodeableConcept item : this.medium)
747        if (!item.isEmpty())
748          return true;
749      return false;
750    }
751
752    /**
753     * @return {@link #medium} (A channel that was used for this communication (e.g. email, fax).)
754     */
755    // syntactic sugar
756    public CodeableConcept addMedium() { //3
757      CodeableConcept t = new CodeableConcept();
758      if (this.medium == null)
759        this.medium = new ArrayList<CodeableConcept>();
760      this.medium.add(t);
761      return t;
762    }
763
764    // syntactic sugar
765    public CommunicationRequest addMedium(CodeableConcept t) { //3
766      if (t == null)
767        return this;
768      if (this.medium == null)
769        this.medium = new ArrayList<CodeableConcept>();
770      this.medium.add(t);
771      return this;
772    }
773
774    /**
775     * @return {@link #requester} (The responsible person who authorizes this order, e.g. physician. This may be different than the author of the order statement, e.g. clerk, who may have entered the statement into the order entry application.)
776     */
777    public Reference getRequester() { 
778      if (this.requester == null)
779        if (Configuration.errorOnAutoCreate())
780          throw new Error("Attempt to auto-create CommunicationRequest.requester");
781        else if (Configuration.doAutoCreate())
782          this.requester = new Reference(); // cc
783      return this.requester;
784    }
785
786    public boolean hasRequester() { 
787      return this.requester != null && !this.requester.isEmpty();
788    }
789
790    /**
791     * @param value {@link #requester} (The responsible person who authorizes this order, e.g. physician. This may be different than the author of the order statement, e.g. clerk, who may have entered the statement into the order entry application.)
792     */
793    public CommunicationRequest setRequester(Reference value) { 
794      this.requester = value;
795      return this;
796    }
797
798    /**
799     * @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 responsible person who authorizes this order, e.g. physician. This may be different than the author of the order statement, e.g. clerk, who may have entered the statement into the order entry application.)
800     */
801    public Resource getRequesterTarget() { 
802      return this.requesterTarget;
803    }
804
805    /**
806     * @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 responsible person who authorizes this order, e.g. physician. This may be different than the author of the order statement, e.g. clerk, who may have entered the statement into the order entry application.)
807     */
808    public CommunicationRequest setRequesterTarget(Resource value) { 
809      this.requesterTarget = value;
810      return this;
811    }
812
813    /**
814     * @return {@link #status} (The status of the proposal or order.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
815     */
816    public Enumeration<CommunicationRequestStatus> getStatusElement() { 
817      if (this.status == null)
818        if (Configuration.errorOnAutoCreate())
819          throw new Error("Attempt to auto-create CommunicationRequest.status");
820        else if (Configuration.doAutoCreate())
821          this.status = new Enumeration<CommunicationRequestStatus>(new CommunicationRequestStatusEnumFactory()); // bb
822      return this.status;
823    }
824
825    public boolean hasStatusElement() { 
826      return this.status != null && !this.status.isEmpty();
827    }
828
829    public boolean hasStatus() { 
830      return this.status != null && !this.status.isEmpty();
831    }
832
833    /**
834     * @param value {@link #status} (The status of the proposal or order.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
835     */
836    public CommunicationRequest setStatusElement(Enumeration<CommunicationRequestStatus> value) { 
837      this.status = value;
838      return this;
839    }
840
841    /**
842     * @return The status of the proposal or order.
843     */
844    public CommunicationRequestStatus getStatus() { 
845      return this.status == null ? null : this.status.getValue();
846    }
847
848    /**
849     * @param value The status of the proposal or order.
850     */
851    public CommunicationRequest setStatus(CommunicationRequestStatus value) { 
852      if (value == null)
853        this.status = null;
854      else {
855        if (this.status == null)
856          this.status = new Enumeration<CommunicationRequestStatus>(new CommunicationRequestStatusEnumFactory());
857        this.status.setValue(value);
858      }
859      return this;
860    }
861
862    /**
863     * @return {@link #encounter} (The encounter within which the communication request was created.)
864     */
865    public Reference getEncounter() { 
866      if (this.encounter == null)
867        if (Configuration.errorOnAutoCreate())
868          throw new Error("Attempt to auto-create CommunicationRequest.encounter");
869        else if (Configuration.doAutoCreate())
870          this.encounter = new Reference(); // cc
871      return this.encounter;
872    }
873
874    public boolean hasEncounter() { 
875      return this.encounter != null && !this.encounter.isEmpty();
876    }
877
878    /**
879     * @param value {@link #encounter} (The encounter within which the communication request was created.)
880     */
881    public CommunicationRequest setEncounter(Reference value) { 
882      this.encounter = value;
883      return this;
884    }
885
886    /**
887     * @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 within which the communication request was created.)
888     */
889    public Encounter getEncounterTarget() { 
890      if (this.encounterTarget == null)
891        if (Configuration.errorOnAutoCreate())
892          throw new Error("Attempt to auto-create CommunicationRequest.encounter");
893        else if (Configuration.doAutoCreate())
894          this.encounterTarget = new Encounter(); // aa
895      return this.encounterTarget;
896    }
897
898    /**
899     * @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 within which the communication request was created.)
900     */
901    public CommunicationRequest setEncounterTarget(Encounter value) { 
902      this.encounterTarget = value;
903      return this;
904    }
905
906    /**
907     * @return {@link #scheduled} (The time when this communication is to occur.)
908     */
909    public Type getScheduled() { 
910      return this.scheduled;
911    }
912
913    /**
914     * @return {@link #scheduled} (The time when this communication is to occur.)
915     */
916    public DateTimeType getScheduledDateTimeType() throws FHIRException { 
917      if (!(this.scheduled instanceof DateTimeType))
918        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.scheduled.getClass().getName()+" was encountered");
919      return (DateTimeType) this.scheduled;
920    }
921
922    public boolean hasScheduledDateTimeType() { 
923      return this.scheduled instanceof DateTimeType;
924    }
925
926    /**
927     * @return {@link #scheduled} (The time when this communication is to occur.)
928     */
929    public Period getScheduledPeriod() throws FHIRException { 
930      if (!(this.scheduled instanceof Period))
931        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.scheduled.getClass().getName()+" was encountered");
932      return (Period) this.scheduled;
933    }
934
935    public boolean hasScheduledPeriod() { 
936      return this.scheduled instanceof Period;
937    }
938
939    public boolean hasScheduled() { 
940      return this.scheduled != null && !this.scheduled.isEmpty();
941    }
942
943    /**
944     * @param value {@link #scheduled} (The time when this communication is to occur.)
945     */
946    public CommunicationRequest setScheduled(Type value) { 
947      this.scheduled = value;
948      return this;
949    }
950
951    /**
952     * @return {@link #reason} (The reason or justification for the communication request.)
953     */
954    public List<CodeableConcept> getReason() { 
955      if (this.reason == null)
956        this.reason = new ArrayList<CodeableConcept>();
957      return this.reason;
958    }
959
960    public boolean hasReason() { 
961      if (this.reason == null)
962        return false;
963      for (CodeableConcept item : this.reason)
964        if (!item.isEmpty())
965          return true;
966      return false;
967    }
968
969    /**
970     * @return {@link #reason} (The reason or justification for the communication request.)
971     */
972    // syntactic sugar
973    public CodeableConcept addReason() { //3
974      CodeableConcept t = new CodeableConcept();
975      if (this.reason == null)
976        this.reason = new ArrayList<CodeableConcept>();
977      this.reason.add(t);
978      return t;
979    }
980
981    // syntactic sugar
982    public CommunicationRequest addReason(CodeableConcept t) { //3
983      if (t == null)
984        return this;
985      if (this.reason == null)
986        this.reason = new ArrayList<CodeableConcept>();
987      this.reason.add(t);
988      return this;
989    }
990
991    /**
992     * @return {@link #requestedOn} (The time when the request was made.). This is the underlying object with id, value and extensions. The accessor "getRequestedOn" gives direct access to the value
993     */
994    public DateTimeType getRequestedOnElement() { 
995      if (this.requestedOn == null)
996        if (Configuration.errorOnAutoCreate())
997          throw new Error("Attempt to auto-create CommunicationRequest.requestedOn");
998        else if (Configuration.doAutoCreate())
999          this.requestedOn = new DateTimeType(); // bb
1000      return this.requestedOn;
1001    }
1002
1003    public boolean hasRequestedOnElement() { 
1004      return this.requestedOn != null && !this.requestedOn.isEmpty();
1005    }
1006
1007    public boolean hasRequestedOn() { 
1008      return this.requestedOn != null && !this.requestedOn.isEmpty();
1009    }
1010
1011    /**
1012     * @param value {@link #requestedOn} (The time when the request was made.). This is the underlying object with id, value and extensions. The accessor "getRequestedOn" gives direct access to the value
1013     */
1014    public CommunicationRequest setRequestedOnElement(DateTimeType value) { 
1015      this.requestedOn = value;
1016      return this;
1017    }
1018
1019    /**
1020     * @return The time when the request was made.
1021     */
1022    public Date getRequestedOn() { 
1023      return this.requestedOn == null ? null : this.requestedOn.getValue();
1024    }
1025
1026    /**
1027     * @param value The time when the request was made.
1028     */
1029    public CommunicationRequest setRequestedOn(Date value) { 
1030      if (value == null)
1031        this.requestedOn = null;
1032      else {
1033        if (this.requestedOn == null)
1034          this.requestedOn = new DateTimeType();
1035        this.requestedOn.setValue(value);
1036      }
1037      return this;
1038    }
1039
1040    /**
1041     * @return {@link #subject} (The patient who is the focus of this communication request.)
1042     */
1043    public Reference getSubject() { 
1044      if (this.subject == null)
1045        if (Configuration.errorOnAutoCreate())
1046          throw new Error("Attempt to auto-create CommunicationRequest.subject");
1047        else if (Configuration.doAutoCreate())
1048          this.subject = new Reference(); // cc
1049      return this.subject;
1050    }
1051
1052    public boolean hasSubject() { 
1053      return this.subject != null && !this.subject.isEmpty();
1054    }
1055
1056    /**
1057     * @param value {@link #subject} (The patient who is the focus of this communication request.)
1058     */
1059    public CommunicationRequest setSubject(Reference value) { 
1060      this.subject = value;
1061      return this;
1062    }
1063
1064    /**
1065     * @return {@link #subject} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The patient who is the focus of this communication request.)
1066     */
1067    public Patient getSubjectTarget() { 
1068      if (this.subjectTarget == null)
1069        if (Configuration.errorOnAutoCreate())
1070          throw new Error("Attempt to auto-create CommunicationRequest.subject");
1071        else if (Configuration.doAutoCreate())
1072          this.subjectTarget = new Patient(); // aa
1073      return this.subjectTarget;
1074    }
1075
1076    /**
1077     * @param value {@link #subject} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The patient who is the focus of this communication request.)
1078     */
1079    public CommunicationRequest setSubjectTarget(Patient value) { 
1080      this.subjectTarget = value;
1081      return this;
1082    }
1083
1084    /**
1085     * @return {@link #priority} (Characterizes how quickly the proposed act must be initiated. Includes concepts such as stat, urgent, routine.)
1086     */
1087    public CodeableConcept getPriority() { 
1088      if (this.priority == null)
1089        if (Configuration.errorOnAutoCreate())
1090          throw new Error("Attempt to auto-create CommunicationRequest.priority");
1091        else if (Configuration.doAutoCreate())
1092          this.priority = new CodeableConcept(); // cc
1093      return this.priority;
1094    }
1095
1096    public boolean hasPriority() { 
1097      return this.priority != null && !this.priority.isEmpty();
1098    }
1099
1100    /**
1101     * @param value {@link #priority} (Characterizes how quickly the proposed act must be initiated. Includes concepts such as stat, urgent, routine.)
1102     */
1103    public CommunicationRequest setPriority(CodeableConcept value) { 
1104      this.priority = value;
1105      return this;
1106    }
1107
1108      protected void listChildren(List<Property> childrenList) {
1109        super.listChildren(childrenList);
1110        childrenList.add(new Property("identifier", "Identifier", "A unique ID of this request for reference purposes. It must be provided if user wants it returned as part of any output, otherwise it will be autogenerated, if needed, by CDS system. Does not need to be the actual ID of the source system.", 0, java.lang.Integer.MAX_VALUE, identifier));
1111        childrenList.add(new Property("category", "CodeableConcept", "The type of message to be sent such as alert, notification, reminder, instruction, etc.", 0, java.lang.Integer.MAX_VALUE, category));
1112        childrenList.add(new Property("sender", "Reference(Device|Organization|Patient|Practitioner|RelatedPerson)", "The entity (e.g. person, organization, clinical information system, or device) which is to be the source of the communication.", 0, java.lang.Integer.MAX_VALUE, sender));
1113        childrenList.add(new Property("recipient", "Reference(Device|Organization|Patient|Practitioner|RelatedPerson)", "The entity (e.g. person, organization, clinical information system, or device) which is the intended target of the communication.", 0, java.lang.Integer.MAX_VALUE, recipient));
1114        childrenList.add(new Property("payload", "", "Text, attachment(s), or resource(s) to be communicated to the recipient.", 0, java.lang.Integer.MAX_VALUE, payload));
1115        childrenList.add(new Property("medium", "CodeableConcept", "A channel that was used for this communication (e.g. email, fax).", 0, java.lang.Integer.MAX_VALUE, medium));
1116        childrenList.add(new Property("requester", "Reference(Practitioner|Patient|RelatedPerson)", "The responsible person who authorizes this order, e.g. physician. This may be different than the author of the order statement, e.g. clerk, who may have entered the statement into the order entry application.", 0, java.lang.Integer.MAX_VALUE, requester));
1117        childrenList.add(new Property("status", "code", "The status of the proposal or order.", 0, java.lang.Integer.MAX_VALUE, status));
1118        childrenList.add(new Property("encounter", "Reference(Encounter)", "The encounter within which the communication request was created.", 0, java.lang.Integer.MAX_VALUE, encounter));
1119        childrenList.add(new Property("scheduled[x]", "dateTime|Period", "The time when this communication is to occur.", 0, java.lang.Integer.MAX_VALUE, scheduled));
1120        childrenList.add(new Property("reason", "CodeableConcept", "The reason or justification for the communication request.", 0, java.lang.Integer.MAX_VALUE, reason));
1121        childrenList.add(new Property("requestedOn", "dateTime", "The time when the request was made.", 0, java.lang.Integer.MAX_VALUE, requestedOn));
1122        childrenList.add(new Property("subject", "Reference(Patient)", "The patient who is the focus of this communication request.", 0, java.lang.Integer.MAX_VALUE, subject));
1123        childrenList.add(new Property("priority", "CodeableConcept", "Characterizes how quickly the proposed act must be initiated. Includes concepts such as stat, urgent, routine.", 0, java.lang.Integer.MAX_VALUE, priority));
1124      }
1125
1126      @Override
1127      public void setProperty(String name, Base value) throws FHIRException {
1128        if (name.equals("identifier"))
1129          this.getIdentifier().add(castToIdentifier(value));
1130        else if (name.equals("category"))
1131          this.category = castToCodeableConcept(value); // CodeableConcept
1132        else if (name.equals("sender"))
1133          this.sender = castToReference(value); // Reference
1134        else if (name.equals("recipient"))
1135          this.getRecipient().add(castToReference(value));
1136        else if (name.equals("payload"))
1137          this.getPayload().add((CommunicationRequestPayloadComponent) value);
1138        else if (name.equals("medium"))
1139          this.getMedium().add(castToCodeableConcept(value));
1140        else if (name.equals("requester"))
1141          this.requester = castToReference(value); // Reference
1142        else if (name.equals("status"))
1143          this.status = new CommunicationRequestStatusEnumFactory().fromType(value); // Enumeration<CommunicationRequestStatus>
1144        else if (name.equals("encounter"))
1145          this.encounter = castToReference(value); // Reference
1146        else if (name.equals("scheduled[x]"))
1147          this.scheduled = (Type) value; // Type
1148        else if (name.equals("reason"))
1149          this.getReason().add(castToCodeableConcept(value));
1150        else if (name.equals("requestedOn"))
1151          this.requestedOn = castToDateTime(value); // DateTimeType
1152        else if (name.equals("subject"))
1153          this.subject = castToReference(value); // Reference
1154        else if (name.equals("priority"))
1155          this.priority = castToCodeableConcept(value); // CodeableConcept
1156        else
1157          super.setProperty(name, value);
1158      }
1159
1160      @Override
1161      public Base addChild(String name) throws FHIRException {
1162        if (name.equals("identifier")) {
1163          return addIdentifier();
1164        }
1165        else if (name.equals("category")) {
1166          this.category = new CodeableConcept();
1167          return this.category;
1168        }
1169        else if (name.equals("sender")) {
1170          this.sender = new Reference();
1171          return this.sender;
1172        }
1173        else if (name.equals("recipient")) {
1174          return addRecipient();
1175        }
1176        else if (name.equals("payload")) {
1177          return addPayload();
1178        }
1179        else if (name.equals("medium")) {
1180          return addMedium();
1181        }
1182        else if (name.equals("requester")) {
1183          this.requester = new Reference();
1184          return this.requester;
1185        }
1186        else if (name.equals("status")) {
1187          throw new FHIRException("Cannot call addChild on a primitive type CommunicationRequest.status");
1188        }
1189        else if (name.equals("encounter")) {
1190          this.encounter = new Reference();
1191          return this.encounter;
1192        }
1193        else if (name.equals("scheduledDateTime")) {
1194          this.scheduled = new DateTimeType();
1195          return this.scheduled;
1196        }
1197        else if (name.equals("scheduledPeriod")) {
1198          this.scheduled = new Period();
1199          return this.scheduled;
1200        }
1201        else if (name.equals("reason")) {
1202          return addReason();
1203        }
1204        else if (name.equals("requestedOn")) {
1205          throw new FHIRException("Cannot call addChild on a primitive type CommunicationRequest.requestedOn");
1206        }
1207        else if (name.equals("subject")) {
1208          this.subject = new Reference();
1209          return this.subject;
1210        }
1211        else if (name.equals("priority")) {
1212          this.priority = new CodeableConcept();
1213          return this.priority;
1214        }
1215        else
1216          return super.addChild(name);
1217      }
1218
1219  public String fhirType() {
1220    return "CommunicationRequest";
1221
1222  }
1223
1224      public CommunicationRequest copy() {
1225        CommunicationRequest dst = new CommunicationRequest();
1226        copyValues(dst);
1227        if (identifier != null) {
1228          dst.identifier = new ArrayList<Identifier>();
1229          for (Identifier i : identifier)
1230            dst.identifier.add(i.copy());
1231        };
1232        dst.category = category == null ? null : category.copy();
1233        dst.sender = sender == null ? null : sender.copy();
1234        if (recipient != null) {
1235          dst.recipient = new ArrayList<Reference>();
1236          for (Reference i : recipient)
1237            dst.recipient.add(i.copy());
1238        };
1239        if (payload != null) {
1240          dst.payload = new ArrayList<CommunicationRequestPayloadComponent>();
1241          for (CommunicationRequestPayloadComponent i : payload)
1242            dst.payload.add(i.copy());
1243        };
1244        if (medium != null) {
1245          dst.medium = new ArrayList<CodeableConcept>();
1246          for (CodeableConcept i : medium)
1247            dst.medium.add(i.copy());
1248        };
1249        dst.requester = requester == null ? null : requester.copy();
1250        dst.status = status == null ? null : status.copy();
1251        dst.encounter = encounter == null ? null : encounter.copy();
1252        dst.scheduled = scheduled == null ? null : scheduled.copy();
1253        if (reason != null) {
1254          dst.reason = new ArrayList<CodeableConcept>();
1255          for (CodeableConcept i : reason)
1256            dst.reason.add(i.copy());
1257        };
1258        dst.requestedOn = requestedOn == null ? null : requestedOn.copy();
1259        dst.subject = subject == null ? null : subject.copy();
1260        dst.priority = priority == null ? null : priority.copy();
1261        return dst;
1262      }
1263
1264      protected CommunicationRequest typedCopy() {
1265        return copy();
1266      }
1267
1268      @Override
1269      public boolean equalsDeep(Base other) {
1270        if (!super.equalsDeep(other))
1271          return false;
1272        if (!(other instanceof CommunicationRequest))
1273          return false;
1274        CommunicationRequest o = (CommunicationRequest) other;
1275        return compareDeep(identifier, o.identifier, true) && compareDeep(category, o.category, true) && compareDeep(sender, o.sender, true)
1276           && compareDeep(recipient, o.recipient, true) && compareDeep(payload, o.payload, true) && compareDeep(medium, o.medium, true)
1277           && compareDeep(requester, o.requester, true) && compareDeep(status, o.status, true) && compareDeep(encounter, o.encounter, true)
1278           && compareDeep(scheduled, o.scheduled, true) && compareDeep(reason, o.reason, true) && compareDeep(requestedOn, o.requestedOn, true)
1279           && compareDeep(subject, o.subject, true) && compareDeep(priority, o.priority, true);
1280      }
1281
1282      @Override
1283      public boolean equalsShallow(Base other) {
1284        if (!super.equalsShallow(other))
1285          return false;
1286        if (!(other instanceof CommunicationRequest))
1287          return false;
1288        CommunicationRequest o = (CommunicationRequest) other;
1289        return compareValues(status, o.status, true) && compareValues(requestedOn, o.requestedOn, true);
1290      }
1291
1292      public boolean isEmpty() {
1293        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (category == null || category.isEmpty())
1294           && (sender == null || sender.isEmpty()) && (recipient == null || recipient.isEmpty()) && (payload == null || payload.isEmpty())
1295           && (medium == null || medium.isEmpty()) && (requester == null || requester.isEmpty()) && (status == null || status.isEmpty())
1296           && (encounter == null || encounter.isEmpty()) && (scheduled == null || scheduled.isEmpty())
1297           && (reason == null || reason.isEmpty()) && (requestedOn == null || requestedOn.isEmpty())
1298           && (subject == null || subject.isEmpty()) && (priority == null || priority.isEmpty());
1299      }
1300
1301  @Override
1302  public ResourceType getResourceType() {
1303    return ResourceType.CommunicationRequest;
1304   }
1305
1306  @SearchParamDefinition(name="requester", path="CommunicationRequest.requester", description="An individual who requested a communication", type="reference" )
1307  public static final String SP_REQUESTER = "requester";
1308  @SearchParamDefinition(name="identifier", path="CommunicationRequest.identifier", description="Unique identifier", type="token" )
1309  public static final String SP_IDENTIFIER = "identifier";
1310  @SearchParamDefinition(name="subject", path="CommunicationRequest.subject", description="Focus of message", type="reference" )
1311  public static final String SP_SUBJECT = "subject";
1312  @SearchParamDefinition(name="medium", path="CommunicationRequest.medium", description="A channel of communication", type="token" )
1313  public static final String SP_MEDIUM = "medium";
1314  @SearchParamDefinition(name="encounter", path="CommunicationRequest.encounter", description="Encounter leading to message", type="reference" )
1315  public static final String SP_ENCOUNTER = "encounter";
1316  @SearchParamDefinition(name="priority", path="CommunicationRequest.priority", description="Message urgency", type="token" )
1317  public static final String SP_PRIORITY = "priority";
1318  @SearchParamDefinition(name="requested", path="CommunicationRequest.requestedOn", description="When ordered or proposed", type="date" )
1319  public static final String SP_REQUESTED = "requested";
1320  @SearchParamDefinition(name="sender", path="CommunicationRequest.sender", description="Message sender", type="reference" )
1321  public static final String SP_SENDER = "sender";
1322  @SearchParamDefinition(name="patient", path="CommunicationRequest.subject", description="Focus of message", type="reference" )
1323  public static final String SP_PATIENT = "patient";
1324  @SearchParamDefinition(name="recipient", path="CommunicationRequest.recipient", description="Message recipient", type="reference" )
1325  public static final String SP_RECIPIENT = "recipient";
1326  @SearchParamDefinition(name="time", path="CommunicationRequest.scheduledDateTime", description="When scheduled", type="date" )
1327  public static final String SP_TIME = "time";
1328  @SearchParamDefinition(name="category", path="CommunicationRequest.category", description="Message category", type="token" )
1329  public static final String SP_CATEGORY = "category";
1330  @SearchParamDefinition(name="status", path="CommunicationRequest.status", description="proposed | planned | requested | received | accepted | in-progress | completed | suspended | rejected | failed", type="token" )
1331  public static final String SP_STATUS = "status";
1332
1333}
1334