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