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 * Archetypes act as the configuration basis for the particular structures of instances defined by the reference model. To enable archetypes to be used to create valid data, key classes in the reference model act as root points for archetyping; accordingly, these classes have the archetype_details attribute set. An instance of the class ARCHETYPED contains the relevant archetype identification information, allowing generating archetypes to be matched up with data instances.
050 */
051@DatatypeDef(name="ARCHETYPED")
052public class ARCHETYPED extends LogicalBase implements ICompositeType {
053
054    /**
055     * Globally unique archetype identifier.
056     */
057    @Child(name = "archetype_id", type = {ARCHETYPE_ID.class}, order=0, min=1, max=1, modifier=false, summary=false)
058    @Description(shortDefinition="Globally unique archetype identifier", formalDefinition="Globally unique archetype identifier." )
059    protected ARCHETYPE_ID archetype_id;
060
061    /**
062     * Globally unique template identifier, if a template was active at this point in the structure. Normally, a template would only be used at the top of a top-level structure, but the possibility exists for templates at lower levels.
063     */
064    @Child(name = "template_id", type = {TEMPLATE_ID.class}, order=1, min=0, max=1, modifier=false, summary=false)
065    @Description(shortDefinition="Globally unique template identifier, if a template was active", formalDefinition="Globally unique template identifier, if a template was active at this point in the structure. Normally, a template would only be used at the top of a top-level structure, but the possibility exists for templates at lower levels." )
066    protected TEMPLATE_ID template_id;
067
068    /**
069     * Version of the openEHR reference model used to create this object. Expressed in terms of the release version string, e.g. 1.0 , 1.2.4 .
070     */
071    @Child(name = "rm_version", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=false)
072    @Description(shortDefinition="Version of the openEHR reference model used to create this object", formalDefinition="Version of the openEHR reference model used to create this object. Expressed in terms of the release version string, e.g. 1.0 , 1.2.4 ." )
073    protected StringType rm_version;
074
075    private static final long serialVersionUID = 155490869L;
076
077  /**
078   * Constructor
079   */
080    public ARCHETYPED() {
081      super();
082    }
083
084  /**
085   * Constructor
086   */
087    public ARCHETYPED(ARCHETYPE_ID archetype_id) {
088      super();
089      this.setArchetype_id(archetype_id);
090    }
091
092    /**
093     * @return {@link #archetype_id} (Globally unique archetype identifier.)
094     */
095    public ARCHETYPE_ID getArchetype_id() { 
096      if (this.archetype_id == null)
097        if (Configuration.errorOnAutoCreate())
098          throw new Error("Attempt to auto-create ARCHETYPED.archetype_id");
099        else if (Configuration.doAutoCreate())
100          this.archetype_id = new ARCHETYPE_ID(); // cc
101      return this.archetype_id;
102    }
103
104    public boolean hasArchetype_id() { 
105      return this.archetype_id != null && !this.archetype_id.isEmpty();
106    }
107
108    /**
109     * @param value {@link #archetype_id} (Globally unique archetype identifier.)
110     */
111    public ARCHETYPED setArchetype_id(ARCHETYPE_ID value) { 
112      this.archetype_id = value;
113      return this;
114    }
115
116    /**
117     * @return {@link #template_id} (Globally unique template identifier, if a template was active at this point in the structure. Normally, a template would only be used at the top of a top-level structure, but the possibility exists for templates at lower levels.)
118     */
119    public TEMPLATE_ID getTemplate_id() { 
120      if (this.template_id == null)
121        if (Configuration.errorOnAutoCreate())
122          throw new Error("Attempt to auto-create ARCHETYPED.template_id");
123        else if (Configuration.doAutoCreate())
124          this.template_id = new TEMPLATE_ID(); // cc
125      return this.template_id;
126    }
127
128    public boolean hasTemplate_id() { 
129      return this.template_id != null && !this.template_id.isEmpty();
130    }
131
132    /**
133     * @param value {@link #template_id} (Globally unique template identifier, if a template was active at this point in the structure. Normally, a template would only be used at the top of a top-level structure, but the possibility exists for templates at lower levels.)
134     */
135    public ARCHETYPED setTemplate_id(TEMPLATE_ID value) { 
136      this.template_id = value;
137      return this;
138    }
139
140    /**
141     * @return {@link #rm_version} (Version of the openEHR reference model used to create this object. Expressed in terms of the release version string, e.g. 1.0 , 1.2.4 .). This is the underlying object with id, value and extensions. The accessor "getRm_version" gives direct access to the value
142     */
143    public StringType getRm_versionElement() { 
144      if (this.rm_version == null)
145        if (Configuration.errorOnAutoCreate())
146          throw new Error("Attempt to auto-create ARCHETYPED.rm_version");
147        else if (Configuration.doAutoCreate())
148          this.rm_version = new StringType(); // bb
149      return this.rm_version;
150    }
151
152    public boolean hasRm_versionElement() { 
153      return this.rm_version != null && !this.rm_version.isEmpty();
154    }
155
156    public boolean hasRm_version() { 
157      return this.rm_version != null && !this.rm_version.isEmpty();
158    }
159
160    /**
161     * @param value {@link #rm_version} (Version of the openEHR reference model used to create this object. Expressed in terms of the release version string, e.g. 1.0 , 1.2.4 .). This is the underlying object with id, value and extensions. The accessor "getRm_version" gives direct access to the value
162     */
163    public ARCHETYPED setRm_versionElement(StringType value) { 
164      this.rm_version = value;
165      return this;
166    }
167
168    /**
169     * @return Version of the openEHR reference model used to create this object. Expressed in terms of the release version string, e.g. 1.0 , 1.2.4 .
170     */
171    public String getRm_version() { 
172      return this.rm_version == null ? null : this.rm_version.getValue();
173    }
174
175    /**
176     * @param value Version of the openEHR reference model used to create this object. Expressed in terms of the release version string, e.g. 1.0 , 1.2.4 .
177     */
178    public ARCHETYPED setRm_version(String value) { 
179      if (Utilities.noString(value))
180        this.rm_version = null;
181      else {
182        if (this.rm_version == null)
183          this.rm_version = new StringType();
184        this.rm_version.setValue(value);
185      }
186      return this;
187    }
188
189      protected void listChildren(List<Property> children) {
190        super.listChildren(children);
191        children.add(new Property("archetype_id", "http://openehr.org/fhir/StructureDefinition/ARCHETYPE-ID", "Globally unique archetype identifier.", 0, 1, archetype_id));
192        children.add(new Property("template_id", "http://openehr.org/fhir/StructureDefinition/TEMPLATE-ID", "Globally unique template identifier, if a template was active at this point in the structure. Normally, a template would only be used at the top of a top-level structure, but the possibility exists for templates at lower levels.", 0, 1, template_id));
193        children.add(new Property("rm_version", "string", "Version of the openEHR reference model used to create this object. Expressed in terms of the release version string, e.g. 1.0 , 1.2.4 .", 0, 1, rm_version));
194      }
195
196      @Override
197      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
198        switch (_hash) {
199        case -1252479343: /*archetype_id*/  return new Property("archetype_id", "http://openehr.org/fhir/StructureDefinition/ARCHETYPE-ID", "Globally unique archetype identifier.", 0, 1, archetype_id);
200        case 1769642752: /*template_id*/  return new Property("template_id", "http://openehr.org/fhir/StructureDefinition/TEMPLATE-ID", "Globally unique template identifier, if a template was active at this point in the structure. Normally, a template would only be used at the top of a top-level structure, but the possibility exists for templates at lower levels.", 0, 1, template_id);
201        case -1956878636: /*rm_version*/  return new Property("rm_version", "string", "Version of the openEHR reference model used to create this object. Expressed in terms of the release version string, e.g. 1.0 , 1.2.4 .", 0, 1, rm_version);
202        default: return super.getNamedProperty(_hash, _name, _checkValid);
203        }
204
205      }
206
207      @Override
208      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
209        switch (hash) {
210        case -1252479343: /*archetype_id*/ return this.archetype_id == null ? new Base[0] : new Base[] {this.archetype_id}; // ARCHETYPE_ID
211        case 1769642752: /*template_id*/ return this.template_id == null ? new Base[0] : new Base[] {this.template_id}; // TEMPLATE_ID
212        case -1956878636: /*rm_version*/ return this.rm_version == null ? new Base[0] : new Base[] {this.rm_version}; // StringType
213        default: return super.getProperty(hash, name, checkValid);
214        }
215
216      }
217
218      @Override
219      public Base setProperty(int hash, String name, Base value) throws FHIRException {
220        switch (hash) {
221        case -1252479343: // archetype_id
222          this.archetype_id = (ARCHETYPE_ID) value; // ARCHETYPE_ID
223          return value;
224        case 1769642752: // template_id
225          this.template_id = (TEMPLATE_ID) value; // TEMPLATE_ID
226          return value;
227        case -1956878636: // rm_version
228          this.rm_version = TypeConvertor.castToString(value); // StringType
229          return value;
230        default: return super.setProperty(hash, name, value);
231        }
232
233      }
234
235      @Override
236      public Base setProperty(String name, Base value) throws FHIRException {
237        if (name.equals("archetype_id")) {
238          this.archetype_id = (ARCHETYPE_ID) value; // ARCHETYPE_ID
239        } else if (name.equals("template_id")) {
240          this.template_id = (TEMPLATE_ID) value; // TEMPLATE_ID
241        } else if (name.equals("rm_version")) {
242          this.rm_version = TypeConvertor.castToString(value); // StringType
243        } else
244          return super.setProperty(name, value);
245        return value;
246      }
247
248      @Override
249      public Base makeProperty(int hash, String name) throws FHIRException {
250        switch (hash) {
251        case -1252479343:  return getArchetype_id();
252        case 1769642752:  return getTemplate_id();
253        case -1956878636:  return getRm_versionElement();
254        default: return super.makeProperty(hash, name);
255        }
256
257      }
258
259      @Override
260      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
261        switch (hash) {
262        case -1252479343: /*archetype_id*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/ARCHETYPE-ID"};
263        case 1769642752: /*template_id*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/TEMPLATE-ID"};
264        case -1956878636: /*rm_version*/ return new String[] {"string"};
265        default: return super.getTypesForProperty(hash, name);
266        }
267
268      }
269
270      @Override
271      public Base addChild(String name) throws FHIRException {
272        if (name.equals("archetype_id")) {
273          this.archetype_id = new ARCHETYPE_ID();
274          return this.archetype_id;
275        }
276        else if (name.equals("template_id")) {
277          this.template_id = new TEMPLATE_ID();
278          return this.template_id;
279        }
280        else if (name.equals("rm_version")) {
281          throw new FHIRException("Cannot call addChild on a singleton property ARCHETYPED.rm_version");
282        }
283        else
284          return super.addChild(name);
285      }
286
287  public String fhirType() {
288    return "ARCHETYPED";
289
290  }
291
292      public ARCHETYPED copy() {
293        ARCHETYPED dst = new ARCHETYPED();
294        copyValues(dst);
295        return dst;
296      }
297
298      public void copyValues(ARCHETYPED dst) {
299        super.copyValues(dst);
300        dst.archetype_id = archetype_id == null ? null : archetype_id.copy();
301        dst.template_id = template_id == null ? null : template_id.copy();
302        dst.rm_version = rm_version == null ? null : rm_version.copy();
303      }
304
305      protected ARCHETYPED typedCopy() {
306        return copy();
307      }
308
309      @Override
310      public boolean equalsDeep(Base other_) {
311        if (!super.equalsDeep(other_))
312          return false;
313        if (!(other_ instanceof ARCHETYPED))
314          return false;
315        ARCHETYPED o = (ARCHETYPED) other_;
316        return compareDeep(archetype_id, o.archetype_id, true) && compareDeep(template_id, o.template_id, true)
317           && compareDeep(rm_version, o.rm_version, true);
318      }
319
320      @Override
321      public boolean equalsShallow(Base other_) {
322        if (!super.equalsShallow(other_))
323          return false;
324        if (!(other_ instanceof ARCHETYPED))
325          return false;
326        ARCHETYPED o = (ARCHETYPED) other_;
327        return compareValues(rm_version, o.rm_version, true);
328      }
329
330      public boolean isEmpty() {
331        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(archetype_id, template_id
332          , rm_version);
333      }
334
335
336}
337