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