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