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.*; 035import org.hl7.fhir.utilities.xhtml.XhtmlNode; 036 037import org.hl7.fhir.utilities.Utilities; 038import ca.uhn.fhir.model.api.annotation.Child; 039import ca.uhn.fhir.model.api.annotation.ChildOrder; 040import ca.uhn.fhir.model.api.annotation.Description; 041import ca.uhn.fhir.model.api.annotation.DatatypeDef; 042import ca.uhn.fhir.model.api.annotation.Block; 043import org.hl7.fhir.instance.model.api.*; 044import org.hl7.fhir.exceptions.FHIRException; 045/** 046 * A human-readable formatted text, including images. 047 */ 048@DatatypeDef(name="Narrative") 049public class Narrative extends BaseNarrative implements INarrative { 050 051 public enum NarrativeStatus { 052 /** 053 * The contents of the narrative are entirely generated from the structured data in the content. 054 */ 055 GENERATED, 056 /** 057 * The contents of the narrative are entirely generated from the structured data in the content and some of the content is generated from extensions 058 */ 059 EXTENSIONS, 060 /** 061 * The contents of the narrative may contain additional information not found in the structured data. Note that there is no computable way to determine what the extra information is, other than by human inspection 062 */ 063 ADDITIONAL, 064 /** 065 * The contents of the narrative are some equivalent of "No human-readable text provided in this case" 066 */ 067 EMPTY, 068 /** 069 * added to help the parsers with the generic types 070 */ 071 NULL; 072 public static NarrativeStatus fromCode(String codeString) throws FHIRException { 073 if (codeString == null || "".equals(codeString)) 074 return null; 075 if ("generated".equals(codeString)) 076 return GENERATED; 077 if ("extensions".equals(codeString)) 078 return EXTENSIONS; 079 if ("additional".equals(codeString)) 080 return ADDITIONAL; 081 if ("empty".equals(codeString)) 082 return EMPTY; 083 if (Configuration.isAcceptInvalidEnums()) 084 return null; 085 else 086 throw new FHIRException("Unknown NarrativeStatus code '"+codeString+"'"); 087 } 088 public String toCode() { 089 switch (this) { 090 case GENERATED: return "generated"; 091 case EXTENSIONS: return "extensions"; 092 case ADDITIONAL: return "additional"; 093 case EMPTY: return "empty"; 094 default: return "?"; 095 } 096 } 097 public String getSystem() { 098 switch (this) { 099 case GENERATED: return "http://hl7.org/fhir/narrative-status"; 100 case EXTENSIONS: return "http://hl7.org/fhir/narrative-status"; 101 case ADDITIONAL: return "http://hl7.org/fhir/narrative-status"; 102 case EMPTY: return "http://hl7.org/fhir/narrative-status"; 103 default: return "?"; 104 } 105 } 106 public String getDefinition() { 107 switch (this) { 108 case GENERATED: return "The contents of the narrative are entirely generated from the structured data in the content."; 109 case EXTENSIONS: return "The contents of the narrative are entirely generated from the structured data in the content and some of the content is generated from extensions"; 110 case ADDITIONAL: return "The contents of the narrative may contain additional information not found in the structured data. Note that there is no computable way to determine what the extra information is, other than by human inspection"; 111 case EMPTY: return "The contents of the narrative are some equivalent of \"No human-readable text provided in this case\""; 112 default: return "?"; 113 } 114 } 115 public String getDisplay() { 116 switch (this) { 117 case GENERATED: return "Generated"; 118 case EXTENSIONS: return "Extensions"; 119 case ADDITIONAL: return "Additional"; 120 case EMPTY: return "Empty"; 121 default: return "?"; 122 } 123 } 124 } 125 126 public static class NarrativeStatusEnumFactory implements EnumFactory<NarrativeStatus> { 127 public NarrativeStatus fromCode(String codeString) throws IllegalArgumentException { 128 if (codeString == null || "".equals(codeString)) 129 if (codeString == null || "".equals(codeString)) 130 return null; 131 if ("generated".equals(codeString)) 132 return NarrativeStatus.GENERATED; 133 if ("extensions".equals(codeString)) 134 return NarrativeStatus.EXTENSIONS; 135 if ("additional".equals(codeString)) 136 return NarrativeStatus.ADDITIONAL; 137 if ("empty".equals(codeString)) 138 return NarrativeStatus.EMPTY; 139 throw new IllegalArgumentException("Unknown NarrativeStatus code '"+codeString+"'"); 140 } 141 public Enumeration<NarrativeStatus> fromType(Base code) throws FHIRException { 142 if (code == null) 143 return null; 144 if (code.isEmpty()) 145 return new Enumeration<NarrativeStatus>(this); 146 String codeString = ((PrimitiveType) code).asStringValue(); 147 if (codeString == null || "".equals(codeString)) 148 return null; 149 if ("generated".equals(codeString)) 150 return new Enumeration<NarrativeStatus>(this, NarrativeStatus.GENERATED); 151 if ("extensions".equals(codeString)) 152 return new Enumeration<NarrativeStatus>(this, NarrativeStatus.EXTENSIONS); 153 if ("additional".equals(codeString)) 154 return new Enumeration<NarrativeStatus>(this, NarrativeStatus.ADDITIONAL); 155 if ("empty".equals(codeString)) 156 return new Enumeration<NarrativeStatus>(this, NarrativeStatus.EMPTY); 157 throw new FHIRException("Unknown NarrativeStatus code '"+codeString+"'"); 158 } 159 public String toCode(NarrativeStatus code) { 160 if (code == NarrativeStatus.GENERATED) 161 return "generated"; 162 if (code == NarrativeStatus.EXTENSIONS) 163 return "extensions"; 164 if (code == NarrativeStatus.ADDITIONAL) 165 return "additional"; 166 if (code == NarrativeStatus.EMPTY) 167 return "empty"; 168 return "?"; 169 } 170 public String toSystem(NarrativeStatus code) { 171 return code.getSystem(); 172 } 173 } 174 175 /** 176 * The status of the narrative - whether it's entirely generated (from just the defined data or the extensions too), or whether a human authored it and it may contain additional data. 177 */ 178 @Child(name = "status", type = {CodeType.class}, order=0, min=1, max=1, modifier=false, summary=false) 179 @Description(shortDefinition="generated | extensions | additional | empty", formalDefinition="The status of the narrative - whether it's entirely generated (from just the defined data or the extensions too), or whether a human authored it and it may contain additional data." ) 180 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/narrative-status") 181 protected Enumeration<NarrativeStatus> status; 182 183 /** 184 * The actual narrative content, a stripped down version of XHTML. 185 */ 186 @Child(name = "div", type = {}, order=1, min=1, max=1, modifier=false, summary=false) 187 @Description(shortDefinition="Limited xhtml content", formalDefinition="The actual narrative content, a stripped down version of XHTML." ) 188 protected XhtmlNode div; 189 190 private static final long serialVersionUID = 1463852859L; 191 192 /** 193 * Constructor 194 */ 195 public Narrative() { 196 super(); 197 } 198 199 /** 200 * Constructor 201 */ 202 public Narrative(Enumeration<NarrativeStatus> status, XhtmlNode div) { 203 super(); 204 this.status = status; 205 this.div = div; 206 } 207 208 /** 209 * @return {@link #status} (The status of the narrative - whether it's entirely generated (from just the defined data or the extensions too), or whether a human authored it and it may contain additional data.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value 210 */ 211 public Enumeration<NarrativeStatus> getStatusElement() { 212 if (this.status == null) 213 if (Configuration.errorOnAutoCreate()) 214 throw new Error("Attempt to auto-create Narrative.status"); 215 else if (Configuration.doAutoCreate()) 216 this.status = new Enumeration<NarrativeStatus>(new NarrativeStatusEnumFactory()); // bb 217 return this.status; 218 } 219 220 public boolean hasStatusElement() { 221 return this.status != null && !this.status.isEmpty(); 222 } 223 224 public boolean hasStatus() { 225 return this.status != null && !this.status.isEmpty(); 226 } 227 228 /** 229 * @param value {@link #status} (The status of the narrative - whether it's entirely generated (from just the defined data or the extensions too), or whether a human authored it and it may contain additional data.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value 230 */ 231 public Narrative setStatusElement(Enumeration<NarrativeStatus> value) { 232 this.status = value; 233 return this; 234 } 235 236 /** 237 * @return The status of the narrative - whether it's entirely generated (from just the defined data or the extensions too), or whether a human authored it and it may contain additional data. 238 */ 239 public NarrativeStatus getStatus() { 240 return this.status == null ? null : this.status.getValue(); 241 } 242 243 /** 244 * @param value The status of the narrative - whether it's entirely generated (from just the defined data or the extensions too), or whether a human authored it and it may contain additional data. 245 */ 246 public Narrative setStatus(NarrativeStatus value) { 247 if (this.status == null) 248 this.status = new Enumeration<NarrativeStatus>(new NarrativeStatusEnumFactory()); 249 this.status.setValue(value); 250 return this; 251 } 252 253 /** 254 * @return {@link #div} (The actual narrative content, a stripped down version of XHTML.) 255 */ 256 public XhtmlNode getDiv() { 257 if (this.div == null) 258 if (Configuration.errorOnAutoCreate()) 259 throw new Error("Attempt to auto-create Narrative.div"); 260 else if (Configuration.doAutoCreate()) 261 this.div = new XhtmlNode(); // cc 262 return this.div; 263 } 264 265 public boolean hasDiv() { 266 return this.div != null && !this.div.isEmpty(); 267 } 268 269 /** 270 * @param value {@link #div} (The actual narrative content, a stripped down version of XHTML.) 271 */ 272 public Narrative setDiv(XhtmlNode value) { 273 this.div = value; 274 return this; 275 } 276 277 protected void listChildren(List<Property> childrenList) { 278 super.listChildren(childrenList); 279 childrenList.add(new Property("status", "code", "The status of the narrative - whether it's entirely generated (from just the defined data or the extensions too), or whether a human authored it and it may contain additional data.", 0, java.lang.Integer.MAX_VALUE, status)); 280 } 281 282 @Override 283 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 284 switch (hash) { 285 case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<NarrativeStatus> 286 case 99473: /*div*/ return this.div == null ? new Base[0] : new Base[] {new StringType(new org.hl7.fhir.utilities.xhtml.XhtmlComposer().setXmlOnly(true).composeEx(this.div))}; // XhtmlNode 287 default: return super.getProperty(hash, name, checkValid); 288 } 289 290 } 291 292 @Override 293 public Base setProperty(int hash, String name, Base value) throws FHIRException { 294 switch (hash) { 295 case -892481550: // status 296 value = new NarrativeStatusEnumFactory().fromType(castToCode(value)); 297 this.status = (Enumeration) value; // Enumeration<NarrativeStatus> 298 return value; 299 case 99473: // div 300 this.div = castToXhtml(value); // XhtmlNode 301 return value; 302 default: return super.setProperty(hash, name, value); 303 } 304 305 } 306 307 @Override 308 public Base setProperty(String name, Base value) throws FHIRException { 309 if (name.equals("status")) { 310 value = new NarrativeStatusEnumFactory().fromType(castToCode(value)); 311 this.status = (Enumeration) value; // Enumeration<NarrativeStatus> 312 } else if (name.equals("div")) { 313 this.div = castToXhtml(value); // XhtmlNode 314 } else 315 return super.setProperty(name, value); 316 return value; 317 } 318 319 @Override 320 public Base makeProperty(int hash, String name) throws FHIRException { 321 switch (hash) { 322 case -892481550: return getStatusElement(); 323 default: return super.makeProperty(hash, name); 324 } 325 326 } 327 328 @Override 329 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 330 switch (hash) { 331 case -892481550: /*status*/ return new String[] {"code"}; 332 case 99473: /*div*/ return new String[] {"xhtml"}; 333 default: return super.getTypesForProperty(hash, name); 334 } 335 336 } 337 338 @Override 339 public Base addChild(String name) throws FHIRException { 340 if (name.equals("status")) { 341 throw new FHIRException("Cannot call addChild on a primitive type Narrative.status"); 342 } 343 else 344 return super.addChild(name); 345 } 346 347 public String fhirType() { 348 return "Narrative"; 349 350 } 351 352 public Narrative copy() { 353 Narrative dst = new Narrative(); 354 copyValues(dst); 355 dst.status = status == null ? null : status.copy(); 356 dst.div = div == null ? null : div.copy(); 357 return dst; 358 } 359 360 protected Narrative typedCopy() { 361 return copy(); 362 } 363 364 @Override 365 public boolean equalsDeep(Base other) { 366 if (!super.equalsDeep(other)) 367 return false; 368 if (!(other instanceof Narrative)) 369 return false; 370 Narrative o = (Narrative) other; 371 return compareDeep(status, o.status, true) && compareDeep(div, o.div, true); 372 } 373 374 @Override 375 public boolean equalsShallow(Base other) { 376 if (!super.equalsShallow(other)) 377 return false; 378 if (!(other instanceof Narrative)) 379 return false; 380 Narrative o = (Narrative) other; 381 return compareValues(status, o.status, true); 382 } 383 384 public boolean isEmpty() { 385 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(status, div); 386 } 387 388 389} 390