
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 * Abstract class defining the concept of relative quantified 'amounts'. For relative quantities, the + and - operators are defined (unlike descendants of DV_ABSOLUTE_QUANTITY, such as the date/time types). 049 */ 050@DatatypeDef(name="DV_AMOUNT") 051public abstract class DV_AMOUNT extends DV_QUANTIFIED implements ICompositeType { 052 053 /** 054 * If True, indicates that when this object was created, accuracy was recorded as a percent value; if False, as an absolute quantity value. 055 */ 056 @Child(name = "accuracy_is_percent", type = {BooleanType.class}, order=0, min=0, max=1, modifier=false, summary=false) 057 @Description(shortDefinition="If True, indicates that when this object was created, accuracy was recorded as a percent value; if False, as an absolute quantity value", formalDefinition="If True, indicates that when this object was created, accuracy was recorded as a percent value; if False, as an absolute quantity value." ) 058 protected BooleanType accuracy_is_percent; 059 060 private static final long serialVersionUID = 421282386L; 061 062 /** 063 * Constructor 064 */ 065 public DV_AMOUNT() { 066 super(); 067 } 068 069 /** 070 * @return {@link #accuracy_is_percent} (If True, indicates that when this object was created, accuracy was recorded as a percent value; if False, as an absolute quantity value.). This is the underlying object with id, value and extensions. The accessor "getAccuracy_is_percent" gives direct access to the value 071 */ 072 public BooleanType getAccuracy_is_percentElement() { 073 if (this.accuracy_is_percent == null) 074 if (Configuration.errorOnAutoCreate()) 075 throw new Error("Attempt to auto-create DV_AMOUNT.accuracy_is_percent"); 076 else if (Configuration.doAutoCreate()) 077 this.accuracy_is_percent = new BooleanType(); // bb 078 return this.accuracy_is_percent; 079 } 080 081 public boolean hasAccuracy_is_percentElement() { 082 return this.accuracy_is_percent != null && !this.accuracy_is_percent.isEmpty(); 083 } 084 085 public boolean hasAccuracy_is_percent() { 086 return this.accuracy_is_percent != null && !this.accuracy_is_percent.isEmpty(); 087 } 088 089 /** 090 * @param value {@link #accuracy_is_percent} (If True, indicates that when this object was created, accuracy was recorded as a percent value; if False, as an absolute quantity value.). This is the underlying object with id, value and extensions. The accessor "getAccuracy_is_percent" gives direct access to the value 091 */ 092 public DV_AMOUNT setAccuracy_is_percentElement(BooleanType value) { 093 this.accuracy_is_percent = value; 094 return this; 095 } 096 097 /** 098 * @return If True, indicates that when this object was created, accuracy was recorded as a percent value; if False, as an absolute quantity value. 099 */ 100 public boolean getAccuracy_is_percent() { 101 return this.accuracy_is_percent == null || this.accuracy_is_percent.isEmpty() ? false : this.accuracy_is_percent.getValue(); 102 } 103 104 /** 105 * @param value If True, indicates that when this object was created, accuracy was recorded as a percent value; if False, as an absolute quantity value. 106 */ 107 public DV_AMOUNT setAccuracy_is_percent(boolean value) { 108 if (this.accuracy_is_percent == null) 109 this.accuracy_is_percent = new BooleanType(); 110 this.accuracy_is_percent.setValue(value); 111 return this; 112 } 113 114 protected void listChildren(List<Property> children) { 115 super.listChildren(children); 116 children.add(new Property("accuracy_is_percent", "boolean", "If True, indicates that when this object was created, accuracy was recorded as a percent value; if False, as an absolute quantity value.", 0, 1, accuracy_is_percent)); 117 } 118 119 @Override 120 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 121 switch (_hash) { 122 case 629785910: /*accuracy_is_percent*/ return new Property("accuracy_is_percent", "boolean", "If True, indicates that when this object was created, accuracy was recorded as a percent value; if False, as an absolute quantity value.", 0, 1, accuracy_is_percent); 123 default: return super.getNamedProperty(_hash, _name, _checkValid); 124 } 125 126 } 127 128 @Override 129 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 130 switch (hash) { 131 case 629785910: /*accuracy_is_percent*/ return this.accuracy_is_percent == null ? new Base[0] : new Base[] {this.accuracy_is_percent}; // BooleanType 132 default: return super.getProperty(hash, name, checkValid); 133 } 134 135 } 136 137 @Override 138 public Base setProperty(int hash, String name, Base value) throws FHIRException { 139 switch (hash) { 140 case 629785910: // accuracy_is_percent 141 this.accuracy_is_percent = TypeConvertor.castToBoolean(value); // BooleanType 142 return value; 143 default: return super.setProperty(hash, name, value); 144 } 145 146 } 147 148 @Override 149 public Base setProperty(String name, Base value) throws FHIRException { 150 if (name.equals("accuracy_is_percent")) { 151 this.accuracy_is_percent = TypeConvertor.castToBoolean(value); // BooleanType 152 } else 153 return super.setProperty(name, value); 154 return value; 155 } 156 157 @Override 158 public Base makeProperty(int hash, String name) throws FHIRException { 159 switch (hash) { 160 case 629785910: return getAccuracy_is_percentElement(); 161 default: return super.makeProperty(hash, name); 162 } 163 164 } 165 166 @Override 167 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 168 switch (hash) { 169 case 629785910: /*accuracy_is_percent*/ return new String[] {"boolean"}; 170 default: return super.getTypesForProperty(hash, name); 171 } 172 173 } 174 175 @Override 176 public Base addChild(String name) throws FHIRException { 177 if (name.equals("accuracy_is_percent")) { 178 throw new FHIRException("Cannot call addChild on a singleton property DV_AMOUNT.accuracy_is_percent"); 179 } 180 else 181 return super.addChild(name); 182 } 183 184 public String fhirType() { 185 return "DV_AMOUNT"; 186 187 } 188 189 public abstract DV_AMOUNT copy(); 190 191 public void copyValues(DV_AMOUNT dst) { 192 super.copyValues(dst); 193 dst.accuracy_is_percent = accuracy_is_percent == null ? null : accuracy_is_percent.copy(); 194 } 195 196 @Override 197 public boolean equalsDeep(Base other_) { 198 if (!super.equalsDeep(other_)) 199 return false; 200 if (!(other_ instanceof DV_AMOUNT)) 201 return false; 202 DV_AMOUNT o = (DV_AMOUNT) other_; 203 return compareDeep(accuracy_is_percent, o.accuracy_is_percent, true); 204 } 205 206 @Override 207 public boolean equalsShallow(Base other_) { 208 if (!super.equalsShallow(other_)) 209 return false; 210 if (!(other_ instanceof DV_AMOUNT)) 211 return false; 212 DV_AMOUNT o = (DV_AMOUNT) other_; 213 return compareValues(accuracy_is_percent, o.accuracy_is_percent, true); 214 } 215 216 public boolean isEmpty() { 217 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(accuracy_is_percent); 218 } 219 220 221} 222