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