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.utilities.Utilities;
038import org.hl7.fhir.r5.openehr.Enumerations.*;
039import org.hl7.fhir.exceptions.FHIRException;
040import org.hl7.fhir.r5.model.*;
041import org.hl7.fhir.instance.model.api.ICompositeType;
042import ca.uhn.fhir.model.api.annotation.Child;
043import ca.uhn.fhir.model.api.annotation.ChildOrder;
044import ca.uhn.fhir.model.api.annotation.DatatypeDef;
045import ca.uhn.fhir.model.api.annotation.Description;
046import ca.uhn.fhir.model.api.annotation.Block;
047
048/**
049 * Encapsulated data expressed as a parsable String. The internal model of the data item is not described in the openEHR model in common with other encapsulated types, but in this case, the form of the data is assumed to be plaintext, rather than compressed or other types of large binary data.
050 */
051@DatatypeDef(name="DV_PARSABLE")
052public class DV_PARSABLE extends DV_ENCAPSULATED implements ICompositeType {
053
054    /**
055     * The string, which may validly be empty in some syntaxes.
056     */
057    @Child(name = "value", type = {StringType.class}, order=0, min=1, max=1, modifier=false, summary=false)
058    @Description(shortDefinition="The string, which may validly be empty in some syntaxes", formalDefinition="The string, which may validly be empty in some syntaxes." )
059    protected StringType value;
060
061    /**
062     * Name of the formalism, e.g. GLIF 1.0 , Proforma etc.
063     */
064    @Child(name = "formalism", type = {StringType.class}, order=1, min=1, max=1, modifier=false, summary=false)
065    @Description(shortDefinition="Name of the formalism, e.g. GLIF 1.0 , Proforma etc", formalDefinition="Name of the formalism, e.g. GLIF 1.0 , Proforma etc." )
066    protected StringType formalism;
067
068    private static final long serialVersionUID = -1693649635L;
069
070  /**
071   * Constructor
072   */
073    public DV_PARSABLE() {
074      super();
075    }
076
077  /**
078   * Constructor
079   */
080    public DV_PARSABLE(String value, String formalism) {
081      super();
082      this.setValue(value);
083      this.setFormalism(formalism);
084    }
085
086    /**
087     * @return {@link #value} (The string, which may validly be empty in some syntaxes.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
088     */
089    public StringType getValueElement() { 
090      if (this.value == null)
091        if (Configuration.errorOnAutoCreate())
092          throw new Error("Attempt to auto-create DV_PARSABLE.value");
093        else if (Configuration.doAutoCreate())
094          this.value = new StringType(); // bb
095      return this.value;
096    }
097
098    public boolean hasValueElement() { 
099      return this.value != null && !this.value.isEmpty();
100    }
101
102    public boolean hasValue() { 
103      return this.value != null && !this.value.isEmpty();
104    }
105
106    /**
107     * @param value {@link #value} (The string, which may validly be empty in some syntaxes.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
108     */
109    public DV_PARSABLE setValueElement(StringType value) { 
110      this.value = value;
111      return this;
112    }
113
114    /**
115     * @return The string, which may validly be empty in some syntaxes.
116     */
117    public String getValue() { 
118      return this.value == null ? null : this.value.getValue();
119    }
120
121    /**
122     * @param value The string, which may validly be empty in some syntaxes.
123     */
124    public DV_PARSABLE setValue(String value) { 
125        if (this.value == null)
126          this.value = new StringType();
127        this.value.setValue(value);
128      return this;
129    }
130
131    /**
132     * @return {@link #formalism} (Name of the formalism, e.g. GLIF 1.0 , Proforma etc.). This is the underlying object with id, value and extensions. The accessor "getFormalism" gives direct access to the value
133     */
134    public StringType getFormalismElement() { 
135      if (this.formalism == null)
136        if (Configuration.errorOnAutoCreate())
137          throw new Error("Attempt to auto-create DV_PARSABLE.formalism");
138        else if (Configuration.doAutoCreate())
139          this.formalism = new StringType(); // bb
140      return this.formalism;
141    }
142
143    public boolean hasFormalismElement() { 
144      return this.formalism != null && !this.formalism.isEmpty();
145    }
146
147    public boolean hasFormalism() { 
148      return this.formalism != null && !this.formalism.isEmpty();
149    }
150
151    /**
152     * @param value {@link #formalism} (Name of the formalism, e.g. GLIF 1.0 , Proforma etc.). This is the underlying object with id, value and extensions. The accessor "getFormalism" gives direct access to the value
153     */
154    public DV_PARSABLE setFormalismElement(StringType value) { 
155      this.formalism = value;
156      return this;
157    }
158
159    /**
160     * @return Name of the formalism, e.g. GLIF 1.0 , Proforma etc.
161     */
162    public String getFormalism() { 
163      return this.formalism == null ? null : this.formalism.getValue();
164    }
165
166    /**
167     * @param value Name of the formalism, e.g. GLIF 1.0 , Proforma etc.
168     */
169    public DV_PARSABLE setFormalism(String value) { 
170        if (this.formalism == null)
171          this.formalism = new StringType();
172        this.formalism.setValue(value);
173      return this;
174    }
175
176      protected void listChildren(List<Property> children) {
177        super.listChildren(children);
178        children.add(new Property("value", "string", "The string, which may validly be empty in some syntaxes.", 0, 1, value));
179        children.add(new Property("formalism", "string", "Name of the formalism, e.g. GLIF 1.0 , Proforma etc.", 0, 1, formalism));
180      }
181
182      @Override
183      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
184        switch (_hash) {
185        case 111972721: /*value*/  return new Property("value", "string", "The string, which may validly be empty in some syntaxes.", 0, 1, value);
186        case 1811342900: /*formalism*/  return new Property("formalism", "string", "Name of the formalism, e.g. GLIF 1.0 , Proforma etc.", 0, 1, formalism);
187        default: return super.getNamedProperty(_hash, _name, _checkValid);
188        }
189
190      }
191
192      @Override
193      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
194        switch (hash) {
195        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // StringType
196        case 1811342900: /*formalism*/ return this.formalism == null ? new Base[0] : new Base[] {this.formalism}; // StringType
197        default: return super.getProperty(hash, name, checkValid);
198        }
199
200      }
201
202      @Override
203      public Base setProperty(int hash, String name, Base value) throws FHIRException {
204        switch (hash) {
205        case 111972721: // value
206          this.value = TypeConvertor.castToString(value); // StringType
207          return value;
208        case 1811342900: // formalism
209          this.formalism = TypeConvertor.castToString(value); // StringType
210          return value;
211        default: return super.setProperty(hash, name, value);
212        }
213
214      }
215
216      @Override
217      public Base setProperty(String name, Base value) throws FHIRException {
218        if (name.equals("value")) {
219          this.value = TypeConvertor.castToString(value); // StringType
220        } else if (name.equals("formalism")) {
221          this.formalism = TypeConvertor.castToString(value); // StringType
222        } else
223          return super.setProperty(name, value);
224        return value;
225      }
226
227      @Override
228      public Base makeProperty(int hash, String name) throws FHIRException {
229        switch (hash) {
230        case 111972721:  return getValueElement();
231        case 1811342900:  return getFormalismElement();
232        default: return super.makeProperty(hash, name);
233        }
234
235      }
236
237      @Override
238      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
239        switch (hash) {
240        case 111972721: /*value*/ return new String[] {"string"};
241        case 1811342900: /*formalism*/ return new String[] {"string"};
242        default: return super.getTypesForProperty(hash, name);
243        }
244
245      }
246
247      @Override
248      public Base addChild(String name) throws FHIRException {
249        if (name.equals("value")) {
250          throw new FHIRException("Cannot call addChild on a singleton property DV_PARSABLE.value");
251        }
252        else if (name.equals("formalism")) {
253          throw new FHIRException("Cannot call addChild on a singleton property DV_PARSABLE.formalism");
254        }
255        else
256          return super.addChild(name);
257      }
258
259  public String fhirType() {
260    return "DV_PARSABLE";
261
262  }
263
264      public DV_PARSABLE copy() {
265        DV_PARSABLE dst = new DV_PARSABLE();
266        copyValues(dst);
267        return dst;
268      }
269
270      public void copyValues(DV_PARSABLE dst) {
271        super.copyValues(dst);
272        dst.value = value == null ? null : value.copy();
273        dst.formalism = formalism == null ? null : formalism.copy();
274      }
275
276      protected DV_PARSABLE typedCopy() {
277        return copy();
278      }
279
280      @Override
281      public boolean equalsDeep(Base other_) {
282        if (!super.equalsDeep(other_))
283          return false;
284        if (!(other_ instanceof DV_PARSABLE))
285          return false;
286        DV_PARSABLE o = (DV_PARSABLE) other_;
287        return compareDeep(value, o.value, true) && compareDeep(formalism, o.formalism, true);
288      }
289
290      @Override
291      public boolean equalsShallow(Base other_) {
292        if (!super.equalsShallow(other_))
293          return false;
294        if (!(other_ instanceof DV_PARSABLE))
295          return false;
296        DV_PARSABLE o = (DV_PARSABLE) other_;
297        return compareValues(value, o.value, true) && compareValues(formalism, o.formalism, true);
298      }
299
300      public boolean isEmpty() {
301        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(value, formalism);
302      }
303
304
305}
306