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