001package org.hl7.fhir.r4b.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 Fri, Dec 31, 2021 05:58+1100 for FHIR v4.3.0-snapshot1 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.r4b.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 * Base StructureDefinition for 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 } 291 292 @Override 293 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 294 switch (_hash) { 295 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); 296 default: return super.getNamedProperty(_hash, _name, _checkValid); 297 } 298 299 } 300 301 @Override 302 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 303 switch (hash) { 304 case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<NarrativeStatus> 305 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 306 default: return super.getProperty(hash, name, checkValid); 307 } 308 309 } 310 311 @Override 312 public Base setProperty(int hash, String name, Base value) throws FHIRException { 313 switch (hash) { 314 case -892481550: // status 315 value = new NarrativeStatusEnumFactory().fromType(TypeConvertor.castToCode(value)); 316 this.status = (Enumeration) value; // Enumeration<NarrativeStatus> 317 return value; 318 case 99473: // div 319 this.div = TypeConvertor.castToXhtml(value); // XhtmlNode 320 return value; 321 default: return super.setProperty(hash, name, value); 322 } 323 324 } 325 326 @Override 327 public Base setProperty(String name, Base value) throws FHIRException { 328 if (name.equals("status")) { 329 value = new NarrativeStatusEnumFactory().fromType(TypeConvertor.castToCode(value)); 330 this.status = (Enumeration) value; // Enumeration<NarrativeStatus> 331 } else if (name.equals("div")) { 332 this.div = TypeConvertor.castToXhtml(value); // XhtmlNode 333 } else 334 return super.setProperty(name, value); 335 return value; 336 } 337 338 @Override 339 public Base makeProperty(int hash, String name) throws FHIRException { 340 switch (hash) { 341 case -892481550: return getStatusElement(); 342 case 99473: /*div*/ 343 if (div == null) 344 div = new XhtmlNode(NodeType.Element, "div"); 345 return new StringType(new org.hl7.fhir.utilities.xhtml.XhtmlComposer(true).composeEx(this.div)); 346 default: return super.makeProperty(hash, name); 347 } 348 349 } 350 351 @Override 352 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 353 switch (hash) { 354 case -892481550: /*status*/ return new String[] {"code"}; 355 case 99473: /*div*/ return new String[] {"xhtml"}; 356 default: return super.getTypesForProperty(hash, name); 357 } 358 359 } 360 361 @Override 362 public Base addChild(String name) throws FHIRException { 363 if (name.equals("status")) { 364 throw new FHIRException("Cannot call addChild on a primitive type Narrative.status"); 365 } 366 else 367 return super.addChild(name); 368 } 369 370 public String fhirType() { 371 return "Narrative"; 372 373 } 374 375 public Narrative copy() { 376 Narrative dst = new Narrative(); 377 copyValues(dst); 378 return dst; 379 } 380 381 public void copyValues(Narrative dst) { 382 super.copyValues(dst); 383 dst.status = status == null ? null : status.copy(); 384 dst.div = div == null ? null : div.copy(); 385 } 386 387 protected Narrative typedCopy() { 388 return copy(); 389 } 390 391 @Override 392 public boolean equalsDeep(Base other_) { 393 if (!super.equalsDeep(other_)) 394 return false; 395 if (!(other_ instanceof Narrative)) 396 return false; 397 Narrative o = (Narrative) other_; 398 return compareDeep(status, o.status, true) && compareDeep(div, o.div, true); 399 } 400 401 @Override 402 public boolean equalsShallow(Base other_) { 403 if (!super.equalsShallow(other_)) 404 return false; 405 if (!(other_ instanceof Narrative)) 406 return false; 407 Narrative o = (Narrative) other_; 408 return compareValues(status, o.status, true); 409 } 410 411 public boolean isEmpty() { 412 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(status, div); 413 } 414 415 416} 417