
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.utilities.Utilities; 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 * 050 */ 051@DatatypeDef(name="WebTemplateTermBinding") 052public class WebTemplateTermBinding extends LogicalBase implements ICompositeType { 053 054 /** 055 * 056 */ 057 @Child(name = "code", type = {CodeType.class}, order=0, min=1, max=1, modifier=false, summary=false) 058 @Description(shortDefinition="Which terminology is bound", formalDefinition="" ) 059 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="https://specifications.openehr.org/fhir/valueset-term-binding-type") 060 protected CodeType code; 061 062 /** 063 * 064 */ 065 @Child(name = "value", type = {WebTemplateTermBindingValue.class}, order=1, min=1, max=1, modifier=false, summary=false) 066 @Description(shortDefinition="The binding", formalDefinition="" ) 067 protected WebTemplateTermBindingValue value; 068 069 private static final long serialVersionUID = -1040833865L; 070 071 /** 072 * Constructor 073 */ 074 public WebTemplateTermBinding() { 075 super(); 076 } 077 078 /** 079 * Constructor 080 */ 081 public WebTemplateTermBinding(String code, WebTemplateTermBindingValue value) { 082 super(); 083 this.setCode(code); 084 this.setValue(value); 085 } 086 087 /** 088 * @return {@link #code} (). This is the underlying object with id, value and extensions. The accessor "getCode" gives direct access to the value 089 */ 090 public CodeType getCodeElement() { 091 if (this.code == null) 092 if (Configuration.errorOnAutoCreate()) 093 throw new Error("Attempt to auto-create WebTemplateTermBinding.code"); 094 else if (Configuration.doAutoCreate()) 095 this.code = new CodeType(); // bb 096 return this.code; 097 } 098 099 public boolean hasCodeElement() { 100 return this.code != null && !this.code.isEmpty(); 101 } 102 103 public boolean hasCode() { 104 return this.code != null && !this.code.isEmpty(); 105 } 106 107 /** 108 * @param value {@link #code} (). This is the underlying object with id, value and extensions. The accessor "getCode" gives direct access to the value 109 */ 110 public WebTemplateTermBinding setCodeElement(CodeType value) { 111 this.code = value; 112 return this; 113 } 114 115 /** 116 * @return 117 */ 118 public String getCode() { 119 return this.code == null ? null : this.code.getValue(); 120 } 121 122 /** 123 * @param value 124 */ 125 public WebTemplateTermBinding setCode(String value) { 126 if (this.code == null) 127 this.code = new CodeType(); 128 this.code.setValue(value); 129 return this; 130 } 131 132 /** 133 * @return {@link #value} () 134 */ 135 public WebTemplateTermBindingValue getValue() { 136 if (this.value == null) 137 if (Configuration.errorOnAutoCreate()) 138 throw new Error("Attempt to auto-create WebTemplateTermBinding.value"); 139 else if (Configuration.doAutoCreate()) 140 this.value = new WebTemplateTermBindingValue(); // cc 141 return this.value; 142 } 143 144 public boolean hasValue() { 145 return this.value != null && !this.value.isEmpty(); 146 } 147 148 /** 149 * @param value {@link #value} () 150 */ 151 public WebTemplateTermBinding setValue(WebTemplateTermBindingValue value) { 152 this.value = value; 153 return this; 154 } 155 156 protected void listChildren(List<Property> children) { 157 super.listChildren(children); 158 children.add(new Property("code", "code", "", 0, 1, code)); 159 children.add(new Property("value", "http://openehr.org/fhir/StructureDefinition/WebTemplateTermBindingValue", "", 0, 1, value)); 160 } 161 162 @Override 163 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 164 switch (_hash) { 165 case 3059181: /*code*/ return new Property("code", "code", "", 0, 1, code); 166 case 111972721: /*value*/ return new Property("value", "http://openehr.org/fhir/StructureDefinition/WebTemplateTermBindingValue", "", 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 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeType 176 case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // WebTemplateTermBindingValue 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 3059181: // code 186 this.code = TypeConvertor.castToCode(value); // CodeType 187 return value; 188 case 111972721: // value 189 this.value = (WebTemplateTermBindingValue) value; // WebTemplateTermBindingValue 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("code")) { 199 this.code = TypeConvertor.castToCode(value); // CodeType 200 } else if (name.equals("value")) { 201 this.value = (WebTemplateTermBindingValue) value; // WebTemplateTermBindingValue 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 3059181: return getCodeElement(); 211 case 111972721: return getValue(); 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 3059181: /*code*/ return new String[] {"code"}; 221 case 111972721: /*value*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/WebTemplateTermBindingValue"}; 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("code")) { 230 throw new FHIRException("Cannot call addChild on a singleton property WebTemplateTermBinding.code"); 231 } 232 else if (name.equals("value")) { 233 this.value = new WebTemplateTermBindingValue(); 234 return this.value; 235 } 236 else 237 return super.addChild(name); 238 } 239 240 public String fhirType() { 241 return "WebTemplateTermBinding"; 242 243 } 244 245 public WebTemplateTermBinding copy() { 246 WebTemplateTermBinding dst = new WebTemplateTermBinding(); 247 copyValues(dst); 248 return dst; 249 } 250 251 public void copyValues(WebTemplateTermBinding dst) { 252 super.copyValues(dst); 253 dst.code = code == null ? null : code.copy(); 254 dst.value = value == null ? null : value.copy(); 255 } 256 257 protected WebTemplateTermBinding 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 WebTemplateTermBinding)) 266 return false; 267 WebTemplateTermBinding o = (WebTemplateTermBinding) other_; 268 return compareDeep(code, o.code, 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 WebTemplateTermBinding)) 276 return false; 277 WebTemplateTermBinding o = (WebTemplateTermBinding) other_; 278 return compareValues(code, o.code, true); 279 } 280 281 public boolean isEmpty() { 282 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(code, value); 283 } 284 285 286} 287