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