
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 Sat, Nov 5, 2022 10:47+1100 for FHIR v5.0.0-ballot 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(Base code) throws FHIRException { 152 if (code == null) 153 return null; 154 if (code.isEmpty()) 155 return new Enumeration<NarrativeStatus>(this); 156 String codeString = ((PrimitiveType) code).asStringValue(); 157 if (codeString == null || "".equals(codeString)) 158 return null; 159 if ("generated".equals(codeString)) 160 return new Enumeration<NarrativeStatus>(this, NarrativeStatus.GENERATED); 161 if ("extensions".equals(codeString)) 162 return new Enumeration<NarrativeStatus>(this, NarrativeStatus.EXTENSIONS); 163 if ("additional".equals(codeString)) 164 return new Enumeration<NarrativeStatus>(this, NarrativeStatus.ADDITIONAL); 165 if ("empty".equals(codeString)) 166 return new Enumeration<NarrativeStatus>(this, NarrativeStatus.EMPTY); 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 StringType(new org.hl7.fhir.utilities.xhtml.XhtmlComposer(true).composeEx(this.div))}; // 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 return value; 322 default: return super.setProperty(hash, name, value); 323 } 324 325 } 326 327 @Override 328 public Base setProperty(String name, Base value) throws FHIRException { 329 if (name.equals("status")) { 330 value = new NarrativeStatusEnumFactory().fromType(TypeConvertor.castToCode(value)); 331 this.status = (Enumeration) value; // Enumeration<NarrativeStatus> 332 } else if (name.equals("div")) { 333 this.div = TypeConvertor.castToXhtml(value); // XhtmlNode 334 } else 335 return super.setProperty(name, value); 336 return value; 337 } 338 339 @Override 340 public Base makeProperty(int hash, String name) throws FHIRException { 341 switch (hash) { 342 case -892481550: return getStatusElement(); 343 case 99473: /*div*/ 344 if (div == null) 345 div = new XhtmlNode(NodeType.Element, "div"); 346 return new StringType(new org.hl7.fhir.utilities.xhtml.XhtmlComposer(true).composeEx(this.div)); 347 default: return super.makeProperty(hash, name); 348 } 349 350 } 351 352 @Override 353 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 354 switch (hash) { 355 case -892481550: /*status*/ return new String[] {"code"}; 356 case 99473: /*div*/ return new String[] {"xhtml"}; 357 default: return super.getTypesForProperty(hash, name); 358 } 359 360 } 361 362 @Override 363 public Base addChild(String name) throws FHIRException { 364 if (name.equals("status")) { 365 throw new FHIRException("Cannot call addChild on a primitive type Narrative.status"); 366 } 367 else 368 return super.addChild(name); 369 } 370 371 public String fhirType() { 372 return "Narrative"; 373 374 } 375 376 public Narrative copy() { 377 Narrative dst = new Narrative(); 378 copyValues(dst); 379 return dst; 380 } 381 382 public void copyValues(Narrative dst) { 383 super.copyValues(dst); 384 dst.status = status == null ? null : status.copy(); 385 dst.div = div == null ? null : div.copy(); 386 } 387 388 protected Narrative typedCopy() { 389 return copy(); 390 } 391 392 @Override 393 public boolean equalsDeep(Base other_) { 394 if (!super.equalsDeep(other_)) 395 return false; 396 if (!(other_ instanceof Narrative)) 397 return false; 398 Narrative o = (Narrative) other_; 399 return compareDeep(status, o.status, true) && compareDeep(div, o.div, true); 400 } 401 402 @Override 403 public boolean equalsShallow(Base other_) { 404 if (!super.equalsShallow(other_)) 405 return false; 406 if (!(other_ instanceof Narrative)) 407 return false; 408 Narrative o = (Narrative) other_; 409 return compareValues(status, o.status, true); 410 } 411 412 public boolean isEmpty() { 413 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(status, div); 414 } 415 416 417} 418