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