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