001package org.hl7.fhir.r4.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 Thu, Sep 13, 2018 09:04-0400 for FHIR v3.5.0
033
034import java.util.*;
035
036import java.math.*;
037import org.hl7.fhir.utilities.Utilities;
038import ca.uhn.fhir.model.api.annotation.ResourceDef;
039import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
040import ca.uhn.fhir.model.api.annotation.Child;
041import ca.uhn.fhir.model.api.annotation.ChildOrder;
042import ca.uhn.fhir.model.api.annotation.Description;
043import ca.uhn.fhir.model.api.annotation.Block;
044import org.hl7.fhir.instance.model.api.*;
045import org.hl7.fhir.exceptions.FHIRException;
046/**
047 * A container for a collection of resources.
048 */
049@ResourceDef(name="Bundle", profile="http://hl7.org/fhir/StructureDefinition/Bundle")
050public class Bundle extends Resource implements IBaseBundle {
051
052    public enum BundleType {
053        /**
054         * The bundle is a document. The first resource is a Composition.
055         */
056        DOCUMENT, 
057        /**
058         * The bundle is a message. The first resource is a MessageHeader.
059         */
060        MESSAGE, 
061        /**
062         * The bundle is a transaction - intended to be processed by a server as an atomic commit.
063         */
064        TRANSACTION, 
065        /**
066         * The bundle is a transaction response. Because the response is a transaction response, the transaction has succeeded, and all responses are error free.
067         */
068        TRANSACTIONRESPONSE, 
069        /**
070         * The bundle is a set of actions - intended to be processed by a server as a group of independent actions.
071         */
072        BATCH, 
073        /**
074         * The bundle is a batch response. Note that as a batch, some responses may indicate failure and others success.
075         */
076        BATCHRESPONSE, 
077        /**
078         * The bundle is a list of resources from a history interaction on a server.
079         */
080        HISTORY, 
081        /**
082         * The bundle is a list of resources returned as a result of a search/query interaction, operation, or message.
083         */
084        SEARCHSET, 
085        /**
086         * The bundle is a set of resources collected into a single package for ease of distribution that imposes no processing obligations or behavioral rules beyond persistence.
087         */
088        COLLECTION, 
089        /**
090         * added to help the parsers with the generic types
091         */
092        NULL;
093        public static BundleType fromCode(String codeString) throws FHIRException {
094            if (codeString == null || "".equals(codeString))
095                return null;
096        if ("document".equals(codeString))
097          return DOCUMENT;
098        if ("message".equals(codeString))
099          return MESSAGE;
100        if ("transaction".equals(codeString))
101          return TRANSACTION;
102        if ("transaction-response".equals(codeString))
103          return TRANSACTIONRESPONSE;
104        if ("batch".equals(codeString))
105          return BATCH;
106        if ("batch-response".equals(codeString))
107          return BATCHRESPONSE;
108        if ("history".equals(codeString))
109          return HISTORY;
110        if ("searchset".equals(codeString))
111          return SEARCHSET;
112        if ("collection".equals(codeString))
113          return COLLECTION;
114        if (Configuration.isAcceptInvalidEnums())
115          return null;
116        else
117          throw new FHIRException("Unknown BundleType code '"+codeString+"'");
118        }
119        public String toCode() {
120          switch (this) {
121            case DOCUMENT: return "document";
122            case MESSAGE: return "message";
123            case TRANSACTION: return "transaction";
124            case TRANSACTIONRESPONSE: return "transaction-response";
125            case BATCH: return "batch";
126            case BATCHRESPONSE: return "batch-response";
127            case HISTORY: return "history";
128            case SEARCHSET: return "searchset";
129            case COLLECTION: return "collection";
130            default: return "?";
131          }
132        }
133        public String getSystem() {
134          switch (this) {
135            case DOCUMENT: return "http://hl7.org/fhir/bundle-type";
136            case MESSAGE: return "http://hl7.org/fhir/bundle-type";
137            case TRANSACTION: return "http://hl7.org/fhir/bundle-type";
138            case TRANSACTIONRESPONSE: return "http://hl7.org/fhir/bundle-type";
139            case BATCH: return "http://hl7.org/fhir/bundle-type";
140            case BATCHRESPONSE: return "http://hl7.org/fhir/bundle-type";
141            case HISTORY: return "http://hl7.org/fhir/bundle-type";
142            case SEARCHSET: return "http://hl7.org/fhir/bundle-type";
143            case COLLECTION: return "http://hl7.org/fhir/bundle-type";
144            default: return "?";
145          }
146        }
147        public String getDefinition() {
148          switch (this) {
149            case DOCUMENT: return "The bundle is a document. The first resource is a Composition.";
150            case MESSAGE: return "The bundle is a message. The first resource is a MessageHeader.";
151            case TRANSACTION: return "The bundle is a transaction - intended to be processed by a server as an atomic commit.";
152            case TRANSACTIONRESPONSE: return "The bundle is a transaction response. Because the response is a transaction response, the transaction has succeeded, and all responses are error free.";
153            case BATCH: return "The bundle is a set of actions - intended to be processed by a server as a group of independent actions.";
154            case BATCHRESPONSE: return "The bundle is a batch response. Note that as a batch, some responses may indicate failure and others success.";
155            case HISTORY: return "The bundle is a list of resources from a history interaction on a server.";
156            case SEARCHSET: return "The bundle is a list of resources returned as a result of a search/query interaction, operation, or message.";
157            case COLLECTION: return "The bundle is a set of resources collected into a single package for ease of distribution that imposes no processing obligations or behavioral rules beyond persistence.";
158            default: return "?";
159          }
160        }
161        public String getDisplay() {
162          switch (this) {
163            case DOCUMENT: return "Document";
164            case MESSAGE: return "Message";
165            case TRANSACTION: return "Transaction";
166            case TRANSACTIONRESPONSE: return "Transaction Response";
167            case BATCH: return "Batch";
168            case BATCHRESPONSE: return "Batch Response";
169            case HISTORY: return "History List";
170            case SEARCHSET: return "Search Results";
171            case COLLECTION: return "Collection";
172            default: return "?";
173          }
174        }
175    }
176
177  public static class BundleTypeEnumFactory implements EnumFactory<BundleType> {
178    public BundleType fromCode(String codeString) throws IllegalArgumentException {
179      if (codeString == null || "".equals(codeString))
180            if (codeString == null || "".equals(codeString))
181                return null;
182        if ("document".equals(codeString))
183          return BundleType.DOCUMENT;
184        if ("message".equals(codeString))
185          return BundleType.MESSAGE;
186        if ("transaction".equals(codeString))
187          return BundleType.TRANSACTION;
188        if ("transaction-response".equals(codeString))
189          return BundleType.TRANSACTIONRESPONSE;
190        if ("batch".equals(codeString))
191          return BundleType.BATCH;
192        if ("batch-response".equals(codeString))
193          return BundleType.BATCHRESPONSE;
194        if ("history".equals(codeString))
195          return BundleType.HISTORY;
196        if ("searchset".equals(codeString))
197          return BundleType.SEARCHSET;
198        if ("collection".equals(codeString))
199          return BundleType.COLLECTION;
200        throw new IllegalArgumentException("Unknown BundleType code '"+codeString+"'");
201        }
202        public Enumeration<BundleType> fromType(Base code) throws FHIRException {
203          if (code == null)
204            return null;
205          if (code.isEmpty())
206            return new Enumeration<BundleType>(this);
207          String codeString = ((PrimitiveType) code).asStringValue();
208          if (codeString == null || "".equals(codeString))
209            return null;
210        if ("document".equals(codeString))
211          return new Enumeration<BundleType>(this, BundleType.DOCUMENT);
212        if ("message".equals(codeString))
213          return new Enumeration<BundleType>(this, BundleType.MESSAGE);
214        if ("transaction".equals(codeString))
215          return new Enumeration<BundleType>(this, BundleType.TRANSACTION);
216        if ("transaction-response".equals(codeString))
217          return new Enumeration<BundleType>(this, BundleType.TRANSACTIONRESPONSE);
218        if ("batch".equals(codeString))
219          return new Enumeration<BundleType>(this, BundleType.BATCH);
220        if ("batch-response".equals(codeString))
221          return new Enumeration<BundleType>(this, BundleType.BATCHRESPONSE);
222        if ("history".equals(codeString))
223          return new Enumeration<BundleType>(this, BundleType.HISTORY);
224        if ("searchset".equals(codeString))
225          return new Enumeration<BundleType>(this, BundleType.SEARCHSET);
226        if ("collection".equals(codeString))
227          return new Enumeration<BundleType>(this, BundleType.COLLECTION);
228        throw new FHIRException("Unknown BundleType code '"+codeString+"'");
229        }
230    public String toCode(BundleType code) {
231      if (code == BundleType.DOCUMENT)
232        return "document";
233      if (code == BundleType.MESSAGE)
234        return "message";
235      if (code == BundleType.TRANSACTION)
236        return "transaction";
237      if (code == BundleType.TRANSACTIONRESPONSE)
238        return "transaction-response";
239      if (code == BundleType.BATCH)
240        return "batch";
241      if (code == BundleType.BATCHRESPONSE)
242        return "batch-response";
243      if (code == BundleType.HISTORY)
244        return "history";
245      if (code == BundleType.SEARCHSET)
246        return "searchset";
247      if (code == BundleType.COLLECTION)
248        return "collection";
249      return "?";
250      }
251    public String toSystem(BundleType code) {
252      return code.getSystem();
253      }
254    }
255
256    public enum SearchEntryMode {
257        /**
258         * This resource matched the search specification.
259         */
260        MATCH, 
261        /**
262         * This resource is returned because it is referred to from another resource in the search set.
263         */
264        INCLUDE, 
265        /**
266         * An OperationOutcome that provides additional information about the processing of a search.
267         */
268        OUTCOME, 
269        /**
270         * added to help the parsers with the generic types
271         */
272        NULL;
273        public static SearchEntryMode fromCode(String codeString) throws FHIRException {
274            if (codeString == null || "".equals(codeString))
275                return null;
276        if ("match".equals(codeString))
277          return MATCH;
278        if ("include".equals(codeString))
279          return INCLUDE;
280        if ("outcome".equals(codeString))
281          return OUTCOME;
282        if (Configuration.isAcceptInvalidEnums())
283          return null;
284        else
285          throw new FHIRException("Unknown SearchEntryMode code '"+codeString+"'");
286        }
287        public String toCode() {
288          switch (this) {
289            case MATCH: return "match";
290            case INCLUDE: return "include";
291            case OUTCOME: return "outcome";
292            default: return "?";
293          }
294        }
295        public String getSystem() {
296          switch (this) {
297            case MATCH: return "http://hl7.org/fhir/search-entry-mode";
298            case INCLUDE: return "http://hl7.org/fhir/search-entry-mode";
299            case OUTCOME: return "http://hl7.org/fhir/search-entry-mode";
300            default: return "?";
301          }
302        }
303        public String getDefinition() {
304          switch (this) {
305            case MATCH: return "This resource matched the search specification.";
306            case INCLUDE: return "This resource is returned because it is referred to from another resource in the search set.";
307            case OUTCOME: return "An OperationOutcome that provides additional information about the processing of a search.";
308            default: return "?";
309          }
310        }
311        public String getDisplay() {
312          switch (this) {
313            case MATCH: return "Match";
314            case INCLUDE: return "Include";
315            case OUTCOME: return "Outcome";
316            default: return "?";
317          }
318        }
319    }
320
321  public static class SearchEntryModeEnumFactory implements EnumFactory<SearchEntryMode> {
322    public SearchEntryMode fromCode(String codeString) throws IllegalArgumentException {
323      if (codeString == null || "".equals(codeString))
324            if (codeString == null || "".equals(codeString))
325                return null;
326        if ("match".equals(codeString))
327          return SearchEntryMode.MATCH;
328        if ("include".equals(codeString))
329          return SearchEntryMode.INCLUDE;
330        if ("outcome".equals(codeString))
331          return SearchEntryMode.OUTCOME;
332        throw new IllegalArgumentException("Unknown SearchEntryMode code '"+codeString+"'");
333        }
334        public Enumeration<SearchEntryMode> fromType(Base code) throws FHIRException {
335          if (code == null)
336            return null;
337          if (code.isEmpty())
338            return new Enumeration<SearchEntryMode>(this);
339          String codeString = ((PrimitiveType) code).asStringValue();
340          if (codeString == null || "".equals(codeString))
341            return null;
342        if ("match".equals(codeString))
343          return new Enumeration<SearchEntryMode>(this, SearchEntryMode.MATCH);
344        if ("include".equals(codeString))
345          return new Enumeration<SearchEntryMode>(this, SearchEntryMode.INCLUDE);
346        if ("outcome".equals(codeString))
347          return new Enumeration<SearchEntryMode>(this, SearchEntryMode.OUTCOME);
348        throw new FHIRException("Unknown SearchEntryMode code '"+codeString+"'");
349        }
350    public String toCode(SearchEntryMode code) {
351      if (code == SearchEntryMode.MATCH)
352        return "match";
353      if (code == SearchEntryMode.INCLUDE)
354        return "include";
355      if (code == SearchEntryMode.OUTCOME)
356        return "outcome";
357      return "?";
358      }
359    public String toSystem(SearchEntryMode code) {
360      return code.getSystem();
361      }
362    }
363
364    public enum HTTPVerb {
365        /**
366         * HTTP GET Command.
367         */
368        GET, 
369        /**
370         * HTTP HEAD Command.
371         */
372        HEAD, 
373        /**
374         * HTTP POST Command.
375         */
376        POST, 
377        /**
378         * HTTP PUT Command.
379         */
380        PUT, 
381        /**
382         * HTTP DELETE Command.
383         */
384        DELETE, 
385        /**
386         * HTTP PATCH Command.
387         */
388        PATCH, 
389        /**
390         * added to help the parsers with the generic types
391         */
392        NULL;
393        public static HTTPVerb fromCode(String codeString) throws FHIRException {
394            if (codeString == null || "".equals(codeString))
395                return null;
396        if ("GET".equals(codeString))
397          return GET;
398        if ("HEAD".equals(codeString))
399          return HEAD;
400        if ("POST".equals(codeString))
401          return POST;
402        if ("PUT".equals(codeString))
403          return PUT;
404        if ("DELETE".equals(codeString))
405          return DELETE;
406        if ("PATCH".equals(codeString))
407          return PATCH;
408        if (Configuration.isAcceptInvalidEnums())
409          return null;
410        else
411          throw new FHIRException("Unknown HTTPVerb code '"+codeString+"'");
412        }
413        public String toCode() {
414          switch (this) {
415            case GET: return "GET";
416            case HEAD: return "HEAD";
417            case POST: return "POST";
418            case PUT: return "PUT";
419            case DELETE: return "DELETE";
420            case PATCH: return "PATCH";
421            default: return "?";
422          }
423        }
424        public String getSystem() {
425          switch (this) {
426            case GET: return "http://hl7.org/fhir/http-verb";
427            case HEAD: return "http://hl7.org/fhir/http-verb";
428            case POST: return "http://hl7.org/fhir/http-verb";
429            case PUT: return "http://hl7.org/fhir/http-verb";
430            case DELETE: return "http://hl7.org/fhir/http-verb";
431            case PATCH: return "http://hl7.org/fhir/http-verb";
432            default: return "?";
433          }
434        }
435        public String getDefinition() {
436          switch (this) {
437            case GET: return "HTTP GET Command.";
438            case HEAD: return "HTTP HEAD Command.";
439            case POST: return "HTTP POST Command.";
440            case PUT: return "HTTP PUT Command.";
441            case DELETE: return "HTTP DELETE Command.";
442            case PATCH: return "HTTP PATCH Command.";
443            default: return "?";
444          }
445        }
446        public String getDisplay() {
447          switch (this) {
448            case GET: return "GET";
449            case HEAD: return "HEAD";
450            case POST: return "POST";
451            case PUT: return "PUT";
452            case DELETE: return "DELETE";
453            case PATCH: return "PATCH";
454            default: return "?";
455          }
456        }
457    }
458
459  public static class HTTPVerbEnumFactory implements EnumFactory<HTTPVerb> {
460    public HTTPVerb fromCode(String codeString) throws IllegalArgumentException {
461      if (codeString == null || "".equals(codeString))
462            if (codeString == null || "".equals(codeString))
463                return null;
464        if ("GET".equals(codeString))
465          return HTTPVerb.GET;
466        if ("HEAD".equals(codeString))
467          return HTTPVerb.HEAD;
468        if ("POST".equals(codeString))
469          return HTTPVerb.POST;
470        if ("PUT".equals(codeString))
471          return HTTPVerb.PUT;
472        if ("DELETE".equals(codeString))
473          return HTTPVerb.DELETE;
474        if ("PATCH".equals(codeString))
475          return HTTPVerb.PATCH;
476        throw new IllegalArgumentException("Unknown HTTPVerb code '"+codeString+"'");
477        }
478        public Enumeration<HTTPVerb> fromType(Base code) throws FHIRException {
479          if (code == null)
480            return null;
481          if (code.isEmpty())
482            return new Enumeration<HTTPVerb>(this);
483          String codeString = ((PrimitiveType) code).asStringValue();
484          if (codeString == null || "".equals(codeString))
485            return null;
486        if ("GET".equals(codeString))
487          return new Enumeration<HTTPVerb>(this, HTTPVerb.GET);
488        if ("HEAD".equals(codeString))
489          return new Enumeration<HTTPVerb>(this, HTTPVerb.HEAD);
490        if ("POST".equals(codeString))
491          return new Enumeration<HTTPVerb>(this, HTTPVerb.POST);
492        if ("PUT".equals(codeString))
493          return new Enumeration<HTTPVerb>(this, HTTPVerb.PUT);
494        if ("DELETE".equals(codeString))
495          return new Enumeration<HTTPVerb>(this, HTTPVerb.DELETE);
496        if ("PATCH".equals(codeString))
497          return new Enumeration<HTTPVerb>(this, HTTPVerb.PATCH);
498        throw new FHIRException("Unknown HTTPVerb code '"+codeString+"'");
499        }
500    public String toCode(HTTPVerb code) {
501      if (code == HTTPVerb.GET)
502        return "GET";
503      if (code == HTTPVerb.HEAD)
504        return "HEAD";
505      if (code == HTTPVerb.POST)
506        return "POST";
507      if (code == HTTPVerb.PUT)
508        return "PUT";
509      if (code == HTTPVerb.DELETE)
510        return "DELETE";
511      if (code == HTTPVerb.PATCH)
512        return "PATCH";
513      return "?";
514      }
515    public String toSystem(HTTPVerb code) {
516      return code.getSystem();
517      }
518    }
519
520    @Block()
521    public static class BundleLinkComponent extends BackboneElement implements IBaseBackboneElement {
522        /**
523         * A name which details the functional use for this link - see [http://www.iana.org/assignments/link-relations/link-relations.xhtml#link-relations-1](http://www.iana.org/assignments/link-relations/link-relations.xhtml#link-relations-1).
524         */
525        @Child(name = "relation", type = {StringType.class}, order=1, min=1, max=1, modifier=false, summary=true)
526        @Description(shortDefinition="See http://www.iana.org/assignments/link-relations/link-relations.xhtml#link-relations-1", formalDefinition="A name which details the functional use for this link - see [http://www.iana.org/assignments/link-relations/link-relations.xhtml#link-relations-1](http://www.iana.org/assignments/link-relations/link-relations.xhtml#link-relations-1)." )
527        protected StringType relation;
528
529        /**
530         * The reference details for the link.
531         */
532        @Child(name = "url", type = {UriType.class}, order=2, min=1, max=1, modifier=false, summary=true)
533        @Description(shortDefinition="Reference details for the link", formalDefinition="The reference details for the link." )
534        protected UriType url;
535
536        private static final long serialVersionUID = -1010386066L;
537
538    /**
539     * Constructor
540     */
541      public BundleLinkComponent() {
542        super();
543      }
544
545    /**
546     * Constructor
547     */
548      public BundleLinkComponent(StringType relation, UriType url) {
549        super();
550        this.relation = relation;
551        this.url = url;
552      }
553
554        /**
555         * @return {@link #relation} (A name which details the functional use for this link - see [http://www.iana.org/assignments/link-relations/link-relations.xhtml#link-relations-1](http://www.iana.org/assignments/link-relations/link-relations.xhtml#link-relations-1).). This is the underlying object with id, value and extensions. The accessor "getRelation" gives direct access to the value
556         */
557        public StringType getRelationElement() { 
558          if (this.relation == null)
559            if (Configuration.errorOnAutoCreate())
560              throw new Error("Attempt to auto-create BundleLinkComponent.relation");
561            else if (Configuration.doAutoCreate())
562              this.relation = new StringType(); // bb
563          return this.relation;
564        }
565
566        public boolean hasRelationElement() { 
567          return this.relation != null && !this.relation.isEmpty();
568        }
569
570        public boolean hasRelation() { 
571          return this.relation != null && !this.relation.isEmpty();
572        }
573
574        /**
575         * @param value {@link #relation} (A name which details the functional use for this link - see [http://www.iana.org/assignments/link-relations/link-relations.xhtml#link-relations-1](http://www.iana.org/assignments/link-relations/link-relations.xhtml#link-relations-1).). This is the underlying object with id, value and extensions. The accessor "getRelation" gives direct access to the value
576         */
577        public BundleLinkComponent setRelationElement(StringType value) { 
578          this.relation = value;
579          return this;
580        }
581
582        /**
583         * @return A name which details the functional use for this link - see [http://www.iana.org/assignments/link-relations/link-relations.xhtml#link-relations-1](http://www.iana.org/assignments/link-relations/link-relations.xhtml#link-relations-1).
584         */
585        public String getRelation() { 
586          return this.relation == null ? null : this.relation.getValue();
587        }
588
589        /**
590         * @param value A name which details the functional use for this link - see [http://www.iana.org/assignments/link-relations/link-relations.xhtml#link-relations-1](http://www.iana.org/assignments/link-relations/link-relations.xhtml#link-relations-1).
591         */
592        public BundleLinkComponent setRelation(String value) { 
593            if (this.relation == null)
594              this.relation = new StringType();
595            this.relation.setValue(value);
596          return this;
597        }
598
599        /**
600         * @return {@link #url} (The reference details for the link.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
601         */
602        public UriType getUrlElement() { 
603          if (this.url == null)
604            if (Configuration.errorOnAutoCreate())
605              throw new Error("Attempt to auto-create BundleLinkComponent.url");
606            else if (Configuration.doAutoCreate())
607              this.url = new UriType(); // bb
608          return this.url;
609        }
610
611        public boolean hasUrlElement() { 
612          return this.url != null && !this.url.isEmpty();
613        }
614
615        public boolean hasUrl() { 
616          return this.url != null && !this.url.isEmpty();
617        }
618
619        /**
620         * @param value {@link #url} (The reference details for the link.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
621         */
622        public BundleLinkComponent setUrlElement(UriType value) { 
623          this.url = value;
624          return this;
625        }
626
627        /**
628         * @return The reference details for the link.
629         */
630        public String getUrl() { 
631          return this.url == null ? null : this.url.getValue();
632        }
633
634        /**
635         * @param value The reference details for the link.
636         */
637        public BundleLinkComponent setUrl(String value) { 
638            if (this.url == null)
639              this.url = new UriType();
640            this.url.setValue(value);
641          return this;
642        }
643
644        protected void listChildren(List<Property> children) {
645          super.listChildren(children);
646          children.add(new Property("relation", "string", "A name which details the functional use for this link - see [http://www.iana.org/assignments/link-relations/link-relations.xhtml#link-relations-1](http://www.iana.org/assignments/link-relations/link-relations.xhtml#link-relations-1).", 0, 1, relation));
647          children.add(new Property("url", "uri", "The reference details for the link.", 0, 1, url));
648        }
649
650        @Override
651        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
652          switch (_hash) {
653          case -554436100: /*relation*/  return new Property("relation", "string", "A name which details the functional use for this link - see [http://www.iana.org/assignments/link-relations/link-relations.xhtml#link-relations-1](http://www.iana.org/assignments/link-relations/link-relations.xhtml#link-relations-1).", 0, 1, relation);
654          case 116079: /*url*/  return new Property("url", "uri", "The reference details for the link.", 0, 1, url);
655          default: return super.getNamedProperty(_hash, _name, _checkValid);
656          }
657
658        }
659
660      @Override
661      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
662        switch (hash) {
663        case -554436100: /*relation*/ return this.relation == null ? new Base[0] : new Base[] {this.relation}; // StringType
664        case 116079: /*url*/ return this.url == null ? new Base[0] : new Base[] {this.url}; // UriType
665        default: return super.getProperty(hash, name, checkValid);
666        }
667
668      }
669
670      @Override
671      public Base setProperty(int hash, String name, Base value) throws FHIRException {
672        switch (hash) {
673        case -554436100: // relation
674          this.relation = castToString(value); // StringType
675          return value;
676        case 116079: // url
677          this.url = castToUri(value); // UriType
678          return value;
679        default: return super.setProperty(hash, name, value);
680        }
681
682      }
683
684      @Override
685      public Base setProperty(String name, Base value) throws FHIRException {
686        if (name.equals("relation")) {
687          this.relation = castToString(value); // StringType
688        } else if (name.equals("url")) {
689          this.url = castToUri(value); // UriType
690        } else
691          return super.setProperty(name, value);
692        return value;
693      }
694
695      @Override
696      public Base makeProperty(int hash, String name) throws FHIRException {
697        switch (hash) {
698        case -554436100:  return getRelationElement();
699        case 116079:  return getUrlElement();
700        default: return super.makeProperty(hash, name);
701        }
702
703      }
704
705      @Override
706      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
707        switch (hash) {
708        case -554436100: /*relation*/ return new String[] {"string"};
709        case 116079: /*url*/ return new String[] {"uri"};
710        default: return super.getTypesForProperty(hash, name);
711        }
712
713      }
714
715      @Override
716      public Base addChild(String name) throws FHIRException {
717        if (name.equals("relation")) {
718          throw new FHIRException("Cannot call addChild on a primitive type Bundle.relation");
719        }
720        else if (name.equals("url")) {
721          throw new FHIRException("Cannot call addChild on a primitive type Bundle.url");
722        }
723        else
724          return super.addChild(name);
725      }
726
727      public BundleLinkComponent copy() {
728        BundleLinkComponent dst = new BundleLinkComponent();
729        copyValues(dst);
730        dst.relation = relation == null ? null : relation.copy();
731        dst.url = url == null ? null : url.copy();
732        return dst;
733      }
734
735      @Override
736      public boolean equalsDeep(Base other_) {
737        if (!super.equalsDeep(other_))
738          return false;
739        if (!(other_ instanceof BundleLinkComponent))
740          return false;
741        BundleLinkComponent o = (BundleLinkComponent) other_;
742        return compareDeep(relation, o.relation, true) && compareDeep(url, o.url, true);
743      }
744
745      @Override
746      public boolean equalsShallow(Base other_) {
747        if (!super.equalsShallow(other_))
748          return false;
749        if (!(other_ instanceof BundleLinkComponent))
750          return false;
751        BundleLinkComponent o = (BundleLinkComponent) other_;
752        return compareValues(relation, o.relation, true) && compareValues(url, o.url, true);
753      }
754
755      public boolean isEmpty() {
756        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(relation, url);
757      }
758
759  public String fhirType() {
760    return "Bundle.link";
761
762  }
763
764  }
765
766    @Block()
767    public static class BundleEntryComponent extends BackboneElement implements IBaseBackboneElement {
768        /**
769         * A series of links that provide context to this entry.
770         */
771        @Child(name = "link", type = {BundleLinkComponent.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
772        @Description(shortDefinition="Links related to this entry", formalDefinition="A series of links that provide context to this entry." )
773        protected List<BundleLinkComponent> link;
774
775        /**
776         * The Absolute URL for the resource.  The fullUrl SHALL NOT disagree with the id in the resource - i.e. if the fullUrl is not a urn:uuid, the URL shall be version-independent URL consistent with the Resource.id. The fullUrl is a version independent reference to the resource. The fullUrl element SHALL have a value except that: 
777* fullUrl can be empty on a POST (although it does not need to when specifying a temporary id for reference in the bundle)
778* Results from operations might involve resources that are not identified.
779         */
780        @Child(name = "fullUrl", type = {UriType.class}, order=2, min=0, max=1, modifier=false, summary=true)
781        @Description(shortDefinition="URI for resource (Absolute URL server address or URI for UUID/OID)", formalDefinition="The Absolute URL for the resource.  The fullUrl SHALL NOT disagree with the id in the resource - i.e. if the fullUrl is not a urn:uuid, the URL shall be version-independent URL consistent with the Resource.id. The fullUrl is a version independent reference to the resource. The fullUrl element SHALL have a value except that: \n* fullUrl can be empty on a POST (although it does not need to when specifying a temporary id for reference in the bundle)\n* Results from operations might involve resources that are not identified." )
782        protected UriType fullUrl;
783
784        /**
785         * The Resource for the entry. The purpose/meaning of the resource is determined by the Bundle.type.
786         */
787        @Child(name = "resource", type = {Resource.class}, order=3, min=0, max=1, modifier=false, summary=true)
788        @Description(shortDefinition="A resource in the bundle", formalDefinition="The Resource for the entry. The purpose/meaning of the resource is determined by the Bundle.type." )
789        protected Resource resource;
790
791        /**
792         * Information about the search process that lead to the creation of this entry.
793         */
794        @Child(name = "search", type = {}, order=4, min=0, max=1, modifier=false, summary=true)
795        @Description(shortDefinition="Search related information", formalDefinition="Information about the search process that lead to the creation of this entry." )
796        protected BundleEntrySearchComponent search;
797
798        /**
799         * Additional information about how this entry should be processed as part of a transaction or batch.  For history, it shows how the entry was processed to create the version contained in the entry.
800         */
801        @Child(name = "request", type = {}, order=5, min=0, max=1, modifier=false, summary=true)
802        @Description(shortDefinition="Additional execution information (transaction/batch/history)", formalDefinition="Additional information about how this entry should be processed as part of a transaction or batch.  For history, it shows how the entry was processed to create the version contained in the entry." )
803        protected BundleEntryRequestComponent request;
804
805        /**
806         * Indicates the results of processing the corresponding 'request' entry in the batch or transaction being responded to or what the results of an operation where when returning history.
807         */
808        @Child(name = "response", type = {}, order=6, min=0, max=1, modifier=false, summary=true)
809        @Description(shortDefinition="Results of execution (transaction/batch/history)", formalDefinition="Indicates the results of processing the corresponding 'request' entry in the batch or transaction being responded to or what the results of an operation where when returning history." )
810        protected BundleEntryResponseComponent response;
811
812        private static final long serialVersionUID = 517783054L;
813
814    /**
815     * Constructor
816     */
817      public BundleEntryComponent() {
818        super();
819      }
820
821        /**
822         * @return {@link #link} (A series of links that provide context to this entry.)
823         */
824        public List<BundleLinkComponent> getLink() { 
825          if (this.link == null)
826            this.link = new ArrayList<BundleLinkComponent>();
827          return this.link;
828        }
829
830        /**
831         * @return Returns a reference to <code>this</code> for easy method chaining
832         */
833        public BundleEntryComponent setLink(List<BundleLinkComponent> theLink) { 
834          this.link = theLink;
835          return this;
836        }
837
838        public boolean hasLink() { 
839          if (this.link == null)
840            return false;
841          for (BundleLinkComponent item : this.link)
842            if (!item.isEmpty())
843              return true;
844          return false;
845        }
846
847        public BundleLinkComponent addLink() { //3
848          BundleLinkComponent t = new BundleLinkComponent();
849          if (this.link == null)
850            this.link = new ArrayList<BundleLinkComponent>();
851          this.link.add(t);
852          return t;
853        }
854
855        public BundleEntryComponent addLink(BundleLinkComponent t) { //3
856          if (t == null)
857            return this;
858          if (this.link == null)
859            this.link = new ArrayList<BundleLinkComponent>();
860          this.link.add(t);
861          return this;
862        }
863
864        /**
865         * @return The first repetition of repeating field {@link #link}, creating it if it does not already exist
866         */
867        public BundleLinkComponent getLinkFirstRep() { 
868          if (getLink().isEmpty()) {
869            addLink();
870          }
871          return getLink().get(0);
872        }
873
874        /**
875         * @return {@link #fullUrl} (The Absolute URL for the resource.  The fullUrl SHALL NOT disagree with the id in the resource - i.e. if the fullUrl is not a urn:uuid, the URL shall be version-independent URL consistent with the Resource.id. The fullUrl is a version independent reference to the resource. The fullUrl element SHALL have a value except that: 
876* fullUrl can be empty on a POST (although it does not need to when specifying a temporary id for reference in the bundle)
877* Results from operations might involve resources that are not identified.). This is the underlying object with id, value and extensions. The accessor "getFullUrl" gives direct access to the value
878         */
879        public UriType getFullUrlElement() { 
880          if (this.fullUrl == null)
881            if (Configuration.errorOnAutoCreate())
882              throw new Error("Attempt to auto-create BundleEntryComponent.fullUrl");
883            else if (Configuration.doAutoCreate())
884              this.fullUrl = new UriType(); // bb
885          return this.fullUrl;
886        }
887
888        public boolean hasFullUrlElement() { 
889          return this.fullUrl != null && !this.fullUrl.isEmpty();
890        }
891
892        public boolean hasFullUrl() { 
893          return this.fullUrl != null && !this.fullUrl.isEmpty();
894        }
895
896        /**
897         * @param value {@link #fullUrl} (The Absolute URL for the resource.  The fullUrl SHALL NOT disagree with the id in the resource - i.e. if the fullUrl is not a urn:uuid, the URL shall be version-independent URL consistent with the Resource.id. The fullUrl is a version independent reference to the resource. The fullUrl element SHALL have a value except that: 
898* fullUrl can be empty on a POST (although it does not need to when specifying a temporary id for reference in the bundle)
899* Results from operations might involve resources that are not identified.). This is the underlying object with id, value and extensions. The accessor "getFullUrl" gives direct access to the value
900         */
901        public BundleEntryComponent setFullUrlElement(UriType value) { 
902          this.fullUrl = value;
903          return this;
904        }
905
906        /**
907         * @return The Absolute URL for the resource.  The fullUrl SHALL NOT disagree with the id in the resource - i.e. if the fullUrl is not a urn:uuid, the URL shall be version-independent URL consistent with the Resource.id. The fullUrl is a version independent reference to the resource. The fullUrl element SHALL have a value except that: 
908* fullUrl can be empty on a POST (although it does not need to when specifying a temporary id for reference in the bundle)
909* Results from operations might involve resources that are not identified.
910         */
911        public String getFullUrl() { 
912          return this.fullUrl == null ? null : this.fullUrl.getValue();
913        }
914
915        /**
916         * @param value The Absolute URL for the resource.  The fullUrl SHALL NOT disagree with the id in the resource - i.e. if the fullUrl is not a urn:uuid, the URL shall be version-independent URL consistent with the Resource.id. The fullUrl is a version independent reference to the resource. The fullUrl element SHALL have a value except that: 
917* fullUrl can be empty on a POST (although it does not need to when specifying a temporary id for reference in the bundle)
918* Results from operations might involve resources that are not identified.
919         */
920        public BundleEntryComponent setFullUrl(String value) { 
921          if (Utilities.noString(value))
922            this.fullUrl = null;
923          else {
924            if (this.fullUrl == null)
925              this.fullUrl = new UriType();
926            this.fullUrl.setValue(value);
927          }
928          return this;
929        }
930
931        /**
932         * @return {@link #resource} (The Resource for the entry. The purpose/meaning of the resource is determined by the Bundle.type.)
933         */
934        public Resource getResource() { 
935          return this.resource;
936        }
937
938        public boolean hasResource() { 
939          return this.resource != null && !this.resource.isEmpty();
940        }
941
942        /**
943         * @param value {@link #resource} (The Resource for the entry. The purpose/meaning of the resource is determined by the Bundle.type.)
944         */
945        public BundleEntryComponent setResource(Resource value) { 
946          this.resource = value;
947          return this;
948        }
949
950        /**
951         * @return {@link #search} (Information about the search process that lead to the creation of this entry.)
952         */
953        public BundleEntrySearchComponent getSearch() { 
954          if (this.search == null)
955            if (Configuration.errorOnAutoCreate())
956              throw new Error("Attempt to auto-create BundleEntryComponent.search");
957            else if (Configuration.doAutoCreate())
958              this.search = new BundleEntrySearchComponent(); // cc
959          return this.search;
960        }
961
962        public boolean hasSearch() { 
963          return this.search != null && !this.search.isEmpty();
964        }
965
966        /**
967         * @param value {@link #search} (Information about the search process that lead to the creation of this entry.)
968         */
969        public BundleEntryComponent setSearch(BundleEntrySearchComponent value) { 
970          this.search = value;
971          return this;
972        }
973
974        /**
975         * @return {@link #request} (Additional information about how this entry should be processed as part of a transaction or batch.  For history, it shows how the entry was processed to create the version contained in the entry.)
976         */
977        public BundleEntryRequestComponent getRequest() { 
978          if (this.request == null)
979            if (Configuration.errorOnAutoCreate())
980              throw new Error("Attempt to auto-create BundleEntryComponent.request");
981            else if (Configuration.doAutoCreate())
982              this.request = new BundleEntryRequestComponent(); // cc
983          return this.request;
984        }
985
986        public boolean hasRequest() { 
987          return this.request != null && !this.request.isEmpty();
988        }
989
990        /**
991         * @param value {@link #request} (Additional information about how this entry should be processed as part of a transaction or batch.  For history, it shows how the entry was processed to create the version contained in the entry.)
992         */
993        public BundleEntryComponent setRequest(BundleEntryRequestComponent value) { 
994          this.request = value;
995          return this;
996        }
997
998        /**
999         * @return {@link #response} (Indicates the results of processing the corresponding 'request' entry in the batch or transaction being responded to or what the results of an operation where when returning history.)
1000         */
1001        public BundleEntryResponseComponent getResponse() { 
1002          if (this.response == null)
1003            if (Configuration.errorOnAutoCreate())
1004              throw new Error("Attempt to auto-create BundleEntryComponent.response");
1005            else if (Configuration.doAutoCreate())
1006              this.response = new BundleEntryResponseComponent(); // cc
1007          return this.response;
1008        }
1009
1010        public boolean hasResponse() { 
1011          return this.response != null && !this.response.isEmpty();
1012        }
1013
1014        /**
1015         * @param value {@link #response} (Indicates the results of processing the corresponding 'request' entry in the batch or transaction being responded to or what the results of an operation where when returning history.)
1016         */
1017        public BundleEntryComponent setResponse(BundleEntryResponseComponent value) { 
1018          this.response = value;
1019          return this;
1020        }
1021
1022 /**
1023   * Returns the {@link #getLink() link} which matches a given {@link BundleLinkComponent#getRelation() relation}. 
1024   * If no link is found which matches the given relation, returns <code>null</code>. If more than one
1025   * link is found which matches the given relation, returns the first matching BundleLinkComponent.
1026   * 
1027   * @param theRelation
1028   *            The relation, such as "next", or "self. See the constants such as {@link IBaseBundle#LINK_SELF} and {@link IBaseBundle#LINK_NEXT}.
1029   * @return Returns a matching BundleLinkComponent, or <code>null</code>
1030   * @see IBaseBundle#LINK_NEXT
1031   * @see IBaseBundle#LINK_PREV
1032   * @see IBaseBundle#LINK_SELF
1033   */
1034  public BundleLinkComponent getLink(String theRelation) {
1035    org.apache.commons.lang3.Validate.notBlank(theRelation, "theRelation may not be null or empty");
1036    for (BundleLinkComponent next : getLink()) {
1037      if (theRelation.equals(next.getRelation())) {
1038        return next;
1039      }
1040    }
1041    return null;
1042  }
1043
1044  /**
1045   * Returns the {@link #getLink() link} which matches a given {@link BundleLinkComponent#getRelation() relation}. 
1046   * If no link is found which matches the given relation, creates a new BundleLinkComponent with the
1047   * given relation and adds it to this Bundle. If more than one
1048   * link is found which matches the given relation, returns the first matching BundleLinkComponent.
1049   * 
1050   * @param theRelation
1051   *            The relation, such as "next", or "self. See the constants such as {@link IBaseBundle#LINK_SELF} and {@link IBaseBundle#LINK_NEXT}.
1052   * @return Returns a matching BundleLinkComponent, or <code>null</code>
1053   * @see IBaseBundle#LINK_NEXT
1054   * @see IBaseBundle#LINK_PREV
1055   * @see IBaseBundle#LINK_SELF
1056   */
1057  public BundleLinkComponent getLinkOrCreate(String theRelation) {
1058    org.apache.commons.lang3.Validate.notBlank(theRelation, "theRelation may not be null or empty");
1059    for (BundleLinkComponent next : getLink()) {
1060      if (theRelation.equals(next.getRelation())) {
1061        return next;
1062      }
1063    }
1064    BundleLinkComponent retVal = new BundleLinkComponent();
1065    retVal.setRelation(theRelation);
1066    getLink().add(retVal);
1067    return retVal;
1068  }
1069        protected void listChildren(List<Property> children) {
1070          super.listChildren(children);
1071          children.add(new Property("link", "@Bundle.link", "A series of links that provide context to this entry.", 0, java.lang.Integer.MAX_VALUE, link));
1072          children.add(new Property("fullUrl", "uri", "The Absolute URL for the resource.  The fullUrl SHALL NOT disagree with the id in the resource - i.e. if the fullUrl is not a urn:uuid, the URL shall be version-independent URL consistent with the Resource.id. The fullUrl is a version independent reference to the resource. The fullUrl element SHALL have a value except that: \n* fullUrl can be empty on a POST (although it does not need to when specifying a temporary id for reference in the bundle)\n* Results from operations might involve resources that are not identified.", 0, 1, fullUrl));
1073          children.add(new Property("resource", "Resource", "The Resource for the entry. The purpose/meaning of the resource is determined by the Bundle.type.", 0, 1, resource));
1074          children.add(new Property("search", "", "Information about the search process that lead to the creation of this entry.", 0, 1, search));
1075          children.add(new Property("request", "", "Additional information about how this entry should be processed as part of a transaction or batch.  For history, it shows how the entry was processed to create the version contained in the entry.", 0, 1, request));
1076          children.add(new Property("response", "", "Indicates the results of processing the corresponding 'request' entry in the batch or transaction being responded to or what the results of an operation where when returning history.", 0, 1, response));
1077        }
1078
1079        @Override
1080        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1081          switch (_hash) {
1082          case 3321850: /*link*/  return new Property("link", "@Bundle.link", "A series of links that provide context to this entry.", 0, java.lang.Integer.MAX_VALUE, link);
1083          case -511251360: /*fullUrl*/  return new Property("fullUrl", "uri", "The Absolute URL for the resource.  The fullUrl SHALL NOT disagree with the id in the resource - i.e. if the fullUrl is not a urn:uuid, the URL shall be version-independent URL consistent with the Resource.id. The fullUrl is a version independent reference to the resource. The fullUrl element SHALL have a value except that: \n* fullUrl can be empty on a POST (although it does not need to when specifying a temporary id for reference in the bundle)\n* Results from operations might involve resources that are not identified.", 0, 1, fullUrl);
1084          case -341064690: /*resource*/  return new Property("resource", "Resource", "The Resource for the entry. The purpose/meaning of the resource is determined by the Bundle.type.", 0, 1, resource);
1085          case -906336856: /*search*/  return new Property("search", "", "Information about the search process that lead to the creation of this entry.", 0, 1, search);
1086          case 1095692943: /*request*/  return new Property("request", "", "Additional information about how this entry should be processed as part of a transaction or batch.  For history, it shows how the entry was processed to create the version contained in the entry.", 0, 1, request);
1087          case -340323263: /*response*/  return new Property("response", "", "Indicates the results of processing the corresponding 'request' entry in the batch or transaction being responded to or what the results of an operation where when returning history.", 0, 1, response);
1088          default: return super.getNamedProperty(_hash, _name, _checkValid);
1089          }
1090
1091        }
1092
1093      @Override
1094      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1095        switch (hash) {
1096        case 3321850: /*link*/ return this.link == null ? new Base[0] : this.link.toArray(new Base[this.link.size()]); // BundleLinkComponent
1097        case -511251360: /*fullUrl*/ return this.fullUrl == null ? new Base[0] : new Base[] {this.fullUrl}; // UriType
1098        case -341064690: /*resource*/ return this.resource == null ? new Base[0] : new Base[] {this.resource}; // Resource
1099        case -906336856: /*search*/ return this.search == null ? new Base[0] : new Base[] {this.search}; // BundleEntrySearchComponent
1100        case 1095692943: /*request*/ return this.request == null ? new Base[0] : new Base[] {this.request}; // BundleEntryRequestComponent
1101        case -340323263: /*response*/ return this.response == null ? new Base[0] : new Base[] {this.response}; // BundleEntryResponseComponent
1102        default: return super.getProperty(hash, name, checkValid);
1103        }
1104
1105      }
1106
1107      @Override
1108      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1109        switch (hash) {
1110        case 3321850: // link
1111          this.getLink().add((BundleLinkComponent) value); // BundleLinkComponent
1112          return value;
1113        case -511251360: // fullUrl
1114          this.fullUrl = castToUri(value); // UriType
1115          return value;
1116        case -341064690: // resource
1117          this.resource = castToResource(value); // Resource
1118          return value;
1119        case -906336856: // search
1120          this.search = (BundleEntrySearchComponent) value; // BundleEntrySearchComponent
1121          return value;
1122        case 1095692943: // request
1123          this.request = (BundleEntryRequestComponent) value; // BundleEntryRequestComponent
1124          return value;
1125        case -340323263: // response
1126          this.response = (BundleEntryResponseComponent) value; // BundleEntryResponseComponent
1127          return value;
1128        default: return super.setProperty(hash, name, value);
1129        }
1130
1131      }
1132
1133      @Override
1134      public Base setProperty(String name, Base value) throws FHIRException {
1135        if (name.equals("link")) {
1136          this.getLink().add((BundleLinkComponent) value);
1137        } else if (name.equals("fullUrl")) {
1138          this.fullUrl = castToUri(value); // UriType
1139        } else if (name.equals("resource")) {
1140          this.resource = castToResource(value); // Resource
1141        } else if (name.equals("search")) {
1142          this.search = (BundleEntrySearchComponent) value; // BundleEntrySearchComponent
1143        } else if (name.equals("request")) {
1144          this.request = (BundleEntryRequestComponent) value; // BundleEntryRequestComponent
1145        } else if (name.equals("response")) {
1146          this.response = (BundleEntryResponseComponent) value; // BundleEntryResponseComponent
1147        } else
1148          return super.setProperty(name, value);
1149        return value;
1150      }
1151
1152      @Override
1153      public Base makeProperty(int hash, String name) throws FHIRException {
1154        switch (hash) {
1155        case 3321850:  return addLink(); 
1156        case -511251360:  return getFullUrlElement();
1157        case -341064690: throw new FHIRException("Cannot make property resource as it is not a complex type"); // Resource
1158        case -906336856:  return getSearch(); 
1159        case 1095692943:  return getRequest(); 
1160        case -340323263:  return getResponse(); 
1161        default: return super.makeProperty(hash, name);
1162        }
1163
1164      }
1165
1166      @Override
1167      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1168        switch (hash) {
1169        case 3321850: /*link*/ return new String[] {"@Bundle.link"};
1170        case -511251360: /*fullUrl*/ return new String[] {"uri"};
1171        case -341064690: /*resource*/ return new String[] {"Resource"};
1172        case -906336856: /*search*/ return new String[] {};
1173        case 1095692943: /*request*/ return new String[] {};
1174        case -340323263: /*response*/ return new String[] {};
1175        default: return super.getTypesForProperty(hash, name);
1176        }
1177
1178      }
1179
1180      @Override
1181      public Base addChild(String name) throws FHIRException {
1182        if (name.equals("link")) {
1183          return addLink();
1184        }
1185        else if (name.equals("fullUrl")) {
1186          throw new FHIRException("Cannot call addChild on a primitive type Bundle.fullUrl");
1187        }
1188        else if (name.equals("resource")) {
1189          throw new FHIRException("Cannot call addChild on an abstract type Bundle.resource");
1190        }
1191        else if (name.equals("search")) {
1192          this.search = new BundleEntrySearchComponent();
1193          return this.search;
1194        }
1195        else if (name.equals("request")) {
1196          this.request = new BundleEntryRequestComponent();
1197          return this.request;
1198        }
1199        else if (name.equals("response")) {
1200          this.response = new BundleEntryResponseComponent();
1201          return this.response;
1202        }
1203        else
1204          return super.addChild(name);
1205      }
1206
1207      public BundleEntryComponent copy() {
1208        BundleEntryComponent dst = new BundleEntryComponent();
1209        copyValues(dst);
1210        if (link != null) {
1211          dst.link = new ArrayList<BundleLinkComponent>();
1212          for (BundleLinkComponent i : link)
1213            dst.link.add(i.copy());
1214        };
1215        dst.fullUrl = fullUrl == null ? null : fullUrl.copy();
1216        dst.resource = resource == null ? null : resource.copy();
1217        dst.search = search == null ? null : search.copy();
1218        dst.request = request == null ? null : request.copy();
1219        dst.response = response == null ? null : response.copy();
1220        return dst;
1221      }
1222
1223      @Override
1224      public boolean equalsDeep(Base other_) {
1225        if (!super.equalsDeep(other_))
1226          return false;
1227        if (!(other_ instanceof BundleEntryComponent))
1228          return false;
1229        BundleEntryComponent o = (BundleEntryComponent) other_;
1230        return compareDeep(link, o.link, true) && compareDeep(fullUrl, o.fullUrl, true) && compareDeep(resource, o.resource, true)
1231           && compareDeep(search, o.search, true) && compareDeep(request, o.request, true) && compareDeep(response, o.response, true)
1232          ;
1233      }
1234
1235      @Override
1236      public boolean equalsShallow(Base other_) {
1237        if (!super.equalsShallow(other_))
1238          return false;
1239        if (!(other_ instanceof BundleEntryComponent))
1240          return false;
1241        BundleEntryComponent o = (BundleEntryComponent) other_;
1242        return compareValues(fullUrl, o.fullUrl, true);
1243      }
1244
1245      public boolean isEmpty() {
1246        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(link, fullUrl, resource
1247          , search, request, response);
1248      }
1249
1250  public String fhirType() {
1251    return "Bundle.entry";
1252
1253  }
1254
1255  }
1256
1257    @Block()
1258    public static class BundleEntrySearchComponent extends BackboneElement implements IBaseBackboneElement {
1259        /**
1260         * Why this entry is in the result set - whether it's included as a match or because of an _include requirement, or to convey information or warning information about the search process.
1261         */
1262        @Child(name = "mode", type = {CodeType.class}, order=1, min=0, max=1, modifier=false, summary=true)
1263        @Description(shortDefinition="match | include | outcome - why this is in the result set", formalDefinition="Why this entry is in the result set - whether it's included as a match or because of an _include requirement, or to convey information or warning information about the search process." )
1264        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/search-entry-mode")
1265        protected Enumeration<SearchEntryMode> mode;
1266
1267        /**
1268         * When searching, the server's search ranking score for the entry.
1269         */
1270        @Child(name = "score", type = {DecimalType.class}, order=2, min=0, max=1, modifier=false, summary=true)
1271        @Description(shortDefinition="Search ranking (between 0 and 1)", formalDefinition="When searching, the server's search ranking score for the entry." )
1272        protected DecimalType score;
1273
1274        private static final long serialVersionUID = 837739866L;
1275
1276    /**
1277     * Constructor
1278     */
1279      public BundleEntrySearchComponent() {
1280        super();
1281      }
1282
1283        /**
1284         * @return {@link #mode} (Why this entry is in the result set - whether it's included as a match or because of an _include requirement, or to convey information or warning information about the search process.). This is the underlying object with id, value and extensions. The accessor "getMode" gives direct access to the value
1285         */
1286        public Enumeration<SearchEntryMode> getModeElement() { 
1287          if (this.mode == null)
1288            if (Configuration.errorOnAutoCreate())
1289              throw new Error("Attempt to auto-create BundleEntrySearchComponent.mode");
1290            else if (Configuration.doAutoCreate())
1291              this.mode = new Enumeration<SearchEntryMode>(new SearchEntryModeEnumFactory()); // bb
1292          return this.mode;
1293        }
1294
1295        public boolean hasModeElement() { 
1296          return this.mode != null && !this.mode.isEmpty();
1297        }
1298
1299        public boolean hasMode() { 
1300          return this.mode != null && !this.mode.isEmpty();
1301        }
1302
1303        /**
1304         * @param value {@link #mode} (Why this entry is in the result set - whether it's included as a match or because of an _include requirement, or to convey information or warning information about the search process.). This is the underlying object with id, value and extensions. The accessor "getMode" gives direct access to the value
1305         */
1306        public BundleEntrySearchComponent setModeElement(Enumeration<SearchEntryMode> value) { 
1307          this.mode = value;
1308          return this;
1309        }
1310
1311        /**
1312         * @return Why this entry is in the result set - whether it's included as a match or because of an _include requirement, or to convey information or warning information about the search process.
1313         */
1314        public SearchEntryMode getMode() { 
1315          return this.mode == null ? null : this.mode.getValue();
1316        }
1317
1318        /**
1319         * @param value Why this entry is in the result set - whether it's included as a match or because of an _include requirement, or to convey information or warning information about the search process.
1320         */
1321        public BundleEntrySearchComponent setMode(SearchEntryMode value) { 
1322          if (value == null)
1323            this.mode = null;
1324          else {
1325            if (this.mode == null)
1326              this.mode = new Enumeration<SearchEntryMode>(new SearchEntryModeEnumFactory());
1327            this.mode.setValue(value);
1328          }
1329          return this;
1330        }
1331
1332        /**
1333         * @return {@link #score} (When searching, the server's search ranking score for the entry.). This is the underlying object with id, value and extensions. The accessor "getScore" gives direct access to the value
1334         */
1335        public DecimalType getScoreElement() { 
1336          if (this.score == null)
1337            if (Configuration.errorOnAutoCreate())
1338              throw new Error("Attempt to auto-create BundleEntrySearchComponent.score");
1339            else if (Configuration.doAutoCreate())
1340              this.score = new DecimalType(); // bb
1341          return this.score;
1342        }
1343
1344        public boolean hasScoreElement() { 
1345          return this.score != null && !this.score.isEmpty();
1346        }
1347
1348        public boolean hasScore() { 
1349          return this.score != null && !this.score.isEmpty();
1350        }
1351
1352        /**
1353         * @param value {@link #score} (When searching, the server's search ranking score for the entry.). This is the underlying object with id, value and extensions. The accessor "getScore" gives direct access to the value
1354         */
1355        public BundleEntrySearchComponent setScoreElement(DecimalType value) { 
1356          this.score = value;
1357          return this;
1358        }
1359
1360        /**
1361         * @return When searching, the server's search ranking score for the entry.
1362         */
1363        public BigDecimal getScore() { 
1364          return this.score == null ? null : this.score.getValue();
1365        }
1366
1367        /**
1368         * @param value When searching, the server's search ranking score for the entry.
1369         */
1370        public BundleEntrySearchComponent setScore(BigDecimal value) { 
1371          if (value == null)
1372            this.score = null;
1373          else {
1374            if (this.score == null)
1375              this.score = new DecimalType();
1376            this.score.setValue(value);
1377          }
1378          return this;
1379        }
1380
1381        /**
1382         * @param value When searching, the server's search ranking score for the entry.
1383         */
1384        public BundleEntrySearchComponent setScore(long value) { 
1385              this.score = new DecimalType();
1386            this.score.setValue(value);
1387          return this;
1388        }
1389
1390        /**
1391         * @param value When searching, the server's search ranking score for the entry.
1392         */
1393        public BundleEntrySearchComponent setScore(double value) { 
1394              this.score = new DecimalType();
1395            this.score.setValue(value);
1396          return this;
1397        }
1398
1399        protected void listChildren(List<Property> children) {
1400          super.listChildren(children);
1401          children.add(new Property("mode", "code", "Why this entry is in the result set - whether it's included as a match or because of an _include requirement, or to convey information or warning information about the search process.", 0, 1, mode));
1402          children.add(new Property("score", "decimal", "When searching, the server's search ranking score for the entry.", 0, 1, score));
1403        }
1404
1405        @Override
1406        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1407          switch (_hash) {
1408          case 3357091: /*mode*/  return new Property("mode", "code", "Why this entry is in the result set - whether it's included as a match or because of an _include requirement, or to convey information or warning information about the search process.", 0, 1, mode);
1409          case 109264530: /*score*/  return new Property("score", "decimal", "When searching, the server's search ranking score for the entry.", 0, 1, score);
1410          default: return super.getNamedProperty(_hash, _name, _checkValid);
1411          }
1412
1413        }
1414
1415      @Override
1416      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1417        switch (hash) {
1418        case 3357091: /*mode*/ return this.mode == null ? new Base[0] : new Base[] {this.mode}; // Enumeration<SearchEntryMode>
1419        case 109264530: /*score*/ return this.score == null ? new Base[0] : new Base[] {this.score}; // DecimalType
1420        default: return super.getProperty(hash, name, checkValid);
1421        }
1422
1423      }
1424
1425      @Override
1426      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1427        switch (hash) {
1428        case 3357091: // mode
1429          value = new SearchEntryModeEnumFactory().fromType(castToCode(value));
1430          this.mode = (Enumeration) value; // Enumeration<SearchEntryMode>
1431          return value;
1432        case 109264530: // score
1433          this.score = castToDecimal(value); // DecimalType
1434          return value;
1435        default: return super.setProperty(hash, name, value);
1436        }
1437
1438      }
1439
1440      @Override
1441      public Base setProperty(String name, Base value) throws FHIRException {
1442        if (name.equals("mode")) {
1443          value = new SearchEntryModeEnumFactory().fromType(castToCode(value));
1444          this.mode = (Enumeration) value; // Enumeration<SearchEntryMode>
1445        } else if (name.equals("score")) {
1446          this.score = castToDecimal(value); // DecimalType
1447        } else
1448          return super.setProperty(name, value);
1449        return value;
1450      }
1451
1452      @Override
1453      public Base makeProperty(int hash, String name) throws FHIRException {
1454        switch (hash) {
1455        case 3357091:  return getModeElement();
1456        case 109264530:  return getScoreElement();
1457        default: return super.makeProperty(hash, name);
1458        }
1459
1460      }
1461
1462      @Override
1463      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1464        switch (hash) {
1465        case 3357091: /*mode*/ return new String[] {"code"};
1466        case 109264530: /*score*/ return new String[] {"decimal"};
1467        default: return super.getTypesForProperty(hash, name);
1468        }
1469
1470      }
1471
1472      @Override
1473      public Base addChild(String name) throws FHIRException {
1474        if (name.equals("mode")) {
1475          throw new FHIRException("Cannot call addChild on a primitive type Bundle.mode");
1476        }
1477        else if (name.equals("score")) {
1478          throw new FHIRException("Cannot call addChild on a primitive type Bundle.score");
1479        }
1480        else
1481          return super.addChild(name);
1482      }
1483
1484      public BundleEntrySearchComponent copy() {
1485        BundleEntrySearchComponent dst = new BundleEntrySearchComponent();
1486        copyValues(dst);
1487        dst.mode = mode == null ? null : mode.copy();
1488        dst.score = score == null ? null : score.copy();
1489        return dst;
1490      }
1491
1492      @Override
1493      public boolean equalsDeep(Base other_) {
1494        if (!super.equalsDeep(other_))
1495          return false;
1496        if (!(other_ instanceof BundleEntrySearchComponent))
1497          return false;
1498        BundleEntrySearchComponent o = (BundleEntrySearchComponent) other_;
1499        return compareDeep(mode, o.mode, true) && compareDeep(score, o.score, true);
1500      }
1501
1502      @Override
1503      public boolean equalsShallow(Base other_) {
1504        if (!super.equalsShallow(other_))
1505          return false;
1506        if (!(other_ instanceof BundleEntrySearchComponent))
1507          return false;
1508        BundleEntrySearchComponent o = (BundleEntrySearchComponent) other_;
1509        return compareValues(mode, o.mode, true) && compareValues(score, o.score, true);
1510      }
1511
1512      public boolean isEmpty() {
1513        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(mode, score);
1514      }
1515
1516  public String fhirType() {
1517    return "Bundle.entry.search";
1518
1519  }
1520
1521  }
1522
1523    @Block()
1524    public static class BundleEntryRequestComponent extends BackboneElement implements IBaseBackboneElement {
1525        /**
1526         * In a transaction or batch, this is the HTTP action to be executed for this entry. In a history bundle, this indicates the HTTP action that occurred.
1527         */
1528        @Child(name = "method", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=true)
1529        @Description(shortDefinition="GET | HEAD | POST | PUT | DELETE | PATCH", formalDefinition="In a transaction or batch, this is the HTTP action to be executed for this entry. In a history bundle, this indicates the HTTP action that occurred." )
1530        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/http-verb")
1531        protected Enumeration<HTTPVerb> method;
1532
1533        /**
1534         * The URL for this entry, relative to the root (the address to which the request is posted).
1535         */
1536        @Child(name = "url", type = {UriType.class}, order=2, min=1, max=1, modifier=false, summary=true)
1537        @Description(shortDefinition="URL for HTTP equivalent of this entry", formalDefinition="The URL for this entry, relative to the root (the address to which the request is posted)." )
1538        protected UriType url;
1539
1540        /**
1541         * If the ETag values match, return a 304 Not Modified status. See the API documentation for ["Conditional Read"](http.html#cread).
1542         */
1543        @Child(name = "ifNoneMatch", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
1544        @Description(shortDefinition="For managing cache currency", formalDefinition="If the ETag values match, return a 304 Not Modified status. See the API documentation for [\"Conditional Read\"](http.html#cread)." )
1545        protected StringType ifNoneMatch;
1546
1547        /**
1548         * Only perform the operation if the last updated date matches. See the API documentation for ["Conditional Read"](http.html#cread).
1549         */
1550        @Child(name = "ifModifiedSince", type = {InstantType.class}, order=4, min=0, max=1, modifier=false, summary=true)
1551        @Description(shortDefinition="For managing cache currency", formalDefinition="Only perform the operation if the last updated date matches. See the API documentation for [\"Conditional Read\"](http.html#cread)." )
1552        protected InstantType ifModifiedSince;
1553
1554        /**
1555         * Only perform the operation if the Etag value matches. For more information, see the API section ["Managing Resource Contention"](http.html#concurrency).
1556         */
1557        @Child(name = "ifMatch", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=true)
1558        @Description(shortDefinition="For managing update contention", formalDefinition="Only perform the operation if the Etag value matches. For more information, see the API section [\"Managing Resource Contention\"](http.html#concurrency)." )
1559        protected StringType ifMatch;
1560
1561        /**
1562         * Instruct the server not to perform the create if a specified resource already exists. For further information, see the API documentation for ["Conditional Create"](http.html#ccreate). This is just the query portion of the URL - what follows the "?" (not including the "?").
1563         */
1564        @Child(name = "ifNoneExist", type = {StringType.class}, order=6, min=0, max=1, modifier=false, summary=true)
1565        @Description(shortDefinition="For conditional creates", formalDefinition="Instruct the server not to perform the create if a specified resource already exists. For further information, see the API documentation for [\"Conditional Create\"](http.html#ccreate). This is just the query portion of the URL - what follows the \"?\" (not including the \"?\")." )
1566        protected StringType ifNoneExist;
1567
1568        private static final long serialVersionUID = -1349769744L;
1569
1570    /**
1571     * Constructor
1572     */
1573      public BundleEntryRequestComponent() {
1574        super();
1575      }
1576
1577    /**
1578     * Constructor
1579     */
1580      public BundleEntryRequestComponent(Enumeration<HTTPVerb> method, UriType url) {
1581        super();
1582        this.method = method;
1583        this.url = url;
1584      }
1585
1586        /**
1587         * @return {@link #method} (In a transaction or batch, this is the HTTP action to be executed for this entry. In a history bundle, this indicates the HTTP action that occurred.). This is the underlying object with id, value and extensions. The accessor "getMethod" gives direct access to the value
1588         */
1589        public Enumeration<HTTPVerb> getMethodElement() { 
1590          if (this.method == null)
1591            if (Configuration.errorOnAutoCreate())
1592              throw new Error("Attempt to auto-create BundleEntryRequestComponent.method");
1593            else if (Configuration.doAutoCreate())
1594              this.method = new Enumeration<HTTPVerb>(new HTTPVerbEnumFactory()); // bb
1595          return this.method;
1596        }
1597
1598        public boolean hasMethodElement() { 
1599          return this.method != null && !this.method.isEmpty();
1600        }
1601
1602        public boolean hasMethod() { 
1603          return this.method != null && !this.method.isEmpty();
1604        }
1605
1606        /**
1607         * @param value {@link #method} (In a transaction or batch, this is the HTTP action to be executed for this entry. In a history bundle, this indicates the HTTP action that occurred.). This is the underlying object with id, value and extensions. The accessor "getMethod" gives direct access to the value
1608         */
1609        public BundleEntryRequestComponent setMethodElement(Enumeration<HTTPVerb> value) { 
1610          this.method = value;
1611          return this;
1612        }
1613
1614        /**
1615         * @return In a transaction or batch, this is the HTTP action to be executed for this entry. In a history bundle, this indicates the HTTP action that occurred.
1616         */
1617        public HTTPVerb getMethod() { 
1618          return this.method == null ? null : this.method.getValue();
1619        }
1620
1621        /**
1622         * @param value In a transaction or batch, this is the HTTP action to be executed for this entry. In a history bundle, this indicates the HTTP action that occurred.
1623         */
1624        public BundleEntryRequestComponent setMethod(HTTPVerb value) { 
1625            if (this.method == null)
1626              this.method = new Enumeration<HTTPVerb>(new HTTPVerbEnumFactory());
1627            this.method.setValue(value);
1628          return this;
1629        }
1630
1631        /**
1632         * @return {@link #url} (The URL for this entry, relative to the root (the address to which the request is posted).). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
1633         */
1634        public UriType getUrlElement() { 
1635          if (this.url == null)
1636            if (Configuration.errorOnAutoCreate())
1637              throw new Error("Attempt to auto-create BundleEntryRequestComponent.url");
1638            else if (Configuration.doAutoCreate())
1639              this.url = new UriType(); // bb
1640          return this.url;
1641        }
1642
1643        public boolean hasUrlElement() { 
1644          return this.url != null && !this.url.isEmpty();
1645        }
1646
1647        public boolean hasUrl() { 
1648          return this.url != null && !this.url.isEmpty();
1649        }
1650
1651        /**
1652         * @param value {@link #url} (The URL for this entry, relative to the root (the address to which the request is posted).). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
1653         */
1654        public BundleEntryRequestComponent setUrlElement(UriType value) { 
1655          this.url = value;
1656          return this;
1657        }
1658
1659        /**
1660         * @return The URL for this entry, relative to the root (the address to which the request is posted).
1661         */
1662        public String getUrl() { 
1663          return this.url == null ? null : this.url.getValue();
1664        }
1665
1666        /**
1667         * @param value The URL for this entry, relative to the root (the address to which the request is posted).
1668         */
1669        public BundleEntryRequestComponent setUrl(String value) { 
1670            if (this.url == null)
1671              this.url = new UriType();
1672            this.url.setValue(value);
1673          return this;
1674        }
1675
1676        /**
1677         * @return {@link #ifNoneMatch} (If the ETag values match, return a 304 Not Modified status. See the API documentation for ["Conditional Read"](http.html#cread).). This is the underlying object with id, value and extensions. The accessor "getIfNoneMatch" gives direct access to the value
1678         */
1679        public StringType getIfNoneMatchElement() { 
1680          if (this.ifNoneMatch == null)
1681            if (Configuration.errorOnAutoCreate())
1682              throw new Error("Attempt to auto-create BundleEntryRequestComponent.ifNoneMatch");
1683            else if (Configuration.doAutoCreate())
1684              this.ifNoneMatch = new StringType(); // bb
1685          return this.ifNoneMatch;
1686        }
1687
1688        public boolean hasIfNoneMatchElement() { 
1689          return this.ifNoneMatch != null && !this.ifNoneMatch.isEmpty();
1690        }
1691
1692        public boolean hasIfNoneMatch() { 
1693          return this.ifNoneMatch != null && !this.ifNoneMatch.isEmpty();
1694        }
1695
1696        /**
1697         * @param value {@link #ifNoneMatch} (If the ETag values match, return a 304 Not Modified status. See the API documentation for ["Conditional Read"](http.html#cread).). This is the underlying object with id, value and extensions. The accessor "getIfNoneMatch" gives direct access to the value
1698         */
1699        public BundleEntryRequestComponent setIfNoneMatchElement(StringType value) { 
1700          this.ifNoneMatch = value;
1701          return this;
1702        }
1703
1704        /**
1705         * @return If the ETag values match, return a 304 Not Modified status. See the API documentation for ["Conditional Read"](http.html#cread).
1706         */
1707        public String getIfNoneMatch() { 
1708          return this.ifNoneMatch == null ? null : this.ifNoneMatch.getValue();
1709        }
1710
1711        /**
1712         * @param value If the ETag values match, return a 304 Not Modified status. See the API documentation for ["Conditional Read"](http.html#cread).
1713         */
1714        public BundleEntryRequestComponent setIfNoneMatch(String value) { 
1715          if (Utilities.noString(value))
1716            this.ifNoneMatch = null;
1717          else {
1718            if (this.ifNoneMatch == null)
1719              this.ifNoneMatch = new StringType();
1720            this.ifNoneMatch.setValue(value);
1721          }
1722          return this;
1723        }
1724
1725        /**
1726         * @return {@link #ifModifiedSince} (Only perform the operation if the last updated date matches. See the API documentation for ["Conditional Read"](http.html#cread).). This is the underlying object with id, value and extensions. The accessor "getIfModifiedSince" gives direct access to the value
1727         */
1728        public InstantType getIfModifiedSinceElement() { 
1729          if (this.ifModifiedSince == null)
1730            if (Configuration.errorOnAutoCreate())
1731              throw new Error("Attempt to auto-create BundleEntryRequestComponent.ifModifiedSince");
1732            else if (Configuration.doAutoCreate())
1733              this.ifModifiedSince = new InstantType(); // bb
1734          return this.ifModifiedSince;
1735        }
1736
1737        public boolean hasIfModifiedSinceElement() { 
1738          return this.ifModifiedSince != null && !this.ifModifiedSince.isEmpty();
1739        }
1740
1741        public boolean hasIfModifiedSince() { 
1742          return this.ifModifiedSince != null && !this.ifModifiedSince.isEmpty();
1743        }
1744
1745        /**
1746         * @param value {@link #ifModifiedSince} (Only perform the operation if the last updated date matches. See the API documentation for ["Conditional Read"](http.html#cread).). This is the underlying object with id, value and extensions. The accessor "getIfModifiedSince" gives direct access to the value
1747         */
1748        public BundleEntryRequestComponent setIfModifiedSinceElement(InstantType value) { 
1749          this.ifModifiedSince = value;
1750          return this;
1751        }
1752
1753        /**
1754         * @return Only perform the operation if the last updated date matches. See the API documentation for ["Conditional Read"](http.html#cread).
1755         */
1756        public Date getIfModifiedSince() { 
1757          return this.ifModifiedSince == null ? null : this.ifModifiedSince.getValue();
1758        }
1759
1760        /**
1761         * @param value Only perform the operation if the last updated date matches. See the API documentation for ["Conditional Read"](http.html#cread).
1762         */
1763        public BundleEntryRequestComponent setIfModifiedSince(Date value) { 
1764          if (value == null)
1765            this.ifModifiedSince = null;
1766          else {
1767            if (this.ifModifiedSince == null)
1768              this.ifModifiedSince = new InstantType();
1769            this.ifModifiedSince.setValue(value);
1770          }
1771          return this;
1772        }
1773
1774        /**
1775         * @return {@link #ifMatch} (Only perform the operation if the Etag value matches. For more information, see the API section ["Managing Resource Contention"](http.html#concurrency).). This is the underlying object with id, value and extensions. The accessor "getIfMatch" gives direct access to the value
1776         */
1777        public StringType getIfMatchElement() { 
1778          if (this.ifMatch == null)
1779            if (Configuration.errorOnAutoCreate())
1780              throw new Error("Attempt to auto-create BundleEntryRequestComponent.ifMatch");
1781            else if (Configuration.doAutoCreate())
1782              this.ifMatch = new StringType(); // bb
1783          return this.ifMatch;
1784        }
1785
1786        public boolean hasIfMatchElement() { 
1787          return this.ifMatch != null && !this.ifMatch.isEmpty();
1788        }
1789
1790        public boolean hasIfMatch() { 
1791          return this.ifMatch != null && !this.ifMatch.isEmpty();
1792        }
1793
1794        /**
1795         * @param value {@link #ifMatch} (Only perform the operation if the Etag value matches. For more information, see the API section ["Managing Resource Contention"](http.html#concurrency).). This is the underlying object with id, value and extensions. The accessor "getIfMatch" gives direct access to the value
1796         */
1797        public BundleEntryRequestComponent setIfMatchElement(StringType value) { 
1798          this.ifMatch = value;
1799          return this;
1800        }
1801
1802        /**
1803         * @return Only perform the operation if the Etag value matches. For more information, see the API section ["Managing Resource Contention"](http.html#concurrency).
1804         */
1805        public String getIfMatch() { 
1806          return this.ifMatch == null ? null : this.ifMatch.getValue();
1807        }
1808
1809        /**
1810         * @param value Only perform the operation if the Etag value matches. For more information, see the API section ["Managing Resource Contention"](http.html#concurrency).
1811         */
1812        public BundleEntryRequestComponent setIfMatch(String value) { 
1813          if (Utilities.noString(value))
1814            this.ifMatch = null;
1815          else {
1816            if (this.ifMatch == null)
1817              this.ifMatch = new StringType();
1818            this.ifMatch.setValue(value);
1819          }
1820          return this;
1821        }
1822
1823        /**
1824         * @return {@link #ifNoneExist} (Instruct the server not to perform the create if a specified resource already exists. For further information, see the API documentation for ["Conditional Create"](http.html#ccreate). This is just the query portion of the URL - what follows the "?" (not including the "?").). This is the underlying object with id, value and extensions. The accessor "getIfNoneExist" gives direct access to the value
1825         */
1826        public StringType getIfNoneExistElement() { 
1827          if (this.ifNoneExist == null)
1828            if (Configuration.errorOnAutoCreate())
1829              throw new Error("Attempt to auto-create BundleEntryRequestComponent.ifNoneExist");
1830            else if (Configuration.doAutoCreate())
1831              this.ifNoneExist = new StringType(); // bb
1832          return this.ifNoneExist;
1833        }
1834
1835        public boolean hasIfNoneExistElement() { 
1836          return this.ifNoneExist != null && !this.ifNoneExist.isEmpty();
1837        }
1838
1839        public boolean hasIfNoneExist() { 
1840          return this.ifNoneExist != null && !this.ifNoneExist.isEmpty();
1841        }
1842
1843        /**
1844         * @param value {@link #ifNoneExist} (Instruct the server not to perform the create if a specified resource already exists. For further information, see the API documentation for ["Conditional Create"](http.html#ccreate). This is just the query portion of the URL - what follows the "?" (not including the "?").). This is the underlying object with id, value and extensions. The accessor "getIfNoneExist" gives direct access to the value
1845         */
1846        public BundleEntryRequestComponent setIfNoneExistElement(StringType value) { 
1847          this.ifNoneExist = value;
1848          return this;
1849        }
1850
1851        /**
1852         * @return Instruct the server not to perform the create if a specified resource already exists. For further information, see the API documentation for ["Conditional Create"](http.html#ccreate). This is just the query portion of the URL - what follows the "?" (not including the "?").
1853         */
1854        public String getIfNoneExist() { 
1855          return this.ifNoneExist == null ? null : this.ifNoneExist.getValue();
1856        }
1857
1858        /**
1859         * @param value Instruct the server not to perform the create if a specified resource already exists. For further information, see the API documentation for ["Conditional Create"](http.html#ccreate). This is just the query portion of the URL - what follows the "?" (not including the "?").
1860         */
1861        public BundleEntryRequestComponent setIfNoneExist(String value) { 
1862          if (Utilities.noString(value))
1863            this.ifNoneExist = null;
1864          else {
1865            if (this.ifNoneExist == null)
1866              this.ifNoneExist = new StringType();
1867            this.ifNoneExist.setValue(value);
1868          }
1869          return this;
1870        }
1871
1872        protected void listChildren(List<Property> children) {
1873          super.listChildren(children);
1874          children.add(new Property("method", "code", "In a transaction or batch, this is the HTTP action to be executed for this entry. In a history bundle, this indicates the HTTP action that occurred.", 0, 1, method));
1875          children.add(new Property("url", "uri", "The URL for this entry, relative to the root (the address to which the request is posted).", 0, 1, url));
1876          children.add(new Property("ifNoneMatch", "string", "If the ETag values match, return a 304 Not Modified status. See the API documentation for [\"Conditional Read\"](http.html#cread).", 0, 1, ifNoneMatch));
1877          children.add(new Property("ifModifiedSince", "instant", "Only perform the operation if the last updated date matches. See the API documentation for [\"Conditional Read\"](http.html#cread).", 0, 1, ifModifiedSince));
1878          children.add(new Property("ifMatch", "string", "Only perform the operation if the Etag value matches. For more information, see the API section [\"Managing Resource Contention\"](http.html#concurrency).", 0, 1, ifMatch));
1879          children.add(new Property("ifNoneExist", "string", "Instruct the server not to perform the create if a specified resource already exists. For further information, see the API documentation for [\"Conditional Create\"](http.html#ccreate). This is just the query portion of the URL - what follows the \"?\" (not including the \"?\").", 0, 1, ifNoneExist));
1880        }
1881
1882        @Override
1883        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1884          switch (_hash) {
1885          case -1077554975: /*method*/  return new Property("method", "code", "In a transaction or batch, this is the HTTP action to be executed for this entry. In a history bundle, this indicates the HTTP action that occurred.", 0, 1, method);
1886          case 116079: /*url*/  return new Property("url", "uri", "The URL for this entry, relative to the root (the address to which the request is posted).", 0, 1, url);
1887          case 171868368: /*ifNoneMatch*/  return new Property("ifNoneMatch", "string", "If the ETag values match, return a 304 Not Modified status. See the API documentation for [\"Conditional Read\"](http.html#cread).", 0, 1, ifNoneMatch);
1888          case -2061602860: /*ifModifiedSince*/  return new Property("ifModifiedSince", "instant", "Only perform the operation if the last updated date matches. See the API documentation for [\"Conditional Read\"](http.html#cread).", 0, 1, ifModifiedSince);
1889          case 1692894888: /*ifMatch*/  return new Property("ifMatch", "string", "Only perform the operation if the Etag value matches. For more information, see the API section [\"Managing Resource Contention\"](http.html#concurrency).", 0, 1, ifMatch);
1890          case 165155330: /*ifNoneExist*/  return new Property("ifNoneExist", "string", "Instruct the server not to perform the create if a specified resource already exists. For further information, see the API documentation for [\"Conditional Create\"](http.html#ccreate). This is just the query portion of the URL - what follows the \"?\" (not including the \"?\").", 0, 1, ifNoneExist);
1891          default: return super.getNamedProperty(_hash, _name, _checkValid);
1892          }
1893
1894        }
1895
1896      @Override
1897      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1898        switch (hash) {
1899        case -1077554975: /*method*/ return this.method == null ? new Base[0] : new Base[] {this.method}; // Enumeration<HTTPVerb>
1900        case 116079: /*url*/ return this.url == null ? new Base[0] : new Base[] {this.url}; // UriType
1901        case 171868368: /*ifNoneMatch*/ return this.ifNoneMatch == null ? new Base[0] : new Base[] {this.ifNoneMatch}; // StringType
1902        case -2061602860: /*ifModifiedSince*/ return this.ifModifiedSince == null ? new Base[0] : new Base[] {this.ifModifiedSince}; // InstantType
1903        case 1692894888: /*ifMatch*/ return this.ifMatch == null ? new Base[0] : new Base[] {this.ifMatch}; // StringType
1904        case 165155330: /*ifNoneExist*/ return this.ifNoneExist == null ? new Base[0] : new Base[] {this.ifNoneExist}; // StringType
1905        default: return super.getProperty(hash, name, checkValid);
1906        }
1907
1908      }
1909
1910      @Override
1911      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1912        switch (hash) {
1913        case -1077554975: // method
1914          value = new HTTPVerbEnumFactory().fromType(castToCode(value));
1915          this.method = (Enumeration) value; // Enumeration<HTTPVerb>
1916          return value;
1917        case 116079: // url
1918          this.url = castToUri(value); // UriType
1919          return value;
1920        case 171868368: // ifNoneMatch
1921          this.ifNoneMatch = castToString(value); // StringType
1922          return value;
1923        case -2061602860: // ifModifiedSince
1924          this.ifModifiedSince = castToInstant(value); // InstantType
1925          return value;
1926        case 1692894888: // ifMatch
1927          this.ifMatch = castToString(value); // StringType
1928          return value;
1929        case 165155330: // ifNoneExist
1930          this.ifNoneExist = castToString(value); // StringType
1931          return value;
1932        default: return super.setProperty(hash, name, value);
1933        }
1934
1935      }
1936
1937      @Override
1938      public Base setProperty(String name, Base value) throws FHIRException {
1939        if (name.equals("method")) {
1940          value = new HTTPVerbEnumFactory().fromType(castToCode(value));
1941          this.method = (Enumeration) value; // Enumeration<HTTPVerb>
1942        } else if (name.equals("url")) {
1943          this.url = castToUri(value); // UriType
1944        } else if (name.equals("ifNoneMatch")) {
1945          this.ifNoneMatch = castToString(value); // StringType
1946        } else if (name.equals("ifModifiedSince")) {
1947          this.ifModifiedSince = castToInstant(value); // InstantType
1948        } else if (name.equals("ifMatch")) {
1949          this.ifMatch = castToString(value); // StringType
1950        } else if (name.equals("ifNoneExist")) {
1951          this.ifNoneExist = castToString(value); // StringType
1952        } else
1953          return super.setProperty(name, value);
1954        return value;
1955      }
1956
1957      @Override
1958      public Base makeProperty(int hash, String name) throws FHIRException {
1959        switch (hash) {
1960        case -1077554975:  return getMethodElement();
1961        case 116079:  return getUrlElement();
1962        case 171868368:  return getIfNoneMatchElement();
1963        case -2061602860:  return getIfModifiedSinceElement();
1964        case 1692894888:  return getIfMatchElement();
1965        case 165155330:  return getIfNoneExistElement();
1966        default: return super.makeProperty(hash, name);
1967        }
1968
1969      }
1970
1971      @Override
1972      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1973        switch (hash) {
1974        case -1077554975: /*method*/ return new String[] {"code"};
1975        case 116079: /*url*/ return new String[] {"uri"};
1976        case 171868368: /*ifNoneMatch*/ return new String[] {"string"};
1977        case -2061602860: /*ifModifiedSince*/ return new String[] {"instant"};
1978        case 1692894888: /*ifMatch*/ return new String[] {"string"};
1979        case 165155330: /*ifNoneExist*/ return new String[] {"string"};
1980        default: return super.getTypesForProperty(hash, name);
1981        }
1982
1983      }
1984
1985      @Override
1986      public Base addChild(String name) throws FHIRException {
1987        if (name.equals("method")) {
1988          throw new FHIRException("Cannot call addChild on a primitive type Bundle.method");
1989        }
1990        else if (name.equals("url")) {
1991          throw new FHIRException("Cannot call addChild on a primitive type Bundle.url");
1992        }
1993        else if (name.equals("ifNoneMatch")) {
1994          throw new FHIRException("Cannot call addChild on a primitive type Bundle.ifNoneMatch");
1995        }
1996        else if (name.equals("ifModifiedSince")) {
1997          throw new FHIRException("Cannot call addChild on a primitive type Bundle.ifModifiedSince");
1998        }
1999        else if (name.equals("ifMatch")) {
2000          throw new FHIRException("Cannot call addChild on a primitive type Bundle.ifMatch");
2001        }
2002        else if (name.equals("ifNoneExist")) {
2003          throw new FHIRException("Cannot call addChild on a primitive type Bundle.ifNoneExist");
2004        }
2005        else
2006          return super.addChild(name);
2007      }
2008
2009      public BundleEntryRequestComponent copy() {
2010        BundleEntryRequestComponent dst = new BundleEntryRequestComponent();
2011        copyValues(dst);
2012        dst.method = method == null ? null : method.copy();
2013        dst.url = url == null ? null : url.copy();
2014        dst.ifNoneMatch = ifNoneMatch == null ? null : ifNoneMatch.copy();
2015        dst.ifModifiedSince = ifModifiedSince == null ? null : ifModifiedSince.copy();
2016        dst.ifMatch = ifMatch == null ? null : ifMatch.copy();
2017        dst.ifNoneExist = ifNoneExist == null ? null : ifNoneExist.copy();
2018        return dst;
2019      }
2020
2021      @Override
2022      public boolean equalsDeep(Base other_) {
2023        if (!super.equalsDeep(other_))
2024          return false;
2025        if (!(other_ instanceof BundleEntryRequestComponent))
2026          return false;
2027        BundleEntryRequestComponent o = (BundleEntryRequestComponent) other_;
2028        return compareDeep(method, o.method, true) && compareDeep(url, o.url, true) && compareDeep(ifNoneMatch, o.ifNoneMatch, true)
2029           && compareDeep(ifModifiedSince, o.ifModifiedSince, true) && compareDeep(ifMatch, o.ifMatch, true)
2030           && compareDeep(ifNoneExist, o.ifNoneExist, true);
2031      }
2032
2033      @Override
2034      public boolean equalsShallow(Base other_) {
2035        if (!super.equalsShallow(other_))
2036          return false;
2037        if (!(other_ instanceof BundleEntryRequestComponent))
2038          return false;
2039        BundleEntryRequestComponent o = (BundleEntryRequestComponent) other_;
2040        return compareValues(method, o.method, true) && compareValues(url, o.url, true) && compareValues(ifNoneMatch, o.ifNoneMatch, true)
2041           && compareValues(ifModifiedSince, o.ifModifiedSince, true) && compareValues(ifMatch, o.ifMatch, true)
2042           && compareValues(ifNoneExist, o.ifNoneExist, true);
2043      }
2044
2045      public boolean isEmpty() {
2046        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(method, url, ifNoneMatch
2047          , ifModifiedSince, ifMatch, ifNoneExist);
2048      }
2049
2050  public String fhirType() {
2051    return "Bundle.entry.request";
2052
2053  }
2054
2055  }
2056
2057    @Block()
2058    public static class BundleEntryResponseComponent extends BackboneElement implements IBaseBackboneElement {
2059        /**
2060         * The status code returned by processing this entry. The status SHALL start with a 3 digit HTTP code (e.g. 404) and may contain the standard HTTP description associated with the status code.
2061         */
2062        @Child(name = "status", type = {StringType.class}, order=1, min=1, max=1, modifier=false, summary=true)
2063        @Description(shortDefinition="Status response code (text optional)", formalDefinition="The status code returned by processing this entry. The status SHALL start with a 3 digit HTTP code (e.g. 404) and may contain the standard HTTP description associated with the status code." )
2064        protected StringType status;
2065
2066        /**
2067         * The location header created by processing this operation, populated if the operation returns a location.
2068         */
2069        @Child(name = "location", type = {UriType.class}, order=2, min=0, max=1, modifier=false, summary=true)
2070        @Description(shortDefinition="The location (if the operation returns a location)", formalDefinition="The location header created by processing this operation, populated if the operation returns a location." )
2071        protected UriType location;
2072
2073        /**
2074         * The Etag for the resource, if the operation for the entry produced a versioned resource (see [Resource Metadata and Versioning](http.html#versioning) and [Managing Resource Contention](http.html#concurrency)).
2075         */
2076        @Child(name = "etag", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
2077        @Description(shortDefinition="The Etag for the resource (if relevant)", formalDefinition="The Etag for the resource, if the operation for the entry produced a versioned resource (see [Resource Metadata and Versioning](http.html#versioning) and [Managing Resource Contention](http.html#concurrency))." )
2078        protected StringType etag;
2079
2080        /**
2081         * The date/time that the resource was modified on the server.
2082         */
2083        @Child(name = "lastModified", type = {InstantType.class}, order=4, min=0, max=1, modifier=false, summary=true)
2084        @Description(shortDefinition="Server's date time modified", formalDefinition="The date/time that the resource was modified on the server." )
2085        protected InstantType lastModified;
2086
2087        /**
2088         * An OperationOutcome containing hints and warnings produced as part of processing this entry in a batch or transaction.
2089         */
2090        @Child(name = "outcome", type = {Resource.class}, order=5, min=0, max=1, modifier=false, summary=true)
2091        @Description(shortDefinition="OperationOutcome with hints and warnings (for batch/transaction)", formalDefinition="An OperationOutcome containing hints and warnings produced as part of processing this entry in a batch or transaction." )
2092        protected Resource outcome;
2093
2094        private static final long serialVersionUID = 923278008L;
2095
2096    /**
2097     * Constructor
2098     */
2099      public BundleEntryResponseComponent() {
2100        super();
2101      }
2102
2103    /**
2104     * Constructor
2105     */
2106      public BundleEntryResponseComponent(StringType status) {
2107        super();
2108        this.status = status;
2109      }
2110
2111        /**
2112         * @return {@link #status} (The status code returned by processing this entry. The status SHALL start with a 3 digit HTTP code (e.g. 404) and may contain the standard HTTP description associated with the status code.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2113         */
2114        public StringType getStatusElement() { 
2115          if (this.status == null)
2116            if (Configuration.errorOnAutoCreate())
2117              throw new Error("Attempt to auto-create BundleEntryResponseComponent.status");
2118            else if (Configuration.doAutoCreate())
2119              this.status = new StringType(); // bb
2120          return this.status;
2121        }
2122
2123        public boolean hasStatusElement() { 
2124          return this.status != null && !this.status.isEmpty();
2125        }
2126
2127        public boolean hasStatus() { 
2128          return this.status != null && !this.status.isEmpty();
2129        }
2130
2131        /**
2132         * @param value {@link #status} (The status code returned by processing this entry. The status SHALL start with a 3 digit HTTP code (e.g. 404) and may contain the standard HTTP description associated with the status code.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2133         */
2134        public BundleEntryResponseComponent setStatusElement(StringType value) { 
2135          this.status = value;
2136          return this;
2137        }
2138
2139        /**
2140         * @return The status code returned by processing this entry. The status SHALL start with a 3 digit HTTP code (e.g. 404) and may contain the standard HTTP description associated with the status code.
2141         */
2142        public String getStatus() { 
2143          return this.status == null ? null : this.status.getValue();
2144        }
2145
2146        /**
2147         * @param value The status code returned by processing this entry. The status SHALL start with a 3 digit HTTP code (e.g. 404) and may contain the standard HTTP description associated with the status code.
2148         */
2149        public BundleEntryResponseComponent setStatus(String value) { 
2150            if (this.status == null)
2151              this.status = new StringType();
2152            this.status.setValue(value);
2153          return this;
2154        }
2155
2156        /**
2157         * @return {@link #location} (The location header created by processing this operation, populated if the operation returns a location.). This is the underlying object with id, value and extensions. The accessor "getLocation" gives direct access to the value
2158         */
2159        public UriType getLocationElement() { 
2160          if (this.location == null)
2161            if (Configuration.errorOnAutoCreate())
2162              throw new Error("Attempt to auto-create BundleEntryResponseComponent.location");
2163            else if (Configuration.doAutoCreate())
2164              this.location = new UriType(); // bb
2165          return this.location;
2166        }
2167
2168        public boolean hasLocationElement() { 
2169          return this.location != null && !this.location.isEmpty();
2170        }
2171
2172        public boolean hasLocation() { 
2173          return this.location != null && !this.location.isEmpty();
2174        }
2175
2176        /**
2177         * @param value {@link #location} (The location header created by processing this operation, populated if the operation returns a location.). This is the underlying object with id, value and extensions. The accessor "getLocation" gives direct access to the value
2178         */
2179        public BundleEntryResponseComponent setLocationElement(UriType value) { 
2180          this.location = value;
2181          return this;
2182        }
2183
2184        /**
2185         * @return The location header created by processing this operation, populated if the operation returns a location.
2186         */
2187        public String getLocation() { 
2188          return this.location == null ? null : this.location.getValue();
2189        }
2190
2191        /**
2192         * @param value The location header created by processing this operation, populated if the operation returns a location.
2193         */
2194        public BundleEntryResponseComponent setLocation(String value) { 
2195          if (Utilities.noString(value))
2196            this.location = null;
2197          else {
2198            if (this.location == null)
2199              this.location = new UriType();
2200            this.location.setValue(value);
2201          }
2202          return this;
2203        }
2204
2205        /**
2206         * @return {@link #etag} (The Etag for the resource, if the operation for the entry produced a versioned resource (see [Resource Metadata and Versioning](http.html#versioning) and [Managing Resource Contention](http.html#concurrency)).). This is the underlying object with id, value and extensions. The accessor "getEtag" gives direct access to the value
2207         */
2208        public StringType getEtagElement() { 
2209          if (this.etag == null)
2210            if (Configuration.errorOnAutoCreate())
2211              throw new Error("Attempt to auto-create BundleEntryResponseComponent.etag");
2212            else if (Configuration.doAutoCreate())
2213              this.etag = new StringType(); // bb
2214          return this.etag;
2215        }
2216
2217        public boolean hasEtagElement() { 
2218          return this.etag != null && !this.etag.isEmpty();
2219        }
2220
2221        public boolean hasEtag() { 
2222          return this.etag != null && !this.etag.isEmpty();
2223        }
2224
2225        /**
2226         * @param value {@link #etag} (The Etag for the resource, if the operation for the entry produced a versioned resource (see [Resource Metadata and Versioning](http.html#versioning) and [Managing Resource Contention](http.html#concurrency)).). This is the underlying object with id, value and extensions. The accessor "getEtag" gives direct access to the value
2227         */
2228        public BundleEntryResponseComponent setEtagElement(StringType value) { 
2229          this.etag = value;
2230          return this;
2231        }
2232
2233        /**
2234         * @return The Etag for the resource, if the operation for the entry produced a versioned resource (see [Resource Metadata and Versioning](http.html#versioning) and [Managing Resource Contention](http.html#concurrency)).
2235         */
2236        public String getEtag() { 
2237          return this.etag == null ? null : this.etag.getValue();
2238        }
2239
2240        /**
2241         * @param value The Etag for the resource, if the operation for the entry produced a versioned resource (see [Resource Metadata and Versioning](http.html#versioning) and [Managing Resource Contention](http.html#concurrency)).
2242         */
2243        public BundleEntryResponseComponent setEtag(String value) { 
2244          if (Utilities.noString(value))
2245            this.etag = null;
2246          else {
2247            if (this.etag == null)
2248              this.etag = new StringType();
2249            this.etag.setValue(value);
2250          }
2251          return this;
2252        }
2253
2254        /**
2255         * @return {@link #lastModified} (The date/time that the resource was modified on the server.). This is the underlying object with id, value and extensions. The accessor "getLastModified" gives direct access to the value
2256         */
2257        public InstantType getLastModifiedElement() { 
2258          if (this.lastModified == null)
2259            if (Configuration.errorOnAutoCreate())
2260              throw new Error("Attempt to auto-create BundleEntryResponseComponent.lastModified");
2261            else if (Configuration.doAutoCreate())
2262              this.lastModified = new InstantType(); // bb
2263          return this.lastModified;
2264        }
2265
2266        public boolean hasLastModifiedElement() { 
2267          return this.lastModified != null && !this.lastModified.isEmpty();
2268        }
2269
2270        public boolean hasLastModified() { 
2271          return this.lastModified != null && !this.lastModified.isEmpty();
2272        }
2273
2274        /**
2275         * @param value {@link #lastModified} (The date/time that the resource was modified on the server.). This is the underlying object with id, value and extensions. The accessor "getLastModified" gives direct access to the value
2276         */
2277        public BundleEntryResponseComponent setLastModifiedElement(InstantType value) { 
2278          this.lastModified = value;
2279          return this;
2280        }
2281
2282        /**
2283         * @return The date/time that the resource was modified on the server.
2284         */
2285        public Date getLastModified() { 
2286          return this.lastModified == null ? null : this.lastModified.getValue();
2287        }
2288
2289        /**
2290         * @param value The date/time that the resource was modified on the server.
2291         */
2292        public BundleEntryResponseComponent setLastModified(Date value) { 
2293          if (value == null)
2294            this.lastModified = null;
2295          else {
2296            if (this.lastModified == null)
2297              this.lastModified = new InstantType();
2298            this.lastModified.setValue(value);
2299          }
2300          return this;
2301        }
2302
2303        /**
2304         * @return {@link #outcome} (An OperationOutcome containing hints and warnings produced as part of processing this entry in a batch or transaction.)
2305         */
2306        public Resource getOutcome() { 
2307          return this.outcome;
2308        }
2309
2310        public boolean hasOutcome() { 
2311          return this.outcome != null && !this.outcome.isEmpty();
2312        }
2313
2314        /**
2315         * @param value {@link #outcome} (An OperationOutcome containing hints and warnings produced as part of processing this entry in a batch or transaction.)
2316         */
2317        public BundleEntryResponseComponent setOutcome(Resource value) { 
2318          this.outcome = value;
2319          return this;
2320        }
2321
2322        protected void listChildren(List<Property> children) {
2323          super.listChildren(children);
2324          children.add(new Property("status", "string", "The status code returned by processing this entry. The status SHALL start with a 3 digit HTTP code (e.g. 404) and may contain the standard HTTP description associated with the status code.", 0, 1, status));
2325          children.add(new Property("location", "uri", "The location header created by processing this operation, populated if the operation returns a location.", 0, 1, location));
2326          children.add(new Property("etag", "string", "The Etag for the resource, if the operation for the entry produced a versioned resource (see [Resource Metadata and Versioning](http.html#versioning) and [Managing Resource Contention](http.html#concurrency)).", 0, 1, etag));
2327          children.add(new Property("lastModified", "instant", "The date/time that the resource was modified on the server.", 0, 1, lastModified));
2328          children.add(new Property("outcome", "Resource", "An OperationOutcome containing hints and warnings produced as part of processing this entry in a batch or transaction.", 0, 1, outcome));
2329        }
2330
2331        @Override
2332        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2333          switch (_hash) {
2334          case -892481550: /*status*/  return new Property("status", "string", "The status code returned by processing this entry. The status SHALL start with a 3 digit HTTP code (e.g. 404) and may contain the standard HTTP description associated with the status code.", 0, 1, status);
2335          case 1901043637: /*location*/  return new Property("location", "uri", "The location header created by processing this operation, populated if the operation returns a location.", 0, 1, location);
2336          case 3123477: /*etag*/  return new Property("etag", "string", "The Etag for the resource, if the operation for the entry produced a versioned resource (see [Resource Metadata and Versioning](http.html#versioning) and [Managing Resource Contention](http.html#concurrency)).", 0, 1, etag);
2337          case 1959003007: /*lastModified*/  return new Property("lastModified", "instant", "The date/time that the resource was modified on the server.", 0, 1, lastModified);
2338          case -1106507950: /*outcome*/  return new Property("outcome", "Resource", "An OperationOutcome containing hints and warnings produced as part of processing this entry in a batch or transaction.", 0, 1, outcome);
2339          default: return super.getNamedProperty(_hash, _name, _checkValid);
2340          }
2341
2342        }
2343
2344      @Override
2345      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2346        switch (hash) {
2347        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // StringType
2348        case 1901043637: /*location*/ return this.location == null ? new Base[0] : new Base[] {this.location}; // UriType
2349        case 3123477: /*etag*/ return this.etag == null ? new Base[0] : new Base[] {this.etag}; // StringType
2350        case 1959003007: /*lastModified*/ return this.lastModified == null ? new Base[0] : new Base[] {this.lastModified}; // InstantType
2351        case -1106507950: /*outcome*/ return this.outcome == null ? new Base[0] : new Base[] {this.outcome}; // Resource
2352        default: return super.getProperty(hash, name, checkValid);
2353        }
2354
2355      }
2356
2357      @Override
2358      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2359        switch (hash) {
2360        case -892481550: // status
2361          this.status = castToString(value); // StringType
2362          return value;
2363        case 1901043637: // location
2364          this.location = castToUri(value); // UriType
2365          return value;
2366        case 3123477: // etag
2367          this.etag = castToString(value); // StringType
2368          return value;
2369        case 1959003007: // lastModified
2370          this.lastModified = castToInstant(value); // InstantType
2371          return value;
2372        case -1106507950: // outcome
2373          this.outcome = castToResource(value); // Resource
2374          return value;
2375        default: return super.setProperty(hash, name, value);
2376        }
2377
2378      }
2379
2380      @Override
2381      public Base setProperty(String name, Base value) throws FHIRException {
2382        if (name.equals("status")) {
2383          this.status = castToString(value); // StringType
2384        } else if (name.equals("location")) {
2385          this.location = castToUri(value); // UriType
2386        } else if (name.equals("etag")) {
2387          this.etag = castToString(value); // StringType
2388        } else if (name.equals("lastModified")) {
2389          this.lastModified = castToInstant(value); // InstantType
2390        } else if (name.equals("outcome")) {
2391          this.outcome = castToResource(value); // Resource
2392        } else
2393          return super.setProperty(name, value);
2394        return value;
2395      }
2396
2397      @Override
2398      public Base makeProperty(int hash, String name) throws FHIRException {
2399        switch (hash) {
2400        case -892481550:  return getStatusElement();
2401        case 1901043637:  return getLocationElement();
2402        case 3123477:  return getEtagElement();
2403        case 1959003007:  return getLastModifiedElement();
2404        case -1106507950: throw new FHIRException("Cannot make property outcome as it is not a complex type"); // Resource
2405        default: return super.makeProperty(hash, name);
2406        }
2407
2408      }
2409
2410      @Override
2411      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2412        switch (hash) {
2413        case -892481550: /*status*/ return new String[] {"string"};
2414        case 1901043637: /*location*/ return new String[] {"uri"};
2415        case 3123477: /*etag*/ return new String[] {"string"};
2416        case 1959003007: /*lastModified*/ return new String[] {"instant"};
2417        case -1106507950: /*outcome*/ return new String[] {"Resource"};
2418        default: return super.getTypesForProperty(hash, name);
2419        }
2420
2421      }
2422
2423      @Override
2424      public Base addChild(String name) throws FHIRException {
2425        if (name.equals("status")) {
2426          throw new FHIRException("Cannot call addChild on a primitive type Bundle.status");
2427        }
2428        else if (name.equals("location")) {
2429          throw new FHIRException("Cannot call addChild on a primitive type Bundle.location");
2430        }
2431        else if (name.equals("etag")) {
2432          throw new FHIRException("Cannot call addChild on a primitive type Bundle.etag");
2433        }
2434        else if (name.equals("lastModified")) {
2435          throw new FHIRException("Cannot call addChild on a primitive type Bundle.lastModified");
2436        }
2437        else if (name.equals("outcome")) {
2438          throw new FHIRException("Cannot call addChild on an abstract type Bundle.outcome");
2439        }
2440        else
2441          return super.addChild(name);
2442      }
2443
2444      public BundleEntryResponseComponent copy() {
2445        BundleEntryResponseComponent dst = new BundleEntryResponseComponent();
2446        copyValues(dst);
2447        dst.status = status == null ? null : status.copy();
2448        dst.location = location == null ? null : location.copy();
2449        dst.etag = etag == null ? null : etag.copy();
2450        dst.lastModified = lastModified == null ? null : lastModified.copy();
2451        dst.outcome = outcome == null ? null : outcome.copy();
2452        return dst;
2453      }
2454
2455      @Override
2456      public boolean equalsDeep(Base other_) {
2457        if (!super.equalsDeep(other_))
2458          return false;
2459        if (!(other_ instanceof BundleEntryResponseComponent))
2460          return false;
2461        BundleEntryResponseComponent o = (BundleEntryResponseComponent) other_;
2462        return compareDeep(status, o.status, true) && compareDeep(location, o.location, true) && compareDeep(etag, o.etag, true)
2463           && compareDeep(lastModified, o.lastModified, true) && compareDeep(outcome, o.outcome, true);
2464      }
2465
2466      @Override
2467      public boolean equalsShallow(Base other_) {
2468        if (!super.equalsShallow(other_))
2469          return false;
2470        if (!(other_ instanceof BundleEntryResponseComponent))
2471          return false;
2472        BundleEntryResponseComponent o = (BundleEntryResponseComponent) other_;
2473        return compareValues(status, o.status, true) && compareValues(location, o.location, true) && compareValues(etag, o.etag, true)
2474           && compareValues(lastModified, o.lastModified, true);
2475      }
2476
2477      public boolean isEmpty() {
2478        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(status, location, etag, lastModified
2479          , outcome);
2480      }
2481
2482  public String fhirType() {
2483    return "Bundle.entry.response";
2484
2485  }
2486
2487  }
2488
2489    /**
2490     * A persistent identifier for the bundle that won't change as a bundle is copied from server to server.
2491     */
2492    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=1, modifier=false, summary=true)
2493    @Description(shortDefinition="Persistent identifier for the bundle", formalDefinition="A persistent identifier for the bundle that won't change as a bundle is copied from server to server." )
2494    protected Identifier identifier;
2495
2496    /**
2497     * Indicates the purpose of this bundle - how it is intended to be used.
2498     */
2499    @Child(name = "type", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=true)
2500    @Description(shortDefinition="document | message | transaction | transaction-response | batch | batch-response | history | searchset | collection", formalDefinition="Indicates the purpose of this bundle - how it is intended to be used." )
2501    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/bundle-type")
2502    protected Enumeration<BundleType> type;
2503
2504    /**
2505     * The date/time that the bundle was assembled - i.e. when the resources were placed in the bundle.
2506     */
2507    @Child(name = "timestamp", type = {InstantType.class}, order=2, min=0, max=1, modifier=false, summary=true)
2508    @Description(shortDefinition="When the bundle was assembled", formalDefinition="The date/time that the bundle was assembled - i.e. when the resources were placed in the bundle." )
2509    protected InstantType timestamp;
2510
2511    /**
2512     * If a set of search matches, this is the total number of entries of type 'match' across all pages in the search.  It does not include search.mode = 'include' or 'outcome' entries and it does not provide a count of the number of entries in the Bundle.
2513     */
2514    @Child(name = "total", type = {UnsignedIntType.class}, order=3, min=0, max=1, modifier=false, summary=true)
2515    @Description(shortDefinition="If search, the total number of matches", formalDefinition="If a set of search matches, this is the total number of entries of type 'match' across all pages in the search.  It does not include search.mode = 'include' or 'outcome' entries and it does not provide a count of the number of entries in the Bundle." )
2516    protected UnsignedIntType total;
2517
2518    /**
2519     * A series of links that provide context to this bundle.
2520     */
2521    @Child(name = "link", type = {}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2522    @Description(shortDefinition="Links related to this Bundle", formalDefinition="A series of links that provide context to this bundle." )
2523    protected List<BundleLinkComponent> link;
2524
2525    /**
2526     * An entry in a bundle resource - will either contain a resource or information about a resource (transactions and history only).
2527     */
2528    @Child(name = "entry", type = {}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2529    @Description(shortDefinition="Entry in the bundle - will have a resource or information", formalDefinition="An entry in a bundle resource - will either contain a resource or information about a resource (transactions and history only)." )
2530    protected List<BundleEntryComponent> entry;
2531
2532    /**
2533     * Digital Signature - base64 encoded. XML-DSig or a JWT.
2534     */
2535    @Child(name = "signature", type = {Signature.class}, order=6, min=0, max=1, modifier=false, summary=true)
2536    @Description(shortDefinition="Digital Signature", formalDefinition="Digital Signature - base64 encoded. XML-DSig or a JWT." )
2537    protected Signature signature;
2538
2539    private static final long serialVersionUID = 1740470158L;
2540
2541  /**
2542   * Constructor
2543   */
2544    public Bundle() {
2545      super();
2546    }
2547
2548  /**
2549   * Constructor
2550   */
2551    public Bundle(Enumeration<BundleType> type) {
2552      super();
2553      this.type = type;
2554    }
2555
2556    /**
2557     * @return {@link #identifier} (A persistent identifier for the bundle that won't change as a bundle is copied from server to server.)
2558     */
2559    public Identifier getIdentifier() { 
2560      if (this.identifier == null)
2561        if (Configuration.errorOnAutoCreate())
2562          throw new Error("Attempt to auto-create Bundle.identifier");
2563        else if (Configuration.doAutoCreate())
2564          this.identifier = new Identifier(); // cc
2565      return this.identifier;
2566    }
2567
2568    public boolean hasIdentifier() { 
2569      return this.identifier != null && !this.identifier.isEmpty();
2570    }
2571
2572    /**
2573     * @param value {@link #identifier} (A persistent identifier for the bundle that won't change as a bundle is copied from server to server.)
2574     */
2575    public Bundle setIdentifier(Identifier value) { 
2576      this.identifier = value;
2577      return this;
2578    }
2579
2580    /**
2581     * @return {@link #type} (Indicates the purpose of this bundle - how it is intended to be used.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
2582     */
2583    public Enumeration<BundleType> getTypeElement() { 
2584      if (this.type == null)
2585        if (Configuration.errorOnAutoCreate())
2586          throw new Error("Attempt to auto-create Bundle.type");
2587        else if (Configuration.doAutoCreate())
2588          this.type = new Enumeration<BundleType>(new BundleTypeEnumFactory()); // bb
2589      return this.type;
2590    }
2591
2592    public boolean hasTypeElement() { 
2593      return this.type != null && !this.type.isEmpty();
2594    }
2595
2596    public boolean hasType() { 
2597      return this.type != null && !this.type.isEmpty();
2598    }
2599
2600    /**
2601     * @param value {@link #type} (Indicates the purpose of this bundle - how it is intended to be used.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
2602     */
2603    public Bundle setTypeElement(Enumeration<BundleType> value) { 
2604      this.type = value;
2605      return this;
2606    }
2607
2608    /**
2609     * @return Indicates the purpose of this bundle - how it is intended to be used.
2610     */
2611    public BundleType getType() { 
2612      return this.type == null ? null : this.type.getValue();
2613    }
2614
2615    /**
2616     * @param value Indicates the purpose of this bundle - how it is intended to be used.
2617     */
2618    public Bundle setType(BundleType value) { 
2619        if (this.type == null)
2620          this.type = new Enumeration<BundleType>(new BundleTypeEnumFactory());
2621        this.type.setValue(value);
2622      return this;
2623    }
2624
2625    /**
2626     * @return {@link #timestamp} (The date/time that the bundle was assembled - i.e. when the resources were placed in the bundle.). This is the underlying object with id, value and extensions. The accessor "getTimestamp" gives direct access to the value
2627     */
2628    public InstantType getTimestampElement() { 
2629      if (this.timestamp == null)
2630        if (Configuration.errorOnAutoCreate())
2631          throw new Error("Attempt to auto-create Bundle.timestamp");
2632        else if (Configuration.doAutoCreate())
2633          this.timestamp = new InstantType(); // bb
2634      return this.timestamp;
2635    }
2636
2637    public boolean hasTimestampElement() { 
2638      return this.timestamp != null && !this.timestamp.isEmpty();
2639    }
2640
2641    public boolean hasTimestamp() { 
2642      return this.timestamp != null && !this.timestamp.isEmpty();
2643    }
2644
2645    /**
2646     * @param value {@link #timestamp} (The date/time that the bundle was assembled - i.e. when the resources were placed in the bundle.). This is the underlying object with id, value and extensions. The accessor "getTimestamp" gives direct access to the value
2647     */
2648    public Bundle setTimestampElement(InstantType value) { 
2649      this.timestamp = value;
2650      return this;
2651    }
2652
2653    /**
2654     * @return The date/time that the bundle was assembled - i.e. when the resources were placed in the bundle.
2655     */
2656    public Date getTimestamp() { 
2657      return this.timestamp == null ? null : this.timestamp.getValue();
2658    }
2659
2660    /**
2661     * @param value The date/time that the bundle was assembled - i.e. when the resources were placed in the bundle.
2662     */
2663    public Bundle setTimestamp(Date value) { 
2664      if (value == null)
2665        this.timestamp = null;
2666      else {
2667        if (this.timestamp == null)
2668          this.timestamp = new InstantType();
2669        this.timestamp.setValue(value);
2670      }
2671      return this;
2672    }
2673
2674    /**
2675     * @return {@link #total} (If a set of search matches, this is the total number of entries of type 'match' across all pages in the search.  It does not include search.mode = 'include' or 'outcome' entries and it does not provide a count of the number of entries in the Bundle.). This is the underlying object with id, value and extensions. The accessor "getTotal" gives direct access to the value
2676     */
2677    public UnsignedIntType getTotalElement() { 
2678      if (this.total == null)
2679        if (Configuration.errorOnAutoCreate())
2680          throw new Error("Attempt to auto-create Bundle.total");
2681        else if (Configuration.doAutoCreate())
2682          this.total = new UnsignedIntType(); // bb
2683      return this.total;
2684    }
2685
2686    public boolean hasTotalElement() { 
2687      return this.total != null && !this.total.isEmpty();
2688    }
2689
2690    public boolean hasTotal() { 
2691      return this.total != null && !this.total.isEmpty();
2692    }
2693
2694    /**
2695     * @param value {@link #total} (If a set of search matches, this is the total number of entries of type 'match' across all pages in the search.  It does not include search.mode = 'include' or 'outcome' entries and it does not provide a count of the number of entries in the Bundle.). This is the underlying object with id, value and extensions. The accessor "getTotal" gives direct access to the value
2696     */
2697    public Bundle setTotalElement(UnsignedIntType value) { 
2698      this.total = value;
2699      return this;
2700    }
2701
2702    /**
2703     * @return If a set of search matches, this is the total number of entries of type 'match' across all pages in the search.  It does not include search.mode = 'include' or 'outcome' entries and it does not provide a count of the number of entries in the Bundle.
2704     */
2705    public int getTotal() { 
2706      return this.total == null || this.total.isEmpty() ? 0 : this.total.getValue();
2707    }
2708
2709    /**
2710     * @param value If a set of search matches, this is the total number of entries of type 'match' across all pages in the search.  It does not include search.mode = 'include' or 'outcome' entries and it does not provide a count of the number of entries in the Bundle.
2711     */
2712    public Bundle setTotal(int value) { 
2713        if (this.total == null)
2714          this.total = new UnsignedIntType();
2715        this.total.setValue(value);
2716      return this;
2717    }
2718
2719    /**
2720     * @return {@link #link} (A series of links that provide context to this bundle.)
2721     */
2722    public List<BundleLinkComponent> getLink() { 
2723      if (this.link == null)
2724        this.link = new ArrayList<BundleLinkComponent>();
2725      return this.link;
2726    }
2727
2728    /**
2729     * @return Returns a reference to <code>this</code> for easy method chaining
2730     */
2731    public Bundle setLink(List<BundleLinkComponent> theLink) { 
2732      this.link = theLink;
2733      return this;
2734    }
2735
2736    public boolean hasLink() { 
2737      if (this.link == null)
2738        return false;
2739      for (BundleLinkComponent item : this.link)
2740        if (!item.isEmpty())
2741          return true;
2742      return false;
2743    }
2744
2745    public BundleLinkComponent addLink() { //3
2746      BundleLinkComponent t = new BundleLinkComponent();
2747      if (this.link == null)
2748        this.link = new ArrayList<BundleLinkComponent>();
2749      this.link.add(t);
2750      return t;
2751    }
2752
2753    public Bundle addLink(BundleLinkComponent t) { //3
2754      if (t == null)
2755        return this;
2756      if (this.link == null)
2757        this.link = new ArrayList<BundleLinkComponent>();
2758      this.link.add(t);
2759      return this;
2760    }
2761
2762    /**
2763     * @return The first repetition of repeating field {@link #link}, creating it if it does not already exist
2764     */
2765    public BundleLinkComponent getLinkFirstRep() { 
2766      if (getLink().isEmpty()) {
2767        addLink();
2768      }
2769      return getLink().get(0);
2770    }
2771
2772    /**
2773     * @return {@link #entry} (An entry in a bundle resource - will either contain a resource or information about a resource (transactions and history only).)
2774     */
2775    public List<BundleEntryComponent> getEntry() { 
2776      if (this.entry == null)
2777        this.entry = new ArrayList<BundleEntryComponent>();
2778      return this.entry;
2779    }
2780
2781    /**
2782     * @return Returns a reference to <code>this</code> for easy method chaining
2783     */
2784    public Bundle setEntry(List<BundleEntryComponent> theEntry) { 
2785      this.entry = theEntry;
2786      return this;
2787    }
2788
2789    public boolean hasEntry() { 
2790      if (this.entry == null)
2791        return false;
2792      for (BundleEntryComponent item : this.entry)
2793        if (!item.isEmpty())
2794          return true;
2795      return false;
2796    }
2797
2798    public BundleEntryComponent addEntry() { //3
2799      BundleEntryComponent t = new BundleEntryComponent();
2800      if (this.entry == null)
2801        this.entry = new ArrayList<BundleEntryComponent>();
2802      this.entry.add(t);
2803      return t;
2804    }
2805
2806    public Bundle addEntry(BundleEntryComponent t) { //3
2807      if (t == null)
2808        return this;
2809      if (this.entry == null)
2810        this.entry = new ArrayList<BundleEntryComponent>();
2811      this.entry.add(t);
2812      return this;
2813    }
2814
2815    /**
2816     * @return The first repetition of repeating field {@link #entry}, creating it if it does not already exist
2817     */
2818    public BundleEntryComponent getEntryFirstRep() { 
2819      if (getEntry().isEmpty()) {
2820        addEntry();
2821      }
2822      return getEntry().get(0);
2823    }
2824
2825    /**
2826     * @return {@link #signature} (Digital Signature - base64 encoded. XML-DSig or a JWT.)
2827     */
2828    public Signature getSignature() { 
2829      if (this.signature == null)
2830        if (Configuration.errorOnAutoCreate())
2831          throw new Error("Attempt to auto-create Bundle.signature");
2832        else if (Configuration.doAutoCreate())
2833          this.signature = new Signature(); // cc
2834      return this.signature;
2835    }
2836
2837    public boolean hasSignature() { 
2838      return this.signature != null && !this.signature.isEmpty();
2839    }
2840
2841    /**
2842     * @param value {@link #signature} (Digital Signature - base64 encoded. XML-DSig or a JWT.)
2843     */
2844    public Bundle setSignature(Signature value) { 
2845      this.signature = value;
2846      return this;
2847    }
2848
2849 /**
2850   * Returns the {@link #getLink() link} which matches a given {@link BundleLinkComponent#getRelation() relation}. 
2851   * If no link is found which matches the given relation, returns <code>null</code>. If more than one
2852   * link is found which matches the given relation, returns the first matching BundleLinkComponent.
2853   * 
2854   * @param theRelation
2855   *            The relation, such as "next", or "self. See the constants such as {@link IBaseBundle#LINK_SELF} and {@link IBaseBundle#LINK_NEXT}.
2856   * @return Returns a matching BundleLinkComponent, or <code>null</code>
2857   * @see IBaseBundle#LINK_NEXT
2858   * @see IBaseBundle#LINK_PREV
2859   * @see IBaseBundle#LINK_SELF
2860   */
2861  public BundleLinkComponent getLink(String theRelation) {
2862    org.apache.commons.lang3.Validate.notBlank(theRelation, "theRelation may not be null or empty");
2863    for (BundleLinkComponent next : getLink()) {
2864      if (theRelation.equals(next.getRelation())) {
2865        return next;
2866      }
2867    }
2868    return null;
2869  }
2870
2871  /**
2872   * Returns the {@link #getLink() link} which matches a given {@link BundleLinkComponent#getRelation() relation}. 
2873   * If no link is found which matches the given relation, creates a new BundleLinkComponent with the
2874   * given relation and adds it to this Bundle. If more than one
2875   * link is found which matches the given relation, returns the first matching BundleLinkComponent.
2876   * 
2877   * @param theRelation
2878   *            The relation, such as "next", or "self. See the constants such as {@link IBaseBundle#LINK_SELF} and {@link IBaseBundle#LINK_NEXT}.
2879   * @return Returns a matching BundleLinkComponent, or <code>null</code>
2880   * @see IBaseBundle#LINK_NEXT
2881   * @see IBaseBundle#LINK_PREV
2882   * @see IBaseBundle#LINK_SELF
2883   */
2884  public BundleLinkComponent getLinkOrCreate(String theRelation) {
2885    org.apache.commons.lang3.Validate.notBlank(theRelation, "theRelation may not be null or empty");
2886    for (BundleLinkComponent next : getLink()) {
2887      if (theRelation.equals(next.getRelation())) {
2888        return next;
2889      }
2890    }
2891    BundleLinkComponent retVal = new BundleLinkComponent();
2892    retVal.setRelation(theRelation);
2893    getLink().add(retVal);
2894    return retVal;
2895  }
2896      protected void listChildren(List<Property> children) {
2897        super.listChildren(children);
2898        children.add(new Property("identifier", "Identifier", "A persistent identifier for the bundle that won't change as a bundle is copied from server to server.", 0, 1, identifier));
2899        children.add(new Property("type", "code", "Indicates the purpose of this bundle - how it is intended to be used.", 0, 1, type));
2900        children.add(new Property("timestamp", "instant", "The date/time that the bundle was assembled - i.e. when the resources were placed in the bundle.", 0, 1, timestamp));
2901        children.add(new Property("total", "unsignedInt", "If a set of search matches, this is the total number of entries of type 'match' across all pages in the search.  It does not include search.mode = 'include' or 'outcome' entries and it does not provide a count of the number of entries in the Bundle.", 0, 1, total));
2902        children.add(new Property("link", "", "A series of links that provide context to this bundle.", 0, java.lang.Integer.MAX_VALUE, link));
2903        children.add(new Property("entry", "", "An entry in a bundle resource - will either contain a resource or information about a resource (transactions and history only).", 0, java.lang.Integer.MAX_VALUE, entry));
2904        children.add(new Property("signature", "Signature", "Digital Signature - base64 encoded. XML-DSig or a JWT.", 0, 1, signature));
2905      }
2906
2907      @Override
2908      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2909        switch (_hash) {
2910        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "A persistent identifier for the bundle that won't change as a bundle is copied from server to server.", 0, 1, identifier);
2911        case 3575610: /*type*/  return new Property("type", "code", "Indicates the purpose of this bundle - how it is intended to be used.", 0, 1, type);
2912        case 55126294: /*timestamp*/  return new Property("timestamp", "instant", "The date/time that the bundle was assembled - i.e. when the resources were placed in the bundle.", 0, 1, timestamp);
2913        case 110549828: /*total*/  return new Property("total", "unsignedInt", "If a set of search matches, this is the total number of entries of type 'match' across all pages in the search.  It does not include search.mode = 'include' or 'outcome' entries and it does not provide a count of the number of entries in the Bundle.", 0, 1, total);
2914        case 3321850: /*link*/  return new Property("link", "", "A series of links that provide context to this bundle.", 0, java.lang.Integer.MAX_VALUE, link);
2915        case 96667762: /*entry*/  return new Property("entry", "", "An entry in a bundle resource - will either contain a resource or information about a resource (transactions and history only).", 0, java.lang.Integer.MAX_VALUE, entry);
2916        case 1073584312: /*signature*/  return new Property("signature", "Signature", "Digital Signature - base64 encoded. XML-DSig or a JWT.", 0, 1, signature);
2917        default: return super.getNamedProperty(_hash, _name, _checkValid);
2918        }
2919
2920      }
2921
2922      @Override
2923      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2924        switch (hash) {
2925        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
2926        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // Enumeration<BundleType>
2927        case 55126294: /*timestamp*/ return this.timestamp == null ? new Base[0] : new Base[] {this.timestamp}; // InstantType
2928        case 110549828: /*total*/ return this.total == null ? new Base[0] : new Base[] {this.total}; // UnsignedIntType
2929        case 3321850: /*link*/ return this.link == null ? new Base[0] : this.link.toArray(new Base[this.link.size()]); // BundleLinkComponent
2930        case 96667762: /*entry*/ return this.entry == null ? new Base[0] : this.entry.toArray(new Base[this.entry.size()]); // BundleEntryComponent
2931        case 1073584312: /*signature*/ return this.signature == null ? new Base[0] : new Base[] {this.signature}; // Signature
2932        default: return super.getProperty(hash, name, checkValid);
2933        }
2934
2935      }
2936
2937      @Override
2938      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2939        switch (hash) {
2940        case -1618432855: // identifier
2941          this.identifier = castToIdentifier(value); // Identifier
2942          return value;
2943        case 3575610: // type
2944          value = new BundleTypeEnumFactory().fromType(castToCode(value));
2945          this.type = (Enumeration) value; // Enumeration<BundleType>
2946          return value;
2947        case 55126294: // timestamp
2948          this.timestamp = castToInstant(value); // InstantType
2949          return value;
2950        case 110549828: // total
2951          this.total = castToUnsignedInt(value); // UnsignedIntType
2952          return value;
2953        case 3321850: // link
2954          this.getLink().add((BundleLinkComponent) value); // BundleLinkComponent
2955          return value;
2956        case 96667762: // entry
2957          this.getEntry().add((BundleEntryComponent) value); // BundleEntryComponent
2958          return value;
2959        case 1073584312: // signature
2960          this.signature = castToSignature(value); // Signature
2961          return value;
2962        default: return super.setProperty(hash, name, value);
2963        }
2964
2965      }
2966
2967      @Override
2968      public Base setProperty(String name, Base value) throws FHIRException {
2969        if (name.equals("identifier")) {
2970          this.identifier = castToIdentifier(value); // Identifier
2971        } else if (name.equals("type")) {
2972          value = new BundleTypeEnumFactory().fromType(castToCode(value));
2973          this.type = (Enumeration) value; // Enumeration<BundleType>
2974        } else if (name.equals("timestamp")) {
2975          this.timestamp = castToInstant(value); // InstantType
2976        } else if (name.equals("total")) {
2977          this.total = castToUnsignedInt(value); // UnsignedIntType
2978        } else if (name.equals("link")) {
2979          this.getLink().add((BundleLinkComponent) value);
2980        } else if (name.equals("entry")) {
2981          this.getEntry().add((BundleEntryComponent) value);
2982        } else if (name.equals("signature")) {
2983          this.signature = castToSignature(value); // Signature
2984        } else
2985          return super.setProperty(name, value);
2986        return value;
2987      }
2988
2989      @Override
2990      public Base makeProperty(int hash, String name) throws FHIRException {
2991        switch (hash) {
2992        case -1618432855:  return getIdentifier(); 
2993        case 3575610:  return getTypeElement();
2994        case 55126294:  return getTimestampElement();
2995        case 110549828:  return getTotalElement();
2996        case 3321850:  return addLink(); 
2997        case 96667762:  return addEntry(); 
2998        case 1073584312:  return getSignature(); 
2999        default: return super.makeProperty(hash, name);
3000        }
3001
3002      }
3003
3004      @Override
3005      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
3006        switch (hash) {
3007        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
3008        case 3575610: /*type*/ return new String[] {"code"};
3009        case 55126294: /*timestamp*/ return new String[] {"instant"};
3010        case 110549828: /*total*/ return new String[] {"unsignedInt"};
3011        case 3321850: /*link*/ return new String[] {};
3012        case 96667762: /*entry*/ return new String[] {};
3013        case 1073584312: /*signature*/ return new String[] {"Signature"};
3014        default: return super.getTypesForProperty(hash, name);
3015        }
3016
3017      }
3018
3019      @Override
3020      public Base addChild(String name) throws FHIRException {
3021        if (name.equals("identifier")) {
3022          this.identifier = new Identifier();
3023          return this.identifier;
3024        }
3025        else if (name.equals("type")) {
3026          throw new FHIRException("Cannot call addChild on a primitive type Bundle.type");
3027        }
3028        else if (name.equals("timestamp")) {
3029          throw new FHIRException("Cannot call addChild on a primitive type Bundle.timestamp");
3030        }
3031        else if (name.equals("total")) {
3032          throw new FHIRException("Cannot call addChild on a primitive type Bundle.total");
3033        }
3034        else if (name.equals("link")) {
3035          return addLink();
3036        }
3037        else if (name.equals("entry")) {
3038          return addEntry();
3039        }
3040        else if (name.equals("signature")) {
3041          this.signature = new Signature();
3042          return this.signature;
3043        }
3044        else
3045          return super.addChild(name);
3046      }
3047
3048  public String fhirType() {
3049    return "Bundle";
3050
3051  }
3052
3053      public Bundle copy() {
3054        Bundle dst = new Bundle();
3055        copyValues(dst);
3056        dst.identifier = identifier == null ? null : identifier.copy();
3057        dst.type = type == null ? null : type.copy();
3058        dst.timestamp = timestamp == null ? null : timestamp.copy();
3059        dst.total = total == null ? null : total.copy();
3060        if (link != null) {
3061          dst.link = new ArrayList<BundleLinkComponent>();
3062          for (BundleLinkComponent i : link)
3063            dst.link.add(i.copy());
3064        };
3065        if (entry != null) {
3066          dst.entry = new ArrayList<BundleEntryComponent>();
3067          for (BundleEntryComponent i : entry)
3068            dst.entry.add(i.copy());
3069        };
3070        dst.signature = signature == null ? null : signature.copy();
3071        return dst;
3072      }
3073
3074      protected Bundle typedCopy() {
3075        return copy();
3076      }
3077
3078      @Override
3079      public boolean equalsDeep(Base other_) {
3080        if (!super.equalsDeep(other_))
3081          return false;
3082        if (!(other_ instanceof Bundle))
3083          return false;
3084        Bundle o = (Bundle) other_;
3085        return compareDeep(identifier, o.identifier, true) && compareDeep(type, o.type, true) && compareDeep(timestamp, o.timestamp, true)
3086           && compareDeep(total, o.total, true) && compareDeep(link, o.link, true) && compareDeep(entry, o.entry, true)
3087           && compareDeep(signature, o.signature, true);
3088      }
3089
3090      @Override
3091      public boolean equalsShallow(Base other_) {
3092        if (!super.equalsShallow(other_))
3093          return false;
3094        if (!(other_ instanceof Bundle))
3095          return false;
3096        Bundle o = (Bundle) other_;
3097        return compareValues(type, o.type, true) && compareValues(timestamp, o.timestamp, true) && compareValues(total, o.total, true)
3098          ;
3099      }
3100
3101      public boolean isEmpty() {
3102        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, type, timestamp
3103          , total, link, entry, signature);
3104      }
3105
3106  @Override
3107  public ResourceType getResourceType() {
3108    return ResourceType.Bundle;
3109   }
3110
3111 /**
3112   * Search parameter: <b>identifier</b>
3113   * <p>
3114   * Description: <b>Persistent identifier for the bundle</b><br>
3115   * Type: <b>token</b><br>
3116   * Path: <b>Bundle.identifier</b><br>
3117   * </p>
3118   */
3119  @SearchParamDefinition(name="identifier", path="Bundle.identifier", description="Persistent identifier for the bundle", type="token" )
3120  public static final String SP_IDENTIFIER = "identifier";
3121 /**
3122   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
3123   * <p>
3124   * Description: <b>Persistent identifier for the bundle</b><br>
3125   * Type: <b>token</b><br>
3126   * Path: <b>Bundle.identifier</b><br>
3127   * </p>
3128   */
3129  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
3130
3131 /**
3132   * Search parameter: <b>composition</b>
3133   * <p>
3134   * Description: <b>The first resource in the bundle, if the bundle type is "document" - this is a composition, and this parameter provides access to search its contents</b><br>
3135   * Type: <b>reference</b><br>
3136   * Path: <b>Bundle.entry(0).resource</b><br>
3137   * </p>
3138   */
3139  @SearchParamDefinition(name="composition", path="Bundle.entry[0].resource", description="The first resource in the bundle, if the bundle type is \"document\" - this is a composition, and this parameter provides access to search its contents", type="reference", target={Composition.class } )
3140  public static final String SP_COMPOSITION = "composition";
3141 /**
3142   * <b>Fluent Client</b> search parameter constant for <b>composition</b>
3143   * <p>
3144   * Description: <b>The first resource in the bundle, if the bundle type is "document" - this is a composition, and this parameter provides access to search its contents</b><br>
3145   * Type: <b>reference</b><br>
3146   * Path: <b>Bundle.entry(0).resource</b><br>
3147   * </p>
3148   */
3149  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam COMPOSITION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_COMPOSITION);
3150
3151/**
3152   * Constant for fluent queries to be used to add include statements. Specifies
3153   * the path value of "<b>Bundle:composition</b>".
3154   */
3155  public static final ca.uhn.fhir.model.api.Include INCLUDE_COMPOSITION = new ca.uhn.fhir.model.api.Include("Bundle:composition").toLocked();
3156
3157 /**
3158   * Search parameter: <b>type</b>
3159   * <p>
3160   * Description: <b>document | message | transaction | transaction-response | batch | batch-response | history | searchset | collection</b><br>
3161   * Type: <b>token</b><br>
3162   * Path: <b>Bundle.type</b><br>
3163   * </p>
3164   */
3165  @SearchParamDefinition(name="type", path="Bundle.type", description="document | message | transaction | transaction-response | batch | batch-response | history | searchset | collection", type="token" )
3166  public static final String SP_TYPE = "type";
3167 /**
3168   * <b>Fluent Client</b> search parameter constant for <b>type</b>
3169   * <p>
3170   * Description: <b>document | message | transaction | transaction-response | batch | batch-response | history | searchset | collection</b><br>
3171   * Type: <b>token</b><br>
3172   * Path: <b>Bundle.type</b><br>
3173   * </p>
3174   */
3175  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
3176
3177 /**
3178   * Search parameter: <b>message</b>
3179   * <p>
3180   * Description: <b>The first resource in the bundle, if the bundle type is "message" - this is a message header, and this parameter provides access to search its contents</b><br>
3181   * Type: <b>reference</b><br>
3182   * Path: <b>Bundle.entry(0).resource</b><br>
3183   * </p>
3184   */
3185  @SearchParamDefinition(name="message", path="Bundle.entry[0].resource", description="The first resource in the bundle, if the bundle type is \"message\" - this is a message header, and this parameter provides access to search its contents", type="reference", target={MessageHeader.class } )
3186  public static final String SP_MESSAGE = "message";
3187 /**
3188   * <b>Fluent Client</b> search parameter constant for <b>message</b>
3189   * <p>
3190   * Description: <b>The first resource in the bundle, if the bundle type is "message" - this is a message header, and this parameter provides access to search its contents</b><br>
3191   * Type: <b>reference</b><br>
3192   * Path: <b>Bundle.entry(0).resource</b><br>
3193   * </p>
3194   */
3195  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam MESSAGE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_MESSAGE);
3196
3197/**
3198   * Constant for fluent queries to be used to add include statements. Specifies
3199   * the path value of "<b>Bundle:message</b>".
3200   */
3201  public static final ca.uhn.fhir.model.api.Include INCLUDE_MESSAGE = new ca.uhn.fhir.model.api.Include("Bundle:message").toLocked();
3202
3203 /**
3204   * Search parameter: <b>timestamp</b>
3205   * <p>
3206   * Description: <b>When the bundle was assembled</b><br>
3207   * Type: <b>date</b><br>
3208   * Path: <b>Bundle.timestamp</b><br>
3209   * </p>
3210   */
3211  @SearchParamDefinition(name="timestamp", path="Bundle.timestamp", description="When the bundle was assembled", type="date" )
3212  public static final String SP_TIMESTAMP = "timestamp";
3213 /**
3214   * <b>Fluent Client</b> search parameter constant for <b>timestamp</b>
3215   * <p>
3216   * Description: <b>When the bundle was assembled</b><br>
3217   * Type: <b>date</b><br>
3218   * Path: <b>Bundle.timestamp</b><br>
3219   * </p>
3220   */
3221  public static final ca.uhn.fhir.rest.gclient.DateClientParam TIMESTAMP = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_TIMESTAMP);
3222
3223
3224}
3225