
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 * Generic class defining an interval (i.e. range) of a comparable type. An interval is a contiguous subrange of a comparable base type. Used to define intervals of dates, times, quantities (whose units match) and so on. The type parameter, T, must be a descendant of the type DV_ORDERED, which is necessary (but not sufficient) for instances to be compared (strictly_comparable is also needed). 049 050Without the DV_ORDINAL class, quite a few more DV_ classes would be needed to express logical intervals, namely interval versions of all the date/time classes, and of quantity classes. Further, it allows the semantics of intervals to be stated in one place unequivocally, including the conditions for strict comparison. 051 */ 052@DatatypeDef(name="DV_ORDINAL") 053public class DV_ORDINAL extends DV_ORDERED implements ICompositeType { 054 055 /** 056 * Coded textual representation of this value in the enumeration, which may be strings made from + symbols, or other enumerations of terms such as mild, moderate, severe, or even the same number series as the values, e.g. 1, 2, 3. 057 */ 058 @Child(name = "symbol", type = {DV_CODED_TEXT.class}, order=0, min=1, max=1, modifier=false, summary=false) 059 @Description(shortDefinition="Coded textual representation of this value in the enumeration", formalDefinition="Coded textual representation of this value in the enumeration, which may be strings made from + symbols, or other enumerations of terms such as mild, moderate, severe, or even the same number series as the values, e.g. 1, 2, 3." ) 060 protected DV_CODED_TEXT symbol; 061 062 /** 063 * Value in ordered enumeration of values. Any integer value can be used. 064 */ 065 @Child(name = "value", type = {IntegerType.class}, order=1, min=1, max=1, modifier=false, summary=false) 066 @Description(shortDefinition="Value in ordered enumeration of values", formalDefinition="Value in ordered enumeration of values. Any integer value can be used." ) 067 protected IntegerType value; 068 069 private static final long serialVersionUID = -1263083887L; 070 071 /** 072 * Constructor 073 */ 074 public DV_ORDINAL() { 075 super(); 076 } 077 078 /** 079 * Constructor 080 */ 081 public DV_ORDINAL(DV_CODED_TEXT symbol, int value) { 082 super(); 083 this.setSymbol(symbol); 084 this.setValue(value); 085 } 086 087 /** 088 * @return {@link #symbol} (Coded textual representation of this value in the enumeration, which may be strings made from + symbols, or other enumerations of terms such as mild, moderate, severe, or even the same number series as the values, e.g. 1, 2, 3.) 089 */ 090 public DV_CODED_TEXT getSymbol() { 091 if (this.symbol == null) 092 if (Configuration.errorOnAutoCreate()) 093 throw new Error("Attempt to auto-create DV_ORDINAL.symbol"); 094 else if (Configuration.doAutoCreate()) 095 this.symbol = new DV_CODED_TEXT(); // cc 096 return this.symbol; 097 } 098 099 public boolean hasSymbol() { 100 return this.symbol != null && !this.symbol.isEmpty(); 101 } 102 103 /** 104 * @param value {@link #symbol} (Coded textual representation of this value in the enumeration, which may be strings made from + symbols, or other enumerations of terms such as mild, moderate, severe, or even the same number series as the values, e.g. 1, 2, 3.) 105 */ 106 public DV_ORDINAL setSymbol(DV_CODED_TEXT value) { 107 this.symbol = value; 108 return this; 109 } 110 111 /** 112 * @return {@link #value} (Value in ordered enumeration of values. Any integer value can be used.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value 113 */ 114 public IntegerType getValueElement() { 115 if (this.value == null) 116 if (Configuration.errorOnAutoCreate()) 117 throw new Error("Attempt to auto-create DV_ORDINAL.value"); 118 else if (Configuration.doAutoCreate()) 119 this.value = new IntegerType(); // bb 120 return this.value; 121 } 122 123 public boolean hasValueElement() { 124 return this.value != null && !this.value.isEmpty(); 125 } 126 127 public boolean hasValue() { 128 return this.value != null && !this.value.isEmpty(); 129 } 130 131 /** 132 * @param value {@link #value} (Value in ordered enumeration of values. Any integer value can be used.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value 133 */ 134 public DV_ORDINAL setValueElement(IntegerType value) { 135 this.value = value; 136 return this; 137 } 138 139 /** 140 * @return Value in ordered enumeration of values. Any integer value can be used. 141 */ 142 public int getValue() { 143 return this.value == null || this.value.isEmpty() ? 0 : this.value.getValue(); 144 } 145 146 /** 147 * @param value Value in ordered enumeration of values. Any integer value can be used. 148 */ 149 public DV_ORDINAL setValue(int value) { 150 if (this.value == null) 151 this.value = new IntegerType(); 152 this.value.setValue(value); 153 return this; 154 } 155 156 protected void listChildren(List<Property> children) { 157 super.listChildren(children); 158 children.add(new Property("symbol", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "Coded textual representation of this value in the enumeration, which may be strings made from + symbols, or other enumerations of terms such as mild, moderate, severe, or even the same number series as the values, e.g. 1, 2, 3.", 0, 1, symbol)); 159 children.add(new Property("value", "integer", "Value in ordered enumeration of values. Any integer value can be used.", 0, 1, value)); 160 } 161 162 @Override 163 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 164 switch (_hash) { 165 case -887523944: /*symbol*/ return new Property("symbol", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "Coded textual representation of this value in the enumeration, which may be strings made from + symbols, or other enumerations of terms such as mild, moderate, severe, or even the same number series as the values, e.g. 1, 2, 3.", 0, 1, symbol); 166 case 111972721: /*value*/ return new Property("value", "integer", "Value in ordered enumeration of values. Any integer value can be used.", 0, 1, value); 167 default: return super.getNamedProperty(_hash, _name, _checkValid); 168 } 169 170 } 171 172 @Override 173 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 174 switch (hash) { 175 case -887523944: /*symbol*/ return this.symbol == null ? new Base[0] : new Base[] {this.symbol}; // DV_CODED_TEXT 176 case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // IntegerType 177 default: return super.getProperty(hash, name, checkValid); 178 } 179 180 } 181 182 @Override 183 public Base setProperty(int hash, String name, Base value) throws FHIRException { 184 switch (hash) { 185 case -887523944: // symbol 186 this.symbol = (DV_CODED_TEXT) value; // DV_CODED_TEXT 187 return value; 188 case 111972721: // value 189 this.value = TypeConvertor.castToInteger(value); // IntegerType 190 return value; 191 default: return super.setProperty(hash, name, value); 192 } 193 194 } 195 196 @Override 197 public Base setProperty(String name, Base value) throws FHIRException { 198 if (name.equals("symbol")) { 199 this.symbol = (DV_CODED_TEXT) value; // DV_CODED_TEXT 200 } else if (name.equals("value")) { 201 this.value = TypeConvertor.castToInteger(value); // IntegerType 202 } else 203 return super.setProperty(name, value); 204 return value; 205 } 206 207 @Override 208 public Base makeProperty(int hash, String name) throws FHIRException { 209 switch (hash) { 210 case -887523944: return getSymbol(); 211 case 111972721: return getValueElement(); 212 default: return super.makeProperty(hash, name); 213 } 214 215 } 216 217 @Override 218 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 219 switch (hash) { 220 case -887523944: /*symbol*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT"}; 221 case 111972721: /*value*/ return new String[] {"integer"}; 222 default: return super.getTypesForProperty(hash, name); 223 } 224 225 } 226 227 @Override 228 public Base addChild(String name) throws FHIRException { 229 if (name.equals("symbol")) { 230 this.symbol = new DV_CODED_TEXT(); 231 return this.symbol; 232 } 233 else if (name.equals("value")) { 234 throw new FHIRException("Cannot call addChild on a singleton property DV_ORDINAL.value"); 235 } 236 else 237 return super.addChild(name); 238 } 239 240 public String fhirType() { 241 return "DV_ORDINAL"; 242 243 } 244 245 public DV_ORDINAL copy() { 246 DV_ORDINAL dst = new DV_ORDINAL(); 247 copyValues(dst); 248 return dst; 249 } 250 251 public void copyValues(DV_ORDINAL dst) { 252 super.copyValues(dst); 253 dst.symbol = symbol == null ? null : symbol.copy(); 254 dst.value = value == null ? null : value.copy(); 255 } 256 257 protected DV_ORDINAL typedCopy() { 258 return copy(); 259 } 260 261 @Override 262 public boolean equalsDeep(Base other_) { 263 if (!super.equalsDeep(other_)) 264 return false; 265 if (!(other_ instanceof DV_ORDINAL)) 266 return false; 267 DV_ORDINAL o = (DV_ORDINAL) other_; 268 return compareDeep(symbol, o.symbol, true) && compareDeep(value, o.value, true); 269 } 270 271 @Override 272 public boolean equalsShallow(Base other_) { 273 if (!super.equalsShallow(other_)) 274 return false; 275 if (!(other_ instanceof DV_ORDINAL)) 276 return false; 277 DV_ORDINAL o = (DV_ORDINAL) other_; 278 return compareValues(value, o.value, true); 279 } 280 281 public boolean isEmpty() { 282 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(symbol, value); 283 } 284 285 286} 287