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 Tue, Dec 28, 2021 07:16+1100 for FHIR v5.0.0-snapshot1
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.
052 */
053@ResourceDef(name="Permission", profile="http://hl7.org/fhir/StructureDefinition/Permission")
054public class Permission extends DomainResource {
055
056    public enum PermissionStatus {
057        /**
058         * Permission is given.
059         */
060        ACTIVE, 
061        /**
062         * Permission was entered in error and is not active.
063         */
064        ENTEREDINERROR, 
065        /**
066         * Permission is being defined.
067         */
068        DRAFT, 
069        /**
070         * Permission not granted.
071         */
072        REJECTED, 
073        /**
074         * added to help the parsers with the generic types
075         */
076        NULL;
077        public static PermissionStatus fromCode(String codeString) throws FHIRException {
078            if (codeString == null || "".equals(codeString))
079                return null;
080        if ("active".equals(codeString))
081          return ACTIVE;
082        if ("entered-in-error".equals(codeString))
083          return ENTEREDINERROR;
084        if ("draft".equals(codeString))
085          return DRAFT;
086        if ("rejected".equals(codeString))
087          return REJECTED;
088        if (Configuration.isAcceptInvalidEnums())
089          return null;
090        else
091          throw new FHIRException("Unknown PermissionStatus code '"+codeString+"'");
092        }
093        public String toCode() {
094          switch (this) {
095            case ACTIVE: return "active";
096            case ENTEREDINERROR: return "entered-in-error";
097            case DRAFT: return "draft";
098            case REJECTED: return "rejected";
099            default: return "?";
100          }
101        }
102        public String getSystem() {
103          switch (this) {
104            case ACTIVE: return "http://hl7.org/fhir/permission-status";
105            case ENTEREDINERROR: return "http://hl7.org/fhir/permission-status";
106            case DRAFT: return "http://hl7.org/fhir/permission-status";
107            case REJECTED: return "http://hl7.org/fhir/permission-status";
108            default: return "?";
109          }
110        }
111        public String getDefinition() {
112          switch (this) {
113            case ACTIVE: return "Permission is given.";
114            case ENTEREDINERROR: return "Permission was entered in error and is not active.";
115            case DRAFT: return "Permission is being defined.";
116            case REJECTED: return "Permission not granted.";
117            default: return "?";
118          }
119        }
120        public String getDisplay() {
121          switch (this) {
122            case ACTIVE: return "Active";
123            case ENTEREDINERROR: return "Entered in Error";
124            case DRAFT: return "Draft";
125            case REJECTED: return "Rejected";
126            default: return "?";
127          }
128        }
129    }
130
131  public static class PermissionStatusEnumFactory implements EnumFactory<PermissionStatus> {
132    public PermissionStatus fromCode(String codeString) throws IllegalArgumentException {
133      if (codeString == null || "".equals(codeString))
134            if (codeString == null || "".equals(codeString))
135                return null;
136        if ("active".equals(codeString))
137          return PermissionStatus.ACTIVE;
138        if ("entered-in-error".equals(codeString))
139          return PermissionStatus.ENTEREDINERROR;
140        if ("draft".equals(codeString))
141          return PermissionStatus.DRAFT;
142        if ("rejected".equals(codeString))
143          return PermissionStatus.REJECTED;
144        throw new IllegalArgumentException("Unknown PermissionStatus code '"+codeString+"'");
145        }
146        public Enumeration<PermissionStatus> fromType(Base code) throws FHIRException {
147          if (code == null)
148            return null;
149          if (code.isEmpty())
150            return new Enumeration<PermissionStatus>(this);
151          String codeString = ((PrimitiveType) code).asStringValue();
152          if (codeString == null || "".equals(codeString))
153            return null;
154        if ("active".equals(codeString))
155          return new Enumeration<PermissionStatus>(this, PermissionStatus.ACTIVE);
156        if ("entered-in-error".equals(codeString))
157          return new Enumeration<PermissionStatus>(this, PermissionStatus.ENTEREDINERROR);
158        if ("draft".equals(codeString))
159          return new Enumeration<PermissionStatus>(this, PermissionStatus.DRAFT);
160        if ("rejected".equals(codeString))
161          return new Enumeration<PermissionStatus>(this, PermissionStatus.REJECTED);
162        throw new FHIRException("Unknown PermissionStatus code '"+codeString+"'");
163        }
164    public String toCode(PermissionStatus code) {
165      if (code == PermissionStatus.ACTIVE)
166        return "active";
167      if (code == PermissionStatus.ENTEREDINERROR)
168        return "entered-in-error";
169      if (code == PermissionStatus.DRAFT)
170        return "draft";
171      if (code == PermissionStatus.REJECTED)
172        return "rejected";
173      return "?";
174      }
175    public String toSystem(PermissionStatus code) {
176      return code.getSystem();
177      }
178    }
179
180    @Block()
181    public static class PermissionProcessingActivityComponent extends BackboneElement implements IBaseBackboneElement {
182        /**
183         * If the processing is a transfer, we must capture where it the data allowed or expected to be shared - with a party or person.
184         */
185        @Child(name = "partyReference", type = {Organization.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
186        @Description(shortDefinition="If the processing is a transfer, we must capture where it the data allowed or expected to be shared - with a party or person", formalDefinition="If the processing is a transfer, we must capture where it the data allowed or expected to be shared - with a party or person." )
187        protected List<Reference> partyReference;
188
189        /**
190         * If the processing is a transfer, or involves another party, we must capture where it the data allowed or expected to be shared - with a party or person. This can be a party instance or party type
191§ Purpose – a specific purpose of the data.
192         */
193        @Child(name = "partyCodeableConcept", type = {CodeableConcept.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
194        @Description(shortDefinition="If the processing is a transfer, or involves another party, we must capture where it the data allowed or expected to be shared - with a party or person. This can be a party instance or party type\n§ Purpose – a specific purpose of the data", formalDefinition="If the processing is a transfer, or involves another party, we must capture where it the data allowed or expected to be shared - with a party or person. This can be a party instance or party type\n§ Purpose – a specific purpose of the data." )
195        protected List<CodeableConcept> partyCodeableConcept;
196
197        /**
198         * The purpose for which the permission is given.
199         */
200        @Child(name = "purpose", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
201        @Description(shortDefinition="The purpose for which the permission is given", formalDefinition="The purpose for which the permission is given." )
202        protected List<CodeableConcept> purpose;
203
204        private static final long serialVersionUID = -1556351771L;
205
206    /**
207     * Constructor
208     */
209      public PermissionProcessingActivityComponent() {
210        super();
211      }
212
213        /**
214         * @return {@link #partyReference} (If the processing is a transfer, we must capture where it the data allowed or expected to be shared - with a party or person.)
215         */
216        public List<Reference> getPartyReference() { 
217          if (this.partyReference == null)
218            this.partyReference = new ArrayList<Reference>();
219          return this.partyReference;
220        }
221
222        /**
223         * @return Returns a reference to <code>this</code> for easy method chaining
224         */
225        public PermissionProcessingActivityComponent setPartyReference(List<Reference> thePartyReference) { 
226          this.partyReference = thePartyReference;
227          return this;
228        }
229
230        public boolean hasPartyReference() { 
231          if (this.partyReference == null)
232            return false;
233          for (Reference item : this.partyReference)
234            if (!item.isEmpty())
235              return true;
236          return false;
237        }
238
239        public Reference addPartyReference() { //3
240          Reference t = new Reference();
241          if (this.partyReference == null)
242            this.partyReference = new ArrayList<Reference>();
243          this.partyReference.add(t);
244          return t;
245        }
246
247        public PermissionProcessingActivityComponent addPartyReference(Reference t) { //3
248          if (t == null)
249            return this;
250          if (this.partyReference == null)
251            this.partyReference = new ArrayList<Reference>();
252          this.partyReference.add(t);
253          return this;
254        }
255
256        /**
257         * @return The first repetition of repeating field {@link #partyReference}, creating it if it does not already exist {3}
258         */
259        public Reference getPartyReferenceFirstRep() { 
260          if (getPartyReference().isEmpty()) {
261            addPartyReference();
262          }
263          return getPartyReference().get(0);
264        }
265
266        /**
267         * @return {@link #partyCodeableConcept} (If the processing is a transfer, or involves another party, we must capture where it the data allowed or expected to be shared - with a party or person. This can be a party instance or party type
268§ Purpose – a specific purpose of the data.)
269         */
270        public List<CodeableConcept> getPartyCodeableConcept() { 
271          if (this.partyCodeableConcept == null)
272            this.partyCodeableConcept = new ArrayList<CodeableConcept>();
273          return this.partyCodeableConcept;
274        }
275
276        /**
277         * @return Returns a reference to <code>this</code> for easy method chaining
278         */
279        public PermissionProcessingActivityComponent setPartyCodeableConcept(List<CodeableConcept> thePartyCodeableConcept) { 
280          this.partyCodeableConcept = thePartyCodeableConcept;
281          return this;
282        }
283
284        public boolean hasPartyCodeableConcept() { 
285          if (this.partyCodeableConcept == null)
286            return false;
287          for (CodeableConcept item : this.partyCodeableConcept)
288            if (!item.isEmpty())
289              return true;
290          return false;
291        }
292
293        public CodeableConcept addPartyCodeableConcept() { //3
294          CodeableConcept t = new CodeableConcept();
295          if (this.partyCodeableConcept == null)
296            this.partyCodeableConcept = new ArrayList<CodeableConcept>();
297          this.partyCodeableConcept.add(t);
298          return t;
299        }
300
301        public PermissionProcessingActivityComponent addPartyCodeableConcept(CodeableConcept t) { //3
302          if (t == null)
303            return this;
304          if (this.partyCodeableConcept == null)
305            this.partyCodeableConcept = new ArrayList<CodeableConcept>();
306          this.partyCodeableConcept.add(t);
307          return this;
308        }
309
310        /**
311         * @return The first repetition of repeating field {@link #partyCodeableConcept}, creating it if it does not already exist {3}
312         */
313        public CodeableConcept getPartyCodeableConceptFirstRep() { 
314          if (getPartyCodeableConcept().isEmpty()) {
315            addPartyCodeableConcept();
316          }
317          return getPartyCodeableConcept().get(0);
318        }
319
320        /**
321         * @return {@link #purpose} (The purpose for which the permission is given.)
322         */
323        public List<CodeableConcept> getPurpose() { 
324          if (this.purpose == null)
325            this.purpose = new ArrayList<CodeableConcept>();
326          return this.purpose;
327        }
328
329        /**
330         * @return Returns a reference to <code>this</code> for easy method chaining
331         */
332        public PermissionProcessingActivityComponent setPurpose(List<CodeableConcept> thePurpose) { 
333          this.purpose = thePurpose;
334          return this;
335        }
336
337        public boolean hasPurpose() { 
338          if (this.purpose == null)
339            return false;
340          for (CodeableConcept item : this.purpose)
341            if (!item.isEmpty())
342              return true;
343          return false;
344        }
345
346        public CodeableConcept addPurpose() { //3
347          CodeableConcept t = new CodeableConcept();
348          if (this.purpose == null)
349            this.purpose = new ArrayList<CodeableConcept>();
350          this.purpose.add(t);
351          return t;
352        }
353
354        public PermissionProcessingActivityComponent addPurpose(CodeableConcept t) { //3
355          if (t == null)
356            return this;
357          if (this.purpose == null)
358            this.purpose = new ArrayList<CodeableConcept>();
359          this.purpose.add(t);
360          return this;
361        }
362
363        /**
364         * @return The first repetition of repeating field {@link #purpose}, creating it if it does not already exist {3}
365         */
366        public CodeableConcept getPurposeFirstRep() { 
367          if (getPurpose().isEmpty()) {
368            addPurpose();
369          }
370          return getPurpose().get(0);
371        }
372
373        protected void listChildren(List<Property> children) {
374          super.listChildren(children);
375          children.add(new Property("partyReference", "Reference(Organization)", "If the processing is a transfer, we must capture where it the data allowed or expected to be shared - with a party or person.", 0, java.lang.Integer.MAX_VALUE, partyReference));
376          children.add(new Property("partyCodeableConcept", "CodeableConcept", "If the processing is a transfer, or involves another party, we must capture where it the data allowed or expected to be shared - with a party or person. This can be a party instance or party type\n§ Purpose – a specific purpose of the data.", 0, java.lang.Integer.MAX_VALUE, partyCodeableConcept));
377          children.add(new Property("purpose", "CodeableConcept", "The purpose for which the permission is given.", 0, java.lang.Integer.MAX_VALUE, purpose));
378        }
379
380        @Override
381        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
382          switch (_hash) {
383          case -865196283: /*partyReference*/  return new Property("partyReference", "Reference(Organization)", "If the processing is a transfer, we must capture where it the data allowed or expected to be shared - with a party or person.", 0, java.lang.Integer.MAX_VALUE, partyReference);
384          case -1283677221: /*partyCodeableConcept*/  return new Property("partyCodeableConcept", "CodeableConcept", "If the processing is a transfer, or involves another party, we must capture where it the data allowed or expected to be shared - with a party or person. This can be a party instance or party type\n§ Purpose – a specific purpose of the data.", 0, java.lang.Integer.MAX_VALUE, partyCodeableConcept);
385          case -220463842: /*purpose*/  return new Property("purpose", "CodeableConcept", "The purpose for which the permission is given.", 0, java.lang.Integer.MAX_VALUE, purpose);
386          default: return super.getNamedProperty(_hash, _name, _checkValid);
387          }
388
389        }
390
391      @Override
392      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
393        switch (hash) {
394        case -865196283: /*partyReference*/ return this.partyReference == null ? new Base[0] : this.partyReference.toArray(new Base[this.partyReference.size()]); // Reference
395        case -1283677221: /*partyCodeableConcept*/ return this.partyCodeableConcept == null ? new Base[0] : this.partyCodeableConcept.toArray(new Base[this.partyCodeableConcept.size()]); // CodeableConcept
396        case -220463842: /*purpose*/ return this.purpose == null ? new Base[0] : this.purpose.toArray(new Base[this.purpose.size()]); // CodeableConcept
397        default: return super.getProperty(hash, name, checkValid);
398        }
399
400      }
401
402      @Override
403      public Base setProperty(int hash, String name, Base value) throws FHIRException {
404        switch (hash) {
405        case -865196283: // partyReference
406          this.getPartyReference().add(TypeConvertor.castToReference(value)); // Reference
407          return value;
408        case -1283677221: // partyCodeableConcept
409          this.getPartyCodeableConcept().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
410          return value;
411        case -220463842: // purpose
412          this.getPurpose().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
413          return value;
414        default: return super.setProperty(hash, name, value);
415        }
416
417      }
418
419      @Override
420      public Base setProperty(String name, Base value) throws FHIRException {
421        if (name.equals("partyReference")) {
422          this.getPartyReference().add(TypeConvertor.castToReference(value));
423        } else if (name.equals("partyCodeableConcept")) {
424          this.getPartyCodeableConcept().add(TypeConvertor.castToCodeableConcept(value));
425        } else if (name.equals("purpose")) {
426          this.getPurpose().add(TypeConvertor.castToCodeableConcept(value));
427        } else
428          return super.setProperty(name, value);
429        return value;
430      }
431
432      @Override
433      public Base makeProperty(int hash, String name) throws FHIRException {
434        switch (hash) {
435        case -865196283:  return addPartyReference(); 
436        case -1283677221:  return addPartyCodeableConcept(); 
437        case -220463842:  return addPurpose(); 
438        default: return super.makeProperty(hash, name);
439        }
440
441      }
442
443      @Override
444      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
445        switch (hash) {
446        case -865196283: /*partyReference*/ return new String[] {"Reference"};
447        case -1283677221: /*partyCodeableConcept*/ return new String[] {"CodeableConcept"};
448        case -220463842: /*purpose*/ return new String[] {"CodeableConcept"};
449        default: return super.getTypesForProperty(hash, name);
450        }
451
452      }
453
454      @Override
455      public Base addChild(String name) throws FHIRException {
456        if (name.equals("partyReference")) {
457          return addPartyReference();
458        }
459        else if (name.equals("partyCodeableConcept")) {
460          return addPartyCodeableConcept();
461        }
462        else if (name.equals("purpose")) {
463          return addPurpose();
464        }
465        else
466          return super.addChild(name);
467      }
468
469      public PermissionProcessingActivityComponent copy() {
470        PermissionProcessingActivityComponent dst = new PermissionProcessingActivityComponent();
471        copyValues(dst);
472        return dst;
473      }
474
475      public void copyValues(PermissionProcessingActivityComponent dst) {
476        super.copyValues(dst);
477        if (partyReference != null) {
478          dst.partyReference = new ArrayList<Reference>();
479          for (Reference i : partyReference)
480            dst.partyReference.add(i.copy());
481        };
482        if (partyCodeableConcept != null) {
483          dst.partyCodeableConcept = new ArrayList<CodeableConcept>();
484          for (CodeableConcept i : partyCodeableConcept)
485            dst.partyCodeableConcept.add(i.copy());
486        };
487        if (purpose != null) {
488          dst.purpose = new ArrayList<CodeableConcept>();
489          for (CodeableConcept i : purpose)
490            dst.purpose.add(i.copy());
491        };
492      }
493
494      @Override
495      public boolean equalsDeep(Base other_) {
496        if (!super.equalsDeep(other_))
497          return false;
498        if (!(other_ instanceof PermissionProcessingActivityComponent))
499          return false;
500        PermissionProcessingActivityComponent o = (PermissionProcessingActivityComponent) other_;
501        return compareDeep(partyReference, o.partyReference, true) && compareDeep(partyCodeableConcept, o.partyCodeableConcept, true)
502           && compareDeep(purpose, o.purpose, true);
503      }
504
505      @Override
506      public boolean equalsShallow(Base other_) {
507        if (!super.equalsShallow(other_))
508          return false;
509        if (!(other_ instanceof PermissionProcessingActivityComponent))
510          return false;
511        PermissionProcessingActivityComponent o = (PermissionProcessingActivityComponent) other_;
512        return true;
513      }
514
515      public boolean isEmpty() {
516        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(partyReference, partyCodeableConcept
517          , purpose);
518      }
519
520  public String fhirType() {
521    return "Permission.processingActivity";
522
523  }
524
525  }
526
527    @Block()
528    public static class PermissionJustificationComponent extends BackboneElement implements IBaseBackboneElement {
529        /**
530         * Evidence – reference to consent, or a contract, or a policy, or a regulation, or an attachment that contains a screenshot.
531         */
532        @Child(name = "evidence", type = {Consent.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
533        @Description(shortDefinition="Evidence – reference to consent, or a contract, or a policy, or a regulation, or an attachment that contains a screenshot", formalDefinition="Evidence – reference to consent, or a contract, or a policy, or a regulation, or an attachment that contains a screenshot." )
534        protected List<Reference> evidence;
535
536        /**
537         * This would be a codeableconcept, or a coding, which can be constrained to , for example, the 6 grounds for processing in GDPR.
538         */
539        @Child(name = "grounds", type = {CodeableConcept.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
540        @Description(shortDefinition="This would be a codeableconcept, or a coding, which can be constrained to , for example, the 6 grounds for processing in GDPR", formalDefinition="This would be a codeableconcept, or a coding, which can be constrained to , for example, the 6 grounds for processing in GDPR." )
541        protected List<CodeableConcept> grounds;
542
543        private static final long serialVersionUID = -146214493L;
544
545    /**
546     * Constructor
547     */
548      public PermissionJustificationComponent() {
549        super();
550      }
551
552        /**
553         * @return {@link #evidence} (Evidence – reference to consent, or a contract, or a policy, or a regulation, or an attachment that contains a screenshot.)
554         */
555        public List<Reference> getEvidence() { 
556          if (this.evidence == null)
557            this.evidence = new ArrayList<Reference>();
558          return this.evidence;
559        }
560
561        /**
562         * @return Returns a reference to <code>this</code> for easy method chaining
563         */
564        public PermissionJustificationComponent setEvidence(List<Reference> theEvidence) { 
565          this.evidence = theEvidence;
566          return this;
567        }
568
569        public boolean hasEvidence() { 
570          if (this.evidence == null)
571            return false;
572          for (Reference item : this.evidence)
573            if (!item.isEmpty())
574              return true;
575          return false;
576        }
577
578        public Reference addEvidence() { //3
579          Reference t = new Reference();
580          if (this.evidence == null)
581            this.evidence = new ArrayList<Reference>();
582          this.evidence.add(t);
583          return t;
584        }
585
586        public PermissionJustificationComponent addEvidence(Reference t) { //3
587          if (t == null)
588            return this;
589          if (this.evidence == null)
590            this.evidence = new ArrayList<Reference>();
591          this.evidence.add(t);
592          return this;
593        }
594
595        /**
596         * @return The first repetition of repeating field {@link #evidence}, creating it if it does not already exist {3}
597         */
598        public Reference getEvidenceFirstRep() { 
599          if (getEvidence().isEmpty()) {
600            addEvidence();
601          }
602          return getEvidence().get(0);
603        }
604
605        /**
606         * @return {@link #grounds} (This would be a codeableconcept, or a coding, which can be constrained to , for example, the 6 grounds for processing in GDPR.)
607         */
608        public List<CodeableConcept> getGrounds() { 
609          if (this.grounds == null)
610            this.grounds = new ArrayList<CodeableConcept>();
611          return this.grounds;
612        }
613
614        /**
615         * @return Returns a reference to <code>this</code> for easy method chaining
616         */
617        public PermissionJustificationComponent setGrounds(List<CodeableConcept> theGrounds) { 
618          this.grounds = theGrounds;
619          return this;
620        }
621
622        public boolean hasGrounds() { 
623          if (this.grounds == null)
624            return false;
625          for (CodeableConcept item : this.grounds)
626            if (!item.isEmpty())
627              return true;
628          return false;
629        }
630
631        public CodeableConcept addGrounds() { //3
632          CodeableConcept t = new CodeableConcept();
633          if (this.grounds == null)
634            this.grounds = new ArrayList<CodeableConcept>();
635          this.grounds.add(t);
636          return t;
637        }
638
639        public PermissionJustificationComponent addGrounds(CodeableConcept t) { //3
640          if (t == null)
641            return this;
642          if (this.grounds == null)
643            this.grounds = new ArrayList<CodeableConcept>();
644          this.grounds.add(t);
645          return this;
646        }
647
648        /**
649         * @return The first repetition of repeating field {@link #grounds}, creating it if it does not already exist {3}
650         */
651        public CodeableConcept getGroundsFirstRep() { 
652          if (getGrounds().isEmpty()) {
653            addGrounds();
654          }
655          return getGrounds().get(0);
656        }
657
658        protected void listChildren(List<Property> children) {
659          super.listChildren(children);
660          children.add(new Property("evidence", "Reference(Consent)", "Evidence – reference to consent, or a contract, or a policy, or a regulation, or an attachment that contains a screenshot.", 0, java.lang.Integer.MAX_VALUE, evidence));
661          children.add(new Property("grounds", "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, grounds));
662        }
663
664        @Override
665        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
666          switch (_hash) {
667          case 382967383: /*evidence*/  return new Property("evidence", "Reference(Consent)", "Evidence – reference to consent, or a contract, or a policy, or a regulation, or an attachment that contains a screenshot.", 0, java.lang.Integer.MAX_VALUE, evidence);
668          case 293427148: /*grounds*/  return new Property("grounds", "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, grounds);
669          default: return super.getNamedProperty(_hash, _name, _checkValid);
670          }
671
672        }
673
674      @Override
675      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
676        switch (hash) {
677        case 382967383: /*evidence*/ return this.evidence == null ? new Base[0] : this.evidence.toArray(new Base[this.evidence.size()]); // Reference
678        case 293427148: /*grounds*/ return this.grounds == null ? new Base[0] : this.grounds.toArray(new Base[this.grounds.size()]); // CodeableConcept
679        default: return super.getProperty(hash, name, checkValid);
680        }
681
682      }
683
684      @Override
685      public Base setProperty(int hash, String name, Base value) throws FHIRException {
686        switch (hash) {
687        case 382967383: // evidence
688          this.getEvidence().add(TypeConvertor.castToReference(value)); // Reference
689          return value;
690        case 293427148: // grounds
691          this.getGrounds().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
692          return value;
693        default: return super.setProperty(hash, name, value);
694        }
695
696      }
697
698      @Override
699      public Base setProperty(String name, Base value) throws FHIRException {
700        if (name.equals("evidence")) {
701          this.getEvidence().add(TypeConvertor.castToReference(value));
702        } else if (name.equals("grounds")) {
703          this.getGrounds().add(TypeConvertor.castToCodeableConcept(value));
704        } else
705          return super.setProperty(name, value);
706        return value;
707      }
708
709      @Override
710      public Base makeProperty(int hash, String name) throws FHIRException {
711        switch (hash) {
712        case 382967383:  return addEvidence(); 
713        case 293427148:  return addGrounds(); 
714        default: return super.makeProperty(hash, name);
715        }
716
717      }
718
719      @Override
720      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
721        switch (hash) {
722        case 382967383: /*evidence*/ return new String[] {"Reference"};
723        case 293427148: /*grounds*/ return new String[] {"CodeableConcept"};
724        default: return super.getTypesForProperty(hash, name);
725        }
726
727      }
728
729      @Override
730      public Base addChild(String name) throws FHIRException {
731        if (name.equals("evidence")) {
732          return addEvidence();
733        }
734        else if (name.equals("grounds")) {
735          return addGrounds();
736        }
737        else
738          return super.addChild(name);
739      }
740
741      public PermissionJustificationComponent copy() {
742        PermissionJustificationComponent dst = new PermissionJustificationComponent();
743        copyValues(dst);
744        return dst;
745      }
746
747      public void copyValues(PermissionJustificationComponent dst) {
748        super.copyValues(dst);
749        if (evidence != null) {
750          dst.evidence = new ArrayList<Reference>();
751          for (Reference i : evidence)
752            dst.evidence.add(i.copy());
753        };
754        if (grounds != null) {
755          dst.grounds = new ArrayList<CodeableConcept>();
756          for (CodeableConcept i : grounds)
757            dst.grounds.add(i.copy());
758        };
759      }
760
761      @Override
762      public boolean equalsDeep(Base other_) {
763        if (!super.equalsDeep(other_))
764          return false;
765        if (!(other_ instanceof PermissionJustificationComponent))
766          return false;
767        PermissionJustificationComponent o = (PermissionJustificationComponent) other_;
768        return compareDeep(evidence, o.evidence, true) && compareDeep(grounds, o.grounds, true);
769      }
770
771      @Override
772      public boolean equalsShallow(Base other_) {
773        if (!super.equalsShallow(other_))
774          return false;
775        if (!(other_ instanceof PermissionJustificationComponent))
776          return false;
777        PermissionJustificationComponent o = (PermissionJustificationComponent) other_;
778        return true;
779      }
780
781      public boolean isEmpty() {
782        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(evidence, grounds);
783      }
784
785  public String fhirType() {
786    return "Permission.justification";
787
788  }
789
790  }
791
792    /**
793     * Status.
794     */
795    @Child(name = "status", type = {CodeType.class}, order=0, min=1, max=1, modifier=false, summary=true)
796    @Description(shortDefinition="active | entered-in-error | draft | rejected", formalDefinition="Status." )
797    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/permission-status")
798    protected Enumeration<PermissionStatus> status;
799
800    /**
801     * grant|refuse.
802     */
803    @Child(name = "intent", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
804    @Description(shortDefinition="grant|refuse", formalDefinition="grant|refuse." )
805    protected CodeableConcept intent;
806
807    /**
808     * The person or entity that asserts the permission.
809     */
810    @Child(name = "asserter", type = {Person.class}, order=2, min=0, max=1, modifier=false, summary=true)
811    @Description(shortDefinition="The person or entity that asserts the permission", formalDefinition="The person or entity that asserts the permission." )
812    protected Reference asserter;
813
814    /**
815     * The date that permission was asserted.
816     */
817    @Child(name = "assertionDate", type = {DateTimeType.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
818    @Description(shortDefinition="The date that permission was asserted", formalDefinition="The date that permission was asserted." )
819    protected List<DateTimeType> assertionDate;
820
821    /**
822     * The period in which the permission is active.
823     */
824    @Child(name = "validity", type = {Period.class}, order=4, min=0, max=1, modifier=false, summary=true)
825    @Description(shortDefinition="The period in which the permission is active", formalDefinition="The period in which the permission is active." )
826    protected Period validity;
827
828    /**
829     * The purpose for which the permission is given.
830     */
831    @Child(name = "purpose", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
832    @Description(shortDefinition="The purpose for which the permission is given", formalDefinition="The purpose for which the permission is given." )
833    protected List<CodeableConcept> purpose;
834
835    /**
836     * This can be 1) the definition of data elements, or 2) a category or label) e.g. “sensitive”. It could also be a c) graph-like definition of a set of data elements.
837     */
838    @Child(name = "dataScope", type = {Expression.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
839    @Description(shortDefinition="This can be 1) the definition of data elements, or 2) a category or label) e.g. “sensitive”. It could also be a c) graph-like definition of a set of data elements", formalDefinition="This can be 1) the definition of data elements, or 2) a category or label) e.g. “sensitive”. It could also be a c) graph-like definition of a set of data elements." )
840    protected List<Expression> dataScope;
841
842    /**
843     * A description or definition of which activities are allowed to be done on the data.
844     */
845    @Child(name = "processingActivity", type = {}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
846    @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." )
847    protected List<PermissionProcessingActivityComponent> processingActivity;
848
849    /**
850     * The asserted justification for using the data.
851     */
852    @Child(name = "justification", type = {}, order=8, min=0, max=1, modifier=false, summary=true)
853    @Description(shortDefinition="The asserted justification for using the data", formalDefinition="The asserted justification for using the data." )
854    protected PermissionJustificationComponent justification;
855
856    /**
857     * What limits apply to the use of the data.
858     */
859    @Child(name = "usageLimitations", type = {CodeableConcept.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
860    @Description(shortDefinition="What limits apply to the use of the data", formalDefinition="What limits apply to the use of the data." )
861    protected List<CodeableConcept> usageLimitations;
862
863    private static final long serialVersionUID = -1764304363L;
864
865  /**
866   * Constructor
867   */
868    public Permission() {
869      super();
870    }
871
872  /**
873   * Constructor
874   */
875    public Permission(PermissionStatus status) {
876      super();
877      this.setStatus(status);
878    }
879
880    /**
881     * @return {@link #status} (Status.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
882     */
883    public Enumeration<PermissionStatus> getStatusElement() { 
884      if (this.status == null)
885        if (Configuration.errorOnAutoCreate())
886          throw new Error("Attempt to auto-create Permission.status");
887        else if (Configuration.doAutoCreate())
888          this.status = new Enumeration<PermissionStatus>(new PermissionStatusEnumFactory()); // bb
889      return this.status;
890    }
891
892    public boolean hasStatusElement() { 
893      return this.status != null && !this.status.isEmpty();
894    }
895
896    public boolean hasStatus() { 
897      return this.status != null && !this.status.isEmpty();
898    }
899
900    /**
901     * @param value {@link #status} (Status.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
902     */
903    public Permission setStatusElement(Enumeration<PermissionStatus> value) { 
904      this.status = value;
905      return this;
906    }
907
908    /**
909     * @return Status.
910     */
911    public PermissionStatus getStatus() { 
912      return this.status == null ? null : this.status.getValue();
913    }
914
915    /**
916     * @param value Status.
917     */
918    public Permission setStatus(PermissionStatus value) { 
919        if (this.status == null)
920          this.status = new Enumeration<PermissionStatus>(new PermissionStatusEnumFactory());
921        this.status.setValue(value);
922      return this;
923    }
924
925    /**
926     * @return {@link #intent} (grant|refuse.)
927     */
928    public CodeableConcept getIntent() { 
929      if (this.intent == null)
930        if (Configuration.errorOnAutoCreate())
931          throw new Error("Attempt to auto-create Permission.intent");
932        else if (Configuration.doAutoCreate())
933          this.intent = new CodeableConcept(); // cc
934      return this.intent;
935    }
936
937    public boolean hasIntent() { 
938      return this.intent != null && !this.intent.isEmpty();
939    }
940
941    /**
942     * @param value {@link #intent} (grant|refuse.)
943     */
944    public Permission setIntent(CodeableConcept value) { 
945      this.intent = value;
946      return this;
947    }
948
949    /**
950     * @return {@link #asserter} (The person or entity that asserts the permission.)
951     */
952    public Reference getAsserter() { 
953      if (this.asserter == null)
954        if (Configuration.errorOnAutoCreate())
955          throw new Error("Attempt to auto-create Permission.asserter");
956        else if (Configuration.doAutoCreate())
957          this.asserter = new Reference(); // cc
958      return this.asserter;
959    }
960
961    public boolean hasAsserter() { 
962      return this.asserter != null && !this.asserter.isEmpty();
963    }
964
965    /**
966     * @param value {@link #asserter} (The person or entity that asserts the permission.)
967     */
968    public Permission setAsserter(Reference value) { 
969      this.asserter = value;
970      return this;
971    }
972
973    /**
974     * @return {@link #assertionDate} (The date that permission was asserted.)
975     */
976    public List<DateTimeType> getAssertionDate() { 
977      if (this.assertionDate == null)
978        this.assertionDate = new ArrayList<DateTimeType>();
979      return this.assertionDate;
980    }
981
982    /**
983     * @return Returns a reference to <code>this</code> for easy method chaining
984     */
985    public Permission setAssertionDate(List<DateTimeType> theAssertionDate) { 
986      this.assertionDate = theAssertionDate;
987      return this;
988    }
989
990    public boolean hasAssertionDate() { 
991      if (this.assertionDate == null)
992        return false;
993      for (DateTimeType item : this.assertionDate)
994        if (!item.isEmpty())
995          return true;
996      return false;
997    }
998
999    /**
1000     * @return {@link #assertionDate} (The date that permission was asserted.)
1001     */
1002    public DateTimeType addAssertionDateElement() {//2 
1003      DateTimeType t = new DateTimeType();
1004      if (this.assertionDate == null)
1005        this.assertionDate = new ArrayList<DateTimeType>();
1006      this.assertionDate.add(t);
1007      return t;
1008    }
1009
1010    /**
1011     * @param value {@link #assertionDate} (The date that permission was asserted.)
1012     */
1013    public Permission addAssertionDate(Date value) { //1
1014      DateTimeType t = new DateTimeType();
1015      t.setValue(value);
1016      if (this.assertionDate == null)
1017        this.assertionDate = new ArrayList<DateTimeType>();
1018      this.assertionDate.add(t);
1019      return this;
1020    }
1021
1022    /**
1023     * @param value {@link #assertionDate} (The date that permission was asserted.)
1024     */
1025    public boolean hasAssertionDate(Date value) { 
1026      if (this.assertionDate == null)
1027        return false;
1028      for (DateTimeType v : this.assertionDate)
1029        if (v.getValue().equals(value)) // dateTime
1030          return true;
1031      return false;
1032    }
1033
1034    /**
1035     * @return {@link #validity} (The period in which the permission is active.)
1036     */
1037    public Period getValidity() { 
1038      if (this.validity == null)
1039        if (Configuration.errorOnAutoCreate())
1040          throw new Error("Attempt to auto-create Permission.validity");
1041        else if (Configuration.doAutoCreate())
1042          this.validity = new Period(); // cc
1043      return this.validity;
1044    }
1045
1046    public boolean hasValidity() { 
1047      return this.validity != null && !this.validity.isEmpty();
1048    }
1049
1050    /**
1051     * @param value {@link #validity} (The period in which the permission is active.)
1052     */
1053    public Permission setValidity(Period value) { 
1054      this.validity = value;
1055      return this;
1056    }
1057
1058    /**
1059     * @return {@link #purpose} (The purpose for which the permission is given.)
1060     */
1061    public List<CodeableConcept> getPurpose() { 
1062      if (this.purpose == null)
1063        this.purpose = new ArrayList<CodeableConcept>();
1064      return this.purpose;
1065    }
1066
1067    /**
1068     * @return Returns a reference to <code>this</code> for easy method chaining
1069     */
1070    public Permission setPurpose(List<CodeableConcept> thePurpose) { 
1071      this.purpose = thePurpose;
1072      return this;
1073    }
1074
1075    public boolean hasPurpose() { 
1076      if (this.purpose == null)
1077        return false;
1078      for (CodeableConcept item : this.purpose)
1079        if (!item.isEmpty())
1080          return true;
1081      return false;
1082    }
1083
1084    public CodeableConcept addPurpose() { //3
1085      CodeableConcept t = new CodeableConcept();
1086      if (this.purpose == null)
1087        this.purpose = new ArrayList<CodeableConcept>();
1088      this.purpose.add(t);
1089      return t;
1090    }
1091
1092    public Permission addPurpose(CodeableConcept t) { //3
1093      if (t == null)
1094        return this;
1095      if (this.purpose == null)
1096        this.purpose = new ArrayList<CodeableConcept>();
1097      this.purpose.add(t);
1098      return this;
1099    }
1100
1101    /**
1102     * @return The first repetition of repeating field {@link #purpose}, creating it if it does not already exist {3}
1103     */
1104    public CodeableConcept getPurposeFirstRep() { 
1105      if (getPurpose().isEmpty()) {
1106        addPurpose();
1107      }
1108      return getPurpose().get(0);
1109    }
1110
1111    /**
1112     * @return {@link #dataScope} (This can be 1) the definition of data elements, or 2) a category or label) e.g. “sensitive”. It could also be a c) graph-like definition of a set of data elements.)
1113     */
1114    public List<Expression> getDataScope() { 
1115      if (this.dataScope == null)
1116        this.dataScope = new ArrayList<Expression>();
1117      return this.dataScope;
1118    }
1119
1120    /**
1121     * @return Returns a reference to <code>this</code> for easy method chaining
1122     */
1123    public Permission setDataScope(List<Expression> theDataScope) { 
1124      this.dataScope = theDataScope;
1125      return this;
1126    }
1127
1128    public boolean hasDataScope() { 
1129      if (this.dataScope == null)
1130        return false;
1131      for (Expression item : this.dataScope)
1132        if (!item.isEmpty())
1133          return true;
1134      return false;
1135    }
1136
1137    public Expression addDataScope() { //3
1138      Expression t = new Expression();
1139      if (this.dataScope == null)
1140        this.dataScope = new ArrayList<Expression>();
1141      this.dataScope.add(t);
1142      return t;
1143    }
1144
1145    public Permission addDataScope(Expression t) { //3
1146      if (t == null)
1147        return this;
1148      if (this.dataScope == null)
1149        this.dataScope = new ArrayList<Expression>();
1150      this.dataScope.add(t);
1151      return this;
1152    }
1153
1154    /**
1155     * @return The first repetition of repeating field {@link #dataScope}, creating it if it does not already exist {3}
1156     */
1157    public Expression getDataScopeFirstRep() { 
1158      if (getDataScope().isEmpty()) {
1159        addDataScope();
1160      }
1161      return getDataScope().get(0);
1162    }
1163
1164    /**
1165     * @return {@link #processingActivity} (A description or definition of which activities are allowed to be done on the data.)
1166     */
1167    public List<PermissionProcessingActivityComponent> getProcessingActivity() { 
1168      if (this.processingActivity == null)
1169        this.processingActivity = new ArrayList<PermissionProcessingActivityComponent>();
1170      return this.processingActivity;
1171    }
1172
1173    /**
1174     * @return Returns a reference to <code>this</code> for easy method chaining
1175     */
1176    public Permission setProcessingActivity(List<PermissionProcessingActivityComponent> theProcessingActivity) { 
1177      this.processingActivity = theProcessingActivity;
1178      return this;
1179    }
1180
1181    public boolean hasProcessingActivity() { 
1182      if (this.processingActivity == null)
1183        return false;
1184      for (PermissionProcessingActivityComponent item : this.processingActivity)
1185        if (!item.isEmpty())
1186          return true;
1187      return false;
1188    }
1189
1190    public PermissionProcessingActivityComponent addProcessingActivity() { //3
1191      PermissionProcessingActivityComponent t = new PermissionProcessingActivityComponent();
1192      if (this.processingActivity == null)
1193        this.processingActivity = new ArrayList<PermissionProcessingActivityComponent>();
1194      this.processingActivity.add(t);
1195      return t;
1196    }
1197
1198    public Permission addProcessingActivity(PermissionProcessingActivityComponent t) { //3
1199      if (t == null)
1200        return this;
1201      if (this.processingActivity == null)
1202        this.processingActivity = new ArrayList<PermissionProcessingActivityComponent>();
1203      this.processingActivity.add(t);
1204      return this;
1205    }
1206
1207    /**
1208     * @return The first repetition of repeating field {@link #processingActivity}, creating it if it does not already exist {3}
1209     */
1210    public PermissionProcessingActivityComponent getProcessingActivityFirstRep() { 
1211      if (getProcessingActivity().isEmpty()) {
1212        addProcessingActivity();
1213      }
1214      return getProcessingActivity().get(0);
1215    }
1216
1217    /**
1218     * @return {@link #justification} (The asserted justification for using the data.)
1219     */
1220    public PermissionJustificationComponent getJustification() { 
1221      if (this.justification == null)
1222        if (Configuration.errorOnAutoCreate())
1223          throw new Error("Attempt to auto-create Permission.justification");
1224        else if (Configuration.doAutoCreate())
1225          this.justification = new PermissionJustificationComponent(); // cc
1226      return this.justification;
1227    }
1228
1229    public boolean hasJustification() { 
1230      return this.justification != null && !this.justification.isEmpty();
1231    }
1232
1233    /**
1234     * @param value {@link #justification} (The asserted justification for using the data.)
1235     */
1236    public Permission setJustification(PermissionJustificationComponent value) { 
1237      this.justification = value;
1238      return this;
1239    }
1240
1241    /**
1242     * @return {@link #usageLimitations} (What limits apply to the use of the data.)
1243     */
1244    public List<CodeableConcept> getUsageLimitations() { 
1245      if (this.usageLimitations == null)
1246        this.usageLimitations = new ArrayList<CodeableConcept>();
1247      return this.usageLimitations;
1248    }
1249
1250    /**
1251     * @return Returns a reference to <code>this</code> for easy method chaining
1252     */
1253    public Permission setUsageLimitations(List<CodeableConcept> theUsageLimitations) { 
1254      this.usageLimitations = theUsageLimitations;
1255      return this;
1256    }
1257
1258    public boolean hasUsageLimitations() { 
1259      if (this.usageLimitations == null)
1260        return false;
1261      for (CodeableConcept item : this.usageLimitations)
1262        if (!item.isEmpty())
1263          return true;
1264      return false;
1265    }
1266
1267    public CodeableConcept addUsageLimitations() { //3
1268      CodeableConcept t = new CodeableConcept();
1269      if (this.usageLimitations == null)
1270        this.usageLimitations = new ArrayList<CodeableConcept>();
1271      this.usageLimitations.add(t);
1272      return t;
1273    }
1274
1275    public Permission addUsageLimitations(CodeableConcept t) { //3
1276      if (t == null)
1277        return this;
1278      if (this.usageLimitations == null)
1279        this.usageLimitations = new ArrayList<CodeableConcept>();
1280      this.usageLimitations.add(t);
1281      return this;
1282    }
1283
1284    /**
1285     * @return The first repetition of repeating field {@link #usageLimitations}, creating it if it does not already exist {3}
1286     */
1287    public CodeableConcept getUsageLimitationsFirstRep() { 
1288      if (getUsageLimitations().isEmpty()) {
1289        addUsageLimitations();
1290      }
1291      return getUsageLimitations().get(0);
1292    }
1293
1294      protected void listChildren(List<Property> children) {
1295        super.listChildren(children);
1296        children.add(new Property("status", "code", "Status.", 0, 1, status));
1297        children.add(new Property("intent", "CodeableConcept", "grant|refuse.", 0, 1, intent));
1298        children.add(new Property("asserter", "Reference(Person)", "The person or entity that asserts the permission.", 0, 1, asserter));
1299        children.add(new Property("assertionDate", "dateTime", "The date that permission was asserted.", 0, java.lang.Integer.MAX_VALUE, assertionDate));
1300        children.add(new Property("validity", "Period", "The period in which the permission is active.", 0, 1, validity));
1301        children.add(new Property("purpose", "CodeableConcept", "The purpose for which the permission is given.", 0, java.lang.Integer.MAX_VALUE, purpose));
1302        children.add(new Property("dataScope", "Expression", "This can be 1) the definition of data elements, or 2) a category or label) e.g. “sensitive”. It could also be a c) graph-like definition of a set of data elements.", 0, java.lang.Integer.MAX_VALUE, dataScope));
1303        children.add(new Property("processingActivity", "", "A description or definition of which activities are allowed to be done on the data.", 0, java.lang.Integer.MAX_VALUE, processingActivity));
1304        children.add(new Property("justification", "", "The asserted justification for using the data.", 0, 1, justification));
1305        children.add(new Property("usageLimitations", "CodeableConcept", "What limits apply to the use of the data.", 0, java.lang.Integer.MAX_VALUE, usageLimitations));
1306      }
1307
1308      @Override
1309      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1310        switch (_hash) {
1311        case -892481550: /*status*/  return new Property("status", "code", "Status.", 0, 1, status);
1312        case -1183762788: /*intent*/  return new Property("intent", "CodeableConcept", "grant|refuse.", 0, 1, intent);
1313        case -373242253: /*asserter*/  return new Property("asserter", "Reference(Person)", "The person or entity that asserts the permission.", 0, 1, asserter);
1314        case -1498338864: /*assertionDate*/  return new Property("assertionDate", "dateTime", "The date that permission was asserted.", 0, java.lang.Integer.MAX_VALUE, assertionDate);
1315        case -1421265102: /*validity*/  return new Property("validity", "Period", "The period in which the permission is active.", 0, 1, validity);
1316        case -220463842: /*purpose*/  return new Property("purpose", "CodeableConcept", "The purpose for which the permission is given.", 0, java.lang.Integer.MAX_VALUE, purpose);
1317        case -374957878: /*dataScope*/  return new Property("dataScope", "Expression", "This can be 1) the definition of data elements, or 2) a category or label) e.g. “sensitive”. It could also be a c) graph-like definition of a set of data elements.", 0, java.lang.Integer.MAX_VALUE, dataScope);
1318        case -2117745854: /*processingActivity*/  return new Property("processingActivity", "", "A description or definition of which activities are allowed to be done on the data.", 0, java.lang.Integer.MAX_VALUE, processingActivity);
1319        case 1864993522: /*justification*/  return new Property("justification", "", "The asserted justification for using the data.", 0, 1, justification);
1320        case -788364488: /*usageLimitations*/  return new Property("usageLimitations", "CodeableConcept", "What limits apply to the use of the data.", 0, java.lang.Integer.MAX_VALUE, usageLimitations);
1321        default: return super.getNamedProperty(_hash, _name, _checkValid);
1322        }
1323
1324      }
1325
1326      @Override
1327      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1328        switch (hash) {
1329        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<PermissionStatus>
1330        case -1183762788: /*intent*/ return this.intent == null ? new Base[0] : new Base[] {this.intent}; // CodeableConcept
1331        case -373242253: /*asserter*/ return this.asserter == null ? new Base[0] : new Base[] {this.asserter}; // Reference
1332        case -1498338864: /*assertionDate*/ return this.assertionDate == null ? new Base[0] : this.assertionDate.toArray(new Base[this.assertionDate.size()]); // DateTimeType
1333        case -1421265102: /*validity*/ return this.validity == null ? new Base[0] : new Base[] {this.validity}; // Period
1334        case -220463842: /*purpose*/ return this.purpose == null ? new Base[0] : this.purpose.toArray(new Base[this.purpose.size()]); // CodeableConcept
1335        case -374957878: /*dataScope*/ return this.dataScope == null ? new Base[0] : this.dataScope.toArray(new Base[this.dataScope.size()]); // Expression
1336        case -2117745854: /*processingActivity*/ return this.processingActivity == null ? new Base[0] : this.processingActivity.toArray(new Base[this.processingActivity.size()]); // PermissionProcessingActivityComponent
1337        case 1864993522: /*justification*/ return this.justification == null ? new Base[0] : new Base[] {this.justification}; // PermissionJustificationComponent
1338        case -788364488: /*usageLimitations*/ return this.usageLimitations == null ? new Base[0] : this.usageLimitations.toArray(new Base[this.usageLimitations.size()]); // CodeableConcept
1339        default: return super.getProperty(hash, name, checkValid);
1340        }
1341
1342      }
1343
1344      @Override
1345      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1346        switch (hash) {
1347        case -892481550: // status
1348          value = new PermissionStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
1349          this.status = (Enumeration) value; // Enumeration<PermissionStatus>
1350          return value;
1351        case -1183762788: // intent
1352          this.intent = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1353          return value;
1354        case -373242253: // asserter
1355          this.asserter = TypeConvertor.castToReference(value); // Reference
1356          return value;
1357        case -1498338864: // assertionDate
1358          this.getAssertionDate().add(TypeConvertor.castToDateTime(value)); // DateTimeType
1359          return value;
1360        case -1421265102: // validity
1361          this.validity = TypeConvertor.castToPeriod(value); // Period
1362          return value;
1363        case -220463842: // purpose
1364          this.getPurpose().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
1365          return value;
1366        case -374957878: // dataScope
1367          this.getDataScope().add(TypeConvertor.castToExpression(value)); // Expression
1368          return value;
1369        case -2117745854: // processingActivity
1370          this.getProcessingActivity().add((PermissionProcessingActivityComponent) value); // PermissionProcessingActivityComponent
1371          return value;
1372        case 1864993522: // justification
1373          this.justification = (PermissionJustificationComponent) value; // PermissionJustificationComponent
1374          return value;
1375        case -788364488: // usageLimitations
1376          this.getUsageLimitations().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
1377          return value;
1378        default: return super.setProperty(hash, name, value);
1379        }
1380
1381      }
1382
1383      @Override
1384      public Base setProperty(String name, Base value) throws FHIRException {
1385        if (name.equals("status")) {
1386          value = new PermissionStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
1387          this.status = (Enumeration) value; // Enumeration<PermissionStatus>
1388        } else if (name.equals("intent")) {
1389          this.intent = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1390        } else if (name.equals("asserter")) {
1391          this.asserter = TypeConvertor.castToReference(value); // Reference
1392        } else if (name.equals("assertionDate")) {
1393          this.getAssertionDate().add(TypeConvertor.castToDateTime(value));
1394        } else if (name.equals("validity")) {
1395          this.validity = TypeConvertor.castToPeriod(value); // Period
1396        } else if (name.equals("purpose")) {
1397          this.getPurpose().add(TypeConvertor.castToCodeableConcept(value));
1398        } else if (name.equals("dataScope")) {
1399          this.getDataScope().add(TypeConvertor.castToExpression(value));
1400        } else if (name.equals("processingActivity")) {
1401          this.getProcessingActivity().add((PermissionProcessingActivityComponent) value);
1402        } else if (name.equals("justification")) {
1403          this.justification = (PermissionJustificationComponent) value; // PermissionJustificationComponent
1404        } else if (name.equals("usageLimitations")) {
1405          this.getUsageLimitations().add(TypeConvertor.castToCodeableConcept(value));
1406        } else
1407          return super.setProperty(name, value);
1408        return value;
1409      }
1410
1411      @Override
1412      public Base makeProperty(int hash, String name) throws FHIRException {
1413        switch (hash) {
1414        case -892481550:  return getStatusElement();
1415        case -1183762788:  return getIntent();
1416        case -373242253:  return getAsserter();
1417        case -1498338864:  return addAssertionDateElement();
1418        case -1421265102:  return getValidity();
1419        case -220463842:  return addPurpose(); 
1420        case -374957878:  return addDataScope(); 
1421        case -2117745854:  return addProcessingActivity(); 
1422        case 1864993522:  return getJustification();
1423        case -788364488:  return addUsageLimitations(); 
1424        default: return super.makeProperty(hash, name);
1425        }
1426
1427      }
1428
1429      @Override
1430      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1431        switch (hash) {
1432        case -892481550: /*status*/ return new String[] {"code"};
1433        case -1183762788: /*intent*/ return new String[] {"CodeableConcept"};
1434        case -373242253: /*asserter*/ return new String[] {"Reference"};
1435        case -1498338864: /*assertionDate*/ return new String[] {"dateTime"};
1436        case -1421265102: /*validity*/ return new String[] {"Period"};
1437        case -220463842: /*purpose*/ return new String[] {"CodeableConcept"};
1438        case -374957878: /*dataScope*/ return new String[] {"Expression"};
1439        case -2117745854: /*processingActivity*/ return new String[] {};
1440        case 1864993522: /*justification*/ return new String[] {};
1441        case -788364488: /*usageLimitations*/ return new String[] {"CodeableConcept"};
1442        default: return super.getTypesForProperty(hash, name);
1443        }
1444
1445      }
1446
1447      @Override
1448      public Base addChild(String name) throws FHIRException {
1449        if (name.equals("status")) {
1450          throw new FHIRException("Cannot call addChild on a primitive type Permission.status");
1451        }
1452        else if (name.equals("intent")) {
1453          this.intent = new CodeableConcept();
1454          return this.intent;
1455        }
1456        else if (name.equals("asserter")) {
1457          this.asserter = new Reference();
1458          return this.asserter;
1459        }
1460        else if (name.equals("assertionDate")) {
1461          throw new FHIRException("Cannot call addChild on a primitive type Permission.assertionDate");
1462        }
1463        else if (name.equals("validity")) {
1464          this.validity = new Period();
1465          return this.validity;
1466        }
1467        else if (name.equals("purpose")) {
1468          return addPurpose();
1469        }
1470        else if (name.equals("dataScope")) {
1471          return addDataScope();
1472        }
1473        else if (name.equals("processingActivity")) {
1474          return addProcessingActivity();
1475        }
1476        else if (name.equals("justification")) {
1477          this.justification = new PermissionJustificationComponent();
1478          return this.justification;
1479        }
1480        else if (name.equals("usageLimitations")) {
1481          return addUsageLimitations();
1482        }
1483        else
1484          return super.addChild(name);
1485      }
1486
1487  public String fhirType() {
1488    return "Permission";
1489
1490  }
1491
1492      public Permission copy() {
1493        Permission dst = new Permission();
1494        copyValues(dst);
1495        return dst;
1496      }
1497
1498      public void copyValues(Permission dst) {
1499        super.copyValues(dst);
1500        dst.status = status == null ? null : status.copy();
1501        dst.intent = intent == null ? null : intent.copy();
1502        dst.asserter = asserter == null ? null : asserter.copy();
1503        if (assertionDate != null) {
1504          dst.assertionDate = new ArrayList<DateTimeType>();
1505          for (DateTimeType i : assertionDate)
1506            dst.assertionDate.add(i.copy());
1507        };
1508        dst.validity = validity == null ? null : validity.copy();
1509        if (purpose != null) {
1510          dst.purpose = new ArrayList<CodeableConcept>();
1511          for (CodeableConcept i : purpose)
1512            dst.purpose.add(i.copy());
1513        };
1514        if (dataScope != null) {
1515          dst.dataScope = new ArrayList<Expression>();
1516          for (Expression i : dataScope)
1517            dst.dataScope.add(i.copy());
1518        };
1519        if (processingActivity != null) {
1520          dst.processingActivity = new ArrayList<PermissionProcessingActivityComponent>();
1521          for (PermissionProcessingActivityComponent i : processingActivity)
1522            dst.processingActivity.add(i.copy());
1523        };
1524        dst.justification = justification == null ? null : justification.copy();
1525        if (usageLimitations != null) {
1526          dst.usageLimitations = new ArrayList<CodeableConcept>();
1527          for (CodeableConcept i : usageLimitations)
1528            dst.usageLimitations.add(i.copy());
1529        };
1530      }
1531
1532      protected Permission typedCopy() {
1533        return copy();
1534      }
1535
1536      @Override
1537      public boolean equalsDeep(Base other_) {
1538        if (!super.equalsDeep(other_))
1539          return false;
1540        if (!(other_ instanceof Permission))
1541          return false;
1542        Permission o = (Permission) other_;
1543        return compareDeep(status, o.status, true) && compareDeep(intent, o.intent, true) && compareDeep(asserter, o.asserter, true)
1544           && compareDeep(assertionDate, o.assertionDate, true) && compareDeep(validity, o.validity, true)
1545           && compareDeep(purpose, o.purpose, true) && compareDeep(dataScope, o.dataScope, true) && compareDeep(processingActivity, o.processingActivity, true)
1546           && compareDeep(justification, o.justification, true) && compareDeep(usageLimitations, o.usageLimitations, true)
1547          ;
1548      }
1549
1550      @Override
1551      public boolean equalsShallow(Base other_) {
1552        if (!super.equalsShallow(other_))
1553          return false;
1554        if (!(other_ instanceof Permission))
1555          return false;
1556        Permission o = (Permission) other_;
1557        return compareValues(status, o.status, true) && compareValues(assertionDate, o.assertionDate, true)
1558          ;
1559      }
1560
1561      public boolean isEmpty() {
1562        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(status, intent, asserter
1563          , assertionDate, validity, purpose, dataScope, processingActivity, justification
1564          , usageLimitations);
1565      }
1566
1567  @Override
1568  public ResourceType getResourceType() {
1569    return ResourceType.Permission;
1570   }
1571
1572 /**
1573   * Search parameter: <b>status</b>
1574   * <p>
1575   * Description: <b>active | entered-in-error | draft | rejected</b><br>
1576   * Type: <b>token</b><br>
1577   * Path: <b>Permission.status</b><br>
1578   * </p>
1579   */
1580  @SearchParamDefinition(name="status", path="Permission.status", description="active | entered-in-error | draft | rejected", type="token" )
1581  public static final String SP_STATUS = "status";
1582 /**
1583   * <b>Fluent Client</b> search parameter constant for <b>status</b>
1584   * <p>
1585   * Description: <b>active | entered-in-error | draft | rejected</b><br>
1586   * Type: <b>token</b><br>
1587   * Path: <b>Permission.status</b><br>
1588   * </p>
1589   */
1590  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
1591
1592
1593}
1594