001package org.hl7.fhir.dstu2.model; 002 003 004 005 006/* 007 Copyright (c) 2011+, HL7, Inc. 008 All rights reserved. 009 010 Redistribution and use in source and binary forms, with or without modification, 011 are permitted provided that the following conditions are met: 012 013 * Redistributions of source code must retain the above copyright notice, this 014 list of conditions and the following disclaimer. 015 * Redistributions in binary form must reproduce the above copyright notice, 016 this list of conditions and the following disclaimer in the documentation 017 and/or other materials provided with the distribution. 018 * Neither the name of HL7 nor the names of its contributors may be used to 019 endorse or promote products derived from this software without specific 020 prior written permission. 021 022 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 023 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 024 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 025 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 026 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 027 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 028 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 029 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 030 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 031 POSSIBILITY OF SUCH DAMAGE. 032 033*/ 034 035// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2 036import java.util.ArrayList; 037import java.util.List; 038 039import ca.uhn.fhir.model.api.annotation.Child; 040import ca.uhn.fhir.model.api.annotation.Description; 041import org.hl7.fhir.instance.model.api.IBaseHasExtensions; 042import org.hl7.fhir.instance.model.api.IBaseHasModifierExtensions; 043import org.hl7.fhir.instance.model.api.IDomainResource; 044import org.hl7.fhir.exceptions.FHIRException; 045/** 046 * A resource that includes narrative, extensions, and contained resources. 047 */ 048public abstract class DomainResource extends Resource implements IBaseHasExtensions, IBaseHasModifierExtensions, IDomainResource { 049 050 /** 051 * 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. 052 */ 053 @Child(name = "text", type = {Narrative.class}, order=0, min=0, max=1, modifier=false, summary=false) 054 @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." ) 055 protected Narrative text; 056 057 /** 058 * 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. 059 */ 060 @Child(name = "contained", type = {Resource.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 061 @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." ) 062 protected List<Resource> contained; 063 064 /** 065 * 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. 066 */ 067 @Child(name = "extension", type = {Extension.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 068 @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." ) 069 protected List<Extension> extension; 070 071 /** 072 * 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. 073 */ 074 @Child(name = "modifierExtension", type = {Extension.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=true, summary=false) 075 @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." ) 076 protected List<Extension> modifierExtension; 077 078 private static final long serialVersionUID = -970285559L; 079 080 /* 081 * Constructor 082 */ 083 public DomainResource() { 084 super(); 085 } 086 087 /** 088 * @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.) 089 */ 090 public Narrative getText() { 091 if (this.text == null) 092 if (Configuration.errorOnAutoCreate()) 093 throw new Error("Attempt to auto-create DomainResource.text"); 094 else if (Configuration.doAutoCreate()) 095 this.text = new Narrative(); // cc 096 return this.text; 097 } 098 099 public boolean hasText() { 100 return this.text != null && !this.text.isEmpty(); 101 } 102 103 /** 104 * @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.) 105 */ 106 public DomainResource setText(Narrative value) { 107 this.text = value; 108 return this; 109 } 110 111 /** 112 * @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.) 113 */ 114 public List<Resource> getContained() { 115 if (this.contained == null) 116 this.contained = new ArrayList<Resource>(); 117 return this.contained; 118 } 119 120 public boolean hasContained() { 121 if (this.contained == null) 122 return false; 123 for (Resource item : this.contained) 124 if (!item.isEmpty()) 125 return true; 126 return false; 127 } 128 129 // syntactic sugar 130 public DomainResource addContained(Resource t) { //3 131 if (t == null) 132 return this; 133 if (this.contained == null) 134 this.contained = new ArrayList<Resource>(); 135 this.contained.add(t); 136 return this; 137 } 138 139 140 141 /** 142 * @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.) 143 */ 144 /** 145 * @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.) 146 */ 147 public List<Extension> getExtension() { 148 if (this.extension == null) 149 this.extension = new ArrayList<Extension>(); 150 return this.extension; 151 } 152 153 public boolean hasExtension() { 154 if (this.extension == null) 155 return false; 156 for (Extension item : this.extension) 157 if (!item.isEmpty()) 158 return true; 159 return false; 160 } 161 162 /** 163 * @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.) 164 */ 165 // syntactic sugar 166 public Extension addExtension() { //3 167 Extension t = new Extension(); 168 if (this.extension == null) 169 this.extension = new ArrayList<Extension>(); 170 this.extension.add(t); 171 return t; 172 } 173 174 // syntactic sugar 175 public DomainResource addExtension(Extension t) { //3 176 if (t == null) 177 return this; 178 if (this.extension == null) 179 this.extension = new ArrayList<Extension>(); 180 this.extension.add(t); 181 return this; 182 } 183 184 /** 185 * @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.) 186 */ 187 public List<Extension> getModifierExtension() { 188 if (this.modifierExtension == null) 189 this.modifierExtension = new ArrayList<Extension>(); 190 return this.modifierExtension; 191 } 192 193 public boolean hasModifierExtension() { 194 if (this.modifierExtension == null) 195 return false; 196 for (Extension item : this.modifierExtension) 197 if (!item.isEmpty()) 198 return true; 199 return false; 200 } 201 202 /** 203 * @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.) 204 */ 205 // syntactic sugar 206 public Extension addModifierExtension() { //3 207 Extension t = new Extension(); 208 if (this.modifierExtension == null) 209 this.modifierExtension = new ArrayList<Extension>(); 210 this.modifierExtension.add(t); 211 return t; 212 } 213 214 // syntactic sugar 215 public DomainResource addModifierExtension(Extension t) { //3 216 if (t == null) 217 return this; 218 if (this.modifierExtension == null) 219 this.modifierExtension = new ArrayList<Extension>(); 220 this.modifierExtension.add(t); 221 return this; 222 } 223 224 protected void listChildren(List<Property> childrenList) { 225 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)); 226 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)); 227 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)); 228 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)); 229 } 230 231 @Override 232 public void setProperty(String name, Base value) throws FHIRException { 233 if (name.equals("text")) 234 this.text = castToNarrative(value); // Narrative 235 else if (name.equals("contained")) 236 this.getContained().add(castToResource(value)); 237 else if (name.equals("extension")) 238 this.getExtension().add(castToExtension(value)); 239 else if (name.equals("modifierExtension")) 240 this.getModifierExtension().add(castToExtension(value)); 241 else 242 super.setProperty(name, value); 243 } 244 245 @Override 246 public Base addChild(String name) throws FHIRException { 247 if (name.equals("text")) { 248 this.text = new Narrative(); 249 return this.text; 250 } 251 else if (name.equals("contained")) { 252 throw new FHIRException("Cannot call addChild on an abstract type DomainResource.contained"); 253 } 254 else if (name.equals("extension")) { 255 return addExtension(); 256 } 257 else if (name.equals("modifierExtension")) { 258 return addModifierExtension(); 259 } 260 else 261 return super.addChild(name); 262 } 263 264 public String fhirType() { 265 return "DomainResource"; 266 267 } 268 269 public abstract DomainResource copy(); 270 271 public void copyValues(DomainResource dst) { 272 super.copyValues(dst); 273 dst.text = text == null ? null : text.copy(); 274 if (contained != null) { 275 dst.contained = new ArrayList<Resource>(); 276 for (Resource i : contained) 277 dst.contained.add(i.copy()); 278 }; 279 if (extension != null) { 280 dst.extension = new ArrayList<Extension>(); 281 for (Extension i : extension) 282 dst.extension.add(i.copy()); 283 }; 284 if (modifierExtension != null) { 285 dst.modifierExtension = new ArrayList<Extension>(); 286 for (Extension i : modifierExtension) 287 dst.modifierExtension.add(i.copy()); 288 }; 289 } 290 291 @Override 292 public boolean equalsDeep(Base other) { 293 if (!super.equalsDeep(other)) 294 return false; 295 if (!(other instanceof DomainResource)) 296 return false; 297 DomainResource o = (DomainResource) other; 298 return compareDeep(text, o.text, true) && compareDeep(contained, o.contained, true) && compareDeep(extension, o.extension, true) 299 && compareDeep(modifierExtension, o.modifierExtension, true); 300 } 301 302 @Override 303 public boolean equalsShallow(Base other) { 304 if (!super.equalsShallow(other)) 305 return false; 306 if (!(other instanceof DomainResource)) 307 return false; 308 DomainResource o = (DomainResource) other; 309 return true; 310 } 311 312 public boolean isEmpty() { 313 return super.isEmpty() && (text == null || text.isEmpty()) && (contained == null || contained.isEmpty()) 314 && (extension == null || extension.isEmpty()) && (modifierExtension == null || modifierExtension.isEmpty()) 315 ; 316 } 317 318 319}