001package org.hl7.fhir.r5.model; 002 003 004/* 005 * #%L 006 * org.hl7.fhir.r5 007 * %% 008 * Copyright (C) 2014 - 2019 Health Level 7 009 * %% 010 * Licensed under the Apache License, Version 2.0 (the \"License\"); 011 * you may not use this file except in compliance with the License. 012 * You may obtain a copy of the License at 013 * 014 * http://www.apache.org/licenses/LICENSE-2.0 015 * 016 * Unless required by applicable law or agreed to in writing, software 017 * distributed under the License is distributed on an \"AS IS\" BASIS, 018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 019 * See the License for the specific language governing permissions and 020 * limitations under the License. 021 * #L% 022 */ 023 024/* 025 Copyright (c) 2011+, HL7, Inc. 026 All rights reserved. 027 028 Redistribution and use in source and binary forms, with or without modification, \ 029 are permitted provided that the following conditions are met: 030 031 * Redistributions of source code must retain the above copyright notice, this \ 032 list of conditions and the following disclaimer. 033 * Redistributions in binary form must reproduce the above copyright notice, \ 034 this list of conditions and the following disclaimer in the documentation \ 035 and/or other materials provided with the distribution. 036 * Neither the name of HL7 nor the names of its contributors may be used to 037 endorse or promote products derived from this software without specific 038 prior written permission. 039 040 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \ 041 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \ 042 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \ 043 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \ 044 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \ 045 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \ 046 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \ 047 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \ 048 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \ 049 POSSIBILITY OF SUCH DAMAGE. 050 */ 051 052// Generated on Tue, Dec 31, 2019 12:12+1100 for FHIR vcurrent 053 054import java.util.ArrayList; 055import java.util.Date; 056import java.util.List; 057import org.hl7.fhir.r5.model.Enumerations.*; 058import org.hl7.fhir.instance.model.api.IBaseDatatypeElement; 059import org.hl7.fhir.exceptions.FHIRException; 060import org.hl7.fhir.instance.model.api.ICompositeType; 061import ca.uhn.fhir.model.api.annotation.Child; 062import ca.uhn.fhir.model.api.annotation.ChildOrder; 063import ca.uhn.fhir.model.api.annotation.DatatypeDef; 064import ca.uhn.fhir.model.api.annotation.Description; 065import ca.uhn.fhir.model.api.annotation.Block; 066 067/** 068 * Base StructureDefinition for CodeableReference Type: A reference to a resource (by instance), or instead, a reference to a cencept defined in a terminology or ontology (by class). 069 */ 070@DatatypeDef(name="CodeableReference") 071public class CodeableReference extends DataType implements ICompositeType { 072 073 /** 074 * A reference to a concept - e.g. the information is identified by it's general classto the degree of precision found in the terminology. 075 */ 076 @Child(name = "concept", type = {CodeableConcept.class}, order=0, min=0, max=1, modifier=false, summary=true) 077 @Description(shortDefinition="Reference to a concept (by class)", formalDefinition="A reference to a concept - e.g. the information is identified by it's general classto the degree of precision found in the terminology." ) 078 protected CodeableConcept concept; 079 080 /** 081 * A reference to a resource the provides exact details about the information being referenced. 082 */ 083 @Child(name = "reference", type = {Reference.class}, order=1, min=0, max=1, modifier=false, summary=true) 084 @Description(shortDefinition="Reference to a resource (by instance)", formalDefinition="A reference to a resource the provides exact details about the information being referenced." ) 085 protected Reference reference; 086 087 private static final long serialVersionUID = 2070287445L; 088 089 /** 090 * Constructor 091 */ 092 public CodeableReference() { 093 super(); 094 } 095 096 /** 097 * @return {@link #concept} (A reference to a concept - e.g. the information is identified by it's general classto the degree of precision found in the terminology.) 098 */ 099 public CodeableConcept getConcept() { 100 if (this.concept == null) 101 if (Configuration.errorOnAutoCreate()) 102 throw new Error("Attempt to auto-create CodeableReference.concept"); 103 else if (Configuration.doAutoCreate()) 104 this.concept = new CodeableConcept(); // cc 105 return this.concept; 106 } 107 108 public boolean hasConcept() { 109 return this.concept != null && !this.concept.isEmpty(); 110 } 111 112 /** 113 * @param value {@link #concept} (A reference to a concept - e.g. the information is identified by it's general classto the degree of precision found in the terminology.) 114 */ 115 public CodeableReference setConcept(CodeableConcept value) { 116 this.concept = value; 117 return this; 118 } 119 120 /** 121 * @return {@link #reference} (A reference to a resource the provides exact details about the information being referenced.) 122 */ 123 public Reference getReference() { 124 if (this.reference == null) 125 if (Configuration.errorOnAutoCreate()) 126 throw new Error("Attempt to auto-create CodeableReference.reference"); 127 else if (Configuration.doAutoCreate()) 128 this.reference = new Reference(); // cc 129 return this.reference; 130 } 131 132 public boolean hasReference() { 133 return this.reference != null && !this.reference.isEmpty(); 134 } 135 136 /** 137 * @param value {@link #reference} (A reference to a resource the provides exact details about the information being referenced.) 138 */ 139 public CodeableReference setReference(Reference value) { 140 this.reference = value; 141 return this; 142 } 143 144 protected void listChildren(List<Property> children) { 145 super.listChildren(children); 146 children.add(new Property("concept", "CodeableConcept", "A reference to a concept - e.g. the information is identified by it's general classto the degree of precision found in the terminology.", 0, 1, concept)); 147 children.add(new Property("reference", "Reference", "A reference to a resource the provides exact details about the information being referenced.", 0, 1, reference)); 148 } 149 150 @Override 151 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 152 switch (_hash) { 153 case 951024232: /*concept*/ return new Property("concept", "CodeableConcept", "A reference to a concept - e.g. the information is identified by it's general classto the degree of precision found in the terminology.", 0, 1, concept); 154 case -925155509: /*reference*/ return new Property("reference", "Reference", "A reference to a resource the provides exact details about the information being referenced.", 0, 1, reference); 155 default: return super.getNamedProperty(_hash, _name, _checkValid); 156 } 157 158 } 159 160 @Override 161 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 162 switch (hash) { 163 case 951024232: /*concept*/ return this.concept == null ? new Base[0] : new Base[] {this.concept}; // CodeableConcept 164 case -925155509: /*reference*/ return this.reference == null ? new Base[0] : new Base[] {this.reference}; // Reference 165 default: return super.getProperty(hash, name, checkValid); 166 } 167 168 } 169 170 @Override 171 public Base setProperty(int hash, String name, Base value) throws FHIRException { 172 switch (hash) { 173 case 951024232: // concept 174 this.concept = TypeConvertor.castToCodeableConcept(value); // CodeableConcept 175 return value; 176 case -925155509: // reference 177 this.reference = TypeConvertor.castToReference(value); // Reference 178 return value; 179 default: return super.setProperty(hash, name, value); 180 } 181 182 } 183 184 @Override 185 public Base setProperty(String name, Base value) throws FHIRException { 186 if (name.equals("concept")) { 187 this.concept = TypeConvertor.castToCodeableConcept(value); // CodeableConcept 188 } else if (name.equals("reference")) { 189 this.reference = TypeConvertor.castToReference(value); // Reference 190 } else 191 return super.setProperty(name, value); 192 return value; 193 } 194 195 @Override 196 public Base makeProperty(int hash, String name) throws FHIRException { 197 switch (hash) { 198 case 951024232: return getConcept(); 199 case -925155509: return getReference(); 200 default: return super.makeProperty(hash, name); 201 } 202 203 } 204 205 @Override 206 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 207 switch (hash) { 208 case 951024232: /*concept*/ return new String[] {"CodeableConcept"}; 209 case -925155509: /*reference*/ return new String[] {"Reference"}; 210 default: return super.getTypesForProperty(hash, name); 211 } 212 213 } 214 215 @Override 216 public Base addChild(String name) throws FHIRException { 217 if (name.equals("concept")) { 218 this.concept = new CodeableConcept(); 219 return this.concept; 220 } 221 else if (name.equals("reference")) { 222 this.reference = new Reference(); 223 return this.reference; 224 } 225 else 226 return super.addChild(name); 227 } 228 229 public String fhirType() { 230 return "CodeableReference"; 231 232 } 233 234 public CodeableReference copy() { 235 CodeableReference dst = new CodeableReference(); 236 copyValues(dst); 237 return dst; 238 } 239 240 public void copyValues(CodeableReference dst) { 241 super.copyValues(dst); 242 dst.concept = concept == null ? null : concept.copy(); 243 dst.reference = reference == null ? null : reference.copy(); 244 } 245 246 protected CodeableReference typedCopy() { 247 return copy(); 248 } 249 250 @Override 251 public boolean equalsDeep(Base other_) { 252 if (!super.equalsDeep(other_)) 253 return false; 254 if (!(other_ instanceof CodeableReference)) 255 return false; 256 CodeableReference o = (CodeableReference) other_; 257 return compareDeep(concept, o.concept, true) && compareDeep(reference, o.reference, true); 258 } 259 260 @Override 261 public boolean equalsShallow(Base other_) { 262 if (!super.equalsShallow(other_)) 263 return false; 264 if (!(other_ instanceof CodeableReference)) 265 return false; 266 CodeableReference o = (CodeableReference) other_; 267 return true; 268 } 269 270 public boolean isEmpty() { 271 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(concept, reference); 272 } 273 274 275} 276