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