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 * Version control abstraction, defining semantics for versioning one complex object.
050 */
051@DatatypeDef(name="VERSION")
052public abstract class VERSION extends LogicalBase implements ICompositeType {
053
054    /**
055     * Contribution in which this version was added.
056     */
057    @Child(name = "contribution", type = {OBJECT_REF.class}, order=0, min=1, max=1, modifier=false, summary=false)
058    @Description(shortDefinition="Contribution in which this version was added", formalDefinition="Contribution in which this version was added." )
059    protected OBJECT_REF contribution;
060
061    /**
062     * OpenPGP digital signature or digest of content committed in this Version.
063     */
064    @Child(name = "signature", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=false)
065    @Description(shortDefinition="OpenPGP digital signature or digest of content committed in this Version", formalDefinition="OpenPGP digital signature or digest of content committed in this Version." )
066    protected StringType signature;
067
068    /**
069     * Audit trail corresponding to the committal of this version to the VERSIONED_OBJECT.
070     */
071    @Child(name = "commit_audit", type = {AUDIT_DETAILS.class}, order=2, min=1, max=1, modifier=false, summary=false)
072    @Description(shortDefinition="Audit trail corresponding to the committal of this version to the VERSIONED_OBJECT", formalDefinition="Audit trail corresponding to the committal of this version to the VERSIONED_OBJECT." )
073    protected AUDIT_DETAILS commit_audit;
074
075    private static final long serialVersionUID = 1394455611L;
076
077  /**
078   * Constructor
079   */
080    public VERSION() {
081      super();
082    }
083
084  /**
085   * Constructor
086   */
087    public VERSION(OBJECT_REF contribution, AUDIT_DETAILS commit_audit) {
088      super();
089      this.setContribution(contribution);
090      this.setCommit_audit(commit_audit);
091    }
092
093    /**
094     * @return {@link #contribution} (Contribution in which this version was added.)
095     */
096    public OBJECT_REF getContribution() { 
097      if (this.contribution == null)
098        if (Configuration.errorOnAutoCreate())
099          throw new Error("Attempt to auto-create VERSION.contribution");
100        else if (Configuration.doAutoCreate())
101          this.contribution = new OBJECT_REF(); // cc
102      return this.contribution;
103    }
104
105    public boolean hasContribution() { 
106      return this.contribution != null && !this.contribution.isEmpty();
107    }
108
109    /**
110     * @param value {@link #contribution} (Contribution in which this version was added.)
111     */
112    public VERSION setContribution(OBJECT_REF value) { 
113      this.contribution = value;
114      return this;
115    }
116
117    /**
118     * @return {@link #signature} (OpenPGP digital signature or digest of content committed in this Version.). This is the underlying object with id, value and extensions. The accessor "getSignature" gives direct access to the value
119     */
120    public StringType getSignatureElement() { 
121      if (this.signature == null)
122        if (Configuration.errorOnAutoCreate())
123          throw new Error("Attempt to auto-create VERSION.signature");
124        else if (Configuration.doAutoCreate())
125          this.signature = new StringType(); // bb
126      return this.signature;
127    }
128
129    public boolean hasSignatureElement() { 
130      return this.signature != null && !this.signature.isEmpty();
131    }
132
133    public boolean hasSignature() { 
134      return this.signature != null && !this.signature.isEmpty();
135    }
136
137    /**
138     * @param value {@link #signature} (OpenPGP digital signature or digest of content committed in this Version.). This is the underlying object with id, value and extensions. The accessor "getSignature" gives direct access to the value
139     */
140    public VERSION setSignatureElement(StringType value) { 
141      this.signature = value;
142      return this;
143    }
144
145    /**
146     * @return OpenPGP digital signature or digest of content committed in this Version.
147     */
148    public String getSignature() { 
149      return this.signature == null ? null : this.signature.getValue();
150    }
151
152    /**
153     * @param value OpenPGP digital signature or digest of content committed in this Version.
154     */
155    public VERSION setSignature(String value) { 
156      if (Utilities.noString(value))
157        this.signature = null;
158      else {
159        if (this.signature == null)
160          this.signature = new StringType();
161        this.signature.setValue(value);
162      }
163      return this;
164    }
165
166    /**
167     * @return {@link #commit_audit} (Audit trail corresponding to the committal of this version to the VERSIONED_OBJECT.)
168     */
169    public AUDIT_DETAILS getCommit_audit() { 
170      if (this.commit_audit == null)
171        if (Configuration.errorOnAutoCreate())
172          throw new Error("Attempt to auto-create VERSION.commit_audit");
173        else if (Configuration.doAutoCreate())
174          this.commit_audit = new AUDIT_DETAILS(); // cc
175      return this.commit_audit;
176    }
177
178    public boolean hasCommit_audit() { 
179      return this.commit_audit != null && !this.commit_audit.isEmpty();
180    }
181
182    /**
183     * @param value {@link #commit_audit} (Audit trail corresponding to the committal of this version to the VERSIONED_OBJECT.)
184     */
185    public VERSION setCommit_audit(AUDIT_DETAILS value) { 
186      this.commit_audit = value;
187      return this;
188    }
189
190      protected void listChildren(List<Property> children) {
191        super.listChildren(children);
192        children.add(new Property("contribution", "http://openehr.org/fhir/StructureDefinition/OBJECT-REF", "Contribution in which this version was added.", 0, 1, contribution));
193        children.add(new Property("signature", "string", "OpenPGP digital signature or digest of content committed in this Version.", 0, 1, signature));
194        children.add(new Property("commit_audit", "http://openehr.org/fhir/StructureDefinition/AUDIT-DETAILS", "Audit trail corresponding to the committal of this version to the VERSIONED_OBJECT.", 0, 1, commit_audit));
195      }
196
197      @Override
198      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
199        switch (_hash) {
200        case 1375970320: /*contribution*/  return new Property("contribution", "http://openehr.org/fhir/StructureDefinition/OBJECT-REF", "Contribution in which this version was added.", 0, 1, contribution);
201        case 1073584312: /*signature*/  return new Property("signature", "string", "OpenPGP digital signature or digest of content committed in this Version.", 0, 1, signature);
202        case -392355117: /*commit_audit*/  return new Property("commit_audit", "http://openehr.org/fhir/StructureDefinition/AUDIT-DETAILS", "Audit trail corresponding to the committal of this version to the VERSIONED_OBJECT.", 0, 1, commit_audit);
203        default: return super.getNamedProperty(_hash, _name, _checkValid);
204        }
205
206      }
207
208      @Override
209      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
210        switch (hash) {
211        case 1375970320: /*contribution*/ return this.contribution == null ? new Base[0] : new Base[] {this.contribution}; // OBJECT_REF
212        case 1073584312: /*signature*/ return this.signature == null ? new Base[0] : new Base[] {this.signature}; // StringType
213        case -392355117: /*commit_audit*/ return this.commit_audit == null ? new Base[0] : new Base[] {this.commit_audit}; // AUDIT_DETAILS
214        default: return super.getProperty(hash, name, checkValid);
215        }
216
217      }
218
219      @Override
220      public Base setProperty(int hash, String name, Base value) throws FHIRException {
221        switch (hash) {
222        case 1375970320: // contribution
223          this.contribution = (OBJECT_REF) value; // OBJECT_REF
224          return value;
225        case 1073584312: // signature
226          this.signature = TypeConvertor.castToString(value); // StringType
227          return value;
228        case -392355117: // commit_audit
229          this.commit_audit = (AUDIT_DETAILS) value; // AUDIT_DETAILS
230          return value;
231        default: return super.setProperty(hash, name, value);
232        }
233
234      }
235
236      @Override
237      public Base setProperty(String name, Base value) throws FHIRException {
238        if (name.equals("contribution")) {
239          this.contribution = (OBJECT_REF) value; // OBJECT_REF
240        } else if (name.equals("signature")) {
241          this.signature = TypeConvertor.castToString(value); // StringType
242        } else if (name.equals("commit_audit")) {
243          this.commit_audit = (AUDIT_DETAILS) value; // AUDIT_DETAILS
244        } else
245          return super.setProperty(name, value);
246        return value;
247      }
248
249      @Override
250      public Base makeProperty(int hash, String name) throws FHIRException {
251        switch (hash) {
252        case 1375970320:  return getContribution();
253        case 1073584312:  return getSignatureElement();
254        case -392355117:  return getCommit_audit();
255        default: return super.makeProperty(hash, name);
256        }
257
258      }
259
260      @Override
261      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
262        switch (hash) {
263        case 1375970320: /*contribution*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/OBJECT-REF"};
264        case 1073584312: /*signature*/ return new String[] {"string"};
265        case -392355117: /*commit_audit*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/AUDIT-DETAILS"};
266        default: return super.getTypesForProperty(hash, name);
267        }
268
269      }
270
271      @Override
272      public Base addChild(String name) throws FHIRException {
273        if (name.equals("contribution")) {
274          this.contribution = new OBJECT_REF();
275          return this.contribution;
276        }
277        else if (name.equals("signature")) {
278          throw new FHIRException("Cannot call addChild on a singleton property VERSION.signature");
279        }
280        else if (name.equals("commit_audit")) {
281          this.commit_audit = new AUDIT_DETAILS();
282          return this.commit_audit;
283        }
284        else
285          return super.addChild(name);
286      }
287
288  public String fhirType() {
289    return "VERSION";
290
291  }
292
293      public abstract VERSION copy();
294
295      public void copyValues(VERSION dst) {
296        super.copyValues(dst);
297        dst.contribution = contribution == null ? null : contribution.copy();
298        dst.signature = signature == null ? null : signature.copy();
299        dst.commit_audit = commit_audit == null ? null : commit_audit.copy();
300      }
301
302      @Override
303      public boolean equalsDeep(Base other_) {
304        if (!super.equalsDeep(other_))
305          return false;
306        if (!(other_ instanceof VERSION))
307          return false;
308        VERSION o = (VERSION) other_;
309        return compareDeep(contribution, o.contribution, true) && compareDeep(signature, o.signature, true)
310           && compareDeep(commit_audit, o.commit_audit, true);
311      }
312
313      @Override
314      public boolean equalsShallow(Base other_) {
315        if (!super.equalsShallow(other_))
316          return false;
317        if (!(other_ instanceof VERSION))
318          return false;
319        VERSION o = (VERSION) other_;
320        return compareValues(signature, o.signature, true);
321      }
322
323      public boolean isEmpty() {
324        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(contribution, signature, commit_audit
325          );
326      }
327
328
329}
330