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