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