001package org.hl7.fhir.dstu3.model; 002 003/* 004 Copyright (c) 2011+, HL7, Inc. 005 All rights reserved. 006 007 Redistribution and use in source and binary forms, with or without modification, 008 are permitted provided that the following conditions are met: 009 010 * Redistributions of source code must retain the above copyright notice, this 011 list of conditions and the following disclaimer. 012 * Redistributions in binary form must reproduce the above copyright notice, 013 this list of conditions and the following disclaimer in the documentation 014 and/or other materials provided with the distribution. 015 * Neither the name of HL7 nor the names of its contributors may be used to 016 endorse or promote products derived from this software without specific 017 prior written permission. 018 019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 020 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 021 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 022 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 023 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 024 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 025 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 026 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 027 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 028 POSSIBILITY OF SUCH DAMAGE. 029 030*/ 031 032// Generated on Mon, Apr 17, 2017 17:38-0400 for FHIR v3.0.1 033 034import java.util.*; 035 036import org.hl7.fhir.utilities.Utilities; 037import ca.uhn.fhir.model.api.annotation.Child; 038import ca.uhn.fhir.model.api.annotation.ChildOrder; 039import ca.uhn.fhir.model.api.annotation.Description; 040import ca.uhn.fhir.model.api.annotation.DatatypeDef; 041import ca.uhn.fhir.model.api.annotation.Block; 042import org.hl7.fhir.instance.model.api.*; 043import org.hl7.fhir.exceptions.FHIRException; 044/** 045 * A text note which also contains information about who made the statement and when. 046 */ 047@DatatypeDef(name="Annotation") 048public class Annotation extends Type implements ICompositeType { 049 050 /** 051 * The individual responsible for making the annotation. 052 */ 053 @Child(name = "author", type = {Practitioner.class, Patient.class, RelatedPerson.class, StringType.class}, order=0, min=0, max=1, modifier=false, summary=true) 054 @Description(shortDefinition="Individual responsible for the annotation", formalDefinition="The individual responsible for making the annotation." ) 055 protected Type author; 056 057 /** 058 * Indicates when this particular annotation was made. 059 */ 060 @Child(name = "time", type = {DateTimeType.class}, order=1, min=0, max=1, modifier=false, summary=true) 061 @Description(shortDefinition="When the annotation was made", formalDefinition="Indicates when this particular annotation was made." ) 062 protected DateTimeType time; 063 064 /** 065 * The text of the annotation. 066 */ 067 @Child(name = "text", type = {StringType.class}, order=2, min=1, max=1, modifier=false, summary=false) 068 @Description(shortDefinition="The annotation - text content", formalDefinition="The text of the annotation." ) 069 protected StringType text; 070 071 private static final long serialVersionUID = -575590381L; 072 073 /** 074 * Constructor 075 */ 076 public Annotation() { 077 super(); 078 } 079 080 /** 081 * Constructor 082 */ 083 public Annotation(StringType text) { 084 super(); 085 this.text = text; 086 } 087 088 /** 089 * @return {@link #author} (The individual responsible for making the annotation.) 090 */ 091 public Type getAuthor() { 092 return this.author; 093 } 094 095 /** 096 * @return {@link #author} (The individual responsible for making the annotation.) 097 */ 098 public Reference getAuthorReference() throws FHIRException { 099 if (!(this.author instanceof Reference)) 100 throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.author.getClass().getName()+" was encountered"); 101 return (Reference) this.author; 102 } 103 104 public boolean hasAuthorReference() { 105 return this.author instanceof Reference; 106 } 107 108 /** 109 * @return {@link #author} (The individual responsible for making the annotation.) 110 */ 111 public StringType getAuthorStringType() throws FHIRException { 112 if (!(this.author instanceof StringType)) 113 throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.author.getClass().getName()+" was encountered"); 114 return (StringType) this.author; 115 } 116 117 public boolean hasAuthorStringType() { 118 return this.author instanceof StringType; 119 } 120 121 public boolean hasAuthor() { 122 return this.author != null && !this.author.isEmpty(); 123 } 124 125 /** 126 * @param value {@link #author} (The individual responsible for making the annotation.) 127 */ 128 public Annotation setAuthor(Type value) { 129 this.author = value; 130 return this; 131 } 132 133 /** 134 * @return {@link #time} (Indicates when this particular annotation was made.). This is the underlying object with id, value and extensions. The accessor "getTime" gives direct access to the value 135 */ 136 public DateTimeType getTimeElement() { 137 if (this.time == null) 138 if (Configuration.errorOnAutoCreate()) 139 throw new Error("Attempt to auto-create Annotation.time"); 140 else if (Configuration.doAutoCreate()) 141 this.time = new DateTimeType(); // bb 142 return this.time; 143 } 144 145 public boolean hasTimeElement() { 146 return this.time != null && !this.time.isEmpty(); 147 } 148 149 public boolean hasTime() { 150 return this.time != null && !this.time.isEmpty(); 151 } 152 153 /** 154 * @param value {@link #time} (Indicates when this particular annotation was made.). This is the underlying object with id, value and extensions. The accessor "getTime" gives direct access to the value 155 */ 156 public Annotation setTimeElement(DateTimeType value) { 157 this.time = value; 158 return this; 159 } 160 161 /** 162 * @return Indicates when this particular annotation was made. 163 */ 164 public Date getTime() { 165 return this.time == null ? null : this.time.getValue(); 166 } 167 168 /** 169 * @param value Indicates when this particular annotation was made. 170 */ 171 public Annotation setTime(Date value) { 172 if (value == null) 173 this.time = null; 174 else { 175 if (this.time == null) 176 this.time = new DateTimeType(); 177 this.time.setValue(value); 178 } 179 return this; 180 } 181 182 /** 183 * @return {@link #text} (The text of the annotation.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value 184 */ 185 public StringType getTextElement() { 186 if (this.text == null) 187 if (Configuration.errorOnAutoCreate()) 188 throw new Error("Attempt to auto-create Annotation.text"); 189 else if (Configuration.doAutoCreate()) 190 this.text = new StringType(); // bb 191 return this.text; 192 } 193 194 public boolean hasTextElement() { 195 return this.text != null && !this.text.isEmpty(); 196 } 197 198 public boolean hasText() { 199 return this.text != null && !this.text.isEmpty(); 200 } 201 202 /** 203 * @param value {@link #text} (The text of the annotation.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value 204 */ 205 public Annotation setTextElement(StringType value) { 206 this.text = value; 207 return this; 208 } 209 210 /** 211 * @return The text of the annotation. 212 */ 213 public String getText() { 214 return this.text == null ? null : this.text.getValue(); 215 } 216 217 /** 218 * @param value The text of the annotation. 219 */ 220 public Annotation setText(String value) { 221 if (this.text == null) 222 this.text = new StringType(); 223 this.text.setValue(value); 224 return this; 225 } 226 227 protected void listChildren(List<Property> childrenList) { 228 super.listChildren(childrenList); 229 childrenList.add(new Property("author[x]", "Reference(Practitioner|Patient|RelatedPerson)|string", "The individual responsible for making the annotation.", 0, java.lang.Integer.MAX_VALUE, author)); 230 childrenList.add(new Property("time", "dateTime", "Indicates when this particular annotation was made.", 0, java.lang.Integer.MAX_VALUE, time)); 231 childrenList.add(new Property("text", "string", "The text of the annotation.", 0, java.lang.Integer.MAX_VALUE, text)); 232 } 233 234 @Override 235 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 236 switch (hash) { 237 case -1406328437: /*author*/ return this.author == null ? new Base[0] : new Base[] {this.author}; // Type 238 case 3560141: /*time*/ return this.time == null ? new Base[0] : new Base[] {this.time}; // DateTimeType 239 case 3556653: /*text*/ return this.text == null ? new Base[0] : new Base[] {this.text}; // StringType 240 default: return super.getProperty(hash, name, checkValid); 241 } 242 243 } 244 245 @Override 246 public Base setProperty(int hash, String name, Base value) throws FHIRException { 247 switch (hash) { 248 case -1406328437: // author 249 this.author = castToType(value); // Type 250 return value; 251 case 3560141: // time 252 this.time = castToDateTime(value); // DateTimeType 253 return value; 254 case 3556653: // text 255 this.text = castToString(value); // StringType 256 return value; 257 default: return super.setProperty(hash, name, value); 258 } 259 260 } 261 262 @Override 263 public Base setProperty(String name, Base value) throws FHIRException { 264 if (name.equals("author[x]")) { 265 this.author = castToType(value); // Type 266 } else if (name.equals("time")) { 267 this.time = castToDateTime(value); // DateTimeType 268 } else if (name.equals("text")) { 269 this.text = castToString(value); // StringType 270 } else 271 return super.setProperty(name, value); 272 return value; 273 } 274 275 @Override 276 public Base makeProperty(int hash, String name) throws FHIRException { 277 switch (hash) { 278 case 1475597077: return getAuthor(); 279 case -1406328437: return getAuthor(); 280 case 3560141: return getTimeElement(); 281 case 3556653: return getTextElement(); 282 default: return super.makeProperty(hash, name); 283 } 284 285 } 286 287 @Override 288 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 289 switch (hash) { 290 case -1406328437: /*author*/ return new String[] {"Reference", "string"}; 291 case 3560141: /*time*/ return new String[] {"dateTime"}; 292 case 3556653: /*text*/ return new String[] {"string"}; 293 default: return super.getTypesForProperty(hash, name); 294 } 295 296 } 297 298 @Override 299 public Base addChild(String name) throws FHIRException { 300 if (name.equals("authorReference")) { 301 this.author = new Reference(); 302 return this.author; 303 } 304 else if (name.equals("authorString")) { 305 this.author = new StringType(); 306 return this.author; 307 } 308 else if (name.equals("time")) { 309 throw new FHIRException("Cannot call addChild on a primitive type Annotation.time"); 310 } 311 else if (name.equals("text")) { 312 throw new FHIRException("Cannot call addChild on a primitive type Annotation.text"); 313 } 314 else 315 return super.addChild(name); 316 } 317 318 public String fhirType() { 319 return "Annotation"; 320 321 } 322 323 public Annotation copy() { 324 Annotation dst = new Annotation(); 325 copyValues(dst); 326 dst.author = author == null ? null : author.copy(); 327 dst.time = time == null ? null : time.copy(); 328 dst.text = text == null ? null : text.copy(); 329 return dst; 330 } 331 332 protected Annotation typedCopy() { 333 return copy(); 334 } 335 336 @Override 337 public boolean equalsDeep(Base other) { 338 if (!super.equalsDeep(other)) 339 return false; 340 if (!(other instanceof Annotation)) 341 return false; 342 Annotation o = (Annotation) other; 343 return compareDeep(author, o.author, true) && compareDeep(time, o.time, true) && compareDeep(text, o.text, true) 344 ; 345 } 346 347 @Override 348 public boolean equalsShallow(Base other) { 349 if (!super.equalsShallow(other)) 350 return false; 351 if (!(other instanceof Annotation)) 352 return false; 353 Annotation o = (Annotation) other; 354 return compareValues(time, o.time, true) && compareValues(text, o.text, true); 355 } 356 357 public boolean isEmpty() { 358 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(author, time, text); 359 } 360 361 362} 363