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