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