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 case NULL: return null; 099 default: return "?"; 100 } 101 } 102 public String getSystem() { 103 switch (this) { 104 case GENERATED: return "http://hl7.org/fhir/narrative-status"; 105 case EXTENSIONS: return "http://hl7.org/fhir/narrative-status"; 106 case ADDITIONAL: return "http://hl7.org/fhir/narrative-status"; 107 case EMPTY: return "http://hl7.org/fhir/narrative-status"; 108 case NULL: return null; 109 default: return "?"; 110 } 111 } 112 public String getDefinition() { 113 switch (this) { 114 case GENERATED: return "The contents of the narrative are entirely generated from the core elements in the content."; 115 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."; 116 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."; 117 case EMPTY: return "The contents of the narrative are some equivalent of \"No human-readable text provided in this case\"."; 118 case NULL: return null; 119 default: return "?"; 120 } 121 } 122 public String getDisplay() { 123 switch (this) { 124 case GENERATED: return "Generated"; 125 case EXTENSIONS: return "Extensions"; 126 case ADDITIONAL: return "Additional"; 127 case EMPTY: return "Empty"; 128 case NULL: return null; 129 default: return "?"; 130 } 131 } 132 } 133 134 public static class NarrativeStatusEnumFactory implements EnumFactory<NarrativeStatus> { 135 public NarrativeStatus fromCode(String codeString) throws IllegalArgumentException { 136 if (codeString == null || "".equals(codeString)) 137 if (codeString == null || "".equals(codeString)) 138 return null; 139 if ("generated".equals(codeString)) 140 return NarrativeStatus.GENERATED; 141 if ("extensions".equals(codeString)) 142 return NarrativeStatus.EXTENSIONS; 143 if ("additional".equals(codeString)) 144 return NarrativeStatus.ADDITIONAL; 145 if ("empty".equals(codeString)) 146 return NarrativeStatus.EMPTY; 147 throw new IllegalArgumentException("Unknown NarrativeStatus code '"+codeString+"'"); 148 } 149 public Enumeration<NarrativeStatus> fromType(Base code) throws FHIRException { 150 if (code == null) 151 return null; 152 if (code.isEmpty()) 153 return new Enumeration<NarrativeStatus>(this); 154 String codeString = ((PrimitiveType) code).asStringValue(); 155 if (codeString == null || "".equals(codeString)) 156 return null; 157 if ("generated".equals(codeString)) 158 return new Enumeration<NarrativeStatus>(this, NarrativeStatus.GENERATED); 159 if ("extensions".equals(codeString)) 160 return new Enumeration<NarrativeStatus>(this, NarrativeStatus.EXTENSIONS); 161 if ("additional".equals(codeString)) 162 return new Enumeration<NarrativeStatus>(this, NarrativeStatus.ADDITIONAL); 163 if ("empty".equals(codeString)) 164 return new Enumeration<NarrativeStatus>(this, NarrativeStatus.EMPTY); 165 throw new FHIRException("Unknown NarrativeStatus code '"+codeString+"'"); 166 } 167 public String toCode(NarrativeStatus code) { 168 if (code == NarrativeStatus.GENERATED) 169 return "generated"; 170 if (code == NarrativeStatus.EXTENSIONS) 171 return "extensions"; 172 if (code == NarrativeStatus.ADDITIONAL) 173 return "additional"; 174 if (code == NarrativeStatus.EMPTY) 175 return "empty"; 176 return "?"; 177 } 178 public String toSystem(NarrativeStatus code) { 179 return code.getSystem(); 180 } 181 } 182 183 /** 184 * 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. 185 */ 186 @Child(name = "status", type = {CodeType.class}, order=0, min=1, max=1, modifier=false, summary=false) 187 @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." ) 188 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/narrative-status") 189 protected Enumeration<NarrativeStatus> status; 190 191 /** 192 * The actual narrative content, a stripped down version of XHTML. 193 */ 194 @Child(name = "div", type = {}, order=1, min=1, max=1, modifier=false, summary=false) 195 @Description(shortDefinition="Limited xhtml content", formalDefinition="The actual narrative content, a stripped down version of XHTML." ) 196 protected XhtmlNode div; 197 198 private static final long serialVersionUID = 1463852859L; 199 200 /** 201 * Constructor 202 */ 203 public Narrative() { 204 super(); 205 } 206 207 /** 208 * Constructor 209 */ 210 public Narrative(Enumeration<NarrativeStatus> status, XhtmlNode div) { 211 super(); 212 this.status = status; 213 this.div = div; 214 } 215 216 /** 217 * @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 218 */ 219 public Enumeration<NarrativeStatus> getStatusElement() { 220 if (this.status == null) 221 if (Configuration.errorOnAutoCreate()) 222 throw new Error("Attempt to auto-create Narrative.status"); 223 else if (Configuration.doAutoCreate()) 224 this.status = new Enumeration<NarrativeStatus>(new NarrativeStatusEnumFactory()); // bb 225 return this.status; 226 } 227 228 public boolean hasStatusElement() { 229 return this.status != null && !this.status.isEmpty(); 230 } 231 232 public boolean hasStatus() { 233 return this.status != null && !this.status.isEmpty(); 234 } 235 236 /** 237 * @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 238 */ 239 public Narrative setStatusElement(Enumeration<NarrativeStatus> value) { 240 this.status = value; 241 return this; 242 } 243 244 /** 245 * @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. 246 */ 247 public NarrativeStatus getStatus() { 248 return this.status == null ? null : this.status.getValue(); 249 } 250 251 /** 252 * @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. 253 */ 254 public Narrative setStatus(NarrativeStatus value) { 255 if (this.status == null) 256 this.status = new Enumeration<NarrativeStatus>(new NarrativeStatusEnumFactory()); 257 this.status.setValue(value); 258 return this; 259 } 260 261 /** 262 * @return {@link #div} (The actual narrative content, a stripped down version of XHTML.) 263 */ 264 public XhtmlNode getDiv() { 265 if (this.div == null) 266 if (Configuration.errorOnAutoCreate()) 267 throw new Error("Attempt to auto-create Narrative.div"); 268 else if (Configuration.doAutoCreate()) 269 this.div = new XhtmlNode(NodeType.Element, "div"); // cc 270 return this.div; 271 } 272 273 public boolean hasDiv() { 274 return this.div != null && !this.div.isEmpty(); 275 } 276 277 /** 278 * @param value {@link #div} (The actual narrative content, a stripped down version of XHTML.) 279 */ 280 public Narrative setDiv(XhtmlNode value) { 281 this.div = value; 282 return this; 283 } 284 285 protected void listChildren(List<Property> children) { 286 super.listChildren(children); 287 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)); 288 } 289 290 @Override 291 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 292 switch (_hash) { 293 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); 294 default: return super.getNamedProperty(_hash, _name, _checkValid); 295 } 296 297 } 298 299 @Override 300 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 301 switch (hash) { 302 case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<NarrativeStatus> 303 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 304 default: return super.getProperty(hash, name, checkValid); 305 } 306 307 } 308 309 @Override 310 public Base setProperty(int hash, String name, Base value) throws FHIRException { 311 switch (hash) { 312 case -892481550: // status 313 value = new NarrativeStatusEnumFactory().fromType(castToCode(value)); 314 this.status = (Enumeration) value; // Enumeration<NarrativeStatus> 315 return value; 316 case 99473: // div 317 this.div = castToXhtml(value); // XhtmlNode 318 return value; 319 default: return super.setProperty(hash, name, value); 320 } 321 322 } 323 324 @Override 325 public Base setProperty(String name, Base value) throws FHIRException { 326 if (name.equals("status")) { 327 value = new NarrativeStatusEnumFactory().fromType(castToCode(value)); 328 this.status = (Enumeration) value; // Enumeration<NarrativeStatus> 329 } else if (name.equals("div")) { 330 this.div = castToXhtml(value); // XhtmlNode 331 } else 332 return super.setProperty(name, value); 333 return value; 334 } 335 336 @Override 337 public Base makeProperty(int hash, String name) throws FHIRException { 338 switch (hash) { 339 case -892481550: return getStatusElement(); 340 case 99473: /*div*/ 341 if (div == null) 342 div = new XhtmlNode(NodeType.Element, "div"); 343 return new StringType(new org.hl7.fhir.utilities.xhtml.XhtmlComposer(true).composeEx(this.div)); 344 default: return super.makeProperty(hash, name); 345 } 346 347 } 348 349 @Override 350 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 351 switch (hash) { 352 case -892481550: /*status*/ return new String[] {"code"}; 353 case 99473: /*div*/ return new String[] {"xhtml"}; 354 default: return super.getTypesForProperty(hash, name); 355 } 356 357 } 358 359 @Override 360 public Base addChild(String name) throws FHIRException { 361 if (name.equals("status")) { 362 throw new FHIRException("Cannot call addChild on a primitive type Narrative.status"); 363 } 364 else 365 return super.addChild(name); 366 } 367 368 public String fhirType() { 369 return "Narrative"; 370 371 } 372 373 public Narrative copy() { 374 Narrative dst = new Narrative(); 375 copyValues(dst); 376 return dst; 377 } 378 379 public void copyValues(Narrative dst) { 380 super.copyValues(dst); 381 dst.status = status == null ? null : status.copy(); 382 dst.div = div == null ? null : div.copy(); 383 } 384 385 protected Narrative typedCopy() { 386 return copy(); 387 } 388 389 @Override 390 public boolean equalsDeep(Base other_) { 391 if (!super.equalsDeep(other_)) 392 return false; 393 if (!(other_ instanceof Narrative)) 394 return false; 395 Narrative o = (Narrative) other_; 396 return compareDeep(status, o.status, true) && compareDeep(div, o.div, true); 397 } 398 399 @Override 400 public boolean equalsShallow(Base other_) { 401 if (!super.equalsShallow(other_)) 402 return false; 403 if (!(other_ instanceof Narrative)) 404 return false; 405 Narrative o = (Narrative) other_; 406 return compareValues(status, o.status, true); 407 } 408 409 public boolean isEmpty() { 410 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(status, div); 411 } 412 413 414}