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