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.List; 056 057import ca.uhn.fhir.model.api.annotation.Child; 058import ca.uhn.fhir.model.api.annotation.Description; 059import org.hl7.fhir.instance.model.api.IBaseHasExtensions; 060import org.hl7.fhir.instance.model.api.IBaseHasModifierExtensions; 061import org.hl7.fhir.instance.model.api.IDomainResource; 062import org.hl7.fhir.exceptions.FHIRException; 063/** 064 * A resource that includes narrative, extensions, and contained resources. 065 */ 066public abstract class DomainResource extends Resource implements IBaseHasExtensions, IBaseHasModifierExtensions, IDomainResource { 067 068 /** 069 * 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. 070 */ 071 @Child(name = "text", type = {Narrative.class}, order=0, min=0, max=1, modifier=false, summary=false) 072 @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." ) 073 protected Narrative text; 074 075 /** 076 * 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. 077 */ 078 @Child(name = "contained", type = {Resource.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 079 @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." ) 080 protected List<Resource> contained; 081 082 /** 083 * 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. 084 */ 085 @Child(name = "extension", type = {Extension.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 086 @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." ) 087 protected List<Extension> extension; 088 089 /** 090 * 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. 091 */ 092 @Child(name = "modifierExtension", type = {Extension.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=true, summary=false) 093 @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." ) 094 protected List<Extension> modifierExtension; 095 096 private static final long serialVersionUID = -970285559L; 097 098 /* 099 * Constructor 100 */ 101 public DomainResource() { 102 super(); 103 } 104 105 /** 106 * @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.) 107 */ 108 public Narrative getText() { 109 if (this.text == null) 110 if (Configuration.errorOnAutoCreate()) 111 throw new Error("Attempt to auto-create DomainResource.text"); 112 else if (Configuration.doAutoCreate()) 113 this.text = new Narrative(); // cc 114 return this.text; 115 } 116 117 public boolean hasText() { 118 return this.text != null && !this.text.isEmpty(); 119 } 120 121 /** 122 * @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.) 123 */ 124 public DomainResource setText(Narrative value) { 125 this.text = value; 126 return this; 127 } 128 129 /** 130 * @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.) 131 */ 132 public List<Resource> getContained() { 133 if (this.contained == null) 134 this.contained = new ArrayList<Resource>(); 135 return this.contained; 136 } 137 138 public boolean hasContained() { 139 if (this.contained == null) 140 return false; 141 for (Resource item : this.contained) 142 if (!item.isEmpty()) 143 return true; 144 return false; 145 } 146 147 // syntactic sugar 148 public DomainResource addContained(Resource t) { //3 149 if (t == null) 150 return this; 151 if (this.contained == null) 152 this.contained = new ArrayList<Resource>(); 153 this.contained.add(t); 154 return this; 155 } 156 157 158 159 /** 160 * @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.) 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 public List<Extension> getExtension() { 166 if (this.extension == null) 167 this.extension = new ArrayList<Extension>(); 168 return this.extension; 169 } 170 171 public boolean hasExtension() { 172 if (this.extension == null) 173 return false; 174 for (Extension item : this.extension) 175 if (!item.isEmpty()) 176 return true; 177 return false; 178 } 179 180 /** 181 * @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.) 182 */ 183 // syntactic sugar 184 public Extension addExtension() { //3 185 Extension t = new Extension(); 186 if (this.extension == null) 187 this.extension = new ArrayList<Extension>(); 188 this.extension.add(t); 189 return t; 190 } 191 192 // syntactic sugar 193 public DomainResource addExtension(Extension t) { //3 194 if (t == null) 195 return this; 196 if (this.extension == null) 197 this.extension = new ArrayList<Extension>(); 198 this.extension.add(t); 199 return this; 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 public List<Extension> getModifierExtension() { 206 if (this.modifierExtension == null) 207 this.modifierExtension = new ArrayList<Extension>(); 208 return this.modifierExtension; 209 } 210 211 public boolean hasModifierExtension() { 212 if (this.modifierExtension == null) 213 return false; 214 for (Extension item : this.modifierExtension) 215 if (!item.isEmpty()) 216 return true; 217 return false; 218 } 219 220 /** 221 * @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.) 222 */ 223 // syntactic sugar 224 public Extension addModifierExtension() { //3 225 Extension t = new Extension(); 226 if (this.modifierExtension == null) 227 this.modifierExtension = new ArrayList<Extension>(); 228 this.modifierExtension.add(t); 229 return t; 230 } 231 232 // syntactic sugar 233 public DomainResource addModifierExtension(Extension t) { //3 234 if (t == null) 235 return this; 236 if (this.modifierExtension == null) 237 this.modifierExtension = new ArrayList<Extension>(); 238 this.modifierExtension.add(t); 239 return this; 240 } 241 242 protected void listChildren(List<Property> childrenList) { 243 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)); 244 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)); 245 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)); 246 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)); 247 } 248 249 @Override 250 public void setProperty(String name, Base value) throws FHIRException { 251 if (name.equals("text")) 252 this.text = castToNarrative(value); // Narrative 253 else if (name.equals("contained")) 254 this.getContained().add(castToResource(value)); 255 else if (name.equals("extension")) 256 this.getExtension().add(castToExtension(value)); 257 else if (name.equals("modifierExtension")) 258 this.getModifierExtension().add(castToExtension(value)); 259 else 260 super.setProperty(name, value); 261 } 262 263 @Override 264 public Base addChild(String name) throws FHIRException { 265 if (name.equals("text")) { 266 this.text = new Narrative(); 267 return this.text; 268 } 269 else if (name.equals("contained")) { 270 throw new FHIRException("Cannot call addChild on an abstract type DomainResource.contained"); 271 } 272 else if (name.equals("extension")) { 273 return addExtension(); 274 } 275 else if (name.equals("modifierExtension")) { 276 return addModifierExtension(); 277 } 278 else 279 return super.addChild(name); 280 } 281 282 public String fhirType() { 283 return "DomainResource"; 284 285 } 286 287 public abstract DomainResource copy(); 288 289 public void copyValues(DomainResource dst) { 290 super.copyValues(dst); 291 dst.text = text == null ? null : text.copy(); 292 if (contained != null) { 293 dst.contained = new ArrayList<Resource>(); 294 for (Resource i : contained) 295 dst.contained.add(i.copy()); 296 }; 297 if (extension != null) { 298 dst.extension = new ArrayList<Extension>(); 299 for (Extension i : extension) 300 dst.extension.add(i.copy()); 301 }; 302 if (modifierExtension != null) { 303 dst.modifierExtension = new ArrayList<Extension>(); 304 for (Extension i : modifierExtension) 305 dst.modifierExtension.add(i.copy()); 306 }; 307 } 308 309 @Override 310 public boolean equalsDeep(Base other) { 311 if (!super.equalsDeep(other)) 312 return false; 313 if (!(other instanceof DomainResource)) 314 return false; 315 DomainResource o = (DomainResource) other; 316 return compareDeep(text, o.text, true) && compareDeep(contained, o.contained, true) && compareDeep(extension, o.extension, true) 317 && compareDeep(modifierExtension, o.modifierExtension, true); 318 } 319 320 @Override 321 public boolean equalsShallow(Base other) { 322 if (!super.equalsShallow(other)) 323 return false; 324 if (!(other instanceof DomainResource)) 325 return false; 326 DomainResource o = (DomainResource) other; 327 return true; 328 } 329 330 public boolean isEmpty() { 331 return super.isEmpty() && (text == null || text.isEmpty()) && (contained == null || contained.isEmpty()) 332 && (extension == null || extension.isEmpty()) && (modifierExtension == null || modifierExtension.isEmpty()) 333 ; 334 } 335 336 337} 338