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