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