001package org.hl7.fhir.r4.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Thu, Dec 27, 2018 10:06-0500 for FHIR v4.0.0
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import ca.uhn.fhir.model.api.annotation.ResourceDef;
038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.Block;
043import org.hl7.fhir.instance.model.api.*;
044import org.hl7.fhir.exceptions.FHIRException;
045/**
046 * 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.
047 */
048@ResourceDef(name="CommunicationRequest", profile="http://hl7.org/fhir/StructureDefinition/CommunicationRequest")
049public class CommunicationRequest extends DomainResource {
050
051    public enum CommunicationRequestStatus {
052        /**
053         * The request has been created but is not yet complete or ready for action.
054         */
055        DRAFT, 
056        /**
057         * The request is in force and ready to be acted upon.
058         */
059        ACTIVE, 
060        /**
061         * The request (and any implicit authorization to act) has been temporarily withdrawn but is expected to resume in the future.
062         */
063        ONHOLD, 
064        /**
065         * The request (and any implicit authorization to act) has been terminated prior to the known full completion of the intended actions.  No further activity should occur.
066         */
067        REVOKED, 
068        /**
069         * The activity described by the request has been fully performed.  No further activity will occur.
070         */
071        COMPLETED, 
072        /**
073         * This request should never have existed and should be considered 'void'.  (It is possible that real-world decisions were based on it.  If real-world activity has occurred, the status should be "cancelled" rather than "entered-in-error".).
074         */
075        ENTEREDINERROR, 
076        /**
077         * The authoring/source system does not know which of the status values currently applies for this request.  Note: This concept is not to be used for "other" - one of the listed statuses is presumed to apply,  but the authoring/source system does not know which.
078         */
079        UNKNOWN, 
080        /**
081         * added to help the parsers with the generic types
082         */
083        NULL;
084        public static CommunicationRequestStatus fromCode(String codeString) throws FHIRException {
085            if (codeString == null || "".equals(codeString))
086                return null;
087        if ("draft".equals(codeString))
088          return DRAFT;
089        if ("active".equals(codeString))
090          return ACTIVE;
091        if ("on-hold".equals(codeString))
092          return ONHOLD;
093        if ("revoked".equals(codeString))
094          return REVOKED;
095        if ("completed".equals(codeString))
096          return COMPLETED;
097        if ("entered-in-error".equals(codeString))
098          return ENTEREDINERROR;
099        if ("unknown".equals(codeString))
100          return UNKNOWN;
101        if (Configuration.isAcceptInvalidEnums())
102          return null;
103        else
104          throw new FHIRException("Unknown CommunicationRequestStatus code '"+codeString+"'");
105        }
106        public String toCode() {
107          switch (this) {
108            case DRAFT: return "draft";
109            case ACTIVE: return "active";
110            case ONHOLD: return "on-hold";
111            case REVOKED: return "revoked";
112            case COMPLETED: return "completed";
113            case ENTEREDINERROR: return "entered-in-error";
114            case UNKNOWN: return "unknown";
115            default: return "?";
116          }
117        }
118        public String getSystem() {
119          switch (this) {
120            case DRAFT: return "http://hl7.org/fhir/request-status";
121            case ACTIVE: return "http://hl7.org/fhir/request-status";
122            case ONHOLD: return "http://hl7.org/fhir/request-status";
123            case REVOKED: return "http://hl7.org/fhir/request-status";
124            case COMPLETED: return "http://hl7.org/fhir/request-status";
125            case ENTEREDINERROR: return "http://hl7.org/fhir/request-status";
126            case UNKNOWN: return "http://hl7.org/fhir/request-status";
127            default: return "?";
128          }
129        }
130        public String getDefinition() {
131          switch (this) {
132            case DRAFT: return "The request has been created but is not yet complete or ready for action.";
133            case ACTIVE: return "The request is in force and ready to be acted upon.";
134            case ONHOLD: return "The request (and any implicit authorization to act) has been temporarily withdrawn but is expected to resume in the future.";
135            case REVOKED: return "The request (and any implicit authorization to act) has been terminated prior to the known full completion of the intended actions.  No further activity should occur.";
136            case COMPLETED: return "The activity described by the request has been fully performed.  No further activity will occur.";
137            case ENTEREDINERROR: return "This request should never have existed and should be considered 'void'.  (It is possible that real-world decisions were based on it.  If real-world activity has occurred, the status should be \"cancelled\" rather than \"entered-in-error\".).";
138            case UNKNOWN: return "The authoring/source system does not know which of the status values currently applies for this request.  Note: This concept is not to be used for \"other\" - one of the listed statuses is presumed to apply,  but the authoring/source system does not know which.";
139            default: return "?";
140          }
141        }
142        public String getDisplay() {
143          switch (this) {
144            case DRAFT: return "Draft";
145            case ACTIVE: return "Active";
146            case ONHOLD: return "On Hold";
147            case REVOKED: return "Revoked";
148            case COMPLETED: return "Completed";
149            case ENTEREDINERROR: return "Entered in Error";
150            case UNKNOWN: return "Unknown";
151            default: return "?";
152          }
153        }
154    }
155
156  public static class CommunicationRequestStatusEnumFactory implements EnumFactory<CommunicationRequestStatus> {
157    public CommunicationRequestStatus fromCode(String codeString) throws IllegalArgumentException {
158      if (codeString == null || "".equals(codeString))
159            if (codeString == null || "".equals(codeString))
160                return null;
161        if ("draft".equals(codeString))
162          return CommunicationRequestStatus.DRAFT;
163        if ("active".equals(codeString))
164          return CommunicationRequestStatus.ACTIVE;
165        if ("on-hold".equals(codeString))
166          return CommunicationRequestStatus.ONHOLD;
167        if ("revoked".equals(codeString))
168          return CommunicationRequestStatus.REVOKED;
169        if ("completed".equals(codeString))
170          return CommunicationRequestStatus.COMPLETED;
171        if ("entered-in-error".equals(codeString))
172          return CommunicationRequestStatus.ENTEREDINERROR;
173        if ("unknown".equals(codeString))
174          return CommunicationRequestStatus.UNKNOWN;
175        throw new IllegalArgumentException("Unknown CommunicationRequestStatus code '"+codeString+"'");
176        }
177        public Enumeration<CommunicationRequestStatus> fromType(Base code) throws FHIRException {
178          if (code == null)
179            return null;
180          if (code.isEmpty())
181            return new Enumeration<CommunicationRequestStatus>(this);
182          String codeString = ((PrimitiveType) code).asStringValue();
183          if (codeString == null || "".equals(codeString))
184            return null;
185        if ("draft".equals(codeString))
186          return new Enumeration<CommunicationRequestStatus>(this, CommunicationRequestStatus.DRAFT);
187        if ("active".equals(codeString))
188          return new Enumeration<CommunicationRequestStatus>(this, CommunicationRequestStatus.ACTIVE);
189        if ("on-hold".equals(codeString))
190          return new Enumeration<CommunicationRequestStatus>(this, CommunicationRequestStatus.ONHOLD);
191        if ("revoked".equals(codeString))
192          return new Enumeration<CommunicationRequestStatus>(this, CommunicationRequestStatus.REVOKED);
193        if ("completed".equals(codeString))
194          return new Enumeration<CommunicationRequestStatus>(this, CommunicationRequestStatus.COMPLETED);
195        if ("entered-in-error".equals(codeString))
196          return new Enumeration<CommunicationRequestStatus>(this, CommunicationRequestStatus.ENTEREDINERROR);
197        if ("unknown".equals(codeString))
198          return new Enumeration<CommunicationRequestStatus>(this, CommunicationRequestStatus.UNKNOWN);
199        throw new FHIRException("Unknown CommunicationRequestStatus code '"+codeString+"'");
200        }
201    public String toCode(CommunicationRequestStatus code) {
202      if (code == CommunicationRequestStatus.DRAFT)
203        return "draft";
204      if (code == CommunicationRequestStatus.ACTIVE)
205        return "active";
206      if (code == CommunicationRequestStatus.ONHOLD)
207        return "on-hold";
208      if (code == CommunicationRequestStatus.REVOKED)
209        return "revoked";
210      if (code == CommunicationRequestStatus.COMPLETED)
211        return "completed";
212      if (code == CommunicationRequestStatus.ENTEREDINERROR)
213        return "entered-in-error";
214      if (code == CommunicationRequestStatus.UNKNOWN)
215        return "unknown";
216      return "?";
217      }
218    public String toSystem(CommunicationRequestStatus code) {
219      return code.getSystem();
220      }
221    }
222
223    public enum CommunicationPriority {
224        /**
225         * The request has normal priority.
226         */
227        ROUTINE, 
228        /**
229         * The request should be actioned promptly - higher priority than routine.
230         */
231        URGENT, 
232        /**
233         * The request should be actioned as soon as possible - higher priority than urgent.
234         */
235        ASAP, 
236        /**
237         * The request should be actioned immediately - highest possible priority.  E.g. an emergency.
238         */
239        STAT, 
240        /**
241         * added to help the parsers with the generic types
242         */
243        NULL;
244        public static CommunicationPriority fromCode(String codeString) throws FHIRException {
245            if (codeString == null || "".equals(codeString))
246                return null;
247        if ("routine".equals(codeString))
248          return ROUTINE;
249        if ("urgent".equals(codeString))
250          return URGENT;
251        if ("asap".equals(codeString))
252          return ASAP;
253        if ("stat".equals(codeString))
254          return STAT;
255        if (Configuration.isAcceptInvalidEnums())
256          return null;
257        else
258          throw new FHIRException("Unknown CommunicationPriority code '"+codeString+"'");
259        }
260        public String toCode() {
261          switch (this) {
262            case ROUTINE: return "routine";
263            case URGENT: return "urgent";
264            case ASAP: return "asap";
265            case STAT: return "stat";
266            default: return "?";
267          }
268        }
269        public String getSystem() {
270          switch (this) {
271            case ROUTINE: return "http://hl7.org/fhir/request-priority";
272            case URGENT: return "http://hl7.org/fhir/request-priority";
273            case ASAP: return "http://hl7.org/fhir/request-priority";
274            case STAT: return "http://hl7.org/fhir/request-priority";
275            default: return "?";
276          }
277        }
278        public String getDefinition() {
279          switch (this) {
280            case ROUTINE: return "The request has normal priority.";
281            case URGENT: return "The request should be actioned promptly - higher priority than routine.";
282            case ASAP: return "The request should be actioned as soon as possible - higher priority than urgent.";
283            case STAT: return "The request should be actioned immediately - highest possible priority.  E.g. an emergency.";
284            default: return "?";
285          }
286        }
287        public String getDisplay() {
288          switch (this) {
289            case ROUTINE: return "Routine";
290            case URGENT: return "Urgent";
291            case ASAP: return "ASAP";
292            case STAT: return "STAT";
293            default: return "?";
294          }
295        }
296    }
297
298  public static class CommunicationPriorityEnumFactory implements EnumFactory<CommunicationPriority> {
299    public CommunicationPriority fromCode(String codeString) throws IllegalArgumentException {
300      if (codeString == null || "".equals(codeString))
301            if (codeString == null || "".equals(codeString))
302                return null;
303        if ("routine".equals(codeString))
304          return CommunicationPriority.ROUTINE;
305        if ("urgent".equals(codeString))
306          return CommunicationPriority.URGENT;
307        if ("asap".equals(codeString))
308          return CommunicationPriority.ASAP;
309        if ("stat".equals(codeString))
310          return CommunicationPriority.STAT;
311        throw new IllegalArgumentException("Unknown CommunicationPriority code '"+codeString+"'");
312        }
313        public Enumeration<CommunicationPriority> fromType(Base code) throws FHIRException {
314          if (code == null)
315            return null;
316          if (code.isEmpty())
317            return new Enumeration<CommunicationPriority>(this);
318          String codeString = ((PrimitiveType) code).asStringValue();
319          if (codeString == null || "".equals(codeString))
320            return null;
321        if ("routine".equals(codeString))
322          return new Enumeration<CommunicationPriority>(this, CommunicationPriority.ROUTINE);
323        if ("urgent".equals(codeString))
324          return new Enumeration<CommunicationPriority>(this, CommunicationPriority.URGENT);
325        if ("asap".equals(codeString))
326          return new Enumeration<CommunicationPriority>(this, CommunicationPriority.ASAP);
327        if ("stat".equals(codeString))
328          return new Enumeration<CommunicationPriority>(this, CommunicationPriority.STAT);
329        throw new FHIRException("Unknown CommunicationPriority code '"+codeString+"'");
330        }
331    public String toCode(CommunicationPriority code) {
332      if (code == CommunicationPriority.ROUTINE)
333        return "routine";
334      if (code == CommunicationPriority.URGENT)
335        return "urgent";
336      if (code == CommunicationPriority.ASAP)
337        return "asap";
338      if (code == CommunicationPriority.STAT)
339        return "stat";
340      return "?";
341      }
342    public String toSystem(CommunicationPriority code) {
343      return code.getSystem();
344      }
345    }
346
347    @Block()
348    public static class CommunicationRequestPayloadComponent extends BackboneElement implements IBaseBackboneElement {
349        /**
350         * The communicated content (or for multi-part communications, one portion of the communication).
351         */
352        @Child(name = "content", type = {StringType.class, Attachment.class, Reference.class}, order=1, min=1, max=1, modifier=false, summary=false)
353        @Description(shortDefinition="Message part content", formalDefinition="The communicated content (or for multi-part communications, one portion of the communication)." )
354        protected Type content;
355
356        private static final long serialVersionUID = -1763459053L;
357
358    /**
359     * Constructor
360     */
361      public CommunicationRequestPayloadComponent() {
362        super();
363      }
364
365    /**
366     * Constructor
367     */
368      public CommunicationRequestPayloadComponent(Type content) {
369        super();
370        this.content = content;
371      }
372
373        /**
374         * @return {@link #content} (The communicated content (or for multi-part communications, one portion of the communication).)
375         */
376        public Type getContent() { 
377          return this.content;
378        }
379
380        /**
381         * @return {@link #content} (The communicated content (or for multi-part communications, one portion of the communication).)
382         */
383        public StringType getContentStringType() throws FHIRException { 
384          if (this.content == null)
385            this.content = new StringType();
386          if (!(this.content instanceof StringType))
387            throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.content.getClass().getName()+" was encountered");
388          return (StringType) this.content;
389        }
390
391        public boolean hasContentStringType() { 
392          return this != null && this.content instanceof StringType;
393        }
394
395        /**
396         * @return {@link #content} (The communicated content (or for multi-part communications, one portion of the communication).)
397         */
398        public Attachment getContentAttachment() throws FHIRException { 
399          if (this.content == null)
400            this.content = new Attachment();
401          if (!(this.content instanceof Attachment))
402            throw new FHIRException("Type mismatch: the type Attachment was expected, but "+this.content.getClass().getName()+" was encountered");
403          return (Attachment) this.content;
404        }
405
406        public boolean hasContentAttachment() { 
407          return this != null && this.content instanceof Attachment;
408        }
409
410        /**
411         * @return {@link #content} (The communicated content (or for multi-part communications, one portion of the communication).)
412         */
413        public Reference getContentReference() throws FHIRException { 
414          if (this.content == null)
415            this.content = new Reference();
416          if (!(this.content instanceof Reference))
417            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.content.getClass().getName()+" was encountered");
418          return (Reference) this.content;
419        }
420
421        public boolean hasContentReference() { 
422          return this != null && this.content instanceof Reference;
423        }
424
425        public boolean hasContent() { 
426          return this.content != null && !this.content.isEmpty();
427        }
428
429        /**
430         * @param value {@link #content} (The communicated content (or for multi-part communications, one portion of the communication).)
431         */
432        public CommunicationRequestPayloadComponent setContent(Type value) { 
433          if (value != null && !(value instanceof StringType || value instanceof Attachment || value instanceof Reference))
434            throw new Error("Not the right type for CommunicationRequest.payload.content[x]: "+value.fhirType());
435          this.content = value;
436          return this;
437        }
438
439        protected void listChildren(List<Property> children) {
440          super.listChildren(children);
441          children.add(new Property("content[x]", "string|Attachment|Reference(Any)", "The communicated content (or for multi-part communications, one portion of the communication).", 0, 1, content));
442        }
443
444        @Override
445        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
446          switch (_hash) {
447          case 264548711: /*content[x]*/  return new Property("content[x]", "string|Attachment|Reference(Any)", "The communicated content (or for multi-part communications, one portion of the communication).", 0, 1, content);
448          case 951530617: /*content*/  return new Property("content[x]", "string|Attachment|Reference(Any)", "The communicated content (or for multi-part communications, one portion of the communication).", 0, 1, content);
449          case -326336022: /*contentString*/  return new Property("content[x]", "string|Attachment|Reference(Any)", "The communicated content (or for multi-part communications, one portion of the communication).", 0, 1, content);
450          case -702028164: /*contentAttachment*/  return new Property("content[x]", "string|Attachment|Reference(Any)", "The communicated content (or for multi-part communications, one portion of the communication).", 0, 1, content);
451          case 1193747154: /*contentReference*/  return new Property("content[x]", "string|Attachment|Reference(Any)", "The communicated content (or for multi-part communications, one portion of the communication).", 0, 1, content);
452          default: return super.getNamedProperty(_hash, _name, _checkValid);
453          }
454
455        }
456
457      @Override
458      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
459        switch (hash) {
460        case 951530617: /*content*/ return this.content == null ? new Base[0] : new Base[] {this.content}; // Type
461        default: return super.getProperty(hash, name, checkValid);
462        }
463
464      }
465
466      @Override
467      public Base setProperty(int hash, String name, Base value) throws FHIRException {
468        switch (hash) {
469        case 951530617: // content
470          this.content = castToType(value); // Type
471          return value;
472        default: return super.setProperty(hash, name, value);
473        }
474
475      }
476
477      @Override
478      public Base setProperty(String name, Base value) throws FHIRException {
479        if (name.equals("content[x]")) {
480          this.content = castToType(value); // Type
481        } else
482          return super.setProperty(name, value);
483        return value;
484      }
485
486      @Override
487      public Base makeProperty(int hash, String name) throws FHIRException {
488        switch (hash) {
489        case 264548711:  return getContent(); 
490        case 951530617:  return getContent(); 
491        default: return super.makeProperty(hash, name);
492        }
493
494      }
495
496      @Override
497      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
498        switch (hash) {
499        case 951530617: /*content*/ return new String[] {"string", "Attachment", "Reference"};
500        default: return super.getTypesForProperty(hash, name);
501        }
502
503      }
504
505      @Override
506      public Base addChild(String name) throws FHIRException {
507        if (name.equals("contentString")) {
508          this.content = new StringType();
509          return this.content;
510        }
511        else if (name.equals("contentAttachment")) {
512          this.content = new Attachment();
513          return this.content;
514        }
515        else if (name.equals("contentReference")) {
516          this.content = new Reference();
517          return this.content;
518        }
519        else
520          return super.addChild(name);
521      }
522
523      public CommunicationRequestPayloadComponent copy() {
524        CommunicationRequestPayloadComponent dst = new CommunicationRequestPayloadComponent();
525        copyValues(dst);
526        dst.content = content == null ? null : content.copy();
527        return dst;
528      }
529
530      @Override
531      public boolean equalsDeep(Base other_) {
532        if (!super.equalsDeep(other_))
533          return false;
534        if (!(other_ instanceof CommunicationRequestPayloadComponent))
535          return false;
536        CommunicationRequestPayloadComponent o = (CommunicationRequestPayloadComponent) other_;
537        return compareDeep(content, o.content, true);
538      }
539
540      @Override
541      public boolean equalsShallow(Base other_) {
542        if (!super.equalsShallow(other_))
543          return false;
544        if (!(other_ instanceof CommunicationRequestPayloadComponent))
545          return false;
546        CommunicationRequestPayloadComponent o = (CommunicationRequestPayloadComponent) other_;
547        return true;
548      }
549
550      public boolean isEmpty() {
551        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(content);
552      }
553
554  public String fhirType() {
555    return "CommunicationRequest.payload";
556
557  }
558
559  }
560
561    /**
562     * Business identifiers assigned to this communication request by the performer or other systems which remain constant as the resource is updated and propagates from server to server.
563     */
564    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
565    @Description(shortDefinition="Unique identifier", formalDefinition="Business identifiers assigned to this communication request by the performer or other systems which remain constant as the resource is updated and propagates from server to server." )
566    protected List<Identifier> identifier;
567
568    /**
569     * A plan or proposal that is fulfilled in whole or in part by this request.
570     */
571    @Child(name = "basedOn", type = {Reference.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
572    @Description(shortDefinition="Fulfills plan or proposal", formalDefinition="A plan or proposal that is fulfilled in whole or in part by this request." )
573    protected List<Reference> basedOn;
574    /**
575     * The actual objects that are the target of the reference (A plan or proposal that is fulfilled in whole or in part by this request.)
576     */
577    protected List<Resource> basedOnTarget;
578
579
580    /**
581     * Completed or terminated request(s) whose function is taken by this new request.
582     */
583    @Child(name = "replaces", type = {CommunicationRequest.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
584    @Description(shortDefinition="Request(s) replaced by this request", formalDefinition="Completed or terminated request(s) whose function is taken by this new request." )
585    protected List<Reference> replaces;
586    /**
587     * The actual objects that are the target of the reference (Completed or terminated request(s) whose function is taken by this new request.)
588     */
589    protected List<CommunicationRequest> replacesTarget;
590
591
592    /**
593     * A shared identifier common to all requests that were authorized more or less simultaneously by a single author, representing the identifier of the requisition, prescription or similar form.
594     */
595    @Child(name = "groupIdentifier", type = {Identifier.class}, order=3, min=0, max=1, modifier=false, summary=true)
596    @Description(shortDefinition="Composite request this is part of", formalDefinition="A shared identifier common to all requests that were authorized more or less simultaneously by a single author, representing the identifier of the requisition, prescription or similar form." )
597    protected Identifier groupIdentifier;
598
599    /**
600     * The status of the proposal or order.
601     */
602    @Child(name = "status", type = {CodeType.class}, order=4, min=1, max=1, modifier=true, summary=true)
603    @Description(shortDefinition="draft | active | suspended | cancelled | completed | entered-in-error | unknown", formalDefinition="The status of the proposal or order." )
604    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/request-status")
605    protected Enumeration<CommunicationRequestStatus> status;
606
607    /**
608     * Captures the reason for the current state of the CommunicationRequest.
609     */
610    @Child(name = "statusReason", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=false)
611    @Description(shortDefinition="Reason for current status", formalDefinition="Captures the reason for the current state of the CommunicationRequest." )
612    protected CodeableConcept statusReason;
613
614    /**
615     * The type of message to be sent such as alert, notification, reminder, instruction, etc.
616     */
617    @Child(name = "category", type = {CodeableConcept.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
618    @Description(shortDefinition="Message category", formalDefinition="The type of message to be sent such as alert, notification, reminder, instruction, etc." )
619    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/communication-category")
620    protected List<CodeableConcept> category;
621
622    /**
623     * Characterizes how quickly the proposed act must be initiated. Includes concepts such as stat, urgent, routine.
624     */
625    @Child(name = "priority", type = {CodeType.class}, order=7, min=0, max=1, modifier=false, summary=true)
626    @Description(shortDefinition="Message urgency", formalDefinition="Characterizes how quickly the proposed act must be initiated. Includes concepts such as stat, urgent, routine." )
627    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/request-priority")
628    protected Enumeration<CommunicationPriority> priority;
629
630    /**
631     * If true indicates that the CommunicationRequest is asking for the specified action to *not* occur.
632     */
633    @Child(name = "doNotPerform", type = {BooleanType.class}, order=8, min=0, max=1, modifier=true, summary=true)
634    @Description(shortDefinition="True if request is prohibiting action", formalDefinition="If true indicates that the CommunicationRequest is asking for the specified action to *not* occur." )
635    protected BooleanType doNotPerform;
636
637    /**
638     * A channel that was used for this communication (e.g. email, fax).
639     */
640    @Child(name = "medium", type = {CodeableConcept.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
641    @Description(shortDefinition="A channel of communication", formalDefinition="A channel that was used for this communication (e.g. email, fax)." )
642    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v3-ParticipationMode")
643    protected List<CodeableConcept> medium;
644
645    /**
646     * The patient or group that is the focus of this communication request.
647     */
648    @Child(name = "subject", type = {Patient.class, Group.class}, order=10, min=0, max=1, modifier=false, summary=false)
649    @Description(shortDefinition="Focus of message", formalDefinition="The patient or group that is the focus of this communication request." )
650    protected Reference subject;
651
652    /**
653     * The actual object that is the target of the reference (The patient or group that is the focus of this communication request.)
654     */
655    protected Resource subjectTarget;
656
657    /**
658     * Other resources that pertain to this communication request and to which this communication request should be associated.
659     */
660    @Child(name = "about", type = {Reference.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
661    @Description(shortDefinition="Resources that pertain to this communication request", formalDefinition="Other resources that pertain to this communication request and to which this communication request should be associated." )
662    protected List<Reference> about;
663    /**
664     * The actual objects that are the target of the reference (Other resources that pertain to this communication request and to which this communication request should be associated.)
665     */
666    protected List<Resource> aboutTarget;
667
668
669    /**
670     * The Encounter during which this CommunicationRequest was created or to which the creation of this record is tightly associated.
671     */
672    @Child(name = "encounter", type = {Encounter.class}, order=12, min=0, max=1, modifier=false, summary=true)
673    @Description(shortDefinition="Encounter created as part of", formalDefinition="The Encounter during which this CommunicationRequest was created or to which the creation of this record is tightly associated." )
674    protected Reference encounter;
675
676    /**
677     * The actual object that is the target of the reference (The Encounter during which this CommunicationRequest was created or to which the creation of this record is tightly associated.)
678     */
679    protected Encounter encounterTarget;
680
681    /**
682     * Text, attachment(s), or resource(s) to be communicated to the recipient.
683     */
684    @Child(name = "payload", type = {}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
685    @Description(shortDefinition="Message payload", formalDefinition="Text, attachment(s), or resource(s) to be communicated to the recipient." )
686    protected List<CommunicationRequestPayloadComponent> payload;
687
688    /**
689     * The time when this communication is to occur.
690     */
691    @Child(name = "occurrence", type = {DateTimeType.class, Period.class}, order=14, min=0, max=1, modifier=false, summary=true)
692    @Description(shortDefinition="When scheduled", formalDefinition="The time when this communication is to occur." )
693    protected Type occurrence;
694
695    /**
696     * For draft requests, indicates the date of initial creation.  For requests with other statuses, indicates the date of activation.
697     */
698    @Child(name = "authoredOn", type = {DateTimeType.class}, order=15, min=0, max=1, modifier=false, summary=true)
699    @Description(shortDefinition="When request transitioned to being actionable", formalDefinition="For draft requests, indicates the date of initial creation.  For requests with other statuses, indicates the date of activation." )
700    protected DateTimeType authoredOn;
701
702    /**
703     * The device, individual, or organization who initiated the request and has responsibility for its activation.
704     */
705    @Child(name = "requester", type = {Practitioner.class, PractitionerRole.class, Organization.class, Patient.class, RelatedPerson.class, Device.class}, order=16, min=0, max=1, modifier=false, summary=true)
706    @Description(shortDefinition="Who/what is requesting service", formalDefinition="The device, individual, or organization who initiated the request and has responsibility for its activation." )
707    protected Reference requester;
708
709    /**
710     * The actual object that is the target of the reference (The device, individual, or organization who initiated the request and has responsibility for its activation.)
711     */
712    protected Resource requesterTarget;
713
714    /**
715     * The entity (e.g. person, organization, clinical information system, device, group, or care team) which is the intended target of the communication.
716     */
717    @Child(name = "recipient", type = {Device.class, Organization.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class, Group.class, CareTeam.class, HealthcareService.class}, order=17, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
718    @Description(shortDefinition="Message recipient", formalDefinition="The entity (e.g. person, organization, clinical information system, device, group, or care team) which is the intended target of the communication." )
719    protected List<Reference> recipient;
720    /**
721     * The actual objects that are the target of the reference (The entity (e.g. person, organization, clinical information system, device, group, or care team) which is the intended target of the communication.)
722     */
723    protected List<Resource> recipientTarget;
724
725
726    /**
727     * The entity (e.g. person, organization, clinical information system, or device) which is to be the source of the communication.
728     */
729    @Child(name = "sender", type = {Device.class, Organization.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class, HealthcareService.class}, order=18, min=0, max=1, modifier=false, summary=true)
730    @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." )
731    protected Reference sender;
732
733    /**
734     * 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.)
735     */
736    protected Resource senderTarget;
737
738    /**
739     * Describes why the request is being made in coded or textual form.
740     */
741    @Child(name = "reasonCode", type = {CodeableConcept.class}, order=19, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
742    @Description(shortDefinition="Why is communication needed?", formalDefinition="Describes why the request is being made in coded or textual form." )
743    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v3-ActReason")
744    protected List<CodeableConcept> reasonCode;
745
746    /**
747     * Indicates another resource whose existence justifies this request.
748     */
749    @Child(name = "reasonReference", type = {Condition.class, Observation.class, DiagnosticReport.class, DocumentReference.class}, order=20, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
750    @Description(shortDefinition="Why is communication needed?", formalDefinition="Indicates another resource whose existence justifies this request." )
751    protected List<Reference> reasonReference;
752    /**
753     * The actual objects that are the target of the reference (Indicates another resource whose existence justifies this request.)
754     */
755    protected List<Resource> reasonReferenceTarget;
756
757
758    /**
759     * Comments made about the request by the requester, sender, recipient, subject or other participants.
760     */
761    @Child(name = "note", type = {Annotation.class}, order=21, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
762    @Description(shortDefinition="Comments made about communication request", formalDefinition="Comments made about the request by the requester, sender, recipient, subject or other participants." )
763    protected List<Annotation> note;
764
765    private static final long serialVersionUID = 2131096857L;
766
767  /**
768   * Constructor
769   */
770    public CommunicationRequest() {
771      super();
772    }
773
774  /**
775   * Constructor
776   */
777    public CommunicationRequest(Enumeration<CommunicationRequestStatus> status) {
778      super();
779      this.status = status;
780    }
781
782    /**
783     * @return {@link #identifier} (Business identifiers assigned to this communication request by the performer or other systems which remain constant as the resource is updated and propagates from server to server.)
784     */
785    public List<Identifier> getIdentifier() { 
786      if (this.identifier == null)
787        this.identifier = new ArrayList<Identifier>();
788      return this.identifier;
789    }
790
791    /**
792     * @return Returns a reference to <code>this</code> for easy method chaining
793     */
794    public CommunicationRequest setIdentifier(List<Identifier> theIdentifier) { 
795      this.identifier = theIdentifier;
796      return this;
797    }
798
799    public boolean hasIdentifier() { 
800      if (this.identifier == null)
801        return false;
802      for (Identifier item : this.identifier)
803        if (!item.isEmpty())
804          return true;
805      return false;
806    }
807
808    public Identifier addIdentifier() { //3
809      Identifier t = new Identifier();
810      if (this.identifier == null)
811        this.identifier = new ArrayList<Identifier>();
812      this.identifier.add(t);
813      return t;
814    }
815
816    public CommunicationRequest addIdentifier(Identifier t) { //3
817      if (t == null)
818        return this;
819      if (this.identifier == null)
820        this.identifier = new ArrayList<Identifier>();
821      this.identifier.add(t);
822      return this;
823    }
824
825    /**
826     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
827     */
828    public Identifier getIdentifierFirstRep() { 
829      if (getIdentifier().isEmpty()) {
830        addIdentifier();
831      }
832      return getIdentifier().get(0);
833    }
834
835    /**
836     * @return {@link #basedOn} (A plan or proposal that is fulfilled in whole or in part by this request.)
837     */
838    public List<Reference> getBasedOn() { 
839      if (this.basedOn == null)
840        this.basedOn = new ArrayList<Reference>();
841      return this.basedOn;
842    }
843
844    /**
845     * @return Returns a reference to <code>this</code> for easy method chaining
846     */
847    public CommunicationRequest setBasedOn(List<Reference> theBasedOn) { 
848      this.basedOn = theBasedOn;
849      return this;
850    }
851
852    public boolean hasBasedOn() { 
853      if (this.basedOn == null)
854        return false;
855      for (Reference item : this.basedOn)
856        if (!item.isEmpty())
857          return true;
858      return false;
859    }
860
861    public Reference addBasedOn() { //3
862      Reference t = new Reference();
863      if (this.basedOn == null)
864        this.basedOn = new ArrayList<Reference>();
865      this.basedOn.add(t);
866      return t;
867    }
868
869    public CommunicationRequest addBasedOn(Reference t) { //3
870      if (t == null)
871        return this;
872      if (this.basedOn == null)
873        this.basedOn = new ArrayList<Reference>();
874      this.basedOn.add(t);
875      return this;
876    }
877
878    /**
879     * @return The first repetition of repeating field {@link #basedOn}, creating it if it does not already exist
880     */
881    public Reference getBasedOnFirstRep() { 
882      if (getBasedOn().isEmpty()) {
883        addBasedOn();
884      }
885      return getBasedOn().get(0);
886    }
887
888    /**
889     * @deprecated Use Reference#setResource(IBaseResource) instead
890     */
891    @Deprecated
892    public List<Resource> getBasedOnTarget() { 
893      if (this.basedOnTarget == null)
894        this.basedOnTarget = new ArrayList<Resource>();
895      return this.basedOnTarget;
896    }
897
898    /**
899     * @return {@link #replaces} (Completed or terminated request(s) whose function is taken by this new request.)
900     */
901    public List<Reference> getReplaces() { 
902      if (this.replaces == null)
903        this.replaces = new ArrayList<Reference>();
904      return this.replaces;
905    }
906
907    /**
908     * @return Returns a reference to <code>this</code> for easy method chaining
909     */
910    public CommunicationRequest setReplaces(List<Reference> theReplaces) { 
911      this.replaces = theReplaces;
912      return this;
913    }
914
915    public boolean hasReplaces() { 
916      if (this.replaces == null)
917        return false;
918      for (Reference item : this.replaces)
919        if (!item.isEmpty())
920          return true;
921      return false;
922    }
923
924    public Reference addReplaces() { //3
925      Reference t = new Reference();
926      if (this.replaces == null)
927        this.replaces = new ArrayList<Reference>();
928      this.replaces.add(t);
929      return t;
930    }
931
932    public CommunicationRequest addReplaces(Reference t) { //3
933      if (t == null)
934        return this;
935      if (this.replaces == null)
936        this.replaces = new ArrayList<Reference>();
937      this.replaces.add(t);
938      return this;
939    }
940
941    /**
942     * @return The first repetition of repeating field {@link #replaces}, creating it if it does not already exist
943     */
944    public Reference getReplacesFirstRep() { 
945      if (getReplaces().isEmpty()) {
946        addReplaces();
947      }
948      return getReplaces().get(0);
949    }
950
951    /**
952     * @deprecated Use Reference#setResource(IBaseResource) instead
953     */
954    @Deprecated
955    public List<CommunicationRequest> getReplacesTarget() { 
956      if (this.replacesTarget == null)
957        this.replacesTarget = new ArrayList<CommunicationRequest>();
958      return this.replacesTarget;
959    }
960
961    /**
962     * @deprecated Use Reference#setResource(IBaseResource) instead
963     */
964    @Deprecated
965    public CommunicationRequest addReplacesTarget() { 
966      CommunicationRequest r = new CommunicationRequest();
967      if (this.replacesTarget == null)
968        this.replacesTarget = new ArrayList<CommunicationRequest>();
969      this.replacesTarget.add(r);
970      return r;
971    }
972
973    /**
974     * @return {@link #groupIdentifier} (A shared identifier common to all requests that were authorized more or less simultaneously by a single author, representing the identifier of the requisition, prescription or similar form.)
975     */
976    public Identifier getGroupIdentifier() { 
977      if (this.groupIdentifier == null)
978        if (Configuration.errorOnAutoCreate())
979          throw new Error("Attempt to auto-create CommunicationRequest.groupIdentifier");
980        else if (Configuration.doAutoCreate())
981          this.groupIdentifier = new Identifier(); // cc
982      return this.groupIdentifier;
983    }
984
985    public boolean hasGroupIdentifier() { 
986      return this.groupIdentifier != null && !this.groupIdentifier.isEmpty();
987    }
988
989    /**
990     * @param value {@link #groupIdentifier} (A shared identifier common to all requests that were authorized more or less simultaneously by a single author, representing the identifier of the requisition, prescription or similar form.)
991     */
992    public CommunicationRequest setGroupIdentifier(Identifier value) { 
993      this.groupIdentifier = value;
994      return this;
995    }
996
997    /**
998     * @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
999     */
1000    public Enumeration<CommunicationRequestStatus> getStatusElement() { 
1001      if (this.status == null)
1002        if (Configuration.errorOnAutoCreate())
1003          throw new Error("Attempt to auto-create CommunicationRequest.status");
1004        else if (Configuration.doAutoCreate())
1005          this.status = new Enumeration<CommunicationRequestStatus>(new CommunicationRequestStatusEnumFactory()); // bb
1006      return this.status;
1007    }
1008
1009    public boolean hasStatusElement() { 
1010      return this.status != null && !this.status.isEmpty();
1011    }
1012
1013    public boolean hasStatus() { 
1014      return this.status != null && !this.status.isEmpty();
1015    }
1016
1017    /**
1018     * @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
1019     */
1020    public CommunicationRequest setStatusElement(Enumeration<CommunicationRequestStatus> value) { 
1021      this.status = value;
1022      return this;
1023    }
1024
1025    /**
1026     * @return The status of the proposal or order.
1027     */
1028    public CommunicationRequestStatus getStatus() { 
1029      return this.status == null ? null : this.status.getValue();
1030    }
1031
1032    /**
1033     * @param value The status of the proposal or order.
1034     */
1035    public CommunicationRequest setStatus(CommunicationRequestStatus value) { 
1036        if (this.status == null)
1037          this.status = new Enumeration<CommunicationRequestStatus>(new CommunicationRequestStatusEnumFactory());
1038        this.status.setValue(value);
1039      return this;
1040    }
1041
1042    /**
1043     * @return {@link #statusReason} (Captures the reason for the current state of the CommunicationRequest.)
1044     */
1045    public CodeableConcept getStatusReason() { 
1046      if (this.statusReason == null)
1047        if (Configuration.errorOnAutoCreate())
1048          throw new Error("Attempt to auto-create CommunicationRequest.statusReason");
1049        else if (Configuration.doAutoCreate())
1050          this.statusReason = new CodeableConcept(); // cc
1051      return this.statusReason;
1052    }
1053
1054    public boolean hasStatusReason() { 
1055      return this.statusReason != null && !this.statusReason.isEmpty();
1056    }
1057
1058    /**
1059     * @param value {@link #statusReason} (Captures the reason for the current state of the CommunicationRequest.)
1060     */
1061    public CommunicationRequest setStatusReason(CodeableConcept value) { 
1062      this.statusReason = value;
1063      return this;
1064    }
1065
1066    /**
1067     * @return {@link #category} (The type of message to be sent such as alert, notification, reminder, instruction, etc.)
1068     */
1069    public List<CodeableConcept> getCategory() { 
1070      if (this.category == null)
1071        this.category = new ArrayList<CodeableConcept>();
1072      return this.category;
1073    }
1074
1075    /**
1076     * @return Returns a reference to <code>this</code> for easy method chaining
1077     */
1078    public CommunicationRequest setCategory(List<CodeableConcept> theCategory) { 
1079      this.category = theCategory;
1080      return this;
1081    }
1082
1083    public boolean hasCategory() { 
1084      if (this.category == null)
1085        return false;
1086      for (CodeableConcept item : this.category)
1087        if (!item.isEmpty())
1088          return true;
1089      return false;
1090    }
1091
1092    public CodeableConcept addCategory() { //3
1093      CodeableConcept t = new CodeableConcept();
1094      if (this.category == null)
1095        this.category = new ArrayList<CodeableConcept>();
1096      this.category.add(t);
1097      return t;
1098    }
1099
1100    public CommunicationRequest addCategory(CodeableConcept t) { //3
1101      if (t == null)
1102        return this;
1103      if (this.category == null)
1104        this.category = new ArrayList<CodeableConcept>();
1105      this.category.add(t);
1106      return this;
1107    }
1108
1109    /**
1110     * @return The first repetition of repeating field {@link #category}, creating it if it does not already exist
1111     */
1112    public CodeableConcept getCategoryFirstRep() { 
1113      if (getCategory().isEmpty()) {
1114        addCategory();
1115      }
1116      return getCategory().get(0);
1117    }
1118
1119    /**
1120     * @return {@link #priority} (Characterizes how quickly the proposed act must be initiated. Includes concepts such as stat, urgent, routine.). This is the underlying object with id, value and extensions. The accessor "getPriority" gives direct access to the value
1121     */
1122    public Enumeration<CommunicationPriority> getPriorityElement() { 
1123      if (this.priority == null)
1124        if (Configuration.errorOnAutoCreate())
1125          throw new Error("Attempt to auto-create CommunicationRequest.priority");
1126        else if (Configuration.doAutoCreate())
1127          this.priority = new Enumeration<CommunicationPriority>(new CommunicationPriorityEnumFactory()); // bb
1128      return this.priority;
1129    }
1130
1131    public boolean hasPriorityElement() { 
1132      return this.priority != null && !this.priority.isEmpty();
1133    }
1134
1135    public boolean hasPriority() { 
1136      return this.priority != null && !this.priority.isEmpty();
1137    }
1138
1139    /**
1140     * @param value {@link #priority} (Characterizes how quickly the proposed act must be initiated. Includes concepts such as stat, urgent, routine.). This is the underlying object with id, value and extensions. The accessor "getPriority" gives direct access to the value
1141     */
1142    public CommunicationRequest setPriorityElement(Enumeration<CommunicationPriority> value) { 
1143      this.priority = value;
1144      return this;
1145    }
1146
1147    /**
1148     * @return Characterizes how quickly the proposed act must be initiated. Includes concepts such as stat, urgent, routine.
1149     */
1150    public CommunicationPriority getPriority() { 
1151      return this.priority == null ? null : this.priority.getValue();
1152    }
1153
1154    /**
1155     * @param value Characterizes how quickly the proposed act must be initiated. Includes concepts such as stat, urgent, routine.
1156     */
1157    public CommunicationRequest setPriority(CommunicationPriority value) { 
1158      if (value == null)
1159        this.priority = null;
1160      else {
1161        if (this.priority == null)
1162          this.priority = new Enumeration<CommunicationPriority>(new CommunicationPriorityEnumFactory());
1163        this.priority.setValue(value);
1164      }
1165      return this;
1166    }
1167
1168    /**
1169     * @return {@link #doNotPerform} (If true indicates that the CommunicationRequest is asking for the specified action to *not* occur.). This is the underlying object with id, value and extensions. The accessor "getDoNotPerform" gives direct access to the value
1170     */
1171    public BooleanType getDoNotPerformElement() { 
1172      if (this.doNotPerform == null)
1173        if (Configuration.errorOnAutoCreate())
1174          throw new Error("Attempt to auto-create CommunicationRequest.doNotPerform");
1175        else if (Configuration.doAutoCreate())
1176          this.doNotPerform = new BooleanType(); // bb
1177      return this.doNotPerform;
1178    }
1179
1180    public boolean hasDoNotPerformElement() { 
1181      return this.doNotPerform != null && !this.doNotPerform.isEmpty();
1182    }
1183
1184    public boolean hasDoNotPerform() { 
1185      return this.doNotPerform != null && !this.doNotPerform.isEmpty();
1186    }
1187
1188    /**
1189     * @param value {@link #doNotPerform} (If true indicates that the CommunicationRequest is asking for the specified action to *not* occur.). This is the underlying object with id, value and extensions. The accessor "getDoNotPerform" gives direct access to the value
1190     */
1191    public CommunicationRequest setDoNotPerformElement(BooleanType value) { 
1192      this.doNotPerform = value;
1193      return this;
1194    }
1195
1196    /**
1197     * @return If true indicates that the CommunicationRequest is asking for the specified action to *not* occur.
1198     */
1199    public boolean getDoNotPerform() { 
1200      return this.doNotPerform == null || this.doNotPerform.isEmpty() ? false : this.doNotPerform.getValue();
1201    }
1202
1203    /**
1204     * @param value If true indicates that the CommunicationRequest is asking for the specified action to *not* occur.
1205     */
1206    public CommunicationRequest setDoNotPerform(boolean value) { 
1207        if (this.doNotPerform == null)
1208          this.doNotPerform = new BooleanType();
1209        this.doNotPerform.setValue(value);
1210      return this;
1211    }
1212
1213    /**
1214     * @return {@link #medium} (A channel that was used for this communication (e.g. email, fax).)
1215     */
1216    public List<CodeableConcept> getMedium() { 
1217      if (this.medium == null)
1218        this.medium = new ArrayList<CodeableConcept>();
1219      return this.medium;
1220    }
1221
1222    /**
1223     * @return Returns a reference to <code>this</code> for easy method chaining
1224     */
1225    public CommunicationRequest setMedium(List<CodeableConcept> theMedium) { 
1226      this.medium = theMedium;
1227      return this;
1228    }
1229
1230    public boolean hasMedium() { 
1231      if (this.medium == null)
1232        return false;
1233      for (CodeableConcept item : this.medium)
1234        if (!item.isEmpty())
1235          return true;
1236      return false;
1237    }
1238
1239    public CodeableConcept addMedium() { //3
1240      CodeableConcept t = new CodeableConcept();
1241      if (this.medium == null)
1242        this.medium = new ArrayList<CodeableConcept>();
1243      this.medium.add(t);
1244      return t;
1245    }
1246
1247    public CommunicationRequest addMedium(CodeableConcept t) { //3
1248      if (t == null)
1249        return this;
1250      if (this.medium == null)
1251        this.medium = new ArrayList<CodeableConcept>();
1252      this.medium.add(t);
1253      return this;
1254    }
1255
1256    /**
1257     * @return The first repetition of repeating field {@link #medium}, creating it if it does not already exist
1258     */
1259    public CodeableConcept getMediumFirstRep() { 
1260      if (getMedium().isEmpty()) {
1261        addMedium();
1262      }
1263      return getMedium().get(0);
1264    }
1265
1266    /**
1267     * @return {@link #subject} (The patient or group that is the focus of this communication request.)
1268     */
1269    public Reference getSubject() { 
1270      if (this.subject == null)
1271        if (Configuration.errorOnAutoCreate())
1272          throw new Error("Attempt to auto-create CommunicationRequest.subject");
1273        else if (Configuration.doAutoCreate())
1274          this.subject = new Reference(); // cc
1275      return this.subject;
1276    }
1277
1278    public boolean hasSubject() { 
1279      return this.subject != null && !this.subject.isEmpty();
1280    }
1281
1282    /**
1283     * @param value {@link #subject} (The patient or group that is the focus of this communication request.)
1284     */
1285    public CommunicationRequest setSubject(Reference value) { 
1286      this.subject = value;
1287      return this;
1288    }
1289
1290    /**
1291     * @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 or group that is the focus of this communication request.)
1292     */
1293    public Resource getSubjectTarget() { 
1294      return this.subjectTarget;
1295    }
1296
1297    /**
1298     * @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 or group that is the focus of this communication request.)
1299     */
1300    public CommunicationRequest setSubjectTarget(Resource value) { 
1301      this.subjectTarget = value;
1302      return this;
1303    }
1304
1305    /**
1306     * @return {@link #about} (Other resources that pertain to this communication request and to which this communication request should be associated.)
1307     */
1308    public List<Reference> getAbout() { 
1309      if (this.about == null)
1310        this.about = new ArrayList<Reference>();
1311      return this.about;
1312    }
1313
1314    /**
1315     * @return Returns a reference to <code>this</code> for easy method chaining
1316     */
1317    public CommunicationRequest setAbout(List<Reference> theAbout) { 
1318      this.about = theAbout;
1319      return this;
1320    }
1321
1322    public boolean hasAbout() { 
1323      if (this.about == null)
1324        return false;
1325      for (Reference item : this.about)
1326        if (!item.isEmpty())
1327          return true;
1328      return false;
1329    }
1330
1331    public Reference addAbout() { //3
1332      Reference t = new Reference();
1333      if (this.about == null)
1334        this.about = new ArrayList<Reference>();
1335      this.about.add(t);
1336      return t;
1337    }
1338
1339    public CommunicationRequest addAbout(Reference t) { //3
1340      if (t == null)
1341        return this;
1342      if (this.about == null)
1343        this.about = new ArrayList<Reference>();
1344      this.about.add(t);
1345      return this;
1346    }
1347
1348    /**
1349     * @return The first repetition of repeating field {@link #about}, creating it if it does not already exist
1350     */
1351    public Reference getAboutFirstRep() { 
1352      if (getAbout().isEmpty()) {
1353        addAbout();
1354      }
1355      return getAbout().get(0);
1356    }
1357
1358    /**
1359     * @deprecated Use Reference#setResource(IBaseResource) instead
1360     */
1361    @Deprecated
1362    public List<Resource> getAboutTarget() { 
1363      if (this.aboutTarget == null)
1364        this.aboutTarget = new ArrayList<Resource>();
1365      return this.aboutTarget;
1366    }
1367
1368    /**
1369     * @return {@link #encounter} (The Encounter during which this CommunicationRequest was created or to which the creation of this record is tightly associated.)
1370     */
1371    public Reference getEncounter() { 
1372      if (this.encounter == null)
1373        if (Configuration.errorOnAutoCreate())
1374          throw new Error("Attempt to auto-create CommunicationRequest.encounter");
1375        else if (Configuration.doAutoCreate())
1376          this.encounter = new Reference(); // cc
1377      return this.encounter;
1378    }
1379
1380    public boolean hasEncounter() { 
1381      return this.encounter != null && !this.encounter.isEmpty();
1382    }
1383
1384    /**
1385     * @param value {@link #encounter} (The Encounter during which this CommunicationRequest was created or to which the creation of this record is tightly associated.)
1386     */
1387    public CommunicationRequest setEncounter(Reference value) { 
1388      this.encounter = value;
1389      return this;
1390    }
1391
1392    /**
1393     * @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 during which this CommunicationRequest was created or to which the creation of this record is tightly associated.)
1394     */
1395    public Encounter getEncounterTarget() { 
1396      if (this.encounterTarget == null)
1397        if (Configuration.errorOnAutoCreate())
1398          throw new Error("Attempt to auto-create CommunicationRequest.encounter");
1399        else if (Configuration.doAutoCreate())
1400          this.encounterTarget = new Encounter(); // aa
1401      return this.encounterTarget;
1402    }
1403
1404    /**
1405     * @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 during which this CommunicationRequest was created or to which the creation of this record is tightly associated.)
1406     */
1407    public CommunicationRequest setEncounterTarget(Encounter value) { 
1408      this.encounterTarget = value;
1409      return this;
1410    }
1411
1412    /**
1413     * @return {@link #payload} (Text, attachment(s), or resource(s) to be communicated to the recipient.)
1414     */
1415    public List<CommunicationRequestPayloadComponent> getPayload() { 
1416      if (this.payload == null)
1417        this.payload = new ArrayList<CommunicationRequestPayloadComponent>();
1418      return this.payload;
1419    }
1420
1421    /**
1422     * @return Returns a reference to <code>this</code> for easy method chaining
1423     */
1424    public CommunicationRequest setPayload(List<CommunicationRequestPayloadComponent> thePayload) { 
1425      this.payload = thePayload;
1426      return this;
1427    }
1428
1429    public boolean hasPayload() { 
1430      if (this.payload == null)
1431        return false;
1432      for (CommunicationRequestPayloadComponent item : this.payload)
1433        if (!item.isEmpty())
1434          return true;
1435      return false;
1436    }
1437
1438    public CommunicationRequestPayloadComponent addPayload() { //3
1439      CommunicationRequestPayloadComponent t = new CommunicationRequestPayloadComponent();
1440      if (this.payload == null)
1441        this.payload = new ArrayList<CommunicationRequestPayloadComponent>();
1442      this.payload.add(t);
1443      return t;
1444    }
1445
1446    public CommunicationRequest addPayload(CommunicationRequestPayloadComponent t) { //3
1447      if (t == null)
1448        return this;
1449      if (this.payload == null)
1450        this.payload = new ArrayList<CommunicationRequestPayloadComponent>();
1451      this.payload.add(t);
1452      return this;
1453    }
1454
1455    /**
1456     * @return The first repetition of repeating field {@link #payload}, creating it if it does not already exist
1457     */
1458    public CommunicationRequestPayloadComponent getPayloadFirstRep() { 
1459      if (getPayload().isEmpty()) {
1460        addPayload();
1461      }
1462      return getPayload().get(0);
1463    }
1464
1465    /**
1466     * @return {@link #occurrence} (The time when this communication is to occur.)
1467     */
1468    public Type getOccurrence() { 
1469      return this.occurrence;
1470    }
1471
1472    /**
1473     * @return {@link #occurrence} (The time when this communication is to occur.)
1474     */
1475    public DateTimeType getOccurrenceDateTimeType() throws FHIRException { 
1476      if (this.occurrence == null)
1477        this.occurrence = new DateTimeType();
1478      if (!(this.occurrence instanceof DateTimeType))
1479        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.occurrence.getClass().getName()+" was encountered");
1480      return (DateTimeType) this.occurrence;
1481    }
1482
1483    public boolean hasOccurrenceDateTimeType() { 
1484      return this != null && this.occurrence instanceof DateTimeType;
1485    }
1486
1487    /**
1488     * @return {@link #occurrence} (The time when this communication is to occur.)
1489     */
1490    public Period getOccurrencePeriod() throws FHIRException { 
1491      if (this.occurrence == null)
1492        this.occurrence = new Period();
1493      if (!(this.occurrence instanceof Period))
1494        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.occurrence.getClass().getName()+" was encountered");
1495      return (Period) this.occurrence;
1496    }
1497
1498    public boolean hasOccurrencePeriod() { 
1499      return this != null && this.occurrence instanceof Period;
1500    }
1501
1502    public boolean hasOccurrence() { 
1503      return this.occurrence != null && !this.occurrence.isEmpty();
1504    }
1505
1506    /**
1507     * @param value {@link #occurrence} (The time when this communication is to occur.)
1508     */
1509    public CommunicationRequest setOccurrence(Type value) { 
1510      if (value != null && !(value instanceof DateTimeType || value instanceof Period))
1511        throw new Error("Not the right type for CommunicationRequest.occurrence[x]: "+value.fhirType());
1512      this.occurrence = value;
1513      return this;
1514    }
1515
1516    /**
1517     * @return {@link #authoredOn} (For draft requests, indicates the date of initial creation.  For requests with other statuses, indicates the date of activation.). This is the underlying object with id, value and extensions. The accessor "getAuthoredOn" gives direct access to the value
1518     */
1519    public DateTimeType getAuthoredOnElement() { 
1520      if (this.authoredOn == null)
1521        if (Configuration.errorOnAutoCreate())
1522          throw new Error("Attempt to auto-create CommunicationRequest.authoredOn");
1523        else if (Configuration.doAutoCreate())
1524          this.authoredOn = new DateTimeType(); // bb
1525      return this.authoredOn;
1526    }
1527
1528    public boolean hasAuthoredOnElement() { 
1529      return this.authoredOn != null && !this.authoredOn.isEmpty();
1530    }
1531
1532    public boolean hasAuthoredOn() { 
1533      return this.authoredOn != null && !this.authoredOn.isEmpty();
1534    }
1535
1536    /**
1537     * @param value {@link #authoredOn} (For draft requests, indicates the date of initial creation.  For requests with other statuses, indicates the date of activation.). This is the underlying object with id, value and extensions. The accessor "getAuthoredOn" gives direct access to the value
1538     */
1539    public CommunicationRequest setAuthoredOnElement(DateTimeType value) { 
1540      this.authoredOn = value;
1541      return this;
1542    }
1543
1544    /**
1545     * @return For draft requests, indicates the date of initial creation.  For requests with other statuses, indicates the date of activation.
1546     */
1547    public Date getAuthoredOn() { 
1548      return this.authoredOn == null ? null : this.authoredOn.getValue();
1549    }
1550
1551    /**
1552     * @param value For draft requests, indicates the date of initial creation.  For requests with other statuses, indicates the date of activation.
1553     */
1554    public CommunicationRequest setAuthoredOn(Date value) { 
1555      if (value == null)
1556        this.authoredOn = null;
1557      else {
1558        if (this.authoredOn == null)
1559          this.authoredOn = new DateTimeType();
1560        this.authoredOn.setValue(value);
1561      }
1562      return this;
1563    }
1564
1565    /**
1566     * @return {@link #requester} (The device, individual, or organization who initiated the request and has responsibility for its activation.)
1567     */
1568    public Reference getRequester() { 
1569      if (this.requester == null)
1570        if (Configuration.errorOnAutoCreate())
1571          throw new Error("Attempt to auto-create CommunicationRequest.requester");
1572        else if (Configuration.doAutoCreate())
1573          this.requester = new Reference(); // cc
1574      return this.requester;
1575    }
1576
1577    public boolean hasRequester() { 
1578      return this.requester != null && !this.requester.isEmpty();
1579    }
1580
1581    /**
1582     * @param value {@link #requester} (The device, individual, or organization who initiated the request and has responsibility for its activation.)
1583     */
1584    public CommunicationRequest setRequester(Reference value) { 
1585      this.requester = value;
1586      return this;
1587    }
1588
1589    /**
1590     * @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 device, individual, or organization who initiated the request and has responsibility for its activation.)
1591     */
1592    public Resource getRequesterTarget() { 
1593      return this.requesterTarget;
1594    }
1595
1596    /**
1597     * @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 device, individual, or organization who initiated the request and has responsibility for its activation.)
1598     */
1599    public CommunicationRequest setRequesterTarget(Resource value) { 
1600      this.requesterTarget = value;
1601      return this;
1602    }
1603
1604    /**
1605     * @return {@link #recipient} (The entity (e.g. person, organization, clinical information system, device, group, or care team) which is the intended target of the communication.)
1606     */
1607    public List<Reference> getRecipient() { 
1608      if (this.recipient == null)
1609        this.recipient = new ArrayList<Reference>();
1610      return this.recipient;
1611    }
1612
1613    /**
1614     * @return Returns a reference to <code>this</code> for easy method chaining
1615     */
1616    public CommunicationRequest setRecipient(List<Reference> theRecipient) { 
1617      this.recipient = theRecipient;
1618      return this;
1619    }
1620
1621    public boolean hasRecipient() { 
1622      if (this.recipient == null)
1623        return false;
1624      for (Reference item : this.recipient)
1625        if (!item.isEmpty())
1626          return true;
1627      return false;
1628    }
1629
1630    public Reference addRecipient() { //3
1631      Reference t = new Reference();
1632      if (this.recipient == null)
1633        this.recipient = new ArrayList<Reference>();
1634      this.recipient.add(t);
1635      return t;
1636    }
1637
1638    public CommunicationRequest addRecipient(Reference t) { //3
1639      if (t == null)
1640        return this;
1641      if (this.recipient == null)
1642        this.recipient = new ArrayList<Reference>();
1643      this.recipient.add(t);
1644      return this;
1645    }
1646
1647    /**
1648     * @return The first repetition of repeating field {@link #recipient}, creating it if it does not already exist
1649     */
1650    public Reference getRecipientFirstRep() { 
1651      if (getRecipient().isEmpty()) {
1652        addRecipient();
1653      }
1654      return getRecipient().get(0);
1655    }
1656
1657    /**
1658     * @deprecated Use Reference#setResource(IBaseResource) instead
1659     */
1660    @Deprecated
1661    public List<Resource> getRecipientTarget() { 
1662      if (this.recipientTarget == null)
1663        this.recipientTarget = new ArrayList<Resource>();
1664      return this.recipientTarget;
1665    }
1666
1667    /**
1668     * @return {@link #sender} (The entity (e.g. person, organization, clinical information system, or device) which is to be the source of the communication.)
1669     */
1670    public Reference getSender() { 
1671      if (this.sender == null)
1672        if (Configuration.errorOnAutoCreate())
1673          throw new Error("Attempt to auto-create CommunicationRequest.sender");
1674        else if (Configuration.doAutoCreate())
1675          this.sender = new Reference(); // cc
1676      return this.sender;
1677    }
1678
1679    public boolean hasSender() { 
1680      return this.sender != null && !this.sender.isEmpty();
1681    }
1682
1683    /**
1684     * @param value {@link #sender} (The entity (e.g. person, organization, clinical information system, or device) which is to be the source of the communication.)
1685     */
1686    public CommunicationRequest setSender(Reference value) { 
1687      this.sender = value;
1688      return this;
1689    }
1690
1691    /**
1692     * @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.)
1693     */
1694    public Resource getSenderTarget() { 
1695      return this.senderTarget;
1696    }
1697
1698    /**
1699     * @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.)
1700     */
1701    public CommunicationRequest setSenderTarget(Resource value) { 
1702      this.senderTarget = value;
1703      return this;
1704    }
1705
1706    /**
1707     * @return {@link #reasonCode} (Describes why the request is being made in coded or textual form.)
1708     */
1709    public List<CodeableConcept> getReasonCode() { 
1710      if (this.reasonCode == null)
1711        this.reasonCode = new ArrayList<CodeableConcept>();
1712      return this.reasonCode;
1713    }
1714
1715    /**
1716     * @return Returns a reference to <code>this</code> for easy method chaining
1717     */
1718    public CommunicationRequest setReasonCode(List<CodeableConcept> theReasonCode) { 
1719      this.reasonCode = theReasonCode;
1720      return this;
1721    }
1722
1723    public boolean hasReasonCode() { 
1724      if (this.reasonCode == null)
1725        return false;
1726      for (CodeableConcept item : this.reasonCode)
1727        if (!item.isEmpty())
1728          return true;
1729      return false;
1730    }
1731
1732    public CodeableConcept addReasonCode() { //3
1733      CodeableConcept t = new CodeableConcept();
1734      if (this.reasonCode == null)
1735        this.reasonCode = new ArrayList<CodeableConcept>();
1736      this.reasonCode.add(t);
1737      return t;
1738    }
1739
1740    public CommunicationRequest addReasonCode(CodeableConcept t) { //3
1741      if (t == null)
1742        return this;
1743      if (this.reasonCode == null)
1744        this.reasonCode = new ArrayList<CodeableConcept>();
1745      this.reasonCode.add(t);
1746      return this;
1747    }
1748
1749    /**
1750     * @return The first repetition of repeating field {@link #reasonCode}, creating it if it does not already exist
1751     */
1752    public CodeableConcept getReasonCodeFirstRep() { 
1753      if (getReasonCode().isEmpty()) {
1754        addReasonCode();
1755      }
1756      return getReasonCode().get(0);
1757    }
1758
1759    /**
1760     * @return {@link #reasonReference} (Indicates another resource whose existence justifies this request.)
1761     */
1762    public List<Reference> getReasonReference() { 
1763      if (this.reasonReference == null)
1764        this.reasonReference = new ArrayList<Reference>();
1765      return this.reasonReference;
1766    }
1767
1768    /**
1769     * @return Returns a reference to <code>this</code> for easy method chaining
1770     */
1771    public CommunicationRequest setReasonReference(List<Reference> theReasonReference) { 
1772      this.reasonReference = theReasonReference;
1773      return this;
1774    }
1775
1776    public boolean hasReasonReference() { 
1777      if (this.reasonReference == null)
1778        return false;
1779      for (Reference item : this.reasonReference)
1780        if (!item.isEmpty())
1781          return true;
1782      return false;
1783    }
1784
1785    public Reference addReasonReference() { //3
1786      Reference t = new Reference();
1787      if (this.reasonReference == null)
1788        this.reasonReference = new ArrayList<Reference>();
1789      this.reasonReference.add(t);
1790      return t;
1791    }
1792
1793    public CommunicationRequest addReasonReference(Reference t) { //3
1794      if (t == null)
1795        return this;
1796      if (this.reasonReference == null)
1797        this.reasonReference = new ArrayList<Reference>();
1798      this.reasonReference.add(t);
1799      return this;
1800    }
1801
1802    /**
1803     * @return The first repetition of repeating field {@link #reasonReference}, creating it if it does not already exist
1804     */
1805    public Reference getReasonReferenceFirstRep() { 
1806      if (getReasonReference().isEmpty()) {
1807        addReasonReference();
1808      }
1809      return getReasonReference().get(0);
1810    }
1811
1812    /**
1813     * @deprecated Use Reference#setResource(IBaseResource) instead
1814     */
1815    @Deprecated
1816    public List<Resource> getReasonReferenceTarget() { 
1817      if (this.reasonReferenceTarget == null)
1818        this.reasonReferenceTarget = new ArrayList<Resource>();
1819      return this.reasonReferenceTarget;
1820    }
1821
1822    /**
1823     * @return {@link #note} (Comments made about the request by the requester, sender, recipient, subject or other participants.)
1824     */
1825    public List<Annotation> getNote() { 
1826      if (this.note == null)
1827        this.note = new ArrayList<Annotation>();
1828      return this.note;
1829    }
1830
1831    /**
1832     * @return Returns a reference to <code>this</code> for easy method chaining
1833     */
1834    public CommunicationRequest setNote(List<Annotation> theNote) { 
1835      this.note = theNote;
1836      return this;
1837    }
1838
1839    public boolean hasNote() { 
1840      if (this.note == null)
1841        return false;
1842      for (Annotation item : this.note)
1843        if (!item.isEmpty())
1844          return true;
1845      return false;
1846    }
1847
1848    public Annotation addNote() { //3
1849      Annotation t = new Annotation();
1850      if (this.note == null)
1851        this.note = new ArrayList<Annotation>();
1852      this.note.add(t);
1853      return t;
1854    }
1855
1856    public CommunicationRequest addNote(Annotation t) { //3
1857      if (t == null)
1858        return this;
1859      if (this.note == null)
1860        this.note = new ArrayList<Annotation>();
1861      this.note.add(t);
1862      return this;
1863    }
1864
1865    /**
1866     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist
1867     */
1868    public Annotation getNoteFirstRep() { 
1869      if (getNote().isEmpty()) {
1870        addNote();
1871      }
1872      return getNote().get(0);
1873    }
1874
1875      protected void listChildren(List<Property> children) {
1876        super.listChildren(children);
1877        children.add(new Property("identifier", "Identifier", "Business identifiers assigned to this communication request by the performer or other systems which remain constant as the resource is updated and propagates from server to server.", 0, java.lang.Integer.MAX_VALUE, identifier));
1878        children.add(new Property("basedOn", "Reference(Any)", "A plan or proposal that is fulfilled in whole or in part by this request.", 0, java.lang.Integer.MAX_VALUE, basedOn));
1879        children.add(new Property("replaces", "Reference(CommunicationRequest)", "Completed or terminated request(s) whose function is taken by this new request.", 0, java.lang.Integer.MAX_VALUE, replaces));
1880        children.add(new Property("groupIdentifier", "Identifier", "A shared identifier common to all requests that were authorized more or less simultaneously by a single author, representing the identifier of the requisition, prescription or similar form.", 0, 1, groupIdentifier));
1881        children.add(new Property("status", "code", "The status of the proposal or order.", 0, 1, status));
1882        children.add(new Property("statusReason", "CodeableConcept", "Captures the reason for the current state of the CommunicationRequest.", 0, 1, statusReason));
1883        children.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));
1884        children.add(new Property("priority", "code", "Characterizes how quickly the proposed act must be initiated. Includes concepts such as stat, urgent, routine.", 0, 1, priority));
1885        children.add(new Property("doNotPerform", "boolean", "If true indicates that the CommunicationRequest is asking for the specified action to *not* occur.", 0, 1, doNotPerform));
1886        children.add(new Property("medium", "CodeableConcept", "A channel that was used for this communication (e.g. email, fax).", 0, java.lang.Integer.MAX_VALUE, medium));
1887        children.add(new Property("subject", "Reference(Patient|Group)", "The patient or group that is the focus of this communication request.", 0, 1, subject));
1888        children.add(new Property("about", "Reference(Any)", "Other resources that pertain to this communication request and to which this communication request should be associated.", 0, java.lang.Integer.MAX_VALUE, about));
1889        children.add(new Property("encounter", "Reference(Encounter)", "The Encounter during which this CommunicationRequest was created or to which the creation of this record is tightly associated.", 0, 1, encounter));
1890        children.add(new Property("payload", "", "Text, attachment(s), or resource(s) to be communicated to the recipient.", 0, java.lang.Integer.MAX_VALUE, payload));
1891        children.add(new Property("occurrence[x]", "dateTime|Period", "The time when this communication is to occur.", 0, 1, occurrence));
1892        children.add(new Property("authoredOn", "dateTime", "For draft requests, indicates the date of initial creation.  For requests with other statuses, indicates the date of activation.", 0, 1, authoredOn));
1893        children.add(new Property("requester", "Reference(Practitioner|PractitionerRole|Organization|Patient|RelatedPerson|Device)", "The device, individual, or organization who initiated the request and has responsibility for its activation.", 0, 1, requester));
1894        children.add(new Property("recipient", "Reference(Device|Organization|Patient|Practitioner|PractitionerRole|RelatedPerson|Group|CareTeam|HealthcareService)", "The entity (e.g. person, organization, clinical information system, device, group, or care team) which is the intended target of the communication.", 0, java.lang.Integer.MAX_VALUE, recipient));
1895        children.add(new Property("sender", "Reference(Device|Organization|Patient|Practitioner|PractitionerRole|RelatedPerson|HealthcareService)", "The entity (e.g. person, organization, clinical information system, or device) which is to be the source of the communication.", 0, 1, sender));
1896        children.add(new Property("reasonCode", "CodeableConcept", "Describes why the request is being made in coded or textual form.", 0, java.lang.Integer.MAX_VALUE, reasonCode));
1897        children.add(new Property("reasonReference", "Reference(Condition|Observation|DiagnosticReport|DocumentReference)", "Indicates another resource whose existence justifies this request.", 0, java.lang.Integer.MAX_VALUE, reasonReference));
1898        children.add(new Property("note", "Annotation", "Comments made about the request by the requester, sender, recipient, subject or other participants.", 0, java.lang.Integer.MAX_VALUE, note));
1899      }
1900
1901      @Override
1902      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1903        switch (_hash) {
1904        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Business identifiers assigned to this communication request by the performer or other systems which remain constant as the resource is updated and propagates from server to server.", 0, java.lang.Integer.MAX_VALUE, identifier);
1905        case -332612366: /*basedOn*/  return new Property("basedOn", "Reference(Any)", "A plan or proposal that is fulfilled in whole or in part by this request.", 0, java.lang.Integer.MAX_VALUE, basedOn);
1906        case -430332865: /*replaces*/  return new Property("replaces", "Reference(CommunicationRequest)", "Completed or terminated request(s) whose function is taken by this new request.", 0, java.lang.Integer.MAX_VALUE, replaces);
1907        case -445338488: /*groupIdentifier*/  return new Property("groupIdentifier", "Identifier", "A shared identifier common to all requests that were authorized more or less simultaneously by a single author, representing the identifier of the requisition, prescription or similar form.", 0, 1, groupIdentifier);
1908        case -892481550: /*status*/  return new Property("status", "code", "The status of the proposal or order.", 0, 1, status);
1909        case 2051346646: /*statusReason*/  return new Property("statusReason", "CodeableConcept", "Captures the reason for the current state of the CommunicationRequest.", 0, 1, statusReason);
1910        case 50511102: /*category*/  return 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);
1911        case -1165461084: /*priority*/  return new Property("priority", "code", "Characterizes how quickly the proposed act must be initiated. Includes concepts such as stat, urgent, routine.", 0, 1, priority);
1912        case -1788508167: /*doNotPerform*/  return new Property("doNotPerform", "boolean", "If true indicates that the CommunicationRequest is asking for the specified action to *not* occur.", 0, 1, doNotPerform);
1913        case -1078030475: /*medium*/  return new Property("medium", "CodeableConcept", "A channel that was used for this communication (e.g. email, fax).", 0, java.lang.Integer.MAX_VALUE, medium);
1914        case -1867885268: /*subject*/  return new Property("subject", "Reference(Patient|Group)", "The patient or group that is the focus of this communication request.", 0, 1, subject);
1915        case 92611469: /*about*/  return new Property("about", "Reference(Any)", "Other resources that pertain to this communication request and to which this communication request should be associated.", 0, java.lang.Integer.MAX_VALUE, about);
1916        case 1524132147: /*encounter*/  return new Property("encounter", "Reference(Encounter)", "The Encounter during which this CommunicationRequest was created or to which the creation of this record is tightly associated.", 0, 1, encounter);
1917        case -786701938: /*payload*/  return new Property("payload", "", "Text, attachment(s), or resource(s) to be communicated to the recipient.", 0, java.lang.Integer.MAX_VALUE, payload);
1918        case -2022646513: /*occurrence[x]*/  return new Property("occurrence[x]", "dateTime|Period", "The time when this communication is to occur.", 0, 1, occurrence);
1919        case 1687874001: /*occurrence*/  return new Property("occurrence[x]", "dateTime|Period", "The time when this communication is to occur.", 0, 1, occurrence);
1920        case -298443636: /*occurrenceDateTime*/  return new Property("occurrence[x]", "dateTime|Period", "The time when this communication is to occur.", 0, 1, occurrence);
1921        case 1397156594: /*occurrencePeriod*/  return new Property("occurrence[x]", "dateTime|Period", "The time when this communication is to occur.", 0, 1, occurrence);
1922        case -1500852503: /*authoredOn*/  return new Property("authoredOn", "dateTime", "For draft requests, indicates the date of initial creation.  For requests with other statuses, indicates the date of activation.", 0, 1, authoredOn);
1923        case 693933948: /*requester*/  return new Property("requester", "Reference(Practitioner|PractitionerRole|Organization|Patient|RelatedPerson|Device)", "The device, individual, or organization who initiated the request and has responsibility for its activation.", 0, 1, requester);
1924        case 820081177: /*recipient*/  return new Property("recipient", "Reference(Device|Organization|Patient|Practitioner|PractitionerRole|RelatedPerson|Group|CareTeam|HealthcareService)", "The entity (e.g. person, organization, clinical information system, device, group, or care team) which is the intended target of the communication.", 0, java.lang.Integer.MAX_VALUE, recipient);
1925        case -905962955: /*sender*/  return new Property("sender", "Reference(Device|Organization|Patient|Practitioner|PractitionerRole|RelatedPerson|HealthcareService)", "The entity (e.g. person, organization, clinical information system, or device) which is to be the source of the communication.", 0, 1, sender);
1926        case 722137681: /*reasonCode*/  return new Property("reasonCode", "CodeableConcept", "Describes why the request is being made in coded or textual form.", 0, java.lang.Integer.MAX_VALUE, reasonCode);
1927        case -1146218137: /*reasonReference*/  return new Property("reasonReference", "Reference(Condition|Observation|DiagnosticReport|DocumentReference)", "Indicates another resource whose existence justifies this request.", 0, java.lang.Integer.MAX_VALUE, reasonReference);
1928        case 3387378: /*note*/  return new Property("note", "Annotation", "Comments made about the request by the requester, sender, recipient, subject or other participants.", 0, java.lang.Integer.MAX_VALUE, note);
1929        default: return super.getNamedProperty(_hash, _name, _checkValid);
1930        }
1931
1932      }
1933
1934      @Override
1935      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1936        switch (hash) {
1937        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1938        case -332612366: /*basedOn*/ return this.basedOn == null ? new Base[0] : this.basedOn.toArray(new Base[this.basedOn.size()]); // Reference
1939        case -430332865: /*replaces*/ return this.replaces == null ? new Base[0] : this.replaces.toArray(new Base[this.replaces.size()]); // Reference
1940        case -445338488: /*groupIdentifier*/ return this.groupIdentifier == null ? new Base[0] : new Base[] {this.groupIdentifier}; // Identifier
1941        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<CommunicationRequestStatus>
1942        case 2051346646: /*statusReason*/ return this.statusReason == null ? new Base[0] : new Base[] {this.statusReason}; // CodeableConcept
1943        case 50511102: /*category*/ return this.category == null ? new Base[0] : this.category.toArray(new Base[this.category.size()]); // CodeableConcept
1944        case -1165461084: /*priority*/ return this.priority == null ? new Base[0] : new Base[] {this.priority}; // Enumeration<CommunicationPriority>
1945        case -1788508167: /*doNotPerform*/ return this.doNotPerform == null ? new Base[0] : new Base[] {this.doNotPerform}; // BooleanType
1946        case -1078030475: /*medium*/ return this.medium == null ? new Base[0] : this.medium.toArray(new Base[this.medium.size()]); // CodeableConcept
1947        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
1948        case 92611469: /*about*/ return this.about == null ? new Base[0] : this.about.toArray(new Base[this.about.size()]); // Reference
1949        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : new Base[] {this.encounter}; // Reference
1950        case -786701938: /*payload*/ return this.payload == null ? new Base[0] : this.payload.toArray(new Base[this.payload.size()]); // CommunicationRequestPayloadComponent
1951        case 1687874001: /*occurrence*/ return this.occurrence == null ? new Base[0] : new Base[] {this.occurrence}; // Type
1952        case -1500852503: /*authoredOn*/ return this.authoredOn == null ? new Base[0] : new Base[] {this.authoredOn}; // DateTimeType
1953        case 693933948: /*requester*/ return this.requester == null ? new Base[0] : new Base[] {this.requester}; // Reference
1954        case 820081177: /*recipient*/ return this.recipient == null ? new Base[0] : this.recipient.toArray(new Base[this.recipient.size()]); // Reference
1955        case -905962955: /*sender*/ return this.sender == null ? new Base[0] : new Base[] {this.sender}; // Reference
1956        case 722137681: /*reasonCode*/ return this.reasonCode == null ? new Base[0] : this.reasonCode.toArray(new Base[this.reasonCode.size()]); // CodeableConcept
1957        case -1146218137: /*reasonReference*/ return this.reasonReference == null ? new Base[0] : this.reasonReference.toArray(new Base[this.reasonReference.size()]); // Reference
1958        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
1959        default: return super.getProperty(hash, name, checkValid);
1960        }
1961
1962      }
1963
1964      @Override
1965      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1966        switch (hash) {
1967        case -1618432855: // identifier
1968          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1969          return value;
1970        case -332612366: // basedOn
1971          this.getBasedOn().add(castToReference(value)); // Reference
1972          return value;
1973        case -430332865: // replaces
1974          this.getReplaces().add(castToReference(value)); // Reference
1975          return value;
1976        case -445338488: // groupIdentifier
1977          this.groupIdentifier = castToIdentifier(value); // Identifier
1978          return value;
1979        case -892481550: // status
1980          value = new CommunicationRequestStatusEnumFactory().fromType(castToCode(value));
1981          this.status = (Enumeration) value; // Enumeration<CommunicationRequestStatus>
1982          return value;
1983        case 2051346646: // statusReason
1984          this.statusReason = castToCodeableConcept(value); // CodeableConcept
1985          return value;
1986        case 50511102: // category
1987          this.getCategory().add(castToCodeableConcept(value)); // CodeableConcept
1988          return value;
1989        case -1165461084: // priority
1990          value = new CommunicationPriorityEnumFactory().fromType(castToCode(value));
1991          this.priority = (Enumeration) value; // Enumeration<CommunicationPriority>
1992          return value;
1993        case -1788508167: // doNotPerform
1994          this.doNotPerform = castToBoolean(value); // BooleanType
1995          return value;
1996        case -1078030475: // medium
1997          this.getMedium().add(castToCodeableConcept(value)); // CodeableConcept
1998          return value;
1999        case -1867885268: // subject
2000          this.subject = castToReference(value); // Reference
2001          return value;
2002        case 92611469: // about
2003          this.getAbout().add(castToReference(value)); // Reference
2004          return value;
2005        case 1524132147: // encounter
2006          this.encounter = castToReference(value); // Reference
2007          return value;
2008        case -786701938: // payload
2009          this.getPayload().add((CommunicationRequestPayloadComponent) value); // CommunicationRequestPayloadComponent
2010          return value;
2011        case 1687874001: // occurrence
2012          this.occurrence = castToType(value); // Type
2013          return value;
2014        case -1500852503: // authoredOn
2015          this.authoredOn = castToDateTime(value); // DateTimeType
2016          return value;
2017        case 693933948: // requester
2018          this.requester = castToReference(value); // Reference
2019          return value;
2020        case 820081177: // recipient
2021          this.getRecipient().add(castToReference(value)); // Reference
2022          return value;
2023        case -905962955: // sender
2024          this.sender = castToReference(value); // Reference
2025          return value;
2026        case 722137681: // reasonCode
2027          this.getReasonCode().add(castToCodeableConcept(value)); // CodeableConcept
2028          return value;
2029        case -1146218137: // reasonReference
2030          this.getReasonReference().add(castToReference(value)); // Reference
2031          return value;
2032        case 3387378: // note
2033          this.getNote().add(castToAnnotation(value)); // Annotation
2034          return value;
2035        default: return super.setProperty(hash, name, value);
2036        }
2037
2038      }
2039
2040      @Override
2041      public Base setProperty(String name, Base value) throws FHIRException {
2042        if (name.equals("identifier")) {
2043          this.getIdentifier().add(castToIdentifier(value));
2044        } else if (name.equals("basedOn")) {
2045          this.getBasedOn().add(castToReference(value));
2046        } else if (name.equals("replaces")) {
2047          this.getReplaces().add(castToReference(value));
2048        } else if (name.equals("groupIdentifier")) {
2049          this.groupIdentifier = castToIdentifier(value); // Identifier
2050        } else if (name.equals("status")) {
2051          value = new CommunicationRequestStatusEnumFactory().fromType(castToCode(value));
2052          this.status = (Enumeration) value; // Enumeration<CommunicationRequestStatus>
2053        } else if (name.equals("statusReason")) {
2054          this.statusReason = castToCodeableConcept(value); // CodeableConcept
2055        } else if (name.equals("category")) {
2056          this.getCategory().add(castToCodeableConcept(value));
2057        } else if (name.equals("priority")) {
2058          value = new CommunicationPriorityEnumFactory().fromType(castToCode(value));
2059          this.priority = (Enumeration) value; // Enumeration<CommunicationPriority>
2060        } else if (name.equals("doNotPerform")) {
2061          this.doNotPerform = castToBoolean(value); // BooleanType
2062        } else if (name.equals("medium")) {
2063          this.getMedium().add(castToCodeableConcept(value));
2064        } else if (name.equals("subject")) {
2065          this.subject = castToReference(value); // Reference
2066        } else if (name.equals("about")) {
2067          this.getAbout().add(castToReference(value));
2068        } else if (name.equals("encounter")) {
2069          this.encounter = castToReference(value); // Reference
2070        } else if (name.equals("payload")) {
2071          this.getPayload().add((CommunicationRequestPayloadComponent) value);
2072        } else if (name.equals("occurrence[x]")) {
2073          this.occurrence = castToType(value); // Type
2074        } else if (name.equals("authoredOn")) {
2075          this.authoredOn = castToDateTime(value); // DateTimeType
2076        } else if (name.equals("requester")) {
2077          this.requester = castToReference(value); // Reference
2078        } else if (name.equals("recipient")) {
2079          this.getRecipient().add(castToReference(value));
2080        } else if (name.equals("sender")) {
2081          this.sender = castToReference(value); // Reference
2082        } else if (name.equals("reasonCode")) {
2083          this.getReasonCode().add(castToCodeableConcept(value));
2084        } else if (name.equals("reasonReference")) {
2085          this.getReasonReference().add(castToReference(value));
2086        } else if (name.equals("note")) {
2087          this.getNote().add(castToAnnotation(value));
2088        } else
2089          return super.setProperty(name, value);
2090        return value;
2091      }
2092
2093      @Override
2094      public Base makeProperty(int hash, String name) throws FHIRException {
2095        switch (hash) {
2096        case -1618432855:  return addIdentifier(); 
2097        case -332612366:  return addBasedOn(); 
2098        case -430332865:  return addReplaces(); 
2099        case -445338488:  return getGroupIdentifier(); 
2100        case -892481550:  return getStatusElement();
2101        case 2051346646:  return getStatusReason(); 
2102        case 50511102:  return addCategory(); 
2103        case -1165461084:  return getPriorityElement();
2104        case -1788508167:  return getDoNotPerformElement();
2105        case -1078030475:  return addMedium(); 
2106        case -1867885268:  return getSubject(); 
2107        case 92611469:  return addAbout(); 
2108        case 1524132147:  return getEncounter(); 
2109        case -786701938:  return addPayload(); 
2110        case -2022646513:  return getOccurrence(); 
2111        case 1687874001:  return getOccurrence(); 
2112        case -1500852503:  return getAuthoredOnElement();
2113        case 693933948:  return getRequester(); 
2114        case 820081177:  return addRecipient(); 
2115        case -905962955:  return getSender(); 
2116        case 722137681:  return addReasonCode(); 
2117        case -1146218137:  return addReasonReference(); 
2118        case 3387378:  return addNote(); 
2119        default: return super.makeProperty(hash, name);
2120        }
2121
2122      }
2123
2124      @Override
2125      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2126        switch (hash) {
2127        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2128        case -332612366: /*basedOn*/ return new String[] {"Reference"};
2129        case -430332865: /*replaces*/ return new String[] {"Reference"};
2130        case -445338488: /*groupIdentifier*/ return new String[] {"Identifier"};
2131        case -892481550: /*status*/ return new String[] {"code"};
2132        case 2051346646: /*statusReason*/ return new String[] {"CodeableConcept"};
2133        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
2134        case -1165461084: /*priority*/ return new String[] {"code"};
2135        case -1788508167: /*doNotPerform*/ return new String[] {"boolean"};
2136        case -1078030475: /*medium*/ return new String[] {"CodeableConcept"};
2137        case -1867885268: /*subject*/ return new String[] {"Reference"};
2138        case 92611469: /*about*/ return new String[] {"Reference"};
2139        case 1524132147: /*encounter*/ return new String[] {"Reference"};
2140        case -786701938: /*payload*/ return new String[] {};
2141        case 1687874001: /*occurrence*/ return new String[] {"dateTime", "Period"};
2142        case -1500852503: /*authoredOn*/ return new String[] {"dateTime"};
2143        case 693933948: /*requester*/ return new String[] {"Reference"};
2144        case 820081177: /*recipient*/ return new String[] {"Reference"};
2145        case -905962955: /*sender*/ return new String[] {"Reference"};
2146        case 722137681: /*reasonCode*/ return new String[] {"CodeableConcept"};
2147        case -1146218137: /*reasonReference*/ return new String[] {"Reference"};
2148        case 3387378: /*note*/ return new String[] {"Annotation"};
2149        default: return super.getTypesForProperty(hash, name);
2150        }
2151
2152      }
2153
2154      @Override
2155      public Base addChild(String name) throws FHIRException {
2156        if (name.equals("identifier")) {
2157          return addIdentifier();
2158        }
2159        else if (name.equals("basedOn")) {
2160          return addBasedOn();
2161        }
2162        else if (name.equals("replaces")) {
2163          return addReplaces();
2164        }
2165        else if (name.equals("groupIdentifier")) {
2166          this.groupIdentifier = new Identifier();
2167          return this.groupIdentifier;
2168        }
2169        else if (name.equals("status")) {
2170          throw new FHIRException("Cannot call addChild on a primitive type CommunicationRequest.status");
2171        }
2172        else if (name.equals("statusReason")) {
2173          this.statusReason = new CodeableConcept();
2174          return this.statusReason;
2175        }
2176        else if (name.equals("category")) {
2177          return addCategory();
2178        }
2179        else if (name.equals("priority")) {
2180          throw new FHIRException("Cannot call addChild on a primitive type CommunicationRequest.priority");
2181        }
2182        else if (name.equals("doNotPerform")) {
2183          throw new FHIRException("Cannot call addChild on a primitive type CommunicationRequest.doNotPerform");
2184        }
2185        else if (name.equals("medium")) {
2186          return addMedium();
2187        }
2188        else if (name.equals("subject")) {
2189          this.subject = new Reference();
2190          return this.subject;
2191        }
2192        else if (name.equals("about")) {
2193          return addAbout();
2194        }
2195        else if (name.equals("encounter")) {
2196          this.encounter = new Reference();
2197          return this.encounter;
2198        }
2199        else if (name.equals("payload")) {
2200          return addPayload();
2201        }
2202        else if (name.equals("occurrenceDateTime")) {
2203          this.occurrence = new DateTimeType();
2204          return this.occurrence;
2205        }
2206        else if (name.equals("occurrencePeriod")) {
2207          this.occurrence = new Period();
2208          return this.occurrence;
2209        }
2210        else if (name.equals("authoredOn")) {
2211          throw new FHIRException("Cannot call addChild on a primitive type CommunicationRequest.authoredOn");
2212        }
2213        else if (name.equals("requester")) {
2214          this.requester = new Reference();
2215          return this.requester;
2216        }
2217        else if (name.equals("recipient")) {
2218          return addRecipient();
2219        }
2220        else if (name.equals("sender")) {
2221          this.sender = new Reference();
2222          return this.sender;
2223        }
2224        else if (name.equals("reasonCode")) {
2225          return addReasonCode();
2226        }
2227        else if (name.equals("reasonReference")) {
2228          return addReasonReference();
2229        }
2230        else if (name.equals("note")) {
2231          return addNote();
2232        }
2233        else
2234          return super.addChild(name);
2235      }
2236
2237  public String fhirType() {
2238    return "CommunicationRequest";
2239
2240  }
2241
2242      public CommunicationRequest copy() {
2243        CommunicationRequest dst = new CommunicationRequest();
2244        copyValues(dst);
2245        if (identifier != null) {
2246          dst.identifier = new ArrayList<Identifier>();
2247          for (Identifier i : identifier)
2248            dst.identifier.add(i.copy());
2249        };
2250        if (basedOn != null) {
2251          dst.basedOn = new ArrayList<Reference>();
2252          for (Reference i : basedOn)
2253            dst.basedOn.add(i.copy());
2254        };
2255        if (replaces != null) {
2256          dst.replaces = new ArrayList<Reference>();
2257          for (Reference i : replaces)
2258            dst.replaces.add(i.copy());
2259        };
2260        dst.groupIdentifier = groupIdentifier == null ? null : groupIdentifier.copy();
2261        dst.status = status == null ? null : status.copy();
2262        dst.statusReason = statusReason == null ? null : statusReason.copy();
2263        if (category != null) {
2264          dst.category = new ArrayList<CodeableConcept>();
2265          for (CodeableConcept i : category)
2266            dst.category.add(i.copy());
2267        };
2268        dst.priority = priority == null ? null : priority.copy();
2269        dst.doNotPerform = doNotPerform == null ? null : doNotPerform.copy();
2270        if (medium != null) {
2271          dst.medium = new ArrayList<CodeableConcept>();
2272          for (CodeableConcept i : medium)
2273            dst.medium.add(i.copy());
2274        };
2275        dst.subject = subject == null ? null : subject.copy();
2276        if (about != null) {
2277          dst.about = new ArrayList<Reference>();
2278          for (Reference i : about)
2279            dst.about.add(i.copy());
2280        };
2281        dst.encounter = encounter == null ? null : encounter.copy();
2282        if (payload != null) {
2283          dst.payload = new ArrayList<CommunicationRequestPayloadComponent>();
2284          for (CommunicationRequestPayloadComponent i : payload)
2285            dst.payload.add(i.copy());
2286        };
2287        dst.occurrence = occurrence == null ? null : occurrence.copy();
2288        dst.authoredOn = authoredOn == null ? null : authoredOn.copy();
2289        dst.requester = requester == null ? null : requester.copy();
2290        if (recipient != null) {
2291          dst.recipient = new ArrayList<Reference>();
2292          for (Reference i : recipient)
2293            dst.recipient.add(i.copy());
2294        };
2295        dst.sender = sender == null ? null : sender.copy();
2296        if (reasonCode != null) {
2297          dst.reasonCode = new ArrayList<CodeableConcept>();
2298          for (CodeableConcept i : reasonCode)
2299            dst.reasonCode.add(i.copy());
2300        };
2301        if (reasonReference != null) {
2302          dst.reasonReference = new ArrayList<Reference>();
2303          for (Reference i : reasonReference)
2304            dst.reasonReference.add(i.copy());
2305        };
2306        if (note != null) {
2307          dst.note = new ArrayList<Annotation>();
2308          for (Annotation i : note)
2309            dst.note.add(i.copy());
2310        };
2311        return dst;
2312      }
2313
2314      protected CommunicationRequest typedCopy() {
2315        return copy();
2316      }
2317
2318      @Override
2319      public boolean equalsDeep(Base other_) {
2320        if (!super.equalsDeep(other_))
2321          return false;
2322        if (!(other_ instanceof CommunicationRequest))
2323          return false;
2324        CommunicationRequest o = (CommunicationRequest) other_;
2325        return compareDeep(identifier, o.identifier, true) && compareDeep(basedOn, o.basedOn, true) && compareDeep(replaces, o.replaces, true)
2326           && compareDeep(groupIdentifier, o.groupIdentifier, true) && compareDeep(status, o.status, true)
2327           && compareDeep(statusReason, o.statusReason, true) && compareDeep(category, o.category, true) && compareDeep(priority, o.priority, true)
2328           && compareDeep(doNotPerform, o.doNotPerform, true) && compareDeep(medium, o.medium, true) && compareDeep(subject, o.subject, true)
2329           && compareDeep(about, o.about, true) && compareDeep(encounter, o.encounter, true) && compareDeep(payload, o.payload, true)
2330           && compareDeep(occurrence, o.occurrence, true) && compareDeep(authoredOn, o.authoredOn, true) && compareDeep(requester, o.requester, true)
2331           && compareDeep(recipient, o.recipient, true) && compareDeep(sender, o.sender, true) && compareDeep(reasonCode, o.reasonCode, true)
2332           && compareDeep(reasonReference, o.reasonReference, true) && compareDeep(note, o.note, true);
2333      }
2334
2335      @Override
2336      public boolean equalsShallow(Base other_) {
2337        if (!super.equalsShallow(other_))
2338          return false;
2339        if (!(other_ instanceof CommunicationRequest))
2340          return false;
2341        CommunicationRequest o = (CommunicationRequest) other_;
2342        return compareValues(status, o.status, true) && compareValues(priority, o.priority, true) && compareValues(doNotPerform, o.doNotPerform, true)
2343           && compareValues(authoredOn, o.authoredOn, true);
2344      }
2345
2346      public boolean isEmpty() {
2347        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, basedOn, replaces
2348          , groupIdentifier, status, statusReason, category, priority, doNotPerform, medium
2349          , subject, about, encounter, payload, occurrence, authoredOn, requester, recipient
2350          , sender, reasonCode, reasonReference, note);
2351      }
2352
2353  @Override
2354  public ResourceType getResourceType() {
2355    return ResourceType.CommunicationRequest;
2356   }
2357
2358 /**
2359   * Search parameter: <b>requester</b>
2360   * <p>
2361   * Description: <b>Who/what is requesting service</b><br>
2362   * Type: <b>reference</b><br>
2363   * Path: <b>CommunicationRequest.requester</b><br>
2364   * </p>
2365   */
2366  @SearchParamDefinition(name="requester", path="CommunicationRequest.requester", description="Who/what is requesting service", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner"), @ca.uhn.fhir.model.api.annotation.Compartment(name="RelatedPerson") }, target={Device.class, Organization.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class } )
2367  public static final String SP_REQUESTER = "requester";
2368 /**
2369   * <b>Fluent Client</b> search parameter constant for <b>requester</b>
2370   * <p>
2371   * Description: <b>Who/what is requesting service</b><br>
2372   * Type: <b>reference</b><br>
2373   * Path: <b>CommunicationRequest.requester</b><br>
2374   * </p>
2375   */
2376  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam REQUESTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_REQUESTER);
2377
2378/**
2379   * Constant for fluent queries to be used to add include statements. Specifies
2380   * the path value of "<b>CommunicationRequest:requester</b>".
2381   */
2382  public static final ca.uhn.fhir.model.api.Include INCLUDE_REQUESTER = new ca.uhn.fhir.model.api.Include("CommunicationRequest:requester").toLocked();
2383
2384 /**
2385   * Search parameter: <b>authored</b>
2386   * <p>
2387   * Description: <b>When request transitioned to being actionable</b><br>
2388   * Type: <b>date</b><br>
2389   * Path: <b>CommunicationRequest.authoredOn</b><br>
2390   * </p>
2391   */
2392  @SearchParamDefinition(name="authored", path="CommunicationRequest.authoredOn", description="When request transitioned to being actionable", type="date" )
2393  public static final String SP_AUTHORED = "authored";
2394 /**
2395   * <b>Fluent Client</b> search parameter constant for <b>authored</b>
2396   * <p>
2397   * Description: <b>When request transitioned to being actionable</b><br>
2398   * Type: <b>date</b><br>
2399   * Path: <b>CommunicationRequest.authoredOn</b><br>
2400   * </p>
2401   */
2402  public static final ca.uhn.fhir.rest.gclient.DateClientParam AUTHORED = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_AUTHORED);
2403
2404 /**
2405   * Search parameter: <b>identifier</b>
2406   * <p>
2407   * Description: <b>Unique identifier</b><br>
2408   * Type: <b>token</b><br>
2409   * Path: <b>CommunicationRequest.identifier</b><br>
2410   * </p>
2411   */
2412  @SearchParamDefinition(name="identifier", path="CommunicationRequest.identifier", description="Unique identifier", type="token" )
2413  public static final String SP_IDENTIFIER = "identifier";
2414 /**
2415   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2416   * <p>
2417   * Description: <b>Unique identifier</b><br>
2418   * Type: <b>token</b><br>
2419   * Path: <b>CommunicationRequest.identifier</b><br>
2420   * </p>
2421   */
2422  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2423
2424 /**
2425   * Search parameter: <b>subject</b>
2426   * <p>
2427   * Description: <b>Focus of message</b><br>
2428   * Type: <b>reference</b><br>
2429   * Path: <b>CommunicationRequest.subject</b><br>
2430   * </p>
2431   */
2432  @SearchParamDefinition(name="subject", path="CommunicationRequest.subject", description="Focus of message", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Group.class, Patient.class } )
2433  public static final String SP_SUBJECT = "subject";
2434 /**
2435   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
2436   * <p>
2437   * Description: <b>Focus of message</b><br>
2438   * Type: <b>reference</b><br>
2439   * Path: <b>CommunicationRequest.subject</b><br>
2440   * </p>
2441   */
2442  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
2443
2444/**
2445   * Constant for fluent queries to be used to add include statements. Specifies
2446   * the path value of "<b>CommunicationRequest:subject</b>".
2447   */
2448  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("CommunicationRequest:subject").toLocked();
2449
2450 /**
2451   * Search parameter: <b>replaces</b>
2452   * <p>
2453   * Description: <b>Request(s) replaced by this request</b><br>
2454   * Type: <b>reference</b><br>
2455   * Path: <b>CommunicationRequest.replaces</b><br>
2456   * </p>
2457   */
2458  @SearchParamDefinition(name="replaces", path="CommunicationRequest.replaces", description="Request(s) replaced by this request", type="reference", target={CommunicationRequest.class } )
2459  public static final String SP_REPLACES = "replaces";
2460 /**
2461   * <b>Fluent Client</b> search parameter constant for <b>replaces</b>
2462   * <p>
2463   * Description: <b>Request(s) replaced by this request</b><br>
2464   * Type: <b>reference</b><br>
2465   * Path: <b>CommunicationRequest.replaces</b><br>
2466   * </p>
2467   */
2468  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam REPLACES = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_REPLACES);
2469
2470/**
2471   * Constant for fluent queries to be used to add include statements. Specifies
2472   * the path value of "<b>CommunicationRequest:replaces</b>".
2473   */
2474  public static final ca.uhn.fhir.model.api.Include INCLUDE_REPLACES = new ca.uhn.fhir.model.api.Include("CommunicationRequest:replaces").toLocked();
2475
2476 /**
2477   * Search parameter: <b>medium</b>
2478   * <p>
2479   * Description: <b>A channel of communication</b><br>
2480   * Type: <b>token</b><br>
2481   * Path: <b>CommunicationRequest.medium</b><br>
2482   * </p>
2483   */
2484  @SearchParamDefinition(name="medium", path="CommunicationRequest.medium", description="A channel of communication", type="token" )
2485  public static final String SP_MEDIUM = "medium";
2486 /**
2487   * <b>Fluent Client</b> search parameter constant for <b>medium</b>
2488   * <p>
2489   * Description: <b>A channel of communication</b><br>
2490   * Type: <b>token</b><br>
2491   * Path: <b>CommunicationRequest.medium</b><br>
2492   * </p>
2493   */
2494  public static final ca.uhn.fhir.rest.gclient.TokenClientParam MEDIUM = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_MEDIUM);
2495
2496 /**
2497   * Search parameter: <b>encounter</b>
2498   * <p>
2499   * Description: <b>Encounter created as part of</b><br>
2500   * Type: <b>reference</b><br>
2501   * Path: <b>CommunicationRequest.encounter</b><br>
2502   * </p>
2503   */
2504  @SearchParamDefinition(name="encounter", path="CommunicationRequest.encounter", description="Encounter created as part of", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Encounter") }, target={Encounter.class } )
2505  public static final String SP_ENCOUNTER = "encounter";
2506 /**
2507   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
2508   * <p>
2509   * Description: <b>Encounter created as part of</b><br>
2510   * Type: <b>reference</b><br>
2511   * Path: <b>CommunicationRequest.encounter</b><br>
2512   * </p>
2513   */
2514  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
2515
2516/**
2517   * Constant for fluent queries to be used to add include statements. Specifies
2518   * the path value of "<b>CommunicationRequest:encounter</b>".
2519   */
2520  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("CommunicationRequest:encounter").toLocked();
2521
2522 /**
2523   * Search parameter: <b>occurrence</b>
2524   * <p>
2525   * Description: <b>When scheduled</b><br>
2526   * Type: <b>date</b><br>
2527   * Path: <b>CommunicationRequest.occurrenceDateTime</b><br>
2528   * </p>
2529   */
2530  @SearchParamDefinition(name="occurrence", path="(CommunicationRequest.occurrence as dateTime)", description="When scheduled", type="date" )
2531  public static final String SP_OCCURRENCE = "occurrence";
2532 /**
2533   * <b>Fluent Client</b> search parameter constant for <b>occurrence</b>
2534   * <p>
2535   * Description: <b>When scheduled</b><br>
2536   * Type: <b>date</b><br>
2537   * Path: <b>CommunicationRequest.occurrenceDateTime</b><br>
2538   * </p>
2539   */
2540  public static final ca.uhn.fhir.rest.gclient.DateClientParam OCCURRENCE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_OCCURRENCE);
2541
2542 /**
2543   * Search parameter: <b>priority</b>
2544   * <p>
2545   * Description: <b>Message urgency</b><br>
2546   * Type: <b>token</b><br>
2547   * Path: <b>CommunicationRequest.priority</b><br>
2548   * </p>
2549   */
2550  @SearchParamDefinition(name="priority", path="CommunicationRequest.priority", description="Message urgency", type="token" )
2551  public static final String SP_PRIORITY = "priority";
2552 /**
2553   * <b>Fluent Client</b> search parameter constant for <b>priority</b>
2554   * <p>
2555   * Description: <b>Message urgency</b><br>
2556   * Type: <b>token</b><br>
2557   * Path: <b>CommunicationRequest.priority</b><br>
2558   * </p>
2559   */
2560  public static final ca.uhn.fhir.rest.gclient.TokenClientParam PRIORITY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_PRIORITY);
2561
2562 /**
2563   * Search parameter: <b>group-identifier</b>
2564   * <p>
2565   * Description: <b>Composite request this is part of</b><br>
2566   * Type: <b>token</b><br>
2567   * Path: <b>CommunicationRequest.groupIdentifier</b><br>
2568   * </p>
2569   */
2570  @SearchParamDefinition(name="group-identifier", path="CommunicationRequest.groupIdentifier", description="Composite request this is part of", type="token" )
2571  public static final String SP_GROUP_IDENTIFIER = "group-identifier";
2572 /**
2573   * <b>Fluent Client</b> search parameter constant for <b>group-identifier</b>
2574   * <p>
2575   * Description: <b>Composite request this is part of</b><br>
2576   * Type: <b>token</b><br>
2577   * Path: <b>CommunicationRequest.groupIdentifier</b><br>
2578   * </p>
2579   */
2580  public static final ca.uhn.fhir.rest.gclient.TokenClientParam GROUP_IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_GROUP_IDENTIFIER);
2581
2582 /**
2583   * Search parameter: <b>based-on</b>
2584   * <p>
2585   * Description: <b>Fulfills plan or proposal</b><br>
2586   * Type: <b>reference</b><br>
2587   * Path: <b>CommunicationRequest.basedOn</b><br>
2588   * </p>
2589   */
2590  @SearchParamDefinition(name="based-on", path="CommunicationRequest.basedOn", description="Fulfills plan or proposal", type="reference" )
2591  public static final String SP_BASED_ON = "based-on";
2592 /**
2593   * <b>Fluent Client</b> search parameter constant for <b>based-on</b>
2594   * <p>
2595   * Description: <b>Fulfills plan or proposal</b><br>
2596   * Type: <b>reference</b><br>
2597   * Path: <b>CommunicationRequest.basedOn</b><br>
2598   * </p>
2599   */
2600  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam BASED_ON = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_BASED_ON);
2601
2602/**
2603   * Constant for fluent queries to be used to add include statements. Specifies
2604   * the path value of "<b>CommunicationRequest:based-on</b>".
2605   */
2606  public static final ca.uhn.fhir.model.api.Include INCLUDE_BASED_ON = new ca.uhn.fhir.model.api.Include("CommunicationRequest:based-on").toLocked();
2607
2608 /**
2609   * Search parameter: <b>sender</b>
2610   * <p>
2611   * Description: <b>Message sender</b><br>
2612   * Type: <b>reference</b><br>
2613   * Path: <b>CommunicationRequest.sender</b><br>
2614   * </p>
2615   */
2616  @SearchParamDefinition(name="sender", path="CommunicationRequest.sender", description="Message sender", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Device"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner"), @ca.uhn.fhir.model.api.annotation.Compartment(name="RelatedPerson") }, target={Device.class, HealthcareService.class, Organization.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class } )
2617  public static final String SP_SENDER = "sender";
2618 /**
2619   * <b>Fluent Client</b> search parameter constant for <b>sender</b>
2620   * <p>
2621   * Description: <b>Message sender</b><br>
2622   * Type: <b>reference</b><br>
2623   * Path: <b>CommunicationRequest.sender</b><br>
2624   * </p>
2625   */
2626  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SENDER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SENDER);
2627
2628/**
2629   * Constant for fluent queries to be used to add include statements. Specifies
2630   * the path value of "<b>CommunicationRequest:sender</b>".
2631   */
2632  public static final ca.uhn.fhir.model.api.Include INCLUDE_SENDER = new ca.uhn.fhir.model.api.Include("CommunicationRequest:sender").toLocked();
2633
2634 /**
2635   * Search parameter: <b>patient</b>
2636   * <p>
2637   * Description: <b>Focus of message</b><br>
2638   * Type: <b>reference</b><br>
2639   * Path: <b>CommunicationRequest.subject</b><br>
2640   * </p>
2641   */
2642  @SearchParamDefinition(name="patient", path="CommunicationRequest.subject.where(resolve() is Patient)", description="Focus of message", type="reference", target={Patient.class } )
2643  public static final String SP_PATIENT = "patient";
2644 /**
2645   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2646   * <p>
2647   * Description: <b>Focus of message</b><br>
2648   * Type: <b>reference</b><br>
2649   * Path: <b>CommunicationRequest.subject</b><br>
2650   * </p>
2651   */
2652  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
2653
2654/**
2655   * Constant for fluent queries to be used to add include statements. Specifies
2656   * the path value of "<b>CommunicationRequest:patient</b>".
2657   */
2658  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("CommunicationRequest:patient").toLocked();
2659
2660 /**
2661   * Search parameter: <b>recipient</b>
2662   * <p>
2663   * Description: <b>Message recipient</b><br>
2664   * Type: <b>reference</b><br>
2665   * Path: <b>CommunicationRequest.recipient</b><br>
2666   * </p>
2667   */
2668  @SearchParamDefinition(name="recipient", path="CommunicationRequest.recipient", description="Message recipient", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Device"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner"), @ca.uhn.fhir.model.api.annotation.Compartment(name="RelatedPerson") }, target={CareTeam.class, Device.class, Group.class, HealthcareService.class, Organization.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class } )
2669  public static final String SP_RECIPIENT = "recipient";
2670 /**
2671   * <b>Fluent Client</b> search parameter constant for <b>recipient</b>
2672   * <p>
2673   * Description: <b>Message recipient</b><br>
2674   * Type: <b>reference</b><br>
2675   * Path: <b>CommunicationRequest.recipient</b><br>
2676   * </p>
2677   */
2678  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam RECIPIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_RECIPIENT);
2679
2680/**
2681   * Constant for fluent queries to be used to add include statements. Specifies
2682   * the path value of "<b>CommunicationRequest:recipient</b>".
2683   */
2684  public static final ca.uhn.fhir.model.api.Include INCLUDE_RECIPIENT = new ca.uhn.fhir.model.api.Include("CommunicationRequest:recipient").toLocked();
2685
2686 /**
2687   * Search parameter: <b>category</b>
2688   * <p>
2689   * Description: <b>Message category</b><br>
2690   * Type: <b>token</b><br>
2691   * Path: <b>CommunicationRequest.category</b><br>
2692   * </p>
2693   */
2694  @SearchParamDefinition(name="category", path="CommunicationRequest.category", description="Message category", type="token" )
2695  public static final String SP_CATEGORY = "category";
2696 /**
2697   * <b>Fluent Client</b> search parameter constant for <b>category</b>
2698   * <p>
2699   * Description: <b>Message category</b><br>
2700   * Type: <b>token</b><br>
2701   * Path: <b>CommunicationRequest.category</b><br>
2702   * </p>
2703   */
2704  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CATEGORY);
2705
2706 /**
2707   * Search parameter: <b>status</b>
2708   * <p>
2709   * Description: <b>draft | active | suspended | cancelled | completed | entered-in-error | unknown</b><br>
2710   * Type: <b>token</b><br>
2711   * Path: <b>CommunicationRequest.status</b><br>
2712   * </p>
2713   */
2714  @SearchParamDefinition(name="status", path="CommunicationRequest.status", description="draft | active | suspended | cancelled | completed | entered-in-error | unknown", type="token" )
2715  public static final String SP_STATUS = "status";
2716 /**
2717   * <b>Fluent Client</b> search parameter constant for <b>status</b>
2718   * <p>
2719   * Description: <b>draft | active | suspended | cancelled | completed | entered-in-error | unknown</b><br>
2720   * Type: <b>token</b><br>
2721   * Path: <b>CommunicationRequest.status</b><br>
2722   * </p>
2723   */
2724  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
2725
2726
2727}
2728