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