001package org.hl7.fhir.dstu2.model;
002
003
004
005
006/*
007  Copyright (c) 2011+, HL7, Inc.
008  All rights reserved.
009  
010  Redistribution and use in source and binary forms, with or without modification, 
011  are permitted provided that the following conditions are met:
012  
013   * Redistributions of source code must retain the above copyright notice, this 
014     list of conditions and the following disclaimer.
015   * Redistributions in binary form must reproduce the above copyright notice, 
016     this list of conditions and the following disclaimer in the documentation 
017     and/or other materials provided with the distribution.
018   * Neither the name of HL7 nor the names of its contributors may be used to 
019     endorse or promote products derived from this software without specific 
020     prior written permission.
021  
022  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
023  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
024  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
025  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
026  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
027  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
028  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
029  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
030  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
031  POSSIBILITY OF SUCH DAMAGE.
032  
033*/
034
035// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
036import java.util.ArrayList;
037import java.util.Date;
038import java.util.List;
039
040import ca.uhn.fhir.model.api.annotation.Block;
041import ca.uhn.fhir.model.api.annotation.Child;
042import ca.uhn.fhir.model.api.annotation.Description;
043import ca.uhn.fhir.model.api.annotation.ResourceDef;
044import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
045import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
046import org.hl7.fhir.exceptions.FHIRException;
047import org.hl7.fhir.utilities.Utilities;
048/**
049 * The header for a message exchange that is either requesting or responding to an action.  The reference(s) that are the subject of the action as well as other information related to the action are typically transmitted in a bundle in which the MessageHeader resource instance is the first resource in the bundle.
050 */
051@ResourceDef(name="MessageHeader", profile="http://hl7.org/fhir/Profile/MessageHeader")
052public class MessageHeader extends DomainResource {
053
054    public enum ResponseType {
055        /**
056         * The message was accepted and processed without error.
057         */
058        OK, 
059        /**
060         * Some internal unexpected error occurred - wait and try again. Note - this is usually used for things like database unavailable, which may be expected to resolve, though human intervention may be required.
061         */
062        TRANSIENTERROR, 
063        /**
064         * The message was rejected because of some content in it. There is no point in re-sending without change. The response narrative SHALL describe the issue.
065         */
066        FATALERROR, 
067        /**
068         * added to help the parsers
069         */
070        NULL;
071        public static ResponseType fromCode(String codeString) throws FHIRException {
072            if (codeString == null || "".equals(codeString))
073                return null;
074        if ("ok".equals(codeString))
075          return OK;
076        if ("transient-error".equals(codeString))
077          return TRANSIENTERROR;
078        if ("fatal-error".equals(codeString))
079          return FATALERROR;
080        throw new FHIRException("Unknown ResponseType code '"+codeString+"'");
081        }
082        public String toCode() {
083          switch (this) {
084            case OK: return "ok";
085            case TRANSIENTERROR: return "transient-error";
086            case FATALERROR: return "fatal-error";
087            case NULL: return null;
088            default: return "?";
089          }
090        }
091        public String getSystem() {
092          switch (this) {
093            case OK: return "http://hl7.org/fhir/response-code";
094            case TRANSIENTERROR: return "http://hl7.org/fhir/response-code";
095            case FATALERROR: return "http://hl7.org/fhir/response-code";
096            case NULL: return null;
097            default: return "?";
098          }
099        }
100        public String getDefinition() {
101          switch (this) {
102            case OK: return "The message was accepted and processed without error.";
103            case TRANSIENTERROR: return "Some internal unexpected error occurred - wait and try again. Note - this is usually used for things like database unavailable, which may be expected to resolve, though human intervention may be required.";
104            case FATALERROR: return "The message was rejected because of some content in it. There is no point in re-sending without change. The response narrative SHALL describe the issue.";
105            case NULL: return null;
106            default: return "?";
107          }
108        }
109        public String getDisplay() {
110          switch (this) {
111            case OK: return "OK";
112            case TRANSIENTERROR: return "Transient Error";
113            case FATALERROR: return "Fatal Error";
114            case NULL: return null;
115            default: return "?";
116          }
117        }
118    }
119
120  public static class ResponseTypeEnumFactory implements EnumFactory<ResponseType> {
121    public ResponseType fromCode(String codeString) throws IllegalArgumentException {
122      if (codeString == null || "".equals(codeString))
123            if (codeString == null || "".equals(codeString))
124                return null;
125        if ("ok".equals(codeString))
126          return ResponseType.OK;
127        if ("transient-error".equals(codeString))
128          return ResponseType.TRANSIENTERROR;
129        if ("fatal-error".equals(codeString))
130          return ResponseType.FATALERROR;
131        throw new IllegalArgumentException("Unknown ResponseType code '"+codeString+"'");
132        }
133        public Enumeration<ResponseType> fromType(Base code) throws FHIRException {
134          if (code == null || code.isEmpty())
135            return null;
136          String codeString = ((PrimitiveType) code).asStringValue();
137          if (codeString == null || "".equals(codeString))
138            return null;
139        if ("ok".equals(codeString))
140          return new Enumeration<ResponseType>(this, ResponseType.OK);
141        if ("transient-error".equals(codeString))
142          return new Enumeration<ResponseType>(this, ResponseType.TRANSIENTERROR);
143        if ("fatal-error".equals(codeString))
144          return new Enumeration<ResponseType>(this, ResponseType.FATALERROR);
145        throw new FHIRException("Unknown ResponseType code '"+codeString+"'");
146        }
147    public String toCode(ResponseType code) {
148      if (code == ResponseType.OK)
149        return "ok";
150      if (code == ResponseType.TRANSIENTERROR)
151        return "transient-error";
152      if (code == ResponseType.FATALERROR)
153        return "fatal-error";
154      return "?";
155      }
156    }
157
158    @Block()
159    public static class MessageHeaderResponseComponent extends BackboneElement implements IBaseBackboneElement {
160        /**
161         * The id of the message that this message is a response to.
162         */
163        @Child(name = "identifier", type = {IdType.class}, order=1, min=1, max=1, modifier=false, summary=true)
164        @Description(shortDefinition="Id of original message", formalDefinition="The id of the message that this message is a response to." )
165        protected IdType identifier;
166
167        /**
168         * Code that identifies the type of response to the message - whether it was successful or not, and whether it should be resent or not.
169         */
170        @Child(name = "code", type = {CodeType.class}, order=2, min=1, max=1, modifier=true, summary=true)
171        @Description(shortDefinition="ok | transient-error | fatal-error", formalDefinition="Code that identifies the type of response to the message - whether it was successful or not, and whether it should be resent or not." )
172        protected Enumeration<ResponseType> code;
173
174        /**
175         * Full details of any issues found in the message.
176         */
177        @Child(name = "details", type = {OperationOutcome.class}, order=3, min=0, max=1, modifier=false, summary=true)
178        @Description(shortDefinition="Specific list of hints/warnings/errors", formalDefinition="Full details of any issues found in the message." )
179        protected Reference details;
180
181        /**
182         * The actual object that is the target of the reference (Full details of any issues found in the message.)
183         */
184        protected OperationOutcome detailsTarget;
185
186        private static final long serialVersionUID = -1008716838L;
187
188    /*
189     * Constructor
190     */
191      public MessageHeaderResponseComponent() {
192        super();
193      }
194
195    /*
196     * Constructor
197     */
198      public MessageHeaderResponseComponent(IdType identifier, Enumeration<ResponseType> code) {
199        super();
200        this.identifier = identifier;
201        this.code = code;
202      }
203
204        /**
205         * @return {@link #identifier} (The id of the message that this message is a response to.). This is the underlying object with id, value and extensions. The accessor "getIdentifier" gives direct access to the value
206         */
207        public IdType getIdentifierElement() { 
208          if (this.identifier == null)
209            if (Configuration.errorOnAutoCreate())
210              throw new Error("Attempt to auto-create MessageHeaderResponseComponent.identifier");
211            else if (Configuration.doAutoCreate())
212              this.identifier = new IdType(); // bb
213          return this.identifier;
214        }
215
216        public boolean hasIdentifierElement() { 
217          return this.identifier != null && !this.identifier.isEmpty();
218        }
219
220        public boolean hasIdentifier() { 
221          return this.identifier != null && !this.identifier.isEmpty();
222        }
223
224        /**
225         * @param value {@link #identifier} (The id of the message that this message is a response to.). This is the underlying object with id, value and extensions. The accessor "getIdentifier" gives direct access to the value
226         */
227        public MessageHeaderResponseComponent setIdentifierElement(IdType value) { 
228          this.identifier = value;
229          return this;
230        }
231
232        /**
233         * @return The id of the message that this message is a response to.
234         */
235        public String getIdentifier() { 
236          return this.identifier == null ? null : this.identifier.getValue();
237        }
238
239        /**
240         * @param value The id of the message that this message is a response to.
241         */
242        public MessageHeaderResponseComponent setIdentifier(String value) { 
243            if (this.identifier == null)
244              this.identifier = new IdType();
245            this.identifier.setValue(value);
246          return this;
247        }
248
249        /**
250         * @return {@link #code} (Code that identifies the type of response to the message - whether it was successful or not, and whether it should be resent or not.). This is the underlying object with id, value and extensions. The accessor "getCode" gives direct access to the value
251         */
252        public Enumeration<ResponseType> getCodeElement() { 
253          if (this.code == null)
254            if (Configuration.errorOnAutoCreate())
255              throw new Error("Attempt to auto-create MessageHeaderResponseComponent.code");
256            else if (Configuration.doAutoCreate())
257              this.code = new Enumeration<ResponseType>(new ResponseTypeEnumFactory()); // bb
258          return this.code;
259        }
260
261        public boolean hasCodeElement() { 
262          return this.code != null && !this.code.isEmpty();
263        }
264
265        public boolean hasCode() { 
266          return this.code != null && !this.code.isEmpty();
267        }
268
269        /**
270         * @param value {@link #code} (Code that identifies the type of response to the message - whether it was successful or not, and whether it should be resent or not.). This is the underlying object with id, value and extensions. The accessor "getCode" gives direct access to the value
271         */
272        public MessageHeaderResponseComponent setCodeElement(Enumeration<ResponseType> value) { 
273          this.code = value;
274          return this;
275        }
276
277        /**
278         * @return Code that identifies the type of response to the message - whether it was successful or not, and whether it should be resent or not.
279         */
280        public ResponseType getCode() { 
281          return this.code == null ? null : this.code.getValue();
282        }
283
284        /**
285         * @param value Code that identifies the type of response to the message - whether it was successful or not, and whether it should be resent or not.
286         */
287        public MessageHeaderResponseComponent setCode(ResponseType value) { 
288            if (this.code == null)
289              this.code = new Enumeration<ResponseType>(new ResponseTypeEnumFactory());
290            this.code.setValue(value);
291          return this;
292        }
293
294        /**
295         * @return {@link #details} (Full details of any issues found in the message.)
296         */
297        public Reference getDetails() { 
298          if (this.details == null)
299            if (Configuration.errorOnAutoCreate())
300              throw new Error("Attempt to auto-create MessageHeaderResponseComponent.details");
301            else if (Configuration.doAutoCreate())
302              this.details = new Reference(); // cc
303          return this.details;
304        }
305
306        public boolean hasDetails() { 
307          return this.details != null && !this.details.isEmpty();
308        }
309
310        /**
311         * @param value {@link #details} (Full details of any issues found in the message.)
312         */
313        public MessageHeaderResponseComponent setDetails(Reference value) { 
314          this.details = value;
315          return this;
316        }
317
318        /**
319         * @return {@link #details} 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. (Full details of any issues found in the message.)
320         */
321        public OperationOutcome getDetailsTarget() { 
322          if (this.detailsTarget == null)
323            if (Configuration.errorOnAutoCreate())
324              throw new Error("Attempt to auto-create MessageHeaderResponseComponent.details");
325            else if (Configuration.doAutoCreate())
326              this.detailsTarget = new OperationOutcome(); // aa
327          return this.detailsTarget;
328        }
329
330        /**
331         * @param value {@link #details} 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. (Full details of any issues found in the message.)
332         */
333        public MessageHeaderResponseComponent setDetailsTarget(OperationOutcome value) { 
334          this.detailsTarget = value;
335          return this;
336        }
337
338        protected void listChildren(List<Property> childrenList) {
339          super.listChildren(childrenList);
340          childrenList.add(new Property("identifier", "id", "The id of the message that this message is a response to.", 0, java.lang.Integer.MAX_VALUE, identifier));
341          childrenList.add(new Property("code", "code", "Code that identifies the type of response to the message - whether it was successful or not, and whether it should be resent or not.", 0, java.lang.Integer.MAX_VALUE, code));
342          childrenList.add(new Property("details", "Reference(OperationOutcome)", "Full details of any issues found in the message.", 0, java.lang.Integer.MAX_VALUE, details));
343        }
344
345      @Override
346      public void setProperty(String name, Base value) throws FHIRException {
347        if (name.equals("identifier"))
348          this.identifier = castToId(value); // IdType
349        else if (name.equals("code"))
350          this.code = new ResponseTypeEnumFactory().fromType(value); // Enumeration<ResponseType>
351        else if (name.equals("details"))
352          this.details = castToReference(value); // Reference
353        else
354          super.setProperty(name, value);
355      }
356
357      @Override
358      public Base addChild(String name) throws FHIRException {
359        if (name.equals("identifier")) {
360          throw new FHIRException("Cannot call addChild on a primitive type MessageHeader.identifier");
361        }
362        else if (name.equals("code")) {
363          throw new FHIRException("Cannot call addChild on a primitive type MessageHeader.code");
364        }
365        else if (name.equals("details")) {
366          this.details = new Reference();
367          return this.details;
368        }
369        else
370          return super.addChild(name);
371      }
372
373      public MessageHeaderResponseComponent copy() {
374        MessageHeaderResponseComponent dst = new MessageHeaderResponseComponent();
375        copyValues(dst);
376        dst.identifier = identifier == null ? null : identifier.copy();
377        dst.code = code == null ? null : code.copy();
378        dst.details = details == null ? null : details.copy();
379        return dst;
380      }
381
382      @Override
383      public boolean equalsDeep(Base other) {
384        if (!super.equalsDeep(other))
385          return false;
386        if (!(other instanceof MessageHeaderResponseComponent))
387          return false;
388        MessageHeaderResponseComponent o = (MessageHeaderResponseComponent) other;
389        return compareDeep(identifier, o.identifier, true) && compareDeep(code, o.code, true) && compareDeep(details, o.details, true)
390          ;
391      }
392
393      @Override
394      public boolean equalsShallow(Base other) {
395        if (!super.equalsShallow(other))
396          return false;
397        if (!(other instanceof MessageHeaderResponseComponent))
398          return false;
399        MessageHeaderResponseComponent o = (MessageHeaderResponseComponent) other;
400        return compareValues(identifier, o.identifier, true) && compareValues(code, o.code, true);
401      }
402
403      public boolean isEmpty() {
404        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (code == null || code.isEmpty())
405           && (details == null || details.isEmpty());
406      }
407
408  public String fhirType() {
409    return "MessageHeader.response";
410
411  }
412
413  }
414
415    @Block()
416    public static class MessageSourceComponent extends BackboneElement implements IBaseBackboneElement {
417        /**
418         * Human-readable name for the source system.
419         */
420        @Child(name = "name", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
421        @Description(shortDefinition="Name of system", formalDefinition="Human-readable name for the source system." )
422        protected StringType name;
423
424        /**
425         * May include configuration or other information useful in debugging.
426         */
427        @Child(name = "software", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true)
428        @Description(shortDefinition="Name of software running the system", formalDefinition="May include configuration or other information useful in debugging." )
429        protected StringType software;
430
431        /**
432         * Can convey versions of multiple systems in situations where a message passes through multiple hands.
433         */
434        @Child(name = "version", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
435        @Description(shortDefinition="Version of software running", formalDefinition="Can convey versions of multiple systems in situations where a message passes through multiple hands." )
436        protected StringType version;
437
438        /**
439         * An e-mail, phone, website or other contact point to use to resolve issues with message communications.
440         */
441        @Child(name = "contact", type = {ContactPoint.class}, order=4, min=0, max=1, modifier=false, summary=true)
442        @Description(shortDefinition="Human contact for problems", formalDefinition="An e-mail, phone, website or other contact point to use to resolve issues with message communications." )
443        protected ContactPoint contact;
444
445        /**
446         * Identifies the routing target to send acknowledgements to.
447         */
448        @Child(name = "endpoint", type = {UriType.class}, order=5, min=1, max=1, modifier=false, summary=true)
449        @Description(shortDefinition="Actual message source address or id", formalDefinition="Identifies the routing target to send acknowledgements to." )
450        protected UriType endpoint;
451
452        private static final long serialVersionUID = -115878196L;
453
454    /*
455     * Constructor
456     */
457      public MessageSourceComponent() {
458        super();
459      }
460
461    /*
462     * Constructor
463     */
464      public MessageSourceComponent(UriType endpoint) {
465        super();
466        this.endpoint = endpoint;
467      }
468
469        /**
470         * @return {@link #name} (Human-readable name for the source system.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
471         */
472        public StringType getNameElement() { 
473          if (this.name == null)
474            if (Configuration.errorOnAutoCreate())
475              throw new Error("Attempt to auto-create MessageSourceComponent.name");
476            else if (Configuration.doAutoCreate())
477              this.name = new StringType(); // bb
478          return this.name;
479        }
480
481        public boolean hasNameElement() { 
482          return this.name != null && !this.name.isEmpty();
483        }
484
485        public boolean hasName() { 
486          return this.name != null && !this.name.isEmpty();
487        }
488
489        /**
490         * @param value {@link #name} (Human-readable name for the source system.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
491         */
492        public MessageSourceComponent setNameElement(StringType value) { 
493          this.name = value;
494          return this;
495        }
496
497        /**
498         * @return Human-readable name for the source system.
499         */
500        public String getName() { 
501          return this.name == null ? null : this.name.getValue();
502        }
503
504        /**
505         * @param value Human-readable name for the source system.
506         */
507        public MessageSourceComponent setName(String value) { 
508          if (Utilities.noString(value))
509            this.name = null;
510          else {
511            if (this.name == null)
512              this.name = new StringType();
513            this.name.setValue(value);
514          }
515          return this;
516        }
517
518        /**
519         * @return {@link #software} (May include configuration or other information useful in debugging.). This is the underlying object with id, value and extensions. The accessor "getSoftware" gives direct access to the value
520         */
521        public StringType getSoftwareElement() { 
522          if (this.software == null)
523            if (Configuration.errorOnAutoCreate())
524              throw new Error("Attempt to auto-create MessageSourceComponent.software");
525            else if (Configuration.doAutoCreate())
526              this.software = new StringType(); // bb
527          return this.software;
528        }
529
530        public boolean hasSoftwareElement() { 
531          return this.software != null && !this.software.isEmpty();
532        }
533
534        public boolean hasSoftware() { 
535          return this.software != null && !this.software.isEmpty();
536        }
537
538        /**
539         * @param value {@link #software} (May include configuration or other information useful in debugging.). This is the underlying object with id, value and extensions. The accessor "getSoftware" gives direct access to the value
540         */
541        public MessageSourceComponent setSoftwareElement(StringType value) { 
542          this.software = value;
543          return this;
544        }
545
546        /**
547         * @return May include configuration or other information useful in debugging.
548         */
549        public String getSoftware() { 
550          return this.software == null ? null : this.software.getValue();
551        }
552
553        /**
554         * @param value May include configuration or other information useful in debugging.
555         */
556        public MessageSourceComponent setSoftware(String value) { 
557          if (Utilities.noString(value))
558            this.software = null;
559          else {
560            if (this.software == null)
561              this.software = new StringType();
562            this.software.setValue(value);
563          }
564          return this;
565        }
566
567        /**
568         * @return {@link #version} (Can convey versions of multiple systems in situations where a message passes through multiple hands.). This is the underlying object with id, value and extensions. The accessor "getVersion" gives direct access to the value
569         */
570        public StringType getVersionElement() { 
571          if (this.version == null)
572            if (Configuration.errorOnAutoCreate())
573              throw new Error("Attempt to auto-create MessageSourceComponent.version");
574            else if (Configuration.doAutoCreate())
575              this.version = new StringType(); // bb
576          return this.version;
577        }
578
579        public boolean hasVersionElement() { 
580          return this.version != null && !this.version.isEmpty();
581        }
582
583        public boolean hasVersion() { 
584          return this.version != null && !this.version.isEmpty();
585        }
586
587        /**
588         * @param value {@link #version} (Can convey versions of multiple systems in situations where a message passes through multiple hands.). This is the underlying object with id, value and extensions. The accessor "getVersion" gives direct access to the value
589         */
590        public MessageSourceComponent setVersionElement(StringType value) { 
591          this.version = value;
592          return this;
593        }
594
595        /**
596         * @return Can convey versions of multiple systems in situations where a message passes through multiple hands.
597         */
598        public String getVersion() { 
599          return this.version == null ? null : this.version.getValue();
600        }
601
602        /**
603         * @param value Can convey versions of multiple systems in situations where a message passes through multiple hands.
604         */
605        public MessageSourceComponent setVersion(String value) { 
606          if (Utilities.noString(value))
607            this.version = null;
608          else {
609            if (this.version == null)
610              this.version = new StringType();
611            this.version.setValue(value);
612          }
613          return this;
614        }
615
616        /**
617         * @return {@link #contact} (An e-mail, phone, website or other contact point to use to resolve issues with message communications.)
618         */
619        public ContactPoint getContact() { 
620          if (this.contact == null)
621            if (Configuration.errorOnAutoCreate())
622              throw new Error("Attempt to auto-create MessageSourceComponent.contact");
623            else if (Configuration.doAutoCreate())
624              this.contact = new ContactPoint(); // cc
625          return this.contact;
626        }
627
628        public boolean hasContact() { 
629          return this.contact != null && !this.contact.isEmpty();
630        }
631
632        /**
633         * @param value {@link #contact} (An e-mail, phone, website or other contact point to use to resolve issues with message communications.)
634         */
635        public MessageSourceComponent setContact(ContactPoint value) { 
636          this.contact = value;
637          return this;
638        }
639
640        /**
641         * @return {@link #endpoint} (Identifies the routing target to send acknowledgements to.). This is the underlying object with id, value and extensions. The accessor "getEndpoint" gives direct access to the value
642         */
643        public UriType getEndpointElement() { 
644          if (this.endpoint == null)
645            if (Configuration.errorOnAutoCreate())
646              throw new Error("Attempt to auto-create MessageSourceComponent.endpoint");
647            else if (Configuration.doAutoCreate())
648              this.endpoint = new UriType(); // bb
649          return this.endpoint;
650        }
651
652        public boolean hasEndpointElement() { 
653          return this.endpoint != null && !this.endpoint.isEmpty();
654        }
655
656        public boolean hasEndpoint() { 
657          return this.endpoint != null && !this.endpoint.isEmpty();
658        }
659
660        /**
661         * @param value {@link #endpoint} (Identifies the routing target to send acknowledgements to.). This is the underlying object with id, value and extensions. The accessor "getEndpoint" gives direct access to the value
662         */
663        public MessageSourceComponent setEndpointElement(UriType value) { 
664          this.endpoint = value;
665          return this;
666        }
667
668        /**
669         * @return Identifies the routing target to send acknowledgements to.
670         */
671        public String getEndpoint() { 
672          return this.endpoint == null ? null : this.endpoint.getValue();
673        }
674
675        /**
676         * @param value Identifies the routing target to send acknowledgements to.
677         */
678        public MessageSourceComponent setEndpoint(String value) { 
679            if (this.endpoint == null)
680              this.endpoint = new UriType();
681            this.endpoint.setValue(value);
682          return this;
683        }
684
685        protected void listChildren(List<Property> childrenList) {
686          super.listChildren(childrenList);
687          childrenList.add(new Property("name", "string", "Human-readable name for the source system.", 0, java.lang.Integer.MAX_VALUE, name));
688          childrenList.add(new Property("software", "string", "May include configuration or other information useful in debugging.", 0, java.lang.Integer.MAX_VALUE, software));
689          childrenList.add(new Property("version", "string", "Can convey versions of multiple systems in situations where a message passes through multiple hands.", 0, java.lang.Integer.MAX_VALUE, version));
690          childrenList.add(new Property("contact", "ContactPoint", "An e-mail, phone, website or other contact point to use to resolve issues with message communications.", 0, java.lang.Integer.MAX_VALUE, contact));
691          childrenList.add(new Property("endpoint", "uri", "Identifies the routing target to send acknowledgements to.", 0, java.lang.Integer.MAX_VALUE, endpoint));
692        }
693
694      @Override
695      public void setProperty(String name, Base value) throws FHIRException {
696        if (name.equals("name"))
697          this.name = castToString(value); // StringType
698        else if (name.equals("software"))
699          this.software = castToString(value); // StringType
700        else if (name.equals("version"))
701          this.version = castToString(value); // StringType
702        else if (name.equals("contact"))
703          this.contact = castToContactPoint(value); // ContactPoint
704        else if (name.equals("endpoint"))
705          this.endpoint = castToUri(value); // UriType
706        else
707          super.setProperty(name, value);
708      }
709
710      @Override
711      public Base addChild(String name) throws FHIRException {
712        if (name.equals("name")) {
713          throw new FHIRException("Cannot call addChild on a primitive type MessageHeader.name");
714        }
715        else if (name.equals("software")) {
716          throw new FHIRException("Cannot call addChild on a primitive type MessageHeader.software");
717        }
718        else if (name.equals("version")) {
719          throw new FHIRException("Cannot call addChild on a primitive type MessageHeader.version");
720        }
721        else if (name.equals("contact")) {
722          this.contact = new ContactPoint();
723          return this.contact;
724        }
725        else if (name.equals("endpoint")) {
726          throw new FHIRException("Cannot call addChild on a primitive type MessageHeader.endpoint");
727        }
728        else
729          return super.addChild(name);
730      }
731
732      public MessageSourceComponent copy() {
733        MessageSourceComponent dst = new MessageSourceComponent();
734        copyValues(dst);
735        dst.name = name == null ? null : name.copy();
736        dst.software = software == null ? null : software.copy();
737        dst.version = version == null ? null : version.copy();
738        dst.contact = contact == null ? null : contact.copy();
739        dst.endpoint = endpoint == null ? null : endpoint.copy();
740        return dst;
741      }
742
743      @Override
744      public boolean equalsDeep(Base other) {
745        if (!super.equalsDeep(other))
746          return false;
747        if (!(other instanceof MessageSourceComponent))
748          return false;
749        MessageSourceComponent o = (MessageSourceComponent) other;
750        return compareDeep(name, o.name, true) && compareDeep(software, o.software, true) && compareDeep(version, o.version, true)
751           && compareDeep(contact, o.contact, true) && compareDeep(endpoint, o.endpoint, true);
752      }
753
754      @Override
755      public boolean equalsShallow(Base other) {
756        if (!super.equalsShallow(other))
757          return false;
758        if (!(other instanceof MessageSourceComponent))
759          return false;
760        MessageSourceComponent o = (MessageSourceComponent) other;
761        return compareValues(name, o.name, true) && compareValues(software, o.software, true) && compareValues(version, o.version, true)
762           && compareValues(endpoint, o.endpoint, true);
763      }
764
765      public boolean isEmpty() {
766        return super.isEmpty() && (name == null || name.isEmpty()) && (software == null || software.isEmpty())
767           && (version == null || version.isEmpty()) && (contact == null || contact.isEmpty()) && (endpoint == null || endpoint.isEmpty())
768          ;
769      }
770
771  public String fhirType() {
772    return "MessageHeader.source";
773
774  }
775
776  }
777
778    @Block()
779    public static class MessageDestinationComponent extends BackboneElement implements IBaseBackboneElement {
780        /**
781         * Human-readable name for the target system.
782         */
783        @Child(name = "name", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
784        @Description(shortDefinition="Name of system", formalDefinition="Human-readable name for the target system." )
785        protected StringType name;
786
787        /**
788         * Identifies the target end system in situations where the initial message transmission is to an intermediary system.
789         */
790        @Child(name = "target", type = {Device.class}, order=2, min=0, max=1, modifier=false, summary=true)
791        @Description(shortDefinition="Particular delivery destination within the destination", formalDefinition="Identifies the target end system in situations where the initial message transmission is to an intermediary system." )
792        protected Reference target;
793
794        /**
795         * The actual object that is the target of the reference (Identifies the target end system in situations where the initial message transmission is to an intermediary system.)
796         */
797        protected Device targetTarget;
798
799        /**
800         * Indicates where the message should be routed to.
801         */
802        @Child(name = "endpoint", type = {UriType.class}, order=3, min=1, max=1, modifier=false, summary=true)
803        @Description(shortDefinition="Actual destination address or id", formalDefinition="Indicates where the message should be routed to." )
804        protected UriType endpoint;
805
806        private static final long serialVersionUID = -2097633309L;
807
808    /*
809     * Constructor
810     */
811      public MessageDestinationComponent() {
812        super();
813      }
814
815    /*
816     * Constructor
817     */
818      public MessageDestinationComponent(UriType endpoint) {
819        super();
820        this.endpoint = endpoint;
821      }
822
823        /**
824         * @return {@link #name} (Human-readable name for the target system.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
825         */
826        public StringType getNameElement() { 
827          if (this.name == null)
828            if (Configuration.errorOnAutoCreate())
829              throw new Error("Attempt to auto-create MessageDestinationComponent.name");
830            else if (Configuration.doAutoCreate())
831              this.name = new StringType(); // bb
832          return this.name;
833        }
834
835        public boolean hasNameElement() { 
836          return this.name != null && !this.name.isEmpty();
837        }
838
839        public boolean hasName() { 
840          return this.name != null && !this.name.isEmpty();
841        }
842
843        /**
844         * @param value {@link #name} (Human-readable name for the target system.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
845         */
846        public MessageDestinationComponent setNameElement(StringType value) { 
847          this.name = value;
848          return this;
849        }
850
851        /**
852         * @return Human-readable name for the target system.
853         */
854        public String getName() { 
855          return this.name == null ? null : this.name.getValue();
856        }
857
858        /**
859         * @param value Human-readable name for the target system.
860         */
861        public MessageDestinationComponent setName(String value) { 
862          if (Utilities.noString(value))
863            this.name = null;
864          else {
865            if (this.name == null)
866              this.name = new StringType();
867            this.name.setValue(value);
868          }
869          return this;
870        }
871
872        /**
873         * @return {@link #target} (Identifies the target end system in situations where the initial message transmission is to an intermediary system.)
874         */
875        public Reference getTarget() { 
876          if (this.target == null)
877            if (Configuration.errorOnAutoCreate())
878              throw new Error("Attempt to auto-create MessageDestinationComponent.target");
879            else if (Configuration.doAutoCreate())
880              this.target = new Reference(); // cc
881          return this.target;
882        }
883
884        public boolean hasTarget() { 
885          return this.target != null && !this.target.isEmpty();
886        }
887
888        /**
889         * @param value {@link #target} (Identifies the target end system in situations where the initial message transmission is to an intermediary system.)
890         */
891        public MessageDestinationComponent setTarget(Reference value) { 
892          this.target = value;
893          return this;
894        }
895
896        /**
897         * @return {@link #target} 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. (Identifies the target end system in situations where the initial message transmission is to an intermediary system.)
898         */
899        public Device getTargetTarget() { 
900          if (this.targetTarget == null)
901            if (Configuration.errorOnAutoCreate())
902              throw new Error("Attempt to auto-create MessageDestinationComponent.target");
903            else if (Configuration.doAutoCreate())
904              this.targetTarget = new Device(); // aa
905          return this.targetTarget;
906        }
907
908        /**
909         * @param value {@link #target} 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. (Identifies the target end system in situations where the initial message transmission is to an intermediary system.)
910         */
911        public MessageDestinationComponent setTargetTarget(Device value) { 
912          this.targetTarget = value;
913          return this;
914        }
915
916        /**
917         * @return {@link #endpoint} (Indicates where the message should be routed to.). This is the underlying object with id, value and extensions. The accessor "getEndpoint" gives direct access to the value
918         */
919        public UriType getEndpointElement() { 
920          if (this.endpoint == null)
921            if (Configuration.errorOnAutoCreate())
922              throw new Error("Attempt to auto-create MessageDestinationComponent.endpoint");
923            else if (Configuration.doAutoCreate())
924              this.endpoint = new UriType(); // bb
925          return this.endpoint;
926        }
927
928        public boolean hasEndpointElement() { 
929          return this.endpoint != null && !this.endpoint.isEmpty();
930        }
931
932        public boolean hasEndpoint() { 
933          return this.endpoint != null && !this.endpoint.isEmpty();
934        }
935
936        /**
937         * @param value {@link #endpoint} (Indicates where the message should be routed to.). This is the underlying object with id, value and extensions. The accessor "getEndpoint" gives direct access to the value
938         */
939        public MessageDestinationComponent setEndpointElement(UriType value) { 
940          this.endpoint = value;
941          return this;
942        }
943
944        /**
945         * @return Indicates where the message should be routed to.
946         */
947        public String getEndpoint() { 
948          return this.endpoint == null ? null : this.endpoint.getValue();
949        }
950
951        /**
952         * @param value Indicates where the message should be routed to.
953         */
954        public MessageDestinationComponent setEndpoint(String value) { 
955            if (this.endpoint == null)
956              this.endpoint = new UriType();
957            this.endpoint.setValue(value);
958          return this;
959        }
960
961        protected void listChildren(List<Property> childrenList) {
962          super.listChildren(childrenList);
963          childrenList.add(new Property("name", "string", "Human-readable name for the target system.", 0, java.lang.Integer.MAX_VALUE, name));
964          childrenList.add(new Property("target", "Reference(Device)", "Identifies the target end system in situations where the initial message transmission is to an intermediary system.", 0, java.lang.Integer.MAX_VALUE, target));
965          childrenList.add(new Property("endpoint", "uri", "Indicates where the message should be routed to.", 0, java.lang.Integer.MAX_VALUE, endpoint));
966        }
967
968      @Override
969      public void setProperty(String name, Base value) throws FHIRException {
970        if (name.equals("name"))
971          this.name = castToString(value); // StringType
972        else if (name.equals("target"))
973          this.target = castToReference(value); // Reference
974        else if (name.equals("endpoint"))
975          this.endpoint = castToUri(value); // UriType
976        else
977          super.setProperty(name, value);
978      }
979
980      @Override
981      public Base addChild(String name) throws FHIRException {
982        if (name.equals("name")) {
983          throw new FHIRException("Cannot call addChild on a primitive type MessageHeader.name");
984        }
985        else if (name.equals("target")) {
986          this.target = new Reference();
987          return this.target;
988        }
989        else if (name.equals("endpoint")) {
990          throw new FHIRException("Cannot call addChild on a primitive type MessageHeader.endpoint");
991        }
992        else
993          return super.addChild(name);
994      }
995
996      public MessageDestinationComponent copy() {
997        MessageDestinationComponent dst = new MessageDestinationComponent();
998        copyValues(dst);
999        dst.name = name == null ? null : name.copy();
1000        dst.target = target == null ? null : target.copy();
1001        dst.endpoint = endpoint == null ? null : endpoint.copy();
1002        return dst;
1003      }
1004
1005      @Override
1006      public boolean equalsDeep(Base other) {
1007        if (!super.equalsDeep(other))
1008          return false;
1009        if (!(other instanceof MessageDestinationComponent))
1010          return false;
1011        MessageDestinationComponent o = (MessageDestinationComponent) other;
1012        return compareDeep(name, o.name, true) && compareDeep(target, o.target, true) && compareDeep(endpoint, o.endpoint, true)
1013          ;
1014      }
1015
1016      @Override
1017      public boolean equalsShallow(Base other) {
1018        if (!super.equalsShallow(other))
1019          return false;
1020        if (!(other instanceof MessageDestinationComponent))
1021          return false;
1022        MessageDestinationComponent o = (MessageDestinationComponent) other;
1023        return compareValues(name, o.name, true) && compareValues(endpoint, o.endpoint, true);
1024      }
1025
1026      public boolean isEmpty() {
1027        return super.isEmpty() && (name == null || name.isEmpty()) && (target == null || target.isEmpty())
1028           && (endpoint == null || endpoint.isEmpty());
1029      }
1030
1031  public String fhirType() {
1032    return "MessageHeader.destination";
1033
1034  }
1035
1036  }
1037
1038    /**
1039     * The time that the message was sent.
1040     */
1041    @Child(name = "timestamp", type = {InstantType.class}, order=0, min=1, max=1, modifier=false, summary=true)
1042    @Description(shortDefinition="Time that the message was sent", formalDefinition="The time that the message was sent." )
1043    protected InstantType timestamp;
1044
1045    /**
1046     * Code that identifies the event this message represents and connects it with its definition. Events defined as part of the FHIR specification have the system value "http://hl7.org/fhir/message-events".
1047     */
1048    @Child(name = "event", type = {Coding.class}, order=1, min=1, max=1, modifier=true, summary=true)
1049    @Description(shortDefinition="Code for the event this message represents", formalDefinition="Code that identifies the event this message represents and connects it with its definition. Events defined as part of the FHIR specification have the system value \"http://hl7.org/fhir/message-events\"." )
1050    protected Coding event;
1051
1052    /**
1053     * Information about the message that this message is a response to.  Only present if this message is a response.
1054     */
1055    @Child(name = "response", type = {}, order=2, min=0, max=1, modifier=true, summary=true)
1056    @Description(shortDefinition="If this is a reply to prior message", formalDefinition="Information about the message that this message is a response to.  Only present if this message is a response." )
1057    protected MessageHeaderResponseComponent response;
1058
1059    /**
1060     * The source application from which this message originated.
1061     */
1062    @Child(name = "source", type = {}, order=3, min=1, max=1, modifier=false, summary=true)
1063    @Description(shortDefinition="Message Source Application", formalDefinition="The source application from which this message originated." )
1064    protected MessageSourceComponent source;
1065
1066    /**
1067     * The destination application which the message is intended for.
1068     */
1069    @Child(name = "destination", type = {}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1070    @Description(shortDefinition="Message Destination Application(s)", formalDefinition="The destination application which the message is intended for." )
1071    protected List<MessageDestinationComponent> destination;
1072
1073    /**
1074     * The person or device that performed the data entry leading to this message. Where there is more than one candidate, pick the most proximal to the message. Can provide other enterers in extensions.
1075     */
1076    @Child(name = "enterer", type = {Practitioner.class}, order=5, min=0, max=1, modifier=false, summary=true)
1077    @Description(shortDefinition="The source of the data entry", formalDefinition="The person or device that performed the data entry leading to this message. Where there is more than one candidate, pick the most proximal to the message. Can provide other enterers in extensions." )
1078    protected Reference enterer;
1079
1080    /**
1081     * The actual object that is the target of the reference (The person or device that performed the data entry leading to this message. Where there is more than one candidate, pick the most proximal to the message. Can provide other enterers in extensions.)
1082     */
1083    protected Practitioner entererTarget;
1084
1085    /**
1086     * The logical author of the message - the person or device that decided the described event should happen. Where there is more than one candidate, pick the most proximal to the MessageHeader. Can provide other authors in extensions.
1087     */
1088    @Child(name = "author", type = {Practitioner.class}, order=6, min=0, max=1, modifier=false, summary=true)
1089    @Description(shortDefinition="The source of the decision", formalDefinition="The logical author of the message - the person or device that decided the described event should happen. Where there is more than one candidate, pick the most proximal to the MessageHeader. Can provide other authors in extensions." )
1090    protected Reference author;
1091
1092    /**
1093     * The actual object that is the target of the reference (The logical author of the message - the person or device that decided the described event should happen. Where there is more than one candidate, pick the most proximal to the MessageHeader. Can provide other authors in extensions.)
1094     */
1095    protected Practitioner authorTarget;
1096
1097    /**
1098     * Allows data conveyed by a message to be addressed to a particular person or department when routing to a specific application isn't sufficient.
1099     */
1100    @Child(name = "receiver", type = {Practitioner.class, Organization.class}, order=7, min=0, max=1, modifier=false, summary=true)
1101    @Description(shortDefinition="Intended \"real-world\" recipient for the data", formalDefinition="Allows data conveyed by a message to be addressed to a particular person or department when routing to a specific application isn't sufficient." )
1102    protected Reference receiver;
1103
1104    /**
1105     * The actual object that is the target of the reference (Allows data conveyed by a message to be addressed to a particular person or department when routing to a specific application isn't sufficient.)
1106     */
1107    protected Resource receiverTarget;
1108
1109    /**
1110     * The person or organization that accepts overall responsibility for the contents of the message. The implication is that the message event happened under the policies of the responsible party.
1111     */
1112    @Child(name = "responsible", type = {Practitioner.class, Organization.class}, order=8, min=0, max=1, modifier=false, summary=true)
1113    @Description(shortDefinition="Final responsibility for event", formalDefinition="The person or organization that accepts overall responsibility for the contents of the message. The implication is that the message event happened under the policies of the responsible party." )
1114    protected Reference responsible;
1115
1116    /**
1117     * The actual object that is the target of the reference (The person or organization that accepts overall responsibility for the contents of the message. The implication is that the message event happened under the policies of the responsible party.)
1118     */
1119    protected Resource responsibleTarget;
1120
1121    /**
1122     * Coded indication of the cause for the event - indicates  a reason for the occurrence of the event that is a focus of this message.
1123     */
1124    @Child(name = "reason", type = {CodeableConcept.class}, order=9, min=0, max=1, modifier=false, summary=true)
1125    @Description(shortDefinition="Cause of event", formalDefinition="Coded indication of the cause for the event - indicates  a reason for the occurrence of the event that is a focus of this message." )
1126    protected CodeableConcept reason;
1127
1128    /**
1129     * The actual data of the message - a reference to the root/focus class of the event.
1130     */
1131    @Child(name = "data", type = {}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1132    @Description(shortDefinition="The actual content of the message", formalDefinition="The actual data of the message - a reference to the root/focus class of the event." )
1133    protected List<Reference> data;
1134    /**
1135     * The actual objects that are the target of the reference (The actual data of the message - a reference to the root/focus class of the event.)
1136     */
1137    protected List<Resource> dataTarget;
1138
1139
1140    private static final long serialVersionUID = 1429728517L;
1141
1142  /*
1143   * Constructor
1144   */
1145    public MessageHeader() {
1146      super();
1147    }
1148
1149  /*
1150   * Constructor
1151   */
1152    public MessageHeader(InstantType timestamp, Coding event, MessageSourceComponent source) {
1153      super();
1154      this.timestamp = timestamp;
1155      this.event = event;
1156      this.source = source;
1157    }
1158
1159    /**
1160     * @return {@link #timestamp} (The time that the message was sent.). This is the underlying object with id, value and extensions. The accessor "getTimestamp" gives direct access to the value
1161     */
1162    public InstantType getTimestampElement() { 
1163      if (this.timestamp == null)
1164        if (Configuration.errorOnAutoCreate())
1165          throw new Error("Attempt to auto-create MessageHeader.timestamp");
1166        else if (Configuration.doAutoCreate())
1167          this.timestamp = new InstantType(); // bb
1168      return this.timestamp;
1169    }
1170
1171    public boolean hasTimestampElement() { 
1172      return this.timestamp != null && !this.timestamp.isEmpty();
1173    }
1174
1175    public boolean hasTimestamp() { 
1176      return this.timestamp != null && !this.timestamp.isEmpty();
1177    }
1178
1179    /**
1180     * @param value {@link #timestamp} (The time that the message was sent.). This is the underlying object with id, value and extensions. The accessor "getTimestamp" gives direct access to the value
1181     */
1182    public MessageHeader setTimestampElement(InstantType value) { 
1183      this.timestamp = value;
1184      return this;
1185    }
1186
1187    /**
1188     * @return The time that the message was sent.
1189     */
1190    public Date getTimestamp() { 
1191      return this.timestamp == null ? null : this.timestamp.getValue();
1192    }
1193
1194    /**
1195     * @param value The time that the message was sent.
1196     */
1197    public MessageHeader setTimestamp(Date value) { 
1198        if (this.timestamp == null)
1199          this.timestamp = new InstantType();
1200        this.timestamp.setValue(value);
1201      return this;
1202    }
1203
1204    /**
1205     * @return {@link #event} (Code that identifies the event this message represents and connects it with its definition. Events defined as part of the FHIR specification have the system value "http://hl7.org/fhir/message-events".)
1206     */
1207    public Coding getEvent() { 
1208      if (this.event == null)
1209        if (Configuration.errorOnAutoCreate())
1210          throw new Error("Attempt to auto-create MessageHeader.event");
1211        else if (Configuration.doAutoCreate())
1212          this.event = new Coding(); // cc
1213      return this.event;
1214    }
1215
1216    public boolean hasEvent() { 
1217      return this.event != null && !this.event.isEmpty();
1218    }
1219
1220    /**
1221     * @param value {@link #event} (Code that identifies the event this message represents and connects it with its definition. Events defined as part of the FHIR specification have the system value "http://hl7.org/fhir/message-events".)
1222     */
1223    public MessageHeader setEvent(Coding value) { 
1224      this.event = value;
1225      return this;
1226    }
1227
1228    /**
1229     * @return {@link #response} (Information about the message that this message is a response to.  Only present if this message is a response.)
1230     */
1231    public MessageHeaderResponseComponent getResponse() { 
1232      if (this.response == null)
1233        if (Configuration.errorOnAutoCreate())
1234          throw new Error("Attempt to auto-create MessageHeader.response");
1235        else if (Configuration.doAutoCreate())
1236          this.response = new MessageHeaderResponseComponent(); // cc
1237      return this.response;
1238    }
1239
1240    public boolean hasResponse() { 
1241      return this.response != null && !this.response.isEmpty();
1242    }
1243
1244    /**
1245     * @param value {@link #response} (Information about the message that this message is a response to.  Only present if this message is a response.)
1246     */
1247    public MessageHeader setResponse(MessageHeaderResponseComponent value) { 
1248      this.response = value;
1249      return this;
1250    }
1251
1252    /**
1253     * @return {@link #source} (The source application from which this message originated.)
1254     */
1255    public MessageSourceComponent getSource() { 
1256      if (this.source == null)
1257        if (Configuration.errorOnAutoCreate())
1258          throw new Error("Attempt to auto-create MessageHeader.source");
1259        else if (Configuration.doAutoCreate())
1260          this.source = new MessageSourceComponent(); // cc
1261      return this.source;
1262    }
1263
1264    public boolean hasSource() { 
1265      return this.source != null && !this.source.isEmpty();
1266    }
1267
1268    /**
1269     * @param value {@link #source} (The source application from which this message originated.)
1270     */
1271    public MessageHeader setSource(MessageSourceComponent value) { 
1272      this.source = value;
1273      return this;
1274    }
1275
1276    /**
1277     * @return {@link #destination} (The destination application which the message is intended for.)
1278     */
1279    public List<MessageDestinationComponent> getDestination() { 
1280      if (this.destination == null)
1281        this.destination = new ArrayList<MessageDestinationComponent>();
1282      return this.destination;
1283    }
1284
1285    public boolean hasDestination() { 
1286      if (this.destination == null)
1287        return false;
1288      for (MessageDestinationComponent item : this.destination)
1289        if (!item.isEmpty())
1290          return true;
1291      return false;
1292    }
1293
1294    /**
1295     * @return {@link #destination} (The destination application which the message is intended for.)
1296     */
1297    // syntactic sugar
1298    public MessageDestinationComponent addDestination() { //3
1299      MessageDestinationComponent t = new MessageDestinationComponent();
1300      if (this.destination == null)
1301        this.destination = new ArrayList<MessageDestinationComponent>();
1302      this.destination.add(t);
1303      return t;
1304    }
1305
1306    // syntactic sugar
1307    public MessageHeader addDestination(MessageDestinationComponent t) { //3
1308      if (t == null)
1309        return this;
1310      if (this.destination == null)
1311        this.destination = new ArrayList<MessageDestinationComponent>();
1312      this.destination.add(t);
1313      return this;
1314    }
1315
1316    /**
1317     * @return {@link #enterer} (The person or device that performed the data entry leading to this message. Where there is more than one candidate, pick the most proximal to the message. Can provide other enterers in extensions.)
1318     */
1319    public Reference getEnterer() { 
1320      if (this.enterer == null)
1321        if (Configuration.errorOnAutoCreate())
1322          throw new Error("Attempt to auto-create MessageHeader.enterer");
1323        else if (Configuration.doAutoCreate())
1324          this.enterer = new Reference(); // cc
1325      return this.enterer;
1326    }
1327
1328    public boolean hasEnterer() { 
1329      return this.enterer != null && !this.enterer.isEmpty();
1330    }
1331
1332    /**
1333     * @param value {@link #enterer} (The person or device that performed the data entry leading to this message. Where there is more than one candidate, pick the most proximal to the message. Can provide other enterers in extensions.)
1334     */
1335    public MessageHeader setEnterer(Reference value) { 
1336      this.enterer = value;
1337      return this;
1338    }
1339
1340    /**
1341     * @return {@link #enterer} 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 person or device that performed the data entry leading to this message. Where there is more than one candidate, pick the most proximal to the message. Can provide other enterers in extensions.)
1342     */
1343    public Practitioner getEntererTarget() { 
1344      if (this.entererTarget == null)
1345        if (Configuration.errorOnAutoCreate())
1346          throw new Error("Attempt to auto-create MessageHeader.enterer");
1347        else if (Configuration.doAutoCreate())
1348          this.entererTarget = new Practitioner(); // aa
1349      return this.entererTarget;
1350    }
1351
1352    /**
1353     * @param value {@link #enterer} 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 person or device that performed the data entry leading to this message. Where there is more than one candidate, pick the most proximal to the message. Can provide other enterers in extensions.)
1354     */
1355    public MessageHeader setEntererTarget(Practitioner value) { 
1356      this.entererTarget = value;
1357      return this;
1358    }
1359
1360    /**
1361     * @return {@link #author} (The logical author of the message - the person or device that decided the described event should happen. Where there is more than one candidate, pick the most proximal to the MessageHeader. Can provide other authors in extensions.)
1362     */
1363    public Reference getAuthor() { 
1364      if (this.author == null)
1365        if (Configuration.errorOnAutoCreate())
1366          throw new Error("Attempt to auto-create MessageHeader.author");
1367        else if (Configuration.doAutoCreate())
1368          this.author = new Reference(); // cc
1369      return this.author;
1370    }
1371
1372    public boolean hasAuthor() { 
1373      return this.author != null && !this.author.isEmpty();
1374    }
1375
1376    /**
1377     * @param value {@link #author} (The logical author of the message - the person or device that decided the described event should happen. Where there is more than one candidate, pick the most proximal to the MessageHeader. Can provide other authors in extensions.)
1378     */
1379    public MessageHeader setAuthor(Reference value) { 
1380      this.author = value;
1381      return this;
1382    }
1383
1384    /**
1385     * @return {@link #author} 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 logical author of the message - the person or device that decided the described event should happen. Where there is more than one candidate, pick the most proximal to the MessageHeader. Can provide other authors in extensions.)
1386     */
1387    public Practitioner getAuthorTarget() { 
1388      if (this.authorTarget == null)
1389        if (Configuration.errorOnAutoCreate())
1390          throw new Error("Attempt to auto-create MessageHeader.author");
1391        else if (Configuration.doAutoCreate())
1392          this.authorTarget = new Practitioner(); // aa
1393      return this.authorTarget;
1394    }
1395
1396    /**
1397     * @param value {@link #author} 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 logical author of the message - the person or device that decided the described event should happen. Where there is more than one candidate, pick the most proximal to the MessageHeader. Can provide other authors in extensions.)
1398     */
1399    public MessageHeader setAuthorTarget(Practitioner value) { 
1400      this.authorTarget = value;
1401      return this;
1402    }
1403
1404    /**
1405     * @return {@link #receiver} (Allows data conveyed by a message to be addressed to a particular person or department when routing to a specific application isn't sufficient.)
1406     */
1407    public Reference getReceiver() { 
1408      if (this.receiver == null)
1409        if (Configuration.errorOnAutoCreate())
1410          throw new Error("Attempt to auto-create MessageHeader.receiver");
1411        else if (Configuration.doAutoCreate())
1412          this.receiver = new Reference(); // cc
1413      return this.receiver;
1414    }
1415
1416    public boolean hasReceiver() { 
1417      return this.receiver != null && !this.receiver.isEmpty();
1418    }
1419
1420    /**
1421     * @param value {@link #receiver} (Allows data conveyed by a message to be addressed to a particular person or department when routing to a specific application isn't sufficient.)
1422     */
1423    public MessageHeader setReceiver(Reference value) { 
1424      this.receiver = value;
1425      return this;
1426    }
1427
1428    /**
1429     * @return {@link #receiver} 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. (Allows data conveyed by a message to be addressed to a particular person or department when routing to a specific application isn't sufficient.)
1430     */
1431    public Resource getReceiverTarget() { 
1432      return this.receiverTarget;
1433    }
1434
1435    /**
1436     * @param value {@link #receiver} 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. (Allows data conveyed by a message to be addressed to a particular person or department when routing to a specific application isn't sufficient.)
1437     */
1438    public MessageHeader setReceiverTarget(Resource value) { 
1439      this.receiverTarget = value;
1440      return this;
1441    }
1442
1443    /**
1444     * @return {@link #responsible} (The person or organization that accepts overall responsibility for the contents of the message. The implication is that the message event happened under the policies of the responsible party.)
1445     */
1446    public Reference getResponsible() { 
1447      if (this.responsible == null)
1448        if (Configuration.errorOnAutoCreate())
1449          throw new Error("Attempt to auto-create MessageHeader.responsible");
1450        else if (Configuration.doAutoCreate())
1451          this.responsible = new Reference(); // cc
1452      return this.responsible;
1453    }
1454
1455    public boolean hasResponsible() { 
1456      return this.responsible != null && !this.responsible.isEmpty();
1457    }
1458
1459    /**
1460     * @param value {@link #responsible} (The person or organization that accepts overall responsibility for the contents of the message. The implication is that the message event happened under the policies of the responsible party.)
1461     */
1462    public MessageHeader setResponsible(Reference value) { 
1463      this.responsible = value;
1464      return this;
1465    }
1466
1467    /**
1468     * @return {@link #responsible} 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 person or organization that accepts overall responsibility for the contents of the message. The implication is that the message event happened under the policies of the responsible party.)
1469     */
1470    public Resource getResponsibleTarget() { 
1471      return this.responsibleTarget;
1472    }
1473
1474    /**
1475     * @param value {@link #responsible} 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 person or organization that accepts overall responsibility for the contents of the message. The implication is that the message event happened under the policies of the responsible party.)
1476     */
1477    public MessageHeader setResponsibleTarget(Resource value) { 
1478      this.responsibleTarget = value;
1479      return this;
1480    }
1481
1482    /**
1483     * @return {@link #reason} (Coded indication of the cause for the event - indicates  a reason for the occurrence of the event that is a focus of this message.)
1484     */
1485    public CodeableConcept getReason() { 
1486      if (this.reason == null)
1487        if (Configuration.errorOnAutoCreate())
1488          throw new Error("Attempt to auto-create MessageHeader.reason");
1489        else if (Configuration.doAutoCreate())
1490          this.reason = new CodeableConcept(); // cc
1491      return this.reason;
1492    }
1493
1494    public boolean hasReason() { 
1495      return this.reason != null && !this.reason.isEmpty();
1496    }
1497
1498    /**
1499     * @param value {@link #reason} (Coded indication of the cause for the event - indicates  a reason for the occurrence of the event that is a focus of this message.)
1500     */
1501    public MessageHeader setReason(CodeableConcept value) { 
1502      this.reason = value;
1503      return this;
1504    }
1505
1506    /**
1507     * @return {@link #data} (The actual data of the message - a reference to the root/focus class of the event.)
1508     */
1509    public List<Reference> getData() { 
1510      if (this.data == null)
1511        this.data = new ArrayList<Reference>();
1512      return this.data;
1513    }
1514
1515    public boolean hasData() { 
1516      if (this.data == null)
1517        return false;
1518      for (Reference item : this.data)
1519        if (!item.isEmpty())
1520          return true;
1521      return false;
1522    }
1523
1524    /**
1525     * @return {@link #data} (The actual data of the message - a reference to the root/focus class of the event.)
1526     */
1527    // syntactic sugar
1528    public Reference addData() { //3
1529      Reference t = new Reference();
1530      if (this.data == null)
1531        this.data = new ArrayList<Reference>();
1532      this.data.add(t);
1533      return t;
1534    }
1535
1536    // syntactic sugar
1537    public MessageHeader addData(Reference t) { //3
1538      if (t == null)
1539        return this;
1540      if (this.data == null)
1541        this.data = new ArrayList<Reference>();
1542      this.data.add(t);
1543      return this;
1544    }
1545
1546    /**
1547     * @return {@link #data} (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 actual data of the message - a reference to the root/focus class of the event.)
1548     */
1549    public List<Resource> getDataTarget() { 
1550      if (this.dataTarget == null)
1551        this.dataTarget = new ArrayList<Resource>();
1552      return this.dataTarget;
1553    }
1554
1555      protected void listChildren(List<Property> childrenList) {
1556        super.listChildren(childrenList);
1557        childrenList.add(new Property("timestamp", "instant", "The time that the message was sent.", 0, java.lang.Integer.MAX_VALUE, timestamp));
1558        childrenList.add(new Property("event", "Coding", "Code that identifies the event this message represents and connects it with its definition. Events defined as part of the FHIR specification have the system value \"http://hl7.org/fhir/message-events\".", 0, java.lang.Integer.MAX_VALUE, event));
1559        childrenList.add(new Property("response", "", "Information about the message that this message is a response to.  Only present if this message is a response.", 0, java.lang.Integer.MAX_VALUE, response));
1560        childrenList.add(new Property("source", "", "The source application from which this message originated.", 0, java.lang.Integer.MAX_VALUE, source));
1561        childrenList.add(new Property("destination", "", "The destination application which the message is intended for.", 0, java.lang.Integer.MAX_VALUE, destination));
1562        childrenList.add(new Property("enterer", "Reference(Practitioner)", "The person or device that performed the data entry leading to this message. Where there is more than one candidate, pick the most proximal to the message. Can provide other enterers in extensions.", 0, java.lang.Integer.MAX_VALUE, enterer));
1563        childrenList.add(new Property("author", "Reference(Practitioner)", "The logical author of the message - the person or device that decided the described event should happen. Where there is more than one candidate, pick the most proximal to the MessageHeader. Can provide other authors in extensions.", 0, java.lang.Integer.MAX_VALUE, author));
1564        childrenList.add(new Property("receiver", "Reference(Practitioner|Organization)", "Allows data conveyed by a message to be addressed to a particular person or department when routing to a specific application isn't sufficient.", 0, java.lang.Integer.MAX_VALUE, receiver));
1565        childrenList.add(new Property("responsible", "Reference(Practitioner|Organization)", "The person or organization that accepts overall responsibility for the contents of the message. The implication is that the message event happened under the policies of the responsible party.", 0, java.lang.Integer.MAX_VALUE, responsible));
1566        childrenList.add(new Property("reason", "CodeableConcept", "Coded indication of the cause for the event - indicates  a reason for the occurrence of the event that is a focus of this message.", 0, java.lang.Integer.MAX_VALUE, reason));
1567        childrenList.add(new Property("data", "Reference(Any)", "The actual data of the message - a reference to the root/focus class of the event.", 0, java.lang.Integer.MAX_VALUE, data));
1568      }
1569
1570      @Override
1571      public void setProperty(String name, Base value) throws FHIRException {
1572        if (name.equals("timestamp"))
1573          this.timestamp = castToInstant(value); // InstantType
1574        else if (name.equals("event"))
1575          this.event = castToCoding(value); // Coding
1576        else if (name.equals("response"))
1577          this.response = (MessageHeaderResponseComponent) value; // MessageHeaderResponseComponent
1578        else if (name.equals("source"))
1579          this.source = (MessageSourceComponent) value; // MessageSourceComponent
1580        else if (name.equals("destination"))
1581          this.getDestination().add((MessageDestinationComponent) value);
1582        else if (name.equals("enterer"))
1583          this.enterer = castToReference(value); // Reference
1584        else if (name.equals("author"))
1585          this.author = castToReference(value); // Reference
1586        else if (name.equals("receiver"))
1587          this.receiver = castToReference(value); // Reference
1588        else if (name.equals("responsible"))
1589          this.responsible = castToReference(value); // Reference
1590        else if (name.equals("reason"))
1591          this.reason = castToCodeableConcept(value); // CodeableConcept
1592        else if (name.equals("data"))
1593          this.getData().add(castToReference(value));
1594        else
1595          super.setProperty(name, value);
1596      }
1597
1598      @Override
1599      public Base addChild(String name) throws FHIRException {
1600        if (name.equals("timestamp")) {
1601          throw new FHIRException("Cannot call addChild on a primitive type MessageHeader.timestamp");
1602        }
1603        else if (name.equals("event")) {
1604          this.event = new Coding();
1605          return this.event;
1606        }
1607        else if (name.equals("response")) {
1608          this.response = new MessageHeaderResponseComponent();
1609          return this.response;
1610        }
1611        else if (name.equals("source")) {
1612          this.source = new MessageSourceComponent();
1613          return this.source;
1614        }
1615        else if (name.equals("destination")) {
1616          return addDestination();
1617        }
1618        else if (name.equals("enterer")) {
1619          this.enterer = new Reference();
1620          return this.enterer;
1621        }
1622        else if (name.equals("author")) {
1623          this.author = new Reference();
1624          return this.author;
1625        }
1626        else if (name.equals("receiver")) {
1627          this.receiver = new Reference();
1628          return this.receiver;
1629        }
1630        else if (name.equals("responsible")) {
1631          this.responsible = new Reference();
1632          return this.responsible;
1633        }
1634        else if (name.equals("reason")) {
1635          this.reason = new CodeableConcept();
1636          return this.reason;
1637        }
1638        else if (name.equals("data")) {
1639          return addData();
1640        }
1641        else
1642          return super.addChild(name);
1643      }
1644
1645  public String fhirType() {
1646    return "MessageHeader";
1647
1648  }
1649
1650      public MessageHeader copy() {
1651        MessageHeader dst = new MessageHeader();
1652        copyValues(dst);
1653        dst.timestamp = timestamp == null ? null : timestamp.copy();
1654        dst.event = event == null ? null : event.copy();
1655        dst.response = response == null ? null : response.copy();
1656        dst.source = source == null ? null : source.copy();
1657        if (destination != null) {
1658          dst.destination = new ArrayList<MessageDestinationComponent>();
1659          for (MessageDestinationComponent i : destination)
1660            dst.destination.add(i.copy());
1661        };
1662        dst.enterer = enterer == null ? null : enterer.copy();
1663        dst.author = author == null ? null : author.copy();
1664        dst.receiver = receiver == null ? null : receiver.copy();
1665        dst.responsible = responsible == null ? null : responsible.copy();
1666        dst.reason = reason == null ? null : reason.copy();
1667        if (data != null) {
1668          dst.data = new ArrayList<Reference>();
1669          for (Reference i : data)
1670            dst.data.add(i.copy());
1671        };
1672        return dst;
1673      }
1674
1675      protected MessageHeader typedCopy() {
1676        return copy();
1677      }
1678
1679      @Override
1680      public boolean equalsDeep(Base other) {
1681        if (!super.equalsDeep(other))
1682          return false;
1683        if (!(other instanceof MessageHeader))
1684          return false;
1685        MessageHeader o = (MessageHeader) other;
1686        return compareDeep(timestamp, o.timestamp, true) && compareDeep(event, o.event, true) && compareDeep(response, o.response, true)
1687           && compareDeep(source, o.source, true) && compareDeep(destination, o.destination, true) && compareDeep(enterer, o.enterer, true)
1688           && compareDeep(author, o.author, true) && compareDeep(receiver, o.receiver, true) && compareDeep(responsible, o.responsible, true)
1689           && compareDeep(reason, o.reason, true) && compareDeep(data, o.data, true);
1690      }
1691
1692      @Override
1693      public boolean equalsShallow(Base other) {
1694        if (!super.equalsShallow(other))
1695          return false;
1696        if (!(other instanceof MessageHeader))
1697          return false;
1698        MessageHeader o = (MessageHeader) other;
1699        return compareValues(timestamp, o.timestamp, true);
1700      }
1701
1702      public boolean isEmpty() {
1703        return super.isEmpty() && (timestamp == null || timestamp.isEmpty()) && (event == null || event.isEmpty())
1704           && (response == null || response.isEmpty()) && (source == null || source.isEmpty()) && (destination == null || destination.isEmpty())
1705           && (enterer == null || enterer.isEmpty()) && (author == null || author.isEmpty()) && (receiver == null || receiver.isEmpty())
1706           && (responsible == null || responsible.isEmpty()) && (reason == null || reason.isEmpty())
1707           && (data == null || data.isEmpty());
1708      }
1709
1710  @Override
1711  public ResourceType getResourceType() {
1712    return ResourceType.MessageHeader;
1713   }
1714
1715  @SearchParamDefinition(name="code", path="MessageHeader.response.code", description="ok | transient-error | fatal-error", type="token" )
1716  public static final String SP_CODE = "code";
1717  @SearchParamDefinition(name="data", path="MessageHeader.data", description="The actual content of the message", type="reference" )
1718  public static final String SP_DATA = "data";
1719  @SearchParamDefinition(name="receiver", path="MessageHeader.receiver", description="Intended \"real-world\" recipient for the data", type="reference" )
1720  public static final String SP_RECEIVER = "receiver";
1721  @SearchParamDefinition(name="author", path="MessageHeader.author", description="The source of the decision", type="reference" )
1722  public static final String SP_AUTHOR = "author";
1723  @SearchParamDefinition(name="destination", path="MessageHeader.destination.name", description="Name of system", type="string" )
1724  public static final String SP_DESTINATION = "destination";
1725  @SearchParamDefinition(name="source", path="MessageHeader.source.name", description="Name of system", type="string" )
1726  public static final String SP_SOURCE = "source";
1727  @SearchParamDefinition(name="target", path="MessageHeader.destination.target", description="Particular delivery destination within the destination", type="reference" )
1728  public static final String SP_TARGET = "target";
1729  @SearchParamDefinition(name="destination-uri", path="MessageHeader.destination.endpoint", description="Actual destination address or id", type="uri" )
1730  public static final String SP_DESTINATIONURI = "destination-uri";
1731  @SearchParamDefinition(name="source-uri", path="MessageHeader.source.endpoint", description="Actual message source address or id", type="uri" )
1732  public static final String SP_SOURCEURI = "source-uri";
1733  @SearchParamDefinition(name="responsible", path="MessageHeader.responsible", description="Final responsibility for event", type="reference" )
1734  public static final String SP_RESPONSIBLE = "responsible";
1735  @SearchParamDefinition(name="response-id", path="MessageHeader.response.identifier", description="Id of original message", type="token" )
1736  public static final String SP_RESPONSEID = "response-id";
1737  @SearchParamDefinition(name="enterer", path="MessageHeader.enterer", description="The source of the data entry", type="reference" )
1738  public static final String SP_ENTERER = "enterer";
1739  @SearchParamDefinition(name="event", path="MessageHeader.event", description="Code for the event this message represents", type="token" )
1740  public static final String SP_EVENT = "event";
1741  @SearchParamDefinition(name="timestamp", path="MessageHeader.timestamp", description="Time that the message was sent", type="date" )
1742  public static final String SP_TIMESTAMP = "timestamp";
1743
1744}