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