
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 java.math.*; 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 * Countable quantities. Used for countable types such as pregnancies and steps (taken by a physiotherapy patient), number of cigarettes smoked in a day. 050 */ 051@DatatypeDef(name="DV_COUNT") 052public class DV_COUNT extends DV_AMOUNT implements ICompositeType { 053 054 /** 055 * Numeric magnitude. 056 */ 057 @Child(name = "magnitude", type = {DecimalType.class}, order=0, min=1, max=1, modifier=false, summary=false) 058 @Description(shortDefinition="Numeric magnitude", formalDefinition="Numeric magnitude." ) 059 protected DecimalType magnitude; 060 061 private static final long serialVersionUID = -829015249L; 062 063 /** 064 * Constructor 065 */ 066 public DV_COUNT() { 067 super(); 068 } 069 070 /** 071 * Constructor 072 */ 073 public DV_COUNT(BigDecimal magnitude) { 074 super(); 075 this.setMagnitude(magnitude); 076 } 077 078 /** 079 * @return {@link #magnitude} (Numeric magnitude.). This is the underlying object with id, value and extensions. The accessor "getMagnitude" gives direct access to the value 080 */ 081 public DecimalType getMagnitudeElement() { 082 if (this.magnitude == null) 083 if (Configuration.errorOnAutoCreate()) 084 throw new Error("Attempt to auto-create DV_COUNT.magnitude"); 085 else if (Configuration.doAutoCreate()) 086 this.magnitude = new DecimalType(); // bb 087 return this.magnitude; 088 } 089 090 public boolean hasMagnitudeElement() { 091 return this.magnitude != null && !this.magnitude.isEmpty(); 092 } 093 094 public boolean hasMagnitude() { 095 return this.magnitude != null && !this.magnitude.isEmpty(); 096 } 097 098 /** 099 * @param value {@link #magnitude} (Numeric magnitude.). This is the underlying object with id, value and extensions. The accessor "getMagnitude" gives direct access to the value 100 */ 101 public DV_COUNT setMagnitudeElement(DecimalType value) { 102 this.magnitude = value; 103 return this; 104 } 105 106 /** 107 * @return Numeric magnitude. 108 */ 109 public BigDecimal getMagnitude() { 110 return this.magnitude == null ? null : this.magnitude.getValue(); 111 } 112 113 /** 114 * @param value Numeric magnitude. 115 */ 116 public DV_COUNT setMagnitude(BigDecimal value) { 117 if (this.magnitude == null) 118 this.magnitude = new DecimalType(); 119 this.magnitude.setValue(value); 120 return this; 121 } 122 123 /** 124 * @param value Numeric magnitude. 125 */ 126 public DV_COUNT setMagnitude(long value) { 127 this.magnitude = new DecimalType(); 128 this.magnitude.setValue(value); 129 return this; 130 } 131 132 /** 133 * @param value Numeric magnitude. 134 */ 135 public DV_COUNT setMagnitude(double value) { 136 this.magnitude = new DecimalType(); 137 this.magnitude.setValue(value); 138 return this; 139 } 140 141 protected void listChildren(List<Property> children) { 142 super.listChildren(children); 143 children.add(new Property("magnitude", "decimal", "Numeric magnitude.", 0, 1, magnitude)); 144 } 145 146 @Override 147 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 148 switch (_hash) { 149 case -2016783856: /*magnitude*/ return new Property("magnitude", "decimal", "Numeric magnitude.", 0, 1, magnitude); 150 default: return super.getNamedProperty(_hash, _name, _checkValid); 151 } 152 153 } 154 155 @Override 156 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 157 switch (hash) { 158 case -2016783856: /*magnitude*/ return this.magnitude == null ? new Base[0] : new Base[] {this.magnitude}; // DecimalType 159 default: return super.getProperty(hash, name, checkValid); 160 } 161 162 } 163 164 @Override 165 public Base setProperty(int hash, String name, Base value) throws FHIRException { 166 switch (hash) { 167 case -2016783856: // magnitude 168 this.magnitude = TypeConvertor.castToDecimal(value); // DecimalType 169 return value; 170 default: return super.setProperty(hash, name, value); 171 } 172 173 } 174 175 @Override 176 public Base setProperty(String name, Base value) throws FHIRException { 177 if (name.equals("magnitude")) { 178 this.magnitude = TypeConvertor.castToDecimal(value); // DecimalType 179 } else 180 return super.setProperty(name, value); 181 return value; 182 } 183 184 @Override 185 public Base makeProperty(int hash, String name) throws FHIRException { 186 switch (hash) { 187 case -2016783856: return getMagnitudeElement(); 188 default: return super.makeProperty(hash, name); 189 } 190 191 } 192 193 @Override 194 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 195 switch (hash) { 196 case -2016783856: /*magnitude*/ return new String[] {"decimal"}; 197 default: return super.getTypesForProperty(hash, name); 198 } 199 200 } 201 202 @Override 203 public Base addChild(String name) throws FHIRException { 204 if (name.equals("magnitude")) { 205 throw new FHIRException("Cannot call addChild on a singleton property DV_COUNT.magnitude"); 206 } 207 else 208 return super.addChild(name); 209 } 210 211 public String fhirType() { 212 return "DV_COUNT"; 213 214 } 215 216 public DV_COUNT copy() { 217 DV_COUNT dst = new DV_COUNT(); 218 copyValues(dst); 219 return dst; 220 } 221 222 public void copyValues(DV_COUNT dst) { 223 super.copyValues(dst); 224 dst.magnitude = magnitude == null ? null : magnitude.copy(); 225 } 226 227 protected DV_COUNT typedCopy() { 228 return copy(); 229 } 230 231 @Override 232 public boolean equalsDeep(Base other_) { 233 if (!super.equalsDeep(other_)) 234 return false; 235 if (!(other_ instanceof DV_COUNT)) 236 return false; 237 DV_COUNT o = (DV_COUNT) other_; 238 return compareDeep(magnitude, o.magnitude, true); 239 } 240 241 @Override 242 public boolean equalsShallow(Base other_) { 243 if (!super.equalsShallow(other_)) 244 return false; 245 if (!(other_ instanceof DV_COUNT)) 246 return false; 247 DV_COUNT o = (DV_COUNT) other_; 248 return compareValues(magnitude, o.magnitude, true); 249 } 250 251 public boolean isEmpty() { 252 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(magnitude); 253 } 254 255 256} 257