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 * Version control abstraction, defining semantics for versioning one complex object.
049 */
050@DatatypeDef(name="VERSIONED_OBJECT")
051public class VERSIONED_OBJECT extends LogicalBase implements ICompositeType {
052
053    /**
054     * Unique identifier of this version container in the form of a UID with no extension. This id will be the same in all instances of the same container in a distributed environment, meaning that it can be understood as the uid of the virtual version tree.
055     */
056    @Child(name = "uid", type = {HIER_OBJECT_ID.class}, order=0, min=1, max=1, modifier=false, summary=false)
057    @Description(shortDefinition="Unique identifier of this version container in the form of a UID with no extension", formalDefinition="Unique identifier of this version container in the form of a UID with no extension. This id will be the same in all instances of the same container in a distributed environment, meaning that it can be understood as the uid of the virtual version tree." )
058    protected HIER_OBJECT_ID uid;
059
060    /**
061     * Reference to object to which this version container belongs, e.g. the id of the containing EHR or other relevant owning entity.
062     */
063    @Child(name = "owner_id", type = {OBJECT_REF.class}, order=1, min=1, max=1, modifier=false, summary=false)
064    @Description(shortDefinition="Reference to object to which this version container belongs, e.g. the id of the containing EHR or other relevant owning entity", formalDefinition="Reference to object to which this version container belongs, e.g. the id of the containing EHR or other relevant owning entity." )
065    protected OBJECT_REF owner_id;
066
067    /**
068     * Time of initial creation of this versioned object.
069     */
070    @Child(name = "time_created", type = {DV_DATE_TIME.class}, order=2, min=1, max=1, modifier=false, summary=false)
071    @Description(shortDefinition="Time of initial creation of this versioned object", formalDefinition="Time of initial creation of this versioned object." )
072    protected DV_DATE_TIME time_created;
073
074    private static final long serialVersionUID = 615162631L;
075
076  /**
077   * Constructor
078   */
079    public VERSIONED_OBJECT() {
080      super();
081    }
082
083  /**
084   * Constructor
085   */
086    public VERSIONED_OBJECT(HIER_OBJECT_ID uid, OBJECT_REF owner_id, DV_DATE_TIME time_created) {
087      super();
088      this.setUid(uid);
089      this.setOwner_id(owner_id);
090      this.setTime_created(time_created);
091    }
092
093    /**
094     * @return {@link #uid} (Unique identifier of this version container in the form of a UID with no extension. This id will be the same in all instances of the same container in a distributed environment, meaning that it can be understood as the uid of the virtual version tree.)
095     */
096    public HIER_OBJECT_ID getUid() { 
097      if (this.uid == null)
098        if (Configuration.errorOnAutoCreate())
099          throw new Error("Attempt to auto-create VERSIONED_OBJECT.uid");
100        else if (Configuration.doAutoCreate())
101          this.uid = new HIER_OBJECT_ID(); // cc
102      return this.uid;
103    }
104
105    public boolean hasUid() { 
106      return this.uid != null && !this.uid.isEmpty();
107    }
108
109    /**
110     * @param value {@link #uid} (Unique identifier of this version container in the form of a UID with no extension. This id will be the same in all instances of the same container in a distributed environment, meaning that it can be understood as the uid of the virtual version tree.)
111     */
112    public VERSIONED_OBJECT setUid(HIER_OBJECT_ID value) { 
113      this.uid = value;
114      return this;
115    }
116
117    /**
118     * @return {@link #owner_id} (Reference to object to which this version container belongs, e.g. the id of the containing EHR or other relevant owning entity.)
119     */
120    public OBJECT_REF getOwner_id() { 
121      if (this.owner_id == null)
122        if (Configuration.errorOnAutoCreate())
123          throw new Error("Attempt to auto-create VERSIONED_OBJECT.owner_id");
124        else if (Configuration.doAutoCreate())
125          this.owner_id = new OBJECT_REF(); // cc
126      return this.owner_id;
127    }
128
129    public boolean hasOwner_id() { 
130      return this.owner_id != null && !this.owner_id.isEmpty();
131    }
132
133    /**
134     * @param value {@link #owner_id} (Reference to object to which this version container belongs, e.g. the id of the containing EHR or other relevant owning entity.)
135     */
136    public VERSIONED_OBJECT setOwner_id(OBJECT_REF value) { 
137      this.owner_id = value;
138      return this;
139    }
140
141    /**
142     * @return {@link #time_created} (Time of initial creation of this versioned object.)
143     */
144    public DV_DATE_TIME getTime_created() { 
145      if (this.time_created == null)
146        if (Configuration.errorOnAutoCreate())
147          throw new Error("Attempt to auto-create VERSIONED_OBJECT.time_created");
148        else if (Configuration.doAutoCreate())
149          this.time_created = new DV_DATE_TIME(); // cc
150      return this.time_created;
151    }
152
153    public boolean hasTime_created() { 
154      return this.time_created != null && !this.time_created.isEmpty();
155    }
156
157    /**
158     * @param value {@link #time_created} (Time of initial creation of this versioned object.)
159     */
160    public VERSIONED_OBJECT setTime_created(DV_DATE_TIME value) { 
161      this.time_created = value;
162      return this;
163    }
164
165      protected void listChildren(List<Property> children) {
166        super.listChildren(children);
167        children.add(new Property("uid", "http://openehr.org/fhir/StructureDefinition/HIER-OBJECT-ID", "Unique identifier of this version container in the form of a UID with no extension. This id will be the same in all instances of the same container in a distributed environment, meaning that it can be understood as the uid of the virtual version tree.", 0, 1, uid));
168        children.add(new Property("owner_id", "http://openehr.org/fhir/StructureDefinition/OBJECT-REF", "Reference to object to which this version container belongs, e.g. the id of the containing EHR or other relevant owning entity.", 0, 1, owner_id));
169        children.add(new Property("time_created", "http://openehr.org/fhir/StructureDefinition/DV-DATE-TIME", "Time of initial creation of this versioned object.", 0, 1, time_created));
170      }
171
172      @Override
173      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
174        switch (_hash) {
175        case 115792: /*uid*/  return new Property("uid", "http://openehr.org/fhir/StructureDefinition/HIER-OBJECT-ID", "Unique identifier of this version container in the form of a UID with no extension. This id will be the same in all instances of the same container in a distributed environment, meaning that it can be understood as the uid of the virtual version tree.", 0, 1, uid);
176        case 1663147559: /*owner_id*/  return new Property("owner_id", "http://openehr.org/fhir/StructureDefinition/OBJECT-REF", "Reference to object to which this version container belongs, e.g. the id of the containing EHR or other relevant owning entity.", 0, 1, owner_id);
177        case -630236298: /*time_created*/  return new Property("time_created", "http://openehr.org/fhir/StructureDefinition/DV-DATE-TIME", "Time of initial creation of this versioned object.", 0, 1, time_created);
178        default: return super.getNamedProperty(_hash, _name, _checkValid);
179        }
180
181      }
182
183      @Override
184      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
185        switch (hash) {
186        case 115792: /*uid*/ return this.uid == null ? new Base[0] : new Base[] {this.uid}; // HIER_OBJECT_ID
187        case 1663147559: /*owner_id*/ return this.owner_id == null ? new Base[0] : new Base[] {this.owner_id}; // OBJECT_REF
188        case -630236298: /*time_created*/ return this.time_created == null ? new Base[0] : new Base[] {this.time_created}; // DV_DATE_TIME
189        default: return super.getProperty(hash, name, checkValid);
190        }
191
192      }
193
194      @Override
195      public Base setProperty(int hash, String name, Base value) throws FHIRException {
196        switch (hash) {
197        case 115792: // uid
198          this.uid = (HIER_OBJECT_ID) value; // HIER_OBJECT_ID
199          return value;
200        case 1663147559: // owner_id
201          this.owner_id = (OBJECT_REF) value; // OBJECT_REF
202          return value;
203        case -630236298: // time_created
204          this.time_created = (DV_DATE_TIME) value; // DV_DATE_TIME
205          return value;
206        default: return super.setProperty(hash, name, value);
207        }
208
209      }
210
211      @Override
212      public Base setProperty(String name, Base value) throws FHIRException {
213        if (name.equals("uid")) {
214          this.uid = (HIER_OBJECT_ID) value; // HIER_OBJECT_ID
215        } else if (name.equals("owner_id")) {
216          this.owner_id = (OBJECT_REF) value; // OBJECT_REF
217        } else if (name.equals("time_created")) {
218          this.time_created = (DV_DATE_TIME) value; // DV_DATE_TIME
219        } else
220          return super.setProperty(name, value);
221        return value;
222      }
223
224      @Override
225      public Base makeProperty(int hash, String name) throws FHIRException {
226        switch (hash) {
227        case 115792:  return getUid();
228        case 1663147559:  return getOwner_id();
229        case -630236298:  return getTime_created();
230        default: return super.makeProperty(hash, name);
231        }
232
233      }
234
235      @Override
236      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
237        switch (hash) {
238        case 115792: /*uid*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/HIER-OBJECT-ID"};
239        case 1663147559: /*owner_id*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/OBJECT-REF"};
240        case -630236298: /*time_created*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-DATE-TIME"};
241        default: return super.getTypesForProperty(hash, name);
242        }
243
244      }
245
246      @Override
247      public Base addChild(String name) throws FHIRException {
248        if (name.equals("uid")) {
249          this.uid = new HIER_OBJECT_ID();
250          return this.uid;
251        }
252        else if (name.equals("owner_id")) {
253          this.owner_id = new OBJECT_REF();
254          return this.owner_id;
255        }
256        else if (name.equals("time_created")) {
257          this.time_created = new DV_DATE_TIME();
258          return this.time_created;
259        }
260        else
261          return super.addChild(name);
262      }
263
264  public String fhirType() {
265    return "VERSIONED_OBJECT";
266
267  }
268
269      public VERSIONED_OBJECT copy() {
270        VERSIONED_OBJECT dst = new VERSIONED_OBJECT();
271        copyValues(dst);
272        return dst;
273      }
274
275      public void copyValues(VERSIONED_OBJECT dst) {
276        super.copyValues(dst);
277        dst.uid = uid == null ? null : uid.copy();
278        dst.owner_id = owner_id == null ? null : owner_id.copy();
279        dst.time_created = time_created == null ? null : time_created.copy();
280      }
281
282      protected VERSIONED_OBJECT typedCopy() {
283        return copy();
284      }
285
286      @Override
287      public boolean equalsDeep(Base other_) {
288        if (!super.equalsDeep(other_))
289          return false;
290        if (!(other_ instanceof VERSIONED_OBJECT))
291          return false;
292        VERSIONED_OBJECT o = (VERSIONED_OBJECT) other_;
293        return compareDeep(uid, o.uid, true) && compareDeep(owner_id, o.owner_id, true) && compareDeep(time_created, o.time_created, true)
294          ;
295      }
296
297      @Override
298      public boolean equalsShallow(Base other_) {
299        if (!super.equalsShallow(other_))
300          return false;
301        if (!(other_ instanceof VERSIONED_OBJECT))
302          return false;
303        VERSIONED_OBJECT o = (VERSIONED_OBJECT) other_;
304        return true;
305      }
306
307      public boolean isEmpty() {
308        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(uid, owner_id, time_created
309          );
310      }
311
312
313}
314