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