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