001package org.hl7.fhir.dstu2.model; 002 003/*- 004 * #%L 005 * org.hl7.fhir.dstu2 006 * %% 007 * Copyright (C) 2014 - 2019 Health Level 7 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 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 053// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2 054import java.util.Date; 055import java.util.List; 056 057import ca.uhn.fhir.model.api.annotation.Child; 058import ca.uhn.fhir.model.api.annotation.DatatypeDef; 059import ca.uhn.fhir.model.api.annotation.Description; 060import org.hl7.fhir.instance.model.api.ICompositeType; 061import org.hl7.fhir.exceptions.FHIRException; 062/** 063 * A text note which also contains information about who made the statement and when. 064 */ 065@DatatypeDef(name="Annotation") 066public class Annotation extends Type implements ICompositeType { 067 068 /** 069 * The individual responsible for making the annotation. 070 */ 071 @Child(name = "author", type = {Practitioner.class, Patient.class, RelatedPerson.class, StringType.class}, order=0, min=0, max=1, modifier=false, summary=true) 072 @Description(shortDefinition="Individual responsible for the annotation", formalDefinition="The individual responsible for making the annotation." ) 073 protected Type author; 074 075 /** 076 * Indicates when this particular annotation was made. 077 */ 078 @Child(name = "time", type = {DateTimeType.class}, order=1, min=0, max=1, modifier=false, summary=true) 079 @Description(shortDefinition="When the annotation was made", formalDefinition="Indicates when this particular annotation was made." ) 080 protected DateTimeType time; 081 082 /** 083 * The text of the annotation. 084 */ 085 @Child(name = "text", type = {StringType.class}, order=2, min=1, max=1, modifier=false, summary=true) 086 @Description(shortDefinition="The annotation - text content", formalDefinition="The text of the annotation." ) 087 protected StringType text; 088 089 private static final long serialVersionUID = -575590381L; 090 091 /* 092 * Constructor 093 */ 094 public Annotation() { 095 super(); 096 } 097 098 /* 099 * Constructor 100 */ 101 public Annotation(StringType text) { 102 super(); 103 this.text = text; 104 } 105 106 /** 107 * @return {@link #author} (The individual responsible for making the annotation.) 108 */ 109 public Type getAuthor() { 110 return this.author; 111 } 112 113 /** 114 * @return {@link #author} (The individual responsible for making the annotation.) 115 */ 116 public Reference getAuthorReference() throws FHIRException { 117 if (!(this.author instanceof Reference)) 118 throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.author.getClass().getName()+" was encountered"); 119 return (Reference) this.author; 120 } 121 122 public boolean hasAuthorReference() { 123 return this.author instanceof Reference; 124 } 125 126 /** 127 * @return {@link #author} (The individual responsible for making the annotation.) 128 */ 129 public StringType getAuthorStringType() throws FHIRException { 130 if (!(this.author instanceof StringType)) 131 throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.author.getClass().getName()+" was encountered"); 132 return (StringType) this.author; 133 } 134 135 public boolean hasAuthorStringType() { 136 return this.author instanceof StringType; 137 } 138 139 public boolean hasAuthor() { 140 return this.author != null && !this.author.isEmpty(); 141 } 142 143 /** 144 * @param value {@link #author} (The individual responsible for making the annotation.) 145 */ 146 public Annotation setAuthor(Type value) { 147 this.author = value; 148 return this; 149 } 150 151 /** 152 * @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 153 */ 154 public DateTimeType getTimeElement() { 155 if (this.time == null) 156 if (Configuration.errorOnAutoCreate()) 157 throw new Error("Attempt to auto-create Annotation.time"); 158 else if (Configuration.doAutoCreate()) 159 this.time = new DateTimeType(); // bb 160 return this.time; 161 } 162 163 public boolean hasTimeElement() { 164 return this.time != null && !this.time.isEmpty(); 165 } 166 167 public boolean hasTime() { 168 return this.time != null && !this.time.isEmpty(); 169 } 170 171 /** 172 * @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 173 */ 174 public Annotation setTimeElement(DateTimeType value) { 175 this.time = value; 176 return this; 177 } 178 179 /** 180 * @return Indicates when this particular annotation was made. 181 */ 182 public Date getTime() { 183 return this.time == null ? null : this.time.getValue(); 184 } 185 186 /** 187 * @param value Indicates when this particular annotation was made. 188 */ 189 public Annotation setTime(Date value) { 190 if (value == null) 191 this.time = null; 192 else { 193 if (this.time == null) 194 this.time = new DateTimeType(); 195 this.time.setValue(value); 196 } 197 return this; 198 } 199 200 /** 201 * @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 202 */ 203 public StringType getTextElement() { 204 if (this.text == null) 205 if (Configuration.errorOnAutoCreate()) 206 throw new Error("Attempt to auto-create Annotation.text"); 207 else if (Configuration.doAutoCreate()) 208 this.text = new StringType(); // bb 209 return this.text; 210 } 211 212 public boolean hasTextElement() { 213 return this.text != null && !this.text.isEmpty(); 214 } 215 216 public boolean hasText() { 217 return this.text != null && !this.text.isEmpty(); 218 } 219 220 /** 221 * @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 222 */ 223 public Annotation setTextElement(StringType value) { 224 this.text = value; 225 return this; 226 } 227 228 /** 229 * @return The text of the annotation. 230 */ 231 public String getText() { 232 return this.text == null ? null : this.text.getValue(); 233 } 234 235 /** 236 * @param value The text of the annotation. 237 */ 238 public Annotation setText(String value) { 239 if (this.text == null) 240 this.text = new StringType(); 241 this.text.setValue(value); 242 return this; 243 } 244 245 protected void listChildren(List<Property> childrenList) { 246 super.listChildren(childrenList); 247 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)); 248 childrenList.add(new Property("time", "dateTime", "Indicates when this particular annotation was made.", 0, java.lang.Integer.MAX_VALUE, time)); 249 childrenList.add(new Property("text", "string", "The text of the annotation.", 0, java.lang.Integer.MAX_VALUE, text)); 250 } 251 252 @Override 253 public void setProperty(String name, Base value) throws FHIRException { 254 if (name.equals("author[x]")) 255 this.author = (Type) value; // Type 256 else if (name.equals("time")) 257 this.time = castToDateTime(value); // DateTimeType 258 else if (name.equals("text")) 259 this.text = castToString(value); // StringType 260 else 261 super.setProperty(name, value); 262 } 263 264 @Override 265 public Base addChild(String name) throws FHIRException { 266 if (name.equals("authorReference")) { 267 this.author = new Reference(); 268 return this.author; 269 } 270 else if (name.equals("authorString")) { 271 this.author = new StringType(); 272 return this.author; 273 } 274 else if (name.equals("time")) { 275 throw new FHIRException("Cannot call addChild on a primitive type Annotation.time"); 276 } 277 else if (name.equals("text")) { 278 throw new FHIRException("Cannot call addChild on a primitive type Annotation.text"); 279 } 280 else 281 return super.addChild(name); 282 } 283 284 public String fhirType() { 285 return "Annotation"; 286 287 } 288 289 public Annotation copy() { 290 Annotation dst = new Annotation(); 291 copyValues(dst); 292 dst.author = author == null ? null : author.copy(); 293 dst.time = time == null ? null : time.copy(); 294 dst.text = text == null ? null : text.copy(); 295 return dst; 296 } 297 298 protected Annotation typedCopy() { 299 return copy(); 300 } 301 302 @Override 303 public boolean equalsDeep(Base other) { 304 if (!super.equalsDeep(other)) 305 return false; 306 if (!(other instanceof Annotation)) 307 return false; 308 Annotation o = (Annotation) other; 309 return compareDeep(author, o.author, true) && compareDeep(time, o.time, true) && compareDeep(text, o.text, true) 310 ; 311 } 312 313 @Override 314 public boolean equalsShallow(Base other) { 315 if (!super.equalsShallow(other)) 316 return false; 317 if (!(other instanceof Annotation)) 318 return false; 319 Annotation o = (Annotation) other; 320 return compareValues(time, o.time, true) && compareValues(text, o.text, true); 321 } 322 323 public boolean isEmpty() { 324 return super.isEmpty() && (author == null || author.isEmpty()) && (time == null || time.isEmpty()) 325 && (text == null || text.isEmpty()); 326 } 327 328 329} 330