001package org.hl7.fhir.dstu2.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 Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2 036import java.util.Date; 037import java.util.List; 038 039import ca.uhn.fhir.model.api.annotation.Child; 040import ca.uhn.fhir.model.api.annotation.DatatypeDef; 041import ca.uhn.fhir.model.api.annotation.Description; 042import org.hl7.fhir.instance.model.api.ICompositeType; 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=true) 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 void setProperty(String name, Base value) throws FHIRException { 236 if (name.equals("author[x]")) 237 this.author = (Type) value; // Type 238 else if (name.equals("time")) 239 this.time = castToDateTime(value); // DateTimeType 240 else if (name.equals("text")) 241 this.text = castToString(value); // StringType 242 else 243 super.setProperty(name, value); 244 } 245 246 @Override 247 public Base addChild(String name) throws FHIRException { 248 if (name.equals("authorReference")) { 249 this.author = new Reference(); 250 return this.author; 251 } 252 else if (name.equals("authorString")) { 253 this.author = new StringType(); 254 return this.author; 255 } 256 else if (name.equals("time")) { 257 throw new FHIRException("Cannot call addChild on a primitive type Annotation.time"); 258 } 259 else if (name.equals("text")) { 260 throw new FHIRException("Cannot call addChild on a primitive type Annotation.text"); 261 } 262 else 263 return super.addChild(name); 264 } 265 266 public String fhirType() { 267 return "Annotation"; 268 269 } 270 271 public Annotation copy() { 272 Annotation dst = new Annotation(); 273 copyValues(dst); 274 dst.author = author == null ? null : author.copy(); 275 dst.time = time == null ? null : time.copy(); 276 dst.text = text == null ? null : text.copy(); 277 return dst; 278 } 279 280 protected Annotation typedCopy() { 281 return copy(); 282 } 283 284 @Override 285 public boolean equalsDeep(Base other) { 286 if (!super.equalsDeep(other)) 287 return false; 288 if (!(other instanceof Annotation)) 289 return false; 290 Annotation o = (Annotation) other; 291 return compareDeep(author, o.author, true) && compareDeep(time, o.time, true) && compareDeep(text, o.text, true) 292 ; 293 } 294 295 @Override 296 public boolean equalsShallow(Base other) { 297 if (!super.equalsShallow(other)) 298 return false; 299 if (!(other instanceof Annotation)) 300 return false; 301 Annotation o = (Annotation) other; 302 return compareValues(time, o.time, true) && compareValues(text, o.text, true); 303 } 304 305 public boolean isEmpty() { 306 return super.isEmpty() && (author == null || author.isEmpty()) && (time == null || time.isEmpty()) 307 && (text == null || text.isEmpty()); 308 } 309 310 311}