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, Sep 13, 2018 09:04-0400 for FHIR v3.5.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 authorization/request to act has been temporarily withdrawn but is expected to resume in the future.
062         */
063        ONHOLD, 
064        /**
065         * The authorization/request 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         * Activity against the request has been sufficiently completed to the satisfaction of the requester.
070         */
071        COMPLETED, 
072        /**
073         * This electronic record should never have existed, though 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 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 system creating the request does not know.
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 authorization/request to act has been temporarily withdrawn but is expected to resume in the future.";
135            case REVOKED: return "The authorization/request to act has been terminated prior to the known full completion of the intended actions.  No further activity should occur.";
136            case COMPLETED: return "Activity against the request has been sufficiently completed to the satisfaction of the requester.";
137            case ENTEREDINERROR: return "This electronic record should never have existed, though 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 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 system creating the request does not know.";
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            return null;
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            return null;
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            return null;
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 or episode of care within which the communication request was created.
671     */
672    @Child(name = "context", type = {Encounter.class, EpisodeOfCare.class}, order=12, min=0, max=1, modifier=false, summary=true)
673    @Description(shortDefinition="Encounter or episode leading to message", formalDefinition="The encounter or episode of care within which the communication request was created." )
674    protected Reference context;
675
676    /**
677     * The actual object that is the target of the reference (The encounter or episode of care within which the communication request was created.)
678     */
679    protected Resource contextTarget;
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 = -1338248070L;
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 #context} (The encounter or episode of care within which the communication request was created.)
1370     */
1371    public Reference getContext() { 
1372      if (this.context == null)
1373        if (Configuration.errorOnAutoCreate())
1374          throw new Error("Attempt to auto-create CommunicationRequest.context");
1375        else if (Configuration.doAutoCreate())
1376          this.context = new Reference(); // cc
1377      return this.context;
1378    }
1379
1380    public boolean hasContext() { 
1381      return this.context != null && !this.context.isEmpty();
1382    }
1383
1384    /**
1385     * @param value {@link #context} (The encounter or episode of care within which the communication request was created.)
1386     */
1387    public CommunicationRequest setContext(Reference value) { 
1388      this.context = value;
1389      return this;
1390    }
1391
1392    /**
1393     * @return {@link #context} 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 or episode of care within which the communication request was created.)
1394     */
1395    public Resource getContextTarget() { 
1396      return this.contextTarget;
1397    }
1398
1399    /**
1400     * @param value {@link #context} 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 or episode of care within which the communication request was created.)
1401     */
1402    public CommunicationRequest setContextTarget(Resource value) { 
1403      this.contextTarget = value;
1404      return this;
1405    }
1406
1407    /**
1408     * @return {@link #payload} (Text, attachment(s), or resource(s) to be communicated to the recipient.)
1409     */
1410    public List<CommunicationRequestPayloadComponent> getPayload() { 
1411      if (this.payload == null)
1412        this.payload = new ArrayList<CommunicationRequestPayloadComponent>();
1413      return this.payload;
1414    }
1415
1416    /**
1417     * @return Returns a reference to <code>this</code> for easy method chaining
1418     */
1419    public CommunicationRequest setPayload(List<CommunicationRequestPayloadComponent> thePayload) { 
1420      this.payload = thePayload;
1421      return this;
1422    }
1423
1424    public boolean hasPayload() { 
1425      if (this.payload == null)
1426        return false;
1427      for (CommunicationRequestPayloadComponent item : this.payload)
1428        if (!item.isEmpty())
1429          return true;
1430      return false;
1431    }
1432
1433    public CommunicationRequestPayloadComponent addPayload() { //3
1434      CommunicationRequestPayloadComponent t = new CommunicationRequestPayloadComponent();
1435      if (this.payload == null)
1436        this.payload = new ArrayList<CommunicationRequestPayloadComponent>();
1437      this.payload.add(t);
1438      return t;
1439    }
1440
1441    public CommunicationRequest addPayload(CommunicationRequestPayloadComponent t) { //3
1442      if (t == null)
1443        return this;
1444      if (this.payload == null)
1445        this.payload = new ArrayList<CommunicationRequestPayloadComponent>();
1446      this.payload.add(t);
1447      return this;
1448    }
1449
1450    /**
1451     * @return The first repetition of repeating field {@link #payload}, creating it if it does not already exist
1452     */
1453    public CommunicationRequestPayloadComponent getPayloadFirstRep() { 
1454      if (getPayload().isEmpty()) {
1455        addPayload();
1456      }
1457      return getPayload().get(0);
1458    }
1459
1460    /**
1461     * @return {@link #occurrence} (The time when this communication is to occur.)
1462     */
1463    public Type getOccurrence() { 
1464      return this.occurrence;
1465    }
1466
1467    /**
1468     * @return {@link #occurrence} (The time when this communication is to occur.)
1469     */
1470    public DateTimeType getOccurrenceDateTimeType() throws FHIRException { 
1471      if (this.occurrence == null)
1472        return null;
1473      if (!(this.occurrence instanceof DateTimeType))
1474        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.occurrence.getClass().getName()+" was encountered");
1475      return (DateTimeType) this.occurrence;
1476    }
1477
1478    public boolean hasOccurrenceDateTimeType() { 
1479      return this != null && this.occurrence instanceof DateTimeType;
1480    }
1481
1482    /**
1483     * @return {@link #occurrence} (The time when this communication is to occur.)
1484     */
1485    public Period getOccurrencePeriod() throws FHIRException { 
1486      if (this.occurrence == null)
1487        return null;
1488      if (!(this.occurrence instanceof Period))
1489        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.occurrence.getClass().getName()+" was encountered");
1490      return (Period) this.occurrence;
1491    }
1492
1493    public boolean hasOccurrencePeriod() { 
1494      return this != null && this.occurrence instanceof Period;
1495    }
1496
1497    public boolean hasOccurrence() { 
1498      return this.occurrence != null && !this.occurrence.isEmpty();
1499    }
1500
1501    /**
1502     * @param value {@link #occurrence} (The time when this communication is to occur.)
1503     */
1504    public CommunicationRequest setOccurrence(Type value) { 
1505      if (value != null && !(value instanceof DateTimeType || value instanceof Period))
1506        throw new Error("Not the right type for CommunicationRequest.occurrence[x]: "+value.fhirType());
1507      this.occurrence = value;
1508      return this;
1509    }
1510
1511    /**
1512     * @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
1513     */
1514    public DateTimeType getAuthoredOnElement() { 
1515      if (this.authoredOn == null)
1516        if (Configuration.errorOnAutoCreate())
1517          throw new Error("Attempt to auto-create CommunicationRequest.authoredOn");
1518        else if (Configuration.doAutoCreate())
1519          this.authoredOn = new DateTimeType(); // bb
1520      return this.authoredOn;
1521    }
1522
1523    public boolean hasAuthoredOnElement() { 
1524      return this.authoredOn != null && !this.authoredOn.isEmpty();
1525    }
1526
1527    public boolean hasAuthoredOn() { 
1528      return this.authoredOn != null && !this.authoredOn.isEmpty();
1529    }
1530
1531    /**
1532     * @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
1533     */
1534    public CommunicationRequest setAuthoredOnElement(DateTimeType value) { 
1535      this.authoredOn = value;
1536      return this;
1537    }
1538
1539    /**
1540     * @return For draft requests, indicates the date of initial creation.  For requests with other statuses, indicates the date of activation.
1541     */
1542    public Date getAuthoredOn() { 
1543      return this.authoredOn == null ? null : this.authoredOn.getValue();
1544    }
1545
1546    /**
1547     * @param value For draft requests, indicates the date of initial creation.  For requests with other statuses, indicates the date of activation.
1548     */
1549    public CommunicationRequest setAuthoredOn(Date value) { 
1550      if (value == null)
1551        this.authoredOn = null;
1552      else {
1553        if (this.authoredOn == null)
1554          this.authoredOn = new DateTimeType();
1555        this.authoredOn.setValue(value);
1556      }
1557      return this;
1558    }
1559
1560    /**
1561     * @return {@link #requester} (The device, individual, or organization who initiated the request and has responsibility for its activation.)
1562     */
1563    public Reference getRequester() { 
1564      if (this.requester == null)
1565        if (Configuration.errorOnAutoCreate())
1566          throw new Error("Attempt to auto-create CommunicationRequest.requester");
1567        else if (Configuration.doAutoCreate())
1568          this.requester = new Reference(); // cc
1569      return this.requester;
1570    }
1571
1572    public boolean hasRequester() { 
1573      return this.requester != null && !this.requester.isEmpty();
1574    }
1575
1576    /**
1577     * @param value {@link #requester} (The device, individual, or organization who initiated the request and has responsibility for its activation.)
1578     */
1579    public CommunicationRequest setRequester(Reference value) { 
1580      this.requester = value;
1581      return this;
1582    }
1583
1584    /**
1585     * @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.)
1586     */
1587    public Resource getRequesterTarget() { 
1588      return this.requesterTarget;
1589    }
1590
1591    /**
1592     * @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.)
1593     */
1594    public CommunicationRequest setRequesterTarget(Resource value) { 
1595      this.requesterTarget = value;
1596      return this;
1597    }
1598
1599    /**
1600     * @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.)
1601     */
1602    public List<Reference> getRecipient() { 
1603      if (this.recipient == null)
1604        this.recipient = new ArrayList<Reference>();
1605      return this.recipient;
1606    }
1607
1608    /**
1609     * @return Returns a reference to <code>this</code> for easy method chaining
1610     */
1611    public CommunicationRequest setRecipient(List<Reference> theRecipient) { 
1612      this.recipient = theRecipient;
1613      return this;
1614    }
1615
1616    public boolean hasRecipient() { 
1617      if (this.recipient == null)
1618        return false;
1619      for (Reference item : this.recipient)
1620        if (!item.isEmpty())
1621          return true;
1622      return false;
1623    }
1624
1625    public Reference addRecipient() { //3
1626      Reference t = new Reference();
1627      if (this.recipient == null)
1628        this.recipient = new ArrayList<Reference>();
1629      this.recipient.add(t);
1630      return t;
1631    }
1632
1633    public CommunicationRequest addRecipient(Reference t) { //3
1634      if (t == null)
1635        return this;
1636      if (this.recipient == null)
1637        this.recipient = new ArrayList<Reference>();
1638      this.recipient.add(t);
1639      return this;
1640    }
1641
1642    /**
1643     * @return The first repetition of repeating field {@link #recipient}, creating it if it does not already exist
1644     */
1645    public Reference getRecipientFirstRep() { 
1646      if (getRecipient().isEmpty()) {
1647        addRecipient();
1648      }
1649      return getRecipient().get(0);
1650    }
1651
1652    /**
1653     * @deprecated Use Reference#setResource(IBaseResource) instead
1654     */
1655    @Deprecated
1656    public List<Resource> getRecipientTarget() { 
1657      if (this.recipientTarget == null)
1658        this.recipientTarget = new ArrayList<Resource>();
1659      return this.recipientTarget;
1660    }
1661
1662    /**
1663     * @return {@link #sender} (The entity (e.g. person, organization, clinical information system, or device) which is to be the source of the communication.)
1664     */
1665    public Reference getSender() { 
1666      if (this.sender == null)
1667        if (Configuration.errorOnAutoCreate())
1668          throw new Error("Attempt to auto-create CommunicationRequest.sender");
1669        else if (Configuration.doAutoCreate())
1670          this.sender = new Reference(); // cc
1671      return this.sender;
1672    }
1673
1674    public boolean hasSender() { 
1675      return this.sender != null && !this.sender.isEmpty();
1676    }
1677
1678    /**
1679     * @param value {@link #sender} (The entity (e.g. person, organization, clinical information system, or device) which is to be the source of the communication.)
1680     */
1681    public CommunicationRequest setSender(Reference value) { 
1682      this.sender = value;
1683      return this;
1684    }
1685
1686    /**
1687     * @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.)
1688     */
1689    public Resource getSenderTarget() { 
1690      return this.senderTarget;
1691    }
1692
1693    /**
1694     * @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.)
1695     */
1696    public CommunicationRequest setSenderTarget(Resource value) { 
1697      this.senderTarget = value;
1698      return this;
1699    }
1700
1701    /**
1702     * @return {@link #reasonCode} (Describes why the request is being made in coded or textual form.)
1703     */
1704    public List<CodeableConcept> getReasonCode() { 
1705      if (this.reasonCode == null)
1706        this.reasonCode = new ArrayList<CodeableConcept>();
1707      return this.reasonCode;
1708    }
1709
1710    /**
1711     * @return Returns a reference to <code>this</code> for easy method chaining
1712     */
1713    public CommunicationRequest setReasonCode(List<CodeableConcept> theReasonCode) { 
1714      this.reasonCode = theReasonCode;
1715      return this;
1716    }
1717
1718    public boolean hasReasonCode() { 
1719      if (this.reasonCode == null)
1720        return false;
1721      for (CodeableConcept item : this.reasonCode)
1722        if (!item.isEmpty())
1723          return true;
1724      return false;
1725    }
1726
1727    public CodeableConcept addReasonCode() { //3
1728      CodeableConcept t = new CodeableConcept();
1729      if (this.reasonCode == null)
1730        this.reasonCode = new ArrayList<CodeableConcept>();
1731      this.reasonCode.add(t);
1732      return t;
1733    }
1734
1735    public CommunicationRequest addReasonCode(CodeableConcept t) { //3
1736      if (t == null)
1737        return this;
1738      if (this.reasonCode == null)
1739        this.reasonCode = new ArrayList<CodeableConcept>();
1740      this.reasonCode.add(t);
1741      return this;
1742    }
1743
1744    /**
1745     * @return The first repetition of repeating field {@link #reasonCode}, creating it if it does not already exist
1746     */
1747    public CodeableConcept getReasonCodeFirstRep() { 
1748      if (getReasonCode().isEmpty()) {
1749        addReasonCode();
1750      }
1751      return getReasonCode().get(0);
1752    }
1753
1754    /**
1755     * @return {@link #reasonReference} (Indicates another resource whose existence justifies this request.)
1756     */
1757    public List<Reference> getReasonReference() { 
1758      if (this.reasonReference == null)
1759        this.reasonReference = new ArrayList<Reference>();
1760      return this.reasonReference;
1761    }
1762
1763    /**
1764     * @return Returns a reference to <code>this</code> for easy method chaining
1765     */
1766    public CommunicationRequest setReasonReference(List<Reference> theReasonReference) { 
1767      this.reasonReference = theReasonReference;
1768      return this;
1769    }
1770
1771    public boolean hasReasonReference() { 
1772      if (this.reasonReference == null)
1773        return false;
1774      for (Reference item : this.reasonReference)
1775        if (!item.isEmpty())
1776          return true;
1777      return false;
1778    }
1779
1780    public Reference addReasonReference() { //3
1781      Reference t = new Reference();
1782      if (this.reasonReference == null)
1783        this.reasonReference = new ArrayList<Reference>();
1784      this.reasonReference.add(t);
1785      return t;
1786    }
1787
1788    public CommunicationRequest addReasonReference(Reference t) { //3
1789      if (t == null)
1790        return this;
1791      if (this.reasonReference == null)
1792        this.reasonReference = new ArrayList<Reference>();
1793      this.reasonReference.add(t);
1794      return this;
1795    }
1796
1797    /**
1798     * @return The first repetition of repeating field {@link #reasonReference}, creating it if it does not already exist
1799     */
1800    public Reference getReasonReferenceFirstRep() { 
1801      if (getReasonReference().isEmpty()) {
1802        addReasonReference();
1803      }
1804      return getReasonReference().get(0);
1805    }
1806
1807    /**
1808     * @deprecated Use Reference#setResource(IBaseResource) instead
1809     */
1810    @Deprecated
1811    public List<Resource> getReasonReferenceTarget() { 
1812      if (this.reasonReferenceTarget == null)
1813        this.reasonReferenceTarget = new ArrayList<Resource>();
1814      return this.reasonReferenceTarget;
1815    }
1816
1817    /**
1818     * @return {@link #note} (Comments made about the request by the requester, sender, recipient, subject or other participants.)
1819     */
1820    public List<Annotation> getNote() { 
1821      if (this.note == null)
1822        this.note = new ArrayList<Annotation>();
1823      return this.note;
1824    }
1825
1826    /**
1827     * @return Returns a reference to <code>this</code> for easy method chaining
1828     */
1829    public CommunicationRequest setNote(List<Annotation> theNote) { 
1830      this.note = theNote;
1831      return this;
1832    }
1833
1834    public boolean hasNote() { 
1835      if (this.note == null)
1836        return false;
1837      for (Annotation item : this.note)
1838        if (!item.isEmpty())
1839          return true;
1840      return false;
1841    }
1842
1843    public Annotation addNote() { //3
1844      Annotation t = new Annotation();
1845      if (this.note == null)
1846        this.note = new ArrayList<Annotation>();
1847      this.note.add(t);
1848      return t;
1849    }
1850
1851    public CommunicationRequest addNote(Annotation t) { //3
1852      if (t == null)
1853        return this;
1854      if (this.note == null)
1855        this.note = new ArrayList<Annotation>();
1856      this.note.add(t);
1857      return this;
1858    }
1859
1860    /**
1861     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist
1862     */
1863    public Annotation getNoteFirstRep() { 
1864      if (getNote().isEmpty()) {
1865        addNote();
1866      }
1867      return getNote().get(0);
1868    }
1869
1870      protected void listChildren(List<Property> children) {
1871        super.listChildren(children);
1872        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));
1873        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));
1874        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));
1875        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));
1876        children.add(new Property("status", "code", "The status of the proposal or order.", 0, 1, status));
1877        children.add(new Property("statusReason", "CodeableConcept", "Captures the reason for the current state of the CommunicationRequest.", 0, 1, statusReason));
1878        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));
1879        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));
1880        children.add(new Property("doNotPerform", "boolean", "If true indicates that the CommunicationRequest is asking for the specified action to *not* occur.", 0, 1, doNotPerform));
1881        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));
1882        children.add(new Property("subject", "Reference(Patient|Group)", "The patient or group that is the focus of this communication request.", 0, 1, subject));
1883        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));
1884        children.add(new Property("context", "Reference(Encounter|EpisodeOfCare)", "The encounter or episode of care within which the communication request was created.", 0, 1, context));
1885        children.add(new Property("payload", "", "Text, attachment(s), or resource(s) to be communicated to the recipient.", 0, java.lang.Integer.MAX_VALUE, payload));
1886        children.add(new Property("occurrence[x]", "dateTime|Period", "The time when this communication is to occur.", 0, 1, occurrence));
1887        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));
1888        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));
1889        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));
1890        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));
1891        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));
1892        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));
1893        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));
1894      }
1895
1896      @Override
1897      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1898        switch (_hash) {
1899        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);
1900        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);
1901        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);
1902        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);
1903        case -892481550: /*status*/  return new Property("status", "code", "The status of the proposal or order.", 0, 1, status);
1904        case 2051346646: /*statusReason*/  return new Property("statusReason", "CodeableConcept", "Captures the reason for the current state of the CommunicationRequest.", 0, 1, statusReason);
1905        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);
1906        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);
1907        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);
1908        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);
1909        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);
1910        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);
1911        case 951530927: /*context*/  return new Property("context", "Reference(Encounter|EpisodeOfCare)", "The encounter or episode of care within which the communication request was created.", 0, 1, context);
1912        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);
1913        case -2022646513: /*occurrence[x]*/  return new Property("occurrence[x]", "dateTime|Period", "The time when this communication is to occur.", 0, 1, occurrence);
1914        case 1687874001: /*occurrence*/  return new Property("occurrence[x]", "dateTime|Period", "The time when this communication is to occur.", 0, 1, occurrence);
1915        case -298443636: /*occurrenceDateTime*/  return new Property("occurrence[x]", "dateTime|Period", "The time when this communication is to occur.", 0, 1, occurrence);
1916        case 1397156594: /*occurrencePeriod*/  return new Property("occurrence[x]", "dateTime|Period", "The time when this communication is to occur.", 0, 1, occurrence);
1917        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);
1918        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);
1919        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);
1920        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);
1921        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);
1922        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);
1923        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);
1924        default: return super.getNamedProperty(_hash, _name, _checkValid);
1925        }
1926
1927      }
1928
1929      @Override
1930      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1931        switch (hash) {
1932        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1933        case -332612366: /*basedOn*/ return this.basedOn == null ? new Base[0] : this.basedOn.toArray(new Base[this.basedOn.size()]); // Reference
1934        case -430332865: /*replaces*/ return this.replaces == null ? new Base[0] : this.replaces.toArray(new Base[this.replaces.size()]); // Reference
1935        case -445338488: /*groupIdentifier*/ return this.groupIdentifier == null ? new Base[0] : new Base[] {this.groupIdentifier}; // Identifier
1936        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<CommunicationRequestStatus>
1937        case 2051346646: /*statusReason*/ return this.statusReason == null ? new Base[0] : new Base[] {this.statusReason}; // CodeableConcept
1938        case 50511102: /*category*/ return this.category == null ? new Base[0] : this.category.toArray(new Base[this.category.size()]); // CodeableConcept
1939        case -1165461084: /*priority*/ return this.priority == null ? new Base[0] : new Base[] {this.priority}; // Enumeration<CommunicationPriority>
1940        case -1788508167: /*doNotPerform*/ return this.doNotPerform == null ? new Base[0] : new Base[] {this.doNotPerform}; // BooleanType
1941        case -1078030475: /*medium*/ return this.medium == null ? new Base[0] : this.medium.toArray(new Base[this.medium.size()]); // CodeableConcept
1942        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
1943        case 92611469: /*about*/ return this.about == null ? new Base[0] : this.about.toArray(new Base[this.about.size()]); // Reference
1944        case 951530927: /*context*/ return this.context == null ? new Base[0] : new Base[] {this.context}; // Reference
1945        case -786701938: /*payload*/ return this.payload == null ? new Base[0] : this.payload.toArray(new Base[this.payload.size()]); // CommunicationRequestPayloadComponent
1946        case 1687874001: /*occurrence*/ return this.occurrence == null ? new Base[0] : new Base[] {this.occurrence}; // Type
1947        case -1500852503: /*authoredOn*/ return this.authoredOn == null ? new Base[0] : new Base[] {this.authoredOn}; // DateTimeType
1948        case 693933948: /*requester*/ return this.requester == null ? new Base[0] : new Base[] {this.requester}; // Reference
1949        case 820081177: /*recipient*/ return this.recipient == null ? new Base[0] : this.recipient.toArray(new Base[this.recipient.size()]); // Reference
1950        case -905962955: /*sender*/ return this.sender == null ? new Base[0] : new Base[] {this.sender}; // Reference
1951        case 722137681: /*reasonCode*/ return this.reasonCode == null ? new Base[0] : this.reasonCode.toArray(new Base[this.reasonCode.size()]); // CodeableConcept
1952        case -1146218137: /*reasonReference*/ return this.reasonReference == null ? new Base[0] : this.reasonReference.toArray(new Base[this.reasonReference.size()]); // Reference
1953        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
1954        default: return super.getProperty(hash, name, checkValid);
1955        }
1956
1957      }
1958
1959      @Override
1960      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1961        switch (hash) {
1962        case -1618432855: // identifier
1963          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1964          return value;
1965        case -332612366: // basedOn
1966          this.getBasedOn().add(castToReference(value)); // Reference
1967          return value;
1968        case -430332865: // replaces
1969          this.getReplaces().add(castToReference(value)); // Reference
1970          return value;
1971        case -445338488: // groupIdentifier
1972          this.groupIdentifier = castToIdentifier(value); // Identifier
1973          return value;
1974        case -892481550: // status
1975          value = new CommunicationRequestStatusEnumFactory().fromType(castToCode(value));
1976          this.status = (Enumeration) value; // Enumeration<CommunicationRequestStatus>
1977          return value;
1978        case 2051346646: // statusReason
1979          this.statusReason = castToCodeableConcept(value); // CodeableConcept
1980          return value;
1981        case 50511102: // category
1982          this.getCategory().add(castToCodeableConcept(value)); // CodeableConcept
1983          return value;
1984        case -1165461084: // priority
1985          value = new CommunicationPriorityEnumFactory().fromType(castToCode(value));
1986          this.priority = (Enumeration) value; // Enumeration<CommunicationPriority>
1987          return value;
1988        case -1788508167: // doNotPerform
1989          this.doNotPerform = castToBoolean(value); // BooleanType
1990          return value;
1991        case -1078030475: // medium
1992          this.getMedium().add(castToCodeableConcept(value)); // CodeableConcept
1993          return value;
1994        case -1867885268: // subject
1995          this.subject = castToReference(value); // Reference
1996          return value;
1997        case 92611469: // about
1998          this.getAbout().add(castToReference(value)); // Reference
1999          return value;
2000        case 951530927: // context
2001          this.context = castToReference(value); // Reference
2002          return value;
2003        case -786701938: // payload
2004          this.getPayload().add((CommunicationRequestPayloadComponent) value); // CommunicationRequestPayloadComponent
2005          return value;
2006        case 1687874001: // occurrence
2007          this.occurrence = castToType(value); // Type
2008          return value;
2009        case -1500852503: // authoredOn
2010          this.authoredOn = castToDateTime(value); // DateTimeType
2011          return value;
2012        case 693933948: // requester
2013          this.requester = castToReference(value); // Reference
2014          return value;
2015        case 820081177: // recipient
2016          this.getRecipient().add(castToReference(value)); // Reference
2017          return value;
2018        case -905962955: // sender
2019          this.sender = castToReference(value); // Reference
2020          return value;
2021        case 722137681: // reasonCode
2022          this.getReasonCode().add(castToCodeableConcept(value)); // CodeableConcept
2023          return value;
2024        case -1146218137: // reasonReference
2025          this.getReasonReference().add(castToReference(value)); // Reference
2026          return value;
2027        case 3387378: // note
2028          this.getNote().add(castToAnnotation(value)); // Annotation
2029          return value;
2030        default: return super.setProperty(hash, name, value);
2031        }
2032
2033      }
2034
2035      @Override
2036      public Base setProperty(String name, Base value) throws FHIRException {
2037        if (name.equals("identifier")) {
2038          this.getIdentifier().add(castToIdentifier(value));
2039        } else if (name.equals("basedOn")) {
2040          this.getBasedOn().add(castToReference(value));
2041        } else if (name.equals("replaces")) {
2042          this.getReplaces().add(castToReference(value));
2043        } else if (name.equals("groupIdentifier")) {
2044          this.groupIdentifier = castToIdentifier(value); // Identifier
2045        } else if (name.equals("status")) {
2046          value = new CommunicationRequestStatusEnumFactory().fromType(castToCode(value));
2047          this.status = (Enumeration) value; // Enumeration<CommunicationRequestStatus>
2048        } else if (name.equals("statusReason")) {
2049          this.statusReason = castToCodeableConcept(value); // CodeableConcept
2050        } else if (name.equals("category")) {
2051          this.getCategory().add(castToCodeableConcept(value));
2052        } else if (name.equals("priority")) {
2053          value = new CommunicationPriorityEnumFactory().fromType(castToCode(value));
2054          this.priority = (Enumeration) value; // Enumeration<CommunicationPriority>
2055        } else if (name.equals("doNotPerform")) {
2056          this.doNotPerform = castToBoolean(value); // BooleanType
2057        } else if (name.equals("medium")) {
2058          this.getMedium().add(castToCodeableConcept(value));
2059        } else if (name.equals("subject")) {
2060          this.subject = castToReference(value); // Reference
2061        } else if (name.equals("about")) {
2062          this.getAbout().add(castToReference(value));
2063        } else if (name.equals("context")) {
2064          this.context = castToReference(value); // Reference
2065        } else if (name.equals("payload")) {
2066          this.getPayload().add((CommunicationRequestPayloadComponent) value);
2067        } else if (name.equals("occurrence[x]")) {
2068          this.occurrence = castToType(value); // Type
2069        } else if (name.equals("authoredOn")) {
2070          this.authoredOn = castToDateTime(value); // DateTimeType
2071        } else if (name.equals("requester")) {
2072          this.requester = castToReference(value); // Reference
2073        } else if (name.equals("recipient")) {
2074          this.getRecipient().add(castToReference(value));
2075        } else if (name.equals("sender")) {
2076          this.sender = castToReference(value); // Reference
2077        } else if (name.equals("reasonCode")) {
2078          this.getReasonCode().add(castToCodeableConcept(value));
2079        } else if (name.equals("reasonReference")) {
2080          this.getReasonReference().add(castToReference(value));
2081        } else if (name.equals("note")) {
2082          this.getNote().add(castToAnnotation(value));
2083        } else
2084          return super.setProperty(name, value);
2085        return value;
2086      }
2087
2088      @Override
2089      public Base makeProperty(int hash, String name) throws FHIRException {
2090        switch (hash) {
2091        case -1618432855:  return addIdentifier(); 
2092        case -332612366:  return addBasedOn(); 
2093        case -430332865:  return addReplaces(); 
2094        case -445338488:  return getGroupIdentifier(); 
2095        case -892481550:  return getStatusElement();
2096        case 2051346646:  return getStatusReason(); 
2097        case 50511102:  return addCategory(); 
2098        case -1165461084:  return getPriorityElement();
2099        case -1788508167:  return getDoNotPerformElement();
2100        case -1078030475:  return addMedium(); 
2101        case -1867885268:  return getSubject(); 
2102        case 92611469:  return addAbout(); 
2103        case 951530927:  return getContext(); 
2104        case -786701938:  return addPayload(); 
2105        case -2022646513:  return getOccurrence(); 
2106        case 1687874001:  return getOccurrence(); 
2107        case -1500852503:  return getAuthoredOnElement();
2108        case 693933948:  return getRequester(); 
2109        case 820081177:  return addRecipient(); 
2110        case -905962955:  return getSender(); 
2111        case 722137681:  return addReasonCode(); 
2112        case -1146218137:  return addReasonReference(); 
2113        case 3387378:  return addNote(); 
2114        default: return super.makeProperty(hash, name);
2115        }
2116
2117      }
2118
2119      @Override
2120      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2121        switch (hash) {
2122        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2123        case -332612366: /*basedOn*/ return new String[] {"Reference"};
2124        case -430332865: /*replaces*/ return new String[] {"Reference"};
2125        case -445338488: /*groupIdentifier*/ return new String[] {"Identifier"};
2126        case -892481550: /*status*/ return new String[] {"code"};
2127        case 2051346646: /*statusReason*/ return new String[] {"CodeableConcept"};
2128        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
2129        case -1165461084: /*priority*/ return new String[] {"code"};
2130        case -1788508167: /*doNotPerform*/ return new String[] {"boolean"};
2131        case -1078030475: /*medium*/ return new String[] {"CodeableConcept"};
2132        case -1867885268: /*subject*/ return new String[] {"Reference"};
2133        case 92611469: /*about*/ return new String[] {"Reference"};
2134        case 951530927: /*context*/ return new String[] {"Reference"};
2135        case -786701938: /*payload*/ return new String[] {};
2136        case 1687874001: /*occurrence*/ return new String[] {"dateTime", "Period"};
2137        case -1500852503: /*authoredOn*/ return new String[] {"dateTime"};
2138        case 693933948: /*requester*/ return new String[] {"Reference"};
2139        case 820081177: /*recipient*/ return new String[] {"Reference"};
2140        case -905962955: /*sender*/ return new String[] {"Reference"};
2141        case 722137681: /*reasonCode*/ return new String[] {"CodeableConcept"};
2142        case -1146218137: /*reasonReference*/ return new String[] {"Reference"};
2143        case 3387378: /*note*/ return new String[] {"Annotation"};
2144        default: return super.getTypesForProperty(hash, name);
2145        }
2146
2147      }
2148
2149      @Override
2150      public Base addChild(String name) throws FHIRException {
2151        if (name.equals("identifier")) {
2152          return addIdentifier();
2153        }
2154        else if (name.equals("basedOn")) {
2155          return addBasedOn();
2156        }
2157        else if (name.equals("replaces")) {
2158          return addReplaces();
2159        }
2160        else if (name.equals("groupIdentifier")) {
2161          this.groupIdentifier = new Identifier();
2162          return this.groupIdentifier;
2163        }
2164        else if (name.equals("status")) {
2165          throw new FHIRException("Cannot call addChild on a primitive type CommunicationRequest.status");
2166        }
2167        else if (name.equals("statusReason")) {
2168          this.statusReason = new CodeableConcept();
2169          return this.statusReason;
2170        }
2171        else if (name.equals("category")) {
2172          return addCategory();
2173        }
2174        else if (name.equals("priority")) {
2175          throw new FHIRException("Cannot call addChild on a primitive type CommunicationRequest.priority");
2176        }
2177        else if (name.equals("doNotPerform")) {
2178          throw new FHIRException("Cannot call addChild on a primitive type CommunicationRequest.doNotPerform");
2179        }
2180        else if (name.equals("medium")) {
2181          return addMedium();
2182        }
2183        else if (name.equals("subject")) {
2184          this.subject = new Reference();
2185          return this.subject;
2186        }
2187        else if (name.equals("about")) {
2188          return addAbout();
2189        }
2190        else if (name.equals("context")) {
2191          this.context = new Reference();
2192          return this.context;
2193        }
2194        else if (name.equals("payload")) {
2195          return addPayload();
2196        }
2197        else if (name.equals("occurrenceDateTime")) {
2198          this.occurrence = new DateTimeType();
2199          return this.occurrence;
2200        }
2201        else if (name.equals("occurrencePeriod")) {
2202          this.occurrence = new Period();
2203          return this.occurrence;
2204        }
2205        else if (name.equals("authoredOn")) {
2206          throw new FHIRException("Cannot call addChild on a primitive type CommunicationRequest.authoredOn");
2207        }
2208        else if (name.equals("requester")) {
2209          this.requester = new Reference();
2210          return this.requester;
2211        }
2212        else if (name.equals("recipient")) {
2213          return addRecipient();
2214        }
2215        else if (name.equals("sender")) {
2216          this.sender = new Reference();
2217          return this.sender;
2218        }
2219        else if (name.equals("reasonCode")) {
2220          return addReasonCode();
2221        }
2222        else if (name.equals("reasonReference")) {
2223          return addReasonReference();
2224        }
2225        else if (name.equals("note")) {
2226          return addNote();
2227        }
2228        else
2229          return super.addChild(name);
2230      }
2231
2232  public String fhirType() {
2233    return "CommunicationRequest";
2234
2235  }
2236
2237      public CommunicationRequest copy() {
2238        CommunicationRequest dst = new CommunicationRequest();
2239        copyValues(dst);
2240        if (identifier != null) {
2241          dst.identifier = new ArrayList<Identifier>();
2242          for (Identifier i : identifier)
2243            dst.identifier.add(i.copy());
2244        };
2245        if (basedOn != null) {
2246          dst.basedOn = new ArrayList<Reference>();
2247          for (Reference i : basedOn)
2248            dst.basedOn.add(i.copy());
2249        };
2250        if (replaces != null) {
2251          dst.replaces = new ArrayList<Reference>();
2252          for (Reference i : replaces)
2253            dst.replaces.add(i.copy());
2254        };
2255        dst.groupIdentifier = groupIdentifier == null ? null : groupIdentifier.copy();
2256        dst.status = status == null ? null : status.copy();
2257        dst.statusReason = statusReason == null ? null : statusReason.copy();
2258        if (category != null) {
2259          dst.category = new ArrayList<CodeableConcept>();
2260          for (CodeableConcept i : category)
2261            dst.category.add(i.copy());
2262        };
2263        dst.priority = priority == null ? null : priority.copy();
2264        dst.doNotPerform = doNotPerform == null ? null : doNotPerform.copy();
2265        if (medium != null) {
2266          dst.medium = new ArrayList<CodeableConcept>();
2267          for (CodeableConcept i : medium)
2268            dst.medium.add(i.copy());
2269        };
2270        dst.subject = subject == null ? null : subject.copy();
2271        if (about != null) {
2272          dst.about = new ArrayList<Reference>();
2273          for (Reference i : about)
2274            dst.about.add(i.copy());
2275        };
2276        dst.context = context == null ? null : context.copy();
2277        if (payload != null) {
2278          dst.payload = new ArrayList<CommunicationRequestPayloadComponent>();
2279          for (CommunicationRequestPayloadComponent i : payload)
2280            dst.payload.add(i.copy());
2281        };
2282        dst.occurrence = occurrence == null ? null : occurrence.copy();
2283        dst.authoredOn = authoredOn == null ? null : authoredOn.copy();
2284        dst.requester = requester == null ? null : requester.copy();
2285        if (recipient != null) {
2286          dst.recipient = new ArrayList<Reference>();
2287          for (Reference i : recipient)
2288            dst.recipient.add(i.copy());
2289        };
2290        dst.sender = sender == null ? null : sender.copy();
2291        if (reasonCode != null) {
2292          dst.reasonCode = new ArrayList<CodeableConcept>();
2293          for (CodeableConcept i : reasonCode)
2294            dst.reasonCode.add(i.copy());
2295        };
2296        if (reasonReference != null) {
2297          dst.reasonReference = new ArrayList<Reference>();
2298          for (Reference i : reasonReference)
2299            dst.reasonReference.add(i.copy());
2300        };
2301        if (note != null) {
2302          dst.note = new ArrayList<Annotation>();
2303          for (Annotation i : note)
2304            dst.note.add(i.copy());
2305        };
2306        return dst;
2307      }
2308
2309      protected CommunicationRequest typedCopy() {
2310        return copy();
2311      }
2312
2313      @Override
2314      public boolean equalsDeep(Base other_) {
2315        if (!super.equalsDeep(other_))
2316          return false;
2317        if (!(other_ instanceof CommunicationRequest))
2318          return false;
2319        CommunicationRequest o = (CommunicationRequest) other_;
2320        return compareDeep(identifier, o.identifier, true) && compareDeep(basedOn, o.basedOn, true) && compareDeep(replaces, o.replaces, true)
2321           && compareDeep(groupIdentifier, o.groupIdentifier, true) && compareDeep(status, o.status, true)
2322           && compareDeep(statusReason, o.statusReason, true) && compareDeep(category, o.category, true) && compareDeep(priority, o.priority, true)
2323           && compareDeep(doNotPerform, o.doNotPerform, true) && compareDeep(medium, o.medium, true) && compareDeep(subject, o.subject, true)
2324           && compareDeep(about, o.about, true) && compareDeep(context, o.context, true) && compareDeep(payload, o.payload, true)
2325           && compareDeep(occurrence, o.occurrence, true) && compareDeep(authoredOn, o.authoredOn, true) && compareDeep(requester, o.requester, true)
2326           && compareDeep(recipient, o.recipient, true) && compareDeep(sender, o.sender, true) && compareDeep(reasonCode, o.reasonCode, true)
2327           && compareDeep(reasonReference, o.reasonReference, true) && compareDeep(note, o.note, true);
2328      }
2329
2330      @Override
2331      public boolean equalsShallow(Base other_) {
2332        if (!super.equalsShallow(other_))
2333          return false;
2334        if (!(other_ instanceof CommunicationRequest))
2335          return false;
2336        CommunicationRequest o = (CommunicationRequest) other_;
2337        return compareValues(status, o.status, true) && compareValues(priority, o.priority, true) && compareValues(doNotPerform, o.doNotPerform, true)
2338           && compareValues(authoredOn, o.authoredOn, true);
2339      }
2340
2341      public boolean isEmpty() {
2342        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, basedOn, replaces
2343          , groupIdentifier, status, statusReason, category, priority, doNotPerform, medium
2344          , subject, about, context, payload, occurrence, authoredOn, requester, recipient
2345          , sender, reasonCode, reasonReference, note);
2346      }
2347
2348  @Override
2349  public ResourceType getResourceType() {
2350    return ResourceType.CommunicationRequest;
2351   }
2352
2353 /**
2354   * Search parameter: <b>requester</b>
2355   * <p>
2356   * Description: <b>Who/what is requesting service</b><br>
2357   * Type: <b>reference</b><br>
2358   * Path: <b>CommunicationRequest.requester</b><br>
2359   * </p>
2360   */
2361  @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 } )
2362  public static final String SP_REQUESTER = "requester";
2363 /**
2364   * <b>Fluent Client</b> search parameter constant for <b>requester</b>
2365   * <p>
2366   * Description: <b>Who/what is requesting service</b><br>
2367   * Type: <b>reference</b><br>
2368   * Path: <b>CommunicationRequest.requester</b><br>
2369   * </p>
2370   */
2371  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam REQUESTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_REQUESTER);
2372
2373/**
2374   * Constant for fluent queries to be used to add include statements. Specifies
2375   * the path value of "<b>CommunicationRequest:requester</b>".
2376   */
2377  public static final ca.uhn.fhir.model.api.Include INCLUDE_REQUESTER = new ca.uhn.fhir.model.api.Include("CommunicationRequest:requester").toLocked();
2378
2379 /**
2380   * Search parameter: <b>authored</b>
2381   * <p>
2382   * Description: <b>When request transitioned to being actionable</b><br>
2383   * Type: <b>date</b><br>
2384   * Path: <b>CommunicationRequest.authoredOn</b><br>
2385   * </p>
2386   */
2387  @SearchParamDefinition(name="authored", path="CommunicationRequest.authoredOn", description="When request transitioned to being actionable", type="date" )
2388  public static final String SP_AUTHORED = "authored";
2389 /**
2390   * <b>Fluent Client</b> search parameter constant for <b>authored</b>
2391   * <p>
2392   * Description: <b>When request transitioned to being actionable</b><br>
2393   * Type: <b>date</b><br>
2394   * Path: <b>CommunicationRequest.authoredOn</b><br>
2395   * </p>
2396   */
2397  public static final ca.uhn.fhir.rest.gclient.DateClientParam AUTHORED = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_AUTHORED);
2398
2399 /**
2400   * Search parameter: <b>identifier</b>
2401   * <p>
2402   * Description: <b>Unique identifier</b><br>
2403   * Type: <b>token</b><br>
2404   * Path: <b>CommunicationRequest.identifier</b><br>
2405   * </p>
2406   */
2407  @SearchParamDefinition(name="identifier", path="CommunicationRequest.identifier", description="Unique identifier", type="token" )
2408  public static final String SP_IDENTIFIER = "identifier";
2409 /**
2410   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2411   * <p>
2412   * Description: <b>Unique identifier</b><br>
2413   * Type: <b>token</b><br>
2414   * Path: <b>CommunicationRequest.identifier</b><br>
2415   * </p>
2416   */
2417  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2418
2419 /**
2420   * Search parameter: <b>subject</b>
2421   * <p>
2422   * Description: <b>Focus of message</b><br>
2423   * Type: <b>reference</b><br>
2424   * Path: <b>CommunicationRequest.subject</b><br>
2425   * </p>
2426   */
2427  @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 } )
2428  public static final String SP_SUBJECT = "subject";
2429 /**
2430   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
2431   * <p>
2432   * Description: <b>Focus of message</b><br>
2433   * Type: <b>reference</b><br>
2434   * Path: <b>CommunicationRequest.subject</b><br>
2435   * </p>
2436   */
2437  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
2438
2439/**
2440   * Constant for fluent queries to be used to add include statements. Specifies
2441   * the path value of "<b>CommunicationRequest:subject</b>".
2442   */
2443  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("CommunicationRequest:subject").toLocked();
2444
2445 /**
2446   * Search parameter: <b>replaces</b>
2447   * <p>
2448   * Description: <b>Request(s) replaced by this request</b><br>
2449   * Type: <b>reference</b><br>
2450   * Path: <b>CommunicationRequest.replaces</b><br>
2451   * </p>
2452   */
2453  @SearchParamDefinition(name="replaces", path="CommunicationRequest.replaces", description="Request(s) replaced by this request", type="reference", target={CommunicationRequest.class } )
2454  public static final String SP_REPLACES = "replaces";
2455 /**
2456   * <b>Fluent Client</b> search parameter constant for <b>replaces</b>
2457   * <p>
2458   * Description: <b>Request(s) replaced by this request</b><br>
2459   * Type: <b>reference</b><br>
2460   * Path: <b>CommunicationRequest.replaces</b><br>
2461   * </p>
2462   */
2463  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam REPLACES = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_REPLACES);
2464
2465/**
2466   * Constant for fluent queries to be used to add include statements. Specifies
2467   * the path value of "<b>CommunicationRequest:replaces</b>".
2468   */
2469  public static final ca.uhn.fhir.model.api.Include INCLUDE_REPLACES = new ca.uhn.fhir.model.api.Include("CommunicationRequest:replaces").toLocked();
2470
2471 /**
2472   * Search parameter: <b>medium</b>
2473   * <p>
2474   * Description: <b>A channel of communication</b><br>
2475   * Type: <b>token</b><br>
2476   * Path: <b>CommunicationRequest.medium</b><br>
2477   * </p>
2478   */
2479  @SearchParamDefinition(name="medium", path="CommunicationRequest.medium", description="A channel of communication", type="token" )
2480  public static final String SP_MEDIUM = "medium";
2481 /**
2482   * <b>Fluent Client</b> search parameter constant for <b>medium</b>
2483   * <p>
2484   * Description: <b>A channel of communication</b><br>
2485   * Type: <b>token</b><br>
2486   * Path: <b>CommunicationRequest.medium</b><br>
2487   * </p>
2488   */
2489  public static final ca.uhn.fhir.rest.gclient.TokenClientParam MEDIUM = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_MEDIUM);
2490
2491 /**
2492   * Search parameter: <b>occurrence</b>
2493   * <p>
2494   * Description: <b>When scheduled</b><br>
2495   * Type: <b>date</b><br>
2496   * Path: <b>CommunicationRequest.occurrenceDateTime</b><br>
2497   * </p>
2498   */
2499  @SearchParamDefinition(name="occurrence", path="(CommunicationRequest.occurrence as dateTime)", description="When scheduled", type="date" )
2500  public static final String SP_OCCURRENCE = "occurrence";
2501 /**
2502   * <b>Fluent Client</b> search parameter constant for <b>occurrence</b>
2503   * <p>
2504   * Description: <b>When scheduled</b><br>
2505   * Type: <b>date</b><br>
2506   * Path: <b>CommunicationRequest.occurrenceDateTime</b><br>
2507   * </p>
2508   */
2509  public static final ca.uhn.fhir.rest.gclient.DateClientParam OCCURRENCE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_OCCURRENCE);
2510
2511 /**
2512   * Search parameter: <b>encounter</b>
2513   * <p>
2514   * Description: <b>Encounter leading to message</b><br>
2515   * Type: <b>reference</b><br>
2516   * Path: <b>CommunicationRequest.context</b><br>
2517   * </p>
2518   */
2519  @SearchParamDefinition(name="encounter", path="CommunicationRequest.context.where(resolve() is Encounter)", description="Encounter leading to message", type="reference", target={Encounter.class } )
2520  public static final String SP_ENCOUNTER = "encounter";
2521 /**
2522   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
2523   * <p>
2524   * Description: <b>Encounter leading to message</b><br>
2525   * Type: <b>reference</b><br>
2526   * Path: <b>CommunicationRequest.context</b><br>
2527   * </p>
2528   */
2529  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
2530
2531/**
2532   * Constant for fluent queries to be used to add include statements. Specifies
2533   * the path value of "<b>CommunicationRequest:encounter</b>".
2534   */
2535  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("CommunicationRequest:encounter").toLocked();
2536
2537 /**
2538   * Search parameter: <b>priority</b>
2539   * <p>
2540   * Description: <b>Message urgency</b><br>
2541   * Type: <b>token</b><br>
2542   * Path: <b>CommunicationRequest.priority</b><br>
2543   * </p>
2544   */
2545  @SearchParamDefinition(name="priority", path="CommunicationRequest.priority", description="Message urgency", type="token" )
2546  public static final String SP_PRIORITY = "priority";
2547 /**
2548   * <b>Fluent Client</b> search parameter constant for <b>priority</b>
2549   * <p>
2550   * Description: <b>Message urgency</b><br>
2551   * Type: <b>token</b><br>
2552   * Path: <b>CommunicationRequest.priority</b><br>
2553   * </p>
2554   */
2555  public static final ca.uhn.fhir.rest.gclient.TokenClientParam PRIORITY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_PRIORITY);
2556
2557 /**
2558   * Search parameter: <b>group-identifier</b>
2559   * <p>
2560   * Description: <b>Composite request this is part of</b><br>
2561   * Type: <b>token</b><br>
2562   * Path: <b>CommunicationRequest.groupIdentifier</b><br>
2563   * </p>
2564   */
2565  @SearchParamDefinition(name="group-identifier", path="CommunicationRequest.groupIdentifier", description="Composite request this is part of", type="token" )
2566  public static final String SP_GROUP_IDENTIFIER = "group-identifier";
2567 /**
2568   * <b>Fluent Client</b> search parameter constant for <b>group-identifier</b>
2569   * <p>
2570   * Description: <b>Composite request this is part of</b><br>
2571   * Type: <b>token</b><br>
2572   * Path: <b>CommunicationRequest.groupIdentifier</b><br>
2573   * </p>
2574   */
2575  public static final ca.uhn.fhir.rest.gclient.TokenClientParam GROUP_IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_GROUP_IDENTIFIER);
2576
2577 /**
2578   * Search parameter: <b>based-on</b>
2579   * <p>
2580   * Description: <b>Fulfills plan or proposal</b><br>
2581   * Type: <b>reference</b><br>
2582   * Path: <b>CommunicationRequest.basedOn</b><br>
2583   * </p>
2584   */
2585  @SearchParamDefinition(name="based-on", path="CommunicationRequest.basedOn", description="Fulfills plan or proposal", type="reference" )
2586  public static final String SP_BASED_ON = "based-on";
2587 /**
2588   * <b>Fluent Client</b> search parameter constant for <b>based-on</b>
2589   * <p>
2590   * Description: <b>Fulfills plan or proposal</b><br>
2591   * Type: <b>reference</b><br>
2592   * Path: <b>CommunicationRequest.basedOn</b><br>
2593   * </p>
2594   */
2595  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam BASED_ON = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_BASED_ON);
2596
2597/**
2598   * Constant for fluent queries to be used to add include statements. Specifies
2599   * the path value of "<b>CommunicationRequest:based-on</b>".
2600   */
2601  public static final ca.uhn.fhir.model.api.Include INCLUDE_BASED_ON = new ca.uhn.fhir.model.api.Include("CommunicationRequest:based-on").toLocked();
2602
2603 /**
2604   * Search parameter: <b>sender</b>
2605   * <p>
2606   * Description: <b>Message sender</b><br>
2607   * Type: <b>reference</b><br>
2608   * Path: <b>CommunicationRequest.sender</b><br>
2609   * </p>
2610   */
2611  @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 } )
2612  public static final String SP_SENDER = "sender";
2613 /**
2614   * <b>Fluent Client</b> search parameter constant for <b>sender</b>
2615   * <p>
2616   * Description: <b>Message sender</b><br>
2617   * Type: <b>reference</b><br>
2618   * Path: <b>CommunicationRequest.sender</b><br>
2619   * </p>
2620   */
2621  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SENDER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SENDER);
2622
2623/**
2624   * Constant for fluent queries to be used to add include statements. Specifies
2625   * the path value of "<b>CommunicationRequest:sender</b>".
2626   */
2627  public static final ca.uhn.fhir.model.api.Include INCLUDE_SENDER = new ca.uhn.fhir.model.api.Include("CommunicationRequest:sender").toLocked();
2628
2629 /**
2630   * Search parameter: <b>patient</b>
2631   * <p>
2632   * Description: <b>Focus of message</b><br>
2633   * Type: <b>reference</b><br>
2634   * Path: <b>CommunicationRequest.subject</b><br>
2635   * </p>
2636   */
2637  @SearchParamDefinition(name="patient", path="CommunicationRequest.subject.where(resolve() is Patient)", description="Focus of message", type="reference", target={Patient.class } )
2638  public static final String SP_PATIENT = "patient";
2639 /**
2640   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2641   * <p>
2642   * Description: <b>Focus of message</b><br>
2643   * Type: <b>reference</b><br>
2644   * Path: <b>CommunicationRequest.subject</b><br>
2645   * </p>
2646   */
2647  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
2648
2649/**
2650   * Constant for fluent queries to be used to add include statements. Specifies
2651   * the path value of "<b>CommunicationRequest:patient</b>".
2652   */
2653  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("CommunicationRequest:patient").toLocked();
2654
2655 /**
2656   * Search parameter: <b>recipient</b>
2657   * <p>
2658   * Description: <b>Message recipient</b><br>
2659   * Type: <b>reference</b><br>
2660   * Path: <b>CommunicationRequest.recipient</b><br>
2661   * </p>
2662   */
2663  @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 } )
2664  public static final String SP_RECIPIENT = "recipient";
2665 /**
2666   * <b>Fluent Client</b> search parameter constant for <b>recipient</b>
2667   * <p>
2668   * Description: <b>Message recipient</b><br>
2669   * Type: <b>reference</b><br>
2670   * Path: <b>CommunicationRequest.recipient</b><br>
2671   * </p>
2672   */
2673  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam RECIPIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_RECIPIENT);
2674
2675/**
2676   * Constant for fluent queries to be used to add include statements. Specifies
2677   * the path value of "<b>CommunicationRequest:recipient</b>".
2678   */
2679  public static final ca.uhn.fhir.model.api.Include INCLUDE_RECIPIENT = new ca.uhn.fhir.model.api.Include("CommunicationRequest:recipient").toLocked();
2680
2681 /**
2682   * Search parameter: <b>context</b>
2683   * <p>
2684   * Description: <b>Encounter or episode leading to message</b><br>
2685   * Type: <b>reference</b><br>
2686   * Path: <b>CommunicationRequest.context</b><br>
2687   * </p>
2688   */
2689  @SearchParamDefinition(name="context", path="CommunicationRequest.context", description="Encounter or episode leading to message", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Encounter") }, target={Encounter.class, EpisodeOfCare.class } )
2690  public static final String SP_CONTEXT = "context";
2691 /**
2692   * <b>Fluent Client</b> search parameter constant for <b>context</b>
2693   * <p>
2694   * Description: <b>Encounter or episode leading to message</b><br>
2695   * Type: <b>reference</b><br>
2696   * Path: <b>CommunicationRequest.context</b><br>
2697   * </p>
2698   */
2699  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam CONTEXT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_CONTEXT);
2700
2701/**
2702   * Constant for fluent queries to be used to add include statements. Specifies
2703   * the path value of "<b>CommunicationRequest:context</b>".
2704   */
2705  public static final ca.uhn.fhir.model.api.Include INCLUDE_CONTEXT = new ca.uhn.fhir.model.api.Include("CommunicationRequest:context").toLocked();
2706
2707 /**
2708   * Search parameter: <b>category</b>
2709   * <p>
2710   * Description: <b>Message category</b><br>
2711   * Type: <b>token</b><br>
2712   * Path: <b>CommunicationRequest.category</b><br>
2713   * </p>
2714   */
2715  @SearchParamDefinition(name="category", path="CommunicationRequest.category", description="Message category", type="token" )
2716  public static final String SP_CATEGORY = "category";
2717 /**
2718   * <b>Fluent Client</b> search parameter constant for <b>category</b>
2719   * <p>
2720   * Description: <b>Message category</b><br>
2721   * Type: <b>token</b><br>
2722   * Path: <b>CommunicationRequest.category</b><br>
2723   * </p>
2724   */
2725  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CATEGORY);
2726
2727 /**
2728   * Search parameter: <b>status</b>
2729   * <p>
2730   * Description: <b>draft | active | suspended | cancelled | completed | entered-in-error | unknown</b><br>
2731   * Type: <b>token</b><br>
2732   * Path: <b>CommunicationRequest.status</b><br>
2733   * </p>
2734   */
2735  @SearchParamDefinition(name="status", path="CommunicationRequest.status", description="draft | active | suspended | cancelled | completed | entered-in-error | unknown", type="token" )
2736  public static final String SP_STATUS = "status";
2737 /**
2738   * <b>Fluent Client</b> search parameter constant for <b>status</b>
2739   * <p>
2740   * Description: <b>draft | active | suspended | cancelled | completed | entered-in-error | unknown</b><br>
2741   * Type: <b>token</b><br>
2742   * Path: <b>CommunicationRequest.status</b><br>
2743   * </p>
2744   */
2745  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
2746
2747
2748}
2749