001package org.hl7.fhir.dstu2016may.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 Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
033import java.util.ArrayList;
034import java.util.Date;
035import java.util.List;
036
037import org.hl7.fhir.exceptions.FHIRException;
038import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
039
040import ca.uhn.fhir.model.api.annotation.Block;
041import ca.uhn.fhir.model.api.annotation.Child;
042import ca.uhn.fhir.model.api.annotation.Description;
043import ca.uhn.fhir.model.api.annotation.ResourceDef;
044import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
045/**
046 * An occurrence of information being transmitted; e.g. an alert that was sent to a responsible provider, a public health agency was notified about a reportable condition.
047 */
048@ResourceDef(name="Communication", profile="http://hl7.org/fhir/Profile/Communication")
049public class Communication extends DomainResource {
050
051    public enum CommunicationStatus {
052        /**
053         * The communication transmission is ongoing.
054         */
055        INPROGRESS, 
056        /**
057         * The message transmission is complete, i.e., delivered to the recipient's destination.
058         */
059        COMPLETED, 
060        /**
061         * The communication transmission has been held by originating system/user request.
062         */
063        SUSPENDED, 
064        /**
065         * The receiving system has declined to accept the message.
066         */
067        REJECTED, 
068        /**
069         * There was a failure in transmitting the message out.
070         */
071        FAILED, 
072        /**
073         * added to help the parsers
074         */
075        NULL;
076        public static CommunicationStatus fromCode(String codeString) throws FHIRException {
077            if (codeString == null || "".equals(codeString))
078                return null;
079        if ("in-progress".equals(codeString))
080          return INPROGRESS;
081        if ("completed".equals(codeString))
082          return COMPLETED;
083        if ("suspended".equals(codeString))
084          return SUSPENDED;
085        if ("rejected".equals(codeString))
086          return REJECTED;
087        if ("failed".equals(codeString))
088          return FAILED;
089        throw new FHIRException("Unknown CommunicationStatus code '"+codeString+"'");
090        }
091        public String toCode() {
092          switch (this) {
093            case INPROGRESS: return "in-progress";
094            case COMPLETED: return "completed";
095            case SUSPENDED: return "suspended";
096            case REJECTED: return "rejected";
097            case FAILED: return "failed";
098            default: return "?";
099          }
100        }
101        public String getSystem() {
102          switch (this) {
103            case INPROGRESS: return "http://hl7.org/fhir/communication-status";
104            case COMPLETED: return "http://hl7.org/fhir/communication-status";
105            case SUSPENDED: return "http://hl7.org/fhir/communication-status";
106            case REJECTED: return "http://hl7.org/fhir/communication-status";
107            case FAILED: return "http://hl7.org/fhir/communication-status";
108            default: return "?";
109          }
110        }
111        public String getDefinition() {
112          switch (this) {
113            case INPROGRESS: return "The communication transmission is ongoing.";
114            case COMPLETED: return "The message transmission is complete, i.e., delivered to the recipient's destination.";
115            case SUSPENDED: return "The communication transmission has been held by originating system/user request.";
116            case REJECTED: return "The receiving system has declined to accept the message.";
117            case FAILED: return "There was a failure in transmitting the message out.";
118            default: return "?";
119          }
120        }
121        public String getDisplay() {
122          switch (this) {
123            case INPROGRESS: return "In Progress";
124            case COMPLETED: return "Completed";
125            case SUSPENDED: return "Suspended";
126            case REJECTED: return "Rejected";
127            case FAILED: return "Failed";
128            default: return "?";
129          }
130        }
131    }
132
133  public static class CommunicationStatusEnumFactory implements EnumFactory<CommunicationStatus> {
134    public CommunicationStatus fromCode(String codeString) throws IllegalArgumentException {
135      if (codeString == null || "".equals(codeString))
136            if (codeString == null || "".equals(codeString))
137                return null;
138        if ("in-progress".equals(codeString))
139          return CommunicationStatus.INPROGRESS;
140        if ("completed".equals(codeString))
141          return CommunicationStatus.COMPLETED;
142        if ("suspended".equals(codeString))
143          return CommunicationStatus.SUSPENDED;
144        if ("rejected".equals(codeString))
145          return CommunicationStatus.REJECTED;
146        if ("failed".equals(codeString))
147          return CommunicationStatus.FAILED;
148        throw new IllegalArgumentException("Unknown CommunicationStatus code '"+codeString+"'");
149        }
150        public Enumeration<CommunicationStatus> fromType(Base code) throws FHIRException {
151          if (code == null || code.isEmpty())
152            return null;
153          String codeString = ((PrimitiveType) code).asStringValue();
154          if (codeString == null || "".equals(codeString))
155            return null;
156        if ("in-progress".equals(codeString))
157          return new Enumeration<CommunicationStatus>(this, CommunicationStatus.INPROGRESS);
158        if ("completed".equals(codeString))
159          return new Enumeration<CommunicationStatus>(this, CommunicationStatus.COMPLETED);
160        if ("suspended".equals(codeString))
161          return new Enumeration<CommunicationStatus>(this, CommunicationStatus.SUSPENDED);
162        if ("rejected".equals(codeString))
163          return new Enumeration<CommunicationStatus>(this, CommunicationStatus.REJECTED);
164        if ("failed".equals(codeString))
165          return new Enumeration<CommunicationStatus>(this, CommunicationStatus.FAILED);
166        throw new FHIRException("Unknown CommunicationStatus code '"+codeString+"'");
167        }
168    public String toCode(CommunicationStatus code) {
169      if (code == CommunicationStatus.INPROGRESS)
170        return "in-progress";
171      if (code == CommunicationStatus.COMPLETED)
172        return "completed";
173      if (code == CommunicationStatus.SUSPENDED)
174        return "suspended";
175      if (code == CommunicationStatus.REJECTED)
176        return "rejected";
177      if (code == CommunicationStatus.FAILED)
178        return "failed";
179      return "?";
180      }
181    public String toSystem(CommunicationStatus code) {
182      return code.getSystem();
183      }
184    }
185
186    @Block()
187    public static class CommunicationPayloadComponent extends BackboneElement implements IBaseBackboneElement {
188        /**
189         * A communicated content (or for multi-part communications, one portion of the communication).
190         */
191        @Child(name = "content", type = {StringType.class, Attachment.class}, order=1, min=1, max=1, modifier=false, summary=true)
192        @Description(shortDefinition="Message part content", formalDefinition="A communicated content (or for multi-part communications, one portion of the communication)." )
193        protected Type content;
194
195        private static final long serialVersionUID = -1763459053L;
196
197    /**
198     * Constructor
199     */
200      public CommunicationPayloadComponent() {
201        super();
202      }
203
204    /**
205     * Constructor
206     */
207      public CommunicationPayloadComponent(Type content) {
208        super();
209        this.content = content;
210      }
211
212        /**
213         * @return {@link #content} (A communicated content (or for multi-part communications, one portion of the communication).)
214         */
215        public Type getContent() { 
216          return this.content;
217        }
218
219        /**
220         * @return {@link #content} (A communicated content (or for multi-part communications, one portion of the communication).)
221         */
222        public StringType getContentStringType() throws FHIRException { 
223          if (!(this.content instanceof StringType))
224            throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.content.getClass().getName()+" was encountered");
225          return (StringType) this.content;
226        }
227
228        public boolean hasContentStringType() { 
229          return this.content instanceof StringType;
230        }
231
232        /**
233         * @return {@link #content} (A communicated content (or for multi-part communications, one portion of the communication).)
234         */
235        public Attachment getContentAttachment() throws FHIRException { 
236          if (!(this.content instanceof Attachment))
237            throw new FHIRException("Type mismatch: the type Attachment was expected, but "+this.content.getClass().getName()+" was encountered");
238          return (Attachment) this.content;
239        }
240
241        public boolean hasContentAttachment() { 
242          return this.content instanceof Attachment;
243        }
244
245        /**
246         * @return {@link #content} (A communicated content (or for multi-part communications, one portion of the communication).)
247         */
248        public Reference getContentReference() throws FHIRException { 
249          if (!(this.content instanceof Reference))
250            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.content.getClass().getName()+" was encountered");
251          return (Reference) this.content;
252        }
253
254        public boolean hasContentReference() { 
255          return this.content instanceof Reference;
256        }
257
258        public boolean hasContent() { 
259          return this.content != null && !this.content.isEmpty();
260        }
261
262        /**
263         * @param value {@link #content} (A communicated content (or for multi-part communications, one portion of the communication).)
264         */
265        public CommunicationPayloadComponent setContent(Type value) { 
266          this.content = value;
267          return this;
268        }
269
270        protected void listChildren(List<Property> childrenList) {
271          super.listChildren(childrenList);
272          childrenList.add(new Property("content[x]", "string|Attachment|Reference(Any)", "A communicated content (or for multi-part communications, one portion of the communication).", 0, java.lang.Integer.MAX_VALUE, content));
273        }
274
275      @Override
276      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
277        switch (hash) {
278        case 951530617: /*content*/ return this.content == null ? new Base[0] : new Base[] {this.content}; // Type
279        default: return super.getProperty(hash, name, checkValid);
280        }
281
282      }
283
284      @Override
285      public void setProperty(int hash, String name, Base value) throws FHIRException {
286        switch (hash) {
287        case 951530617: // content
288          this.content = (Type) value; // Type
289          break;
290        default: super.setProperty(hash, name, value);
291        }
292
293      }
294
295      @Override
296      public void setProperty(String name, Base value) throws FHIRException {
297        if (name.equals("content[x]"))
298          this.content = (Type) value; // Type
299        else
300          super.setProperty(name, value);
301      }
302
303      @Override
304      public Base makeProperty(int hash, String name) throws FHIRException {
305        switch (hash) {
306        case 264548711:  return getContent(); // Type
307        default: return super.makeProperty(hash, name);
308        }
309
310      }
311
312      @Override
313      public Base addChild(String name) throws FHIRException {
314        if (name.equals("contentString")) {
315          this.content = new StringType();
316          return this.content;
317        }
318        else if (name.equals("contentAttachment")) {
319          this.content = new Attachment();
320          return this.content;
321        }
322        else if (name.equals("contentReference")) {
323          this.content = new Reference();
324          return this.content;
325        }
326        else
327          return super.addChild(name);
328      }
329
330      public CommunicationPayloadComponent copy() {
331        CommunicationPayloadComponent dst = new CommunicationPayloadComponent();
332        copyValues(dst);
333        dst.content = content == null ? null : content.copy();
334        return dst;
335      }
336
337      @Override
338      public boolean equalsDeep(Base other) {
339        if (!super.equalsDeep(other))
340          return false;
341        if (!(other instanceof CommunicationPayloadComponent))
342          return false;
343        CommunicationPayloadComponent o = (CommunicationPayloadComponent) other;
344        return compareDeep(content, o.content, true);
345      }
346
347      @Override
348      public boolean equalsShallow(Base other) {
349        if (!super.equalsShallow(other))
350          return false;
351        if (!(other instanceof CommunicationPayloadComponent))
352          return false;
353        CommunicationPayloadComponent o = (CommunicationPayloadComponent) other;
354        return true;
355      }
356
357      public boolean isEmpty() {
358        return super.isEmpty() && (content == null || content.isEmpty());
359      }
360
361  public String fhirType() {
362    return "Communication.payload";
363
364  }
365
366  }
367
368    /**
369     * Identifiers associated with this Communication that are defined by business processes and/ or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).
370     */
371    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
372    @Description(shortDefinition="Unique identifier", formalDefinition="Identifiers associated with this Communication that are defined by business processes and/ or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation)." )
373    protected List<Identifier> identifier;
374
375    /**
376     * The type of message conveyed such as alert, notification, reminder, instruction, etc.
377     */
378    @Child(name = "category", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
379    @Description(shortDefinition="Message category", formalDefinition="The type of message conveyed such as alert, notification, reminder, instruction, etc." )
380    protected CodeableConcept category;
381
382    /**
383     * The entity (e.g. person, organization, clinical information system, or device) which was the source of the communication.
384     */
385    @Child(name = "sender", type = {Device.class, Organization.class, Patient.class, Practitioner.class, RelatedPerson.class}, order=2, min=0, max=1, modifier=false, summary=true)
386    @Description(shortDefinition="Message sender", formalDefinition="The entity (e.g. person, organization, clinical information system, or device) which was the source of the communication." )
387    protected Reference sender;
388
389    /**
390     * The actual object that is the target of the reference (The entity (e.g. person, organization, clinical information system, or device) which was the source of the communication.)
391     */
392    protected Resource senderTarget;
393
394    /**
395     * The entity (e.g. person, organization, clinical information system, or device) which was the target of the communication. If receipts need to be tracked by individual, a separate resource instance will need to be created for each recipient.  Multiple recipient communications are intended where either a receipt(s) is not tracked (e.g. a mass mail-out) or is captured in aggregate (all emails confirmed received by a particular time).
396     */
397    @Child(name = "recipient", type = {Device.class, Organization.class, Patient.class, Practitioner.class, RelatedPerson.class, Group.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
398    @Description(shortDefinition="Message recipient", formalDefinition="The entity (e.g. person, organization, clinical information system, or device) which was the target of the communication. If receipts need to be tracked by individual, a separate resource instance will need to be created for each recipient.  Multiple recipient communications are intended where either a receipt(s) is not tracked (e.g. a mass mail-out) or is captured in aggregate (all emails confirmed received by a particular time)." )
399    protected List<Reference> recipient;
400    /**
401     * The actual objects that are the target of the reference (The entity (e.g. person, organization, clinical information system, or device) which was the target of the communication. If receipts need to be tracked by individual, a separate resource instance will need to be created for each recipient.  Multiple recipient communications are intended where either a receipt(s) is not tracked (e.g. a mass mail-out) or is captured in aggregate (all emails confirmed received by a particular time).)
402     */
403    protected List<Resource> recipientTarget;
404
405
406    /**
407     * Text, attachment(s), or resource(s) that was communicated to the recipient.
408     */
409    @Child(name = "payload", type = {}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
410    @Description(shortDefinition="Message payload", formalDefinition="Text, attachment(s), or resource(s) that was communicated to the recipient." )
411    protected List<CommunicationPayloadComponent> payload;
412
413    /**
414     * A channel that was used for this communication (e.g. email, fax).
415     */
416    @Child(name = "medium", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
417    @Description(shortDefinition="A channel of communication", formalDefinition="A channel that was used for this communication (e.g. email, fax)." )
418    protected List<CodeableConcept> medium;
419
420    /**
421     * The status of the transmission.
422     */
423    @Child(name = "status", type = {CodeType.class}, order=6, min=0, max=1, modifier=true, summary=true)
424    @Description(shortDefinition="in-progress | completed | suspended | rejected | failed", formalDefinition="The status of the transmission." )
425    protected Enumeration<CommunicationStatus> status;
426
427    /**
428     * The encounter within which the communication was sent.
429     */
430    @Child(name = "encounter", type = {Encounter.class}, order=7, min=0, max=1, modifier=false, summary=true)
431    @Description(shortDefinition="Encounter leading to message", formalDefinition="The encounter within which the communication was sent." )
432    protected Reference encounter;
433
434    /**
435     * The actual object that is the target of the reference (The encounter within which the communication was sent.)
436     */
437    protected Encounter encounterTarget;
438
439    /**
440     * The time when this communication was sent.
441     */
442    @Child(name = "sent", type = {DateTimeType.class}, order=8, min=0, max=1, modifier=false, summary=true)
443    @Description(shortDefinition="When sent", formalDefinition="The time when this communication was sent." )
444    protected DateTimeType sent;
445
446    /**
447     * The time when this communication arrived at the destination.
448     */
449    @Child(name = "received", type = {DateTimeType.class}, order=9, min=0, max=1, modifier=false, summary=true)
450    @Description(shortDefinition="When received", formalDefinition="The time when this communication arrived at the destination." )
451    protected DateTimeType received;
452
453    /**
454     * The reason or justification for the communication.
455     */
456    @Child(name = "reason", type = {CodeableConcept.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
457    @Description(shortDefinition="Indication for message", formalDefinition="The reason or justification for the communication." )
458    protected List<CodeableConcept> reason;
459
460    /**
461     * The patient who was the focus of this communication.
462     */
463    @Child(name = "subject", type = {Patient.class}, order=11, min=0, max=1, modifier=false, summary=true)
464    @Description(shortDefinition="Focus of message", formalDefinition="The patient who was the focus of this communication." )
465    protected Reference subject;
466
467    /**
468     * The actual object that is the target of the reference (The patient who was the focus of this communication.)
469     */
470    protected Patient subjectTarget;
471
472    /**
473     * The communication request that was responsible for producing this communication.
474     */
475    @Child(name = "requestDetail", type = {CommunicationRequest.class}, order=12, min=0, max=1, modifier=false, summary=true)
476    @Description(shortDefinition="CommunicationRequest producing this message", formalDefinition="The communication request that was responsible for producing this communication." )
477    protected Reference requestDetail;
478
479    /**
480     * The actual object that is the target of the reference (The communication request that was responsible for producing this communication.)
481     */
482    protected CommunicationRequest requestDetailTarget;
483
484    private static final long serialVersionUID = -1654449146L;
485
486  /**
487   * Constructor
488   */
489    public Communication() {
490      super();
491    }
492
493    /**
494     * @return {@link #identifier} (Identifiers associated with this Communication that are defined by business processes and/ or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).)
495     */
496    public List<Identifier> getIdentifier() { 
497      if (this.identifier == null)
498        this.identifier = new ArrayList<Identifier>();
499      return this.identifier;
500    }
501
502    public boolean hasIdentifier() { 
503      if (this.identifier == null)
504        return false;
505      for (Identifier item : this.identifier)
506        if (!item.isEmpty())
507          return true;
508      return false;
509    }
510
511    /**
512     * @return {@link #identifier} (Identifiers associated with this Communication that are defined by business processes and/ or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).)
513     */
514    // syntactic sugar
515    public Identifier addIdentifier() { //3
516      Identifier t = new Identifier();
517      if (this.identifier == null)
518        this.identifier = new ArrayList<Identifier>();
519      this.identifier.add(t);
520      return t;
521    }
522
523    // syntactic sugar
524    public Communication addIdentifier(Identifier t) { //3
525      if (t == null)
526        return this;
527      if (this.identifier == null)
528        this.identifier = new ArrayList<Identifier>();
529      this.identifier.add(t);
530      return this;
531    }
532
533    /**
534     * @return {@link #category} (The type of message conveyed such as alert, notification, reminder, instruction, etc.)
535     */
536    public CodeableConcept getCategory() { 
537      if (this.category == null)
538        if (Configuration.errorOnAutoCreate())
539          throw new Error("Attempt to auto-create Communication.category");
540        else if (Configuration.doAutoCreate())
541          this.category = new CodeableConcept(); // cc
542      return this.category;
543    }
544
545    public boolean hasCategory() { 
546      return this.category != null && !this.category.isEmpty();
547    }
548
549    /**
550     * @param value {@link #category} (The type of message conveyed such as alert, notification, reminder, instruction, etc.)
551     */
552    public Communication setCategory(CodeableConcept value) { 
553      this.category = value;
554      return this;
555    }
556
557    /**
558     * @return {@link #sender} (The entity (e.g. person, organization, clinical information system, or device) which was the source of the communication.)
559     */
560    public Reference getSender() { 
561      if (this.sender == null)
562        if (Configuration.errorOnAutoCreate())
563          throw new Error("Attempt to auto-create Communication.sender");
564        else if (Configuration.doAutoCreate())
565          this.sender = new Reference(); // cc
566      return this.sender;
567    }
568
569    public boolean hasSender() { 
570      return this.sender != null && !this.sender.isEmpty();
571    }
572
573    /**
574     * @param value {@link #sender} (The entity (e.g. person, organization, clinical information system, or device) which was the source of the communication.)
575     */
576    public Communication setSender(Reference value) { 
577      this.sender = value;
578      return this;
579    }
580
581    /**
582     * @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 was the source of the communication.)
583     */
584    public Resource getSenderTarget() { 
585      return this.senderTarget;
586    }
587
588    /**
589     * @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 was the source of the communication.)
590     */
591    public Communication setSenderTarget(Resource value) { 
592      this.senderTarget = value;
593      return this;
594    }
595
596    /**
597     * @return {@link #recipient} (The entity (e.g. person, organization, clinical information system, or device) which was the target of the communication. If receipts need to be tracked by individual, a separate resource instance will need to be created for each recipient.  Multiple recipient communications are intended where either a receipt(s) is not tracked (e.g. a mass mail-out) or is captured in aggregate (all emails confirmed received by a particular time).)
598     */
599    public List<Reference> getRecipient() { 
600      if (this.recipient == null)
601        this.recipient = new ArrayList<Reference>();
602      return this.recipient;
603    }
604
605    public boolean hasRecipient() { 
606      if (this.recipient == null)
607        return false;
608      for (Reference item : this.recipient)
609        if (!item.isEmpty())
610          return true;
611      return false;
612    }
613
614    /**
615     * @return {@link #recipient} (The entity (e.g. person, organization, clinical information system, or device) which was the target of the communication. If receipts need to be tracked by individual, a separate resource instance will need to be created for each recipient.  Multiple recipient communications are intended where either a receipt(s) is not tracked (e.g. a mass mail-out) or is captured in aggregate (all emails confirmed received by a particular time).)
616     */
617    // syntactic sugar
618    public Reference addRecipient() { //3
619      Reference t = new Reference();
620      if (this.recipient == null)
621        this.recipient = new ArrayList<Reference>();
622      this.recipient.add(t);
623      return t;
624    }
625
626    // syntactic sugar
627    public Communication addRecipient(Reference t) { //3
628      if (t == null)
629        return this;
630      if (this.recipient == null)
631        this.recipient = new ArrayList<Reference>();
632      this.recipient.add(t);
633      return this;
634    }
635
636    /**
637     * @return {@link #recipient} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. The entity (e.g. person, organization, clinical information system, or device) which was the target of the communication. If receipts need to be tracked by individual, a separate resource instance will need to be created for each recipient.  Multiple recipient communications are intended where either a receipt(s) is not tracked (e.g. a mass mail-out) or is captured in aggregate (all emails confirmed received by a particular time).)
638     */
639    public List<Resource> getRecipientTarget() { 
640      if (this.recipientTarget == null)
641        this.recipientTarget = new ArrayList<Resource>();
642      return this.recipientTarget;
643    }
644
645    /**
646     * @return {@link #payload} (Text, attachment(s), or resource(s) that was communicated to the recipient.)
647     */
648    public List<CommunicationPayloadComponent> getPayload() { 
649      if (this.payload == null)
650        this.payload = new ArrayList<CommunicationPayloadComponent>();
651      return this.payload;
652    }
653
654    public boolean hasPayload() { 
655      if (this.payload == null)
656        return false;
657      for (CommunicationPayloadComponent item : this.payload)
658        if (!item.isEmpty())
659          return true;
660      return false;
661    }
662
663    /**
664     * @return {@link #payload} (Text, attachment(s), or resource(s) that was communicated to the recipient.)
665     */
666    // syntactic sugar
667    public CommunicationPayloadComponent addPayload() { //3
668      CommunicationPayloadComponent t = new CommunicationPayloadComponent();
669      if (this.payload == null)
670        this.payload = new ArrayList<CommunicationPayloadComponent>();
671      this.payload.add(t);
672      return t;
673    }
674
675    // syntactic sugar
676    public Communication addPayload(CommunicationPayloadComponent t) { //3
677      if (t == null)
678        return this;
679      if (this.payload == null)
680        this.payload = new ArrayList<CommunicationPayloadComponent>();
681      this.payload.add(t);
682      return this;
683    }
684
685    /**
686     * @return {@link #medium} (A channel that was used for this communication (e.g. email, fax).)
687     */
688    public List<CodeableConcept> getMedium() { 
689      if (this.medium == null)
690        this.medium = new ArrayList<CodeableConcept>();
691      return this.medium;
692    }
693
694    public boolean hasMedium() { 
695      if (this.medium == null)
696        return false;
697      for (CodeableConcept item : this.medium)
698        if (!item.isEmpty())
699          return true;
700      return false;
701    }
702
703    /**
704     * @return {@link #medium} (A channel that was used for this communication (e.g. email, fax).)
705     */
706    // syntactic sugar
707    public CodeableConcept addMedium() { //3
708      CodeableConcept t = new CodeableConcept();
709      if (this.medium == null)
710        this.medium = new ArrayList<CodeableConcept>();
711      this.medium.add(t);
712      return t;
713    }
714
715    // syntactic sugar
716    public Communication addMedium(CodeableConcept t) { //3
717      if (t == null)
718        return this;
719      if (this.medium == null)
720        this.medium = new ArrayList<CodeableConcept>();
721      this.medium.add(t);
722      return this;
723    }
724
725    /**
726     * @return {@link #status} (The status of the transmission.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
727     */
728    public Enumeration<CommunicationStatus> getStatusElement() { 
729      if (this.status == null)
730        if (Configuration.errorOnAutoCreate())
731          throw new Error("Attempt to auto-create Communication.status");
732        else if (Configuration.doAutoCreate())
733          this.status = new Enumeration<CommunicationStatus>(new CommunicationStatusEnumFactory()); // bb
734      return this.status;
735    }
736
737    public boolean hasStatusElement() { 
738      return this.status != null && !this.status.isEmpty();
739    }
740
741    public boolean hasStatus() { 
742      return this.status != null && !this.status.isEmpty();
743    }
744
745    /**
746     * @param value {@link #status} (The status of the transmission.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
747     */
748    public Communication setStatusElement(Enumeration<CommunicationStatus> value) { 
749      this.status = value;
750      return this;
751    }
752
753    /**
754     * @return The status of the transmission.
755     */
756    public CommunicationStatus getStatus() { 
757      return this.status == null ? null : this.status.getValue();
758    }
759
760    /**
761     * @param value The status of the transmission.
762     */
763    public Communication setStatus(CommunicationStatus value) { 
764      if (value == null)
765        this.status = null;
766      else {
767        if (this.status == null)
768          this.status = new Enumeration<CommunicationStatus>(new CommunicationStatusEnumFactory());
769        this.status.setValue(value);
770      }
771      return this;
772    }
773
774    /**
775     * @return {@link #encounter} (The encounter within which the communication was sent.)
776     */
777    public Reference getEncounter() { 
778      if (this.encounter == null)
779        if (Configuration.errorOnAutoCreate())
780          throw new Error("Attempt to auto-create Communication.encounter");
781        else if (Configuration.doAutoCreate())
782          this.encounter = new Reference(); // cc
783      return this.encounter;
784    }
785
786    public boolean hasEncounter() { 
787      return this.encounter != null && !this.encounter.isEmpty();
788    }
789
790    /**
791     * @param value {@link #encounter} (The encounter within which the communication was sent.)
792     */
793    public Communication setEncounter(Reference value) { 
794      this.encounter = value;
795      return this;
796    }
797
798    /**
799     * @return {@link #encounter} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The encounter within which the communication was sent.)
800     */
801    public Encounter getEncounterTarget() { 
802      if (this.encounterTarget == null)
803        if (Configuration.errorOnAutoCreate())
804          throw new Error("Attempt to auto-create Communication.encounter");
805        else if (Configuration.doAutoCreate())
806          this.encounterTarget = new Encounter(); // aa
807      return this.encounterTarget;
808    }
809
810    /**
811     * @param value {@link #encounter} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The encounter within which the communication was sent.)
812     */
813    public Communication setEncounterTarget(Encounter value) { 
814      this.encounterTarget = value;
815      return this;
816    }
817
818    /**
819     * @return {@link #sent} (The time when this communication was sent.). This is the underlying object with id, value and extensions. The accessor "getSent" gives direct access to the value
820     */
821    public DateTimeType getSentElement() { 
822      if (this.sent == null)
823        if (Configuration.errorOnAutoCreate())
824          throw new Error("Attempt to auto-create Communication.sent");
825        else if (Configuration.doAutoCreate())
826          this.sent = new DateTimeType(); // bb
827      return this.sent;
828    }
829
830    public boolean hasSentElement() { 
831      return this.sent != null && !this.sent.isEmpty();
832    }
833
834    public boolean hasSent() { 
835      return this.sent != null && !this.sent.isEmpty();
836    }
837
838    /**
839     * @param value {@link #sent} (The time when this communication was sent.). This is the underlying object with id, value and extensions. The accessor "getSent" gives direct access to the value
840     */
841    public Communication setSentElement(DateTimeType value) { 
842      this.sent = value;
843      return this;
844    }
845
846    /**
847     * @return The time when this communication was sent.
848     */
849    public Date getSent() { 
850      return this.sent == null ? null : this.sent.getValue();
851    }
852
853    /**
854     * @param value The time when this communication was sent.
855     */
856    public Communication setSent(Date value) { 
857      if (value == null)
858        this.sent = null;
859      else {
860        if (this.sent == null)
861          this.sent = new DateTimeType();
862        this.sent.setValue(value);
863      }
864      return this;
865    }
866
867    /**
868     * @return {@link #received} (The time when this communication arrived at the destination.). This is the underlying object with id, value and extensions. The accessor "getReceived" gives direct access to the value
869     */
870    public DateTimeType getReceivedElement() { 
871      if (this.received == null)
872        if (Configuration.errorOnAutoCreate())
873          throw new Error("Attempt to auto-create Communication.received");
874        else if (Configuration.doAutoCreate())
875          this.received = new DateTimeType(); // bb
876      return this.received;
877    }
878
879    public boolean hasReceivedElement() { 
880      return this.received != null && !this.received.isEmpty();
881    }
882
883    public boolean hasReceived() { 
884      return this.received != null && !this.received.isEmpty();
885    }
886
887    /**
888     * @param value {@link #received} (The time when this communication arrived at the destination.). This is the underlying object with id, value and extensions. The accessor "getReceived" gives direct access to the value
889     */
890    public Communication setReceivedElement(DateTimeType value) { 
891      this.received = value;
892      return this;
893    }
894
895    /**
896     * @return The time when this communication arrived at the destination.
897     */
898    public Date getReceived() { 
899      return this.received == null ? null : this.received.getValue();
900    }
901
902    /**
903     * @param value The time when this communication arrived at the destination.
904     */
905    public Communication setReceived(Date value) { 
906      if (value == null)
907        this.received = null;
908      else {
909        if (this.received == null)
910          this.received = new DateTimeType();
911        this.received.setValue(value);
912      }
913      return this;
914    }
915
916    /**
917     * @return {@link #reason} (The reason or justification for the communication.)
918     */
919    public List<CodeableConcept> getReason() { 
920      if (this.reason == null)
921        this.reason = new ArrayList<CodeableConcept>();
922      return this.reason;
923    }
924
925    public boolean hasReason() { 
926      if (this.reason == null)
927        return false;
928      for (CodeableConcept item : this.reason)
929        if (!item.isEmpty())
930          return true;
931      return false;
932    }
933
934    /**
935     * @return {@link #reason} (The reason or justification for the communication.)
936     */
937    // syntactic sugar
938    public CodeableConcept addReason() { //3
939      CodeableConcept t = new CodeableConcept();
940      if (this.reason == null)
941        this.reason = new ArrayList<CodeableConcept>();
942      this.reason.add(t);
943      return t;
944    }
945
946    // syntactic sugar
947    public Communication addReason(CodeableConcept t) { //3
948      if (t == null)
949        return this;
950      if (this.reason == null)
951        this.reason = new ArrayList<CodeableConcept>();
952      this.reason.add(t);
953      return this;
954    }
955
956    /**
957     * @return {@link #subject} (The patient who was the focus of this communication.)
958     */
959    public Reference getSubject() { 
960      if (this.subject == null)
961        if (Configuration.errorOnAutoCreate())
962          throw new Error("Attempt to auto-create Communication.subject");
963        else if (Configuration.doAutoCreate())
964          this.subject = new Reference(); // cc
965      return this.subject;
966    }
967
968    public boolean hasSubject() { 
969      return this.subject != null && !this.subject.isEmpty();
970    }
971
972    /**
973     * @param value {@link #subject} (The patient who was the focus of this communication.)
974     */
975    public Communication setSubject(Reference value) { 
976      this.subject = value;
977      return this;
978    }
979
980    /**
981     * @return {@link #subject} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The patient who was the focus of this communication.)
982     */
983    public Patient getSubjectTarget() { 
984      if (this.subjectTarget == null)
985        if (Configuration.errorOnAutoCreate())
986          throw new Error("Attempt to auto-create Communication.subject");
987        else if (Configuration.doAutoCreate())
988          this.subjectTarget = new Patient(); // aa
989      return this.subjectTarget;
990    }
991
992    /**
993     * @param value {@link #subject} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The patient who was the focus of this communication.)
994     */
995    public Communication setSubjectTarget(Patient value) { 
996      this.subjectTarget = value;
997      return this;
998    }
999
1000    /**
1001     * @return {@link #requestDetail} (The communication request that was responsible for producing this communication.)
1002     */
1003    public Reference getRequestDetail() { 
1004      if (this.requestDetail == null)
1005        if (Configuration.errorOnAutoCreate())
1006          throw new Error("Attempt to auto-create Communication.requestDetail");
1007        else if (Configuration.doAutoCreate())
1008          this.requestDetail = new Reference(); // cc
1009      return this.requestDetail;
1010    }
1011
1012    public boolean hasRequestDetail() { 
1013      return this.requestDetail != null && !this.requestDetail.isEmpty();
1014    }
1015
1016    /**
1017     * @param value {@link #requestDetail} (The communication request that was responsible for producing this communication.)
1018     */
1019    public Communication setRequestDetail(Reference value) { 
1020      this.requestDetail = value;
1021      return this;
1022    }
1023
1024    /**
1025     * @return {@link #requestDetail} 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 communication request that was responsible for producing this communication.)
1026     */
1027    public CommunicationRequest getRequestDetailTarget() { 
1028      if (this.requestDetailTarget == null)
1029        if (Configuration.errorOnAutoCreate())
1030          throw new Error("Attempt to auto-create Communication.requestDetail");
1031        else if (Configuration.doAutoCreate())
1032          this.requestDetailTarget = new CommunicationRequest(); // aa
1033      return this.requestDetailTarget;
1034    }
1035
1036    /**
1037     * @param value {@link #requestDetail} 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 communication request that was responsible for producing this communication.)
1038     */
1039    public Communication setRequestDetailTarget(CommunicationRequest value) { 
1040      this.requestDetailTarget = value;
1041      return this;
1042    }
1043
1044      protected void listChildren(List<Property> childrenList) {
1045        super.listChildren(childrenList);
1046        childrenList.add(new Property("identifier", "Identifier", "Identifiers associated with this Communication that are defined by business processes and/ or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).", 0, java.lang.Integer.MAX_VALUE, identifier));
1047        childrenList.add(new Property("category", "CodeableConcept", "The type of message conveyed such as alert, notification, reminder, instruction, etc.", 0, java.lang.Integer.MAX_VALUE, category));
1048        childrenList.add(new Property("sender", "Reference(Device|Organization|Patient|Practitioner|RelatedPerson)", "The entity (e.g. person, organization, clinical information system, or device) which was the source of the communication.", 0, java.lang.Integer.MAX_VALUE, sender));
1049        childrenList.add(new Property("recipient", "Reference(Device|Organization|Patient|Practitioner|RelatedPerson|Group)", "The entity (e.g. person, organization, clinical information system, or device) which was the target of the communication. If receipts need to be tracked by individual, a separate resource instance will need to be created for each recipient.  Multiple recipient communications are intended where either a receipt(s) is not tracked (e.g. a mass mail-out) or is captured in aggregate (all emails confirmed received by a particular time).", 0, java.lang.Integer.MAX_VALUE, recipient));
1050        childrenList.add(new Property("payload", "", "Text, attachment(s), or resource(s) that was communicated to the recipient.", 0, java.lang.Integer.MAX_VALUE, payload));
1051        childrenList.add(new Property("medium", "CodeableConcept", "A channel that was used for this communication (e.g. email, fax).", 0, java.lang.Integer.MAX_VALUE, medium));
1052        childrenList.add(new Property("status", "code", "The status of the transmission.", 0, java.lang.Integer.MAX_VALUE, status));
1053        childrenList.add(new Property("encounter", "Reference(Encounter)", "The encounter within which the communication was sent.", 0, java.lang.Integer.MAX_VALUE, encounter));
1054        childrenList.add(new Property("sent", "dateTime", "The time when this communication was sent.", 0, java.lang.Integer.MAX_VALUE, sent));
1055        childrenList.add(new Property("received", "dateTime", "The time when this communication arrived at the destination.", 0, java.lang.Integer.MAX_VALUE, received));
1056        childrenList.add(new Property("reason", "CodeableConcept", "The reason or justification for the communication.", 0, java.lang.Integer.MAX_VALUE, reason));
1057        childrenList.add(new Property("subject", "Reference(Patient)", "The patient who was the focus of this communication.", 0, java.lang.Integer.MAX_VALUE, subject));
1058        childrenList.add(new Property("requestDetail", "Reference(CommunicationRequest)", "The communication request that was responsible for producing this communication.", 0, java.lang.Integer.MAX_VALUE, requestDetail));
1059      }
1060
1061      @Override
1062      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1063        switch (hash) {
1064        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1065        case 50511102: /*category*/ return this.category == null ? new Base[0] : new Base[] {this.category}; // CodeableConcept
1066        case -905962955: /*sender*/ return this.sender == null ? new Base[0] : new Base[] {this.sender}; // Reference
1067        case 820081177: /*recipient*/ return this.recipient == null ? new Base[0] : this.recipient.toArray(new Base[this.recipient.size()]); // Reference
1068        case -786701938: /*payload*/ return this.payload == null ? new Base[0] : this.payload.toArray(new Base[this.payload.size()]); // CommunicationPayloadComponent
1069        case -1078030475: /*medium*/ return this.medium == null ? new Base[0] : this.medium.toArray(new Base[this.medium.size()]); // CodeableConcept
1070        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<CommunicationStatus>
1071        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : new Base[] {this.encounter}; // Reference
1072        case 3526552: /*sent*/ return this.sent == null ? new Base[0] : new Base[] {this.sent}; // DateTimeType
1073        case -808719903: /*received*/ return this.received == null ? new Base[0] : new Base[] {this.received}; // DateTimeType
1074        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : this.reason.toArray(new Base[this.reason.size()]); // CodeableConcept
1075        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
1076        case 960204736: /*requestDetail*/ return this.requestDetail == null ? new Base[0] : new Base[] {this.requestDetail}; // Reference
1077        default: return super.getProperty(hash, name, checkValid);
1078        }
1079
1080      }
1081
1082      @Override
1083      public void setProperty(int hash, String name, Base value) throws FHIRException {
1084        switch (hash) {
1085        case -1618432855: // identifier
1086          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1087          break;
1088        case 50511102: // category
1089          this.category = castToCodeableConcept(value); // CodeableConcept
1090          break;
1091        case -905962955: // sender
1092          this.sender = castToReference(value); // Reference
1093          break;
1094        case 820081177: // recipient
1095          this.getRecipient().add(castToReference(value)); // Reference
1096          break;
1097        case -786701938: // payload
1098          this.getPayload().add((CommunicationPayloadComponent) value); // CommunicationPayloadComponent
1099          break;
1100        case -1078030475: // medium
1101          this.getMedium().add(castToCodeableConcept(value)); // CodeableConcept
1102          break;
1103        case -892481550: // status
1104          this.status = new CommunicationStatusEnumFactory().fromType(value); // Enumeration<CommunicationStatus>
1105          break;
1106        case 1524132147: // encounter
1107          this.encounter = castToReference(value); // Reference
1108          break;
1109        case 3526552: // sent
1110          this.sent = castToDateTime(value); // DateTimeType
1111          break;
1112        case -808719903: // received
1113          this.received = castToDateTime(value); // DateTimeType
1114          break;
1115        case -934964668: // reason
1116          this.getReason().add(castToCodeableConcept(value)); // CodeableConcept
1117          break;
1118        case -1867885268: // subject
1119          this.subject = castToReference(value); // Reference
1120          break;
1121        case 960204736: // requestDetail
1122          this.requestDetail = castToReference(value); // Reference
1123          break;
1124        default: super.setProperty(hash, name, value);
1125        }
1126
1127      }
1128
1129      @Override
1130      public void setProperty(String name, Base value) throws FHIRException {
1131        if (name.equals("identifier"))
1132          this.getIdentifier().add(castToIdentifier(value));
1133        else if (name.equals("category"))
1134          this.category = castToCodeableConcept(value); // CodeableConcept
1135        else if (name.equals("sender"))
1136          this.sender = castToReference(value); // Reference
1137        else if (name.equals("recipient"))
1138          this.getRecipient().add(castToReference(value));
1139        else if (name.equals("payload"))
1140          this.getPayload().add((CommunicationPayloadComponent) value);
1141        else if (name.equals("medium"))
1142          this.getMedium().add(castToCodeableConcept(value));
1143        else if (name.equals("status"))
1144          this.status = new CommunicationStatusEnumFactory().fromType(value); // Enumeration<CommunicationStatus>
1145        else if (name.equals("encounter"))
1146          this.encounter = castToReference(value); // Reference
1147        else if (name.equals("sent"))
1148          this.sent = castToDateTime(value); // DateTimeType
1149        else if (name.equals("received"))
1150          this.received = castToDateTime(value); // DateTimeType
1151        else if (name.equals("reason"))
1152          this.getReason().add(castToCodeableConcept(value));
1153        else if (name.equals("subject"))
1154          this.subject = castToReference(value); // Reference
1155        else if (name.equals("requestDetail"))
1156          this.requestDetail = castToReference(value); // Reference
1157        else
1158          super.setProperty(name, value);
1159      }
1160
1161      @Override
1162      public Base makeProperty(int hash, String name) throws FHIRException {
1163        switch (hash) {
1164        case -1618432855:  return addIdentifier(); // Identifier
1165        case 50511102:  return getCategory(); // CodeableConcept
1166        case -905962955:  return getSender(); // Reference
1167        case 820081177:  return addRecipient(); // Reference
1168        case -786701938:  return addPayload(); // CommunicationPayloadComponent
1169        case -1078030475:  return addMedium(); // CodeableConcept
1170        case -892481550: throw new FHIRException("Cannot make property status as it is not a complex type"); // Enumeration<CommunicationStatus>
1171        case 1524132147:  return getEncounter(); // Reference
1172        case 3526552: throw new FHIRException("Cannot make property sent as it is not a complex type"); // DateTimeType
1173        case -808719903: throw new FHIRException("Cannot make property received as it is not a complex type"); // DateTimeType
1174        case -934964668:  return addReason(); // CodeableConcept
1175        case -1867885268:  return getSubject(); // Reference
1176        case 960204736:  return getRequestDetail(); // Reference
1177        default: return super.makeProperty(hash, name);
1178        }
1179
1180      }
1181
1182      @Override
1183      public Base addChild(String name) throws FHIRException {
1184        if (name.equals("identifier")) {
1185          return addIdentifier();
1186        }
1187        else if (name.equals("category")) {
1188          this.category = new CodeableConcept();
1189          return this.category;
1190        }
1191        else if (name.equals("sender")) {
1192          this.sender = new Reference();
1193          return this.sender;
1194        }
1195        else if (name.equals("recipient")) {
1196          return addRecipient();
1197        }
1198        else if (name.equals("payload")) {
1199          return addPayload();
1200        }
1201        else if (name.equals("medium")) {
1202          return addMedium();
1203        }
1204        else if (name.equals("status")) {
1205          throw new FHIRException("Cannot call addChild on a primitive type Communication.status");
1206        }
1207        else if (name.equals("encounter")) {
1208          this.encounter = new Reference();
1209          return this.encounter;
1210        }
1211        else if (name.equals("sent")) {
1212          throw new FHIRException("Cannot call addChild on a primitive type Communication.sent");
1213        }
1214        else if (name.equals("received")) {
1215          throw new FHIRException("Cannot call addChild on a primitive type Communication.received");
1216        }
1217        else if (name.equals("reason")) {
1218          return addReason();
1219        }
1220        else if (name.equals("subject")) {
1221          this.subject = new Reference();
1222          return this.subject;
1223        }
1224        else if (name.equals("requestDetail")) {
1225          this.requestDetail = new Reference();
1226          return this.requestDetail;
1227        }
1228        else
1229          return super.addChild(name);
1230      }
1231
1232  public String fhirType() {
1233    return "Communication";
1234
1235  }
1236
1237      public Communication copy() {
1238        Communication dst = new Communication();
1239        copyValues(dst);
1240        if (identifier != null) {
1241          dst.identifier = new ArrayList<Identifier>();
1242          for (Identifier i : identifier)
1243            dst.identifier.add(i.copy());
1244        };
1245        dst.category = category == null ? null : category.copy();
1246        dst.sender = sender == null ? null : sender.copy();
1247        if (recipient != null) {
1248          dst.recipient = new ArrayList<Reference>();
1249          for (Reference i : recipient)
1250            dst.recipient.add(i.copy());
1251        };
1252        if (payload != null) {
1253          dst.payload = new ArrayList<CommunicationPayloadComponent>();
1254          for (CommunicationPayloadComponent i : payload)
1255            dst.payload.add(i.copy());
1256        };
1257        if (medium != null) {
1258          dst.medium = new ArrayList<CodeableConcept>();
1259          for (CodeableConcept i : medium)
1260            dst.medium.add(i.copy());
1261        };
1262        dst.status = status == null ? null : status.copy();
1263        dst.encounter = encounter == null ? null : encounter.copy();
1264        dst.sent = sent == null ? null : sent.copy();
1265        dst.received = received == null ? null : received.copy();
1266        if (reason != null) {
1267          dst.reason = new ArrayList<CodeableConcept>();
1268          for (CodeableConcept i : reason)
1269            dst.reason.add(i.copy());
1270        };
1271        dst.subject = subject == null ? null : subject.copy();
1272        dst.requestDetail = requestDetail == null ? null : requestDetail.copy();
1273        return dst;
1274      }
1275
1276      protected Communication typedCopy() {
1277        return copy();
1278      }
1279
1280      @Override
1281      public boolean equalsDeep(Base other) {
1282        if (!super.equalsDeep(other))
1283          return false;
1284        if (!(other instanceof Communication))
1285          return false;
1286        Communication o = (Communication) other;
1287        return compareDeep(identifier, o.identifier, true) && compareDeep(category, o.category, true) && compareDeep(sender, o.sender, true)
1288           && compareDeep(recipient, o.recipient, true) && compareDeep(payload, o.payload, true) && compareDeep(medium, o.medium, true)
1289           && compareDeep(status, o.status, true) && compareDeep(encounter, o.encounter, true) && compareDeep(sent, o.sent, true)
1290           && compareDeep(received, o.received, true) && compareDeep(reason, o.reason, true) && compareDeep(subject, o.subject, true)
1291           && compareDeep(requestDetail, o.requestDetail, true);
1292      }
1293
1294      @Override
1295      public boolean equalsShallow(Base other) {
1296        if (!super.equalsShallow(other))
1297          return false;
1298        if (!(other instanceof Communication))
1299          return false;
1300        Communication o = (Communication) other;
1301        return compareValues(status, o.status, true) && compareValues(sent, o.sent, true) && compareValues(received, o.received, true)
1302          ;
1303      }
1304
1305      public boolean isEmpty() {
1306        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (category == null || category.isEmpty())
1307           && (sender == null || sender.isEmpty()) && (recipient == null || recipient.isEmpty()) && (payload == null || payload.isEmpty())
1308           && (medium == null || medium.isEmpty()) && (status == null || status.isEmpty()) && (encounter == null || encounter.isEmpty())
1309           && (sent == null || sent.isEmpty()) && (received == null || received.isEmpty()) && (reason == null || reason.isEmpty())
1310           && (subject == null || subject.isEmpty()) && (requestDetail == null || requestDetail.isEmpty())
1311          ;
1312      }
1313
1314  @Override
1315  public ResourceType getResourceType() {
1316    return ResourceType.Communication;
1317   }
1318
1319 /**
1320   * Search parameter: <b>sender</b>
1321   * <p>
1322   * Description: <b>Message sender</b><br>
1323   * Type: <b>reference</b><br>
1324   * Path: <b>Communication.sender</b><br>
1325   * </p>
1326   */
1327  @SearchParamDefinition(name="sender", path="Communication.sender", description="Message sender", type="reference" )
1328  public static final String SP_SENDER = "sender";
1329 /**
1330   * <b>Fluent Client</b> search parameter constant for <b>sender</b>
1331   * <p>
1332   * Description: <b>Message sender</b><br>
1333   * Type: <b>reference</b><br>
1334   * Path: <b>Communication.sender</b><br>
1335   * </p>
1336   */
1337  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SENDER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SENDER);
1338
1339/**
1340   * Constant for fluent queries to be used to add include statements. Specifies
1341   * the path value of "<b>Communication:sender</b>".
1342   */
1343  public static final ca.uhn.fhir.model.api.Include INCLUDE_SENDER = new ca.uhn.fhir.model.api.Include("Communication:sender").toLocked();
1344
1345 /**
1346   * Search parameter: <b>sent</b>
1347   * <p>
1348   * Description: <b>When sent</b><br>
1349   * Type: <b>date</b><br>
1350   * Path: <b>Communication.sent</b><br>
1351   * </p>
1352   */
1353  @SearchParamDefinition(name="sent", path="Communication.sent", description="When sent", type="date" )
1354  public static final String SP_SENT = "sent";
1355 /**
1356   * <b>Fluent Client</b> search parameter constant for <b>sent</b>
1357   * <p>
1358   * Description: <b>When sent</b><br>
1359   * Type: <b>date</b><br>
1360   * Path: <b>Communication.sent</b><br>
1361   * </p>
1362   */
1363  public static final ca.uhn.fhir.rest.gclient.DateClientParam SENT = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_SENT);
1364
1365 /**
1366   * Search parameter: <b>category</b>
1367   * <p>
1368   * Description: <b>Message category</b><br>
1369   * Type: <b>token</b><br>
1370   * Path: <b>Communication.category</b><br>
1371   * </p>
1372   */
1373  @SearchParamDefinition(name="category", path="Communication.category", description="Message category", type="token" )
1374  public static final String SP_CATEGORY = "category";
1375 /**
1376   * <b>Fluent Client</b> search parameter constant for <b>category</b>
1377   * <p>
1378   * Description: <b>Message category</b><br>
1379   * Type: <b>token</b><br>
1380   * Path: <b>Communication.category</b><br>
1381   * </p>
1382   */
1383  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CATEGORY);
1384
1385 /**
1386   * Search parameter: <b>patient</b>
1387   * <p>
1388   * Description: <b>Focus of message</b><br>
1389   * Type: <b>reference</b><br>
1390   * Path: <b>Communication.subject</b><br>
1391   * </p>
1392   */
1393  @SearchParamDefinition(name="patient", path="Communication.subject", description="Focus of message", type="reference" )
1394  public static final String SP_PATIENT = "patient";
1395 /**
1396   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
1397   * <p>
1398   * Description: <b>Focus of message</b><br>
1399   * Type: <b>reference</b><br>
1400   * Path: <b>Communication.subject</b><br>
1401   * </p>
1402   */
1403  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
1404
1405/**
1406   * Constant for fluent queries to be used to add include statements. Specifies
1407   * the path value of "<b>Communication:patient</b>".
1408   */
1409  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("Communication:patient").toLocked();
1410
1411 /**
1412   * Search parameter: <b>status</b>
1413   * <p>
1414   * Description: <b>in-progress | completed | suspended | rejected | failed</b><br>
1415   * Type: <b>token</b><br>
1416   * Path: <b>Communication.status</b><br>
1417   * </p>
1418   */
1419  @SearchParamDefinition(name="status", path="Communication.status", description="in-progress | completed | suspended | rejected | failed", type="token" )
1420  public static final String SP_STATUS = "status";
1421 /**
1422   * <b>Fluent Client</b> search parameter constant for <b>status</b>
1423   * <p>
1424   * Description: <b>in-progress | completed | suspended | rejected | failed</b><br>
1425   * Type: <b>token</b><br>
1426   * Path: <b>Communication.status</b><br>
1427   * </p>
1428   */
1429  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
1430
1431 /**
1432   * Search parameter: <b>subject</b>
1433   * <p>
1434   * Description: <b>Focus of message</b><br>
1435   * Type: <b>reference</b><br>
1436   * Path: <b>Communication.subject</b><br>
1437   * </p>
1438   */
1439  @SearchParamDefinition(name="subject", path="Communication.subject", description="Focus of message", type="reference" )
1440  public static final String SP_SUBJECT = "subject";
1441 /**
1442   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
1443   * <p>
1444   * Description: <b>Focus of message</b><br>
1445   * Type: <b>reference</b><br>
1446   * Path: <b>Communication.subject</b><br>
1447   * </p>
1448   */
1449  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
1450
1451/**
1452   * Constant for fluent queries to be used to add include statements. Specifies
1453   * the path value of "<b>Communication:subject</b>".
1454   */
1455  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("Communication:subject").toLocked();
1456
1457 /**
1458   * Search parameter: <b>request</b>
1459   * <p>
1460   * Description: <b>CommunicationRequest producing this message</b><br>
1461   * Type: <b>reference</b><br>
1462   * Path: <b>Communication.requestDetail</b><br>
1463   * </p>
1464   */
1465  @SearchParamDefinition(name="request", path="Communication.requestDetail", description="CommunicationRequest producing this message", type="reference" )
1466  public static final String SP_REQUEST = "request";
1467 /**
1468   * <b>Fluent Client</b> search parameter constant for <b>request</b>
1469   * <p>
1470   * Description: <b>CommunicationRequest producing this message</b><br>
1471   * Type: <b>reference</b><br>
1472   * Path: <b>Communication.requestDetail</b><br>
1473   * </p>
1474   */
1475  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam REQUEST = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_REQUEST);
1476
1477/**
1478   * Constant for fluent queries to be used to add include statements. Specifies
1479   * the path value of "<b>Communication:request</b>".
1480   */
1481  public static final ca.uhn.fhir.model.api.Include INCLUDE_REQUEST = new ca.uhn.fhir.model.api.Include("Communication:request").toLocked();
1482
1483 /**
1484   * Search parameter: <b>received</b>
1485   * <p>
1486   * Description: <b>When received</b><br>
1487   * Type: <b>date</b><br>
1488   * Path: <b>Communication.received</b><br>
1489   * </p>
1490   */
1491  @SearchParamDefinition(name="received", path="Communication.received", description="When received", type="date" )
1492  public static final String SP_RECEIVED = "received";
1493 /**
1494   * <b>Fluent Client</b> search parameter constant for <b>received</b>
1495   * <p>
1496   * Description: <b>When received</b><br>
1497   * Type: <b>date</b><br>
1498   * Path: <b>Communication.received</b><br>
1499   * </p>
1500   */
1501  public static final ca.uhn.fhir.rest.gclient.DateClientParam RECEIVED = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_RECEIVED);
1502
1503 /**
1504   * Search parameter: <b>encounter</b>
1505   * <p>
1506   * Description: <b>Encounter leading to message</b><br>
1507   * Type: <b>reference</b><br>
1508   * Path: <b>Communication.encounter</b><br>
1509   * </p>
1510   */
1511  @SearchParamDefinition(name="encounter", path="Communication.encounter", description="Encounter leading to message", type="reference" )
1512  public static final String SP_ENCOUNTER = "encounter";
1513 /**
1514   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
1515   * <p>
1516   * Description: <b>Encounter leading to message</b><br>
1517   * Type: <b>reference</b><br>
1518   * Path: <b>Communication.encounter</b><br>
1519   * </p>
1520   */
1521  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
1522
1523/**
1524   * Constant for fluent queries to be used to add include statements. Specifies
1525   * the path value of "<b>Communication:encounter</b>".
1526   */
1527  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("Communication:encounter").toLocked();
1528
1529 /**
1530   * Search parameter: <b>identifier</b>
1531   * <p>
1532   * Description: <b>Unique identifier</b><br>
1533   * Type: <b>token</b><br>
1534   * Path: <b>Communication.identifier</b><br>
1535   * </p>
1536   */
1537  @SearchParamDefinition(name="identifier", path="Communication.identifier", description="Unique identifier", type="token" )
1538  public static final String SP_IDENTIFIER = "identifier";
1539 /**
1540   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1541   * <p>
1542   * Description: <b>Unique identifier</b><br>
1543   * Type: <b>token</b><br>
1544   * Path: <b>Communication.identifier</b><br>
1545   * </p>
1546   */
1547  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
1548
1549 /**
1550   * Search parameter: <b>medium</b>
1551   * <p>
1552   * Description: <b>A channel of communication</b><br>
1553   * Type: <b>token</b><br>
1554   * Path: <b>Communication.medium</b><br>
1555   * </p>
1556   */
1557  @SearchParamDefinition(name="medium", path="Communication.medium", description="A channel of communication", type="token" )
1558  public static final String SP_MEDIUM = "medium";
1559 /**
1560   * <b>Fluent Client</b> search parameter constant for <b>medium</b>
1561   * <p>
1562   * Description: <b>A channel of communication</b><br>
1563   * Type: <b>token</b><br>
1564   * Path: <b>Communication.medium</b><br>
1565   * </p>
1566   */
1567  public static final ca.uhn.fhir.rest.gclient.TokenClientParam MEDIUM = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_MEDIUM);
1568
1569 /**
1570   * Search parameter: <b>recipient</b>
1571   * <p>
1572   * Description: <b>Message recipient</b><br>
1573   * Type: <b>reference</b><br>
1574   * Path: <b>Communication.recipient</b><br>
1575   * </p>
1576   */
1577  @SearchParamDefinition(name="recipient", path="Communication.recipient", description="Message recipient", type="reference" )
1578  public static final String SP_RECIPIENT = "recipient";
1579 /**
1580   * <b>Fluent Client</b> search parameter constant for <b>recipient</b>
1581   * <p>
1582   * Description: <b>Message recipient</b><br>
1583   * Type: <b>reference</b><br>
1584   * Path: <b>Communication.recipient</b><br>
1585   * </p>
1586   */
1587  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam RECIPIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_RECIPIENT);
1588
1589/**
1590   * Constant for fluent queries to be used to add include statements. Specifies
1591   * the path value of "<b>Communication:recipient</b>".
1592   */
1593  public static final ca.uhn.fhir.model.api.Include INCLUDE_RECIPIENT = new ca.uhn.fhir.model.api.Include("Communication:recipient").toLocked();
1594
1595
1596}
1597