001package org.hl7.fhir.instance.model; 002 003/* 004 Copyright (c) 2011+, HL7, Inc. 005 All rights reserved. 006 007 Redistribution and use in source and binary forms, with or without modification, 008 are permitted provided that the following conditions are met: 009 010 * Redistributions of source code must retain the above copyright notice, this 011 list of conditions and the following disclaimer. 012 * Redistributions in binary form must reproduce the above copyright notice, 013 this list of conditions and the following disclaimer in the documentation 014 and/or other materials provided with the distribution. 015 * Neither the name of HL7 nor the names of its contributors may be used to 016 endorse or promote products derived from this software without specific 017 prior written permission. 018 019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 020 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 021 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 022 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 023 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 024 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 025 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 026 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 027 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 028 POSSIBILITY OF SUCH DAMAGE. 029 030*/ 031 032// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2 033import java.util.*; 034 035import org.hl7.fhir.exceptions.FHIRException; 036import org.hl7.fhir.instance.model.api.IBaseBackboneElement; 037import org.hl7.fhir.utilities.Utilities; 038 039import ca.uhn.fhir.model.api.annotation.*; 040/** 041 * 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. 042 */ 043@ResourceDef(name="Provenance", profile="http://hl7.org/fhir/Profile/Provenance") 044public class Provenance extends DomainResource { 045 046 public enum ProvenanceEntityRole { 047 /** 048 * 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. 049 */ 050 DERIVATION, 051 /** 052 * A derivation for which the resulting entity is a revised version of some original. 053 */ 054 REVISION, 055 /** 056 * 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. 057 */ 058 QUOTATION, 059 /** 060 * 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. 061 */ 062 SOURCE, 063 /** 064 * added to help the parsers 065 */ 066 NULL; 067 public static ProvenanceEntityRole fromCode(String codeString) throws FHIRException { 068 if (codeString == null || "".equals(codeString)) 069 return null; 070 if ("derivation".equals(codeString)) 071 return DERIVATION; 072 if ("revision".equals(codeString)) 073 return REVISION; 074 if ("quotation".equals(codeString)) 075 return QUOTATION; 076 if ("source".equals(codeString)) 077 return SOURCE; 078 throw new FHIRException("Unknown ProvenanceEntityRole code '"+codeString+"'"); 079 } 080 public String toCode() { 081 switch (this) { 082 case DERIVATION: return "derivation"; 083 case REVISION: return "revision"; 084 case QUOTATION: return "quotation"; 085 case SOURCE: return "source"; 086 default: return "?"; 087 } 088 } 089 public String getSystem() { 090 switch (this) { 091 case DERIVATION: return "http://hl7.org/fhir/provenance-entity-role"; 092 case REVISION: return "http://hl7.org/fhir/provenance-entity-role"; 093 case QUOTATION: return "http://hl7.org/fhir/provenance-entity-role"; 094 case SOURCE: return "http://hl7.org/fhir/provenance-entity-role"; 095 default: return "?"; 096 } 097 } 098 public String getDefinition() { 099 switch (this) { 100 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."; 101 case REVISION: return "A derivation for which the resulting entity is a revised version of some original."; 102 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."; 103 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."; 104 default: return "?"; 105 } 106 } 107 public String getDisplay() { 108 switch (this) { 109 case DERIVATION: return "Derivation"; 110 case REVISION: return "Revision"; 111 case QUOTATION: return "Quotation"; 112 case SOURCE: return "Source"; 113 default: return "?"; 114 } 115 } 116 } 117 118 public static class ProvenanceEntityRoleEnumFactory implements EnumFactory<ProvenanceEntityRole> { 119 public ProvenanceEntityRole fromCode(String codeString) throws IllegalArgumentException { 120 if (codeString == null || "".equals(codeString)) 121 if (codeString == null || "".equals(codeString)) 122 return null; 123 if ("derivation".equals(codeString)) 124 return ProvenanceEntityRole.DERIVATION; 125 if ("revision".equals(codeString)) 126 return ProvenanceEntityRole.REVISION; 127 if ("quotation".equals(codeString)) 128 return ProvenanceEntityRole.QUOTATION; 129 if ("source".equals(codeString)) 130 return ProvenanceEntityRole.SOURCE; 131 throw new IllegalArgumentException("Unknown ProvenanceEntityRole code '"+codeString+"'"); 132 } 133 public Enumeration<ProvenanceEntityRole> fromType(Base code) throws FHIRException { 134 if (code == null || code.isEmpty()) 135 return null; 136 String codeString = ((PrimitiveType) code).asStringValue(); 137 if (codeString == null || "".equals(codeString)) 138 return null; 139 if ("derivation".equals(codeString)) 140 return new Enumeration<ProvenanceEntityRole>(this, ProvenanceEntityRole.DERIVATION); 141 if ("revision".equals(codeString)) 142 return new Enumeration<ProvenanceEntityRole>(this, ProvenanceEntityRole.REVISION); 143 if ("quotation".equals(codeString)) 144 return new Enumeration<ProvenanceEntityRole>(this, ProvenanceEntityRole.QUOTATION); 145 if ("source".equals(codeString)) 146 return new Enumeration<ProvenanceEntityRole>(this, ProvenanceEntityRole.SOURCE); 147 throw new FHIRException("Unknown ProvenanceEntityRole code '"+codeString+"'"); 148 } 149 public String toCode(ProvenanceEntityRole code) { 150 if (code == ProvenanceEntityRole.DERIVATION) 151 return "derivation"; 152 if (code == ProvenanceEntityRole.REVISION) 153 return "revision"; 154 if (code == ProvenanceEntityRole.QUOTATION) 155 return "quotation"; 156 if (code == ProvenanceEntityRole.SOURCE) 157 return "source"; 158 return "?"; 159 } 160 } 161 162 @Block() 163 public static class ProvenanceAgentComponent extends BackboneElement implements IBaseBackboneElement { 164 /** 165 * The function of the agent with respect to the activity. 166 */ 167 @Child(name = "role", type = {Coding.class}, order=1, min=1, max=1, modifier=false, summary=true) 168 @Description(shortDefinition="What the agents involvement was", formalDefinition="The function of the agent with respect to the activity." ) 169 protected Coding role; 170 171 /** 172 * The individual, device or organization that participated in the event. 173 */ 174 @Child(name = "actor", type = {Practitioner.class, RelatedPerson.class, Patient.class, Device.class, Organization.class}, order=2, min=0, max=1, modifier=false, summary=true) 175 @Description(shortDefinition="Individual, device or organization playing role", formalDefinition="The individual, device or organization that participated in the event." ) 176 protected Reference actor; 177 178 /** 179 * The actual object that is the target of the reference (The individual, device or organization that participated in the event.) 180 */ 181 protected Resource actorTarget; 182 183 /** 184 * The identity of the agent as known by the authorization system. 185 */ 186 @Child(name = "userId", type = {Identifier.class}, order=3, min=0, max=1, modifier=false, summary=true) 187 @Description(shortDefinition="Authorization-system identifier for the agent", formalDefinition="The identity of the agent as known by the authorization system." ) 188 protected Identifier userId; 189 190 /** 191 * A relationship between two the agents referenced in this resource. This is defined to allow for explicit description of the delegation between agents. For example, this human author used this device, or one person acted on another's behest. 192 */ 193 @Child(name = "relatedAgent", type = {}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 194 @Description(shortDefinition="Track delegation between agents", formalDefinition="A relationship between two the agents referenced in this resource. This is defined to allow for explicit description of the delegation between agents. For example, this human author used this device, or one person acted on another's behest." ) 195 protected List<ProvenanceAgentRelatedAgentComponent> relatedAgent; 196 197 private static final long serialVersionUID = 1792758952L; 198 199 /* 200 * Constructor 201 */ 202 public ProvenanceAgentComponent() { 203 super(); 204 } 205 206 /* 207 * Constructor 208 */ 209 public ProvenanceAgentComponent(Coding role) { 210 super(); 211 this.role = role; 212 } 213 214 /** 215 * @return {@link #role} (The function of the agent with respect to the activity.) 216 */ 217 public Coding getRole() { 218 if (this.role == null) 219 if (Configuration.errorOnAutoCreate()) 220 throw new Error("Attempt to auto-create ProvenanceAgentComponent.role"); 221 else if (Configuration.doAutoCreate()) 222 this.role = new Coding(); // cc 223 return this.role; 224 } 225 226 public boolean hasRole() { 227 return this.role != null && !this.role.isEmpty(); 228 } 229 230 /** 231 * @param value {@link #role} (The function of the agent with respect to the activity.) 232 */ 233 public ProvenanceAgentComponent setRole(Coding value) { 234 this.role = value; 235 return this; 236 } 237 238 /** 239 * @return {@link #actor} (The individual, device or organization that participated in the event.) 240 */ 241 public Reference getActor() { 242 if (this.actor == null) 243 if (Configuration.errorOnAutoCreate()) 244 throw new Error("Attempt to auto-create ProvenanceAgentComponent.actor"); 245 else if (Configuration.doAutoCreate()) 246 this.actor = new Reference(); // cc 247 return this.actor; 248 } 249 250 public boolean hasActor() { 251 return this.actor != null && !this.actor.isEmpty(); 252 } 253 254 /** 255 * @param value {@link #actor} (The individual, device or organization that participated in the event.) 256 */ 257 public ProvenanceAgentComponent setActor(Reference value) { 258 this.actor = value; 259 return this; 260 } 261 262 /** 263 * @return {@link #actor} 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. (The individual, device or organization that participated in the event.) 264 */ 265 public Resource getActorTarget() { 266 return this.actorTarget; 267 } 268 269 /** 270 * @param value {@link #actor} 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. (The individual, device or organization that participated in the event.) 271 */ 272 public ProvenanceAgentComponent setActorTarget(Resource value) { 273 this.actorTarget = value; 274 return this; 275 } 276 277 /** 278 * @return {@link #userId} (The identity of the agent as known by the authorization system.) 279 */ 280 public Identifier getUserId() { 281 if (this.userId == null) 282 if (Configuration.errorOnAutoCreate()) 283 throw new Error("Attempt to auto-create ProvenanceAgentComponent.userId"); 284 else if (Configuration.doAutoCreate()) 285 this.userId = new Identifier(); // cc 286 return this.userId; 287 } 288 289 public boolean hasUserId() { 290 return this.userId != null && !this.userId.isEmpty(); 291 } 292 293 /** 294 * @param value {@link #userId} (The identity of the agent as known by the authorization system.) 295 */ 296 public ProvenanceAgentComponent setUserId(Identifier value) { 297 this.userId = value; 298 return this; 299 } 300 301 /** 302 * @return {@link #relatedAgent} (A relationship between two the agents referenced in this resource. This is defined to allow for explicit description of the delegation between agents. For example, this human author used this device, or one person acted on another's behest.) 303 */ 304 public List<ProvenanceAgentRelatedAgentComponent> getRelatedAgent() { 305 if (this.relatedAgent == null) 306 this.relatedAgent = new ArrayList<ProvenanceAgentRelatedAgentComponent>(); 307 return this.relatedAgent; 308 } 309 310 public boolean hasRelatedAgent() { 311 if (this.relatedAgent == null) 312 return false; 313 for (ProvenanceAgentRelatedAgentComponent item : this.relatedAgent) 314 if (!item.isEmpty()) 315 return true; 316 return false; 317 } 318 319 /** 320 * @return {@link #relatedAgent} (A relationship between two the agents referenced in this resource. This is defined to allow for explicit description of the delegation between agents. For example, this human author used this device, or one person acted on another's behest.) 321 */ 322 // syntactic sugar 323 public ProvenanceAgentRelatedAgentComponent addRelatedAgent() { //3 324 ProvenanceAgentRelatedAgentComponent t = new ProvenanceAgentRelatedAgentComponent(); 325 if (this.relatedAgent == null) 326 this.relatedAgent = new ArrayList<ProvenanceAgentRelatedAgentComponent>(); 327 this.relatedAgent.add(t); 328 return t; 329 } 330 331 // syntactic sugar 332 public ProvenanceAgentComponent addRelatedAgent(ProvenanceAgentRelatedAgentComponent t) { //3 333 if (t == null) 334 return this; 335 if (this.relatedAgent == null) 336 this.relatedAgent = new ArrayList<ProvenanceAgentRelatedAgentComponent>(); 337 this.relatedAgent.add(t); 338 return this; 339 } 340 341 protected void listChildren(List<Property> childrenList) { 342 super.listChildren(childrenList); 343 childrenList.add(new Property("role", "Coding", "The function of the agent with respect to the activity.", 0, java.lang.Integer.MAX_VALUE, role)); 344 childrenList.add(new Property("actor", "Reference(Practitioner|RelatedPerson|Patient|Device|Organization)", "The individual, device or organization that participated in the event.", 0, java.lang.Integer.MAX_VALUE, actor)); 345 childrenList.add(new Property("userId", "Identifier", "The identity of the agent as known by the authorization system.", 0, java.lang.Integer.MAX_VALUE, userId)); 346 childrenList.add(new Property("relatedAgent", "", "A relationship between two the agents referenced in this resource. This is defined to allow for explicit description of the delegation between agents. For example, this human author used this device, or one person acted on another's behest.", 0, java.lang.Integer.MAX_VALUE, relatedAgent)); 347 } 348 349 @Override 350 public void setProperty(String name, Base value) throws FHIRException { 351 if (name.equals("role")) 352 this.role = castToCoding(value); // Coding 353 else if (name.equals("actor")) 354 this.actor = castToReference(value); // Reference 355 else if (name.equals("userId")) 356 this.userId = castToIdentifier(value); // Identifier 357 else if (name.equals("relatedAgent")) 358 this.getRelatedAgent().add((ProvenanceAgentRelatedAgentComponent) value); 359 else 360 super.setProperty(name, value); 361 } 362 363 @Override 364 public Base addChild(String name) throws FHIRException { 365 if (name.equals("role")) { 366 this.role = new Coding(); 367 return this.role; 368 } 369 else if (name.equals("actor")) { 370 this.actor = new Reference(); 371 return this.actor; 372 } 373 else if (name.equals("userId")) { 374 this.userId = new Identifier(); 375 return this.userId; 376 } 377 else if (name.equals("relatedAgent")) { 378 return addRelatedAgent(); 379 } 380 else 381 return super.addChild(name); 382 } 383 384 public ProvenanceAgentComponent copy() { 385 ProvenanceAgentComponent dst = new ProvenanceAgentComponent(); 386 copyValues(dst); 387 dst.role = role == null ? null : role.copy(); 388 dst.actor = actor == null ? null : actor.copy(); 389 dst.userId = userId == null ? null : userId.copy(); 390 if (relatedAgent != null) { 391 dst.relatedAgent = new ArrayList<ProvenanceAgentRelatedAgentComponent>(); 392 for (ProvenanceAgentRelatedAgentComponent i : relatedAgent) 393 dst.relatedAgent.add(i.copy()); 394 }; 395 return dst; 396 } 397 398 @Override 399 public boolean equalsDeep(Base other) { 400 if (!super.equalsDeep(other)) 401 return false; 402 if (!(other instanceof ProvenanceAgentComponent)) 403 return false; 404 ProvenanceAgentComponent o = (ProvenanceAgentComponent) other; 405 return compareDeep(role, o.role, true) && compareDeep(actor, o.actor, true) && compareDeep(userId, o.userId, true) 406 && compareDeep(relatedAgent, o.relatedAgent, true); 407 } 408 409 @Override 410 public boolean equalsShallow(Base other) { 411 if (!super.equalsShallow(other)) 412 return false; 413 if (!(other instanceof ProvenanceAgentComponent)) 414 return false; 415 ProvenanceAgentComponent o = (ProvenanceAgentComponent) other; 416 return true; 417 } 418 419 public boolean isEmpty() { 420 return super.isEmpty() && (role == null || role.isEmpty()) && (actor == null || actor.isEmpty()) 421 && (userId == null || userId.isEmpty()) && (relatedAgent == null || relatedAgent.isEmpty()) 422 ; 423 } 424 425 public String fhirType() { 426 return "Provenance.agent"; 427 428 } 429 430 } 431 432 @Block() 433 public static class ProvenanceAgentRelatedAgentComponent extends BackboneElement implements IBaseBackboneElement { 434 /** 435 * The type of relationship between agents. 436 */ 437 @Child(name = "type", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=true) 438 @Description(shortDefinition="Type of relationship between agents", formalDefinition="The type of relationship between agents." ) 439 protected CodeableConcept type; 440 441 /** 442 * An internal reference to another agent listed in this provenance by its identifier. 443 */ 444 @Child(name = "target", type = {UriType.class}, order=2, min=1, max=1, modifier=false, summary=true) 445 @Description(shortDefinition="Reference to other agent in this resource by identifier", formalDefinition="An internal reference to another agent listed in this provenance by its identifier." ) 446 protected UriType target; 447 448 private static final long serialVersionUID = 794181198L; 449 450 /* 451 * Constructor 452 */ 453 public ProvenanceAgentRelatedAgentComponent() { 454 super(); 455 } 456 457 /* 458 * Constructor 459 */ 460 public ProvenanceAgentRelatedAgentComponent(CodeableConcept type, UriType target) { 461 super(); 462 this.type = type; 463 this.target = target; 464 } 465 466 /** 467 * @return {@link #type} (The type of relationship between agents.) 468 */ 469 public CodeableConcept getType() { 470 if (this.type == null) 471 if (Configuration.errorOnAutoCreate()) 472 throw new Error("Attempt to auto-create ProvenanceAgentRelatedAgentComponent.type"); 473 else if (Configuration.doAutoCreate()) 474 this.type = new CodeableConcept(); // cc 475 return this.type; 476 } 477 478 public boolean hasType() { 479 return this.type != null && !this.type.isEmpty(); 480 } 481 482 /** 483 * @param value {@link #type} (The type of relationship between agents.) 484 */ 485 public ProvenanceAgentRelatedAgentComponent setType(CodeableConcept value) { 486 this.type = value; 487 return this; 488 } 489 490 /** 491 * @return {@link #target} (An internal reference to another agent listed in this provenance by its identifier.). This is the underlying object with id, value and extensions. The accessor "getTarget" gives direct access to the value 492 */ 493 public UriType getTargetElement() { 494 if (this.target == null) 495 if (Configuration.errorOnAutoCreate()) 496 throw new Error("Attempt to auto-create ProvenanceAgentRelatedAgentComponent.target"); 497 else if (Configuration.doAutoCreate()) 498 this.target = new UriType(); // bb 499 return this.target; 500 } 501 502 public boolean hasTargetElement() { 503 return this.target != null && !this.target.isEmpty(); 504 } 505 506 public boolean hasTarget() { 507 return this.target != null && !this.target.isEmpty(); 508 } 509 510 /** 511 * @param value {@link #target} (An internal reference to another agent listed in this provenance by its identifier.). This is the underlying object with id, value and extensions. The accessor "getTarget" gives direct access to the value 512 */ 513 public ProvenanceAgentRelatedAgentComponent setTargetElement(UriType value) { 514 this.target = value; 515 return this; 516 } 517 518 /** 519 * @return An internal reference to another agent listed in this provenance by its identifier. 520 */ 521 public String getTarget() { 522 return this.target == null ? null : this.target.getValue(); 523 } 524 525 /** 526 * @param value An internal reference to another agent listed in this provenance by its identifier. 527 */ 528 public ProvenanceAgentRelatedAgentComponent setTarget(String value) { 529 if (this.target == null) 530 this.target = new UriType(); 531 this.target.setValue(value); 532 return this; 533 } 534 535 protected void listChildren(List<Property> childrenList) { 536 super.listChildren(childrenList); 537 childrenList.add(new Property("type", "CodeableConcept", "The type of relationship between agents.", 0, java.lang.Integer.MAX_VALUE, type)); 538 childrenList.add(new Property("target", "uri", "An internal reference to another agent listed in this provenance by its identifier.", 0, java.lang.Integer.MAX_VALUE, target)); 539 } 540 541 @Override 542 public void setProperty(String name, Base value) throws FHIRException { 543 if (name.equals("type")) 544 this.type = castToCodeableConcept(value); // CodeableConcept 545 else if (name.equals("target")) 546 this.target = castToUri(value); // UriType 547 else 548 super.setProperty(name, value); 549 } 550 551 @Override 552 public Base addChild(String name) throws FHIRException { 553 if (name.equals("type")) { 554 this.type = new CodeableConcept(); 555 return this.type; 556 } 557 else if (name.equals("target")) { 558 throw new FHIRException("Cannot call addChild on a primitive type Provenance.target"); 559 } 560 else 561 return super.addChild(name); 562 } 563 564 public ProvenanceAgentRelatedAgentComponent copy() { 565 ProvenanceAgentRelatedAgentComponent dst = new ProvenanceAgentRelatedAgentComponent(); 566 copyValues(dst); 567 dst.type = type == null ? null : type.copy(); 568 dst.target = target == null ? null : target.copy(); 569 return dst; 570 } 571 572 @Override 573 public boolean equalsDeep(Base other) { 574 if (!super.equalsDeep(other)) 575 return false; 576 if (!(other instanceof ProvenanceAgentRelatedAgentComponent)) 577 return false; 578 ProvenanceAgentRelatedAgentComponent o = (ProvenanceAgentRelatedAgentComponent) other; 579 return compareDeep(type, o.type, true) && compareDeep(target, o.target, true); 580 } 581 582 @Override 583 public boolean equalsShallow(Base other) { 584 if (!super.equalsShallow(other)) 585 return false; 586 if (!(other instanceof ProvenanceAgentRelatedAgentComponent)) 587 return false; 588 ProvenanceAgentRelatedAgentComponent o = (ProvenanceAgentRelatedAgentComponent) other; 589 return compareValues(target, o.target, true); 590 } 591 592 public boolean isEmpty() { 593 return super.isEmpty() && (type == null || type.isEmpty()) && (target == null || target.isEmpty()) 594 ; 595 } 596 597 public String fhirType() { 598 return "Provenance.agent.relatedAgent"; 599 600 } 601 602 } 603 604 @Block() 605 public static class ProvenanceEntityComponent extends BackboneElement implements IBaseBackboneElement { 606 /** 607 * How the entity was used during the activity. 608 */ 609 @Child(name = "role", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=true) 610 @Description(shortDefinition="derivation | revision | quotation | source", formalDefinition="How the entity was used during the activity." ) 611 protected Enumeration<ProvenanceEntityRole> role; 612 613 /** 614 * The type of the entity. If the entity is a resource, then this is a resource type. 615 */ 616 @Child(name = "type", type = {Coding.class}, order=2, min=1, max=1, modifier=false, summary=true) 617 @Description(shortDefinition="The type of resource in this entity", formalDefinition="The type of the entity. If the entity is a resource, then this is a resource type." ) 618 protected Coding type; 619 620 /** 621 * Identity of the Entity used. May be a logical or physical uri and maybe absolute or relative. 622 */ 623 @Child(name = "reference", type = {UriType.class}, order=3, min=1, max=1, modifier=false, summary=true) 624 @Description(shortDefinition="Identity of entity", formalDefinition="Identity of the Entity used. May be a logical or physical uri and maybe absolute or relative." ) 625 protected UriType reference; 626 627 /** 628 * Human-readable description of the entity. 629 */ 630 @Child(name = "display", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=true) 631 @Description(shortDefinition="Human description of entity", formalDefinition="Human-readable description of the entity." ) 632 protected StringType display; 633 634 /** 635 * 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. 636 */ 637 @Child(name = "agent", type = {ProvenanceAgentComponent.class}, order=5, min=0, max=1, modifier=false, summary=true) 638 @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." ) 639 protected ProvenanceAgentComponent agent; 640 641 private static final long serialVersionUID = 1533729633L; 642 643 /* 644 * Constructor 645 */ 646 public ProvenanceEntityComponent() { 647 super(); 648 } 649 650 /* 651 * Constructor 652 */ 653 public ProvenanceEntityComponent(Enumeration<ProvenanceEntityRole> role, Coding type, UriType reference) { 654 super(); 655 this.role = role; 656 this.type = type; 657 this.reference = reference; 658 } 659 660 /** 661 * @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 662 */ 663 public Enumeration<ProvenanceEntityRole> getRoleElement() { 664 if (this.role == null) 665 if (Configuration.errorOnAutoCreate()) 666 throw new Error("Attempt to auto-create ProvenanceEntityComponent.role"); 667 else if (Configuration.doAutoCreate()) 668 this.role = new Enumeration<ProvenanceEntityRole>(new ProvenanceEntityRoleEnumFactory()); // bb 669 return this.role; 670 } 671 672 public boolean hasRoleElement() { 673 return this.role != null && !this.role.isEmpty(); 674 } 675 676 public boolean hasRole() { 677 return this.role != null && !this.role.isEmpty(); 678 } 679 680 /** 681 * @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 682 */ 683 public ProvenanceEntityComponent setRoleElement(Enumeration<ProvenanceEntityRole> value) { 684 this.role = value; 685 return this; 686 } 687 688 /** 689 * @return How the entity was used during the activity. 690 */ 691 public ProvenanceEntityRole getRole() { 692 return this.role == null ? null : this.role.getValue(); 693 } 694 695 /** 696 * @param value How the entity was used during the activity. 697 */ 698 public ProvenanceEntityComponent setRole(ProvenanceEntityRole value) { 699 if (this.role == null) 700 this.role = new Enumeration<ProvenanceEntityRole>(new ProvenanceEntityRoleEnumFactory()); 701 this.role.setValue(value); 702 return this; 703 } 704 705 /** 706 * @return {@link #type} (The type of the entity. If the entity is a resource, then this is a resource type.) 707 */ 708 public Coding getType() { 709 if (this.type == null) 710 if (Configuration.errorOnAutoCreate()) 711 throw new Error("Attempt to auto-create ProvenanceEntityComponent.type"); 712 else if (Configuration.doAutoCreate()) 713 this.type = new Coding(); // cc 714 return this.type; 715 } 716 717 public boolean hasType() { 718 return this.type != null && !this.type.isEmpty(); 719 } 720 721 /** 722 * @param value {@link #type} (The type of the entity. If the entity is a resource, then this is a resource type.) 723 */ 724 public ProvenanceEntityComponent setType(Coding value) { 725 this.type = value; 726 return this; 727 } 728 729 /** 730 * @return {@link #reference} (Identity of the Entity used. May be a logical or physical uri and maybe absolute or relative.). This is the underlying object with id, value and extensions. The accessor "getReference" gives direct access to the value 731 */ 732 public UriType getReferenceElement() { 733 if (this.reference == null) 734 if (Configuration.errorOnAutoCreate()) 735 throw new Error("Attempt to auto-create ProvenanceEntityComponent.reference"); 736 else if (Configuration.doAutoCreate()) 737 this.reference = new UriType(); // bb 738 return this.reference; 739 } 740 741 public boolean hasReferenceElement() { 742 return this.reference != null && !this.reference.isEmpty(); 743 } 744 745 public boolean hasReference() { 746 return this.reference != null && !this.reference.isEmpty(); 747 } 748 749 /** 750 * @param value {@link #reference} (Identity of the Entity used. May be a logical or physical uri and maybe absolute or relative.). This is the underlying object with id, value and extensions. The accessor "getReference" gives direct access to the value 751 */ 752 public ProvenanceEntityComponent setReferenceElement(UriType value) { 753 this.reference = value; 754 return this; 755 } 756 757 /** 758 * @return Identity of the Entity used. May be a logical or physical uri and maybe absolute or relative. 759 */ 760 public String getReference() { 761 return this.reference == null ? null : this.reference.getValue(); 762 } 763 764 /** 765 * @param value Identity of the Entity used. May be a logical or physical uri and maybe absolute or relative. 766 */ 767 public ProvenanceEntityComponent setReference(String value) { 768 if (this.reference == null) 769 this.reference = new UriType(); 770 this.reference.setValue(value); 771 return this; 772 } 773 774 /** 775 * @return {@link #display} (Human-readable description of the entity.). This is the underlying object with id, value and extensions. The accessor "getDisplay" gives direct access to the value 776 */ 777 public StringType getDisplayElement() { 778 if (this.display == null) 779 if (Configuration.errorOnAutoCreate()) 780 throw new Error("Attempt to auto-create ProvenanceEntityComponent.display"); 781 else if (Configuration.doAutoCreate()) 782 this.display = new StringType(); // bb 783 return this.display; 784 } 785 786 public boolean hasDisplayElement() { 787 return this.display != null && !this.display.isEmpty(); 788 } 789 790 public boolean hasDisplay() { 791 return this.display != null && !this.display.isEmpty(); 792 } 793 794 /** 795 * @param value {@link #display} (Human-readable description of the entity.). This is the underlying object with id, value and extensions. The accessor "getDisplay" gives direct access to the value 796 */ 797 public ProvenanceEntityComponent setDisplayElement(StringType value) { 798 this.display = value; 799 return this; 800 } 801 802 /** 803 * @return Human-readable description of the entity. 804 */ 805 public String getDisplay() { 806 return this.display == null ? null : this.display.getValue(); 807 } 808 809 /** 810 * @param value Human-readable description of the entity. 811 */ 812 public ProvenanceEntityComponent setDisplay(String value) { 813 if (Utilities.noString(value)) 814 this.display = null; 815 else { 816 if (this.display == null) 817 this.display = new StringType(); 818 this.display.setValue(value); 819 } 820 return this; 821 } 822 823 /** 824 * @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.) 825 */ 826 public ProvenanceAgentComponent getAgent() { 827 if (this.agent == null) 828 if (Configuration.errorOnAutoCreate()) 829 throw new Error("Attempt to auto-create ProvenanceEntityComponent.agent"); 830 else if (Configuration.doAutoCreate()) 831 this.agent = new ProvenanceAgentComponent(); // cc 832 return this.agent; 833 } 834 835 public boolean hasAgent() { 836 return this.agent != null && !this.agent.isEmpty(); 837 } 838 839 /** 840 * @param value {@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.) 841 */ 842 public ProvenanceEntityComponent setAgent(ProvenanceAgentComponent value) { 843 this.agent = value; 844 return this; 845 } 846 847 protected void listChildren(List<Property> childrenList) { 848 super.listChildren(childrenList); 849 childrenList.add(new Property("role", "code", "How the entity was used during the activity.", 0, java.lang.Integer.MAX_VALUE, role)); 850 childrenList.add(new Property("type", "Coding", "The type of the entity. If the entity is a resource, then this is a resource type.", 0, java.lang.Integer.MAX_VALUE, type)); 851 childrenList.add(new Property("reference", "uri", "Identity of the Entity used. May be a logical or physical uri and maybe absolute or relative.", 0, java.lang.Integer.MAX_VALUE, reference)); 852 childrenList.add(new Property("display", "string", "Human-readable description of the entity.", 0, java.lang.Integer.MAX_VALUE, display)); 853 childrenList.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)); 854 } 855 856 @Override 857 public void setProperty(String name, Base value) throws FHIRException { 858 if (name.equals("role")) 859 this.role = new ProvenanceEntityRoleEnumFactory().fromType(value); // Enumeration<ProvenanceEntityRole> 860 else if (name.equals("type")) 861 this.type = castToCoding(value); // Coding 862 else if (name.equals("reference")) 863 this.reference = castToUri(value); // UriType 864 else if (name.equals("display")) 865 this.display = castToString(value); // StringType 866 else if (name.equals("agent")) 867 this.agent = (ProvenanceAgentComponent) value; // ProvenanceAgentComponent 868 else 869 super.setProperty(name, value); 870 } 871 872 @Override 873 public Base addChild(String name) throws FHIRException { 874 if (name.equals("role")) { 875 throw new FHIRException("Cannot call addChild on a primitive type Provenance.role"); 876 } 877 else if (name.equals("type")) { 878 this.type = new Coding(); 879 return this.type; 880 } 881 else if (name.equals("reference")) { 882 throw new FHIRException("Cannot call addChild on a primitive type Provenance.reference"); 883 } 884 else if (name.equals("display")) { 885 throw new FHIRException("Cannot call addChild on a primitive type Provenance.display"); 886 } 887 else if (name.equals("agent")) { 888 this.agent = new ProvenanceAgentComponent(); 889 return this.agent; 890 } 891 else 892 return super.addChild(name); 893 } 894 895 public ProvenanceEntityComponent copy() { 896 ProvenanceEntityComponent dst = new ProvenanceEntityComponent(); 897 copyValues(dst); 898 dst.role = role == null ? null : role.copy(); 899 dst.type = type == null ? null : type.copy(); 900 dst.reference = reference == null ? null : reference.copy(); 901 dst.display = display == null ? null : display.copy(); 902 dst.agent = agent == null ? null : agent.copy(); 903 return dst; 904 } 905 906 @Override 907 public boolean equalsDeep(Base other) { 908 if (!super.equalsDeep(other)) 909 return false; 910 if (!(other instanceof ProvenanceEntityComponent)) 911 return false; 912 ProvenanceEntityComponent o = (ProvenanceEntityComponent) other; 913 return compareDeep(role, o.role, true) && compareDeep(type, o.type, true) && compareDeep(reference, o.reference, true) 914 && compareDeep(display, o.display, true) && compareDeep(agent, o.agent, true); 915 } 916 917 @Override 918 public boolean equalsShallow(Base other) { 919 if (!super.equalsShallow(other)) 920 return false; 921 if (!(other instanceof ProvenanceEntityComponent)) 922 return false; 923 ProvenanceEntityComponent o = (ProvenanceEntityComponent) other; 924 return compareValues(role, o.role, true) && compareValues(reference, o.reference, true) && compareValues(display, o.display, true) 925 ; 926 } 927 928 public boolean isEmpty() { 929 return super.isEmpty() && (role == null || role.isEmpty()) && (type == null || type.isEmpty()) 930 && (reference == null || reference.isEmpty()) && (display == null || display.isEmpty()) && (agent == null || agent.isEmpty()) 931 ; 932 } 933 934 public String fhirType() { 935 return "Provenance.entity"; 936 937 } 938 939 } 940 941 /** 942 * 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. 943 */ 944 @Child(name = "target", type = {}, order=0, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 945 @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." ) 946 protected List<Reference> target; 947 /** 948 * 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.) 949 */ 950 protected List<Resource> targetTarget; 951 952 953 /** 954 * The period during which the activity occurred. 955 */ 956 @Child(name = "period", type = {Period.class}, order=1, min=0, max=1, modifier=false, summary=true) 957 @Description(shortDefinition="When the activity occurred", formalDefinition="The period during which the activity occurred." ) 958 protected Period period; 959 960 /** 961 * The instant of time at which the activity was recorded. 962 */ 963 @Child(name = "recorded", type = {InstantType.class}, order=2, min=1, max=1, modifier=false, summary=true) 964 @Description(shortDefinition="When the activity was recorded / updated", formalDefinition="The instant of time at which the activity was recorded." ) 965 protected InstantType recorded; 966 967 /** 968 * The reason that the activity was taking place. 969 */ 970 @Child(name = "reason", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 971 @Description(shortDefinition="Reason the activity is occurring", formalDefinition="The reason that the activity was taking place." ) 972 protected List<CodeableConcept> reason; 973 974 /** 975 * 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. 976 */ 977 @Child(name = "activity", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=true) 978 @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." ) 979 protected CodeableConcept activity; 980 981 /** 982 * Where the activity occurred, if relevant. 983 */ 984 @Child(name = "location", type = {Location.class}, order=5, min=0, max=1, modifier=false, summary=true) 985 @Description(shortDefinition="Where the activity occurred, if relevant", formalDefinition="Where the activity occurred, if relevant." ) 986 protected Reference location; 987 988 /** 989 * The actual object that is the target of the reference (Where the activity occurred, if relevant.) 990 */ 991 protected Location locationTarget; 992 993 /** 994 * Policy or plan the activity was defined by. Typically, a single activity may have multiple applicable policy documents, such as patient consent, guarantor funding, etc. 995 */ 996 @Child(name = "policy", type = {UriType.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 997 @Description(shortDefinition="Policy or plan the activity was defined by", formalDefinition="Policy or plan the activity was defined by. Typically, a single activity may have multiple applicable policy documents, such as patient consent, guarantor funding, etc." ) 998 protected List<UriType> policy; 999 1000 /** 1001 * An agent takes a role in an activity such that the agent can be assigned some degree of responsibility for the activity taking place. An agent can be a person, an organization, software, or other entities that may be ascribed responsibility. 1002 */ 1003 @Child(name = "agent", type = {}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 1004 @Description(shortDefinition="Agents involved in creating resource", formalDefinition="An agent takes a role in an activity such that the agent can be assigned some degree of responsibility for the activity taking place. An agent can be a person, an organization, software, or other entities that may be ascribed responsibility." ) 1005 protected List<ProvenanceAgentComponent> agent; 1006 1007 /** 1008 * An entity used in this activity. 1009 */ 1010 @Child(name = "entity", type = {}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 1011 @Description(shortDefinition="An entity used in this activity", formalDefinition="An entity used in this activity." ) 1012 protected List<ProvenanceEntityComponent> entity; 1013 1014 /** 1015 * A digital signature on the target Reference(s). The signer should match a Provenance.agent. The purpose of the signature is indicated. 1016 */ 1017 @Child(name = "signature", type = {Signature.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 1018 @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." ) 1019 protected List<Signature> signature; 1020 1021 private static final long serialVersionUID = -1053458671L; 1022 1023 /* 1024 * Constructor 1025 */ 1026 public Provenance() { 1027 super(); 1028 } 1029 1030 /* 1031 * Constructor 1032 */ 1033 public Provenance(InstantType recorded) { 1034 super(); 1035 this.recorded = recorded; 1036 } 1037 1038 /** 1039 * @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.) 1040 */ 1041 public List<Reference> getTarget() { 1042 if (this.target == null) 1043 this.target = new ArrayList<Reference>(); 1044 return this.target; 1045 } 1046 1047 public boolean hasTarget() { 1048 if (this.target == null) 1049 return false; 1050 for (Reference item : this.target) 1051 if (!item.isEmpty()) 1052 return true; 1053 return false; 1054 } 1055 1056 /** 1057 * @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.) 1058 */ 1059 // syntactic sugar 1060 public Reference addTarget() { //3 1061 Reference t = new Reference(); 1062 if (this.target == null) 1063 this.target = new ArrayList<Reference>(); 1064 this.target.add(t); 1065 return t; 1066 } 1067 1068 // syntactic sugar 1069 public Provenance addTarget(Reference t) { //3 1070 if (t == null) 1071 return this; 1072 if (this.target == null) 1073 this.target = new ArrayList<Reference>(); 1074 this.target.add(t); 1075 return this; 1076 } 1077 1078 /** 1079 * @return {@link #target} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. 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.) 1080 */ 1081 public List<Resource> getTargetTarget() { 1082 if (this.targetTarget == null) 1083 this.targetTarget = new ArrayList<Resource>(); 1084 return this.targetTarget; 1085 } 1086 1087 /** 1088 * @return {@link #period} (The period during which the activity occurred.) 1089 */ 1090 public Period getPeriod() { 1091 if (this.period == null) 1092 if (Configuration.errorOnAutoCreate()) 1093 throw new Error("Attempt to auto-create Provenance.period"); 1094 else if (Configuration.doAutoCreate()) 1095 this.period = new Period(); // cc 1096 return this.period; 1097 } 1098 1099 public boolean hasPeriod() { 1100 return this.period != null && !this.period.isEmpty(); 1101 } 1102 1103 /** 1104 * @param value {@link #period} (The period during which the activity occurred.) 1105 */ 1106 public Provenance setPeriod(Period value) { 1107 this.period = value; 1108 return this; 1109 } 1110 1111 /** 1112 * @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 1113 */ 1114 public InstantType getRecordedElement() { 1115 if (this.recorded == null) 1116 if (Configuration.errorOnAutoCreate()) 1117 throw new Error("Attempt to auto-create Provenance.recorded"); 1118 else if (Configuration.doAutoCreate()) 1119 this.recorded = new InstantType(); // bb 1120 return this.recorded; 1121 } 1122 1123 public boolean hasRecordedElement() { 1124 return this.recorded != null && !this.recorded.isEmpty(); 1125 } 1126 1127 public boolean hasRecorded() { 1128 return this.recorded != null && !this.recorded.isEmpty(); 1129 } 1130 1131 /** 1132 * @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 1133 */ 1134 public Provenance setRecordedElement(InstantType value) { 1135 this.recorded = value; 1136 return this; 1137 } 1138 1139 /** 1140 * @return The instant of time at which the activity was recorded. 1141 */ 1142 public Date getRecorded() { 1143 return this.recorded == null ? null : this.recorded.getValue(); 1144 } 1145 1146 /** 1147 * @param value The instant of time at which the activity was recorded. 1148 */ 1149 public Provenance setRecorded(Date value) { 1150 if (this.recorded == null) 1151 this.recorded = new InstantType(); 1152 this.recorded.setValue(value); 1153 return this; 1154 } 1155 1156 /** 1157 * @return {@link #reason} (The reason that the activity was taking place.) 1158 */ 1159 public List<CodeableConcept> getReason() { 1160 if (this.reason == null) 1161 this.reason = new ArrayList<CodeableConcept>(); 1162 return this.reason; 1163 } 1164 1165 public boolean hasReason() { 1166 if (this.reason == null) 1167 return false; 1168 for (CodeableConcept item : this.reason) 1169 if (!item.isEmpty()) 1170 return true; 1171 return false; 1172 } 1173 1174 /** 1175 * @return {@link #reason} (The reason that the activity was taking place.) 1176 */ 1177 // syntactic sugar 1178 public CodeableConcept addReason() { //3 1179 CodeableConcept t = new CodeableConcept(); 1180 if (this.reason == null) 1181 this.reason = new ArrayList<CodeableConcept>(); 1182 this.reason.add(t); 1183 return t; 1184 } 1185 1186 // syntactic sugar 1187 public Provenance addReason(CodeableConcept t) { //3 1188 if (t == null) 1189 return this; 1190 if (this.reason == null) 1191 this.reason = new ArrayList<CodeableConcept>(); 1192 this.reason.add(t); 1193 return this; 1194 } 1195 1196 /** 1197 * @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.) 1198 */ 1199 public CodeableConcept getActivity() { 1200 if (this.activity == null) 1201 if (Configuration.errorOnAutoCreate()) 1202 throw new Error("Attempt to auto-create Provenance.activity"); 1203 else if (Configuration.doAutoCreate()) 1204 this.activity = new CodeableConcept(); // cc 1205 return this.activity; 1206 } 1207 1208 public boolean hasActivity() { 1209 return this.activity != null && !this.activity.isEmpty(); 1210 } 1211 1212 /** 1213 * @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.) 1214 */ 1215 public Provenance setActivity(CodeableConcept value) { 1216 this.activity = value; 1217 return this; 1218 } 1219 1220 /** 1221 * @return {@link #location} (Where the activity occurred, if relevant.) 1222 */ 1223 public Reference getLocation() { 1224 if (this.location == null) 1225 if (Configuration.errorOnAutoCreate()) 1226 throw new Error("Attempt to auto-create Provenance.location"); 1227 else if (Configuration.doAutoCreate()) 1228 this.location = new Reference(); // cc 1229 return this.location; 1230 } 1231 1232 public boolean hasLocation() { 1233 return this.location != null && !this.location.isEmpty(); 1234 } 1235 1236 /** 1237 * @param value {@link #location} (Where the activity occurred, if relevant.) 1238 */ 1239 public Provenance setLocation(Reference value) { 1240 this.location = value; 1241 return this; 1242 } 1243 1244 /** 1245 * @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.) 1246 */ 1247 public Location getLocationTarget() { 1248 if (this.locationTarget == null) 1249 if (Configuration.errorOnAutoCreate()) 1250 throw new Error("Attempt to auto-create Provenance.location"); 1251 else if (Configuration.doAutoCreate()) 1252 this.locationTarget = new Location(); // aa 1253 return this.locationTarget; 1254 } 1255 1256 /** 1257 * @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.) 1258 */ 1259 public Provenance setLocationTarget(Location value) { 1260 this.locationTarget = value; 1261 return this; 1262 } 1263 1264 /** 1265 * @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.) 1266 */ 1267 public List<UriType> getPolicy() { 1268 if (this.policy == null) 1269 this.policy = new ArrayList<UriType>(); 1270 return this.policy; 1271 } 1272 1273 public boolean hasPolicy() { 1274 if (this.policy == null) 1275 return false; 1276 for (UriType item : this.policy) 1277 if (!item.isEmpty()) 1278 return true; 1279 return false; 1280 } 1281 1282 /** 1283 * @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.) 1284 */ 1285 // syntactic sugar 1286 public UriType addPolicyElement() {//2 1287 UriType t = new UriType(); 1288 if (this.policy == null) 1289 this.policy = new ArrayList<UriType>(); 1290 this.policy.add(t); 1291 return t; 1292 } 1293 1294 /** 1295 * @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.) 1296 */ 1297 public Provenance addPolicy(String value) { //1 1298 UriType t = new UriType(); 1299 t.setValue(value); 1300 if (this.policy == null) 1301 this.policy = new ArrayList<UriType>(); 1302 this.policy.add(t); 1303 return this; 1304 } 1305 1306 /** 1307 * @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.) 1308 */ 1309 public boolean hasPolicy(String value) { 1310 if (this.policy == null) 1311 return false; 1312 for (UriType v : this.policy) 1313 if (v.equals(value)) // uri 1314 return true; 1315 return false; 1316 } 1317 1318 /** 1319 * @return {@link #agent} (An agent takes a role in an activity such that the agent can be assigned some degree of responsibility for the activity taking place. An agent can be a person, an organization, software, or other entities that may be ascribed responsibility.) 1320 */ 1321 public List<ProvenanceAgentComponent> getAgent() { 1322 if (this.agent == null) 1323 this.agent = new ArrayList<ProvenanceAgentComponent>(); 1324 return this.agent; 1325 } 1326 1327 public boolean hasAgent() { 1328 if (this.agent == null) 1329 return false; 1330 for (ProvenanceAgentComponent item : this.agent) 1331 if (!item.isEmpty()) 1332 return true; 1333 return false; 1334 } 1335 1336 /** 1337 * @return {@link #agent} (An agent takes a role in an activity such that the agent can be assigned some degree of responsibility for the activity taking place. An agent can be a person, an organization, software, or other entities that may be ascribed responsibility.) 1338 */ 1339 // syntactic sugar 1340 public ProvenanceAgentComponent addAgent() { //3 1341 ProvenanceAgentComponent t = new ProvenanceAgentComponent(); 1342 if (this.agent == null) 1343 this.agent = new ArrayList<ProvenanceAgentComponent>(); 1344 this.agent.add(t); 1345 return t; 1346 } 1347 1348 // syntactic sugar 1349 public Provenance addAgent(ProvenanceAgentComponent t) { //3 1350 if (t == null) 1351 return this; 1352 if (this.agent == null) 1353 this.agent = new ArrayList<ProvenanceAgentComponent>(); 1354 this.agent.add(t); 1355 return this; 1356 } 1357 1358 /** 1359 * @return {@link #entity} (An entity used in this activity.) 1360 */ 1361 public List<ProvenanceEntityComponent> getEntity() { 1362 if (this.entity == null) 1363 this.entity = new ArrayList<ProvenanceEntityComponent>(); 1364 return this.entity; 1365 } 1366 1367 public boolean hasEntity() { 1368 if (this.entity == null) 1369 return false; 1370 for (ProvenanceEntityComponent item : this.entity) 1371 if (!item.isEmpty()) 1372 return true; 1373 return false; 1374 } 1375 1376 /** 1377 * @return {@link #entity} (An entity used in this activity.) 1378 */ 1379 // syntactic sugar 1380 public ProvenanceEntityComponent addEntity() { //3 1381 ProvenanceEntityComponent t = new ProvenanceEntityComponent(); 1382 if (this.entity == null) 1383 this.entity = new ArrayList<ProvenanceEntityComponent>(); 1384 this.entity.add(t); 1385 return t; 1386 } 1387 1388 // syntactic sugar 1389 public Provenance addEntity(ProvenanceEntityComponent t) { //3 1390 if (t == null) 1391 return this; 1392 if (this.entity == null) 1393 this.entity = new ArrayList<ProvenanceEntityComponent>(); 1394 this.entity.add(t); 1395 return this; 1396 } 1397 1398 /** 1399 * @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.) 1400 */ 1401 public List<Signature> getSignature() { 1402 if (this.signature == null) 1403 this.signature = new ArrayList<Signature>(); 1404 return this.signature; 1405 } 1406 1407 public boolean hasSignature() { 1408 if (this.signature == null) 1409 return false; 1410 for (Signature item : this.signature) 1411 if (!item.isEmpty()) 1412 return true; 1413 return false; 1414 } 1415 1416 /** 1417 * @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.) 1418 */ 1419 // syntactic sugar 1420 public Signature addSignature() { //3 1421 Signature t = new Signature(); 1422 if (this.signature == null) 1423 this.signature = new ArrayList<Signature>(); 1424 this.signature.add(t); 1425 return t; 1426 } 1427 1428 // syntactic sugar 1429 public Provenance addSignature(Signature t) { //3 1430 if (t == null) 1431 return this; 1432 if (this.signature == null) 1433 this.signature = new ArrayList<Signature>(); 1434 this.signature.add(t); 1435 return this; 1436 } 1437 1438 protected void listChildren(List<Property> childrenList) { 1439 super.listChildren(childrenList); 1440 childrenList.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)); 1441 childrenList.add(new Property("period", "Period", "The period during which the activity occurred.", 0, java.lang.Integer.MAX_VALUE, period)); 1442 childrenList.add(new Property("recorded", "instant", "The instant of time at which the activity was recorded.", 0, java.lang.Integer.MAX_VALUE, recorded)); 1443 childrenList.add(new Property("reason", "CodeableConcept", "The reason that the activity was taking place.", 0, java.lang.Integer.MAX_VALUE, reason)); 1444 childrenList.add(new Property("activity", "CodeableConcept", "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, java.lang.Integer.MAX_VALUE, activity)); 1445 childrenList.add(new Property("location", "Reference(Location)", "Where the activity occurred, if relevant.", 0, java.lang.Integer.MAX_VALUE, location)); 1446 childrenList.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)); 1447 childrenList.add(new Property("agent", "", "An agent takes a role in an activity such that the agent can be assigned some degree of responsibility for the activity taking place. An agent can be a person, an organization, software, or other entities that may be ascribed responsibility.", 0, java.lang.Integer.MAX_VALUE, agent)); 1448 childrenList.add(new Property("entity", "", "An entity used in this activity.", 0, java.lang.Integer.MAX_VALUE, entity)); 1449 childrenList.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)); 1450 } 1451 1452 @Override 1453 public void setProperty(String name, Base value) throws FHIRException { 1454 if (name.equals("target")) 1455 this.getTarget().add(castToReference(value)); 1456 else if (name.equals("period")) 1457 this.period = castToPeriod(value); // Period 1458 else if (name.equals("recorded")) 1459 this.recorded = castToInstant(value); // InstantType 1460 else if (name.equals("reason")) 1461 this.getReason().add(castToCodeableConcept(value)); 1462 else if (name.equals("activity")) 1463 this.activity = castToCodeableConcept(value); // CodeableConcept 1464 else if (name.equals("location")) 1465 this.location = castToReference(value); // Reference 1466 else if (name.equals("policy")) 1467 this.getPolicy().add(castToUri(value)); 1468 else if (name.equals("agent")) 1469 this.getAgent().add((ProvenanceAgentComponent) value); 1470 else if (name.equals("entity")) 1471 this.getEntity().add((ProvenanceEntityComponent) value); 1472 else if (name.equals("signature")) 1473 this.getSignature().add(castToSignature(value)); 1474 else 1475 super.setProperty(name, value); 1476 } 1477 1478 @Override 1479 public Base addChild(String name) throws FHIRException { 1480 if (name.equals("target")) { 1481 return addTarget(); 1482 } 1483 else if (name.equals("period")) { 1484 this.period = new Period(); 1485 return this.period; 1486 } 1487 else if (name.equals("recorded")) { 1488 throw new FHIRException("Cannot call addChild on a primitive type Provenance.recorded"); 1489 } 1490 else if (name.equals("reason")) { 1491 return addReason(); 1492 } 1493 else if (name.equals("activity")) { 1494 this.activity = new CodeableConcept(); 1495 return this.activity; 1496 } 1497 else if (name.equals("location")) { 1498 this.location = new Reference(); 1499 return this.location; 1500 } 1501 else if (name.equals("policy")) { 1502 throw new FHIRException("Cannot call addChild on a primitive type Provenance.policy"); 1503 } 1504 else if (name.equals("agent")) { 1505 return addAgent(); 1506 } 1507 else if (name.equals("entity")) { 1508 return addEntity(); 1509 } 1510 else if (name.equals("signature")) { 1511 return addSignature(); 1512 } 1513 else 1514 return super.addChild(name); 1515 } 1516 1517 public String fhirType() { 1518 return "Provenance"; 1519 1520 } 1521 1522 public Provenance copy() { 1523 Provenance dst = new Provenance(); 1524 copyValues(dst); 1525 if (target != null) { 1526 dst.target = new ArrayList<Reference>(); 1527 for (Reference i : target) 1528 dst.target.add(i.copy()); 1529 }; 1530 dst.period = period == null ? null : period.copy(); 1531 dst.recorded = recorded == null ? null : recorded.copy(); 1532 if (reason != null) { 1533 dst.reason = new ArrayList<CodeableConcept>(); 1534 for (CodeableConcept i : reason) 1535 dst.reason.add(i.copy()); 1536 }; 1537 dst.activity = activity == null ? null : activity.copy(); 1538 dst.location = location == null ? null : location.copy(); 1539 if (policy != null) { 1540 dst.policy = new ArrayList<UriType>(); 1541 for (UriType i : policy) 1542 dst.policy.add(i.copy()); 1543 }; 1544 if (agent != null) { 1545 dst.agent = new ArrayList<ProvenanceAgentComponent>(); 1546 for (ProvenanceAgentComponent i : agent) 1547 dst.agent.add(i.copy()); 1548 }; 1549 if (entity != null) { 1550 dst.entity = new ArrayList<ProvenanceEntityComponent>(); 1551 for (ProvenanceEntityComponent i : entity) 1552 dst.entity.add(i.copy()); 1553 }; 1554 if (signature != null) { 1555 dst.signature = new ArrayList<Signature>(); 1556 for (Signature i : signature) 1557 dst.signature.add(i.copy()); 1558 }; 1559 return dst; 1560 } 1561 1562 protected Provenance typedCopy() { 1563 return copy(); 1564 } 1565 1566 @Override 1567 public boolean equalsDeep(Base other) { 1568 if (!super.equalsDeep(other)) 1569 return false; 1570 if (!(other instanceof Provenance)) 1571 return false; 1572 Provenance o = (Provenance) other; 1573 return compareDeep(target, o.target, true) && compareDeep(period, o.period, true) && compareDeep(recorded, o.recorded, true) 1574 && compareDeep(reason, o.reason, true) && compareDeep(activity, o.activity, true) && compareDeep(location, o.location, true) 1575 && compareDeep(policy, o.policy, true) && compareDeep(agent, o.agent, true) && compareDeep(entity, o.entity, true) 1576 && compareDeep(signature, o.signature, true); 1577 } 1578 1579 @Override 1580 public boolean equalsShallow(Base other) { 1581 if (!super.equalsShallow(other)) 1582 return false; 1583 if (!(other instanceof Provenance)) 1584 return false; 1585 Provenance o = (Provenance) other; 1586 return compareValues(recorded, o.recorded, true) && compareValues(policy, o.policy, true); 1587 } 1588 1589 public boolean isEmpty() { 1590 return super.isEmpty() && (target == null || target.isEmpty()) && (period == null || period.isEmpty()) 1591 && (recorded == null || recorded.isEmpty()) && (reason == null || reason.isEmpty()) && (activity == null || activity.isEmpty()) 1592 && (location == null || location.isEmpty()) && (policy == null || policy.isEmpty()) && (agent == null || agent.isEmpty()) 1593 && (entity == null || entity.isEmpty()) && (signature == null || signature.isEmpty()); 1594 } 1595 1596 @Override 1597 public ResourceType getResourceType() { 1598 return ResourceType.Provenance; 1599 } 1600 1601 @SearchParamDefinition(name="sigtype", path="Provenance.signature.type", description="Indication of the reason the entity signed the object(s)", type="token" ) 1602 public static final String SP_SIGTYPE = "sigtype"; 1603 @SearchParamDefinition(name="agent", path="Provenance.agent.actor", description="Individual, device or organization playing role", type="reference" ) 1604 public static final String SP_AGENT = "agent"; 1605 @SearchParamDefinition(name="entitytype", path="Provenance.entity.type", description="The type of resource in this entity", type="token" ) 1606 public static final String SP_ENTITYTYPE = "entitytype"; 1607 @SearchParamDefinition(name="patient", path="Provenance.target", description="Target Reference(s) (usually version specific)", type="reference" ) 1608 public static final String SP_PATIENT = "patient"; 1609 @SearchParamDefinition(name="start", path="Provenance.period.start", description="Starting time with inclusive boundary", type="date" ) 1610 public static final String SP_START = "start"; 1611 @SearchParamDefinition(name="end", path="Provenance.period.end", description="End time with inclusive boundary, if not ongoing", type="date" ) 1612 public static final String SP_END = "end"; 1613 @SearchParamDefinition(name="location", path="Provenance.location", description="Where the activity occurred, if relevant", type="reference" ) 1614 public static final String SP_LOCATION = "location"; 1615 @SearchParamDefinition(name="userid", path="Provenance.agent.userId", description="Authorization-system identifier for the agent", type="token" ) 1616 public static final String SP_USERID = "userid"; 1617 @SearchParamDefinition(name="entity", path="Provenance.entity.reference", description="Identity of entity", type="uri" ) 1618 public static final String SP_ENTITY = "entity"; 1619 @SearchParamDefinition(name="target", path="Provenance.target", description="Target Reference(s) (usually version specific)", type="reference" ) 1620 public static final String SP_TARGET = "target"; 1621 1622} 1623