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 * The PATHABLE class defines the pathing capabilities used by nearly all classes in the openEHR reference model, mostly via inheritance of PATHABLE. The defining characteristics of PATHABLE objects are that they can locate child objects using paths, and they know their parent object in a compositional hierarchy. The parent feature is defined as abstract in the model, and may be implemented in any way convenient.
050 */
051@DatatypeDef(name="PATHABLE")
052public abstract class PATHABLE extends Any implements ICompositeType {
053
054    /**
055     * This is the term provided via a clinical application or batch process to name this EHR construct: its retention in the EHR faithfully preserves the original label by which this entry was known to end users.
056     */
057    @Child(name = "name", type = {DV_TEXT.class}, order=0, min=1, max=1, modifier=false, summary=false)
058    @Description(shortDefinition="Runtime name of this fragment, used to build runtime paths", formalDefinition="This is the term provided via a clinical application or batch process to name this EHR construct: its retention in the EHR faithfully preserves the original label by which this entry was known to end users." )
059    protected DV_TEXT name;
060
061    /**
062     * Design-time archetype identifier of this node taken from its generating archetype; used to build archetype paths. Always in the form of an at-code, e.g. at0005. This value enables a 'standardised' name for this node to be generated, by referring to the generating archetype local terminology.
063     */
064    @Child(name = "archetype_node_id", type = {StringType.class}, order=1, min=1, max=1, modifier=false, summary=false)
065    @Description(shortDefinition="Design-time archetype identifier of this node taken from its generating archetype", formalDefinition="Design-time archetype identifier of this node taken from its generating archetype; used to build archetype paths. Always in the form of an at-code, e.g. at0005. This value enables a 'standardised' name for this node to be generated, by referring to the generating archetype local terminology." )
066    protected StringType archetype_node_id;
067
068    /**
069     * Optional globally unique object identifier for root points of archetyped structures.
070     */
071    @Child(name = "uid", type = {UID_BASED_ID.class}, order=2, min=0, max=1, modifier=false, summary=false)
072    @Description(shortDefinition="Optional globally unique object identifier for root points of archetyped structures", formalDefinition="Optional globally unique object identifier for root points of archetyped structures." )
073    protected UID_BASED_ID uid;
074
075    /**
076     * Links to other archetyped structures (data whose root object inherits from ARCHETYPED, such as ENTRY, SECTION and so on). Links may be to structures in other compositions.
077     */
078    @Child(name = "links", type = {LINK.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
079    @Description(shortDefinition="Links to other archetyped structures", formalDefinition="Links to other archetyped structures (data whose root object inherits from ARCHETYPED, such as ENTRY, SECTION and so on). Links may be to structures in other compositions." )
080    protected List<LINK> linksList;
081
082    /**
083     * Details of archetyping used on this node.
084     */
085    @Child(name = "archetype_details", type = {ARCHETYPED.class}, order=4, min=0, max=1, modifier=false, summary=false)
086    @Description(shortDefinition="Details of archetyping used on this node", formalDefinition="Details of archetyping used on this node." )
087    protected ARCHETYPED archetype_details;
088
089    /**
090     * Audit trail from non-openEHR system of original commit of information forming the content of this node, or from a conversion gateway which has synthesised this node.
091     */
092    @Child(name = "feeder_audit", type = {FEEDER_AUDIT.class}, order=5, min=0, max=1, modifier=false, summary=false)
093    @Description(shortDefinition="Audit trail from non-openEHR system of original commit of information forming the content of this node", formalDefinition="Audit trail from non-openEHR system of original commit of information forming the content of this node, or from a conversion gateway which has synthesised this node." )
094    protected FEEDER_AUDIT feeder_audit;
095
096    private static final long serialVersionUID = 802051356L;
097
098  /**
099   * Constructor
100   */
101    public PATHABLE() {
102      super();
103    }
104
105  /**
106   * Constructor
107   */
108    public PATHABLE(DV_TEXT name, String archetype_node_id) {
109      super();
110      this.setName(name);
111      this.setArchetype_node_id(archetype_node_id);
112    }
113
114    /**
115     * @return {@link #name} (This is the term provided via a clinical application or batch process to name this EHR construct: its retention in the EHR faithfully preserves the original label by which this entry was known to end users.)
116     */
117    public DV_TEXT getName() { 
118      if (this.name == null)
119        if (Configuration.errorOnAutoCreate())
120          throw new Error("Attempt to auto-create PATHABLE.name");
121        else if (Configuration.doAutoCreate())
122          this.name = new DV_TEXT(); // cc
123      return this.name;
124    }
125
126    public boolean hasName() { 
127      return this.name != null && !this.name.isEmpty();
128    }
129
130    /**
131     * @param value {@link #name} (This is the term provided via a clinical application or batch process to name this EHR construct: its retention in the EHR faithfully preserves the original label by which this entry was known to end users.)
132     */
133    public PATHABLE setName(DV_TEXT value) { 
134      this.name = value;
135      return this;
136    }
137
138    /**
139     * @return {@link #archetype_node_id} (Design-time archetype identifier of this node taken from its generating archetype; used to build archetype paths. Always in the form of an at-code, e.g. at0005. This value enables a 'standardised' name for this node to be generated, by referring to the generating archetype local terminology.). This is the underlying object with id, value and extensions. The accessor "getArchetype_node_id" gives direct access to the value
140     */
141    public StringType getArchetype_node_idElement() { 
142      if (this.archetype_node_id == null)
143        if (Configuration.errorOnAutoCreate())
144          throw new Error("Attempt to auto-create PATHABLE.archetype_node_id");
145        else if (Configuration.doAutoCreate())
146          this.archetype_node_id = new StringType(); // bb
147      return this.archetype_node_id;
148    }
149
150    public boolean hasArchetype_node_idElement() { 
151      return this.archetype_node_id != null && !this.archetype_node_id.isEmpty();
152    }
153
154    public boolean hasArchetype_node_id() { 
155      return this.archetype_node_id != null && !this.archetype_node_id.isEmpty();
156    }
157
158    /**
159     * @param value {@link #archetype_node_id} (Design-time archetype identifier of this node taken from its generating archetype; used to build archetype paths. Always in the form of an at-code, e.g. at0005. This value enables a 'standardised' name for this node to be generated, by referring to the generating archetype local terminology.). This is the underlying object with id, value and extensions. The accessor "getArchetype_node_id" gives direct access to the value
160     */
161    public PATHABLE setArchetype_node_idElement(StringType value) { 
162      this.archetype_node_id = value;
163      return this;
164    }
165
166    /**
167     * @return Design-time archetype identifier of this node taken from its generating archetype; used to build archetype paths. Always in the form of an at-code, e.g. at0005. This value enables a 'standardised' name for this node to be generated, by referring to the generating archetype local terminology.
168     */
169    public String getArchetype_node_id() { 
170      return this.archetype_node_id == null ? null : this.archetype_node_id.getValue();
171    }
172
173    /**
174     * @param value Design-time archetype identifier of this node taken from its generating archetype; used to build archetype paths. Always in the form of an at-code, e.g. at0005. This value enables a 'standardised' name for this node to be generated, by referring to the generating archetype local terminology.
175     */
176    public PATHABLE setArchetype_node_id(String value) { 
177        if (this.archetype_node_id == null)
178          this.archetype_node_id = new StringType();
179        this.archetype_node_id.setValue(value);
180      return this;
181    }
182
183    /**
184     * @return {@link #uid} (Optional globally unique object identifier for root points of archetyped structures.)
185     */
186    public UID_BASED_ID getUid() { 
187      return this.uid;
188    }
189
190    public boolean hasUid() { 
191      return this.uid != null && !this.uid.isEmpty();
192    }
193
194    /**
195     * @param value {@link #uid} (Optional globally unique object identifier for root points of archetyped structures.)
196     */
197    public PATHABLE setUid(UID_BASED_ID value) { 
198      this.uid = value;
199      return this;
200    }
201
202    /**
203     * @return {@link #links} (Links to other archetyped structures (data whose root object inherits from ARCHETYPED, such as ENTRY, SECTION and so on). Links may be to structures in other compositions.)
204     */
205    public List<LINK> getLinksList() { 
206      if (this.linksList == null)
207        this.linksList = new ArrayList<LINK>();
208      return this.linksList;
209    }
210
211    /**
212     * @return Returns a reference to <code>this</code> for easy method chaining
213     */
214    public PATHABLE setLinksList(List<LINK> theLinks) { 
215      this.linksList = theLinks;
216      return this;
217    }
218
219    public boolean hasLinks() { 
220      if (this.linksList == null)
221        return false;
222      for (LINK item : this.linksList)
223        if (!item.isEmpty())
224          return true;
225      return false;
226    }
227
228    public LINK addLinks() { //3a
229      LINK t = new LINK();
230      if (this.linksList == null)
231        this.linksList = new ArrayList<LINK>();
232      this.linksList.add(t);
233      return t;
234    }
235
236    public PATHABLE addLinks(LINK t) { //3b
237      if (t == null)
238        return this;
239      if (this.linksList == null)
240        this.linksList = new ArrayList<LINK>();
241      this.linksList.add(t);
242      return this;
243    }
244
245    /**
246     * @return The first repetition of repeating field {@link #links}, creating it if it does not already exist {3}
247     */
248    public LINK getLinksFirstRep() { 
249      if (getLinksList().isEmpty()) {
250        addLinks();
251      }
252      return getLinksList().get(0);
253    }
254
255    /**
256     * @return {@link #archetype_details} (Details of archetyping used on this node.)
257     */
258    public ARCHETYPED getArchetype_details() { 
259      if (this.archetype_details == null)
260        if (Configuration.errorOnAutoCreate())
261          throw new Error("Attempt to auto-create PATHABLE.archetype_details");
262        else if (Configuration.doAutoCreate())
263          this.archetype_details = new ARCHETYPED(); // cc
264      return this.archetype_details;
265    }
266
267    public boolean hasArchetype_details() { 
268      return this.archetype_details != null && !this.archetype_details.isEmpty();
269    }
270
271    /**
272     * @param value {@link #archetype_details} (Details of archetyping used on this node.)
273     */
274    public PATHABLE setArchetype_details(ARCHETYPED value) { 
275      this.archetype_details = value;
276      return this;
277    }
278
279    /**
280     * @return {@link #feeder_audit} (Audit trail from non-openEHR system of original commit of information forming the content of this node, or from a conversion gateway which has synthesised this node.)
281     */
282    public FEEDER_AUDIT getFeeder_audit() { 
283      if (this.feeder_audit == null)
284        if (Configuration.errorOnAutoCreate())
285          throw new Error("Attempt to auto-create PATHABLE.feeder_audit");
286        else if (Configuration.doAutoCreate())
287          this.feeder_audit = new FEEDER_AUDIT(); // cc
288      return this.feeder_audit;
289    }
290
291    public boolean hasFeeder_audit() { 
292      return this.feeder_audit != null && !this.feeder_audit.isEmpty();
293    }
294
295    /**
296     * @param value {@link #feeder_audit} (Audit trail from non-openEHR system of original commit of information forming the content of this node, or from a conversion gateway which has synthesised this node.)
297     */
298    public PATHABLE setFeeder_audit(FEEDER_AUDIT value) { 
299      this.feeder_audit = value;
300      return this;
301    }
302
303      protected void listChildren(List<Property> children) {
304        super.listChildren(children);
305        children.add(new Property("name", "http://openehr.org/fhir/StructureDefinition/DV-TEXT", "This is the term provided via a clinical application or batch process to name this EHR construct: its retention in the EHR faithfully preserves the original label by which this entry was known to end users.", 0, 1, name));
306        children.add(new Property("archetype_node_id", "string", "Design-time archetype identifier of this node taken from its generating archetype; used to build archetype paths. Always in the form of an at-code, e.g. at0005. This value enables a 'standardised' name for this node to be generated, by referring to the generating archetype local terminology.", 0, 1, archetype_node_id));
307        children.add(new Property("uid", "http://openehr.org/fhir/StructureDefinition/UID-BASED-ID", "Optional globally unique object identifier for root points of archetyped structures.", 0, 1, uid));
308        children.add(new Property("links", "http://openehr.org/fhir/StructureDefinition/LINK", "Links to other archetyped structures (data whose root object inherits from ARCHETYPED, such as ENTRY, SECTION and so on). Links may be to structures in other compositions.", 0, java.lang.Integer.MAX_VALUE, linksList));
309        children.add(new Property("archetype_details", "http://openehr.org/fhir/StructureDefinition/ARCHETYPED", "Details of archetyping used on this node.", 0, 1, archetype_details));
310        children.add(new Property("feeder_audit", "http://openehr.org/fhir/StructureDefinition/FEEDER-AUDIT", "Audit trail from non-openEHR system of original commit of information forming the content of this node, or from a conversion gateway which has synthesised this node.", 0, 1, feeder_audit));
311      }
312
313      @Override
314      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
315        switch (_hash) {
316        case 3373707: /*name*/  return new Property("name", "http://openehr.org/fhir/StructureDefinition/DV-TEXT", "This is the term provided via a clinical application or batch process to name this EHR construct: its retention in the EHR faithfully preserves the original label by which this entry was known to end users.", 0, 1, name);
317        case -448281406: /*archetype_node_id*/  return new Property("archetype_node_id", "string", "Design-time archetype identifier of this node taken from its generating archetype; used to build archetype paths. Always in the form of an at-code, e.g. at0005. This value enables a 'standardised' name for this node to be generated, by referring to the generating archetype local terminology.", 0, 1, archetype_node_id);
318        case 115792: /*uid*/  return new Property("uid", "http://openehr.org/fhir/StructureDefinition/UID-BASED-ID", "Optional globally unique object identifier for root points of archetyped structures.", 0, 1, uid);
319        case 102977465: /*links*/  return new Property("links", "http://openehr.org/fhir/StructureDefinition/LINK", "Links to other archetyped structures (data whose root object inherits from ARCHETYPED, such as ENTRY, SECTION and so on). Links may be to structures in other compositions.", 0, java.lang.Integer.MAX_VALUE, linksList);
320        case -1005008244: /*archetype_details*/  return new Property("archetype_details", "http://openehr.org/fhir/StructureDefinition/ARCHETYPED", "Details of archetyping used on this node.", 0, 1, archetype_details);
321        case 1287552359: /*feeder_audit*/  return new Property("feeder_audit", "http://openehr.org/fhir/StructureDefinition/FEEDER-AUDIT", "Audit trail from non-openEHR system of original commit of information forming the content of this node, or from a conversion gateway which has synthesised this node.", 0, 1, feeder_audit);
322        default: return super.getNamedProperty(_hash, _name, _checkValid);
323        }
324
325      }
326
327      @Override
328      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
329        switch (hash) {
330        case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // DV_TEXT
331        case -448281406: /*archetype_node_id*/ return this.archetype_node_id == null ? new Base[0] : new Base[] {this.archetype_node_id}; // StringType
332        case 115792: /*uid*/ return this.uid == null ? new Base[0] : new Base[] {this.uid}; // UID_BASED_ID
333        case 102977465: /*links*/ return this.linksList == null ? new Base[0] : this.linksList.toArray(new Base[this.linksList.size()]); // LINK
334        case -1005008244: /*archetype_details*/ return this.archetype_details == null ? new Base[0] : new Base[] {this.archetype_details}; // ARCHETYPED
335        case 1287552359: /*feeder_audit*/ return this.feeder_audit == null ? new Base[0] : new Base[] {this.feeder_audit}; // FEEDER_AUDIT
336        default: return super.getProperty(hash, name, checkValid);
337        }
338
339      }
340
341      @Override
342      public Base setProperty(int hash, String name, Base value) throws FHIRException {
343        switch (hash) {
344        case 3373707: // name
345          this.name = (DV_TEXT) value; // DV_TEXT
346          return value;
347        case -448281406: // archetype_node_id
348          this.archetype_node_id = TypeConvertor.castToString(value); // StringType
349          return value;
350        case 115792: // uid
351          this.uid = (UID_BASED_ID) value; // UID_BASED_ID
352          return value;
353        case 102977465: // links
354          this.getLinksList().add((LINK) value); // LINK
355          return value;
356        case -1005008244: // archetype_details
357          this.archetype_details = (ARCHETYPED) value; // ARCHETYPED
358          return value;
359        case 1287552359: // feeder_audit
360          this.feeder_audit = (FEEDER_AUDIT) value; // FEEDER_AUDIT
361          return value;
362        default: return super.setProperty(hash, name, value);
363        }
364
365      }
366
367      @Override
368      public Base setProperty(String name, Base value) throws FHIRException {
369        if (name.equals("name")) {
370          this.name = (DV_TEXT) value; // DV_TEXT
371        } else if (name.equals("archetype_node_id")) {
372          this.archetype_node_id = TypeConvertor.castToString(value); // StringType
373        } else if (name.equals("uid")) {
374          this.uid = (UID_BASED_ID) value; // UID_BASED_ID
375        } else if (name.equals("links")) {
376          this.getLinksList().add((LINK) value); // LINK
377        } else if (name.equals("archetype_details")) {
378          this.archetype_details = (ARCHETYPED) value; // ARCHETYPED
379        } else if (name.equals("feeder_audit")) {
380          this.feeder_audit = (FEEDER_AUDIT) value; // FEEDER_AUDIT
381        } else
382          return super.setProperty(name, value);
383        return value;
384      }
385
386      @Override
387      public Base makeProperty(int hash, String name) throws FHIRException {
388        switch (hash) {
389        case 3373707:  return getName();
390        case -448281406:  return getArchetype_node_idElement();
391        case 115792: /*div*/
392          throw new Error("Unable to make an instance of the abstract property 'uid'");
393        case 102977465:  return addLinks(); 
394        case -1005008244:  return getArchetype_details();
395        case 1287552359:  return getFeeder_audit();
396        default: return super.makeProperty(hash, name);
397        }
398
399      }
400
401      @Override
402      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
403        switch (hash) {
404        case 3373707: /*name*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-TEXT"};
405        case -448281406: /*archetype_node_id*/ return new String[] {"string"};
406        case 115792: /*uid*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/UID-BASED-ID"};
407        case 102977465: /*links*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/LINK"};
408        case -1005008244: /*archetype_details*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/ARCHETYPED"};
409        case 1287552359: /*feeder_audit*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/FEEDER-AUDIT"};
410        default: return super.getTypesForProperty(hash, name);
411        }
412
413      }
414
415      @Override
416      public Base addChild(String name) throws FHIRException {
417        if (name.equals("name")) {
418          this.name = new DV_TEXT();
419          return this.name;
420        }
421        else if (name.equals("archetype_node_id")) {
422          throw new FHIRException("Cannot call addChild on a singleton property PATHABLE.archetype_node_id");
423        }
424        else if (name.equals("uid")) {
425          throw new FHIRException("Cannot call addChild on an abstract type PATHABLE.uid");
426        }
427        else if (name.equals("links")) {
428          return addLinks();
429        }
430        else if (name.equals("archetype_details")) {
431          this.archetype_details = new ARCHETYPED();
432          return this.archetype_details;
433        }
434        else if (name.equals("feeder_audit")) {
435          this.feeder_audit = new FEEDER_AUDIT();
436          return this.feeder_audit;
437        }
438        else
439          return super.addChild(name);
440      }
441
442  public String fhirType() {
443    return "PATHABLE";
444
445  }
446
447      public abstract PATHABLE copy();
448
449      public void copyValues(PATHABLE dst) {
450        super.copyValues(dst);
451        dst.name = name == null ? null : name.copy();
452        dst.archetype_node_id = archetype_node_id == null ? null : archetype_node_id.copy();
453        dst.uid = uid == null ? null : uid.copy();
454        if (linksList != null) {
455          dst.linksList = new ArrayList<LINK>();
456          for (LINK i : linksList)
457            dst.linksList.add(i.copy());
458        };
459        dst.archetype_details = archetype_details == null ? null : archetype_details.copy();
460        dst.feeder_audit = feeder_audit == null ? null : feeder_audit.copy();
461      }
462
463      @Override
464      public boolean equalsDeep(Base other_) {
465        if (!super.equalsDeep(other_))
466          return false;
467        if (!(other_ instanceof PATHABLE))
468          return false;
469        PATHABLE o = (PATHABLE) other_;
470        return compareDeep(name, o.name, true) && compareDeep(archetype_node_id, o.archetype_node_id, true)
471           && compareDeep(uid, o.uid, true) && compareDeep(linksList, o.linksList, true) && compareDeep(archetype_details, o.archetype_details, true)
472           && compareDeep(feeder_audit, o.feeder_audit, true);
473      }
474
475      @Override
476      public boolean equalsShallow(Base other_) {
477        if (!super.equalsShallow(other_))
478          return false;
479        if (!(other_ instanceof PATHABLE))
480          return false;
481        PATHABLE o = (PATHABLE) other_;
482        return compareValues(archetype_node_id, o.archetype_node_id, true);
483      }
484
485      public boolean isEmpty() {
486        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(name, archetype_node_id, uid
487          , linksList, archetype_details, feeder_audit);
488      }
489
490
491}
492