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