001package org.hl7.fhir.r5.model; 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.model.Enumerations.*; 038import org.hl7.fhir.instance.model.api.IBaseDatatypeElement; 039import org.hl7.fhir.exceptions.FHIRException; 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 * RatioRange Type: A range of ratios expressed as a low and high numerator and a denominator. 049 */ 050@DatatypeDef(name="RatioRange") 051public class RatioRange extends DataType implements ICompositeType { 052 053 /** 054 * The value of the low limit numerator. 055 */ 056 @Child(name = "lowNumerator", type = {Quantity.class}, order=0, min=0, max=1, modifier=false, summary=true) 057 @Description(shortDefinition="Low Numerator limit", formalDefinition="The value of the low limit numerator." ) 058 protected Quantity lowNumerator; 059 060 /** 061 * The value of the high limit numerator. 062 */ 063 @Child(name = "highNumerator", type = {Quantity.class}, order=1, min=0, max=1, modifier=false, summary=true) 064 @Description(shortDefinition="High Numerator limit", formalDefinition="The value of the high limit numerator." ) 065 protected Quantity highNumerator; 066 067 /** 068 * The value of the denominator. 069 */ 070 @Child(name = "denominator", type = {Quantity.class}, order=2, min=0, max=1, modifier=false, summary=true) 071 @Description(shortDefinition="Denominator value", formalDefinition="The value of the denominator." ) 072 protected Quantity denominator; 073 074 private static final long serialVersionUID = -1691080287L; 075 076 /** 077 * Constructor 078 */ 079 public RatioRange() { 080 super(); 081 } 082 083 /** 084 * @return {@link #lowNumerator} (The value of the low limit numerator.) 085 */ 086 public Quantity getLowNumerator() { 087 if (this.lowNumerator == null) 088 if (Configuration.errorOnAutoCreate()) 089 throw new Error("Attempt to auto-create RatioRange.lowNumerator"); 090 else if (Configuration.doAutoCreate()) 091 this.lowNumerator = new Quantity(); // cc 092 return this.lowNumerator; 093 } 094 095 public boolean hasLowNumerator() { 096 return this.lowNumerator != null && !this.lowNumerator.isEmpty(); 097 } 098 099 /** 100 * @param value {@link #lowNumerator} (The value of the low limit numerator.) 101 */ 102 public RatioRange setLowNumerator(Quantity value) { 103 this.lowNumerator = value; 104 return this; 105 } 106 107 /** 108 * @return {@link #highNumerator} (The value of the high limit numerator.) 109 */ 110 public Quantity getHighNumerator() { 111 if (this.highNumerator == null) 112 if (Configuration.errorOnAutoCreate()) 113 throw new Error("Attempt to auto-create RatioRange.highNumerator"); 114 else if (Configuration.doAutoCreate()) 115 this.highNumerator = new Quantity(); // cc 116 return this.highNumerator; 117 } 118 119 public boolean hasHighNumerator() { 120 return this.highNumerator != null && !this.highNumerator.isEmpty(); 121 } 122 123 /** 124 * @param value {@link #highNumerator} (The value of the high limit numerator.) 125 */ 126 public RatioRange setHighNumerator(Quantity value) { 127 this.highNumerator = value; 128 return this; 129 } 130 131 /** 132 * @return {@link #denominator} (The value of the denominator.) 133 */ 134 public Quantity getDenominator() { 135 if (this.denominator == null) 136 if (Configuration.errorOnAutoCreate()) 137 throw new Error("Attempt to auto-create RatioRange.denominator"); 138 else if (Configuration.doAutoCreate()) 139 this.denominator = new Quantity(); // cc 140 return this.denominator; 141 } 142 143 public boolean hasDenominator() { 144 return this.denominator != null && !this.denominator.isEmpty(); 145 } 146 147 /** 148 * @param value {@link #denominator} (The value of the denominator.) 149 */ 150 public RatioRange setDenominator(Quantity value) { 151 this.denominator = value; 152 return this; 153 } 154 155 protected void listChildren(List<Property> children) { 156 super.listChildren(children); 157 children.add(new Property("lowNumerator", "Quantity", "The value of the low limit numerator.", 0, 1, lowNumerator)); 158 children.add(new Property("highNumerator", "Quantity", "The value of the high limit numerator.", 0, 1, highNumerator)); 159 children.add(new Property("denominator", "Quantity", "The value of the denominator.", 0, 1, denominator)); 160 } 161 162 @Override 163 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 164 switch (_hash) { 165 case 1003958677: /*lowNumerator*/ return new Property("lowNumerator", "Quantity", "The value of the low limit numerator.", 0, 1, lowNumerator); 166 case 311013127: /*highNumerator*/ return new Property("highNumerator", "Quantity", "The value of the high limit numerator.", 0, 1, highNumerator); 167 case -1983274394: /*denominator*/ return new Property("denominator", "Quantity", "The value of the denominator.", 0, 1, denominator); 168 default: return super.getNamedProperty(_hash, _name, _checkValid); 169 } 170 171 } 172 173 @Override 174 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 175 switch (hash) { 176 case 1003958677: /*lowNumerator*/ return this.lowNumerator == null ? new Base[0] : new Base[] {this.lowNumerator}; // Quantity 177 case 311013127: /*highNumerator*/ return this.highNumerator == null ? new Base[0] : new Base[] {this.highNumerator}; // Quantity 178 case -1983274394: /*denominator*/ return this.denominator == null ? new Base[0] : new Base[] {this.denominator}; // Quantity 179 default: return super.getProperty(hash, name, checkValid); 180 } 181 182 } 183 184 @Override 185 public Base setProperty(int hash, String name, Base value) throws FHIRException { 186 switch (hash) { 187 case 1003958677: // lowNumerator 188 this.lowNumerator = TypeConvertor.castToQuantity(value); // Quantity 189 return value; 190 case 311013127: // highNumerator 191 this.highNumerator = TypeConvertor.castToQuantity(value); // Quantity 192 return value; 193 case -1983274394: // denominator 194 this.denominator = TypeConvertor.castToQuantity(value); // Quantity 195 return value; 196 default: return super.setProperty(hash, name, value); 197 } 198 199 } 200 201 @Override 202 public Base setProperty(String name, Base value) throws FHIRException { 203 if (name.equals("lowNumerator")) { 204 this.lowNumerator = TypeConvertor.castToQuantity(value); // Quantity 205 } else if (name.equals("highNumerator")) { 206 this.highNumerator = TypeConvertor.castToQuantity(value); // Quantity 207 } else if (name.equals("denominator")) { 208 this.denominator = TypeConvertor.castToQuantity(value); // Quantity 209 } else 210 return super.setProperty(name, value); 211 return value; 212 } 213 214 @Override 215 public Base makeProperty(int hash, String name) throws FHIRException { 216 switch (hash) { 217 case 1003958677: return getLowNumerator(); 218 case 311013127: return getHighNumerator(); 219 case -1983274394: return getDenominator(); 220 default: return super.makeProperty(hash, name); 221 } 222 223 } 224 225 @Override 226 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 227 switch (hash) { 228 case 1003958677: /*lowNumerator*/ return new String[] {"Quantity"}; 229 case 311013127: /*highNumerator*/ return new String[] {"Quantity"}; 230 case -1983274394: /*denominator*/ return new String[] {"Quantity"}; 231 default: return super.getTypesForProperty(hash, name); 232 } 233 234 } 235 236 @Override 237 public Base addChild(String name) throws FHIRException { 238 if (name.equals("lowNumerator")) { 239 this.lowNumerator = new Quantity(); 240 return this.lowNumerator; 241 } 242 else if (name.equals("highNumerator")) { 243 this.highNumerator = new Quantity(); 244 return this.highNumerator; 245 } 246 else if (name.equals("denominator")) { 247 this.denominator = new Quantity(); 248 return this.denominator; 249 } 250 else 251 return super.addChild(name); 252 } 253 254 public String fhirType() { 255 return "RatioRange"; 256 257 } 258 259 public RatioRange copy() { 260 RatioRange dst = new RatioRange(); 261 copyValues(dst); 262 return dst; 263 } 264 265 public void copyValues(RatioRange dst) { 266 super.copyValues(dst); 267 dst.lowNumerator = lowNumerator == null ? null : lowNumerator.copy(); 268 dst.highNumerator = highNumerator == null ? null : highNumerator.copy(); 269 dst.denominator = denominator == null ? null : denominator.copy(); 270 } 271 272 protected RatioRange typedCopy() { 273 return copy(); 274 } 275 276 @Override 277 public boolean equalsDeep(Base other_) { 278 if (!super.equalsDeep(other_)) 279 return false; 280 if (!(other_ instanceof RatioRange)) 281 return false; 282 RatioRange o = (RatioRange) other_; 283 return compareDeep(lowNumerator, o.lowNumerator, true) && compareDeep(highNumerator, o.highNumerator, true) 284 && compareDeep(denominator, o.denominator, true); 285 } 286 287 @Override 288 public boolean equalsShallow(Base other_) { 289 if (!super.equalsShallow(other_)) 290 return false; 291 if (!(other_ instanceof RatioRange)) 292 return false; 293 RatioRange o = (RatioRange) other_; 294 return true; 295 } 296 297 public boolean isEmpty() { 298 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(lowNumerator, highNumerator 299 , denominator); 300 } 301 302 303} 304