001package org.hl7.fhir.dstu3.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Fri, Mar 16, 2018 15:21+1100 for FHIR v3.0.1
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import ca.uhn.fhir.model.api.annotation.ResourceDef;
038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.Block;
043import org.hl7.fhir.instance.model.api.*;
044import org.hl7.fhir.exceptions.FHIRException;
045import org.hl7.fhir.exceptions.FHIRFormatError;
046/**
047 * Provenance of a resource is a record that describes entities and processes involved in producing and delivering or otherwise influencing that resource. Provenance provides a critical foundation for assessing authenticity, enabling trust, and allowing reproducibility. Provenance assertions are a form of contextual metadata and can themselves become important records with their own provenance. Provenance statement indicates clinical significance in terms of confidence in authenticity, reliability, and trustworthiness, integrity, and stage in lifecycle (e.g. Document Completion - has the artifact been legally authenticated), all of which may impact security, privacy, and trust policies.
048 */
049@ResourceDef(name="Provenance", profile="http://hl7.org/fhir/StructureDefinition/Provenance")
050public class Provenance extends DomainResource {
051
052    public enum ProvenanceEntityRole {
053        /**
054         * A transformation of an entity into another, an update of an entity resulting in a new one, or the construction of a new entity based on a preexisting entity.
055         */
056        DERIVATION, 
057        /**
058         * A derivation for which the resulting entity is a revised version of some original.
059         */
060        REVISION, 
061        /**
062         * The repeat of (some or all of) an entity, such as text or image, by someone who may or may not be its original author.
063         */
064        QUOTATION, 
065        /**
066         * A primary source for a topic refers to something produced by some agent with direct experience and knowledge about the topic, at the time of the topic's study, without benefit from hindsight.
067         */
068        SOURCE, 
069        /**
070         * A derivation for which the entity is removed from accessibility usually through the use of the Delete operation.
071         */
072        REMOVAL, 
073        /**
074         * added to help the parsers with the generic types
075         */
076        NULL;
077        public static ProvenanceEntityRole fromCode(String codeString) throws FHIRException {
078            if (codeString == null || "".equals(codeString))
079                return null;
080        if ("derivation".equals(codeString))
081          return DERIVATION;
082        if ("revision".equals(codeString))
083          return REVISION;
084        if ("quotation".equals(codeString))
085          return QUOTATION;
086        if ("source".equals(codeString))
087          return SOURCE;
088        if ("removal".equals(codeString))
089          return REMOVAL;
090        if (Configuration.isAcceptInvalidEnums())
091          return null;
092        else
093          throw new FHIRException("Unknown ProvenanceEntityRole code '"+codeString+"'");
094        }
095        public String toCode() {
096          switch (this) {
097            case DERIVATION: return "derivation";
098            case REVISION: return "revision";
099            case QUOTATION: return "quotation";
100            case SOURCE: return "source";
101            case REMOVAL: return "removal";
102            default: return "?";
103          }
104        }
105        public String getSystem() {
106          switch (this) {
107            case DERIVATION: return "http://hl7.org/fhir/provenance-entity-role";
108            case REVISION: return "http://hl7.org/fhir/provenance-entity-role";
109            case QUOTATION: return "http://hl7.org/fhir/provenance-entity-role";
110            case SOURCE: return "http://hl7.org/fhir/provenance-entity-role";
111            case REMOVAL: return "http://hl7.org/fhir/provenance-entity-role";
112            default: return "?";
113          }
114        }
115        public String getDefinition() {
116          switch (this) {
117            case DERIVATION: return "A transformation of an entity into another, an update of an entity resulting in a new one, or the construction of a new entity based on a preexisting entity.";
118            case REVISION: return "A derivation for which the resulting entity is a revised version of some original.";
119            case QUOTATION: return "The repeat of (some or all of) an entity, such as text or image, by someone who may or may not be its original author.";
120            case SOURCE: return "A primary source for a topic refers to something produced by some agent with direct experience and knowledge about the topic, at the time of the topic's study, without benefit from hindsight.";
121            case REMOVAL: return "A derivation for which the entity is removed from accessibility usually through the use of the Delete operation.";
122            default: return "?";
123          }
124        }
125        public String getDisplay() {
126          switch (this) {
127            case DERIVATION: return "Derivation";
128            case REVISION: return "Revision";
129            case QUOTATION: return "Quotation";
130            case SOURCE: return "Source";
131            case REMOVAL: return "Removal";
132            default: return "?";
133          }
134        }
135    }
136
137  public static class ProvenanceEntityRoleEnumFactory implements EnumFactory<ProvenanceEntityRole> {
138    public ProvenanceEntityRole fromCode(String codeString) throws IllegalArgumentException {
139      if (codeString == null || "".equals(codeString))
140            if (codeString == null || "".equals(codeString))
141                return null;
142        if ("derivation".equals(codeString))
143          return ProvenanceEntityRole.DERIVATION;
144        if ("revision".equals(codeString))
145          return ProvenanceEntityRole.REVISION;
146        if ("quotation".equals(codeString))
147          return ProvenanceEntityRole.QUOTATION;
148        if ("source".equals(codeString))
149          return ProvenanceEntityRole.SOURCE;
150        if ("removal".equals(codeString))
151          return ProvenanceEntityRole.REMOVAL;
152        throw new IllegalArgumentException("Unknown ProvenanceEntityRole code '"+codeString+"'");
153        }
154        public Enumeration<ProvenanceEntityRole> fromType(Base code) throws FHIRException {
155          if (code == null)
156            return null;
157          if (code.isEmpty())
158            return new Enumeration<ProvenanceEntityRole>(this);
159          String codeString = ((PrimitiveType) code).asStringValue();
160          if (codeString == null || "".equals(codeString))
161            return null;
162        if ("derivation".equals(codeString))
163          return new Enumeration<ProvenanceEntityRole>(this, ProvenanceEntityRole.DERIVATION);
164        if ("revision".equals(codeString))
165          return new Enumeration<ProvenanceEntityRole>(this, ProvenanceEntityRole.REVISION);
166        if ("quotation".equals(codeString))
167          return new Enumeration<ProvenanceEntityRole>(this, ProvenanceEntityRole.QUOTATION);
168        if ("source".equals(codeString))
169          return new Enumeration<ProvenanceEntityRole>(this, ProvenanceEntityRole.SOURCE);
170        if ("removal".equals(codeString))
171          return new Enumeration<ProvenanceEntityRole>(this, ProvenanceEntityRole.REMOVAL);
172        throw new FHIRException("Unknown ProvenanceEntityRole code '"+codeString+"'");
173        }
174    public String toCode(ProvenanceEntityRole code) {
175      if (code == ProvenanceEntityRole.DERIVATION)
176        return "derivation";
177      if (code == ProvenanceEntityRole.REVISION)
178        return "revision";
179      if (code == ProvenanceEntityRole.QUOTATION)
180        return "quotation";
181      if (code == ProvenanceEntityRole.SOURCE)
182        return "source";
183      if (code == ProvenanceEntityRole.REMOVAL)
184        return "removal";
185      return "?";
186      }
187    public String toSystem(ProvenanceEntityRole code) {
188      return code.getSystem();
189      }
190    }
191
192    @Block()
193    public static class ProvenanceAgentComponent extends BackboneElement implements IBaseBackboneElement {
194        /**
195         * The function of the agent with respect to the activity. The security role enabling the agent with respect to the activity.
196         */
197        @Child(name = "role", type = {CodeableConcept.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
198        @Description(shortDefinition="What the agents role was", formalDefinition="The function of the agent with respect to the activity. The security role enabling the agent with respect to the activity." )
199        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/security-role-type")
200        protected List<CodeableConcept> role;
201
202        /**
203         * The individual, device or organization that participated in the event.
204         */
205        @Child(name = "who", type = {UriType.class, Practitioner.class, RelatedPerson.class, Patient.class, Device.class, Organization.class}, order=2, min=1, max=1, modifier=false, summary=true)
206        @Description(shortDefinition="Who participated", formalDefinition="The individual, device or organization that participated in the event." )
207        protected Type who;
208
209        /**
210         * The individual, device, or organization for whom the change was made.
211         */
212        @Child(name = "onBehalfOf", type = {UriType.class, Practitioner.class, RelatedPerson.class, Patient.class, Device.class, Organization.class}, order=3, min=0, max=1, modifier=false, summary=false)
213        @Description(shortDefinition="Who the agent is representing", formalDefinition="The individual, device, or organization for whom the change was made." )
214        protected Type onBehalfOf;
215
216        /**
217         * The type of relationship between agents.
218         */
219        @Child(name = "relatedAgentType", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=false)
220        @Description(shortDefinition="Type of relationship between agents", formalDefinition="The type of relationship between agents." )
221        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/v3-RoleLinkType")
222        protected CodeableConcept relatedAgentType;
223
224        private static final long serialVersionUID = -1431948744L;
225
226    /**
227     * Constructor
228     */
229      public ProvenanceAgentComponent() {
230        super();
231      }
232
233    /**
234     * Constructor
235     */
236      public ProvenanceAgentComponent(Type who) {
237        super();
238        this.who = who;
239      }
240
241        /**
242         * @return {@link #role} (The function of the agent with respect to the activity. The security role enabling the agent with respect to the activity.)
243         */
244        public List<CodeableConcept> getRole() { 
245          if (this.role == null)
246            this.role = new ArrayList<CodeableConcept>();
247          return this.role;
248        }
249
250        /**
251         * @return Returns a reference to <code>this</code> for easy method chaining
252         */
253        public ProvenanceAgentComponent setRole(List<CodeableConcept> theRole) { 
254          this.role = theRole;
255          return this;
256        }
257
258        public boolean hasRole() { 
259          if (this.role == null)
260            return false;
261          for (CodeableConcept item : this.role)
262            if (!item.isEmpty())
263              return true;
264          return false;
265        }
266
267        public CodeableConcept addRole() { //3
268          CodeableConcept t = new CodeableConcept();
269          if (this.role == null)
270            this.role = new ArrayList<CodeableConcept>();
271          this.role.add(t);
272          return t;
273        }
274
275        public ProvenanceAgentComponent addRole(CodeableConcept t) { //3
276          if (t == null)
277            return this;
278          if (this.role == null)
279            this.role = new ArrayList<CodeableConcept>();
280          this.role.add(t);
281          return this;
282        }
283
284        /**
285         * @return The first repetition of repeating field {@link #role}, creating it if it does not already exist
286         */
287        public CodeableConcept getRoleFirstRep() { 
288          if (getRole().isEmpty()) {
289            addRole();
290          }
291          return getRole().get(0);
292        }
293
294        /**
295         * @return {@link #who} (The individual, device or organization that participated in the event.)
296         */
297        public Type getWho() { 
298          return this.who;
299        }
300
301        /**
302         * @return {@link #who} (The individual, device or organization that participated in the event.)
303         */
304        public UriType getWhoUriType() throws FHIRException { 
305          if (this.who == null)
306            return null;
307          if (!(this.who instanceof UriType))
308            throw new FHIRException("Type mismatch: the type UriType was expected, but "+this.who.getClass().getName()+" was encountered");
309          return (UriType) this.who;
310        }
311
312        public boolean hasWhoUriType() { 
313          return this != null && this.who instanceof UriType;
314        }
315
316        /**
317         * @return {@link #who} (The individual, device or organization that participated in the event.)
318         */
319        public Reference getWhoReference() throws FHIRException { 
320          if (this.who == null)
321            return null;
322          if (!(this.who instanceof Reference))
323            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.who.getClass().getName()+" was encountered");
324          return (Reference) this.who;
325        }
326
327        public boolean hasWhoReference() { 
328          return this != null && this.who instanceof Reference;
329        }
330
331        public boolean hasWho() { 
332          return this.who != null && !this.who.isEmpty();
333        }
334
335        /**
336         * @param value {@link #who} (The individual, device or organization that participated in the event.)
337         */
338        public ProvenanceAgentComponent setWho(Type value) throws FHIRFormatError { 
339          if (value != null && !(value instanceof UriType || value instanceof Reference))
340            throw new FHIRFormatError("Not the right type for Provenance.agent.who[x]: "+value.fhirType());
341          this.who = value;
342          return this;
343        }
344
345        /**
346         * @return {@link #onBehalfOf} (The individual, device, or organization for whom the change was made.)
347         */
348        public Type getOnBehalfOf() { 
349          return this.onBehalfOf;
350        }
351
352        /**
353         * @return {@link #onBehalfOf} (The individual, device, or organization for whom the change was made.)
354         */
355        public UriType getOnBehalfOfUriType() throws FHIRException { 
356          if (this.onBehalfOf == null)
357            return null;
358          if (!(this.onBehalfOf instanceof UriType))
359            throw new FHIRException("Type mismatch: the type UriType was expected, but "+this.onBehalfOf.getClass().getName()+" was encountered");
360          return (UriType) this.onBehalfOf;
361        }
362
363        public boolean hasOnBehalfOfUriType() { 
364          return this != null && this.onBehalfOf instanceof UriType;
365        }
366
367        /**
368         * @return {@link #onBehalfOf} (The individual, device, or organization for whom the change was made.)
369         */
370        public Reference getOnBehalfOfReference() throws FHIRException { 
371          if (this.onBehalfOf == null)
372            return null;
373          if (!(this.onBehalfOf instanceof Reference))
374            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.onBehalfOf.getClass().getName()+" was encountered");
375          return (Reference) this.onBehalfOf;
376        }
377
378        public boolean hasOnBehalfOfReference() { 
379          return this != null && this.onBehalfOf instanceof Reference;
380        }
381
382        public boolean hasOnBehalfOf() { 
383          return this.onBehalfOf != null && !this.onBehalfOf.isEmpty();
384        }
385
386        /**
387         * @param value {@link #onBehalfOf} (The individual, device, or organization for whom the change was made.)
388         */
389        public ProvenanceAgentComponent setOnBehalfOf(Type value) throws FHIRFormatError { 
390          if (value != null && !(value instanceof UriType || value instanceof Reference))
391            throw new FHIRFormatError("Not the right type for Provenance.agent.onBehalfOf[x]: "+value.fhirType());
392          this.onBehalfOf = value;
393          return this;
394        }
395
396        /**
397         * @return {@link #relatedAgentType} (The type of relationship between agents.)
398         */
399        public CodeableConcept getRelatedAgentType() { 
400          if (this.relatedAgentType == null)
401            if (Configuration.errorOnAutoCreate())
402              throw new Error("Attempt to auto-create ProvenanceAgentComponent.relatedAgentType");
403            else if (Configuration.doAutoCreate())
404              this.relatedAgentType = new CodeableConcept(); // cc
405          return this.relatedAgentType;
406        }
407
408        public boolean hasRelatedAgentType() { 
409          return this.relatedAgentType != null && !this.relatedAgentType.isEmpty();
410        }
411
412        /**
413         * @param value {@link #relatedAgentType} (The type of relationship between agents.)
414         */
415        public ProvenanceAgentComponent setRelatedAgentType(CodeableConcept value)  { 
416          this.relatedAgentType = value;
417          return this;
418        }
419
420        protected void listChildren(List<Property> children) {
421          super.listChildren(children);
422          children.add(new Property("role", "CodeableConcept", "The function of the agent with respect to the activity. The security role enabling the agent with respect to the activity.", 0, java.lang.Integer.MAX_VALUE, role));
423          children.add(new Property("who[x]", "uri|Reference(Practitioner|RelatedPerson|Patient|Device|Organization)", "The individual, device or organization that participated in the event.", 0, 1, who));
424          children.add(new Property("onBehalfOf[x]", "uri|Reference(Practitioner|RelatedPerson|Patient|Device|Organization)", "The individual, device, or organization for whom the change was made.", 0, 1, onBehalfOf));
425          children.add(new Property("relatedAgentType", "CodeableConcept", "The type of relationship between agents.", 0, 1, relatedAgentType));
426        }
427
428        @Override
429        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
430          switch (_hash) {
431          case 3506294: /*role*/  return new Property("role", "CodeableConcept", "The function of the agent with respect to the activity. The security role enabling the agent with respect to the activity.", 0, java.lang.Integer.MAX_VALUE, role);
432          case -788654078: /*who[x]*/  return new Property("who[x]", "uri|Reference(Practitioner|RelatedPerson|Patient|Device|Organization)", "The individual, device or organization that participated in the event.", 0, 1, who);
433          case 117694: /*who*/  return new Property("who[x]", "uri|Reference(Practitioner|RelatedPerson|Patient|Device|Organization)", "The individual, device or organization that participated in the event.", 0, 1, who);
434          case -788660018: /*whoUri*/  return new Property("who[x]", "uri|Reference(Practitioner|RelatedPerson|Patient|Device|Organization)", "The individual, device or organization that participated in the event.", 0, 1, who);
435          case 1017243949: /*whoReference*/  return new Property("who[x]", "uri|Reference(Practitioner|RelatedPerson|Patient|Device|Organization)", "The individual, device or organization that participated in the event.", 0, 1, who);
436          case 418120340: /*onBehalfOf[x]*/  return new Property("onBehalfOf[x]", "uri|Reference(Practitioner|RelatedPerson|Patient|Device|Organization)", "The individual, device, or organization for whom the change was made.", 0, 1, onBehalfOf);
437          case -14402964: /*onBehalfOf*/  return new Property("onBehalfOf[x]", "uri|Reference(Practitioner|RelatedPerson|Patient|Device|Organization)", "The individual, device, or organization for whom the change was made.", 0, 1, onBehalfOf);
438          case 418114400: /*onBehalfOfUri*/  return new Property("onBehalfOf[x]", "uri|Reference(Practitioner|RelatedPerson|Patient|Device|Organization)", "The individual, device, or organization for whom the change was made.", 0, 1, onBehalfOf);
439          case -1136255425: /*onBehalfOfReference*/  return new Property("onBehalfOf[x]", "uri|Reference(Practitioner|RelatedPerson|Patient|Device|Organization)", "The individual, device, or organization for whom the change was made.", 0, 1, onBehalfOf);
440          case 1228161012: /*relatedAgentType*/  return new Property("relatedAgentType", "CodeableConcept", "The type of relationship between agents.", 0, 1, relatedAgentType);
441          default: return super.getNamedProperty(_hash, _name, _checkValid);
442          }
443
444        }
445
446      @Override
447      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
448        switch (hash) {
449        case 3506294: /*role*/ return this.role == null ? new Base[0] : this.role.toArray(new Base[this.role.size()]); // CodeableConcept
450        case 117694: /*who*/ return this.who == null ? new Base[0] : new Base[] {this.who}; // Type
451        case -14402964: /*onBehalfOf*/ return this.onBehalfOf == null ? new Base[0] : new Base[] {this.onBehalfOf}; // Type
452        case 1228161012: /*relatedAgentType*/ return this.relatedAgentType == null ? new Base[0] : new Base[] {this.relatedAgentType}; // CodeableConcept
453        default: return super.getProperty(hash, name, checkValid);
454        }
455
456      }
457
458      @Override
459      public Base setProperty(int hash, String name, Base value) throws FHIRException {
460        switch (hash) {
461        case 3506294: // role
462          this.getRole().add(castToCodeableConcept(value)); // CodeableConcept
463          return value;
464        case 117694: // who
465          this.who = castToType(value); // Type
466          return value;
467        case -14402964: // onBehalfOf
468          this.onBehalfOf = castToType(value); // Type
469          return value;
470        case 1228161012: // relatedAgentType
471          this.relatedAgentType = castToCodeableConcept(value); // CodeableConcept
472          return value;
473        default: return super.setProperty(hash, name, value);
474        }
475
476      }
477
478      @Override
479      public Base setProperty(String name, Base value) throws FHIRException {
480        if (name.equals("role")) {
481          this.getRole().add(castToCodeableConcept(value));
482        } else if (name.equals("who[x]")) {
483          this.who = castToType(value); // Type
484        } else if (name.equals("onBehalfOf[x]")) {
485          this.onBehalfOf = castToType(value); // Type
486        } else if (name.equals("relatedAgentType")) {
487          this.relatedAgentType = castToCodeableConcept(value); // CodeableConcept
488        } else
489          return super.setProperty(name, value);
490        return value;
491      }
492
493      @Override
494      public Base makeProperty(int hash, String name) throws FHIRException {
495        switch (hash) {
496        case 3506294:  return addRole(); 
497        case -788654078:  return getWho(); 
498        case 117694:  return getWho(); 
499        case 418120340:  return getOnBehalfOf(); 
500        case -14402964:  return getOnBehalfOf(); 
501        case 1228161012:  return getRelatedAgentType(); 
502        default: return super.makeProperty(hash, name);
503        }
504
505      }
506
507      @Override
508      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
509        switch (hash) {
510        case 3506294: /*role*/ return new String[] {"CodeableConcept"};
511        case 117694: /*who*/ return new String[] {"uri", "Reference"};
512        case -14402964: /*onBehalfOf*/ return new String[] {"uri", "Reference"};
513        case 1228161012: /*relatedAgentType*/ return new String[] {"CodeableConcept"};
514        default: return super.getTypesForProperty(hash, name);
515        }
516
517      }
518
519      @Override
520      public Base addChild(String name) throws FHIRException {
521        if (name.equals("role")) {
522          return addRole();
523        }
524        else if (name.equals("whoUri")) {
525          this.who = new UriType();
526          return this.who;
527        }
528        else if (name.equals("whoReference")) {
529          this.who = new Reference();
530          return this.who;
531        }
532        else if (name.equals("onBehalfOfUri")) {
533          this.onBehalfOf = new UriType();
534          return this.onBehalfOf;
535        }
536        else if (name.equals("onBehalfOfReference")) {
537          this.onBehalfOf = new Reference();
538          return this.onBehalfOf;
539        }
540        else if (name.equals("relatedAgentType")) {
541          this.relatedAgentType = new CodeableConcept();
542          return this.relatedAgentType;
543        }
544        else
545          return super.addChild(name);
546      }
547
548      public ProvenanceAgentComponent copy() {
549        ProvenanceAgentComponent dst = new ProvenanceAgentComponent();
550        copyValues(dst);
551        if (role != null) {
552          dst.role = new ArrayList<CodeableConcept>();
553          for (CodeableConcept i : role)
554            dst.role.add(i.copy());
555        };
556        dst.who = who == null ? null : who.copy();
557        dst.onBehalfOf = onBehalfOf == null ? null : onBehalfOf.copy();
558        dst.relatedAgentType = relatedAgentType == null ? null : relatedAgentType.copy();
559        return dst;
560      }
561
562      @Override
563      public boolean equalsDeep(Base other_) {
564        if (!super.equalsDeep(other_))
565          return false;
566        if (!(other_ instanceof ProvenanceAgentComponent))
567          return false;
568        ProvenanceAgentComponent o = (ProvenanceAgentComponent) other_;
569        return compareDeep(role, o.role, true) && compareDeep(who, o.who, true) && compareDeep(onBehalfOf, o.onBehalfOf, true)
570           && compareDeep(relatedAgentType, o.relatedAgentType, true);
571      }
572
573      @Override
574      public boolean equalsShallow(Base other_) {
575        if (!super.equalsShallow(other_))
576          return false;
577        if (!(other_ instanceof ProvenanceAgentComponent))
578          return false;
579        ProvenanceAgentComponent o = (ProvenanceAgentComponent) other_;
580        return true;
581      }
582
583      public boolean isEmpty() {
584        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(role, who, onBehalfOf, relatedAgentType
585          );
586      }
587
588  public String fhirType() {
589    return "Provenance.agent";
590
591  }
592
593  }
594
595    @Block()
596    public static class ProvenanceEntityComponent extends BackboneElement implements IBaseBackboneElement {
597        /**
598         * How the entity was used during the activity.
599         */
600        @Child(name = "role", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=true)
601        @Description(shortDefinition="derivation | revision | quotation | source | removal", formalDefinition="How the entity was used during the activity." )
602        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/provenance-entity-role")
603        protected Enumeration<ProvenanceEntityRole> role;
604
605        /**
606         * Identity of the  Entity used. May be a logical or physical uri and maybe absolute or relative.
607         */
608        @Child(name = "what", type = {UriType.class, Reference.class, Identifier.class}, order=2, min=1, max=1, modifier=false, summary=true)
609        @Description(shortDefinition="Identity of entity", formalDefinition="Identity of the  Entity used. May be a logical or physical uri and maybe absolute or relative." )
610        protected Type what;
611
612        /**
613         * The entity is attributed to an agent to express the agent's responsibility for that entity, possibly along with other agents. This description can be understood as shorthand for saying that the agent was responsible for the activity which generated the entity.
614         */
615        @Child(name = "agent", type = {ProvenanceAgentComponent.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
616        @Description(shortDefinition="Entity is attributed to this agent", formalDefinition="The entity is attributed to an agent to express the agent's responsibility for that entity, possibly along with other agents. This description can be understood as shorthand for saying that the agent was responsible for the activity which generated the entity." )
617        protected List<ProvenanceAgentComponent> agent;
618
619        private static final long serialVersionUID = 1436676923L;
620
621    /**
622     * Constructor
623     */
624      public ProvenanceEntityComponent() {
625        super();
626      }
627
628    /**
629     * Constructor
630     */
631      public ProvenanceEntityComponent(Enumeration<ProvenanceEntityRole> role, Type what) {
632        super();
633        this.role = role;
634        this.what = what;
635      }
636
637        /**
638         * @return {@link #role} (How the entity was used during the activity.). This is the underlying object with id, value and extensions. The accessor "getRole" gives direct access to the value
639         */
640        public Enumeration<ProvenanceEntityRole> getRoleElement() { 
641          if (this.role == null)
642            if (Configuration.errorOnAutoCreate())
643              throw new Error("Attempt to auto-create ProvenanceEntityComponent.role");
644            else if (Configuration.doAutoCreate())
645              this.role = new Enumeration<ProvenanceEntityRole>(new ProvenanceEntityRoleEnumFactory()); // bb
646          return this.role;
647        }
648
649        public boolean hasRoleElement() { 
650          return this.role != null && !this.role.isEmpty();
651        }
652
653        public boolean hasRole() { 
654          return this.role != null && !this.role.isEmpty();
655        }
656
657        /**
658         * @param value {@link #role} (How the entity was used during the activity.). This is the underlying object with id, value and extensions. The accessor "getRole" gives direct access to the value
659         */
660        public ProvenanceEntityComponent setRoleElement(Enumeration<ProvenanceEntityRole> value) { 
661          this.role = value;
662          return this;
663        }
664
665        /**
666         * @return How the entity was used during the activity.
667         */
668        public ProvenanceEntityRole getRole() { 
669          return this.role == null ? null : this.role.getValue();
670        }
671
672        /**
673         * @param value How the entity was used during the activity.
674         */
675        public ProvenanceEntityComponent setRole(ProvenanceEntityRole value) { 
676            if (this.role == null)
677              this.role = new Enumeration<ProvenanceEntityRole>(new ProvenanceEntityRoleEnumFactory());
678            this.role.setValue(value);
679          return this;
680        }
681
682        /**
683         * @return {@link #what} (Identity of the  Entity used. May be a logical or physical uri and maybe absolute or relative.)
684         */
685        public Type getWhat() { 
686          return this.what;
687        }
688
689        /**
690         * @return {@link #what} (Identity of the  Entity used. May be a logical or physical uri and maybe absolute or relative.)
691         */
692        public UriType getWhatUriType() throws FHIRException { 
693          if (this.what == null)
694            return null;
695          if (!(this.what instanceof UriType))
696            throw new FHIRException("Type mismatch: the type UriType was expected, but "+this.what.getClass().getName()+" was encountered");
697          return (UriType) this.what;
698        }
699
700        public boolean hasWhatUriType() { 
701          return this != null && this.what instanceof UriType;
702        }
703
704        /**
705         * @return {@link #what} (Identity of the  Entity used. May be a logical or physical uri and maybe absolute or relative.)
706         */
707        public Reference getWhatReference() throws FHIRException { 
708          if (this.what == null)
709            return null;
710          if (!(this.what instanceof Reference))
711            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.what.getClass().getName()+" was encountered");
712          return (Reference) this.what;
713        }
714
715        public boolean hasWhatReference() { 
716          return this != null && this.what instanceof Reference;
717        }
718
719        /**
720         * @return {@link #what} (Identity of the  Entity used. May be a logical or physical uri and maybe absolute or relative.)
721         */
722        public Identifier getWhatIdentifier() throws FHIRException { 
723          if (this.what == null)
724            return null;
725          if (!(this.what instanceof Identifier))
726            throw new FHIRException("Type mismatch: the type Identifier was expected, but "+this.what.getClass().getName()+" was encountered");
727          return (Identifier) this.what;
728        }
729
730        public boolean hasWhatIdentifier() { 
731          return this != null && this.what instanceof Identifier;
732        }
733
734        public boolean hasWhat() { 
735          return this.what != null && !this.what.isEmpty();
736        }
737
738        /**
739         * @param value {@link #what} (Identity of the  Entity used. May be a logical or physical uri and maybe absolute or relative.)
740         */
741        public ProvenanceEntityComponent setWhat(Type value) throws FHIRFormatError { 
742          if (value != null && !(value instanceof UriType || value instanceof Reference || value instanceof Identifier))
743            throw new FHIRFormatError("Not the right type for Provenance.entity.what[x]: "+value.fhirType());
744          this.what = value;
745          return this;
746        }
747
748        /**
749         * @return {@link #agent} (The entity is attributed to an agent to express the agent's responsibility for that entity, possibly along with other agents. This description can be understood as shorthand for saying that the agent was responsible for the activity which generated the entity.)
750         */
751        public List<ProvenanceAgentComponent> getAgent() { 
752          if (this.agent == null)
753            this.agent = new ArrayList<ProvenanceAgentComponent>();
754          return this.agent;
755        }
756
757        /**
758         * @return Returns a reference to <code>this</code> for easy method chaining
759         */
760        public ProvenanceEntityComponent setAgent(List<ProvenanceAgentComponent> theAgent) { 
761          this.agent = theAgent;
762          return this;
763        }
764
765        public boolean hasAgent() { 
766          if (this.agent == null)
767            return false;
768          for (ProvenanceAgentComponent item : this.agent)
769            if (!item.isEmpty())
770              return true;
771          return false;
772        }
773
774        public ProvenanceAgentComponent addAgent() { //3
775          ProvenanceAgentComponent t = new ProvenanceAgentComponent();
776          if (this.agent == null)
777            this.agent = new ArrayList<ProvenanceAgentComponent>();
778          this.agent.add(t);
779          return t;
780        }
781
782        public ProvenanceEntityComponent addAgent(ProvenanceAgentComponent t) { //3
783          if (t == null)
784            return this;
785          if (this.agent == null)
786            this.agent = new ArrayList<ProvenanceAgentComponent>();
787          this.agent.add(t);
788          return this;
789        }
790
791        /**
792         * @return The first repetition of repeating field {@link #agent}, creating it if it does not already exist
793         */
794        public ProvenanceAgentComponent getAgentFirstRep() { 
795          if (getAgent().isEmpty()) {
796            addAgent();
797          }
798          return getAgent().get(0);
799        }
800
801        protected void listChildren(List<Property> children) {
802          super.listChildren(children);
803          children.add(new Property("role", "code", "How the entity was used during the activity.", 0, 1, role));
804          children.add(new Property("what[x]", "uri|Reference(Any)|Identifier", "Identity of the  Entity used. May be a logical or physical uri and maybe absolute or relative.", 0, 1, what));
805          children.add(new Property("agent", "@Provenance.agent", "The entity is attributed to an agent to express the agent's responsibility for that entity, possibly along with other agents. This description can be understood as shorthand for saying that the agent was responsible for the activity which generated the entity.", 0, java.lang.Integer.MAX_VALUE, agent));
806        }
807
808        @Override
809        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
810          switch (_hash) {
811          case 3506294: /*role*/  return new Property("role", "code", "How the entity was used during the activity.", 0, 1, role);
812          case 1309315900: /*what[x]*/  return new Property("what[x]", "uri|Reference(Any)|Identifier", "Identity of the  Entity used. May be a logical or physical uri and maybe absolute or relative.", 0, 1, what);
813          case 3648196: /*what*/  return new Property("what[x]", "uri|Reference(Any)|Identifier", "Identity of the  Entity used. May be a logical or physical uri and maybe absolute or relative.", 0, 1, what);
814          case 1309309960: /*whatUri*/  return new Property("what[x]", "uri|Reference(Any)|Identifier", "Identity of the  Entity used. May be a logical or physical uri and maybe absolute or relative.", 0, 1, what);
815          case 1531941095: /*whatReference*/  return new Property("what[x]", "uri|Reference(Any)|Identifier", "Identity of the  Entity used. May be a logical or physical uri and maybe absolute or relative.", 0, 1, what);
816          case 1537117837: /*whatIdentifier*/  return new Property("what[x]", "uri|Reference(Any)|Identifier", "Identity of the  Entity used. May be a logical or physical uri and maybe absolute or relative.", 0, 1, what);
817          case 92750597: /*agent*/  return new Property("agent", "@Provenance.agent", "The entity is attributed to an agent to express the agent's responsibility for that entity, possibly along with other agents. This description can be understood as shorthand for saying that the agent was responsible for the activity which generated the entity.", 0, java.lang.Integer.MAX_VALUE, agent);
818          default: return super.getNamedProperty(_hash, _name, _checkValid);
819          }
820
821        }
822
823      @Override
824      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
825        switch (hash) {
826        case 3506294: /*role*/ return this.role == null ? new Base[0] : new Base[] {this.role}; // Enumeration<ProvenanceEntityRole>
827        case 3648196: /*what*/ return this.what == null ? new Base[0] : new Base[] {this.what}; // Type
828        case 92750597: /*agent*/ return this.agent == null ? new Base[0] : this.agent.toArray(new Base[this.agent.size()]); // ProvenanceAgentComponent
829        default: return super.getProperty(hash, name, checkValid);
830        }
831
832      }
833
834      @Override
835      public Base setProperty(int hash, String name, Base value) throws FHIRException {
836        switch (hash) {
837        case 3506294: // role
838          value = new ProvenanceEntityRoleEnumFactory().fromType(castToCode(value));
839          this.role = (Enumeration) value; // Enumeration<ProvenanceEntityRole>
840          return value;
841        case 3648196: // what
842          this.what = castToType(value); // Type
843          return value;
844        case 92750597: // agent
845          this.getAgent().add((ProvenanceAgentComponent) value); // ProvenanceAgentComponent
846          return value;
847        default: return super.setProperty(hash, name, value);
848        }
849
850      }
851
852      @Override
853      public Base setProperty(String name, Base value) throws FHIRException {
854        if (name.equals("role")) {
855          value = new ProvenanceEntityRoleEnumFactory().fromType(castToCode(value));
856          this.role = (Enumeration) value; // Enumeration<ProvenanceEntityRole>
857        } else if (name.equals("what[x]")) {
858          this.what = castToType(value); // Type
859        } else if (name.equals("agent")) {
860          this.getAgent().add((ProvenanceAgentComponent) value);
861        } else
862          return super.setProperty(name, value);
863        return value;
864      }
865
866      @Override
867      public Base makeProperty(int hash, String name) throws FHIRException {
868        switch (hash) {
869        case 3506294:  return getRoleElement();
870        case 1309315900:  return getWhat(); 
871        case 3648196:  return getWhat(); 
872        case 92750597:  return addAgent(); 
873        default: return super.makeProperty(hash, name);
874        }
875
876      }
877
878      @Override
879      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
880        switch (hash) {
881        case 3506294: /*role*/ return new String[] {"code"};
882        case 3648196: /*what*/ return new String[] {"uri", "Reference", "Identifier"};
883        case 92750597: /*agent*/ return new String[] {"@Provenance.agent"};
884        default: return super.getTypesForProperty(hash, name);
885        }
886
887      }
888
889      @Override
890      public Base addChild(String name) throws FHIRException {
891        if (name.equals("role")) {
892          throw new FHIRException("Cannot call addChild on a primitive type Provenance.role");
893        }
894        else if (name.equals("whatUri")) {
895          this.what = new UriType();
896          return this.what;
897        }
898        else if (name.equals("whatReference")) {
899          this.what = new Reference();
900          return this.what;
901        }
902        else if (name.equals("whatIdentifier")) {
903          this.what = new Identifier();
904          return this.what;
905        }
906        else if (name.equals("agent")) {
907          return addAgent();
908        }
909        else
910          return super.addChild(name);
911      }
912
913      public ProvenanceEntityComponent copy() {
914        ProvenanceEntityComponent dst = new ProvenanceEntityComponent();
915        copyValues(dst);
916        dst.role = role == null ? null : role.copy();
917        dst.what = what == null ? null : what.copy();
918        if (agent != null) {
919          dst.agent = new ArrayList<ProvenanceAgentComponent>();
920          for (ProvenanceAgentComponent i : agent)
921            dst.agent.add(i.copy());
922        };
923        return dst;
924      }
925
926      @Override
927      public boolean equalsDeep(Base other_) {
928        if (!super.equalsDeep(other_))
929          return false;
930        if (!(other_ instanceof ProvenanceEntityComponent))
931          return false;
932        ProvenanceEntityComponent o = (ProvenanceEntityComponent) other_;
933        return compareDeep(role, o.role, true) && compareDeep(what, o.what, true) && compareDeep(agent, o.agent, true)
934          ;
935      }
936
937      @Override
938      public boolean equalsShallow(Base other_) {
939        if (!super.equalsShallow(other_))
940          return false;
941        if (!(other_ instanceof ProvenanceEntityComponent))
942          return false;
943        ProvenanceEntityComponent o = (ProvenanceEntityComponent) other_;
944        return compareValues(role, o.role, true);
945      }
946
947      public boolean isEmpty() {
948        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(role, what, agent);
949      }
950
951  public String fhirType() {
952    return "Provenance.entity";
953
954  }
955
956  }
957
958    /**
959     * The Reference(s) that were generated or updated by  the activity described in this resource. A provenance can point to more than one target if multiple resources were created/updated by the same activity.
960     */
961    @Child(name = "target", type = {Reference.class}, order=0, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
962    @Description(shortDefinition="Target Reference(s) (usually version specific)", formalDefinition="The Reference(s) that were generated or updated by  the activity described in this resource. A provenance can point to more than one target if multiple resources were created/updated by the same activity." )
963    protected List<Reference> target;
964    /**
965     * The actual objects that are the target of the reference (The Reference(s) that were generated or updated by  the activity described in this resource. A provenance can point to more than one target if multiple resources were created/updated by the same activity.)
966     */
967    protected List<Resource> targetTarget;
968
969
970    /**
971     * The period during which the activity occurred.
972     */
973    @Child(name = "period", type = {Period.class}, order=1, min=0, max=1, modifier=false, summary=false)
974    @Description(shortDefinition="When the activity occurred", formalDefinition="The period during which the activity occurred." )
975    protected Period period;
976
977    /**
978     * The instant of time at which the activity was recorded.
979     */
980    @Child(name = "recorded", type = {InstantType.class}, order=2, min=1, max=1, modifier=false, summary=true)
981    @Description(shortDefinition="When the activity was recorded / updated", formalDefinition="The instant of time at which the activity was recorded." )
982    protected InstantType recorded;
983
984    /**
985     * Policy or plan the activity was defined by. Typically, a single activity may have multiple applicable policy documents, such as patient consent, guarantor funding, etc.
986     */
987    @Child(name = "policy", type = {UriType.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
988    @Description(shortDefinition="Policy or plan the activity was defined by", formalDefinition="Policy or plan the activity was defined by. Typically, a single activity may have multiple applicable policy documents, such as patient consent, guarantor funding, etc." )
989    protected List<UriType> policy;
990
991    /**
992     * Where the activity occurred, if relevant.
993     */
994    @Child(name = "location", type = {Location.class}, order=4, min=0, max=1, modifier=false, summary=false)
995    @Description(shortDefinition="Where the activity occurred, if relevant", formalDefinition="Where the activity occurred, if relevant." )
996    protected Reference location;
997
998    /**
999     * The actual object that is the target of the reference (Where the activity occurred, if relevant.)
1000     */
1001    protected Location locationTarget;
1002
1003    /**
1004     * The reason that the activity was taking place.
1005     */
1006    @Child(name = "reason", type = {Coding.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1007    @Description(shortDefinition="Reason the activity is occurring", formalDefinition="The reason that the activity was taking place." )
1008    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/v3-PurposeOfUse")
1009    protected List<Coding> reason;
1010
1011    /**
1012     * An activity is something that occurs over a period of time and acts upon or with entities; it may include consuming, processing, transforming, modifying, relocating, using, or generating entities.
1013     */
1014    @Child(name = "activity", type = {Coding.class}, order=6, min=0, max=1, modifier=false, summary=false)
1015    @Description(shortDefinition="Activity that occurred", formalDefinition="An activity is something that occurs over a period of time and acts upon or with entities; it may include consuming, processing, transforming, modifying, relocating, using, or generating entities." )
1016    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/provenance-activity-type")
1017    protected Coding activity;
1018
1019    /**
1020     * An actor taking a role in an activity  for which it can be assigned some degree of responsibility for the activity taking place.
1021     */
1022    @Child(name = "agent", type = {}, order=7, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1023    @Description(shortDefinition="Actor involved", formalDefinition="An actor taking a role in an activity  for which it can be assigned some degree of responsibility for the activity taking place." )
1024    protected List<ProvenanceAgentComponent> agent;
1025
1026    /**
1027     * An entity used in this activity.
1028     */
1029    @Child(name = "entity", type = {}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1030    @Description(shortDefinition="An entity used in this activity", formalDefinition="An entity used in this activity." )
1031    protected List<ProvenanceEntityComponent> entity;
1032
1033    /**
1034     * A digital signature on the target Reference(s). The signer should match a Provenance.agent. The purpose of the signature is indicated.
1035     */
1036    @Child(name = "signature", type = {Signature.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1037    @Description(shortDefinition="Signature on target", formalDefinition="A digital signature on the target Reference(s). The signer should match a Provenance.agent. The purpose of the signature is indicated." )
1038    protected List<Signature> signature;
1039
1040    private static final long serialVersionUID = -1668640371L;
1041
1042  /**
1043   * Constructor
1044   */
1045    public Provenance() {
1046      super();
1047    }
1048
1049  /**
1050   * Constructor
1051   */
1052    public Provenance(InstantType recorded) {
1053      super();
1054      this.recorded = recorded;
1055    }
1056
1057    /**
1058     * @return {@link #target} (The Reference(s) that were generated or updated by  the activity described in this resource. A provenance can point to more than one target if multiple resources were created/updated by the same activity.)
1059     */
1060    public List<Reference> getTarget() { 
1061      if (this.target == null)
1062        this.target = new ArrayList<Reference>();
1063      return this.target;
1064    }
1065
1066    /**
1067     * @return Returns a reference to <code>this</code> for easy method chaining
1068     */
1069    public Provenance setTarget(List<Reference> theTarget) { 
1070      this.target = theTarget;
1071      return this;
1072    }
1073
1074    public boolean hasTarget() { 
1075      if (this.target == null)
1076        return false;
1077      for (Reference item : this.target)
1078        if (!item.isEmpty())
1079          return true;
1080      return false;
1081    }
1082
1083    public Reference addTarget() { //3
1084      Reference t = new Reference();
1085      if (this.target == null)
1086        this.target = new ArrayList<Reference>();
1087      this.target.add(t);
1088      return t;
1089    }
1090
1091    public Provenance addTarget(Reference t) { //3
1092      if (t == null)
1093        return this;
1094      if (this.target == null)
1095        this.target = new ArrayList<Reference>();
1096      this.target.add(t);
1097      return this;
1098    }
1099
1100    /**
1101     * @return The first repetition of repeating field {@link #target}, creating it if it does not already exist
1102     */
1103    public Reference getTargetFirstRep() { 
1104      if (getTarget().isEmpty()) {
1105        addTarget();
1106      }
1107      return getTarget().get(0);
1108    }
1109
1110    /**
1111     * @deprecated Use Reference#setResource(IBaseResource) instead
1112     */
1113    @Deprecated
1114    public List<Resource> getTargetTarget() { 
1115      if (this.targetTarget == null)
1116        this.targetTarget = new ArrayList<Resource>();
1117      return this.targetTarget;
1118    }
1119
1120    /**
1121     * @return {@link #period} (The period during which the activity occurred.)
1122     */
1123    public Period getPeriod() { 
1124      if (this.period == null)
1125        if (Configuration.errorOnAutoCreate())
1126          throw new Error("Attempt to auto-create Provenance.period");
1127        else if (Configuration.doAutoCreate())
1128          this.period = new Period(); // cc
1129      return this.period;
1130    }
1131
1132    public boolean hasPeriod() { 
1133      return this.period != null && !this.period.isEmpty();
1134    }
1135
1136    /**
1137     * @param value {@link #period} (The period during which the activity occurred.)
1138     */
1139    public Provenance setPeriod(Period value)  { 
1140      this.period = value;
1141      return this;
1142    }
1143
1144    /**
1145     * @return {@link #recorded} (The instant of time at which the activity was recorded.). This is the underlying object with id, value and extensions. The accessor "getRecorded" gives direct access to the value
1146     */
1147    public InstantType getRecordedElement() { 
1148      if (this.recorded == null)
1149        if (Configuration.errorOnAutoCreate())
1150          throw new Error("Attempt to auto-create Provenance.recorded");
1151        else if (Configuration.doAutoCreate())
1152          this.recorded = new InstantType(); // bb
1153      return this.recorded;
1154    }
1155
1156    public boolean hasRecordedElement() { 
1157      return this.recorded != null && !this.recorded.isEmpty();
1158    }
1159
1160    public boolean hasRecorded() { 
1161      return this.recorded != null && !this.recorded.isEmpty();
1162    }
1163
1164    /**
1165     * @param value {@link #recorded} (The instant of time at which the activity was recorded.). This is the underlying object with id, value and extensions. The accessor "getRecorded" gives direct access to the value
1166     */
1167    public Provenance setRecordedElement(InstantType value) { 
1168      this.recorded = value;
1169      return this;
1170    }
1171
1172    /**
1173     * @return The instant of time at which the activity was recorded.
1174     */
1175    public Date getRecorded() { 
1176      return this.recorded == null ? null : this.recorded.getValue();
1177    }
1178
1179    /**
1180     * @param value The instant of time at which the activity was recorded.
1181     */
1182    public Provenance setRecorded(Date value) { 
1183        if (this.recorded == null)
1184          this.recorded = new InstantType();
1185        this.recorded.setValue(value);
1186      return this;
1187    }
1188
1189    /**
1190     * @return {@link #policy} (Policy or plan the activity was defined by. Typically, a single activity may have multiple applicable policy documents, such as patient consent, guarantor funding, etc.)
1191     */
1192    public List<UriType> getPolicy() { 
1193      if (this.policy == null)
1194        this.policy = new ArrayList<UriType>();
1195      return this.policy;
1196    }
1197
1198    /**
1199     * @return Returns a reference to <code>this</code> for easy method chaining
1200     */
1201    public Provenance setPolicy(List<UriType> thePolicy) { 
1202      this.policy = thePolicy;
1203      return this;
1204    }
1205
1206    public boolean hasPolicy() { 
1207      if (this.policy == null)
1208        return false;
1209      for (UriType item : this.policy)
1210        if (!item.isEmpty())
1211          return true;
1212      return false;
1213    }
1214
1215    /**
1216     * @return {@link #policy} (Policy or plan the activity was defined by. Typically, a single activity may have multiple applicable policy documents, such as patient consent, guarantor funding, etc.)
1217     */
1218    public UriType addPolicyElement() {//2 
1219      UriType t = new UriType();
1220      if (this.policy == null)
1221        this.policy = new ArrayList<UriType>();
1222      this.policy.add(t);
1223      return t;
1224    }
1225
1226    /**
1227     * @param value {@link #policy} (Policy or plan the activity was defined by. Typically, a single activity may have multiple applicable policy documents, such as patient consent, guarantor funding, etc.)
1228     */
1229    public Provenance addPolicy(String value) { //1
1230      UriType t = new UriType();
1231      t.setValue(value);
1232      if (this.policy == null)
1233        this.policy = new ArrayList<UriType>();
1234      this.policy.add(t);
1235      return this;
1236    }
1237
1238    /**
1239     * @param value {@link #policy} (Policy or plan the activity was defined by. Typically, a single activity may have multiple applicable policy documents, such as patient consent, guarantor funding, etc.)
1240     */
1241    public boolean hasPolicy(String value) { 
1242      if (this.policy == null)
1243        return false;
1244      for (UriType v : this.policy)
1245        if (v.getValue().equals(value)) // uri
1246          return true;
1247      return false;
1248    }
1249
1250    /**
1251     * @return {@link #location} (Where the activity occurred, if relevant.)
1252     */
1253    public Reference getLocation() { 
1254      if (this.location == null)
1255        if (Configuration.errorOnAutoCreate())
1256          throw new Error("Attempt to auto-create Provenance.location");
1257        else if (Configuration.doAutoCreate())
1258          this.location = new Reference(); // cc
1259      return this.location;
1260    }
1261
1262    public boolean hasLocation() { 
1263      return this.location != null && !this.location.isEmpty();
1264    }
1265
1266    /**
1267     * @param value {@link #location} (Where the activity occurred, if relevant.)
1268     */
1269    public Provenance setLocation(Reference value)  { 
1270      this.location = value;
1271      return this;
1272    }
1273
1274    /**
1275     * @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 activity occurred, if relevant.)
1276     */
1277    public Location getLocationTarget() { 
1278      if (this.locationTarget == null)
1279        if (Configuration.errorOnAutoCreate())
1280          throw new Error("Attempt to auto-create Provenance.location");
1281        else if (Configuration.doAutoCreate())
1282          this.locationTarget = new Location(); // aa
1283      return this.locationTarget;
1284    }
1285
1286    /**
1287     * @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 activity occurred, if relevant.)
1288     */
1289    public Provenance setLocationTarget(Location value) { 
1290      this.locationTarget = value;
1291      return this;
1292    }
1293
1294    /**
1295     * @return {@link #reason} (The reason that the activity was taking place.)
1296     */
1297    public List<Coding> getReason() { 
1298      if (this.reason == null)
1299        this.reason = new ArrayList<Coding>();
1300      return this.reason;
1301    }
1302
1303    /**
1304     * @return Returns a reference to <code>this</code> for easy method chaining
1305     */
1306    public Provenance setReason(List<Coding> theReason) { 
1307      this.reason = theReason;
1308      return this;
1309    }
1310
1311    public boolean hasReason() { 
1312      if (this.reason == null)
1313        return false;
1314      for (Coding item : this.reason)
1315        if (!item.isEmpty())
1316          return true;
1317      return false;
1318    }
1319
1320    public Coding addReason() { //3
1321      Coding t = new Coding();
1322      if (this.reason == null)
1323        this.reason = new ArrayList<Coding>();
1324      this.reason.add(t);
1325      return t;
1326    }
1327
1328    public Provenance addReason(Coding t) { //3
1329      if (t == null)
1330        return this;
1331      if (this.reason == null)
1332        this.reason = new ArrayList<Coding>();
1333      this.reason.add(t);
1334      return this;
1335    }
1336
1337    /**
1338     * @return The first repetition of repeating field {@link #reason}, creating it if it does not already exist
1339     */
1340    public Coding getReasonFirstRep() { 
1341      if (getReason().isEmpty()) {
1342        addReason();
1343      }
1344      return getReason().get(0);
1345    }
1346
1347    /**
1348     * @return {@link #activity} (An activity is something that occurs over a period of time and acts upon or with entities; it may include consuming, processing, transforming, modifying, relocating, using, or generating entities.)
1349     */
1350    public Coding getActivity() { 
1351      if (this.activity == null)
1352        if (Configuration.errorOnAutoCreate())
1353          throw new Error("Attempt to auto-create Provenance.activity");
1354        else if (Configuration.doAutoCreate())
1355          this.activity = new Coding(); // cc
1356      return this.activity;
1357    }
1358
1359    public boolean hasActivity() { 
1360      return this.activity != null && !this.activity.isEmpty();
1361    }
1362
1363    /**
1364     * @param value {@link #activity} (An activity is something that occurs over a period of time and acts upon or with entities; it may include consuming, processing, transforming, modifying, relocating, using, or generating entities.)
1365     */
1366    public Provenance setActivity(Coding value)  { 
1367      this.activity = value;
1368      return this;
1369    }
1370
1371    /**
1372     * @return {@link #agent} (An actor taking a role in an activity  for which it can be assigned some degree of responsibility for the activity taking place.)
1373     */
1374    public List<ProvenanceAgentComponent> getAgent() { 
1375      if (this.agent == null)
1376        this.agent = new ArrayList<ProvenanceAgentComponent>();
1377      return this.agent;
1378    }
1379
1380    /**
1381     * @return Returns a reference to <code>this</code> for easy method chaining
1382     */
1383    public Provenance setAgent(List<ProvenanceAgentComponent> theAgent) { 
1384      this.agent = theAgent;
1385      return this;
1386    }
1387
1388    public boolean hasAgent() { 
1389      if (this.agent == null)
1390        return false;
1391      for (ProvenanceAgentComponent item : this.agent)
1392        if (!item.isEmpty())
1393          return true;
1394      return false;
1395    }
1396
1397    public ProvenanceAgentComponent addAgent() { //3
1398      ProvenanceAgentComponent t = new ProvenanceAgentComponent();
1399      if (this.agent == null)
1400        this.agent = new ArrayList<ProvenanceAgentComponent>();
1401      this.agent.add(t);
1402      return t;
1403    }
1404
1405    public Provenance addAgent(ProvenanceAgentComponent t) { //3
1406      if (t == null)
1407        return this;
1408      if (this.agent == null)
1409        this.agent = new ArrayList<ProvenanceAgentComponent>();
1410      this.agent.add(t);
1411      return this;
1412    }
1413
1414    /**
1415     * @return The first repetition of repeating field {@link #agent}, creating it if it does not already exist
1416     */
1417    public ProvenanceAgentComponent getAgentFirstRep() { 
1418      if (getAgent().isEmpty()) {
1419        addAgent();
1420      }
1421      return getAgent().get(0);
1422    }
1423
1424    /**
1425     * @return {@link #entity} (An entity used in this activity.)
1426     */
1427    public List<ProvenanceEntityComponent> getEntity() { 
1428      if (this.entity == null)
1429        this.entity = new ArrayList<ProvenanceEntityComponent>();
1430      return this.entity;
1431    }
1432
1433    /**
1434     * @return Returns a reference to <code>this</code> for easy method chaining
1435     */
1436    public Provenance setEntity(List<ProvenanceEntityComponent> theEntity) { 
1437      this.entity = theEntity;
1438      return this;
1439    }
1440
1441    public boolean hasEntity() { 
1442      if (this.entity == null)
1443        return false;
1444      for (ProvenanceEntityComponent item : this.entity)
1445        if (!item.isEmpty())
1446          return true;
1447      return false;
1448    }
1449
1450    public ProvenanceEntityComponent addEntity() { //3
1451      ProvenanceEntityComponent t = new ProvenanceEntityComponent();
1452      if (this.entity == null)
1453        this.entity = new ArrayList<ProvenanceEntityComponent>();
1454      this.entity.add(t);
1455      return t;
1456    }
1457
1458    public Provenance addEntity(ProvenanceEntityComponent t) { //3
1459      if (t == null)
1460        return this;
1461      if (this.entity == null)
1462        this.entity = new ArrayList<ProvenanceEntityComponent>();
1463      this.entity.add(t);
1464      return this;
1465    }
1466
1467    /**
1468     * @return The first repetition of repeating field {@link #entity}, creating it if it does not already exist
1469     */
1470    public ProvenanceEntityComponent getEntityFirstRep() { 
1471      if (getEntity().isEmpty()) {
1472        addEntity();
1473      }
1474      return getEntity().get(0);
1475    }
1476
1477    /**
1478     * @return {@link #signature} (A digital signature on the target Reference(s). The signer should match a Provenance.agent. The purpose of the signature is indicated.)
1479     */
1480    public List<Signature> getSignature() { 
1481      if (this.signature == null)
1482        this.signature = new ArrayList<Signature>();
1483      return this.signature;
1484    }
1485
1486    /**
1487     * @return Returns a reference to <code>this</code> for easy method chaining
1488     */
1489    public Provenance setSignature(List<Signature> theSignature) { 
1490      this.signature = theSignature;
1491      return this;
1492    }
1493
1494    public boolean hasSignature() { 
1495      if (this.signature == null)
1496        return false;
1497      for (Signature item : this.signature)
1498        if (!item.isEmpty())
1499          return true;
1500      return false;
1501    }
1502
1503    public Signature addSignature() { //3
1504      Signature t = new Signature();
1505      if (this.signature == null)
1506        this.signature = new ArrayList<Signature>();
1507      this.signature.add(t);
1508      return t;
1509    }
1510
1511    public Provenance addSignature(Signature t) { //3
1512      if (t == null)
1513        return this;
1514      if (this.signature == null)
1515        this.signature = new ArrayList<Signature>();
1516      this.signature.add(t);
1517      return this;
1518    }
1519
1520    /**
1521     * @return The first repetition of repeating field {@link #signature}, creating it if it does not already exist
1522     */
1523    public Signature getSignatureFirstRep() { 
1524      if (getSignature().isEmpty()) {
1525        addSignature();
1526      }
1527      return getSignature().get(0);
1528    }
1529
1530      protected void listChildren(List<Property> children) {
1531        super.listChildren(children);
1532        children.add(new Property("target", "Reference(Any)", "The Reference(s) that were generated or updated by  the activity described in this resource. A provenance can point to more than one target if multiple resources were created/updated by the same activity.", 0, java.lang.Integer.MAX_VALUE, target));
1533        children.add(new Property("period", "Period", "The period during which the activity occurred.", 0, 1, period));
1534        children.add(new Property("recorded", "instant", "The instant of time at which the activity was recorded.", 0, 1, recorded));
1535        children.add(new Property("policy", "uri", "Policy or plan the activity was defined by. Typically, a single activity may have multiple applicable policy documents, such as patient consent, guarantor funding, etc.", 0, java.lang.Integer.MAX_VALUE, policy));
1536        children.add(new Property("location", "Reference(Location)", "Where the activity occurred, if relevant.", 0, 1, location));
1537        children.add(new Property("reason", "Coding", "The reason that the activity was taking place.", 0, java.lang.Integer.MAX_VALUE, reason));
1538        children.add(new Property("activity", "Coding", "An activity is something that occurs over a period of time and acts upon or with entities; it may include consuming, processing, transforming, modifying, relocating, using, or generating entities.", 0, 1, activity));
1539        children.add(new Property("agent", "", "An actor taking a role in an activity  for which it can be assigned some degree of responsibility for the activity taking place.", 0, java.lang.Integer.MAX_VALUE, agent));
1540        children.add(new Property("entity", "", "An entity used in this activity.", 0, java.lang.Integer.MAX_VALUE, entity));
1541        children.add(new Property("signature", "Signature", "A digital signature on the target Reference(s). The signer should match a Provenance.agent. The purpose of the signature is indicated.", 0, java.lang.Integer.MAX_VALUE, signature));
1542      }
1543
1544      @Override
1545      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1546        switch (_hash) {
1547        case -880905839: /*target*/  return new Property("target", "Reference(Any)", "The Reference(s) that were generated or updated by  the activity described in this resource. A provenance can point to more than one target if multiple resources were created/updated by the same activity.", 0, java.lang.Integer.MAX_VALUE, target);
1548        case -991726143: /*period*/  return new Property("period", "Period", "The period during which the activity occurred.", 0, 1, period);
1549        case -799233872: /*recorded*/  return new Property("recorded", "instant", "The instant of time at which the activity was recorded.", 0, 1, recorded);
1550        case -982670030: /*policy*/  return new Property("policy", "uri", "Policy or plan the activity was defined by. Typically, a single activity may have multiple applicable policy documents, such as patient consent, guarantor funding, etc.", 0, java.lang.Integer.MAX_VALUE, policy);
1551        case 1901043637: /*location*/  return new Property("location", "Reference(Location)", "Where the activity occurred, if relevant.", 0, 1, location);
1552        case -934964668: /*reason*/  return new Property("reason", "Coding", "The reason that the activity was taking place.", 0, java.lang.Integer.MAX_VALUE, reason);
1553        case -1655966961: /*activity*/  return new Property("activity", "Coding", "An activity is something that occurs over a period of time and acts upon or with entities; it may include consuming, processing, transforming, modifying, relocating, using, or generating entities.", 0, 1, activity);
1554        case 92750597: /*agent*/  return new Property("agent", "", "An actor taking a role in an activity  for which it can be assigned some degree of responsibility for the activity taking place.", 0, java.lang.Integer.MAX_VALUE, agent);
1555        case -1298275357: /*entity*/  return new Property("entity", "", "An entity used in this activity.", 0, java.lang.Integer.MAX_VALUE, entity);
1556        case 1073584312: /*signature*/  return new Property("signature", "Signature", "A digital signature on the target Reference(s). The signer should match a Provenance.agent. The purpose of the signature is indicated.", 0, java.lang.Integer.MAX_VALUE, signature);
1557        default: return super.getNamedProperty(_hash, _name, _checkValid);
1558        }
1559
1560      }
1561
1562      @Override
1563      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1564        switch (hash) {
1565        case -880905839: /*target*/ return this.target == null ? new Base[0] : this.target.toArray(new Base[this.target.size()]); // Reference
1566        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
1567        case -799233872: /*recorded*/ return this.recorded == null ? new Base[0] : new Base[] {this.recorded}; // InstantType
1568        case -982670030: /*policy*/ return this.policy == null ? new Base[0] : this.policy.toArray(new Base[this.policy.size()]); // UriType
1569        case 1901043637: /*location*/ return this.location == null ? new Base[0] : new Base[] {this.location}; // Reference
1570        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : this.reason.toArray(new Base[this.reason.size()]); // Coding
1571        case -1655966961: /*activity*/ return this.activity == null ? new Base[0] : new Base[] {this.activity}; // Coding
1572        case 92750597: /*agent*/ return this.agent == null ? new Base[0] : this.agent.toArray(new Base[this.agent.size()]); // ProvenanceAgentComponent
1573        case -1298275357: /*entity*/ return this.entity == null ? new Base[0] : this.entity.toArray(new Base[this.entity.size()]); // ProvenanceEntityComponent
1574        case 1073584312: /*signature*/ return this.signature == null ? new Base[0] : this.signature.toArray(new Base[this.signature.size()]); // Signature
1575        default: return super.getProperty(hash, name, checkValid);
1576        }
1577
1578      }
1579
1580      @Override
1581      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1582        switch (hash) {
1583        case -880905839: // target
1584          this.getTarget().add(castToReference(value)); // Reference
1585          return value;
1586        case -991726143: // period
1587          this.period = castToPeriod(value); // Period
1588          return value;
1589        case -799233872: // recorded
1590          this.recorded = castToInstant(value); // InstantType
1591          return value;
1592        case -982670030: // policy
1593          this.getPolicy().add(castToUri(value)); // UriType
1594          return value;
1595        case 1901043637: // location
1596          this.location = castToReference(value); // Reference
1597          return value;
1598        case -934964668: // reason
1599          this.getReason().add(castToCoding(value)); // Coding
1600          return value;
1601        case -1655966961: // activity
1602          this.activity = castToCoding(value); // Coding
1603          return value;
1604        case 92750597: // agent
1605          this.getAgent().add((ProvenanceAgentComponent) value); // ProvenanceAgentComponent
1606          return value;
1607        case -1298275357: // entity
1608          this.getEntity().add((ProvenanceEntityComponent) value); // ProvenanceEntityComponent
1609          return value;
1610        case 1073584312: // signature
1611          this.getSignature().add(castToSignature(value)); // Signature
1612          return value;
1613        default: return super.setProperty(hash, name, value);
1614        }
1615
1616      }
1617
1618      @Override
1619      public Base setProperty(String name, Base value) throws FHIRException {
1620        if (name.equals("target")) {
1621          this.getTarget().add(castToReference(value));
1622        } else if (name.equals("period")) {
1623          this.period = castToPeriod(value); // Period
1624        } else if (name.equals("recorded")) {
1625          this.recorded = castToInstant(value); // InstantType
1626        } else if (name.equals("policy")) {
1627          this.getPolicy().add(castToUri(value));
1628        } else if (name.equals("location")) {
1629          this.location = castToReference(value); // Reference
1630        } else if (name.equals("reason")) {
1631          this.getReason().add(castToCoding(value));
1632        } else if (name.equals("activity")) {
1633          this.activity = castToCoding(value); // Coding
1634        } else if (name.equals("agent")) {
1635          this.getAgent().add((ProvenanceAgentComponent) value);
1636        } else if (name.equals("entity")) {
1637          this.getEntity().add((ProvenanceEntityComponent) value);
1638        } else if (name.equals("signature")) {
1639          this.getSignature().add(castToSignature(value));
1640        } else
1641          return super.setProperty(name, value);
1642        return value;
1643      }
1644
1645      @Override
1646      public Base makeProperty(int hash, String name) throws FHIRException {
1647        switch (hash) {
1648        case -880905839:  return addTarget(); 
1649        case -991726143:  return getPeriod(); 
1650        case -799233872:  return getRecordedElement();
1651        case -982670030:  return addPolicyElement();
1652        case 1901043637:  return getLocation(); 
1653        case -934964668:  return addReason(); 
1654        case -1655966961:  return getActivity(); 
1655        case 92750597:  return addAgent(); 
1656        case -1298275357:  return addEntity(); 
1657        case 1073584312:  return addSignature(); 
1658        default: return super.makeProperty(hash, name);
1659        }
1660
1661      }
1662
1663      @Override
1664      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1665        switch (hash) {
1666        case -880905839: /*target*/ return new String[] {"Reference"};
1667        case -991726143: /*period*/ return new String[] {"Period"};
1668        case -799233872: /*recorded*/ return new String[] {"instant"};
1669        case -982670030: /*policy*/ return new String[] {"uri"};
1670        case 1901043637: /*location*/ return new String[] {"Reference"};
1671        case -934964668: /*reason*/ return new String[] {"Coding"};
1672        case -1655966961: /*activity*/ return new String[] {"Coding"};
1673        case 92750597: /*agent*/ return new String[] {};
1674        case -1298275357: /*entity*/ return new String[] {};
1675        case 1073584312: /*signature*/ return new String[] {"Signature"};
1676        default: return super.getTypesForProperty(hash, name);
1677        }
1678
1679      }
1680
1681      @Override
1682      public Base addChild(String name) throws FHIRException {
1683        if (name.equals("target")) {
1684          return addTarget();
1685        }
1686        else if (name.equals("period")) {
1687          this.period = new Period();
1688          return this.period;
1689        }
1690        else if (name.equals("recorded")) {
1691          throw new FHIRException("Cannot call addChild on a primitive type Provenance.recorded");
1692        }
1693        else if (name.equals("policy")) {
1694          throw new FHIRException("Cannot call addChild on a primitive type Provenance.policy");
1695        }
1696        else if (name.equals("location")) {
1697          this.location = new Reference();
1698          return this.location;
1699        }
1700        else if (name.equals("reason")) {
1701          return addReason();
1702        }
1703        else if (name.equals("activity")) {
1704          this.activity = new Coding();
1705          return this.activity;
1706        }
1707        else if (name.equals("agent")) {
1708          return addAgent();
1709        }
1710        else if (name.equals("entity")) {
1711          return addEntity();
1712        }
1713        else if (name.equals("signature")) {
1714          return addSignature();
1715        }
1716        else
1717          return super.addChild(name);
1718      }
1719
1720  public String fhirType() {
1721    return "Provenance";
1722
1723  }
1724
1725      public Provenance copy() {
1726        Provenance dst = new Provenance();
1727        copyValues(dst);
1728        if (target != null) {
1729          dst.target = new ArrayList<Reference>();
1730          for (Reference i : target)
1731            dst.target.add(i.copy());
1732        };
1733        dst.period = period == null ? null : period.copy();
1734        dst.recorded = recorded == null ? null : recorded.copy();
1735        if (policy != null) {
1736          dst.policy = new ArrayList<UriType>();
1737          for (UriType i : policy)
1738            dst.policy.add(i.copy());
1739        };
1740        dst.location = location == null ? null : location.copy();
1741        if (reason != null) {
1742          dst.reason = new ArrayList<Coding>();
1743          for (Coding i : reason)
1744            dst.reason.add(i.copy());
1745        };
1746        dst.activity = activity == null ? null : activity.copy();
1747        if (agent != null) {
1748          dst.agent = new ArrayList<ProvenanceAgentComponent>();
1749          for (ProvenanceAgentComponent i : agent)
1750            dst.agent.add(i.copy());
1751        };
1752        if (entity != null) {
1753          dst.entity = new ArrayList<ProvenanceEntityComponent>();
1754          for (ProvenanceEntityComponent i : entity)
1755            dst.entity.add(i.copy());
1756        };
1757        if (signature != null) {
1758          dst.signature = new ArrayList<Signature>();
1759          for (Signature i : signature)
1760            dst.signature.add(i.copy());
1761        };
1762        return dst;
1763      }
1764
1765      protected Provenance typedCopy() {
1766        return copy();
1767      }
1768
1769      @Override
1770      public boolean equalsDeep(Base other_) {
1771        if (!super.equalsDeep(other_))
1772          return false;
1773        if (!(other_ instanceof Provenance))
1774          return false;
1775        Provenance o = (Provenance) other_;
1776        return compareDeep(target, o.target, true) && compareDeep(period, o.period, true) && compareDeep(recorded, o.recorded, true)
1777           && compareDeep(policy, o.policy, true) && compareDeep(location, o.location, true) && compareDeep(reason, o.reason, true)
1778           && compareDeep(activity, o.activity, true) && compareDeep(agent, o.agent, true) && compareDeep(entity, o.entity, true)
1779           && compareDeep(signature, o.signature, true);
1780      }
1781
1782      @Override
1783      public boolean equalsShallow(Base other_) {
1784        if (!super.equalsShallow(other_))
1785          return false;
1786        if (!(other_ instanceof Provenance))
1787          return false;
1788        Provenance o = (Provenance) other_;
1789        return compareValues(recorded, o.recorded, true) && compareValues(policy, o.policy, true);
1790      }
1791
1792      public boolean isEmpty() {
1793        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(target, period, recorded
1794          , policy, location, reason, activity, agent, entity, signature);
1795      }
1796
1797  @Override
1798  public ResourceType getResourceType() {
1799    return ResourceType.Provenance;
1800   }
1801
1802 /**
1803   * Search parameter: <b>entity-ref</b>
1804   * <p>
1805   * Description: <b>Identity of entity</b><br>
1806   * Type: <b>reference</b><br>
1807   * Path: <b>Provenance.entity.whatReference</b><br>
1808   * </p>
1809   */
1810  @SearchParamDefinition(name="entity-ref", path="Provenance.entity.what.as(Reference)", description="Identity of entity", type="reference" )
1811  public static final String SP_ENTITY_REF = "entity-ref";
1812 /**
1813   * <b>Fluent Client</b> search parameter constant for <b>entity-ref</b>
1814   * <p>
1815   * Description: <b>Identity of entity</b><br>
1816   * Type: <b>reference</b><br>
1817   * Path: <b>Provenance.entity.whatReference</b><br>
1818   * </p>
1819   */
1820  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENTITY_REF = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENTITY_REF);
1821
1822/**
1823   * Constant for fluent queries to be used to add include statements. Specifies
1824   * the path value of "<b>Provenance:entity-ref</b>".
1825   */
1826  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENTITY_REF = new ca.uhn.fhir.model.api.Include("Provenance:entity-ref").toLocked();
1827
1828 /**
1829   * Search parameter: <b>agent</b>
1830   * <p>
1831   * Description: <b>Who participated</b><br>
1832   * Type: <b>reference</b><br>
1833   * Path: <b>Provenance.agent.who[x]</b><br>
1834   * </p>
1835   */
1836  @SearchParamDefinition(name="agent", path="Provenance.agent.who", description="Who participated", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Device"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner"), @ca.uhn.fhir.model.api.annotation.Compartment(name="RelatedPerson") }, target={Device.class, Organization.class, Patient.class, Practitioner.class, RelatedPerson.class } )
1837  public static final String SP_AGENT = "agent";
1838 /**
1839   * <b>Fluent Client</b> search parameter constant for <b>agent</b>
1840   * <p>
1841   * Description: <b>Who participated</b><br>
1842   * Type: <b>reference</b><br>
1843   * Path: <b>Provenance.agent.who[x]</b><br>
1844   * </p>
1845   */
1846  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam AGENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_AGENT);
1847
1848/**
1849   * Constant for fluent queries to be used to add include statements. Specifies
1850   * the path value of "<b>Provenance:agent</b>".
1851   */
1852  public static final ca.uhn.fhir.model.api.Include INCLUDE_AGENT = new ca.uhn.fhir.model.api.Include("Provenance:agent").toLocked();
1853
1854 /**
1855   * Search parameter: <b>signature-type</b>
1856   * <p>
1857   * Description: <b>Indication of the reason the entity signed the object(s)</b><br>
1858   * Type: <b>token</b><br>
1859   * Path: <b>Provenance.signature.type</b><br>
1860   * </p>
1861   */
1862  @SearchParamDefinition(name="signature-type", path="Provenance.signature.type", description="Indication of the reason the entity signed the object(s)", type="token" )
1863  public static final String SP_SIGNATURE_TYPE = "signature-type";
1864 /**
1865   * <b>Fluent Client</b> search parameter constant for <b>signature-type</b>
1866   * <p>
1867   * Description: <b>Indication of the reason the entity signed the object(s)</b><br>
1868   * Type: <b>token</b><br>
1869   * Path: <b>Provenance.signature.type</b><br>
1870   * </p>
1871   */
1872  public static final ca.uhn.fhir.rest.gclient.TokenClientParam SIGNATURE_TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_SIGNATURE_TYPE);
1873
1874 /**
1875   * Search parameter: <b>patient</b>
1876   * <p>
1877   * Description: <b>Target Reference(s) (usually version specific)</b><br>
1878   * Type: <b>reference</b><br>
1879   * Path: <b>Provenance.target</b><br>
1880   * </p>
1881   */
1882  @SearchParamDefinition(name="patient", path="Provenance.target", description="Target Reference(s) (usually version specific)", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Patient.class } )
1883  public static final String SP_PATIENT = "patient";
1884 /**
1885   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
1886   * <p>
1887   * Description: <b>Target Reference(s) (usually version specific)</b><br>
1888   * Type: <b>reference</b><br>
1889   * Path: <b>Provenance.target</b><br>
1890   * </p>
1891   */
1892  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
1893
1894/**
1895   * Constant for fluent queries to be used to add include statements. Specifies
1896   * the path value of "<b>Provenance:patient</b>".
1897   */
1898  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("Provenance:patient").toLocked();
1899
1900 /**
1901   * Search parameter: <b>start</b>
1902   * <p>
1903   * Description: <b>Starting time with inclusive boundary</b><br>
1904   * Type: <b>date</b><br>
1905   * Path: <b>Provenance.period.start</b><br>
1906   * </p>
1907   */
1908  @SearchParamDefinition(name="start", path="Provenance.period.start", description="Starting time with inclusive boundary", type="date" )
1909  public static final String SP_START = "start";
1910 /**
1911   * <b>Fluent Client</b> search parameter constant for <b>start</b>
1912   * <p>
1913   * Description: <b>Starting time with inclusive boundary</b><br>
1914   * Type: <b>date</b><br>
1915   * Path: <b>Provenance.period.start</b><br>
1916   * </p>
1917   */
1918  public static final ca.uhn.fhir.rest.gclient.DateClientParam START = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_START);
1919
1920 /**
1921   * Search parameter: <b>end</b>
1922   * <p>
1923   * Description: <b>End time with inclusive boundary, if not ongoing</b><br>
1924   * Type: <b>date</b><br>
1925   * Path: <b>Provenance.period.end</b><br>
1926   * </p>
1927   */
1928  @SearchParamDefinition(name="end", path="Provenance.period.end", description="End time with inclusive boundary, if not ongoing", type="date" )
1929  public static final String SP_END = "end";
1930 /**
1931   * <b>Fluent Client</b> search parameter constant for <b>end</b>
1932   * <p>
1933   * Description: <b>End time with inclusive boundary, if not ongoing</b><br>
1934   * Type: <b>date</b><br>
1935   * Path: <b>Provenance.period.end</b><br>
1936   * </p>
1937   */
1938  public static final ca.uhn.fhir.rest.gclient.DateClientParam END = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_END);
1939
1940 /**
1941   * Search parameter: <b>location</b>
1942   * <p>
1943   * Description: <b>Where the activity occurred, if relevant</b><br>
1944   * Type: <b>reference</b><br>
1945   * Path: <b>Provenance.location</b><br>
1946   * </p>
1947   */
1948  @SearchParamDefinition(name="location", path="Provenance.location", description="Where the activity occurred, if relevant", type="reference", target={Location.class } )
1949  public static final String SP_LOCATION = "location";
1950 /**
1951   * <b>Fluent Client</b> search parameter constant for <b>location</b>
1952   * <p>
1953   * Description: <b>Where the activity occurred, if relevant</b><br>
1954   * Type: <b>reference</b><br>
1955   * Path: <b>Provenance.location</b><br>
1956   * </p>
1957   */
1958  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam LOCATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_LOCATION);
1959
1960/**
1961   * Constant for fluent queries to be used to add include statements. Specifies
1962   * the path value of "<b>Provenance:location</b>".
1963   */
1964  public static final ca.uhn.fhir.model.api.Include INCLUDE_LOCATION = new ca.uhn.fhir.model.api.Include("Provenance:location").toLocked();
1965
1966 /**
1967   * Search parameter: <b>recorded</b>
1968   * <p>
1969   * Description: <b>When the activity was recorded / updated</b><br>
1970   * Type: <b>date</b><br>
1971   * Path: <b>Provenance.recorded</b><br>
1972   * </p>
1973   */
1974  @SearchParamDefinition(name="recorded", path="Provenance.recorded", description="When the activity was recorded / updated", type="date" )
1975  public static final String SP_RECORDED = "recorded";
1976 /**
1977   * <b>Fluent Client</b> search parameter constant for <b>recorded</b>
1978   * <p>
1979   * Description: <b>When the activity was recorded / updated</b><br>
1980   * Type: <b>date</b><br>
1981   * Path: <b>Provenance.recorded</b><br>
1982   * </p>
1983   */
1984  public static final ca.uhn.fhir.rest.gclient.DateClientParam RECORDED = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_RECORDED);
1985
1986 /**
1987   * Search parameter: <b>agent-role</b>
1988   * <p>
1989   * Description: <b>What the agents role was</b><br>
1990   * Type: <b>token</b><br>
1991   * Path: <b>Provenance.agent.role</b><br>
1992   * </p>
1993   */
1994  @SearchParamDefinition(name="agent-role", path="Provenance.agent.role", description="What the agents role was", type="token" )
1995  public static final String SP_AGENT_ROLE = "agent-role";
1996 /**
1997   * <b>Fluent Client</b> search parameter constant for <b>agent-role</b>
1998   * <p>
1999   * Description: <b>What the agents role was</b><br>
2000   * Type: <b>token</b><br>
2001   * Path: <b>Provenance.agent.role</b><br>
2002   * </p>
2003   */
2004  public static final ca.uhn.fhir.rest.gclient.TokenClientParam AGENT_ROLE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_AGENT_ROLE);
2005
2006 /**
2007   * Search parameter: <b>entity-id</b>
2008   * <p>
2009   * Description: <b>Identity of entity</b><br>
2010   * Type: <b>token</b><br>
2011   * Path: <b>Provenance.entity.whatIdentifier</b><br>
2012   * </p>
2013   */
2014  @SearchParamDefinition(name="entity-id", path="Provenance.entity.what.as(Identifier)", description="Identity of entity", type="token" )
2015  public static final String SP_ENTITY_ID = "entity-id";
2016 /**
2017   * <b>Fluent Client</b> search parameter constant for <b>entity-id</b>
2018   * <p>
2019   * Description: <b>Identity of entity</b><br>
2020   * Type: <b>token</b><br>
2021   * Path: <b>Provenance.entity.whatIdentifier</b><br>
2022   * </p>
2023   */
2024  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ENTITY_ID = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_ENTITY_ID);
2025
2026 /**
2027   * Search parameter: <b>target</b>
2028   * <p>
2029   * Description: <b>Target Reference(s) (usually version specific)</b><br>
2030   * Type: <b>reference</b><br>
2031   * Path: <b>Provenance.target</b><br>
2032   * </p>
2033   */
2034  @SearchParamDefinition(name="target", path="Provenance.target", description="Target Reference(s) (usually version specific)", type="reference" )
2035  public static final String SP_TARGET = "target";
2036 /**
2037   * <b>Fluent Client</b> search parameter constant for <b>target</b>
2038   * <p>
2039   * Description: <b>Target Reference(s) (usually version specific)</b><br>
2040   * Type: <b>reference</b><br>
2041   * Path: <b>Provenance.target</b><br>
2042   * </p>
2043   */
2044  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam TARGET = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_TARGET);
2045
2046/**
2047   * Constant for fluent queries to be used to add include statements. Specifies
2048   * the path value of "<b>Provenance:target</b>".
2049   */
2050  public static final ca.uhn.fhir.model.api.Include INCLUDE_TARGET = new ca.uhn.fhir.model.api.Include("Provenance:target").toLocked();
2051
2052
2053}
2054