001package org.hl7.fhir.dstu3.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Mon, Apr 17, 2017 17:38-0400 for FHIR v3.0.1
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import org.hl7.fhir.dstu3.model.Enumerations.*;
038import ca.uhn.fhir.model.api.annotation.ResourceDef;
039import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
040import ca.uhn.fhir.model.api.annotation.Child;
041import ca.uhn.fhir.model.api.annotation.ChildOrder;
042import ca.uhn.fhir.model.api.annotation.Description;
043import ca.uhn.fhir.model.api.annotation.Block;
044import org.hl7.fhir.instance.model.api.*;
045import org.hl7.fhir.exceptions.FHIRException;
046/**
047 * A record of a healthcare consumer’s policy choices, which permits or denies identified recipient(s) or recipient role(s) to perform one or more actions within a given policy context, for specific purposes and periods of time.
048 */
049@ResourceDef(name="Consent", profile="http://hl7.org/fhir/Profile/Consent")
050public class Consent extends DomainResource {
051
052    public enum ConsentState {
053        /**
054         * The consent is in development or awaiting use but is not yet intended to be acted upon.
055         */
056        DRAFT, 
057        /**
058         * The consent has been proposed but not yet agreed to by all parties. The negotiation stage.
059         */
060        PROPOSED, 
061        /**
062         * The consent is to be followed and enforced.
063         */
064        ACTIVE, 
065        /**
066         * The consent has been rejected by one or more of the parties.
067         */
068        REJECTED, 
069        /**
070         * The consent is terminated or replaced.
071         */
072        INACTIVE, 
073        /**
074         * The consent was created wrongly (e.g. wrong patient) and should be ignored
075         */
076        ENTEREDINERROR, 
077        /**
078         * added to help the parsers with the generic types
079         */
080        NULL;
081        public static ConsentState fromCode(String codeString) throws FHIRException {
082            if (codeString == null || "".equals(codeString))
083                return null;
084        if ("draft".equals(codeString))
085          return DRAFT;
086        if ("proposed".equals(codeString))
087          return PROPOSED;
088        if ("active".equals(codeString))
089          return ACTIVE;
090        if ("rejected".equals(codeString))
091          return REJECTED;
092        if ("inactive".equals(codeString))
093          return INACTIVE;
094        if ("entered-in-error".equals(codeString))
095          return ENTEREDINERROR;
096        if (Configuration.isAcceptInvalidEnums())
097          return null;
098        else
099          throw new FHIRException("Unknown ConsentState code '"+codeString+"'");
100        }
101        public String toCode() {
102          switch (this) {
103            case DRAFT: return "draft";
104            case PROPOSED: return "proposed";
105            case ACTIVE: return "active";
106            case REJECTED: return "rejected";
107            case INACTIVE: return "inactive";
108            case ENTEREDINERROR: return "entered-in-error";
109            default: return "?";
110          }
111        }
112        public String getSystem() {
113          switch (this) {
114            case DRAFT: return "http://hl7.org/fhir/consent-state-codes";
115            case PROPOSED: return "http://hl7.org/fhir/consent-state-codes";
116            case ACTIVE: return "http://hl7.org/fhir/consent-state-codes";
117            case REJECTED: return "http://hl7.org/fhir/consent-state-codes";
118            case INACTIVE: return "http://hl7.org/fhir/consent-state-codes";
119            case ENTEREDINERROR: return "http://hl7.org/fhir/consent-state-codes";
120            default: return "?";
121          }
122        }
123        public String getDefinition() {
124          switch (this) {
125            case DRAFT: return "The consent is in development or awaiting use but is not yet intended to be acted upon.";
126            case PROPOSED: return "The consent has been proposed but not yet agreed to by all parties. The negotiation stage.";
127            case ACTIVE: return "The consent is to be followed and enforced.";
128            case REJECTED: return "The consent has been rejected by one or more of the parties.";
129            case INACTIVE: return "The consent is terminated or replaced.";
130            case ENTEREDINERROR: return "The consent was created wrongly (e.g. wrong patient) and should be ignored";
131            default: return "?";
132          }
133        }
134        public String getDisplay() {
135          switch (this) {
136            case DRAFT: return "Pending";
137            case PROPOSED: return "Proposed";
138            case ACTIVE: return "Active";
139            case REJECTED: return "Rejected";
140            case INACTIVE: return "Inactive";
141            case ENTEREDINERROR: return "Entered in Error";
142            default: return "?";
143          }
144        }
145    }
146
147  public static class ConsentStateEnumFactory implements EnumFactory<ConsentState> {
148    public ConsentState fromCode(String codeString) throws IllegalArgumentException {
149      if (codeString == null || "".equals(codeString))
150            if (codeString == null || "".equals(codeString))
151                return null;
152        if ("draft".equals(codeString))
153          return ConsentState.DRAFT;
154        if ("proposed".equals(codeString))
155          return ConsentState.PROPOSED;
156        if ("active".equals(codeString))
157          return ConsentState.ACTIVE;
158        if ("rejected".equals(codeString))
159          return ConsentState.REJECTED;
160        if ("inactive".equals(codeString))
161          return ConsentState.INACTIVE;
162        if ("entered-in-error".equals(codeString))
163          return ConsentState.ENTEREDINERROR;
164        throw new IllegalArgumentException("Unknown ConsentState code '"+codeString+"'");
165        }
166        public Enumeration<ConsentState> fromType(Base code) throws FHIRException {
167          if (code == null)
168            return null;
169          if (code.isEmpty())
170            return new Enumeration<ConsentState>(this);
171          String codeString = ((PrimitiveType) code).asStringValue();
172          if (codeString == null || "".equals(codeString))
173            return null;
174        if ("draft".equals(codeString))
175          return new Enumeration<ConsentState>(this, ConsentState.DRAFT);
176        if ("proposed".equals(codeString))
177          return new Enumeration<ConsentState>(this, ConsentState.PROPOSED);
178        if ("active".equals(codeString))
179          return new Enumeration<ConsentState>(this, ConsentState.ACTIVE);
180        if ("rejected".equals(codeString))
181          return new Enumeration<ConsentState>(this, ConsentState.REJECTED);
182        if ("inactive".equals(codeString))
183          return new Enumeration<ConsentState>(this, ConsentState.INACTIVE);
184        if ("entered-in-error".equals(codeString))
185          return new Enumeration<ConsentState>(this, ConsentState.ENTEREDINERROR);
186        throw new FHIRException("Unknown ConsentState code '"+codeString+"'");
187        }
188    public String toCode(ConsentState code) {
189      if (code == ConsentState.DRAFT)
190        return "draft";
191      if (code == ConsentState.PROPOSED)
192        return "proposed";
193      if (code == ConsentState.ACTIVE)
194        return "active";
195      if (code == ConsentState.REJECTED)
196        return "rejected";
197      if (code == ConsentState.INACTIVE)
198        return "inactive";
199      if (code == ConsentState.ENTEREDINERROR)
200        return "entered-in-error";
201      return "?";
202      }
203    public String toSystem(ConsentState code) {
204      return code.getSystem();
205      }
206    }
207
208    public enum ConsentDataMeaning {
209        /**
210         * The consent applies directly to the instance of the resource
211         */
212        INSTANCE, 
213        /**
214         * The consent applies directly to the instance of the resource and instances it refers to
215         */
216        RELATED, 
217        /**
218         * The consent applies directly to the instance of the resource and instances that refer to it
219         */
220        DEPENDENTS, 
221        /**
222         * The consent applies to instances of resources that are authored by
223         */
224        AUTHOREDBY, 
225        /**
226         * added to help the parsers with the generic types
227         */
228        NULL;
229        public static ConsentDataMeaning fromCode(String codeString) throws FHIRException {
230            if (codeString == null || "".equals(codeString))
231                return null;
232        if ("instance".equals(codeString))
233          return INSTANCE;
234        if ("related".equals(codeString))
235          return RELATED;
236        if ("dependents".equals(codeString))
237          return DEPENDENTS;
238        if ("authoredby".equals(codeString))
239          return AUTHOREDBY;
240        if (Configuration.isAcceptInvalidEnums())
241          return null;
242        else
243          throw new FHIRException("Unknown ConsentDataMeaning code '"+codeString+"'");
244        }
245        public String toCode() {
246          switch (this) {
247            case INSTANCE: return "instance";
248            case RELATED: return "related";
249            case DEPENDENTS: return "dependents";
250            case AUTHOREDBY: return "authoredby";
251            default: return "?";
252          }
253        }
254        public String getSystem() {
255          switch (this) {
256            case INSTANCE: return "http://hl7.org/fhir/consent-data-meaning";
257            case RELATED: return "http://hl7.org/fhir/consent-data-meaning";
258            case DEPENDENTS: return "http://hl7.org/fhir/consent-data-meaning";
259            case AUTHOREDBY: return "http://hl7.org/fhir/consent-data-meaning";
260            default: return "?";
261          }
262        }
263        public String getDefinition() {
264          switch (this) {
265            case INSTANCE: return "The consent applies directly to the instance of the resource";
266            case RELATED: return "The consent applies directly to the instance of the resource and instances it refers to";
267            case DEPENDENTS: return "The consent applies directly to the instance of the resource and instances that refer to it";
268            case AUTHOREDBY: return "The consent applies to instances of resources that are authored by";
269            default: return "?";
270          }
271        }
272        public String getDisplay() {
273          switch (this) {
274            case INSTANCE: return "Instance";
275            case RELATED: return "Related";
276            case DEPENDENTS: return "Dependents";
277            case AUTHOREDBY: return "AuthoredBy";
278            default: return "?";
279          }
280        }
281    }
282
283  public static class ConsentDataMeaningEnumFactory implements EnumFactory<ConsentDataMeaning> {
284    public ConsentDataMeaning fromCode(String codeString) throws IllegalArgumentException {
285      if (codeString == null || "".equals(codeString))
286            if (codeString == null || "".equals(codeString))
287                return null;
288        if ("instance".equals(codeString))
289          return ConsentDataMeaning.INSTANCE;
290        if ("related".equals(codeString))
291          return ConsentDataMeaning.RELATED;
292        if ("dependents".equals(codeString))
293          return ConsentDataMeaning.DEPENDENTS;
294        if ("authoredby".equals(codeString))
295          return ConsentDataMeaning.AUTHOREDBY;
296        throw new IllegalArgumentException("Unknown ConsentDataMeaning code '"+codeString+"'");
297        }
298        public Enumeration<ConsentDataMeaning> fromType(Base code) throws FHIRException {
299          if (code == null)
300            return null;
301          if (code.isEmpty())
302            return new Enumeration<ConsentDataMeaning>(this);
303          String codeString = ((PrimitiveType) code).asStringValue();
304          if (codeString == null || "".equals(codeString))
305            return null;
306        if ("instance".equals(codeString))
307          return new Enumeration<ConsentDataMeaning>(this, ConsentDataMeaning.INSTANCE);
308        if ("related".equals(codeString))
309          return new Enumeration<ConsentDataMeaning>(this, ConsentDataMeaning.RELATED);
310        if ("dependents".equals(codeString))
311          return new Enumeration<ConsentDataMeaning>(this, ConsentDataMeaning.DEPENDENTS);
312        if ("authoredby".equals(codeString))
313          return new Enumeration<ConsentDataMeaning>(this, ConsentDataMeaning.AUTHOREDBY);
314        throw new FHIRException("Unknown ConsentDataMeaning code '"+codeString+"'");
315        }
316    public String toCode(ConsentDataMeaning code) {
317      if (code == ConsentDataMeaning.INSTANCE)
318        return "instance";
319      if (code == ConsentDataMeaning.RELATED)
320        return "related";
321      if (code == ConsentDataMeaning.DEPENDENTS)
322        return "dependents";
323      if (code == ConsentDataMeaning.AUTHOREDBY)
324        return "authoredby";
325      return "?";
326      }
327    public String toSystem(ConsentDataMeaning code) {
328      return code.getSystem();
329      }
330    }
331
332    public enum ConsentExceptType {
333        /**
334         * Consent is denied for actions meeting these rules
335         */
336        DENY, 
337        /**
338         * Consent is provided for actions meeting these rules
339         */
340        PERMIT, 
341        /**
342         * added to help the parsers with the generic types
343         */
344        NULL;
345        public static ConsentExceptType fromCode(String codeString) throws FHIRException {
346            if (codeString == null || "".equals(codeString))
347                return null;
348        if ("deny".equals(codeString))
349          return DENY;
350        if ("permit".equals(codeString))
351          return PERMIT;
352        if (Configuration.isAcceptInvalidEnums())
353          return null;
354        else
355          throw new FHIRException("Unknown ConsentExceptType code '"+codeString+"'");
356        }
357        public String toCode() {
358          switch (this) {
359            case DENY: return "deny";
360            case PERMIT: return "permit";
361            default: return "?";
362          }
363        }
364        public String getSystem() {
365          switch (this) {
366            case DENY: return "http://hl7.org/fhir/consent-except-type";
367            case PERMIT: return "http://hl7.org/fhir/consent-except-type";
368            default: return "?";
369          }
370        }
371        public String getDefinition() {
372          switch (this) {
373            case DENY: return "Consent is denied for actions meeting these rules";
374            case PERMIT: return "Consent is provided for actions meeting these rules";
375            default: return "?";
376          }
377        }
378        public String getDisplay() {
379          switch (this) {
380            case DENY: return "Opt Out";
381            case PERMIT: return "Opt In";
382            default: return "?";
383          }
384        }
385    }
386
387  public static class ConsentExceptTypeEnumFactory implements EnumFactory<ConsentExceptType> {
388    public ConsentExceptType fromCode(String codeString) throws IllegalArgumentException {
389      if (codeString == null || "".equals(codeString))
390            if (codeString == null || "".equals(codeString))
391                return null;
392        if ("deny".equals(codeString))
393          return ConsentExceptType.DENY;
394        if ("permit".equals(codeString))
395          return ConsentExceptType.PERMIT;
396        throw new IllegalArgumentException("Unknown ConsentExceptType code '"+codeString+"'");
397        }
398        public Enumeration<ConsentExceptType> fromType(Base code) throws FHIRException {
399          if (code == null)
400            return null;
401          if (code.isEmpty())
402            return new Enumeration<ConsentExceptType>(this);
403          String codeString = ((PrimitiveType) code).asStringValue();
404          if (codeString == null || "".equals(codeString))
405            return null;
406        if ("deny".equals(codeString))
407          return new Enumeration<ConsentExceptType>(this, ConsentExceptType.DENY);
408        if ("permit".equals(codeString))
409          return new Enumeration<ConsentExceptType>(this, ConsentExceptType.PERMIT);
410        throw new FHIRException("Unknown ConsentExceptType code '"+codeString+"'");
411        }
412    public String toCode(ConsentExceptType code) {
413      if (code == ConsentExceptType.DENY)
414        return "deny";
415      if (code == ConsentExceptType.PERMIT)
416        return "permit";
417      return "?";
418      }
419    public String toSystem(ConsentExceptType code) {
420      return code.getSystem();
421      }
422    }
423
424    @Block()
425    public static class ConsentActorComponent extends BackboneElement implements IBaseBackboneElement {
426        /**
427         * How the individual is involved in the resources content that is described in the consent.
428         */
429        @Child(name = "role", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=false)
430        @Description(shortDefinition="How the actor is involved", formalDefinition="How the individual is involved in the resources content that is described in the consent." )
431        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/security-role-type")
432        protected CodeableConcept role;
433
434        /**
435         * The resource that identifies the actor. To identify a actors by type, use group to identify a set of actors by some property they share (e.g. 'admitting officers').
436         */
437        @Child(name = "reference", type = {Device.class, Group.class, CareTeam.class, Organization.class, Patient.class, Practitioner.class, RelatedPerson.class}, order=2, min=1, max=1, modifier=false, summary=false)
438        @Description(shortDefinition="Resource for the actor (or group, by role)", formalDefinition="The resource that identifies the actor. To identify a actors by type, use group to identify a set of actors by some property they share (e.g. 'admitting officers')." )
439        protected Reference reference;
440
441        /**
442         * The actual object that is the target of the reference (The resource that identifies the actor. To identify a actors by type, use group to identify a set of actors by some property they share (e.g. 'admitting officers').)
443         */
444        protected Resource referenceTarget;
445
446        private static final long serialVersionUID = 1152919415L;
447
448    /**
449     * Constructor
450     */
451      public ConsentActorComponent() {
452        super();
453      }
454
455    /**
456     * Constructor
457     */
458      public ConsentActorComponent(CodeableConcept role, Reference reference) {
459        super();
460        this.role = role;
461        this.reference = reference;
462      }
463
464        /**
465         * @return {@link #role} (How the individual is involved in the resources content that is described in the consent.)
466         */
467        public CodeableConcept getRole() { 
468          if (this.role == null)
469            if (Configuration.errorOnAutoCreate())
470              throw new Error("Attempt to auto-create ConsentActorComponent.role");
471            else if (Configuration.doAutoCreate())
472              this.role = new CodeableConcept(); // cc
473          return this.role;
474        }
475
476        public boolean hasRole() { 
477          return this.role != null && !this.role.isEmpty();
478        }
479
480        /**
481         * @param value {@link #role} (How the individual is involved in the resources content that is described in the consent.)
482         */
483        public ConsentActorComponent setRole(CodeableConcept value) { 
484          this.role = value;
485          return this;
486        }
487
488        /**
489         * @return {@link #reference} (The resource that identifies the actor. To identify a actors by type, use group to identify a set of actors by some property they share (e.g. 'admitting officers').)
490         */
491        public Reference getReference() { 
492          if (this.reference == null)
493            if (Configuration.errorOnAutoCreate())
494              throw new Error("Attempt to auto-create ConsentActorComponent.reference");
495            else if (Configuration.doAutoCreate())
496              this.reference = new Reference(); // cc
497          return this.reference;
498        }
499
500        public boolean hasReference() { 
501          return this.reference != null && !this.reference.isEmpty();
502        }
503
504        /**
505         * @param value {@link #reference} (The resource that identifies the actor. To identify a actors by type, use group to identify a set of actors by some property they share (e.g. 'admitting officers').)
506         */
507        public ConsentActorComponent setReference(Reference value) { 
508          this.reference = value;
509          return this;
510        }
511
512        /**
513         * @return {@link #reference} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The resource that identifies the actor. To identify a actors by type, use group to identify a set of actors by some property they share (e.g. 'admitting officers').)
514         */
515        public Resource getReferenceTarget() { 
516          return this.referenceTarget;
517        }
518
519        /**
520         * @param value {@link #reference} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The resource that identifies the actor. To identify a actors by type, use group to identify a set of actors by some property they share (e.g. 'admitting officers').)
521         */
522        public ConsentActorComponent setReferenceTarget(Resource value) { 
523          this.referenceTarget = value;
524          return this;
525        }
526
527        protected void listChildren(List<Property> childrenList) {
528          super.listChildren(childrenList);
529          childrenList.add(new Property("role", "CodeableConcept", "How the individual is involved in the resources content that is described in the consent.", 0, java.lang.Integer.MAX_VALUE, role));
530          childrenList.add(new Property("reference", "Reference(Device|Group|CareTeam|Organization|Patient|Practitioner|RelatedPerson)", "The resource that identifies the actor. To identify a actors by type, use group to identify a set of actors by some property they share (e.g. 'admitting officers').", 0, java.lang.Integer.MAX_VALUE, reference));
531        }
532
533      @Override
534      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
535        switch (hash) {
536        case 3506294: /*role*/ return this.role == null ? new Base[0] : new Base[] {this.role}; // CodeableConcept
537        case -925155509: /*reference*/ return this.reference == null ? new Base[0] : new Base[] {this.reference}; // Reference
538        default: return super.getProperty(hash, name, checkValid);
539        }
540
541      }
542
543      @Override
544      public Base setProperty(int hash, String name, Base value) throws FHIRException {
545        switch (hash) {
546        case 3506294: // role
547          this.role = castToCodeableConcept(value); // CodeableConcept
548          return value;
549        case -925155509: // reference
550          this.reference = castToReference(value); // Reference
551          return value;
552        default: return super.setProperty(hash, name, value);
553        }
554
555      }
556
557      @Override
558      public Base setProperty(String name, Base value) throws FHIRException {
559        if (name.equals("role")) {
560          this.role = castToCodeableConcept(value); // CodeableConcept
561        } else if (name.equals("reference")) {
562          this.reference = castToReference(value); // Reference
563        } else
564          return super.setProperty(name, value);
565        return value;
566      }
567
568      @Override
569      public Base makeProperty(int hash, String name) throws FHIRException {
570        switch (hash) {
571        case 3506294:  return getRole(); 
572        case -925155509:  return getReference(); 
573        default: return super.makeProperty(hash, name);
574        }
575
576      }
577
578      @Override
579      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
580        switch (hash) {
581        case 3506294: /*role*/ return new String[] {"CodeableConcept"};
582        case -925155509: /*reference*/ return new String[] {"Reference"};
583        default: return super.getTypesForProperty(hash, name);
584        }
585
586      }
587
588      @Override
589      public Base addChild(String name) throws FHIRException {
590        if (name.equals("role")) {
591          this.role = new CodeableConcept();
592          return this.role;
593        }
594        else if (name.equals("reference")) {
595          this.reference = new Reference();
596          return this.reference;
597        }
598        else
599          return super.addChild(name);
600      }
601
602      public ConsentActorComponent copy() {
603        ConsentActorComponent dst = new ConsentActorComponent();
604        copyValues(dst);
605        dst.role = role == null ? null : role.copy();
606        dst.reference = reference == null ? null : reference.copy();
607        return dst;
608      }
609
610      @Override
611      public boolean equalsDeep(Base other) {
612        if (!super.equalsDeep(other))
613          return false;
614        if (!(other instanceof ConsentActorComponent))
615          return false;
616        ConsentActorComponent o = (ConsentActorComponent) other;
617        return compareDeep(role, o.role, true) && compareDeep(reference, o.reference, true);
618      }
619
620      @Override
621      public boolean equalsShallow(Base other) {
622        if (!super.equalsShallow(other))
623          return false;
624        if (!(other instanceof ConsentActorComponent))
625          return false;
626        ConsentActorComponent o = (ConsentActorComponent) other;
627        return true;
628      }
629
630      public boolean isEmpty() {
631        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(role, reference);
632      }
633
634  public String fhirType() {
635    return "Consent.actor";
636
637  }
638
639  }
640
641    @Block()
642    public static class ConsentPolicyComponent extends BackboneElement implements IBaseBackboneElement {
643        /**
644         * Entity or Organization having regulatory jurisdiction or accountability for  enforcing policies pertaining to Consent Directives.
645         */
646        @Child(name = "authority", type = {UriType.class}, order=1, min=0, max=1, modifier=false, summary=false)
647        @Description(shortDefinition="Enforcement source for policy", formalDefinition="Entity or Organization having regulatory jurisdiction or accountability for  enforcing policies pertaining to Consent Directives." )
648        protected UriType authority;
649
650        /**
651         * The references to the policies that are included in this consent scope. Policies may be organizational, but are often defined jurisdictionally, or in law.
652         */
653        @Child(name = "uri", type = {UriType.class}, order=2, min=0, max=1, modifier=false, summary=false)
654        @Description(shortDefinition="Specific policy covered by this consent", formalDefinition="The references to the policies that are included in this consent scope. Policies may be organizational, but are often defined jurisdictionally, or in law." )
655        protected UriType uri;
656
657        private static final long serialVersionUID = 672275705L;
658
659    /**
660     * Constructor
661     */
662      public ConsentPolicyComponent() {
663        super();
664      }
665
666        /**
667         * @return {@link #authority} (Entity or Organization having regulatory jurisdiction or accountability for  enforcing policies pertaining to Consent Directives.). This is the underlying object with id, value and extensions. The accessor "getAuthority" gives direct access to the value
668         */
669        public UriType getAuthorityElement() { 
670          if (this.authority == null)
671            if (Configuration.errorOnAutoCreate())
672              throw new Error("Attempt to auto-create ConsentPolicyComponent.authority");
673            else if (Configuration.doAutoCreate())
674              this.authority = new UriType(); // bb
675          return this.authority;
676        }
677
678        public boolean hasAuthorityElement() { 
679          return this.authority != null && !this.authority.isEmpty();
680        }
681
682        public boolean hasAuthority() { 
683          return this.authority != null && !this.authority.isEmpty();
684        }
685
686        /**
687         * @param value {@link #authority} (Entity or Organization having regulatory jurisdiction or accountability for  enforcing policies pertaining to Consent Directives.). This is the underlying object with id, value and extensions. The accessor "getAuthority" gives direct access to the value
688         */
689        public ConsentPolicyComponent setAuthorityElement(UriType value) { 
690          this.authority = value;
691          return this;
692        }
693
694        /**
695         * @return Entity or Organization having regulatory jurisdiction or accountability for  enforcing policies pertaining to Consent Directives.
696         */
697        public String getAuthority() { 
698          return this.authority == null ? null : this.authority.getValue();
699        }
700
701        /**
702         * @param value Entity or Organization having regulatory jurisdiction or accountability for  enforcing policies pertaining to Consent Directives.
703         */
704        public ConsentPolicyComponent setAuthority(String value) { 
705          if (Utilities.noString(value))
706            this.authority = null;
707          else {
708            if (this.authority == null)
709              this.authority = new UriType();
710            this.authority.setValue(value);
711          }
712          return this;
713        }
714
715        /**
716         * @return {@link #uri} (The references to the policies that are included in this consent scope. Policies may be organizational, but are often defined jurisdictionally, or in law.). This is the underlying object with id, value and extensions. The accessor "getUri" gives direct access to the value
717         */
718        public UriType getUriElement() { 
719          if (this.uri == null)
720            if (Configuration.errorOnAutoCreate())
721              throw new Error("Attempt to auto-create ConsentPolicyComponent.uri");
722            else if (Configuration.doAutoCreate())
723              this.uri = new UriType(); // bb
724          return this.uri;
725        }
726
727        public boolean hasUriElement() { 
728          return this.uri != null && !this.uri.isEmpty();
729        }
730
731        public boolean hasUri() { 
732          return this.uri != null && !this.uri.isEmpty();
733        }
734
735        /**
736         * @param value {@link #uri} (The references to the policies that are included in this consent scope. Policies may be organizational, but are often defined jurisdictionally, or in law.). This is the underlying object with id, value and extensions. The accessor "getUri" gives direct access to the value
737         */
738        public ConsentPolicyComponent setUriElement(UriType value) { 
739          this.uri = value;
740          return this;
741        }
742
743        /**
744         * @return The references to the policies that are included in this consent scope. Policies may be organizational, but are often defined jurisdictionally, or in law.
745         */
746        public String getUri() { 
747          return this.uri == null ? null : this.uri.getValue();
748        }
749
750        /**
751         * @param value The references to the policies that are included in this consent scope. Policies may be organizational, but are often defined jurisdictionally, or in law.
752         */
753        public ConsentPolicyComponent setUri(String value) { 
754          if (Utilities.noString(value))
755            this.uri = null;
756          else {
757            if (this.uri == null)
758              this.uri = new UriType();
759            this.uri.setValue(value);
760          }
761          return this;
762        }
763
764        protected void listChildren(List<Property> childrenList) {
765          super.listChildren(childrenList);
766          childrenList.add(new Property("authority", "uri", "Entity or Organization having regulatory jurisdiction or accountability for  enforcing policies pertaining to Consent Directives.", 0, java.lang.Integer.MAX_VALUE, authority));
767          childrenList.add(new Property("uri", "uri", "The references to the policies that are included in this consent scope. Policies may be organizational, but are often defined jurisdictionally, or in law.", 0, java.lang.Integer.MAX_VALUE, uri));
768        }
769
770      @Override
771      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
772        switch (hash) {
773        case 1475610435: /*authority*/ return this.authority == null ? new Base[0] : new Base[] {this.authority}; // UriType
774        case 116076: /*uri*/ return this.uri == null ? new Base[0] : new Base[] {this.uri}; // UriType
775        default: return super.getProperty(hash, name, checkValid);
776        }
777
778      }
779
780      @Override
781      public Base setProperty(int hash, String name, Base value) throws FHIRException {
782        switch (hash) {
783        case 1475610435: // authority
784          this.authority = castToUri(value); // UriType
785          return value;
786        case 116076: // uri
787          this.uri = castToUri(value); // UriType
788          return value;
789        default: return super.setProperty(hash, name, value);
790        }
791
792      }
793
794      @Override
795      public Base setProperty(String name, Base value) throws FHIRException {
796        if (name.equals("authority")) {
797          this.authority = castToUri(value); // UriType
798        } else if (name.equals("uri")) {
799          this.uri = castToUri(value); // UriType
800        } else
801          return super.setProperty(name, value);
802        return value;
803      }
804
805      @Override
806      public Base makeProperty(int hash, String name) throws FHIRException {
807        switch (hash) {
808        case 1475610435:  return getAuthorityElement();
809        case 116076:  return getUriElement();
810        default: return super.makeProperty(hash, name);
811        }
812
813      }
814
815      @Override
816      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
817        switch (hash) {
818        case 1475610435: /*authority*/ return new String[] {"uri"};
819        case 116076: /*uri*/ return new String[] {"uri"};
820        default: return super.getTypesForProperty(hash, name);
821        }
822
823      }
824
825      @Override
826      public Base addChild(String name) throws FHIRException {
827        if (name.equals("authority")) {
828          throw new FHIRException("Cannot call addChild on a primitive type Consent.authority");
829        }
830        else if (name.equals("uri")) {
831          throw new FHIRException("Cannot call addChild on a primitive type Consent.uri");
832        }
833        else
834          return super.addChild(name);
835      }
836
837      public ConsentPolicyComponent copy() {
838        ConsentPolicyComponent dst = new ConsentPolicyComponent();
839        copyValues(dst);
840        dst.authority = authority == null ? null : authority.copy();
841        dst.uri = uri == null ? null : uri.copy();
842        return dst;
843      }
844
845      @Override
846      public boolean equalsDeep(Base other) {
847        if (!super.equalsDeep(other))
848          return false;
849        if (!(other instanceof ConsentPolicyComponent))
850          return false;
851        ConsentPolicyComponent o = (ConsentPolicyComponent) other;
852        return compareDeep(authority, o.authority, true) && compareDeep(uri, o.uri, true);
853      }
854
855      @Override
856      public boolean equalsShallow(Base other) {
857        if (!super.equalsShallow(other))
858          return false;
859        if (!(other instanceof ConsentPolicyComponent))
860          return false;
861        ConsentPolicyComponent o = (ConsentPolicyComponent) other;
862        return compareValues(authority, o.authority, true) && compareValues(uri, o.uri, true);
863      }
864
865      public boolean isEmpty() {
866        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(authority, uri);
867      }
868
869  public String fhirType() {
870    return "Consent.policy";
871
872  }
873
874  }
875
876    @Block()
877    public static class ConsentDataComponent extends BackboneElement implements IBaseBackboneElement {
878        /**
879         * How the resource reference is interpreted when testing consent restrictions.
880         */
881        @Child(name = "meaning", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=true)
882        @Description(shortDefinition="instance | related | dependents | authoredby", formalDefinition="How the resource reference is interpreted when testing consent restrictions." )
883        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/consent-data-meaning")
884        protected Enumeration<ConsentDataMeaning> meaning;
885
886        /**
887         * A reference to a specific resource that defines which resources are covered by this consent.
888         */
889        @Child(name = "reference", type = {Reference.class}, order=2, min=1, max=1, modifier=false, summary=true)
890        @Description(shortDefinition="The actual data reference", formalDefinition="A reference to a specific resource that defines which resources are covered by this consent." )
891        protected Reference reference;
892
893        /**
894         * The actual object that is the target of the reference (A reference to a specific resource that defines which resources are covered by this consent.)
895         */
896        protected Resource referenceTarget;
897
898        private static final long serialVersionUID = -424898645L;
899
900    /**
901     * Constructor
902     */
903      public ConsentDataComponent() {
904        super();
905      }
906
907    /**
908     * Constructor
909     */
910      public ConsentDataComponent(Enumeration<ConsentDataMeaning> meaning, Reference reference) {
911        super();
912        this.meaning = meaning;
913        this.reference = reference;
914      }
915
916        /**
917         * @return {@link #meaning} (How the resource reference is interpreted when testing consent restrictions.). This is the underlying object with id, value and extensions. The accessor "getMeaning" gives direct access to the value
918         */
919        public Enumeration<ConsentDataMeaning> getMeaningElement() { 
920          if (this.meaning == null)
921            if (Configuration.errorOnAutoCreate())
922              throw new Error("Attempt to auto-create ConsentDataComponent.meaning");
923            else if (Configuration.doAutoCreate())
924              this.meaning = new Enumeration<ConsentDataMeaning>(new ConsentDataMeaningEnumFactory()); // bb
925          return this.meaning;
926        }
927
928        public boolean hasMeaningElement() { 
929          return this.meaning != null && !this.meaning.isEmpty();
930        }
931
932        public boolean hasMeaning() { 
933          return this.meaning != null && !this.meaning.isEmpty();
934        }
935
936        /**
937         * @param value {@link #meaning} (How the resource reference is interpreted when testing consent restrictions.). This is the underlying object with id, value and extensions. The accessor "getMeaning" gives direct access to the value
938         */
939        public ConsentDataComponent setMeaningElement(Enumeration<ConsentDataMeaning> value) { 
940          this.meaning = value;
941          return this;
942        }
943
944        /**
945         * @return How the resource reference is interpreted when testing consent restrictions.
946         */
947        public ConsentDataMeaning getMeaning() { 
948          return this.meaning == null ? null : this.meaning.getValue();
949        }
950
951        /**
952         * @param value How the resource reference is interpreted when testing consent restrictions.
953         */
954        public ConsentDataComponent setMeaning(ConsentDataMeaning value) { 
955            if (this.meaning == null)
956              this.meaning = new Enumeration<ConsentDataMeaning>(new ConsentDataMeaningEnumFactory());
957            this.meaning.setValue(value);
958          return this;
959        }
960
961        /**
962         * @return {@link #reference} (A reference to a specific resource that defines which resources are covered by this consent.)
963         */
964        public Reference getReference() { 
965          if (this.reference == null)
966            if (Configuration.errorOnAutoCreate())
967              throw new Error("Attempt to auto-create ConsentDataComponent.reference");
968            else if (Configuration.doAutoCreate())
969              this.reference = new Reference(); // cc
970          return this.reference;
971        }
972
973        public boolean hasReference() { 
974          return this.reference != null && !this.reference.isEmpty();
975        }
976
977        /**
978         * @param value {@link #reference} (A reference to a specific resource that defines which resources are covered by this consent.)
979         */
980        public ConsentDataComponent setReference(Reference value) { 
981          this.reference = value;
982          return this;
983        }
984
985        /**
986         * @return {@link #reference} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (A reference to a specific resource that defines which resources are covered by this consent.)
987         */
988        public Resource getReferenceTarget() { 
989          return this.referenceTarget;
990        }
991
992        /**
993         * @param value {@link #reference} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (A reference to a specific resource that defines which resources are covered by this consent.)
994         */
995        public ConsentDataComponent setReferenceTarget(Resource value) { 
996          this.referenceTarget = value;
997          return this;
998        }
999
1000        protected void listChildren(List<Property> childrenList) {
1001          super.listChildren(childrenList);
1002          childrenList.add(new Property("meaning", "code", "How the resource reference is interpreted when testing consent restrictions.", 0, java.lang.Integer.MAX_VALUE, meaning));
1003          childrenList.add(new Property("reference", "Reference(Any)", "A reference to a specific resource that defines which resources are covered by this consent.", 0, java.lang.Integer.MAX_VALUE, reference));
1004        }
1005
1006      @Override
1007      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1008        switch (hash) {
1009        case 938160637: /*meaning*/ return this.meaning == null ? new Base[0] : new Base[] {this.meaning}; // Enumeration<ConsentDataMeaning>
1010        case -925155509: /*reference*/ return this.reference == null ? new Base[0] : new Base[] {this.reference}; // Reference
1011        default: return super.getProperty(hash, name, checkValid);
1012        }
1013
1014      }
1015
1016      @Override
1017      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1018        switch (hash) {
1019        case 938160637: // meaning
1020          value = new ConsentDataMeaningEnumFactory().fromType(castToCode(value));
1021          this.meaning = (Enumeration) value; // Enumeration<ConsentDataMeaning>
1022          return value;
1023        case -925155509: // reference
1024          this.reference = castToReference(value); // Reference
1025          return value;
1026        default: return super.setProperty(hash, name, value);
1027        }
1028
1029      }
1030
1031      @Override
1032      public Base setProperty(String name, Base value) throws FHIRException {
1033        if (name.equals("meaning")) {
1034          value = new ConsentDataMeaningEnumFactory().fromType(castToCode(value));
1035          this.meaning = (Enumeration) value; // Enumeration<ConsentDataMeaning>
1036        } else if (name.equals("reference")) {
1037          this.reference = castToReference(value); // Reference
1038        } else
1039          return super.setProperty(name, value);
1040        return value;
1041      }
1042
1043      @Override
1044      public Base makeProperty(int hash, String name) throws FHIRException {
1045        switch (hash) {
1046        case 938160637:  return getMeaningElement();
1047        case -925155509:  return getReference(); 
1048        default: return super.makeProperty(hash, name);
1049        }
1050
1051      }
1052
1053      @Override
1054      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1055        switch (hash) {
1056        case 938160637: /*meaning*/ return new String[] {"code"};
1057        case -925155509: /*reference*/ return new String[] {"Reference"};
1058        default: return super.getTypesForProperty(hash, name);
1059        }
1060
1061      }
1062
1063      @Override
1064      public Base addChild(String name) throws FHIRException {
1065        if (name.equals("meaning")) {
1066          throw new FHIRException("Cannot call addChild on a primitive type Consent.meaning");
1067        }
1068        else if (name.equals("reference")) {
1069          this.reference = new Reference();
1070          return this.reference;
1071        }
1072        else
1073          return super.addChild(name);
1074      }
1075
1076      public ConsentDataComponent copy() {
1077        ConsentDataComponent dst = new ConsentDataComponent();
1078        copyValues(dst);
1079        dst.meaning = meaning == null ? null : meaning.copy();
1080        dst.reference = reference == null ? null : reference.copy();
1081        return dst;
1082      }
1083
1084      @Override
1085      public boolean equalsDeep(Base other) {
1086        if (!super.equalsDeep(other))
1087          return false;
1088        if (!(other instanceof ConsentDataComponent))
1089          return false;
1090        ConsentDataComponent o = (ConsentDataComponent) other;
1091        return compareDeep(meaning, o.meaning, true) && compareDeep(reference, o.reference, true);
1092      }
1093
1094      @Override
1095      public boolean equalsShallow(Base other) {
1096        if (!super.equalsShallow(other))
1097          return false;
1098        if (!(other instanceof ConsentDataComponent))
1099          return false;
1100        ConsentDataComponent o = (ConsentDataComponent) other;
1101        return compareValues(meaning, o.meaning, true);
1102      }
1103
1104      public boolean isEmpty() {
1105        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(meaning, reference);
1106      }
1107
1108  public String fhirType() {
1109    return "Consent.data";
1110
1111  }
1112
1113  }
1114
1115    @Block()
1116    public static class ExceptComponent extends BackboneElement implements IBaseBackboneElement {
1117        /**
1118         * Action  to take - permit or deny - when the exception conditions are met.
1119         */
1120        @Child(name = "type", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=true)
1121        @Description(shortDefinition="deny | permit", formalDefinition="Action  to take - permit or deny - when the exception conditions are met." )
1122        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/consent-except-type")
1123        protected Enumeration<ConsentExceptType> type;
1124
1125        /**
1126         * The timeframe in this exception is valid.
1127         */
1128        @Child(name = "period", type = {Period.class}, order=2, min=0, max=1, modifier=false, summary=true)
1129        @Description(shortDefinition="Timeframe for this exception", formalDefinition="The timeframe in this exception is valid." )
1130        protected Period period;
1131
1132        /**
1133         * Who or what is controlled by this Exception. Use group to identify a set of actors by some property they share (e.g. 'admitting officers').
1134         */
1135        @Child(name = "actor", type = {}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1136        @Description(shortDefinition="Who|what controlled by this exception (or group, by role)", formalDefinition="Who or what is controlled by this Exception. Use group to identify a set of actors by some property they share (e.g. 'admitting officers')." )
1137        protected List<ExceptActorComponent> actor;
1138
1139        /**
1140         * Actions controlled by this Exception.
1141         */
1142        @Child(name = "action", type = {CodeableConcept.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1143        @Description(shortDefinition="Actions controlled by this exception", formalDefinition="Actions controlled by this Exception." )
1144        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/consent-action")
1145        protected List<CodeableConcept> action;
1146
1147        /**
1148         * A set of security labels that define which resources are controlled by this exception. If more than one label is specified, all resources must have all the specified labels.
1149         */
1150        @Child(name = "securityLabel", type = {Coding.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1151        @Description(shortDefinition="Security Labels that define affected resources", formalDefinition="A set of security labels that define which resources are controlled by this exception. If more than one label is specified, all resources must have all the specified labels." )
1152        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/security-labels")
1153        protected List<Coding> securityLabel;
1154
1155        /**
1156         * The context of the activities a user is taking - why the user is accessing the data - that are controlled by this exception.
1157         */
1158        @Child(name = "purpose", type = {Coding.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1159        @Description(shortDefinition="Context of activities covered by this exception", formalDefinition="The context of the activities a user is taking - why the user is accessing the data - that are controlled by this exception." )
1160        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/v3-PurposeOfUse")
1161        protected List<Coding> purpose;
1162
1163        /**
1164         * The class of information covered by this exception. The type can be a FHIR resource type, a profile on a type, or a CDA document, or some other type that indicates what sort of information the consent relates to.
1165         */
1166        @Child(name = "class", type = {Coding.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1167        @Description(shortDefinition="e.g. Resource Type, Profile, or CDA etc", formalDefinition="The class of information covered by this exception. The type can be a FHIR resource type, a profile on a type, or a CDA document, or some other type that indicates what sort of information the consent relates to." )
1168        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/consent-content-class")
1169        protected List<Coding> class_;
1170
1171        /**
1172         * If this code is found in an instance, then the exception applies.
1173         */
1174        @Child(name = "code", type = {Coding.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1175        @Description(shortDefinition="e.g. LOINC or SNOMED CT code, etc in the content", formalDefinition="If this code is found in an instance, then the exception applies." )
1176        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/consent-content-code")
1177        protected List<Coding> code;
1178
1179        /**
1180         * Clinical or Operational Relevant period of time that bounds the data controlled by this exception.
1181         */
1182        @Child(name = "dataPeriod", type = {Period.class}, order=9, min=0, max=1, modifier=false, summary=true)
1183        @Description(shortDefinition="Timeframe for data controlled by this exception", formalDefinition="Clinical or Operational Relevant period of time that bounds the data controlled by this exception." )
1184        protected Period dataPeriod;
1185
1186        /**
1187         * The resources controlled by this exception, if specific resources are referenced.
1188         */
1189        @Child(name = "data", type = {}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1190        @Description(shortDefinition="Data controlled by this exception", formalDefinition="The resources controlled by this exception, if specific resources are referenced." )
1191        protected List<ExceptDataComponent> data;
1192
1193        private static final long serialVersionUID = 1586636291L;
1194
1195    /**
1196     * Constructor
1197     */
1198      public ExceptComponent() {
1199        super();
1200      }
1201
1202    /**
1203     * Constructor
1204     */
1205      public ExceptComponent(Enumeration<ConsentExceptType> type) {
1206        super();
1207        this.type = type;
1208      }
1209
1210        /**
1211         * @return {@link #type} (Action  to take - permit or deny - when the exception conditions are met.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
1212         */
1213        public Enumeration<ConsentExceptType> getTypeElement() { 
1214          if (this.type == null)
1215            if (Configuration.errorOnAutoCreate())
1216              throw new Error("Attempt to auto-create ExceptComponent.type");
1217            else if (Configuration.doAutoCreate())
1218              this.type = new Enumeration<ConsentExceptType>(new ConsentExceptTypeEnumFactory()); // bb
1219          return this.type;
1220        }
1221
1222        public boolean hasTypeElement() { 
1223          return this.type != null && !this.type.isEmpty();
1224        }
1225
1226        public boolean hasType() { 
1227          return this.type != null && !this.type.isEmpty();
1228        }
1229
1230        /**
1231         * @param value {@link #type} (Action  to take - permit or deny - when the exception conditions are met.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
1232         */
1233        public ExceptComponent setTypeElement(Enumeration<ConsentExceptType> value) { 
1234          this.type = value;
1235          return this;
1236        }
1237
1238        /**
1239         * @return Action  to take - permit or deny - when the exception conditions are met.
1240         */
1241        public ConsentExceptType getType() { 
1242          return this.type == null ? null : this.type.getValue();
1243        }
1244
1245        /**
1246         * @param value Action  to take - permit or deny - when the exception conditions are met.
1247         */
1248        public ExceptComponent setType(ConsentExceptType value) { 
1249            if (this.type == null)
1250              this.type = new Enumeration<ConsentExceptType>(new ConsentExceptTypeEnumFactory());
1251            this.type.setValue(value);
1252          return this;
1253        }
1254
1255        /**
1256         * @return {@link #period} (The timeframe in this exception is valid.)
1257         */
1258        public Period getPeriod() { 
1259          if (this.period == null)
1260            if (Configuration.errorOnAutoCreate())
1261              throw new Error("Attempt to auto-create ExceptComponent.period");
1262            else if (Configuration.doAutoCreate())
1263              this.period = new Period(); // cc
1264          return this.period;
1265        }
1266
1267        public boolean hasPeriod() { 
1268          return this.period != null && !this.period.isEmpty();
1269        }
1270
1271        /**
1272         * @param value {@link #period} (The timeframe in this exception is valid.)
1273         */
1274        public ExceptComponent setPeriod(Period value) { 
1275          this.period = value;
1276          return this;
1277        }
1278
1279        /**
1280         * @return {@link #actor} (Who or what is controlled by this Exception. Use group to identify a set of actors by some property they share (e.g. 'admitting officers').)
1281         */
1282        public List<ExceptActorComponent> getActor() { 
1283          if (this.actor == null)
1284            this.actor = new ArrayList<ExceptActorComponent>();
1285          return this.actor;
1286        }
1287
1288        /**
1289         * @return Returns a reference to <code>this</code> for easy method chaining
1290         */
1291        public ExceptComponent setActor(List<ExceptActorComponent> theActor) { 
1292          this.actor = theActor;
1293          return this;
1294        }
1295
1296        public boolean hasActor() { 
1297          if (this.actor == null)
1298            return false;
1299          for (ExceptActorComponent item : this.actor)
1300            if (!item.isEmpty())
1301              return true;
1302          return false;
1303        }
1304
1305        public ExceptActorComponent addActor() { //3
1306          ExceptActorComponent t = new ExceptActorComponent();
1307          if (this.actor == null)
1308            this.actor = new ArrayList<ExceptActorComponent>();
1309          this.actor.add(t);
1310          return t;
1311        }
1312
1313        public ExceptComponent addActor(ExceptActorComponent t) { //3
1314          if (t == null)
1315            return this;
1316          if (this.actor == null)
1317            this.actor = new ArrayList<ExceptActorComponent>();
1318          this.actor.add(t);
1319          return this;
1320        }
1321
1322        /**
1323         * @return The first repetition of repeating field {@link #actor}, creating it if it does not already exist
1324         */
1325        public ExceptActorComponent getActorFirstRep() { 
1326          if (getActor().isEmpty()) {
1327            addActor();
1328          }
1329          return getActor().get(0);
1330        }
1331
1332        /**
1333         * @return {@link #action} (Actions controlled by this Exception.)
1334         */
1335        public List<CodeableConcept> getAction() { 
1336          if (this.action == null)
1337            this.action = new ArrayList<CodeableConcept>();
1338          return this.action;
1339        }
1340
1341        /**
1342         * @return Returns a reference to <code>this</code> for easy method chaining
1343         */
1344        public ExceptComponent setAction(List<CodeableConcept> theAction) { 
1345          this.action = theAction;
1346          return this;
1347        }
1348
1349        public boolean hasAction() { 
1350          if (this.action == null)
1351            return false;
1352          for (CodeableConcept item : this.action)
1353            if (!item.isEmpty())
1354              return true;
1355          return false;
1356        }
1357
1358        public CodeableConcept addAction() { //3
1359          CodeableConcept t = new CodeableConcept();
1360          if (this.action == null)
1361            this.action = new ArrayList<CodeableConcept>();
1362          this.action.add(t);
1363          return t;
1364        }
1365
1366        public ExceptComponent addAction(CodeableConcept t) { //3
1367          if (t == null)
1368            return this;
1369          if (this.action == null)
1370            this.action = new ArrayList<CodeableConcept>();
1371          this.action.add(t);
1372          return this;
1373        }
1374
1375        /**
1376         * @return The first repetition of repeating field {@link #action}, creating it if it does not already exist
1377         */
1378        public CodeableConcept getActionFirstRep() { 
1379          if (getAction().isEmpty()) {
1380            addAction();
1381          }
1382          return getAction().get(0);
1383        }
1384
1385        /**
1386         * @return {@link #securityLabel} (A set of security labels that define which resources are controlled by this exception. If more than one label is specified, all resources must have all the specified labels.)
1387         */
1388        public List<Coding> getSecurityLabel() { 
1389          if (this.securityLabel == null)
1390            this.securityLabel = new ArrayList<Coding>();
1391          return this.securityLabel;
1392        }
1393
1394        /**
1395         * @return Returns a reference to <code>this</code> for easy method chaining
1396         */
1397        public ExceptComponent setSecurityLabel(List<Coding> theSecurityLabel) { 
1398          this.securityLabel = theSecurityLabel;
1399          return this;
1400        }
1401
1402        public boolean hasSecurityLabel() { 
1403          if (this.securityLabel == null)
1404            return false;
1405          for (Coding item : this.securityLabel)
1406            if (!item.isEmpty())
1407              return true;
1408          return false;
1409        }
1410
1411        public Coding addSecurityLabel() { //3
1412          Coding t = new Coding();
1413          if (this.securityLabel == null)
1414            this.securityLabel = new ArrayList<Coding>();
1415          this.securityLabel.add(t);
1416          return t;
1417        }
1418
1419        public ExceptComponent addSecurityLabel(Coding t) { //3
1420          if (t == null)
1421            return this;
1422          if (this.securityLabel == null)
1423            this.securityLabel = new ArrayList<Coding>();
1424          this.securityLabel.add(t);
1425          return this;
1426        }
1427
1428        /**
1429         * @return The first repetition of repeating field {@link #securityLabel}, creating it if it does not already exist
1430         */
1431        public Coding getSecurityLabelFirstRep() { 
1432          if (getSecurityLabel().isEmpty()) {
1433            addSecurityLabel();
1434          }
1435          return getSecurityLabel().get(0);
1436        }
1437
1438        /**
1439         * @return {@link #purpose} (The context of the activities a user is taking - why the user is accessing the data - that are controlled by this exception.)
1440         */
1441        public List<Coding> getPurpose() { 
1442          if (this.purpose == null)
1443            this.purpose = new ArrayList<Coding>();
1444          return this.purpose;
1445        }
1446
1447        /**
1448         * @return Returns a reference to <code>this</code> for easy method chaining
1449         */
1450        public ExceptComponent setPurpose(List<Coding> thePurpose) { 
1451          this.purpose = thePurpose;
1452          return this;
1453        }
1454
1455        public boolean hasPurpose() { 
1456          if (this.purpose == null)
1457            return false;
1458          for (Coding item : this.purpose)
1459            if (!item.isEmpty())
1460              return true;
1461          return false;
1462        }
1463
1464        public Coding addPurpose() { //3
1465          Coding t = new Coding();
1466          if (this.purpose == null)
1467            this.purpose = new ArrayList<Coding>();
1468          this.purpose.add(t);
1469          return t;
1470        }
1471
1472        public ExceptComponent addPurpose(Coding t) { //3
1473          if (t == null)
1474            return this;
1475          if (this.purpose == null)
1476            this.purpose = new ArrayList<Coding>();
1477          this.purpose.add(t);
1478          return this;
1479        }
1480
1481        /**
1482         * @return The first repetition of repeating field {@link #purpose}, creating it if it does not already exist
1483         */
1484        public Coding getPurposeFirstRep() { 
1485          if (getPurpose().isEmpty()) {
1486            addPurpose();
1487          }
1488          return getPurpose().get(0);
1489        }
1490
1491        /**
1492         * @return {@link #class_} (The class of information covered by this exception. The type can be a FHIR resource type, a profile on a type, or a CDA document, or some other type that indicates what sort of information the consent relates to.)
1493         */
1494        public List<Coding> getClass_() { 
1495          if (this.class_ == null)
1496            this.class_ = new ArrayList<Coding>();
1497          return this.class_;
1498        }
1499
1500        /**
1501         * @return Returns a reference to <code>this</code> for easy method chaining
1502         */
1503        public ExceptComponent setClass_(List<Coding> theClass_) { 
1504          this.class_ = theClass_;
1505          return this;
1506        }
1507
1508        public boolean hasClass_() { 
1509          if (this.class_ == null)
1510            return false;
1511          for (Coding item : this.class_)
1512            if (!item.isEmpty())
1513              return true;
1514          return false;
1515        }
1516
1517        public Coding addClass_() { //3
1518          Coding t = new Coding();
1519          if (this.class_ == null)
1520            this.class_ = new ArrayList<Coding>();
1521          this.class_.add(t);
1522          return t;
1523        }
1524
1525        public ExceptComponent addClass_(Coding t) { //3
1526          if (t == null)
1527            return this;
1528          if (this.class_ == null)
1529            this.class_ = new ArrayList<Coding>();
1530          this.class_.add(t);
1531          return this;
1532        }
1533
1534        /**
1535         * @return The first repetition of repeating field {@link #class_}, creating it if it does not already exist
1536         */
1537        public Coding getClass_FirstRep() { 
1538          if (getClass_().isEmpty()) {
1539            addClass_();
1540          }
1541          return getClass_().get(0);
1542        }
1543
1544        /**
1545         * @return {@link #code} (If this code is found in an instance, then the exception applies.)
1546         */
1547        public List<Coding> getCode() { 
1548          if (this.code == null)
1549            this.code = new ArrayList<Coding>();
1550          return this.code;
1551        }
1552
1553        /**
1554         * @return Returns a reference to <code>this</code> for easy method chaining
1555         */
1556        public ExceptComponent setCode(List<Coding> theCode) { 
1557          this.code = theCode;
1558          return this;
1559        }
1560
1561        public boolean hasCode() { 
1562          if (this.code == null)
1563            return false;
1564          for (Coding item : this.code)
1565            if (!item.isEmpty())
1566              return true;
1567          return false;
1568        }
1569
1570        public Coding addCode() { //3
1571          Coding t = new Coding();
1572          if (this.code == null)
1573            this.code = new ArrayList<Coding>();
1574          this.code.add(t);
1575          return t;
1576        }
1577
1578        public ExceptComponent addCode(Coding t) { //3
1579          if (t == null)
1580            return this;
1581          if (this.code == null)
1582            this.code = new ArrayList<Coding>();
1583          this.code.add(t);
1584          return this;
1585        }
1586
1587        /**
1588         * @return The first repetition of repeating field {@link #code}, creating it if it does not already exist
1589         */
1590        public Coding getCodeFirstRep() { 
1591          if (getCode().isEmpty()) {
1592            addCode();
1593          }
1594          return getCode().get(0);
1595        }
1596
1597        /**
1598         * @return {@link #dataPeriod} (Clinical or Operational Relevant period of time that bounds the data controlled by this exception.)
1599         */
1600        public Period getDataPeriod() { 
1601          if (this.dataPeriod == null)
1602            if (Configuration.errorOnAutoCreate())
1603              throw new Error("Attempt to auto-create ExceptComponent.dataPeriod");
1604            else if (Configuration.doAutoCreate())
1605              this.dataPeriod = new Period(); // cc
1606          return this.dataPeriod;
1607        }
1608
1609        public boolean hasDataPeriod() { 
1610          return this.dataPeriod != null && !this.dataPeriod.isEmpty();
1611        }
1612
1613        /**
1614         * @param value {@link #dataPeriod} (Clinical or Operational Relevant period of time that bounds the data controlled by this exception.)
1615         */
1616        public ExceptComponent setDataPeriod(Period value) { 
1617          this.dataPeriod = value;
1618          return this;
1619        }
1620
1621        /**
1622         * @return {@link #data} (The resources controlled by this exception, if specific resources are referenced.)
1623         */
1624        public List<ExceptDataComponent> getData() { 
1625          if (this.data == null)
1626            this.data = new ArrayList<ExceptDataComponent>();
1627          return this.data;
1628        }
1629
1630        /**
1631         * @return Returns a reference to <code>this</code> for easy method chaining
1632         */
1633        public ExceptComponent setData(List<ExceptDataComponent> theData) { 
1634          this.data = theData;
1635          return this;
1636        }
1637
1638        public boolean hasData() { 
1639          if (this.data == null)
1640            return false;
1641          for (ExceptDataComponent item : this.data)
1642            if (!item.isEmpty())
1643              return true;
1644          return false;
1645        }
1646
1647        public ExceptDataComponent addData() { //3
1648          ExceptDataComponent t = new ExceptDataComponent();
1649          if (this.data == null)
1650            this.data = new ArrayList<ExceptDataComponent>();
1651          this.data.add(t);
1652          return t;
1653        }
1654
1655        public ExceptComponent addData(ExceptDataComponent t) { //3
1656          if (t == null)
1657            return this;
1658          if (this.data == null)
1659            this.data = new ArrayList<ExceptDataComponent>();
1660          this.data.add(t);
1661          return this;
1662        }
1663
1664        /**
1665         * @return The first repetition of repeating field {@link #data}, creating it if it does not already exist
1666         */
1667        public ExceptDataComponent getDataFirstRep() { 
1668          if (getData().isEmpty()) {
1669            addData();
1670          }
1671          return getData().get(0);
1672        }
1673
1674        protected void listChildren(List<Property> childrenList) {
1675          super.listChildren(childrenList);
1676          childrenList.add(new Property("type", "code", "Action  to take - permit or deny - when the exception conditions are met.", 0, java.lang.Integer.MAX_VALUE, type));
1677          childrenList.add(new Property("period", "Period", "The timeframe in this exception is valid.", 0, java.lang.Integer.MAX_VALUE, period));
1678          childrenList.add(new Property("actor", "", "Who or what is controlled by this Exception. Use group to identify a set of actors by some property they share (e.g. 'admitting officers').", 0, java.lang.Integer.MAX_VALUE, actor));
1679          childrenList.add(new Property("action", "CodeableConcept", "Actions controlled by this Exception.", 0, java.lang.Integer.MAX_VALUE, action));
1680          childrenList.add(new Property("securityLabel", "Coding", "A set of security labels that define which resources are controlled by this exception. If more than one label is specified, all resources must have all the specified labels.", 0, java.lang.Integer.MAX_VALUE, securityLabel));
1681          childrenList.add(new Property("purpose", "Coding", "The context of the activities a user is taking - why the user is accessing the data - that are controlled by this exception.", 0, java.lang.Integer.MAX_VALUE, purpose));
1682          childrenList.add(new Property("class", "Coding", "The class of information covered by this exception. The type can be a FHIR resource type, a profile on a type, or a CDA document, or some other type that indicates what sort of information the consent relates to.", 0, java.lang.Integer.MAX_VALUE, class_));
1683          childrenList.add(new Property("code", "Coding", "If this code is found in an instance, then the exception applies.", 0, java.lang.Integer.MAX_VALUE, code));
1684          childrenList.add(new Property("dataPeriod", "Period", "Clinical or Operational Relevant period of time that bounds the data controlled by this exception.", 0, java.lang.Integer.MAX_VALUE, dataPeriod));
1685          childrenList.add(new Property("data", "", "The resources controlled by this exception, if specific resources are referenced.", 0, java.lang.Integer.MAX_VALUE, data));
1686        }
1687
1688      @Override
1689      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1690        switch (hash) {
1691        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // Enumeration<ConsentExceptType>
1692        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
1693        case 92645877: /*actor*/ return this.actor == null ? new Base[0] : this.actor.toArray(new Base[this.actor.size()]); // ExceptActorComponent
1694        case -1422950858: /*action*/ return this.action == null ? new Base[0] : this.action.toArray(new Base[this.action.size()]); // CodeableConcept
1695        case -722296940: /*securityLabel*/ return this.securityLabel == null ? new Base[0] : this.securityLabel.toArray(new Base[this.securityLabel.size()]); // Coding
1696        case -220463842: /*purpose*/ return this.purpose == null ? new Base[0] : this.purpose.toArray(new Base[this.purpose.size()]); // Coding
1697        case 94742904: /*class*/ return this.class_ == null ? new Base[0] : this.class_.toArray(new Base[this.class_.size()]); // Coding
1698        case 3059181: /*code*/ return this.code == null ? new Base[0] : this.code.toArray(new Base[this.code.size()]); // Coding
1699        case 1177250315: /*dataPeriod*/ return this.dataPeriod == null ? new Base[0] : new Base[] {this.dataPeriod}; // Period
1700        case 3076010: /*data*/ return this.data == null ? new Base[0] : this.data.toArray(new Base[this.data.size()]); // ExceptDataComponent
1701        default: return super.getProperty(hash, name, checkValid);
1702        }
1703
1704      }
1705
1706      @Override
1707      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1708        switch (hash) {
1709        case 3575610: // type
1710          value = new ConsentExceptTypeEnumFactory().fromType(castToCode(value));
1711          this.type = (Enumeration) value; // Enumeration<ConsentExceptType>
1712          return value;
1713        case -991726143: // period
1714          this.period = castToPeriod(value); // Period
1715          return value;
1716        case 92645877: // actor
1717          this.getActor().add((ExceptActorComponent) value); // ExceptActorComponent
1718          return value;
1719        case -1422950858: // action
1720          this.getAction().add(castToCodeableConcept(value)); // CodeableConcept
1721          return value;
1722        case -722296940: // securityLabel
1723          this.getSecurityLabel().add(castToCoding(value)); // Coding
1724          return value;
1725        case -220463842: // purpose
1726          this.getPurpose().add(castToCoding(value)); // Coding
1727          return value;
1728        case 94742904: // class
1729          this.getClass_().add(castToCoding(value)); // Coding
1730          return value;
1731        case 3059181: // code
1732          this.getCode().add(castToCoding(value)); // Coding
1733          return value;
1734        case 1177250315: // dataPeriod
1735          this.dataPeriod = castToPeriod(value); // Period
1736          return value;
1737        case 3076010: // data
1738          this.getData().add((ExceptDataComponent) value); // ExceptDataComponent
1739          return value;
1740        default: return super.setProperty(hash, name, value);
1741        }
1742
1743      }
1744
1745      @Override
1746      public Base setProperty(String name, Base value) throws FHIRException {
1747        if (name.equals("type")) {
1748          value = new ConsentExceptTypeEnumFactory().fromType(castToCode(value));
1749          this.type = (Enumeration) value; // Enumeration<ConsentExceptType>
1750        } else if (name.equals("period")) {
1751          this.period = castToPeriod(value); // Period
1752        } else if (name.equals("actor")) {
1753          this.getActor().add((ExceptActorComponent) value);
1754        } else if (name.equals("action")) {
1755          this.getAction().add(castToCodeableConcept(value));
1756        } else if (name.equals("securityLabel")) {
1757          this.getSecurityLabel().add(castToCoding(value));
1758        } else if (name.equals("purpose")) {
1759          this.getPurpose().add(castToCoding(value));
1760        } else if (name.equals("class")) {
1761          this.getClass_().add(castToCoding(value));
1762        } else if (name.equals("code")) {
1763          this.getCode().add(castToCoding(value));
1764        } else if (name.equals("dataPeriod")) {
1765          this.dataPeriod = castToPeriod(value); // Period
1766        } else if (name.equals("data")) {
1767          this.getData().add((ExceptDataComponent) value);
1768        } else
1769          return super.setProperty(name, value);
1770        return value;
1771      }
1772
1773      @Override
1774      public Base makeProperty(int hash, String name) throws FHIRException {
1775        switch (hash) {
1776        case 3575610:  return getTypeElement();
1777        case -991726143:  return getPeriod(); 
1778        case 92645877:  return addActor(); 
1779        case -1422950858:  return addAction(); 
1780        case -722296940:  return addSecurityLabel(); 
1781        case -220463842:  return addPurpose(); 
1782        case 94742904:  return addClass_(); 
1783        case 3059181:  return addCode(); 
1784        case 1177250315:  return getDataPeriod(); 
1785        case 3076010:  return addData(); 
1786        default: return super.makeProperty(hash, name);
1787        }
1788
1789      }
1790
1791      @Override
1792      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1793        switch (hash) {
1794        case 3575610: /*type*/ return new String[] {"code"};
1795        case -991726143: /*period*/ return new String[] {"Period"};
1796        case 92645877: /*actor*/ return new String[] {};
1797        case -1422950858: /*action*/ return new String[] {"CodeableConcept"};
1798        case -722296940: /*securityLabel*/ return new String[] {"Coding"};
1799        case -220463842: /*purpose*/ return new String[] {"Coding"};
1800        case 94742904: /*class*/ return new String[] {"Coding"};
1801        case 3059181: /*code*/ return new String[] {"Coding"};
1802        case 1177250315: /*dataPeriod*/ return new String[] {"Period"};
1803        case 3076010: /*data*/ return new String[] {};
1804        default: return super.getTypesForProperty(hash, name);
1805        }
1806
1807      }
1808
1809      @Override
1810      public Base addChild(String name) throws FHIRException {
1811        if (name.equals("type")) {
1812          throw new FHIRException("Cannot call addChild on a primitive type Consent.type");
1813        }
1814        else if (name.equals("period")) {
1815          this.period = new Period();
1816          return this.period;
1817        }
1818        else if (name.equals("actor")) {
1819          return addActor();
1820        }
1821        else if (name.equals("action")) {
1822          return addAction();
1823        }
1824        else if (name.equals("securityLabel")) {
1825          return addSecurityLabel();
1826        }
1827        else if (name.equals("purpose")) {
1828          return addPurpose();
1829        }
1830        else if (name.equals("class")) {
1831          return addClass_();
1832        }
1833        else if (name.equals("code")) {
1834          return addCode();
1835        }
1836        else if (name.equals("dataPeriod")) {
1837          this.dataPeriod = new Period();
1838          return this.dataPeriod;
1839        }
1840        else if (name.equals("data")) {
1841          return addData();
1842        }
1843        else
1844          return super.addChild(name);
1845      }
1846
1847      public ExceptComponent copy() {
1848        ExceptComponent dst = new ExceptComponent();
1849        copyValues(dst);
1850        dst.type = type == null ? null : type.copy();
1851        dst.period = period == null ? null : period.copy();
1852        if (actor != null) {
1853          dst.actor = new ArrayList<ExceptActorComponent>();
1854          for (ExceptActorComponent i : actor)
1855            dst.actor.add(i.copy());
1856        };
1857        if (action != null) {
1858          dst.action = new ArrayList<CodeableConcept>();
1859          for (CodeableConcept i : action)
1860            dst.action.add(i.copy());
1861        };
1862        if (securityLabel != null) {
1863          dst.securityLabel = new ArrayList<Coding>();
1864          for (Coding i : securityLabel)
1865            dst.securityLabel.add(i.copy());
1866        };
1867        if (purpose != null) {
1868          dst.purpose = new ArrayList<Coding>();
1869          for (Coding i : purpose)
1870            dst.purpose.add(i.copy());
1871        };
1872        if (class_ != null) {
1873          dst.class_ = new ArrayList<Coding>();
1874          for (Coding i : class_)
1875            dst.class_.add(i.copy());
1876        };
1877        if (code != null) {
1878          dst.code = new ArrayList<Coding>();
1879          for (Coding i : code)
1880            dst.code.add(i.copy());
1881        };
1882        dst.dataPeriod = dataPeriod == null ? null : dataPeriod.copy();
1883        if (data != null) {
1884          dst.data = new ArrayList<ExceptDataComponent>();
1885          for (ExceptDataComponent i : data)
1886            dst.data.add(i.copy());
1887        };
1888        return dst;
1889      }
1890
1891      @Override
1892      public boolean equalsDeep(Base other) {
1893        if (!super.equalsDeep(other))
1894          return false;
1895        if (!(other instanceof ExceptComponent))
1896          return false;
1897        ExceptComponent o = (ExceptComponent) other;
1898        return compareDeep(type, o.type, true) && compareDeep(period, o.period, true) && compareDeep(actor, o.actor, true)
1899           && compareDeep(action, o.action, true) && compareDeep(securityLabel, o.securityLabel, true) && compareDeep(purpose, o.purpose, true)
1900           && compareDeep(class_, o.class_, true) && compareDeep(code, o.code, true) && compareDeep(dataPeriod, o.dataPeriod, true)
1901           && compareDeep(data, o.data, true);
1902      }
1903
1904      @Override
1905      public boolean equalsShallow(Base other) {
1906        if (!super.equalsShallow(other))
1907          return false;
1908        if (!(other instanceof ExceptComponent))
1909          return false;
1910        ExceptComponent o = (ExceptComponent) other;
1911        return compareValues(type, o.type, true);
1912      }
1913
1914      public boolean isEmpty() {
1915        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, period, actor, action
1916          , securityLabel, purpose, class_, code, dataPeriod, data);
1917      }
1918
1919  public String fhirType() {
1920    return "Consent.except";
1921
1922  }
1923
1924  }
1925
1926    @Block()
1927    public static class ExceptActorComponent extends BackboneElement implements IBaseBackboneElement {
1928        /**
1929         * How the individual is involved in the resources content that is described in the exception.
1930         */
1931        @Child(name = "role", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=false)
1932        @Description(shortDefinition="How the actor is involved", formalDefinition="How the individual is involved in the resources content that is described in the exception." )
1933        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/security-role-type")
1934        protected CodeableConcept role;
1935
1936        /**
1937         * The resource that identifies the actor. To identify a actors by type, use group to identify a set of actors by some property they share (e.g. 'admitting officers').
1938         */
1939        @Child(name = "reference", type = {Device.class, Group.class, CareTeam.class, Organization.class, Patient.class, Practitioner.class, RelatedPerson.class}, order=2, min=1, max=1, modifier=false, summary=false)
1940        @Description(shortDefinition="Resource for the actor (or group, by role)", formalDefinition="The resource that identifies the actor. To identify a actors by type, use group to identify a set of actors by some property they share (e.g. 'admitting officers')." )
1941        protected Reference reference;
1942
1943        /**
1944         * The actual object that is the target of the reference (The resource that identifies the actor. To identify a actors by type, use group to identify a set of actors by some property they share (e.g. 'admitting officers').)
1945         */
1946        protected Resource referenceTarget;
1947
1948        private static final long serialVersionUID = 1152919415L;
1949
1950    /**
1951     * Constructor
1952     */
1953      public ExceptActorComponent() {
1954        super();
1955      }
1956
1957    /**
1958     * Constructor
1959     */
1960      public ExceptActorComponent(CodeableConcept role, Reference reference) {
1961        super();
1962        this.role = role;
1963        this.reference = reference;
1964      }
1965
1966        /**
1967         * @return {@link #role} (How the individual is involved in the resources content that is described in the exception.)
1968         */
1969        public CodeableConcept getRole() { 
1970          if (this.role == null)
1971            if (Configuration.errorOnAutoCreate())
1972              throw new Error("Attempt to auto-create ExceptActorComponent.role");
1973            else if (Configuration.doAutoCreate())
1974              this.role = new CodeableConcept(); // cc
1975          return this.role;
1976        }
1977
1978        public boolean hasRole() { 
1979          return this.role != null && !this.role.isEmpty();
1980        }
1981
1982        /**
1983         * @param value {@link #role} (How the individual is involved in the resources content that is described in the exception.)
1984         */
1985        public ExceptActorComponent setRole(CodeableConcept value) { 
1986          this.role = value;
1987          return this;
1988        }
1989
1990        /**
1991         * @return {@link #reference} (The resource that identifies the actor. To identify a actors by type, use group to identify a set of actors by some property they share (e.g. 'admitting officers').)
1992         */
1993        public Reference getReference() { 
1994          if (this.reference == null)
1995            if (Configuration.errorOnAutoCreate())
1996              throw new Error("Attempt to auto-create ExceptActorComponent.reference");
1997            else if (Configuration.doAutoCreate())
1998              this.reference = new Reference(); // cc
1999          return this.reference;
2000        }
2001
2002        public boolean hasReference() { 
2003          return this.reference != null && !this.reference.isEmpty();
2004        }
2005
2006        /**
2007         * @param value {@link #reference} (The resource that identifies the actor. To identify a actors by type, use group to identify a set of actors by some property they share (e.g. 'admitting officers').)
2008         */
2009        public ExceptActorComponent setReference(Reference value) { 
2010          this.reference = value;
2011          return this;
2012        }
2013
2014        /**
2015         * @return {@link #reference} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The resource that identifies the actor. To identify a actors by type, use group to identify a set of actors by some property they share (e.g. 'admitting officers').)
2016         */
2017        public Resource getReferenceTarget() { 
2018          return this.referenceTarget;
2019        }
2020
2021        /**
2022         * @param value {@link #reference} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The resource that identifies the actor. To identify a actors by type, use group to identify a set of actors by some property they share (e.g. 'admitting officers').)
2023         */
2024        public ExceptActorComponent setReferenceTarget(Resource value) { 
2025          this.referenceTarget = value;
2026          return this;
2027        }
2028
2029        protected void listChildren(List<Property> childrenList) {
2030          super.listChildren(childrenList);
2031          childrenList.add(new Property("role", "CodeableConcept", "How the individual is involved in the resources content that is described in the exception.", 0, java.lang.Integer.MAX_VALUE, role));
2032          childrenList.add(new Property("reference", "Reference(Device|Group|CareTeam|Organization|Patient|Practitioner|RelatedPerson)", "The resource that identifies the actor. To identify a actors by type, use group to identify a set of actors by some property they share (e.g. 'admitting officers').", 0, java.lang.Integer.MAX_VALUE, reference));
2033        }
2034
2035      @Override
2036      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2037        switch (hash) {
2038        case 3506294: /*role*/ return this.role == null ? new Base[0] : new Base[] {this.role}; // CodeableConcept
2039        case -925155509: /*reference*/ return this.reference == null ? new Base[0] : new Base[] {this.reference}; // Reference
2040        default: return super.getProperty(hash, name, checkValid);
2041        }
2042
2043      }
2044
2045      @Override
2046      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2047        switch (hash) {
2048        case 3506294: // role
2049          this.role = castToCodeableConcept(value); // CodeableConcept
2050          return value;
2051        case -925155509: // reference
2052          this.reference = castToReference(value); // Reference
2053          return value;
2054        default: return super.setProperty(hash, name, value);
2055        }
2056
2057      }
2058
2059      @Override
2060      public Base setProperty(String name, Base value) throws FHIRException {
2061        if (name.equals("role")) {
2062          this.role = castToCodeableConcept(value); // CodeableConcept
2063        } else if (name.equals("reference")) {
2064          this.reference = castToReference(value); // Reference
2065        } else
2066          return super.setProperty(name, value);
2067        return value;
2068      }
2069
2070      @Override
2071      public Base makeProperty(int hash, String name) throws FHIRException {
2072        switch (hash) {
2073        case 3506294:  return getRole(); 
2074        case -925155509:  return getReference(); 
2075        default: return super.makeProperty(hash, name);
2076        }
2077
2078      }
2079
2080      @Override
2081      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2082        switch (hash) {
2083        case 3506294: /*role*/ return new String[] {"CodeableConcept"};
2084        case -925155509: /*reference*/ return new String[] {"Reference"};
2085        default: return super.getTypesForProperty(hash, name);
2086        }
2087
2088      }
2089
2090      @Override
2091      public Base addChild(String name) throws FHIRException {
2092        if (name.equals("role")) {
2093          this.role = new CodeableConcept();
2094          return this.role;
2095        }
2096        else if (name.equals("reference")) {
2097          this.reference = new Reference();
2098          return this.reference;
2099        }
2100        else
2101          return super.addChild(name);
2102      }
2103
2104      public ExceptActorComponent copy() {
2105        ExceptActorComponent dst = new ExceptActorComponent();
2106        copyValues(dst);
2107        dst.role = role == null ? null : role.copy();
2108        dst.reference = reference == null ? null : reference.copy();
2109        return dst;
2110      }
2111
2112      @Override
2113      public boolean equalsDeep(Base other) {
2114        if (!super.equalsDeep(other))
2115          return false;
2116        if (!(other instanceof ExceptActorComponent))
2117          return false;
2118        ExceptActorComponent o = (ExceptActorComponent) other;
2119        return compareDeep(role, o.role, true) && compareDeep(reference, o.reference, true);
2120      }
2121
2122      @Override
2123      public boolean equalsShallow(Base other) {
2124        if (!super.equalsShallow(other))
2125          return false;
2126        if (!(other instanceof ExceptActorComponent))
2127          return false;
2128        ExceptActorComponent o = (ExceptActorComponent) other;
2129        return true;
2130      }
2131
2132      public boolean isEmpty() {
2133        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(role, reference);
2134      }
2135
2136  public String fhirType() {
2137    return "Consent.except.actor";
2138
2139  }
2140
2141  }
2142
2143    @Block()
2144    public static class ExceptDataComponent extends BackboneElement implements IBaseBackboneElement {
2145        /**
2146         * How the resource reference is interpreted when testing consent restrictions.
2147         */
2148        @Child(name = "meaning", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=true)
2149        @Description(shortDefinition="instance | related | dependents | authoredby", formalDefinition="How the resource reference is interpreted when testing consent restrictions." )
2150        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/consent-data-meaning")
2151        protected Enumeration<ConsentDataMeaning> meaning;
2152
2153        /**
2154         * A reference to a specific resource that defines which resources are covered by this consent.
2155         */
2156        @Child(name = "reference", type = {Reference.class}, order=2, min=1, max=1, modifier=false, summary=true)
2157        @Description(shortDefinition="The actual data reference", formalDefinition="A reference to a specific resource that defines which resources are covered by this consent." )
2158        protected Reference reference;
2159
2160        /**
2161         * The actual object that is the target of the reference (A reference to a specific resource that defines which resources are covered by this consent.)
2162         */
2163        protected Resource referenceTarget;
2164
2165        private static final long serialVersionUID = -424898645L;
2166
2167    /**
2168     * Constructor
2169     */
2170      public ExceptDataComponent() {
2171        super();
2172      }
2173
2174    /**
2175     * Constructor
2176     */
2177      public ExceptDataComponent(Enumeration<ConsentDataMeaning> meaning, Reference reference) {
2178        super();
2179        this.meaning = meaning;
2180        this.reference = reference;
2181      }
2182
2183        /**
2184         * @return {@link #meaning} (How the resource reference is interpreted when testing consent restrictions.). This is the underlying object with id, value and extensions. The accessor "getMeaning" gives direct access to the value
2185         */
2186        public Enumeration<ConsentDataMeaning> getMeaningElement() { 
2187          if (this.meaning == null)
2188            if (Configuration.errorOnAutoCreate())
2189              throw new Error("Attempt to auto-create ExceptDataComponent.meaning");
2190            else if (Configuration.doAutoCreate())
2191              this.meaning = new Enumeration<ConsentDataMeaning>(new ConsentDataMeaningEnumFactory()); // bb
2192          return this.meaning;
2193        }
2194
2195        public boolean hasMeaningElement() { 
2196          return this.meaning != null && !this.meaning.isEmpty();
2197        }
2198
2199        public boolean hasMeaning() { 
2200          return this.meaning != null && !this.meaning.isEmpty();
2201        }
2202
2203        /**
2204         * @param value {@link #meaning} (How the resource reference is interpreted when testing consent restrictions.). This is the underlying object with id, value and extensions. The accessor "getMeaning" gives direct access to the value
2205         */
2206        public ExceptDataComponent setMeaningElement(Enumeration<ConsentDataMeaning> value) { 
2207          this.meaning = value;
2208          return this;
2209        }
2210
2211        /**
2212         * @return How the resource reference is interpreted when testing consent restrictions.
2213         */
2214        public ConsentDataMeaning getMeaning() { 
2215          return this.meaning == null ? null : this.meaning.getValue();
2216        }
2217
2218        /**
2219         * @param value How the resource reference is interpreted when testing consent restrictions.
2220         */
2221        public ExceptDataComponent setMeaning(ConsentDataMeaning value) { 
2222            if (this.meaning == null)
2223              this.meaning = new Enumeration<ConsentDataMeaning>(new ConsentDataMeaningEnumFactory());
2224            this.meaning.setValue(value);
2225          return this;
2226        }
2227
2228        /**
2229         * @return {@link #reference} (A reference to a specific resource that defines which resources are covered by this consent.)
2230         */
2231        public Reference getReference() { 
2232          if (this.reference == null)
2233            if (Configuration.errorOnAutoCreate())
2234              throw new Error("Attempt to auto-create ExceptDataComponent.reference");
2235            else if (Configuration.doAutoCreate())
2236              this.reference = new Reference(); // cc
2237          return this.reference;
2238        }
2239
2240        public boolean hasReference() { 
2241          return this.reference != null && !this.reference.isEmpty();
2242        }
2243
2244        /**
2245         * @param value {@link #reference} (A reference to a specific resource that defines which resources are covered by this consent.)
2246         */
2247        public ExceptDataComponent setReference(Reference value) { 
2248          this.reference = value;
2249          return this;
2250        }
2251
2252        /**
2253         * @return {@link #reference} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (A reference to a specific resource that defines which resources are covered by this consent.)
2254         */
2255        public Resource getReferenceTarget() { 
2256          return this.referenceTarget;
2257        }
2258
2259        /**
2260         * @param value {@link #reference} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (A reference to a specific resource that defines which resources are covered by this consent.)
2261         */
2262        public ExceptDataComponent setReferenceTarget(Resource value) { 
2263          this.referenceTarget = value;
2264          return this;
2265        }
2266
2267        protected void listChildren(List<Property> childrenList) {
2268          super.listChildren(childrenList);
2269          childrenList.add(new Property("meaning", "code", "How the resource reference is interpreted when testing consent restrictions.", 0, java.lang.Integer.MAX_VALUE, meaning));
2270          childrenList.add(new Property("reference", "Reference(Any)", "A reference to a specific resource that defines which resources are covered by this consent.", 0, java.lang.Integer.MAX_VALUE, reference));
2271        }
2272
2273      @Override
2274      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2275        switch (hash) {
2276        case 938160637: /*meaning*/ return this.meaning == null ? new Base[0] : new Base[] {this.meaning}; // Enumeration<ConsentDataMeaning>
2277        case -925155509: /*reference*/ return this.reference == null ? new Base[0] : new Base[] {this.reference}; // Reference
2278        default: return super.getProperty(hash, name, checkValid);
2279        }
2280
2281      }
2282
2283      @Override
2284      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2285        switch (hash) {
2286        case 938160637: // meaning
2287          value = new ConsentDataMeaningEnumFactory().fromType(castToCode(value));
2288          this.meaning = (Enumeration) value; // Enumeration<ConsentDataMeaning>
2289          return value;
2290        case -925155509: // reference
2291          this.reference = castToReference(value); // Reference
2292          return value;
2293        default: return super.setProperty(hash, name, value);
2294        }
2295
2296      }
2297
2298      @Override
2299      public Base setProperty(String name, Base value) throws FHIRException {
2300        if (name.equals("meaning")) {
2301          value = new ConsentDataMeaningEnumFactory().fromType(castToCode(value));
2302          this.meaning = (Enumeration) value; // Enumeration<ConsentDataMeaning>
2303        } else if (name.equals("reference")) {
2304          this.reference = castToReference(value); // Reference
2305        } else
2306          return super.setProperty(name, value);
2307        return value;
2308      }
2309
2310      @Override
2311      public Base makeProperty(int hash, String name) throws FHIRException {
2312        switch (hash) {
2313        case 938160637:  return getMeaningElement();
2314        case -925155509:  return getReference(); 
2315        default: return super.makeProperty(hash, name);
2316        }
2317
2318      }
2319
2320      @Override
2321      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2322        switch (hash) {
2323        case 938160637: /*meaning*/ return new String[] {"code"};
2324        case -925155509: /*reference*/ return new String[] {"Reference"};
2325        default: return super.getTypesForProperty(hash, name);
2326        }
2327
2328      }
2329
2330      @Override
2331      public Base addChild(String name) throws FHIRException {
2332        if (name.equals("meaning")) {
2333          throw new FHIRException("Cannot call addChild on a primitive type Consent.meaning");
2334        }
2335        else if (name.equals("reference")) {
2336          this.reference = new Reference();
2337          return this.reference;
2338        }
2339        else
2340          return super.addChild(name);
2341      }
2342
2343      public ExceptDataComponent copy() {
2344        ExceptDataComponent dst = new ExceptDataComponent();
2345        copyValues(dst);
2346        dst.meaning = meaning == null ? null : meaning.copy();
2347        dst.reference = reference == null ? null : reference.copy();
2348        return dst;
2349      }
2350
2351      @Override
2352      public boolean equalsDeep(Base other) {
2353        if (!super.equalsDeep(other))
2354          return false;
2355        if (!(other instanceof ExceptDataComponent))
2356          return false;
2357        ExceptDataComponent o = (ExceptDataComponent) other;
2358        return compareDeep(meaning, o.meaning, true) && compareDeep(reference, o.reference, true);
2359      }
2360
2361      @Override
2362      public boolean equalsShallow(Base other) {
2363        if (!super.equalsShallow(other))
2364          return false;
2365        if (!(other instanceof ExceptDataComponent))
2366          return false;
2367        ExceptDataComponent o = (ExceptDataComponent) other;
2368        return compareValues(meaning, o.meaning, true);
2369      }
2370
2371      public boolean isEmpty() {
2372        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(meaning, reference);
2373      }
2374
2375  public String fhirType() {
2376    return "Consent.except.data";
2377
2378  }
2379
2380  }
2381
2382    /**
2383     * Unique identifier for this copy of the Consent Statement.
2384     */
2385    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=1, modifier=false, summary=true)
2386    @Description(shortDefinition="Identifier for this record (external references)", formalDefinition="Unique identifier for this copy of the Consent Statement." )
2387    protected Identifier identifier;
2388
2389    /**
2390     * Indicates the current state of this consent.
2391     */
2392    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
2393    @Description(shortDefinition="draft | proposed | active | rejected | inactive | entered-in-error", formalDefinition="Indicates the current state of this consent." )
2394    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/consent-state-codes")
2395    protected Enumeration<ConsentState> status;
2396
2397    /**
2398     * A classification of the type of consents found in the statement. This element supports indexing and retrieval of consent statements.
2399     */
2400    @Child(name = "category", type = {CodeableConcept.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2401    @Description(shortDefinition="Classification of the consent statement - for indexing/retrieval", formalDefinition="A classification of the type of consents found in the statement. This element supports indexing and retrieval of consent statements." )
2402    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/consent-category")
2403    protected List<CodeableConcept> category;
2404
2405    /**
2406     * The patient/healthcare consumer to whom this consent applies.
2407     */
2408    @Child(name = "patient", type = {Patient.class}, order=3, min=1, max=1, modifier=false, summary=true)
2409    @Description(shortDefinition="Who the consent applies to", formalDefinition="The patient/healthcare consumer to whom this consent applies." )
2410    protected Reference patient;
2411
2412    /**
2413     * The actual object that is the target of the reference (The patient/healthcare consumer to whom this consent applies.)
2414     */
2415    protected Patient patientTarget;
2416
2417    /**
2418     * Relevant time or time-period when this Consent is applicable.
2419     */
2420    @Child(name = "period", type = {Period.class}, order=4, min=0, max=1, modifier=false, summary=true)
2421    @Description(shortDefinition="Period that this consent applies", formalDefinition="Relevant time or time-period when this Consent is applicable." )
2422    protected Period period;
2423
2424    /**
2425     * When this  Consent was issued / created / indexed.
2426     */
2427    @Child(name = "dateTime", type = {DateTimeType.class}, order=5, min=0, max=1, modifier=false, summary=true)
2428    @Description(shortDefinition="When this Consent was created or indexed", formalDefinition="When this  Consent was issued / created / indexed." )
2429    protected DateTimeType dateTime;
2430
2431    /**
2432     * Either the Grantor, which is the entity responsible for granting the rights listed in a Consent Directive or the Grantee, which is the entity responsible for complying with the Consent Directive, including any obligations or limitations on authorizations and enforcement of prohibitions.
2433     */
2434    @Child(name = "consentingParty", type = {Organization.class, Patient.class, Practitioner.class, RelatedPerson.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2435    @Description(shortDefinition="Who is agreeing to the policy and exceptions", formalDefinition="Either the Grantor, which is the entity responsible for granting the rights listed in a Consent Directive or the Grantee, which is the entity responsible for complying with the Consent Directive, including any obligations or limitations on authorizations and enforcement of prohibitions." )
2436    protected List<Reference> consentingParty;
2437    /**
2438     * The actual objects that are the target of the reference (Either the Grantor, which is the entity responsible for granting the rights listed in a Consent Directive or the Grantee, which is the entity responsible for complying with the Consent Directive, including any obligations or limitations on authorizations and enforcement of prohibitions.)
2439     */
2440    protected List<Resource> consentingPartyTarget;
2441
2442
2443    /**
2444     * Who or what is controlled by this consent. Use group to identify a set of actors by some property they share (e.g. 'admitting officers').
2445     */
2446    @Child(name = "actor", type = {}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2447    @Description(shortDefinition="Who|what controlled by this consent (or group, by role)", formalDefinition="Who or what is controlled by this consent. Use group to identify a set of actors by some property they share (e.g. 'admitting officers')." )
2448    protected List<ConsentActorComponent> actor;
2449
2450    /**
2451     * Actions controlled by this consent.
2452     */
2453    @Child(name = "action", type = {CodeableConcept.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2454    @Description(shortDefinition="Actions controlled by this consent", formalDefinition="Actions controlled by this consent." )
2455    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/consent-action")
2456    protected List<CodeableConcept> action;
2457
2458    /**
2459     * The organization that manages the consent, and the framework within which it is executed.
2460     */
2461    @Child(name = "organization", type = {Organization.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2462    @Description(shortDefinition="Custodian of the consent", formalDefinition="The organization that manages the consent, and the framework within which it is executed." )
2463    protected List<Reference> organization;
2464    /**
2465     * The actual objects that are the target of the reference (The organization that manages the consent, and the framework within which it is executed.)
2466     */
2467    protected List<Organization> organizationTarget;
2468
2469
2470    /**
2471     * The source on which this consent statement is based. The source might be a scanned original paper form, or a reference to a consent that links back to such a source, a reference to a document repository (e.g. XDS) that stores the original consent document.
2472     */
2473    @Child(name = "source", type = {Attachment.class, Identifier.class, Consent.class, DocumentReference.class, Contract.class, QuestionnaireResponse.class}, order=10, min=0, max=1, modifier=false, summary=true)
2474    @Description(shortDefinition="Source from which this consent is taken", formalDefinition="The source on which this consent statement is based. The source might be a scanned original paper form, or a reference to a consent that links back to such a source, a reference to a document repository (e.g. XDS) that stores the original consent document." )
2475    protected Type source;
2476
2477    /**
2478     * The references to the policies that are included in this consent scope. Policies may be organizational, but are often defined jurisdictionally, or in law.
2479     */
2480    @Child(name = "policy", type = {}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2481    @Description(shortDefinition="Policies covered by this consent", formalDefinition="The references to the policies that are included in this consent scope. Policies may be organizational, but are often defined jurisdictionally, or in law." )
2482    protected List<ConsentPolicyComponent> policy;
2483
2484    /**
2485     * A referece to the specific computable policy.
2486     */
2487    @Child(name = "policyRule", type = {UriType.class}, order=12, min=0, max=1, modifier=false, summary=true)
2488    @Description(shortDefinition="Policy that this consents to", formalDefinition="A referece to the specific computable policy." )
2489    protected UriType policyRule;
2490
2491    /**
2492     * A set of security labels that define which resources are controlled by this consent. If more than one label is specified, all resources must have all the specified labels.
2493     */
2494    @Child(name = "securityLabel", type = {Coding.class}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2495    @Description(shortDefinition="Security Labels that define affected resources", formalDefinition="A set of security labels that define which resources are controlled by this consent. If more than one label is specified, all resources must have all the specified labels." )
2496    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/security-labels")
2497    protected List<Coding> securityLabel;
2498
2499    /**
2500     * The context of the activities a user is taking - why the user is accessing the data - that are controlled by this consent.
2501     */
2502    @Child(name = "purpose", type = {Coding.class}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2503    @Description(shortDefinition="Context of activities for which the agreement is made", formalDefinition="The context of the activities a user is taking - why the user is accessing the data - that are controlled by this consent." )
2504    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/v3-PurposeOfUse")
2505    protected List<Coding> purpose;
2506
2507    /**
2508     * Clinical or Operational Relevant period of time that bounds the data controlled by this consent.
2509     */
2510    @Child(name = "dataPeriod", type = {Period.class}, order=15, min=0, max=1, modifier=false, summary=true)
2511    @Description(shortDefinition="Timeframe for data controlled by this consent", formalDefinition="Clinical or Operational Relevant period of time that bounds the data controlled by this consent." )
2512    protected Period dataPeriod;
2513
2514    /**
2515     * The resources controlled by this consent, if specific resources are referenced.
2516     */
2517    @Child(name = "data", type = {}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2518    @Description(shortDefinition="Data controlled by this consent", formalDefinition="The resources controlled by this consent, if specific resources are referenced." )
2519    protected List<ConsentDataComponent> data;
2520
2521    /**
2522     * An exception to the base policy of this consent. An exception can be an addition or removal of access permissions.
2523     */
2524    @Child(name = "except", type = {}, order=17, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2525    @Description(shortDefinition="Additional rule -  addition or removal of permissions", formalDefinition="An exception to the base policy of this consent. An exception can be an addition or removal of access permissions." )
2526    protected List<ExceptComponent> except;
2527
2528    private static final long serialVersionUID = -345946739L;
2529
2530  /**
2531   * Constructor
2532   */
2533    public Consent() {
2534      super();
2535    }
2536
2537  /**
2538   * Constructor
2539   */
2540    public Consent(Enumeration<ConsentState> status, Reference patient) {
2541      super();
2542      this.status = status;
2543      this.patient = patient;
2544    }
2545
2546    /**
2547     * @return {@link #identifier} (Unique identifier for this copy of the Consent Statement.)
2548     */
2549    public Identifier getIdentifier() { 
2550      if (this.identifier == null)
2551        if (Configuration.errorOnAutoCreate())
2552          throw new Error("Attempt to auto-create Consent.identifier");
2553        else if (Configuration.doAutoCreate())
2554          this.identifier = new Identifier(); // cc
2555      return this.identifier;
2556    }
2557
2558    public boolean hasIdentifier() { 
2559      return this.identifier != null && !this.identifier.isEmpty();
2560    }
2561
2562    /**
2563     * @param value {@link #identifier} (Unique identifier for this copy of the Consent Statement.)
2564     */
2565    public Consent setIdentifier(Identifier value) { 
2566      this.identifier = value;
2567      return this;
2568    }
2569
2570    /**
2571     * @return {@link #status} (Indicates the current state of this consent.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2572     */
2573    public Enumeration<ConsentState> getStatusElement() { 
2574      if (this.status == null)
2575        if (Configuration.errorOnAutoCreate())
2576          throw new Error("Attempt to auto-create Consent.status");
2577        else if (Configuration.doAutoCreate())
2578          this.status = new Enumeration<ConsentState>(new ConsentStateEnumFactory()); // bb
2579      return this.status;
2580    }
2581
2582    public boolean hasStatusElement() { 
2583      return this.status != null && !this.status.isEmpty();
2584    }
2585
2586    public boolean hasStatus() { 
2587      return this.status != null && !this.status.isEmpty();
2588    }
2589
2590    /**
2591     * @param value {@link #status} (Indicates the current state of this consent.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2592     */
2593    public Consent setStatusElement(Enumeration<ConsentState> value) { 
2594      this.status = value;
2595      return this;
2596    }
2597
2598    /**
2599     * @return Indicates the current state of this consent.
2600     */
2601    public ConsentState getStatus() { 
2602      return this.status == null ? null : this.status.getValue();
2603    }
2604
2605    /**
2606     * @param value Indicates the current state of this consent.
2607     */
2608    public Consent setStatus(ConsentState value) { 
2609        if (this.status == null)
2610          this.status = new Enumeration<ConsentState>(new ConsentStateEnumFactory());
2611        this.status.setValue(value);
2612      return this;
2613    }
2614
2615    /**
2616     * @return {@link #category} (A classification of the type of consents found in the statement. This element supports indexing and retrieval of consent statements.)
2617     */
2618    public List<CodeableConcept> getCategory() { 
2619      if (this.category == null)
2620        this.category = new ArrayList<CodeableConcept>();
2621      return this.category;
2622    }
2623
2624    /**
2625     * @return Returns a reference to <code>this</code> for easy method chaining
2626     */
2627    public Consent setCategory(List<CodeableConcept> theCategory) { 
2628      this.category = theCategory;
2629      return this;
2630    }
2631
2632    public boolean hasCategory() { 
2633      if (this.category == null)
2634        return false;
2635      for (CodeableConcept item : this.category)
2636        if (!item.isEmpty())
2637          return true;
2638      return false;
2639    }
2640
2641    public CodeableConcept addCategory() { //3
2642      CodeableConcept t = new CodeableConcept();
2643      if (this.category == null)
2644        this.category = new ArrayList<CodeableConcept>();
2645      this.category.add(t);
2646      return t;
2647    }
2648
2649    public Consent addCategory(CodeableConcept t) { //3
2650      if (t == null)
2651        return this;
2652      if (this.category == null)
2653        this.category = new ArrayList<CodeableConcept>();
2654      this.category.add(t);
2655      return this;
2656    }
2657
2658    /**
2659     * @return The first repetition of repeating field {@link #category}, creating it if it does not already exist
2660     */
2661    public CodeableConcept getCategoryFirstRep() { 
2662      if (getCategory().isEmpty()) {
2663        addCategory();
2664      }
2665      return getCategory().get(0);
2666    }
2667
2668    /**
2669     * @return {@link #patient} (The patient/healthcare consumer to whom this consent applies.)
2670     */
2671    public Reference getPatient() { 
2672      if (this.patient == null)
2673        if (Configuration.errorOnAutoCreate())
2674          throw new Error("Attempt to auto-create Consent.patient");
2675        else if (Configuration.doAutoCreate())
2676          this.patient = new Reference(); // cc
2677      return this.patient;
2678    }
2679
2680    public boolean hasPatient() { 
2681      return this.patient != null && !this.patient.isEmpty();
2682    }
2683
2684    /**
2685     * @param value {@link #patient} (The patient/healthcare consumer to whom this consent applies.)
2686     */
2687    public Consent setPatient(Reference value) { 
2688      this.patient = value;
2689      return this;
2690    }
2691
2692    /**
2693     * @return {@link #patient} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The patient/healthcare consumer to whom this consent applies.)
2694     */
2695    public Patient getPatientTarget() { 
2696      if (this.patientTarget == null)
2697        if (Configuration.errorOnAutoCreate())
2698          throw new Error("Attempt to auto-create Consent.patient");
2699        else if (Configuration.doAutoCreate())
2700          this.patientTarget = new Patient(); // aa
2701      return this.patientTarget;
2702    }
2703
2704    /**
2705     * @param value {@link #patient} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The patient/healthcare consumer to whom this consent applies.)
2706     */
2707    public Consent setPatientTarget(Patient value) { 
2708      this.patientTarget = value;
2709      return this;
2710    }
2711
2712    /**
2713     * @return {@link #period} (Relevant time or time-period when this Consent is applicable.)
2714     */
2715    public Period getPeriod() { 
2716      if (this.period == null)
2717        if (Configuration.errorOnAutoCreate())
2718          throw new Error("Attempt to auto-create Consent.period");
2719        else if (Configuration.doAutoCreate())
2720          this.period = new Period(); // cc
2721      return this.period;
2722    }
2723
2724    public boolean hasPeriod() { 
2725      return this.period != null && !this.period.isEmpty();
2726    }
2727
2728    /**
2729     * @param value {@link #period} (Relevant time or time-period when this Consent is applicable.)
2730     */
2731    public Consent setPeriod(Period value) { 
2732      this.period = value;
2733      return this;
2734    }
2735
2736    /**
2737     * @return {@link #dateTime} (When this  Consent was issued / created / indexed.). This is the underlying object with id, value and extensions. The accessor "getDateTime" gives direct access to the value
2738     */
2739    public DateTimeType getDateTimeElement() { 
2740      if (this.dateTime == null)
2741        if (Configuration.errorOnAutoCreate())
2742          throw new Error("Attempt to auto-create Consent.dateTime");
2743        else if (Configuration.doAutoCreate())
2744          this.dateTime = new DateTimeType(); // bb
2745      return this.dateTime;
2746    }
2747
2748    public boolean hasDateTimeElement() { 
2749      return this.dateTime != null && !this.dateTime.isEmpty();
2750    }
2751
2752    public boolean hasDateTime() { 
2753      return this.dateTime != null && !this.dateTime.isEmpty();
2754    }
2755
2756    /**
2757     * @param value {@link #dateTime} (When this  Consent was issued / created / indexed.). This is the underlying object with id, value and extensions. The accessor "getDateTime" gives direct access to the value
2758     */
2759    public Consent setDateTimeElement(DateTimeType value) { 
2760      this.dateTime = value;
2761      return this;
2762    }
2763
2764    /**
2765     * @return When this  Consent was issued / created / indexed.
2766     */
2767    public Date getDateTime() { 
2768      return this.dateTime == null ? null : this.dateTime.getValue();
2769    }
2770
2771    /**
2772     * @param value When this  Consent was issued / created / indexed.
2773     */
2774    public Consent setDateTime(Date value) { 
2775      if (value == null)
2776        this.dateTime = null;
2777      else {
2778        if (this.dateTime == null)
2779          this.dateTime = new DateTimeType();
2780        this.dateTime.setValue(value);
2781      }
2782      return this;
2783    }
2784
2785    /**
2786     * @return {@link #consentingParty} (Either the Grantor, which is the entity responsible for granting the rights listed in a Consent Directive or the Grantee, which is the entity responsible for complying with the Consent Directive, including any obligations or limitations on authorizations and enforcement of prohibitions.)
2787     */
2788    public List<Reference> getConsentingParty() { 
2789      if (this.consentingParty == null)
2790        this.consentingParty = new ArrayList<Reference>();
2791      return this.consentingParty;
2792    }
2793
2794    /**
2795     * @return Returns a reference to <code>this</code> for easy method chaining
2796     */
2797    public Consent setConsentingParty(List<Reference> theConsentingParty) { 
2798      this.consentingParty = theConsentingParty;
2799      return this;
2800    }
2801
2802    public boolean hasConsentingParty() { 
2803      if (this.consentingParty == null)
2804        return false;
2805      for (Reference item : this.consentingParty)
2806        if (!item.isEmpty())
2807          return true;
2808      return false;
2809    }
2810
2811    public Reference addConsentingParty() { //3
2812      Reference t = new Reference();
2813      if (this.consentingParty == null)
2814        this.consentingParty = new ArrayList<Reference>();
2815      this.consentingParty.add(t);
2816      return t;
2817    }
2818
2819    public Consent addConsentingParty(Reference t) { //3
2820      if (t == null)
2821        return this;
2822      if (this.consentingParty == null)
2823        this.consentingParty = new ArrayList<Reference>();
2824      this.consentingParty.add(t);
2825      return this;
2826    }
2827
2828    /**
2829     * @return The first repetition of repeating field {@link #consentingParty}, creating it if it does not already exist
2830     */
2831    public Reference getConsentingPartyFirstRep() { 
2832      if (getConsentingParty().isEmpty()) {
2833        addConsentingParty();
2834      }
2835      return getConsentingParty().get(0);
2836    }
2837
2838    /**
2839     * @deprecated Use Reference#setResource(IBaseResource) instead
2840     */
2841    @Deprecated
2842    public List<Resource> getConsentingPartyTarget() { 
2843      if (this.consentingPartyTarget == null)
2844        this.consentingPartyTarget = new ArrayList<Resource>();
2845      return this.consentingPartyTarget;
2846    }
2847
2848    /**
2849     * @return {@link #actor} (Who or what is controlled by this consent. Use group to identify a set of actors by some property they share (e.g. 'admitting officers').)
2850     */
2851    public List<ConsentActorComponent> getActor() { 
2852      if (this.actor == null)
2853        this.actor = new ArrayList<ConsentActorComponent>();
2854      return this.actor;
2855    }
2856
2857    /**
2858     * @return Returns a reference to <code>this</code> for easy method chaining
2859     */
2860    public Consent setActor(List<ConsentActorComponent> theActor) { 
2861      this.actor = theActor;
2862      return this;
2863    }
2864
2865    public boolean hasActor() { 
2866      if (this.actor == null)
2867        return false;
2868      for (ConsentActorComponent item : this.actor)
2869        if (!item.isEmpty())
2870          return true;
2871      return false;
2872    }
2873
2874    public ConsentActorComponent addActor() { //3
2875      ConsentActorComponent t = new ConsentActorComponent();
2876      if (this.actor == null)
2877        this.actor = new ArrayList<ConsentActorComponent>();
2878      this.actor.add(t);
2879      return t;
2880    }
2881
2882    public Consent addActor(ConsentActorComponent t) { //3
2883      if (t == null)
2884        return this;
2885      if (this.actor == null)
2886        this.actor = new ArrayList<ConsentActorComponent>();
2887      this.actor.add(t);
2888      return this;
2889    }
2890
2891    /**
2892     * @return The first repetition of repeating field {@link #actor}, creating it if it does not already exist
2893     */
2894    public ConsentActorComponent getActorFirstRep() { 
2895      if (getActor().isEmpty()) {
2896        addActor();
2897      }
2898      return getActor().get(0);
2899    }
2900
2901    /**
2902     * @return {@link #action} (Actions controlled by this consent.)
2903     */
2904    public List<CodeableConcept> getAction() { 
2905      if (this.action == null)
2906        this.action = new ArrayList<CodeableConcept>();
2907      return this.action;
2908    }
2909
2910    /**
2911     * @return Returns a reference to <code>this</code> for easy method chaining
2912     */
2913    public Consent setAction(List<CodeableConcept> theAction) { 
2914      this.action = theAction;
2915      return this;
2916    }
2917
2918    public boolean hasAction() { 
2919      if (this.action == null)
2920        return false;
2921      for (CodeableConcept item : this.action)
2922        if (!item.isEmpty())
2923          return true;
2924      return false;
2925    }
2926
2927    public CodeableConcept addAction() { //3
2928      CodeableConcept t = new CodeableConcept();
2929      if (this.action == null)
2930        this.action = new ArrayList<CodeableConcept>();
2931      this.action.add(t);
2932      return t;
2933    }
2934
2935    public Consent addAction(CodeableConcept t) { //3
2936      if (t == null)
2937        return this;
2938      if (this.action == null)
2939        this.action = new ArrayList<CodeableConcept>();
2940      this.action.add(t);
2941      return this;
2942    }
2943
2944    /**
2945     * @return The first repetition of repeating field {@link #action}, creating it if it does not already exist
2946     */
2947    public CodeableConcept getActionFirstRep() { 
2948      if (getAction().isEmpty()) {
2949        addAction();
2950      }
2951      return getAction().get(0);
2952    }
2953
2954    /**
2955     * @return {@link #organization} (The organization that manages the consent, and the framework within which it is executed.)
2956     */
2957    public List<Reference> getOrganization() { 
2958      if (this.organization == null)
2959        this.organization = new ArrayList<Reference>();
2960      return this.organization;
2961    }
2962
2963    /**
2964     * @return Returns a reference to <code>this</code> for easy method chaining
2965     */
2966    public Consent setOrganization(List<Reference> theOrganization) { 
2967      this.organization = theOrganization;
2968      return this;
2969    }
2970
2971    public boolean hasOrganization() { 
2972      if (this.organization == null)
2973        return false;
2974      for (Reference item : this.organization)
2975        if (!item.isEmpty())
2976          return true;
2977      return false;
2978    }
2979
2980    public Reference addOrganization() { //3
2981      Reference t = new Reference();
2982      if (this.organization == null)
2983        this.organization = new ArrayList<Reference>();
2984      this.organization.add(t);
2985      return t;
2986    }
2987
2988    public Consent addOrganization(Reference t) { //3
2989      if (t == null)
2990        return this;
2991      if (this.organization == null)
2992        this.organization = new ArrayList<Reference>();
2993      this.organization.add(t);
2994      return this;
2995    }
2996
2997    /**
2998     * @return The first repetition of repeating field {@link #organization}, creating it if it does not already exist
2999     */
3000    public Reference getOrganizationFirstRep() { 
3001      if (getOrganization().isEmpty()) {
3002        addOrganization();
3003      }
3004      return getOrganization().get(0);
3005    }
3006
3007    /**
3008     * @deprecated Use Reference#setResource(IBaseResource) instead
3009     */
3010    @Deprecated
3011    public List<Organization> getOrganizationTarget() { 
3012      if (this.organizationTarget == null)
3013        this.organizationTarget = new ArrayList<Organization>();
3014      return this.organizationTarget;
3015    }
3016
3017    /**
3018     * @deprecated Use Reference#setResource(IBaseResource) instead
3019     */
3020    @Deprecated
3021    public Organization addOrganizationTarget() { 
3022      Organization r = new Organization();
3023      if (this.organizationTarget == null)
3024        this.organizationTarget = new ArrayList<Organization>();
3025      this.organizationTarget.add(r);
3026      return r;
3027    }
3028
3029    /**
3030     * @return {@link #source} (The source on which this consent statement is based. The source might be a scanned original paper form, or a reference to a consent that links back to such a source, a reference to a document repository (e.g. XDS) that stores the original consent document.)
3031     */
3032    public Type getSource() { 
3033      return this.source;
3034    }
3035
3036    /**
3037     * @return {@link #source} (The source on which this consent statement is based. The source might be a scanned original paper form, or a reference to a consent that links back to such a source, a reference to a document repository (e.g. XDS) that stores the original consent document.)
3038     */
3039    public Attachment getSourceAttachment() throws FHIRException { 
3040      if (!(this.source instanceof Attachment))
3041        throw new FHIRException("Type mismatch: the type Attachment was expected, but "+this.source.getClass().getName()+" was encountered");
3042      return (Attachment) this.source;
3043    }
3044
3045    public boolean hasSourceAttachment() { 
3046      return this.source instanceof Attachment;
3047    }
3048
3049    /**
3050     * @return {@link #source} (The source on which this consent statement is based. The source might be a scanned original paper form, or a reference to a consent that links back to such a source, a reference to a document repository (e.g. XDS) that stores the original consent document.)
3051     */
3052    public Identifier getSourceIdentifier() throws FHIRException { 
3053      if (!(this.source instanceof Identifier))
3054        throw new FHIRException("Type mismatch: the type Identifier was expected, but "+this.source.getClass().getName()+" was encountered");
3055      return (Identifier) this.source;
3056    }
3057
3058    public boolean hasSourceIdentifier() { 
3059      return this.source instanceof Identifier;
3060    }
3061
3062    /**
3063     * @return {@link #source} (The source on which this consent statement is based. The source might be a scanned original paper form, or a reference to a consent that links back to such a source, a reference to a document repository (e.g. XDS) that stores the original consent document.)
3064     */
3065    public Reference getSourceReference() throws FHIRException { 
3066      if (!(this.source instanceof Reference))
3067        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.source.getClass().getName()+" was encountered");
3068      return (Reference) this.source;
3069    }
3070
3071    public boolean hasSourceReference() { 
3072      return this.source instanceof Reference;
3073    }
3074
3075    public boolean hasSource() { 
3076      return this.source != null && !this.source.isEmpty();
3077    }
3078
3079    /**
3080     * @param value {@link #source} (The source on which this consent statement is based. The source might be a scanned original paper form, or a reference to a consent that links back to such a source, a reference to a document repository (e.g. XDS) that stores the original consent document.)
3081     */
3082    public Consent setSource(Type value) { 
3083      this.source = value;
3084      return this;
3085    }
3086
3087    /**
3088     * @return {@link #policy} (The references to the policies that are included in this consent scope. Policies may be organizational, but are often defined jurisdictionally, or in law.)
3089     */
3090    public List<ConsentPolicyComponent> getPolicy() { 
3091      if (this.policy == null)
3092        this.policy = new ArrayList<ConsentPolicyComponent>();
3093      return this.policy;
3094    }
3095
3096    /**
3097     * @return Returns a reference to <code>this</code> for easy method chaining
3098     */
3099    public Consent setPolicy(List<ConsentPolicyComponent> thePolicy) { 
3100      this.policy = thePolicy;
3101      return this;
3102    }
3103
3104    public boolean hasPolicy() { 
3105      if (this.policy == null)
3106        return false;
3107      for (ConsentPolicyComponent item : this.policy)
3108        if (!item.isEmpty())
3109          return true;
3110      return false;
3111    }
3112
3113    public ConsentPolicyComponent addPolicy() { //3
3114      ConsentPolicyComponent t = new ConsentPolicyComponent();
3115      if (this.policy == null)
3116        this.policy = new ArrayList<ConsentPolicyComponent>();
3117      this.policy.add(t);
3118      return t;
3119    }
3120
3121    public Consent addPolicy(ConsentPolicyComponent t) { //3
3122      if (t == null)
3123        return this;
3124      if (this.policy == null)
3125        this.policy = new ArrayList<ConsentPolicyComponent>();
3126      this.policy.add(t);
3127      return this;
3128    }
3129
3130    /**
3131     * @return The first repetition of repeating field {@link #policy}, creating it if it does not already exist
3132     */
3133    public ConsentPolicyComponent getPolicyFirstRep() { 
3134      if (getPolicy().isEmpty()) {
3135        addPolicy();
3136      }
3137      return getPolicy().get(0);
3138    }
3139
3140    /**
3141     * @return {@link #policyRule} (A referece to the specific computable policy.). This is the underlying object with id, value and extensions. The accessor "getPolicyRule" gives direct access to the value
3142     */
3143    public UriType getPolicyRuleElement() { 
3144      if (this.policyRule == null)
3145        if (Configuration.errorOnAutoCreate())
3146          throw new Error("Attempt to auto-create Consent.policyRule");
3147        else if (Configuration.doAutoCreate())
3148          this.policyRule = new UriType(); // bb
3149      return this.policyRule;
3150    }
3151
3152    public boolean hasPolicyRuleElement() { 
3153      return this.policyRule != null && !this.policyRule.isEmpty();
3154    }
3155
3156    public boolean hasPolicyRule() { 
3157      return this.policyRule != null && !this.policyRule.isEmpty();
3158    }
3159
3160    /**
3161     * @param value {@link #policyRule} (A referece to the specific computable policy.). This is the underlying object with id, value and extensions. The accessor "getPolicyRule" gives direct access to the value
3162     */
3163    public Consent setPolicyRuleElement(UriType value) { 
3164      this.policyRule = value;
3165      return this;
3166    }
3167
3168    /**
3169     * @return A referece to the specific computable policy.
3170     */
3171    public String getPolicyRule() { 
3172      return this.policyRule == null ? null : this.policyRule.getValue();
3173    }
3174
3175    /**
3176     * @param value A referece to the specific computable policy.
3177     */
3178    public Consent setPolicyRule(String value) { 
3179      if (Utilities.noString(value))
3180        this.policyRule = null;
3181      else {
3182        if (this.policyRule == null)
3183          this.policyRule = new UriType();
3184        this.policyRule.setValue(value);
3185      }
3186      return this;
3187    }
3188
3189    /**
3190     * @return {@link #securityLabel} (A set of security labels that define which resources are controlled by this consent. If more than one label is specified, all resources must have all the specified labels.)
3191     */
3192    public List<Coding> getSecurityLabel() { 
3193      if (this.securityLabel == null)
3194        this.securityLabel = new ArrayList<Coding>();
3195      return this.securityLabel;
3196    }
3197
3198    /**
3199     * @return Returns a reference to <code>this</code> for easy method chaining
3200     */
3201    public Consent setSecurityLabel(List<Coding> theSecurityLabel) { 
3202      this.securityLabel = theSecurityLabel;
3203      return this;
3204    }
3205
3206    public boolean hasSecurityLabel() { 
3207      if (this.securityLabel == null)
3208        return false;
3209      for (Coding item : this.securityLabel)
3210        if (!item.isEmpty())
3211          return true;
3212      return false;
3213    }
3214
3215    public Coding addSecurityLabel() { //3
3216      Coding t = new Coding();
3217      if (this.securityLabel == null)
3218        this.securityLabel = new ArrayList<Coding>();
3219      this.securityLabel.add(t);
3220      return t;
3221    }
3222
3223    public Consent addSecurityLabel(Coding t) { //3
3224      if (t == null)
3225        return this;
3226      if (this.securityLabel == null)
3227        this.securityLabel = new ArrayList<Coding>();
3228      this.securityLabel.add(t);
3229      return this;
3230    }
3231
3232    /**
3233     * @return The first repetition of repeating field {@link #securityLabel}, creating it if it does not already exist
3234     */
3235    public Coding getSecurityLabelFirstRep() { 
3236      if (getSecurityLabel().isEmpty()) {
3237        addSecurityLabel();
3238      }
3239      return getSecurityLabel().get(0);
3240    }
3241
3242    /**
3243     * @return {@link #purpose} (The context of the activities a user is taking - why the user is accessing the data - that are controlled by this consent.)
3244     */
3245    public List<Coding> getPurpose() { 
3246      if (this.purpose == null)
3247        this.purpose = new ArrayList<Coding>();
3248      return this.purpose;
3249    }
3250
3251    /**
3252     * @return Returns a reference to <code>this</code> for easy method chaining
3253     */
3254    public Consent setPurpose(List<Coding> thePurpose) { 
3255      this.purpose = thePurpose;
3256      return this;
3257    }
3258
3259    public boolean hasPurpose() { 
3260      if (this.purpose == null)
3261        return false;
3262      for (Coding item : this.purpose)
3263        if (!item.isEmpty())
3264          return true;
3265      return false;
3266    }
3267
3268    public Coding addPurpose() { //3
3269      Coding t = new Coding();
3270      if (this.purpose == null)
3271        this.purpose = new ArrayList<Coding>();
3272      this.purpose.add(t);
3273      return t;
3274    }
3275
3276    public Consent addPurpose(Coding t) { //3
3277      if (t == null)
3278        return this;
3279      if (this.purpose == null)
3280        this.purpose = new ArrayList<Coding>();
3281      this.purpose.add(t);
3282      return this;
3283    }
3284
3285    /**
3286     * @return The first repetition of repeating field {@link #purpose}, creating it if it does not already exist
3287     */
3288    public Coding getPurposeFirstRep() { 
3289      if (getPurpose().isEmpty()) {
3290        addPurpose();
3291      }
3292      return getPurpose().get(0);
3293    }
3294
3295    /**
3296     * @return {@link #dataPeriod} (Clinical or Operational Relevant period of time that bounds the data controlled by this consent.)
3297     */
3298    public Period getDataPeriod() { 
3299      if (this.dataPeriod == null)
3300        if (Configuration.errorOnAutoCreate())
3301          throw new Error("Attempt to auto-create Consent.dataPeriod");
3302        else if (Configuration.doAutoCreate())
3303          this.dataPeriod = new Period(); // cc
3304      return this.dataPeriod;
3305    }
3306
3307    public boolean hasDataPeriod() { 
3308      return this.dataPeriod != null && !this.dataPeriod.isEmpty();
3309    }
3310
3311    /**
3312     * @param value {@link #dataPeriod} (Clinical or Operational Relevant period of time that bounds the data controlled by this consent.)
3313     */
3314    public Consent setDataPeriod(Period value) { 
3315      this.dataPeriod = value;
3316      return this;
3317    }
3318
3319    /**
3320     * @return {@link #data} (The resources controlled by this consent, if specific resources are referenced.)
3321     */
3322    public List<ConsentDataComponent> getData() { 
3323      if (this.data == null)
3324        this.data = new ArrayList<ConsentDataComponent>();
3325      return this.data;
3326    }
3327
3328    /**
3329     * @return Returns a reference to <code>this</code> for easy method chaining
3330     */
3331    public Consent setData(List<ConsentDataComponent> theData) { 
3332      this.data = theData;
3333      return this;
3334    }
3335
3336    public boolean hasData() { 
3337      if (this.data == null)
3338        return false;
3339      for (ConsentDataComponent item : this.data)
3340        if (!item.isEmpty())
3341          return true;
3342      return false;
3343    }
3344
3345    public ConsentDataComponent addData() { //3
3346      ConsentDataComponent t = new ConsentDataComponent();
3347      if (this.data == null)
3348        this.data = new ArrayList<ConsentDataComponent>();
3349      this.data.add(t);
3350      return t;
3351    }
3352
3353    public Consent addData(ConsentDataComponent t) { //3
3354      if (t == null)
3355        return this;
3356      if (this.data == null)
3357        this.data = new ArrayList<ConsentDataComponent>();
3358      this.data.add(t);
3359      return this;
3360    }
3361
3362    /**
3363     * @return The first repetition of repeating field {@link #data}, creating it if it does not already exist
3364     */
3365    public ConsentDataComponent getDataFirstRep() { 
3366      if (getData().isEmpty()) {
3367        addData();
3368      }
3369      return getData().get(0);
3370    }
3371
3372    /**
3373     * @return {@link #except} (An exception to the base policy of this consent. An exception can be an addition or removal of access permissions.)
3374     */
3375    public List<ExceptComponent> getExcept() { 
3376      if (this.except == null)
3377        this.except = new ArrayList<ExceptComponent>();
3378      return this.except;
3379    }
3380
3381    /**
3382     * @return Returns a reference to <code>this</code> for easy method chaining
3383     */
3384    public Consent setExcept(List<ExceptComponent> theExcept) { 
3385      this.except = theExcept;
3386      return this;
3387    }
3388
3389    public boolean hasExcept() { 
3390      if (this.except == null)
3391        return false;
3392      for (ExceptComponent item : this.except)
3393        if (!item.isEmpty())
3394          return true;
3395      return false;
3396    }
3397
3398    public ExceptComponent addExcept() { //3
3399      ExceptComponent t = new ExceptComponent();
3400      if (this.except == null)
3401        this.except = new ArrayList<ExceptComponent>();
3402      this.except.add(t);
3403      return t;
3404    }
3405
3406    public Consent addExcept(ExceptComponent t) { //3
3407      if (t == null)
3408        return this;
3409      if (this.except == null)
3410        this.except = new ArrayList<ExceptComponent>();
3411      this.except.add(t);
3412      return this;
3413    }
3414
3415    /**
3416     * @return The first repetition of repeating field {@link #except}, creating it if it does not already exist
3417     */
3418    public ExceptComponent getExceptFirstRep() { 
3419      if (getExcept().isEmpty()) {
3420        addExcept();
3421      }
3422      return getExcept().get(0);
3423    }
3424
3425      protected void listChildren(List<Property> childrenList) {
3426        super.listChildren(childrenList);
3427        childrenList.add(new Property("identifier", "Identifier", "Unique identifier for this copy of the Consent Statement.", 0, java.lang.Integer.MAX_VALUE, identifier));
3428        childrenList.add(new Property("status", "code", "Indicates the current state of this consent.", 0, java.lang.Integer.MAX_VALUE, status));
3429        childrenList.add(new Property("category", "CodeableConcept", "A classification of the type of consents found in the statement. This element supports indexing and retrieval of consent statements.", 0, java.lang.Integer.MAX_VALUE, category));
3430        childrenList.add(new Property("patient", "Reference(Patient)", "The patient/healthcare consumer to whom this consent applies.", 0, java.lang.Integer.MAX_VALUE, patient));
3431        childrenList.add(new Property("period", "Period", "Relevant time or time-period when this Consent is applicable.", 0, java.lang.Integer.MAX_VALUE, period));
3432        childrenList.add(new Property("dateTime", "dateTime", "When this  Consent was issued / created / indexed.", 0, java.lang.Integer.MAX_VALUE, dateTime));
3433        childrenList.add(new Property("consentingParty", "Reference(Organization|Patient|Practitioner|RelatedPerson)", "Either the Grantor, which is the entity responsible for granting the rights listed in a Consent Directive or the Grantee, which is the entity responsible for complying with the Consent Directive, including any obligations or limitations on authorizations and enforcement of prohibitions.", 0, java.lang.Integer.MAX_VALUE, consentingParty));
3434        childrenList.add(new Property("actor", "", "Who or what is controlled by this consent. Use group to identify a set of actors by some property they share (e.g. 'admitting officers').", 0, java.lang.Integer.MAX_VALUE, actor));
3435        childrenList.add(new Property("action", "CodeableConcept", "Actions controlled by this consent.", 0, java.lang.Integer.MAX_VALUE, action));
3436        childrenList.add(new Property("organization", "Reference(Organization)", "The organization that manages the consent, and the framework within which it is executed.", 0, java.lang.Integer.MAX_VALUE, organization));
3437        childrenList.add(new Property("source[x]", "Attachment|Identifier|Reference(Consent|DocumentReference|Contract|QuestionnaireResponse)", "The source on which this consent statement is based. The source might be a scanned original paper form, or a reference to a consent that links back to such a source, a reference to a document repository (e.g. XDS) that stores the original consent document.", 0, java.lang.Integer.MAX_VALUE, source));
3438        childrenList.add(new Property("policy", "", "The references to the policies that are included in this consent scope. Policies may be organizational, but are often defined jurisdictionally, or in law.", 0, java.lang.Integer.MAX_VALUE, policy));
3439        childrenList.add(new Property("policyRule", "uri", "A referece to the specific computable policy.", 0, java.lang.Integer.MAX_VALUE, policyRule));
3440        childrenList.add(new Property("securityLabel", "Coding", "A set of security labels that define which resources are controlled by this consent. If more than one label is specified, all resources must have all the specified labels.", 0, java.lang.Integer.MAX_VALUE, securityLabel));
3441        childrenList.add(new Property("purpose", "Coding", "The context of the activities a user is taking - why the user is accessing the data - that are controlled by this consent.", 0, java.lang.Integer.MAX_VALUE, purpose));
3442        childrenList.add(new Property("dataPeriod", "Period", "Clinical or Operational Relevant period of time that bounds the data controlled by this consent.", 0, java.lang.Integer.MAX_VALUE, dataPeriod));
3443        childrenList.add(new Property("data", "", "The resources controlled by this consent, if specific resources are referenced.", 0, java.lang.Integer.MAX_VALUE, data));
3444        childrenList.add(new Property("except", "", "An exception to the base policy of this consent. An exception can be an addition or removal of access permissions.", 0, java.lang.Integer.MAX_VALUE, except));
3445      }
3446
3447      @Override
3448      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
3449        switch (hash) {
3450        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
3451        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<ConsentState>
3452        case 50511102: /*category*/ return this.category == null ? new Base[0] : this.category.toArray(new Base[this.category.size()]); // CodeableConcept
3453        case -791418107: /*patient*/ return this.patient == null ? new Base[0] : new Base[] {this.patient}; // Reference
3454        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
3455        case 1792749467: /*dateTime*/ return this.dateTime == null ? new Base[0] : new Base[] {this.dateTime}; // DateTimeType
3456        case -1886702018: /*consentingParty*/ return this.consentingParty == null ? new Base[0] : this.consentingParty.toArray(new Base[this.consentingParty.size()]); // Reference
3457        case 92645877: /*actor*/ return this.actor == null ? new Base[0] : this.actor.toArray(new Base[this.actor.size()]); // ConsentActorComponent
3458        case -1422950858: /*action*/ return this.action == null ? new Base[0] : this.action.toArray(new Base[this.action.size()]); // CodeableConcept
3459        case 1178922291: /*organization*/ return this.organization == null ? new Base[0] : this.organization.toArray(new Base[this.organization.size()]); // Reference
3460        case -896505829: /*source*/ return this.source == null ? new Base[0] : new Base[] {this.source}; // Type
3461        case -982670030: /*policy*/ return this.policy == null ? new Base[0] : this.policy.toArray(new Base[this.policy.size()]); // ConsentPolicyComponent
3462        case 1593493326: /*policyRule*/ return this.policyRule == null ? new Base[0] : new Base[] {this.policyRule}; // UriType
3463        case -722296940: /*securityLabel*/ return this.securityLabel == null ? new Base[0] : this.securityLabel.toArray(new Base[this.securityLabel.size()]); // Coding
3464        case -220463842: /*purpose*/ return this.purpose == null ? new Base[0] : this.purpose.toArray(new Base[this.purpose.size()]); // Coding
3465        case 1177250315: /*dataPeriod*/ return this.dataPeriod == null ? new Base[0] : new Base[] {this.dataPeriod}; // Period
3466        case 3076010: /*data*/ return this.data == null ? new Base[0] : this.data.toArray(new Base[this.data.size()]); // ConsentDataComponent
3467        case -1289550567: /*except*/ return this.except == null ? new Base[0] : this.except.toArray(new Base[this.except.size()]); // ExceptComponent
3468        default: return super.getProperty(hash, name, checkValid);
3469        }
3470
3471      }
3472
3473      @Override
3474      public Base setProperty(int hash, String name, Base value) throws FHIRException {
3475        switch (hash) {
3476        case -1618432855: // identifier
3477          this.identifier = castToIdentifier(value); // Identifier
3478          return value;
3479        case -892481550: // status
3480          value = new ConsentStateEnumFactory().fromType(castToCode(value));
3481          this.status = (Enumeration) value; // Enumeration<ConsentState>
3482          return value;
3483        case 50511102: // category
3484          this.getCategory().add(castToCodeableConcept(value)); // CodeableConcept
3485          return value;
3486        case -791418107: // patient
3487          this.patient = castToReference(value); // Reference
3488          return value;
3489        case -991726143: // period
3490          this.period = castToPeriod(value); // Period
3491          return value;
3492        case 1792749467: // dateTime
3493          this.dateTime = castToDateTime(value); // DateTimeType
3494          return value;
3495        case -1886702018: // consentingParty
3496          this.getConsentingParty().add(castToReference(value)); // Reference
3497          return value;
3498        case 92645877: // actor
3499          this.getActor().add((ConsentActorComponent) value); // ConsentActorComponent
3500          return value;
3501        case -1422950858: // action
3502          this.getAction().add(castToCodeableConcept(value)); // CodeableConcept
3503          return value;
3504        case 1178922291: // organization
3505          this.getOrganization().add(castToReference(value)); // Reference
3506          return value;
3507        case -896505829: // source
3508          this.source = castToType(value); // Type
3509          return value;
3510        case -982670030: // policy
3511          this.getPolicy().add((ConsentPolicyComponent) value); // ConsentPolicyComponent
3512          return value;
3513        case 1593493326: // policyRule
3514          this.policyRule = castToUri(value); // UriType
3515          return value;
3516        case -722296940: // securityLabel
3517          this.getSecurityLabel().add(castToCoding(value)); // Coding
3518          return value;
3519        case -220463842: // purpose
3520          this.getPurpose().add(castToCoding(value)); // Coding
3521          return value;
3522        case 1177250315: // dataPeriod
3523          this.dataPeriod = castToPeriod(value); // Period
3524          return value;
3525        case 3076010: // data
3526          this.getData().add((ConsentDataComponent) value); // ConsentDataComponent
3527          return value;
3528        case -1289550567: // except
3529          this.getExcept().add((ExceptComponent) value); // ExceptComponent
3530          return value;
3531        default: return super.setProperty(hash, name, value);
3532        }
3533
3534      }
3535
3536      @Override
3537      public Base setProperty(String name, Base value) throws FHIRException {
3538        if (name.equals("identifier")) {
3539          this.identifier = castToIdentifier(value); // Identifier
3540        } else if (name.equals("status")) {
3541          value = new ConsentStateEnumFactory().fromType(castToCode(value));
3542          this.status = (Enumeration) value; // Enumeration<ConsentState>
3543        } else if (name.equals("category")) {
3544          this.getCategory().add(castToCodeableConcept(value));
3545        } else if (name.equals("patient")) {
3546          this.patient = castToReference(value); // Reference
3547        } else if (name.equals("period")) {
3548          this.period = castToPeriod(value); // Period
3549        } else if (name.equals("dateTime")) {
3550          this.dateTime = castToDateTime(value); // DateTimeType
3551        } else if (name.equals("consentingParty")) {
3552          this.getConsentingParty().add(castToReference(value));
3553        } else if (name.equals("actor")) {
3554          this.getActor().add((ConsentActorComponent) value);
3555        } else if (name.equals("action")) {
3556          this.getAction().add(castToCodeableConcept(value));
3557        } else if (name.equals("organization")) {
3558          this.getOrganization().add(castToReference(value));
3559        } else if (name.equals("source[x]")) {
3560          this.source = castToType(value); // Type
3561        } else if (name.equals("policy")) {
3562          this.getPolicy().add((ConsentPolicyComponent) value);
3563        } else if (name.equals("policyRule")) {
3564          this.policyRule = castToUri(value); // UriType
3565        } else if (name.equals("securityLabel")) {
3566          this.getSecurityLabel().add(castToCoding(value));
3567        } else if (name.equals("purpose")) {
3568          this.getPurpose().add(castToCoding(value));
3569        } else if (name.equals("dataPeriod")) {
3570          this.dataPeriod = castToPeriod(value); // Period
3571        } else if (name.equals("data")) {
3572          this.getData().add((ConsentDataComponent) value);
3573        } else if (name.equals("except")) {
3574          this.getExcept().add((ExceptComponent) value);
3575        } else
3576          return super.setProperty(name, value);
3577        return value;
3578      }
3579
3580      @Override
3581      public Base makeProperty(int hash, String name) throws FHIRException {
3582        switch (hash) {
3583        case -1618432855:  return getIdentifier(); 
3584        case -892481550:  return getStatusElement();
3585        case 50511102:  return addCategory(); 
3586        case -791418107:  return getPatient(); 
3587        case -991726143:  return getPeriod(); 
3588        case 1792749467:  return getDateTimeElement();
3589        case -1886702018:  return addConsentingParty(); 
3590        case 92645877:  return addActor(); 
3591        case -1422950858:  return addAction(); 
3592        case 1178922291:  return addOrganization(); 
3593        case -1698413947:  return getSource(); 
3594        case -896505829:  return getSource(); 
3595        case -982670030:  return addPolicy(); 
3596        case 1593493326:  return getPolicyRuleElement();
3597        case -722296940:  return addSecurityLabel(); 
3598        case -220463842:  return addPurpose(); 
3599        case 1177250315:  return getDataPeriod(); 
3600        case 3076010:  return addData(); 
3601        case -1289550567:  return addExcept(); 
3602        default: return super.makeProperty(hash, name);
3603        }
3604
3605      }
3606
3607      @Override
3608      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
3609        switch (hash) {
3610        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
3611        case -892481550: /*status*/ return new String[] {"code"};
3612        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
3613        case -791418107: /*patient*/ return new String[] {"Reference"};
3614        case -991726143: /*period*/ return new String[] {"Period"};
3615        case 1792749467: /*dateTime*/ return new String[] {"dateTime"};
3616        case -1886702018: /*consentingParty*/ return new String[] {"Reference"};
3617        case 92645877: /*actor*/ return new String[] {};
3618        case -1422950858: /*action*/ return new String[] {"CodeableConcept"};
3619        case 1178922291: /*organization*/ return new String[] {"Reference"};
3620        case -896505829: /*source*/ return new String[] {"Attachment", "Identifier", "Reference"};
3621        case -982670030: /*policy*/ return new String[] {};
3622        case 1593493326: /*policyRule*/ return new String[] {"uri"};
3623        case -722296940: /*securityLabel*/ return new String[] {"Coding"};
3624        case -220463842: /*purpose*/ return new String[] {"Coding"};
3625        case 1177250315: /*dataPeriod*/ return new String[] {"Period"};
3626        case 3076010: /*data*/ return new String[] {};
3627        case -1289550567: /*except*/ return new String[] {};
3628        default: return super.getTypesForProperty(hash, name);
3629        }
3630
3631      }
3632
3633      @Override
3634      public Base addChild(String name) throws FHIRException {
3635        if (name.equals("identifier")) {
3636          this.identifier = new Identifier();
3637          return this.identifier;
3638        }
3639        else if (name.equals("status")) {
3640          throw new FHIRException("Cannot call addChild on a primitive type Consent.status");
3641        }
3642        else if (name.equals("category")) {
3643          return addCategory();
3644        }
3645        else if (name.equals("patient")) {
3646          this.patient = new Reference();
3647          return this.patient;
3648        }
3649        else if (name.equals("period")) {
3650          this.period = new Period();
3651          return this.period;
3652        }
3653        else if (name.equals("dateTime")) {
3654          throw new FHIRException("Cannot call addChild on a primitive type Consent.dateTime");
3655        }
3656        else if (name.equals("consentingParty")) {
3657          return addConsentingParty();
3658        }
3659        else if (name.equals("actor")) {
3660          return addActor();
3661        }
3662        else if (name.equals("action")) {
3663          return addAction();
3664        }
3665        else if (name.equals("organization")) {
3666          return addOrganization();
3667        }
3668        else if (name.equals("sourceAttachment")) {
3669          this.source = new Attachment();
3670          return this.source;
3671        }
3672        else if (name.equals("sourceIdentifier")) {
3673          this.source = new Identifier();
3674          return this.source;
3675        }
3676        else if (name.equals("sourceReference")) {
3677          this.source = new Reference();
3678          return this.source;
3679        }
3680        else if (name.equals("policy")) {
3681          return addPolicy();
3682        }
3683        else if (name.equals("policyRule")) {
3684          throw new FHIRException("Cannot call addChild on a primitive type Consent.policyRule");
3685        }
3686        else if (name.equals("securityLabel")) {
3687          return addSecurityLabel();
3688        }
3689        else if (name.equals("purpose")) {
3690          return addPurpose();
3691        }
3692        else if (name.equals("dataPeriod")) {
3693          this.dataPeriod = new Period();
3694          return this.dataPeriod;
3695        }
3696        else if (name.equals("data")) {
3697          return addData();
3698        }
3699        else if (name.equals("except")) {
3700          return addExcept();
3701        }
3702        else
3703          return super.addChild(name);
3704      }
3705
3706  public String fhirType() {
3707    return "Consent";
3708
3709  }
3710
3711      public Consent copy() {
3712        Consent dst = new Consent();
3713        copyValues(dst);
3714        dst.identifier = identifier == null ? null : identifier.copy();
3715        dst.status = status == null ? null : status.copy();
3716        if (category != null) {
3717          dst.category = new ArrayList<CodeableConcept>();
3718          for (CodeableConcept i : category)
3719            dst.category.add(i.copy());
3720        };
3721        dst.patient = patient == null ? null : patient.copy();
3722        dst.period = period == null ? null : period.copy();
3723        dst.dateTime = dateTime == null ? null : dateTime.copy();
3724        if (consentingParty != null) {
3725          dst.consentingParty = new ArrayList<Reference>();
3726          for (Reference i : consentingParty)
3727            dst.consentingParty.add(i.copy());
3728        };
3729        if (actor != null) {
3730          dst.actor = new ArrayList<ConsentActorComponent>();
3731          for (ConsentActorComponent i : actor)
3732            dst.actor.add(i.copy());
3733        };
3734        if (action != null) {
3735          dst.action = new ArrayList<CodeableConcept>();
3736          for (CodeableConcept i : action)
3737            dst.action.add(i.copy());
3738        };
3739        if (organization != null) {
3740          dst.organization = new ArrayList<Reference>();
3741          for (Reference i : organization)
3742            dst.organization.add(i.copy());
3743        };
3744        dst.source = source == null ? null : source.copy();
3745        if (policy != null) {
3746          dst.policy = new ArrayList<ConsentPolicyComponent>();
3747          for (ConsentPolicyComponent i : policy)
3748            dst.policy.add(i.copy());
3749        };
3750        dst.policyRule = policyRule == null ? null : policyRule.copy();
3751        if (securityLabel != null) {
3752          dst.securityLabel = new ArrayList<Coding>();
3753          for (Coding i : securityLabel)
3754            dst.securityLabel.add(i.copy());
3755        };
3756        if (purpose != null) {
3757          dst.purpose = new ArrayList<Coding>();
3758          for (Coding i : purpose)
3759            dst.purpose.add(i.copy());
3760        };
3761        dst.dataPeriod = dataPeriod == null ? null : dataPeriod.copy();
3762        if (data != null) {
3763          dst.data = new ArrayList<ConsentDataComponent>();
3764          for (ConsentDataComponent i : data)
3765            dst.data.add(i.copy());
3766        };
3767        if (except != null) {
3768          dst.except = new ArrayList<ExceptComponent>();
3769          for (ExceptComponent i : except)
3770            dst.except.add(i.copy());
3771        };
3772        return dst;
3773      }
3774
3775      protected Consent typedCopy() {
3776        return copy();
3777      }
3778
3779      @Override
3780      public boolean equalsDeep(Base other) {
3781        if (!super.equalsDeep(other))
3782          return false;
3783        if (!(other instanceof Consent))
3784          return false;
3785        Consent o = (Consent) other;
3786        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(category, o.category, true)
3787           && compareDeep(patient, o.patient, true) && compareDeep(period, o.period, true) && compareDeep(dateTime, o.dateTime, true)
3788           && compareDeep(consentingParty, o.consentingParty, true) && compareDeep(actor, o.actor, true) && compareDeep(action, o.action, true)
3789           && compareDeep(organization, o.organization, true) && compareDeep(source, o.source, true) && compareDeep(policy, o.policy, true)
3790           && compareDeep(policyRule, o.policyRule, true) && compareDeep(securityLabel, o.securityLabel, true)
3791           && compareDeep(purpose, o.purpose, true) && compareDeep(dataPeriod, o.dataPeriod, true) && compareDeep(data, o.data, true)
3792           && compareDeep(except, o.except, true);
3793      }
3794
3795      @Override
3796      public boolean equalsShallow(Base other) {
3797        if (!super.equalsShallow(other))
3798          return false;
3799        if (!(other instanceof Consent))
3800          return false;
3801        Consent o = (Consent) other;
3802        return compareValues(status, o.status, true) && compareValues(dateTime, o.dateTime, true) && compareValues(policyRule, o.policyRule, true)
3803          ;
3804      }
3805
3806      public boolean isEmpty() {
3807        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, category
3808          , patient, period, dateTime, consentingParty, actor, action, organization, source
3809          , policy, policyRule, securityLabel, purpose, dataPeriod, data, except);
3810      }
3811
3812  @Override
3813  public ResourceType getResourceType() {
3814    return ResourceType.Consent;
3815   }
3816
3817 /**
3818   * Search parameter: <b>date</b>
3819   * <p>
3820   * Description: <b>When this Consent was created or indexed</b><br>
3821   * Type: <b>date</b><br>
3822   * Path: <b>Consent.dateTime</b><br>
3823   * </p>
3824   */
3825  @SearchParamDefinition(name="date", path="Consent.dateTime", description="When this Consent was created or indexed", type="date" )
3826  public static final String SP_DATE = "date";
3827 /**
3828   * <b>Fluent Client</b> search parameter constant for <b>date</b>
3829   * <p>
3830   * Description: <b>When this Consent was created or indexed</b><br>
3831   * Type: <b>date</b><br>
3832   * Path: <b>Consent.dateTime</b><br>
3833   * </p>
3834   */
3835  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
3836
3837 /**
3838   * Search parameter: <b>identifier</b>
3839   * <p>
3840   * Description: <b>Identifier for this record (external references)</b><br>
3841   * Type: <b>token</b><br>
3842   * Path: <b>Consent.identifier</b><br>
3843   * </p>
3844   */
3845  @SearchParamDefinition(name="identifier", path="Consent.identifier", description="Identifier for this record (external references)", type="token" )
3846  public static final String SP_IDENTIFIER = "identifier";
3847 /**
3848   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
3849   * <p>
3850   * Description: <b>Identifier for this record (external references)</b><br>
3851   * Type: <b>token</b><br>
3852   * Path: <b>Consent.identifier</b><br>
3853   * </p>
3854   */
3855  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
3856
3857 /**
3858   * Search parameter: <b>securitylabel</b>
3859   * <p>
3860   * Description: <b>Security Labels that define affected resources</b><br>
3861   * Type: <b>token</b><br>
3862   * Path: <b>Consent.securityLabel, Consent.except.securityLabel</b><br>
3863   * </p>
3864   */
3865  @SearchParamDefinition(name="securitylabel", path="Consent.securityLabel | Consent.except.securityLabel", description="Security Labels that define affected resources", type="token" )
3866  public static final String SP_SECURITYLABEL = "securitylabel";
3867 /**
3868   * <b>Fluent Client</b> search parameter constant for <b>securitylabel</b>
3869   * <p>
3870   * Description: <b>Security Labels that define affected resources</b><br>
3871   * Type: <b>token</b><br>
3872   * Path: <b>Consent.securityLabel, Consent.except.securityLabel</b><br>
3873   * </p>
3874   */
3875  public static final ca.uhn.fhir.rest.gclient.TokenClientParam SECURITYLABEL = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_SECURITYLABEL);
3876
3877 /**
3878   * Search parameter: <b>period</b>
3879   * <p>
3880   * Description: <b>Period that this consent applies</b><br>
3881   * Type: <b>date</b><br>
3882   * Path: <b>Consent.period</b><br>
3883   * </p>
3884   */
3885  @SearchParamDefinition(name="period", path="Consent.period", description="Period that this consent applies", type="date" )
3886  public static final String SP_PERIOD = "period";
3887 /**
3888   * <b>Fluent Client</b> search parameter constant for <b>period</b>
3889   * <p>
3890   * Description: <b>Period that this consent applies</b><br>
3891   * Type: <b>date</b><br>
3892   * Path: <b>Consent.period</b><br>
3893   * </p>
3894   */
3895  public static final ca.uhn.fhir.rest.gclient.DateClientParam PERIOD = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_PERIOD);
3896
3897 /**
3898   * Search parameter: <b>data</b>
3899   * <p>
3900   * Description: <b>The actual data reference</b><br>
3901   * Type: <b>reference</b><br>
3902   * Path: <b>Consent.data.reference, Consent.except.data.reference</b><br>
3903   * </p>
3904   */
3905  @SearchParamDefinition(name="data", path="Consent.data.reference | Consent.except.data.reference", description="The actual data reference", type="reference" )
3906  public static final String SP_DATA = "data";
3907 /**
3908   * <b>Fluent Client</b> search parameter constant for <b>data</b>
3909   * <p>
3910   * Description: <b>The actual data reference</b><br>
3911   * Type: <b>reference</b><br>
3912   * Path: <b>Consent.data.reference, Consent.except.data.reference</b><br>
3913   * </p>
3914   */
3915  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam DATA = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_DATA);
3916
3917/**
3918   * Constant for fluent queries to be used to add include statements. Specifies
3919   * the path value of "<b>Consent:data</b>".
3920   */
3921  public static final ca.uhn.fhir.model.api.Include INCLUDE_DATA = new ca.uhn.fhir.model.api.Include("Consent:data").toLocked();
3922
3923 /**
3924   * Search parameter: <b>purpose</b>
3925   * <p>
3926   * Description: <b>Context of activities for which the agreement is made</b><br>
3927   * Type: <b>token</b><br>
3928   * Path: <b>Consent.purpose, Consent.except.purpose</b><br>
3929   * </p>
3930   */
3931  @SearchParamDefinition(name="purpose", path="Consent.purpose | Consent.except.purpose", description="Context of activities for which the agreement is made", type="token" )
3932  public static final String SP_PURPOSE = "purpose";
3933 /**
3934   * <b>Fluent Client</b> search parameter constant for <b>purpose</b>
3935   * <p>
3936   * Description: <b>Context of activities for which the agreement is made</b><br>
3937   * Type: <b>token</b><br>
3938   * Path: <b>Consent.purpose, Consent.except.purpose</b><br>
3939   * </p>
3940   */
3941  public static final ca.uhn.fhir.rest.gclient.TokenClientParam PURPOSE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_PURPOSE);
3942
3943 /**
3944   * Search parameter: <b>source</b>
3945   * <p>
3946   * Description: <b>Source from which this consent is taken</b><br>
3947   * Type: <b>reference</b><br>
3948   * Path: <b>Consent.source[x]</b><br>
3949   * </p>
3950   */
3951  @SearchParamDefinition(name="source", path="Consent.source", description="Source from which this consent is taken", type="reference", target={Consent.class, Contract.class, DocumentReference.class, QuestionnaireResponse.class } )
3952  public static final String SP_SOURCE = "source";
3953 /**
3954   * <b>Fluent Client</b> search parameter constant for <b>source</b>
3955   * <p>
3956   * Description: <b>Source from which this consent is taken</b><br>
3957   * Type: <b>reference</b><br>
3958   * Path: <b>Consent.source[x]</b><br>
3959   * </p>
3960   */
3961  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SOURCE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SOURCE);
3962
3963/**
3964   * Constant for fluent queries to be used to add include statements. Specifies
3965   * the path value of "<b>Consent:source</b>".
3966   */
3967  public static final ca.uhn.fhir.model.api.Include INCLUDE_SOURCE = new ca.uhn.fhir.model.api.Include("Consent:source").toLocked();
3968
3969 /**
3970   * Search parameter: <b>actor</b>
3971   * <p>
3972   * Description: <b>Resource for the actor (or group, by role)</b><br>
3973   * Type: <b>reference</b><br>
3974   * Path: <b>Consent.actor.reference, Consent.except.actor.reference</b><br>
3975   * </p>
3976   */
3977  @SearchParamDefinition(name="actor", path="Consent.actor.reference | Consent.except.actor.reference", description="Resource for the actor (or group, by role)", type="reference", target={CareTeam.class, Device.class, Group.class, Organization.class, Patient.class, Practitioner.class, RelatedPerson.class } )
3978  public static final String SP_ACTOR = "actor";
3979 /**
3980   * <b>Fluent Client</b> search parameter constant for <b>actor</b>
3981   * <p>
3982   * Description: <b>Resource for the actor (or group, by role)</b><br>
3983   * Type: <b>reference</b><br>
3984   * Path: <b>Consent.actor.reference, Consent.except.actor.reference</b><br>
3985   * </p>
3986   */
3987  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ACTOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ACTOR);
3988
3989/**
3990   * Constant for fluent queries to be used to add include statements. Specifies
3991   * the path value of "<b>Consent:actor</b>".
3992   */
3993  public static final ca.uhn.fhir.model.api.Include INCLUDE_ACTOR = new ca.uhn.fhir.model.api.Include("Consent:actor").toLocked();
3994
3995 /**
3996   * Search parameter: <b>patient</b>
3997   * <p>
3998   * Description: <b>Who the consent applies to</b><br>
3999   * Type: <b>reference</b><br>
4000   * Path: <b>Consent.patient</b><br>
4001   * </p>
4002   */
4003  @SearchParamDefinition(name="patient", path="Consent.patient", description="Who the consent applies to", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Patient.class } )
4004  public static final String SP_PATIENT = "patient";
4005 /**
4006   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
4007   * <p>
4008   * Description: <b>Who the consent applies to</b><br>
4009   * Type: <b>reference</b><br>
4010   * Path: <b>Consent.patient</b><br>
4011   * </p>
4012   */
4013  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
4014
4015/**
4016   * Constant for fluent queries to be used to add include statements. Specifies
4017   * the path value of "<b>Consent:patient</b>".
4018   */
4019  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("Consent:patient").toLocked();
4020
4021 /**
4022   * Search parameter: <b>organization</b>
4023   * <p>
4024   * Description: <b>Custodian of the consent</b><br>
4025   * Type: <b>reference</b><br>
4026   * Path: <b>Consent.organization</b><br>
4027   * </p>
4028   */
4029  @SearchParamDefinition(name="organization", path="Consent.organization", description="Custodian of the consent", type="reference", target={Organization.class } )
4030  public static final String SP_ORGANIZATION = "organization";
4031 /**
4032   * <b>Fluent Client</b> search parameter constant for <b>organization</b>
4033   * <p>
4034   * Description: <b>Custodian of the consent</b><br>
4035   * Type: <b>reference</b><br>
4036   * Path: <b>Consent.organization</b><br>
4037   * </p>
4038   */
4039  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ORGANIZATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ORGANIZATION);
4040
4041/**
4042   * Constant for fluent queries to be used to add include statements. Specifies
4043   * the path value of "<b>Consent:organization</b>".
4044   */
4045  public static final ca.uhn.fhir.model.api.Include INCLUDE_ORGANIZATION = new ca.uhn.fhir.model.api.Include("Consent:organization").toLocked();
4046
4047 /**
4048   * Search parameter: <b>action</b>
4049   * <p>
4050   * Description: <b>Actions controlled by this consent</b><br>
4051   * Type: <b>token</b><br>
4052   * Path: <b>Consent.action, Consent.except.action</b><br>
4053   * </p>
4054   */
4055  @SearchParamDefinition(name="action", path="Consent.action | Consent.except.action", description="Actions controlled by this consent", type="token" )
4056  public static final String SP_ACTION = "action";
4057 /**
4058   * <b>Fluent Client</b> search parameter constant for <b>action</b>
4059   * <p>
4060   * Description: <b>Actions controlled by this consent</b><br>
4061   * Type: <b>token</b><br>
4062   * Path: <b>Consent.action, Consent.except.action</b><br>
4063   * </p>
4064   */
4065  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ACTION = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_ACTION);
4066
4067 /**
4068   * Search parameter: <b>consentor</b>
4069   * <p>
4070   * Description: <b>Who is agreeing to the policy and exceptions</b><br>
4071   * Type: <b>reference</b><br>
4072   * Path: <b>Consent.consentingParty</b><br>
4073   * </p>
4074   */
4075  @SearchParamDefinition(name="consentor", path="Consent.consentingParty", description="Who is agreeing to the policy and exceptions", type="reference", target={Organization.class, Patient.class, Practitioner.class, RelatedPerson.class } )
4076  public static final String SP_CONSENTOR = "consentor";
4077 /**
4078   * <b>Fluent Client</b> search parameter constant for <b>consentor</b>
4079   * <p>
4080   * Description: <b>Who is agreeing to the policy and exceptions</b><br>
4081   * Type: <b>reference</b><br>
4082   * Path: <b>Consent.consentingParty</b><br>
4083   * </p>
4084   */
4085  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam CONSENTOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_CONSENTOR);
4086
4087/**
4088   * Constant for fluent queries to be used to add include statements. Specifies
4089   * the path value of "<b>Consent:consentor</b>".
4090   */
4091  public static final ca.uhn.fhir.model.api.Include INCLUDE_CONSENTOR = new ca.uhn.fhir.model.api.Include("Consent:consentor").toLocked();
4092
4093 /**
4094   * Search parameter: <b>category</b>
4095   * <p>
4096   * Description: <b>Classification of the consent statement - for indexing/retrieval</b><br>
4097   * Type: <b>token</b><br>
4098   * Path: <b>Consent.category</b><br>
4099   * </p>
4100   */
4101  @SearchParamDefinition(name="category", path="Consent.category", description="Classification of the consent statement - for indexing/retrieval", type="token" )
4102  public static final String SP_CATEGORY = "category";
4103 /**
4104   * <b>Fluent Client</b> search parameter constant for <b>category</b>
4105   * <p>
4106   * Description: <b>Classification of the consent statement - for indexing/retrieval</b><br>
4107   * Type: <b>token</b><br>
4108   * Path: <b>Consent.category</b><br>
4109   * </p>
4110   */
4111  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CATEGORY);
4112
4113 /**
4114   * Search parameter: <b>status</b>
4115   * <p>
4116   * Description: <b>draft | proposed | active | rejected | inactive | entered-in-error</b><br>
4117   * Type: <b>token</b><br>
4118   * Path: <b>Consent.status</b><br>
4119   * </p>
4120   */
4121  @SearchParamDefinition(name="status", path="Consent.status", description="draft | proposed | active | rejected | inactive | entered-in-error", type="token" )
4122  public static final String SP_STATUS = "status";
4123 /**
4124   * <b>Fluent Client</b> search parameter constant for <b>status</b>
4125   * <p>
4126   * Description: <b>draft | proposed | active | rejected | inactive | entered-in-error</b><br>
4127   * Type: <b>token</b><br>
4128   * Path: <b>Consent.status</b><br>
4129   * </p>
4130   */
4131  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
4132
4133
4134}
4135