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 * Represents a period of time with respect to a notional point in time, which is not specified. A sign may be used to indicate the duration is backwards in time rather than forwards. Used for recording the duration of something in the real world, particularly when there is a need a) to represent the duration in customary format, i.e. days, hours, minutes etc, and b) if it will be used in computational operations with date/time quantities, i.e. additions, subtractions etc.
050 */
051@DatatypeDef(name="DV_DURATION")
052public class DV_DURATION extends DV_AMOUNT implements ICompositeType {
053
054    /**
055     * Represents a period of time with respect to a notional point in time, which is not specified. A sign may be used to indicate the duration is backwards in time rather than forwards. Used for recording the duration of something in the real world, particularly when there is a need a) to represent the duration in customary format, i.e. days, hours, minutes etc, and b) if it will be used in computational operations with date/time quantities, i.e. additions, subtractions etc. Misuse: Durations cannot be used to represent points in time, or intervals of time.
056     */
057    @Child(name = "value", type = {StringType.class}, order=0, min=0, max=1, modifier=false, summary=false)
058    @Description(shortDefinition="ISO8601 duration string, including described deviations to support negative values and weeks", formalDefinition="Represents a period of time with respect to a notional point in time, which is not specified. A sign may be used to indicate the duration is backwards in time rather than forwards. Used for recording the duration of something in the real world, particularly when there is a need a) to represent the duration in customary format, i.e. days, hours, minutes etc, and b) if it will be used in computational operations with date/time quantities, i.e. additions, subtractions etc. Misuse: Durations cannot be used to represent points in time, or intervals of time." )
059    protected StringType value;
060
061    private static final long serialVersionUID = -301439478L;
062
063  /**
064   * Constructor
065   */
066    public DV_DURATION() {
067      super();
068    }
069
070    /**
071     * @return {@link #value} (Represents a period of time with respect to a notional point in time, which is not specified. A sign may be used to indicate the duration is backwards in time rather than forwards. Used for recording the duration of something in the real world, particularly when there is a need a) to represent the duration in customary format, i.e. days, hours, minutes etc, and b) if it will be used in computational operations with date/time quantities, i.e. additions, subtractions etc. Misuse: Durations cannot be used to represent points in time, or intervals of time.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
072     */
073    public StringType getValueElement() { 
074      if (this.value == null)
075        if (Configuration.errorOnAutoCreate())
076          throw new Error("Attempt to auto-create DV_DURATION.value");
077        else if (Configuration.doAutoCreate())
078          this.value = new StringType(); // bb
079      return this.value;
080    }
081
082    public boolean hasValueElement() { 
083      return this.value != null && !this.value.isEmpty();
084    }
085
086    public boolean hasValue() { 
087      return this.value != null && !this.value.isEmpty();
088    }
089
090    /**
091     * @param value {@link #value} (Represents a period of time with respect to a notional point in time, which is not specified. A sign may be used to indicate the duration is backwards in time rather than forwards. Used for recording the duration of something in the real world, particularly when there is a need a) to represent the duration in customary format, i.e. days, hours, minutes etc, and b) if it will be used in computational operations with date/time quantities, i.e. additions, subtractions etc. Misuse: Durations cannot be used to represent points in time, or intervals of time.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
092     */
093    public DV_DURATION setValueElement(StringType value) { 
094      this.value = value;
095      return this;
096    }
097
098    /**
099     * @return Represents a period of time with respect to a notional point in time, which is not specified. A sign may be used to indicate the duration is backwards in time rather than forwards. Used for recording the duration of something in the real world, particularly when there is a need a) to represent the duration in customary format, i.e. days, hours, minutes etc, and b) if it will be used in computational operations with date/time quantities, i.e. additions, subtractions etc. Misuse: Durations cannot be used to represent points in time, or intervals of time.
100     */
101    public String getValue() { 
102      return this.value == null ? null : this.value.getValue();
103    }
104
105    /**
106     * @param value Represents a period of time with respect to a notional point in time, which is not specified. A sign may be used to indicate the duration is backwards in time rather than forwards. Used for recording the duration of something in the real world, particularly when there is a need a) to represent the duration in customary format, i.e. days, hours, minutes etc, and b) if it will be used in computational operations with date/time quantities, i.e. additions, subtractions etc. Misuse: Durations cannot be used to represent points in time, or intervals of time.
107     */
108    public DV_DURATION setValue(String value) { 
109      if (Utilities.noString(value))
110        this.value = null;
111      else {
112        if (this.value == null)
113          this.value = new StringType();
114        this.value.setValue(value);
115      }
116      return this;
117    }
118
119      protected void listChildren(List<Property> children) {
120        super.listChildren(children);
121        children.add(new Property("value", "string", "Represents a period of time with respect to a notional point in time, which is not specified. A sign may be used to indicate the duration is backwards in time rather than forwards. Used for recording the duration of something in the real world, particularly when there is a need a) to represent the duration in customary format, i.e. days, hours, minutes etc, and b) if it will be used in computational operations with date/time quantities, i.e. additions, subtractions etc. Misuse: Durations cannot be used to represent points in time, or intervals of time.", 0, 1, value));
122      }
123
124      @Override
125      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
126        switch (_hash) {
127        case 111972721: /*value*/  return new Property("value", "string", "Represents a period of time with respect to a notional point in time, which is not specified. A sign may be used to indicate the duration is backwards in time rather than forwards. Used for recording the duration of something in the real world, particularly when there is a need a) to represent the duration in customary format, i.e. days, hours, minutes etc, and b) if it will be used in computational operations with date/time quantities, i.e. additions, subtractions etc. Misuse: Durations cannot be used to represent points in time, or intervals of time.", 0, 1, value);
128        default: return super.getNamedProperty(_hash, _name, _checkValid);
129        }
130
131      }
132
133      @Override
134      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
135        switch (hash) {
136        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // StringType
137        default: return super.getProperty(hash, name, checkValid);
138        }
139
140      }
141
142      @Override
143      public Base setProperty(int hash, String name, Base value) throws FHIRException {
144        switch (hash) {
145        case 111972721: // value
146          this.value = TypeConvertor.castToString(value); // StringType
147          return value;
148        default: return super.setProperty(hash, name, value);
149        }
150
151      }
152
153      @Override
154      public Base setProperty(String name, Base value) throws FHIRException {
155        if (name.equals("value")) {
156          this.value = TypeConvertor.castToString(value); // StringType
157        } else
158          return super.setProperty(name, value);
159        return value;
160      }
161
162      @Override
163      public Base makeProperty(int hash, String name) throws FHIRException {
164        switch (hash) {
165        case 111972721:  return getValueElement();
166        default: return super.makeProperty(hash, name);
167        }
168
169      }
170
171      @Override
172      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
173        switch (hash) {
174        case 111972721: /*value*/ return new String[] {"string"};
175        default: return super.getTypesForProperty(hash, name);
176        }
177
178      }
179
180      @Override
181      public Base addChild(String name) throws FHIRException {
182        if (name.equals("value")) {
183          throw new FHIRException("Cannot call addChild on a singleton property DV_DURATION.value");
184        }
185        else
186          return super.addChild(name);
187      }
188
189  public String fhirType() {
190    return "DV_DURATION";
191
192  }
193
194      public DV_DURATION copy() {
195        DV_DURATION dst = new DV_DURATION();
196        copyValues(dst);
197        return dst;
198      }
199
200      public void copyValues(DV_DURATION dst) {
201        super.copyValues(dst);
202        dst.value = value == null ? null : value.copy();
203      }
204
205      protected DV_DURATION typedCopy() {
206        return copy();
207      }
208
209      @Override
210      public boolean equalsDeep(Base other_) {
211        if (!super.equalsDeep(other_))
212          return false;
213        if (!(other_ instanceof DV_DURATION))
214          return false;
215        DV_DURATION o = (DV_DURATION) other_;
216        return compareDeep(value, o.value, true);
217      }
218
219      @Override
220      public boolean equalsShallow(Base other_) {
221        if (!super.equalsShallow(other_))
222          return false;
223        if (!(other_ instanceof DV_DURATION))
224          return false;
225        DV_DURATION o = (DV_DURATION) other_;
226        return compareValues(value, o.value, true);
227      }
228
229      public boolean isEmpty() {
230        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(value);
231      }
232
233
234}
235