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            case NULL: return null;
091            default: return "?";
092          }
093        }
094        public String getSystem() {
095          switch (this) {
096            case GENERATED: return "http://hl7.org/fhir/narrative-status";
097            case EXTENSIONS: return "http://hl7.org/fhir/narrative-status";
098            case ADDITIONAL: return "http://hl7.org/fhir/narrative-status";
099            case EMPTY: return "http://hl7.org/fhir/narrative-status";
100            case NULL: return null;
101            default: return "?";
102          }
103        }
104        public String getDefinition() {
105          switch (this) {
106            case GENERATED: return "The contents of the narrative are entirely generated from the structured data in the content.";
107            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";
108            case ADDITIONAL: return "The contents of the narrative contain additional information not found in the structured data";
109            case EMPTY: return "The contents of the narrative are some equivalent of \"No human-readable text provided in this case\"";
110            case NULL: return null;
111            default: return "?";
112          }
113        }
114        public String getDisplay() {
115          switch (this) {
116            case GENERATED: return "Generated";
117            case EXTENSIONS: return "Extensions";
118            case ADDITIONAL: return "Additional";
119            case EMPTY: return "Empty";
120            case NULL: return null;
121            default: return "?";
122          }
123        }
124    }
125
126  public static class NarrativeStatusEnumFactory implements EnumFactory<NarrativeStatus> {
127    public NarrativeStatus fromCode(String codeString) throws IllegalArgumentException {
128      if (codeString == null || "".equals(codeString))
129            if (codeString == null || "".equals(codeString))
130                return null;
131        if ("generated".equals(codeString))
132          return NarrativeStatus.GENERATED;
133        if ("extensions".equals(codeString))
134          return NarrativeStatus.EXTENSIONS;
135        if ("additional".equals(codeString))
136          return NarrativeStatus.ADDITIONAL;
137        if ("empty".equals(codeString))
138          return NarrativeStatus.EMPTY;
139        throw new IllegalArgumentException("Unknown NarrativeStatus code '"+codeString+"'");
140        }
141        public Enumeration<NarrativeStatus> fromType(Base code) throws FHIRException {
142          if (code == null || code.isEmpty())
143            return null;
144          String codeString = ((PrimitiveType) code).asStringValue();
145          if (codeString == null || "".equals(codeString))
146            return null;
147        if ("generated".equals(codeString))
148          return new Enumeration<NarrativeStatus>(this, NarrativeStatus.GENERATED);
149        if ("extensions".equals(codeString))
150          return new Enumeration<NarrativeStatus>(this, NarrativeStatus.EXTENSIONS);
151        if ("additional".equals(codeString))
152          return new Enumeration<NarrativeStatus>(this, NarrativeStatus.ADDITIONAL);
153        if ("empty".equals(codeString))
154          return new Enumeration<NarrativeStatus>(this, NarrativeStatus.EMPTY);
155        throw new FHIRException("Unknown NarrativeStatus code '"+codeString+"'");
156        }
157    public String toCode(NarrativeStatus code) {
158      if (code == NarrativeStatus.GENERATED)
159        return "generated";
160      if (code == NarrativeStatus.EXTENSIONS)
161        return "extensions";
162      if (code == NarrativeStatus.ADDITIONAL)
163        return "additional";
164      if (code == NarrativeStatus.EMPTY)
165        return "empty";
166      return "?";
167      }
168    }
169
170    /**
171     * 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.
172     */
173    @Child(name = "status", type = {CodeType.class}, order=0, min=1, max=1, modifier=false, summary=false)
174    @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." )
175    protected Enumeration<NarrativeStatus> status;
176
177    /**
178     * The actual narrative content, a stripped down version of XHTML.
179     */
180    @Child(name = "div", type = {}, order=1, min=1, max=1, modifier=false, summary=false)
181    @Description(shortDefinition="Limited xhtml content", formalDefinition="The actual narrative content, a stripped down version of XHTML." )
182    protected XhtmlNode div;
183
184    private static final long serialVersionUID = 1463852859L;
185
186  /*
187   * Constructor
188   */
189    public Narrative() {
190      super();
191    }
192
193  /*
194   * Constructor
195   */
196    public Narrative(Enumeration<NarrativeStatus> status, XhtmlNode div) {
197      super();
198      this.status = status;
199      this.div = div;
200    }
201
202    /**
203     * @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
204     */
205    public Enumeration<NarrativeStatus> getStatusElement() { 
206      if (this.status == null)
207        if (Configuration.errorOnAutoCreate())
208          throw new Error("Attempt to auto-create Narrative.status");
209        else if (Configuration.doAutoCreate())
210          this.status = new Enumeration<NarrativeStatus>(new NarrativeStatusEnumFactory()); // bb
211      return this.status;
212    }
213
214    public boolean hasStatusElement() { 
215      return this.status != null && !this.status.isEmpty();
216    }
217
218    public boolean hasStatus() { 
219      return this.status != null && !this.status.isEmpty();
220    }
221
222    /**
223     * @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
224     */
225    public Narrative setStatusElement(Enumeration<NarrativeStatus> value) { 
226      this.status = value;
227      return this;
228    }
229
230    /**
231     * @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.
232     */
233    public NarrativeStatus getStatus() { 
234      return this.status == null ? null : this.status.getValue();
235    }
236
237    /**
238     * @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.
239     */
240    public Narrative setStatus(NarrativeStatus value) { 
241        if (this.status == null)
242          this.status = new Enumeration<NarrativeStatus>(new NarrativeStatusEnumFactory());
243        this.status.setValue(value);
244      return this;
245    }
246
247    /**
248     * @return {@link #div} (The actual narrative content, a stripped down version of XHTML.)
249     */
250    public XhtmlNode getDiv() { 
251      if (this.div == null)
252        if (Configuration.errorOnAutoCreate())
253          throw new Error("Attempt to auto-create Narrative.div");
254        else if (Configuration.doAutoCreate())
255          this.div = new XhtmlNode(); // cc
256      return this.div;
257    }
258
259    public boolean hasDiv() { 
260      return this.div != null && !this.div.isEmpty();
261    }
262
263    /**
264     * @param value {@link #div} (The actual narrative content, a stripped down version of XHTML.)
265     */
266    public Narrative setDiv(XhtmlNode value) { 
267      this.div = value;
268      return this;
269    }
270
271      protected void listChildren(List<Property> childrenList) {
272        super.listChildren(childrenList);
273        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));
274      }
275
276      @Override
277      public void setProperty(String name, Base value) throws FHIRException {
278        if (name.equals("status"))
279          this.status = new NarrativeStatusEnumFactory().fromType(value); // Enumeration<NarrativeStatus>
280        else
281          super.setProperty(name, value);
282      }
283
284      @Override
285      public Base addChild(String name) throws FHIRException {
286        if (name.equals("status")) {
287          throw new FHIRException("Cannot call addChild on a primitive type Narrative.status");
288        }
289        else
290          return super.addChild(name);
291      }
292
293  public String fhirType() {
294    return "Narrative";
295
296  }
297
298      public Narrative copy() {
299        Narrative dst = new Narrative();
300        copyValues(dst);
301        dst.status = status == null ? null : status.copy();
302        dst.div = div == null ? null : div.copy();
303        return dst;
304      }
305
306      protected Narrative typedCopy() {
307        return copy();
308      }
309
310      @Override
311      public boolean equalsDeep(Base other) {
312        if (!super.equalsDeep(other))
313          return false;
314        if (!(other instanceof Narrative))
315          return false;
316        Narrative o = (Narrative) other;
317        return compareDeep(status, o.status, true) && compareDeep(div, o.div, true);
318      }
319
320      @Override
321      public boolean equalsShallow(Base other) {
322        if (!super.equalsShallow(other))
323          return false;
324        if (!(other instanceof Narrative))
325          return false;
326        Narrative o = (Narrative) other;
327        return compareValues(status, o.status, true);
328      }
329
330      public boolean isEmpty() {
331        return super.isEmpty() && (status == null || status.isEmpty()) && (div == null || div.isEmpty())
332          ;
333      }
334
335
336}