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