001package org.hl7.fhir.dstu3.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 Fri, Mar 16, 2018 15:21+1100 for FHIR v3.0.1
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import org.hl7.fhir.dstu3.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;
046import org.hl7.fhir.exceptions.FHIRFormatError;
047/**
048 * 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.
049 */
050@ResourceDef(name="AuditEvent", profile="http://hl7.org/fhir/StructureDefinition/AuditEvent")
051public class AuditEvent extends DomainResource {
052
053    public enum AuditEventAction {
054        /**
055         * Create a new database object, such as placing an order.
056         */
057        C, 
058        /**
059         * Display or print data, such as a doctor census.
060         */
061        R, 
062        /**
063         * Update data, such as revise patient information.
064         */
065        U, 
066        /**
067         * Delete items, such as a doctor master file record.
068         */
069        D, 
070        /**
071         * 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.
072         */
073        E, 
074        /**
075         * added to help the parsers with the generic types
076         */
077        NULL;
078        public static AuditEventAction fromCode(String codeString) throws FHIRException {
079            if (codeString == null || "".equals(codeString))
080                return null;
081        if ("C".equals(codeString))
082          return C;
083        if ("R".equals(codeString))
084          return R;
085        if ("U".equals(codeString))
086          return U;
087        if ("D".equals(codeString))
088          return D;
089        if ("E".equals(codeString))
090          return E;
091        if (Configuration.isAcceptInvalidEnums())
092          return null;
093        else
094          throw new FHIRException("Unknown AuditEventAction code '"+codeString+"'");
095        }
096        public String toCode() {
097          switch (this) {
098            case C: return "C";
099            case R: return "R";
100            case U: return "U";
101            case D: return "D";
102            case E: return "E";
103            default: return "?";
104          }
105        }
106        public String getSystem() {
107          switch (this) {
108            case C: return "http://hl7.org/fhir/audit-event-action";
109            case R: return "http://hl7.org/fhir/audit-event-action";
110            case U: return "http://hl7.org/fhir/audit-event-action";
111            case D: return "http://hl7.org/fhir/audit-event-action";
112            case E: return "http://hl7.org/fhir/audit-event-action";
113            default: return "?";
114          }
115        }
116        public String getDefinition() {
117          switch (this) {
118            case C: return "Create a new database object, such as placing an order.";
119            case R: return "Display or print data, such as a doctor census.";
120            case U: return "Update data, such as revise patient information.";
121            case D: return "Delete items, such as a doctor master file record.";
122            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.";
123            default: return "?";
124          }
125        }
126        public String getDisplay() {
127          switch (this) {
128            case C: return "Create";
129            case R: return "Read/View/Print";
130            case U: return "Update";
131            case D: return "Delete";
132            case E: return "Execute";
133            default: return "?";
134          }
135        }
136    }
137
138  public static class AuditEventActionEnumFactory implements EnumFactory<AuditEventAction> {
139    public AuditEventAction fromCode(String codeString) throws IllegalArgumentException {
140      if (codeString == null || "".equals(codeString))
141            if (codeString == null || "".equals(codeString))
142                return null;
143        if ("C".equals(codeString))
144          return AuditEventAction.C;
145        if ("R".equals(codeString))
146          return AuditEventAction.R;
147        if ("U".equals(codeString))
148          return AuditEventAction.U;
149        if ("D".equals(codeString))
150          return AuditEventAction.D;
151        if ("E".equals(codeString))
152          return AuditEventAction.E;
153        throw new IllegalArgumentException("Unknown AuditEventAction code '"+codeString+"'");
154        }
155        public Enumeration<AuditEventAction> fromType(Base code) throws FHIRException {
156          if (code == null)
157            return null;
158          if (code.isEmpty())
159            return new Enumeration<AuditEventAction>(this);
160          String codeString = ((PrimitiveType) code).asStringValue();
161          if (codeString == null || "".equals(codeString))
162            return null;
163        if ("C".equals(codeString))
164          return new Enumeration<AuditEventAction>(this, AuditEventAction.C);
165        if ("R".equals(codeString))
166          return new Enumeration<AuditEventAction>(this, AuditEventAction.R);
167        if ("U".equals(codeString))
168          return new Enumeration<AuditEventAction>(this, AuditEventAction.U);
169        if ("D".equals(codeString))
170          return new Enumeration<AuditEventAction>(this, AuditEventAction.D);
171        if ("E".equals(codeString))
172          return new Enumeration<AuditEventAction>(this, AuditEventAction.E);
173        throw new FHIRException("Unknown AuditEventAction code '"+codeString+"'");
174        }
175    public String toCode(AuditEventAction code) {
176      if (code == AuditEventAction.C)
177        return "C";
178      if (code == AuditEventAction.R)
179        return "R";
180      if (code == AuditEventAction.U)
181        return "U";
182      if (code == AuditEventAction.D)
183        return "D";
184      if (code == AuditEventAction.E)
185        return "E";
186      return "?";
187      }
188    public String toSystem(AuditEventAction code) {
189      return code.getSystem();
190      }
191    }
192
193    public enum AuditEventOutcome {
194        /**
195         * The operation completed successfully (whether with warnings or not).
196         */
197        _0, 
198        /**
199         * The action was not successful due to some kind of catered for error (often equivalent to an HTTP 400 response).
200         */
201        _4, 
202        /**
203         * The action was not successful due to some kind of unexpected error (often equivalent to an HTTP 500 response).
204         */
205        _8, 
206        /**
207         * An error of such magnitude occurred that the system is no longer available for use (i.e. the system died).
208         */
209        _12, 
210        /**
211         * added to help the parsers with the generic types
212         */
213        NULL;
214        public static AuditEventOutcome fromCode(String codeString) throws FHIRException {
215            if (codeString == null || "".equals(codeString))
216                return null;
217        if ("0".equals(codeString))
218          return _0;
219        if ("4".equals(codeString))
220          return _4;
221        if ("8".equals(codeString))
222          return _8;
223        if ("12".equals(codeString))
224          return _12;
225        if (Configuration.isAcceptInvalidEnums())
226          return null;
227        else
228          throw new FHIRException("Unknown AuditEventOutcome code '"+codeString+"'");
229        }
230        public String toCode() {
231          switch (this) {
232            case _0: return "0";
233            case _4: return "4";
234            case _8: return "8";
235            case _12: return "12";
236            default: return "?";
237          }
238        }
239        public String getSystem() {
240          switch (this) {
241            case _0: return "http://hl7.org/fhir/audit-event-outcome";
242            case _4: return "http://hl7.org/fhir/audit-event-outcome";
243            case _8: return "http://hl7.org/fhir/audit-event-outcome";
244            case _12: return "http://hl7.org/fhir/audit-event-outcome";
245            default: return "?";
246          }
247        }
248        public String getDefinition() {
249          switch (this) {
250            case _0: return "The operation completed successfully (whether with warnings or not).";
251            case _4: return "The action was not successful due to some kind of catered for error (often equivalent to an HTTP 400 response).";
252            case _8: return "The action was not successful due to some kind of unexpected error (often equivalent to an HTTP 500 response).";
253            case _12: return "An error of such magnitude occurred that the system is no longer available for use (i.e. the system died).";
254            default: return "?";
255          }
256        }
257        public String getDisplay() {
258          switch (this) {
259            case _0: return "Success";
260            case _4: return "Minor failure";
261            case _8: return "Serious failure";
262            case _12: return "Major failure";
263            default: return "?";
264          }
265        }
266    }
267
268  public static class AuditEventOutcomeEnumFactory implements EnumFactory<AuditEventOutcome> {
269    public AuditEventOutcome fromCode(String codeString) throws IllegalArgumentException {
270      if (codeString == null || "".equals(codeString))
271            if (codeString == null || "".equals(codeString))
272                return null;
273        if ("0".equals(codeString))
274          return AuditEventOutcome._0;
275        if ("4".equals(codeString))
276          return AuditEventOutcome._4;
277        if ("8".equals(codeString))
278          return AuditEventOutcome._8;
279        if ("12".equals(codeString))
280          return AuditEventOutcome._12;
281        throw new IllegalArgumentException("Unknown AuditEventOutcome code '"+codeString+"'");
282        }
283        public Enumeration<AuditEventOutcome> fromType(Base code) throws FHIRException {
284          if (code == null)
285            return null;
286          if (code.isEmpty())
287            return new Enumeration<AuditEventOutcome>(this);
288          String codeString = ((PrimitiveType) code).asStringValue();
289          if (codeString == null || "".equals(codeString))
290            return null;
291        if ("0".equals(codeString))
292          return new Enumeration<AuditEventOutcome>(this, AuditEventOutcome._0);
293        if ("4".equals(codeString))
294          return new Enumeration<AuditEventOutcome>(this, AuditEventOutcome._4);
295        if ("8".equals(codeString))
296          return new Enumeration<AuditEventOutcome>(this, AuditEventOutcome._8);
297        if ("12".equals(codeString))
298          return new Enumeration<AuditEventOutcome>(this, AuditEventOutcome._12);
299        throw new FHIRException("Unknown AuditEventOutcome code '"+codeString+"'");
300        }
301    public String toCode(AuditEventOutcome code) {
302      if (code == AuditEventOutcome._0)
303        return "0";
304      if (code == AuditEventOutcome._4)
305        return "4";
306      if (code == AuditEventOutcome._8)
307        return "8";
308      if (code == AuditEventOutcome._12)
309        return "12";
310      return "?";
311      }
312    public String toSystem(AuditEventOutcome code) {
313      return code.getSystem();
314      }
315    }
316
317    public enum AuditEventAgentNetworkType {
318        /**
319         * The machine name, including DNS name.
320         */
321        _1, 
322        /**
323         * The assigned Internet Protocol (IP) address.
324         */
325        _2, 
326        /**
327         * The assigned telephone number.
328         */
329        _3, 
330        /**
331         * The assigned email address.
332         */
333        _4, 
334        /**
335         * URI (User directory, HTTP-PUT, ftp, etc.).
336         */
337        _5, 
338        /**
339         * added to help the parsers with the generic types
340         */
341        NULL;
342        public static AuditEventAgentNetworkType fromCode(String codeString) throws FHIRException {
343            if (codeString == null || "".equals(codeString))
344                return null;
345        if ("1".equals(codeString))
346          return _1;
347        if ("2".equals(codeString))
348          return _2;
349        if ("3".equals(codeString))
350          return _3;
351        if ("4".equals(codeString))
352          return _4;
353        if ("5".equals(codeString))
354          return _5;
355        if (Configuration.isAcceptInvalidEnums())
356          return null;
357        else
358          throw new FHIRException("Unknown AuditEventAgentNetworkType code '"+codeString+"'");
359        }
360        public String toCode() {
361          switch (this) {
362            case _1: return "1";
363            case _2: return "2";
364            case _3: return "3";
365            case _4: return "4";
366            case _5: return "5";
367            default: return "?";
368          }
369        }
370        public String getSystem() {
371          switch (this) {
372            case _1: return "http://hl7.org/fhir/network-type";
373            case _2: return "http://hl7.org/fhir/network-type";
374            case _3: return "http://hl7.org/fhir/network-type";
375            case _4: return "http://hl7.org/fhir/network-type";
376            case _5: return "http://hl7.org/fhir/network-type";
377            default: return "?";
378          }
379        }
380        public String getDefinition() {
381          switch (this) {
382            case _1: return "The machine name, including DNS name.";
383            case _2: return "The assigned Internet Protocol (IP) address.";
384            case _3: return "The assigned telephone number.";
385            case _4: return "The assigned email address.";
386            case _5: return "URI (User directory, HTTP-PUT, ftp, etc.).";
387            default: return "?";
388          }
389        }
390        public String getDisplay() {
391          switch (this) {
392            case _1: return "Machine Name";
393            case _2: return "IP Address";
394            case _3: return "Telephone Number";
395            case _4: return "Email address";
396            case _5: return "URI";
397            default: return "?";
398          }
399        }
400    }
401
402  public static class AuditEventAgentNetworkTypeEnumFactory implements EnumFactory<AuditEventAgentNetworkType> {
403    public AuditEventAgentNetworkType fromCode(String codeString) throws IllegalArgumentException {
404      if (codeString == null || "".equals(codeString))
405            if (codeString == null || "".equals(codeString))
406                return null;
407        if ("1".equals(codeString))
408          return AuditEventAgentNetworkType._1;
409        if ("2".equals(codeString))
410          return AuditEventAgentNetworkType._2;
411        if ("3".equals(codeString))
412          return AuditEventAgentNetworkType._3;
413        if ("4".equals(codeString))
414          return AuditEventAgentNetworkType._4;
415        if ("5".equals(codeString))
416          return AuditEventAgentNetworkType._5;
417        throw new IllegalArgumentException("Unknown AuditEventAgentNetworkType code '"+codeString+"'");
418        }
419        public Enumeration<AuditEventAgentNetworkType> fromType(Base code) throws FHIRException {
420          if (code == null)
421            return null;
422          if (code.isEmpty())
423            return new Enumeration<AuditEventAgentNetworkType>(this);
424          String codeString = ((PrimitiveType) code).asStringValue();
425          if (codeString == null || "".equals(codeString))
426            return null;
427        if ("1".equals(codeString))
428          return new Enumeration<AuditEventAgentNetworkType>(this, AuditEventAgentNetworkType._1);
429        if ("2".equals(codeString))
430          return new Enumeration<AuditEventAgentNetworkType>(this, AuditEventAgentNetworkType._2);
431        if ("3".equals(codeString))
432          return new Enumeration<AuditEventAgentNetworkType>(this, AuditEventAgentNetworkType._3);
433        if ("4".equals(codeString))
434          return new Enumeration<AuditEventAgentNetworkType>(this, AuditEventAgentNetworkType._4);
435        if ("5".equals(codeString))
436          return new Enumeration<AuditEventAgentNetworkType>(this, AuditEventAgentNetworkType._5);
437        throw new FHIRException("Unknown AuditEventAgentNetworkType code '"+codeString+"'");
438        }
439    public String toCode(AuditEventAgentNetworkType code) {
440      if (code == AuditEventAgentNetworkType._1)
441        return "1";
442      if (code == AuditEventAgentNetworkType._2)
443        return "2";
444      if (code == AuditEventAgentNetworkType._3)
445        return "3";
446      if (code == AuditEventAgentNetworkType._4)
447        return "4";
448      if (code == AuditEventAgentNetworkType._5)
449        return "5";
450      return "?";
451      }
452    public String toSystem(AuditEventAgentNetworkType code) {
453      return code.getSystem();
454      }
455    }
456
457    @Block()
458    public static class AuditEventAgentComponent extends BackboneElement implements IBaseBackboneElement {
459        /**
460         * 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.
461         */
462        @Child(name = "role", type = {CodeableConcept.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
463        @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." )
464        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/security-role-type")
465        protected List<CodeableConcept> role;
466
467        /**
468         * Direct reference to a resource that identifies the agent.
469         */
470        @Child(name = "reference", type = {Practitioner.class, Organization.class, Device.class, Patient.class, RelatedPerson.class}, order=2, min=0, max=1, modifier=false, summary=true)
471        @Description(shortDefinition="Direct reference to resource", formalDefinition="Direct reference to a resource that identifies the agent." )
472        protected Reference reference;
473
474        /**
475         * The actual object that is the target of the reference (Direct reference to a resource that identifies the agent.)
476         */
477        protected Resource referenceTarget;
478
479        /**
480         * Unique identifier for the user actively participating in the event.
481         */
482        @Child(name = "userId", type = {Identifier.class}, order=3, min=0, max=1, modifier=false, summary=true)
483        @Description(shortDefinition="Unique identifier for the user", formalDefinition="Unique identifier for the user actively participating in the event." )
484        protected Identifier userId;
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 id e.g. authentication", 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-meaningful 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=false)
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://hl7.org/fhir/ValueSet/v3-PurposeOfUse")
547        protected List<CodeableConcept> purposeOfUse;
548
549        private static final long serialVersionUID = 1205071410L;
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 #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.)
568         */
569        public List<CodeableConcept> getRole() { 
570          if (this.role == null)
571            this.role = new ArrayList<CodeableConcept>();
572          return this.role;
573        }
574
575        /**
576         * @return Returns a reference to <code>this</code> for easy method chaining
577         */
578        public AuditEventAgentComponent setRole(List<CodeableConcept> theRole) { 
579          this.role = theRole;
580          return this;
581        }
582
583        public boolean hasRole() { 
584          if (this.role == null)
585            return false;
586          for (CodeableConcept item : this.role)
587            if (!item.isEmpty())
588              return true;
589          return false;
590        }
591
592        public CodeableConcept addRole() { //3
593          CodeableConcept t = new CodeableConcept();
594          if (this.role == null)
595            this.role = new ArrayList<CodeableConcept>();
596          this.role.add(t);
597          return t;
598        }
599
600        public AuditEventAgentComponent addRole(CodeableConcept t) { //3
601          if (t == null)
602            return this;
603          if (this.role == null)
604            this.role = new ArrayList<CodeableConcept>();
605          this.role.add(t);
606          return this;
607        }
608
609        /**
610         * @return The first repetition of repeating field {@link #role}, creating it if it does not already exist
611         */
612        public CodeableConcept getRoleFirstRep() { 
613          if (getRole().isEmpty()) {
614            addRole();
615          }
616          return getRole().get(0);
617        }
618
619        /**
620         * @return {@link #reference} (Direct reference to a resource that identifies the agent.)
621         */
622        public Reference getReference() { 
623          if (this.reference == null)
624            if (Configuration.errorOnAutoCreate())
625              throw new Error("Attempt to auto-create AuditEventAgentComponent.reference");
626            else if (Configuration.doAutoCreate())
627              this.reference = new Reference(); // cc
628          return this.reference;
629        }
630
631        public boolean hasReference() { 
632          return this.reference != null && !this.reference.isEmpty();
633        }
634
635        /**
636         * @param value {@link #reference} (Direct reference to a resource that identifies the agent.)
637         */
638        public AuditEventAgentComponent setReference(Reference value)  { 
639          this.reference = value;
640          return this;
641        }
642
643        /**
644         * @return {@link #reference} 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. (Direct reference to a resource that identifies the agent.)
645         */
646        public Resource getReferenceTarget() { 
647          return this.referenceTarget;
648        }
649
650        /**
651         * @param value {@link #reference} 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. (Direct reference to a resource that identifies the agent.)
652         */
653        public AuditEventAgentComponent setReferenceTarget(Resource value) { 
654          this.referenceTarget = value;
655          return this;
656        }
657
658        /**
659         * @return {@link #userId} (Unique identifier for the user actively participating in the event.)
660         */
661        public Identifier getUserId() { 
662          if (this.userId == null)
663            if (Configuration.errorOnAutoCreate())
664              throw new Error("Attempt to auto-create AuditEventAgentComponent.userId");
665            else if (Configuration.doAutoCreate())
666              this.userId = new Identifier(); // cc
667          return this.userId;
668        }
669
670        public boolean hasUserId() { 
671          return this.userId != null && !this.userId.isEmpty();
672        }
673
674        /**
675         * @param value {@link #userId} (Unique identifier for the user actively participating in the event.)
676         */
677        public AuditEventAgentComponent setUserId(Identifier value)  { 
678          this.userId = 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("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));
1034          children.add(new Property("reference", "Reference(Practitioner|Organization|Device|Patient|RelatedPerson)", "Direct reference to a resource that identifies the agent.", 0, 1, reference));
1035          children.add(new Property("userId", "Identifier", "Unique identifier for the user actively participating in the event.", 0, 1, userId));
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 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);
1050          case -925155509: /*reference*/  return new Property("reference", "Reference(Practitioner|Organization|Device|Patient|RelatedPerson)", "Direct reference to a resource that identifies the agent.", 0, 1, reference);
1051          case -836030906: /*userId*/  return new Property("userId", "Identifier", "Unique identifier for the user actively participating in the event.", 0, 1, userId);
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 3506294: /*role*/ return this.role == null ? new Base[0] : this.role.toArray(new Base[this.role.size()]); // CodeableConcept
1069        case -925155509: /*reference*/ return this.reference == null ? new Base[0] : new Base[] {this.reference}; // Reference
1070        case -836030906: /*userId*/ return this.userId == null ? new Base[0] : new Base[] {this.userId}; // Identifier
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 3506294: // role
1088          this.getRole().add(castToCodeableConcept(value)); // CodeableConcept
1089          return value;
1090        case -925155509: // reference
1091          this.reference = castToReference(value); // Reference
1092          return value;
1093        case -836030906: // userId
1094          this.userId = castToIdentifier(value); // Identifier
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("role")) {
1128          this.getRole().add(castToCodeableConcept(value));
1129        } else if (name.equals("reference")) {
1130          this.reference = castToReference(value); // Reference
1131        } else if (name.equals("userId")) {
1132          this.userId = castToIdentifier(value); // Identifier
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 3506294:  return addRole(); 
1158        case -925155509:  return getReference(); 
1159        case -836030906:  return getUserId(); 
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 3506294: /*role*/ return new String[] {"CodeableConcept"};
1177        case -925155509: /*reference*/ return new String[] {"Reference"};
1178        case -836030906: /*userId*/ return new String[] {"Identifier"};
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("role")) {
1195          return addRole();
1196        }
1197        else if (name.equals("reference")) {
1198          this.reference = new Reference();
1199          return this.reference;
1200        }
1201        else if (name.equals("userId")) {
1202          this.userId = new Identifier();
1203          return this.userId;
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        if (role != null) {
1240          dst.role = new ArrayList<CodeableConcept>();
1241          for (CodeableConcept i : role)
1242            dst.role.add(i.copy());
1243        };
1244        dst.reference = reference == null ? null : reference.copy();
1245        dst.userId = userId == null ? null : userId.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(role, o.role, true) && compareDeep(reference, o.reference, true) && compareDeep(userId, o.userId, 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(role, reference, userId
1291          , altId, 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 = "identifier", type = {Identifier.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 Identifier identifier;
1564
1565        /**
1566         * Code specifying the type of source where event originated.
1567         */
1568        @Child(name = "type", type = {Coding.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1569        @Description(shortDefinition="The type of source where event originated", formalDefinition="Code specifying the type of source where event originated." )
1570        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/audit-source-type")
1571        protected List<Coding> type;
1572
1573        private static final long serialVersionUID = -1562673890L;
1574
1575    /**
1576     * Constructor
1577     */
1578      public AuditEventSourceComponent() {
1579        super();
1580      }
1581
1582    /**
1583     * Constructor
1584     */
1585      public AuditEventSourceComponent(Identifier identifier) {
1586        super();
1587        this.identifier = identifier;
1588      }
1589
1590        /**
1591         * @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
1592         */
1593        public StringType getSiteElement() { 
1594          if (this.site == null)
1595            if (Configuration.errorOnAutoCreate())
1596              throw new Error("Attempt to auto-create AuditEventSourceComponent.site");
1597            else if (Configuration.doAutoCreate())
1598              this.site = new StringType(); // bb
1599          return this.site;
1600        }
1601
1602        public boolean hasSiteElement() { 
1603          return this.site != null && !this.site.isEmpty();
1604        }
1605
1606        public boolean hasSite() { 
1607          return this.site != null && !this.site.isEmpty();
1608        }
1609
1610        /**
1611         * @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
1612         */
1613        public AuditEventSourceComponent setSiteElement(StringType value) { 
1614          this.site = value;
1615          return this;
1616        }
1617
1618        /**
1619         * @return Logical source location within the healthcare enterprise network.  For example, a hospital or other provider location within a multi-entity provider group.
1620         */
1621        public String getSite() { 
1622          return this.site == null ? null : this.site.getValue();
1623        }
1624
1625        /**
1626         * @param value Logical source location within the healthcare enterprise network.  For example, a hospital or other provider location within a multi-entity provider group.
1627         */
1628        public AuditEventSourceComponent setSite(String value) { 
1629          if (Utilities.noString(value))
1630            this.site = null;
1631          else {
1632            if (this.site == null)
1633              this.site = new StringType();
1634            this.site.setValue(value);
1635          }
1636          return this;
1637        }
1638
1639        /**
1640         * @return {@link #identifier} (Identifier of the source where the event was detected.)
1641         */
1642        public Identifier getIdentifier() { 
1643          if (this.identifier == null)
1644            if (Configuration.errorOnAutoCreate())
1645              throw new Error("Attempt to auto-create AuditEventSourceComponent.identifier");
1646            else if (Configuration.doAutoCreate())
1647              this.identifier = new Identifier(); // cc
1648          return this.identifier;
1649        }
1650
1651        public boolean hasIdentifier() { 
1652          return this.identifier != null && !this.identifier.isEmpty();
1653        }
1654
1655        /**
1656         * @param value {@link #identifier} (Identifier of the source where the event was detected.)
1657         */
1658        public AuditEventSourceComponent setIdentifier(Identifier value)  { 
1659          this.identifier = value;
1660          return this;
1661        }
1662
1663        /**
1664         * @return {@link #type} (Code specifying the type of source where event originated.)
1665         */
1666        public List<Coding> getType() { 
1667          if (this.type == null)
1668            this.type = new ArrayList<Coding>();
1669          return this.type;
1670        }
1671
1672        /**
1673         * @return Returns a reference to <code>this</code> for easy method chaining
1674         */
1675        public AuditEventSourceComponent setType(List<Coding> theType) { 
1676          this.type = theType;
1677          return this;
1678        }
1679
1680        public boolean hasType() { 
1681          if (this.type == null)
1682            return false;
1683          for (Coding item : this.type)
1684            if (!item.isEmpty())
1685              return true;
1686          return false;
1687        }
1688
1689        public Coding addType() { //3
1690          Coding t = new Coding();
1691          if (this.type == null)
1692            this.type = new ArrayList<Coding>();
1693          this.type.add(t);
1694          return t;
1695        }
1696
1697        public AuditEventSourceComponent addType(Coding t) { //3
1698          if (t == null)
1699            return this;
1700          if (this.type == null)
1701            this.type = new ArrayList<Coding>();
1702          this.type.add(t);
1703          return this;
1704        }
1705
1706        /**
1707         * @return The first repetition of repeating field {@link #type}, creating it if it does not already exist
1708         */
1709        public Coding getTypeFirstRep() { 
1710          if (getType().isEmpty()) {
1711            addType();
1712          }
1713          return getType().get(0);
1714        }
1715
1716        protected void listChildren(List<Property> children) {
1717          super.listChildren(children);
1718          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));
1719          children.add(new Property("identifier", "Identifier", "Identifier of the source where the event was detected.", 0, 1, identifier));
1720          children.add(new Property("type", "Coding", "Code specifying the type of source where event originated.", 0, java.lang.Integer.MAX_VALUE, type));
1721        }
1722
1723        @Override
1724        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1725          switch (_hash) {
1726          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);
1727          case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Identifier of the source where the event was detected.", 0, 1, identifier);
1728          case 3575610: /*type*/  return new Property("type", "Coding", "Code specifying the type of source where event originated.", 0, java.lang.Integer.MAX_VALUE, type);
1729          default: return super.getNamedProperty(_hash, _name, _checkValid);
1730          }
1731
1732        }
1733
1734      @Override
1735      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1736        switch (hash) {
1737        case 3530567: /*site*/ return this.site == null ? new Base[0] : new Base[] {this.site}; // StringType
1738        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
1739        case 3575610: /*type*/ return this.type == null ? new Base[0] : this.type.toArray(new Base[this.type.size()]); // Coding
1740        default: return super.getProperty(hash, name, checkValid);
1741        }
1742
1743      }
1744
1745      @Override
1746      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1747        switch (hash) {
1748        case 3530567: // site
1749          this.site = castToString(value); // StringType
1750          return value;
1751        case -1618432855: // identifier
1752          this.identifier = castToIdentifier(value); // Identifier
1753          return value;
1754        case 3575610: // type
1755          this.getType().add(castToCoding(value)); // Coding
1756          return value;
1757        default: return super.setProperty(hash, name, value);
1758        }
1759
1760      }
1761
1762      @Override
1763      public Base setProperty(String name, Base value) throws FHIRException {
1764        if (name.equals("site")) {
1765          this.site = castToString(value); // StringType
1766        } else if (name.equals("identifier")) {
1767          this.identifier = castToIdentifier(value); // Identifier
1768        } else if (name.equals("type")) {
1769          this.getType().add(castToCoding(value));
1770        } else
1771          return super.setProperty(name, value);
1772        return value;
1773      }
1774
1775      @Override
1776      public Base makeProperty(int hash, String name) throws FHIRException {
1777        switch (hash) {
1778        case 3530567:  return getSiteElement();
1779        case -1618432855:  return getIdentifier(); 
1780        case 3575610:  return addType(); 
1781        default: return super.makeProperty(hash, name);
1782        }
1783
1784      }
1785
1786      @Override
1787      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1788        switch (hash) {
1789        case 3530567: /*site*/ return new String[] {"string"};
1790        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1791        case 3575610: /*type*/ return new String[] {"Coding"};
1792        default: return super.getTypesForProperty(hash, name);
1793        }
1794
1795      }
1796
1797      @Override
1798      public Base addChild(String name) throws FHIRException {
1799        if (name.equals("site")) {
1800          throw new FHIRException("Cannot call addChild on a primitive type AuditEvent.site");
1801        }
1802        else if (name.equals("identifier")) {
1803          this.identifier = new Identifier();
1804          return this.identifier;
1805        }
1806        else if (name.equals("type")) {
1807          return addType();
1808        }
1809        else
1810          return super.addChild(name);
1811      }
1812
1813      public AuditEventSourceComponent copy() {
1814        AuditEventSourceComponent dst = new AuditEventSourceComponent();
1815        copyValues(dst);
1816        dst.site = site == null ? null : site.copy();
1817        dst.identifier = identifier == null ? null : identifier.copy();
1818        if (type != null) {
1819          dst.type = new ArrayList<Coding>();
1820          for (Coding i : type)
1821            dst.type.add(i.copy());
1822        };
1823        return dst;
1824      }
1825
1826      @Override
1827      public boolean equalsDeep(Base other_) {
1828        if (!super.equalsDeep(other_))
1829          return false;
1830        if (!(other_ instanceof AuditEventSourceComponent))
1831          return false;
1832        AuditEventSourceComponent o = (AuditEventSourceComponent) other_;
1833        return compareDeep(site, o.site, true) && compareDeep(identifier, o.identifier, true) && compareDeep(type, o.type, true)
1834          ;
1835      }
1836
1837      @Override
1838      public boolean equalsShallow(Base other_) {
1839        if (!super.equalsShallow(other_))
1840          return false;
1841        if (!(other_ instanceof AuditEventSourceComponent))
1842          return false;
1843        AuditEventSourceComponent o = (AuditEventSourceComponent) other_;
1844        return compareValues(site, o.site, true);
1845      }
1846
1847      public boolean isEmpty() {
1848        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(site, identifier, type);
1849      }
1850
1851  public String fhirType() {
1852    return "AuditEvent.source";
1853
1854  }
1855
1856  }
1857
1858    @Block()
1859    public static class AuditEventEntityComponent extends BackboneElement implements IBaseBackboneElement {
1860        /**
1861         * Identifies a specific instance of the entity. The reference should always be version specific.
1862         */
1863        @Child(name = "identifier", type = {Identifier.class}, order=1, min=0, max=1, modifier=false, summary=true)
1864        @Description(shortDefinition="Specific instance of object", formalDefinition="Identifies a specific instance of the entity. The reference should always be version specific." )
1865        protected Identifier identifier;
1866
1867        /**
1868         * Identifies a specific instance of the entity. The reference should be version specific.
1869         */
1870        @Child(name = "reference", type = {Reference.class}, order=2, min=0, max=1, modifier=false, summary=true)
1871        @Description(shortDefinition="Specific instance of resource", formalDefinition="Identifies a specific instance of the entity. The reference should be version specific." )
1872        protected Reference reference;
1873
1874        /**
1875         * The actual object that is the target of the reference (Identifies a specific instance of the entity. The reference should be version specific.)
1876         */
1877        protected Resource referenceTarget;
1878
1879        /**
1880         * The type of the object that was involved in this audit event.
1881         */
1882        @Child(name = "type", type = {Coding.class}, order=3, min=0, max=1, modifier=false, summary=false)
1883        @Description(shortDefinition="Type of entity involved", formalDefinition="The type of the object that was involved in this audit event." )
1884        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/audit-entity-type")
1885        protected Coding type;
1886
1887        /**
1888         * Code representing the role the entity played in the event being audited.
1889         */
1890        @Child(name = "role", type = {Coding.class}, order=4, min=0, max=1, modifier=false, summary=false)
1891        @Description(shortDefinition="What role the entity played", formalDefinition="Code representing the role the entity played in the event being audited." )
1892        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/object-role")
1893        protected Coding role;
1894
1895        /**
1896         * Identifier for the data life-cycle stage for the entity.
1897         */
1898        @Child(name = "lifecycle", type = {Coding.class}, order=5, min=0, max=1, modifier=false, summary=false)
1899        @Description(shortDefinition="Life-cycle stage for the entity", formalDefinition="Identifier for the data life-cycle stage for the entity." )
1900        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/object-lifecycle-events")
1901        protected Coding lifecycle;
1902
1903        /**
1904         * Security labels for the identified entity.
1905         */
1906        @Child(name = "securityLabel", type = {Coding.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1907        @Description(shortDefinition="Security labels on the entity", formalDefinition="Security labels for the identified entity." )
1908        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/security-labels")
1909        protected List<Coding> securityLabel;
1910
1911        /**
1912         * A name of the entity in the audit event.
1913         */
1914        @Child(name = "name", type = {StringType.class}, order=7, min=0, max=1, modifier=false, summary=true)
1915        @Description(shortDefinition="Descriptor for entity", formalDefinition="A name of the entity in the audit event." )
1916        protected StringType name;
1917
1918        /**
1919         * Text that describes the entity in more detail.
1920         */
1921        @Child(name = "description", type = {StringType.class}, order=8, min=0, max=1, modifier=false, summary=false)
1922        @Description(shortDefinition="Descriptive text", formalDefinition="Text that describes the entity in more detail." )
1923        protected StringType description;
1924
1925        /**
1926         * The query parameters for a query-type entities.
1927         */
1928        @Child(name = "query", type = {Base64BinaryType.class}, order=9, min=0, max=1, modifier=false, summary=true)
1929        @Description(shortDefinition="Query parameters", formalDefinition="The query parameters for a query-type entities." )
1930        protected Base64BinaryType query;
1931
1932        /**
1933         * Tagged value pairs for conveying additional information about the entity.
1934         */
1935        @Child(name = "detail", type = {}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1936        @Description(shortDefinition="Additional Information about the entity", formalDefinition="Tagged value pairs for conveying additional information about the entity." )
1937        protected List<AuditEventEntityDetailComponent> detail;
1938
1939        private static final long serialVersionUID = -1393424632L;
1940
1941    /**
1942     * Constructor
1943     */
1944      public AuditEventEntityComponent() {
1945        super();
1946      }
1947
1948        /**
1949         * @return {@link #identifier} (Identifies a specific instance of the entity. The reference should always be version specific.)
1950         */
1951        public Identifier getIdentifier() { 
1952          if (this.identifier == null)
1953            if (Configuration.errorOnAutoCreate())
1954              throw new Error("Attempt to auto-create AuditEventEntityComponent.identifier");
1955            else if (Configuration.doAutoCreate())
1956              this.identifier = new Identifier(); // cc
1957          return this.identifier;
1958        }
1959
1960        public boolean hasIdentifier() { 
1961          return this.identifier != null && !this.identifier.isEmpty();
1962        }
1963
1964        /**
1965         * @param value {@link #identifier} (Identifies a specific instance of the entity. The reference should always be version specific.)
1966         */
1967        public AuditEventEntityComponent setIdentifier(Identifier value)  { 
1968          this.identifier = value;
1969          return this;
1970        }
1971
1972        /**
1973         * @return {@link #reference} (Identifies a specific instance of the entity. The reference should be version specific.)
1974         */
1975        public Reference getReference() { 
1976          if (this.reference == null)
1977            if (Configuration.errorOnAutoCreate())
1978              throw new Error("Attempt to auto-create AuditEventEntityComponent.reference");
1979            else if (Configuration.doAutoCreate())
1980              this.reference = new Reference(); // cc
1981          return this.reference;
1982        }
1983
1984        public boolean hasReference() { 
1985          return this.reference != null && !this.reference.isEmpty();
1986        }
1987
1988        /**
1989         * @param value {@link #reference} (Identifies a specific instance of the entity. The reference should be version specific.)
1990         */
1991        public AuditEventEntityComponent setReference(Reference value)  { 
1992          this.reference = value;
1993          return this;
1994        }
1995
1996        /**
1997         * @return {@link #reference} 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.)
1998         */
1999        public Resource getReferenceTarget() { 
2000          return this.referenceTarget;
2001        }
2002
2003        /**
2004         * @param value {@link #reference} 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.)
2005         */
2006        public AuditEventEntityComponent setReferenceTarget(Resource value) { 
2007          this.referenceTarget = value;
2008          return this;
2009        }
2010
2011        /**
2012         * @return {@link #type} (The type of the object that was involved in this audit event.)
2013         */
2014        public Coding getType() { 
2015          if (this.type == null)
2016            if (Configuration.errorOnAutoCreate())
2017              throw new Error("Attempt to auto-create AuditEventEntityComponent.type");
2018            else if (Configuration.doAutoCreate())
2019              this.type = new Coding(); // cc
2020          return this.type;
2021        }
2022
2023        public boolean hasType() { 
2024          return this.type != null && !this.type.isEmpty();
2025        }
2026
2027        /**
2028         * @param value {@link #type} (The type of the object that was involved in this audit event.)
2029         */
2030        public AuditEventEntityComponent setType(Coding value)  { 
2031          this.type = value;
2032          return this;
2033        }
2034
2035        /**
2036         * @return {@link #role} (Code representing the role the entity played in the event being audited.)
2037         */
2038        public Coding getRole() { 
2039          if (this.role == null)
2040            if (Configuration.errorOnAutoCreate())
2041              throw new Error("Attempt to auto-create AuditEventEntityComponent.role");
2042            else if (Configuration.doAutoCreate())
2043              this.role = new Coding(); // cc
2044          return this.role;
2045        }
2046
2047        public boolean hasRole() { 
2048          return this.role != null && !this.role.isEmpty();
2049        }
2050
2051        /**
2052         * @param value {@link #role} (Code representing the role the entity played in the event being audited.)
2053         */
2054        public AuditEventEntityComponent setRole(Coding value)  { 
2055          this.role = value;
2056          return this;
2057        }
2058
2059        /**
2060         * @return {@link #lifecycle} (Identifier for the data life-cycle stage for the entity.)
2061         */
2062        public Coding getLifecycle() { 
2063          if (this.lifecycle == null)
2064            if (Configuration.errorOnAutoCreate())
2065              throw new Error("Attempt to auto-create AuditEventEntityComponent.lifecycle");
2066            else if (Configuration.doAutoCreate())
2067              this.lifecycle = new Coding(); // cc
2068          return this.lifecycle;
2069        }
2070
2071        public boolean hasLifecycle() { 
2072          return this.lifecycle != null && !this.lifecycle.isEmpty();
2073        }
2074
2075        /**
2076         * @param value {@link #lifecycle} (Identifier for the data life-cycle stage for the entity.)
2077         */
2078        public AuditEventEntityComponent setLifecycle(Coding value)  { 
2079          this.lifecycle = value;
2080          return this;
2081        }
2082
2083        /**
2084         * @return {@link #securityLabel} (Security labels for the identified entity.)
2085         */
2086        public List<Coding> getSecurityLabel() { 
2087          if (this.securityLabel == null)
2088            this.securityLabel = new ArrayList<Coding>();
2089          return this.securityLabel;
2090        }
2091
2092        /**
2093         * @return Returns a reference to <code>this</code> for easy method chaining
2094         */
2095        public AuditEventEntityComponent setSecurityLabel(List<Coding> theSecurityLabel) { 
2096          this.securityLabel = theSecurityLabel;
2097          return this;
2098        }
2099
2100        public boolean hasSecurityLabel() { 
2101          if (this.securityLabel == null)
2102            return false;
2103          for (Coding item : this.securityLabel)
2104            if (!item.isEmpty())
2105              return true;
2106          return false;
2107        }
2108
2109        public Coding addSecurityLabel() { //3
2110          Coding t = new Coding();
2111          if (this.securityLabel == null)
2112            this.securityLabel = new ArrayList<Coding>();
2113          this.securityLabel.add(t);
2114          return t;
2115        }
2116
2117        public AuditEventEntityComponent addSecurityLabel(Coding t) { //3
2118          if (t == null)
2119            return this;
2120          if (this.securityLabel == null)
2121            this.securityLabel = new ArrayList<Coding>();
2122          this.securityLabel.add(t);
2123          return this;
2124        }
2125
2126        /**
2127         * @return The first repetition of repeating field {@link #securityLabel}, creating it if it does not already exist
2128         */
2129        public Coding getSecurityLabelFirstRep() { 
2130          if (getSecurityLabel().isEmpty()) {
2131            addSecurityLabel();
2132          }
2133          return getSecurityLabel().get(0);
2134        }
2135
2136        /**
2137         * @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
2138         */
2139        public StringType getNameElement() { 
2140          if (this.name == null)
2141            if (Configuration.errorOnAutoCreate())
2142              throw new Error("Attempt to auto-create AuditEventEntityComponent.name");
2143            else if (Configuration.doAutoCreate())
2144              this.name = new StringType(); // bb
2145          return this.name;
2146        }
2147
2148        public boolean hasNameElement() { 
2149          return this.name != null && !this.name.isEmpty();
2150        }
2151
2152        public boolean hasName() { 
2153          return this.name != null && !this.name.isEmpty();
2154        }
2155
2156        /**
2157         * @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
2158         */
2159        public AuditEventEntityComponent setNameElement(StringType value) { 
2160          this.name = value;
2161          return this;
2162        }
2163
2164        /**
2165         * @return A name of the entity in the audit event.
2166         */
2167        public String getName() { 
2168          return this.name == null ? null : this.name.getValue();
2169        }
2170
2171        /**
2172         * @param value A name of the entity in the audit event.
2173         */
2174        public AuditEventEntityComponent setName(String value) { 
2175          if (Utilities.noString(value))
2176            this.name = null;
2177          else {
2178            if (this.name == null)
2179              this.name = new StringType();
2180            this.name.setValue(value);
2181          }
2182          return this;
2183        }
2184
2185        /**
2186         * @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
2187         */
2188        public StringType getDescriptionElement() { 
2189          if (this.description == null)
2190            if (Configuration.errorOnAutoCreate())
2191              throw new Error("Attempt to auto-create AuditEventEntityComponent.description");
2192            else if (Configuration.doAutoCreate())
2193              this.description = new StringType(); // bb
2194          return this.description;
2195        }
2196
2197        public boolean hasDescriptionElement() { 
2198          return this.description != null && !this.description.isEmpty();
2199        }
2200
2201        public boolean hasDescription() { 
2202          return this.description != null && !this.description.isEmpty();
2203        }
2204
2205        /**
2206         * @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
2207         */
2208        public AuditEventEntityComponent setDescriptionElement(StringType value) { 
2209          this.description = value;
2210          return this;
2211        }
2212
2213        /**
2214         * @return Text that describes the entity in more detail.
2215         */
2216        public String getDescription() { 
2217          return this.description == null ? null : this.description.getValue();
2218        }
2219
2220        /**
2221         * @param value Text that describes the entity in more detail.
2222         */
2223        public AuditEventEntityComponent setDescription(String value) { 
2224          if (Utilities.noString(value))
2225            this.description = null;
2226          else {
2227            if (this.description == null)
2228              this.description = new StringType();
2229            this.description.setValue(value);
2230          }
2231          return this;
2232        }
2233
2234        /**
2235         * @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
2236         */
2237        public Base64BinaryType getQueryElement() { 
2238          if (this.query == null)
2239            if (Configuration.errorOnAutoCreate())
2240              throw new Error("Attempt to auto-create AuditEventEntityComponent.query");
2241            else if (Configuration.doAutoCreate())
2242              this.query = new Base64BinaryType(); // bb
2243          return this.query;
2244        }
2245
2246        public boolean hasQueryElement() { 
2247          return this.query != null && !this.query.isEmpty();
2248        }
2249
2250        public boolean hasQuery() { 
2251          return this.query != null && !this.query.isEmpty();
2252        }
2253
2254        /**
2255         * @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
2256         */
2257        public AuditEventEntityComponent setQueryElement(Base64BinaryType value) { 
2258          this.query = value;
2259          return this;
2260        }
2261
2262        /**
2263         * @return The query parameters for a query-type entities.
2264         */
2265        public byte[] getQuery() { 
2266          return this.query == null ? null : this.query.getValue();
2267        }
2268
2269        /**
2270         * @param value The query parameters for a query-type entities.
2271         */
2272        public AuditEventEntityComponent setQuery(byte[] value) { 
2273          if (value == null)
2274            this.query = null;
2275          else {
2276            if (this.query == null)
2277              this.query = new Base64BinaryType();
2278            this.query.setValue(value);
2279          }
2280          return this;
2281        }
2282
2283        /**
2284         * @return {@link #detail} (Tagged value pairs for conveying additional information about the entity.)
2285         */
2286        public List<AuditEventEntityDetailComponent> getDetail() { 
2287          if (this.detail == null)
2288            this.detail = new ArrayList<AuditEventEntityDetailComponent>();
2289          return this.detail;
2290        }
2291
2292        /**
2293         * @return Returns a reference to <code>this</code> for easy method chaining
2294         */
2295        public AuditEventEntityComponent setDetail(List<AuditEventEntityDetailComponent> theDetail) { 
2296          this.detail = theDetail;
2297          return this;
2298        }
2299
2300        public boolean hasDetail() { 
2301          if (this.detail == null)
2302            return false;
2303          for (AuditEventEntityDetailComponent item : this.detail)
2304            if (!item.isEmpty())
2305              return true;
2306          return false;
2307        }
2308
2309        public AuditEventEntityDetailComponent addDetail() { //3
2310          AuditEventEntityDetailComponent t = new AuditEventEntityDetailComponent();
2311          if (this.detail == null)
2312            this.detail = new ArrayList<AuditEventEntityDetailComponent>();
2313          this.detail.add(t);
2314          return t;
2315        }
2316
2317        public AuditEventEntityComponent addDetail(AuditEventEntityDetailComponent t) { //3
2318          if (t == null)
2319            return this;
2320          if (this.detail == null)
2321            this.detail = new ArrayList<AuditEventEntityDetailComponent>();
2322          this.detail.add(t);
2323          return this;
2324        }
2325
2326        /**
2327         * @return The first repetition of repeating field {@link #detail}, creating it if it does not already exist
2328         */
2329        public AuditEventEntityDetailComponent getDetailFirstRep() { 
2330          if (getDetail().isEmpty()) {
2331            addDetail();
2332          }
2333          return getDetail().get(0);
2334        }
2335
2336        protected void listChildren(List<Property> children) {
2337          super.listChildren(children);
2338          children.add(new Property("identifier", "Identifier", "Identifies a specific instance of the entity. The reference should always be version specific.", 0, 1, identifier));
2339          children.add(new Property("reference", "Reference(Any)", "Identifies a specific instance of the entity. The reference should be version specific.", 0, 1, reference));
2340          children.add(new Property("type", "Coding", "The type of the object that was involved in this audit event.", 0, 1, type));
2341          children.add(new Property("role", "Coding", "Code representing the role the entity played in the event being audited.", 0, 1, role));
2342          children.add(new Property("lifecycle", "Coding", "Identifier for the data life-cycle stage for the entity.", 0, 1, lifecycle));
2343          children.add(new Property("securityLabel", "Coding", "Security labels for the identified entity.", 0, java.lang.Integer.MAX_VALUE, securityLabel));
2344          children.add(new Property("name", "string", "A name of the entity in the audit event.", 0, 1, name));
2345          children.add(new Property("description", "string", "Text that describes the entity in more detail.", 0, 1, description));
2346          children.add(new Property("query", "base64Binary", "The query parameters for a query-type entities.", 0, 1, query));
2347          children.add(new Property("detail", "", "Tagged value pairs for conveying additional information about the entity.", 0, java.lang.Integer.MAX_VALUE, detail));
2348        }
2349
2350        @Override
2351        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2352          switch (_hash) {
2353          case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Identifies a specific instance of the entity. The reference should always be version specific.", 0, 1, identifier);
2354          case -925155509: /*reference*/  return new Property("reference", "Reference(Any)", "Identifies a specific instance of the entity. The reference should be version specific.", 0, 1, reference);
2355          case 3575610: /*type*/  return new Property("type", "Coding", "The type of the object that was involved in this audit event.", 0, 1, type);
2356          case 3506294: /*role*/  return new Property("role", "Coding", "Code representing the role the entity played in the event being audited.", 0, 1, role);
2357          case -302323862: /*lifecycle*/  return new Property("lifecycle", "Coding", "Identifier for the data life-cycle stage for the entity.", 0, 1, lifecycle);
2358          case -722296940: /*securityLabel*/  return new Property("securityLabel", "Coding", "Security labels for the identified entity.", 0, java.lang.Integer.MAX_VALUE, securityLabel);
2359          case 3373707: /*name*/  return new Property("name", "string", "A name of the entity in the audit event.", 0, 1, name);
2360          case -1724546052: /*description*/  return new Property("description", "string", "Text that describes the entity in more detail.", 0, 1, description);
2361          case 107944136: /*query*/  return new Property("query", "base64Binary", "The query parameters for a query-type entities.", 0, 1, query);
2362          case -1335224239: /*detail*/  return new Property("detail", "", "Tagged value pairs for conveying additional information about the entity.", 0, java.lang.Integer.MAX_VALUE, detail);
2363          default: return super.getNamedProperty(_hash, _name, _checkValid);
2364          }
2365
2366        }
2367
2368      @Override
2369      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2370        switch (hash) {
2371        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
2372        case -925155509: /*reference*/ return this.reference == null ? new Base[0] : new Base[] {this.reference}; // Reference
2373        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // Coding
2374        case 3506294: /*role*/ return this.role == null ? new Base[0] : new Base[] {this.role}; // Coding
2375        case -302323862: /*lifecycle*/ return this.lifecycle == null ? new Base[0] : new Base[] {this.lifecycle}; // Coding
2376        case -722296940: /*securityLabel*/ return this.securityLabel == null ? new Base[0] : this.securityLabel.toArray(new Base[this.securityLabel.size()]); // Coding
2377        case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // StringType
2378        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
2379        case 107944136: /*query*/ return this.query == null ? new Base[0] : new Base[] {this.query}; // Base64BinaryType
2380        case -1335224239: /*detail*/ return this.detail == null ? new Base[0] : this.detail.toArray(new Base[this.detail.size()]); // AuditEventEntityDetailComponent
2381        default: return super.getProperty(hash, name, checkValid);
2382        }
2383
2384      }
2385
2386      @Override
2387      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2388        switch (hash) {
2389        case -1618432855: // identifier
2390          this.identifier = castToIdentifier(value); // Identifier
2391          return value;
2392        case -925155509: // reference
2393          this.reference = castToReference(value); // Reference
2394          return value;
2395        case 3575610: // type
2396          this.type = castToCoding(value); // Coding
2397          return value;
2398        case 3506294: // role
2399          this.role = castToCoding(value); // Coding
2400          return value;
2401        case -302323862: // lifecycle
2402          this.lifecycle = castToCoding(value); // Coding
2403          return value;
2404        case -722296940: // securityLabel
2405          this.getSecurityLabel().add(castToCoding(value)); // Coding
2406          return value;
2407        case 3373707: // name
2408          this.name = castToString(value); // StringType
2409          return value;
2410        case -1724546052: // description
2411          this.description = castToString(value); // StringType
2412          return value;
2413        case 107944136: // query
2414          this.query = castToBase64Binary(value); // Base64BinaryType
2415          return value;
2416        case -1335224239: // detail
2417          this.getDetail().add((AuditEventEntityDetailComponent) value); // AuditEventEntityDetailComponent
2418          return value;
2419        default: return super.setProperty(hash, name, value);
2420        }
2421
2422      }
2423
2424      @Override
2425      public Base setProperty(String name, Base value) throws FHIRException {
2426        if (name.equals("identifier")) {
2427          this.identifier = castToIdentifier(value); // Identifier
2428        } else if (name.equals("reference")) {
2429          this.reference = castToReference(value); // Reference
2430        } else if (name.equals("type")) {
2431          this.type = castToCoding(value); // Coding
2432        } else if (name.equals("role")) {
2433          this.role = castToCoding(value); // Coding
2434        } else if (name.equals("lifecycle")) {
2435          this.lifecycle = castToCoding(value); // Coding
2436        } else if (name.equals("securityLabel")) {
2437          this.getSecurityLabel().add(castToCoding(value));
2438        } else if (name.equals("name")) {
2439          this.name = castToString(value); // StringType
2440        } else if (name.equals("description")) {
2441          this.description = castToString(value); // StringType
2442        } else if (name.equals("query")) {
2443          this.query = castToBase64Binary(value); // Base64BinaryType
2444        } else if (name.equals("detail")) {
2445          this.getDetail().add((AuditEventEntityDetailComponent) value);
2446        } else
2447          return super.setProperty(name, value);
2448        return value;
2449      }
2450
2451      @Override
2452      public Base makeProperty(int hash, String name) throws FHIRException {
2453        switch (hash) {
2454        case -1618432855:  return getIdentifier(); 
2455        case -925155509:  return getReference(); 
2456        case 3575610:  return getType(); 
2457        case 3506294:  return getRole(); 
2458        case -302323862:  return getLifecycle(); 
2459        case -722296940:  return addSecurityLabel(); 
2460        case 3373707:  return getNameElement();
2461        case -1724546052:  return getDescriptionElement();
2462        case 107944136:  return getQueryElement();
2463        case -1335224239:  return addDetail(); 
2464        default: return super.makeProperty(hash, name);
2465        }
2466
2467      }
2468
2469      @Override
2470      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2471        switch (hash) {
2472        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2473        case -925155509: /*reference*/ return new String[] {"Reference"};
2474        case 3575610: /*type*/ return new String[] {"Coding"};
2475        case 3506294: /*role*/ return new String[] {"Coding"};
2476        case -302323862: /*lifecycle*/ return new String[] {"Coding"};
2477        case -722296940: /*securityLabel*/ return new String[] {"Coding"};
2478        case 3373707: /*name*/ return new String[] {"string"};
2479        case -1724546052: /*description*/ return new String[] {"string"};
2480        case 107944136: /*query*/ return new String[] {"base64Binary"};
2481        case -1335224239: /*detail*/ return new String[] {};
2482        default: return super.getTypesForProperty(hash, name);
2483        }
2484
2485      }
2486
2487      @Override
2488      public Base addChild(String name) throws FHIRException {
2489        if (name.equals("identifier")) {
2490          this.identifier = new Identifier();
2491          return this.identifier;
2492        }
2493        else if (name.equals("reference")) {
2494          this.reference = new Reference();
2495          return this.reference;
2496        }
2497        else if (name.equals("type")) {
2498          this.type = new Coding();
2499          return this.type;
2500        }
2501        else if (name.equals("role")) {
2502          this.role = new Coding();
2503          return this.role;
2504        }
2505        else if (name.equals("lifecycle")) {
2506          this.lifecycle = new Coding();
2507          return this.lifecycle;
2508        }
2509        else if (name.equals("securityLabel")) {
2510          return addSecurityLabel();
2511        }
2512        else if (name.equals("name")) {
2513          throw new FHIRException("Cannot call addChild on a primitive type AuditEvent.name");
2514        }
2515        else if (name.equals("description")) {
2516          throw new FHIRException("Cannot call addChild on a primitive type AuditEvent.description");
2517        }
2518        else if (name.equals("query")) {
2519          throw new FHIRException("Cannot call addChild on a primitive type AuditEvent.query");
2520        }
2521        else if (name.equals("detail")) {
2522          return addDetail();
2523        }
2524        else
2525          return super.addChild(name);
2526      }
2527
2528      public AuditEventEntityComponent copy() {
2529        AuditEventEntityComponent dst = new AuditEventEntityComponent();
2530        copyValues(dst);
2531        dst.identifier = identifier == null ? null : identifier.copy();
2532        dst.reference = reference == null ? null : reference.copy();
2533        dst.type = type == null ? null : type.copy();
2534        dst.role = role == null ? null : role.copy();
2535        dst.lifecycle = lifecycle == null ? null : lifecycle.copy();
2536        if (securityLabel != null) {
2537          dst.securityLabel = new ArrayList<Coding>();
2538          for (Coding i : securityLabel)
2539            dst.securityLabel.add(i.copy());
2540        };
2541        dst.name = name == null ? null : name.copy();
2542        dst.description = description == null ? null : description.copy();
2543        dst.query = query == null ? null : query.copy();
2544        if (detail != null) {
2545          dst.detail = new ArrayList<AuditEventEntityDetailComponent>();
2546          for (AuditEventEntityDetailComponent i : detail)
2547            dst.detail.add(i.copy());
2548        };
2549        return dst;
2550      }
2551
2552      @Override
2553      public boolean equalsDeep(Base other_) {
2554        if (!super.equalsDeep(other_))
2555          return false;
2556        if (!(other_ instanceof AuditEventEntityComponent))
2557          return false;
2558        AuditEventEntityComponent o = (AuditEventEntityComponent) other_;
2559        return compareDeep(identifier, o.identifier, true) && compareDeep(reference, o.reference, true)
2560           && compareDeep(type, o.type, true) && compareDeep(role, o.role, true) && compareDeep(lifecycle, o.lifecycle, true)
2561           && compareDeep(securityLabel, o.securityLabel, true) && compareDeep(name, o.name, true) && compareDeep(description, o.description, true)
2562           && compareDeep(query, o.query, true) && compareDeep(detail, o.detail, true);
2563      }
2564
2565      @Override
2566      public boolean equalsShallow(Base other_) {
2567        if (!super.equalsShallow(other_))
2568          return false;
2569        if (!(other_ instanceof AuditEventEntityComponent))
2570          return false;
2571        AuditEventEntityComponent o = (AuditEventEntityComponent) other_;
2572        return compareValues(name, o.name, true) && compareValues(description, o.description, true) && compareValues(query, o.query, true)
2573          ;
2574      }
2575
2576      public boolean isEmpty() {
2577        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, reference, type
2578          , role, lifecycle, securityLabel, name, description, query, detail);
2579      }
2580
2581  public String fhirType() {
2582    return "AuditEvent.entity";
2583
2584  }
2585
2586  }
2587
2588    @Block()
2589    public static class AuditEventEntityDetailComponent extends BackboneElement implements IBaseBackboneElement {
2590        /**
2591         * The type of extra detail provided in the value.
2592         */
2593        @Child(name = "type", type = {StringType.class}, order=1, min=1, max=1, modifier=false, summary=false)
2594        @Description(shortDefinition="Name of the property", formalDefinition="The type of extra detail provided in the value." )
2595        protected StringType type;
2596
2597        /**
2598         * The details, base64 encoded. Used to carry bulk information.
2599         */
2600        @Child(name = "value", type = {Base64BinaryType.class}, order=2, min=1, max=1, modifier=false, summary=false)
2601        @Description(shortDefinition="Property value", formalDefinition="The details, base64 encoded. Used to carry bulk information." )
2602        protected Base64BinaryType value;
2603
2604        private static final long serialVersionUID = 11139504L;
2605
2606    /**
2607     * Constructor
2608     */
2609      public AuditEventEntityDetailComponent() {
2610        super();
2611      }
2612
2613    /**
2614     * Constructor
2615     */
2616      public AuditEventEntityDetailComponent(StringType type, Base64BinaryType value) {
2617        super();
2618        this.type = type;
2619        this.value = value;
2620      }
2621
2622        /**
2623         * @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
2624         */
2625        public StringType getTypeElement() { 
2626          if (this.type == null)
2627            if (Configuration.errorOnAutoCreate())
2628              throw new Error("Attempt to auto-create AuditEventEntityDetailComponent.type");
2629            else if (Configuration.doAutoCreate())
2630              this.type = new StringType(); // bb
2631          return this.type;
2632        }
2633
2634        public boolean hasTypeElement() { 
2635          return this.type != null && !this.type.isEmpty();
2636        }
2637
2638        public boolean hasType() { 
2639          return this.type != null && !this.type.isEmpty();
2640        }
2641
2642        /**
2643         * @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
2644         */
2645        public AuditEventEntityDetailComponent setTypeElement(StringType value) { 
2646          this.type = value;
2647          return this;
2648        }
2649
2650        /**
2651         * @return The type of extra detail provided in the value.
2652         */
2653        public String getType() { 
2654          return this.type == null ? null : this.type.getValue();
2655        }
2656
2657        /**
2658         * @param value The type of extra detail provided in the value.
2659         */
2660        public AuditEventEntityDetailComponent setType(String value) { 
2661            if (this.type == null)
2662              this.type = new StringType();
2663            this.type.setValue(value);
2664          return this;
2665        }
2666
2667        /**
2668         * @return {@link #value} (The details, base64 encoded. Used to carry bulk information.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
2669         */
2670        public Base64BinaryType getValueElement() { 
2671          if (this.value == null)
2672            if (Configuration.errorOnAutoCreate())
2673              throw new Error("Attempt to auto-create AuditEventEntityDetailComponent.value");
2674            else if (Configuration.doAutoCreate())
2675              this.value = new Base64BinaryType(); // bb
2676          return this.value;
2677        }
2678
2679        public boolean hasValueElement() { 
2680          return this.value != null && !this.value.isEmpty();
2681        }
2682
2683        public boolean hasValue() { 
2684          return this.value != null && !this.value.isEmpty();
2685        }
2686
2687        /**
2688         * @param value {@link #value} (The details, base64 encoded. Used to carry bulk information.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
2689         */
2690        public AuditEventEntityDetailComponent setValueElement(Base64BinaryType value) { 
2691          this.value = value;
2692          return this;
2693        }
2694
2695        /**
2696         * @return The details, base64 encoded. Used to carry bulk information.
2697         */
2698        public byte[] getValue() { 
2699          return this.value == null ? null : this.value.getValue();
2700        }
2701
2702        /**
2703         * @param value The details, base64 encoded. Used to carry bulk information.
2704         */
2705        public AuditEventEntityDetailComponent setValue(byte[] value) { 
2706            if (this.value == null)
2707              this.value = new Base64BinaryType();
2708            this.value.setValue(value);
2709          return this;
2710        }
2711
2712        protected void listChildren(List<Property> children) {
2713          super.listChildren(children);
2714          children.add(new Property("type", "string", "The type of extra detail provided in the value.", 0, 1, type));
2715          children.add(new Property("value", "base64Binary", "The details, base64 encoded. Used to carry bulk information.", 0, 1, value));
2716        }
2717
2718        @Override
2719        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2720          switch (_hash) {
2721          case 3575610: /*type*/  return new Property("type", "string", "The type of extra detail provided in the value.", 0, 1, type);
2722          case 111972721: /*value*/  return new Property("value", "base64Binary", "The details, base64 encoded. Used to carry bulk information.", 0, 1, value);
2723          default: return super.getNamedProperty(_hash, _name, _checkValid);
2724          }
2725
2726        }
2727
2728      @Override
2729      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2730        switch (hash) {
2731        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // StringType
2732        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // Base64BinaryType
2733        default: return super.getProperty(hash, name, checkValid);
2734        }
2735
2736      }
2737
2738      @Override
2739      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2740        switch (hash) {
2741        case 3575610: // type
2742          this.type = castToString(value); // StringType
2743          return value;
2744        case 111972721: // value
2745          this.value = castToBase64Binary(value); // Base64BinaryType
2746          return value;
2747        default: return super.setProperty(hash, name, value);
2748        }
2749
2750      }
2751
2752      @Override
2753      public Base setProperty(String name, Base value) throws FHIRException {
2754        if (name.equals("type")) {
2755          this.type = castToString(value); // StringType
2756        } else if (name.equals("value")) {
2757          this.value = castToBase64Binary(value); // Base64BinaryType
2758        } else
2759          return super.setProperty(name, value);
2760        return value;
2761      }
2762
2763      @Override
2764      public Base makeProperty(int hash, String name) throws FHIRException {
2765        switch (hash) {
2766        case 3575610:  return getTypeElement();
2767        case 111972721:  return getValueElement();
2768        default: return super.makeProperty(hash, name);
2769        }
2770
2771      }
2772
2773      @Override
2774      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2775        switch (hash) {
2776        case 3575610: /*type*/ return new String[] {"string"};
2777        case 111972721: /*value*/ return new String[] {"base64Binary"};
2778        default: return super.getTypesForProperty(hash, name);
2779        }
2780
2781      }
2782
2783      @Override
2784      public Base addChild(String name) throws FHIRException {
2785        if (name.equals("type")) {
2786          throw new FHIRException("Cannot call addChild on a primitive type AuditEvent.type");
2787        }
2788        else if (name.equals("value")) {
2789          throw new FHIRException("Cannot call addChild on a primitive type AuditEvent.value");
2790        }
2791        else
2792          return super.addChild(name);
2793      }
2794
2795      public AuditEventEntityDetailComponent copy() {
2796        AuditEventEntityDetailComponent dst = new AuditEventEntityDetailComponent();
2797        copyValues(dst);
2798        dst.type = type == null ? null : type.copy();
2799        dst.value = value == null ? null : value.copy();
2800        return dst;
2801      }
2802
2803      @Override
2804      public boolean equalsDeep(Base other_) {
2805        if (!super.equalsDeep(other_))
2806          return false;
2807        if (!(other_ instanceof AuditEventEntityDetailComponent))
2808          return false;
2809        AuditEventEntityDetailComponent o = (AuditEventEntityDetailComponent) other_;
2810        return compareDeep(type, o.type, true) && compareDeep(value, o.value, true);
2811      }
2812
2813      @Override
2814      public boolean equalsShallow(Base other_) {
2815        if (!super.equalsShallow(other_))
2816          return false;
2817        if (!(other_ instanceof AuditEventEntityDetailComponent))
2818          return false;
2819        AuditEventEntityDetailComponent o = (AuditEventEntityDetailComponent) other_;
2820        return compareValues(type, o.type, true) && compareValues(value, o.value, true);
2821      }
2822
2823      public boolean isEmpty() {
2824        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, value);
2825      }
2826
2827  public String fhirType() {
2828    return "AuditEvent.entity.detail";
2829
2830  }
2831
2832  }
2833
2834    /**
2835     * 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.
2836     */
2837    @Child(name = "type", type = {Coding.class}, order=0, min=1, max=1, modifier=false, summary=true)
2838    @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." )
2839    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/audit-event-type")
2840    protected Coding type;
2841
2842    /**
2843     * Identifier for the category of event.
2844     */
2845    @Child(name = "subtype", type = {Coding.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2846    @Description(shortDefinition="More specific type/id for the event", formalDefinition="Identifier for the category of event." )
2847    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/audit-event-sub-type")
2848    protected List<Coding> subtype;
2849
2850    /**
2851     * Indicator for type of action performed during the event that generated the audit.
2852     */
2853    @Child(name = "action", type = {CodeType.class}, order=2, min=0, max=1, modifier=false, summary=true)
2854    @Description(shortDefinition="Type of action performed during the event", formalDefinition="Indicator for type of action performed during the event that generated the audit." )
2855    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/audit-event-action")
2856    protected Enumeration<AuditEventAction> action;
2857
2858    /**
2859     * The time when the event occurred on the source.
2860     */
2861    @Child(name = "recorded", type = {InstantType.class}, order=3, min=1, max=1, modifier=false, summary=true)
2862    @Description(shortDefinition="Time when the event occurred on source", formalDefinition="The time when the event occurred on the source." )
2863    protected InstantType recorded;
2864
2865    /**
2866     * Indicates whether the event succeeded or failed.
2867     */
2868    @Child(name = "outcome", type = {CodeType.class}, order=4, min=0, max=1, modifier=false, summary=true)
2869    @Description(shortDefinition="Whether the event succeeded or failed", formalDefinition="Indicates whether the event succeeded or failed." )
2870    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/audit-event-outcome")
2871    protected Enumeration<AuditEventOutcome> outcome;
2872
2873    /**
2874     * A free text description of the outcome of the event.
2875     */
2876    @Child(name = "outcomeDesc", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=true)
2877    @Description(shortDefinition="Description of the event outcome", formalDefinition="A free text description of the outcome of the event." )
2878    protected StringType outcomeDesc;
2879
2880    /**
2881     * The purposeOfUse (reason) that was used during the event being recorded.
2882     */
2883    @Child(name = "purposeOfEvent", type = {CodeableConcept.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2884    @Description(shortDefinition="The purposeOfUse of the event", formalDefinition="The purposeOfUse (reason) that was used during the event being recorded." )
2885    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/v3-PurposeOfUse")
2886    protected List<CodeableConcept> purposeOfEvent;
2887
2888    /**
2889     * An actor taking an active role in the event or activity that is logged.
2890     */
2891    @Child(name = "agent", type = {}, order=7, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2892    @Description(shortDefinition="Actor involved in the event", formalDefinition="An actor taking an active role in the event or activity that is logged." )
2893    protected List<AuditEventAgentComponent> agent;
2894
2895    /**
2896     * The system that is reporting the event.
2897     */
2898    @Child(name = "source", type = {}, order=8, min=1, max=1, modifier=false, summary=false)
2899    @Description(shortDefinition="Audit Event Reporter", formalDefinition="The system that is reporting the event." )
2900    protected AuditEventSourceComponent source;
2901
2902    /**
2903     * Specific instances of data or objects that have been accessed.
2904     */
2905    @Child(name = "entity", type = {}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2906    @Description(shortDefinition="Data or objects used", formalDefinition="Specific instances of data or objects that have been accessed." )
2907    protected List<AuditEventEntityComponent> entity;
2908
2909    private static final long serialVersionUID = 2102955199L;
2910
2911  /**
2912   * Constructor
2913   */
2914    public AuditEvent() {
2915      super();
2916    }
2917
2918  /**
2919   * Constructor
2920   */
2921    public AuditEvent(Coding type, InstantType recorded, AuditEventSourceComponent source) {
2922      super();
2923      this.type = type;
2924      this.recorded = recorded;
2925      this.source = source;
2926    }
2927
2928    /**
2929     * @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.)
2930     */
2931    public Coding getType() { 
2932      if (this.type == null)
2933        if (Configuration.errorOnAutoCreate())
2934          throw new Error("Attempt to auto-create AuditEvent.type");
2935        else if (Configuration.doAutoCreate())
2936          this.type = new Coding(); // cc
2937      return this.type;
2938    }
2939
2940    public boolean hasType() { 
2941      return this.type != null && !this.type.isEmpty();
2942    }
2943
2944    /**
2945     * @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.)
2946     */
2947    public AuditEvent setType(Coding value)  { 
2948      this.type = value;
2949      return this;
2950    }
2951
2952    /**
2953     * @return {@link #subtype} (Identifier for the category of event.)
2954     */
2955    public List<Coding> getSubtype() { 
2956      if (this.subtype == null)
2957        this.subtype = new ArrayList<Coding>();
2958      return this.subtype;
2959    }
2960
2961    /**
2962     * @return Returns a reference to <code>this</code> for easy method chaining
2963     */
2964    public AuditEvent setSubtype(List<Coding> theSubtype) { 
2965      this.subtype = theSubtype;
2966      return this;
2967    }
2968
2969    public boolean hasSubtype() { 
2970      if (this.subtype == null)
2971        return false;
2972      for (Coding item : this.subtype)
2973        if (!item.isEmpty())
2974          return true;
2975      return false;
2976    }
2977
2978    public Coding addSubtype() { //3
2979      Coding t = new Coding();
2980      if (this.subtype == null)
2981        this.subtype = new ArrayList<Coding>();
2982      this.subtype.add(t);
2983      return t;
2984    }
2985
2986    public AuditEvent addSubtype(Coding t) { //3
2987      if (t == null)
2988        return this;
2989      if (this.subtype == null)
2990        this.subtype = new ArrayList<Coding>();
2991      this.subtype.add(t);
2992      return this;
2993    }
2994
2995    /**
2996     * @return The first repetition of repeating field {@link #subtype}, creating it if it does not already exist
2997     */
2998    public Coding getSubtypeFirstRep() { 
2999      if (getSubtype().isEmpty()) {
3000        addSubtype();
3001      }
3002      return getSubtype().get(0);
3003    }
3004
3005    /**
3006     * @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
3007     */
3008    public Enumeration<AuditEventAction> getActionElement() { 
3009      if (this.action == null)
3010        if (Configuration.errorOnAutoCreate())
3011          throw new Error("Attempt to auto-create AuditEvent.action");
3012        else if (Configuration.doAutoCreate())
3013          this.action = new Enumeration<AuditEventAction>(new AuditEventActionEnumFactory()); // bb
3014      return this.action;
3015    }
3016
3017    public boolean hasActionElement() { 
3018      return this.action != null && !this.action.isEmpty();
3019    }
3020
3021    public boolean hasAction() { 
3022      return this.action != null && !this.action.isEmpty();
3023    }
3024
3025    /**
3026     * @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
3027     */
3028    public AuditEvent setActionElement(Enumeration<AuditEventAction> value) { 
3029      this.action = value;
3030      return this;
3031    }
3032
3033    /**
3034     * @return Indicator for type of action performed during the event that generated the audit.
3035     */
3036    public AuditEventAction getAction() { 
3037      return this.action == null ? null : this.action.getValue();
3038    }
3039
3040    /**
3041     * @param value Indicator for type of action performed during the event that generated the audit.
3042     */
3043    public AuditEvent setAction(AuditEventAction value) { 
3044      if (value == null)
3045        this.action = null;
3046      else {
3047        if (this.action == null)
3048          this.action = new Enumeration<AuditEventAction>(new AuditEventActionEnumFactory());
3049        this.action.setValue(value);
3050      }
3051      return this;
3052    }
3053
3054    /**
3055     * @return {@link #recorded} (The time when the event occurred on the source.). This is the underlying object with id, value and extensions. The accessor "getRecorded" gives direct access to the value
3056     */
3057    public InstantType getRecordedElement() { 
3058      if (this.recorded == null)
3059        if (Configuration.errorOnAutoCreate())
3060          throw new Error("Attempt to auto-create AuditEvent.recorded");
3061        else if (Configuration.doAutoCreate())
3062          this.recorded = new InstantType(); // bb
3063      return this.recorded;
3064    }
3065
3066    public boolean hasRecordedElement() { 
3067      return this.recorded != null && !this.recorded.isEmpty();
3068    }
3069
3070    public boolean hasRecorded() { 
3071      return this.recorded != null && !this.recorded.isEmpty();
3072    }
3073
3074    /**
3075     * @param value {@link #recorded} (The time when the event occurred on the source.). This is the underlying object with id, value and extensions. The accessor "getRecorded" gives direct access to the value
3076     */
3077    public AuditEvent setRecordedElement(InstantType value) { 
3078      this.recorded = value;
3079      return this;
3080    }
3081
3082    /**
3083     * @return The time when the event occurred on the source.
3084     */
3085    public Date getRecorded() { 
3086      return this.recorded == null ? null : this.recorded.getValue();
3087    }
3088
3089    /**
3090     * @param value The time when the event occurred on the source.
3091     */
3092    public AuditEvent setRecorded(Date value) { 
3093        if (this.recorded == null)
3094          this.recorded = new InstantType();
3095        this.recorded.setValue(value);
3096      return this;
3097    }
3098
3099    /**
3100     * @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
3101     */
3102    public Enumeration<AuditEventOutcome> getOutcomeElement() { 
3103      if (this.outcome == null)
3104        if (Configuration.errorOnAutoCreate())
3105          throw new Error("Attempt to auto-create AuditEvent.outcome");
3106        else if (Configuration.doAutoCreate())
3107          this.outcome = new Enumeration<AuditEventOutcome>(new AuditEventOutcomeEnumFactory()); // bb
3108      return this.outcome;
3109    }
3110
3111    public boolean hasOutcomeElement() { 
3112      return this.outcome != null && !this.outcome.isEmpty();
3113    }
3114
3115    public boolean hasOutcome() { 
3116      return this.outcome != null && !this.outcome.isEmpty();
3117    }
3118
3119    /**
3120     * @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
3121     */
3122    public AuditEvent setOutcomeElement(Enumeration<AuditEventOutcome> value) { 
3123      this.outcome = value;
3124      return this;
3125    }
3126
3127    /**
3128     * @return Indicates whether the event succeeded or failed.
3129     */
3130    public AuditEventOutcome getOutcome() { 
3131      return this.outcome == null ? null : this.outcome.getValue();
3132    }
3133
3134    /**
3135     * @param value Indicates whether the event succeeded or failed.
3136     */
3137    public AuditEvent setOutcome(AuditEventOutcome value) { 
3138      if (value == null)
3139        this.outcome = null;
3140      else {
3141        if (this.outcome == null)
3142          this.outcome = new Enumeration<AuditEventOutcome>(new AuditEventOutcomeEnumFactory());
3143        this.outcome.setValue(value);
3144      }
3145      return this;
3146    }
3147
3148    /**
3149     * @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
3150     */
3151    public StringType getOutcomeDescElement() { 
3152      if (this.outcomeDesc == null)
3153        if (Configuration.errorOnAutoCreate())
3154          throw new Error("Attempt to auto-create AuditEvent.outcomeDesc");
3155        else if (Configuration.doAutoCreate())
3156          this.outcomeDesc = new StringType(); // bb
3157      return this.outcomeDesc;
3158    }
3159
3160    public boolean hasOutcomeDescElement() { 
3161      return this.outcomeDesc != null && !this.outcomeDesc.isEmpty();
3162    }
3163
3164    public boolean hasOutcomeDesc() { 
3165      return this.outcomeDesc != null && !this.outcomeDesc.isEmpty();
3166    }
3167
3168    /**
3169     * @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
3170     */
3171    public AuditEvent setOutcomeDescElement(StringType value) { 
3172      this.outcomeDesc = value;
3173      return this;
3174    }
3175
3176    /**
3177     * @return A free text description of the outcome of the event.
3178     */
3179    public String getOutcomeDesc() { 
3180      return this.outcomeDesc == null ? null : this.outcomeDesc.getValue();
3181    }
3182
3183    /**
3184     * @param value A free text description of the outcome of the event.
3185     */
3186    public AuditEvent setOutcomeDesc(String value) { 
3187      if (Utilities.noString(value))
3188        this.outcomeDesc = null;
3189      else {
3190        if (this.outcomeDesc == null)
3191          this.outcomeDesc = new StringType();
3192        this.outcomeDesc.setValue(value);
3193      }
3194      return this;
3195    }
3196
3197    /**
3198     * @return {@link #purposeOfEvent} (The purposeOfUse (reason) that was used during the event being recorded.)
3199     */
3200    public List<CodeableConcept> getPurposeOfEvent() { 
3201      if (this.purposeOfEvent == null)
3202        this.purposeOfEvent = new ArrayList<CodeableConcept>();
3203      return this.purposeOfEvent;
3204    }
3205
3206    /**
3207     * @return Returns a reference to <code>this</code> for easy method chaining
3208     */
3209    public AuditEvent setPurposeOfEvent(List<CodeableConcept> thePurposeOfEvent) { 
3210      this.purposeOfEvent = thePurposeOfEvent;
3211      return this;
3212    }
3213
3214    public boolean hasPurposeOfEvent() { 
3215      if (this.purposeOfEvent == null)
3216        return false;
3217      for (CodeableConcept item : this.purposeOfEvent)
3218        if (!item.isEmpty())
3219          return true;
3220      return false;
3221    }
3222
3223    public CodeableConcept addPurposeOfEvent() { //3
3224      CodeableConcept t = new CodeableConcept();
3225      if (this.purposeOfEvent == null)
3226        this.purposeOfEvent = new ArrayList<CodeableConcept>();
3227      this.purposeOfEvent.add(t);
3228      return t;
3229    }
3230
3231    public AuditEvent addPurposeOfEvent(CodeableConcept t) { //3
3232      if (t == null)
3233        return this;
3234      if (this.purposeOfEvent == null)
3235        this.purposeOfEvent = new ArrayList<CodeableConcept>();
3236      this.purposeOfEvent.add(t);
3237      return this;
3238    }
3239
3240    /**
3241     * @return The first repetition of repeating field {@link #purposeOfEvent}, creating it if it does not already exist
3242     */
3243    public CodeableConcept getPurposeOfEventFirstRep() { 
3244      if (getPurposeOfEvent().isEmpty()) {
3245        addPurposeOfEvent();
3246      }
3247      return getPurposeOfEvent().get(0);
3248    }
3249
3250    /**
3251     * @return {@link #agent} (An actor taking an active role in the event or activity that is logged.)
3252     */
3253    public List<AuditEventAgentComponent> getAgent() { 
3254      if (this.agent == null)
3255        this.agent = new ArrayList<AuditEventAgentComponent>();
3256      return this.agent;
3257    }
3258
3259    /**
3260     * @return Returns a reference to <code>this</code> for easy method chaining
3261     */
3262    public AuditEvent setAgent(List<AuditEventAgentComponent> theAgent) { 
3263      this.agent = theAgent;
3264      return this;
3265    }
3266
3267    public boolean hasAgent() { 
3268      if (this.agent == null)
3269        return false;
3270      for (AuditEventAgentComponent item : this.agent)
3271        if (!item.isEmpty())
3272          return true;
3273      return false;
3274    }
3275
3276    public AuditEventAgentComponent addAgent() { //3
3277      AuditEventAgentComponent t = new AuditEventAgentComponent();
3278      if (this.agent == null)
3279        this.agent = new ArrayList<AuditEventAgentComponent>();
3280      this.agent.add(t);
3281      return t;
3282    }
3283
3284    public AuditEvent addAgent(AuditEventAgentComponent t) { //3
3285      if (t == null)
3286        return this;
3287      if (this.agent == null)
3288        this.agent = new ArrayList<AuditEventAgentComponent>();
3289      this.agent.add(t);
3290      return this;
3291    }
3292
3293    /**
3294     * @return The first repetition of repeating field {@link #agent}, creating it if it does not already exist
3295     */
3296    public AuditEventAgentComponent getAgentFirstRep() { 
3297      if (getAgent().isEmpty()) {
3298        addAgent();
3299      }
3300      return getAgent().get(0);
3301    }
3302
3303    /**
3304     * @return {@link #source} (The system that is reporting the event.)
3305     */
3306    public AuditEventSourceComponent getSource() { 
3307      if (this.source == null)
3308        if (Configuration.errorOnAutoCreate())
3309          throw new Error("Attempt to auto-create AuditEvent.source");
3310        else if (Configuration.doAutoCreate())
3311          this.source = new AuditEventSourceComponent(); // cc
3312      return this.source;
3313    }
3314
3315    public boolean hasSource() { 
3316      return this.source != null && !this.source.isEmpty();
3317    }
3318
3319    /**
3320     * @param value {@link #source} (The system that is reporting the event.)
3321     */
3322    public AuditEvent setSource(AuditEventSourceComponent value)  { 
3323      this.source = value;
3324      return this;
3325    }
3326
3327    /**
3328     * @return {@link #entity} (Specific instances of data or objects that have been accessed.)
3329     */
3330    public List<AuditEventEntityComponent> getEntity() { 
3331      if (this.entity == null)
3332        this.entity = new ArrayList<AuditEventEntityComponent>();
3333      return this.entity;
3334    }
3335
3336    /**
3337     * @return Returns a reference to <code>this</code> for easy method chaining
3338     */
3339    public AuditEvent setEntity(List<AuditEventEntityComponent> theEntity) { 
3340      this.entity = theEntity;
3341      return this;
3342    }
3343
3344    public boolean hasEntity() { 
3345      if (this.entity == null)
3346        return false;
3347      for (AuditEventEntityComponent item : this.entity)
3348        if (!item.isEmpty())
3349          return true;
3350      return false;
3351    }
3352
3353    public AuditEventEntityComponent addEntity() { //3
3354      AuditEventEntityComponent t = new AuditEventEntityComponent();
3355      if (this.entity == null)
3356        this.entity = new ArrayList<AuditEventEntityComponent>();
3357      this.entity.add(t);
3358      return t;
3359    }
3360
3361    public AuditEvent addEntity(AuditEventEntityComponent t) { //3
3362      if (t == null)
3363        return this;
3364      if (this.entity == null)
3365        this.entity = new ArrayList<AuditEventEntityComponent>();
3366      this.entity.add(t);
3367      return this;
3368    }
3369
3370    /**
3371     * @return The first repetition of repeating field {@link #entity}, creating it if it does not already exist
3372     */
3373    public AuditEventEntityComponent getEntityFirstRep() { 
3374      if (getEntity().isEmpty()) {
3375        addEntity();
3376      }
3377      return getEntity().get(0);
3378    }
3379
3380      protected void listChildren(List<Property> children) {
3381        super.listChildren(children);
3382        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));
3383        children.add(new Property("subtype", "Coding", "Identifier for the category of event.", 0, java.lang.Integer.MAX_VALUE, subtype));
3384        children.add(new Property("action", "code", "Indicator for type of action performed during the event that generated the audit.", 0, 1, action));
3385        children.add(new Property("recorded", "instant", "The time when the event occurred on the source.", 0, 1, recorded));
3386        children.add(new Property("outcome", "code", "Indicates whether the event succeeded or failed.", 0, 1, outcome));
3387        children.add(new Property("outcomeDesc", "string", "A free text description of the outcome of the event.", 0, 1, outcomeDesc));
3388        children.add(new Property("purposeOfEvent", "CodeableConcept", "The purposeOfUse (reason) that was used during the event being recorded.", 0, java.lang.Integer.MAX_VALUE, purposeOfEvent));
3389        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));
3390        children.add(new Property("source", "", "The system that is reporting the event.", 0, 1, source));
3391        children.add(new Property("entity", "", "Specific instances of data or objects that have been accessed.", 0, java.lang.Integer.MAX_VALUE, entity));
3392      }
3393
3394      @Override
3395      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
3396        switch (_hash) {
3397        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);
3398        case -1867567750: /*subtype*/  return new Property("subtype", "Coding", "Identifier for the category of event.", 0, java.lang.Integer.MAX_VALUE, subtype);
3399        case -1422950858: /*action*/  return new Property("action", "code", "Indicator for type of action performed during the event that generated the audit.", 0, 1, action);
3400        case -799233872: /*recorded*/  return new Property("recorded", "instant", "The time when the event occurred on the source.", 0, 1, recorded);
3401        case -1106507950: /*outcome*/  return new Property("outcome", "code", "Indicates whether the event succeeded or failed.", 0, 1, outcome);
3402        case 1062502659: /*outcomeDesc*/  return new Property("outcomeDesc", "string", "A free text description of the outcome of the event.", 0, 1, outcomeDesc);
3403        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);
3404        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);
3405        case -896505829: /*source*/  return new Property("source", "", "The system that is reporting the event.", 0, 1, source);
3406        case -1298275357: /*entity*/  return new Property("entity", "", "Specific instances of data or objects that have been accessed.", 0, java.lang.Integer.MAX_VALUE, entity);
3407        default: return super.getNamedProperty(_hash, _name, _checkValid);
3408        }
3409
3410      }
3411
3412      @Override
3413      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
3414        switch (hash) {
3415        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // Coding
3416        case -1867567750: /*subtype*/ return this.subtype == null ? new Base[0] : this.subtype.toArray(new Base[this.subtype.size()]); // Coding
3417        case -1422950858: /*action*/ return this.action == null ? new Base[0] : new Base[] {this.action}; // Enumeration<AuditEventAction>
3418        case -799233872: /*recorded*/ return this.recorded == null ? new Base[0] : new Base[] {this.recorded}; // InstantType
3419        case -1106507950: /*outcome*/ return this.outcome == null ? new Base[0] : new Base[] {this.outcome}; // Enumeration<AuditEventOutcome>
3420        case 1062502659: /*outcomeDesc*/ return this.outcomeDesc == null ? new Base[0] : new Base[] {this.outcomeDesc}; // StringType
3421        case -341917691: /*purposeOfEvent*/ return this.purposeOfEvent == null ? new Base[0] : this.purposeOfEvent.toArray(new Base[this.purposeOfEvent.size()]); // CodeableConcept
3422        case 92750597: /*agent*/ return this.agent == null ? new Base[0] : this.agent.toArray(new Base[this.agent.size()]); // AuditEventAgentComponent
3423        case -896505829: /*source*/ return this.source == null ? new Base[0] : new Base[] {this.source}; // AuditEventSourceComponent
3424        case -1298275357: /*entity*/ return this.entity == null ? new Base[0] : this.entity.toArray(new Base[this.entity.size()]); // AuditEventEntityComponent
3425        default: return super.getProperty(hash, name, checkValid);
3426        }
3427
3428      }
3429
3430      @Override
3431      public Base setProperty(int hash, String name, Base value) throws FHIRException {
3432        switch (hash) {
3433        case 3575610: // type
3434          this.type = castToCoding(value); // Coding
3435          return value;
3436        case -1867567750: // subtype
3437          this.getSubtype().add(castToCoding(value)); // Coding
3438          return value;
3439        case -1422950858: // action
3440          value = new AuditEventActionEnumFactory().fromType(castToCode(value));
3441          this.action = (Enumeration) value; // Enumeration<AuditEventAction>
3442          return value;
3443        case -799233872: // recorded
3444          this.recorded = castToInstant(value); // InstantType
3445          return value;
3446        case -1106507950: // outcome
3447          value = new AuditEventOutcomeEnumFactory().fromType(castToCode(value));
3448          this.outcome = (Enumeration) value; // Enumeration<AuditEventOutcome>
3449          return value;
3450        case 1062502659: // outcomeDesc
3451          this.outcomeDesc = castToString(value); // StringType
3452          return value;
3453        case -341917691: // purposeOfEvent
3454          this.getPurposeOfEvent().add(castToCodeableConcept(value)); // CodeableConcept
3455          return value;
3456        case 92750597: // agent
3457          this.getAgent().add((AuditEventAgentComponent) value); // AuditEventAgentComponent
3458          return value;
3459        case -896505829: // source
3460          this.source = (AuditEventSourceComponent) value; // AuditEventSourceComponent
3461          return value;
3462        case -1298275357: // entity
3463          this.getEntity().add((AuditEventEntityComponent) value); // AuditEventEntityComponent
3464          return value;
3465        default: return super.setProperty(hash, name, value);
3466        }
3467
3468      }
3469
3470      @Override
3471      public Base setProperty(String name, Base value) throws FHIRException {
3472        if (name.equals("type")) {
3473          this.type = castToCoding(value); // Coding
3474        } else if (name.equals("subtype")) {
3475          this.getSubtype().add(castToCoding(value));
3476        } else if (name.equals("action")) {
3477          value = new AuditEventActionEnumFactory().fromType(castToCode(value));
3478          this.action = (Enumeration) value; // Enumeration<AuditEventAction>
3479        } else if (name.equals("recorded")) {
3480          this.recorded = castToInstant(value); // InstantType
3481        } else if (name.equals("outcome")) {
3482          value = new AuditEventOutcomeEnumFactory().fromType(castToCode(value));
3483          this.outcome = (Enumeration) value; // Enumeration<AuditEventOutcome>
3484        } else if (name.equals("outcomeDesc")) {
3485          this.outcomeDesc = castToString(value); // StringType
3486        } else if (name.equals("purposeOfEvent")) {
3487          this.getPurposeOfEvent().add(castToCodeableConcept(value));
3488        } else if (name.equals("agent")) {
3489          this.getAgent().add((AuditEventAgentComponent) value);
3490        } else if (name.equals("source")) {
3491          this.source = (AuditEventSourceComponent) value; // AuditEventSourceComponent
3492        } else if (name.equals("entity")) {
3493          this.getEntity().add((AuditEventEntityComponent) value);
3494        } else
3495          return super.setProperty(name, value);
3496        return value;
3497      }
3498
3499      @Override
3500      public Base makeProperty(int hash, String name) throws FHIRException {
3501        switch (hash) {
3502        case 3575610:  return getType(); 
3503        case -1867567750:  return addSubtype(); 
3504        case -1422950858:  return getActionElement();
3505        case -799233872:  return getRecordedElement();
3506        case -1106507950:  return getOutcomeElement();
3507        case 1062502659:  return getOutcomeDescElement();
3508        case -341917691:  return addPurposeOfEvent(); 
3509        case 92750597:  return addAgent(); 
3510        case -896505829:  return getSource(); 
3511        case -1298275357:  return addEntity(); 
3512        default: return super.makeProperty(hash, name);
3513        }
3514
3515      }
3516
3517      @Override
3518      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
3519        switch (hash) {
3520        case 3575610: /*type*/ return new String[] {"Coding"};
3521        case -1867567750: /*subtype*/ return new String[] {"Coding"};
3522        case -1422950858: /*action*/ return new String[] {"code"};
3523        case -799233872: /*recorded*/ return new String[] {"instant"};
3524        case -1106507950: /*outcome*/ return new String[] {"code"};
3525        case 1062502659: /*outcomeDesc*/ return new String[] {"string"};
3526        case -341917691: /*purposeOfEvent*/ return new String[] {"CodeableConcept"};
3527        case 92750597: /*agent*/ return new String[] {};
3528        case -896505829: /*source*/ return new String[] {};
3529        case -1298275357: /*entity*/ return new String[] {};
3530        default: return super.getTypesForProperty(hash, name);
3531        }
3532
3533      }
3534
3535      @Override
3536      public Base addChild(String name) throws FHIRException {
3537        if (name.equals("type")) {
3538          this.type = new Coding();
3539          return this.type;
3540        }
3541        else if (name.equals("subtype")) {
3542          return addSubtype();
3543        }
3544        else if (name.equals("action")) {
3545          throw new FHIRException("Cannot call addChild on a primitive type AuditEvent.action");
3546        }
3547        else if (name.equals("recorded")) {
3548          throw new FHIRException("Cannot call addChild on a primitive type AuditEvent.recorded");
3549        }
3550        else if (name.equals("outcome")) {
3551          throw new FHIRException("Cannot call addChild on a primitive type AuditEvent.outcome");
3552        }
3553        else if (name.equals("outcomeDesc")) {
3554          throw new FHIRException("Cannot call addChild on a primitive type AuditEvent.outcomeDesc");
3555        }
3556        else if (name.equals("purposeOfEvent")) {
3557          return addPurposeOfEvent();
3558        }
3559        else if (name.equals("agent")) {
3560          return addAgent();
3561        }
3562        else if (name.equals("source")) {
3563          this.source = new AuditEventSourceComponent();
3564          return this.source;
3565        }
3566        else if (name.equals("entity")) {
3567          return addEntity();
3568        }
3569        else
3570          return super.addChild(name);
3571      }
3572
3573  public String fhirType() {
3574    return "AuditEvent";
3575
3576  }
3577
3578      public AuditEvent copy() {
3579        AuditEvent dst = new AuditEvent();
3580        copyValues(dst);
3581        dst.type = type == null ? null : type.copy();
3582        if (subtype != null) {
3583          dst.subtype = new ArrayList<Coding>();
3584          for (Coding i : subtype)
3585            dst.subtype.add(i.copy());
3586        };
3587        dst.action = action == null ? null : action.copy();
3588        dst.recorded = recorded == null ? null : recorded.copy();
3589        dst.outcome = outcome == null ? null : outcome.copy();
3590        dst.outcomeDesc = outcomeDesc == null ? null : outcomeDesc.copy();
3591        if (purposeOfEvent != null) {
3592          dst.purposeOfEvent = new ArrayList<CodeableConcept>();
3593          for (CodeableConcept i : purposeOfEvent)
3594            dst.purposeOfEvent.add(i.copy());
3595        };
3596        if (agent != null) {
3597          dst.agent = new ArrayList<AuditEventAgentComponent>();
3598          for (AuditEventAgentComponent i : agent)
3599            dst.agent.add(i.copy());
3600        };
3601        dst.source = source == null ? null : source.copy();
3602        if (entity != null) {
3603          dst.entity = new ArrayList<AuditEventEntityComponent>();
3604          for (AuditEventEntityComponent i : entity)
3605            dst.entity.add(i.copy());
3606        };
3607        return dst;
3608      }
3609
3610      protected AuditEvent typedCopy() {
3611        return copy();
3612      }
3613
3614      @Override
3615      public boolean equalsDeep(Base other_) {
3616        if (!super.equalsDeep(other_))
3617          return false;
3618        if (!(other_ instanceof AuditEvent))
3619          return false;
3620        AuditEvent o = (AuditEvent) other_;
3621        return compareDeep(type, o.type, true) && compareDeep(subtype, o.subtype, true) && compareDeep(action, o.action, true)
3622           && compareDeep(recorded, o.recorded, true) && compareDeep(outcome, o.outcome, true) && compareDeep(outcomeDesc, o.outcomeDesc, true)
3623           && compareDeep(purposeOfEvent, o.purposeOfEvent, true) && compareDeep(agent, o.agent, true) && compareDeep(source, o.source, true)
3624           && compareDeep(entity, o.entity, true);
3625      }
3626
3627      @Override
3628      public boolean equalsShallow(Base other_) {
3629        if (!super.equalsShallow(other_))
3630          return false;
3631        if (!(other_ instanceof AuditEvent))
3632          return false;
3633        AuditEvent o = (AuditEvent) other_;
3634        return compareValues(action, o.action, true) && compareValues(recorded, o.recorded, true) && compareValues(outcome, o.outcome, true)
3635           && compareValues(outcomeDesc, o.outcomeDesc, true);
3636      }
3637
3638      public boolean isEmpty() {
3639        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, subtype, action, recorded
3640          , outcome, outcomeDesc, purposeOfEvent, agent, source, entity);
3641      }
3642
3643  @Override
3644  public ResourceType getResourceType() {
3645    return ResourceType.AuditEvent;
3646   }
3647
3648 /**
3649   * Search parameter: <b>date</b>
3650   * <p>
3651   * Description: <b>Time when the event occurred on source</b><br>
3652   * Type: <b>date</b><br>
3653   * Path: <b>AuditEvent.recorded</b><br>
3654   * </p>
3655   */
3656  @SearchParamDefinition(name="date", path="AuditEvent.recorded", description="Time when the event occurred on source", type="date" )
3657  public static final String SP_DATE = "date";
3658 /**
3659   * <b>Fluent Client</b> search parameter constant for <b>date</b>
3660   * <p>
3661   * Description: <b>Time when the event occurred on source</b><br>
3662   * Type: <b>date</b><br>
3663   * Path: <b>AuditEvent.recorded</b><br>
3664   * </p>
3665   */
3666  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
3667
3668 /**
3669   * Search parameter: <b>entity-type</b>
3670   * <p>
3671   * Description: <b>Type of entity involved</b><br>
3672   * Type: <b>token</b><br>
3673   * Path: <b>AuditEvent.entity.type</b><br>
3674   * </p>
3675   */
3676  @SearchParamDefinition(name="entity-type", path="AuditEvent.entity.type", description="Type of entity involved", type="token" )
3677  public static final String SP_ENTITY_TYPE = "entity-type";
3678 /**
3679   * <b>Fluent Client</b> search parameter constant for <b>entity-type</b>
3680   * <p>
3681   * Description: <b>Type of entity involved</b><br>
3682   * Type: <b>token</b><br>
3683   * Path: <b>AuditEvent.entity.type</b><br>
3684   * </p>
3685   */
3686  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ENTITY_TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_ENTITY_TYPE);
3687
3688 /**
3689   * Search parameter: <b>agent</b>
3690   * <p>
3691   * Description: <b>Direct reference to resource</b><br>
3692   * Type: <b>reference</b><br>
3693   * Path: <b>AuditEvent.agent.reference</b><br>
3694   * </p>
3695   */
3696  @SearchParamDefinition(name="agent", path="AuditEvent.agent.reference", description="Direct reference to resource", 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, RelatedPerson.class } )
3697  public static final String SP_AGENT = "agent";
3698 /**
3699   * <b>Fluent Client</b> search parameter constant for <b>agent</b>
3700   * <p>
3701   * Description: <b>Direct reference to resource</b><br>
3702   * Type: <b>reference</b><br>
3703   * Path: <b>AuditEvent.agent.reference</b><br>
3704   * </p>
3705   */
3706  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam AGENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_AGENT);
3707
3708/**
3709   * Constant for fluent queries to be used to add include statements. Specifies
3710   * the path value of "<b>AuditEvent:agent</b>".
3711   */
3712  public static final ca.uhn.fhir.model.api.Include INCLUDE_AGENT = new ca.uhn.fhir.model.api.Include("AuditEvent:agent").toLocked();
3713
3714 /**
3715   * Search parameter: <b>address</b>
3716   * <p>
3717   * Description: <b>Identifier for the network access point of the user device</b><br>
3718   * Type: <b>string</b><br>
3719   * Path: <b>AuditEvent.agent.network.address</b><br>
3720   * </p>
3721   */
3722  @SearchParamDefinition(name="address", path="AuditEvent.agent.network.address", description="Identifier for the network access point of the user device", type="string" )
3723  public static final String SP_ADDRESS = "address";
3724 /**
3725   * <b>Fluent Client</b> search parameter constant for <b>address</b>
3726   * <p>
3727   * Description: <b>Identifier for the network access point of the user device</b><br>
3728   * Type: <b>string</b><br>
3729   * Path: <b>AuditEvent.agent.network.address</b><br>
3730   * </p>
3731   */
3732  public static final ca.uhn.fhir.rest.gclient.StringClientParam ADDRESS = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_ADDRESS);
3733
3734 /**
3735   * Search parameter: <b>entity-role</b>
3736   * <p>
3737   * Description: <b>What role the entity played</b><br>
3738   * Type: <b>token</b><br>
3739   * Path: <b>AuditEvent.entity.role</b><br>
3740   * </p>
3741   */
3742  @SearchParamDefinition(name="entity-role", path="AuditEvent.entity.role", description="What role the entity played", type="token" )
3743  public static final String SP_ENTITY_ROLE = "entity-role";
3744 /**
3745   * <b>Fluent Client</b> search parameter constant for <b>entity-role</b>
3746   * <p>
3747   * Description: <b>What role the entity played</b><br>
3748   * Type: <b>token</b><br>
3749   * Path: <b>AuditEvent.entity.role</b><br>
3750   * </p>
3751   */
3752  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ENTITY_ROLE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_ENTITY_ROLE);
3753
3754 /**
3755   * Search parameter: <b>source</b>
3756   * <p>
3757   * Description: <b>The identity of source detecting the event</b><br>
3758   * Type: <b>token</b><br>
3759   * Path: <b>AuditEvent.source.identifier</b><br>
3760   * </p>
3761   */
3762  @SearchParamDefinition(name="source", path="AuditEvent.source.identifier", description="The identity of source detecting the event", type="token" )
3763  public static final String SP_SOURCE = "source";
3764 /**
3765   * <b>Fluent Client</b> search parameter constant for <b>source</b>
3766   * <p>
3767   * Description: <b>The identity of source detecting the event</b><br>
3768   * Type: <b>token</b><br>
3769   * Path: <b>AuditEvent.source.identifier</b><br>
3770   * </p>
3771   */
3772  public static final ca.uhn.fhir.rest.gclient.TokenClientParam SOURCE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_SOURCE);
3773
3774 /**
3775   * Search parameter: <b>type</b>
3776   * <p>
3777   * Description: <b>Type/identifier of event</b><br>
3778   * Type: <b>token</b><br>
3779   * Path: <b>AuditEvent.type</b><br>
3780   * </p>
3781   */
3782  @SearchParamDefinition(name="type", path="AuditEvent.type", description="Type/identifier of event", type="token" )
3783  public static final String SP_TYPE = "type";
3784 /**
3785   * <b>Fluent Client</b> search parameter constant for <b>type</b>
3786   * <p>
3787   * Description: <b>Type/identifier of event</b><br>
3788   * Type: <b>token</b><br>
3789   * Path: <b>AuditEvent.type</b><br>
3790   * </p>
3791   */
3792  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
3793
3794 /**
3795   * Search parameter: <b>altid</b>
3796   * <p>
3797   * Description: <b>Alternative User id e.g. authentication</b><br>
3798   * Type: <b>token</b><br>
3799   * Path: <b>AuditEvent.agent.altId</b><br>
3800   * </p>
3801   */
3802  @SearchParamDefinition(name="altid", path="AuditEvent.agent.altId", description="Alternative User id e.g. authentication", type="token" )
3803  public static final String SP_ALTID = "altid";
3804 /**
3805   * <b>Fluent Client</b> search parameter constant for <b>altid</b>
3806   * <p>
3807   * Description: <b>Alternative User id e.g. authentication</b><br>
3808   * Type: <b>token</b><br>
3809   * Path: <b>AuditEvent.agent.altId</b><br>
3810   * </p>
3811   */
3812  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ALTID = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_ALTID);
3813
3814 /**
3815   * Search parameter: <b>site</b>
3816   * <p>
3817   * Description: <b>Logical source location within the enterprise</b><br>
3818   * Type: <b>token</b><br>
3819   * Path: <b>AuditEvent.source.site</b><br>
3820   * </p>
3821   */
3822  @SearchParamDefinition(name="site", path="AuditEvent.source.site", description="Logical source location within the enterprise", type="token" )
3823  public static final String SP_SITE = "site";
3824 /**
3825   * <b>Fluent Client</b> search parameter constant for <b>site</b>
3826   * <p>
3827   * Description: <b>Logical source location within the enterprise</b><br>
3828   * Type: <b>token</b><br>
3829   * Path: <b>AuditEvent.source.site</b><br>
3830   * </p>
3831   */
3832  public static final ca.uhn.fhir.rest.gclient.TokenClientParam SITE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_SITE);
3833
3834 /**
3835   * Search parameter: <b>agent-name</b>
3836   * <p>
3837   * Description: <b>Human-meaningful name for the agent</b><br>
3838   * Type: <b>string</b><br>
3839   * Path: <b>AuditEvent.agent.name</b><br>
3840   * </p>
3841   */
3842  @SearchParamDefinition(name="agent-name", path="AuditEvent.agent.name", description="Human-meaningful name for the agent", type="string" )
3843  public static final String SP_AGENT_NAME = "agent-name";
3844 /**
3845   * <b>Fluent Client</b> search parameter constant for <b>agent-name</b>
3846   * <p>
3847   * Description: <b>Human-meaningful name for the agent</b><br>
3848   * Type: <b>string</b><br>
3849   * Path: <b>AuditEvent.agent.name</b><br>
3850   * </p>
3851   */
3852  public static final ca.uhn.fhir.rest.gclient.StringClientParam AGENT_NAME = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_AGENT_NAME);
3853
3854 /**
3855   * Search parameter: <b>entity-name</b>
3856   * <p>
3857   * Description: <b>Descriptor for entity</b><br>
3858   * Type: <b>string</b><br>
3859   * Path: <b>AuditEvent.entity.name</b><br>
3860   * </p>
3861   */
3862  @SearchParamDefinition(name="entity-name", path="AuditEvent.entity.name", description="Descriptor for entity", type="string" )
3863  public static final String SP_ENTITY_NAME = "entity-name";
3864 /**
3865   * <b>Fluent Client</b> search parameter constant for <b>entity-name</b>
3866   * <p>
3867   * Description: <b>Descriptor for entity</b><br>
3868   * Type: <b>string</b><br>
3869   * Path: <b>AuditEvent.entity.name</b><br>
3870   * </p>
3871   */
3872  public static final ca.uhn.fhir.rest.gclient.StringClientParam ENTITY_NAME = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_ENTITY_NAME);
3873
3874 /**
3875   * Search parameter: <b>subtype</b>
3876   * <p>
3877   * Description: <b>More specific type/id for the event</b><br>
3878   * Type: <b>token</b><br>
3879   * Path: <b>AuditEvent.subtype</b><br>
3880   * </p>
3881   */
3882  @SearchParamDefinition(name="subtype", path="AuditEvent.subtype", description="More specific type/id for the event", type="token" )
3883  public static final String SP_SUBTYPE = "subtype";
3884 /**
3885   * <b>Fluent Client</b> search parameter constant for <b>subtype</b>
3886   * <p>
3887   * Description: <b>More specific type/id for the event</b><br>
3888   * Type: <b>token</b><br>
3889   * Path: <b>AuditEvent.subtype</b><br>
3890   * </p>
3891   */
3892  public static final ca.uhn.fhir.rest.gclient.TokenClientParam SUBTYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_SUBTYPE);
3893
3894 /**
3895   * Search parameter: <b>patient</b>
3896   * <p>
3897   * Description: <b>Direct reference to resource</b><br>
3898   * Type: <b>reference</b><br>
3899   * Path: <b>AuditEvent.agent.reference, AuditEvent.entity.reference</b><br>
3900   * </p>
3901   */
3902  @SearchParamDefinition(name="patient", path="AuditEvent.agent.reference | AuditEvent.entity.reference", description="Direct reference to resource", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Patient.class } )
3903  public static final String SP_PATIENT = "patient";
3904 /**
3905   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
3906   * <p>
3907   * Description: <b>Direct reference to resource</b><br>
3908   * Type: <b>reference</b><br>
3909   * Path: <b>AuditEvent.agent.reference, AuditEvent.entity.reference</b><br>
3910   * </p>
3911   */
3912  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
3913
3914/**
3915   * Constant for fluent queries to be used to add include statements. Specifies
3916   * the path value of "<b>AuditEvent:patient</b>".
3917   */
3918  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("AuditEvent:patient").toLocked();
3919
3920 /**
3921   * Search parameter: <b>action</b>
3922   * <p>
3923   * Description: <b>Type of action performed during the event</b><br>
3924   * Type: <b>token</b><br>
3925   * Path: <b>AuditEvent.action</b><br>
3926   * </p>
3927   */
3928  @SearchParamDefinition(name="action", path="AuditEvent.action", description="Type of action performed during the event", type="token" )
3929  public static final String SP_ACTION = "action";
3930 /**
3931   * <b>Fluent Client</b> search parameter constant for <b>action</b>
3932   * <p>
3933   * Description: <b>Type of action performed during the event</b><br>
3934   * Type: <b>token</b><br>
3935   * Path: <b>AuditEvent.action</b><br>
3936   * </p>
3937   */
3938  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ACTION = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_ACTION);
3939
3940 /**
3941   * Search parameter: <b>agent-role</b>
3942   * <p>
3943   * Description: <b>Agent role in the event</b><br>
3944   * Type: <b>token</b><br>
3945   * Path: <b>AuditEvent.agent.role</b><br>
3946   * </p>
3947   */
3948  @SearchParamDefinition(name="agent-role", path="AuditEvent.agent.role", description="Agent role in the event", type="token" )
3949  public static final String SP_AGENT_ROLE = "agent-role";
3950 /**
3951   * <b>Fluent Client</b> search parameter constant for <b>agent-role</b>
3952   * <p>
3953   * Description: <b>Agent role in the event</b><br>
3954   * Type: <b>token</b><br>
3955   * Path: <b>AuditEvent.agent.role</b><br>
3956   * </p>
3957   */
3958  public static final ca.uhn.fhir.rest.gclient.TokenClientParam AGENT_ROLE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_AGENT_ROLE);
3959
3960 /**
3961   * Search parameter: <b>user</b>
3962   * <p>
3963   * Description: <b>Unique identifier for the user</b><br>
3964   * Type: <b>token</b><br>
3965   * Path: <b>AuditEvent.agent.userId</b><br>
3966   * </p>
3967   */
3968  @SearchParamDefinition(name="user", path="AuditEvent.agent.userId", description="Unique identifier for the user", type="token" )
3969  public static final String SP_USER = "user";
3970 /**
3971   * <b>Fluent Client</b> search parameter constant for <b>user</b>
3972   * <p>
3973   * Description: <b>Unique identifier for the user</b><br>
3974   * Type: <b>token</b><br>
3975   * Path: <b>AuditEvent.agent.userId</b><br>
3976   * </p>
3977   */
3978  public static final ca.uhn.fhir.rest.gclient.TokenClientParam USER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_USER);
3979
3980 /**
3981   * Search parameter: <b>entity</b>
3982   * <p>
3983   * Description: <b>Specific instance of resource</b><br>
3984   * Type: <b>reference</b><br>
3985   * Path: <b>AuditEvent.entity.reference</b><br>
3986   * </p>
3987   */
3988  @SearchParamDefinition(name="entity", path="AuditEvent.entity.reference", description="Specific instance of resource", type="reference" )
3989  public static final String SP_ENTITY = "entity";
3990 /**
3991   * <b>Fluent Client</b> search parameter constant for <b>entity</b>
3992   * <p>
3993   * Description: <b>Specific instance of resource</b><br>
3994   * Type: <b>reference</b><br>
3995   * Path: <b>AuditEvent.entity.reference</b><br>
3996   * </p>
3997   */
3998  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENTITY = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENTITY);
3999
4000/**
4001   * Constant for fluent queries to be used to add include statements. Specifies
4002   * the path value of "<b>AuditEvent:entity</b>".
4003   */
4004  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENTITY = new ca.uhn.fhir.model.api.Include("AuditEvent:entity").toLocked();
4005
4006 /**
4007   * Search parameter: <b>entity-id</b>
4008   * <p>
4009   * Description: <b>Specific instance of object</b><br>
4010   * Type: <b>token</b><br>
4011   * Path: <b>AuditEvent.entity.identifier</b><br>
4012   * </p>
4013   */
4014  @SearchParamDefinition(name="entity-id", path="AuditEvent.entity.identifier", description="Specific instance of object", type="token" )
4015  public static final String SP_ENTITY_ID = "entity-id";
4016 /**
4017   * <b>Fluent Client</b> search parameter constant for <b>entity-id</b>
4018   * <p>
4019   * Description: <b>Specific instance of object</b><br>
4020   * Type: <b>token</b><br>
4021   * Path: <b>AuditEvent.entity.identifier</b><br>
4022   * </p>
4023   */
4024  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ENTITY_ID = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_ENTITY_ID);
4025
4026 /**
4027   * Search parameter: <b>outcome</b>
4028   * <p>
4029   * Description: <b>Whether the event succeeded or failed</b><br>
4030   * Type: <b>token</b><br>
4031   * Path: <b>AuditEvent.outcome</b><br>
4032   * </p>
4033   */
4034  @SearchParamDefinition(name="outcome", path="AuditEvent.outcome", description="Whether the event succeeded or failed", type="token" )
4035  public static final String SP_OUTCOME = "outcome";
4036 /**
4037   * <b>Fluent Client</b> search parameter constant for <b>outcome</b>
4038   * <p>
4039   * Description: <b>Whether the event succeeded or failed</b><br>
4040   * Type: <b>token</b><br>
4041   * Path: <b>AuditEvent.outcome</b><br>
4042   * </p>
4043   */
4044  public static final ca.uhn.fhir.rest.gclient.TokenClientParam OUTCOME = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_OUTCOME);
4045
4046 /**
4047   * Search parameter: <b>policy</b>
4048   * <p>
4049   * Description: <b>Policy that authorized event</b><br>
4050   * Type: <b>uri</b><br>
4051   * Path: <b>AuditEvent.agent.policy</b><br>
4052   * </p>
4053   */
4054  @SearchParamDefinition(name="policy", path="AuditEvent.agent.policy", description="Policy that authorized event", type="uri" )
4055  public static final String SP_POLICY = "policy";
4056 /**
4057   * <b>Fluent Client</b> search parameter constant for <b>policy</b>
4058   * <p>
4059   * Description: <b>Policy that authorized event</b><br>
4060   * Type: <b>uri</b><br>
4061   * Path: <b>AuditEvent.agent.policy</b><br>
4062   * </p>
4063   */
4064  public static final ca.uhn.fhir.rest.gclient.UriClientParam POLICY = new ca.uhn.fhir.rest.gclient.UriClientParam(SP_POLICY);
4065
4066
4067}
4068