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 * A record of an event relevant for purposes such as operations, privacy, security, maintenance, and performance analysis.
052 */
053@ResourceDef(name="AuditEvent", profile="http://hl7.org/fhir/StructureDefinition/AuditEvent")
054public class AuditEvent extends DomainResource {
055
056    public enum AuditEventAction {
057        /**
058         * Create a new database object, such as placing an order.
059         */
060        C, 
061        /**
062         * Display or print data, such as a doctor census.
063         */
064        R, 
065        /**
066         * Update data, such as revise patient information.
067         */
068        U, 
069        /**
070         * Delete items, such as a doctor master file record.
071         */
072        D, 
073        /**
074         * Perform a system or application function such as log-on, program execution or use of an object's method, or perform a query/search operation.
075         */
076        E, 
077        /**
078         * added to help the parsers with the generic types
079         */
080        NULL;
081        public static AuditEventAction fromCode(String codeString) throws FHIRException {
082            if (codeString == null || "".equals(codeString))
083                return null;
084        if ("C".equals(codeString))
085          return C;
086        if ("R".equals(codeString))
087          return R;
088        if ("U".equals(codeString))
089          return U;
090        if ("D".equals(codeString))
091          return D;
092        if ("E".equals(codeString))
093          return E;
094        if (Configuration.isAcceptInvalidEnums())
095          return null;
096        else
097          throw new FHIRException("Unknown AuditEventAction code '"+codeString+"'");
098        }
099        public String toCode() {
100          switch (this) {
101            case C: return "C";
102            case R: return "R";
103            case U: return "U";
104            case D: return "D";
105            case E: return "E";
106            default: return "?";
107          }
108        }
109        public String getSystem() {
110          switch (this) {
111            case C: return "http://hl7.org/fhir/audit-event-action";
112            case R: return "http://hl7.org/fhir/audit-event-action";
113            case U: return "http://hl7.org/fhir/audit-event-action";
114            case D: return "http://hl7.org/fhir/audit-event-action";
115            case E: return "http://hl7.org/fhir/audit-event-action";
116            default: return "?";
117          }
118        }
119        public String getDefinition() {
120          switch (this) {
121            case C: return "Create a new database object, such as placing an order.";
122            case R: return "Display or print data, such as a doctor census.";
123            case U: return "Update data, such as revise patient information.";
124            case D: return "Delete items, such as a doctor master file record.";
125            case E: return "Perform a system or application function such as log-on, program execution or use of an object's method, or perform a query/search operation.";
126            default: return "?";
127          }
128        }
129        public String getDisplay() {
130          switch (this) {
131            case C: return "Create";
132            case R: return "Read/View/Print";
133            case U: return "Update";
134            case D: return "Delete";
135            case E: return "Execute";
136            default: return "?";
137          }
138        }
139    }
140
141  public static class AuditEventActionEnumFactory implements EnumFactory<AuditEventAction> {
142    public AuditEventAction fromCode(String codeString) throws IllegalArgumentException {
143      if (codeString == null || "".equals(codeString))
144            if (codeString == null || "".equals(codeString))
145                return null;
146        if ("C".equals(codeString))
147          return AuditEventAction.C;
148        if ("R".equals(codeString))
149          return AuditEventAction.R;
150        if ("U".equals(codeString))
151          return AuditEventAction.U;
152        if ("D".equals(codeString))
153          return AuditEventAction.D;
154        if ("E".equals(codeString))
155          return AuditEventAction.E;
156        throw new IllegalArgumentException("Unknown AuditEventAction code '"+codeString+"'");
157        }
158        public Enumeration<AuditEventAction> fromType(Base code) throws FHIRException {
159          if (code == null)
160            return null;
161          if (code.isEmpty())
162            return new Enumeration<AuditEventAction>(this);
163          String codeString = ((PrimitiveType) code).asStringValue();
164          if (codeString == null || "".equals(codeString))
165            return null;
166        if ("C".equals(codeString))
167          return new Enumeration<AuditEventAction>(this, AuditEventAction.C);
168        if ("R".equals(codeString))
169          return new Enumeration<AuditEventAction>(this, AuditEventAction.R);
170        if ("U".equals(codeString))
171          return new Enumeration<AuditEventAction>(this, AuditEventAction.U);
172        if ("D".equals(codeString))
173          return new Enumeration<AuditEventAction>(this, AuditEventAction.D);
174        if ("E".equals(codeString))
175          return new Enumeration<AuditEventAction>(this, AuditEventAction.E);
176        throw new FHIRException("Unknown AuditEventAction code '"+codeString+"'");
177        }
178    public String toCode(AuditEventAction code) {
179      if (code == AuditEventAction.C)
180        return "C";
181      if (code == AuditEventAction.R)
182        return "R";
183      if (code == AuditEventAction.U)
184        return "U";
185      if (code == AuditEventAction.D)
186        return "D";
187      if (code == AuditEventAction.E)
188        return "E";
189      return "?";
190      }
191    public String toSystem(AuditEventAction code) {
192      return code.getSystem();
193      }
194    }
195
196    public enum AuditEventSeverity {
197        /**
198         * System is unusable.
199         */
200        EMERGENCY, 
201        /**
202         * Action must be taken immediately.
203         */
204        ALERT, 
205        /**
206         * Critical conditions.
207         */
208        CRITICAL, 
209        /**
210         * Error conditions.
211         */
212        ERROR, 
213        /**
214         * Warning conditions.
215         */
216        WARNING, 
217        /**
218         * Normal but significant condition.
219         */
220        NOTICE, 
221        /**
222         * Informational messages.
223         */
224        INFORMATIONAL, 
225        /**
226         * Debug-level messages.
227         */
228        DEBUG, 
229        /**
230         * added to help the parsers with the generic types
231         */
232        NULL;
233        public static AuditEventSeverity fromCode(String codeString) throws FHIRException {
234            if (codeString == null || "".equals(codeString))
235                return null;
236        if ("emergency".equals(codeString))
237          return EMERGENCY;
238        if ("alert".equals(codeString))
239          return ALERT;
240        if ("critical".equals(codeString))
241          return CRITICAL;
242        if ("error".equals(codeString))
243          return ERROR;
244        if ("warning".equals(codeString))
245          return WARNING;
246        if ("notice".equals(codeString))
247          return NOTICE;
248        if ("informational".equals(codeString))
249          return INFORMATIONAL;
250        if ("debug".equals(codeString))
251          return DEBUG;
252        if (Configuration.isAcceptInvalidEnums())
253          return null;
254        else
255          throw new FHIRException("Unknown AuditEventSeverity code '"+codeString+"'");
256        }
257        public String toCode() {
258          switch (this) {
259            case EMERGENCY: return "emergency";
260            case ALERT: return "alert";
261            case CRITICAL: return "critical";
262            case ERROR: return "error";
263            case WARNING: return "warning";
264            case NOTICE: return "notice";
265            case INFORMATIONAL: return "informational";
266            case DEBUG: return "debug";
267            default: return "?";
268          }
269        }
270        public String getSystem() {
271          switch (this) {
272            case EMERGENCY: return "http://hl7.org/fhir/audit-event-severity";
273            case ALERT: return "http://hl7.org/fhir/audit-event-severity";
274            case CRITICAL: return "http://hl7.org/fhir/audit-event-severity";
275            case ERROR: return "http://hl7.org/fhir/audit-event-severity";
276            case WARNING: return "http://hl7.org/fhir/audit-event-severity";
277            case NOTICE: return "http://hl7.org/fhir/audit-event-severity";
278            case INFORMATIONAL: return "http://hl7.org/fhir/audit-event-severity";
279            case DEBUG: return "http://hl7.org/fhir/audit-event-severity";
280            default: return "?";
281          }
282        }
283        public String getDefinition() {
284          switch (this) {
285            case EMERGENCY: return "System is unusable.";
286            case ALERT: return "Action must be taken immediately.";
287            case CRITICAL: return "Critical conditions.";
288            case ERROR: return "Error conditions.";
289            case WARNING: return "Warning conditions.";
290            case NOTICE: return "Normal but significant condition.";
291            case INFORMATIONAL: return "Informational messages.";
292            case DEBUG: return "Debug-level messages.";
293            default: return "?";
294          }
295        }
296        public String getDisplay() {
297          switch (this) {
298            case EMERGENCY: return "Emergency";
299            case ALERT: return "Alert";
300            case CRITICAL: return "Critical";
301            case ERROR: return "Error";
302            case WARNING: return "Warning";
303            case NOTICE: return "Notice";
304            case INFORMATIONAL: return "Informational";
305            case DEBUG: return "Debug";
306            default: return "?";
307          }
308        }
309    }
310
311  public static class AuditEventSeverityEnumFactory implements EnumFactory<AuditEventSeverity> {
312    public AuditEventSeverity fromCode(String codeString) throws IllegalArgumentException {
313      if (codeString == null || "".equals(codeString))
314            if (codeString == null || "".equals(codeString))
315                return null;
316        if ("emergency".equals(codeString))
317          return AuditEventSeverity.EMERGENCY;
318        if ("alert".equals(codeString))
319          return AuditEventSeverity.ALERT;
320        if ("critical".equals(codeString))
321          return AuditEventSeverity.CRITICAL;
322        if ("error".equals(codeString))
323          return AuditEventSeverity.ERROR;
324        if ("warning".equals(codeString))
325          return AuditEventSeverity.WARNING;
326        if ("notice".equals(codeString))
327          return AuditEventSeverity.NOTICE;
328        if ("informational".equals(codeString))
329          return AuditEventSeverity.INFORMATIONAL;
330        if ("debug".equals(codeString))
331          return AuditEventSeverity.DEBUG;
332        throw new IllegalArgumentException("Unknown AuditEventSeverity code '"+codeString+"'");
333        }
334        public Enumeration<AuditEventSeverity> fromType(Base code) throws FHIRException {
335          if (code == null)
336            return null;
337          if (code.isEmpty())
338            return new Enumeration<AuditEventSeverity>(this);
339          String codeString = ((PrimitiveType) code).asStringValue();
340          if (codeString == null || "".equals(codeString))
341            return null;
342        if ("emergency".equals(codeString))
343          return new Enumeration<AuditEventSeverity>(this, AuditEventSeverity.EMERGENCY);
344        if ("alert".equals(codeString))
345          return new Enumeration<AuditEventSeverity>(this, AuditEventSeverity.ALERT);
346        if ("critical".equals(codeString))
347          return new Enumeration<AuditEventSeverity>(this, AuditEventSeverity.CRITICAL);
348        if ("error".equals(codeString))
349          return new Enumeration<AuditEventSeverity>(this, AuditEventSeverity.ERROR);
350        if ("warning".equals(codeString))
351          return new Enumeration<AuditEventSeverity>(this, AuditEventSeverity.WARNING);
352        if ("notice".equals(codeString))
353          return new Enumeration<AuditEventSeverity>(this, AuditEventSeverity.NOTICE);
354        if ("informational".equals(codeString))
355          return new Enumeration<AuditEventSeverity>(this, AuditEventSeverity.INFORMATIONAL);
356        if ("debug".equals(codeString))
357          return new Enumeration<AuditEventSeverity>(this, AuditEventSeverity.DEBUG);
358        throw new FHIRException("Unknown AuditEventSeverity code '"+codeString+"'");
359        }
360    public String toCode(AuditEventSeverity code) {
361      if (code == AuditEventSeverity.EMERGENCY)
362        return "emergency";
363      if (code == AuditEventSeverity.ALERT)
364        return "alert";
365      if (code == AuditEventSeverity.CRITICAL)
366        return "critical";
367      if (code == AuditEventSeverity.ERROR)
368        return "error";
369      if (code == AuditEventSeverity.WARNING)
370        return "warning";
371      if (code == AuditEventSeverity.NOTICE)
372        return "notice";
373      if (code == AuditEventSeverity.INFORMATIONAL)
374        return "informational";
375      if (code == AuditEventSeverity.DEBUG)
376        return "debug";
377      return "?";
378      }
379    public String toSystem(AuditEventSeverity code) {
380      return code.getSystem();
381      }
382    }
383
384    @Block()
385    public static class AuditEventOutcomeComponent extends BackboneElement implements IBaseBackboneElement {
386        /**
387         * Indicates whether the event succeeded or failed.
388         */
389        @Child(name = "code", type = {Coding.class}, order=1, min=1, max=1, modifier=false, summary=true)
390        @Description(shortDefinition="Whether the event succeeded or failed", formalDefinition="Indicates whether the event succeeded or failed." )
391        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/audit-event-outcome")
392        protected Coding code;
393
394        /**
395         * Additional details about the error. This may be a text description of the error or a system code that identifies the error.
396         */
397        @Child(name = "detail", type = {CodeableConcept.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
398        @Description(shortDefinition="Additional outcome detail", formalDefinition="Additional details about the error. This may be a text description of the error or a system code that identifies the error." )
399        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/audit-event-outcome-detail")
400        protected List<CodeableConcept> detail;
401
402        private static final long serialVersionUID = -1108329559L;
403
404    /**
405     * Constructor
406     */
407      public AuditEventOutcomeComponent() {
408        super();
409      }
410
411    /**
412     * Constructor
413     */
414      public AuditEventOutcomeComponent(Coding code) {
415        super();
416        this.setCode(code);
417      }
418
419        /**
420         * @return {@link #code} (Indicates whether the event succeeded or failed.)
421         */
422        public Coding getCode() { 
423          if (this.code == null)
424            if (Configuration.errorOnAutoCreate())
425              throw new Error("Attempt to auto-create AuditEventOutcomeComponent.code");
426            else if (Configuration.doAutoCreate())
427              this.code = new Coding(); // cc
428          return this.code;
429        }
430
431        public boolean hasCode() { 
432          return this.code != null && !this.code.isEmpty();
433        }
434
435        /**
436         * @param value {@link #code} (Indicates whether the event succeeded or failed.)
437         */
438        public AuditEventOutcomeComponent setCode(Coding value) { 
439          this.code = value;
440          return this;
441        }
442
443        /**
444         * @return {@link #detail} (Additional details about the error. This may be a text description of the error or a system code that identifies the error.)
445         */
446        public List<CodeableConcept> getDetail() { 
447          if (this.detail == null)
448            this.detail = new ArrayList<CodeableConcept>();
449          return this.detail;
450        }
451
452        /**
453         * @return Returns a reference to <code>this</code> for easy method chaining
454         */
455        public AuditEventOutcomeComponent setDetail(List<CodeableConcept> theDetail) { 
456          this.detail = theDetail;
457          return this;
458        }
459
460        public boolean hasDetail() { 
461          if (this.detail == null)
462            return false;
463          for (CodeableConcept item : this.detail)
464            if (!item.isEmpty())
465              return true;
466          return false;
467        }
468
469        public CodeableConcept addDetail() { //3
470          CodeableConcept t = new CodeableConcept();
471          if (this.detail == null)
472            this.detail = new ArrayList<CodeableConcept>();
473          this.detail.add(t);
474          return t;
475        }
476
477        public AuditEventOutcomeComponent addDetail(CodeableConcept t) { //3
478          if (t == null)
479            return this;
480          if (this.detail == null)
481            this.detail = new ArrayList<CodeableConcept>();
482          this.detail.add(t);
483          return this;
484        }
485
486        /**
487         * @return The first repetition of repeating field {@link #detail}, creating it if it does not already exist {3}
488         */
489        public CodeableConcept getDetailFirstRep() { 
490          if (getDetail().isEmpty()) {
491            addDetail();
492          }
493          return getDetail().get(0);
494        }
495
496        protected void listChildren(List<Property> children) {
497          super.listChildren(children);
498          children.add(new Property("code", "Coding", "Indicates whether the event succeeded or failed.", 0, 1, code));
499          children.add(new Property("detail", "CodeableConcept", "Additional details about the error. This may be a text description of the error or a system code that identifies the error.", 0, java.lang.Integer.MAX_VALUE, detail));
500        }
501
502        @Override
503        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
504          switch (_hash) {
505          case 3059181: /*code*/  return new Property("code", "Coding", "Indicates whether the event succeeded or failed.", 0, 1, code);
506          case -1335224239: /*detail*/  return new Property("detail", "CodeableConcept", "Additional details about the error. This may be a text description of the error or a system code that identifies the error.", 0, java.lang.Integer.MAX_VALUE, detail);
507          default: return super.getNamedProperty(_hash, _name, _checkValid);
508          }
509
510        }
511
512      @Override
513      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
514        switch (hash) {
515        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // Coding
516        case -1335224239: /*detail*/ return this.detail == null ? new Base[0] : this.detail.toArray(new Base[this.detail.size()]); // CodeableConcept
517        default: return super.getProperty(hash, name, checkValid);
518        }
519
520      }
521
522      @Override
523      public Base setProperty(int hash, String name, Base value) throws FHIRException {
524        switch (hash) {
525        case 3059181: // code
526          this.code = TypeConvertor.castToCoding(value); // Coding
527          return value;
528        case -1335224239: // detail
529          this.getDetail().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
530          return value;
531        default: return super.setProperty(hash, name, value);
532        }
533
534      }
535
536      @Override
537      public Base setProperty(String name, Base value) throws FHIRException {
538        if (name.equals("code")) {
539          this.code = TypeConvertor.castToCoding(value); // Coding
540        } else if (name.equals("detail")) {
541          this.getDetail().add(TypeConvertor.castToCodeableConcept(value));
542        } else
543          return super.setProperty(name, value);
544        return value;
545      }
546
547      @Override
548      public Base makeProperty(int hash, String name) throws FHIRException {
549        switch (hash) {
550        case 3059181:  return getCode();
551        case -1335224239:  return addDetail(); 
552        default: return super.makeProperty(hash, name);
553        }
554
555      }
556
557      @Override
558      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
559        switch (hash) {
560        case 3059181: /*code*/ return new String[] {"Coding"};
561        case -1335224239: /*detail*/ return new String[] {"CodeableConcept"};
562        default: return super.getTypesForProperty(hash, name);
563        }
564
565      }
566
567      @Override
568      public Base addChild(String name) throws FHIRException {
569        if (name.equals("code")) {
570          this.code = new Coding();
571          return this.code;
572        }
573        else if (name.equals("detail")) {
574          return addDetail();
575        }
576        else
577          return super.addChild(name);
578      }
579
580      public AuditEventOutcomeComponent copy() {
581        AuditEventOutcomeComponent dst = new AuditEventOutcomeComponent();
582        copyValues(dst);
583        return dst;
584      }
585
586      public void copyValues(AuditEventOutcomeComponent dst) {
587        super.copyValues(dst);
588        dst.code = code == null ? null : code.copy();
589        if (detail != null) {
590          dst.detail = new ArrayList<CodeableConcept>();
591          for (CodeableConcept i : detail)
592            dst.detail.add(i.copy());
593        };
594      }
595
596      @Override
597      public boolean equalsDeep(Base other_) {
598        if (!super.equalsDeep(other_))
599          return false;
600        if (!(other_ instanceof AuditEventOutcomeComponent))
601          return false;
602        AuditEventOutcomeComponent o = (AuditEventOutcomeComponent) other_;
603        return compareDeep(code, o.code, true) && compareDeep(detail, o.detail, true);
604      }
605
606      @Override
607      public boolean equalsShallow(Base other_) {
608        if (!super.equalsShallow(other_))
609          return false;
610        if (!(other_ instanceof AuditEventOutcomeComponent))
611          return false;
612        AuditEventOutcomeComponent o = (AuditEventOutcomeComponent) other_;
613        return true;
614      }
615
616      public boolean isEmpty() {
617        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(code, detail);
618      }
619
620  public String fhirType() {
621    return "AuditEvent.outcome";
622
623  }
624
625  }
626
627    @Block()
628    public static class AuditEventAgentComponent extends BackboneElement implements IBaseBackboneElement {
629        /**
630         * The Functional Role of the user when performing the event.
631         */
632        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
633        @Description(shortDefinition="How agent participated", formalDefinition="The Functional Role of the user when performing the event." )
634        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/participation-role-type")
635        protected CodeableConcept type;
636
637        /**
638         * The structural roles of the agent indicating the agent's competency. The security role enabling the agent with respect to the activity.
639         */
640        @Child(name = "role", type = {CodeableConcept.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
641        @Description(shortDefinition="Agent role in the event", formalDefinition="The structural roles of the agent indicating the agent's competency. The security role enabling the agent with respect to the activity." )
642        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/security-role-type")
643        protected List<CodeableConcept> role;
644
645        /**
646         * Reference to who this agent is that was involved in the event.
647         */
648        @Child(name = "who", type = {Practitioner.class, PractitionerRole.class, Organization.class, CareTeam.class, Patient.class, Device.class, RelatedPerson.class}, order=3, min=1, max=1, modifier=false, summary=true)
649        @Description(shortDefinition="Identifier of who", formalDefinition="Reference to who this agent is that was involved in the event." )
650        protected Reference who;
651
652        /**
653         * Indicator that the user is or is not the requestor, or initiator, for the event being audited.
654         */
655        @Child(name = "requestor", type = {BooleanType.class}, order=4, min=0, max=1, modifier=false, summary=true)
656        @Description(shortDefinition="Whether user is initiator", formalDefinition="Indicator that the user is or is not the requestor, or initiator, for the event being audited." )
657        protected BooleanType requestor;
658
659        /**
660         * Where the agent location is known, the agent location when the event occurred.
661         */
662        @Child(name = "location", type = {Location.class}, order=5, min=0, max=1, modifier=false, summary=false)
663        @Description(shortDefinition="The agent location when the event occurred", formalDefinition="Where the agent location is known, the agent location when the event occurred." )
664        protected Reference location;
665
666        /**
667         * Where the policy(ies) are known that authorized the agent participation in the event. Typically, a single activity may have multiple applicable policies, such as patient consent, guarantor funding, etc. The policy would also indicate the security token used.
668         */
669        @Child(name = "policy", type = {UriType.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
670        @Description(shortDefinition="Policy that authorized the agent participation in the event", formalDefinition="Where the policy(ies) are known that authorized the agent participation in the event. Typically, a single activity may have multiple applicable policies, such as patient consent, guarantor funding, etc. The policy would also indicate the security token used." )
671        protected List<UriType> policy;
672
673        /**
674         * When the event utilizes a network there should be an agent describing the local system, and an agent describing remote system, with the network interface details.
675         */
676        @Child(name = "network", type = {Endpoint.class, UriType.class, StringType.class}, order=7, min=0, max=1, modifier=false, summary=false)
677        @Description(shortDefinition="This agent network location for the activity", formalDefinition="When the event utilizes a network there should be an agent describing the local system, and an agent describing remote system, with the network interface details." )
678        protected DataType network;
679
680        /**
681         * The authorization (e.g., PurposeOfUse) that was used during the event being recorded.
682         */
683        @Child(name = "authorization", type = {CodeableConcept.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
684        @Description(shortDefinition="Allowable authorization for this agent", formalDefinition="The authorization (e.g., PurposeOfUse) that was used during the event being recorded." )
685        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v3-PurposeOfUse")
686        protected List<CodeableConcept> authorization;
687
688        private static final long serialVersionUID = 509129255L;
689
690    /**
691     * Constructor
692     */
693      public AuditEventAgentComponent() {
694        super();
695      }
696
697    /**
698     * Constructor
699     */
700      public AuditEventAgentComponent(Reference who) {
701        super();
702        this.setWho(who);
703      }
704
705        /**
706         * @return {@link #type} (The Functional Role of the user when performing the event.)
707         */
708        public CodeableConcept getType() { 
709          if (this.type == null)
710            if (Configuration.errorOnAutoCreate())
711              throw new Error("Attempt to auto-create AuditEventAgentComponent.type");
712            else if (Configuration.doAutoCreate())
713              this.type = new CodeableConcept(); // cc
714          return this.type;
715        }
716
717        public boolean hasType() { 
718          return this.type != null && !this.type.isEmpty();
719        }
720
721        /**
722         * @param value {@link #type} (The Functional Role of the user when performing the event.)
723         */
724        public AuditEventAgentComponent setType(CodeableConcept value) { 
725          this.type = value;
726          return this;
727        }
728
729        /**
730         * @return {@link #role} (The structural roles of the agent indicating the agent's competency. The security role enabling the agent with respect to the activity.)
731         */
732        public List<CodeableConcept> getRole() { 
733          if (this.role == null)
734            this.role = new ArrayList<CodeableConcept>();
735          return this.role;
736        }
737
738        /**
739         * @return Returns a reference to <code>this</code> for easy method chaining
740         */
741        public AuditEventAgentComponent setRole(List<CodeableConcept> theRole) { 
742          this.role = theRole;
743          return this;
744        }
745
746        public boolean hasRole() { 
747          if (this.role == null)
748            return false;
749          for (CodeableConcept item : this.role)
750            if (!item.isEmpty())
751              return true;
752          return false;
753        }
754
755        public CodeableConcept addRole() { //3
756          CodeableConcept t = new CodeableConcept();
757          if (this.role == null)
758            this.role = new ArrayList<CodeableConcept>();
759          this.role.add(t);
760          return t;
761        }
762
763        public AuditEventAgentComponent addRole(CodeableConcept t) { //3
764          if (t == null)
765            return this;
766          if (this.role == null)
767            this.role = new ArrayList<CodeableConcept>();
768          this.role.add(t);
769          return this;
770        }
771
772        /**
773         * @return The first repetition of repeating field {@link #role}, creating it if it does not already exist {3}
774         */
775        public CodeableConcept getRoleFirstRep() { 
776          if (getRole().isEmpty()) {
777            addRole();
778          }
779          return getRole().get(0);
780        }
781
782        /**
783         * @return {@link #who} (Reference to who this agent is that was involved in the event.)
784         */
785        public Reference getWho() { 
786          if (this.who == null)
787            if (Configuration.errorOnAutoCreate())
788              throw new Error("Attempt to auto-create AuditEventAgentComponent.who");
789            else if (Configuration.doAutoCreate())
790              this.who = new Reference(); // cc
791          return this.who;
792        }
793
794        public boolean hasWho() { 
795          return this.who != null && !this.who.isEmpty();
796        }
797
798        /**
799         * @param value {@link #who} (Reference to who this agent is that was involved in the event.)
800         */
801        public AuditEventAgentComponent setWho(Reference value) { 
802          this.who = value;
803          return this;
804        }
805
806        /**
807         * @return {@link #requestor} (Indicator that the user is or is not the requestor, or initiator, for the event being audited.). This is the underlying object with id, value and extensions. The accessor "getRequestor" gives direct access to the value
808         */
809        public BooleanType getRequestorElement() { 
810          if (this.requestor == null)
811            if (Configuration.errorOnAutoCreate())
812              throw new Error("Attempt to auto-create AuditEventAgentComponent.requestor");
813            else if (Configuration.doAutoCreate())
814              this.requestor = new BooleanType(); // bb
815          return this.requestor;
816        }
817
818        public boolean hasRequestorElement() { 
819          return this.requestor != null && !this.requestor.isEmpty();
820        }
821
822        public boolean hasRequestor() { 
823          return this.requestor != null && !this.requestor.isEmpty();
824        }
825
826        /**
827         * @param value {@link #requestor} (Indicator that the user is or is not the requestor, or initiator, for the event being audited.). This is the underlying object with id, value and extensions. The accessor "getRequestor" gives direct access to the value
828         */
829        public AuditEventAgentComponent setRequestorElement(BooleanType value) { 
830          this.requestor = value;
831          return this;
832        }
833
834        /**
835         * @return Indicator that the user is or is not the requestor, or initiator, for the event being audited.
836         */
837        public boolean getRequestor() { 
838          return this.requestor == null || this.requestor.isEmpty() ? false : this.requestor.getValue();
839        }
840
841        /**
842         * @param value Indicator that the user is or is not the requestor, or initiator, for the event being audited.
843         */
844        public AuditEventAgentComponent setRequestor(boolean value) { 
845            if (this.requestor == null)
846              this.requestor = new BooleanType();
847            this.requestor.setValue(value);
848          return this;
849        }
850
851        /**
852         * @return {@link #location} (Where the agent location is known, the agent location when the event occurred.)
853         */
854        public Reference getLocation() { 
855          if (this.location == null)
856            if (Configuration.errorOnAutoCreate())
857              throw new Error("Attempt to auto-create AuditEventAgentComponent.location");
858            else if (Configuration.doAutoCreate())
859              this.location = new Reference(); // cc
860          return this.location;
861        }
862
863        public boolean hasLocation() { 
864          return this.location != null && !this.location.isEmpty();
865        }
866
867        /**
868         * @param value {@link #location} (Where the agent location is known, the agent location when the event occurred.)
869         */
870        public AuditEventAgentComponent setLocation(Reference value) { 
871          this.location = value;
872          return this;
873        }
874
875        /**
876         * @return {@link #policy} (Where the policy(ies) are known that authorized the agent participation in the event. Typically, a single activity may have multiple applicable policies, such as patient consent, guarantor funding, etc. The policy would also indicate the security token used.)
877         */
878        public List<UriType> getPolicy() { 
879          if (this.policy == null)
880            this.policy = new ArrayList<UriType>();
881          return this.policy;
882        }
883
884        /**
885         * @return Returns a reference to <code>this</code> for easy method chaining
886         */
887        public AuditEventAgentComponent setPolicy(List<UriType> thePolicy) { 
888          this.policy = thePolicy;
889          return this;
890        }
891
892        public boolean hasPolicy() { 
893          if (this.policy == null)
894            return false;
895          for (UriType item : this.policy)
896            if (!item.isEmpty())
897              return true;
898          return false;
899        }
900
901        /**
902         * @return {@link #policy} (Where the policy(ies) are known that authorized the agent participation in the event. Typically, a single activity may have multiple applicable policies, such as patient consent, guarantor funding, etc. The policy would also indicate the security token used.)
903         */
904        public UriType addPolicyElement() {//2 
905          UriType t = new UriType();
906          if (this.policy == null)
907            this.policy = new ArrayList<UriType>();
908          this.policy.add(t);
909          return t;
910        }
911
912        /**
913         * @param value {@link #policy} (Where the policy(ies) are known that authorized the agent participation in the event. Typically, a single activity may have multiple applicable policies, such as patient consent, guarantor funding, etc. The policy would also indicate the security token used.)
914         */
915        public AuditEventAgentComponent addPolicy(String value) { //1
916          UriType t = new UriType();
917          t.setValue(value);
918          if (this.policy == null)
919            this.policy = new ArrayList<UriType>();
920          this.policy.add(t);
921          return this;
922        }
923
924        /**
925         * @param value {@link #policy} (Where the policy(ies) are known that authorized the agent participation in the event. Typically, a single activity may have multiple applicable policies, such as patient consent, guarantor funding, etc. The policy would also indicate the security token used.)
926         */
927        public boolean hasPolicy(String value) { 
928          if (this.policy == null)
929            return false;
930          for (UriType v : this.policy)
931            if (v.getValue().equals(value)) // uri
932              return true;
933          return false;
934        }
935
936        /**
937         * @return {@link #network} (When the event utilizes a network there should be an agent describing the local system, and an agent describing remote system, with the network interface details.)
938         */
939        public DataType getNetwork() { 
940          return this.network;
941        }
942
943        /**
944         * @return {@link #network} (When the event utilizes a network there should be an agent describing the local system, and an agent describing remote system, with the network interface details.)
945         */
946        public Reference getNetworkReference() throws FHIRException { 
947          if (this.network == null)
948            this.network = new Reference();
949          if (!(this.network instanceof Reference))
950            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.network.getClass().getName()+" was encountered");
951          return (Reference) this.network;
952        }
953
954        public boolean hasNetworkReference() { 
955          return this != null && this.network instanceof Reference;
956        }
957
958        /**
959         * @return {@link #network} (When the event utilizes a network there should be an agent describing the local system, and an agent describing remote system, with the network interface details.)
960         */
961        public UriType getNetworkUriType() throws FHIRException { 
962          if (this.network == null)
963            this.network = new UriType();
964          if (!(this.network instanceof UriType))
965            throw new FHIRException("Type mismatch: the type UriType was expected, but "+this.network.getClass().getName()+" was encountered");
966          return (UriType) this.network;
967        }
968
969        public boolean hasNetworkUriType() { 
970          return this != null && this.network instanceof UriType;
971        }
972
973        /**
974         * @return {@link #network} (When the event utilizes a network there should be an agent describing the local system, and an agent describing remote system, with the network interface details.)
975         */
976        public StringType getNetworkStringType() throws FHIRException { 
977          if (this.network == null)
978            this.network = new StringType();
979          if (!(this.network instanceof StringType))
980            throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.network.getClass().getName()+" was encountered");
981          return (StringType) this.network;
982        }
983
984        public boolean hasNetworkStringType() { 
985          return this != null && this.network instanceof StringType;
986        }
987
988        public boolean hasNetwork() { 
989          return this.network != null && !this.network.isEmpty();
990        }
991
992        /**
993         * @param value {@link #network} (When the event utilizes a network there should be an agent describing the local system, and an agent describing remote system, with the network interface details.)
994         */
995        public AuditEventAgentComponent setNetwork(DataType value) { 
996          if (value != null && !(value instanceof Reference || value instanceof UriType || value instanceof StringType))
997            throw new Error("Not the right type for AuditEvent.agent.network[x]: "+value.fhirType());
998          this.network = value;
999          return this;
1000        }
1001
1002        /**
1003         * @return {@link #authorization} (The authorization (e.g., PurposeOfUse) that was used during the event being recorded.)
1004         */
1005        public List<CodeableConcept> getAuthorization() { 
1006          if (this.authorization == null)
1007            this.authorization = new ArrayList<CodeableConcept>();
1008          return this.authorization;
1009        }
1010
1011        /**
1012         * @return Returns a reference to <code>this</code> for easy method chaining
1013         */
1014        public AuditEventAgentComponent setAuthorization(List<CodeableConcept> theAuthorization) { 
1015          this.authorization = theAuthorization;
1016          return this;
1017        }
1018
1019        public boolean hasAuthorization() { 
1020          if (this.authorization == null)
1021            return false;
1022          for (CodeableConcept item : this.authorization)
1023            if (!item.isEmpty())
1024              return true;
1025          return false;
1026        }
1027
1028        public CodeableConcept addAuthorization() { //3
1029          CodeableConcept t = new CodeableConcept();
1030          if (this.authorization == null)
1031            this.authorization = new ArrayList<CodeableConcept>();
1032          this.authorization.add(t);
1033          return t;
1034        }
1035
1036        public AuditEventAgentComponent addAuthorization(CodeableConcept t) { //3
1037          if (t == null)
1038            return this;
1039          if (this.authorization == null)
1040            this.authorization = new ArrayList<CodeableConcept>();
1041          this.authorization.add(t);
1042          return this;
1043        }
1044
1045        /**
1046         * @return The first repetition of repeating field {@link #authorization}, creating it if it does not already exist {3}
1047         */
1048        public CodeableConcept getAuthorizationFirstRep() { 
1049          if (getAuthorization().isEmpty()) {
1050            addAuthorization();
1051          }
1052          return getAuthorization().get(0);
1053        }
1054
1055        protected void listChildren(List<Property> children) {
1056          super.listChildren(children);
1057          children.add(new Property("type", "CodeableConcept", "The Functional Role of the user when performing the event.", 0, 1, type));
1058          children.add(new Property("role", "CodeableConcept", "The structural roles of the agent indicating the agent's competency. The security role enabling the agent with respect to the activity.", 0, java.lang.Integer.MAX_VALUE, role));
1059          children.add(new Property("who", "Reference(Practitioner|PractitionerRole|Organization|CareTeam|Patient|Device|RelatedPerson)", "Reference to who this agent is that was involved in the event.", 0, 1, who));
1060          children.add(new Property("requestor", "boolean", "Indicator that the user is or is not the requestor, or initiator, for the event being audited.", 0, 1, requestor));
1061          children.add(new Property("location", "Reference(Location)", "Where the agent location is known, the agent location when the event occurred.", 0, 1, location));
1062          children.add(new Property("policy", "uri", "Where the policy(ies) are known that authorized the agent participation in the event. Typically, a single activity may have multiple applicable policies, such as patient consent, guarantor funding, etc. The policy would also indicate the security token used.", 0, java.lang.Integer.MAX_VALUE, policy));
1063          children.add(new Property("network[x]", "Reference(Endpoint)|uri|string", "When the event utilizes a network there should be an agent describing the local system, and an agent describing remote system, with the network interface details.", 0, 1, network));
1064          children.add(new Property("authorization", "CodeableConcept", "The authorization (e.g., PurposeOfUse) that was used during the event being recorded.", 0, java.lang.Integer.MAX_VALUE, authorization));
1065        }
1066
1067        @Override
1068        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1069          switch (_hash) {
1070          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "The Functional Role of the user when performing the event.", 0, 1, type);
1071          case 3506294: /*role*/  return new Property("role", "CodeableConcept", "The structural roles of the agent indicating the agent's competency. The security role enabling the agent with respect to the activity.", 0, java.lang.Integer.MAX_VALUE, role);
1072          case 117694: /*who*/  return new Property("who", "Reference(Practitioner|PractitionerRole|Organization|CareTeam|Patient|Device|RelatedPerson)", "Reference to who this agent is that was involved in the event.", 0, 1, who);
1073          case 693934258: /*requestor*/  return new Property("requestor", "boolean", "Indicator that the user is or is not the requestor, or initiator, for the event being audited.", 0, 1, requestor);
1074          case 1901043637: /*location*/  return new Property("location", "Reference(Location)", "Where the agent location is known, the agent location when the event occurred.", 0, 1, location);
1075          case -982670030: /*policy*/  return new Property("policy", "uri", "Where the policy(ies) are known that authorized the agent participation in the event. Typically, a single activity may have multiple applicable policies, such as patient consent, guarantor funding, etc. The policy would also indicate the security token used.", 0, java.lang.Integer.MAX_VALUE, policy);
1076          case -478235758: /*network[x]*/  return new Property("network[x]", "Reference(Endpoint)|uri|string", "When the event utilizes a network there should be an agent describing the local system, and an agent describing remote system, with the network interface details.", 0, 1, network);
1077          case 1843485230: /*network*/  return new Property("network[x]", "Reference(Endpoint)|uri|string", "When the event utilizes a network there should be an agent describing the local system, and an agent describing remote system, with the network interface details.", 0, 1, network);
1078          case -1769760579: /*networkReference*/  return new Property("network[x]", "Reference(Endpoint)", "When the event utilizes a network there should be an agent describing the local system, and an agent describing remote system, with the network interface details.", 0, 1, network);
1079          case -478241698: /*networkUri*/  return new Property("network[x]", "uri", "When the event utilizes a network there should be an agent describing the local system, and an agent describing remote system, with the network interface details.", 0, 1, network);
1080          case -946943009: /*networkString*/  return new Property("network[x]", "string", "When the event utilizes a network there should be an agent describing the local system, and an agent describing remote system, with the network interface details.", 0, 1, network);
1081          case -1385570183: /*authorization*/  return new Property("authorization", "CodeableConcept", "The authorization (e.g., PurposeOfUse) that was used during the event being recorded.", 0, java.lang.Integer.MAX_VALUE, authorization);
1082          default: return super.getNamedProperty(_hash, _name, _checkValid);
1083          }
1084
1085        }
1086
1087      @Override
1088      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1089        switch (hash) {
1090        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
1091        case 3506294: /*role*/ return this.role == null ? new Base[0] : this.role.toArray(new Base[this.role.size()]); // CodeableConcept
1092        case 117694: /*who*/ return this.who == null ? new Base[0] : new Base[] {this.who}; // Reference
1093        case 693934258: /*requestor*/ return this.requestor == null ? new Base[0] : new Base[] {this.requestor}; // BooleanType
1094        case 1901043637: /*location*/ return this.location == null ? new Base[0] : new Base[] {this.location}; // Reference
1095        case -982670030: /*policy*/ return this.policy == null ? new Base[0] : this.policy.toArray(new Base[this.policy.size()]); // UriType
1096        case 1843485230: /*network*/ return this.network == null ? new Base[0] : new Base[] {this.network}; // DataType
1097        case -1385570183: /*authorization*/ return this.authorization == null ? new Base[0] : this.authorization.toArray(new Base[this.authorization.size()]); // CodeableConcept
1098        default: return super.getProperty(hash, name, checkValid);
1099        }
1100
1101      }
1102
1103      @Override
1104      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1105        switch (hash) {
1106        case 3575610: // type
1107          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1108          return value;
1109        case 3506294: // role
1110          this.getRole().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
1111          return value;
1112        case 117694: // who
1113          this.who = TypeConvertor.castToReference(value); // Reference
1114          return value;
1115        case 693934258: // requestor
1116          this.requestor = TypeConvertor.castToBoolean(value); // BooleanType
1117          return value;
1118        case 1901043637: // location
1119          this.location = TypeConvertor.castToReference(value); // Reference
1120          return value;
1121        case -982670030: // policy
1122          this.getPolicy().add(TypeConvertor.castToUri(value)); // UriType
1123          return value;
1124        case 1843485230: // network
1125          this.network = TypeConvertor.castToType(value); // DataType
1126          return value;
1127        case -1385570183: // authorization
1128          this.getAuthorization().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
1129          return value;
1130        default: return super.setProperty(hash, name, value);
1131        }
1132
1133      }
1134
1135      @Override
1136      public Base setProperty(String name, Base value) throws FHIRException {
1137        if (name.equals("type")) {
1138          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1139        } else if (name.equals("role")) {
1140          this.getRole().add(TypeConvertor.castToCodeableConcept(value));
1141        } else if (name.equals("who")) {
1142          this.who = TypeConvertor.castToReference(value); // Reference
1143        } else if (name.equals("requestor")) {
1144          this.requestor = TypeConvertor.castToBoolean(value); // BooleanType
1145        } else if (name.equals("location")) {
1146          this.location = TypeConvertor.castToReference(value); // Reference
1147        } else if (name.equals("policy")) {
1148          this.getPolicy().add(TypeConvertor.castToUri(value));
1149        } else if (name.equals("network[x]")) {
1150          this.network = TypeConvertor.castToType(value); // DataType
1151        } else if (name.equals("authorization")) {
1152          this.getAuthorization().add(TypeConvertor.castToCodeableConcept(value));
1153        } else
1154          return super.setProperty(name, value);
1155        return value;
1156      }
1157
1158      @Override
1159      public Base makeProperty(int hash, String name) throws FHIRException {
1160        switch (hash) {
1161        case 3575610:  return getType();
1162        case 3506294:  return addRole(); 
1163        case 117694:  return getWho();
1164        case 693934258:  return getRequestorElement();
1165        case 1901043637:  return getLocation();
1166        case -982670030:  return addPolicyElement();
1167        case -478235758:  return getNetwork();
1168        case 1843485230:  return getNetwork();
1169        case -1385570183:  return addAuthorization(); 
1170        default: return super.makeProperty(hash, name);
1171        }
1172
1173      }
1174
1175      @Override
1176      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1177        switch (hash) {
1178        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1179        case 3506294: /*role*/ return new String[] {"CodeableConcept"};
1180        case 117694: /*who*/ return new String[] {"Reference"};
1181        case 693934258: /*requestor*/ return new String[] {"boolean"};
1182        case 1901043637: /*location*/ return new String[] {"Reference"};
1183        case -982670030: /*policy*/ return new String[] {"uri"};
1184        case 1843485230: /*network*/ return new String[] {"Reference", "uri", "string"};
1185        case -1385570183: /*authorization*/ return new String[] {"CodeableConcept"};
1186        default: return super.getTypesForProperty(hash, name);
1187        }
1188
1189      }
1190
1191      @Override
1192      public Base addChild(String name) throws FHIRException {
1193        if (name.equals("type")) {
1194          this.type = new CodeableConcept();
1195          return this.type;
1196        }
1197        else if (name.equals("role")) {
1198          return addRole();
1199        }
1200        else if (name.equals("who")) {
1201          this.who = new Reference();
1202          return this.who;
1203        }
1204        else if (name.equals("requestor")) {
1205          throw new FHIRException("Cannot call addChild on a primitive type AuditEvent.agent.requestor");
1206        }
1207        else if (name.equals("location")) {
1208          this.location = new Reference();
1209          return this.location;
1210        }
1211        else if (name.equals("policy")) {
1212          throw new FHIRException("Cannot call addChild on a primitive type AuditEvent.agent.policy");
1213        }
1214        else if (name.equals("networkReference")) {
1215          this.network = new Reference();
1216          return this.network;
1217        }
1218        else if (name.equals("networkUri")) {
1219          this.network = new UriType();
1220          return this.network;
1221        }
1222        else if (name.equals("networkString")) {
1223          this.network = new StringType();
1224          return this.network;
1225        }
1226        else if (name.equals("authorization")) {
1227          return addAuthorization();
1228        }
1229        else
1230          return super.addChild(name);
1231      }
1232
1233      public AuditEventAgentComponent copy() {
1234        AuditEventAgentComponent dst = new AuditEventAgentComponent();
1235        copyValues(dst);
1236        return dst;
1237      }
1238
1239      public void copyValues(AuditEventAgentComponent dst) {
1240        super.copyValues(dst);
1241        dst.type = type == null ? null : type.copy();
1242        if (role != null) {
1243          dst.role = new ArrayList<CodeableConcept>();
1244          for (CodeableConcept i : role)
1245            dst.role.add(i.copy());
1246        };
1247        dst.who = who == null ? null : who.copy();
1248        dst.requestor = requestor == null ? null : requestor.copy();
1249        dst.location = location == null ? null : location.copy();
1250        if (policy != null) {
1251          dst.policy = new ArrayList<UriType>();
1252          for (UriType i : policy)
1253            dst.policy.add(i.copy());
1254        };
1255        dst.network = network == null ? null : network.copy();
1256        if (authorization != null) {
1257          dst.authorization = new ArrayList<CodeableConcept>();
1258          for (CodeableConcept i : authorization)
1259            dst.authorization.add(i.copy());
1260        };
1261      }
1262
1263      @Override
1264      public boolean equalsDeep(Base other_) {
1265        if (!super.equalsDeep(other_))
1266          return false;
1267        if (!(other_ instanceof AuditEventAgentComponent))
1268          return false;
1269        AuditEventAgentComponent o = (AuditEventAgentComponent) other_;
1270        return compareDeep(type, o.type, true) && compareDeep(role, o.role, true) && compareDeep(who, o.who, true)
1271           && compareDeep(requestor, o.requestor, true) && compareDeep(location, o.location, true) && compareDeep(policy, o.policy, true)
1272           && compareDeep(network, o.network, true) && compareDeep(authorization, o.authorization, true);
1273      }
1274
1275      @Override
1276      public boolean equalsShallow(Base other_) {
1277        if (!super.equalsShallow(other_))
1278          return false;
1279        if (!(other_ instanceof AuditEventAgentComponent))
1280          return false;
1281        AuditEventAgentComponent o = (AuditEventAgentComponent) other_;
1282        return compareValues(requestor, o.requestor, true) && compareValues(policy, o.policy, true);
1283      }
1284
1285      public boolean isEmpty() {
1286        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, role, who, requestor
1287          , location, policy, network, authorization);
1288      }
1289
1290  public String fhirType() {
1291    return "AuditEvent.agent";
1292
1293  }
1294
1295  }
1296
1297    @Block()
1298    public static class AuditEventSourceComponent extends BackboneElement implements IBaseBackboneElement {
1299        /**
1300         * Logical source location within the healthcare enterprise network.  For example, a hospital or other provider location within a multi-entity provider group.
1301         */
1302        @Child(name = "site", type = {Location.class}, order=1, min=0, max=1, modifier=false, summary=false)
1303        @Description(shortDefinition="Logical source location within the enterprise", formalDefinition="Logical source location within the healthcare enterprise network.  For example, a hospital or other provider location within a multi-entity provider group." )
1304        protected Reference site;
1305
1306        /**
1307         * Identifier of the source where the event was detected.
1308         */
1309        @Child(name = "observer", type = {Practitioner.class, PractitionerRole.class, Organization.class, CareTeam.class, Patient.class, Device.class, RelatedPerson.class}, order=2, min=1, max=1, modifier=false, summary=true)
1310        @Description(shortDefinition="The identity of source detecting the event", formalDefinition="Identifier of the source where the event was detected." )
1311        protected Reference observer;
1312
1313        /**
1314         * Code specifying the type of source where event originated.
1315         */
1316        @Child(name = "type", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1317        @Description(shortDefinition="The type of source where event originated", formalDefinition="Code specifying the type of source where event originated." )
1318        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/security-source-type")
1319        protected List<CodeableConcept> type;
1320
1321        private static final long serialVersionUID = -140005578L;
1322
1323    /**
1324     * Constructor
1325     */
1326      public AuditEventSourceComponent() {
1327        super();
1328      }
1329
1330    /**
1331     * Constructor
1332     */
1333      public AuditEventSourceComponent(Reference observer) {
1334        super();
1335        this.setObserver(observer);
1336      }
1337
1338        /**
1339         * @return {@link #site} (Logical source location within the healthcare enterprise network.  For example, a hospital or other provider location within a multi-entity provider group.)
1340         */
1341        public Reference getSite() { 
1342          if (this.site == null)
1343            if (Configuration.errorOnAutoCreate())
1344              throw new Error("Attempt to auto-create AuditEventSourceComponent.site");
1345            else if (Configuration.doAutoCreate())
1346              this.site = new Reference(); // cc
1347          return this.site;
1348        }
1349
1350        public boolean hasSite() { 
1351          return this.site != null && !this.site.isEmpty();
1352        }
1353
1354        /**
1355         * @param value {@link #site} (Logical source location within the healthcare enterprise network.  For example, a hospital or other provider location within a multi-entity provider group.)
1356         */
1357        public AuditEventSourceComponent setSite(Reference value) { 
1358          this.site = value;
1359          return this;
1360        }
1361
1362        /**
1363         * @return {@link #observer} (Identifier of the source where the event was detected.)
1364         */
1365        public Reference getObserver() { 
1366          if (this.observer == null)
1367            if (Configuration.errorOnAutoCreate())
1368              throw new Error("Attempt to auto-create AuditEventSourceComponent.observer");
1369            else if (Configuration.doAutoCreate())
1370              this.observer = new Reference(); // cc
1371          return this.observer;
1372        }
1373
1374        public boolean hasObserver() { 
1375          return this.observer != null && !this.observer.isEmpty();
1376        }
1377
1378        /**
1379         * @param value {@link #observer} (Identifier of the source where the event was detected.)
1380         */
1381        public AuditEventSourceComponent setObserver(Reference value) { 
1382          this.observer = value;
1383          return this;
1384        }
1385
1386        /**
1387         * @return {@link #type} (Code specifying the type of source where event originated.)
1388         */
1389        public List<CodeableConcept> getType() { 
1390          if (this.type == null)
1391            this.type = new ArrayList<CodeableConcept>();
1392          return this.type;
1393        }
1394
1395        /**
1396         * @return Returns a reference to <code>this</code> for easy method chaining
1397         */
1398        public AuditEventSourceComponent setType(List<CodeableConcept> theType) { 
1399          this.type = theType;
1400          return this;
1401        }
1402
1403        public boolean hasType() { 
1404          if (this.type == null)
1405            return false;
1406          for (CodeableConcept item : this.type)
1407            if (!item.isEmpty())
1408              return true;
1409          return false;
1410        }
1411
1412        public CodeableConcept addType() { //3
1413          CodeableConcept t = new CodeableConcept();
1414          if (this.type == null)
1415            this.type = new ArrayList<CodeableConcept>();
1416          this.type.add(t);
1417          return t;
1418        }
1419
1420        public AuditEventSourceComponent addType(CodeableConcept t) { //3
1421          if (t == null)
1422            return this;
1423          if (this.type == null)
1424            this.type = new ArrayList<CodeableConcept>();
1425          this.type.add(t);
1426          return this;
1427        }
1428
1429        /**
1430         * @return The first repetition of repeating field {@link #type}, creating it if it does not already exist {3}
1431         */
1432        public CodeableConcept getTypeFirstRep() { 
1433          if (getType().isEmpty()) {
1434            addType();
1435          }
1436          return getType().get(0);
1437        }
1438
1439        protected void listChildren(List<Property> children) {
1440          super.listChildren(children);
1441          children.add(new Property("site", "Reference(Location)", "Logical source location within the healthcare enterprise network.  For example, a hospital or other provider location within a multi-entity provider group.", 0, 1, site));
1442          children.add(new Property("observer", "Reference(Practitioner|PractitionerRole|Organization|CareTeam|Patient|Device|RelatedPerson)", "Identifier of the source where the event was detected.", 0, 1, observer));
1443          children.add(new Property("type", "CodeableConcept", "Code specifying the type of source where event originated.", 0, java.lang.Integer.MAX_VALUE, type));
1444        }
1445
1446        @Override
1447        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1448          switch (_hash) {
1449          case 3530567: /*site*/  return new Property("site", "Reference(Location)", "Logical source location within the healthcare enterprise network.  For example, a hospital or other provider location within a multi-entity provider group.", 0, 1, site);
1450          case 348607190: /*observer*/  return new Property("observer", "Reference(Practitioner|PractitionerRole|Organization|CareTeam|Patient|Device|RelatedPerson)", "Identifier of the source where the event was detected.", 0, 1, observer);
1451          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "Code specifying the type of source where event originated.", 0, java.lang.Integer.MAX_VALUE, type);
1452          default: return super.getNamedProperty(_hash, _name, _checkValid);
1453          }
1454
1455        }
1456
1457      @Override
1458      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1459        switch (hash) {
1460        case 3530567: /*site*/ return this.site == null ? new Base[0] : new Base[] {this.site}; // Reference
1461        case 348607190: /*observer*/ return this.observer == null ? new Base[0] : new Base[] {this.observer}; // Reference
1462        case 3575610: /*type*/ return this.type == null ? new Base[0] : this.type.toArray(new Base[this.type.size()]); // CodeableConcept
1463        default: return super.getProperty(hash, name, checkValid);
1464        }
1465
1466      }
1467
1468      @Override
1469      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1470        switch (hash) {
1471        case 3530567: // site
1472          this.site = TypeConvertor.castToReference(value); // Reference
1473          return value;
1474        case 348607190: // observer
1475          this.observer = TypeConvertor.castToReference(value); // Reference
1476          return value;
1477        case 3575610: // type
1478          this.getType().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
1479          return value;
1480        default: return super.setProperty(hash, name, value);
1481        }
1482
1483      }
1484
1485      @Override
1486      public Base setProperty(String name, Base value) throws FHIRException {
1487        if (name.equals("site")) {
1488          this.site = TypeConvertor.castToReference(value); // Reference
1489        } else if (name.equals("observer")) {
1490          this.observer = TypeConvertor.castToReference(value); // Reference
1491        } else if (name.equals("type")) {
1492          this.getType().add(TypeConvertor.castToCodeableConcept(value));
1493        } else
1494          return super.setProperty(name, value);
1495        return value;
1496      }
1497
1498      @Override
1499      public Base makeProperty(int hash, String name) throws FHIRException {
1500        switch (hash) {
1501        case 3530567:  return getSite();
1502        case 348607190:  return getObserver();
1503        case 3575610:  return addType(); 
1504        default: return super.makeProperty(hash, name);
1505        }
1506
1507      }
1508
1509      @Override
1510      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1511        switch (hash) {
1512        case 3530567: /*site*/ return new String[] {"Reference"};
1513        case 348607190: /*observer*/ return new String[] {"Reference"};
1514        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1515        default: return super.getTypesForProperty(hash, name);
1516        }
1517
1518      }
1519
1520      @Override
1521      public Base addChild(String name) throws FHIRException {
1522        if (name.equals("site")) {
1523          this.site = new Reference();
1524          return this.site;
1525        }
1526        else if (name.equals("observer")) {
1527          this.observer = new Reference();
1528          return this.observer;
1529        }
1530        else if (name.equals("type")) {
1531          return addType();
1532        }
1533        else
1534          return super.addChild(name);
1535      }
1536
1537      public AuditEventSourceComponent copy() {
1538        AuditEventSourceComponent dst = new AuditEventSourceComponent();
1539        copyValues(dst);
1540        return dst;
1541      }
1542
1543      public void copyValues(AuditEventSourceComponent dst) {
1544        super.copyValues(dst);
1545        dst.site = site == null ? null : site.copy();
1546        dst.observer = observer == null ? null : observer.copy();
1547        if (type != null) {
1548          dst.type = new ArrayList<CodeableConcept>();
1549          for (CodeableConcept i : type)
1550            dst.type.add(i.copy());
1551        };
1552      }
1553
1554      @Override
1555      public boolean equalsDeep(Base other_) {
1556        if (!super.equalsDeep(other_))
1557          return false;
1558        if (!(other_ instanceof AuditEventSourceComponent))
1559          return false;
1560        AuditEventSourceComponent o = (AuditEventSourceComponent) other_;
1561        return compareDeep(site, o.site, true) && compareDeep(observer, o.observer, true) && compareDeep(type, o.type, true)
1562          ;
1563      }
1564
1565      @Override
1566      public boolean equalsShallow(Base other_) {
1567        if (!super.equalsShallow(other_))
1568          return false;
1569        if (!(other_ instanceof AuditEventSourceComponent))
1570          return false;
1571        AuditEventSourceComponent o = (AuditEventSourceComponent) other_;
1572        return true;
1573      }
1574
1575      public boolean isEmpty() {
1576        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(site, observer, type);
1577      }
1578
1579  public String fhirType() {
1580    return "AuditEvent.source";
1581
1582  }
1583
1584  }
1585
1586    @Block()
1587    public static class AuditEventEntityComponent extends BackboneElement implements IBaseBackboneElement {
1588        /**
1589         * Identifies a specific instance of the entity. The reference should be version specific.
1590         */
1591        @Child(name = "what", type = {Reference.class}, order=1, min=0, max=1, modifier=false, summary=true)
1592        @Description(shortDefinition="Specific instance of resource", formalDefinition="Identifies a specific instance of the entity. The reference should be version specific." )
1593        protected Reference what;
1594
1595        /**
1596         * Code representing the role the entity played in the event being audited.
1597         */
1598        @Child(name = "role", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
1599        @Description(shortDefinition="What role the entity played", formalDefinition="Code representing the role the entity played in the event being audited." )
1600        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/object-role")
1601        protected CodeableConcept role;
1602
1603        /**
1604         * Security labels for the identified entity.
1605         */
1606        @Child(name = "securityLabel", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1607        @Description(shortDefinition="Security labels on the entity", formalDefinition="Security labels for the identified entity." )
1608        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/security-labels")
1609        protected List<CodeableConcept> securityLabel;
1610
1611        /**
1612         * The query parameters for a query-type entities.
1613         */
1614        @Child(name = "query", type = {Base64BinaryType.class}, order=4, min=0, max=1, modifier=false, summary=true)
1615        @Description(shortDefinition="Query parameters", formalDefinition="The query parameters for a query-type entities." )
1616        protected Base64BinaryType query;
1617
1618        /**
1619         * Tagged value pairs for conveying additional information about the entity.
1620         */
1621        @Child(name = "detail", type = {}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1622        @Description(shortDefinition="Additional Information about the entity", formalDefinition="Tagged value pairs for conveying additional information about the entity." )
1623        protected List<AuditEventEntityDetailComponent> detail;
1624
1625        /**
1626         * The entity is attributed to an agent to express the agent's responsibility for that entity in the activity. This is most used to indicate when persistence media (the entity) are used by an agent. For example when importing data from a device, the device would be described in an entity, and the user importing data from that media would be indicated as the entity.agent.
1627         */
1628        @Child(name = "agent", type = {AuditEventAgentComponent.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1629        @Description(shortDefinition="Entity is attributed to this agent", formalDefinition="The entity is attributed to an agent to express the agent's responsibility for that entity in the activity. This is most used to indicate when persistence media (the entity) are used by an agent. For example when importing data from a device, the device would be described in an entity, and the user importing data from that media would be indicated as the entity.agent." )
1630        protected List<AuditEventAgentComponent> agent;
1631
1632        private static final long serialVersionUID = -711898650L;
1633
1634    /**
1635     * Constructor
1636     */
1637      public AuditEventEntityComponent() {
1638        super();
1639      }
1640
1641        /**
1642         * @return {@link #what} (Identifies a specific instance of the entity. The reference should be version specific.)
1643         */
1644        public Reference getWhat() { 
1645          if (this.what == null)
1646            if (Configuration.errorOnAutoCreate())
1647              throw new Error("Attempt to auto-create AuditEventEntityComponent.what");
1648            else if (Configuration.doAutoCreate())
1649              this.what = new Reference(); // cc
1650          return this.what;
1651        }
1652
1653        public boolean hasWhat() { 
1654          return this.what != null && !this.what.isEmpty();
1655        }
1656
1657        /**
1658         * @param value {@link #what} (Identifies a specific instance of the entity. The reference should be version specific.)
1659         */
1660        public AuditEventEntityComponent setWhat(Reference value) { 
1661          this.what = value;
1662          return this;
1663        }
1664
1665        /**
1666         * @return {@link #role} (Code representing the role the entity played in the event being audited.)
1667         */
1668        public CodeableConcept getRole() { 
1669          if (this.role == null)
1670            if (Configuration.errorOnAutoCreate())
1671              throw new Error("Attempt to auto-create AuditEventEntityComponent.role");
1672            else if (Configuration.doAutoCreate())
1673              this.role = new CodeableConcept(); // cc
1674          return this.role;
1675        }
1676
1677        public boolean hasRole() { 
1678          return this.role != null && !this.role.isEmpty();
1679        }
1680
1681        /**
1682         * @param value {@link #role} (Code representing the role the entity played in the event being audited.)
1683         */
1684        public AuditEventEntityComponent setRole(CodeableConcept value) { 
1685          this.role = value;
1686          return this;
1687        }
1688
1689        /**
1690         * @return {@link #securityLabel} (Security labels for the identified entity.)
1691         */
1692        public List<CodeableConcept> getSecurityLabel() { 
1693          if (this.securityLabel == null)
1694            this.securityLabel = new ArrayList<CodeableConcept>();
1695          return this.securityLabel;
1696        }
1697
1698        /**
1699         * @return Returns a reference to <code>this</code> for easy method chaining
1700         */
1701        public AuditEventEntityComponent setSecurityLabel(List<CodeableConcept> theSecurityLabel) { 
1702          this.securityLabel = theSecurityLabel;
1703          return this;
1704        }
1705
1706        public boolean hasSecurityLabel() { 
1707          if (this.securityLabel == null)
1708            return false;
1709          for (CodeableConcept item : this.securityLabel)
1710            if (!item.isEmpty())
1711              return true;
1712          return false;
1713        }
1714
1715        public CodeableConcept addSecurityLabel() { //3
1716          CodeableConcept t = new CodeableConcept();
1717          if (this.securityLabel == null)
1718            this.securityLabel = new ArrayList<CodeableConcept>();
1719          this.securityLabel.add(t);
1720          return t;
1721        }
1722
1723        public AuditEventEntityComponent addSecurityLabel(CodeableConcept t) { //3
1724          if (t == null)
1725            return this;
1726          if (this.securityLabel == null)
1727            this.securityLabel = new ArrayList<CodeableConcept>();
1728          this.securityLabel.add(t);
1729          return this;
1730        }
1731
1732        /**
1733         * @return The first repetition of repeating field {@link #securityLabel}, creating it if it does not already exist {3}
1734         */
1735        public CodeableConcept getSecurityLabelFirstRep() { 
1736          if (getSecurityLabel().isEmpty()) {
1737            addSecurityLabel();
1738          }
1739          return getSecurityLabel().get(0);
1740        }
1741
1742        /**
1743         * @return {@link #query} (The query parameters for a query-type entities.). This is the underlying object with id, value and extensions. The accessor "getQuery" gives direct access to the value
1744         */
1745        public Base64BinaryType getQueryElement() { 
1746          if (this.query == null)
1747            if (Configuration.errorOnAutoCreate())
1748              throw new Error("Attempt to auto-create AuditEventEntityComponent.query");
1749            else if (Configuration.doAutoCreate())
1750              this.query = new Base64BinaryType(); // bb
1751          return this.query;
1752        }
1753
1754        public boolean hasQueryElement() { 
1755          return this.query != null && !this.query.isEmpty();
1756        }
1757
1758        public boolean hasQuery() { 
1759          return this.query != null && !this.query.isEmpty();
1760        }
1761
1762        /**
1763         * @param value {@link #query} (The query parameters for a query-type entities.). This is the underlying object with id, value and extensions. The accessor "getQuery" gives direct access to the value
1764         */
1765        public AuditEventEntityComponent setQueryElement(Base64BinaryType value) { 
1766          this.query = value;
1767          return this;
1768        }
1769
1770        /**
1771         * @return The query parameters for a query-type entities.
1772         */
1773        public byte[] getQuery() { 
1774          return this.query == null ? null : this.query.getValue();
1775        }
1776
1777        /**
1778         * @param value The query parameters for a query-type entities.
1779         */
1780        public AuditEventEntityComponent setQuery(byte[] value) { 
1781          if (value == null)
1782            this.query = null;
1783          else {
1784            if (this.query == null)
1785              this.query = new Base64BinaryType();
1786            this.query.setValue(value);
1787          }
1788          return this;
1789        }
1790
1791        /**
1792         * @return {@link #detail} (Tagged value pairs for conveying additional information about the entity.)
1793         */
1794        public List<AuditEventEntityDetailComponent> getDetail() { 
1795          if (this.detail == null)
1796            this.detail = new ArrayList<AuditEventEntityDetailComponent>();
1797          return this.detail;
1798        }
1799
1800        /**
1801         * @return Returns a reference to <code>this</code> for easy method chaining
1802         */
1803        public AuditEventEntityComponent setDetail(List<AuditEventEntityDetailComponent> theDetail) { 
1804          this.detail = theDetail;
1805          return this;
1806        }
1807
1808        public boolean hasDetail() { 
1809          if (this.detail == null)
1810            return false;
1811          for (AuditEventEntityDetailComponent item : this.detail)
1812            if (!item.isEmpty())
1813              return true;
1814          return false;
1815        }
1816
1817        public AuditEventEntityDetailComponent addDetail() { //3
1818          AuditEventEntityDetailComponent t = new AuditEventEntityDetailComponent();
1819          if (this.detail == null)
1820            this.detail = new ArrayList<AuditEventEntityDetailComponent>();
1821          this.detail.add(t);
1822          return t;
1823        }
1824
1825        public AuditEventEntityComponent addDetail(AuditEventEntityDetailComponent t) { //3
1826          if (t == null)
1827            return this;
1828          if (this.detail == null)
1829            this.detail = new ArrayList<AuditEventEntityDetailComponent>();
1830          this.detail.add(t);
1831          return this;
1832        }
1833
1834        /**
1835         * @return The first repetition of repeating field {@link #detail}, creating it if it does not already exist {3}
1836         */
1837        public AuditEventEntityDetailComponent getDetailFirstRep() { 
1838          if (getDetail().isEmpty()) {
1839            addDetail();
1840          }
1841          return getDetail().get(0);
1842        }
1843
1844        /**
1845         * @return {@link #agent} (The entity is attributed to an agent to express the agent's responsibility for that entity in the activity. This is most used to indicate when persistence media (the entity) are used by an agent. For example when importing data from a device, the device would be described in an entity, and the user importing data from that media would be indicated as the entity.agent.)
1846         */
1847        public List<AuditEventAgentComponent> getAgent() { 
1848          if (this.agent == null)
1849            this.agent = new ArrayList<AuditEventAgentComponent>();
1850          return this.agent;
1851        }
1852
1853        /**
1854         * @return Returns a reference to <code>this</code> for easy method chaining
1855         */
1856        public AuditEventEntityComponent setAgent(List<AuditEventAgentComponent> theAgent) { 
1857          this.agent = theAgent;
1858          return this;
1859        }
1860
1861        public boolean hasAgent() { 
1862          if (this.agent == null)
1863            return false;
1864          for (AuditEventAgentComponent item : this.agent)
1865            if (!item.isEmpty())
1866              return true;
1867          return false;
1868        }
1869
1870        public AuditEventAgentComponent addAgent() { //3
1871          AuditEventAgentComponent t = new AuditEventAgentComponent();
1872          if (this.agent == null)
1873            this.agent = new ArrayList<AuditEventAgentComponent>();
1874          this.agent.add(t);
1875          return t;
1876        }
1877
1878        public AuditEventEntityComponent addAgent(AuditEventAgentComponent t) { //3
1879          if (t == null)
1880            return this;
1881          if (this.agent == null)
1882            this.agent = new ArrayList<AuditEventAgentComponent>();
1883          this.agent.add(t);
1884          return this;
1885        }
1886
1887        /**
1888         * @return The first repetition of repeating field {@link #agent}, creating it if it does not already exist {3}
1889         */
1890        public AuditEventAgentComponent getAgentFirstRep() { 
1891          if (getAgent().isEmpty()) {
1892            addAgent();
1893          }
1894          return getAgent().get(0);
1895        }
1896
1897        protected void listChildren(List<Property> children) {
1898          super.listChildren(children);
1899          children.add(new Property("what", "Reference(Any)", "Identifies a specific instance of the entity. The reference should be version specific.", 0, 1, what));
1900          children.add(new Property("role", "CodeableConcept", "Code representing the role the entity played in the event being audited.", 0, 1, role));
1901          children.add(new Property("securityLabel", "CodeableConcept", "Security labels for the identified entity.", 0, java.lang.Integer.MAX_VALUE, securityLabel));
1902          children.add(new Property("query", "base64Binary", "The query parameters for a query-type entities.", 0, 1, query));
1903          children.add(new Property("detail", "", "Tagged value pairs for conveying additional information about the entity.", 0, java.lang.Integer.MAX_VALUE, detail));
1904          children.add(new Property("agent", "@AuditEvent.agent", "The entity is attributed to an agent to express the agent's responsibility for that entity in the activity. This is most used to indicate when persistence media (the entity) are used by an agent. For example when importing data from a device, the device would be described in an entity, and the user importing data from that media would be indicated as the entity.agent.", 0, java.lang.Integer.MAX_VALUE, agent));
1905        }
1906
1907        @Override
1908        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1909          switch (_hash) {
1910          case 3648196: /*what*/  return new Property("what", "Reference(Any)", "Identifies a specific instance of the entity. The reference should be version specific.", 0, 1, what);
1911          case 3506294: /*role*/  return new Property("role", "CodeableConcept", "Code representing the role the entity played in the event being audited.", 0, 1, role);
1912          case -722296940: /*securityLabel*/  return new Property("securityLabel", "CodeableConcept", "Security labels for the identified entity.", 0, java.lang.Integer.MAX_VALUE, securityLabel);
1913          case 107944136: /*query*/  return new Property("query", "base64Binary", "The query parameters for a query-type entities.", 0, 1, query);
1914          case -1335224239: /*detail*/  return new Property("detail", "", "Tagged value pairs for conveying additional information about the entity.", 0, java.lang.Integer.MAX_VALUE, detail);
1915          case 92750597: /*agent*/  return new Property("agent", "@AuditEvent.agent", "The entity is attributed to an agent to express the agent's responsibility for that entity in the activity. This is most used to indicate when persistence media (the entity) are used by an agent. For example when importing data from a device, the device would be described in an entity, and the user importing data from that media would be indicated as the entity.agent.", 0, java.lang.Integer.MAX_VALUE, agent);
1916          default: return super.getNamedProperty(_hash, _name, _checkValid);
1917          }
1918
1919        }
1920
1921      @Override
1922      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1923        switch (hash) {
1924        case 3648196: /*what*/ return this.what == null ? new Base[0] : new Base[] {this.what}; // Reference
1925        case 3506294: /*role*/ return this.role == null ? new Base[0] : new Base[] {this.role}; // CodeableConcept
1926        case -722296940: /*securityLabel*/ return this.securityLabel == null ? new Base[0] : this.securityLabel.toArray(new Base[this.securityLabel.size()]); // CodeableConcept
1927        case 107944136: /*query*/ return this.query == null ? new Base[0] : new Base[] {this.query}; // Base64BinaryType
1928        case -1335224239: /*detail*/ return this.detail == null ? new Base[0] : this.detail.toArray(new Base[this.detail.size()]); // AuditEventEntityDetailComponent
1929        case 92750597: /*agent*/ return this.agent == null ? new Base[0] : this.agent.toArray(new Base[this.agent.size()]); // AuditEventAgentComponent
1930        default: return super.getProperty(hash, name, checkValid);
1931        }
1932
1933      }
1934
1935      @Override
1936      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1937        switch (hash) {
1938        case 3648196: // what
1939          this.what = TypeConvertor.castToReference(value); // Reference
1940          return value;
1941        case 3506294: // role
1942          this.role = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1943          return value;
1944        case -722296940: // securityLabel
1945          this.getSecurityLabel().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
1946          return value;
1947        case 107944136: // query
1948          this.query = TypeConvertor.castToBase64Binary(value); // Base64BinaryType
1949          return value;
1950        case -1335224239: // detail
1951          this.getDetail().add((AuditEventEntityDetailComponent) value); // AuditEventEntityDetailComponent
1952          return value;
1953        case 92750597: // agent
1954          this.getAgent().add((AuditEventAgentComponent) value); // AuditEventAgentComponent
1955          return value;
1956        default: return super.setProperty(hash, name, value);
1957        }
1958
1959      }
1960
1961      @Override
1962      public Base setProperty(String name, Base value) throws FHIRException {
1963        if (name.equals("what")) {
1964          this.what = TypeConvertor.castToReference(value); // Reference
1965        } else if (name.equals("role")) {
1966          this.role = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1967        } else if (name.equals("securityLabel")) {
1968          this.getSecurityLabel().add(TypeConvertor.castToCodeableConcept(value));
1969        } else if (name.equals("query")) {
1970          this.query = TypeConvertor.castToBase64Binary(value); // Base64BinaryType
1971        } else if (name.equals("detail")) {
1972          this.getDetail().add((AuditEventEntityDetailComponent) value);
1973        } else if (name.equals("agent")) {
1974          this.getAgent().add((AuditEventAgentComponent) value);
1975        } else
1976          return super.setProperty(name, value);
1977        return value;
1978      }
1979
1980      @Override
1981      public Base makeProperty(int hash, String name) throws FHIRException {
1982        switch (hash) {
1983        case 3648196:  return getWhat();
1984        case 3506294:  return getRole();
1985        case -722296940:  return addSecurityLabel(); 
1986        case 107944136:  return getQueryElement();
1987        case -1335224239:  return addDetail(); 
1988        case 92750597:  return addAgent(); 
1989        default: return super.makeProperty(hash, name);
1990        }
1991
1992      }
1993
1994      @Override
1995      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1996        switch (hash) {
1997        case 3648196: /*what*/ return new String[] {"Reference"};
1998        case 3506294: /*role*/ return new String[] {"CodeableConcept"};
1999        case -722296940: /*securityLabel*/ return new String[] {"CodeableConcept"};
2000        case 107944136: /*query*/ return new String[] {"base64Binary"};
2001        case -1335224239: /*detail*/ return new String[] {};
2002        case 92750597: /*agent*/ return new String[] {"@AuditEvent.agent"};
2003        default: return super.getTypesForProperty(hash, name);
2004        }
2005
2006      }
2007
2008      @Override
2009      public Base addChild(String name) throws FHIRException {
2010        if (name.equals("what")) {
2011          this.what = new Reference();
2012          return this.what;
2013        }
2014        else if (name.equals("role")) {
2015          this.role = new CodeableConcept();
2016          return this.role;
2017        }
2018        else if (name.equals("securityLabel")) {
2019          return addSecurityLabel();
2020        }
2021        else if (name.equals("query")) {
2022          throw new FHIRException("Cannot call addChild on a primitive type AuditEvent.entity.query");
2023        }
2024        else if (name.equals("detail")) {
2025          return addDetail();
2026        }
2027        else if (name.equals("agent")) {
2028          return addAgent();
2029        }
2030        else
2031          return super.addChild(name);
2032      }
2033
2034      public AuditEventEntityComponent copy() {
2035        AuditEventEntityComponent dst = new AuditEventEntityComponent();
2036        copyValues(dst);
2037        return dst;
2038      }
2039
2040      public void copyValues(AuditEventEntityComponent dst) {
2041        super.copyValues(dst);
2042        dst.what = what == null ? null : what.copy();
2043        dst.role = role == null ? null : role.copy();
2044        if (securityLabel != null) {
2045          dst.securityLabel = new ArrayList<CodeableConcept>();
2046          for (CodeableConcept i : securityLabel)
2047            dst.securityLabel.add(i.copy());
2048        };
2049        dst.query = query == null ? null : query.copy();
2050        if (detail != null) {
2051          dst.detail = new ArrayList<AuditEventEntityDetailComponent>();
2052          for (AuditEventEntityDetailComponent i : detail)
2053            dst.detail.add(i.copy());
2054        };
2055        if (agent != null) {
2056          dst.agent = new ArrayList<AuditEventAgentComponent>();
2057          for (AuditEventAgentComponent i : agent)
2058            dst.agent.add(i.copy());
2059        };
2060      }
2061
2062      @Override
2063      public boolean equalsDeep(Base other_) {
2064        if (!super.equalsDeep(other_))
2065          return false;
2066        if (!(other_ instanceof AuditEventEntityComponent))
2067          return false;
2068        AuditEventEntityComponent o = (AuditEventEntityComponent) other_;
2069        return compareDeep(what, o.what, true) && compareDeep(role, o.role, true) && compareDeep(securityLabel, o.securityLabel, true)
2070           && compareDeep(query, o.query, true) && compareDeep(detail, o.detail, true) && compareDeep(agent, o.agent, true)
2071          ;
2072      }
2073
2074      @Override
2075      public boolean equalsShallow(Base other_) {
2076        if (!super.equalsShallow(other_))
2077          return false;
2078        if (!(other_ instanceof AuditEventEntityComponent))
2079          return false;
2080        AuditEventEntityComponent o = (AuditEventEntityComponent) other_;
2081        return compareValues(query, o.query, true);
2082      }
2083
2084      public boolean isEmpty() {
2085        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(what, role, securityLabel
2086          , query, detail, agent);
2087      }
2088
2089  public String fhirType() {
2090    return "AuditEvent.entity";
2091
2092  }
2093
2094  }
2095
2096    @Block()
2097    public static class AuditEventEntityDetailComponent extends BackboneElement implements IBaseBackboneElement {
2098        /**
2099         * The type of extra detail provided in the value.
2100         */
2101        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=false)
2102        @Description(shortDefinition="Name of the property", formalDefinition="The type of extra detail provided in the value." )
2103        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/audit-event-type")
2104        protected CodeableConcept type;
2105
2106        /**
2107         * The  value of the extra detail.
2108         */
2109        @Child(name = "value", type = {Quantity.class, CodeableConcept.class, StringType.class, BooleanType.class, IntegerType.class, Range.class, Ratio.class, TimeType.class, DateTimeType.class, Period.class, Base64BinaryType.class}, order=2, min=1, max=1, modifier=false, summary=false)
2110        @Description(shortDefinition="Property value", formalDefinition="The  value of the extra detail." )
2111        protected DataType value;
2112
2113        private static final long serialVersionUID = -1659186716L;
2114
2115    /**
2116     * Constructor
2117     */
2118      public AuditEventEntityDetailComponent() {
2119        super();
2120      }
2121
2122    /**
2123     * Constructor
2124     */
2125      public AuditEventEntityDetailComponent(CodeableConcept type, DataType value) {
2126        super();
2127        this.setType(type);
2128        this.setValue(value);
2129      }
2130
2131        /**
2132         * @return {@link #type} (The type of extra detail provided in the value.)
2133         */
2134        public CodeableConcept getType() { 
2135          if (this.type == null)
2136            if (Configuration.errorOnAutoCreate())
2137              throw new Error("Attempt to auto-create AuditEventEntityDetailComponent.type");
2138            else if (Configuration.doAutoCreate())
2139              this.type = new CodeableConcept(); // cc
2140          return this.type;
2141        }
2142
2143        public boolean hasType() { 
2144          return this.type != null && !this.type.isEmpty();
2145        }
2146
2147        /**
2148         * @param value {@link #type} (The type of extra detail provided in the value.)
2149         */
2150        public AuditEventEntityDetailComponent setType(CodeableConcept value) { 
2151          this.type = value;
2152          return this;
2153        }
2154
2155        /**
2156         * @return {@link #value} (The  value of the extra detail.)
2157         */
2158        public DataType getValue() { 
2159          return this.value;
2160        }
2161
2162        /**
2163         * @return {@link #value} (The  value of the extra detail.)
2164         */
2165        public Quantity getValueQuantity() throws FHIRException { 
2166          if (this.value == null)
2167            this.value = new Quantity();
2168          if (!(this.value instanceof Quantity))
2169            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.value.getClass().getName()+" was encountered");
2170          return (Quantity) this.value;
2171        }
2172
2173        public boolean hasValueQuantity() { 
2174          return this != null && this.value instanceof Quantity;
2175        }
2176
2177        /**
2178         * @return {@link #value} (The  value of the extra detail.)
2179         */
2180        public CodeableConcept getValueCodeableConcept() throws FHIRException { 
2181          if (this.value == null)
2182            this.value = new CodeableConcept();
2183          if (!(this.value instanceof CodeableConcept))
2184            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.value.getClass().getName()+" was encountered");
2185          return (CodeableConcept) this.value;
2186        }
2187
2188        public boolean hasValueCodeableConcept() { 
2189          return this != null && this.value instanceof CodeableConcept;
2190        }
2191
2192        /**
2193         * @return {@link #value} (The  value of the extra detail.)
2194         */
2195        public StringType getValueStringType() throws FHIRException { 
2196          if (this.value == null)
2197            this.value = new StringType();
2198          if (!(this.value instanceof StringType))
2199            throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.value.getClass().getName()+" was encountered");
2200          return (StringType) this.value;
2201        }
2202
2203        public boolean hasValueStringType() { 
2204          return this != null && this.value instanceof StringType;
2205        }
2206
2207        /**
2208         * @return {@link #value} (The  value of the extra detail.)
2209         */
2210        public BooleanType getValueBooleanType() throws FHIRException { 
2211          if (this.value == null)
2212            this.value = new BooleanType();
2213          if (!(this.value instanceof BooleanType))
2214            throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.value.getClass().getName()+" was encountered");
2215          return (BooleanType) this.value;
2216        }
2217
2218        public boolean hasValueBooleanType() { 
2219          return this != null && this.value instanceof BooleanType;
2220        }
2221
2222        /**
2223         * @return {@link #value} (The  value of the extra detail.)
2224         */
2225        public IntegerType getValueIntegerType() throws FHIRException { 
2226          if (this.value == null)
2227            this.value = new IntegerType();
2228          if (!(this.value instanceof IntegerType))
2229            throw new FHIRException("Type mismatch: the type IntegerType was expected, but "+this.value.getClass().getName()+" was encountered");
2230          return (IntegerType) this.value;
2231        }
2232
2233        public boolean hasValueIntegerType() { 
2234          return this != null && this.value instanceof IntegerType;
2235        }
2236
2237        /**
2238         * @return {@link #value} (The  value of the extra detail.)
2239         */
2240        public Range getValueRange() throws FHIRException { 
2241          if (this.value == null)
2242            this.value = new Range();
2243          if (!(this.value instanceof Range))
2244            throw new FHIRException("Type mismatch: the type Range was expected, but "+this.value.getClass().getName()+" was encountered");
2245          return (Range) this.value;
2246        }
2247
2248        public boolean hasValueRange() { 
2249          return this != null && this.value instanceof Range;
2250        }
2251
2252        /**
2253         * @return {@link #value} (The  value of the extra detail.)
2254         */
2255        public Ratio getValueRatio() throws FHIRException { 
2256          if (this.value == null)
2257            this.value = new Ratio();
2258          if (!(this.value instanceof Ratio))
2259            throw new FHIRException("Type mismatch: the type Ratio was expected, but "+this.value.getClass().getName()+" was encountered");
2260          return (Ratio) this.value;
2261        }
2262
2263        public boolean hasValueRatio() { 
2264          return this != null && this.value instanceof Ratio;
2265        }
2266
2267        /**
2268         * @return {@link #value} (The  value of the extra detail.)
2269         */
2270        public TimeType getValueTimeType() throws FHIRException { 
2271          if (this.value == null)
2272            this.value = new TimeType();
2273          if (!(this.value instanceof TimeType))
2274            throw new FHIRException("Type mismatch: the type TimeType was expected, but "+this.value.getClass().getName()+" was encountered");
2275          return (TimeType) this.value;
2276        }
2277
2278        public boolean hasValueTimeType() { 
2279          return this != null && this.value instanceof TimeType;
2280        }
2281
2282        /**
2283         * @return {@link #value} (The  value of the extra detail.)
2284         */
2285        public DateTimeType getValueDateTimeType() throws FHIRException { 
2286          if (this.value == null)
2287            this.value = new DateTimeType();
2288          if (!(this.value instanceof DateTimeType))
2289            throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.value.getClass().getName()+" was encountered");
2290          return (DateTimeType) this.value;
2291        }
2292
2293        public boolean hasValueDateTimeType() { 
2294          return this != null && this.value instanceof DateTimeType;
2295        }
2296
2297        /**
2298         * @return {@link #value} (The  value of the extra detail.)
2299         */
2300        public Period getValuePeriod() throws FHIRException { 
2301          if (this.value == null)
2302            this.value = new Period();
2303          if (!(this.value instanceof Period))
2304            throw new FHIRException("Type mismatch: the type Period was expected, but "+this.value.getClass().getName()+" was encountered");
2305          return (Period) this.value;
2306        }
2307
2308        public boolean hasValuePeriod() { 
2309          return this != null && this.value instanceof Period;
2310        }
2311
2312        /**
2313         * @return {@link #value} (The  value of the extra detail.)
2314         */
2315        public Base64BinaryType getValueBase64BinaryType() throws FHIRException { 
2316          if (this.value == null)
2317            this.value = new Base64BinaryType();
2318          if (!(this.value instanceof Base64BinaryType))
2319            throw new FHIRException("Type mismatch: the type Base64BinaryType was expected, but "+this.value.getClass().getName()+" was encountered");
2320          return (Base64BinaryType) this.value;
2321        }
2322
2323        public boolean hasValueBase64BinaryType() { 
2324          return this != null && this.value instanceof Base64BinaryType;
2325        }
2326
2327        public boolean hasValue() { 
2328          return this.value != null && !this.value.isEmpty();
2329        }
2330
2331        /**
2332         * @param value {@link #value} (The  value of the extra detail.)
2333         */
2334        public AuditEventEntityDetailComponent setValue(DataType value) { 
2335          if (value != null && !(value instanceof Quantity || value instanceof CodeableConcept || value instanceof StringType || value instanceof BooleanType || value instanceof IntegerType || value instanceof Range || value instanceof Ratio || value instanceof TimeType || value instanceof DateTimeType || value instanceof Period || value instanceof Base64BinaryType))
2336            throw new Error("Not the right type for AuditEvent.entity.detail.value[x]: "+value.fhirType());
2337          this.value = value;
2338          return this;
2339        }
2340
2341        protected void listChildren(List<Property> children) {
2342          super.listChildren(children);
2343          children.add(new Property("type", "CodeableConcept", "The type of extra detail provided in the value.", 0, 1, type));
2344          children.add(new Property("value[x]", "Quantity|CodeableConcept|string|boolean|integer|Range|Ratio|time|dateTime|Period|base64Binary", "The  value of the extra detail.", 0, 1, value));
2345        }
2346
2347        @Override
2348        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2349          switch (_hash) {
2350          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "The type of extra detail provided in the value.", 0, 1, type);
2351          case -1410166417: /*value[x]*/  return new Property("value[x]", "Quantity|CodeableConcept|string|boolean|integer|Range|Ratio|time|dateTime|Period|base64Binary", "The  value of the extra detail.", 0, 1, value);
2352          case 111972721: /*value*/  return new Property("value[x]", "Quantity|CodeableConcept|string|boolean|integer|Range|Ratio|time|dateTime|Period|base64Binary", "The  value of the extra detail.", 0, 1, value);
2353          case -2029823716: /*valueQuantity*/  return new Property("value[x]", "Quantity", "The  value of the extra detail.", 0, 1, value);
2354          case 924902896: /*valueCodeableConcept*/  return new Property("value[x]", "CodeableConcept", "The  value of the extra detail.", 0, 1, value);
2355          case -1424603934: /*valueString*/  return new Property("value[x]", "string", "The  value of the extra detail.", 0, 1, value);
2356          case 733421943: /*valueBoolean*/  return new Property("value[x]", "boolean", "The  value of the extra detail.", 0, 1, value);
2357          case -1668204915: /*valueInteger*/  return new Property("value[x]", "integer", "The  value of the extra detail.", 0, 1, value);
2358          case 2030761548: /*valueRange*/  return new Property("value[x]", "Range", "The  value of the extra detail.", 0, 1, value);
2359          case 2030767386: /*valueRatio*/  return new Property("value[x]", "Ratio", "The  value of the extra detail.", 0, 1, value);
2360          case -765708322: /*valueTime*/  return new Property("value[x]", "time", "The  value of the extra detail.", 0, 1, value);
2361          case 1047929900: /*valueDateTime*/  return new Property("value[x]", "dateTime", "The  value of the extra detail.", 0, 1, value);
2362          case -1524344174: /*valuePeriod*/  return new Property("value[x]", "Period", "The  value of the extra detail.", 0, 1, value);
2363          case -1535024575: /*valueBase64Binary*/  return new Property("value[x]", "base64Binary", "The  value of the extra detail.", 0, 1, value);
2364          default: return super.getNamedProperty(_hash, _name, _checkValid);
2365          }
2366
2367        }
2368
2369      @Override
2370      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2371        switch (hash) {
2372        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
2373        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // DataType
2374        default: return super.getProperty(hash, name, checkValid);
2375        }
2376
2377      }
2378
2379      @Override
2380      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2381        switch (hash) {
2382        case 3575610: // type
2383          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2384          return value;
2385        case 111972721: // value
2386          this.value = TypeConvertor.castToType(value); // DataType
2387          return value;
2388        default: return super.setProperty(hash, name, value);
2389        }
2390
2391      }
2392
2393      @Override
2394      public Base setProperty(String name, Base value) throws FHIRException {
2395        if (name.equals("type")) {
2396          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2397        } else if (name.equals("value[x]")) {
2398          this.value = TypeConvertor.castToType(value); // DataType
2399        } else
2400          return super.setProperty(name, value);
2401        return value;
2402      }
2403
2404      @Override
2405      public Base makeProperty(int hash, String name) throws FHIRException {
2406        switch (hash) {
2407        case 3575610:  return getType();
2408        case -1410166417:  return getValue();
2409        case 111972721:  return getValue();
2410        default: return super.makeProperty(hash, name);
2411        }
2412
2413      }
2414
2415      @Override
2416      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2417        switch (hash) {
2418        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
2419        case 111972721: /*value*/ return new String[] {"Quantity", "CodeableConcept", "string", "boolean", "integer", "Range", "Ratio", "time", "dateTime", "Period", "base64Binary"};
2420        default: return super.getTypesForProperty(hash, name);
2421        }
2422
2423      }
2424
2425      @Override
2426      public Base addChild(String name) throws FHIRException {
2427        if (name.equals("type")) {
2428          this.type = new CodeableConcept();
2429          return this.type;
2430        }
2431        else if (name.equals("valueQuantity")) {
2432          this.value = new Quantity();
2433          return this.value;
2434        }
2435        else if (name.equals("valueCodeableConcept")) {
2436          this.value = new CodeableConcept();
2437          return this.value;
2438        }
2439        else if (name.equals("valueString")) {
2440          this.value = new StringType();
2441          return this.value;
2442        }
2443        else if (name.equals("valueBoolean")) {
2444          this.value = new BooleanType();
2445          return this.value;
2446        }
2447        else if (name.equals("valueInteger")) {
2448          this.value = new IntegerType();
2449          return this.value;
2450        }
2451        else if (name.equals("valueRange")) {
2452          this.value = new Range();
2453          return this.value;
2454        }
2455        else if (name.equals("valueRatio")) {
2456          this.value = new Ratio();
2457          return this.value;
2458        }
2459        else if (name.equals("valueTime")) {
2460          this.value = new TimeType();
2461          return this.value;
2462        }
2463        else if (name.equals("valueDateTime")) {
2464          this.value = new DateTimeType();
2465          return this.value;
2466        }
2467        else if (name.equals("valuePeriod")) {
2468          this.value = new Period();
2469          return this.value;
2470        }
2471        else if (name.equals("valueBase64Binary")) {
2472          this.value = new Base64BinaryType();
2473          return this.value;
2474        }
2475        else
2476          return super.addChild(name);
2477      }
2478
2479      public AuditEventEntityDetailComponent copy() {
2480        AuditEventEntityDetailComponent dst = new AuditEventEntityDetailComponent();
2481        copyValues(dst);
2482        return dst;
2483      }
2484
2485      public void copyValues(AuditEventEntityDetailComponent dst) {
2486        super.copyValues(dst);
2487        dst.type = type == null ? null : type.copy();
2488        dst.value = value == null ? null : value.copy();
2489      }
2490
2491      @Override
2492      public boolean equalsDeep(Base other_) {
2493        if (!super.equalsDeep(other_))
2494          return false;
2495        if (!(other_ instanceof AuditEventEntityDetailComponent))
2496          return false;
2497        AuditEventEntityDetailComponent o = (AuditEventEntityDetailComponent) other_;
2498        return compareDeep(type, o.type, true) && compareDeep(value, o.value, true);
2499      }
2500
2501      @Override
2502      public boolean equalsShallow(Base other_) {
2503        if (!super.equalsShallow(other_))
2504          return false;
2505        if (!(other_ instanceof AuditEventEntityDetailComponent))
2506          return false;
2507        AuditEventEntityDetailComponent o = (AuditEventEntityDetailComponent) other_;
2508        return true;
2509      }
2510
2511      public boolean isEmpty() {
2512        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, value);
2513      }
2514
2515  public String fhirType() {
2516    return "AuditEvent.entity.detail";
2517
2518  }
2519
2520  }
2521
2522    /**
2523     * Classification of the type of event.
2524     */
2525    @Child(name = "category", type = {CodeableConcept.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2526    @Description(shortDefinition="Type/identifier of event", formalDefinition="Classification of the type of event." )
2527    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/audit-event-type")
2528    protected List<CodeableConcept> category;
2529
2530    /**
2531     * Describes what happened. The most specific code for the event.
2532     */
2533    @Child(name = "code", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=true)
2534    @Description(shortDefinition="Specific type of event", formalDefinition="Describes what happened. The most specific code for the event." )
2535    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/audit-event-sub-type")
2536    protected CodeableConcept code;
2537
2538    /**
2539     * Indicator for type of action performed during the event that generated the audit.
2540     */
2541    @Child(name = "action", type = {CodeType.class}, order=2, min=0, max=1, modifier=false, summary=true)
2542    @Description(shortDefinition="Type of action performed during the event", formalDefinition="Indicator for type of action performed during the event that generated the audit." )
2543    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/audit-event-action")
2544    protected Enumeration<AuditEventAction> action;
2545
2546    /**
2547     * Indicates and enables segmentation of various severity including debugging from critical.
2548     */
2549    @Child(name = "severity", type = {CodeType.class}, order=3, min=0, max=1, modifier=false, summary=true)
2550    @Description(shortDefinition="emergency | alert | critical | error | warning | notice | informational | debug", formalDefinition="Indicates and enables segmentation of various severity including debugging from critical." )
2551    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/audit-event-severity")
2552    protected Enumeration<AuditEventSeverity> severity;
2553
2554    /**
2555     * The time or period during which the activity occurred.
2556     */
2557    @Child(name = "occurred", type = {Period.class, DateTimeType.class}, order=4, min=0, max=1, modifier=false, summary=false)
2558    @Description(shortDefinition="When the activity occurred", formalDefinition="The time or period during which the activity occurred." )
2559    protected DataType occurred;
2560
2561    /**
2562     * The time when the event was recorded.
2563     */
2564    @Child(name = "recorded", type = {InstantType.class}, order=5, min=1, max=1, modifier=false, summary=true)
2565    @Description(shortDefinition="Time when the event was recorded", formalDefinition="The time when the event was recorded." )
2566    protected InstantType recorded;
2567
2568    /**
2569     * Indicates whether the event succeeded or failed. A free text descripiton can be given in outcome.text.
2570     */
2571    @Child(name = "outcome", type = {}, order=6, min=0, max=1, modifier=false, summary=true)
2572    @Description(shortDefinition="Whether the event succeeded or failed", formalDefinition="Indicates whether the event succeeded or failed. A free text descripiton can be given in outcome.text." )
2573    protected AuditEventOutcomeComponent outcome;
2574
2575    /**
2576     * The authorization (e.g., PurposeOfUse) that was used during the event being recorded.
2577     */
2578    @Child(name = "authorization", type = {CodeableConcept.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2579    @Description(shortDefinition="Authorization related to the event", formalDefinition="The authorization (e.g., PurposeOfUse) that was used during the event being recorded." )
2580    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v3-PurposeOfUse")
2581    protected List<CodeableConcept> authorization;
2582
2583    /**
2584     * Allows tracing of authorizatino for the events and tracking whether proposals/recommendations were acted upon.
2585     */
2586    @Child(name = "basedOn", type = {CarePlan.class, DeviceRequest.class, ImmunizationRecommendation.class, MedicationRequest.class, NutritionOrder.class, ServiceRequest.class, Task.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2587    @Description(shortDefinition="Workflow authorization within which this event occurred", formalDefinition="Allows tracing of authorizatino for the events and tracking whether proposals/recommendations were acted upon." )
2588    protected List<Reference> basedOn;
2589
2590    /**
2591     * This will typically be the encounter the event occurred, but some events may be initiated prior to or after the official completion of an encounter but still be tied to the context of the encounter (e.g. pre-admission lab tests).
2592     */
2593    @Child(name = "encounter", type = {Encounter.class}, order=9, min=0, max=1, modifier=false, summary=false)
2594    @Description(shortDefinition="Encounter within which this event occurred or which the event is tightly associated", formalDefinition="This will typically be the encounter the event occurred, but some events may be initiated prior to or after the official completion of an encounter but still be tied to the context of the encounter (e.g. pre-admission lab tests)." )
2595    protected Reference encounter;
2596
2597    /**
2598     * An actor taking an active role in the event or activity that is logged.
2599     */
2600    @Child(name = "agent", type = {}, order=10, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2601    @Description(shortDefinition="Actor involved in the event", formalDefinition="An actor taking an active role in the event or activity that is logged." )
2602    protected List<AuditEventAgentComponent> agent;
2603
2604    /**
2605     * The actor that is reporting the event.
2606     */
2607    @Child(name = "source", type = {}, order=11, min=1, max=1, modifier=false, summary=false)
2608    @Description(shortDefinition="Audit Event Reporter", formalDefinition="The actor that is reporting the event." )
2609    protected AuditEventSourceComponent source;
2610
2611    /**
2612     * Specific instances of data or objects that have been accessed.
2613     */
2614    @Child(name = "entity", type = {}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2615    @Description(shortDefinition="Data or objects used", formalDefinition="Specific instances of data or objects that have been accessed." )
2616    protected List<AuditEventEntityComponent> entity;
2617
2618    private static final long serialVersionUID = 1019127386L;
2619
2620  /**
2621   * Constructor
2622   */
2623    public AuditEvent() {
2624      super();
2625    }
2626
2627  /**
2628   * Constructor
2629   */
2630    public AuditEvent(CodeableConcept code, Date recorded, AuditEventAgentComponent agent, AuditEventSourceComponent source) {
2631      super();
2632      this.setCode(code);
2633      this.setRecorded(recorded);
2634      this.addAgent(agent);
2635      this.setSource(source);
2636    }
2637
2638    /**
2639     * @return {@link #category} (Classification of the type of event.)
2640     */
2641    public List<CodeableConcept> getCategory() { 
2642      if (this.category == null)
2643        this.category = new ArrayList<CodeableConcept>();
2644      return this.category;
2645    }
2646
2647    /**
2648     * @return Returns a reference to <code>this</code> for easy method chaining
2649     */
2650    public AuditEvent setCategory(List<CodeableConcept> theCategory) { 
2651      this.category = theCategory;
2652      return this;
2653    }
2654
2655    public boolean hasCategory() { 
2656      if (this.category == null)
2657        return false;
2658      for (CodeableConcept item : this.category)
2659        if (!item.isEmpty())
2660          return true;
2661      return false;
2662    }
2663
2664    public CodeableConcept addCategory() { //3
2665      CodeableConcept t = new CodeableConcept();
2666      if (this.category == null)
2667        this.category = new ArrayList<CodeableConcept>();
2668      this.category.add(t);
2669      return t;
2670    }
2671
2672    public AuditEvent addCategory(CodeableConcept t) { //3
2673      if (t == null)
2674        return this;
2675      if (this.category == null)
2676        this.category = new ArrayList<CodeableConcept>();
2677      this.category.add(t);
2678      return this;
2679    }
2680
2681    /**
2682     * @return The first repetition of repeating field {@link #category}, creating it if it does not already exist {3}
2683     */
2684    public CodeableConcept getCategoryFirstRep() { 
2685      if (getCategory().isEmpty()) {
2686        addCategory();
2687      }
2688      return getCategory().get(0);
2689    }
2690
2691    /**
2692     * @return {@link #code} (Describes what happened. The most specific code for the event.)
2693     */
2694    public CodeableConcept getCode() { 
2695      if (this.code == null)
2696        if (Configuration.errorOnAutoCreate())
2697          throw new Error("Attempt to auto-create AuditEvent.code");
2698        else if (Configuration.doAutoCreate())
2699          this.code = new CodeableConcept(); // cc
2700      return this.code;
2701    }
2702
2703    public boolean hasCode() { 
2704      return this.code != null && !this.code.isEmpty();
2705    }
2706
2707    /**
2708     * @param value {@link #code} (Describes what happened. The most specific code for the event.)
2709     */
2710    public AuditEvent setCode(CodeableConcept value) { 
2711      this.code = value;
2712      return this;
2713    }
2714
2715    /**
2716     * @return {@link #action} (Indicator for type of action performed during the event that generated the audit.). This is the underlying object with id, value and extensions. The accessor "getAction" gives direct access to the value
2717     */
2718    public Enumeration<AuditEventAction> getActionElement() { 
2719      if (this.action == null)
2720        if (Configuration.errorOnAutoCreate())
2721          throw new Error("Attempt to auto-create AuditEvent.action");
2722        else if (Configuration.doAutoCreate())
2723          this.action = new Enumeration<AuditEventAction>(new AuditEventActionEnumFactory()); // bb
2724      return this.action;
2725    }
2726
2727    public boolean hasActionElement() { 
2728      return this.action != null && !this.action.isEmpty();
2729    }
2730
2731    public boolean hasAction() { 
2732      return this.action != null && !this.action.isEmpty();
2733    }
2734
2735    /**
2736     * @param value {@link #action} (Indicator for type of action performed during the event that generated the audit.). This is the underlying object with id, value and extensions. The accessor "getAction" gives direct access to the value
2737     */
2738    public AuditEvent setActionElement(Enumeration<AuditEventAction> value) { 
2739      this.action = value;
2740      return this;
2741    }
2742
2743    /**
2744     * @return Indicator for type of action performed during the event that generated the audit.
2745     */
2746    public AuditEventAction getAction() { 
2747      return this.action == null ? null : this.action.getValue();
2748    }
2749
2750    /**
2751     * @param value Indicator for type of action performed during the event that generated the audit.
2752     */
2753    public AuditEvent setAction(AuditEventAction value) { 
2754      if (value == null)
2755        this.action = null;
2756      else {
2757        if (this.action == null)
2758          this.action = new Enumeration<AuditEventAction>(new AuditEventActionEnumFactory());
2759        this.action.setValue(value);
2760      }
2761      return this;
2762    }
2763
2764    /**
2765     * @return {@link #severity} (Indicates and enables segmentation of various severity including debugging from critical.). This is the underlying object with id, value and extensions. The accessor "getSeverity" gives direct access to the value
2766     */
2767    public Enumeration<AuditEventSeverity> getSeverityElement() { 
2768      if (this.severity == null)
2769        if (Configuration.errorOnAutoCreate())
2770          throw new Error("Attempt to auto-create AuditEvent.severity");
2771        else if (Configuration.doAutoCreate())
2772          this.severity = new Enumeration<AuditEventSeverity>(new AuditEventSeverityEnumFactory()); // bb
2773      return this.severity;
2774    }
2775
2776    public boolean hasSeverityElement() { 
2777      return this.severity != null && !this.severity.isEmpty();
2778    }
2779
2780    public boolean hasSeverity() { 
2781      return this.severity != null && !this.severity.isEmpty();
2782    }
2783
2784    /**
2785     * @param value {@link #severity} (Indicates and enables segmentation of various severity including debugging from critical.). This is the underlying object with id, value and extensions. The accessor "getSeverity" gives direct access to the value
2786     */
2787    public AuditEvent setSeverityElement(Enumeration<AuditEventSeverity> value) { 
2788      this.severity = value;
2789      return this;
2790    }
2791
2792    /**
2793     * @return Indicates and enables segmentation of various severity including debugging from critical.
2794     */
2795    public AuditEventSeverity getSeverity() { 
2796      return this.severity == null ? null : this.severity.getValue();
2797    }
2798
2799    /**
2800     * @param value Indicates and enables segmentation of various severity including debugging from critical.
2801     */
2802    public AuditEvent setSeverity(AuditEventSeverity value) { 
2803      if (value == null)
2804        this.severity = null;
2805      else {
2806        if (this.severity == null)
2807          this.severity = new Enumeration<AuditEventSeverity>(new AuditEventSeverityEnumFactory());
2808        this.severity.setValue(value);
2809      }
2810      return this;
2811    }
2812
2813    /**
2814     * @return {@link #occurred} (The time or period during which the activity occurred.)
2815     */
2816    public DataType getOccurred() { 
2817      return this.occurred;
2818    }
2819
2820    /**
2821     * @return {@link #occurred} (The time or period during which the activity occurred.)
2822     */
2823    public Period getOccurredPeriod() throws FHIRException { 
2824      if (this.occurred == null)
2825        this.occurred = new Period();
2826      if (!(this.occurred instanceof Period))
2827        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.occurred.getClass().getName()+" was encountered");
2828      return (Period) this.occurred;
2829    }
2830
2831    public boolean hasOccurredPeriod() { 
2832      return this != null && this.occurred instanceof Period;
2833    }
2834
2835    /**
2836     * @return {@link #occurred} (The time or period during which the activity occurred.)
2837     */
2838    public DateTimeType getOccurredDateTimeType() throws FHIRException { 
2839      if (this.occurred == null)
2840        this.occurred = new DateTimeType();
2841      if (!(this.occurred instanceof DateTimeType))
2842        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.occurred.getClass().getName()+" was encountered");
2843      return (DateTimeType) this.occurred;
2844    }
2845
2846    public boolean hasOccurredDateTimeType() { 
2847      return this != null && this.occurred instanceof DateTimeType;
2848    }
2849
2850    public boolean hasOccurred() { 
2851      return this.occurred != null && !this.occurred.isEmpty();
2852    }
2853
2854    /**
2855     * @param value {@link #occurred} (The time or period during which the activity occurred.)
2856     */
2857    public AuditEvent setOccurred(DataType value) { 
2858      if (value != null && !(value instanceof Period || value instanceof DateTimeType))
2859        throw new Error("Not the right type for AuditEvent.occurred[x]: "+value.fhirType());
2860      this.occurred = value;
2861      return this;
2862    }
2863
2864    /**
2865     * @return {@link #recorded} (The time when the event was recorded.). This is the underlying object with id, value and extensions. The accessor "getRecorded" gives direct access to the value
2866     */
2867    public InstantType getRecordedElement() { 
2868      if (this.recorded == null)
2869        if (Configuration.errorOnAutoCreate())
2870          throw new Error("Attempt to auto-create AuditEvent.recorded");
2871        else if (Configuration.doAutoCreate())
2872          this.recorded = new InstantType(); // bb
2873      return this.recorded;
2874    }
2875
2876    public boolean hasRecordedElement() { 
2877      return this.recorded != null && !this.recorded.isEmpty();
2878    }
2879
2880    public boolean hasRecorded() { 
2881      return this.recorded != null && !this.recorded.isEmpty();
2882    }
2883
2884    /**
2885     * @param value {@link #recorded} (The time when the event was recorded.). This is the underlying object with id, value and extensions. The accessor "getRecorded" gives direct access to the value
2886     */
2887    public AuditEvent setRecordedElement(InstantType value) { 
2888      this.recorded = value;
2889      return this;
2890    }
2891
2892    /**
2893     * @return The time when the event was recorded.
2894     */
2895    public Date getRecorded() { 
2896      return this.recorded == null ? null : this.recorded.getValue();
2897    }
2898
2899    /**
2900     * @param value The time when the event was recorded.
2901     */
2902    public AuditEvent setRecorded(Date value) { 
2903        if (this.recorded == null)
2904          this.recorded = new InstantType();
2905        this.recorded.setValue(value);
2906      return this;
2907    }
2908
2909    /**
2910     * @return {@link #outcome} (Indicates whether the event succeeded or failed. A free text descripiton can be given in outcome.text.)
2911     */
2912    public AuditEventOutcomeComponent getOutcome() { 
2913      if (this.outcome == null)
2914        if (Configuration.errorOnAutoCreate())
2915          throw new Error("Attempt to auto-create AuditEvent.outcome");
2916        else if (Configuration.doAutoCreate())
2917          this.outcome = new AuditEventOutcomeComponent(); // cc
2918      return this.outcome;
2919    }
2920
2921    public boolean hasOutcome() { 
2922      return this.outcome != null && !this.outcome.isEmpty();
2923    }
2924
2925    /**
2926     * @param value {@link #outcome} (Indicates whether the event succeeded or failed. A free text descripiton can be given in outcome.text.)
2927     */
2928    public AuditEvent setOutcome(AuditEventOutcomeComponent value) { 
2929      this.outcome = value;
2930      return this;
2931    }
2932
2933    /**
2934     * @return {@link #authorization} (The authorization (e.g., PurposeOfUse) that was used during the event being recorded.)
2935     */
2936    public List<CodeableConcept> getAuthorization() { 
2937      if (this.authorization == null)
2938        this.authorization = new ArrayList<CodeableConcept>();
2939      return this.authorization;
2940    }
2941
2942    /**
2943     * @return Returns a reference to <code>this</code> for easy method chaining
2944     */
2945    public AuditEvent setAuthorization(List<CodeableConcept> theAuthorization) { 
2946      this.authorization = theAuthorization;
2947      return this;
2948    }
2949
2950    public boolean hasAuthorization() { 
2951      if (this.authorization == null)
2952        return false;
2953      for (CodeableConcept item : this.authorization)
2954        if (!item.isEmpty())
2955          return true;
2956      return false;
2957    }
2958
2959    public CodeableConcept addAuthorization() { //3
2960      CodeableConcept t = new CodeableConcept();
2961      if (this.authorization == null)
2962        this.authorization = new ArrayList<CodeableConcept>();
2963      this.authorization.add(t);
2964      return t;
2965    }
2966
2967    public AuditEvent addAuthorization(CodeableConcept t) { //3
2968      if (t == null)
2969        return this;
2970      if (this.authorization == null)
2971        this.authorization = new ArrayList<CodeableConcept>();
2972      this.authorization.add(t);
2973      return this;
2974    }
2975
2976    /**
2977     * @return The first repetition of repeating field {@link #authorization}, creating it if it does not already exist {3}
2978     */
2979    public CodeableConcept getAuthorizationFirstRep() { 
2980      if (getAuthorization().isEmpty()) {
2981        addAuthorization();
2982      }
2983      return getAuthorization().get(0);
2984    }
2985
2986    /**
2987     * @return {@link #basedOn} (Allows tracing of authorizatino for the events and tracking whether proposals/recommendations were acted upon.)
2988     */
2989    public List<Reference> getBasedOn() { 
2990      if (this.basedOn == null)
2991        this.basedOn = new ArrayList<Reference>();
2992      return this.basedOn;
2993    }
2994
2995    /**
2996     * @return Returns a reference to <code>this</code> for easy method chaining
2997     */
2998    public AuditEvent setBasedOn(List<Reference> theBasedOn) { 
2999      this.basedOn = theBasedOn;
3000      return this;
3001    }
3002
3003    public boolean hasBasedOn() { 
3004      if (this.basedOn == null)
3005        return false;
3006      for (Reference item : this.basedOn)
3007        if (!item.isEmpty())
3008          return true;
3009      return false;
3010    }
3011
3012    public Reference addBasedOn() { //3
3013      Reference t = new Reference();
3014      if (this.basedOn == null)
3015        this.basedOn = new ArrayList<Reference>();
3016      this.basedOn.add(t);
3017      return t;
3018    }
3019
3020    public AuditEvent addBasedOn(Reference t) { //3
3021      if (t == null)
3022        return this;
3023      if (this.basedOn == null)
3024        this.basedOn = new ArrayList<Reference>();
3025      this.basedOn.add(t);
3026      return this;
3027    }
3028
3029    /**
3030     * @return The first repetition of repeating field {@link #basedOn}, creating it if it does not already exist {3}
3031     */
3032    public Reference getBasedOnFirstRep() { 
3033      if (getBasedOn().isEmpty()) {
3034        addBasedOn();
3035      }
3036      return getBasedOn().get(0);
3037    }
3038
3039    /**
3040     * @return {@link #encounter} (This will typically be the encounter the event occurred, but some events may be initiated prior to or after the official completion of an encounter but still be tied to the context of the encounter (e.g. pre-admission lab tests).)
3041     */
3042    public Reference getEncounter() { 
3043      if (this.encounter == null)
3044        if (Configuration.errorOnAutoCreate())
3045          throw new Error("Attempt to auto-create AuditEvent.encounter");
3046        else if (Configuration.doAutoCreate())
3047          this.encounter = new Reference(); // cc
3048      return this.encounter;
3049    }
3050
3051    public boolean hasEncounter() { 
3052      return this.encounter != null && !this.encounter.isEmpty();
3053    }
3054
3055    /**
3056     * @param value {@link #encounter} (This will typically be the encounter the event occurred, but some events may be initiated prior to or after the official completion of an encounter but still be tied to the context of the encounter (e.g. pre-admission lab tests).)
3057     */
3058    public AuditEvent setEncounter(Reference value) { 
3059      this.encounter = value;
3060      return this;
3061    }
3062
3063    /**
3064     * @return {@link #agent} (An actor taking an active role in the event or activity that is logged.)
3065     */
3066    public List<AuditEventAgentComponent> getAgent() { 
3067      if (this.agent == null)
3068        this.agent = new ArrayList<AuditEventAgentComponent>();
3069      return this.agent;
3070    }
3071
3072    /**
3073     * @return Returns a reference to <code>this</code> for easy method chaining
3074     */
3075    public AuditEvent setAgent(List<AuditEventAgentComponent> theAgent) { 
3076      this.agent = theAgent;
3077      return this;
3078    }
3079
3080    public boolean hasAgent() { 
3081      if (this.agent == null)
3082        return false;
3083      for (AuditEventAgentComponent item : this.agent)
3084        if (!item.isEmpty())
3085          return true;
3086      return false;
3087    }
3088
3089    public AuditEventAgentComponent addAgent() { //3
3090      AuditEventAgentComponent t = new AuditEventAgentComponent();
3091      if (this.agent == null)
3092        this.agent = new ArrayList<AuditEventAgentComponent>();
3093      this.agent.add(t);
3094      return t;
3095    }
3096
3097    public AuditEvent addAgent(AuditEventAgentComponent t) { //3
3098      if (t == null)
3099        return this;
3100      if (this.agent == null)
3101        this.agent = new ArrayList<AuditEventAgentComponent>();
3102      this.agent.add(t);
3103      return this;
3104    }
3105
3106    /**
3107     * @return The first repetition of repeating field {@link #agent}, creating it if it does not already exist {3}
3108     */
3109    public AuditEventAgentComponent getAgentFirstRep() { 
3110      if (getAgent().isEmpty()) {
3111        addAgent();
3112      }
3113      return getAgent().get(0);
3114    }
3115
3116    /**
3117     * @return {@link #source} (The actor that is reporting the event.)
3118     */
3119    public AuditEventSourceComponent getSource() { 
3120      if (this.source == null)
3121        if (Configuration.errorOnAutoCreate())
3122          throw new Error("Attempt to auto-create AuditEvent.source");
3123        else if (Configuration.doAutoCreate())
3124          this.source = new AuditEventSourceComponent(); // cc
3125      return this.source;
3126    }
3127
3128    public boolean hasSource() { 
3129      return this.source != null && !this.source.isEmpty();
3130    }
3131
3132    /**
3133     * @param value {@link #source} (The actor that is reporting the event.)
3134     */
3135    public AuditEvent setSource(AuditEventSourceComponent value) { 
3136      this.source = value;
3137      return this;
3138    }
3139
3140    /**
3141     * @return {@link #entity} (Specific instances of data or objects that have been accessed.)
3142     */
3143    public List<AuditEventEntityComponent> getEntity() { 
3144      if (this.entity == null)
3145        this.entity = new ArrayList<AuditEventEntityComponent>();
3146      return this.entity;
3147    }
3148
3149    /**
3150     * @return Returns a reference to <code>this</code> for easy method chaining
3151     */
3152    public AuditEvent setEntity(List<AuditEventEntityComponent> theEntity) { 
3153      this.entity = theEntity;
3154      return this;
3155    }
3156
3157    public boolean hasEntity() { 
3158      if (this.entity == null)
3159        return false;
3160      for (AuditEventEntityComponent item : this.entity)
3161        if (!item.isEmpty())
3162          return true;
3163      return false;
3164    }
3165
3166    public AuditEventEntityComponent addEntity() { //3
3167      AuditEventEntityComponent t = new AuditEventEntityComponent();
3168      if (this.entity == null)
3169        this.entity = new ArrayList<AuditEventEntityComponent>();
3170      this.entity.add(t);
3171      return t;
3172    }
3173
3174    public AuditEvent addEntity(AuditEventEntityComponent t) { //3
3175      if (t == null)
3176        return this;
3177      if (this.entity == null)
3178        this.entity = new ArrayList<AuditEventEntityComponent>();
3179      this.entity.add(t);
3180      return this;
3181    }
3182
3183    /**
3184     * @return The first repetition of repeating field {@link #entity}, creating it if it does not already exist {3}
3185     */
3186    public AuditEventEntityComponent getEntityFirstRep() { 
3187      if (getEntity().isEmpty()) {
3188        addEntity();
3189      }
3190      return getEntity().get(0);
3191    }
3192
3193      protected void listChildren(List<Property> children) {
3194        super.listChildren(children);
3195        children.add(new Property("category", "CodeableConcept", "Classification of the type of event.", 0, java.lang.Integer.MAX_VALUE, category));
3196        children.add(new Property("code", "CodeableConcept", "Describes what happened. The most specific code for the event.", 0, 1, code));
3197        children.add(new Property("action", "code", "Indicator for type of action performed during the event that generated the audit.", 0, 1, action));
3198        children.add(new Property("severity", "code", "Indicates and enables segmentation of various severity including debugging from critical.", 0, 1, severity));
3199        children.add(new Property("occurred[x]", "Period|dateTime", "The time or period during which the activity occurred.", 0, 1, occurred));
3200        children.add(new Property("recorded", "instant", "The time when the event was recorded.", 0, 1, recorded));
3201        children.add(new Property("outcome", "", "Indicates whether the event succeeded or failed. A free text descripiton can be given in outcome.text.", 0, 1, outcome));
3202        children.add(new Property("authorization", "CodeableConcept", "The authorization (e.g., PurposeOfUse) that was used during the event being recorded.", 0, java.lang.Integer.MAX_VALUE, authorization));
3203        children.add(new Property("basedOn", "Reference(CarePlan|DeviceRequest|ImmunizationRecommendation|MedicationRequest|NutritionOrder|ServiceRequest|Task)", "Allows tracing of authorizatino for the events and tracking whether proposals/recommendations were acted upon.", 0, java.lang.Integer.MAX_VALUE, basedOn));
3204        children.add(new Property("encounter", "Reference(Encounter)", "This will typically be the encounter the event occurred, but some events may be initiated prior to or after the official completion of an encounter but still be tied to the context of the encounter (e.g. pre-admission lab tests).", 0, 1, encounter));
3205        children.add(new Property("agent", "", "An actor taking an active role in the event or activity that is logged.", 0, java.lang.Integer.MAX_VALUE, agent));
3206        children.add(new Property("source", "", "The actor that is reporting the event.", 0, 1, source));
3207        children.add(new Property("entity", "", "Specific instances of data or objects that have been accessed.", 0, java.lang.Integer.MAX_VALUE, entity));
3208      }
3209
3210      @Override
3211      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
3212        switch (_hash) {
3213        case 50511102: /*category*/  return new Property("category", "CodeableConcept", "Classification of the type of event.", 0, java.lang.Integer.MAX_VALUE, category);
3214        case 3059181: /*code*/  return new Property("code", "CodeableConcept", "Describes what happened. The most specific code for the event.", 0, 1, code);
3215        case -1422950858: /*action*/  return new Property("action", "code", "Indicator for type of action performed during the event that generated the audit.", 0, 1, action);
3216        case 1478300413: /*severity*/  return new Property("severity", "code", "Indicates and enables segmentation of various severity including debugging from critical.", 0, 1, severity);
3217        case 784181563: /*occurred[x]*/  return new Property("occurred[x]", "Period|dateTime", "The time or period during which the activity occurred.", 0, 1, occurred);
3218        case 792816933: /*occurred*/  return new Property("occurred[x]", "Period|dateTime", "The time or period during which the activity occurred.", 0, 1, occurred);
3219        case 894082886: /*occurredPeriod*/  return new Property("occurred[x]", "Period", "The time or period during which the activity occurred.", 0, 1, occurred);
3220        case 1579027424: /*occurredDateTime*/  return new Property("occurred[x]", "dateTime", "The time or period during which the activity occurred.", 0, 1, occurred);
3221        case -799233872: /*recorded*/  return new Property("recorded", "instant", "The time when the event was recorded.", 0, 1, recorded);
3222        case -1106507950: /*outcome*/  return new Property("outcome", "", "Indicates whether the event succeeded or failed. A free text descripiton can be given in outcome.text.", 0, 1, outcome);
3223        case -1385570183: /*authorization*/  return new Property("authorization", "CodeableConcept", "The authorization (e.g., PurposeOfUse) that was used during the event being recorded.", 0, java.lang.Integer.MAX_VALUE, authorization);
3224        case -332612366: /*basedOn*/  return new Property("basedOn", "Reference(CarePlan|DeviceRequest|ImmunizationRecommendation|MedicationRequest|NutritionOrder|ServiceRequest|Task)", "Allows tracing of authorizatino for the events and tracking whether proposals/recommendations were acted upon.", 0, java.lang.Integer.MAX_VALUE, basedOn);
3225        case 1524132147: /*encounter*/  return new Property("encounter", "Reference(Encounter)", "This will typically be the encounter the event occurred, but some events may be initiated prior to or after the official completion of an encounter but still be tied to the context of the encounter (e.g. pre-admission lab tests).", 0, 1, encounter);
3226        case 92750597: /*agent*/  return new Property("agent", "", "An actor taking an active role in the event or activity that is logged.", 0, java.lang.Integer.MAX_VALUE, agent);
3227        case -896505829: /*source*/  return new Property("source", "", "The actor that is reporting the event.", 0, 1, source);
3228        case -1298275357: /*entity*/  return new Property("entity", "", "Specific instances of data or objects that have been accessed.", 0, java.lang.Integer.MAX_VALUE, entity);
3229        default: return super.getNamedProperty(_hash, _name, _checkValid);
3230        }
3231
3232      }
3233
3234      @Override
3235      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
3236        switch (hash) {
3237        case 50511102: /*category*/ return this.category == null ? new Base[0] : this.category.toArray(new Base[this.category.size()]); // CodeableConcept
3238        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
3239        case -1422950858: /*action*/ return this.action == null ? new Base[0] : new Base[] {this.action}; // Enumeration<AuditEventAction>
3240        case 1478300413: /*severity*/ return this.severity == null ? new Base[0] : new Base[] {this.severity}; // Enumeration<AuditEventSeverity>
3241        case 792816933: /*occurred*/ return this.occurred == null ? new Base[0] : new Base[] {this.occurred}; // DataType
3242        case -799233872: /*recorded*/ return this.recorded == null ? new Base[0] : new Base[] {this.recorded}; // InstantType
3243        case -1106507950: /*outcome*/ return this.outcome == null ? new Base[0] : new Base[] {this.outcome}; // AuditEventOutcomeComponent
3244        case -1385570183: /*authorization*/ return this.authorization == null ? new Base[0] : this.authorization.toArray(new Base[this.authorization.size()]); // CodeableConcept
3245        case -332612366: /*basedOn*/ return this.basedOn == null ? new Base[0] : this.basedOn.toArray(new Base[this.basedOn.size()]); // Reference
3246        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : new Base[] {this.encounter}; // Reference
3247        case 92750597: /*agent*/ return this.agent == null ? new Base[0] : this.agent.toArray(new Base[this.agent.size()]); // AuditEventAgentComponent
3248        case -896505829: /*source*/ return this.source == null ? new Base[0] : new Base[] {this.source}; // AuditEventSourceComponent
3249        case -1298275357: /*entity*/ return this.entity == null ? new Base[0] : this.entity.toArray(new Base[this.entity.size()]); // AuditEventEntityComponent
3250        default: return super.getProperty(hash, name, checkValid);
3251        }
3252
3253      }
3254
3255      @Override
3256      public Base setProperty(int hash, String name, Base value) throws FHIRException {
3257        switch (hash) {
3258        case 50511102: // category
3259          this.getCategory().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
3260          return value;
3261        case 3059181: // code
3262          this.code = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3263          return value;
3264        case -1422950858: // action
3265          value = new AuditEventActionEnumFactory().fromType(TypeConvertor.castToCode(value));
3266          this.action = (Enumeration) value; // Enumeration<AuditEventAction>
3267          return value;
3268        case 1478300413: // severity
3269          value = new AuditEventSeverityEnumFactory().fromType(TypeConvertor.castToCode(value));
3270          this.severity = (Enumeration) value; // Enumeration<AuditEventSeverity>
3271          return value;
3272        case 792816933: // occurred
3273          this.occurred = TypeConvertor.castToType(value); // DataType
3274          return value;
3275        case -799233872: // recorded
3276          this.recorded = TypeConvertor.castToInstant(value); // InstantType
3277          return value;
3278        case -1106507950: // outcome
3279          this.outcome = (AuditEventOutcomeComponent) value; // AuditEventOutcomeComponent
3280          return value;
3281        case -1385570183: // authorization
3282          this.getAuthorization().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
3283          return value;
3284        case -332612366: // basedOn
3285          this.getBasedOn().add(TypeConvertor.castToReference(value)); // Reference
3286          return value;
3287        case 1524132147: // encounter
3288          this.encounter = TypeConvertor.castToReference(value); // Reference
3289          return value;
3290        case 92750597: // agent
3291          this.getAgent().add((AuditEventAgentComponent) value); // AuditEventAgentComponent
3292          return value;
3293        case -896505829: // source
3294          this.source = (AuditEventSourceComponent) value; // AuditEventSourceComponent
3295          return value;
3296        case -1298275357: // entity
3297          this.getEntity().add((AuditEventEntityComponent) value); // AuditEventEntityComponent
3298          return value;
3299        default: return super.setProperty(hash, name, value);
3300        }
3301
3302      }
3303
3304      @Override
3305      public Base setProperty(String name, Base value) throws FHIRException {
3306        if (name.equals("category")) {
3307          this.getCategory().add(TypeConvertor.castToCodeableConcept(value));
3308        } else if (name.equals("code")) {
3309          this.code = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3310        } else if (name.equals("action")) {
3311          value = new AuditEventActionEnumFactory().fromType(TypeConvertor.castToCode(value));
3312          this.action = (Enumeration) value; // Enumeration<AuditEventAction>
3313        } else if (name.equals("severity")) {
3314          value = new AuditEventSeverityEnumFactory().fromType(TypeConvertor.castToCode(value));
3315          this.severity = (Enumeration) value; // Enumeration<AuditEventSeverity>
3316        } else if (name.equals("occurred[x]")) {
3317          this.occurred = TypeConvertor.castToType(value); // DataType
3318        } else if (name.equals("recorded")) {
3319          this.recorded = TypeConvertor.castToInstant(value); // InstantType
3320        } else if (name.equals("outcome")) {
3321          this.outcome = (AuditEventOutcomeComponent) value; // AuditEventOutcomeComponent
3322        } else if (name.equals("authorization")) {
3323          this.getAuthorization().add(TypeConvertor.castToCodeableConcept(value));
3324        } else if (name.equals("basedOn")) {
3325          this.getBasedOn().add(TypeConvertor.castToReference(value));
3326        } else if (name.equals("encounter")) {
3327          this.encounter = TypeConvertor.castToReference(value); // Reference
3328        } else if (name.equals("agent")) {
3329          this.getAgent().add((AuditEventAgentComponent) value);
3330        } else if (name.equals("source")) {
3331          this.source = (AuditEventSourceComponent) value; // AuditEventSourceComponent
3332        } else if (name.equals("entity")) {
3333          this.getEntity().add((AuditEventEntityComponent) value);
3334        } else
3335          return super.setProperty(name, value);
3336        return value;
3337      }
3338
3339      @Override
3340      public Base makeProperty(int hash, String name) throws FHIRException {
3341        switch (hash) {
3342        case 50511102:  return addCategory(); 
3343        case 3059181:  return getCode();
3344        case -1422950858:  return getActionElement();
3345        case 1478300413:  return getSeverityElement();
3346        case 784181563:  return getOccurred();
3347        case 792816933:  return getOccurred();
3348        case -799233872:  return getRecordedElement();
3349        case -1106507950:  return getOutcome();
3350        case -1385570183:  return addAuthorization(); 
3351        case -332612366:  return addBasedOn(); 
3352        case 1524132147:  return getEncounter();
3353        case 92750597:  return addAgent(); 
3354        case -896505829:  return getSource();
3355        case -1298275357:  return addEntity(); 
3356        default: return super.makeProperty(hash, name);
3357        }
3358
3359      }
3360
3361      @Override
3362      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
3363        switch (hash) {
3364        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
3365        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
3366        case -1422950858: /*action*/ return new String[] {"code"};
3367        case 1478300413: /*severity*/ return new String[] {"code"};
3368        case 792816933: /*occurred*/ return new String[] {"Period", "dateTime"};
3369        case -799233872: /*recorded*/ return new String[] {"instant"};
3370        case -1106507950: /*outcome*/ return new String[] {};
3371        case -1385570183: /*authorization*/ return new String[] {"CodeableConcept"};
3372        case -332612366: /*basedOn*/ return new String[] {"Reference"};
3373        case 1524132147: /*encounter*/ return new String[] {"Reference"};
3374        case 92750597: /*agent*/ return new String[] {};
3375        case -896505829: /*source*/ return new String[] {};
3376        case -1298275357: /*entity*/ return new String[] {};
3377        default: return super.getTypesForProperty(hash, name);
3378        }
3379
3380      }
3381
3382      @Override
3383      public Base addChild(String name) throws FHIRException {
3384        if (name.equals("category")) {
3385          return addCategory();
3386        }
3387        else if (name.equals("code")) {
3388          this.code = new CodeableConcept();
3389          return this.code;
3390        }
3391        else if (name.equals("action")) {
3392          throw new FHIRException("Cannot call addChild on a primitive type AuditEvent.action");
3393        }
3394        else if (name.equals("severity")) {
3395          throw new FHIRException("Cannot call addChild on a primitive type AuditEvent.severity");
3396        }
3397        else if (name.equals("occurredPeriod")) {
3398          this.occurred = new Period();
3399          return this.occurred;
3400        }
3401        else if (name.equals("occurredDateTime")) {
3402          this.occurred = new DateTimeType();
3403          return this.occurred;
3404        }
3405        else if (name.equals("recorded")) {
3406          throw new FHIRException("Cannot call addChild on a primitive type AuditEvent.recorded");
3407        }
3408        else if (name.equals("outcome")) {
3409          this.outcome = new AuditEventOutcomeComponent();
3410          return this.outcome;
3411        }
3412        else if (name.equals("authorization")) {
3413          return addAuthorization();
3414        }
3415        else if (name.equals("basedOn")) {
3416          return addBasedOn();
3417        }
3418        else if (name.equals("encounter")) {
3419          this.encounter = new Reference();
3420          return this.encounter;
3421        }
3422        else if (name.equals("agent")) {
3423          return addAgent();
3424        }
3425        else if (name.equals("source")) {
3426          this.source = new AuditEventSourceComponent();
3427          return this.source;
3428        }
3429        else if (name.equals("entity")) {
3430          return addEntity();
3431        }
3432        else
3433          return super.addChild(name);
3434      }
3435
3436  public String fhirType() {
3437    return "AuditEvent";
3438
3439  }
3440
3441      public AuditEvent copy() {
3442        AuditEvent dst = new AuditEvent();
3443        copyValues(dst);
3444        return dst;
3445      }
3446
3447      public void copyValues(AuditEvent dst) {
3448        super.copyValues(dst);
3449        if (category != null) {
3450          dst.category = new ArrayList<CodeableConcept>();
3451          for (CodeableConcept i : category)
3452            dst.category.add(i.copy());
3453        };
3454        dst.code = code == null ? null : code.copy();
3455        dst.action = action == null ? null : action.copy();
3456        dst.severity = severity == null ? null : severity.copy();
3457        dst.occurred = occurred == null ? null : occurred.copy();
3458        dst.recorded = recorded == null ? null : recorded.copy();
3459        dst.outcome = outcome == null ? null : outcome.copy();
3460        if (authorization != null) {
3461          dst.authorization = new ArrayList<CodeableConcept>();
3462          for (CodeableConcept i : authorization)
3463            dst.authorization.add(i.copy());
3464        };
3465        if (basedOn != null) {
3466          dst.basedOn = new ArrayList<Reference>();
3467          for (Reference i : basedOn)
3468            dst.basedOn.add(i.copy());
3469        };
3470        dst.encounter = encounter == null ? null : encounter.copy();
3471        if (agent != null) {
3472          dst.agent = new ArrayList<AuditEventAgentComponent>();
3473          for (AuditEventAgentComponent i : agent)
3474            dst.agent.add(i.copy());
3475        };
3476        dst.source = source == null ? null : source.copy();
3477        if (entity != null) {
3478          dst.entity = new ArrayList<AuditEventEntityComponent>();
3479          for (AuditEventEntityComponent i : entity)
3480            dst.entity.add(i.copy());
3481        };
3482      }
3483
3484      protected AuditEvent typedCopy() {
3485        return copy();
3486      }
3487
3488      @Override
3489      public boolean equalsDeep(Base other_) {
3490        if (!super.equalsDeep(other_))
3491          return false;
3492        if (!(other_ instanceof AuditEvent))
3493          return false;
3494        AuditEvent o = (AuditEvent) other_;
3495        return compareDeep(category, o.category, true) && compareDeep(code, o.code, true) && compareDeep(action, o.action, true)
3496           && compareDeep(severity, o.severity, true) && compareDeep(occurred, o.occurred, true) && compareDeep(recorded, o.recorded, true)
3497           && compareDeep(outcome, o.outcome, true) && compareDeep(authorization, o.authorization, true) && compareDeep(basedOn, o.basedOn, true)
3498           && compareDeep(encounter, o.encounter, true) && compareDeep(agent, o.agent, true) && compareDeep(source, o.source, true)
3499           && compareDeep(entity, o.entity, true);
3500      }
3501
3502      @Override
3503      public boolean equalsShallow(Base other_) {
3504        if (!super.equalsShallow(other_))
3505          return false;
3506        if (!(other_ instanceof AuditEvent))
3507          return false;
3508        AuditEvent o = (AuditEvent) other_;
3509        return compareValues(action, o.action, true) && compareValues(severity, o.severity, true) && compareValues(recorded, o.recorded, true)
3510          ;
3511      }
3512
3513      public boolean isEmpty() {
3514        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(category, code, action, severity
3515          , occurred, recorded, outcome, authorization, basedOn, encounter, agent, source
3516          , entity);
3517      }
3518
3519  @Override
3520  public ResourceType getResourceType() {
3521    return ResourceType.AuditEvent;
3522   }
3523
3524 /**
3525   * Search parameter: <b>action</b>
3526   * <p>
3527   * Description: <b>Type of action performed during the event</b><br>
3528   * Type: <b>token</b><br>
3529   * Path: <b>AuditEvent.action</b><br>
3530   * </p>
3531   */
3532  @SearchParamDefinition(name="action", path="AuditEvent.action", description="Type of action performed during the event", type="token" )
3533  public static final String SP_ACTION = "action";
3534 /**
3535   * <b>Fluent Client</b> search parameter constant for <b>action</b>
3536   * <p>
3537   * Description: <b>Type of action performed during the event</b><br>
3538   * Type: <b>token</b><br>
3539   * Path: <b>AuditEvent.action</b><br>
3540   * </p>
3541   */
3542  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ACTION = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_ACTION);
3543
3544 /**
3545   * Search parameter: <b>agent-role</b>
3546   * <p>
3547   * Description: <b>Agent role in the event</b><br>
3548   * Type: <b>token</b><br>
3549   * Path: <b>AuditEvent.agent.role</b><br>
3550   * </p>
3551   */
3552  @SearchParamDefinition(name="agent-role", path="AuditEvent.agent.role", description="Agent role in the event", type="token" )
3553  public static final String SP_AGENT_ROLE = "agent-role";
3554 /**
3555   * <b>Fluent Client</b> search parameter constant for <b>agent-role</b>
3556   * <p>
3557   * Description: <b>Agent role in the event</b><br>
3558   * Type: <b>token</b><br>
3559   * Path: <b>AuditEvent.agent.role</b><br>
3560   * </p>
3561   */
3562  public static final ca.uhn.fhir.rest.gclient.TokenClientParam AGENT_ROLE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_AGENT_ROLE);
3563
3564 /**
3565   * Search parameter: <b>agent</b>
3566   * <p>
3567   * Description: <b>Identifier of who</b><br>
3568   * Type: <b>reference</b><br>
3569   * Path: <b>AuditEvent.agent.who</b><br>
3570   * </p>
3571   */
3572  @SearchParamDefinition(name="agent", path="AuditEvent.agent.who", description="Identifier of who", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Device"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Practitioner") }, target={CareTeam.class, Device.class, Organization.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class } )
3573  public static final String SP_AGENT = "agent";
3574 /**
3575   * <b>Fluent Client</b> search parameter constant for <b>agent</b>
3576   * <p>
3577   * Description: <b>Identifier of who</b><br>
3578   * Type: <b>reference</b><br>
3579   * Path: <b>AuditEvent.agent.who</b><br>
3580   * </p>
3581   */
3582  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam AGENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_AGENT);
3583
3584/**
3585   * Constant for fluent queries to be used to add include statements. Specifies
3586   * the path value of "<b>AuditEvent:agent</b>".
3587   */
3588  public static final ca.uhn.fhir.model.api.Include INCLUDE_AGENT = new ca.uhn.fhir.model.api.Include("AuditEvent:agent").toLocked();
3589
3590 /**
3591   * Search parameter: <b>based-on</b>
3592   * <p>
3593   * Description: <b>Reference to the service request.</b><br>
3594   * Type: <b>reference</b><br>
3595   * Path: <b>AuditEvent.basedOn</b><br>
3596   * </p>
3597   */
3598  @SearchParamDefinition(name="based-on", path="AuditEvent.basedOn", description="Reference to the service request.", type="reference", target={CarePlan.class, DeviceRequest.class, ImmunizationRecommendation.class, MedicationRequest.class, NutritionOrder.class, ServiceRequest.class, Task.class } )
3599  public static final String SP_BASED_ON = "based-on";
3600 /**
3601   * <b>Fluent Client</b> search parameter constant for <b>based-on</b>
3602   * <p>
3603   * Description: <b>Reference to the service request.</b><br>
3604   * Type: <b>reference</b><br>
3605   * Path: <b>AuditEvent.basedOn</b><br>
3606   * </p>
3607   */
3608  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam BASED_ON = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_BASED_ON);
3609
3610/**
3611   * Constant for fluent queries to be used to add include statements. Specifies
3612   * the path value of "<b>AuditEvent:based-on</b>".
3613   */
3614  public static final ca.uhn.fhir.model.api.Include INCLUDE_BASED_ON = new ca.uhn.fhir.model.api.Include("AuditEvent:based-on").toLocked();
3615
3616 /**
3617   * Search parameter: <b>category</b>
3618   * <p>
3619   * Description: <b>Category of event</b><br>
3620   * Type: <b>token</b><br>
3621   * Path: <b>AuditEvent.category</b><br>
3622   * </p>
3623   */
3624  @SearchParamDefinition(name="category", path="AuditEvent.category", description="Category of event", type="token" )
3625  public static final String SP_CATEGORY = "category";
3626 /**
3627   * <b>Fluent Client</b> search parameter constant for <b>category</b>
3628   * <p>
3629   * Description: <b>Category of event</b><br>
3630   * Type: <b>token</b><br>
3631   * Path: <b>AuditEvent.category</b><br>
3632   * </p>
3633   */
3634  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CATEGORY);
3635
3636 /**
3637   * Search parameter: <b>code</b>
3638   * <p>
3639   * Description: <b>More specific code for the event</b><br>
3640   * Type: <b>token</b><br>
3641   * Path: <b>AuditEvent.code</b><br>
3642   * </p>
3643   */
3644  @SearchParamDefinition(name="code", path="AuditEvent.code", description="More specific code for the event", type="token" )
3645  public static final String SP_CODE = "code";
3646 /**
3647   * <b>Fluent Client</b> search parameter constant for <b>code</b>
3648   * <p>
3649   * Description: <b>More specific code for the event</b><br>
3650   * Type: <b>token</b><br>
3651   * Path: <b>AuditEvent.code</b><br>
3652   * </p>
3653   */
3654  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
3655
3656 /**
3657   * Search parameter: <b>date</b>
3658   * <p>
3659   * Description: <b>Time when the event was recorded</b><br>
3660   * Type: <b>date</b><br>
3661   * Path: <b>AuditEvent.recorded</b><br>
3662   * </p>
3663   */
3664  @SearchParamDefinition(name="date", path="AuditEvent.recorded", description="Time when the event was recorded", type="date" )
3665  public static final String SP_DATE = "date";
3666 /**
3667   * <b>Fluent Client</b> search parameter constant for <b>date</b>
3668   * <p>
3669   * Description: <b>Time when the event was recorded</b><br>
3670   * Type: <b>date</b><br>
3671   * Path: <b>AuditEvent.recorded</b><br>
3672   * </p>
3673   */
3674  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
3675
3676 /**
3677   * Search parameter: <b>encounter</b>
3678   * <p>
3679   * Description: <b>Encounter related to the activity recorded in the AuditEvent</b><br>
3680   * Type: <b>reference</b><br>
3681   * Path: <b>AuditEvent.encounter</b><br>
3682   * </p>
3683   */
3684  @SearchParamDefinition(name="encounter", path="AuditEvent.encounter", description="Encounter related to the activity recorded in the AuditEvent", type="reference", target={Encounter.class } )
3685  public static final String SP_ENCOUNTER = "encounter";
3686 /**
3687   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
3688   * <p>
3689   * Description: <b>Encounter related to the activity recorded in the AuditEvent</b><br>
3690   * Type: <b>reference</b><br>
3691   * Path: <b>AuditEvent.encounter</b><br>
3692   * </p>
3693   */
3694  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
3695
3696/**
3697   * Constant for fluent queries to be used to add include statements. Specifies
3698   * the path value of "<b>AuditEvent:encounter</b>".
3699   */
3700  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("AuditEvent:encounter").toLocked();
3701
3702 /**
3703   * Search parameter: <b>entity-role</b>
3704   * <p>
3705   * Description: <b>What role the entity played</b><br>
3706   * Type: <b>token</b><br>
3707   * Path: <b>AuditEvent.entity.role</b><br>
3708   * </p>
3709   */
3710  @SearchParamDefinition(name="entity-role", path="AuditEvent.entity.role", description="What role the entity played", type="token" )
3711  public static final String SP_ENTITY_ROLE = "entity-role";
3712 /**
3713   * <b>Fluent Client</b> search parameter constant for <b>entity-role</b>
3714   * <p>
3715   * Description: <b>What role the entity played</b><br>
3716   * Type: <b>token</b><br>
3717   * Path: <b>AuditEvent.entity.role</b><br>
3718   * </p>
3719   */
3720  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ENTITY_ROLE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_ENTITY_ROLE);
3721
3722 /**
3723   * Search parameter: <b>entity</b>
3724   * <p>
3725   * Description: <b>Specific instance of resource</b><br>
3726   * Type: <b>reference</b><br>
3727   * Path: <b>AuditEvent.entity.what</b><br>
3728   * </p>
3729   */
3730  @SearchParamDefinition(name="entity", path="AuditEvent.entity.what", description="Specific instance of resource", type="reference", target={Account.class, ActivityDefinition.class, AdministrableProductDefinition.class, AdverseEvent.class, AllergyIntolerance.class, Appointment.class, AppointmentResponse.class, ArtifactAssessment.class, AuditEvent.class, Basic.class, Binary.class, BiologicallyDerivedProduct.class, BodyStructure.class, Bundle.class, CapabilityStatement.class, CapabilityStatement2.class, CarePlan.class, CareTeam.class, ChargeItem.class, ChargeItemDefinition.class, Citation.class, Claim.class, ClaimResponse.class, ClinicalImpression.class, ClinicalUseDefinition.class, ClinicalUseIssue.class, CodeSystem.class, Communication.class, CommunicationRequest.class, CompartmentDefinition.class, Composition.class, ConceptMap.class, ConceptMap2.class, Condition.class, ConditionDefinition.class, Consent.class, Contract.class, Coverage.class, CoverageEligibilityRequest.class, CoverageEligibilityResponse.class, DetectedIssue.class, Device.class, DeviceDefinition.class, DeviceDispense.class, DeviceMetric.class, DeviceRequest.class, DeviceUsage.class, DiagnosticReport.class, DocumentManifest.class, DocumentReference.class, Encounter.class, Endpoint.class, EnrollmentRequest.class, EnrollmentResponse.class, EpisodeOfCare.class, EventDefinition.class, Evidence.class, EvidenceReport.class, EvidenceVariable.class, ExampleScenario.class, ExplanationOfBenefit.class, FamilyMemberHistory.class, Flag.class, Goal.class, GraphDefinition.class, Group.class, GuidanceResponse.class, HealthcareService.class, ImagingSelection.class, ImagingStudy.class, Immunization.class, ImmunizationEvaluation.class, ImmunizationRecommendation.class, ImplementationGuide.class, Ingredient.class, InsurancePlan.class, InventoryReport.class, Invoice.class, Library.class, Linkage.class, ListResource.class, Location.class, ManufacturedItemDefinition.class, Measure.class, MeasureReport.class, Medication.class, MedicationAdministration.class, MedicationDispense.class, MedicationKnowledge.class, MedicationRequest.class, MedicationUsage.class, MedicinalProductDefinition.class, MessageDefinition.class, MessageHeader.class, MolecularSequence.class, NamingSystem.class, NutritionIntake.class, NutritionOrder.class, NutritionProduct.class, Observation.class, ObservationDefinition.class, OperationDefinition.class, OperationOutcome.class, Organization.class, OrganizationAffiliation.class, PackagedProductDefinition.class, Patient.class, PaymentNotice.class, PaymentReconciliation.class, Permission.class, Person.class, PlanDefinition.class, Practitioner.class, PractitionerRole.class, Procedure.class, Provenance.class, Questionnaire.class, QuestionnaireResponse.class, RegulatedAuthorization.class, RelatedPerson.class, RequestGroup.class, ResearchStudy.class, ResearchSubject.class, RiskAssessment.class, Schedule.class, SearchParameter.class, ServiceRequest.class, Slot.class, Specimen.class, SpecimenDefinition.class, StructureDefinition.class, StructureMap.class, Subscription.class, SubscriptionStatus.class, SubscriptionTopic.class, Substance.class, SubstanceDefinition.class, SubstanceNucleicAcid.class, SubstancePolymer.class, SubstanceProtein.class, SubstanceReferenceInformation.class, SubstanceSourceMaterial.class, SupplyDelivery.class, SupplyRequest.class, Task.class, TerminologyCapabilities.class, TestReport.class, TestScript.class, ValueSet.class, VerificationResult.class, VisionPrescription.class } )
3731  public static final String SP_ENTITY = "entity";
3732 /**
3733   * <b>Fluent Client</b> search parameter constant for <b>entity</b>
3734   * <p>
3735   * Description: <b>Specific instance of resource</b><br>
3736   * Type: <b>reference</b><br>
3737   * Path: <b>AuditEvent.entity.what</b><br>
3738   * </p>
3739   */
3740  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENTITY = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENTITY);
3741
3742/**
3743   * Constant for fluent queries to be used to add include statements. Specifies
3744   * the path value of "<b>AuditEvent:entity</b>".
3745   */
3746  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENTITY = new ca.uhn.fhir.model.api.Include("AuditEvent:entity").toLocked();
3747
3748 /**
3749   * Search parameter: <b>outcome</b>
3750   * <p>
3751   * Description: <b>Whether the event succeeded or failed</b><br>
3752   * Type: <b>token</b><br>
3753   * Path: <b>AuditEvent.outcome.code</b><br>
3754   * </p>
3755   */
3756  @SearchParamDefinition(name="outcome", path="AuditEvent.outcome.code", description="Whether the event succeeded or failed", type="token" )
3757  public static final String SP_OUTCOME = "outcome";
3758 /**
3759   * <b>Fluent Client</b> search parameter constant for <b>outcome</b>
3760   * <p>
3761   * Description: <b>Whether the event succeeded or failed</b><br>
3762   * Type: <b>token</b><br>
3763   * Path: <b>AuditEvent.outcome.code</b><br>
3764   * </p>
3765   */
3766  public static final ca.uhn.fhir.rest.gclient.TokenClientParam OUTCOME = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_OUTCOME);
3767
3768 /**
3769   * Search parameter: <b>patient</b>
3770   * <p>
3771   * Description: <b>Identifier of who</b><br>
3772   * Type: <b>reference</b><br>
3773   * Path: <b>AuditEvent.agent.who.where(resolve() is Patient) | AuditEvent.entity.what.where(resolve() is Patient)</b><br>
3774   * </p>
3775   */
3776  @SearchParamDefinition(name="patient", path="AuditEvent.agent.who.where(resolve() is Patient) | AuditEvent.entity.what.where(resolve() is Patient)", description="Identifier of who", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Patient") }, target={Account.class, ActivityDefinition.class, AdministrableProductDefinition.class, AdverseEvent.class, AllergyIntolerance.class, Appointment.class, AppointmentResponse.class, ArtifactAssessment.class, AuditEvent.class, Basic.class, Binary.class, BiologicallyDerivedProduct.class, BodyStructure.class, Bundle.class, CapabilityStatement.class, CapabilityStatement2.class, CarePlan.class, CareTeam.class, ChargeItem.class, ChargeItemDefinition.class, Citation.class, Claim.class, ClaimResponse.class, ClinicalImpression.class, ClinicalUseDefinition.class, ClinicalUseIssue.class, CodeSystem.class, Communication.class, CommunicationRequest.class, CompartmentDefinition.class, Composition.class, ConceptMap.class, ConceptMap2.class, Condition.class, ConditionDefinition.class, Consent.class, Contract.class, Coverage.class, CoverageEligibilityRequest.class, CoverageEligibilityResponse.class, DetectedIssue.class, Device.class, DeviceDefinition.class, DeviceDispense.class, DeviceMetric.class, DeviceRequest.class, DeviceUsage.class, DiagnosticReport.class, DocumentManifest.class, DocumentReference.class, Encounter.class, Endpoint.class, EnrollmentRequest.class, EnrollmentResponse.class, EpisodeOfCare.class, EventDefinition.class, Evidence.class, EvidenceReport.class, EvidenceVariable.class, ExampleScenario.class, ExplanationOfBenefit.class, FamilyMemberHistory.class, Flag.class, Goal.class, GraphDefinition.class, Group.class, GuidanceResponse.class, HealthcareService.class, ImagingSelection.class, ImagingStudy.class, Immunization.class, ImmunizationEvaluation.class, ImmunizationRecommendation.class, ImplementationGuide.class, Ingredient.class, InsurancePlan.class, InventoryReport.class, Invoice.class, Library.class, Linkage.class, ListResource.class, Location.class, ManufacturedItemDefinition.class, Measure.class, MeasureReport.class, Medication.class, MedicationAdministration.class, MedicationDispense.class, MedicationKnowledge.class, MedicationRequest.class, MedicationUsage.class, MedicinalProductDefinition.class, MessageDefinition.class, MessageHeader.class, MolecularSequence.class, NamingSystem.class, NutritionIntake.class, NutritionOrder.class, NutritionProduct.class, Observation.class, ObservationDefinition.class, OperationDefinition.class, OperationOutcome.class, Organization.class, OrganizationAffiliation.class, PackagedProductDefinition.class, Patient.class, PaymentNotice.class, PaymentReconciliation.class, Permission.class, Person.class, PlanDefinition.class, Practitioner.class, PractitionerRole.class, Procedure.class, Provenance.class, Questionnaire.class, QuestionnaireResponse.class, RegulatedAuthorization.class, RelatedPerson.class, RequestGroup.class, ResearchStudy.class, ResearchSubject.class, RiskAssessment.class, Schedule.class, SearchParameter.class, ServiceRequest.class, Slot.class, Specimen.class, SpecimenDefinition.class, StructureDefinition.class, StructureMap.class, Subscription.class, SubscriptionStatus.class, SubscriptionTopic.class, Substance.class, SubstanceDefinition.class, SubstanceNucleicAcid.class, SubstancePolymer.class, SubstanceProtein.class, SubstanceReferenceInformation.class, SubstanceSourceMaterial.class, SupplyDelivery.class, SupplyRequest.class, Task.class, TerminologyCapabilities.class, TestReport.class, TestScript.class, ValueSet.class, VerificationResult.class, VisionPrescription.class } )
3777  public static final String SP_PATIENT = "patient";
3778 /**
3779   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
3780   * <p>
3781   * Description: <b>Identifier of who</b><br>
3782   * Type: <b>reference</b><br>
3783   * Path: <b>AuditEvent.agent.who.where(resolve() is Patient) | AuditEvent.entity.what.where(resolve() is Patient)</b><br>
3784   * </p>
3785   */
3786  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
3787
3788/**
3789   * Constant for fluent queries to be used to add include statements. Specifies
3790   * the path value of "<b>AuditEvent:patient</b>".
3791   */
3792  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("AuditEvent:patient").toLocked();
3793
3794 /**
3795   * Search parameter: <b>policy</b>
3796   * <p>
3797   * Description: <b>Policy that authorized event</b><br>
3798   * Type: <b>uri</b><br>
3799   * Path: <b>AuditEvent.agent.policy</b><br>
3800   * </p>
3801   */
3802  @SearchParamDefinition(name="policy", path="AuditEvent.agent.policy", description="Policy that authorized event", type="uri" )
3803  public static final String SP_POLICY = "policy";
3804 /**
3805   * <b>Fluent Client</b> search parameter constant for <b>policy</b>
3806   * <p>
3807   * Description: <b>Policy that authorized event</b><br>
3808   * Type: <b>uri</b><br>
3809   * Path: <b>AuditEvent.agent.policy</b><br>
3810   * </p>
3811   */
3812  public static final ca.uhn.fhir.rest.gclient.UriClientParam POLICY = new ca.uhn.fhir.rest.gclient.UriClientParam(SP_POLICY);
3813
3814 /**
3815   * Search parameter: <b>purpose</b>
3816   * <p>
3817   * Description: <b>The authorization (purposeOfUse) of the event</b><br>
3818   * Type: <b>token</b><br>
3819   * Path: <b>AuditEvent.authorization | AuditEvent.agent.authorization</b><br>
3820   * </p>
3821   */
3822  @SearchParamDefinition(name="purpose", path="AuditEvent.authorization | AuditEvent.agent.authorization", description="The authorization (purposeOfUse) of the event", type="token" )
3823  public static final String SP_PURPOSE = "purpose";
3824 /**
3825   * <b>Fluent Client</b> search parameter constant for <b>purpose</b>
3826   * <p>
3827   * Description: <b>The authorization (purposeOfUse) of the event</b><br>
3828   * Type: <b>token</b><br>
3829   * Path: <b>AuditEvent.authorization | AuditEvent.agent.authorization</b><br>
3830   * </p>
3831   */
3832  public static final ca.uhn.fhir.rest.gclient.TokenClientParam PURPOSE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_PURPOSE);
3833
3834 /**
3835   * Search parameter: <b>source</b>
3836   * <p>
3837   * Description: <b>The identity of source detecting the event</b><br>
3838   * Type: <b>reference</b><br>
3839   * Path: <b>AuditEvent.source.observer</b><br>
3840   * </p>
3841   */
3842  @SearchParamDefinition(name="source", path="AuditEvent.source.observer", description="The identity of source detecting the event", type="reference", target={CareTeam.class, Device.class, Organization.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class } )
3843  public static final String SP_SOURCE = "source";
3844 /**
3845   * <b>Fluent Client</b> search parameter constant for <b>source</b>
3846   * <p>
3847   * Description: <b>The identity of source detecting the event</b><br>
3848   * Type: <b>reference</b><br>
3849   * Path: <b>AuditEvent.source.observer</b><br>
3850   * </p>
3851   */
3852  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SOURCE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SOURCE);
3853
3854/**
3855   * Constant for fluent queries to be used to add include statements. Specifies
3856   * the path value of "<b>AuditEvent:source</b>".
3857   */
3858  public static final ca.uhn.fhir.model.api.Include INCLUDE_SOURCE = new ca.uhn.fhir.model.api.Include("AuditEvent:source").toLocked();
3859
3860
3861}
3862