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