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