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 Base makeProperty(int hash, String name) throws FHIRException {
529        switch (hash) {
530        case 93508670:  return addBasis(); 
531        case 382967383:  return addEvidence(); 
532        default: return super.makeProperty(hash, name);
533        }
534
535      }
536
537      @Override
538      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
539        switch (hash) {
540        case 93508670: /*basis*/ return new String[] {"CodeableConcept"};
541        case 382967383: /*evidence*/ return new String[] {"Reference"};
542        default: return super.getTypesForProperty(hash, name);
543        }
544
545      }
546
547      @Override
548      public Base addChild(String name) throws FHIRException {
549        if (name.equals("basis")) {
550          return addBasis();
551        }
552        else if (name.equals("evidence")) {
553          return addEvidence();
554        }
555        else
556          return super.addChild(name);
557      }
558
559      public PermissionJustificationComponent copy() {
560        PermissionJustificationComponent dst = new PermissionJustificationComponent();
561        copyValues(dst);
562        return dst;
563      }
564
565      public void copyValues(PermissionJustificationComponent dst) {
566        super.copyValues(dst);
567        if (basis != null) {
568          dst.basis = new ArrayList<CodeableConcept>();
569          for (CodeableConcept i : basis)
570            dst.basis.add(i.copy());
571        };
572        if (evidence != null) {
573          dst.evidence = new ArrayList<Reference>();
574          for (Reference i : evidence)
575            dst.evidence.add(i.copy());
576        };
577      }
578
579      @Override
580      public boolean equalsDeep(Base other_) {
581        if (!super.equalsDeep(other_))
582          return false;
583        if (!(other_ instanceof PermissionJustificationComponent))
584          return false;
585        PermissionJustificationComponent o = (PermissionJustificationComponent) other_;
586        return compareDeep(basis, o.basis, true) && compareDeep(evidence, o.evidence, true);
587      }
588
589      @Override
590      public boolean equalsShallow(Base other_) {
591        if (!super.equalsShallow(other_))
592          return false;
593        if (!(other_ instanceof PermissionJustificationComponent))
594          return false;
595        PermissionJustificationComponent o = (PermissionJustificationComponent) other_;
596        return true;
597      }
598
599      public boolean isEmpty() {
600        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(basis, evidence);
601      }
602
603  public String fhirType() {
604    return "Permission.justification";
605
606  }
607
608  }
609
610    @Block()
611    public static class RuleComponent extends BackboneElement implements IBaseBackboneElement {
612        /**
613         * deny | permit.
614         */
615        @Child(name = "type", type = {CodeType.class}, order=1, min=0, max=1, modifier=true, summary=true)
616        @Description(shortDefinition="deny | permit", formalDefinition="deny | permit." )
617        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/consent-provision-type")
618        protected Enumeration<ConsentProvisionType> type;
619
620        /**
621         * A description or definition of which activities are allowed to be done on the data.
622         */
623        @Child(name = "data", type = {}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
624        @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." )
625        protected List<RuleDataComponent> data;
626
627        /**
628         * A description or definition of which activities are allowed to be done on the data.
629         */
630        @Child(name = "activity", type = {}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
631        @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." )
632        protected List<RuleActivityComponent> activity;
633
634        /**
635         * What limits apply to the use of the data.
636         */
637        @Child(name = "limit", type = {CodeableConcept.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
638        @Description(shortDefinition="What limits apply to the use of the data", formalDefinition="What limits apply to the use of the data." )
639        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/security-label-event-examples")
640        protected List<CodeableConcept> limit;
641
642        private static final long serialVersionUID = 1376717588L;
643
644    /**
645     * Constructor
646     */
647      public RuleComponent() {
648        super();
649      }
650
651        /**
652         * @return {@link #type} (deny | permit.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
653         */
654        public Enumeration<ConsentProvisionType> getTypeElement() { 
655          if (this.type == null)
656            if (Configuration.errorOnAutoCreate())
657              throw new Error("Attempt to auto-create RuleComponent.type");
658            else if (Configuration.doAutoCreate())
659              this.type = new Enumeration<ConsentProvisionType>(new ConsentProvisionTypeEnumFactory()); // bb
660          return this.type;
661        }
662
663        public boolean hasTypeElement() { 
664          return this.type != null && !this.type.isEmpty();
665        }
666
667        public boolean hasType() { 
668          return this.type != null && !this.type.isEmpty();
669        }
670
671        /**
672         * @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
673         */
674        public RuleComponent setTypeElement(Enumeration<ConsentProvisionType> value) { 
675          this.type = value;
676          return this;
677        }
678
679        /**
680         * @return deny | permit.
681         */
682        public ConsentProvisionType getType() { 
683          return this.type == null ? null : this.type.getValue();
684        }
685
686        /**
687         * @param value deny | permit.
688         */
689        public RuleComponent setType(ConsentProvisionType value) { 
690          if (value == null)
691            this.type = null;
692          else {
693            if (this.type == null)
694              this.type = new Enumeration<ConsentProvisionType>(new ConsentProvisionTypeEnumFactory());
695            this.type.setValue(value);
696          }
697          return this;
698        }
699
700        /**
701         * @return {@link #data} (A description or definition of which activities are allowed to be done on the data.)
702         */
703        public List<RuleDataComponent> getData() { 
704          if (this.data == null)
705            this.data = new ArrayList<RuleDataComponent>();
706          return this.data;
707        }
708
709        /**
710         * @return Returns a reference to <code>this</code> for easy method chaining
711         */
712        public RuleComponent setData(List<RuleDataComponent> theData) { 
713          this.data = theData;
714          return this;
715        }
716
717        public boolean hasData() { 
718          if (this.data == null)
719            return false;
720          for (RuleDataComponent item : this.data)
721            if (!item.isEmpty())
722              return true;
723          return false;
724        }
725
726        public RuleDataComponent addData() { //3
727          RuleDataComponent t = new RuleDataComponent();
728          if (this.data == null)
729            this.data = new ArrayList<RuleDataComponent>();
730          this.data.add(t);
731          return t;
732        }
733
734        public RuleComponent addData(RuleDataComponent t) { //3
735          if (t == null)
736            return this;
737          if (this.data == null)
738            this.data = new ArrayList<RuleDataComponent>();
739          this.data.add(t);
740          return this;
741        }
742
743        /**
744         * @return The first repetition of repeating field {@link #data}, creating it if it does not already exist {3}
745         */
746        public RuleDataComponent getDataFirstRep() { 
747          if (getData().isEmpty()) {
748            addData();
749          }
750          return getData().get(0);
751        }
752
753        /**
754         * @return {@link #activity} (A description or definition of which activities are allowed to be done on the data.)
755         */
756        public List<RuleActivityComponent> getActivity() { 
757          if (this.activity == null)
758            this.activity = new ArrayList<RuleActivityComponent>();
759          return this.activity;
760        }
761
762        /**
763         * @return Returns a reference to <code>this</code> for easy method chaining
764         */
765        public RuleComponent setActivity(List<RuleActivityComponent> theActivity) { 
766          this.activity = theActivity;
767          return this;
768        }
769
770        public boolean hasActivity() { 
771          if (this.activity == null)
772            return false;
773          for (RuleActivityComponent item : this.activity)
774            if (!item.isEmpty())
775              return true;
776          return false;
777        }
778
779        public RuleActivityComponent addActivity() { //3
780          RuleActivityComponent t = new RuleActivityComponent();
781          if (this.activity == null)
782            this.activity = new ArrayList<RuleActivityComponent>();
783          this.activity.add(t);
784          return t;
785        }
786
787        public RuleComponent addActivity(RuleActivityComponent t) { //3
788          if (t == null)
789            return this;
790          if (this.activity == null)
791            this.activity = new ArrayList<RuleActivityComponent>();
792          this.activity.add(t);
793          return this;
794        }
795
796        /**
797         * @return The first repetition of repeating field {@link #activity}, creating it if it does not already exist {3}
798         */
799        public RuleActivityComponent getActivityFirstRep() { 
800          if (getActivity().isEmpty()) {
801            addActivity();
802          }
803          return getActivity().get(0);
804        }
805
806        /**
807         * @return {@link #limit} (What limits apply to the use of the data.)
808         */
809        public List<CodeableConcept> getLimit() { 
810          if (this.limit == null)
811            this.limit = new ArrayList<CodeableConcept>();
812          return this.limit;
813        }
814
815        /**
816         * @return Returns a reference to <code>this</code> for easy method chaining
817         */
818        public RuleComponent setLimit(List<CodeableConcept> theLimit) { 
819          this.limit = theLimit;
820          return this;
821        }
822
823        public boolean hasLimit() { 
824          if (this.limit == null)
825            return false;
826          for (CodeableConcept item : this.limit)
827            if (!item.isEmpty())
828              return true;
829          return false;
830        }
831
832        public CodeableConcept addLimit() { //3
833          CodeableConcept t = new CodeableConcept();
834          if (this.limit == null)
835            this.limit = new ArrayList<CodeableConcept>();
836          this.limit.add(t);
837          return t;
838        }
839
840        public RuleComponent addLimit(CodeableConcept t) { //3
841          if (t == null)
842            return this;
843          if (this.limit == null)
844            this.limit = new ArrayList<CodeableConcept>();
845          this.limit.add(t);
846          return this;
847        }
848
849        /**
850         * @return The first repetition of repeating field {@link #limit}, creating it if it does not already exist {3}
851         */
852        public CodeableConcept getLimitFirstRep() { 
853          if (getLimit().isEmpty()) {
854            addLimit();
855          }
856          return getLimit().get(0);
857        }
858
859        protected void listChildren(List<Property> children) {
860          super.listChildren(children);
861          children.add(new Property("type", "code", "deny | permit.", 0, 1, type));
862          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));
863          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));
864          children.add(new Property("limit", "CodeableConcept", "What limits apply to the use of the data.", 0, java.lang.Integer.MAX_VALUE, limit));
865        }
866
867        @Override
868        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
869          switch (_hash) {
870          case 3575610: /*type*/  return new Property("type", "code", "deny | permit.", 0, 1, type);
871          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);
872          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);
873          case 102976443: /*limit*/  return new Property("limit", "CodeableConcept", "What limits apply to the use of the data.", 0, java.lang.Integer.MAX_VALUE, limit);
874          default: return super.getNamedProperty(_hash, _name, _checkValid);
875          }
876
877        }
878
879      @Override
880      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
881        switch (hash) {
882        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // Enumeration<ConsentProvisionType>
883        case 3076010: /*data*/ return this.data == null ? new Base[0] : this.data.toArray(new Base[this.data.size()]); // RuleDataComponent
884        case -1655966961: /*activity*/ return this.activity == null ? new Base[0] : this.activity.toArray(new Base[this.activity.size()]); // RuleActivityComponent
885        case 102976443: /*limit*/ return this.limit == null ? new Base[0] : this.limit.toArray(new Base[this.limit.size()]); // CodeableConcept
886        default: return super.getProperty(hash, name, checkValid);
887        }
888
889      }
890
891      @Override
892      public Base setProperty(int hash, String name, Base value) throws FHIRException {
893        switch (hash) {
894        case 3575610: // type
895          value = new ConsentProvisionTypeEnumFactory().fromType(TypeConvertor.castToCode(value));
896          this.type = (Enumeration) value; // Enumeration<ConsentProvisionType>
897          return value;
898        case 3076010: // data
899          this.getData().add((RuleDataComponent) value); // RuleDataComponent
900          return value;
901        case -1655966961: // activity
902          this.getActivity().add((RuleActivityComponent) value); // RuleActivityComponent
903          return value;
904        case 102976443: // limit
905          this.getLimit().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
906          return value;
907        default: return super.setProperty(hash, name, value);
908        }
909
910      }
911
912      @Override
913      public Base setProperty(String name, Base value) throws FHIRException {
914        if (name.equals("type")) {
915          value = new ConsentProvisionTypeEnumFactory().fromType(TypeConvertor.castToCode(value));
916          this.type = (Enumeration) value; // Enumeration<ConsentProvisionType>
917        } else if (name.equals("data")) {
918          this.getData().add((RuleDataComponent) value);
919        } else if (name.equals("activity")) {
920          this.getActivity().add((RuleActivityComponent) value);
921        } else if (name.equals("limit")) {
922          this.getLimit().add(TypeConvertor.castToCodeableConcept(value));
923        } else
924          return super.setProperty(name, value);
925        return value;
926      }
927
928      @Override
929      public Base makeProperty(int hash, String name) throws FHIRException {
930        switch (hash) {
931        case 3575610:  return getTypeElement();
932        case 3076010:  return addData(); 
933        case -1655966961:  return addActivity(); 
934        case 102976443:  return addLimit(); 
935        default: return super.makeProperty(hash, name);
936        }
937
938      }
939
940      @Override
941      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
942        switch (hash) {
943        case 3575610: /*type*/ return new String[] {"code"};
944        case 3076010: /*data*/ return new String[] {};
945        case -1655966961: /*activity*/ return new String[] {};
946        case 102976443: /*limit*/ return new String[] {"CodeableConcept"};
947        default: return super.getTypesForProperty(hash, name);
948        }
949
950      }
951
952      @Override
953      public Base addChild(String name) throws FHIRException {
954        if (name.equals("type")) {
955          throw new FHIRException("Cannot call addChild on a singleton property Permission.rule.type");
956        }
957        else if (name.equals("data")) {
958          return addData();
959        }
960        else if (name.equals("activity")) {
961          return addActivity();
962        }
963        else if (name.equals("limit")) {
964          return addLimit();
965        }
966        else
967          return super.addChild(name);
968      }
969
970      public RuleComponent copy() {
971        RuleComponent dst = new RuleComponent();
972        copyValues(dst);
973        return dst;
974      }
975
976      public void copyValues(RuleComponent dst) {
977        super.copyValues(dst);
978        dst.type = type == null ? null : type.copy();
979        if (data != null) {
980          dst.data = new ArrayList<RuleDataComponent>();
981          for (RuleDataComponent i : data)
982            dst.data.add(i.copy());
983        };
984        if (activity != null) {
985          dst.activity = new ArrayList<RuleActivityComponent>();
986          for (RuleActivityComponent i : activity)
987            dst.activity.add(i.copy());
988        };
989        if (limit != null) {
990          dst.limit = new ArrayList<CodeableConcept>();
991          for (CodeableConcept i : limit)
992            dst.limit.add(i.copy());
993        };
994      }
995
996      @Override
997      public boolean equalsDeep(Base other_) {
998        if (!super.equalsDeep(other_))
999          return false;
1000        if (!(other_ instanceof RuleComponent))
1001          return false;
1002        RuleComponent o = (RuleComponent) other_;
1003        return compareDeep(type, o.type, true) && compareDeep(data, o.data, true) && compareDeep(activity, o.activity, true)
1004           && compareDeep(limit, o.limit, true);
1005      }
1006
1007      @Override
1008      public boolean equalsShallow(Base other_) {
1009        if (!super.equalsShallow(other_))
1010          return false;
1011        if (!(other_ instanceof RuleComponent))
1012          return false;
1013        RuleComponent o = (RuleComponent) other_;
1014        return compareValues(type, o.type, true);
1015      }
1016
1017      public boolean isEmpty() {
1018        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, data, activity, limit
1019          );
1020      }
1021
1022  public String fhirType() {
1023    return "Permission.rule";
1024
1025  }
1026
1027  }
1028
1029    @Block()
1030    public static class RuleDataComponent extends BackboneElement implements IBaseBackboneElement {
1031        /**
1032         * Explicit FHIR Resource references.
1033         */
1034        @Child(name = "resource", type = {}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1035        @Description(shortDefinition="Explicit FHIR Resource references", formalDefinition="Explicit FHIR Resource references." )
1036        protected List<RuleDataResourceComponent> resource;
1037
1038        /**
1039         * The data in scope are those with the given codes present in that data .meta.security element.
1040         */
1041        @Child(name = "security", type = {Coding.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1042        @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." )
1043        protected List<Coding> security;
1044
1045        /**
1046         * Clinical or Operational Relevant period of time that bounds the data controlled by this rule.
1047         */
1048        @Child(name = "period", type = {Period.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1049        @Description(shortDefinition="Timeframe encompasing data create/update", formalDefinition="Clinical or Operational Relevant period of time that bounds the data controlled by this rule." )
1050        protected List<Period> period;
1051
1052        /**
1053         * Used when other data selection elements are insufficient.
1054         */
1055        @Child(name = "expression", type = {Expression.class}, order=4, min=0, max=1, modifier=false, summary=true)
1056        @Description(shortDefinition="Expression identifying the data", formalDefinition="Used when other data selection elements are insufficient." )
1057        protected Expression expression;
1058
1059        private static final long serialVersionUID = -774403139L;
1060
1061    /**
1062     * Constructor
1063     */
1064      public RuleDataComponent() {
1065        super();
1066      }
1067
1068        /**
1069         * @return {@link #resource} (Explicit FHIR Resource references.)
1070         */
1071        public List<RuleDataResourceComponent> getResource() { 
1072          if (this.resource == null)
1073            this.resource = new ArrayList<RuleDataResourceComponent>();
1074          return this.resource;
1075        }
1076
1077        /**
1078         * @return Returns a reference to <code>this</code> for easy method chaining
1079         */
1080        public RuleDataComponent setResource(List<RuleDataResourceComponent> theResource) { 
1081          this.resource = theResource;
1082          return this;
1083        }
1084
1085        public boolean hasResource() { 
1086          if (this.resource == null)
1087            return false;
1088          for (RuleDataResourceComponent item : this.resource)
1089            if (!item.isEmpty())
1090              return true;
1091          return false;
1092        }
1093
1094        public RuleDataResourceComponent addResource() { //3
1095          RuleDataResourceComponent t = new RuleDataResourceComponent();
1096          if (this.resource == null)
1097            this.resource = new ArrayList<RuleDataResourceComponent>();
1098          this.resource.add(t);
1099          return t;
1100        }
1101
1102        public RuleDataComponent addResource(RuleDataResourceComponent t) { //3
1103          if (t == null)
1104            return this;
1105          if (this.resource == null)
1106            this.resource = new ArrayList<RuleDataResourceComponent>();
1107          this.resource.add(t);
1108          return this;
1109        }
1110
1111        /**
1112         * @return The first repetition of repeating field {@link #resource}, creating it if it does not already exist {3}
1113         */
1114        public RuleDataResourceComponent getResourceFirstRep() { 
1115          if (getResource().isEmpty()) {
1116            addResource();
1117          }
1118          return getResource().get(0);
1119        }
1120
1121        /**
1122         * @return {@link #security} (The data in scope are those with the given codes present in that data .meta.security element.)
1123         */
1124        public List<Coding> getSecurity() { 
1125          if (this.security == null)
1126            this.security = new ArrayList<Coding>();
1127          return this.security;
1128        }
1129
1130        /**
1131         * @return Returns a reference to <code>this</code> for easy method chaining
1132         */
1133        public RuleDataComponent setSecurity(List<Coding> theSecurity) { 
1134          this.security = theSecurity;
1135          return this;
1136        }
1137
1138        public boolean hasSecurity() { 
1139          if (this.security == null)
1140            return false;
1141          for (Coding item : this.security)
1142            if (!item.isEmpty())
1143              return true;
1144          return false;
1145        }
1146
1147        public Coding addSecurity() { //3
1148          Coding t = new Coding();
1149          if (this.security == null)
1150            this.security = new ArrayList<Coding>();
1151          this.security.add(t);
1152          return t;
1153        }
1154
1155        public RuleDataComponent addSecurity(Coding t) { //3
1156          if (t == null)
1157            return this;
1158          if (this.security == null)
1159            this.security = new ArrayList<Coding>();
1160          this.security.add(t);
1161          return this;
1162        }
1163
1164        /**
1165         * @return The first repetition of repeating field {@link #security}, creating it if it does not already exist {3}
1166         */
1167        public Coding getSecurityFirstRep() { 
1168          if (getSecurity().isEmpty()) {
1169            addSecurity();
1170          }
1171          return getSecurity().get(0);
1172        }
1173
1174        /**
1175         * @return {@link #period} (Clinical or Operational Relevant period of time that bounds the data controlled by this rule.)
1176         */
1177        public List<Period> getPeriod() { 
1178          if (this.period == null)
1179            this.period = new ArrayList<Period>();
1180          return this.period;
1181        }
1182
1183        /**
1184         * @return Returns a reference to <code>this</code> for easy method chaining
1185         */
1186        public RuleDataComponent setPeriod(List<Period> thePeriod) { 
1187          this.period = thePeriod;
1188          return this;
1189        }
1190
1191        public boolean hasPeriod() { 
1192          if (this.period == null)
1193            return false;
1194          for (Period item : this.period)
1195            if (!item.isEmpty())
1196              return true;
1197          return false;
1198        }
1199
1200        public Period addPeriod() { //3
1201          Period t = new Period();
1202          if (this.period == null)
1203            this.period = new ArrayList<Period>();
1204          this.period.add(t);
1205          return t;
1206        }
1207
1208        public RuleDataComponent addPeriod(Period t) { //3
1209          if (t == null)
1210            return this;
1211          if (this.period == null)
1212            this.period = new ArrayList<Period>();
1213          this.period.add(t);
1214          return this;
1215        }
1216
1217        /**
1218         * @return The first repetition of repeating field {@link #period}, creating it if it does not already exist {3}
1219         */
1220        public Period getPeriodFirstRep() { 
1221          if (getPeriod().isEmpty()) {
1222            addPeriod();
1223          }
1224          return getPeriod().get(0);
1225        }
1226
1227        /**
1228         * @return {@link #expression} (Used when other data selection elements are insufficient.)
1229         */
1230        public Expression getExpression() { 
1231          if (this.expression == null)
1232            if (Configuration.errorOnAutoCreate())
1233              throw new Error("Attempt to auto-create RuleDataComponent.expression");
1234            else if (Configuration.doAutoCreate())
1235              this.expression = new Expression(); // cc
1236          return this.expression;
1237        }
1238
1239        public boolean hasExpression() { 
1240          return this.expression != null && !this.expression.isEmpty();
1241        }
1242
1243        /**
1244         * @param value {@link #expression} (Used when other data selection elements are insufficient.)
1245         */
1246        public RuleDataComponent setExpression(Expression value) { 
1247          this.expression = value;
1248          return this;
1249        }
1250
1251        protected void listChildren(List<Property> children) {
1252          super.listChildren(children);
1253          children.add(new Property("resource", "", "Explicit FHIR Resource references.", 0, java.lang.Integer.MAX_VALUE, resource));
1254          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));
1255          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));
1256          children.add(new Property("expression", "Expression", "Used when other data selection elements are insufficient.", 0, 1, expression));
1257        }
1258
1259        @Override
1260        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1261          switch (_hash) {
1262          case -341064690: /*resource*/  return new Property("resource", "", "Explicit FHIR Resource references.", 0, java.lang.Integer.MAX_VALUE, resource);
1263          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);
1264          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);
1265          case -1795452264: /*expression*/  return new Property("expression", "Expression", "Used when other data selection elements are insufficient.", 0, 1, expression);
1266          default: return super.getNamedProperty(_hash, _name, _checkValid);
1267          }
1268
1269        }
1270
1271      @Override
1272      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1273        switch (hash) {
1274        case -341064690: /*resource*/ return this.resource == null ? new Base[0] : this.resource.toArray(new Base[this.resource.size()]); // RuleDataResourceComponent
1275        case 949122880: /*security*/ return this.security == null ? new Base[0] : this.security.toArray(new Base[this.security.size()]); // Coding
1276        case -991726143: /*period*/ return this.period == null ? new Base[0] : this.period.toArray(new Base[this.period.size()]); // Period
1277        case -1795452264: /*expression*/ return this.expression == null ? new Base[0] : new Base[] {this.expression}; // Expression
1278        default: return super.getProperty(hash, name, checkValid);
1279        }
1280
1281      }
1282
1283      @Override
1284      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1285        switch (hash) {
1286        case -341064690: // resource
1287          this.getResource().add((RuleDataResourceComponent) value); // RuleDataResourceComponent
1288          return value;
1289        case 949122880: // security
1290          this.getSecurity().add(TypeConvertor.castToCoding(value)); // Coding
1291          return value;
1292        case -991726143: // period
1293          this.getPeriod().add(TypeConvertor.castToPeriod(value)); // Period
1294          return value;
1295        case -1795452264: // expression
1296          this.expression = TypeConvertor.castToExpression(value); // Expression
1297          return value;
1298        default: return super.setProperty(hash, name, value);
1299        }
1300
1301      }
1302
1303      @Override
1304      public Base setProperty(String name, Base value) throws FHIRException {
1305        if (name.equals("resource")) {
1306          this.getResource().add((RuleDataResourceComponent) value);
1307        } else if (name.equals("security")) {
1308          this.getSecurity().add(TypeConvertor.castToCoding(value));
1309        } else if (name.equals("period")) {
1310          this.getPeriod().add(TypeConvertor.castToPeriod(value));
1311        } else if (name.equals("expression")) {
1312          this.expression = TypeConvertor.castToExpression(value); // Expression
1313        } else
1314          return super.setProperty(name, value);
1315        return value;
1316      }
1317
1318      @Override
1319      public Base makeProperty(int hash, String name) throws FHIRException {
1320        switch (hash) {
1321        case -341064690:  return addResource(); 
1322        case 949122880:  return addSecurity(); 
1323        case -991726143:  return addPeriod(); 
1324        case -1795452264:  return getExpression();
1325        default: return super.makeProperty(hash, name);
1326        }
1327
1328      }
1329
1330      @Override
1331      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1332        switch (hash) {
1333        case -341064690: /*resource*/ return new String[] {};
1334        case 949122880: /*security*/ return new String[] {"Coding"};
1335        case -991726143: /*period*/ return new String[] {"Period"};
1336        case -1795452264: /*expression*/ return new String[] {"Expression"};
1337        default: return super.getTypesForProperty(hash, name);
1338        }
1339
1340      }
1341
1342      @Override
1343      public Base addChild(String name) throws FHIRException {
1344        if (name.equals("resource")) {
1345          return addResource();
1346        }
1347        else if (name.equals("security")) {
1348          return addSecurity();
1349        }
1350        else if (name.equals("period")) {
1351          return addPeriod();
1352        }
1353        else if (name.equals("expression")) {
1354          this.expression = new Expression();
1355          return this.expression;
1356        }
1357        else
1358          return super.addChild(name);
1359      }
1360
1361      public RuleDataComponent copy() {
1362        RuleDataComponent dst = new RuleDataComponent();
1363        copyValues(dst);
1364        return dst;
1365      }
1366
1367      public void copyValues(RuleDataComponent dst) {
1368        super.copyValues(dst);
1369        if (resource != null) {
1370          dst.resource = new ArrayList<RuleDataResourceComponent>();
1371          for (RuleDataResourceComponent i : resource)
1372            dst.resource.add(i.copy());
1373        };
1374        if (security != null) {
1375          dst.security = new ArrayList<Coding>();
1376          for (Coding i : security)
1377            dst.security.add(i.copy());
1378        };
1379        if (period != null) {
1380          dst.period = new ArrayList<Period>();
1381          for (Period i : period)
1382            dst.period.add(i.copy());
1383        };
1384        dst.expression = expression == null ? null : expression.copy();
1385      }
1386
1387      @Override
1388      public boolean equalsDeep(Base other_) {
1389        if (!super.equalsDeep(other_))
1390          return false;
1391        if (!(other_ instanceof RuleDataComponent))
1392          return false;
1393        RuleDataComponent o = (RuleDataComponent) other_;
1394        return compareDeep(resource, o.resource, true) && compareDeep(security, o.security, true) && compareDeep(period, o.period, true)
1395           && compareDeep(expression, o.expression, true);
1396      }
1397
1398      @Override
1399      public boolean equalsShallow(Base other_) {
1400        if (!super.equalsShallow(other_))
1401          return false;
1402        if (!(other_ instanceof RuleDataComponent))
1403          return false;
1404        RuleDataComponent o = (RuleDataComponent) other_;
1405        return true;
1406      }
1407
1408      public boolean isEmpty() {
1409        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(resource, security, period
1410          , expression);
1411      }
1412
1413  public String fhirType() {
1414    return "Permission.rule.data";
1415
1416  }
1417
1418  }
1419
1420    @Block()
1421    public static class RuleDataResourceComponent extends BackboneElement implements IBaseBackboneElement {
1422        /**
1423         * How the resource reference is interpreted when testing consent restrictions.
1424         */
1425        @Child(name = "meaning", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=true)
1426        @Description(shortDefinition="instance | related | dependents | authoredby", formalDefinition="How the resource reference is interpreted when testing consent restrictions." )
1427        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/consent-data-meaning")
1428        protected Enumeration<ConsentDataMeaning> meaning;
1429
1430        /**
1431         * A reference to a specific resource that defines which resources are covered by this consent.
1432         */
1433        @Child(name = "reference", type = {Reference.class}, order=2, min=1, max=1, modifier=false, summary=true)
1434        @Description(shortDefinition="The actual data reference", formalDefinition="A reference to a specific resource that defines which resources are covered by this consent." )
1435        protected Reference reference;
1436
1437        private static final long serialVersionUID = 1735979153L;
1438
1439    /**
1440     * Constructor
1441     */
1442      public RuleDataResourceComponent() {
1443        super();
1444      }
1445
1446    /**
1447     * Constructor
1448     */
1449      public RuleDataResourceComponent(ConsentDataMeaning meaning, Reference reference) {
1450        super();
1451        this.setMeaning(meaning);
1452        this.setReference(reference);
1453      }
1454
1455        /**
1456         * @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
1457         */
1458        public Enumeration<ConsentDataMeaning> getMeaningElement() { 
1459          if (this.meaning == null)
1460            if (Configuration.errorOnAutoCreate())
1461              throw new Error("Attempt to auto-create RuleDataResourceComponent.meaning");
1462            else if (Configuration.doAutoCreate())
1463              this.meaning = new Enumeration<ConsentDataMeaning>(new ConsentDataMeaningEnumFactory()); // bb
1464          return this.meaning;
1465        }
1466
1467        public boolean hasMeaningElement() { 
1468          return this.meaning != null && !this.meaning.isEmpty();
1469        }
1470
1471        public boolean hasMeaning() { 
1472          return this.meaning != null && !this.meaning.isEmpty();
1473        }
1474
1475        /**
1476         * @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
1477         */
1478        public RuleDataResourceComponent setMeaningElement(Enumeration<ConsentDataMeaning> value) { 
1479          this.meaning = value;
1480          return this;
1481        }
1482
1483        /**
1484         * @return How the resource reference is interpreted when testing consent restrictions.
1485         */
1486        public ConsentDataMeaning getMeaning() { 
1487          return this.meaning == null ? null : this.meaning.getValue();
1488        }
1489
1490        /**
1491         * @param value How the resource reference is interpreted when testing consent restrictions.
1492         */
1493        public RuleDataResourceComponent setMeaning(ConsentDataMeaning value) { 
1494            if (this.meaning == null)
1495              this.meaning = new Enumeration<ConsentDataMeaning>(new ConsentDataMeaningEnumFactory());
1496            this.meaning.setValue(value);
1497          return this;
1498        }
1499
1500        /**
1501         * @return {@link #reference} (A reference to a specific resource that defines which resources are covered by this consent.)
1502         */
1503        public Reference getReference() { 
1504          if (this.reference == null)
1505            if (Configuration.errorOnAutoCreate())
1506              throw new Error("Attempt to auto-create RuleDataResourceComponent.reference");
1507            else if (Configuration.doAutoCreate())
1508              this.reference = new Reference(); // cc
1509          return this.reference;
1510        }
1511
1512        public boolean hasReference() { 
1513          return this.reference != null && !this.reference.isEmpty();
1514        }
1515
1516        /**
1517         * @param value {@link #reference} (A reference to a specific resource that defines which resources are covered by this consent.)
1518         */
1519        public RuleDataResourceComponent setReference(Reference value) { 
1520          this.reference = value;
1521          return this;
1522        }
1523
1524        protected void listChildren(List<Property> children) {
1525          super.listChildren(children);
1526          children.add(new Property("meaning", "code", "How the resource reference is interpreted when testing consent restrictions.", 0, 1, meaning));
1527          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));
1528        }
1529
1530        @Override
1531        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1532          switch (_hash) {
1533          case 938160637: /*meaning*/  return new Property("meaning", "code", "How the resource reference is interpreted when testing consent restrictions.", 0, 1, meaning);
1534          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);
1535          default: return super.getNamedProperty(_hash, _name, _checkValid);
1536          }
1537
1538        }
1539
1540      @Override
1541      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1542        switch (hash) {
1543        case 938160637: /*meaning*/ return this.meaning == null ? new Base[0] : new Base[] {this.meaning}; // Enumeration<ConsentDataMeaning>
1544        case -925155509: /*reference*/ return this.reference == null ? new Base[0] : new Base[] {this.reference}; // Reference
1545        default: return super.getProperty(hash, name, checkValid);
1546        }
1547
1548      }
1549
1550      @Override
1551      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1552        switch (hash) {
1553        case 938160637: // meaning
1554          value = new ConsentDataMeaningEnumFactory().fromType(TypeConvertor.castToCode(value));
1555          this.meaning = (Enumeration) value; // Enumeration<ConsentDataMeaning>
1556          return value;
1557        case -925155509: // reference
1558          this.reference = TypeConvertor.castToReference(value); // Reference
1559          return value;
1560        default: return super.setProperty(hash, name, value);
1561        }
1562
1563      }
1564
1565      @Override
1566      public Base setProperty(String name, Base value) throws FHIRException {
1567        if (name.equals("meaning")) {
1568          value = new ConsentDataMeaningEnumFactory().fromType(TypeConvertor.castToCode(value));
1569          this.meaning = (Enumeration) value; // Enumeration<ConsentDataMeaning>
1570        } else if (name.equals("reference")) {
1571          this.reference = TypeConvertor.castToReference(value); // Reference
1572        } else
1573          return super.setProperty(name, value);
1574        return value;
1575      }
1576
1577      @Override
1578      public Base makeProperty(int hash, String name) throws FHIRException {
1579        switch (hash) {
1580        case 938160637:  return getMeaningElement();
1581        case -925155509:  return getReference();
1582        default: return super.makeProperty(hash, name);
1583        }
1584
1585      }
1586
1587      @Override
1588      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1589        switch (hash) {
1590        case 938160637: /*meaning*/ return new String[] {"code"};
1591        case -925155509: /*reference*/ return new String[] {"Reference"};
1592        default: return super.getTypesForProperty(hash, name);
1593        }
1594
1595      }
1596
1597      @Override
1598      public Base addChild(String name) throws FHIRException {
1599        if (name.equals("meaning")) {
1600          throw new FHIRException("Cannot call addChild on a singleton property Permission.rule.data.resource.meaning");
1601        }
1602        else if (name.equals("reference")) {
1603          this.reference = new Reference();
1604          return this.reference;
1605        }
1606        else
1607          return super.addChild(name);
1608      }
1609
1610      public RuleDataResourceComponent copy() {
1611        RuleDataResourceComponent dst = new RuleDataResourceComponent();
1612        copyValues(dst);
1613        return dst;
1614      }
1615
1616      public void copyValues(RuleDataResourceComponent dst) {
1617        super.copyValues(dst);
1618        dst.meaning = meaning == null ? null : meaning.copy();
1619        dst.reference = reference == null ? null : reference.copy();
1620      }
1621
1622      @Override
1623      public boolean equalsDeep(Base other_) {
1624        if (!super.equalsDeep(other_))
1625          return false;
1626        if (!(other_ instanceof RuleDataResourceComponent))
1627          return false;
1628        RuleDataResourceComponent o = (RuleDataResourceComponent) other_;
1629        return compareDeep(meaning, o.meaning, true) && compareDeep(reference, o.reference, true);
1630      }
1631
1632      @Override
1633      public boolean equalsShallow(Base other_) {
1634        if (!super.equalsShallow(other_))
1635          return false;
1636        if (!(other_ instanceof RuleDataResourceComponent))
1637          return false;
1638        RuleDataResourceComponent o = (RuleDataResourceComponent) other_;
1639        return compareValues(meaning, o.meaning, true);
1640      }
1641
1642      public boolean isEmpty() {
1643        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(meaning, reference);
1644      }
1645
1646  public String fhirType() {
1647    return "Permission.rule.data.resource";
1648
1649  }
1650
1651  }
1652
1653    @Block()
1654    public static class RuleActivityComponent extends BackboneElement implements IBaseBackboneElement {
1655        /**
1656         * The actor(s) authorized for the defined activity.
1657         */
1658        @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)
1659        @Description(shortDefinition="Authorized actor(s)", formalDefinition="The actor(s) authorized for the defined activity." )
1660        protected List<Reference> actor;
1661
1662        /**
1663         * Actions controlled by this Rule.
1664         */
1665        @Child(name = "action", type = {CodeableConcept.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1666        @Description(shortDefinition="Actions controlled by this rule", formalDefinition="Actions controlled by this Rule." )
1667        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/consent-action")
1668        protected List<CodeableConcept> action;
1669
1670        /**
1671         * The purpose for which the permission is given.
1672         */
1673        @Child(name = "purpose", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1674        @Description(shortDefinition="The purpose for which the permission is given", formalDefinition="The purpose for which the permission is given." )
1675        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v3-PurposeOfUse")
1676        protected List<CodeableConcept> purpose;
1677
1678        private static final long serialVersionUID = 1403721720L;
1679
1680    /**
1681     * Constructor
1682     */
1683      public RuleActivityComponent() {
1684        super();
1685      }
1686
1687        /**
1688         * @return {@link #actor} (The actor(s) authorized for the defined activity.)
1689         */
1690        public List<Reference> getActor() { 
1691          if (this.actor == null)
1692            this.actor = new ArrayList<Reference>();
1693          return this.actor;
1694        }
1695
1696        /**
1697         * @return Returns a reference to <code>this</code> for easy method chaining
1698         */
1699        public RuleActivityComponent setActor(List<Reference> theActor) { 
1700          this.actor = theActor;
1701          return this;
1702        }
1703
1704        public boolean hasActor() { 
1705          if (this.actor == null)
1706            return false;
1707          for (Reference item : this.actor)
1708            if (!item.isEmpty())
1709              return true;
1710          return false;
1711        }
1712
1713        public Reference addActor() { //3
1714          Reference t = new Reference();
1715          if (this.actor == null)
1716            this.actor = new ArrayList<Reference>();
1717          this.actor.add(t);
1718          return t;
1719        }
1720
1721        public RuleActivityComponent addActor(Reference t) { //3
1722          if (t == null)
1723            return this;
1724          if (this.actor == null)
1725            this.actor = new ArrayList<Reference>();
1726          this.actor.add(t);
1727          return this;
1728        }
1729
1730        /**
1731         * @return The first repetition of repeating field {@link #actor}, creating it if it does not already exist {3}
1732         */
1733        public Reference getActorFirstRep() { 
1734          if (getActor().isEmpty()) {
1735            addActor();
1736          }
1737          return getActor().get(0);
1738        }
1739
1740        /**
1741         * @return {@link #action} (Actions controlled by this Rule.)
1742         */
1743        public List<CodeableConcept> getAction() { 
1744          if (this.action == null)
1745            this.action = new ArrayList<CodeableConcept>();
1746          return this.action;
1747        }
1748
1749        /**
1750         * @return Returns a reference to <code>this</code> for easy method chaining
1751         */
1752        public RuleActivityComponent setAction(List<CodeableConcept> theAction) { 
1753          this.action = theAction;
1754          return this;
1755        }
1756
1757        public boolean hasAction() { 
1758          if (this.action == null)
1759            return false;
1760          for (CodeableConcept item : this.action)
1761            if (!item.isEmpty())
1762              return true;
1763          return false;
1764        }
1765
1766        public CodeableConcept addAction() { //3
1767          CodeableConcept t = new CodeableConcept();
1768          if (this.action == null)
1769            this.action = new ArrayList<CodeableConcept>();
1770          this.action.add(t);
1771          return t;
1772        }
1773
1774        public RuleActivityComponent addAction(CodeableConcept t) { //3
1775          if (t == null)
1776            return this;
1777          if (this.action == null)
1778            this.action = new ArrayList<CodeableConcept>();
1779          this.action.add(t);
1780          return this;
1781        }
1782
1783        /**
1784         * @return The first repetition of repeating field {@link #action}, creating it if it does not already exist {3}
1785         */
1786        public CodeableConcept getActionFirstRep() { 
1787          if (getAction().isEmpty()) {
1788            addAction();
1789          }
1790          return getAction().get(0);
1791        }
1792
1793        /**
1794         * @return {@link #purpose} (The purpose for which the permission is given.)
1795         */
1796        public List<CodeableConcept> getPurpose() { 
1797          if (this.purpose == null)
1798            this.purpose = new ArrayList<CodeableConcept>();
1799          return this.purpose;
1800        }
1801
1802        /**
1803         * @return Returns a reference to <code>this</code> for easy method chaining
1804         */
1805        public RuleActivityComponent setPurpose(List<CodeableConcept> thePurpose) { 
1806          this.purpose = thePurpose;
1807          return this;
1808        }
1809
1810        public boolean hasPurpose() { 
1811          if (this.purpose == null)
1812            return false;
1813          for (CodeableConcept item : this.purpose)
1814            if (!item.isEmpty())
1815              return true;
1816          return false;
1817        }
1818
1819        public CodeableConcept addPurpose() { //3
1820          CodeableConcept t = new CodeableConcept();
1821          if (this.purpose == null)
1822            this.purpose = new ArrayList<CodeableConcept>();
1823          this.purpose.add(t);
1824          return t;
1825        }
1826
1827        public RuleActivityComponent addPurpose(CodeableConcept t) { //3
1828          if (t == null)
1829            return this;
1830          if (this.purpose == null)
1831            this.purpose = new ArrayList<CodeableConcept>();
1832          this.purpose.add(t);
1833          return this;
1834        }
1835
1836        /**
1837         * @return The first repetition of repeating field {@link #purpose}, creating it if it does not already exist {3}
1838         */
1839        public CodeableConcept getPurposeFirstRep() { 
1840          if (getPurpose().isEmpty()) {
1841            addPurpose();
1842          }
1843          return getPurpose().get(0);
1844        }
1845
1846        protected void listChildren(List<Property> children) {
1847          super.listChildren(children);
1848          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));
1849          children.add(new Property("action", "CodeableConcept", "Actions controlled by this Rule.", 0, java.lang.Integer.MAX_VALUE, action));
1850          children.add(new Property("purpose", "CodeableConcept", "The purpose for which the permission is given.", 0, java.lang.Integer.MAX_VALUE, purpose));
1851        }
1852
1853        @Override
1854        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1855          switch (_hash) {
1856          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);
1857          case -1422950858: /*action*/  return new Property("action", "CodeableConcept", "Actions controlled by this Rule.", 0, java.lang.Integer.MAX_VALUE, action);
1858          case -220463842: /*purpose*/  return new Property("purpose", "CodeableConcept", "The purpose for which the permission is given.", 0, java.lang.Integer.MAX_VALUE, purpose);
1859          default: return super.getNamedProperty(_hash, _name, _checkValid);
1860          }
1861
1862        }
1863
1864      @Override
1865      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1866        switch (hash) {
1867        case 92645877: /*actor*/ return this.actor == null ? new Base[0] : this.actor.toArray(new Base[this.actor.size()]); // Reference
1868        case -1422950858: /*action*/ return this.action == null ? new Base[0] : this.action.toArray(new Base[this.action.size()]); // CodeableConcept
1869        case -220463842: /*purpose*/ return this.purpose == null ? new Base[0] : this.purpose.toArray(new Base[this.purpose.size()]); // CodeableConcept
1870        default: return super.getProperty(hash, name, checkValid);
1871        }
1872
1873      }
1874
1875      @Override
1876      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1877        switch (hash) {
1878        case 92645877: // actor
1879          this.getActor().add(TypeConvertor.castToReference(value)); // Reference
1880          return value;
1881        case -1422950858: // action
1882          this.getAction().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
1883          return value;
1884        case -220463842: // purpose
1885          this.getPurpose().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
1886          return value;
1887        default: return super.setProperty(hash, name, value);
1888        }
1889
1890      }
1891
1892      @Override
1893      public Base setProperty(String name, Base value) throws FHIRException {
1894        if (name.equals("actor")) {
1895          this.getActor().add(TypeConvertor.castToReference(value));
1896        } else if (name.equals("action")) {
1897          this.getAction().add(TypeConvertor.castToCodeableConcept(value));
1898        } else if (name.equals("purpose")) {
1899          this.getPurpose().add(TypeConvertor.castToCodeableConcept(value));
1900        } else
1901          return super.setProperty(name, value);
1902        return value;
1903      }
1904
1905      @Override
1906      public Base makeProperty(int hash, String name) throws FHIRException {
1907        switch (hash) {
1908        case 92645877:  return addActor(); 
1909        case -1422950858:  return addAction(); 
1910        case -220463842:  return addPurpose(); 
1911        default: return super.makeProperty(hash, name);
1912        }
1913
1914      }
1915
1916      @Override
1917      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1918        switch (hash) {
1919        case 92645877: /*actor*/ return new String[] {"Reference"};
1920        case -1422950858: /*action*/ return new String[] {"CodeableConcept"};
1921        case -220463842: /*purpose*/ return new String[] {"CodeableConcept"};
1922        default: return super.getTypesForProperty(hash, name);
1923        }
1924
1925      }
1926
1927      @Override
1928      public Base addChild(String name) throws FHIRException {
1929        if (name.equals("actor")) {
1930          return addActor();
1931        }
1932        else if (name.equals("action")) {
1933          return addAction();
1934        }
1935        else if (name.equals("purpose")) {
1936          return addPurpose();
1937        }
1938        else
1939          return super.addChild(name);
1940      }
1941
1942      public RuleActivityComponent copy() {
1943        RuleActivityComponent dst = new RuleActivityComponent();
1944        copyValues(dst);
1945        return dst;
1946      }
1947
1948      public void copyValues(RuleActivityComponent dst) {
1949        super.copyValues(dst);
1950        if (actor != null) {
1951          dst.actor = new ArrayList<Reference>();
1952          for (Reference i : actor)
1953            dst.actor.add(i.copy());
1954        };
1955        if (action != null) {
1956          dst.action = new ArrayList<CodeableConcept>();
1957          for (CodeableConcept i : action)
1958            dst.action.add(i.copy());
1959        };
1960        if (purpose != null) {
1961          dst.purpose = new ArrayList<CodeableConcept>();
1962          for (CodeableConcept i : purpose)
1963            dst.purpose.add(i.copy());
1964        };
1965      }
1966
1967      @Override
1968      public boolean equalsDeep(Base other_) {
1969        if (!super.equalsDeep(other_))
1970          return false;
1971        if (!(other_ instanceof RuleActivityComponent))
1972          return false;
1973        RuleActivityComponent o = (RuleActivityComponent) other_;
1974        return compareDeep(actor, o.actor, true) && compareDeep(action, o.action, true) && compareDeep(purpose, o.purpose, true)
1975          ;
1976      }
1977
1978      @Override
1979      public boolean equalsShallow(Base other_) {
1980        if (!super.equalsShallow(other_))
1981          return false;
1982        if (!(other_ instanceof RuleActivityComponent))
1983          return false;
1984        RuleActivityComponent o = (RuleActivityComponent) other_;
1985        return true;
1986      }
1987
1988      public boolean isEmpty() {
1989        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(actor, action, purpose);
1990      }
1991
1992  public String fhirType() {
1993    return "Permission.rule.activity";
1994
1995  }
1996
1997  }
1998
1999    /**
2000     * Status.
2001     */
2002    @Child(name = "status", type = {CodeType.class}, order=0, min=1, max=1, modifier=false, summary=true)
2003    @Description(shortDefinition="active | entered-in-error | draft | rejected", formalDefinition="Status." )
2004    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/permission-status")
2005    protected Enumeration<PermissionStatus> status;
2006
2007    /**
2008     * The person or entity that asserts the permission.
2009     */
2010    @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)
2011    @Description(shortDefinition="The person or entity that asserts the permission", formalDefinition="The person or entity that asserts the permission." )
2012    protected Reference asserter;
2013
2014    /**
2015     * The date that permission was asserted.
2016     */
2017    @Child(name = "date", type = {DateTimeType.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2018    @Description(shortDefinition="The date that permission was asserted", formalDefinition="The date that permission was asserted." )
2019    protected List<DateTimeType> date;
2020
2021    /**
2022     * The period in which the permission is active.
2023     */
2024    @Child(name = "validity", type = {Period.class}, order=3, min=0, max=1, modifier=false, summary=true)
2025    @Description(shortDefinition="The period in which the permission is active", formalDefinition="The period in which the permission is active." )
2026    protected Period validity;
2027
2028    /**
2029     * The asserted justification for using the data.
2030     */
2031    @Child(name = "justification", type = {}, order=4, min=0, max=1, modifier=false, summary=true)
2032    @Description(shortDefinition="The asserted justification for using the data", formalDefinition="The asserted justification for using the data." )
2033    protected PermissionJustificationComponent justification;
2034
2035    /**
2036     * Defines a procedure for arriving at an access decision given the set of rules.
2037     */
2038    @Child(name = "combining", type = {CodeType.class}, order=5, min=1, max=1, modifier=true, summary=true)
2039    @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." )
2040    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/permission-rule-combining")
2041    protected Enumeration<PermissionRuleCombining> combining;
2042
2043    /**
2044     * A set of rules.
2045     */
2046    @Child(name = "rule", type = {}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2047    @Description(shortDefinition="Constraints to the Permission", formalDefinition="A set of rules." )
2048    protected List<RuleComponent> rule;
2049
2050    private static final long serialVersionUID = 1252321973L;
2051
2052  /**
2053   * Constructor
2054   */
2055    public Permission() {
2056      super();
2057    }
2058
2059  /**
2060   * Constructor
2061   */
2062    public Permission(PermissionStatus status, PermissionRuleCombining combining) {
2063      super();
2064      this.setStatus(status);
2065      this.setCombining(combining);
2066    }
2067
2068    /**
2069     * @return {@link #status} (Status.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2070     */
2071    public Enumeration<PermissionStatus> getStatusElement() { 
2072      if (this.status == null)
2073        if (Configuration.errorOnAutoCreate())
2074          throw new Error("Attempt to auto-create Permission.status");
2075        else if (Configuration.doAutoCreate())
2076          this.status = new Enumeration<PermissionStatus>(new PermissionStatusEnumFactory()); // bb
2077      return this.status;
2078    }
2079
2080    public boolean hasStatusElement() { 
2081      return this.status != null && !this.status.isEmpty();
2082    }
2083
2084    public boolean hasStatus() { 
2085      return this.status != null && !this.status.isEmpty();
2086    }
2087
2088    /**
2089     * @param value {@link #status} (Status.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2090     */
2091    public Permission setStatusElement(Enumeration<PermissionStatus> value) { 
2092      this.status = value;
2093      return this;
2094    }
2095
2096    /**
2097     * @return Status.
2098     */
2099    public PermissionStatus getStatus() { 
2100      return this.status == null ? null : this.status.getValue();
2101    }
2102
2103    /**
2104     * @param value Status.
2105     */
2106    public Permission setStatus(PermissionStatus value) { 
2107        if (this.status == null)
2108          this.status = new Enumeration<PermissionStatus>(new PermissionStatusEnumFactory());
2109        this.status.setValue(value);
2110      return this;
2111    }
2112
2113    /**
2114     * @return {@link #asserter} (The person or entity that asserts the permission.)
2115     */
2116    public Reference getAsserter() { 
2117      if (this.asserter == null)
2118        if (Configuration.errorOnAutoCreate())
2119          throw new Error("Attempt to auto-create Permission.asserter");
2120        else if (Configuration.doAutoCreate())
2121          this.asserter = new Reference(); // cc
2122      return this.asserter;
2123    }
2124
2125    public boolean hasAsserter() { 
2126      return this.asserter != null && !this.asserter.isEmpty();
2127    }
2128
2129    /**
2130     * @param value {@link #asserter} (The person or entity that asserts the permission.)
2131     */
2132    public Permission setAsserter(Reference value) { 
2133      this.asserter = value;
2134      return this;
2135    }
2136
2137    /**
2138     * @return {@link #date} (The date that permission was asserted.)
2139     */
2140    public List<DateTimeType> getDate() { 
2141      if (this.date == null)
2142        this.date = new ArrayList<DateTimeType>();
2143      return this.date;
2144    }
2145
2146    /**
2147     * @return Returns a reference to <code>this</code> for easy method chaining
2148     */
2149    public Permission setDate(List<DateTimeType> theDate) { 
2150      this.date = theDate;
2151      return this;
2152    }
2153
2154    public boolean hasDate() { 
2155      if (this.date == null)
2156        return false;
2157      for (DateTimeType item : this.date)
2158        if (!item.isEmpty())
2159          return true;
2160      return false;
2161    }
2162
2163    /**
2164     * @return {@link #date} (The date that permission was asserted.)
2165     */
2166    public DateTimeType addDateElement() {//2 
2167      DateTimeType t = new DateTimeType();
2168      if (this.date == null)
2169        this.date = new ArrayList<DateTimeType>();
2170      this.date.add(t);
2171      return t;
2172    }
2173
2174    /**
2175     * @param value {@link #date} (The date that permission was asserted.)
2176     */
2177    public Permission addDate(Date value) { //1
2178      DateTimeType t = new DateTimeType();
2179      t.setValue(value);
2180      if (this.date == null)
2181        this.date = new ArrayList<DateTimeType>();
2182      this.date.add(t);
2183      return this;
2184    }
2185
2186    /**
2187     * @param value {@link #date} (The date that permission was asserted.)
2188     */
2189    public boolean hasDate(Date value) { 
2190      if (this.date == null)
2191        return false;
2192      for (DateTimeType v : this.date)
2193        if (v.getValue().equals(value)) // dateTime
2194          return true;
2195      return false;
2196    }
2197
2198    /**
2199     * @return {@link #validity} (The period in which the permission is active.)
2200     */
2201    public Period getValidity() { 
2202      if (this.validity == null)
2203        if (Configuration.errorOnAutoCreate())
2204          throw new Error("Attempt to auto-create Permission.validity");
2205        else if (Configuration.doAutoCreate())
2206          this.validity = new Period(); // cc
2207      return this.validity;
2208    }
2209
2210    public boolean hasValidity() { 
2211      return this.validity != null && !this.validity.isEmpty();
2212    }
2213
2214    /**
2215     * @param value {@link #validity} (The period in which the permission is active.)
2216     */
2217    public Permission setValidity(Period value) { 
2218      this.validity = value;
2219      return this;
2220    }
2221
2222    /**
2223     * @return {@link #justification} (The asserted justification for using the data.)
2224     */
2225    public PermissionJustificationComponent getJustification() { 
2226      if (this.justification == null)
2227        if (Configuration.errorOnAutoCreate())
2228          throw new Error("Attempt to auto-create Permission.justification");
2229        else if (Configuration.doAutoCreate())
2230          this.justification = new PermissionJustificationComponent(); // cc
2231      return this.justification;
2232    }
2233
2234    public boolean hasJustification() { 
2235      return this.justification != null && !this.justification.isEmpty();
2236    }
2237
2238    /**
2239     * @param value {@link #justification} (The asserted justification for using the data.)
2240     */
2241    public Permission setJustification(PermissionJustificationComponent value) { 
2242      this.justification = value;
2243      return this;
2244    }
2245
2246    /**
2247     * @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
2248     */
2249    public Enumeration<PermissionRuleCombining> getCombiningElement() { 
2250      if (this.combining == null)
2251        if (Configuration.errorOnAutoCreate())
2252          throw new Error("Attempt to auto-create Permission.combining");
2253        else if (Configuration.doAutoCreate())
2254          this.combining = new Enumeration<PermissionRuleCombining>(new PermissionRuleCombiningEnumFactory()); // bb
2255      return this.combining;
2256    }
2257
2258    public boolean hasCombiningElement() { 
2259      return this.combining != null && !this.combining.isEmpty();
2260    }
2261
2262    public boolean hasCombining() { 
2263      return this.combining != null && !this.combining.isEmpty();
2264    }
2265
2266    /**
2267     * @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
2268     */
2269    public Permission setCombiningElement(Enumeration<PermissionRuleCombining> value) { 
2270      this.combining = value;
2271      return this;
2272    }
2273
2274    /**
2275     * @return Defines a procedure for arriving at an access decision given the set of rules.
2276     */
2277    public PermissionRuleCombining getCombining() { 
2278      return this.combining == null ? null : this.combining.getValue();
2279    }
2280
2281    /**
2282     * @param value Defines a procedure for arriving at an access decision given the set of rules.
2283     */
2284    public Permission setCombining(PermissionRuleCombining value) { 
2285        if (this.combining == null)
2286          this.combining = new Enumeration<PermissionRuleCombining>(new PermissionRuleCombiningEnumFactory());
2287        this.combining.setValue(value);
2288      return this;
2289    }
2290
2291    /**
2292     * @return {@link #rule} (A set of rules.)
2293     */
2294    public List<RuleComponent> getRule() { 
2295      if (this.rule == null)
2296        this.rule = new ArrayList<RuleComponent>();
2297      return this.rule;
2298    }
2299
2300    /**
2301     * @return Returns a reference to <code>this</code> for easy method chaining
2302     */
2303    public Permission setRule(List<RuleComponent> theRule) { 
2304      this.rule = theRule;
2305      return this;
2306    }
2307
2308    public boolean hasRule() { 
2309      if (this.rule == null)
2310        return false;
2311      for (RuleComponent item : this.rule)
2312        if (!item.isEmpty())
2313          return true;
2314      return false;
2315    }
2316
2317    public RuleComponent addRule() { //3
2318      RuleComponent t = new RuleComponent();
2319      if (this.rule == null)
2320        this.rule = new ArrayList<RuleComponent>();
2321      this.rule.add(t);
2322      return t;
2323    }
2324
2325    public Permission addRule(RuleComponent t) { //3
2326      if (t == null)
2327        return this;
2328      if (this.rule == null)
2329        this.rule = new ArrayList<RuleComponent>();
2330      this.rule.add(t);
2331      return this;
2332    }
2333
2334    /**
2335     * @return The first repetition of repeating field {@link #rule}, creating it if it does not already exist {3}
2336     */
2337    public RuleComponent getRuleFirstRep() { 
2338      if (getRule().isEmpty()) {
2339        addRule();
2340      }
2341      return getRule().get(0);
2342    }
2343
2344      protected void listChildren(List<Property> children) {
2345        super.listChildren(children);
2346        children.add(new Property("status", "code", "Status.", 0, 1, status));
2347        children.add(new Property("asserter", "Reference(Practitioner|PractitionerRole|Organization|CareTeam|Patient|RelatedPerson|HealthcareService)", "The person or entity that asserts the permission.", 0, 1, asserter));
2348        children.add(new Property("date", "dateTime", "The date that permission was asserted.", 0, java.lang.Integer.MAX_VALUE, date));
2349        children.add(new Property("validity", "Period", "The period in which the permission is active.", 0, 1, validity));
2350        children.add(new Property("justification", "", "The asserted justification for using the data.", 0, 1, justification));
2351        children.add(new Property("combining", "code", "Defines a procedure for arriving at an access decision given the set of rules.", 0, 1, combining));
2352        children.add(new Property("rule", "", "A set of rules.", 0, java.lang.Integer.MAX_VALUE, rule));
2353      }
2354
2355      @Override
2356      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2357        switch (_hash) {
2358        case -892481550: /*status*/  return new Property("status", "code", "Status.", 0, 1, status);
2359        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);
2360        case 3076014: /*date*/  return new Property("date", "dateTime", "The date that permission was asserted.", 0, java.lang.Integer.MAX_VALUE, date);
2361        case -1421265102: /*validity*/  return new Property("validity", "Period", "The period in which the permission is active.", 0, 1, validity);
2362        case 1864993522: /*justification*/  return new Property("justification", "", "The asserted justification for using the data.", 0, 1, justification);
2363        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);
2364        case 3512060: /*rule*/  return new Property("rule", "", "A set of rules.", 0, java.lang.Integer.MAX_VALUE, rule);
2365        default: return super.getNamedProperty(_hash, _name, _checkValid);
2366        }
2367
2368      }
2369
2370      @Override
2371      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2372        switch (hash) {
2373        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<PermissionStatus>
2374        case -373242253: /*asserter*/ return this.asserter == null ? new Base[0] : new Base[] {this.asserter}; // Reference
2375        case 3076014: /*date*/ return this.date == null ? new Base[0] : this.date.toArray(new Base[this.date.size()]); // DateTimeType
2376        case -1421265102: /*validity*/ return this.validity == null ? new Base[0] : new Base[] {this.validity}; // Period
2377        case 1864993522: /*justification*/ return this.justification == null ? new Base[0] : new Base[] {this.justification}; // PermissionJustificationComponent
2378        case -1806252484: /*combining*/ return this.combining == null ? new Base[0] : new Base[] {this.combining}; // Enumeration<PermissionRuleCombining>
2379        case 3512060: /*rule*/ return this.rule == null ? new Base[0] : this.rule.toArray(new Base[this.rule.size()]); // RuleComponent
2380        default: return super.getProperty(hash, name, checkValid);
2381        }
2382
2383      }
2384
2385      @Override
2386      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2387        switch (hash) {
2388        case -892481550: // status
2389          value = new PermissionStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
2390          this.status = (Enumeration) value; // Enumeration<PermissionStatus>
2391          return value;
2392        case -373242253: // asserter
2393          this.asserter = TypeConvertor.castToReference(value); // Reference
2394          return value;
2395        case 3076014: // date
2396          this.getDate().add(TypeConvertor.castToDateTime(value)); // DateTimeType
2397          return value;
2398        case -1421265102: // validity
2399          this.validity = TypeConvertor.castToPeriod(value); // Period
2400          return value;
2401        case 1864993522: // justification
2402          this.justification = (PermissionJustificationComponent) value; // PermissionJustificationComponent
2403          return value;
2404        case -1806252484: // combining
2405          value = new PermissionRuleCombiningEnumFactory().fromType(TypeConvertor.castToCode(value));
2406          this.combining = (Enumeration) value; // Enumeration<PermissionRuleCombining>
2407          return value;
2408        case 3512060: // rule
2409          this.getRule().add((RuleComponent) value); // RuleComponent
2410          return value;
2411        default: return super.setProperty(hash, name, value);
2412        }
2413
2414      }
2415
2416      @Override
2417      public Base setProperty(String name, Base value) throws FHIRException {
2418        if (name.equals("status")) {
2419          value = new PermissionStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
2420          this.status = (Enumeration) value; // Enumeration<PermissionStatus>
2421        } else if (name.equals("asserter")) {
2422          this.asserter = TypeConvertor.castToReference(value); // Reference
2423        } else if (name.equals("date")) {
2424          this.getDate().add(TypeConvertor.castToDateTime(value));
2425        } else if (name.equals("validity")) {
2426          this.validity = TypeConvertor.castToPeriod(value); // Period
2427        } else if (name.equals("justification")) {
2428          this.justification = (PermissionJustificationComponent) value; // PermissionJustificationComponent
2429        } else if (name.equals("combining")) {
2430          value = new PermissionRuleCombiningEnumFactory().fromType(TypeConvertor.castToCode(value));
2431          this.combining = (Enumeration) value; // Enumeration<PermissionRuleCombining>
2432        } else if (name.equals("rule")) {
2433          this.getRule().add((RuleComponent) value);
2434        } else
2435          return super.setProperty(name, value);
2436        return value;
2437      }
2438
2439      @Override
2440      public Base makeProperty(int hash, String name) throws FHIRException {
2441        switch (hash) {
2442        case -892481550:  return getStatusElement();
2443        case -373242253:  return getAsserter();
2444        case 3076014:  return addDateElement();
2445        case -1421265102:  return getValidity();
2446        case 1864993522:  return getJustification();
2447        case -1806252484:  return getCombiningElement();
2448        case 3512060:  return addRule(); 
2449        default: return super.makeProperty(hash, name);
2450        }
2451
2452      }
2453
2454      @Override
2455      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2456        switch (hash) {
2457        case -892481550: /*status*/ return new String[] {"code"};
2458        case -373242253: /*asserter*/ return new String[] {"Reference"};
2459        case 3076014: /*date*/ return new String[] {"dateTime"};
2460        case -1421265102: /*validity*/ return new String[] {"Period"};
2461        case 1864993522: /*justification*/ return new String[] {};
2462        case -1806252484: /*combining*/ return new String[] {"code"};
2463        case 3512060: /*rule*/ return new String[] {};
2464        default: return super.getTypesForProperty(hash, name);
2465        }
2466
2467      }
2468
2469      @Override
2470      public Base addChild(String name) throws FHIRException {
2471        if (name.equals("status")) {
2472          throw new FHIRException("Cannot call addChild on a singleton property Permission.status");
2473        }
2474        else if (name.equals("asserter")) {
2475          this.asserter = new Reference();
2476          return this.asserter;
2477        }
2478        else if (name.equals("date")) {
2479          throw new FHIRException("Cannot call addChild on a singleton property Permission.date");
2480        }
2481        else if (name.equals("validity")) {
2482          this.validity = new Period();
2483          return this.validity;
2484        }
2485        else if (name.equals("justification")) {
2486          this.justification = new PermissionJustificationComponent();
2487          return this.justification;
2488        }
2489        else if (name.equals("combining")) {
2490          throw new FHIRException("Cannot call addChild on a singleton property Permission.combining");
2491        }
2492        else if (name.equals("rule")) {
2493          return addRule();
2494        }
2495        else
2496          return super.addChild(name);
2497      }
2498
2499  public String fhirType() {
2500    return "Permission";
2501
2502  }
2503
2504      public Permission copy() {
2505        Permission dst = new Permission();
2506        copyValues(dst);
2507        return dst;
2508      }
2509
2510      public void copyValues(Permission dst) {
2511        super.copyValues(dst);
2512        dst.status = status == null ? null : status.copy();
2513        dst.asserter = asserter == null ? null : asserter.copy();
2514        if (date != null) {
2515          dst.date = new ArrayList<DateTimeType>();
2516          for (DateTimeType i : date)
2517            dst.date.add(i.copy());
2518        };
2519        dst.validity = validity == null ? null : validity.copy();
2520        dst.justification = justification == null ? null : justification.copy();
2521        dst.combining = combining == null ? null : combining.copy();
2522        if (rule != null) {
2523          dst.rule = new ArrayList<RuleComponent>();
2524          for (RuleComponent i : rule)
2525            dst.rule.add(i.copy());
2526        };
2527      }
2528
2529      protected Permission typedCopy() {
2530        return copy();
2531      }
2532
2533      @Override
2534      public boolean equalsDeep(Base other_) {
2535        if (!super.equalsDeep(other_))
2536          return false;
2537        if (!(other_ instanceof Permission))
2538          return false;
2539        Permission o = (Permission) other_;
2540        return compareDeep(status, o.status, true) && compareDeep(asserter, o.asserter, true) && compareDeep(date, o.date, true)
2541           && compareDeep(validity, o.validity, true) && compareDeep(justification, o.justification, true)
2542           && compareDeep(combining, o.combining, true) && compareDeep(rule, o.rule, true);
2543      }
2544
2545      @Override
2546      public boolean equalsShallow(Base other_) {
2547        if (!super.equalsShallow(other_))
2548          return false;
2549        if (!(other_ instanceof Permission))
2550          return false;
2551        Permission o = (Permission) other_;
2552        return compareValues(status, o.status, true) && compareValues(date, o.date, true) && compareValues(combining, o.combining, true)
2553          ;
2554      }
2555
2556      public boolean isEmpty() {
2557        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(status, asserter, date, validity
2558          , justification, combining, rule);
2559      }
2560
2561  @Override
2562  public ResourceType getResourceType() {
2563    return ResourceType.Permission;
2564   }
2565
2566 /**
2567   * Search parameter: <b>status</b>
2568   * <p>
2569   * Description: <b>active | entered-in-error | draft | rejected</b><br>
2570   * Type: <b>token</b><br>
2571   * Path: <b>Permission.status</b><br>
2572   * </p>
2573   */
2574  @SearchParamDefinition(name="status", path="Permission.status", description="active | entered-in-error | draft | rejected", type="token" )
2575  public static final String SP_STATUS = "status";
2576 /**
2577   * <b>Fluent Client</b> search parameter constant for <b>status</b>
2578   * <p>
2579   * Description: <b>active | entered-in-error | draft | rejected</b><br>
2580   * Type: <b>token</b><br>
2581   * Path: <b>Permission.status</b><br>
2582   * </p>
2583   */
2584  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
2585
2586
2587}
2588