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