001package org.hl7.fhir.dstu2016may.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
033import java.util.ArrayList;
034import java.util.Date;
035import java.util.List;
036
037import org.hl7.fhir.exceptions.FHIRException;
038import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
039import org.hl7.fhir.utilities.Utilities;
040
041import ca.uhn.fhir.model.api.annotation.Block;
042import ca.uhn.fhir.model.api.annotation.Child;
043import ca.uhn.fhir.model.api.annotation.Description;
044import ca.uhn.fhir.model.api.annotation.ResourceDef;
045import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
046/**
047 * 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.
048 */
049@ResourceDef(name="MessageHeader", profile="http://hl7.org/fhir/Profile/MessageHeader")
050public class MessageHeader extends DomainResource {
051
052    public enum ResponseType {
053        /**
054         * The message was accepted and processed without error.
055         */
056        OK, 
057        /**
058         * 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.
059         */
060        TRANSIENTERROR, 
061        /**
062         * 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.
063         */
064        FATALERROR, 
065        /**
066         * added to help the parsers
067         */
068        NULL;
069        public static ResponseType fromCode(String codeString) throws FHIRException {
070            if (codeString == null || "".equals(codeString))
071                return null;
072        if ("ok".equals(codeString))
073          return OK;
074        if ("transient-error".equals(codeString))
075          return TRANSIENTERROR;
076        if ("fatal-error".equals(codeString))
077          return FATALERROR;
078        throw new FHIRException("Unknown ResponseType code '"+codeString+"'");
079        }
080        public String toCode() {
081          switch (this) {
082            case OK: return "ok";
083            case TRANSIENTERROR: return "transient-error";
084            case FATALERROR: return "fatal-error";
085            default: return "?";
086          }
087        }
088        public String getSystem() {
089          switch (this) {
090            case OK: return "http://hl7.org/fhir/response-code";
091            case TRANSIENTERROR: return "http://hl7.org/fhir/response-code";
092            case FATALERROR: return "http://hl7.org/fhir/response-code";
093            default: return "?";
094          }
095        }
096        public String getDefinition() {
097          switch (this) {
098            case OK: return "The message was accepted and processed without error.";
099            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.";
100            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.";
101            default: return "?";
102          }
103        }
104        public String getDisplay() {
105          switch (this) {
106            case OK: return "OK";
107            case TRANSIENTERROR: return "Transient Error";
108            case FATALERROR: return "Fatal Error";
109            default: return "?";
110          }
111        }
112    }
113
114  public static class ResponseTypeEnumFactory implements EnumFactory<ResponseType> {
115    public ResponseType fromCode(String codeString) throws IllegalArgumentException {
116      if (codeString == null || "".equals(codeString))
117            if (codeString == null || "".equals(codeString))
118                return null;
119        if ("ok".equals(codeString))
120          return ResponseType.OK;
121        if ("transient-error".equals(codeString))
122          return ResponseType.TRANSIENTERROR;
123        if ("fatal-error".equals(codeString))
124          return ResponseType.FATALERROR;
125        throw new IllegalArgumentException("Unknown ResponseType code '"+codeString+"'");
126        }
127        public Enumeration<ResponseType> fromType(Base code) throws FHIRException {
128          if (code == null || code.isEmpty())
129            return null;
130          String codeString = ((PrimitiveType) code).asStringValue();
131          if (codeString == null || "".equals(codeString))
132            return null;
133        if ("ok".equals(codeString))
134          return new Enumeration<ResponseType>(this, ResponseType.OK);
135        if ("transient-error".equals(codeString))
136          return new Enumeration<ResponseType>(this, ResponseType.TRANSIENTERROR);
137        if ("fatal-error".equals(codeString))
138          return new Enumeration<ResponseType>(this, ResponseType.FATALERROR);
139        throw new FHIRException("Unknown ResponseType code '"+codeString+"'");
140        }
141    public String toCode(ResponseType code) {
142      if (code == ResponseType.OK)
143        return "ok";
144      if (code == ResponseType.TRANSIENTERROR)
145        return "transient-error";
146      if (code == ResponseType.FATALERROR)
147        return "fatal-error";
148      return "?";
149      }
150    public String toSystem(ResponseType code) {
151      return code.getSystem();
152      }
153    }
154
155    @Block()
156    public static class MessageHeaderResponseComponent extends BackboneElement implements IBaseBackboneElement {
157        /**
158         * The id of the message that this message is a response to.
159         */
160        @Child(name = "identifier", type = {IdType.class}, order=1, min=1, max=1, modifier=false, summary=true)
161        @Description(shortDefinition="Id of original message", formalDefinition="The id of the message that this message is a response to." )
162        protected IdType identifier;
163
164        /**
165         * Code that identifies the type of response to the message - whether it was successful or not, and whether it should be resent or not.
166         */
167        @Child(name = "code", type = {CodeType.class}, order=2, min=1, max=1, modifier=true, summary=true)
168        @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." )
169        protected Enumeration<ResponseType> code;
170
171        /**
172         * Full details of any issues found in the message.
173         */
174        @Child(name = "details", type = {OperationOutcome.class}, order=3, min=0, max=1, modifier=false, summary=true)
175        @Description(shortDefinition="Specific list of hints/warnings/errors", formalDefinition="Full details of any issues found in the message." )
176        protected Reference details;
177
178        /**
179         * The actual object that is the target of the reference (Full details of any issues found in the message.)
180         */
181        protected OperationOutcome detailsTarget;
182
183        private static final long serialVersionUID = -1008716838L;
184
185    /**
186     * Constructor
187     */
188      public MessageHeaderResponseComponent() {
189        super();
190      }
191
192    /**
193     * Constructor
194     */
195      public MessageHeaderResponseComponent(IdType identifier, Enumeration<ResponseType> code) {
196        super();
197        this.identifier = identifier;
198        this.code = code;
199      }
200
201        /**
202         * @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
203         */
204        public IdType getIdentifierElement() { 
205          if (this.identifier == null)
206            if (Configuration.errorOnAutoCreate())
207              throw new Error("Attempt to auto-create MessageHeaderResponseComponent.identifier");
208            else if (Configuration.doAutoCreate())
209              this.identifier = new IdType(); // bb
210          return this.identifier;
211        }
212
213        public boolean hasIdentifierElement() { 
214          return this.identifier != null && !this.identifier.isEmpty();
215        }
216
217        public boolean hasIdentifier() { 
218          return this.identifier != null && !this.identifier.isEmpty();
219        }
220
221        /**
222         * @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
223         */
224        public MessageHeaderResponseComponent setIdentifierElement(IdType value) { 
225          this.identifier = value;
226          return this;
227        }
228
229        /**
230         * @return The id of the message that this message is a response to.
231         */
232        public String getIdentifier() { 
233          return this.identifier == null ? null : this.identifier.getValue();
234        }
235
236        /**
237         * @param value The id of the message that this message is a response to.
238         */
239        public MessageHeaderResponseComponent setIdentifier(String value) { 
240            if (this.identifier == null)
241              this.identifier = new IdType();
242            this.identifier.setValue(value);
243          return this;
244        }
245
246        /**
247         * @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
248         */
249        public Enumeration<ResponseType> getCodeElement() { 
250          if (this.code == null)
251            if (Configuration.errorOnAutoCreate())
252              throw new Error("Attempt to auto-create MessageHeaderResponseComponent.code");
253            else if (Configuration.doAutoCreate())
254              this.code = new Enumeration<ResponseType>(new ResponseTypeEnumFactory()); // bb
255          return this.code;
256        }
257
258        public boolean hasCodeElement() { 
259          return this.code != null && !this.code.isEmpty();
260        }
261
262        public boolean hasCode() { 
263          return this.code != null && !this.code.isEmpty();
264        }
265
266        /**
267         * @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
268         */
269        public MessageHeaderResponseComponent setCodeElement(Enumeration<ResponseType> value) { 
270          this.code = value;
271          return this;
272        }
273
274        /**
275         * @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.
276         */
277        public ResponseType getCode() { 
278          return this.code == null ? null : this.code.getValue();
279        }
280
281        /**
282         * @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.
283         */
284        public MessageHeaderResponseComponent setCode(ResponseType value) { 
285            if (this.code == null)
286              this.code = new Enumeration<ResponseType>(new ResponseTypeEnumFactory());
287            this.code.setValue(value);
288          return this;
289        }
290
291        /**
292         * @return {@link #details} (Full details of any issues found in the message.)
293         */
294        public Reference getDetails() { 
295          if (this.details == null)
296            if (Configuration.errorOnAutoCreate())
297              throw new Error("Attempt to auto-create MessageHeaderResponseComponent.details");
298            else if (Configuration.doAutoCreate())
299              this.details = new Reference(); // cc
300          return this.details;
301        }
302
303        public boolean hasDetails() { 
304          return this.details != null && !this.details.isEmpty();
305        }
306
307        /**
308         * @param value {@link #details} (Full details of any issues found in the message.)
309         */
310        public MessageHeaderResponseComponent setDetails(Reference value) { 
311          this.details = value;
312          return this;
313        }
314
315        /**
316         * @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.)
317         */
318        public OperationOutcome getDetailsTarget() { 
319          if (this.detailsTarget == null)
320            if (Configuration.errorOnAutoCreate())
321              throw new Error("Attempt to auto-create MessageHeaderResponseComponent.details");
322            else if (Configuration.doAutoCreate())
323              this.detailsTarget = new OperationOutcome(); // aa
324          return this.detailsTarget;
325        }
326
327        /**
328         * @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.)
329         */
330        public MessageHeaderResponseComponent setDetailsTarget(OperationOutcome value) { 
331          this.detailsTarget = value;
332          return this;
333        }
334
335        protected void listChildren(List<Property> childrenList) {
336          super.listChildren(childrenList);
337          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));
338          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));
339          childrenList.add(new Property("details", "Reference(OperationOutcome)", "Full details of any issues found in the message.", 0, java.lang.Integer.MAX_VALUE, details));
340        }
341
342      @Override
343      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
344        switch (hash) {
345        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // IdType
346        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // Enumeration<ResponseType>
347        case 1557721666: /*details*/ return this.details == null ? new Base[0] : new Base[] {this.details}; // Reference
348        default: return super.getProperty(hash, name, checkValid);
349        }
350
351      }
352
353      @Override
354      public void setProperty(int hash, String name, Base value) throws FHIRException {
355        switch (hash) {
356        case -1618432855: // identifier
357          this.identifier = castToId(value); // IdType
358          break;
359        case 3059181: // code
360          this.code = new ResponseTypeEnumFactory().fromType(value); // Enumeration<ResponseType>
361          break;
362        case 1557721666: // details
363          this.details = castToReference(value); // Reference
364          break;
365        default: super.setProperty(hash, name, value);
366        }
367
368      }
369
370      @Override
371      public void setProperty(String name, Base value) throws FHIRException {
372        if (name.equals("identifier"))
373          this.identifier = castToId(value); // IdType
374        else if (name.equals("code"))
375          this.code = new ResponseTypeEnumFactory().fromType(value); // Enumeration<ResponseType>
376        else if (name.equals("details"))
377          this.details = castToReference(value); // Reference
378        else
379          super.setProperty(name, value);
380      }
381
382      @Override
383      public Base makeProperty(int hash, String name) throws FHIRException {
384        switch (hash) {
385        case -1618432855: throw new FHIRException("Cannot make property identifier as it is not a complex type"); // IdType
386        case 3059181: throw new FHIRException("Cannot make property code as it is not a complex type"); // Enumeration<ResponseType>
387        case 1557721666:  return getDetails(); // Reference
388        default: return super.makeProperty(hash, name);
389        }
390
391      }
392
393      @Override
394      public Base addChild(String name) throws FHIRException {
395        if (name.equals("identifier")) {
396          throw new FHIRException("Cannot call addChild on a primitive type MessageHeader.identifier");
397        }
398        else if (name.equals("code")) {
399          throw new FHIRException("Cannot call addChild on a primitive type MessageHeader.code");
400        }
401        else if (name.equals("details")) {
402          this.details = new Reference();
403          return this.details;
404        }
405        else
406          return super.addChild(name);
407      }
408
409      public MessageHeaderResponseComponent copy() {
410        MessageHeaderResponseComponent dst = new MessageHeaderResponseComponent();
411        copyValues(dst);
412        dst.identifier = identifier == null ? null : identifier.copy();
413        dst.code = code == null ? null : code.copy();
414        dst.details = details == null ? null : details.copy();
415        return dst;
416      }
417
418      @Override
419      public boolean equalsDeep(Base other) {
420        if (!super.equalsDeep(other))
421          return false;
422        if (!(other instanceof MessageHeaderResponseComponent))
423          return false;
424        MessageHeaderResponseComponent o = (MessageHeaderResponseComponent) other;
425        return compareDeep(identifier, o.identifier, true) && compareDeep(code, o.code, true) && compareDeep(details, o.details, true)
426          ;
427      }
428
429      @Override
430      public boolean equalsShallow(Base other) {
431        if (!super.equalsShallow(other))
432          return false;
433        if (!(other instanceof MessageHeaderResponseComponent))
434          return false;
435        MessageHeaderResponseComponent o = (MessageHeaderResponseComponent) other;
436        return compareValues(identifier, o.identifier, true) && compareValues(code, o.code, true);
437      }
438
439      public boolean isEmpty() {
440        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (code == null || code.isEmpty())
441           && (details == null || details.isEmpty());
442      }
443
444  public String fhirType() {
445    return "MessageHeader.response";
446
447  }
448
449  }
450
451    @Block()
452    public static class MessageSourceComponent extends BackboneElement implements IBaseBackboneElement {
453        /**
454         * Human-readable name for the source system.
455         */
456        @Child(name = "name", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
457        @Description(shortDefinition="Name of system", formalDefinition="Human-readable name for the source system." )
458        protected StringType name;
459
460        /**
461         * May include configuration or other information useful in debugging.
462         */
463        @Child(name = "software", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true)
464        @Description(shortDefinition="Name of software running the system", formalDefinition="May include configuration or other information useful in debugging." )
465        protected StringType software;
466
467        /**
468         * Can convey versions of multiple systems in situations where a message passes through multiple hands.
469         */
470        @Child(name = "version", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
471        @Description(shortDefinition="Version of software running", formalDefinition="Can convey versions of multiple systems in situations where a message passes through multiple hands." )
472        protected StringType version;
473
474        /**
475         * An e-mail, phone, website or other contact point to use to resolve issues with message communications.
476         */
477        @Child(name = "contact", type = {ContactPoint.class}, order=4, min=0, max=1, modifier=false, summary=true)
478        @Description(shortDefinition="Human contact for problems", formalDefinition="An e-mail, phone, website or other contact point to use to resolve issues with message communications." )
479        protected ContactPoint contact;
480
481        /**
482         * Identifies the routing target to send acknowledgements to.
483         */
484        @Child(name = "endpoint", type = {UriType.class}, order=5, min=1, max=1, modifier=false, summary=true)
485        @Description(shortDefinition="Actual message source address or id", formalDefinition="Identifies the routing target to send acknowledgements to." )
486        protected UriType endpoint;
487
488        private static final long serialVersionUID = -115878196L;
489
490    /**
491     * Constructor
492     */
493      public MessageSourceComponent() {
494        super();
495      }
496
497    /**
498     * Constructor
499     */
500      public MessageSourceComponent(UriType endpoint) {
501        super();
502        this.endpoint = endpoint;
503      }
504
505        /**
506         * @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
507         */
508        public StringType getNameElement() { 
509          if (this.name == null)
510            if (Configuration.errorOnAutoCreate())
511              throw new Error("Attempt to auto-create MessageSourceComponent.name");
512            else if (Configuration.doAutoCreate())
513              this.name = new StringType(); // bb
514          return this.name;
515        }
516
517        public boolean hasNameElement() { 
518          return this.name != null && !this.name.isEmpty();
519        }
520
521        public boolean hasName() { 
522          return this.name != null && !this.name.isEmpty();
523        }
524
525        /**
526         * @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
527         */
528        public MessageSourceComponent setNameElement(StringType value) { 
529          this.name = value;
530          return this;
531        }
532
533        /**
534         * @return Human-readable name for the source system.
535         */
536        public String getName() { 
537          return this.name == null ? null : this.name.getValue();
538        }
539
540        /**
541         * @param value Human-readable name for the source system.
542         */
543        public MessageSourceComponent setName(String value) { 
544          if (Utilities.noString(value))
545            this.name = null;
546          else {
547            if (this.name == null)
548              this.name = new StringType();
549            this.name.setValue(value);
550          }
551          return this;
552        }
553
554        /**
555         * @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
556         */
557        public StringType getSoftwareElement() { 
558          if (this.software == null)
559            if (Configuration.errorOnAutoCreate())
560              throw new Error("Attempt to auto-create MessageSourceComponent.software");
561            else if (Configuration.doAutoCreate())
562              this.software = new StringType(); // bb
563          return this.software;
564        }
565
566        public boolean hasSoftwareElement() { 
567          return this.software != null && !this.software.isEmpty();
568        }
569
570        public boolean hasSoftware() { 
571          return this.software != null && !this.software.isEmpty();
572        }
573
574        /**
575         * @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
576         */
577        public MessageSourceComponent setSoftwareElement(StringType value) { 
578          this.software = value;
579          return this;
580        }
581
582        /**
583         * @return May include configuration or other information useful in debugging.
584         */
585        public String getSoftware() { 
586          return this.software == null ? null : this.software.getValue();
587        }
588
589        /**
590         * @param value May include configuration or other information useful in debugging.
591         */
592        public MessageSourceComponent setSoftware(String value) { 
593          if (Utilities.noString(value))
594            this.software = null;
595          else {
596            if (this.software == null)
597              this.software = new StringType();
598            this.software.setValue(value);
599          }
600          return this;
601        }
602
603        /**
604         * @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
605         */
606        public StringType getVersionElement() { 
607          if (this.version == null)
608            if (Configuration.errorOnAutoCreate())
609              throw new Error("Attempt to auto-create MessageSourceComponent.version");
610            else if (Configuration.doAutoCreate())
611              this.version = new StringType(); // bb
612          return this.version;
613        }
614
615        public boolean hasVersionElement() { 
616          return this.version != null && !this.version.isEmpty();
617        }
618
619        public boolean hasVersion() { 
620          return this.version != null && !this.version.isEmpty();
621        }
622
623        /**
624         * @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
625         */
626        public MessageSourceComponent setVersionElement(StringType value) { 
627          this.version = value;
628          return this;
629        }
630
631        /**
632         * @return Can convey versions of multiple systems in situations where a message passes through multiple hands.
633         */
634        public String getVersion() { 
635          return this.version == null ? null : this.version.getValue();
636        }
637
638        /**
639         * @param value Can convey versions of multiple systems in situations where a message passes through multiple hands.
640         */
641        public MessageSourceComponent setVersion(String value) { 
642          if (Utilities.noString(value))
643            this.version = null;
644          else {
645            if (this.version == null)
646              this.version = new StringType();
647            this.version.setValue(value);
648          }
649          return this;
650        }
651
652        /**
653         * @return {@link #contact} (An e-mail, phone, website or other contact point to use to resolve issues with message communications.)
654         */
655        public ContactPoint getContact() { 
656          if (this.contact == null)
657            if (Configuration.errorOnAutoCreate())
658              throw new Error("Attempt to auto-create MessageSourceComponent.contact");
659            else if (Configuration.doAutoCreate())
660              this.contact = new ContactPoint(); // cc
661          return this.contact;
662        }
663
664        public boolean hasContact() { 
665          return this.contact != null && !this.contact.isEmpty();
666        }
667
668        /**
669         * @param value {@link #contact} (An e-mail, phone, website or other contact point to use to resolve issues with message communications.)
670         */
671        public MessageSourceComponent setContact(ContactPoint value) { 
672          this.contact = value;
673          return this;
674        }
675
676        /**
677         * @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
678         */
679        public UriType getEndpointElement() { 
680          if (this.endpoint == null)
681            if (Configuration.errorOnAutoCreate())
682              throw new Error("Attempt to auto-create MessageSourceComponent.endpoint");
683            else if (Configuration.doAutoCreate())
684              this.endpoint = new UriType(); // bb
685          return this.endpoint;
686        }
687
688        public boolean hasEndpointElement() { 
689          return this.endpoint != null && !this.endpoint.isEmpty();
690        }
691
692        public boolean hasEndpoint() { 
693          return this.endpoint != null && !this.endpoint.isEmpty();
694        }
695
696        /**
697         * @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
698         */
699        public MessageSourceComponent setEndpointElement(UriType value) { 
700          this.endpoint = value;
701          return this;
702        }
703
704        /**
705         * @return Identifies the routing target to send acknowledgements to.
706         */
707        public String getEndpoint() { 
708          return this.endpoint == null ? null : this.endpoint.getValue();
709        }
710
711        /**
712         * @param value Identifies the routing target to send acknowledgements to.
713         */
714        public MessageSourceComponent setEndpoint(String value) { 
715            if (this.endpoint == null)
716              this.endpoint = new UriType();
717            this.endpoint.setValue(value);
718          return this;
719        }
720
721        protected void listChildren(List<Property> childrenList) {
722          super.listChildren(childrenList);
723          childrenList.add(new Property("name", "string", "Human-readable name for the source system.", 0, java.lang.Integer.MAX_VALUE, name));
724          childrenList.add(new Property("software", "string", "May include configuration or other information useful in debugging.", 0, java.lang.Integer.MAX_VALUE, software));
725          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));
726          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));
727          childrenList.add(new Property("endpoint", "uri", "Identifies the routing target to send acknowledgements to.", 0, java.lang.Integer.MAX_VALUE, endpoint));
728        }
729
730      @Override
731      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
732        switch (hash) {
733        case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // StringType
734        case 1319330215: /*software*/ return this.software == null ? new Base[0] : new Base[] {this.software}; // StringType
735        case 351608024: /*version*/ return this.version == null ? new Base[0] : new Base[] {this.version}; // StringType
736        case 951526432: /*contact*/ return this.contact == null ? new Base[0] : new Base[] {this.contact}; // ContactPoint
737        case 1741102485: /*endpoint*/ return this.endpoint == null ? new Base[0] : new Base[] {this.endpoint}; // UriType
738        default: return super.getProperty(hash, name, checkValid);
739        }
740
741      }
742
743      @Override
744      public void setProperty(int hash, String name, Base value) throws FHIRException {
745        switch (hash) {
746        case 3373707: // name
747          this.name = castToString(value); // StringType
748          break;
749        case 1319330215: // software
750          this.software = castToString(value); // StringType
751          break;
752        case 351608024: // version
753          this.version = castToString(value); // StringType
754          break;
755        case 951526432: // contact
756          this.contact = castToContactPoint(value); // ContactPoint
757          break;
758        case 1741102485: // endpoint
759          this.endpoint = castToUri(value); // UriType
760          break;
761        default: super.setProperty(hash, name, value);
762        }
763
764      }
765
766      @Override
767      public void setProperty(String name, Base value) throws FHIRException {
768        if (name.equals("name"))
769          this.name = castToString(value); // StringType
770        else if (name.equals("software"))
771          this.software = castToString(value); // StringType
772        else if (name.equals("version"))
773          this.version = castToString(value); // StringType
774        else if (name.equals("contact"))
775          this.contact = castToContactPoint(value); // ContactPoint
776        else if (name.equals("endpoint"))
777          this.endpoint = castToUri(value); // UriType
778        else
779          super.setProperty(name, value);
780      }
781
782      @Override
783      public Base makeProperty(int hash, String name) throws FHIRException {
784        switch (hash) {
785        case 3373707: throw new FHIRException("Cannot make property name as it is not a complex type"); // StringType
786        case 1319330215: throw new FHIRException("Cannot make property software as it is not a complex type"); // StringType
787        case 351608024: throw new FHIRException("Cannot make property version as it is not a complex type"); // StringType
788        case 951526432:  return getContact(); // ContactPoint
789        case 1741102485: throw new FHIRException("Cannot make property endpoint as it is not a complex type"); // UriType
790        default: return super.makeProperty(hash, name);
791        }
792
793      }
794
795      @Override
796      public Base addChild(String name) throws FHIRException {
797        if (name.equals("name")) {
798          throw new FHIRException("Cannot call addChild on a primitive type MessageHeader.name");
799        }
800        else if (name.equals("software")) {
801          throw new FHIRException("Cannot call addChild on a primitive type MessageHeader.software");
802        }
803        else if (name.equals("version")) {
804          throw new FHIRException("Cannot call addChild on a primitive type MessageHeader.version");
805        }
806        else if (name.equals("contact")) {
807          this.contact = new ContactPoint();
808          return this.contact;
809        }
810        else if (name.equals("endpoint")) {
811          throw new FHIRException("Cannot call addChild on a primitive type MessageHeader.endpoint");
812        }
813        else
814          return super.addChild(name);
815      }
816
817      public MessageSourceComponent copy() {
818        MessageSourceComponent dst = new MessageSourceComponent();
819        copyValues(dst);
820        dst.name = name == null ? null : name.copy();
821        dst.software = software == null ? null : software.copy();
822        dst.version = version == null ? null : version.copy();
823        dst.contact = contact == null ? null : contact.copy();
824        dst.endpoint = endpoint == null ? null : endpoint.copy();
825        return dst;
826      }
827
828      @Override
829      public boolean equalsDeep(Base other) {
830        if (!super.equalsDeep(other))
831          return false;
832        if (!(other instanceof MessageSourceComponent))
833          return false;
834        MessageSourceComponent o = (MessageSourceComponent) other;
835        return compareDeep(name, o.name, true) && compareDeep(software, o.software, true) && compareDeep(version, o.version, true)
836           && compareDeep(contact, o.contact, true) && compareDeep(endpoint, o.endpoint, true);
837      }
838
839      @Override
840      public boolean equalsShallow(Base other) {
841        if (!super.equalsShallow(other))
842          return false;
843        if (!(other instanceof MessageSourceComponent))
844          return false;
845        MessageSourceComponent o = (MessageSourceComponent) other;
846        return compareValues(name, o.name, true) && compareValues(software, o.software, true) && compareValues(version, o.version, true)
847           && compareValues(endpoint, o.endpoint, true);
848      }
849
850      public boolean isEmpty() {
851        return super.isEmpty() && (name == null || name.isEmpty()) && (software == null || software.isEmpty())
852           && (version == null || version.isEmpty()) && (contact == null || contact.isEmpty()) && (endpoint == null || endpoint.isEmpty())
853          ;
854      }
855
856  public String fhirType() {
857    return "MessageHeader.source";
858
859  }
860
861  }
862
863    @Block()
864    public static class MessageDestinationComponent extends BackboneElement implements IBaseBackboneElement {
865        /**
866         * Human-readable name for the target system.
867         */
868        @Child(name = "name", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
869        @Description(shortDefinition="Name of system", formalDefinition="Human-readable name for the target system." )
870        protected StringType name;
871
872        /**
873         * Identifies the target end system in situations where the initial message transmission is to an intermediary system.
874         */
875        @Child(name = "target", type = {Device.class}, order=2, min=0, max=1, modifier=false, summary=true)
876        @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." )
877        protected Reference target;
878
879        /**
880         * 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.)
881         */
882        protected Device targetTarget;
883
884        /**
885         * Indicates where the message should be routed to.
886         */
887        @Child(name = "endpoint", type = {UriType.class}, order=3, min=1, max=1, modifier=false, summary=true)
888        @Description(shortDefinition="Actual destination address or id", formalDefinition="Indicates where the message should be routed to." )
889        protected UriType endpoint;
890
891        private static final long serialVersionUID = -2097633309L;
892
893    /**
894     * Constructor
895     */
896      public MessageDestinationComponent() {
897        super();
898      }
899
900    /**
901     * Constructor
902     */
903      public MessageDestinationComponent(UriType endpoint) {
904        super();
905        this.endpoint = endpoint;
906      }
907
908        /**
909         * @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
910         */
911        public StringType getNameElement() { 
912          if (this.name == null)
913            if (Configuration.errorOnAutoCreate())
914              throw new Error("Attempt to auto-create MessageDestinationComponent.name");
915            else if (Configuration.doAutoCreate())
916              this.name = new StringType(); // bb
917          return this.name;
918        }
919
920        public boolean hasNameElement() { 
921          return this.name != null && !this.name.isEmpty();
922        }
923
924        public boolean hasName() { 
925          return this.name != null && !this.name.isEmpty();
926        }
927
928        /**
929         * @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
930         */
931        public MessageDestinationComponent setNameElement(StringType value) { 
932          this.name = value;
933          return this;
934        }
935
936        /**
937         * @return Human-readable name for the target system.
938         */
939        public String getName() { 
940          return this.name == null ? null : this.name.getValue();
941        }
942
943        /**
944         * @param value Human-readable name for the target system.
945         */
946        public MessageDestinationComponent setName(String value) { 
947          if (Utilities.noString(value))
948            this.name = null;
949          else {
950            if (this.name == null)
951              this.name = new StringType();
952            this.name.setValue(value);
953          }
954          return this;
955        }
956
957        /**
958         * @return {@link #target} (Identifies the target end system in situations where the initial message transmission is to an intermediary system.)
959         */
960        public Reference getTarget() { 
961          if (this.target == null)
962            if (Configuration.errorOnAutoCreate())
963              throw new Error("Attempt to auto-create MessageDestinationComponent.target");
964            else if (Configuration.doAutoCreate())
965              this.target = new Reference(); // cc
966          return this.target;
967        }
968
969        public boolean hasTarget() { 
970          return this.target != null && !this.target.isEmpty();
971        }
972
973        /**
974         * @param value {@link #target} (Identifies the target end system in situations where the initial message transmission is to an intermediary system.)
975         */
976        public MessageDestinationComponent setTarget(Reference value) { 
977          this.target = value;
978          return this;
979        }
980
981        /**
982         * @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.)
983         */
984        public Device getTargetTarget() { 
985          if (this.targetTarget == null)
986            if (Configuration.errorOnAutoCreate())
987              throw new Error("Attempt to auto-create MessageDestinationComponent.target");
988            else if (Configuration.doAutoCreate())
989              this.targetTarget = new Device(); // aa
990          return this.targetTarget;
991        }
992
993        /**
994         * @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.)
995         */
996        public MessageDestinationComponent setTargetTarget(Device value) { 
997          this.targetTarget = value;
998          return this;
999        }
1000
1001        /**
1002         * @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
1003         */
1004        public UriType getEndpointElement() { 
1005          if (this.endpoint == null)
1006            if (Configuration.errorOnAutoCreate())
1007              throw new Error("Attempt to auto-create MessageDestinationComponent.endpoint");
1008            else if (Configuration.doAutoCreate())
1009              this.endpoint = new UriType(); // bb
1010          return this.endpoint;
1011        }
1012
1013        public boolean hasEndpointElement() { 
1014          return this.endpoint != null && !this.endpoint.isEmpty();
1015        }
1016
1017        public boolean hasEndpoint() { 
1018          return this.endpoint != null && !this.endpoint.isEmpty();
1019        }
1020
1021        /**
1022         * @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
1023         */
1024        public MessageDestinationComponent setEndpointElement(UriType value) { 
1025          this.endpoint = value;
1026          return this;
1027        }
1028
1029        /**
1030         * @return Indicates where the message should be routed to.
1031         */
1032        public String getEndpoint() { 
1033          return this.endpoint == null ? null : this.endpoint.getValue();
1034        }
1035
1036        /**
1037         * @param value Indicates where the message should be routed to.
1038         */
1039        public MessageDestinationComponent setEndpoint(String value) { 
1040            if (this.endpoint == null)
1041              this.endpoint = new UriType();
1042            this.endpoint.setValue(value);
1043          return this;
1044        }
1045
1046        protected void listChildren(List<Property> childrenList) {
1047          super.listChildren(childrenList);
1048          childrenList.add(new Property("name", "string", "Human-readable name for the target system.", 0, java.lang.Integer.MAX_VALUE, name));
1049          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));
1050          childrenList.add(new Property("endpoint", "uri", "Indicates where the message should be routed to.", 0, java.lang.Integer.MAX_VALUE, endpoint));
1051        }
1052
1053      @Override
1054      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1055        switch (hash) {
1056        case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // StringType
1057        case -880905839: /*target*/ return this.target == null ? new Base[0] : new Base[] {this.target}; // Reference
1058        case 1741102485: /*endpoint*/ return this.endpoint == null ? new Base[0] : new Base[] {this.endpoint}; // UriType
1059        default: return super.getProperty(hash, name, checkValid);
1060        }
1061
1062      }
1063
1064      @Override
1065      public void setProperty(int hash, String name, Base value) throws FHIRException {
1066        switch (hash) {
1067        case 3373707: // name
1068          this.name = castToString(value); // StringType
1069          break;
1070        case -880905839: // target
1071          this.target = castToReference(value); // Reference
1072          break;
1073        case 1741102485: // endpoint
1074          this.endpoint = castToUri(value); // UriType
1075          break;
1076        default: super.setProperty(hash, name, value);
1077        }
1078
1079      }
1080
1081      @Override
1082      public void setProperty(String name, Base value) throws FHIRException {
1083        if (name.equals("name"))
1084          this.name = castToString(value); // StringType
1085        else if (name.equals("target"))
1086          this.target = castToReference(value); // Reference
1087        else if (name.equals("endpoint"))
1088          this.endpoint = castToUri(value); // UriType
1089        else
1090          super.setProperty(name, value);
1091      }
1092
1093      @Override
1094      public Base makeProperty(int hash, String name) throws FHIRException {
1095        switch (hash) {
1096        case 3373707: throw new FHIRException("Cannot make property name as it is not a complex type"); // StringType
1097        case -880905839:  return getTarget(); // Reference
1098        case 1741102485: throw new FHIRException("Cannot make property endpoint as it is not a complex type"); // UriType
1099        default: return super.makeProperty(hash, name);
1100        }
1101
1102      }
1103
1104      @Override
1105      public Base addChild(String name) throws FHIRException {
1106        if (name.equals("name")) {
1107          throw new FHIRException("Cannot call addChild on a primitive type MessageHeader.name");
1108        }
1109        else if (name.equals("target")) {
1110          this.target = new Reference();
1111          return this.target;
1112        }
1113        else if (name.equals("endpoint")) {
1114          throw new FHIRException("Cannot call addChild on a primitive type MessageHeader.endpoint");
1115        }
1116        else
1117          return super.addChild(name);
1118      }
1119
1120      public MessageDestinationComponent copy() {
1121        MessageDestinationComponent dst = new MessageDestinationComponent();
1122        copyValues(dst);
1123        dst.name = name == null ? null : name.copy();
1124        dst.target = target == null ? null : target.copy();
1125        dst.endpoint = endpoint == null ? null : endpoint.copy();
1126        return dst;
1127      }
1128
1129      @Override
1130      public boolean equalsDeep(Base other) {
1131        if (!super.equalsDeep(other))
1132          return false;
1133        if (!(other instanceof MessageDestinationComponent))
1134          return false;
1135        MessageDestinationComponent o = (MessageDestinationComponent) other;
1136        return compareDeep(name, o.name, true) && compareDeep(target, o.target, true) && compareDeep(endpoint, o.endpoint, true)
1137          ;
1138      }
1139
1140      @Override
1141      public boolean equalsShallow(Base other) {
1142        if (!super.equalsShallow(other))
1143          return false;
1144        if (!(other instanceof MessageDestinationComponent))
1145          return false;
1146        MessageDestinationComponent o = (MessageDestinationComponent) other;
1147        return compareValues(name, o.name, true) && compareValues(endpoint, o.endpoint, true);
1148      }
1149
1150      public boolean isEmpty() {
1151        return super.isEmpty() && (name == null || name.isEmpty()) && (target == null || target.isEmpty())
1152           && (endpoint == null || endpoint.isEmpty());
1153      }
1154
1155  public String fhirType() {
1156    return "MessageHeader.destination";
1157
1158  }
1159
1160  }
1161
1162    /**
1163     * The time that the message was sent.
1164     */
1165    @Child(name = "timestamp", type = {InstantType.class}, order=0, min=1, max=1, modifier=false, summary=true)
1166    @Description(shortDefinition="Time that the message was sent", formalDefinition="The time that the message was sent." )
1167    protected InstantType timestamp;
1168
1169    /**
1170     * 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".
1171     */
1172    @Child(name = "event", type = {Coding.class}, order=1, min=1, max=1, modifier=true, summary=true)
1173    @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\"." )
1174    protected Coding event;
1175
1176    /**
1177     * Information about the message that this message is a response to.  Only present if this message is a response.
1178     */
1179    @Child(name = "response", type = {}, order=2, min=0, max=1, modifier=true, summary=true)
1180    @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." )
1181    protected MessageHeaderResponseComponent response;
1182
1183    /**
1184     * The source application from which this message originated.
1185     */
1186    @Child(name = "source", type = {}, order=3, min=1, max=1, modifier=false, summary=true)
1187    @Description(shortDefinition="Message Source Application", formalDefinition="The source application from which this message originated." )
1188    protected MessageSourceComponent source;
1189
1190    /**
1191     * The destination application which the message is intended for.
1192     */
1193    @Child(name = "destination", type = {}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1194    @Description(shortDefinition="Message Destination Application(s)", formalDefinition="The destination application which the message is intended for." )
1195    protected List<MessageDestinationComponent> destination;
1196
1197    /**
1198     * 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.
1199     */
1200    @Child(name = "enterer", type = {Practitioner.class}, order=5, min=0, max=1, modifier=false, summary=true)
1201    @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." )
1202    protected Reference enterer;
1203
1204    /**
1205     * 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.)
1206     */
1207    protected Practitioner entererTarget;
1208
1209    /**
1210     * 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.
1211     */
1212    @Child(name = "author", type = {Practitioner.class}, order=6, min=0, max=1, modifier=false, summary=true)
1213    @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." )
1214    protected Reference author;
1215
1216    /**
1217     * 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.)
1218     */
1219    protected Practitioner authorTarget;
1220
1221    /**
1222     * Allows data conveyed by a message to be addressed to a particular person or department when routing to a specific application isn't sufficient.
1223     */
1224    @Child(name = "receiver", type = {Practitioner.class, Organization.class}, order=7, min=0, max=1, modifier=false, summary=true)
1225    @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." )
1226    protected Reference receiver;
1227
1228    /**
1229     * 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.)
1230     */
1231    protected Resource receiverTarget;
1232
1233    /**
1234     * 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.
1235     */
1236    @Child(name = "responsible", type = {Practitioner.class, Organization.class}, order=8, min=0, max=1, modifier=false, summary=true)
1237    @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." )
1238    protected Reference responsible;
1239
1240    /**
1241     * 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.)
1242     */
1243    protected Resource responsibleTarget;
1244
1245    /**
1246     * Coded indication of the cause for the event - indicates  a reason for the occurrence of the event that is a focus of this message.
1247     */
1248    @Child(name = "reason", type = {CodeableConcept.class}, order=9, min=0, max=1, modifier=false, summary=true)
1249    @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." )
1250    protected CodeableConcept reason;
1251
1252    /**
1253     * The actual data of the message - a reference to the root/focus class of the event.
1254     */
1255    @Child(name = "data", type = {}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1256    @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." )
1257    protected List<Reference> data;
1258    /**
1259     * 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.)
1260     */
1261    protected List<Resource> dataTarget;
1262
1263
1264    private static final long serialVersionUID = 1429728517L;
1265
1266  /**
1267   * Constructor
1268   */
1269    public MessageHeader() {
1270      super();
1271    }
1272
1273  /**
1274   * Constructor
1275   */
1276    public MessageHeader(InstantType timestamp, Coding event, MessageSourceComponent source) {
1277      super();
1278      this.timestamp = timestamp;
1279      this.event = event;
1280      this.source = source;
1281    }
1282
1283    /**
1284     * @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
1285     */
1286    public InstantType getTimestampElement() { 
1287      if (this.timestamp == null)
1288        if (Configuration.errorOnAutoCreate())
1289          throw new Error("Attempt to auto-create MessageHeader.timestamp");
1290        else if (Configuration.doAutoCreate())
1291          this.timestamp = new InstantType(); // bb
1292      return this.timestamp;
1293    }
1294
1295    public boolean hasTimestampElement() { 
1296      return this.timestamp != null && !this.timestamp.isEmpty();
1297    }
1298
1299    public boolean hasTimestamp() { 
1300      return this.timestamp != null && !this.timestamp.isEmpty();
1301    }
1302
1303    /**
1304     * @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
1305     */
1306    public MessageHeader setTimestampElement(InstantType value) { 
1307      this.timestamp = value;
1308      return this;
1309    }
1310
1311    /**
1312     * @return The time that the message was sent.
1313     */
1314    public Date getTimestamp() { 
1315      return this.timestamp == null ? null : this.timestamp.getValue();
1316    }
1317
1318    /**
1319     * @param value The time that the message was sent.
1320     */
1321    public MessageHeader setTimestamp(Date value) { 
1322        if (this.timestamp == null)
1323          this.timestamp = new InstantType();
1324        this.timestamp.setValue(value);
1325      return this;
1326    }
1327
1328    /**
1329     * @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".)
1330     */
1331    public Coding getEvent() { 
1332      if (this.event == null)
1333        if (Configuration.errorOnAutoCreate())
1334          throw new Error("Attempt to auto-create MessageHeader.event");
1335        else if (Configuration.doAutoCreate())
1336          this.event = new Coding(); // cc
1337      return this.event;
1338    }
1339
1340    public boolean hasEvent() { 
1341      return this.event != null && !this.event.isEmpty();
1342    }
1343
1344    /**
1345     * @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".)
1346     */
1347    public MessageHeader setEvent(Coding value) { 
1348      this.event = value;
1349      return this;
1350    }
1351
1352    /**
1353     * @return {@link #response} (Information about the message that this message is a response to.  Only present if this message is a response.)
1354     */
1355    public MessageHeaderResponseComponent getResponse() { 
1356      if (this.response == null)
1357        if (Configuration.errorOnAutoCreate())
1358          throw new Error("Attempt to auto-create MessageHeader.response");
1359        else if (Configuration.doAutoCreate())
1360          this.response = new MessageHeaderResponseComponent(); // cc
1361      return this.response;
1362    }
1363
1364    public boolean hasResponse() { 
1365      return this.response != null && !this.response.isEmpty();
1366    }
1367
1368    /**
1369     * @param value {@link #response} (Information about the message that this message is a response to.  Only present if this message is a response.)
1370     */
1371    public MessageHeader setResponse(MessageHeaderResponseComponent value) { 
1372      this.response = value;
1373      return this;
1374    }
1375
1376    /**
1377     * @return {@link #source} (The source application from which this message originated.)
1378     */
1379    public MessageSourceComponent getSource() { 
1380      if (this.source == null)
1381        if (Configuration.errorOnAutoCreate())
1382          throw new Error("Attempt to auto-create MessageHeader.source");
1383        else if (Configuration.doAutoCreate())
1384          this.source = new MessageSourceComponent(); // cc
1385      return this.source;
1386    }
1387
1388    public boolean hasSource() { 
1389      return this.source != null && !this.source.isEmpty();
1390    }
1391
1392    /**
1393     * @param value {@link #source} (The source application from which this message originated.)
1394     */
1395    public MessageHeader setSource(MessageSourceComponent value) { 
1396      this.source = value;
1397      return this;
1398    }
1399
1400    /**
1401     * @return {@link #destination} (The destination application which the message is intended for.)
1402     */
1403    public List<MessageDestinationComponent> getDestination() { 
1404      if (this.destination == null)
1405        this.destination = new ArrayList<MessageDestinationComponent>();
1406      return this.destination;
1407    }
1408
1409    public boolean hasDestination() { 
1410      if (this.destination == null)
1411        return false;
1412      for (MessageDestinationComponent item : this.destination)
1413        if (!item.isEmpty())
1414          return true;
1415      return false;
1416    }
1417
1418    /**
1419     * @return {@link #destination} (The destination application which the message is intended for.)
1420     */
1421    // syntactic sugar
1422    public MessageDestinationComponent addDestination() { //3
1423      MessageDestinationComponent t = new MessageDestinationComponent();
1424      if (this.destination == null)
1425        this.destination = new ArrayList<MessageDestinationComponent>();
1426      this.destination.add(t);
1427      return t;
1428    }
1429
1430    // syntactic sugar
1431    public MessageHeader addDestination(MessageDestinationComponent t) { //3
1432      if (t == null)
1433        return this;
1434      if (this.destination == null)
1435        this.destination = new ArrayList<MessageDestinationComponent>();
1436      this.destination.add(t);
1437      return this;
1438    }
1439
1440    /**
1441     * @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.)
1442     */
1443    public Reference getEnterer() { 
1444      if (this.enterer == null)
1445        if (Configuration.errorOnAutoCreate())
1446          throw new Error("Attempt to auto-create MessageHeader.enterer");
1447        else if (Configuration.doAutoCreate())
1448          this.enterer = new Reference(); // cc
1449      return this.enterer;
1450    }
1451
1452    public boolean hasEnterer() { 
1453      return this.enterer != null && !this.enterer.isEmpty();
1454    }
1455
1456    /**
1457     * @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.)
1458     */
1459    public MessageHeader setEnterer(Reference value) { 
1460      this.enterer = value;
1461      return this;
1462    }
1463
1464    /**
1465     * @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.)
1466     */
1467    public Practitioner getEntererTarget() { 
1468      if (this.entererTarget == null)
1469        if (Configuration.errorOnAutoCreate())
1470          throw new Error("Attempt to auto-create MessageHeader.enterer");
1471        else if (Configuration.doAutoCreate())
1472          this.entererTarget = new Practitioner(); // aa
1473      return this.entererTarget;
1474    }
1475
1476    /**
1477     * @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.)
1478     */
1479    public MessageHeader setEntererTarget(Practitioner value) { 
1480      this.entererTarget = value;
1481      return this;
1482    }
1483
1484    /**
1485     * @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.)
1486     */
1487    public Reference getAuthor() { 
1488      if (this.author == null)
1489        if (Configuration.errorOnAutoCreate())
1490          throw new Error("Attempt to auto-create MessageHeader.author");
1491        else if (Configuration.doAutoCreate())
1492          this.author = new Reference(); // cc
1493      return this.author;
1494    }
1495
1496    public boolean hasAuthor() { 
1497      return this.author != null && !this.author.isEmpty();
1498    }
1499
1500    /**
1501     * @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.)
1502     */
1503    public MessageHeader setAuthor(Reference value) { 
1504      this.author = value;
1505      return this;
1506    }
1507
1508    /**
1509     * @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.)
1510     */
1511    public Practitioner getAuthorTarget() { 
1512      if (this.authorTarget == null)
1513        if (Configuration.errorOnAutoCreate())
1514          throw new Error("Attempt to auto-create MessageHeader.author");
1515        else if (Configuration.doAutoCreate())
1516          this.authorTarget = new Practitioner(); // aa
1517      return this.authorTarget;
1518    }
1519
1520    /**
1521     * @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.)
1522     */
1523    public MessageHeader setAuthorTarget(Practitioner value) { 
1524      this.authorTarget = value;
1525      return this;
1526    }
1527
1528    /**
1529     * @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.)
1530     */
1531    public Reference getReceiver() { 
1532      if (this.receiver == null)
1533        if (Configuration.errorOnAutoCreate())
1534          throw new Error("Attempt to auto-create MessageHeader.receiver");
1535        else if (Configuration.doAutoCreate())
1536          this.receiver = new Reference(); // cc
1537      return this.receiver;
1538    }
1539
1540    public boolean hasReceiver() { 
1541      return this.receiver != null && !this.receiver.isEmpty();
1542    }
1543
1544    /**
1545     * @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.)
1546     */
1547    public MessageHeader setReceiver(Reference value) { 
1548      this.receiver = value;
1549      return this;
1550    }
1551
1552    /**
1553     * @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.)
1554     */
1555    public Resource getReceiverTarget() { 
1556      return this.receiverTarget;
1557    }
1558
1559    /**
1560     * @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.)
1561     */
1562    public MessageHeader setReceiverTarget(Resource value) { 
1563      this.receiverTarget = value;
1564      return this;
1565    }
1566
1567    /**
1568     * @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.)
1569     */
1570    public Reference getResponsible() { 
1571      if (this.responsible == null)
1572        if (Configuration.errorOnAutoCreate())
1573          throw new Error("Attempt to auto-create MessageHeader.responsible");
1574        else if (Configuration.doAutoCreate())
1575          this.responsible = new Reference(); // cc
1576      return this.responsible;
1577    }
1578
1579    public boolean hasResponsible() { 
1580      return this.responsible != null && !this.responsible.isEmpty();
1581    }
1582
1583    /**
1584     * @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.)
1585     */
1586    public MessageHeader setResponsible(Reference value) { 
1587      this.responsible = value;
1588      return this;
1589    }
1590
1591    /**
1592     * @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.)
1593     */
1594    public Resource getResponsibleTarget() { 
1595      return this.responsibleTarget;
1596    }
1597
1598    /**
1599     * @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.)
1600     */
1601    public MessageHeader setResponsibleTarget(Resource value) { 
1602      this.responsibleTarget = value;
1603      return this;
1604    }
1605
1606    /**
1607     * @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.)
1608     */
1609    public CodeableConcept getReason() { 
1610      if (this.reason == null)
1611        if (Configuration.errorOnAutoCreate())
1612          throw new Error("Attempt to auto-create MessageHeader.reason");
1613        else if (Configuration.doAutoCreate())
1614          this.reason = new CodeableConcept(); // cc
1615      return this.reason;
1616    }
1617
1618    public boolean hasReason() { 
1619      return this.reason != null && !this.reason.isEmpty();
1620    }
1621
1622    /**
1623     * @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.)
1624     */
1625    public MessageHeader setReason(CodeableConcept value) { 
1626      this.reason = value;
1627      return this;
1628    }
1629
1630    /**
1631     * @return {@link #data} (The actual data of the message - a reference to the root/focus class of the event.)
1632     */
1633    public List<Reference> getData() { 
1634      if (this.data == null)
1635        this.data = new ArrayList<Reference>();
1636      return this.data;
1637    }
1638
1639    public boolean hasData() { 
1640      if (this.data == null)
1641        return false;
1642      for (Reference item : this.data)
1643        if (!item.isEmpty())
1644          return true;
1645      return false;
1646    }
1647
1648    /**
1649     * @return {@link #data} (The actual data of the message - a reference to the root/focus class of the event.)
1650     */
1651    // syntactic sugar
1652    public Reference addData() { //3
1653      Reference t = new Reference();
1654      if (this.data == null)
1655        this.data = new ArrayList<Reference>();
1656      this.data.add(t);
1657      return t;
1658    }
1659
1660    // syntactic sugar
1661    public MessageHeader addData(Reference t) { //3
1662      if (t == null)
1663        return this;
1664      if (this.data == null)
1665        this.data = new ArrayList<Reference>();
1666      this.data.add(t);
1667      return this;
1668    }
1669
1670    /**
1671     * @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.)
1672     */
1673    public List<Resource> getDataTarget() { 
1674      if (this.dataTarget == null)
1675        this.dataTarget = new ArrayList<Resource>();
1676      return this.dataTarget;
1677    }
1678
1679      protected void listChildren(List<Property> childrenList) {
1680        super.listChildren(childrenList);
1681        childrenList.add(new Property("timestamp", "instant", "The time that the message was sent.", 0, java.lang.Integer.MAX_VALUE, timestamp));
1682        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));
1683        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));
1684        childrenList.add(new Property("source", "", "The source application from which this message originated.", 0, java.lang.Integer.MAX_VALUE, source));
1685        childrenList.add(new Property("destination", "", "The destination application which the message is intended for.", 0, java.lang.Integer.MAX_VALUE, destination));
1686        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));
1687        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));
1688        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));
1689        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));
1690        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));
1691        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));
1692      }
1693
1694      @Override
1695      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1696        switch (hash) {
1697        case 55126294: /*timestamp*/ return this.timestamp == null ? new Base[0] : new Base[] {this.timestamp}; // InstantType
1698        case 96891546: /*event*/ return this.event == null ? new Base[0] : new Base[] {this.event}; // Coding
1699        case -340323263: /*response*/ return this.response == null ? new Base[0] : new Base[] {this.response}; // MessageHeaderResponseComponent
1700        case -896505829: /*source*/ return this.source == null ? new Base[0] : new Base[] {this.source}; // MessageSourceComponent
1701        case -1429847026: /*destination*/ return this.destination == null ? new Base[0] : this.destination.toArray(new Base[this.destination.size()]); // MessageDestinationComponent
1702        case -1591951995: /*enterer*/ return this.enterer == null ? new Base[0] : new Base[] {this.enterer}; // Reference
1703        case -1406328437: /*author*/ return this.author == null ? new Base[0] : new Base[] {this.author}; // Reference
1704        case -808719889: /*receiver*/ return this.receiver == null ? new Base[0] : new Base[] {this.receiver}; // Reference
1705        case 1847674614: /*responsible*/ return this.responsible == null ? new Base[0] : new Base[] {this.responsible}; // Reference
1706        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : new Base[] {this.reason}; // CodeableConcept
1707        case 3076010: /*data*/ return this.data == null ? new Base[0] : this.data.toArray(new Base[this.data.size()]); // Reference
1708        default: return super.getProperty(hash, name, checkValid);
1709        }
1710
1711      }
1712
1713      @Override
1714      public void setProperty(int hash, String name, Base value) throws FHIRException {
1715        switch (hash) {
1716        case 55126294: // timestamp
1717          this.timestamp = castToInstant(value); // InstantType
1718          break;
1719        case 96891546: // event
1720          this.event = castToCoding(value); // Coding
1721          break;
1722        case -340323263: // response
1723          this.response = (MessageHeaderResponseComponent) value; // MessageHeaderResponseComponent
1724          break;
1725        case -896505829: // source
1726          this.source = (MessageSourceComponent) value; // MessageSourceComponent
1727          break;
1728        case -1429847026: // destination
1729          this.getDestination().add((MessageDestinationComponent) value); // MessageDestinationComponent
1730          break;
1731        case -1591951995: // enterer
1732          this.enterer = castToReference(value); // Reference
1733          break;
1734        case -1406328437: // author
1735          this.author = castToReference(value); // Reference
1736          break;
1737        case -808719889: // receiver
1738          this.receiver = castToReference(value); // Reference
1739          break;
1740        case 1847674614: // responsible
1741          this.responsible = castToReference(value); // Reference
1742          break;
1743        case -934964668: // reason
1744          this.reason = castToCodeableConcept(value); // CodeableConcept
1745          break;
1746        case 3076010: // data
1747          this.getData().add(castToReference(value)); // Reference
1748          break;
1749        default: super.setProperty(hash, name, value);
1750        }
1751
1752      }
1753
1754      @Override
1755      public void setProperty(String name, Base value) throws FHIRException {
1756        if (name.equals("timestamp"))
1757          this.timestamp = castToInstant(value); // InstantType
1758        else if (name.equals("event"))
1759          this.event = castToCoding(value); // Coding
1760        else if (name.equals("response"))
1761          this.response = (MessageHeaderResponseComponent) value; // MessageHeaderResponseComponent
1762        else if (name.equals("source"))
1763          this.source = (MessageSourceComponent) value; // MessageSourceComponent
1764        else if (name.equals("destination"))
1765          this.getDestination().add((MessageDestinationComponent) value);
1766        else if (name.equals("enterer"))
1767          this.enterer = castToReference(value); // Reference
1768        else if (name.equals("author"))
1769          this.author = castToReference(value); // Reference
1770        else if (name.equals("receiver"))
1771          this.receiver = castToReference(value); // Reference
1772        else if (name.equals("responsible"))
1773          this.responsible = castToReference(value); // Reference
1774        else if (name.equals("reason"))
1775          this.reason = castToCodeableConcept(value); // CodeableConcept
1776        else if (name.equals("data"))
1777          this.getData().add(castToReference(value));
1778        else
1779          super.setProperty(name, value);
1780      }
1781
1782      @Override
1783      public Base makeProperty(int hash, String name) throws FHIRException {
1784        switch (hash) {
1785        case 55126294: throw new FHIRException("Cannot make property timestamp as it is not a complex type"); // InstantType
1786        case 96891546:  return getEvent(); // Coding
1787        case -340323263:  return getResponse(); // MessageHeaderResponseComponent
1788        case -896505829:  return getSource(); // MessageSourceComponent
1789        case -1429847026:  return addDestination(); // MessageDestinationComponent
1790        case -1591951995:  return getEnterer(); // Reference
1791        case -1406328437:  return getAuthor(); // Reference
1792        case -808719889:  return getReceiver(); // Reference
1793        case 1847674614:  return getResponsible(); // Reference
1794        case -934964668:  return getReason(); // CodeableConcept
1795        case 3076010:  return addData(); // Reference
1796        default: return super.makeProperty(hash, name);
1797        }
1798
1799      }
1800
1801      @Override
1802      public Base addChild(String name) throws FHIRException {
1803        if (name.equals("timestamp")) {
1804          throw new FHIRException("Cannot call addChild on a primitive type MessageHeader.timestamp");
1805        }
1806        else if (name.equals("event")) {
1807          this.event = new Coding();
1808          return this.event;
1809        }
1810        else if (name.equals("response")) {
1811          this.response = new MessageHeaderResponseComponent();
1812          return this.response;
1813        }
1814        else if (name.equals("source")) {
1815          this.source = new MessageSourceComponent();
1816          return this.source;
1817        }
1818        else if (name.equals("destination")) {
1819          return addDestination();
1820        }
1821        else if (name.equals("enterer")) {
1822          this.enterer = new Reference();
1823          return this.enterer;
1824        }
1825        else if (name.equals("author")) {
1826          this.author = new Reference();
1827          return this.author;
1828        }
1829        else if (name.equals("receiver")) {
1830          this.receiver = new Reference();
1831          return this.receiver;
1832        }
1833        else if (name.equals("responsible")) {
1834          this.responsible = new Reference();
1835          return this.responsible;
1836        }
1837        else if (name.equals("reason")) {
1838          this.reason = new CodeableConcept();
1839          return this.reason;
1840        }
1841        else if (name.equals("data")) {
1842          return addData();
1843        }
1844        else
1845          return super.addChild(name);
1846      }
1847
1848  public String fhirType() {
1849    return "MessageHeader";
1850
1851  }
1852
1853      public MessageHeader copy() {
1854        MessageHeader dst = new MessageHeader();
1855        copyValues(dst);
1856        dst.timestamp = timestamp == null ? null : timestamp.copy();
1857        dst.event = event == null ? null : event.copy();
1858        dst.response = response == null ? null : response.copy();
1859        dst.source = source == null ? null : source.copy();
1860        if (destination != null) {
1861          dst.destination = new ArrayList<MessageDestinationComponent>();
1862          for (MessageDestinationComponent i : destination)
1863            dst.destination.add(i.copy());
1864        };
1865        dst.enterer = enterer == null ? null : enterer.copy();
1866        dst.author = author == null ? null : author.copy();
1867        dst.receiver = receiver == null ? null : receiver.copy();
1868        dst.responsible = responsible == null ? null : responsible.copy();
1869        dst.reason = reason == null ? null : reason.copy();
1870        if (data != null) {
1871          dst.data = new ArrayList<Reference>();
1872          for (Reference i : data)
1873            dst.data.add(i.copy());
1874        };
1875        return dst;
1876      }
1877
1878      protected MessageHeader typedCopy() {
1879        return copy();
1880      }
1881
1882      @Override
1883      public boolean equalsDeep(Base other) {
1884        if (!super.equalsDeep(other))
1885          return false;
1886        if (!(other instanceof MessageHeader))
1887          return false;
1888        MessageHeader o = (MessageHeader) other;
1889        return compareDeep(timestamp, o.timestamp, true) && compareDeep(event, o.event, true) && compareDeep(response, o.response, true)
1890           && compareDeep(source, o.source, true) && compareDeep(destination, o.destination, true) && compareDeep(enterer, o.enterer, true)
1891           && compareDeep(author, o.author, true) && compareDeep(receiver, o.receiver, true) && compareDeep(responsible, o.responsible, true)
1892           && compareDeep(reason, o.reason, true) && compareDeep(data, o.data, true);
1893      }
1894
1895      @Override
1896      public boolean equalsShallow(Base other) {
1897        if (!super.equalsShallow(other))
1898          return false;
1899        if (!(other instanceof MessageHeader))
1900          return false;
1901        MessageHeader o = (MessageHeader) other;
1902        return compareValues(timestamp, o.timestamp, true);
1903      }
1904
1905      public boolean isEmpty() {
1906        return super.isEmpty() && (timestamp == null || timestamp.isEmpty()) && (event == null || event.isEmpty())
1907           && (response == null || response.isEmpty()) && (source == null || source.isEmpty()) && (destination == null || destination.isEmpty())
1908           && (enterer == null || enterer.isEmpty()) && (author == null || author.isEmpty()) && (receiver == null || receiver.isEmpty())
1909           && (responsible == null || responsible.isEmpty()) && (reason == null || reason.isEmpty())
1910           && (data == null || data.isEmpty());
1911      }
1912
1913  @Override
1914  public ResourceType getResourceType() {
1915    return ResourceType.MessageHeader;
1916   }
1917
1918 /**
1919   * Search parameter: <b>destination-uri</b>
1920   * <p>
1921   * Description: <b>Actual destination address or id</b><br>
1922   * Type: <b>uri</b><br>
1923   * Path: <b>MessageHeader.destination.endpoint</b><br>
1924   * </p>
1925   */
1926  @SearchParamDefinition(name="destination-uri", path="MessageHeader.destination.endpoint", description="Actual destination address or id", type="uri" )
1927  public static final String SP_DESTINATION_URI = "destination-uri";
1928 /**
1929   * <b>Fluent Client</b> search parameter constant for <b>destination-uri</b>
1930   * <p>
1931   * Description: <b>Actual destination address or id</b><br>
1932   * Type: <b>uri</b><br>
1933   * Path: <b>MessageHeader.destination.endpoint</b><br>
1934   * </p>
1935   */
1936  public static final ca.uhn.fhir.rest.gclient.UriClientParam DESTINATION_URI = new ca.uhn.fhir.rest.gclient.UriClientParam(SP_DESTINATION_URI);
1937
1938 /**
1939   * Search parameter: <b>receiver</b>
1940   * <p>
1941   * Description: <b>Intended "real-world" recipient for the data</b><br>
1942   * Type: <b>reference</b><br>
1943   * Path: <b>MessageHeader.receiver</b><br>
1944   * </p>
1945   */
1946  @SearchParamDefinition(name="receiver", path="MessageHeader.receiver", description="Intended \"real-world\" recipient for the data", type="reference" )
1947  public static final String SP_RECEIVER = "receiver";
1948 /**
1949   * <b>Fluent Client</b> search parameter constant for <b>receiver</b>
1950   * <p>
1951   * Description: <b>Intended "real-world" recipient for the data</b><br>
1952   * Type: <b>reference</b><br>
1953   * Path: <b>MessageHeader.receiver</b><br>
1954   * </p>
1955   */
1956  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam RECEIVER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_RECEIVER);
1957
1958/**
1959   * Constant for fluent queries to be used to add include statements. Specifies
1960   * the path value of "<b>MessageHeader:receiver</b>".
1961   */
1962  public static final ca.uhn.fhir.model.api.Include INCLUDE_RECEIVER = new ca.uhn.fhir.model.api.Include("MessageHeader:receiver").toLocked();
1963
1964 /**
1965   * Search parameter: <b>responsible</b>
1966   * <p>
1967   * Description: <b>Final responsibility for event</b><br>
1968   * Type: <b>reference</b><br>
1969   * Path: <b>MessageHeader.responsible</b><br>
1970   * </p>
1971   */
1972  @SearchParamDefinition(name="responsible", path="MessageHeader.responsible", description="Final responsibility for event", type="reference" )
1973  public static final String SP_RESPONSIBLE = "responsible";
1974 /**
1975   * <b>Fluent Client</b> search parameter constant for <b>responsible</b>
1976   * <p>
1977   * Description: <b>Final responsibility for event</b><br>
1978   * Type: <b>reference</b><br>
1979   * Path: <b>MessageHeader.responsible</b><br>
1980   * </p>
1981   */
1982  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam RESPONSIBLE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_RESPONSIBLE);
1983
1984/**
1985   * Constant for fluent queries to be used to add include statements. Specifies
1986   * the path value of "<b>MessageHeader:responsible</b>".
1987   */
1988  public static final ca.uhn.fhir.model.api.Include INCLUDE_RESPONSIBLE = new ca.uhn.fhir.model.api.Include("MessageHeader:responsible").toLocked();
1989
1990 /**
1991   * Search parameter: <b>data</b>
1992   * <p>
1993   * Description: <b>The actual content of the message</b><br>
1994   * Type: <b>reference</b><br>
1995   * Path: <b>MessageHeader.data</b><br>
1996   * </p>
1997   */
1998  @SearchParamDefinition(name="data", path="MessageHeader.data", description="The actual content of the message", type="reference" )
1999  public static final String SP_DATA = "data";
2000 /**
2001   * <b>Fluent Client</b> search parameter constant for <b>data</b>
2002   * <p>
2003   * Description: <b>The actual content of the message</b><br>
2004   * Type: <b>reference</b><br>
2005   * Path: <b>MessageHeader.data</b><br>
2006   * </p>
2007   */
2008  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam DATA = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_DATA);
2009
2010/**
2011   * Constant for fluent queries to be used to add include statements. Specifies
2012   * the path value of "<b>MessageHeader:data</b>".
2013   */
2014  public static final ca.uhn.fhir.model.api.Include INCLUDE_DATA = new ca.uhn.fhir.model.api.Include("MessageHeader:data").toLocked();
2015
2016 /**
2017   * Search parameter: <b>code</b>
2018   * <p>
2019   * Description: <b>ok | transient-error | fatal-error</b><br>
2020   * Type: <b>token</b><br>
2021   * Path: <b>MessageHeader.response.code</b><br>
2022   * </p>
2023   */
2024  @SearchParamDefinition(name="code", path="MessageHeader.response.code", description="ok | transient-error | fatal-error", type="token" )
2025  public static final String SP_CODE = "code";
2026 /**
2027   * <b>Fluent Client</b> search parameter constant for <b>code</b>
2028   * <p>
2029   * Description: <b>ok | transient-error | fatal-error</b><br>
2030   * Type: <b>token</b><br>
2031   * Path: <b>MessageHeader.response.code</b><br>
2032   * </p>
2033   */
2034  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
2035
2036 /**
2037   * Search parameter: <b>response-id</b>
2038   * <p>
2039   * Description: <b>Id of original message</b><br>
2040   * Type: <b>token</b><br>
2041   * Path: <b>MessageHeader.response.identifier</b><br>
2042   * </p>
2043   */
2044  @SearchParamDefinition(name="response-id", path="MessageHeader.response.identifier", description="Id of original message", type="token" )
2045  public static final String SP_RESPONSE_ID = "response-id";
2046 /**
2047   * <b>Fluent Client</b> search parameter constant for <b>response-id</b>
2048   * <p>
2049   * Description: <b>Id of original message</b><br>
2050   * Type: <b>token</b><br>
2051   * Path: <b>MessageHeader.response.identifier</b><br>
2052   * </p>
2053   */
2054  public static final ca.uhn.fhir.rest.gclient.TokenClientParam RESPONSE_ID = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_RESPONSE_ID);
2055
2056 /**
2057   * Search parameter: <b>destination</b>
2058   * <p>
2059   * Description: <b>Name of system</b><br>
2060   * Type: <b>string</b><br>
2061   * Path: <b>MessageHeader.destination.name</b><br>
2062   * </p>
2063   */
2064  @SearchParamDefinition(name="destination", path="MessageHeader.destination.name", description="Name of system", type="string" )
2065  public static final String SP_DESTINATION = "destination";
2066 /**
2067   * <b>Fluent Client</b> search parameter constant for <b>destination</b>
2068   * <p>
2069   * Description: <b>Name of system</b><br>
2070   * Type: <b>string</b><br>
2071   * Path: <b>MessageHeader.destination.name</b><br>
2072   * </p>
2073   */
2074  public static final ca.uhn.fhir.rest.gclient.StringClientParam DESTINATION = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_DESTINATION);
2075
2076 /**
2077   * Search parameter: <b>timestamp</b>
2078   * <p>
2079   * Description: <b>Time that the message was sent</b><br>
2080   * Type: <b>date</b><br>
2081   * Path: <b>MessageHeader.timestamp</b><br>
2082   * </p>
2083   */
2084  @SearchParamDefinition(name="timestamp", path="MessageHeader.timestamp", description="Time that the message was sent", type="date" )
2085  public static final String SP_TIMESTAMP = "timestamp";
2086 /**
2087   * <b>Fluent Client</b> search parameter constant for <b>timestamp</b>
2088   * <p>
2089   * Description: <b>Time that the message was sent</b><br>
2090   * Type: <b>date</b><br>
2091   * Path: <b>MessageHeader.timestamp</b><br>
2092   * </p>
2093   */
2094  public static final ca.uhn.fhir.rest.gclient.DateClientParam TIMESTAMP = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_TIMESTAMP);
2095
2096 /**
2097   * Search parameter: <b>author</b>
2098   * <p>
2099   * Description: <b>The source of the decision</b><br>
2100   * Type: <b>reference</b><br>
2101   * Path: <b>MessageHeader.author</b><br>
2102   * </p>
2103   */
2104  @SearchParamDefinition(name="author", path="MessageHeader.author", description="The source of the decision", type="reference" )
2105  public static final String SP_AUTHOR = "author";
2106 /**
2107   * <b>Fluent Client</b> search parameter constant for <b>author</b>
2108   * <p>
2109   * Description: <b>The source of the decision</b><br>
2110   * Type: <b>reference</b><br>
2111   * Path: <b>MessageHeader.author</b><br>
2112   * </p>
2113   */
2114  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam AUTHOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_AUTHOR);
2115
2116/**
2117   * Constant for fluent queries to be used to add include statements. Specifies
2118   * the path value of "<b>MessageHeader:author</b>".
2119   */
2120  public static final ca.uhn.fhir.model.api.Include INCLUDE_AUTHOR = new ca.uhn.fhir.model.api.Include("MessageHeader:author").toLocked();
2121
2122 /**
2123   * Search parameter: <b>source-uri</b>
2124   * <p>
2125   * Description: <b>Actual message source address or id</b><br>
2126   * Type: <b>uri</b><br>
2127   * Path: <b>MessageHeader.source.endpoint</b><br>
2128   * </p>
2129   */
2130  @SearchParamDefinition(name="source-uri", path="MessageHeader.source.endpoint", description="Actual message source address or id", type="uri" )
2131  public static final String SP_SOURCE_URI = "source-uri";
2132 /**
2133   * <b>Fluent Client</b> search parameter constant for <b>source-uri</b>
2134   * <p>
2135   * Description: <b>Actual message source address or id</b><br>
2136   * Type: <b>uri</b><br>
2137   * Path: <b>MessageHeader.source.endpoint</b><br>
2138   * </p>
2139   */
2140  public static final ca.uhn.fhir.rest.gclient.UriClientParam SOURCE_URI = new ca.uhn.fhir.rest.gclient.UriClientParam(SP_SOURCE_URI);
2141
2142 /**
2143   * Search parameter: <b>source</b>
2144   * <p>
2145   * Description: <b>Name of system</b><br>
2146   * Type: <b>string</b><br>
2147   * Path: <b>MessageHeader.source.name</b><br>
2148   * </p>
2149   */
2150  @SearchParamDefinition(name="source", path="MessageHeader.source.name", description="Name of system", type="string" )
2151  public static final String SP_SOURCE = "source";
2152 /**
2153   * <b>Fluent Client</b> search parameter constant for <b>source</b>
2154   * <p>
2155   * Description: <b>Name of system</b><br>
2156   * Type: <b>string</b><br>
2157   * Path: <b>MessageHeader.source.name</b><br>
2158   * </p>
2159   */
2160  public static final ca.uhn.fhir.rest.gclient.StringClientParam SOURCE = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_SOURCE);
2161
2162 /**
2163   * Search parameter: <b>enterer</b>
2164   * <p>
2165   * Description: <b>The source of the data entry</b><br>
2166   * Type: <b>reference</b><br>
2167   * Path: <b>MessageHeader.enterer</b><br>
2168   * </p>
2169   */
2170  @SearchParamDefinition(name="enterer", path="MessageHeader.enterer", description="The source of the data entry", type="reference" )
2171  public static final String SP_ENTERER = "enterer";
2172 /**
2173   * <b>Fluent Client</b> search parameter constant for <b>enterer</b>
2174   * <p>
2175   * Description: <b>The source of the data entry</b><br>
2176   * Type: <b>reference</b><br>
2177   * Path: <b>MessageHeader.enterer</b><br>
2178   * </p>
2179   */
2180  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENTERER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENTERER);
2181
2182/**
2183   * Constant for fluent queries to be used to add include statements. Specifies
2184   * the path value of "<b>MessageHeader:enterer</b>".
2185   */
2186  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENTERER = new ca.uhn.fhir.model.api.Include("MessageHeader:enterer").toLocked();
2187
2188 /**
2189   * Search parameter: <b>event</b>
2190   * <p>
2191   * Description: <b>Code for the event this message represents</b><br>
2192   * Type: <b>token</b><br>
2193   * Path: <b>MessageHeader.event</b><br>
2194   * </p>
2195   */
2196  @SearchParamDefinition(name="event", path="MessageHeader.event", description="Code for the event this message represents", type="token" )
2197  public static final String SP_EVENT = "event";
2198 /**
2199   * <b>Fluent Client</b> search parameter constant for <b>event</b>
2200   * <p>
2201   * Description: <b>Code for the event this message represents</b><br>
2202   * Type: <b>token</b><br>
2203   * Path: <b>MessageHeader.event</b><br>
2204   * </p>
2205   */
2206  public static final ca.uhn.fhir.rest.gclient.TokenClientParam EVENT = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_EVENT);
2207
2208 /**
2209   * Search parameter: <b>target</b>
2210   * <p>
2211   * Description: <b>Particular delivery destination within the destination</b><br>
2212   * Type: <b>reference</b><br>
2213   * Path: <b>MessageHeader.destination.target</b><br>
2214   * </p>
2215   */
2216  @SearchParamDefinition(name="target", path="MessageHeader.destination.target", description="Particular delivery destination within the destination", type="reference" )
2217  public static final String SP_TARGET = "target";
2218 /**
2219   * <b>Fluent Client</b> search parameter constant for <b>target</b>
2220   * <p>
2221   * Description: <b>Particular delivery destination within the destination</b><br>
2222   * Type: <b>reference</b><br>
2223   * Path: <b>MessageHeader.destination.target</b><br>
2224   * </p>
2225   */
2226  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam TARGET = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_TARGET);
2227
2228/**
2229   * Constant for fluent queries to be used to add include statements. Specifies
2230   * the path value of "<b>MessageHeader:target</b>".
2231   */
2232  public static final ca.uhn.fhir.model.api.Include INCLUDE_TARGET = new ca.uhn.fhir.model.api.Include("MessageHeader:target").toLocked();
2233
2234
2235}
2236