001package org.hl7.fhir.dstu3.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 Mon, Apr 17, 2017 17:38-0400 for FHIR v3.0.1 033 034import java.util.*; 035 036import ca.uhn.fhir.model.api.annotation.ResourceDef; 037import ca.uhn.fhir.model.api.annotation.SearchParamDefinition; 038import ca.uhn.fhir.model.api.annotation.Child; 039import ca.uhn.fhir.model.api.annotation.ChildOrder; 040import ca.uhn.fhir.model.api.annotation.Description; 041import ca.uhn.fhir.model.api.annotation.Block; 042import org.hl7.fhir.instance.model.api.*; 043import org.hl7.fhir.exceptions.FHIRException; 044/** 045 * A resource that includes narrative, extensions, and contained resources. 046 */ 047public abstract class DomainResource extends Resource implements IBaseHasExtensions, IBaseHasModifierExtensions, IDomainResource { 048 049 /** 050 * A human-readable narrative that contains a summary of the resource, and may be used to represent the content of the resource to a human. The narrative need not encode all the structured data, but is required to contain sufficient detail to make it "clinically safe" for a human to just read the narrative. Resource definitions may define what content should be represented in the narrative to ensure clinical safety. 051 */ 052 @Child(name = "text", type = {Narrative.class}, order=0, min=0, max=1, modifier=false, summary=false) 053 @Description(shortDefinition="Text summary of the resource, for human interpretation", formalDefinition="A human-readable narrative that contains a summary of the resource, and may be used to represent the content of the resource to a human. The narrative need not encode all the structured data, but is required to contain sufficient detail to make it \"clinically safe\" for a human to just read the narrative. Resource definitions may define what content should be represented in the narrative to ensure clinical safety." ) 054 protected Narrative text; 055 056 /** 057 * These resources do not have an independent existence apart from the resource that contains them - they cannot be identified independently, and nor can they have their own independent transaction scope. 058 */ 059 @Child(name = "contained", type = {Resource.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 060 @Description(shortDefinition="Contained, inline Resources", formalDefinition="These resources do not have an independent existence apart from the resource that contains them - they cannot be identified independently, and nor can they have their own independent transaction scope." ) 061 protected List<Resource> contained; 062 063 /** 064 * May be used to represent additional information that is not part of the basic definition of the resource. In order to make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. 065 */ 066 @Child(name = "extension", type = {Extension.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 067 @Description(shortDefinition="Additional Content defined by implementations", formalDefinition="May be used to represent additional information that is not part of the basic definition of the resource. In order to make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension." ) 068 protected List<Extension> extension; 069 070 /** 071 * May be used to represent additional information that is not part of the basic definition of the resource, and that modifies the understanding of the element that contains it. Usually modifier elements provide negation or qualification. In order to make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions. 072 */ 073 @Child(name = "modifierExtension", type = {Extension.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=true, summary=false) 074 @Description(shortDefinition="Extensions that cannot be ignored", formalDefinition="May be used to represent additional information that is not part of the basic definition of the resource, and that modifies the understanding of the element that contains it. Usually modifier elements provide negation or qualification. In order to make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions." ) 075 protected List<Extension> modifierExtension; 076 077 private static final long serialVersionUID = -970285559L; 078 079 /** 080 * Constructor 081 */ 082 public DomainResource() { 083 super(); 084 } 085 086 /** 087 * @return {@link #text} (A human-readable narrative that contains a summary of the resource, and may be used to represent the content of the resource to a human. The narrative need not encode all the structured data, but is required to contain sufficient detail to make it "clinically safe" for a human to just read the narrative. Resource definitions may define what content should be represented in the narrative to ensure clinical safety.) 088 */ 089 public Narrative getText() { 090 if (this.text == null) 091 if (Configuration.errorOnAutoCreate()) 092 throw new Error("Attempt to auto-create DomainResource.text"); 093 else if (Configuration.doAutoCreate()) 094 this.text = new Narrative(); // cc 095 return this.text; 096 } 097 098 public boolean hasText() { 099 return this.text != null && !this.text.isEmpty(); 100 } 101 102 /** 103 * @param value {@link #text} (A human-readable narrative that contains a summary of the resource, and may be used to represent the content of the resource to a human. The narrative need not encode all the structured data, but is required to contain sufficient detail to make it "clinically safe" for a human to just read the narrative. Resource definitions may define what content should be represented in the narrative to ensure clinical safety.) 104 */ 105 public DomainResource setText(Narrative value) { 106 this.text = value; 107 return this; 108 } 109 110 /** 111 * @return {@link #contained} (These resources do not have an independent existence apart from the resource that contains them - they cannot be identified independently, and nor can they have their own independent transaction scope.) 112 */ 113 public List<Resource> getContained() { 114 if (this.contained == null) 115 this.contained = new ArrayList<Resource>(); 116 return this.contained; 117 } 118 119 /** 120 * @return Returns a reference to <code>this</code> for easy method chaining 121 */ 122 public DomainResource setContained(List<Resource> theContained) { 123 this.contained = theContained; 124 return this; 125 } 126 127 public boolean hasContained() { 128 if (this.contained == null) 129 return false; 130 for (Resource item : this.contained) 131 if (!item.isEmpty()) 132 return true; 133 return false; 134 } 135 136 public DomainResource addContained(Resource t) { //3 137 if (t == null) 138 return this; 139 if (this.contained == null) 140 this.contained = new ArrayList<Resource>(); 141 this.contained.add(t); 142 return this; 143 } 144 145 /** 146 * @return {@link #extension} (May be used to represent additional information that is not part of the basic definition of the resource. In order to make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.) 147 */ 148 public List<Extension> getExtension() { 149 if (this.extension == null) 150 this.extension = new ArrayList<Extension>(); 151 return this.extension; 152 } 153 154 /** 155 * @return Returns a reference to <code>this</code> for easy method chaining 156 */ 157 public DomainResource setExtension(List<Extension> theExtension) { 158 this.extension = theExtension; 159 return this; 160 } 161 162 public boolean hasExtension() { 163 if (this.extension == null) 164 return false; 165 for (Extension item : this.extension) 166 if (!item.isEmpty()) 167 return true; 168 return false; 169 } 170 171 public Extension addExtension() { //3 172 Extension t = new Extension(); 173 if (this.extension == null) 174 this.extension = new ArrayList<Extension>(); 175 this.extension.add(t); 176 return t; 177 } 178 179 public DomainResource addExtension(Extension t) { //3 180 if (t == null) 181 return this; 182 if (this.extension == null) 183 this.extension = new ArrayList<Extension>(); 184 this.extension.add(t); 185 return this; 186 } 187 188 /** 189 * @return {@link #modifierExtension} (May be used to represent additional information that is not part of the basic definition of the resource, and that modifies the understanding of the element that contains it. Usually modifier elements provide negation or qualification. In order to make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.) 190 */ 191 public List<Extension> getModifierExtension() { 192 if (this.modifierExtension == null) 193 this.modifierExtension = new ArrayList<Extension>(); 194 return this.modifierExtension; 195 } 196 197 /** 198 * @return Returns a reference to <code>this</code> for easy method chaining 199 */ 200 public DomainResource setModifierExtension(List<Extension> theModifierExtension) { 201 this.modifierExtension = theModifierExtension; 202 return this; 203 } 204 205 public boolean hasModifierExtension() { 206 if (this.modifierExtension == null) 207 return false; 208 for (Extension item : this.modifierExtension) 209 if (!item.isEmpty()) 210 return true; 211 return false; 212 } 213 214 public Extension addModifierExtension() { //3 215 Extension t = new Extension(); 216 if (this.modifierExtension == null) 217 this.modifierExtension = new ArrayList<Extension>(); 218 this.modifierExtension.add(t); 219 return t; 220 } 221 222 public DomainResource addModifierExtension(Extension t) { //3 223 if (t == null) 224 return this; 225 if (this.modifierExtension == null) 226 this.modifierExtension = new ArrayList<Extension>(); 227 this.modifierExtension.add(t); 228 return this; 229 } 230 231 /** 232 * Returns a list of extensions from this element which have the given URL. Note that 233 * this list may not be modified (you can not add or remove elements from it) 234 */ 235 public List<Extension> getExtensionsByUrl(String theUrl) { 236 org.apache.commons.lang3.Validate.notBlank(theUrl, "theUrl must be provided with a value"); 237 ArrayList<Extension> retVal = new ArrayList<Extension>(); 238 for (Extension next : getExtension()) { 239 if (theUrl.equals(next.getUrl())) { 240 retVal.add(next); 241 } 242 } 243 return Collections.unmodifiableList(retVal); 244 } 245 246 /** 247 * Returns a list of modifier extensions from this element which have the given URL. Note that 248 * this list may not be modified (you can not add or remove elements from it) 249 */ 250 public List<Extension> getModifierExtensionsByUrl(String theUrl) { 251 org.apache.commons.lang3.Validate.notBlank(theUrl, "theUrl must be provided with a value"); 252 ArrayList<Extension> retVal = new ArrayList<Extension>(); 253 for (Extension next : getModifierExtension()) { 254 if (theUrl.equals(next.getUrl())) { 255 retVal.add(next); 256 } 257 } 258 return Collections.unmodifiableList(retVal); 259 } 260 261 protected void listChildren(List<Property> childrenList) { 262 childrenList.add(new Property("text", "Narrative", "A human-readable narrative that contains a summary of the resource, and may be used to represent the content of the resource to a human. The narrative need not encode all the structured data, but is required to contain sufficient detail to make it \"clinically safe\" for a human to just read the narrative. Resource definitions may define what content should be represented in the narrative to ensure clinical safety.", 0, java.lang.Integer.MAX_VALUE, text)); 263 childrenList.add(new Property("contained", "Resource", "These resources do not have an independent existence apart from the resource that contains them - they cannot be identified independently, and nor can they have their own independent transaction scope.", 0, java.lang.Integer.MAX_VALUE, contained)); 264 childrenList.add(new Property("extension", "Extension", "May be used to represent additional information that is not part of the basic definition of the resource. In order to make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", 0, java.lang.Integer.MAX_VALUE, extension)); 265 childrenList.add(new Property("modifierExtension", "Extension", "May be used to represent additional information that is not part of the basic definition of the resource, and that modifies the understanding of the element that contains it. Usually modifier elements provide negation or qualification. In order to make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.", 0, java.lang.Integer.MAX_VALUE, modifierExtension)); 266 } 267 268 @Override 269 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 270 switch (hash) { 271 case 3556653: /*text*/ return this.text == null ? new Base[0] : new Base[] {this.text}; // Narrative 272 case -410956685: /*contained*/ return this.contained == null ? new Base[0] : this.contained.toArray(new Base[this.contained.size()]); // Resource 273 case -612557761: /*extension*/ return this.extension == null ? new Base[0] : this.extension.toArray(new Base[this.extension.size()]); // Extension 274 case -298878168: /*modifierExtension*/ return this.modifierExtension == null ? new Base[0] : this.modifierExtension.toArray(new Base[this.modifierExtension.size()]); // Extension 275 default: return super.getProperty(hash, name, checkValid); 276 } 277 278 } 279 280 @Override 281 public Base setProperty(int hash, String name, Base value) throws FHIRException { 282 switch (hash) { 283 case 3556653: // text 284 this.text = castToNarrative(value); // Narrative 285 return value; 286 case -410956685: // contained 287 this.getContained().add(castToResource(value)); // Resource 288 return value; 289 case -612557761: // extension 290 this.getExtension().add(castToExtension(value)); // Extension 291 return value; 292 case -298878168: // modifierExtension 293 this.getModifierExtension().add(castToExtension(value)); // Extension 294 return value; 295 default: return super.setProperty(hash, name, value); 296 } 297 298 } 299 300 @Override 301 public Base setProperty(String name, Base value) throws FHIRException { 302 if (name.equals("text")) { 303 this.text = castToNarrative(value); // Narrative 304 } else if (name.equals("contained")) { 305 this.getContained().add(castToResource(value)); 306 } else if (name.equals("extension")) { 307 this.getExtension().add(castToExtension(value)); 308 } else if (name.equals("modifierExtension")) { 309 this.getModifierExtension().add(castToExtension(value)); 310 } else 311 return super.setProperty(name, value); 312 return value; 313 } 314 315 @Override 316 public Base makeProperty(int hash, String name) throws FHIRException { 317 switch (hash) { 318 case 3556653: return getText(); 319 case -410956685: throw new FHIRException("Cannot make property contained as it is not a complex type"); // Resource 320 case -612557761: return addExtension(); 321 case -298878168: return addModifierExtension(); 322 default: return super.makeProperty(hash, name); 323 } 324 325 } 326 327 @Override 328 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 329 switch (hash) { 330 case 3556653: /*text*/ return new String[] {"Narrative"}; 331 case -410956685: /*contained*/ return new String[] {"Resource"}; 332 case -612557761: /*extension*/ return new String[] {"Extension"}; 333 case -298878168: /*modifierExtension*/ return new String[] {"Extension"}; 334 default: return super.getTypesForProperty(hash, name); 335 } 336 337 } 338 339 @Override 340 public Base addChild(String name) throws FHIRException { 341 if (name.equals("text")) { 342 this.text = new Narrative(); 343 return this.text; 344 } 345 else if (name.equals("contained")) { 346 throw new FHIRException("Cannot call addChild on an abstract type DomainResource.contained"); 347 } 348 else if (name.equals("extension")) { 349 return addExtension(); 350 } 351 else if (name.equals("modifierExtension")) { 352 return addModifierExtension(); 353 } 354 else 355 return super.addChild(name); 356 } 357 358 public String fhirType() { 359 return "DomainResource"; 360 361 } 362 363 public abstract DomainResource copy(); 364 365 public void copyValues(DomainResource dst) { 366 super.copyValues(dst); 367 dst.text = text == null ? null : text.copy(); 368 if (contained != null) { 369 dst.contained = new ArrayList<Resource>(); 370 for (Resource i : contained) 371 dst.contained.add(i.copy()); 372 }; 373 if (extension != null) { 374 dst.extension = new ArrayList<Extension>(); 375 for (Extension i : extension) 376 dst.extension.add(i.copy()); 377 }; 378 if (modifierExtension != null) { 379 dst.modifierExtension = new ArrayList<Extension>(); 380 for (Extension i : modifierExtension) 381 dst.modifierExtension.add(i.copy()); 382 }; 383 } 384 385 @Override 386 public boolean equalsDeep(Base other) { 387 if (!super.equalsDeep(other)) 388 return false; 389 if (!(other instanceof DomainResource)) 390 return false; 391 DomainResource o = (DomainResource) other; 392 return compareDeep(text, o.text, true) && compareDeep(contained, o.contained, true) && compareDeep(extension, o.extension, true) 393 && compareDeep(modifierExtension, o.modifierExtension, true); 394 } 395 396 @Override 397 public boolean equalsShallow(Base other) { 398 if (!super.equalsShallow(other)) 399 return false; 400 if (!(other instanceof DomainResource)) 401 return false; 402 DomainResource o = (DomainResource) other; 403 return true; 404 } 405 406 public boolean isEmpty() { 407 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(text, contained, extension 408 , modifierExtension); 409 } 410 411 412} 413