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 * A Version containing locally created content and optional attestations.
049 */
050@DatatypeDef(name="ORIGINAL_VERSION")
051public class ORIGINAL_VERSION extends VERSION implements ICompositeType {
052
053    /**
054     * Stored version of inheritance precursor.
055     */
056    @Child(name = "uid", type = {OBJECT_VERSION_ID.class}, order=0, min=1, max=1, modifier=false, summary=false)
057    @Description(shortDefinition="Stored version of inheritance precursor", formalDefinition="Stored version of inheritance precursor." )
058    protected OBJECT_VERSION_ID uid;
059
060    /**
061     * Stored version of inheritance precursor.
062     */
063    @Child(name = "preceding_version_uid", type = {OBJECT_VERSION_ID.class}, order=1, min=1, max=1, modifier=false, summary=false)
064    @Description(shortDefinition="Stored version of inheritance precursor", formalDefinition="Stored version of inheritance precursor." )
065    protected OBJECT_VERSION_ID preceding_version_uid;
066
067    /**
068     * Identifiers of other versions whose content was merged into this version, if any.
069     */
070    @Child(name = "other_input_version_uids", type = {OBJECT_VERSION_ID.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
071    @Description(shortDefinition="Identifiers of other versions whose content was merged into this version, if any", formalDefinition="Identifiers of other versions whose content was merged into this version, if any." )
072    protected List<OBJECT_VERSION_ID> other_input_version_uidsList;
073
074    /**
075     * Lifecycle state of the content item in this version; coded by openEHR vocabulary version lifecycle state.
076     */
077    @Child(name = "lifecycle_state", type = {DV_CODED_TEXT.class}, order=3, min=1, max=1, modifier=false, summary=false)
078    @Description(shortDefinition="Lifecycle state of the content item in this version", formalDefinition="Lifecycle state of the content item in this version; coded by openEHR vocabulary version lifecycle state." )
079    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="https://specifications.openehr.org/fhir/valueset-version_lifecycle_state")
080    protected DV_CODED_TEXT lifecycle_state;
081
082    /**
083     * Set of attestations relating to this version.
084     */
085    @Child(name = "attestations", type = {ATTESTATION.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
086    @Description(shortDefinition="Set of attestations relating to this version", formalDefinition="Set of attestations relating to this version." )
087    protected List<ATTESTATION> attestationsList;
088
089    /**
090     * Data content of this Version.
091     */
092    @Child(name = "data", type = {Reference.class}, order=5, min=0, max=1, modifier=false, summary=false)
093    @Description(shortDefinition="Data content of this Version", formalDefinition="Data content of this Version." )
094    protected Any data;
095
096    private static final long serialVersionUID = 622601284L;
097
098  /**
099   * Constructor
100   */
101    public ORIGINAL_VERSION() {
102      super();
103    }
104
105  /**
106   * Constructor
107   */
108    public ORIGINAL_VERSION(OBJECT_VERSION_ID uid, OBJECT_VERSION_ID preceding_version_uid, DV_CODED_TEXT lifecycle_state) {
109      super();
110      this.setUid(uid);
111      this.setPreceding_version_uid(preceding_version_uid);
112      this.setLifecycle_state(lifecycle_state);
113    }
114
115    /**
116     * @return {@link #uid} (Stored version of inheritance precursor.)
117     */
118    public OBJECT_VERSION_ID getUid() { 
119      if (this.uid == null)
120        if (Configuration.errorOnAutoCreate())
121          throw new Error("Attempt to auto-create ORIGINAL_VERSION.uid");
122        else if (Configuration.doAutoCreate())
123          this.uid = new OBJECT_VERSION_ID(); // cc
124      return this.uid;
125    }
126
127    public boolean hasUid() { 
128      return this.uid != null && !this.uid.isEmpty();
129    }
130
131    /**
132     * @param value {@link #uid} (Stored version of inheritance precursor.)
133     */
134    public ORIGINAL_VERSION setUid(OBJECT_VERSION_ID value) { 
135      this.uid = value;
136      return this;
137    }
138
139    /**
140     * @return {@link #preceding_version_uid} (Stored version of inheritance precursor.)
141     */
142    public OBJECT_VERSION_ID getPreceding_version_uid() { 
143      if (this.preceding_version_uid == null)
144        if (Configuration.errorOnAutoCreate())
145          throw new Error("Attempt to auto-create ORIGINAL_VERSION.preceding_version_uid");
146        else if (Configuration.doAutoCreate())
147          this.preceding_version_uid = new OBJECT_VERSION_ID(); // cc
148      return this.preceding_version_uid;
149    }
150
151    public boolean hasPreceding_version_uid() { 
152      return this.preceding_version_uid != null && !this.preceding_version_uid.isEmpty();
153    }
154
155    /**
156     * @param value {@link #preceding_version_uid} (Stored version of inheritance precursor.)
157     */
158    public ORIGINAL_VERSION setPreceding_version_uid(OBJECT_VERSION_ID value) { 
159      this.preceding_version_uid = value;
160      return this;
161    }
162
163    /**
164     * @return {@link #other_input_version_uids} (Identifiers of other versions whose content was merged into this version, if any.)
165     */
166    public List<OBJECT_VERSION_ID> getOther_input_version_uidsList() { 
167      if (this.other_input_version_uidsList == null)
168        this.other_input_version_uidsList = new ArrayList<OBJECT_VERSION_ID>();
169      return this.other_input_version_uidsList;
170    }
171
172    /**
173     * @return Returns a reference to <code>this</code> for easy method chaining
174     */
175    public ORIGINAL_VERSION setOther_input_version_uidsList(List<OBJECT_VERSION_ID> theOther_input_version_uids) { 
176      this.other_input_version_uidsList = theOther_input_version_uids;
177      return this;
178    }
179
180    public boolean hasOther_input_version_uids() { 
181      if (this.other_input_version_uidsList == null)
182        return false;
183      for (OBJECT_VERSION_ID item : this.other_input_version_uidsList)
184        if (!item.isEmpty())
185          return true;
186      return false;
187    }
188
189    public OBJECT_VERSION_ID addOther_input_version_uids() { //3a
190      OBJECT_VERSION_ID t = new OBJECT_VERSION_ID();
191      if (this.other_input_version_uidsList == null)
192        this.other_input_version_uidsList = new ArrayList<OBJECT_VERSION_ID>();
193      this.other_input_version_uidsList.add(t);
194      return t;
195    }
196
197    public ORIGINAL_VERSION addOther_input_version_uids(OBJECT_VERSION_ID t) { //3b
198      if (t == null)
199        return this;
200      if (this.other_input_version_uidsList == null)
201        this.other_input_version_uidsList = new ArrayList<OBJECT_VERSION_ID>();
202      this.other_input_version_uidsList.add(t);
203      return this;
204    }
205
206    /**
207     * @return The first repetition of repeating field {@link #other_input_version_uids}, creating it if it does not already exist {3}
208     */
209    public OBJECT_VERSION_ID getOther_input_version_uidsFirstRep() { 
210      if (getOther_input_version_uidsList().isEmpty()) {
211        addOther_input_version_uids();
212      }
213      return getOther_input_version_uidsList().get(0);
214    }
215
216    /**
217     * @return {@link #lifecycle_state} (Lifecycle state of the content item in this version; coded by openEHR vocabulary version lifecycle state.)
218     */
219    public DV_CODED_TEXT getLifecycle_state() { 
220      if (this.lifecycle_state == null)
221        if (Configuration.errorOnAutoCreate())
222          throw new Error("Attempt to auto-create ORIGINAL_VERSION.lifecycle_state");
223        else if (Configuration.doAutoCreate())
224          this.lifecycle_state = new DV_CODED_TEXT(); // cc
225      return this.lifecycle_state;
226    }
227
228    public boolean hasLifecycle_state() { 
229      return this.lifecycle_state != null && !this.lifecycle_state.isEmpty();
230    }
231
232    /**
233     * @param value {@link #lifecycle_state} (Lifecycle state of the content item in this version; coded by openEHR vocabulary version lifecycle state.)
234     */
235    public ORIGINAL_VERSION setLifecycle_state(DV_CODED_TEXT value) { 
236      this.lifecycle_state = value;
237      return this;
238    }
239
240    /**
241     * @return {@link #attestations} (Set of attestations relating to this version.)
242     */
243    public List<ATTESTATION> getAttestationsList() { 
244      if (this.attestationsList == null)
245        this.attestationsList = new ArrayList<ATTESTATION>();
246      return this.attestationsList;
247    }
248
249    /**
250     * @return Returns a reference to <code>this</code> for easy method chaining
251     */
252    public ORIGINAL_VERSION setAttestationsList(List<ATTESTATION> theAttestations) { 
253      this.attestationsList = theAttestations;
254      return this;
255    }
256
257    public boolean hasAttestations() { 
258      if (this.attestationsList == null)
259        return false;
260      for (ATTESTATION item : this.attestationsList)
261        if (!item.isEmpty())
262          return true;
263      return false;
264    }
265
266    public ATTESTATION addAttestations() { //3a
267      ATTESTATION t = new ATTESTATION();
268      if (this.attestationsList == null)
269        this.attestationsList = new ArrayList<ATTESTATION>();
270      this.attestationsList.add(t);
271      return t;
272    }
273
274    public ORIGINAL_VERSION addAttestations(ATTESTATION t) { //3b
275      if (t == null)
276        return this;
277      if (this.attestationsList == null)
278        this.attestationsList = new ArrayList<ATTESTATION>();
279      this.attestationsList.add(t);
280      return this;
281    }
282
283    /**
284     * @return The first repetition of repeating field {@link #attestations}, creating it if it does not already exist {3}
285     */
286    public ATTESTATION getAttestationsFirstRep() { 
287      if (getAttestationsList().isEmpty()) {
288        addAttestations();
289      }
290      return getAttestationsList().get(0);
291    }
292
293    /**
294     * @return {@link #data} (Data content of this Version.)
295     */
296    public Any getData() { 
297      return this.data;
298    }
299
300    public boolean hasData() { 
301      return this.data != null && !this.data.isEmpty();
302    }
303
304    /**
305     * @param value {@link #data} (Data content of this Version.)
306     */
307    public ORIGINAL_VERSION setData(Any value) { 
308      this.data = value;
309      return this;
310    }
311
312      protected void listChildren(List<Property> children) {
313        super.listChildren(children);
314        children.add(new Property("uid", "http://openehr.org/fhir/StructureDefinition/OBJECT-VERSION-ID", "Stored version of inheritance precursor.", 0, 1, uid));
315        children.add(new Property("preceding_version_uid", "http://openehr.org/fhir/StructureDefinition/OBJECT-VERSION-ID", "Stored version of inheritance precursor.", 0, 1, preceding_version_uid));
316        children.add(new Property("other_input_version_uids", "http://openehr.org/fhir/StructureDefinition/OBJECT-VERSION-ID", "Identifiers of other versions whose content was merged into this version, if any.", 0, java.lang.Integer.MAX_VALUE, other_input_version_uidsList));
317        children.add(new Property("lifecycle_state", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "Lifecycle state of the content item in this version; coded by openEHR vocabulary version lifecycle state.", 0, 1, lifecycle_state));
318        children.add(new Property("attestations", "http://openehr.org/fhir/StructureDefinition/ATTESTATION", "Set of attestations relating to this version.", 0, java.lang.Integer.MAX_VALUE, attestationsList));
319        children.add(new Property("data", "http://openehr.org/fhir/StructureDefinition/Any", "Data content of this Version.", 0, 1, data));
320      }
321
322      @Override
323      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
324        switch (_hash) {
325        case 115792: /*uid*/  return new Property("uid", "http://openehr.org/fhir/StructureDefinition/OBJECT-VERSION-ID", "Stored version of inheritance precursor.", 0, 1, uid);
326        case -1532609811: /*preceding_version_uid*/  return new Property("preceding_version_uid", "http://openehr.org/fhir/StructureDefinition/OBJECT-VERSION-ID", "Stored version of inheritance precursor.", 0, 1, preceding_version_uid);
327        case -653393650: /*other_input_version_uids*/  return new Property("other_input_version_uids", "http://openehr.org/fhir/StructureDefinition/OBJECT-VERSION-ID", "Identifiers of other versions whose content was merged into this version, if any.", 0, java.lang.Integer.MAX_VALUE, other_input_version_uidsList);
328        case 1508726652: /*lifecycle_state*/  return new Property("lifecycle_state", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "Lifecycle state of the content item in this version; coded by openEHR vocabulary version lifecycle state.", 0, 1, lifecycle_state);
329        case -523510877: /*attestations*/  return new Property("attestations", "http://openehr.org/fhir/StructureDefinition/ATTESTATION", "Set of attestations relating to this version.", 0, java.lang.Integer.MAX_VALUE, attestationsList);
330        case 3076010: /*data*/  return new Property("data", "http://openehr.org/fhir/StructureDefinition/Any", "Data content of this Version.", 0, 1, data);
331        default: return super.getNamedProperty(_hash, _name, _checkValid);
332        }
333
334      }
335
336      @Override
337      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
338        switch (hash) {
339        case 115792: /*uid*/ return this.uid == null ? new Base[0] : new Base[] {this.uid}; // OBJECT_VERSION_ID
340        case -1532609811: /*preceding_version_uid*/ return this.preceding_version_uid == null ? new Base[0] : new Base[] {this.preceding_version_uid}; // OBJECT_VERSION_ID
341        case -653393650: /*other_input_version_uids*/ return this.other_input_version_uidsList == null ? new Base[0] : this.other_input_version_uidsList.toArray(new Base[this.other_input_version_uidsList.size()]); // OBJECT_VERSION_ID
342        case 1508726652: /*lifecycle_state*/ return this.lifecycle_state == null ? new Base[0] : new Base[] {this.lifecycle_state}; // DV_CODED_TEXT
343        case -523510877: /*attestations*/ return this.attestationsList == null ? new Base[0] : this.attestationsList.toArray(new Base[this.attestationsList.size()]); // ATTESTATION
344        case 3076010: /*data*/ return this.data == null ? new Base[0] : new Base[] {this.data}; // Any
345        default: return super.getProperty(hash, name, checkValid);
346        }
347
348      }
349
350      @Override
351      public Base setProperty(int hash, String name, Base value) throws FHIRException {
352        switch (hash) {
353        case 115792: // uid
354          this.uid = (OBJECT_VERSION_ID) value; // OBJECT_VERSION_ID
355          return value;
356        case -1532609811: // preceding_version_uid
357          this.preceding_version_uid = (OBJECT_VERSION_ID) value; // OBJECT_VERSION_ID
358          return value;
359        case -653393650: // other_input_version_uids
360          this.getOther_input_version_uidsList().add((OBJECT_VERSION_ID) value); // OBJECT_VERSION_ID
361          return value;
362        case 1508726652: // lifecycle_state
363          this.lifecycle_state = (DV_CODED_TEXT) value; // DV_CODED_TEXT
364          return value;
365        case -523510877: // attestations
366          this.getAttestationsList().add((ATTESTATION) value); // ATTESTATION
367          return value;
368        case 3076010: // data
369          this.data = (Any) value; // Any
370          return value;
371        default: return super.setProperty(hash, name, value);
372        }
373
374      }
375
376      @Override
377      public Base setProperty(String name, Base value) throws FHIRException {
378        if (name.equals("uid")) {
379          this.uid = (OBJECT_VERSION_ID) value; // OBJECT_VERSION_ID
380        } else if (name.equals("preceding_version_uid")) {
381          this.preceding_version_uid = (OBJECT_VERSION_ID) value; // OBJECT_VERSION_ID
382        } else if (name.equals("other_input_version_uids")) {
383          this.getOther_input_version_uidsList().add((OBJECT_VERSION_ID) value); // OBJECT_VERSION_ID
384        } else if (name.equals("lifecycle_state")) {
385          this.lifecycle_state = (DV_CODED_TEXT) value; // DV_CODED_TEXT
386        } else if (name.equals("attestations")) {
387          this.getAttestationsList().add((ATTESTATION) value); // ATTESTATION
388        } else if (name.equals("data")) {
389          this.data = (Any) value; // Any
390        } else
391          return super.setProperty(name, value);
392        return value;
393      }
394
395      @Override
396      public Base makeProperty(int hash, String name) throws FHIRException {
397        switch (hash) {
398        case 115792:  return getUid();
399        case -1532609811:  return getPreceding_version_uid();
400        case -653393650:  return addOther_input_version_uids(); 
401        case 1508726652:  return getLifecycle_state();
402        case -523510877:  return addAttestations(); 
403        case 3076010: /*div*/
404          throw new Error("Unable to make an instance of the abstract property 'data'");
405        default: return super.makeProperty(hash, name);
406        }
407
408      }
409
410      @Override
411      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
412        switch (hash) {
413        case 115792: /*uid*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/OBJECT-VERSION-ID"};
414        case -1532609811: /*preceding_version_uid*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/OBJECT-VERSION-ID"};
415        case -653393650: /*other_input_version_uids*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/OBJECT-VERSION-ID"};
416        case 1508726652: /*lifecycle_state*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT"};
417        case -523510877: /*attestations*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/ATTESTATION"};
418        case 3076010: /*data*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/Any"};
419        default: return super.getTypesForProperty(hash, name);
420        }
421
422      }
423
424      @Override
425      public Base addChild(String name) throws FHIRException {
426        if (name.equals("uid")) {
427          this.uid = new OBJECT_VERSION_ID();
428          return this.uid;
429        }
430        else if (name.equals("preceding_version_uid")) {
431          this.preceding_version_uid = new OBJECT_VERSION_ID();
432          return this.preceding_version_uid;
433        }
434        else if (name.equals("other_input_version_uids")) {
435          return addOther_input_version_uids();
436        }
437        else if (name.equals("lifecycle_state")) {
438          this.lifecycle_state = new DV_CODED_TEXT();
439          return this.lifecycle_state;
440        }
441        else if (name.equals("attestations")) {
442          return addAttestations();
443        }
444        else if (name.equals("data")) {
445          throw new FHIRException("Cannot call addChild on an abstract type ORIGINAL_VERSION.data");
446        }
447        else
448          return super.addChild(name);
449      }
450
451  public String fhirType() {
452    return "ORIGINAL_VERSION";
453
454  }
455
456      public ORIGINAL_VERSION copy() {
457        ORIGINAL_VERSION dst = new ORIGINAL_VERSION();
458        copyValues(dst);
459        return dst;
460      }
461
462      public void copyValues(ORIGINAL_VERSION dst) {
463        super.copyValues(dst);
464        dst.uid = uid == null ? null : uid.copy();
465        dst.preceding_version_uid = preceding_version_uid == null ? null : preceding_version_uid.copy();
466        if (other_input_version_uidsList != null) {
467          dst.other_input_version_uidsList = new ArrayList<OBJECT_VERSION_ID>();
468          for (OBJECT_VERSION_ID i : other_input_version_uidsList)
469            dst.other_input_version_uidsList.add(i.copy());
470        };
471        dst.lifecycle_state = lifecycle_state == null ? null : lifecycle_state.copy();
472        if (attestationsList != null) {
473          dst.attestationsList = new ArrayList<ATTESTATION>();
474          for (ATTESTATION i : attestationsList)
475            dst.attestationsList.add(i.copy());
476        };
477        dst.data = data == null ? null : data.copy();
478      }
479
480      protected ORIGINAL_VERSION typedCopy() {
481        return copy();
482      }
483
484      @Override
485      public boolean equalsDeep(Base other_) {
486        if (!super.equalsDeep(other_))
487          return false;
488        if (!(other_ instanceof ORIGINAL_VERSION))
489          return false;
490        ORIGINAL_VERSION o = (ORIGINAL_VERSION) other_;
491        return compareDeep(uid, o.uid, true) && compareDeep(preceding_version_uid, o.preceding_version_uid, true)
492           && compareDeep(other_input_version_uidsList, o.other_input_version_uidsList, true) && compareDeep(lifecycle_state, o.lifecycle_state, true)
493           && compareDeep(attestationsList, o.attestationsList, true) && compareDeep(data, o.data, true);
494      }
495
496      @Override
497      public boolean equalsShallow(Base other_) {
498        if (!super.equalsShallow(other_))
499          return false;
500        if (!(other_ instanceof ORIGINAL_VERSION))
501          return false;
502        ORIGINAL_VERSION o = (ORIGINAL_VERSION) other_;
503        return true;
504      }
505
506      public boolean isEmpty() {
507        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(uid, preceding_version_uid
508          , other_input_version_uidsList, lifecycle_state, attestationsList, data);
509      }
510
511
512}
513