001package org.hl7.fhir.dstu2.model; 002 003/*- 004 * #%L 005 * org.hl7.fhir.dstu2 006 * %% 007 * Copyright (C) 2014 - 2019 Health Level 7 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023 024/* 025 Copyright (c) 2011+, HL7, Inc. 026 All rights reserved. 027 028 Redistribution and use in source and binary forms, with or without modification, 029 are permitted provided that the following conditions are met: 030 031 * Redistributions of source code must retain the above copyright notice, this 032 list of conditions and the following disclaimer. 033 * Redistributions in binary form must reproduce the above copyright notice, 034 this list of conditions and the following disclaimer in the documentation 035 and/or other materials provided with the distribution. 036 * Neither the name of HL7 nor the names of its contributors may be used to 037 endorse or promote products derived from this software without specific 038 prior written permission. 039 040 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 041 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 042 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 043 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 044 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 045 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 046 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 047 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 048 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 049 POSSIBILITY OF SUCH DAMAGE. 050 051*/ 052 053// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2 054import java.util.ArrayList; 055import java.util.Date; 056import java.util.List; 057 058import ca.uhn.fhir.model.api.annotation.Child; 059import ca.uhn.fhir.model.api.annotation.Description; 060import ca.uhn.fhir.model.api.annotation.ResourceDef; 061import ca.uhn.fhir.model.api.annotation.SearchParamDefinition; 062import org.hl7.fhir.exceptions.FHIRException; 063/** 064 * Basic is used for handling concepts not yet defined in FHIR, narrative-only resources that don't map to an existing resource, and custom resources not appropriate for inclusion in the FHIR specification. 065 */ 066@ResourceDef(name="Basic", profile="http://hl7.org/fhir/Profile/Basic") 067public class Basic extends DomainResource { 068 069 /** 070 * Identifier assigned to the resource for business purposes, outside the context of FHIR. 071 */ 072 @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 073 @Description(shortDefinition="Business identifier", formalDefinition="Identifier assigned to the resource for business purposes, outside the context of FHIR." ) 074 protected List<Identifier> identifier; 075 076 /** 077 * Identifies the 'type' of resource - equivalent to the resource name for other resources. 078 */ 079 @Child(name = "code", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=true, summary=true) 080 @Description(shortDefinition="Kind of Resource", formalDefinition="Identifies the 'type' of resource - equivalent to the resource name for other resources." ) 081 protected CodeableConcept code; 082 083 /** 084 * Identifies the patient, practitioner, device or any other resource that is the "focus" of this resource. 085 */ 086 @Child(name = "subject", type = {}, order=2, min=0, max=1, modifier=false, summary=true) 087 @Description(shortDefinition="Identifies the focus of this resource", formalDefinition="Identifies the patient, practitioner, device or any other resource that is the \"focus\" of this resource." ) 088 protected Reference subject; 089 090 /** 091 * The actual object that is the target of the reference (Identifies the patient, practitioner, device or any other resource that is the "focus" of this resource.) 092 */ 093 protected Resource subjectTarget; 094 095 /** 096 * Indicates who was responsible for creating the resource instance. 097 */ 098 @Child(name = "author", type = {Practitioner.class, Patient.class, RelatedPerson.class}, order=3, min=0, max=1, modifier=false, summary=true) 099 @Description(shortDefinition="Who created", formalDefinition="Indicates who was responsible for creating the resource instance." ) 100 protected Reference author; 101 102 /** 103 * The actual object that is the target of the reference (Indicates who was responsible for creating the resource instance.) 104 */ 105 protected Resource authorTarget; 106 107 /** 108 * Identifies when the resource was first created. 109 */ 110 @Child(name = "created", type = {DateType.class}, order=4, min=0, max=1, modifier=false, summary=true) 111 @Description(shortDefinition="When created", formalDefinition="Identifies when the resource was first created." ) 112 protected DateType created; 113 114 private static final long serialVersionUID = 916539354L; 115 116 /* 117 * Constructor 118 */ 119 public Basic() { 120 super(); 121 } 122 123 /* 124 * Constructor 125 */ 126 public Basic(CodeableConcept code) { 127 super(); 128 this.code = code; 129 } 130 131 /** 132 * @return {@link #identifier} (Identifier assigned to the resource for business purposes, outside the context of FHIR.) 133 */ 134 public List<Identifier> getIdentifier() { 135 if (this.identifier == null) 136 this.identifier = new ArrayList<Identifier>(); 137 return this.identifier; 138 } 139 140 public boolean hasIdentifier() { 141 if (this.identifier == null) 142 return false; 143 for (Identifier item : this.identifier) 144 if (!item.isEmpty()) 145 return true; 146 return false; 147 } 148 149 /** 150 * @return {@link #identifier} (Identifier assigned to the resource for business purposes, outside the context of FHIR.) 151 */ 152 // syntactic sugar 153 public Identifier addIdentifier() { //3 154 Identifier t = new Identifier(); 155 if (this.identifier == null) 156 this.identifier = new ArrayList<Identifier>(); 157 this.identifier.add(t); 158 return t; 159 } 160 161 // syntactic sugar 162 public Basic addIdentifier(Identifier t) { //3 163 if (t == null) 164 return this; 165 if (this.identifier == null) 166 this.identifier = new ArrayList<Identifier>(); 167 this.identifier.add(t); 168 return this; 169 } 170 171 /** 172 * @return {@link #code} (Identifies the 'type' of resource - equivalent to the resource name for other resources.) 173 */ 174 public CodeableConcept getCode() { 175 if (this.code == null) 176 if (Configuration.errorOnAutoCreate()) 177 throw new Error("Attempt to auto-create Basic.code"); 178 else if (Configuration.doAutoCreate()) 179 this.code = new CodeableConcept(); // cc 180 return this.code; 181 } 182 183 public boolean hasCode() { 184 return this.code != null && !this.code.isEmpty(); 185 } 186 187 /** 188 * @param value {@link #code} (Identifies the 'type' of resource - equivalent to the resource name for other resources.) 189 */ 190 public Basic setCode(CodeableConcept value) { 191 this.code = value; 192 return this; 193 } 194 195 /** 196 * @return {@link #subject} (Identifies the patient, practitioner, device or any other resource that is the "focus" of this resource.) 197 */ 198 public Reference getSubject() { 199 if (this.subject == null) 200 if (Configuration.errorOnAutoCreate()) 201 throw new Error("Attempt to auto-create Basic.subject"); 202 else if (Configuration.doAutoCreate()) 203 this.subject = new Reference(); // cc 204 return this.subject; 205 } 206 207 public boolean hasSubject() { 208 return this.subject != null && !this.subject.isEmpty(); 209 } 210 211 /** 212 * @param value {@link #subject} (Identifies the patient, practitioner, device or any other resource that is the "focus" of this resource.) 213 */ 214 public Basic setSubject(Reference value) { 215 this.subject = value; 216 return this; 217 } 218 219 /** 220 * @return {@link #subject} 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. (Identifies the patient, practitioner, device or any other resource that is the "focus" of this resource.) 221 */ 222 public Resource getSubjectTarget() { 223 return this.subjectTarget; 224 } 225 226 /** 227 * @param value {@link #subject} 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. (Identifies the patient, practitioner, device or any other resource that is the "focus" of this resource.) 228 */ 229 public Basic setSubjectTarget(Resource value) { 230 this.subjectTarget = value; 231 return this; 232 } 233 234 /** 235 * @return {@link #author} (Indicates who was responsible for creating the resource instance.) 236 */ 237 public Reference getAuthor() { 238 if (this.author == null) 239 if (Configuration.errorOnAutoCreate()) 240 throw new Error("Attempt to auto-create Basic.author"); 241 else if (Configuration.doAutoCreate()) 242 this.author = new Reference(); // cc 243 return this.author; 244 } 245 246 public boolean hasAuthor() { 247 return this.author != null && !this.author.isEmpty(); 248 } 249 250 /** 251 * @param value {@link #author} (Indicates who was responsible for creating the resource instance.) 252 */ 253 public Basic setAuthor(Reference value) { 254 this.author = value; 255 return this; 256 } 257 258 /** 259 * @return {@link #author} 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. (Indicates who was responsible for creating the resource instance.) 260 */ 261 public Resource getAuthorTarget() { 262 return this.authorTarget; 263 } 264 265 /** 266 * @param value {@link #author} 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. (Indicates who was responsible for creating the resource instance.) 267 */ 268 public Basic setAuthorTarget(Resource value) { 269 this.authorTarget = value; 270 return this; 271 } 272 273 /** 274 * @return {@link #created} (Identifies when the resource was first created.). This is the underlying object with id, value and extensions. The accessor "getCreated" gives direct access to the value 275 */ 276 public DateType getCreatedElement() { 277 if (this.created == null) 278 if (Configuration.errorOnAutoCreate()) 279 throw new Error("Attempt to auto-create Basic.created"); 280 else if (Configuration.doAutoCreate()) 281 this.created = new DateType(); // bb 282 return this.created; 283 } 284 285 public boolean hasCreatedElement() { 286 return this.created != null && !this.created.isEmpty(); 287 } 288 289 public boolean hasCreated() { 290 return this.created != null && !this.created.isEmpty(); 291 } 292 293 /** 294 * @param value {@link #created} (Identifies when the resource was first created.). This is the underlying object with id, value and extensions. The accessor "getCreated" gives direct access to the value 295 */ 296 public Basic setCreatedElement(DateType value) { 297 this.created = value; 298 return this; 299 } 300 301 /** 302 * @return Identifies when the resource was first created. 303 */ 304 public Date getCreated() { 305 return this.created == null ? null : this.created.getValue(); 306 } 307 308 /** 309 * @param value Identifies when the resource was first created. 310 */ 311 public Basic setCreated(Date value) { 312 if (value == null) 313 this.created = null; 314 else { 315 if (this.created == null) 316 this.created = new DateType(); 317 this.created.setValue(value); 318 } 319 return this; 320 } 321 322 protected void listChildren(List<Property> childrenList) { 323 super.listChildren(childrenList); 324 childrenList.add(new Property("identifier", "Identifier", "Identifier assigned to the resource for business purposes, outside the context of FHIR.", 0, java.lang.Integer.MAX_VALUE, identifier)); 325 childrenList.add(new Property("code", "CodeableConcept", "Identifies the 'type' of resource - equivalent to the resource name for other resources.", 0, java.lang.Integer.MAX_VALUE, code)); 326 childrenList.add(new Property("subject", "Reference(Any)", "Identifies the patient, practitioner, device or any other resource that is the \"focus\" of this resource.", 0, java.lang.Integer.MAX_VALUE, subject)); 327 childrenList.add(new Property("author", "Reference(Practitioner|Patient|RelatedPerson)", "Indicates who was responsible for creating the resource instance.", 0, java.lang.Integer.MAX_VALUE, author)); 328 childrenList.add(new Property("created", "date", "Identifies when the resource was first created.", 0, java.lang.Integer.MAX_VALUE, created)); 329 } 330 331 @Override 332 public void setProperty(String name, Base value) throws FHIRException { 333 if (name.equals("identifier")) 334 this.getIdentifier().add(castToIdentifier(value)); 335 else if (name.equals("code")) 336 this.code = castToCodeableConcept(value); // CodeableConcept 337 else if (name.equals("subject")) 338 this.subject = castToReference(value); // Reference 339 else if (name.equals("author")) 340 this.author = castToReference(value); // Reference 341 else if (name.equals("created")) 342 this.created = castToDate(value); // DateType 343 else 344 super.setProperty(name, value); 345 } 346 347 @Override 348 public Base addChild(String name) throws FHIRException { 349 if (name.equals("identifier")) { 350 return addIdentifier(); 351 } 352 else if (name.equals("code")) { 353 this.code = new CodeableConcept(); 354 return this.code; 355 } 356 else if (name.equals("subject")) { 357 this.subject = new Reference(); 358 return this.subject; 359 } 360 else if (name.equals("author")) { 361 this.author = new Reference(); 362 return this.author; 363 } 364 else if (name.equals("created")) { 365 throw new FHIRException("Cannot call addChild on a primitive type Basic.created"); 366 } 367 else 368 return super.addChild(name); 369 } 370 371 public String fhirType() { 372 return "Basic"; 373 374 } 375 376 public Basic copy() { 377 Basic dst = new Basic(); 378 copyValues(dst); 379 if (identifier != null) { 380 dst.identifier = new ArrayList<Identifier>(); 381 for (Identifier i : identifier) 382 dst.identifier.add(i.copy()); 383 }; 384 dst.code = code == null ? null : code.copy(); 385 dst.subject = subject == null ? null : subject.copy(); 386 dst.author = author == null ? null : author.copy(); 387 dst.created = created == null ? null : created.copy(); 388 return dst; 389 } 390 391 protected Basic typedCopy() { 392 return copy(); 393 } 394 395 @Override 396 public boolean equalsDeep(Base other) { 397 if (!super.equalsDeep(other)) 398 return false; 399 if (!(other instanceof Basic)) 400 return false; 401 Basic o = (Basic) other; 402 return compareDeep(identifier, o.identifier, true) && compareDeep(code, o.code, true) && compareDeep(subject, o.subject, true) 403 && compareDeep(author, o.author, true) && compareDeep(created, o.created, true); 404 } 405 406 @Override 407 public boolean equalsShallow(Base other) { 408 if (!super.equalsShallow(other)) 409 return false; 410 if (!(other instanceof Basic)) 411 return false; 412 Basic o = (Basic) other; 413 return compareValues(created, o.created, true); 414 } 415 416 public boolean isEmpty() { 417 return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (code == null || code.isEmpty()) 418 && (subject == null || subject.isEmpty()) && (author == null || author.isEmpty()) && (created == null || created.isEmpty()) 419 ; 420 } 421 422 @Override 423 public ResourceType getResourceType() { 424 return ResourceType.Basic; 425 } 426 427 @SearchParamDefinition(name="identifier", path="Basic.identifier", description="Business identifier", type="token" ) 428 public static final String SP_IDENTIFIER = "identifier"; 429 @SearchParamDefinition(name="code", path="Basic.code", description="Kind of Resource", type="token" ) 430 public static final String SP_CODE = "code"; 431 @SearchParamDefinition(name="subject", path="Basic.subject", description="Identifies the focus of this resource", type="reference" ) 432 public static final String SP_SUBJECT = "subject"; 433 @SearchParamDefinition(name="created", path="Basic.created", description="When created", type="date" ) 434 public static final String SP_CREATED = "created"; 435 @SearchParamDefinition(name="patient", path="Basic.subject", description="Identifies the focus of this resource", type="reference" ) 436 public static final String SP_PATIENT = "patient"; 437 @SearchParamDefinition(name="author", path="Basic.author", description="Who created", type="reference" ) 438 public static final String SP_AUTHOR = "author"; 439 440} 441