001package org.hl7.fhir.dstu2016may.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 Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
036import java.util.List;
037
038import org.hl7.fhir.exceptions.FHIRException;
039import org.hl7.fhir.instance.model.api.INarrative;
040import org.hl7.fhir.utilities.xhtml.XhtmlNode;
041
042import ca.uhn.fhir.model.api.annotation.Child;
043import ca.uhn.fhir.model.api.annotation.DatatypeDef;
044import ca.uhn.fhir.model.api.annotation.Description;
045/**
046 * A human-readable formatted text, including images.
047 */
048@DatatypeDef(name="Narrative")
049public class Narrative extends BaseNarrative implements INarrative {
050
051    public enum NarrativeStatus {
052        /**
053         * The contents of the narrative are entirely generated from the structured data in the content.
054         */
055        GENERATED, 
056        /**
057         * The contents of the narrative are entirely generated from the structured data in the content and some of the content is generated from extensions
058         */
059        EXTENSIONS, 
060        /**
061         * The contents of the narrative contain additional information not found in the structured data
062         */
063        ADDITIONAL, 
064        /**
065         * The contents of the narrative are some equivalent of "No human-readable text provided in this case"
066         */
067        EMPTY, 
068        /**
069         * added to help the parsers
070         */
071        NULL;
072        public static NarrativeStatus fromCode(String codeString) throws FHIRException {
073            if (codeString == null || "".equals(codeString))
074                return null;
075        if ("generated".equals(codeString))
076          return GENERATED;
077        if ("extensions".equals(codeString))
078          return EXTENSIONS;
079        if ("additional".equals(codeString))
080          return ADDITIONAL;
081        if ("empty".equals(codeString))
082          return EMPTY;
083        throw new FHIRException("Unknown NarrativeStatus code '"+codeString+"'");
084        }
085        public String toCode() {
086          switch (this) {
087            case GENERATED: return "generated";
088            case EXTENSIONS: return "extensions";
089            case ADDITIONAL: return "additional";
090            case EMPTY: return "empty";
091            case NULL: return null;
092            default: return "?";
093          }
094        }
095        public String getSystem() {
096          switch (this) {
097            case GENERATED: return "http://hl7.org/fhir/narrative-status";
098            case EXTENSIONS: return "http://hl7.org/fhir/narrative-status";
099            case ADDITIONAL: return "http://hl7.org/fhir/narrative-status";
100            case EMPTY: return "http://hl7.org/fhir/narrative-status";
101            case NULL: return null;
102            default: return "?";
103          }
104        }
105        public String getDefinition() {
106          switch (this) {
107            case GENERATED: return "The contents of the narrative are entirely generated from the structured data in the content.";
108            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";
109            case ADDITIONAL: return "The contents of the narrative contain additional information not found in the structured data";
110            case EMPTY: return "The contents of the narrative are some equivalent of \"No human-readable text provided in this case\"";
111            case NULL: return null;
112            default: return "?";
113          }
114        }
115        public String getDisplay() {
116          switch (this) {
117            case GENERATED: return "Generated";
118            case EXTENSIONS: return "Extensions";
119            case ADDITIONAL: return "Additional";
120            case EMPTY: return "Empty";
121            case NULL: return null;
122            default: return "?";
123          }
124        }
125    }
126
127  public static class NarrativeStatusEnumFactory implements EnumFactory<NarrativeStatus> {
128    public NarrativeStatus fromCode(String codeString) throws IllegalArgumentException {
129      if (codeString == null || "".equals(codeString))
130            if (codeString == null || "".equals(codeString))
131                return null;
132        if ("generated".equals(codeString))
133          return NarrativeStatus.GENERATED;
134        if ("extensions".equals(codeString))
135          return NarrativeStatus.EXTENSIONS;
136        if ("additional".equals(codeString))
137          return NarrativeStatus.ADDITIONAL;
138        if ("empty".equals(codeString))
139          return NarrativeStatus.EMPTY;
140        throw new IllegalArgumentException("Unknown NarrativeStatus code '"+codeString+"'");
141        }
142        public Enumeration<NarrativeStatus> fromType(Base code) throws FHIRException {
143          if (code == null || code.isEmpty())
144            return null;
145          String codeString = ((PrimitiveType) code).asStringValue();
146          if (codeString == null || "".equals(codeString))
147            return null;
148        if ("generated".equals(codeString))
149          return new Enumeration<NarrativeStatus>(this, NarrativeStatus.GENERATED);
150        if ("extensions".equals(codeString))
151          return new Enumeration<NarrativeStatus>(this, NarrativeStatus.EXTENSIONS);
152        if ("additional".equals(codeString))
153          return new Enumeration<NarrativeStatus>(this, NarrativeStatus.ADDITIONAL);
154        if ("empty".equals(codeString))
155          return new Enumeration<NarrativeStatus>(this, NarrativeStatus.EMPTY);
156        throw new FHIRException("Unknown NarrativeStatus code '"+codeString+"'");
157        }
158    public String toCode(NarrativeStatus code) {
159      if (code == NarrativeStatus.GENERATED)
160        return "generated";
161      if (code == NarrativeStatus.EXTENSIONS)
162        return "extensions";
163      if (code == NarrativeStatus.ADDITIONAL)
164        return "additional";
165      if (code == NarrativeStatus.EMPTY)
166        return "empty";
167      return "?";
168      }
169    public String toSystem(NarrativeStatus code) {
170      return code.getSystem();
171      }
172    }
173
174    /**
175     * 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.
176     */
177    @Child(name = "status", type = {CodeType.class}, order=0, min=1, max=1, modifier=false, summary=false)
178    @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." )
179    protected Enumeration<NarrativeStatus> status;
180
181    /**
182     * The actual narrative content, a stripped down version of XHTML.
183     */
184    @Child(name = "div", type = {}, order=1, min=1, max=1, modifier=false, summary=false)
185    @Description(shortDefinition="Limited xhtml content", formalDefinition="The actual narrative content, a stripped down version of XHTML." )
186    protected XhtmlNode div;
187
188    private static final long serialVersionUID = 1463852859L;
189
190  /**
191   * Constructor
192   */
193    public Narrative() {
194      super();
195    }
196
197  /**
198   * Constructor
199   */
200    public Narrative(Enumeration<NarrativeStatus> status, XhtmlNode div) {
201      super();
202      this.status = status;
203      this.div = div;
204    }
205
206    /**
207     * @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
208     */
209    public Enumeration<NarrativeStatus> getStatusElement() { 
210      if (this.status == null)
211        if (Configuration.errorOnAutoCreate())
212          throw new Error("Attempt to auto-create Narrative.status");
213        else if (Configuration.doAutoCreate())
214          this.status = new Enumeration<NarrativeStatus>(new NarrativeStatusEnumFactory()); // bb
215      return this.status;
216    }
217
218    public boolean hasStatusElement() { 
219      return this.status != null && !this.status.isEmpty();
220    }
221
222    public boolean hasStatus() { 
223      return this.status != null && !this.status.isEmpty();
224    }
225
226    /**
227     * @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
228     */
229    public Narrative setStatusElement(Enumeration<NarrativeStatus> value) { 
230      this.status = value;
231      return this;
232    }
233
234    /**
235     * @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.
236     */
237    public NarrativeStatus getStatus() { 
238      return this.status == null ? null : this.status.getValue();
239    }
240
241    /**
242     * @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.
243     */
244    public Narrative setStatus(NarrativeStatus value) { 
245        if (this.status == null)
246          this.status = new Enumeration<NarrativeStatus>(new NarrativeStatusEnumFactory());
247        this.status.setValue(value);
248      return this;
249    }
250
251    /**
252     * @return {@link #div} (The actual narrative content, a stripped down version of XHTML.)
253     */
254    public XhtmlNode getDiv() { 
255      if (this.div == null)
256        if (Configuration.errorOnAutoCreate())
257          throw new Error("Attempt to auto-create Narrative.div");
258        else if (Configuration.doAutoCreate())
259          this.div = new XhtmlNode(); // cc
260      return this.div;
261    }
262
263    public boolean hasDiv() { 
264      return this.div != null && !this.div.isEmpty();
265    }
266
267    /**
268     * @param value {@link #div} (The actual narrative content, a stripped down version of XHTML.)
269     */
270    public Narrative setDiv(XhtmlNode value) { 
271      this.div = value;
272      return this;
273    }
274
275      protected void listChildren(List<Property> childrenList) {
276        super.listChildren(childrenList);
277        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));
278      }
279
280      @Override
281      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
282        switch (hash) {
283        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<NarrativeStatus>
284        default: return super.getProperty(hash, name, checkValid);
285        }
286
287      }
288
289      @Override
290      public void setProperty(int hash, String name, Base value) throws FHIRException {
291        switch (hash) {
292        case -892481550: // status
293          this.status = new NarrativeStatusEnumFactory().fromType(value); // Enumeration<NarrativeStatus>
294          break;
295        default: super.setProperty(hash, name, value);
296        }
297
298      }
299
300      @Override
301      public void setProperty(String name, Base value) throws FHIRException {
302        if (name.equals("status"))
303          this.status = new NarrativeStatusEnumFactory().fromType(value); // Enumeration<NarrativeStatus>
304        else
305          super.setProperty(name, value);
306      }
307
308      @Override
309      public Base makeProperty(int hash, String name) throws FHIRException {
310        switch (hash) {
311        case -892481550: throw new FHIRException("Cannot make property status as it is not a complex type"); // Enumeration<NarrativeStatus>
312        default: return super.makeProperty(hash, name);
313        }
314
315      }
316
317      @Override
318      public Base addChild(String name) throws FHIRException {
319        if (name.equals("status")) {
320          throw new FHIRException("Cannot call addChild on a primitive type Narrative.status");
321        }
322        else
323          return super.addChild(name);
324      }
325
326  public String fhirType() {
327    return "Narrative";
328
329  }
330
331      public Narrative copy() {
332        Narrative dst = new Narrative();
333        copyValues(dst);
334        dst.status = status == null ? null : status.copy();
335        dst.div = div == null ? null : div.copy();
336        return dst;
337      }
338
339      protected Narrative typedCopy() {
340        return copy();
341      }
342
343      @Override
344      public boolean equalsDeep(Base other) {
345        if (!super.equalsDeep(other))
346          return false;
347        if (!(other instanceof Narrative))
348          return false;
349        Narrative o = (Narrative) other;
350        return compareDeep(status, o.status, true) && compareDeep(div, o.div, true);
351      }
352
353      @Override
354      public boolean equalsShallow(Base other) {
355        if (!super.equalsShallow(other))
356          return false;
357        if (!(other instanceof Narrative))
358          return false;
359        Narrative o = (Narrative) other;
360        return compareValues(status, o.status, true);
361      }
362
363      public boolean isEmpty() {
364        return super.isEmpty() && (status == null || status.isEmpty()) && (div == null || div.isEmpty())
365          ;
366      }
367
368
369}