001package org.hl7.fhir.r5.model;
002
003
004/*
005 * #%L
006 * org.hl7.fhir.r5
007 * %%
008 * Copyright (C) 2014 - 2019 Health Level 7
009 * %%
010 * Licensed under the Apache License, Version 2.0 (the \"License\");
011 * you may not use this file except in compliance with the License.
012 * You may obtain a copy of the License at
013 * 
014 *      http://www.apache.org/licenses/LICENSE-2.0
015 * 
016 * Unless required by applicable law or agreed to in writing, software
017 * distributed under the License is distributed on an \"AS IS\" BASIS,
018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
019 * See the License for the specific language governing permissions and
020 * limitations under the License.
021 * #L%
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// Generated on Tue, Dec 31, 2019 12:12+1100 for FHIR vcurrent
053
054import java.util.ArrayList;
055import java.util.Date;
056import java.util.List;
057import org.hl7.fhir.utilities.Utilities;
058import org.hl7.fhir.r5.model.Enumerations.*;
059import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
060import org.hl7.fhir.exceptions.FHIRException;
061import org.hl7.fhir.instance.model.api.ICompositeType;
062import ca.uhn.fhir.model.api.annotation.ResourceDef;
063import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
064import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
065import ca.uhn.fhir.model.api.annotation.Child;
066import ca.uhn.fhir.model.api.annotation.ChildOrder;
067import ca.uhn.fhir.model.api.annotation.Description;
068import ca.uhn.fhir.model.api.annotation.Block;
069
070import org.hl7.fhir.instance.model.api.IAnyResource;
071/**
072 * This is the base resource type for everything.
073 */
074public abstract class Resource extends BaseResource implements IAnyResource {
075
076    /**
077     * The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.
078     */
079    @Child(name = "id", type = {IdType.class}, order=0, min=0, max=1, modifier=false, summary=true)
080    @Description(shortDefinition="Logical id of this artifact", formalDefinition="The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes." )
081    protected IdType id;
082
083    /**
084     * The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.
085     */
086    @Child(name = "meta", type = {Meta.class}, order=1, min=0, max=1, modifier=false, summary=true)
087    @Description(shortDefinition="Metadata about the resource", formalDefinition="The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource." )
088    protected Meta meta;
089
090    /**
091     * A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.
092     */
093    @Child(name = "implicitRules", type = {UriType.class}, order=2, min=0, max=1, modifier=true, summary=true)
094    @Description(shortDefinition="A set of rules under which this content was created", formalDefinition="A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc." )
095    protected UriType implicitRules;
096
097    /**
098     * The base language in which the resource is written.
099     */
100    @Child(name = "language", type = {CodeType.class}, order=3, min=0, max=1, modifier=false, summary=false)
101    @Description(shortDefinition="Language of the resource content", formalDefinition="The base language in which the resource is written." )
102    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/languages")
103    protected CodeType language;
104
105    private static final long serialVersionUID = -559462759L;
106
107  /**
108   * Constructor
109   */
110    public Resource() {
111      super();
112    }
113
114    /**
115     * @return {@link #id} (The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.). This is the underlying object with id, value and extensions. The accessor "getId" gives direct access to the value
116     */
117    public IdType getIdElement() { 
118      if (this.id == null)
119        if (Configuration.errorOnAutoCreate())
120          throw new Error("Attempt to auto-create Resource.id");
121        else if (Configuration.doAutoCreate())
122          this.id = new IdType(); // bb
123      return this.id;
124    }
125
126    public boolean hasIdElement() { 
127      return this.id != null && !this.id.isEmpty();
128    }
129
130    public boolean hasId() { 
131      return this.id != null && !this.id.isEmpty();
132    }
133
134    /**
135     * @param value {@link #id} (The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.). This is the underlying object with id, value and extensions. The accessor "getId" gives direct access to the value
136     */
137    public Resource setIdElement(IdType value) { 
138      this.id = value;
139      return this;
140    }
141
142    /**
143     * @return The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.
144     */
145    public String getId() { 
146      return this.id == null ? null : this.id.getValue();
147    }
148
149    /**
150     * @param value The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.
151     */
152    public Resource setId(String value) { 
153      if (Utilities.noString(value))
154        this.id = null;
155      else {
156        if (this.id == null)
157          this.id = new IdType();
158        this.id.setValue(value);
159      }
160      return this;
161    }
162
163    /**
164     * @return {@link #meta} (The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.)
165     */
166    public Meta getMeta() { 
167      if (this.meta == null)
168        if (Configuration.errorOnAutoCreate())
169          throw new Error("Attempt to auto-create Resource.meta");
170        else if (Configuration.doAutoCreate())
171          this.meta = new Meta(); // cc
172      return this.meta;
173    }
174
175    public boolean hasMeta() { 
176      return this.meta != null && !this.meta.isEmpty();
177    }
178
179    /**
180     * @param value {@link #meta} (The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.)
181     */
182    public Resource setMeta(Meta value) { 
183      this.meta = value;
184      return this;
185    }
186
187    /**
188     * @return {@link #implicitRules} (A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.). This is the underlying object with id, value and extensions. The accessor "getImplicitRules" gives direct access to the value
189     */
190    public UriType getImplicitRulesElement() { 
191      if (this.implicitRules == null)
192        if (Configuration.errorOnAutoCreate())
193          throw new Error("Attempt to auto-create Resource.implicitRules");
194        else if (Configuration.doAutoCreate())
195          this.implicitRules = new UriType(); // bb
196      return this.implicitRules;
197    }
198
199    public boolean hasImplicitRulesElement() { 
200      return this.implicitRules != null && !this.implicitRules.isEmpty();
201    }
202
203    public boolean hasImplicitRules() { 
204      return this.implicitRules != null && !this.implicitRules.isEmpty();
205    }
206
207    /**
208     * @param value {@link #implicitRules} (A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.). This is the underlying object with id, value and extensions. The accessor "getImplicitRules" gives direct access to the value
209     */
210    public Resource setImplicitRulesElement(UriType value) { 
211      this.implicitRules = value;
212      return this;
213    }
214
215    /**
216     * @return A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.
217     */
218    public String getImplicitRules() { 
219      return this.implicitRules == null ? null : this.implicitRules.getValue();
220    }
221
222    /**
223     * @param value A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.
224     */
225    public Resource setImplicitRules(String value) { 
226      if (Utilities.noString(value))
227        this.implicitRules = null;
228      else {
229        if (this.implicitRules == null)
230          this.implicitRules = new UriType();
231        this.implicitRules.setValue(value);
232      }
233      return this;
234    }
235
236    /**
237     * @return {@link #language} (The base language in which the resource is written.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value
238     */
239    public CodeType getLanguageElement() { 
240      if (this.language == null)
241        if (Configuration.errorOnAutoCreate())
242          throw new Error("Attempt to auto-create Resource.language");
243        else if (Configuration.doAutoCreate())
244          this.language = new CodeType(); // bb
245      return this.language;
246    }
247
248    public boolean hasLanguageElement() { 
249      return this.language != null && !this.language.isEmpty();
250    }
251
252    public boolean hasLanguage() { 
253      return this.language != null && !this.language.isEmpty();
254    }
255
256    /**
257     * @param value {@link #language} (The base language in which the resource is written.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value
258     */
259    public Resource setLanguageElement(CodeType value) { 
260      this.language = value;
261      return this;
262    }
263
264    /**
265     * @return The base language in which the resource is written.
266     */
267    public String getLanguage() { 
268      return this.language == null ? null : this.language.getValue();
269    }
270
271    /**
272     * @param value The base language in which the resource is written.
273     */
274    public Resource setLanguage(String value) { 
275      if (Utilities.noString(value))
276        this.language = null;
277      else {
278        if (this.language == null)
279          this.language = new CodeType();
280        this.language.setValue(value);
281      }
282      return this;
283    }
284
285      protected void listChildren(List<Property> children) {
286        super.listChildren(children);
287        children.add(new Property("id", "id", "The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.", 0, 1, id));
288        children.add(new Property("meta", "Meta", "The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.", 0, 1, meta));
289        children.add(new Property("implicitRules", "uri", "A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.", 0, 1, implicitRules));
290        children.add(new Property("language", "code", "The base language in which the resource is written.", 0, 1, language));
291      }
292
293      @Override
294      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
295        switch (_hash) {
296        case 3355: /*id*/  return new Property("id", "id", "The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.", 0, 1, id);
297        case 3347973: /*meta*/  return new Property("meta", "Meta", "The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.", 0, 1, meta);
298        case -961826286: /*implicitRules*/  return new Property("implicitRules", "uri", "A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.", 0, 1, implicitRules);
299        case -1613589672: /*language*/  return new Property("language", "code", "The base language in which the resource is written.", 0, 1, language);
300        default: return super.getNamedProperty(_hash, _name, _checkValid);
301        }
302
303      }
304
305      @Override
306      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
307        switch (hash) {
308        case 3355: /*id*/ return this.id == null ? new Base[0] : new Base[] {this.id}; // IdType
309        case 3347973: /*meta*/ return this.meta == null ? new Base[0] : new Base[] {this.meta}; // Meta
310        case -961826286: /*implicitRules*/ return this.implicitRules == null ? new Base[0] : new Base[] {this.implicitRules}; // UriType
311        case -1613589672: /*language*/ return this.language == null ? new Base[0] : new Base[] {this.language}; // CodeType
312        default: return super.getProperty(hash, name, checkValid);
313        }
314
315      }
316
317      @Override
318      public Base setProperty(int hash, String name, Base value) throws FHIRException {
319        switch (hash) {
320        case 3355: // id
321          this.id = TypeConvertor.castToId(value); // IdType
322          return value;
323        case 3347973: // meta
324          this.meta = TypeConvertor.castToMeta(value); // Meta
325          return value;
326        case -961826286: // implicitRules
327          this.implicitRules = TypeConvertor.castToUri(value); // UriType
328          return value;
329        case -1613589672: // language
330          this.language = TypeConvertor.castToCode(value); // CodeType
331          return value;
332        default: return super.setProperty(hash, name, value);
333        }
334
335      }
336
337      @Override
338      public Base setProperty(String name, Base value) throws FHIRException {
339        if (name.equals("id")) {
340          this.id = TypeConvertor.castToId(value); // IdType
341        } else if (name.equals("meta")) {
342          this.meta = TypeConvertor.castToMeta(value); // Meta
343        } else if (name.equals("implicitRules")) {
344          this.implicitRules = TypeConvertor.castToUri(value); // UriType
345        } else if (name.equals("language")) {
346          this.language = TypeConvertor.castToCode(value); // CodeType
347        } else
348          return super.setProperty(name, value);
349        return value;
350      }
351
352      @Override
353      public Base makeProperty(int hash, String name) throws FHIRException {
354        switch (hash) {
355        case 3355:  return getIdElement();
356        case 3347973:  return getMeta();
357        case -961826286:  return getImplicitRulesElement();
358        case -1613589672:  return getLanguageElement();
359        default: return super.makeProperty(hash, name);
360        }
361
362      }
363
364      @Override
365      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
366        switch (hash) {
367        case 3355: /*id*/ return new String[] {"id"};
368        case 3347973: /*meta*/ return new String[] {"Meta"};
369        case -961826286: /*implicitRules*/ return new String[] {"uri"};
370        case -1613589672: /*language*/ return new String[] {"code"};
371        default: return super.getTypesForProperty(hash, name);
372        }
373
374      }
375
376      @Override
377      public Base addChild(String name) throws FHIRException {
378        if (name.equals("id")) {
379          throw new FHIRException("Cannot call addChild on a primitive type Resource.id");
380        }
381        else if (name.equals("meta")) {
382          this.meta = new Meta();
383          return this.meta;
384        }
385        else if (name.equals("implicitRules")) {
386          throw new FHIRException("Cannot call addChild on a primitive type Resource.implicitRules");
387        }
388        else if (name.equals("language")) {
389          throw new FHIRException("Cannot call addChild on a primitive type Resource.language");
390        }
391        else
392          return super.addChild(name);
393      }
394
395  public String fhirType() {
396    return "Resource";
397
398  }
399
400      public abstract Resource copy();
401
402      public void copyValues(Resource dst) {
403        super.copyValues(dst);
404        dst.id = id == null ? null : id.copy();
405        dst.meta = meta == null ? null : meta.copy();
406        dst.implicitRules = implicitRules == null ? null : implicitRules.copy();
407        dst.language = language == null ? null : language.copy();
408      }
409
410      @Override
411      public boolean equalsDeep(Base other_) {
412        if (!super.equalsDeep(other_))
413          return false;
414        if (!(other_ instanceof Resource))
415          return false;
416        Resource o = (Resource) other_;
417        return compareDeep(id, o.id, true) && compareDeep(meta, o.meta, true) && compareDeep(implicitRules, o.implicitRules, true)
418           && compareDeep(language, o.language, true);
419      }
420
421      @Override
422      public boolean equalsShallow(Base other_) {
423        if (!super.equalsShallow(other_))
424          return false;
425        if (!(other_ instanceof Resource))
426          return false;
427        Resource o = (Resource) other_;
428        return compareValues(id, o.id, true) && compareValues(implicitRules, o.implicitRules, true) && compareValues(language, o.language, true)
429          ;
430      }
431
432      public boolean isEmpty() {
433        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(id, meta, implicitRules
434          , language);
435      }
436
437// Manual code (from Configuration.txt)t:
438
439 @Override
440  public String getIdBase() {
441    return getId();
442  }
443  
444  @Override
445  public void setIdBase(String value) {
446    setId(value);
447  }
448  public abstract ResourceType getResourceType();
449  
450  public String getLanguage(String defValue) {
451    return hasLanguage() ? getLanguage() : defValue;
452  }
453
454
455// end addition
456
457}
458