001package org.hl7.fhir.r5.openehr;
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.Date;
036import java.util.List;
037import org.hl7.fhir.r5.openehr.Enumerations.*;
038import org.hl7.fhir.exceptions.FHIRException;
039import org.hl7.fhir.r5.model.*;
040import org.hl7.fhir.instance.model.api.ICompositeType;
041import ca.uhn.fhir.model.api.annotation.Child;
042import ca.uhn.fhir.model.api.annotation.ChildOrder;
043import ca.uhn.fhir.model.api.annotation.DatatypeDef;
044import ca.uhn.fhir.model.api.annotation.Description;
045import ca.uhn.fhir.model.api.annotation.Block;
046
047/**
048 * Abstract class defining the common meta-data of all types of encapsulated data.
049 */
050@DatatypeDef(name="DV_ENCAPSULATED")
051public abstract class DV_ENCAPSULATED extends DV_AMOUNT implements ICompositeType {
052
053    /**
054     * Name of character encoding scheme in which this value is encoded. Coded from openEHR Code Set character sets . Unicode is the default assumption in openEHR, with UTF-8 being the assumed encoding. This attribute allows for variations from these assumptions.
055     */
056    @Child(name = "charset", type = {CODE_PHRASE.class}, order=0, min=0, max=1, modifier=false, summary=false)
057    @Description(shortDefinition="Name of character encoding scheme in which this value is encoded. Coded from openEHR Code Set character sets", formalDefinition="Name of character encoding scheme in which this value is encoded. Coded from openEHR Code Set character sets . Unicode is the default assumption in openEHR, with UTF-8 being the assumed encoding. This attribute allows for variations from these assumptions." )
058    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="https://specifications.openehr.org/fhir/valueset-character_sets")
059    protected CODE_PHRASE charset;
060
061    /**
062     * Optional indicator of the localised language in which the data is written, if relevant. Coded from openEHR Code Set languages.
063     */
064    @Child(name = "language", type = {CODE_PHRASE.class}, order=1, min=0, max=1, modifier=false, summary=false)
065    @Description(shortDefinition="Optional indicator of the localised language in which the data is written, if relevant", formalDefinition="Optional indicator of the localised language in which the data is written, if relevant. Coded from openEHR Code Set languages." )
066    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/all-languages")
067    protected CODE_PHRASE language;
068
069    private static final long serialVersionUID = 379442662L;
070
071  /**
072   * Constructor
073   */
074    public DV_ENCAPSULATED() {
075      super();
076    }
077
078    /**
079     * @return {@link #charset} (Name of character encoding scheme in which this value is encoded. Coded from openEHR Code Set character sets . Unicode is the default assumption in openEHR, with UTF-8 being the assumed encoding. This attribute allows for variations from these assumptions.)
080     */
081    public CODE_PHRASE getCharset() { 
082      if (this.charset == null)
083        if (Configuration.errorOnAutoCreate())
084          throw new Error("Attempt to auto-create DV_ENCAPSULATED.charset");
085        else if (Configuration.doAutoCreate())
086          this.charset = new CODE_PHRASE(); // cc
087      return this.charset;
088    }
089
090    public boolean hasCharset() { 
091      return this.charset != null && !this.charset.isEmpty();
092    }
093
094    /**
095     * @param value {@link #charset} (Name of character encoding scheme in which this value is encoded. Coded from openEHR Code Set character sets . Unicode is the default assumption in openEHR, with UTF-8 being the assumed encoding. This attribute allows for variations from these assumptions.)
096     */
097    public DV_ENCAPSULATED setCharset(CODE_PHRASE value) { 
098      this.charset = value;
099      return this;
100    }
101
102    /**
103     * @return {@link #language} (Optional indicator of the localised language in which the data is written, if relevant. Coded from openEHR Code Set languages.)
104     */
105    public CODE_PHRASE getLanguage() { 
106      if (this.language == null)
107        if (Configuration.errorOnAutoCreate())
108          throw new Error("Attempt to auto-create DV_ENCAPSULATED.language");
109        else if (Configuration.doAutoCreate())
110          this.language = new CODE_PHRASE(); // cc
111      return this.language;
112    }
113
114    public boolean hasLanguage() { 
115      return this.language != null && !this.language.isEmpty();
116    }
117
118    /**
119     * @param value {@link #language} (Optional indicator of the localised language in which the data is written, if relevant. Coded from openEHR Code Set languages.)
120     */
121    public DV_ENCAPSULATED setLanguage(CODE_PHRASE value) { 
122      this.language = value;
123      return this;
124    }
125
126      protected void listChildren(List<Property> children) {
127        super.listChildren(children);
128        children.add(new Property("charset", "http://openehr.org/fhir/StructureDefinition/CODE-PHRASE", "Name of character encoding scheme in which this value is encoded. Coded from openEHR Code Set character sets . Unicode is the default assumption in openEHR, with UTF-8 being the assumed encoding. This attribute allows for variations from these assumptions.", 0, 1, charset));
129        children.add(new Property("language", "http://openehr.org/fhir/StructureDefinition/CODE-PHRASE", "Optional indicator of the localised language in which the data is written, if relevant. Coded from openEHR Code Set languages.", 0, 1, language));
130      }
131
132      @Override
133      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
134        switch (_hash) {
135        case 739074380: /*charset*/  return new Property("charset", "http://openehr.org/fhir/StructureDefinition/CODE-PHRASE", "Name of character encoding scheme in which this value is encoded. Coded from openEHR Code Set character sets . Unicode is the default assumption in openEHR, with UTF-8 being the assumed encoding. This attribute allows for variations from these assumptions.", 0, 1, charset);
136        case -1613589672: /*language*/  return new Property("language", "http://openehr.org/fhir/StructureDefinition/CODE-PHRASE", "Optional indicator of the localised language in which the data is written, if relevant. Coded from openEHR Code Set languages.", 0, 1, language);
137        default: return super.getNamedProperty(_hash, _name, _checkValid);
138        }
139
140      }
141
142      @Override
143      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
144        switch (hash) {
145        case 739074380: /*charset*/ return this.charset == null ? new Base[0] : new Base[] {this.charset}; // CODE_PHRASE
146        case -1613589672: /*language*/ return this.language == null ? new Base[0] : new Base[] {this.language}; // CODE_PHRASE
147        default: return super.getProperty(hash, name, checkValid);
148        }
149
150      }
151
152      @Override
153      public Base setProperty(int hash, String name, Base value) throws FHIRException {
154        switch (hash) {
155        case 739074380: // charset
156          this.charset = (CODE_PHRASE) value; // CODE_PHRASE
157          return value;
158        case -1613589672: // language
159          this.language = (CODE_PHRASE) value; // CODE_PHRASE
160          return value;
161        default: return super.setProperty(hash, name, value);
162        }
163
164      }
165
166      @Override
167      public Base setProperty(String name, Base value) throws FHIRException {
168        if (name.equals("charset")) {
169          this.charset = (CODE_PHRASE) value; // CODE_PHRASE
170        } else if (name.equals("language")) {
171          this.language = (CODE_PHRASE) value; // CODE_PHRASE
172        } else
173          return super.setProperty(name, value);
174        return value;
175      }
176
177      @Override
178      public Base makeProperty(int hash, String name) throws FHIRException {
179        switch (hash) {
180        case 739074380:  return getCharset();
181        case -1613589672:  return getLanguage();
182        default: return super.makeProperty(hash, name);
183        }
184
185      }
186
187      @Override
188      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
189        switch (hash) {
190        case 739074380: /*charset*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/CODE-PHRASE"};
191        case -1613589672: /*language*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/CODE-PHRASE"};
192        default: return super.getTypesForProperty(hash, name);
193        }
194
195      }
196
197      @Override
198      public Base addChild(String name) throws FHIRException {
199        if (name.equals("charset")) {
200          this.charset = new CODE_PHRASE();
201          return this.charset;
202        }
203        else if (name.equals("language")) {
204          this.language = new CODE_PHRASE();
205          return this.language;
206        }
207        else
208          return super.addChild(name);
209      }
210
211  public String fhirType() {
212    return "DV_ENCAPSULATED";
213
214  }
215
216      public abstract DV_ENCAPSULATED copy();
217
218      public void copyValues(DV_ENCAPSULATED dst) {
219        super.copyValues(dst);
220        dst.charset = charset == null ? null : charset.copy();
221        dst.language = language == null ? null : language.copy();
222      }
223
224      @Override
225      public boolean equalsDeep(Base other_) {
226        if (!super.equalsDeep(other_))
227          return false;
228        if (!(other_ instanceof DV_ENCAPSULATED))
229          return false;
230        DV_ENCAPSULATED o = (DV_ENCAPSULATED) other_;
231        return compareDeep(charset, o.charset, true) && compareDeep(language, o.language, true);
232      }
233
234      @Override
235      public boolean equalsShallow(Base other_) {
236        if (!super.equalsShallow(other_))
237          return false;
238        if (!(other_ instanceof DV_ENCAPSULATED))
239          return false;
240        DV_ENCAPSULATED o = (DV_ENCAPSULATED) other_;
241        return true;
242      }
243
244      public boolean isEmpty() {
245        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(charset, language);
246      }
247
248
249}
250