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