001package org.hl7.fhir.r5.model;
002
003
004/*
005  Copyright (c) 2011+, HL7, Inc.
006  All rights reserved.
007  
008  Redistribution and use in source and binary forms, with or without modification, \
009  are permitted provided that the following conditions are met:
010  
011   * Redistributions of source code must retain the above copyright notice, this \
012     list of conditions and the following disclaimer.
013   * Redistributions in binary form must reproduce the above copyright notice, \
014     this list of conditions and the following disclaimer in the documentation \
015     and/or other materials provided with the distribution.
016   * Neither the name of HL7 nor the names of its contributors may be used to 
017     endorse or promote products derived from this software without specific 
018     prior written permission.
019  
020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
021  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
022  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
023  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
024  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
025  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
026  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
027  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
028  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
029  POSSIBILITY OF SUCH DAMAGE.
030  */
031
032// Generated on Thu, Mar 23, 2023 19:59+1100 for FHIR v5.0.0
033
034import java.util.ArrayList;
035import java.util.Collections;
036import java.util.List;
037
038import org.hl7.fhir.exceptions.FHIRException;
039import org.hl7.fhir.instance.model.api.IBaseHasExtensions;
040import org.hl7.fhir.instance.model.api.IBaseHasModifierExtensions;
041import org.hl7.fhir.instance.model.api.IDomainResource;
042import org.hl7.fhir.r5.extensions.ExtensionUtilities;
043
044import org.hl7.fhir.utilities.StandardsStatus;
045import org.hl7.fhir.utilities.Utilities;
046
047import ca.uhn.fhir.model.api.annotation.Child;
048import ca.uhn.fhir.model.api.annotation.Description;
049import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
050/**
051 * A resource that includes narrative, extensions, and contained resources.
052 */
053public abstract class DomainResource extends Resource implements IBaseHasExtensions, IBaseHasModifierExtensions, IDomainResource {
054
055    /**
056     * A human-readable narrative that contains a summary of the resource and can 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.
057     */
058    @Child(name = "text", type = {Narrative.class}, order=0, min=0, max=1, modifier=false, summary=false)
059    @Description(shortDefinition="Text summary of the resource, for human interpretation", formalDefinition="A human-readable narrative that contains a summary of the resource and can 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." )
060    protected Narrative text;
061
062    /**
063     * These resources do not have an independent existence apart from the resource that contains them - they cannot be identified independently, nor can they have their own independent transaction scope. This is allowed to be a Parameters resource if and only if it is referenced by a resource that provides context/meaning.
064     */
065    @Child(name = "contained", type = {Resource.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
066    @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, nor can they have their own independent transaction scope. This is allowed to be a Parameters resource if and only if it is referenced by a resource that provides context/meaning." )
067    protected List<Resource> contained;
068
069    /**
070     * May be used to represent additional information that is not part of the basic definition of the resource. To make the use of extensions safe and managable, there is a strict set of governance  applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.
071     */
072    @Child(name = "extension", type = {Extension.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
073    @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. To make the use of extensions safe and managable, there is a strict set of governance  applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension." )
074    protected List<Extension> extension;
075
076    /**
077     * 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 and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and managable, 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.
078
079Modifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).
080     */
081    @Child(name = "modifierExtension", type = {Extension.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=true, summary=true)
082    @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 and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and managable, 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.\n\nModifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself)." )
083    protected List<Extension> modifierExtension;
084
085    private static final long serialVersionUID = -970285559L;
086
087  /**
088   * Constructor
089   */
090    public DomainResource() {
091      super();
092    }
093
094    /**
095     * @return {@link #text} (A human-readable narrative that contains a summary of the resource and can 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.)
096     */
097    public Narrative getText() { 
098      if (this.text == null)
099        if (Configuration.errorOnAutoCreate())
100          throw new Error("Attempt to auto-create DomainResource.text");
101        else if (Configuration.doAutoCreate())
102          this.text = new Narrative(); // cc
103      return this.text;
104    }
105
106    public boolean hasText() { 
107      return this.text != null && !this.text.isEmpty();
108    }
109
110    /**
111     * @param value {@link #text} (A human-readable narrative that contains a summary of the resource and can 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.)
112     */
113    public DomainResource setText(Narrative value) { 
114      this.text = value;
115      return this;
116    }
117
118    /**
119     * @return {@link #contained} (These resources do not have an independent existence apart from the resource that contains them - they cannot be identified independently, nor can they have their own independent transaction scope. This is allowed to be a Parameters resource if and only if it is referenced by a resource that provides context/meaning.)
120     */
121    public List<Resource> getContained() { 
122      if (this.contained == null)
123        this.contained = new ArrayList<Resource>();
124      return this.contained;
125    }
126
127    /**
128     * @return Returns a reference to <code>this</code> for easy method chaining
129     */
130    public DomainResource setContained(List<Resource> theContained) { 
131      this.contained = theContained;
132      return this;
133    }
134
135    public boolean hasContained() { 
136      if (this.contained == null)
137        return false;
138      for (Resource item : this.contained)
139        if (!item.isEmpty())
140          return true;
141      return false;
142    }
143
144    public DomainResource addContained(Resource t) { //3
145      if (t == null)
146        return this;
147      if (this.contained == null)
148        this.contained = new ArrayList<Resource>();
149      this.contained.add(t);
150      return this;
151    }
152
153    /**
154     * @return {@link #extension} (May be used to represent additional information that is not part of the basic definition of the resource. To make the use of extensions safe and managable, there is a strict set of governance  applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.)
155     */
156    public List<Extension> getExtension() { 
157      if (this.extension == null)
158        this.extension = new ArrayList<Extension>();
159      return this.extension;
160    }
161
162    /**
163     * @return Returns a reference to <code>this</code> for easy method chaining
164     */
165    public DomainResource setExtension(List<Extension> theExtension) { 
166      this.extension = theExtension;
167      return this;
168    }
169
170    public boolean hasExtension() {
171      if (this.extension == null)
172        return false;
173      for (Extension item : this.extension)
174        if (!item.isEmpty())
175          return true;
176      return false;
177    }
178
179    public Extension addExtension() { //3
180      Extension t = new Extension();
181      if (this.extension == null)
182        this.extension = new ArrayList<Extension>();
183      this.extension.add(t);
184      return t;
185    }
186
187    public DomainResource addExtension(Extension t) { //3
188      if (t == null)
189        return this;
190      if (this.extension == null)
191        this.extension = new ArrayList<Extension>();
192      this.extension.add(t);
193      return this;
194    }
195
196    /**
197     * @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 and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and managable, 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.
198
199Modifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).)
200     */
201    public List<Extension> getModifierExtension() { 
202      if (this.modifierExtension == null)
203        this.modifierExtension = new ArrayList<Extension>();
204      return this.modifierExtension;
205    }
206
207    /**
208     * @return Returns a reference to <code>this</code> for easy method chaining
209     */
210    public DomainResource setModifierExtension(List<Extension> theModifierExtension) { 
211      this.modifierExtension = theModifierExtension;
212      return this;
213    }
214
215    public boolean hasModifierExtension() { 
216      if (this.modifierExtension == null)
217        return false;
218      for (Extension item : this.modifierExtension)
219        if (!item.isEmpty())
220          return true;
221      return false;
222    }
223
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    public DomainResource addModifierExtension(Extension t) { //3
233      if (t == null)
234        return this;
235      if (this.modifierExtension == null)
236        this.modifierExtension = new ArrayList<Extension>();
237      this.modifierExtension.add(t);
238      return this;
239    }
240
241      protected void listChildren(List<Property> children) {
242        super.listChildren(children);
243        children.add(new Property("text", "Narrative", "A human-readable narrative that contains a summary of the resource and can 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, 1, text));
244        children.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, nor can they have their own independent transaction scope. This is allowed to be a Parameters resource if and only if it is referenced by a resource that provides context/meaning.", 0, java.lang.Integer.MAX_VALUE, contained));
245        children.add(new Property("extension", "Extension", "May be used to represent additional information that is not part of the basic definition of the resource. To make the use of extensions safe and managable, there is a strict set of governance  applied to the definition and use of extensions. Though any implementer can 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        children.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 and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and managable, 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.\n\nModifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).", 0, java.lang.Integer.MAX_VALUE, modifierExtension));
247      }
248
249      @Override
250      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
251        switch (_hash) {
252        case 3556653: /*text*/  return new Property("text", "Narrative", "A human-readable narrative that contains a summary of the resource and can 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, 1, text);
253        case -410956685: /*contained*/  return new Property("contained", "Resource", "These resources do not have an independent existence apart from the resource that contains them - they cannot be identified independently, nor can they have their own independent transaction scope. This is allowed to be a Parameters resource if and only if it is referenced by a resource that provides context/meaning.", 0, java.lang.Integer.MAX_VALUE, contained);
254        case -612557761: /*extension*/  return new Property("extension", "Extension", "May be used to represent additional information that is not part of the basic definition of the resource. To make the use of extensions safe and managable, there is a strict set of governance  applied to the definition and use of extensions. Though any implementer can 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);
255        case -298878168: /*modifierExtension*/  return 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 and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and managable, 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.\n\nModifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).", 0, java.lang.Integer.MAX_VALUE, modifierExtension);
256        default: return super.getNamedProperty(_hash, _name, _checkValid);
257        }
258
259      }
260
261      @Override
262      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
263        switch (hash) {
264        case 3556653: /*text*/ return this.text == null ? new Base[0] : new Base[] {this.text}; // Narrative
265        case -410956685: /*contained*/ return this.contained == null ? new Base[0] : this.contained.toArray(new Base[this.contained.size()]); // Resource
266        case -612557761: /*extension*/ return this.extension == null ? new Base[0] : this.extension.toArray(new Base[this.extension.size()]); // Extension
267        case -298878168: /*modifierExtension*/ return this.modifierExtension == null ? new Base[0] : this.modifierExtension.toArray(new Base[this.modifierExtension.size()]); // Extension
268        default: return super.getProperty(hash, name, checkValid);
269        }
270
271      }
272
273      @Override
274      public Base setProperty(int hash, String name, Base value) throws FHIRException {
275        switch (hash) {
276        case 3556653: // text
277          this.text = TypeConvertor.castToNarrative(value); // Narrative
278          return value;
279        case -410956685: // contained
280          this.getContained().add(TypeConvertor.castToResource(value)); // Resource
281          return value;
282        case -612557761: // extension
283          this.getExtension().add(TypeConvertor.castToExtension(value)); // Extension
284          return value;
285        case -298878168: // modifierExtension
286          this.getModifierExtension().add(TypeConvertor.castToExtension(value)); // Extension
287          return value;
288        default: return super.setProperty(hash, name, value);
289        }
290
291      }
292
293      @Override
294      public Base setProperty(String name, Base value) throws FHIRException {
295        if (name.equals("text")) {
296          this.text = TypeConvertor.castToNarrative(value); // Narrative
297        } else if (name.equals("contained")) {
298          this.getContained().add(TypeConvertor.castToResource(value));
299        } else if (name.equals("extension")) {
300          this.getExtension().add(TypeConvertor.castToExtension(value));
301        } else if (name.equals("modifierExtension")) {
302          this.getModifierExtension().add(TypeConvertor.castToExtension(value));
303        } else
304          return super.setProperty(name, value);
305        return value;
306      }
307
308  @Override
309  public void removeChild(String name, Base value) throws FHIRException {
310        if (name.equals("text")) {
311          this.text = null;
312        } else if (name.equals("contained")) {
313          this.getContained().remove(value);
314        } else if (name.equals("extension")) {
315          this.getExtension().remove(value);
316        } else if (name.equals("modifierExtension")) {
317          this.getModifierExtension().remove(value);
318        } else
319          super.removeChild(name, value);
320        
321      }
322
323      @Override
324      public Base makeProperty(int hash, String name) throws FHIRException {
325        switch (hash) {
326        case 3556653:  return getText();
327        case -410956685: throw new FHIRException("Cannot make property contained as it is not a complex type"); // Resource
328        case -612557761:  return addExtension(); 
329        case -298878168:  return addModifierExtension(); 
330        default: return super.makeProperty(hash, name);
331        }
332
333      }
334
335      @Override
336      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
337        switch (hash) {
338        case 3556653: /*text*/ return new String[] {"Narrative"};
339        case -410956685: /*contained*/ return new String[] {"Resource"};
340        case -612557761: /*extension*/ return new String[] {"Extension"};
341        case -298878168: /*modifierExtension*/ return new String[] {"Extension"};
342        default: return super.getTypesForProperty(hash, name);
343        }
344
345      }
346
347      @Override
348      public Base addChild(String name) throws FHIRException {
349        if (name.equals("text")) {
350          this.text = new Narrative();
351          return this.text;
352        }
353        else if (name.equals("contained")) {
354          throw new FHIRException("Cannot call addChild on an abstract type DomainResource.contained");
355        }
356        else if (name.equals("extension")) {
357          return addExtension();
358        }
359        else if (name.equals("modifierExtension")) {
360          return addModifierExtension();
361        }
362        else
363          return super.addChild(name);
364      }
365
366  public String fhirType() {
367    return "DomainResource";
368
369  }
370
371      public abstract DomainResource copy();
372
373      public void copyValues(DomainResource dst) {
374        super.copyValues(dst);
375        dst.text = text == null ? null : text.copy();
376        if (contained != null) {
377          dst.contained = new ArrayList<Resource>();
378          for (Resource i : contained)
379            dst.contained.add(i.copy());
380        };
381        if (extension != null) {
382          dst.extension = new ArrayList<Extension>();
383          for (Extension i : extension)
384            dst.extension.add(i.copy());
385        };
386        if (modifierExtension != null) {
387          dst.modifierExtension = new ArrayList<Extension>();
388          for (Extension i : modifierExtension)
389            dst.modifierExtension.add(i.copy());
390        };
391      }
392
393      @Override
394      public boolean equalsDeep(Base other_) {
395        if (!super.equalsDeep(other_))
396          return false;
397        if (!(other_ instanceof DomainResource))
398          return false;
399        DomainResource o = (DomainResource) other_;
400        return compareDeep(text, o.text, true) && compareDeep(contained, o.contained, true) && compareDeep(extension, o.extension, true)
401           && compareDeep(modifierExtension, o.modifierExtension, true);
402      }
403
404      @Override
405      public boolean equalsShallow(Base other_) {
406        if (!super.equalsShallow(other_))
407          return false;
408        if (!(other_ instanceof DomainResource))
409          return false;
410        DomainResource o = (DomainResource) other_;
411        return true;
412      }
413
414      public boolean isEmpty() {
415        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(text, contained, extension
416          , modifierExtension);
417      }
418
419 /**
420   * Search parameter: <b>_text</b>
421   * <p>
422   * Description: <b>Search on the narrative of the resource</b><br>
423   * Type: <b>special</b><br>
424   * Path: <b>null</b><br>
425   * </p>
426   */
427  @SearchParamDefinition(name="_text", path="", description="Search on the narrative of the resource", type="special" )
428  public static final String SP_TEXT = "_text";
429 /**
430   * <b>Fluent Client</b> search parameter constant for <b>_text</b>
431   * <p>
432   * Description: <b>Search on the narrative of the resource</b><br>
433   * Type: <b>special</b><br>
434   * Path: <b>null</b><br>
435   * </p>
436   */
437  public static final ca.uhn.fhir.rest.gclient.SpecialClientParam TEXT = new ca.uhn.fhir.rest.gclient.SpecialClientParam(SP_TEXT);
438
439// Manual code (from Configuration.txt):
440public void checkNoModifiers(String noun, String verb) throws FHIRException {
441  if (hasModifierExtension()) {
442    throw new FHIRException("Found unknown Modifier Exceptions on " + noun + " doing " + verb);
443  }
444
445}
446
447  public void addExtension(String url, DataType value) {
448    Extension ex = new Extension();
449    ex.setUrl(url);
450    ex.setValue(value);
451    getExtension().add(ex);
452  }
453
454  public boolean hasExtension(String... theUrls) {
455    for (Extension next : getModifierExtension()) {
456      if (Utilities.existsInList(next.getUrl(), theUrls)) {
457        return true;
458      }
459    }
460    for (Extension next : getExtension()) {
461      if (Utilities.existsInList(next.getUrl(), theUrls)) {
462        return true;
463      }
464    }
465    return false;
466  }
467
468  public boolean hasExtension(String url) {
469    for (Extension next : getModifierExtension()) {
470      if (url.equals(next.getUrl())) {
471        return true;
472      }
473    }
474    for (Extension e : getExtension())
475      if (url.equals(e.getUrl()))
476        return true;
477    return false;
478  }
479
480  public Extension getExtensionByUrl(String theUrl) {
481    org.apache.commons.lang3.Validate.notBlank(theUrl, "theUrl must not be blank or null");
482    ArrayList<Extension> retVal = new ArrayList<Extension>();
483
484    for (Extension next : getExtension()) {
485      if (theUrl.equals(next.getUrl())) {
486        retVal.add(next);
487      }
488    }
489
490    for (Extension next : getModifierExtension()) {
491      if (theUrl.equals(next.getUrl())) {
492        retVal.add(next);
493      }
494    }
495    if (retVal.size() == 0)
496      return null;
497    else {
498      org.apache.commons.lang3.Validate.isTrue(retVal.size() == 1, "Url " + theUrl + " must have only one match");
499      return retVal.get(0);
500    }
501  }
502
503
504  /**
505   * Returns the value as a string if this element has only one extension that matches the given URL, and that can be converted to a string.
506   * <p>
507   * Note: BackboneElements override this to check Modifier Extensions too
508   *
509   * @param theUrl The URL. Must not be blank or null.
510   */
511  public String getExtensionString(String theUrl) throws FHIRException {
512    List<Extension> ext = getExtensionsByUrl(theUrl);
513    if (ext.isEmpty())
514      return null;
515    if (ext.size() > 1)
516      throw new FHIRException("Multiple matching extensions found for extension '" + theUrl + "'");
517    if (!ext.get(0).hasValue())
518      return null;
519    if (!ext.get(0).getValue().isPrimitive())
520      throw new FHIRException("Extension '" + theUrl + "' could not be converted to a string");
521    return ext.get(0).getValue().primitiveValue();
522  }
523
524  public String getExtensionString(String... theUrls) throws FHIRException {
525    for (String url : theUrls) {
526      if (hasExtension(url)) {
527        return getExtensionString(url);
528      }
529    }
530    return null;
531  }
532
533
534  public Resource getContained(String ref) {
535    if (ref == null)
536      return null;
537
538    if (ref.startsWith("#"))
539      ref = ref.substring(1);
540    for (Resource r : getContained()) {
541      if (r.getId().equals(ref))
542        return r;
543    }
544    return null;
545  }
546
547  /**
548   * Returns a list of extensions from this element which have the given URL. Note that
549   * this list may not be modified (you can not add or remove elements from it)
550   */
551  public List<Extension> getExtensionsByUrl(String theUrl) {
552    org.apache.commons.lang3.Validate.notBlank(theUrl, "theUrl must be provided with a value");
553    ArrayList<Extension> retVal = new ArrayList<Extension>();
554    for (Extension next : getExtension()) {
555      if (theUrl.equals(next.getUrl())) {
556        retVal.add(next);
557      }
558    }
559    for (Extension next : getModifierExtension()) {
560      if (theUrl.equals(next.getUrl())) {
561        retVal.add(next);
562      }
563    }
564    return Collections.unmodifiableList(retVal);
565  }
566
567
568  public List<Extension> getExtensionsByUrl(String... theUrls) {
569    ArrayList<Extension> retVal = new ArrayList<>();
570
571    for (Extension next : getExtension()) {
572      if (Utilities.existsInList(next.getUrl(), theUrls)) {
573        retVal.add(next);
574      }
575    }
576    for (Extension next : getModifierExtension()) {
577      if (Utilities.existsInList(next.getUrl(), theUrls)) {
578        retVal.add(next);
579      }
580    }
581    return java.util.Collections.unmodifiableList(retVal);
582  }
583
584  /**
585   * Returns a list of modifier extensions from this element which have the given URL. Note that
586   * this list may not be modified (you can not add or remove elements from it)
587   */
588  public List<Extension> getModifierExtensionsByUrl(String theUrl) {
589    org.apache.commons.lang3.Validate.notBlank(theUrl, "theUrl must be provided with a value");
590    ArrayList<Extension> retVal = new ArrayList<Extension>();
591    for (Extension next : getModifierExtension()) {
592      if (theUrl.equals(next.getUrl())) {
593        retVal.add(next);
594      }
595    }
596    return Collections.unmodifiableList(retVal);
597  }
598
599
600  public StandardsStatus getStandardsStatus() {
601    return ExtensionUtilities.getStandardsStatus(this);
602  }
603
604  public void setStandardsStatus(StandardsStatus status) {
605    ExtensionUtilities.setStandardsStatus(this, status, null);
606  }
607
608    
609// end addition
610
611}
612