001package org.hl7.fhir.r5.model;
002
003
004/*
005  Copyright (c) 2011+, HL7, Inc.
006  All rights reserved.
007  
008  Redistribution and use in source and binary forms, with or without modification, \
009  are permitted provided that the following conditions are met:
010  
011   * Redistributions of source code must retain the above copyright notice, this \
012     list of conditions and the following disclaimer.
013   * Redistributions in binary form must reproduce the above copyright notice, \
014     this list of conditions and the following disclaimer in the documentation \
015     and/or other materials provided with the distribution.
016   * Neither the name of HL7 nor the names of its contributors may be used to 
017     endorse or promote products derived from this software without specific 
018     prior written permission.
019  
020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
021  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
022  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
023  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
024  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
025  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
026  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
027  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
028  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
029  POSSIBILITY OF SUCH DAMAGE.
030  */
031
032// Generated on Thu, Mar 23, 2023 19:59+1100 for FHIR v5.0.0
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import org.hl7.fhir.utilities.Utilities;
038import org.hl7.fhir.r5.model.Enumerations.*;
039import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
040import org.hl7.fhir.exceptions.FHIRException;
041import org.hl7.fhir.instance.model.api.ICompositeType;
042import ca.uhn.fhir.model.api.annotation.ResourceDef;
043import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
044import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
045import ca.uhn.fhir.model.api.annotation.Child;
046import ca.uhn.fhir.model.api.annotation.ChildOrder;
047import ca.uhn.fhir.model.api.annotation.Description;
048import ca.uhn.fhir.model.api.annotation.Block;
049
050/**
051 * Permission resource holds access rules for a given data and context.
052 */
053@ResourceDef(name="Permission", profile="http://hl7.org/fhir/StructureDefinition/Permission")
054public class Permission extends DomainResource {
055
056    public enum PermissionRuleCombining {
057        /**
058         * The deny overrides combining algorithm is intended for those cases where a deny decision should have priority over a permit decision.
059         */
060        DENYOVERRIDES, 
061        /**
062         * The permit overrides combining algorithm is intended for those cases where a permit decision should have priority over a deny decision.
063         */
064        PERMITOVERRIDES, 
065        /**
066         * The behavior of this algorithm is identical to that of the ?Deny-overrides? rule-combining algorithm with one exception.  The order in which the collection of rules is evaluated SHALL match the order as listed in the permission.
067         */
068        ORDEREDDENYOVERRIDES, 
069        /**
070         * The behavior of this algorithm is identical to that of the ?Permit-overrides? rule-combining algorithm with one exception.  The order in which the collection of rules is evaluated SHALL match the order as listed in the permission.
071         */
072        ORDEREDPERMITOVERRIDES, 
073        /**
074         * The ?Deny-unless-permit? combining algorithm is intended for those cases where a permit decision should have priority over a deny decision, and an ?Indeterminate? or ?NotApplicable? must never be the result. It is particularly useful at the top level in a policy structure to ensure that a PDP will always return a definite ?Permit? or ?Deny? result.
075         */
076        DENYUNLESSPERMIT, 
077        /**
078         * The ?Permit-unless-deny? combining algorithm is intended for those cases where a deny decision should have priority over a permit decision, and an ?Indeterminate? or ?NotApplicable? must never be the result. It is particularly useful at the top level in a policy structure to ensure that a PDP will always return a definite ?Permit? or ?Deny? result. This algorithm has the following behavior.
079         */
080        PERMITUNLESSDENY, 
081        /**
082         * added to help the parsers with the generic types
083         */
084        NULL;
085        public static PermissionRuleCombining fromCode(String codeString) throws FHIRException {
086            if (codeString == null || "".equals(codeString))
087                return null;
088        if ("deny-overrides".equals(codeString))
089          return DENYOVERRIDES;
090        if ("permit-overrides".equals(codeString))
091          return PERMITOVERRIDES;
092        if ("ordered-deny-overrides".equals(codeString))
093          return ORDEREDDENYOVERRIDES;
094        if ("ordered-permit-overrides".equals(codeString))
095          return ORDEREDPERMITOVERRIDES;
096        if ("deny-unless-permit".equals(codeString))
097          return DENYUNLESSPERMIT;
098        if ("permit-unless-deny".equals(codeString))
099          return PERMITUNLESSDENY;
100        if (Configuration.isAcceptInvalidEnums())
101          return null;
102        else
103          throw new FHIRException("Unknown PermissionRuleCombining code '"+codeString+"'");
104        }
105        public String toCode() {
106          switch (this) {
107            case DENYOVERRIDES: return "deny-overrides";
108            case PERMITOVERRIDES: return "permit-overrides";
109            case ORDEREDDENYOVERRIDES: return "ordered-deny-overrides";
110            case ORDEREDPERMITOVERRIDES: return "ordered-permit-overrides";
111            case DENYUNLESSPERMIT: return "deny-unless-permit";
112            case PERMITUNLESSDENY: return "permit-unless-deny";
113            case NULL: return null;
114            default: return "?";
115          }
116        }
117        public String getSystem() {
118          switch (this) {
119            case DENYOVERRIDES: return "http://hl7.org/fhir/permission-rule-combining";
120            case PERMITOVERRIDES: return "http://hl7.org/fhir/permission-rule-combining";
121            case ORDEREDDENYOVERRIDES: return "http://hl7.org/fhir/permission-rule-combining";
122            case ORDEREDPERMITOVERRIDES: return "http://hl7.org/fhir/permission-rule-combining";
123            case DENYUNLESSPERMIT: return "http://hl7.org/fhir/permission-rule-combining";
124            case PERMITUNLESSDENY: return "http://hl7.org/fhir/permission-rule-combining";
125            case NULL: return null;
126            default: return "?";
127          }
128        }
129        public String getDefinition() {
130          switch (this) {
131            case DENYOVERRIDES: return "The deny overrides combining algorithm is intended for those cases where a deny decision should have priority over a permit decision.";
132            case PERMITOVERRIDES: return "The permit overrides combining algorithm is intended for those cases where a permit decision should have priority over a deny decision.";
133            case ORDEREDDENYOVERRIDES: return "The behavior of this algorithm is identical to that of the ?Deny-overrides? rule-combining algorithm with one exception.  The order in which the collection of rules is evaluated SHALL match the order as listed in the permission.";
134            case ORDEREDPERMITOVERRIDES: return "The behavior of this algorithm is identical to that of the ?Permit-overrides? rule-combining algorithm with one exception.  The order in which the collection of rules is evaluated SHALL match the order as listed in the permission.";
135            case DENYUNLESSPERMIT: return "The ?Deny-unless-permit? combining algorithm is intended for those cases where a permit decision should have priority over a deny decision, and an ?Indeterminate? or ?NotApplicable? must never be the result. It is particularly useful at the top level in a policy structure to ensure that a PDP will always return a definite ?Permit? or ?Deny? result.";
136            case PERMITUNLESSDENY: return "The ?Permit-unless-deny? combining algorithm is intended for those cases where a deny decision should have priority over a permit decision, and an ?Indeterminate? or ?NotApplicable? must never be the result. It is particularly useful at the top level in a policy structure to ensure that a PDP will always return a definite ?Permit? or ?Deny? result. This algorithm has the following behavior.";
137            case NULL: return null;
138            default: return "?";
139          }
140        }
141        public String getDisplay() {
142          switch (this) {
143            case DENYOVERRIDES: return "Deny-overrides";
144            case PERMITOVERRIDES: return "Permit-overrides";
145            case ORDEREDDENYOVERRIDES: return "Ordered-deny-overrides";
146            case ORDEREDPERMITOVERRIDES: return "Ordered-permit-overrides";
147            case DENYUNLESSPERMIT: return "Deny-unless-permit";
148            case PERMITUNLESSDENY: return "Permit-unless-deny";
149            case NULL: return null;
150            default: return "?";
151          }
152        }
153    }
154
155  public static class PermissionRuleCombiningEnumFactory implements EnumFactory<PermissionRuleCombining> {
156    public PermissionRuleCombining fromCode(String codeString) throws IllegalArgumentException {
157      if (codeString == null || "".equals(codeString))
158            if (codeString == null || "".equals(codeString))
159                return null;
160        if ("deny-overrides".equals(codeString))
161          return PermissionRuleCombining.DENYOVERRIDES;
162        if ("permit-overrides".equals(codeString))
163          return PermissionRuleCombining.PERMITOVERRIDES;
164        if ("ordered-deny-overrides".equals(codeString))
165          return PermissionRuleCombining.ORDEREDDENYOVERRIDES;
166        if ("ordered-permit-overrides".equals(codeString))
167          return PermissionRuleCombining.ORDEREDPERMITOVERRIDES;
168        if ("deny-unless-permit".equals(codeString))
169          return PermissionRuleCombining.DENYUNLESSPERMIT;
170        if ("permit-unless-deny".equals(codeString))
171          return PermissionRuleCombining.PERMITUNLESSDENY;
172        throw new IllegalArgumentException("Unknown PermissionRuleCombining code '"+codeString+"'");
173        }
174        public Enumeration<PermissionRuleCombining> fromType(PrimitiveType<?> code) throws FHIRException {
175          if (code == null)
176            return null;
177          if (code.isEmpty())
178            return new Enumeration<PermissionRuleCombining>(this, PermissionRuleCombining.NULL, code);
179          String codeString = ((PrimitiveType) code).asStringValue();
180          if (codeString == null || "".equals(codeString))
181            return new Enumeration<PermissionRuleCombining>(this, PermissionRuleCombining.NULL, code);
182        if ("deny-overrides".equals(codeString))
183          return new Enumeration<PermissionRuleCombining>(this, PermissionRuleCombining.DENYOVERRIDES, code);
184        if ("permit-overrides".equals(codeString))
185          return new Enumeration<PermissionRuleCombining>(this, PermissionRuleCombining.PERMITOVERRIDES, code);
186        if ("ordered-deny-overrides".equals(codeString))
187          return new Enumeration<PermissionRuleCombining>(this, PermissionRuleCombining.ORDEREDDENYOVERRIDES, code);
188        if ("ordered-permit-overrides".equals(codeString))
189          return new Enumeration<PermissionRuleCombining>(this, PermissionRuleCombining.ORDEREDPERMITOVERRIDES, code);
190        if ("deny-unless-permit".equals(codeString))
191          return new Enumeration<PermissionRuleCombining>(this, PermissionRuleCombining.DENYUNLESSPERMIT, code);
192        if ("permit-unless-deny".equals(codeString))
193          return new Enumeration<PermissionRuleCombining>(this, PermissionRuleCombining.PERMITUNLESSDENY, code);
194        throw new FHIRException("Unknown PermissionRuleCombining code '"+codeString+"'");
195        }
196    public String toCode(PermissionRuleCombining code) {
197      if (code == PermissionRuleCombining.DENYOVERRIDES)
198        return "deny-overrides";
199      if (code == PermissionRuleCombining.PERMITOVERRIDES)
200        return "permit-overrides";
201      if (code == PermissionRuleCombining.ORDEREDDENYOVERRIDES)
202        return "ordered-deny-overrides";
203      if (code == PermissionRuleCombining.ORDEREDPERMITOVERRIDES)
204        return "ordered-permit-overrides";
205      if (code == PermissionRuleCombining.DENYUNLESSPERMIT)
206        return "deny-unless-permit";
207      if (code == PermissionRuleCombining.PERMITUNLESSDENY)
208        return "permit-unless-deny";
209      return "?";
210      }
211    public String toSystem(PermissionRuleCombining code) {
212      return code.getSystem();
213      }
214    }
215
216    public enum PermissionStatus {
217        /**
218         * Permission is given.
219         */
220        ACTIVE, 
221        /**
222         * Permission was entered in error and is not active.
223         */
224        ENTEREDINERROR, 
225        /**
226         * Permission is being defined.
227         */
228        DRAFT, 
229        /**
230         * Permission not granted.
231         */
232        REJECTED, 
233        /**
234         * added to help the parsers with the generic types
235         */
236        NULL;
237        public static PermissionStatus fromCode(String codeString) throws FHIRException {
238            if (codeString == null || "".equals(codeString))
239                return null;
240        if ("active".equals(codeString))
241          return ACTIVE;
242        if ("entered-in-error".equals(codeString))
243          return ENTEREDINERROR;
244        if ("draft".equals(codeString))
245          return DRAFT;
246        if ("rejected".equals(codeString))
247          return REJECTED;
248        if (Configuration.isAcceptInvalidEnums())
249          return null;
250        else
251          throw new FHIRException("Unknown PermissionStatus code '"+codeString+"'");
252        }
253        public String toCode() {
254          switch (this) {
255            case ACTIVE: return "active";
256            case ENTEREDINERROR: return "entered-in-error";
257            case DRAFT: return "draft";
258            case REJECTED: return "rejected";
259            case NULL: return null;
260            default: return "?";
261          }
262        }
263        public String getSystem() {
264          switch (this) {
265            case ACTIVE: return "http://hl7.org/fhir/permission-status";
266            case ENTEREDINERROR: return "http://hl7.org/fhir/permission-status";
267            case DRAFT: return "http://hl7.org/fhir/permission-status";
268            case REJECTED: return "http://hl7.org/fhir/permission-status";
269            case NULL: return null;
270            default: return "?";
271          }
272        }
273        public String getDefinition() {
274          switch (this) {
275            case ACTIVE: return "Permission is given.";
276            case ENTEREDINERROR: return "Permission was entered in error and is not active.";
277            case DRAFT: return "Permission is being defined.";
278            case REJECTED: return "Permission not granted.";
279            case NULL: return null;
280            default: return "?";
281          }
282        }
283        public String getDisplay() {
284          switch (this) {
285            case ACTIVE: return "Active";
286            case ENTEREDINERROR: return "Entered in Error";
287            case DRAFT: return "Draft";
288            case REJECTED: return "Rejected";
289            case NULL: return null;
290            default: return "?";
291          }
292        }
293    }
294
295  public static class PermissionStatusEnumFactory implements EnumFactory<PermissionStatus> {
296    public PermissionStatus fromCode(String codeString) throws IllegalArgumentException {
297      if (codeString == null || "".equals(codeString))
298            if (codeString == null || "".equals(codeString))
299                return null;
300        if ("active".equals(codeString))
301          return PermissionStatus.ACTIVE;
302        if ("entered-in-error".equals(codeString))
303          return PermissionStatus.ENTEREDINERROR;
304        if ("draft".equals(codeString))
305          return PermissionStatus.DRAFT;
306        if ("rejected".equals(codeString))
307          return PermissionStatus.REJECTED;
308        throw new IllegalArgumentException("Unknown PermissionStatus code '"+codeString+"'");
309        }
310        public Enumeration<PermissionStatus> fromType(PrimitiveType<?> code) throws FHIRException {
311          if (code == null)
312            return null;
313          if (code.isEmpty())
314            return new Enumeration<PermissionStatus>(this, PermissionStatus.NULL, code);
315          String codeString = ((PrimitiveType) code).asStringValue();
316          if (codeString == null || "".equals(codeString))
317            return new Enumeration<PermissionStatus>(this, PermissionStatus.NULL, code);
318        if ("active".equals(codeString))
319          return new Enumeration<PermissionStatus>(this, PermissionStatus.ACTIVE, code);
320        if ("entered-in-error".equals(codeString))
321          return new Enumeration<PermissionStatus>(this, PermissionStatus.ENTEREDINERROR, code);
322        if ("draft".equals(codeString))
323          return new Enumeration<PermissionStatus>(this, PermissionStatus.DRAFT, code);
324        if ("rejected".equals(codeString))
325          return new Enumeration<PermissionStatus>(this, PermissionStatus.REJECTED, code);
326        throw new FHIRException("Unknown PermissionStatus code '"+codeString+"'");
327        }
328    public String toCode(PermissionStatus code) {
329      if (code == PermissionStatus.ACTIVE)
330        return "active";
331      if (code == PermissionStatus.ENTEREDINERROR)
332        return "entered-in-error";
333      if (code == PermissionStatus.DRAFT)
334        return "draft";
335      if (code == PermissionStatus.REJECTED)
336        return "rejected";
337      return "?";
338      }
339    public String toSystem(PermissionStatus code) {
340      return code.getSystem();
341      }
342    }
343
344    @Block()
345    public static class PermissionJustificationComponent extends BackboneElement implements IBaseBackboneElement {
346        /**
347         * This would be a codeableconcept, or a coding, which can be constrained to , for example, the 6 grounds for processing in GDPR.
348         */
349        @Child(name = "basis", type = {CodeableConcept.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
350        @Description(shortDefinition="The regulatory grounds upon which this Permission builds", formalDefinition="This would be a codeableconcept, or a coding, which can be constrained to , for example, the 6 grounds for processing in GDPR." )
351        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/consent-policy")
352        protected List<CodeableConcept> basis;
353
354        /**
355         * Justifing rational.
356         */
357        @Child(name = "evidence", type = {Reference.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
358        @Description(shortDefinition="Justifing rational", formalDefinition="Justifing rational." )
359        protected List<Reference> evidence;
360
361        private static final long serialVersionUID = -2023272721L;
362
363    /**
364     * Constructor
365     */
366      public PermissionJustificationComponent() {
367        super();
368      }
369
370        /**
371         * @return {@link #basis} (This would be a codeableconcept, or a coding, which can be constrained to , for example, the 6 grounds for processing in GDPR.)
372         */
373        public List<CodeableConcept> getBasis() { 
374          if (this.basis == null)
375            this.basis = new ArrayList<CodeableConcept>();
376          return this.basis;
377        }
378
379        /**
380         * @return Returns a reference to <code>this</code> for easy method chaining
381         */
382        public PermissionJustificationComponent setBasis(List<CodeableConcept> theBasis) { 
383          this.basis = theBasis;
384          return this;
385        }
386
387        public boolean hasBasis() { 
388          if (this.basis == null)
389            return false;
390          for (CodeableConcept item : this.basis)
391            if (!item.isEmpty())
392              return true;
393          return false;
394        }
395
396        public CodeableConcept addBasis() { //3
397          CodeableConcept t = new CodeableConcept();
398          if (this.basis == null)
399            this.basis = new ArrayList<CodeableConcept>();
400          this.basis.add(t);
401          return t;
402        }
403
404        public PermissionJustificationComponent addBasis(CodeableConcept t) { //3
405          if (t == null)
406            return this;
407          if (this.basis == null)
408            this.basis = new ArrayList<CodeableConcept>();
409          this.basis.add(t);
410          return this;
411        }
412
413        /**
414         * @return The first repetition of repeating field {@link #basis}, creating it if it does not already exist {3}
415         */
416        public CodeableConcept getBasisFirstRep() { 
417          if (getBasis().isEmpty()) {
418            addBasis();
419          }
420          return getBasis().get(0);
421        }
422
423        /**
424         * @return {@link #evidence} (Justifing rational.)
425         */
426        public List<Reference> getEvidence() { 
427          if (this.evidence == null)
428            this.evidence = new ArrayList<Reference>();
429          return this.evidence;
430        }
431
432        /**
433         * @return Returns a reference to <code>this</code> for easy method chaining
434         */
435        public PermissionJustificationComponent setEvidence(List<Reference> theEvidence) { 
436          this.evidence = theEvidence;
437          return this;
438        }
439
440        public boolean hasEvidence() { 
441          if (this.evidence == null)
442            return false;
443          for (Reference item : this.evidence)
444            if (!item.isEmpty())
445              return true;
446          return false;
447        }
448
449        public Reference addEvidence() { //3
450          Reference t = new Reference();
451          if (this.evidence == null)
452            this.evidence = new ArrayList<Reference>();
453          this.evidence.add(t);
454          return t;
455        }
456
457        public PermissionJustificationComponent addEvidence(Reference t) { //3
458          if (t == null)
459            return this;
460          if (this.evidence == null)
461            this.evidence = new ArrayList<Reference>();
462          this.evidence.add(t);
463          return this;
464        }
465
466        /**
467         * @return The first repetition of repeating field {@link #evidence}, creating it if it does not already exist {3}
468         */
469        public Reference getEvidenceFirstRep() { 
470          if (getEvidence().isEmpty()) {
471            addEvidence();
472          }
473          return getEvidence().get(0);
474        }
475
476        protected void listChildren(List<Property> children) {
477          super.listChildren(children);
478          children.add(new Property("basis", "CodeableConcept", "This would be a codeableconcept, or a coding, which can be constrained to , for example, the 6 grounds for processing in GDPR.", 0, java.lang.Integer.MAX_VALUE, basis));
479          children.add(new Property("evidence", "Reference(Any)", "Justifing rational.", 0, java.lang.Integer.MAX_VALUE, evidence));
480        }
481
482        @Override
483        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
484          switch (_hash) {
485          case 93508670: /*basis*/  return new Property("basis", "CodeableConcept", "This would be a codeableconcept, or a coding, which can be constrained to , for example, the 6 grounds for processing in GDPR.", 0, java.lang.Integer.MAX_VALUE, basis);
486          case 382967383: /*evidence*/  return new Property("evidence", "Reference(Any)", "Justifing rational.", 0, java.lang.Integer.MAX_VALUE, evidence);
487          default: return super.getNamedProperty(_hash, _name, _checkValid);
488          }
489
490        }
491
492      @Override
493      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
494        switch (hash) {
495        case 93508670: /*basis*/ return this.basis == null ? new Base[0] : this.basis.toArray(new Base[this.basis.size()]); // CodeableConcept
496        case 382967383: /*evidence*/ return this.evidence == null ? new Base[0] : this.evidence.toArray(new Base[this.evidence.size()]); // Reference
497        default: return super.getProperty(hash, name, checkValid);
498        }
499
500      }
501
502      @Override
503      public Base setProperty(int hash, String name, Base value) throws FHIRException {
504        switch (hash) {
505        case 93508670: // basis
506          this.getBasis().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
507          return value;
508        case 382967383: // evidence
509          this.getEvidence().add(TypeConvertor.castToReference(value)); // Reference
510          return value;
511        default: return super.setProperty(hash, name, value);
512        }
513
514      }
515
516      @Override
517      public Base setProperty(String name, Base value) throws FHIRException {
518        if (name.equals("basis")) {
519          this.getBasis().add(TypeConvertor.castToCodeableConcept(value));
520        } else if (name.equals("evidence")) {
521          this.getEvidence().add(TypeConvertor.castToReference(value));
522        } else
523          return super.setProperty(name, value);
524        return value;
525      }
526
527  @Override
528  public void removeChild(String name, Base value) throws FHIRException {
529        if (name.equals("basis")) {
530          this.getBasis().remove(value);
531        } else if (name.equals("evidence")) {
532          this.getEvidence().remove(value);
533        } else
534          super.removeChild(name, value);
535        
536      }
537
538      @Override
539      public Base makeProperty(int hash, String name) throws FHIRException {
540        switch (hash) {
541        case 93508670:  return addBasis(); 
542        case 382967383:  return addEvidence(); 
543        default: return super.makeProperty(hash, name);
544        }
545
546      }
547
548      @Override
549      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
550        switch (hash) {
551        case 93508670: /*basis*/ return new String[] {"CodeableConcept"};
552        case 382967383: /*evidence*/ return new String[] {"Reference"};
553        default: return super.getTypesForProperty(hash, name);
554        }
555
556      }
557
558      @Override
559      public Base addChild(String name) throws FHIRException {
560        if (name.equals("basis")) {
561          return addBasis();
562        }
563        else if (name.equals("evidence")) {
564          return addEvidence();
565        }
566        else
567          return super.addChild(name);
568      }
569
570      public PermissionJustificationComponent copy() {
571        PermissionJustificationComponent dst = new PermissionJustificationComponent();
572        copyValues(dst);
573        return dst;
574      }
575
576      public void copyValues(PermissionJustificationComponent dst) {
577        super.copyValues(dst);
578        if (basis != null) {
579          dst.basis = new ArrayList<CodeableConcept>();
580          for (CodeableConcept i : basis)
581            dst.basis.add(i.copy());
582        };
583        if (evidence != null) {
584          dst.evidence = new ArrayList<Reference>();
585          for (Reference i : evidence)
586            dst.evidence.add(i.copy());
587        };
588      }
589
590      @Override
591      public boolean equalsDeep(Base other_) {
592        if (!super.equalsDeep(other_))
593          return false;
594        if (!(other_ instanceof PermissionJustificationComponent))
595          return false;
596        PermissionJustificationComponent o = (PermissionJustificationComponent) other_;
597        return compareDeep(basis, o.basis, true) && compareDeep(evidence, o.evidence, true);
598      }
599
600      @Override
601      public boolean equalsShallow(Base other_) {
602        if (!super.equalsShallow(other_))
603          return false;
604        if (!(other_ instanceof PermissionJustificationComponent))
605          return false;
606        PermissionJustificationComponent o = (PermissionJustificationComponent) other_;
607        return true;
608      }
609
610      public boolean isEmpty() {
611        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(basis, evidence);
612      }
613
614  public String fhirType() {
615    return "Permission.justification";
616
617  }
618
619  }
620
621    @Block()
622    public static class RuleComponent extends BackboneElement implements IBaseBackboneElement {
623        /**
624         * deny | permit.
625         */
626        @Child(name = "type", type = {CodeType.class}, order=1, min=0, max=1, modifier=true, summary=true)
627        @Description(shortDefinition="deny | permit", formalDefinition="deny | permit." )
628        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/consent-provision-type")
629        protected Enumeration<ConsentProvisionType> type;
630
631        /**
632         * A description or definition of which activities are allowed to be done on the data.
633         */
634        @Child(name = "data", type = {}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
635        @Description(shortDefinition="The selection criteria to identify data that is within scope of this provision", formalDefinition="A description or definition of which activities are allowed to be done on the data." )
636        protected List<RuleDataComponent> data;
637
638        /**
639         * A description or definition of which activities are allowed to be done on the data.
640         */
641        @Child(name = "activity", type = {}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
642        @Description(shortDefinition="A description or definition of which activities are allowed to be done on the data", formalDefinition="A description or definition of which activities are allowed to be done on the data." )
643        protected List<RuleActivityComponent> activity;
644
645        /**
646         * What limits apply to the use of the data.
647         */
648        @Child(name = "limit", type = {CodeableConcept.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
649        @Description(shortDefinition="What limits apply to the use of the data", formalDefinition="What limits apply to the use of the data." )
650        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/security-label-event-examples")
651        protected List<CodeableConcept> limit;
652
653        private static final long serialVersionUID = 1376717588L;
654
655    /**
656     * Constructor
657     */
658      public RuleComponent() {
659        super();
660      }
661
662        /**
663         * @return {@link #type} (deny | permit.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
664         */
665        public Enumeration<ConsentProvisionType> getTypeElement() { 
666          if (this.type == null)
667            if (Configuration.errorOnAutoCreate())
668              throw new Error("Attempt to auto-create RuleComponent.type");
669            else if (Configuration.doAutoCreate())
670              this.type = new Enumeration<ConsentProvisionType>(new ConsentProvisionTypeEnumFactory()); // bb
671          return this.type;
672        }
673
674        public boolean hasTypeElement() { 
675          return this.type != null && !this.type.isEmpty();
676        }
677
678        public boolean hasType() { 
679          return this.type != null && !this.type.isEmpty();
680        }
681
682        /**
683         * @param value {@link #type} (deny | permit.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
684         */
685        public RuleComponent setTypeElement(Enumeration<ConsentProvisionType> value) { 
686          this.type = value;
687          return this;
688        }
689
690        /**
691         * @return deny | permit.
692         */
693        public ConsentProvisionType getType() { 
694          return this.type == null ? null : this.type.getValue();
695        }
696
697        /**
698         * @param value deny | permit.
699         */
700        public RuleComponent setType(ConsentProvisionType value) { 
701          if (value == null)
702            this.type = null;
703          else {
704            if (this.type == null)
705              this.type = new Enumeration<ConsentProvisionType>(new ConsentProvisionTypeEnumFactory());
706            this.type.setValue(value);
707          }
708          return this;
709        }
710
711        /**
712         * @return {@link #data} (A description or definition of which activities are allowed to be done on the data.)
713         */
714        public List<RuleDataComponent> getData() { 
715          if (this.data == null)
716            this.data = new ArrayList<RuleDataComponent>();
717          return this.data;
718        }
719
720        /**
721         * @return Returns a reference to <code>this</code> for easy method chaining
722         */
723        public RuleComponent setData(List<RuleDataComponent> theData) { 
724          this.data = theData;
725          return this;
726        }
727
728        public boolean hasData() { 
729          if (this.data == null)
730            return false;
731          for (RuleDataComponent item : this.data)
732            if (!item.isEmpty())
733              return true;
734          return false;
735        }
736
737        public RuleDataComponent addData() { //3
738          RuleDataComponent t = new RuleDataComponent();
739          if (this.data == null)
740            this.data = new ArrayList<RuleDataComponent>();
741          this.data.add(t);
742          return t;
743        }
744
745        public RuleComponent addData(RuleDataComponent t) { //3
746          if (t == null)
747            return this;
748          if (this.data == null)
749            this.data = new ArrayList<RuleDataComponent>();
750          this.data.add(t);
751          return this;
752        }
753
754        /**
755         * @return The first repetition of repeating field {@link #data}, creating it if it does not already exist {3}
756         */
757        public RuleDataComponent getDataFirstRep() { 
758          if (getData().isEmpty()) {
759            addData();
760          }
761          return getData().get(0);
762        }
763
764        /**
765         * @return {@link #activity} (A description or definition of which activities are allowed to be done on the data.)
766         */
767        public List<RuleActivityComponent> getActivity() { 
768          if (this.activity == null)
769            this.activity = new ArrayList<RuleActivityComponent>();
770          return this.activity;
771        }
772
773        /**
774         * @return Returns a reference to <code>this</code> for easy method chaining
775         */
776        public RuleComponent setActivity(List<RuleActivityComponent> theActivity) { 
777          this.activity = theActivity;
778          return this;
779        }
780
781        public boolean hasActivity() { 
782          if (this.activity == null)
783            return false;
784          for (RuleActivityComponent item : this.activity)
785            if (!item.isEmpty())
786              return true;
787          return false;
788        }
789
790        public RuleActivityComponent addActivity() { //3
791          RuleActivityComponent t = new RuleActivityComponent();
792          if (this.activity == null)
793            this.activity = new ArrayList<RuleActivityComponent>();
794          this.activity.add(t);
795          return t;
796        }
797
798        public RuleComponent addActivity(RuleActivityComponent t) { //3
799          if (t == null)
800            return this;
801          if (this.activity == null)
802            this.activity = new ArrayList<RuleActivityComponent>();
803          this.activity.add(t);
804          return this;
805        }
806
807        /**
808         * @return The first repetition of repeating field {@link #activity}, creating it if it does not already exist {3}
809         */
810        public RuleActivityComponent getActivityFirstRep() { 
811          if (getActivity().isEmpty()) {
812            addActivity();
813          }
814          return getActivity().get(0);
815        }
816
817        /**
818         * @return {@link #limit} (What limits apply to the use of the data.)
819         */
820        public List<CodeableConcept> getLimit() { 
821          if (this.limit == null)
822            this.limit = new ArrayList<CodeableConcept>();
823          return this.limit;
824        }
825
826        /**
827         * @return Returns a reference to <code>this</code> for easy method chaining
828         */
829        public RuleComponent setLimit(List<CodeableConcept> theLimit) { 
830          this.limit = theLimit;
831          return this;
832        }
833
834        public boolean hasLimit() { 
835          if (this.limit == null)
836            return false;
837          for (CodeableConcept item : this.limit)
838            if (!item.isEmpty())
839              return true;
840          return false;
841        }
842
843        public CodeableConcept addLimit() { //3
844          CodeableConcept t = new CodeableConcept();
845          if (this.limit == null)
846            this.limit = new ArrayList<CodeableConcept>();
847          this.limit.add(t);
848          return t;
849        }
850
851        public RuleComponent addLimit(CodeableConcept t) { //3
852          if (t == null)
853            return this;
854          if (this.limit == null)
855            this.limit = new ArrayList<CodeableConcept>();
856          this.limit.add(t);
857          return this;
858        }
859
860        /**
861         * @return The first repetition of repeating field {@link #limit}, creating it if it does not already exist {3}
862         */
863        public CodeableConcept getLimitFirstRep() { 
864          if (getLimit().isEmpty()) {
865            addLimit();
866          }
867          return getLimit().get(0);
868        }
869
870        protected void listChildren(List<Property> children) {
871          super.listChildren(children);
872          children.add(new Property("type", "code", "deny | permit.", 0, 1, type));
873          children.add(new Property("data", "", "A description or definition of which activities are allowed to be done on the data.", 0, java.lang.Integer.MAX_VALUE, data));
874          children.add(new Property("activity", "", "A description or definition of which activities are allowed to be done on the data.", 0, java.lang.Integer.MAX_VALUE, activity));
875          children.add(new Property("limit", "CodeableConcept", "What limits apply to the use of the data.", 0, java.lang.Integer.MAX_VALUE, limit));
876        }
877
878        @Override
879        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
880          switch (_hash) {
881          case 3575610: /*type*/  return new Property("type", "code", "deny | permit.", 0, 1, type);
882          case 3076010: /*data*/  return new Property("data", "", "A description or definition of which activities are allowed to be done on the data.", 0, java.lang.Integer.MAX_VALUE, data);
883          case -1655966961: /*activity*/  return new Property("activity", "", "A description or definition of which activities are allowed to be done on the data.", 0, java.lang.Integer.MAX_VALUE, activity);
884          case 102976443: /*limit*/  return new Property("limit", "CodeableConcept", "What limits apply to the use of the data.", 0, java.lang.Integer.MAX_VALUE, limit);
885          default: return super.getNamedProperty(_hash, _name, _checkValid);
886          }
887
888        }
889
890      @Override
891      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
892        switch (hash) {
893        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // Enumeration<ConsentProvisionType>
894        case 3076010: /*data*/ return this.data == null ? new Base[0] : this.data.toArray(new Base[this.data.size()]); // RuleDataComponent
895        case -1655966961: /*activity*/ return this.activity == null ? new Base[0] : this.activity.toArray(new Base[this.activity.size()]); // RuleActivityComponent
896        case 102976443: /*limit*/ return this.limit == null ? new Base[0] : this.limit.toArray(new Base[this.limit.size()]); // CodeableConcept
897        default: return super.getProperty(hash, name, checkValid);
898        }
899
900      }
901
902      @Override
903      public Base setProperty(int hash, String name, Base value) throws FHIRException {
904        switch (hash) {
905        case 3575610: // type
906          value = new ConsentProvisionTypeEnumFactory().fromType(TypeConvertor.castToCode(value));
907          this.type = (Enumeration) value; // Enumeration<ConsentProvisionType>
908          return value;
909        case 3076010: // data
910          this.getData().add((RuleDataComponent) value); // RuleDataComponent
911          return value;
912        case -1655966961: // activity
913          this.getActivity().add((RuleActivityComponent) value); // RuleActivityComponent
914          return value;
915        case 102976443: // limit
916          this.getLimit().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
917          return value;
918        default: return super.setProperty(hash, name, value);
919        }
920
921      }
922
923      @Override
924      public Base setProperty(String name, Base value) throws FHIRException {
925        if (name.equals("type")) {
926          value = new ConsentProvisionTypeEnumFactory().fromType(TypeConvertor.castToCode(value));
927          this.type = (Enumeration) value; // Enumeration<ConsentProvisionType>
928        } else if (name.equals("data")) {
929          this.getData().add((RuleDataComponent) value);
930        } else if (name.equals("activity")) {
931          this.getActivity().add((RuleActivityComponent) value);
932        } else if (name.equals("limit")) {
933          this.getLimit().add(TypeConvertor.castToCodeableConcept(value));
934        } else
935          return super.setProperty(name, value);
936        return value;
937      }
938
939  @Override
940  public void removeChild(String name, Base value) throws FHIRException {
941        if (name.equals("type")) {
942          value = new ConsentProvisionTypeEnumFactory().fromType(TypeConvertor.castToCode(value));
943          this.type = (Enumeration) value; // Enumeration<ConsentProvisionType>
944        } else if (name.equals("data")) {
945          this.getData().remove((RuleDataComponent) value);
946        } else if (name.equals("activity")) {
947          this.getActivity().remove((RuleActivityComponent) value);
948        } else if (name.equals("limit")) {
949          this.getLimit().remove(value);
950        } else
951          super.removeChild(name, value);
952        
953      }
954
955      @Override
956      public Base makeProperty(int hash, String name) throws FHIRException {
957        switch (hash) {
958        case 3575610:  return getTypeElement();
959        case 3076010:  return addData(); 
960        case -1655966961:  return addActivity(); 
961        case 102976443:  return addLimit(); 
962        default: return super.makeProperty(hash, name);
963        }
964
965      }
966
967      @Override
968      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
969        switch (hash) {
970        case 3575610: /*type*/ return new String[] {"code"};
971        case 3076010: /*data*/ return new String[] {};
972        case -1655966961: /*activity*/ return new String[] {};
973        case 102976443: /*limit*/ return new String[] {"CodeableConcept"};
974        default: return super.getTypesForProperty(hash, name);
975        }
976
977      }
978
979      @Override
980      public Base addChild(String name) throws FHIRException {
981        if (name.equals("type")) {
982          throw new FHIRException("Cannot call addChild on a singleton property Permission.rule.type");
983        }
984        else if (name.equals("data")) {
985          return addData();
986        }
987        else if (name.equals("activity")) {
988          return addActivity();
989        }
990        else if (name.equals("limit")) {
991          return addLimit();
992        }
993        else
994          return super.addChild(name);
995      }
996
997      public RuleComponent copy() {
998        RuleComponent dst = new RuleComponent();
999        copyValues(dst);
1000        return dst;
1001      }
1002
1003      public void copyValues(RuleComponent dst) {
1004        super.copyValues(dst);
1005        dst.type = type == null ? null : type.copy();
1006        if (data != null) {
1007          dst.data = new ArrayList<RuleDataComponent>();
1008          for (RuleDataComponent i : data)
1009            dst.data.add(i.copy());
1010        };
1011        if (activity != null) {
1012          dst.activity = new ArrayList<RuleActivityComponent>();
1013          for (RuleActivityComponent i : activity)
1014            dst.activity.add(i.copy());
1015        };
1016        if (limit != null) {
1017          dst.limit = new ArrayList<CodeableConcept>();
1018          for (CodeableConcept i : limit)
1019            dst.limit.add(i.copy());
1020        };
1021      }
1022
1023      @Override
1024      public boolean equalsDeep(Base other_) {
1025        if (!super.equalsDeep(other_))
1026          return false;
1027        if (!(other_ instanceof RuleComponent))
1028          return false;
1029        RuleComponent o = (RuleComponent) other_;
1030        return compareDeep(type, o.type, true) && compareDeep(data, o.data, true) && compareDeep(activity, o.activity, true)
1031           && compareDeep(limit, o.limit, true);
1032      }
1033
1034      @Override
1035      public boolean equalsShallow(Base other_) {
1036        if (!super.equalsShallow(other_))
1037          return false;
1038        if (!(other_ instanceof RuleComponent))
1039          return false;
1040        RuleComponent o = (RuleComponent) other_;
1041        return compareValues(type, o.type, true);
1042      }
1043
1044      public boolean isEmpty() {
1045        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, data, activity, limit
1046          );
1047      }
1048
1049  public String fhirType() {
1050    return "Permission.rule";
1051
1052  }
1053
1054  }
1055
1056    @Block()
1057    public static class RuleDataComponent extends BackboneElement implements IBaseBackboneElement {
1058        /**
1059         * Explicit FHIR Resource references.
1060         */
1061        @Child(name = "resource", type = {}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1062        @Description(shortDefinition="Explicit FHIR Resource references", formalDefinition="Explicit FHIR Resource references." )
1063        protected List<RuleDataResourceComponent> resource;
1064
1065        /**
1066         * The data in scope are those with the given codes present in that data .meta.security element.
1067         */
1068        @Child(name = "security", type = {Coding.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1069        @Description(shortDefinition="Security tag code on .meta.security", formalDefinition="The data in scope are those with the given codes present in that data .meta.security element." )
1070        protected List<Coding> security;
1071
1072        /**
1073         * Clinical or Operational Relevant period of time that bounds the data controlled by this rule.
1074         */
1075        @Child(name = "period", type = {Period.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1076        @Description(shortDefinition="Timeframe encompasing data create/update", formalDefinition="Clinical or Operational Relevant period of time that bounds the data controlled by this rule." )
1077        protected List<Period> period;
1078
1079        /**
1080         * Used when other data selection elements are insufficient.
1081         */
1082        @Child(name = "expression", type = {Expression.class}, order=4, min=0, max=1, modifier=false, summary=true)
1083        @Description(shortDefinition="Expression identifying the data", formalDefinition="Used when other data selection elements are insufficient." )
1084        protected Expression expression;
1085
1086        private static final long serialVersionUID = -774403139L;
1087
1088    /**
1089     * Constructor
1090     */
1091      public RuleDataComponent() {
1092        super();
1093      }
1094
1095        /**
1096         * @return {@link #resource} (Explicit FHIR Resource references.)
1097         */
1098        public List<RuleDataResourceComponent> getResource() { 
1099          if (this.resource == null)
1100            this.resource = new ArrayList<RuleDataResourceComponent>();
1101          return this.resource;
1102        }
1103
1104        /**
1105         * @return Returns a reference to <code>this</code> for easy method chaining
1106         */
1107        public RuleDataComponent setResource(List<RuleDataResourceComponent> theResource) { 
1108          this.resource = theResource;
1109          return this;
1110        }
1111
1112        public boolean hasResource() { 
1113          if (this.resource == null)
1114            return false;
1115          for (RuleDataResourceComponent item : this.resource)
1116            if (!item.isEmpty())
1117              return true;
1118          return false;
1119        }
1120
1121        public RuleDataResourceComponent addResource() { //3
1122          RuleDataResourceComponent t = new RuleDataResourceComponent();
1123          if (this.resource == null)
1124            this.resource = new ArrayList<RuleDataResourceComponent>();
1125          this.resource.add(t);
1126          return t;
1127        }
1128
1129        public RuleDataComponent addResource(RuleDataResourceComponent t) { //3
1130          if (t == null)
1131            return this;
1132          if (this.resource == null)
1133            this.resource = new ArrayList<RuleDataResourceComponent>();
1134          this.resource.add(t);
1135          return this;
1136        }
1137
1138        /**
1139         * @return The first repetition of repeating field {@link #resource}, creating it if it does not already exist {3}
1140         */
1141        public RuleDataResourceComponent getResourceFirstRep() { 
1142          if (getResource().isEmpty()) {
1143            addResource();
1144          }
1145          return getResource().get(0);
1146        }
1147
1148        /**
1149         * @return {@link #security} (The data in scope are those with the given codes present in that data .meta.security element.)
1150         */
1151        public List<Coding> getSecurity() { 
1152          if (this.security == null)
1153            this.security = new ArrayList<Coding>();
1154          return this.security;
1155        }
1156
1157        /**
1158         * @return Returns a reference to <code>this</code> for easy method chaining
1159         */
1160        public RuleDataComponent setSecurity(List<Coding> theSecurity) { 
1161          this.security = theSecurity;
1162          return this;
1163        }
1164
1165        public boolean hasSecurity() { 
1166          if (this.security == null)
1167            return false;
1168          for (Coding item : this.security)
1169            if (!item.isEmpty())
1170              return true;
1171          return false;
1172        }
1173
1174        public Coding addSecurity() { //3
1175          Coding t = new Coding();
1176          if (this.security == null)
1177            this.security = new ArrayList<Coding>();
1178          this.security.add(t);
1179          return t;
1180        }
1181
1182        public RuleDataComponent addSecurity(Coding t) { //3
1183          if (t == null)
1184            return this;
1185          if (this.security == null)
1186            this.security = new ArrayList<Coding>();
1187          this.security.add(t);
1188          return this;
1189        }
1190
1191        /**
1192         * @return The first repetition of repeating field {@link #security}, creating it if it does not already exist {3}
1193         */
1194        public Coding getSecurityFirstRep() { 
1195          if (getSecurity().isEmpty()) {
1196            addSecurity();
1197          }
1198          return getSecurity().get(0);
1199        }
1200
1201        /**
1202         * @return {@link #period} (Clinical or Operational Relevant period of time that bounds the data controlled by this rule.)
1203         */
1204        public List<Period> getPeriod() { 
1205          if (this.period == null)
1206            this.period = new ArrayList<Period>();
1207          return this.period;
1208        }
1209
1210        /**
1211         * @return Returns a reference to <code>this</code> for easy method chaining
1212         */
1213        public RuleDataComponent setPeriod(List<Period> thePeriod) { 
1214          this.period = thePeriod;
1215          return this;
1216        }
1217
1218        public boolean hasPeriod() { 
1219          if (this.period == null)
1220            return false;
1221          for (Period item : this.period)
1222            if (!item.isEmpty())
1223              return true;
1224          return false;
1225        }
1226
1227        public Period addPeriod() { //3
1228          Period t = new Period();
1229          if (this.period == null)
1230            this.period = new ArrayList<Period>();
1231          this.period.add(t);
1232          return t;
1233        }
1234
1235        public RuleDataComponent addPeriod(Period t) { //3
1236          if (t == null)
1237            return this;
1238          if (this.period == null)
1239            this.period = new ArrayList<Period>();
1240          this.period.add(t);
1241          return this;
1242        }
1243
1244        /**
1245         * @return The first repetition of repeating field {@link #period}, creating it if it does not already exist {3}
1246         */
1247        public Period getPeriodFirstRep() { 
1248          if (getPeriod().isEmpty()) {
1249            addPeriod();
1250          }
1251          return getPeriod().get(0);
1252        }
1253
1254        /**
1255         * @return {@link #expression} (Used when other data selection elements are insufficient.)
1256         */
1257        public Expression getExpression() { 
1258          if (this.expression == null)
1259            if (Configuration.errorOnAutoCreate())
1260              throw new Error("Attempt to auto-create RuleDataComponent.expression");
1261            else if (Configuration.doAutoCreate())
1262              this.expression = new Expression(); // cc
1263          return this.expression;
1264        }
1265
1266        public boolean hasExpression() { 
1267          return this.expression != null && !this.expression.isEmpty();
1268        }
1269
1270        /**
1271         * @param value {@link #expression} (Used when other data selection elements are insufficient.)
1272         */
1273        public RuleDataComponent setExpression(Expression value) { 
1274          this.expression = value;
1275          return this;
1276        }
1277
1278        protected void listChildren(List<Property> children) {
1279          super.listChildren(children);
1280          children.add(new Property("resource", "", "Explicit FHIR Resource references.", 0, java.lang.Integer.MAX_VALUE, resource));
1281          children.add(new Property("security", "Coding", "The data in scope are those with the given codes present in that data .meta.security element.", 0, java.lang.Integer.MAX_VALUE, security));
1282          children.add(new Property("period", "Period", "Clinical or Operational Relevant period of time that bounds the data controlled by this rule.", 0, java.lang.Integer.MAX_VALUE, period));
1283          children.add(new Property("expression", "Expression", "Used when other data selection elements are insufficient.", 0, 1, expression));
1284        }
1285
1286        @Override
1287        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1288          switch (_hash) {
1289          case -341064690: /*resource*/  return new Property("resource", "", "Explicit FHIR Resource references.", 0, java.lang.Integer.MAX_VALUE, resource);
1290          case 949122880: /*security*/  return new Property("security", "Coding", "The data in scope are those with the given codes present in that data .meta.security element.", 0, java.lang.Integer.MAX_VALUE, security);
1291          case -991726143: /*period*/  return new Property("period", "Period", "Clinical or Operational Relevant period of time that bounds the data controlled by this rule.", 0, java.lang.Integer.MAX_VALUE, period);
1292          case -1795452264: /*expression*/  return new Property("expression", "Expression", "Used when other data selection elements are insufficient.", 0, 1, expression);
1293          default: return super.getNamedProperty(_hash, _name, _checkValid);
1294          }
1295
1296        }
1297
1298      @Override
1299      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1300        switch (hash) {
1301        case -341064690: /*resource*/ return this.resource == null ? new Base[0] : this.resource.toArray(new Base[this.resource.size()]); // RuleDataResourceComponent
1302        case 949122880: /*security*/ return this.security == null ? new Base[0] : this.security.toArray(new Base[this.security.size()]); // Coding
1303        case -991726143: /*period*/ return this.period == null ? new Base[0] : this.period.toArray(new Base[this.period.size()]); // Period
1304        case -1795452264: /*expression*/ return this.expression == null ? new Base[0] : new Base[] {this.expression}; // Expression
1305        default: return super.getProperty(hash, name, checkValid);
1306        }
1307
1308      }
1309
1310      @Override
1311      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1312        switch (hash) {
1313        case -341064690: // resource
1314          this.getResource().add((RuleDataResourceComponent) value); // RuleDataResourceComponent
1315          return value;
1316        case 949122880: // security
1317          this.getSecurity().add(TypeConvertor.castToCoding(value)); // Coding
1318          return value;
1319        case -991726143: // period
1320          this.getPeriod().add(TypeConvertor.castToPeriod(value)); // Period
1321          return value;
1322        case -1795452264: // expression
1323          this.expression = TypeConvertor.castToExpression(value); // Expression
1324          return value;
1325        default: return super.setProperty(hash, name, value);
1326        }
1327
1328      }
1329
1330      @Override
1331      public Base setProperty(String name, Base value) throws FHIRException {
1332        if (name.equals("resource")) {
1333          this.getResource().add((RuleDataResourceComponent) value);
1334        } else if (name.equals("security")) {
1335          this.getSecurity().add(TypeConvertor.castToCoding(value));
1336        } else if (name.equals("period")) {
1337          this.getPeriod().add(TypeConvertor.castToPeriod(value));
1338        } else if (name.equals("expression")) {
1339          this.expression = TypeConvertor.castToExpression(value); // Expression
1340        } else
1341          return super.setProperty(name, value);
1342        return value;
1343      }
1344
1345  @Override
1346  public void removeChild(String name, Base value) throws FHIRException {
1347        if (name.equals("resource")) {
1348          this.getResource().remove((RuleDataResourceComponent) value);
1349        } else if (name.equals("security")) {
1350          this.getSecurity().remove(value);
1351        } else if (name.equals("period")) {
1352          this.getPeriod().remove(value);
1353        } else if (name.equals("expression")) {
1354          this.expression = null;
1355        } else
1356          super.removeChild(name, value);
1357        
1358      }
1359
1360      @Override
1361      public Base makeProperty(int hash, String name) throws FHIRException {
1362        switch (hash) {
1363        case -341064690:  return addResource(); 
1364        case 949122880:  return addSecurity(); 
1365        case -991726143:  return addPeriod(); 
1366        case -1795452264:  return getExpression();
1367        default: return super.makeProperty(hash, name);
1368        }
1369
1370      }
1371
1372      @Override
1373      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1374        switch (hash) {
1375        case -341064690: /*resource*/ return new String[] {};
1376        case 949122880: /*security*/ return new String[] {"Coding"};
1377        case -991726143: /*period*/ return new String[] {"Period"};
1378        case -1795452264: /*expression*/ return new String[] {"Expression"};
1379        default: return super.getTypesForProperty(hash, name);
1380        }
1381
1382      }
1383
1384      @Override
1385      public Base addChild(String name) throws FHIRException {
1386        if (name.equals("resource")) {
1387          return addResource();
1388        }
1389        else if (name.equals("security")) {
1390          return addSecurity();
1391        }
1392        else if (name.equals("period")) {
1393          return addPeriod();
1394        }
1395        else if (name.equals("expression")) {
1396          this.expression = new Expression();
1397          return this.expression;
1398        }
1399        else
1400          return super.addChild(name);
1401      }
1402
1403      public RuleDataComponent copy() {
1404        RuleDataComponent dst = new RuleDataComponent();
1405        copyValues(dst);
1406        return dst;
1407      }
1408
1409      public void copyValues(RuleDataComponent dst) {
1410        super.copyValues(dst);
1411        if (resource != null) {
1412          dst.resource = new ArrayList<RuleDataResourceComponent>();
1413          for (RuleDataResourceComponent i : resource)
1414            dst.resource.add(i.copy());
1415        };
1416        if (security != null) {
1417          dst.security = new ArrayList<Coding>();
1418          for (Coding i : security)
1419            dst.security.add(i.copy());
1420        };
1421        if (period != null) {
1422          dst.period = new ArrayList<Period>();
1423          for (Period i : period)
1424            dst.period.add(i.copy());
1425        };
1426        dst.expression = expression == null ? null : expression.copy();
1427      }
1428
1429      @Override
1430      public boolean equalsDeep(Base other_) {
1431        if (!super.equalsDeep(other_))
1432          return false;
1433        if (!(other_ instanceof RuleDataComponent))
1434          return false;
1435        RuleDataComponent o = (RuleDataComponent) other_;
1436        return compareDeep(resource, o.resource, true) && compareDeep(security, o.security, true) && compareDeep(period, o.period, true)
1437           && compareDeep(expression, o.expression, true);
1438      }
1439
1440      @Override
1441      public boolean equalsShallow(Base other_) {
1442        if (!super.equalsShallow(other_))
1443          return false;
1444        if (!(other_ instanceof RuleDataComponent))
1445          return false;
1446        RuleDataComponent o = (RuleDataComponent) other_;
1447        return true;
1448      }
1449
1450      public boolean isEmpty() {
1451        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(resource, security, period
1452          , expression);
1453      }
1454
1455  public String fhirType() {
1456    return "Permission.rule.data";
1457
1458  }
1459
1460  }
1461
1462    @Block()
1463    public static class RuleDataResourceComponent extends BackboneElement implements IBaseBackboneElement {
1464        /**
1465         * How the resource reference is interpreted when testing consent restrictions.
1466         */
1467        @Child(name = "meaning", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=true)
1468        @Description(shortDefinition="instance | related | dependents | authoredby", formalDefinition="How the resource reference is interpreted when testing consent restrictions." )
1469        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/consent-data-meaning")
1470        protected Enumeration<ConsentDataMeaning> meaning;
1471
1472        /**
1473         * A reference to a specific resource that defines which resources are covered by this consent.
1474         */
1475        @Child(name = "reference", type = {Reference.class}, order=2, min=1, max=1, modifier=false, summary=true)
1476        @Description(shortDefinition="The actual data reference", formalDefinition="A reference to a specific resource that defines which resources are covered by this consent." )
1477        protected Reference reference;
1478
1479        private static final long serialVersionUID = 1735979153L;
1480
1481    /**
1482     * Constructor
1483     */
1484      public RuleDataResourceComponent() {
1485        super();
1486      }
1487
1488    /**
1489     * Constructor
1490     */
1491      public RuleDataResourceComponent(ConsentDataMeaning meaning, Reference reference) {
1492        super();
1493        this.setMeaning(meaning);
1494        this.setReference(reference);
1495      }
1496
1497        /**
1498         * @return {@link #meaning} (How the resource reference is interpreted when testing consent restrictions.). This is the underlying object with id, value and extensions. The accessor "getMeaning" gives direct access to the value
1499         */
1500        public Enumeration<ConsentDataMeaning> getMeaningElement() { 
1501          if (this.meaning == null)
1502            if (Configuration.errorOnAutoCreate())
1503              throw new Error("Attempt to auto-create RuleDataResourceComponent.meaning");
1504            else if (Configuration.doAutoCreate())
1505              this.meaning = new Enumeration<ConsentDataMeaning>(new ConsentDataMeaningEnumFactory()); // bb
1506          return this.meaning;
1507        }
1508
1509        public boolean hasMeaningElement() { 
1510          return this.meaning != null && !this.meaning.isEmpty();
1511        }
1512
1513        public boolean hasMeaning() { 
1514          return this.meaning != null && !this.meaning.isEmpty();
1515        }
1516
1517        /**
1518         * @param value {@link #meaning} (How the resource reference is interpreted when testing consent restrictions.). This is the underlying object with id, value and extensions. The accessor "getMeaning" gives direct access to the value
1519         */
1520        public RuleDataResourceComponent setMeaningElement(Enumeration<ConsentDataMeaning> value) { 
1521          this.meaning = value;
1522          return this;
1523        }
1524
1525        /**
1526         * @return How the resource reference is interpreted when testing consent restrictions.
1527         */
1528        public ConsentDataMeaning getMeaning() { 
1529          return this.meaning == null ? null : this.meaning.getValue();
1530        }
1531
1532        /**
1533         * @param value How the resource reference is interpreted when testing consent restrictions.
1534         */
1535        public RuleDataResourceComponent setMeaning(ConsentDataMeaning value) { 
1536            if (this.meaning == null)
1537              this.meaning = new Enumeration<ConsentDataMeaning>(new ConsentDataMeaningEnumFactory());
1538            this.meaning.setValue(value);
1539          return this;
1540        }
1541
1542        /**
1543         * @return {@link #reference} (A reference to a specific resource that defines which resources are covered by this consent.)
1544         */
1545        public Reference getReference() { 
1546          if (this.reference == null)
1547            if (Configuration.errorOnAutoCreate())
1548              throw new Error("Attempt to auto-create RuleDataResourceComponent.reference");
1549            else if (Configuration.doAutoCreate())
1550              this.reference = new Reference(); // cc
1551          return this.reference;
1552        }
1553
1554        public boolean hasReference() { 
1555          return this.reference != null && !this.reference.isEmpty();
1556        }
1557
1558        /**
1559         * @param value {@link #reference} (A reference to a specific resource that defines which resources are covered by this consent.)
1560         */
1561        public RuleDataResourceComponent setReference(Reference value) { 
1562          this.reference = value;
1563          return this;
1564        }
1565
1566        protected void listChildren(List<Property> children) {
1567          super.listChildren(children);
1568          children.add(new Property("meaning", "code", "How the resource reference is interpreted when testing consent restrictions.", 0, 1, meaning));
1569          children.add(new Property("reference", "Reference(Any)", "A reference to a specific resource that defines which resources are covered by this consent.", 0, 1, reference));
1570        }
1571
1572        @Override
1573        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1574          switch (_hash) {
1575          case 938160637: /*meaning*/  return new Property("meaning", "code", "How the resource reference is interpreted when testing consent restrictions.", 0, 1, meaning);
1576          case -925155509: /*reference*/  return new Property("reference", "Reference(Any)", "A reference to a specific resource that defines which resources are covered by this consent.", 0, 1, reference);
1577          default: return super.getNamedProperty(_hash, _name, _checkValid);
1578          }
1579
1580        }
1581
1582      @Override
1583      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1584        switch (hash) {
1585        case 938160637: /*meaning*/ return this.meaning == null ? new Base[0] : new Base[] {this.meaning}; // Enumeration<ConsentDataMeaning>
1586        case -925155509: /*reference*/ return this.reference == null ? new Base[0] : new Base[] {this.reference}; // Reference
1587        default: return super.getProperty(hash, name, checkValid);
1588        }
1589
1590      }
1591
1592      @Override
1593      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1594        switch (hash) {
1595        case 938160637: // meaning
1596          value = new ConsentDataMeaningEnumFactory().fromType(TypeConvertor.castToCode(value));
1597          this.meaning = (Enumeration) value; // Enumeration<ConsentDataMeaning>
1598          return value;
1599        case -925155509: // reference
1600          this.reference = TypeConvertor.castToReference(value); // Reference
1601          return value;
1602        default: return super.setProperty(hash, name, value);
1603        }
1604
1605      }
1606
1607      @Override
1608      public Base setProperty(String name, Base value) throws FHIRException {
1609        if (name.equals("meaning")) {
1610          value = new ConsentDataMeaningEnumFactory().fromType(TypeConvertor.castToCode(value));
1611          this.meaning = (Enumeration) value; // Enumeration<ConsentDataMeaning>
1612        } else if (name.equals("reference")) {
1613          this.reference = TypeConvertor.castToReference(value); // Reference
1614        } else
1615          return super.setProperty(name, value);
1616        return value;
1617      }
1618
1619  @Override
1620  public void removeChild(String name, Base value) throws FHIRException {
1621        if (name.equals("meaning")) {
1622          value = new ConsentDataMeaningEnumFactory().fromType(TypeConvertor.castToCode(value));
1623          this.meaning = (Enumeration) value; // Enumeration<ConsentDataMeaning>
1624        } else if (name.equals("reference")) {
1625          this.reference = null;
1626        } else
1627          super.removeChild(name, value);
1628        
1629      }
1630
1631      @Override
1632      public Base makeProperty(int hash, String name) throws FHIRException {
1633        switch (hash) {
1634        case 938160637:  return getMeaningElement();
1635        case -925155509:  return getReference();
1636        default: return super.makeProperty(hash, name);
1637        }
1638
1639      }
1640
1641      @Override
1642      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1643        switch (hash) {
1644        case 938160637: /*meaning*/ return new String[] {"code"};
1645        case -925155509: /*reference*/ return new String[] {"Reference"};
1646        default: return super.getTypesForProperty(hash, name);
1647        }
1648
1649      }
1650
1651      @Override
1652      public Base addChild(String name) throws FHIRException {
1653        if (name.equals("meaning")) {
1654          throw new FHIRException("Cannot call addChild on a singleton property Permission.rule.data.resource.meaning");
1655        }
1656        else if (name.equals("reference")) {
1657          this.reference = new Reference();
1658          return this.reference;
1659        }
1660        else
1661          return super.addChild(name);
1662      }
1663
1664      public RuleDataResourceComponent copy() {
1665        RuleDataResourceComponent dst = new RuleDataResourceComponent();
1666        copyValues(dst);
1667        return dst;
1668      }
1669
1670      public void copyValues(RuleDataResourceComponent dst) {
1671        super.copyValues(dst);
1672        dst.meaning = meaning == null ? null : meaning.copy();
1673        dst.reference = reference == null ? null : reference.copy();
1674      }
1675
1676      @Override
1677      public boolean equalsDeep(Base other_) {
1678        if (!super.equalsDeep(other_))
1679          return false;
1680        if (!(other_ instanceof RuleDataResourceComponent))
1681          return false;
1682        RuleDataResourceComponent o = (RuleDataResourceComponent) other_;
1683        return compareDeep(meaning, o.meaning, true) && compareDeep(reference, o.reference, true);
1684      }
1685
1686      @Override
1687      public boolean equalsShallow(Base other_) {
1688        if (!super.equalsShallow(other_))
1689          return false;
1690        if (!(other_ instanceof RuleDataResourceComponent))
1691          return false;
1692        RuleDataResourceComponent o = (RuleDataResourceComponent) other_;
1693        return compareValues(meaning, o.meaning, true);
1694      }
1695
1696      public boolean isEmpty() {
1697        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(meaning, reference);
1698      }
1699
1700  public String fhirType() {
1701    return "Permission.rule.data.resource";
1702
1703  }
1704
1705  }
1706
1707    @Block()
1708    public static class RuleActivityComponent extends BackboneElement implements IBaseBackboneElement {
1709        /**
1710         * The actor(s) authorized for the defined activity.
1711         */
1712        @Child(name = "actor", type = {Device.class, Group.class, CareTeam.class, Organization.class, Patient.class, Practitioner.class, RelatedPerson.class, PractitionerRole.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1713        @Description(shortDefinition="Authorized actor(s)", formalDefinition="The actor(s) authorized for the defined activity." )
1714        protected List<Reference> actor;
1715
1716        /**
1717         * Actions controlled by this Rule.
1718         */
1719        @Child(name = "action", type = {CodeableConcept.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1720        @Description(shortDefinition="Actions controlled by this rule", formalDefinition="Actions controlled by this Rule." )
1721        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/consent-action")
1722        protected List<CodeableConcept> action;
1723
1724        /**
1725         * The purpose for which the permission is given.
1726         */
1727        @Child(name = "purpose", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1728        @Description(shortDefinition="The purpose for which the permission is given", formalDefinition="The purpose for which the permission is given." )
1729        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v3-PurposeOfUse")
1730        protected List<CodeableConcept> purpose;
1731
1732        private static final long serialVersionUID = 1403721720L;
1733
1734    /**
1735     * Constructor
1736     */
1737      public RuleActivityComponent() {
1738        super();
1739      }
1740
1741        /**
1742         * @return {@link #actor} (The actor(s) authorized for the defined activity.)
1743         */
1744        public List<Reference> getActor() { 
1745          if (this.actor == null)
1746            this.actor = new ArrayList<Reference>();
1747          return this.actor;
1748        }
1749
1750        /**
1751         * @return Returns a reference to <code>this</code> for easy method chaining
1752         */
1753        public RuleActivityComponent setActor(List<Reference> theActor) { 
1754          this.actor = theActor;
1755          return this;
1756        }
1757
1758        public boolean hasActor() { 
1759          if (this.actor == null)
1760            return false;
1761          for (Reference item : this.actor)
1762            if (!item.isEmpty())
1763              return true;
1764          return false;
1765        }
1766
1767        public Reference addActor() { //3
1768          Reference t = new Reference();
1769          if (this.actor == null)
1770            this.actor = new ArrayList<Reference>();
1771          this.actor.add(t);
1772          return t;
1773        }
1774
1775        public RuleActivityComponent addActor(Reference t) { //3
1776          if (t == null)
1777            return this;
1778          if (this.actor == null)
1779            this.actor = new ArrayList<Reference>();
1780          this.actor.add(t);
1781          return this;
1782        }
1783
1784        /**
1785         * @return The first repetition of repeating field {@link #actor}, creating it if it does not already exist {3}
1786         */
1787        public Reference getActorFirstRep() { 
1788          if (getActor().isEmpty()) {
1789            addActor();
1790          }
1791          return getActor().get(0);
1792        }
1793
1794        /**
1795         * @return {@link #action} (Actions controlled by this Rule.)
1796         */
1797        public List<CodeableConcept> getAction() { 
1798          if (this.action == null)
1799            this.action = new ArrayList<CodeableConcept>();
1800          return this.action;
1801        }
1802
1803        /**
1804         * @return Returns a reference to <code>this</code> for easy method chaining
1805         */
1806        public RuleActivityComponent setAction(List<CodeableConcept> theAction) { 
1807          this.action = theAction;
1808          return this;
1809        }
1810
1811        public boolean hasAction() { 
1812          if (this.action == null)
1813            return false;
1814          for (CodeableConcept item : this.action)
1815            if (!item.isEmpty())
1816              return true;
1817          return false;
1818        }
1819
1820        public CodeableConcept addAction() { //3
1821          CodeableConcept t = new CodeableConcept();
1822          if (this.action == null)
1823            this.action = new ArrayList<CodeableConcept>();
1824          this.action.add(t);
1825          return t;
1826        }
1827
1828        public RuleActivityComponent addAction(CodeableConcept t) { //3
1829          if (t == null)
1830            return this;
1831          if (this.action == null)
1832            this.action = new ArrayList<CodeableConcept>();
1833          this.action.add(t);
1834          return this;
1835        }
1836
1837        /**
1838         * @return The first repetition of repeating field {@link #action}, creating it if it does not already exist {3}
1839         */
1840        public CodeableConcept getActionFirstRep() { 
1841          if (getAction().isEmpty()) {
1842            addAction();
1843          }
1844          return getAction().get(0);
1845        }
1846
1847        /**
1848         * @return {@link #purpose} (The purpose for which the permission is given.)
1849         */
1850        public List<CodeableConcept> getPurpose() { 
1851          if (this.purpose == null)
1852            this.purpose = new ArrayList<CodeableConcept>();
1853          return this.purpose;
1854        }
1855
1856        /**
1857         * @return Returns a reference to <code>this</code> for easy method chaining
1858         */
1859        public RuleActivityComponent setPurpose(List<CodeableConcept> thePurpose) { 
1860          this.purpose = thePurpose;
1861          return this;
1862        }
1863
1864        public boolean hasPurpose() { 
1865          if (this.purpose == null)
1866            return false;
1867          for (CodeableConcept item : this.purpose)
1868            if (!item.isEmpty())
1869              return true;
1870          return false;
1871        }
1872
1873        public CodeableConcept addPurpose() { //3
1874          CodeableConcept t = new CodeableConcept();
1875          if (this.purpose == null)
1876            this.purpose = new ArrayList<CodeableConcept>();
1877          this.purpose.add(t);
1878          return t;
1879        }
1880
1881        public RuleActivityComponent addPurpose(CodeableConcept t) { //3
1882          if (t == null)
1883            return this;
1884          if (this.purpose == null)
1885            this.purpose = new ArrayList<CodeableConcept>();
1886          this.purpose.add(t);
1887          return this;
1888        }
1889
1890        /**
1891         * @return The first repetition of repeating field {@link #purpose}, creating it if it does not already exist {3}
1892         */
1893        public CodeableConcept getPurposeFirstRep() { 
1894          if (getPurpose().isEmpty()) {
1895            addPurpose();
1896          }
1897          return getPurpose().get(0);
1898        }
1899
1900        protected void listChildren(List<Property> children) {
1901          super.listChildren(children);
1902          children.add(new Property("actor", "Reference(Device|Group|CareTeam|Organization|Patient|Practitioner|RelatedPerson|PractitionerRole)", "The actor(s) authorized for the defined activity.", 0, java.lang.Integer.MAX_VALUE, actor));
1903          children.add(new Property("action", "CodeableConcept", "Actions controlled by this Rule.", 0, java.lang.Integer.MAX_VALUE, action));
1904          children.add(new Property("purpose", "CodeableConcept", "The purpose for which the permission is given.", 0, java.lang.Integer.MAX_VALUE, purpose));
1905        }
1906
1907        @Override
1908        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1909          switch (_hash) {
1910          case 92645877: /*actor*/  return new Property("actor", "Reference(Device|Group|CareTeam|Organization|Patient|Practitioner|RelatedPerson|PractitionerRole)", "The actor(s) authorized for the defined activity.", 0, java.lang.Integer.MAX_VALUE, actor);
1911          case -1422950858: /*action*/  return new Property("action", "CodeableConcept", "Actions controlled by this Rule.", 0, java.lang.Integer.MAX_VALUE, action);
1912          case -220463842: /*purpose*/  return new Property("purpose", "CodeableConcept", "The purpose for which the permission is given.", 0, java.lang.Integer.MAX_VALUE, purpose);
1913          default: return super.getNamedProperty(_hash, _name, _checkValid);
1914          }
1915
1916        }
1917
1918      @Override
1919      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1920        switch (hash) {
1921        case 92645877: /*actor*/ return this.actor == null ? new Base[0] : this.actor.toArray(new Base[this.actor.size()]); // Reference
1922        case -1422950858: /*action*/ return this.action == null ? new Base[0] : this.action.toArray(new Base[this.action.size()]); // CodeableConcept
1923        case -220463842: /*purpose*/ return this.purpose == null ? new Base[0] : this.purpose.toArray(new Base[this.purpose.size()]); // CodeableConcept
1924        default: return super.getProperty(hash, name, checkValid);
1925        }
1926
1927      }
1928
1929      @Override
1930      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1931        switch (hash) {
1932        case 92645877: // actor
1933          this.getActor().add(TypeConvertor.castToReference(value)); // Reference
1934          return value;
1935        case -1422950858: // action
1936          this.getAction().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
1937          return value;
1938        case -220463842: // purpose
1939          this.getPurpose().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
1940          return value;
1941        default: return super.setProperty(hash, name, value);
1942        }
1943
1944      }
1945
1946      @Override
1947      public Base setProperty(String name, Base value) throws FHIRException {
1948        if (name.equals("actor")) {
1949          this.getActor().add(TypeConvertor.castToReference(value));
1950        } else if (name.equals("action")) {
1951          this.getAction().add(TypeConvertor.castToCodeableConcept(value));
1952        } else if (name.equals("purpose")) {
1953          this.getPurpose().add(TypeConvertor.castToCodeableConcept(value));
1954        } else
1955          return super.setProperty(name, value);
1956        return value;
1957      }
1958
1959  @Override
1960  public void removeChild(String name, Base value) throws FHIRException {
1961        if (name.equals("actor")) {
1962          this.getActor().remove(value);
1963        } else if (name.equals("action")) {
1964          this.getAction().remove(value);
1965        } else if (name.equals("purpose")) {
1966          this.getPurpose().remove(value);
1967        } else
1968          super.removeChild(name, value);
1969        
1970      }
1971
1972      @Override
1973      public Base makeProperty(int hash, String name) throws FHIRException {
1974        switch (hash) {
1975        case 92645877:  return addActor(); 
1976        case -1422950858:  return addAction(); 
1977        case -220463842:  return addPurpose(); 
1978        default: return super.makeProperty(hash, name);
1979        }
1980
1981      }
1982
1983      @Override
1984      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1985        switch (hash) {
1986        case 92645877: /*actor*/ return new String[] {"Reference"};
1987        case -1422950858: /*action*/ return new String[] {"CodeableConcept"};
1988        case -220463842: /*purpose*/ return new String[] {"CodeableConcept"};
1989        default: return super.getTypesForProperty(hash, name);
1990        }
1991
1992      }
1993
1994      @Override
1995      public Base addChild(String name) throws FHIRException {
1996        if (name.equals("actor")) {
1997          return addActor();
1998        }
1999        else if (name.equals("action")) {
2000          return addAction();
2001        }
2002        else if (name.equals("purpose")) {
2003          return addPurpose();
2004        }
2005        else
2006          return super.addChild(name);
2007      }
2008
2009      public RuleActivityComponent copy() {
2010        RuleActivityComponent dst = new RuleActivityComponent();
2011        copyValues(dst);
2012        return dst;
2013      }
2014
2015      public void copyValues(RuleActivityComponent dst) {
2016        super.copyValues(dst);
2017        if (actor != null) {
2018          dst.actor = new ArrayList<Reference>();
2019          for (Reference i : actor)
2020            dst.actor.add(i.copy());
2021        };
2022        if (action != null) {
2023          dst.action = new ArrayList<CodeableConcept>();
2024          for (CodeableConcept i : action)
2025            dst.action.add(i.copy());
2026        };
2027        if (purpose != null) {
2028          dst.purpose = new ArrayList<CodeableConcept>();
2029          for (CodeableConcept i : purpose)
2030            dst.purpose.add(i.copy());
2031        };
2032      }
2033
2034      @Override
2035      public boolean equalsDeep(Base other_) {
2036        if (!super.equalsDeep(other_))
2037          return false;
2038        if (!(other_ instanceof RuleActivityComponent))
2039          return false;
2040        RuleActivityComponent o = (RuleActivityComponent) other_;
2041        return compareDeep(actor, o.actor, true) && compareDeep(action, o.action, true) && compareDeep(purpose, o.purpose, true)
2042          ;
2043      }
2044
2045      @Override
2046      public boolean equalsShallow(Base other_) {
2047        if (!super.equalsShallow(other_))
2048          return false;
2049        if (!(other_ instanceof RuleActivityComponent))
2050          return false;
2051        RuleActivityComponent o = (RuleActivityComponent) other_;
2052        return true;
2053      }
2054
2055      public boolean isEmpty() {
2056        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(actor, action, purpose);
2057      }
2058
2059  public String fhirType() {
2060    return "Permission.rule.activity";
2061
2062  }
2063
2064  }
2065
2066    /**
2067     * Status.
2068     */
2069    @Child(name = "status", type = {CodeType.class}, order=0, min=1, max=1, modifier=false, summary=true)
2070    @Description(shortDefinition="active | entered-in-error | draft | rejected", formalDefinition="Status." )
2071    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/permission-status")
2072    protected Enumeration<PermissionStatus> status;
2073
2074    /**
2075     * The person or entity that asserts the permission.
2076     */
2077    @Child(name = "asserter", type = {Practitioner.class, PractitionerRole.class, Organization.class, CareTeam.class, Patient.class, RelatedPerson.class, HealthcareService.class}, order=1, min=0, max=1, modifier=false, summary=true)
2078    @Description(shortDefinition="The person or entity that asserts the permission", formalDefinition="The person or entity that asserts the permission." )
2079    protected Reference asserter;
2080
2081    /**
2082     * The date that permission was asserted.
2083     */
2084    @Child(name = "date", type = {DateTimeType.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2085    @Description(shortDefinition="The date that permission was asserted", formalDefinition="The date that permission was asserted." )
2086    protected List<DateTimeType> date;
2087
2088    /**
2089     * The period in which the permission is active.
2090     */
2091    @Child(name = "validity", type = {Period.class}, order=3, min=0, max=1, modifier=false, summary=true)
2092    @Description(shortDefinition="The period in which the permission is active", formalDefinition="The period in which the permission is active." )
2093    protected Period validity;
2094
2095    /**
2096     * The asserted justification for using the data.
2097     */
2098    @Child(name = "justification", type = {}, order=4, min=0, max=1, modifier=false, summary=true)
2099    @Description(shortDefinition="The asserted justification for using the data", formalDefinition="The asserted justification for using the data." )
2100    protected PermissionJustificationComponent justification;
2101
2102    /**
2103     * Defines a procedure for arriving at an access decision given the set of rules.
2104     */
2105    @Child(name = "combining", type = {CodeType.class}, order=5, min=1, max=1, modifier=true, summary=true)
2106    @Description(shortDefinition="deny-overrides | permit-overrides | ordered-deny-overrides | ordered-permit-overrides | deny-unless-permit | permit-unless-deny", formalDefinition="Defines a procedure for arriving at an access decision given the set of rules." )
2107    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/permission-rule-combining")
2108    protected Enumeration<PermissionRuleCombining> combining;
2109
2110    /**
2111     * A set of rules.
2112     */
2113    @Child(name = "rule", type = {}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2114    @Description(shortDefinition="Constraints to the Permission", formalDefinition="A set of rules." )
2115    protected List<RuleComponent> rule;
2116
2117    private static final long serialVersionUID = 1252321973L;
2118
2119  /**
2120   * Constructor
2121   */
2122    public Permission() {
2123      super();
2124    }
2125
2126  /**
2127   * Constructor
2128   */
2129    public Permission(PermissionStatus status, PermissionRuleCombining combining) {
2130      super();
2131      this.setStatus(status);
2132      this.setCombining(combining);
2133    }
2134
2135    /**
2136     * @return {@link #status} (Status.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2137     */
2138    public Enumeration<PermissionStatus> getStatusElement() { 
2139      if (this.status == null)
2140        if (Configuration.errorOnAutoCreate())
2141          throw new Error("Attempt to auto-create Permission.status");
2142        else if (Configuration.doAutoCreate())
2143          this.status = new Enumeration<PermissionStatus>(new PermissionStatusEnumFactory()); // bb
2144      return this.status;
2145    }
2146
2147    public boolean hasStatusElement() { 
2148      return this.status != null && !this.status.isEmpty();
2149    }
2150
2151    public boolean hasStatus() { 
2152      return this.status != null && !this.status.isEmpty();
2153    }
2154
2155    /**
2156     * @param value {@link #status} (Status.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2157     */
2158    public Permission setStatusElement(Enumeration<PermissionStatus> value) { 
2159      this.status = value;
2160      return this;
2161    }
2162
2163    /**
2164     * @return Status.
2165     */
2166    public PermissionStatus getStatus() { 
2167      return this.status == null ? null : this.status.getValue();
2168    }
2169
2170    /**
2171     * @param value Status.
2172     */
2173    public Permission setStatus(PermissionStatus value) { 
2174        if (this.status == null)
2175          this.status = new Enumeration<PermissionStatus>(new PermissionStatusEnumFactory());
2176        this.status.setValue(value);
2177      return this;
2178    }
2179
2180    /**
2181     * @return {@link #asserter} (The person or entity that asserts the permission.)
2182     */
2183    public Reference getAsserter() { 
2184      if (this.asserter == null)
2185        if (Configuration.errorOnAutoCreate())
2186          throw new Error("Attempt to auto-create Permission.asserter");
2187        else if (Configuration.doAutoCreate())
2188          this.asserter = new Reference(); // cc
2189      return this.asserter;
2190    }
2191
2192    public boolean hasAsserter() { 
2193      return this.asserter != null && !this.asserter.isEmpty();
2194    }
2195
2196    /**
2197     * @param value {@link #asserter} (The person or entity that asserts the permission.)
2198     */
2199    public Permission setAsserter(Reference value) { 
2200      this.asserter = value;
2201      return this;
2202    }
2203
2204    /**
2205     * @return {@link #date} (The date that permission was asserted.)
2206     */
2207    public List<DateTimeType> getDate() { 
2208      if (this.date == null)
2209        this.date = new ArrayList<DateTimeType>();
2210      return this.date;
2211    }
2212
2213    /**
2214     * @return Returns a reference to <code>this</code> for easy method chaining
2215     */
2216    public Permission setDate(List<DateTimeType> theDate) { 
2217      this.date = theDate;
2218      return this;
2219    }
2220
2221    public boolean hasDate() { 
2222      if (this.date == null)
2223        return false;
2224      for (DateTimeType item : this.date)
2225        if (!item.isEmpty())
2226          return true;
2227      return false;
2228    }
2229
2230    /**
2231     * @return {@link #date} (The date that permission was asserted.)
2232     */
2233    public DateTimeType addDateElement() {//2 
2234      DateTimeType t = new DateTimeType();
2235      if (this.date == null)
2236        this.date = new ArrayList<DateTimeType>();
2237      this.date.add(t);
2238      return t;
2239    }
2240
2241    /**
2242     * @param value {@link #date} (The date that permission was asserted.)
2243     */
2244    public Permission addDate(Date value) { //1
2245      DateTimeType t = new DateTimeType();
2246      t.setValue(value);
2247      if (this.date == null)
2248        this.date = new ArrayList<DateTimeType>();
2249      this.date.add(t);
2250      return this;
2251    }
2252
2253    /**
2254     * @param value {@link #date} (The date that permission was asserted.)
2255     */
2256    public boolean hasDate(Date value) { 
2257      if (this.date == null)
2258        return false;
2259      for (DateTimeType v : this.date)
2260        if (v.getValue().equals(value)) // dateTime
2261          return true;
2262      return false;
2263    }
2264
2265    /**
2266     * @return {@link #validity} (The period in which the permission is active.)
2267     */
2268    public Period getValidity() { 
2269      if (this.validity == null)
2270        if (Configuration.errorOnAutoCreate())
2271          throw new Error("Attempt to auto-create Permission.validity");
2272        else if (Configuration.doAutoCreate())
2273          this.validity = new Period(); // cc
2274      return this.validity;
2275    }
2276
2277    public boolean hasValidity() { 
2278      return this.validity != null && !this.validity.isEmpty();
2279    }
2280
2281    /**
2282     * @param value {@link #validity} (The period in which the permission is active.)
2283     */
2284    public Permission setValidity(Period value) { 
2285      this.validity = value;
2286      return this;
2287    }
2288
2289    /**
2290     * @return {@link #justification} (The asserted justification for using the data.)
2291     */
2292    public PermissionJustificationComponent getJustification() { 
2293      if (this.justification == null)
2294        if (Configuration.errorOnAutoCreate())
2295          throw new Error("Attempt to auto-create Permission.justification");
2296        else if (Configuration.doAutoCreate())
2297          this.justification = new PermissionJustificationComponent(); // cc
2298      return this.justification;
2299    }
2300
2301    public boolean hasJustification() { 
2302      return this.justification != null && !this.justification.isEmpty();
2303    }
2304
2305    /**
2306     * @param value {@link #justification} (The asserted justification for using the data.)
2307     */
2308    public Permission setJustification(PermissionJustificationComponent value) { 
2309      this.justification = value;
2310      return this;
2311    }
2312
2313    /**
2314     * @return {@link #combining} (Defines a procedure for arriving at an access decision given the set of rules.). This is the underlying object with id, value and extensions. The accessor "getCombining" gives direct access to the value
2315     */
2316    public Enumeration<PermissionRuleCombining> getCombiningElement() { 
2317      if (this.combining == null)
2318        if (Configuration.errorOnAutoCreate())
2319          throw new Error("Attempt to auto-create Permission.combining");
2320        else if (Configuration.doAutoCreate())
2321          this.combining = new Enumeration<PermissionRuleCombining>(new PermissionRuleCombiningEnumFactory()); // bb
2322      return this.combining;
2323    }
2324
2325    public boolean hasCombiningElement() { 
2326      return this.combining != null && !this.combining.isEmpty();
2327    }
2328
2329    public boolean hasCombining() { 
2330      return this.combining != null && !this.combining.isEmpty();
2331    }
2332
2333    /**
2334     * @param value {@link #combining} (Defines a procedure for arriving at an access decision given the set of rules.). This is the underlying object with id, value and extensions. The accessor "getCombining" gives direct access to the value
2335     */
2336    public Permission setCombiningElement(Enumeration<PermissionRuleCombining> value) { 
2337      this.combining = value;
2338      return this;
2339    }
2340
2341    /**
2342     * @return Defines a procedure for arriving at an access decision given the set of rules.
2343     */
2344    public PermissionRuleCombining getCombining() { 
2345      return this.combining == null ? null : this.combining.getValue();
2346    }
2347
2348    /**
2349     * @param value Defines a procedure for arriving at an access decision given the set of rules.
2350     */
2351    public Permission setCombining(PermissionRuleCombining value) { 
2352        if (this.combining == null)
2353          this.combining = new Enumeration<PermissionRuleCombining>(new PermissionRuleCombiningEnumFactory());
2354        this.combining.setValue(value);
2355      return this;
2356    }
2357
2358    /**
2359     * @return {@link #rule} (A set of rules.)
2360     */
2361    public List<RuleComponent> getRule() { 
2362      if (this.rule == null)
2363        this.rule = new ArrayList<RuleComponent>();
2364      return this.rule;
2365    }
2366
2367    /**
2368     * @return Returns a reference to <code>this</code> for easy method chaining
2369     */
2370    public Permission setRule(List<RuleComponent> theRule) { 
2371      this.rule = theRule;
2372      return this;
2373    }
2374
2375    public boolean hasRule() { 
2376      if (this.rule == null)
2377        return false;
2378      for (RuleComponent item : this.rule)
2379        if (!item.isEmpty())
2380          return true;
2381      return false;
2382    }
2383
2384    public RuleComponent addRule() { //3
2385      RuleComponent t = new RuleComponent();
2386      if (this.rule == null)
2387        this.rule = new ArrayList<RuleComponent>();
2388      this.rule.add(t);
2389      return t;
2390    }
2391
2392    public Permission addRule(RuleComponent t) { //3
2393      if (t == null)
2394        return this;
2395      if (this.rule == null)
2396        this.rule = new ArrayList<RuleComponent>();
2397      this.rule.add(t);
2398      return this;
2399    }
2400
2401    /**
2402     * @return The first repetition of repeating field {@link #rule}, creating it if it does not already exist {3}
2403     */
2404    public RuleComponent getRuleFirstRep() { 
2405      if (getRule().isEmpty()) {
2406        addRule();
2407      }
2408      return getRule().get(0);
2409    }
2410
2411      protected void listChildren(List<Property> children) {
2412        super.listChildren(children);
2413        children.add(new Property("status", "code", "Status.", 0, 1, status));
2414        children.add(new Property("asserter", "Reference(Practitioner|PractitionerRole|Organization|CareTeam|Patient|RelatedPerson|HealthcareService)", "The person or entity that asserts the permission.", 0, 1, asserter));
2415        children.add(new Property("date", "dateTime", "The date that permission was asserted.", 0, java.lang.Integer.MAX_VALUE, date));
2416        children.add(new Property("validity", "Period", "The period in which the permission is active.", 0, 1, validity));
2417        children.add(new Property("justification", "", "The asserted justification for using the data.", 0, 1, justification));
2418        children.add(new Property("combining", "code", "Defines a procedure for arriving at an access decision given the set of rules.", 0, 1, combining));
2419        children.add(new Property("rule", "", "A set of rules.", 0, java.lang.Integer.MAX_VALUE, rule));
2420      }
2421
2422      @Override
2423      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2424        switch (_hash) {
2425        case -892481550: /*status*/  return new Property("status", "code", "Status.", 0, 1, status);
2426        case -373242253: /*asserter*/  return new Property("asserter", "Reference(Practitioner|PractitionerRole|Organization|CareTeam|Patient|RelatedPerson|HealthcareService)", "The person or entity that asserts the permission.", 0, 1, asserter);
2427        case 3076014: /*date*/  return new Property("date", "dateTime", "The date that permission was asserted.", 0, java.lang.Integer.MAX_VALUE, date);
2428        case -1421265102: /*validity*/  return new Property("validity", "Period", "The period in which the permission is active.", 0, 1, validity);
2429        case 1864993522: /*justification*/  return new Property("justification", "", "The asserted justification for using the data.", 0, 1, justification);
2430        case -1806252484: /*combining*/  return new Property("combining", "code", "Defines a procedure for arriving at an access decision given the set of rules.", 0, 1, combining);
2431        case 3512060: /*rule*/  return new Property("rule", "", "A set of rules.", 0, java.lang.Integer.MAX_VALUE, rule);
2432        default: return super.getNamedProperty(_hash, _name, _checkValid);
2433        }
2434
2435      }
2436
2437      @Override
2438      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2439        switch (hash) {
2440        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<PermissionStatus>
2441        case -373242253: /*asserter*/ return this.asserter == null ? new Base[0] : new Base[] {this.asserter}; // Reference
2442        case 3076014: /*date*/ return this.date == null ? new Base[0] : this.date.toArray(new Base[this.date.size()]); // DateTimeType
2443        case -1421265102: /*validity*/ return this.validity == null ? new Base[0] : new Base[] {this.validity}; // Period
2444        case 1864993522: /*justification*/ return this.justification == null ? new Base[0] : new Base[] {this.justification}; // PermissionJustificationComponent
2445        case -1806252484: /*combining*/ return this.combining == null ? new Base[0] : new Base[] {this.combining}; // Enumeration<PermissionRuleCombining>
2446        case 3512060: /*rule*/ return this.rule == null ? new Base[0] : this.rule.toArray(new Base[this.rule.size()]); // RuleComponent
2447        default: return super.getProperty(hash, name, checkValid);
2448        }
2449
2450      }
2451
2452      @Override
2453      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2454        switch (hash) {
2455        case -892481550: // status
2456          value = new PermissionStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
2457          this.status = (Enumeration) value; // Enumeration<PermissionStatus>
2458          return value;
2459        case -373242253: // asserter
2460          this.asserter = TypeConvertor.castToReference(value); // Reference
2461          return value;
2462        case 3076014: // date
2463          this.getDate().add(TypeConvertor.castToDateTime(value)); // DateTimeType
2464          return value;
2465        case -1421265102: // validity
2466          this.validity = TypeConvertor.castToPeriod(value); // Period
2467          return value;
2468        case 1864993522: // justification
2469          this.justification = (PermissionJustificationComponent) value; // PermissionJustificationComponent
2470          return value;
2471        case -1806252484: // combining
2472          value = new PermissionRuleCombiningEnumFactory().fromType(TypeConvertor.castToCode(value));
2473          this.combining = (Enumeration) value; // Enumeration<PermissionRuleCombining>
2474          return value;
2475        case 3512060: // rule
2476          this.getRule().add((RuleComponent) value); // RuleComponent
2477          return value;
2478        default: return super.setProperty(hash, name, value);
2479        }
2480
2481      }
2482
2483      @Override
2484      public Base setProperty(String name, Base value) throws FHIRException {
2485        if (name.equals("status")) {
2486          value = new PermissionStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
2487          this.status = (Enumeration) value; // Enumeration<PermissionStatus>
2488        } else if (name.equals("asserter")) {
2489          this.asserter = TypeConvertor.castToReference(value); // Reference
2490        } else if (name.equals("date")) {
2491          this.getDate().add(TypeConvertor.castToDateTime(value));
2492        } else if (name.equals("validity")) {
2493          this.validity = TypeConvertor.castToPeriod(value); // Period
2494        } else if (name.equals("justification")) {
2495          this.justification = (PermissionJustificationComponent) value; // PermissionJustificationComponent
2496        } else if (name.equals("combining")) {
2497          value = new PermissionRuleCombiningEnumFactory().fromType(TypeConvertor.castToCode(value));
2498          this.combining = (Enumeration) value; // Enumeration<PermissionRuleCombining>
2499        } else if (name.equals("rule")) {
2500          this.getRule().add((RuleComponent) value);
2501        } else
2502          return super.setProperty(name, value);
2503        return value;
2504      }
2505
2506  @Override
2507  public void removeChild(String name, Base value) throws FHIRException {
2508        if (name.equals("status")) {
2509          value = new PermissionStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
2510          this.status = (Enumeration) value; // Enumeration<PermissionStatus>
2511        } else if (name.equals("asserter")) {
2512          this.asserter = null;
2513        } else if (name.equals("date")) {
2514          this.getDate().remove(value);
2515        } else if (name.equals("validity")) {
2516          this.validity = null;
2517        } else if (name.equals("justification")) {
2518          this.justification = (PermissionJustificationComponent) value; // PermissionJustificationComponent
2519        } else if (name.equals("combining")) {
2520          value = new PermissionRuleCombiningEnumFactory().fromType(TypeConvertor.castToCode(value));
2521          this.combining = (Enumeration) value; // Enumeration<PermissionRuleCombining>
2522        } else if (name.equals("rule")) {
2523          this.getRule().remove((RuleComponent) value);
2524        } else
2525          super.removeChild(name, value);
2526        
2527      }
2528
2529      @Override
2530      public Base makeProperty(int hash, String name) throws FHIRException {
2531        switch (hash) {
2532        case -892481550:  return getStatusElement();
2533        case -373242253:  return getAsserter();
2534        case 3076014:  return addDateElement();
2535        case -1421265102:  return getValidity();
2536        case 1864993522:  return getJustification();
2537        case -1806252484:  return getCombiningElement();
2538        case 3512060:  return addRule(); 
2539        default: return super.makeProperty(hash, name);
2540        }
2541
2542      }
2543
2544      @Override
2545      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2546        switch (hash) {
2547        case -892481550: /*status*/ return new String[] {"code"};
2548        case -373242253: /*asserter*/ return new String[] {"Reference"};
2549        case 3076014: /*date*/ return new String[] {"dateTime"};
2550        case -1421265102: /*validity*/ return new String[] {"Period"};
2551        case 1864993522: /*justification*/ return new String[] {};
2552        case -1806252484: /*combining*/ return new String[] {"code"};
2553        case 3512060: /*rule*/ return new String[] {};
2554        default: return super.getTypesForProperty(hash, name);
2555        }
2556
2557      }
2558
2559      @Override
2560      public Base addChild(String name) throws FHIRException {
2561        if (name.equals("status")) {
2562          throw new FHIRException("Cannot call addChild on a singleton property Permission.status");
2563        }
2564        else if (name.equals("asserter")) {
2565          this.asserter = new Reference();
2566          return this.asserter;
2567        }
2568        else if (name.equals("date")) {
2569          throw new FHIRException("Cannot call addChild on a singleton property Permission.date");
2570        }
2571        else if (name.equals("validity")) {
2572          this.validity = new Period();
2573          return this.validity;
2574        }
2575        else if (name.equals("justification")) {
2576          this.justification = new PermissionJustificationComponent();
2577          return this.justification;
2578        }
2579        else if (name.equals("combining")) {
2580          throw new FHIRException("Cannot call addChild on a singleton property Permission.combining");
2581        }
2582        else if (name.equals("rule")) {
2583          return addRule();
2584        }
2585        else
2586          return super.addChild(name);
2587      }
2588
2589  public String fhirType() {
2590    return "Permission";
2591
2592  }
2593
2594      public Permission copy() {
2595        Permission dst = new Permission();
2596        copyValues(dst);
2597        return dst;
2598      }
2599
2600      public void copyValues(Permission dst) {
2601        super.copyValues(dst);
2602        dst.status = status == null ? null : status.copy();
2603        dst.asserter = asserter == null ? null : asserter.copy();
2604        if (date != null) {
2605          dst.date = new ArrayList<DateTimeType>();
2606          for (DateTimeType i : date)
2607            dst.date.add(i.copy());
2608        };
2609        dst.validity = validity == null ? null : validity.copy();
2610        dst.justification = justification == null ? null : justification.copy();
2611        dst.combining = combining == null ? null : combining.copy();
2612        if (rule != null) {
2613          dst.rule = new ArrayList<RuleComponent>();
2614          for (RuleComponent i : rule)
2615            dst.rule.add(i.copy());
2616        };
2617      }
2618
2619      protected Permission typedCopy() {
2620        return copy();
2621      }
2622
2623      @Override
2624      public boolean equalsDeep(Base other_) {
2625        if (!super.equalsDeep(other_))
2626          return false;
2627        if (!(other_ instanceof Permission))
2628          return false;
2629        Permission o = (Permission) other_;
2630        return compareDeep(status, o.status, true) && compareDeep(asserter, o.asserter, true) && compareDeep(date, o.date, true)
2631           && compareDeep(validity, o.validity, true) && compareDeep(justification, o.justification, true)
2632           && compareDeep(combining, o.combining, true) && compareDeep(rule, o.rule, true);
2633      }
2634
2635      @Override
2636      public boolean equalsShallow(Base other_) {
2637        if (!super.equalsShallow(other_))
2638          return false;
2639        if (!(other_ instanceof Permission))
2640          return false;
2641        Permission o = (Permission) other_;
2642        return compareValues(status, o.status, true) && compareValues(date, o.date, true) && compareValues(combining, o.combining, true)
2643          ;
2644      }
2645
2646      public boolean isEmpty() {
2647        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(status, asserter, date, validity
2648          , justification, combining, rule);
2649      }
2650
2651  @Override
2652  public ResourceType getResourceType() {
2653    return ResourceType.Permission;
2654   }
2655
2656 /**
2657   * Search parameter: <b>status</b>
2658   * <p>
2659   * Description: <b>active | entered-in-error | draft | rejected</b><br>
2660   * Type: <b>token</b><br>
2661   * Path: <b>Permission.status</b><br>
2662   * </p>
2663   */
2664  @SearchParamDefinition(name="status", path="Permission.status", description="active | entered-in-error | draft | rejected", type="token" )
2665  public static final String SP_STATUS = "status";
2666 /**
2667   * <b>Fluent Client</b> search parameter constant for <b>status</b>
2668   * <p>
2669   * Description: <b>active | entered-in-error | draft | rejected</b><br>
2670   * Type: <b>token</b><br>
2671   * Path: <b>Permission.status</b><br>
2672   * </p>
2673   */
2674  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
2675
2676
2677}
2678