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