001package org.hl7.fhir.r4.model; 002 003 004 005/* 006 Copyright (c) 2011+, HL7, Inc. 007 All rights reserved. 008 009 Redistribution and use in source and binary forms, with or without modification, 010 are permitted provided that the following conditions are met: 011 012 * Redistributions of source code must retain the above copyright notice, this 013 list of conditions and the following disclaimer. 014 * Redistributions in binary form must reproduce the above copyright notice, 015 this list of conditions and the following disclaimer in the documentation 016 and/or other materials provided with the distribution. 017 * Neither the name of HL7 nor the names of its contributors may be used to 018 endorse or promote products derived from this software without specific 019 prior written permission. 020 021 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 022 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 023 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 024 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 025 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 026 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 027 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 028 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 029 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 030 POSSIBILITY OF SUCH DAMAGE. 031 032*/ 033 034 035// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1 036 037import java.util.*; 038import org.hl7.fhir.utilities.xhtml.NodeType; 039import org.hl7.fhir.utilities.xhtml.XhtmlNode; 040 041import org.hl7.fhir.utilities.Utilities; 042import ca.uhn.fhir.model.api.annotation.Child; 043import ca.uhn.fhir.model.api.annotation.ChildOrder; 044import ca.uhn.fhir.model.api.annotation.Description; 045import ca.uhn.fhir.model.api.annotation.DatatypeDef; 046import ca.uhn.fhir.model.api.annotation.Block; 047import org.hl7.fhir.instance.model.api.*; 048import org.hl7.fhir.exceptions.FHIRException; 049/** 050 * A human-readable summary of the resource conveying the essential clinical and business information for the resource. 051 */ 052@DatatypeDef(name="Narrative") 053public class Narrative extends BaseNarrative implements INarrative { 054 055 public enum NarrativeStatus { 056 /** 057 * The contents of the narrative are entirely generated from the core elements in the content. 058 */ 059 GENERATED, 060 /** 061 * The contents of the narrative are entirely generated from the core elements in the content and some of the content is generated from extensions. The narrative SHALL reflect the impact of all modifier extensions. 062 */ 063 EXTENSIONS, 064 /** 065 * 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. 066 */ 067 ADDITIONAL, 068 /** 069 * The contents of the narrative are some equivalent of "No human-readable text provided in this case". 070 */ 071 EMPTY, 072 /** 073 * added to help the parsers with the generic types 074 */ 075 NULL; 076 public static NarrativeStatus fromCode(String codeString) throws FHIRException { 077 if (codeString == null || "".equals(codeString)) 078 return null; 079 if ("generated".equals(codeString)) 080 return GENERATED; 081 if ("extensions".equals(codeString)) 082 return EXTENSIONS; 083 if ("additional".equals(codeString)) 084 return ADDITIONAL; 085 if ("empty".equals(codeString)) 086 return EMPTY; 087 if (Configuration.isAcceptInvalidEnums()) 088 return null; 089 else 090 throw new FHIRException("Unknown NarrativeStatus code '"+codeString+"'"); 091 } 092 public String toCode() { 093 switch (this) { 094 case GENERATED: return "generated"; 095 case EXTENSIONS: return "extensions"; 096 case ADDITIONAL: return "additional"; 097 case EMPTY: return "empty"; 098 default: return "?"; 099 } 100 } 101 public String getSystem() { 102 switch (this) { 103 case GENERATED: return "http://hl7.org/fhir/narrative-status"; 104 case EXTENSIONS: return "http://hl7.org/fhir/narrative-status"; 105 case ADDITIONAL: return "http://hl7.org/fhir/narrative-status"; 106 case EMPTY: return "http://hl7.org/fhir/narrative-status"; 107 default: return "?"; 108 } 109 } 110 public String getDefinition() { 111 switch (this) { 112 case GENERATED: return "The contents of the narrative are entirely generated from the core elements in the content."; 113 case EXTENSIONS: return "The contents of the narrative are entirely generated from the core elements in the content and some of the content is generated from extensions. The narrative SHALL reflect the impact of all modifier extensions."; 114 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."; 115 case EMPTY: return "The contents of the narrative are some equivalent of \"No human-readable text provided in this case\"."; 116 default: return "?"; 117 } 118 } 119 public String getDisplay() { 120 switch (this) { 121 case GENERATED: return "Generated"; 122 case EXTENSIONS: return "Extensions"; 123 case ADDITIONAL: return "Additional"; 124 case EMPTY: return "Empty"; 125 default: return "?"; 126 } 127 } 128 } 129 130 public static class NarrativeStatusEnumFactory implements EnumFactory<NarrativeStatus> { 131 public NarrativeStatus fromCode(String codeString) throws IllegalArgumentException { 132 if (codeString == null || "".equals(codeString)) 133 if (codeString == null || "".equals(codeString)) 134 return null; 135 if ("generated".equals(codeString)) 136 return NarrativeStatus.GENERATED; 137 if ("extensions".equals(codeString)) 138 return NarrativeStatus.EXTENSIONS; 139 if ("additional".equals(codeString)) 140 return NarrativeStatus.ADDITIONAL; 141 if ("empty".equals(codeString)) 142 return NarrativeStatus.EMPTY; 143 throw new IllegalArgumentException("Unknown NarrativeStatus code '"+codeString+"'"); 144 } 145 public Enumeration<NarrativeStatus> fromType(Base code) throws FHIRException { 146 if (code == null) 147 return null; 148 if (code.isEmpty()) 149 return new Enumeration<NarrativeStatus>(this); 150 String codeString = ((PrimitiveType) code).asStringValue(); 151 if (codeString == null || "".equals(codeString)) 152 return null; 153 if ("generated".equals(codeString)) 154 return new Enumeration<NarrativeStatus>(this, NarrativeStatus.GENERATED); 155 if ("extensions".equals(codeString)) 156 return new Enumeration<NarrativeStatus>(this, NarrativeStatus.EXTENSIONS); 157 if ("additional".equals(codeString)) 158 return new Enumeration<NarrativeStatus>(this, NarrativeStatus.ADDITIONAL); 159 if ("empty".equals(codeString)) 160 return new Enumeration<NarrativeStatus>(this, NarrativeStatus.EMPTY); 161 throw new FHIRException("Unknown NarrativeStatus code '"+codeString+"'"); 162 } 163 public String toCode(NarrativeStatus code) { 164 if (code == NarrativeStatus.GENERATED) 165 return "generated"; 166 if (code == NarrativeStatus.EXTENSIONS) 167 return "extensions"; 168 if (code == NarrativeStatus.ADDITIONAL) 169 return "additional"; 170 if (code == NarrativeStatus.EMPTY) 171 return "empty"; 172 return "?"; 173 } 174 public String toSystem(NarrativeStatus code) { 175 return code.getSystem(); 176 } 177 } 178 179 /** 180 * 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. 181 */ 182 @Child(name = "status", type = {CodeType.class}, order=0, min=1, max=1, modifier=false, summary=false) 183 @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." ) 184 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/narrative-status") 185 protected Enumeration<NarrativeStatus> status; 186 187 /** 188 * The actual narrative content, a stripped down version of XHTML. 189 */ 190 @Child(name = "div", type = {}, order=1, min=1, max=1, modifier=false, summary=false) 191 @Description(shortDefinition="Limited xhtml content", formalDefinition="The actual narrative content, a stripped down version of XHTML." ) 192 protected XhtmlNode div; 193 194 private static final long serialVersionUID = 1463852859L; 195 196 /** 197 * Constructor 198 */ 199 public Narrative() { 200 super(); 201 } 202 203 /** 204 * Constructor 205 */ 206 public Narrative(Enumeration<NarrativeStatus> status, XhtmlNode div) { 207 super(); 208 this.status = status; 209 this.div = div; 210 } 211 212 /** 213 * @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 214 */ 215 public Enumeration<NarrativeStatus> getStatusElement() { 216 if (this.status == null) 217 if (Configuration.errorOnAutoCreate()) 218 throw new Error("Attempt to auto-create Narrative.status"); 219 else if (Configuration.doAutoCreate()) 220 this.status = new Enumeration<NarrativeStatus>(new NarrativeStatusEnumFactory()); // bb 221 return this.status; 222 } 223 224 public boolean hasStatusElement() { 225 return this.status != null && !this.status.isEmpty(); 226 } 227 228 public boolean hasStatus() { 229 return this.status != null && !this.status.isEmpty(); 230 } 231 232 /** 233 * @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 234 */ 235 public Narrative setStatusElement(Enumeration<NarrativeStatus> value) { 236 this.status = value; 237 return this; 238 } 239 240 /** 241 * @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. 242 */ 243 public NarrativeStatus getStatus() { 244 return this.status == null ? null : this.status.getValue(); 245 } 246 247 /** 248 * @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. 249 */ 250 public Narrative setStatus(NarrativeStatus value) { 251 if (this.status == null) 252 this.status = new Enumeration<NarrativeStatus>(new NarrativeStatusEnumFactory()); 253 this.status.setValue(value); 254 return this; 255 } 256 257 /** 258 * @return {@link #div} (The actual narrative content, a stripped down version of XHTML.) 259 */ 260 public XhtmlNode getDiv() { 261 if (this.div == null) 262 if (Configuration.errorOnAutoCreate()) 263 throw new Error("Attempt to auto-create Narrative.div"); 264 else if (Configuration.doAutoCreate()) 265 this.div = new XhtmlNode(NodeType.Element, "div"); // cc 266 return this.div; 267 } 268 269 public boolean hasDiv() { 270 return this.div != null && !this.div.isEmpty(); 271 } 272 273 /** 274 * @param value {@link #div} (The actual narrative content, a stripped down version of XHTML.) 275 */ 276 public Narrative setDiv(XhtmlNode value) { 277 this.div = value; 278 return this; 279 } 280 281 protected void listChildren(List<Property> children) { 282 super.listChildren(children); 283 children.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, 1, status)); 284 } 285 286 @Override 287 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 288 switch (_hash) { 289 case -892481550: /*status*/ return 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, 1, status); 290 default: return super.getNamedProperty(_hash, _name, _checkValid); 291 } 292 293 } 294 295 @Override 296 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 297 switch (hash) { 298 case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<NarrativeStatus> 299 case 99473: /*div*/ return this.div == null ? new Base[0] : new Base[] {new StringType(new org.hl7.fhir.utilities.xhtml.XhtmlComposer(true).composeEx(this.div))}; // XhtmlNode 300 default: return super.getProperty(hash, name, checkValid); 301 } 302 303 } 304 305 @Override 306 public Base setProperty(int hash, String name, Base value) throws FHIRException { 307 switch (hash) { 308 case -892481550: // status 309 value = new NarrativeStatusEnumFactory().fromType(castToCode(value)); 310 this.status = (Enumeration) value; // Enumeration<NarrativeStatus> 311 return value; 312 case 99473: // div 313 this.div = castToXhtml(value); // XhtmlNode 314 return value; 315 default: return super.setProperty(hash, name, value); 316 } 317 318 } 319 320 @Override 321 public Base setProperty(String name, Base value) throws FHIRException { 322 if (name.equals("status")) { 323 value = new NarrativeStatusEnumFactory().fromType(castToCode(value)); 324 this.status = (Enumeration) value; // Enumeration<NarrativeStatus> 325 } else if (name.equals("div")) { 326 this.div = castToXhtml(value); // XhtmlNode 327 } else 328 return super.setProperty(name, value); 329 return value; 330 } 331 332 @Override 333 public Base makeProperty(int hash, String name) throws FHIRException { 334 switch (hash) { 335 case -892481550: return getStatusElement(); 336 case 99473: /*div*/ 337 if (div == null) 338 div = new XhtmlNode(NodeType.Element, "div"); 339 return new StringType(new org.hl7.fhir.utilities.xhtml.XhtmlComposer(true).composeEx(this.div)); 340 default: return super.makeProperty(hash, name); 341 } 342 343 } 344 345 @Override 346 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 347 switch (hash) { 348 case -892481550: /*status*/ return new String[] {"code"}; 349 case 99473: /*div*/ return new String[] {"xhtml"}; 350 default: return super.getTypesForProperty(hash, name); 351 } 352 353 } 354 355 @Override 356 public Base addChild(String name) throws FHIRException { 357 if (name.equals("status")) { 358 throw new FHIRException("Cannot call addChild on a primitive type Narrative.status"); 359 } 360 else 361 return super.addChild(name); 362 } 363 364 public String fhirType() { 365 return "Narrative"; 366 367 } 368 369 public Narrative copy() { 370 Narrative dst = new Narrative(); 371 copyValues(dst); 372 return dst; 373 } 374 375 public void copyValues(Narrative dst) { 376 super.copyValues(dst); 377 dst.status = status == null ? null : status.copy(); 378 dst.div = div == null ? null : div.copy(); 379 } 380 381 protected Narrative typedCopy() { 382 return copy(); 383 } 384 385 @Override 386 public boolean equalsDeep(Base other_) { 387 if (!super.equalsDeep(other_)) 388 return false; 389 if (!(other_ instanceof Narrative)) 390 return false; 391 Narrative o = (Narrative) other_; 392 return compareDeep(status, o.status, true) && compareDeep(div, o.div, true); 393 } 394 395 @Override 396 public boolean equalsShallow(Base other_) { 397 if (!super.equalsShallow(other_)) 398 return false; 399 if (!(other_ instanceof Narrative)) 400 return false; 401 Narrative o = (Narrative) other_; 402 return compareValues(status, o.status, true); 403 } 404 405 public boolean isEmpty() { 406 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(status, div); 407 } 408 409 410}