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