001package org.hl7.fhir.dstu2.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.ArrayList;
034import java.util.Date;
035import java.util.List;
036
037import ca.uhn.fhir.model.api.annotation.Block;
038import ca.uhn.fhir.model.api.annotation.Child;
039import ca.uhn.fhir.model.api.annotation.Description;
040import ca.uhn.fhir.model.api.annotation.ResourceDef;
041import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
042import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
043import org.hl7.fhir.exceptions.FHIRException;
044import org.hl7.fhir.utilities.Utilities;
045
046/**
047 * A set of information summarized from a list of other resources.
048 */
049@ResourceDef(name = "List", profile = "http://hl7.org/fhir/Profile/List_")
050public class List_ extends DomainResource {
051
052  public enum ListStatus {
053    /**
054     * The list is considered to be an active part of the patient's record.
055     */
056    CURRENT,
057    /**
058     * The list is "old" and should no longer be considered accurate or relevant.
059     */
060    RETIRED,
061    /**
062     * The list was never accurate. It is retained for medico-legal purposes only.
063     */
064    ENTEREDINERROR,
065    /**
066     * added to help the parsers
067     */
068    NULL;
069
070    public static ListStatus fromCode(String codeString) throws FHIRException {
071      if (codeString == null || "".equals(codeString))
072        return null;
073      if ("current".equals(codeString))
074        return CURRENT;
075      if ("retired".equals(codeString))
076        return RETIRED;
077      if ("entered-in-error".equals(codeString))
078        return ENTEREDINERROR;
079      throw new FHIRException("Unknown ListStatus code '" + codeString + "'");
080    }
081
082    public String toCode() {
083      switch (this) {
084      case CURRENT:
085        return "current";
086      case RETIRED:
087        return "retired";
088      case ENTEREDINERROR:
089        return "entered-in-error";
090      case NULL:
091        return null;
092      default:
093        return "?";
094      }
095    }
096
097    public String getSystem() {
098      switch (this) {
099      case CURRENT:
100        return "http://hl7.org/fhir/list-status";
101      case RETIRED:
102        return "http://hl7.org/fhir/list-status";
103      case ENTEREDINERROR:
104        return "http://hl7.org/fhir/list-status";
105      case NULL:
106        return null;
107      default:
108        return "?";
109      }
110    }
111
112    public String getDefinition() {
113      switch (this) {
114      case CURRENT:
115        return "The list is considered to be an active part of the patient's record.";
116      case RETIRED:
117        return "The list is \"old\" and should no longer be considered accurate or relevant.";
118      case ENTEREDINERROR:
119        return "The list was never accurate.  It is retained for medico-legal purposes only.";
120      case NULL:
121        return null;
122      default:
123        return "?";
124      }
125    }
126
127    public String getDisplay() {
128      switch (this) {
129      case CURRENT:
130        return "Current";
131      case RETIRED:
132        return "Retired";
133      case ENTEREDINERROR:
134        return "Entered In Error";
135      case NULL:
136        return null;
137      default:
138        return "?";
139      }
140    }
141  }
142
143  public static class ListStatusEnumFactory implements EnumFactory<ListStatus> {
144    public ListStatus fromCode(String codeString) throws IllegalArgumentException {
145      if (codeString == null || "".equals(codeString))
146        if (codeString == null || "".equals(codeString))
147          return null;
148      if ("current".equals(codeString))
149        return ListStatus.CURRENT;
150      if ("retired".equals(codeString))
151        return ListStatus.RETIRED;
152      if ("entered-in-error".equals(codeString))
153        return ListStatus.ENTEREDINERROR;
154      throw new IllegalArgumentException("Unknown ListStatus code '" + codeString + "'");
155    }
156
157    public Enumeration<ListStatus> fromType(Base code) throws FHIRException {
158      if (code == null || code.isEmpty())
159        return null;
160      String codeString = ((PrimitiveType) code).asStringValue();
161      if (codeString == null || "".equals(codeString))
162        return null;
163      if ("current".equals(codeString))
164        return new Enumeration<ListStatus>(this, ListStatus.CURRENT);
165      if ("retired".equals(codeString))
166        return new Enumeration<ListStatus>(this, ListStatus.RETIRED);
167      if ("entered-in-error".equals(codeString))
168        return new Enumeration<ListStatus>(this, ListStatus.ENTEREDINERROR);
169      throw new FHIRException("Unknown ListStatus code '" + codeString + "'");
170    }
171
172    public String toCode(ListStatus code)
173   {
174       if (code == ListStatus.NULL)
175           return null;
176       if (code == ListStatus.CURRENT)
177        return "current";
178      if (code == ListStatus.RETIRED)
179        return "retired";
180      if (code == ListStatus.ENTEREDINERROR)
181        return "entered-in-error";
182      return "?";
183   }
184  }
185
186  public enum ListMode {
187    /**
188     * This list is the master list, maintained in an ongoing fashion with regular
189     * updates as the real world list it is tracking changes
190     */
191    WORKING,
192    /**
193     * This list was prepared as a snapshot. It should not be assumed to be current
194     */
195    SNAPSHOT,
196    /**
197     * A list that indicates where changes have been made or recommended
198     */
199    CHANGES,
200    /**
201     * added to help the parsers
202     */
203    NULL;
204
205    public static ListMode fromCode(String codeString) throws FHIRException {
206      if (codeString == null || "".equals(codeString))
207        return null;
208      if ("working".equals(codeString))
209        return WORKING;
210      if ("snapshot".equals(codeString))
211        return SNAPSHOT;
212      if ("changes".equals(codeString))
213        return CHANGES;
214      throw new FHIRException("Unknown ListMode code '" + codeString + "'");
215    }
216
217    public String toCode() {
218      switch (this) {
219      case WORKING:
220        return "working";
221      case SNAPSHOT:
222        return "snapshot";
223      case CHANGES:
224        return "changes";
225      case NULL:
226        return null;
227      default:
228        return "?";
229      }
230    }
231
232    public String getSystem() {
233      switch (this) {
234      case WORKING:
235        return "http://hl7.org/fhir/list-mode";
236      case SNAPSHOT:
237        return "http://hl7.org/fhir/list-mode";
238      case CHANGES:
239        return "http://hl7.org/fhir/list-mode";
240      case NULL:
241        return null;
242      default:
243        return "?";
244      }
245    }
246
247    public String getDefinition() {
248      switch (this) {
249      case WORKING:
250        return "This list is the master list, maintained in an ongoing fashion with regular updates as the real world list it is tracking changes";
251      case SNAPSHOT:
252        return "This list was prepared as a snapshot. It should not be assumed to be current";
253      case CHANGES:
254        return "A list that indicates where changes have been made or recommended";
255      case NULL:
256        return null;
257      default:
258        return "?";
259      }
260    }
261
262    public String getDisplay() {
263      switch (this) {
264      case WORKING:
265        return "Working List";
266      case SNAPSHOT:
267        return "Snapshot List";
268      case CHANGES:
269        return "Change List";
270      case NULL:
271        return null;
272      default:
273        return "?";
274      }
275    }
276  }
277
278  public static class ListModeEnumFactory implements EnumFactory<ListMode> {
279    public ListMode fromCode(String codeString) throws IllegalArgumentException {
280      if (codeString == null || "".equals(codeString))
281        if (codeString == null || "".equals(codeString))
282          return null;
283      if ("working".equals(codeString))
284        return ListMode.WORKING;
285      if ("snapshot".equals(codeString))
286        return ListMode.SNAPSHOT;
287      if ("changes".equals(codeString))
288        return ListMode.CHANGES;
289      throw new IllegalArgumentException("Unknown ListMode code '" + codeString + "'");
290    }
291
292    public Enumeration<ListMode> fromType(Base code) throws FHIRException {
293      if (code == null || code.isEmpty())
294        return null;
295      String codeString = ((PrimitiveType) code).asStringValue();
296      if (codeString == null || "".equals(codeString))
297        return null;
298      if ("working".equals(codeString))
299        return new Enumeration<ListMode>(this, ListMode.WORKING);
300      if ("snapshot".equals(codeString))
301        return new Enumeration<ListMode>(this, ListMode.SNAPSHOT);
302      if ("changes".equals(codeString))
303        return new Enumeration<ListMode>(this, ListMode.CHANGES);
304      throw new FHIRException("Unknown ListMode code '" + codeString + "'");
305    }
306
307    public String toCode(ListMode code)
308   {
309       if (code == ListMode.NULL)
310           return null;
311       if (code == ListMode.WORKING)
312        return "working";
313      if (code == ListMode.SNAPSHOT)
314        return "snapshot";
315      if (code == ListMode.CHANGES)
316        return "changes";
317      return "?";
318   }
319  }
320
321  @Block()
322  public static class ListEntryComponent extends BackboneElement implements IBaseBackboneElement {
323    /**
324     * The flag allows the system constructing the list to indicate the role and
325     * significance of the item in the list.
326     */
327    @Child(name = "flag", type = {
328        CodeableConcept.class }, order = 1, min = 0, max = 1, modifier = false, summary = false)
329    @Description(shortDefinition = "Status/Workflow information about this item", formalDefinition = "The flag allows the system constructing the list to indicate the role and significance of the item in the list.")
330    protected CodeableConcept flag;
331
332    /**
333     * True if this item is marked as deleted in the list.
334     */
335    @Child(name = "deleted", type = {
336        BooleanType.class }, order = 2, min = 0, max = 1, modifier = true, summary = false)
337    @Description(shortDefinition = "If this item is actually marked as deleted", formalDefinition = "True if this item is marked as deleted in the list.")
338    protected BooleanType deleted;
339
340    /**
341     * When this item was added to the list.
342     */
343    @Child(name = "date", type = { DateTimeType.class }, order = 3, min = 0, max = 1, modifier = false, summary = false)
344    @Description(shortDefinition = "When item added to list", formalDefinition = "When this item was added to the list.")
345    protected DateTimeType date;
346
347    /**
348     * A reference to the actual resource from which data was derived.
349     */
350    @Child(name = "item", type = {}, order = 4, min = 1, max = 1, modifier = false, summary = false)
351    @Description(shortDefinition = "Actual entry", formalDefinition = "A reference to the actual resource from which data was derived.")
352    protected Reference item;
353
354    /**
355     * The actual object that is the target of the reference (A reference to the
356     * actual resource from which data was derived.)
357     */
358    protected Resource itemTarget;
359
360    private static final long serialVersionUID = -758164425L;
361
362    /*
363     * Constructor
364     */
365    public ListEntryComponent() {
366      super();
367    }
368
369    /*
370     * Constructor
371     */
372    public ListEntryComponent(Reference item) {
373      super();
374      this.item = item;
375    }
376
377    /**
378     * @return {@link #flag} (The flag allows the system constructing the list to
379     *         indicate the role and significance of the item in the list.)
380     */
381    public CodeableConcept getFlag() {
382      if (this.flag == null)
383        if (Configuration.errorOnAutoCreate())
384          throw new Error("Attempt to auto-create ListEntryComponent.flag");
385        else if (Configuration.doAutoCreate())
386          this.flag = new CodeableConcept(); // cc
387      return this.flag;
388    }
389
390    public boolean hasFlag() {
391      return this.flag != null && !this.flag.isEmpty();
392    }
393
394    /**
395     * @param value {@link #flag} (The flag allows the system constructing the list
396     *              to indicate the role and significance of the item in the list.)
397     */
398    public ListEntryComponent setFlag(CodeableConcept value) {
399      this.flag = value;
400      return this;
401    }
402
403    /**
404     * @return {@link #deleted} (True if this item is marked as deleted in the
405     *         list.). This is the underlying object with id, value and extensions.
406     *         The accessor "getDeleted" gives direct access to the value
407     */
408    public BooleanType getDeletedElement() {
409      if (this.deleted == null)
410        if (Configuration.errorOnAutoCreate())
411          throw new Error("Attempt to auto-create ListEntryComponent.deleted");
412        else if (Configuration.doAutoCreate())
413          this.deleted = new BooleanType(); // bb
414      return this.deleted;
415    }
416
417    public boolean hasDeletedElement() {
418      return this.deleted != null && !this.deleted.isEmpty();
419    }
420
421    public boolean hasDeleted() {
422      return this.deleted != null && !this.deleted.isEmpty();
423    }
424
425    /**
426     * @param value {@link #deleted} (True if this item is marked as deleted in the
427     *              list.). This is the underlying object with id, value and
428     *              extensions. The accessor "getDeleted" gives direct access to the
429     *              value
430     */
431    public ListEntryComponent setDeletedElement(BooleanType value) {
432      this.deleted = value;
433      return this;
434    }
435
436    /**
437     * @return True if this item is marked as deleted in the list.
438     */
439    public boolean getDeleted() {
440      return this.deleted == null || this.deleted.isEmpty() ? false : this.deleted.getValue();
441    }
442
443    /**
444     * @param value True if this item is marked as deleted in the list.
445     */
446    public ListEntryComponent setDeleted(boolean value) {
447      if (this.deleted == null)
448        this.deleted = new BooleanType();
449      this.deleted.setValue(value);
450      return this;
451    }
452
453    /**
454     * @return {@link #date} (When this item was added to the list.). This is the
455     *         underlying object with id, value and extensions. The accessor
456     *         "getDate" gives direct access to the value
457     */
458    public DateTimeType getDateElement() {
459      if (this.date == null)
460        if (Configuration.errorOnAutoCreate())
461          throw new Error("Attempt to auto-create ListEntryComponent.date");
462        else if (Configuration.doAutoCreate())
463          this.date = new DateTimeType(); // bb
464      return this.date;
465    }
466
467    public boolean hasDateElement() {
468      return this.date != null && !this.date.isEmpty();
469    }
470
471    public boolean hasDate() {
472      return this.date != null && !this.date.isEmpty();
473    }
474
475    /**
476     * @param value {@link #date} (When this item was added to the list.). This is
477     *              the underlying object with id, value and extensions. The
478     *              accessor "getDate" gives direct access to the value
479     */
480    public ListEntryComponent setDateElement(DateTimeType value) {
481      this.date = value;
482      return this;
483    }
484
485    /**
486     * @return When this item was added to the list.
487     */
488    public Date getDate() {
489      return this.date == null ? null : this.date.getValue();
490    }
491
492    /**
493     * @param value When this item was added to the list.
494     */
495    public ListEntryComponent setDate(Date value) {
496      if (value == null)
497        this.date = null;
498      else {
499        if (this.date == null)
500          this.date = new DateTimeType();
501        this.date.setValue(value);
502      }
503      return this;
504    }
505
506    /**
507     * @return {@link #item} (A reference to the actual resource from which data was
508     *         derived.)
509     */
510    public Reference getItem() {
511      if (this.item == null)
512        if (Configuration.errorOnAutoCreate())
513          throw new Error("Attempt to auto-create ListEntryComponent.item");
514        else if (Configuration.doAutoCreate())
515          this.item = new Reference(); // cc
516      return this.item;
517    }
518
519    public boolean hasItem() {
520      return this.item != null && !this.item.isEmpty();
521    }
522
523    /**
524     * @param value {@link #item} (A reference to the actual resource from which
525     *              data was derived.)
526     */
527    public ListEntryComponent setItem(Reference value) {
528      this.item = value;
529      return this;
530    }
531
532    /**
533     * @return {@link #item} The actual object that is the target of the reference.
534     *         The reference library doesn't populate this, but you can use it to
535     *         hold the resource if you resolve it. (A reference to the actual
536     *         resource from which data was derived.)
537     */
538    public Resource getItemTarget() {
539      return this.itemTarget;
540    }
541
542    /**
543     * @param value {@link #item} The actual object that is the target of the
544     *              reference. The reference library doesn't use these, but you can
545     *              use it to hold the resource if you resolve it. (A reference to
546     *              the actual resource from which data was derived.)
547     */
548    public ListEntryComponent setItemTarget(Resource value) {
549      this.itemTarget = value;
550      return this;
551    }
552
553    protected void listChildren(List<Property> childrenList) {
554      super.listChildren(childrenList);
555      childrenList.add(new Property("flag", "CodeableConcept",
556          "The flag allows the system constructing the list to indicate the role and significance of the item in the list.",
557          0, java.lang.Integer.MAX_VALUE, flag));
558      childrenList.add(new Property("deleted", "boolean", "True if this item is marked as deleted in the list.", 0,
559          java.lang.Integer.MAX_VALUE, deleted));
560      childrenList.add(new Property("date", "dateTime", "When this item was added to the list.", 0,
561          java.lang.Integer.MAX_VALUE, date));
562      childrenList.add(new Property("item", "Reference(Any)",
563          "A reference to the actual resource from which data was derived.", 0, java.lang.Integer.MAX_VALUE, item));
564    }
565
566    @Override
567    public void setProperty(String name, Base value) throws FHIRException {
568      if (name.equals("flag"))
569        this.flag = castToCodeableConcept(value); // CodeableConcept
570      else if (name.equals("deleted"))
571        this.deleted = castToBoolean(value); // BooleanType
572      else if (name.equals("date"))
573        this.date = castToDateTime(value); // DateTimeType
574      else if (name.equals("item"))
575        this.item = castToReference(value); // Reference
576      else
577        super.setProperty(name, value);
578    }
579
580    @Override
581    public Base addChild(String name) throws FHIRException {
582      if (name.equals("flag")) {
583        this.flag = new CodeableConcept();
584        return this.flag;
585      } else if (name.equals("deleted")) {
586        throw new FHIRException("Cannot call addChild on a singleton property List_.deleted");
587      } else if (name.equals("date")) {
588        throw new FHIRException("Cannot call addChild on a singleton property List_.date");
589      } else if (name.equals("item")) {
590        this.item = new Reference();
591        return this.item;
592      } else
593        return super.addChild(name);
594    }
595
596    public ListEntryComponent copy() {
597      ListEntryComponent dst = new ListEntryComponent();
598      copyValues(dst);
599      dst.flag = flag == null ? null : flag.copy();
600      dst.deleted = deleted == null ? null : deleted.copy();
601      dst.date = date == null ? null : date.copy();
602      dst.item = item == null ? null : item.copy();
603      return dst;
604    }
605
606    @Override
607    public boolean equalsDeep(Base other) {
608      if (!super.equalsDeep(other))
609        return false;
610      if (!(other instanceof ListEntryComponent))
611        return false;
612      ListEntryComponent o = (ListEntryComponent) other;
613      return compareDeep(flag, o.flag, true) && compareDeep(deleted, o.deleted, true) && compareDeep(date, o.date, true)
614          && compareDeep(item, o.item, true);
615    }
616
617    @Override
618    public boolean equalsShallow(Base other) {
619      if (!super.equalsShallow(other))
620        return false;
621      if (!(other instanceof ListEntryComponent))
622        return false;
623      ListEntryComponent o = (ListEntryComponent) other;
624      return compareValues(deleted, o.deleted, true) && compareValues(date, o.date, true);
625    }
626
627    public boolean isEmpty() {
628      return super.isEmpty() && (flag == null || flag.isEmpty()) && (deleted == null || deleted.isEmpty())
629          && (date == null || date.isEmpty()) && (item == null || item.isEmpty());
630    }
631
632    public String fhirType() {
633      return "List.entry";
634
635    }
636
637  }
638
639  /**
640   * Identifier for the List assigned for business purposes outside the context of
641   * FHIR.
642   */
643  @Child(name = "identifier", type = {
644      Identifier.class }, order = 0, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
645  @Description(shortDefinition = "Business identifier", formalDefinition = "Identifier for the List assigned for business purposes outside the context of FHIR.")
646  protected List<Identifier> identifier;
647
648  /**
649   * A label for the list assigned by the author.
650   */
651  @Child(name = "title", type = { StringType.class }, order = 1, min = 0, max = 1, modifier = false, summary = true)
652  @Description(shortDefinition = "Descriptive name for the list", formalDefinition = "A label for the list assigned by the author.")
653  protected StringType title;
654
655  /**
656   * This code defines the purpose of the list - why it was created.
657   */
658  @Child(name = "code", type = { CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
659  @Description(shortDefinition = "What the purpose of this list is", formalDefinition = "This code defines the purpose of the list - why it was created.")
660  protected CodeableConcept code;
661
662  /**
663   * The common subject (or patient) of the resources that are in the list, if
664   * there is one.
665   */
666  @Child(name = "subject", type = { Patient.class, Group.class, Device.class,
667      Location.class }, order = 3, min = 0, max = 1, modifier = false, summary = true)
668  @Description(shortDefinition = "If all resources have the same subject", formalDefinition = "The common subject (or patient) of the resources that are in the list, if there is one.")
669  protected Reference subject;
670
671  /**
672   * The actual object that is the target of the reference (The common subject (or
673   * patient) of the resources that are in the list, if there is one.)
674   */
675  protected Resource subjectTarget;
676
677  /**
678   * The entity responsible for deciding what the contents of the list were. Where
679   * the list was created by a human, this is the same as the author of the list.
680   */
681  @Child(name = "source", type = { Practitioner.class, Patient.class,
682      Device.class }, order = 4, min = 0, max = 1, modifier = false, summary = true)
683  @Description(shortDefinition = "Who and/or what defined the list contents (aka Author)", formalDefinition = "The entity responsible for deciding what the contents of the list were. Where the list was created by a human, this is the same as the author of the list.")
684  protected Reference source;
685
686  /**
687   * The actual object that is the target of the reference (The entity responsible
688   * for deciding what the contents of the list were. Where the list was created
689   * by a human, this is the same as the author of the list.)
690   */
691  protected Resource sourceTarget;
692
693  /**
694   * The encounter that is the context in which this list was created.
695   */
696  @Child(name = "encounter", type = { Encounter.class }, order = 5, min = 0, max = 1, modifier = false, summary = false)
697  @Description(shortDefinition = "Context in which list created", formalDefinition = "The encounter that is the context in which this list was created.")
698  protected Reference encounter;
699
700  /**
701   * The actual object that is the target of the reference (The encounter that is
702   * the context in which this list was created.)
703   */
704  protected Encounter encounterTarget;
705
706  /**
707   * Indicates the current state of this list.
708   */
709  @Child(name = "status", type = { CodeType.class }, order = 6, min = 1, max = 1, modifier = true, summary = true)
710  @Description(shortDefinition = "current | retired | entered-in-error", formalDefinition = "Indicates the current state of this list.")
711  protected Enumeration<ListStatus> status;
712
713  /**
714   * The date that the list was prepared.
715   */
716  @Child(name = "date", type = { DateTimeType.class }, order = 7, min = 0, max = 1, modifier = false, summary = true)
717  @Description(shortDefinition = "When the list was prepared", formalDefinition = "The date that the list was prepared.")
718  protected DateTimeType date;
719
720  /**
721   * What order applies to the items in the list.
722   */
723  @Child(name = "orderedBy", type = {
724      CodeableConcept.class }, order = 8, min = 0, max = 1, modifier = false, summary = false)
725  @Description(shortDefinition = "What order the list has", formalDefinition = "What order applies to the items in the list.")
726  protected CodeableConcept orderedBy;
727
728  /**
729   * How this list was prepared - whether it is a working list that is suitable
730   * for being maintained on an ongoing basis, or if it represents a snapshot of a
731   * list of items from another source, or whether it is a prepared list where
732   * items may be marked as added, modified or deleted.
733   */
734  @Child(name = "mode", type = { CodeType.class }, order = 9, min = 1, max = 1, modifier = true, summary = true)
735  @Description(shortDefinition = "working | snapshot | changes", formalDefinition = "How this list was prepared - whether it is a working list that is suitable for being maintained on an ongoing basis, or if it represents a snapshot of a list of items from another source, or whether it is a prepared list where items may be marked as added, modified or deleted.")
736  protected Enumeration<ListMode> mode;
737
738  /**
739   * Comments that apply to the overall list.
740   */
741  @Child(name = "note", type = { StringType.class }, order = 10, min = 0, max = 1, modifier = false, summary = false)
742  @Description(shortDefinition = "Comments about the list", formalDefinition = "Comments that apply to the overall list.")
743  protected StringType note;
744
745  /**
746   * Entries in this list.
747   */
748  @Child(name = "entry", type = {}, order = 11, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
749  @Description(shortDefinition = "Entries in the list", formalDefinition = "Entries in this list.")
750  protected List<ListEntryComponent> entry;
751
752  /**
753   * If the list is empty, why the list is empty.
754   */
755  @Child(name = "emptyReason", type = {
756      CodeableConcept.class }, order = 12, min = 0, max = 1, modifier = false, summary = false)
757  @Description(shortDefinition = "Why list is empty", formalDefinition = "If the list is empty, why the list is empty.")
758  protected CodeableConcept emptyReason;
759
760  private static final long serialVersionUID = 1819128642L;
761
762  /*
763   * Constructor
764   */
765  public List_() {
766    super();
767  }
768
769  /*
770   * Constructor
771   */
772  public List_(Enumeration<ListStatus> status, Enumeration<ListMode> mode) {
773    super();
774    this.status = status;
775    this.mode = mode;
776  }
777
778  /**
779   * @return {@link #identifier} (Identifier for the List assigned for business
780   *         purposes outside the context of FHIR.)
781   */
782  public List<Identifier> getIdentifier() {
783    if (this.identifier == null)
784      this.identifier = new ArrayList<Identifier>();
785    return this.identifier;
786  }
787
788  public boolean hasIdentifier() {
789    if (this.identifier == null)
790      return false;
791    for (Identifier item : this.identifier)
792      if (!item.isEmpty())
793        return true;
794    return false;
795  }
796
797  /**
798   * @return {@link #identifier} (Identifier for the List assigned for business
799   *         purposes outside the context of FHIR.)
800   */
801  // syntactic sugar
802  public Identifier addIdentifier() { // 3
803    Identifier t = new Identifier();
804    if (this.identifier == null)
805      this.identifier = new ArrayList<Identifier>();
806    this.identifier.add(t);
807    return t;
808  }
809
810  // syntactic sugar
811  public List_ addIdentifier(Identifier t) { // 3
812    if (t == null)
813      return this;
814    if (this.identifier == null)
815      this.identifier = new ArrayList<Identifier>();
816    this.identifier.add(t);
817    return this;
818  }
819
820  /**
821   * @return {@link #title} (A label for the list assigned by the author.). This
822   *         is the underlying object with id, value and extensions. The accessor
823   *         "getTitle" gives direct access to the value
824   */
825  public StringType getTitleElement() {
826    if (this.title == null)
827      if (Configuration.errorOnAutoCreate())
828        throw new Error("Attempt to auto-create List_.title");
829      else if (Configuration.doAutoCreate())
830        this.title = new StringType(); // bb
831    return this.title;
832  }
833
834  public boolean hasTitleElement() {
835    return this.title != null && !this.title.isEmpty();
836  }
837
838  public boolean hasTitle() {
839    return this.title != null && !this.title.isEmpty();
840  }
841
842  /**
843   * @param value {@link #title} (A label for the list assigned by the author.).
844   *              This is the underlying object with id, value and extensions. The
845   *              accessor "getTitle" gives direct access to the value
846   */
847  public List_ setTitleElement(StringType value) {
848    this.title = value;
849    return this;
850  }
851
852  /**
853   * @return A label for the list assigned by the author.
854   */
855  public String getTitle() {
856    return this.title == null ? null : this.title.getValue();
857  }
858
859  /**
860   * @param value A label for the list assigned by the author.
861   */
862  public List_ setTitle(String value) {
863    if (Utilities.noString(value))
864      this.title = null;
865    else {
866      if (this.title == null)
867        this.title = new StringType();
868      this.title.setValue(value);
869    }
870    return this;
871  }
872
873  /**
874   * @return {@link #code} (This code defines the purpose of the list - why it was
875   *         created.)
876   */
877  public CodeableConcept getCode() {
878    if (this.code == null)
879      if (Configuration.errorOnAutoCreate())
880        throw new Error("Attempt to auto-create List_.code");
881      else if (Configuration.doAutoCreate())
882        this.code = new CodeableConcept(); // cc
883    return this.code;
884  }
885
886  public boolean hasCode() {
887    return this.code != null && !this.code.isEmpty();
888  }
889
890  /**
891   * @param value {@link #code} (This code defines the purpose of the list - why
892   *              it was created.)
893   */
894  public List_ setCode(CodeableConcept value) {
895    this.code = value;
896    return this;
897  }
898
899  /**
900   * @return {@link #subject} (The common subject (or patient) of the resources
901   *         that are in the list, if there is one.)
902   */
903  public Reference getSubject() {
904    if (this.subject == null)
905      if (Configuration.errorOnAutoCreate())
906        throw new Error("Attempt to auto-create List_.subject");
907      else if (Configuration.doAutoCreate())
908        this.subject = new Reference(); // cc
909    return this.subject;
910  }
911
912  public boolean hasSubject() {
913    return this.subject != null && !this.subject.isEmpty();
914  }
915
916  /**
917   * @param value {@link #subject} (The common subject (or patient) of the
918   *              resources that are in the list, if there is one.)
919   */
920  public List_ setSubject(Reference value) {
921    this.subject = value;
922    return this;
923  }
924
925  /**
926   * @return {@link #subject} The actual object that is the target of the
927   *         reference. The reference library doesn't populate this, but you can
928   *         use it to hold the resource if you resolve it. (The common subject
929   *         (or patient) of the resources that are in the list, if there is one.)
930   */
931  public Resource getSubjectTarget() {
932    return this.subjectTarget;
933  }
934
935  /**
936   * @param value {@link #subject} The actual object that is the target of the
937   *              reference. The reference library doesn't use these, but you can
938   *              use it to hold the resource if you resolve it. (The common
939   *              subject (or patient) of the resources that are in the list, if
940   *              there is one.)
941   */
942  public List_ setSubjectTarget(Resource value) {
943    this.subjectTarget = value;
944    return this;
945  }
946
947  /**
948   * @return {@link #source} (The entity responsible for deciding what the
949   *         contents of the list were. Where the list was created by a human,
950   *         this is the same as the author of the list.)
951   */
952  public Reference getSource() {
953    if (this.source == null)
954      if (Configuration.errorOnAutoCreate())
955        throw new Error("Attempt to auto-create List_.source");
956      else if (Configuration.doAutoCreate())
957        this.source = new Reference(); // cc
958    return this.source;
959  }
960
961  public boolean hasSource() {
962    return this.source != null && !this.source.isEmpty();
963  }
964
965  /**
966   * @param value {@link #source} (The entity responsible for deciding what the
967   *              contents of the list were. Where the list was created by a
968   *              human, this is the same as the author of the list.)
969   */
970  public List_ setSource(Reference value) {
971    this.source = value;
972    return this;
973  }
974
975  /**
976   * @return {@link #source} The actual object that is the target of the
977   *         reference. The reference library doesn't populate this, but you can
978   *         use it to hold the resource if you resolve it. (The entity
979   *         responsible for deciding what the contents of the list were. Where
980   *         the list was created by a human, this is the same as the author of
981   *         the list.)
982   */
983  public Resource getSourceTarget() {
984    return this.sourceTarget;
985  }
986
987  /**
988   * @param value {@link #source} The actual object that is the target of the
989   *              reference. The reference library doesn't use these, but you can
990   *              use it to hold the resource if you resolve it. (The entity
991   *              responsible for deciding what the contents of the list were.
992   *              Where the list was created by a human, this is the same as the
993   *              author of the list.)
994   */
995  public List_ setSourceTarget(Resource value) {
996    this.sourceTarget = value;
997    return this;
998  }
999
1000  /**
1001   * @return {@link #encounter} (The encounter that is the context in which this
1002   *         list was created.)
1003   */
1004  public Reference getEncounter() {
1005    if (this.encounter == null)
1006      if (Configuration.errorOnAutoCreate())
1007        throw new Error("Attempt to auto-create List_.encounter");
1008      else if (Configuration.doAutoCreate())
1009        this.encounter = new Reference(); // cc
1010    return this.encounter;
1011  }
1012
1013  public boolean hasEncounter() {
1014    return this.encounter != null && !this.encounter.isEmpty();
1015  }
1016
1017  /**
1018   * @param value {@link #encounter} (The encounter that is the context in which
1019   *              this list was created.)
1020   */
1021  public List_ setEncounter(Reference value) {
1022    this.encounter = value;
1023    return this;
1024  }
1025
1026  /**
1027   * @return {@link #encounter} The actual object that is the target of the
1028   *         reference. The reference library doesn't populate this, but you can
1029   *         use it to hold the resource if you resolve it. (The encounter that is
1030   *         the context in which this list was created.)
1031   */
1032  public Encounter getEncounterTarget() {
1033    if (this.encounterTarget == null)
1034      if (Configuration.errorOnAutoCreate())
1035        throw new Error("Attempt to auto-create List_.encounter");
1036      else if (Configuration.doAutoCreate())
1037        this.encounterTarget = new Encounter(); // aa
1038    return this.encounterTarget;
1039  }
1040
1041  /**
1042   * @param value {@link #encounter} The actual object that is the target of the
1043   *              reference. The reference library doesn't use these, but you can
1044   *              use it to hold the resource if you resolve it. (The encounter
1045   *              that is the context in which this list was created.)
1046   */
1047  public List_ setEncounterTarget(Encounter value) {
1048    this.encounterTarget = value;
1049    return this;
1050  }
1051
1052  /**
1053   * @return {@link #status} (Indicates the current state of this list.). This is
1054   *         the underlying object with id, value and extensions. The accessor
1055   *         "getStatus" gives direct access to the value
1056   */
1057  public Enumeration<ListStatus> getStatusElement() {
1058    if (this.status == null)
1059      if (Configuration.errorOnAutoCreate())
1060        throw new Error("Attempt to auto-create List_.status");
1061      else if (Configuration.doAutoCreate())
1062        this.status = new Enumeration<ListStatus>(new ListStatusEnumFactory()); // bb
1063    return this.status;
1064  }
1065
1066  public boolean hasStatusElement() {
1067    return this.status != null && !this.status.isEmpty();
1068  }
1069
1070  public boolean hasStatus() {
1071    return this.status != null && !this.status.isEmpty();
1072  }
1073
1074  /**
1075   * @param value {@link #status} (Indicates the current state of this list.).
1076   *              This is the underlying object with id, value and extensions. The
1077   *              accessor "getStatus" gives direct access to the value
1078   */
1079  public List_ setStatusElement(Enumeration<ListStatus> value) {
1080    this.status = value;
1081    return this;
1082  }
1083
1084  /**
1085   * @return Indicates the current state of this list.
1086   */
1087  public ListStatus getStatus() {
1088    return this.status == null ? null : this.status.getValue();
1089  }
1090
1091  /**
1092   * @param value Indicates the current state of this list.
1093   */
1094  public List_ setStatus(ListStatus value) {
1095    if (this.status == null)
1096      this.status = new Enumeration<ListStatus>(new ListStatusEnumFactory());
1097    this.status.setValue(value);
1098    return this;
1099  }
1100
1101  /**
1102   * @return {@link #date} (The date that the list was prepared.). This is the
1103   *         underlying object with id, value and extensions. The accessor
1104   *         "getDate" gives direct access to the value
1105   */
1106  public DateTimeType getDateElement() {
1107    if (this.date == null)
1108      if (Configuration.errorOnAutoCreate())
1109        throw new Error("Attempt to auto-create List_.date");
1110      else if (Configuration.doAutoCreate())
1111        this.date = new DateTimeType(); // bb
1112    return this.date;
1113  }
1114
1115  public boolean hasDateElement() {
1116    return this.date != null && !this.date.isEmpty();
1117  }
1118
1119  public boolean hasDate() {
1120    return this.date != null && !this.date.isEmpty();
1121  }
1122
1123  /**
1124   * @param value {@link #date} (The date that the list was prepared.). This is
1125   *              the underlying object with id, value and extensions. The
1126   *              accessor "getDate" gives direct access to the value
1127   */
1128  public List_ setDateElement(DateTimeType value) {
1129    this.date = value;
1130    return this;
1131  }
1132
1133  /**
1134   * @return The date that the list was prepared.
1135   */
1136  public Date getDate() {
1137    return this.date == null ? null : this.date.getValue();
1138  }
1139
1140  /**
1141   * @param value The date that the list was prepared.
1142   */
1143  public List_ setDate(Date value) {
1144    if (value == null)
1145      this.date = null;
1146    else {
1147      if (this.date == null)
1148        this.date = new DateTimeType();
1149      this.date.setValue(value);
1150    }
1151    return this;
1152  }
1153
1154  /**
1155   * @return {@link #orderedBy} (What order applies to the items in the list.)
1156   */
1157  public CodeableConcept getOrderedBy() {
1158    if (this.orderedBy == null)
1159      if (Configuration.errorOnAutoCreate())
1160        throw new Error("Attempt to auto-create List_.orderedBy");
1161      else if (Configuration.doAutoCreate())
1162        this.orderedBy = new CodeableConcept(); // cc
1163    return this.orderedBy;
1164  }
1165
1166  public boolean hasOrderedBy() {
1167    return this.orderedBy != null && !this.orderedBy.isEmpty();
1168  }
1169
1170  /**
1171   * @param value {@link #orderedBy} (What order applies to the items in the
1172   *              list.)
1173   */
1174  public List_ setOrderedBy(CodeableConcept value) {
1175    this.orderedBy = value;
1176    return this;
1177  }
1178
1179  /**
1180   * @return {@link #mode} (How this list was prepared - whether it is a working
1181   *         list that is suitable for being maintained on an ongoing basis, or if
1182   *         it represents a snapshot of a list of items from another source, or
1183   *         whether it is a prepared list where items may be marked as added,
1184   *         modified or deleted.). This is the underlying object with id, value
1185   *         and extensions. The accessor "getMode" gives direct access to the
1186   *         value
1187   */
1188  public Enumeration<ListMode> getModeElement() {
1189    if (this.mode == null)
1190      if (Configuration.errorOnAutoCreate())
1191        throw new Error("Attempt to auto-create List_.mode");
1192      else if (Configuration.doAutoCreate())
1193        this.mode = new Enumeration<ListMode>(new ListModeEnumFactory()); // bb
1194    return this.mode;
1195  }
1196
1197  public boolean hasModeElement() {
1198    return this.mode != null && !this.mode.isEmpty();
1199  }
1200
1201  public boolean hasMode() {
1202    return this.mode != null && !this.mode.isEmpty();
1203  }
1204
1205  /**
1206   * @param value {@link #mode} (How this list was prepared - whether it is a
1207   *              working list that is suitable for being maintained on an ongoing
1208   *              basis, or if it represents a snapshot of a list of items from
1209   *              another source, or whether it is a prepared list where items may
1210   *              be marked as added, modified or deleted.). This is the
1211   *              underlying object with id, value and extensions. The accessor
1212   *              "getMode" gives direct access to the value
1213   */
1214  public List_ setModeElement(Enumeration<ListMode> value) {
1215    this.mode = value;
1216    return this;
1217  }
1218
1219  /**
1220   * @return How this list was prepared - whether it is a working list that is
1221   *         suitable for being maintained on an ongoing basis, or if it
1222   *         represents a snapshot of a list of items from another source, or
1223   *         whether it is a prepared list where items may be marked as added,
1224   *         modified or deleted.
1225   */
1226  public ListMode getMode() {
1227    return this.mode == null ? null : this.mode.getValue();
1228  }
1229
1230  /**
1231   * @param value How this list was prepared - whether it is a working list that
1232   *              is suitable for being maintained on an ongoing basis, or if it
1233   *              represents a snapshot of a list of items from another source, or
1234   *              whether it is a prepared list where items may be marked as
1235   *              added, modified or deleted.
1236   */
1237  public List_ setMode(ListMode value) {
1238    if (this.mode == null)
1239      this.mode = new Enumeration<ListMode>(new ListModeEnumFactory());
1240    this.mode.setValue(value);
1241    return this;
1242  }
1243
1244  /**
1245   * @return {@link #note} (Comments that apply to the overall list.). This is the
1246   *         underlying object with id, value and extensions. The accessor
1247   *         "getNote" gives direct access to the value
1248   */
1249  public StringType getNoteElement() {
1250    if (this.note == null)
1251      if (Configuration.errorOnAutoCreate())
1252        throw new Error("Attempt to auto-create List_.note");
1253      else if (Configuration.doAutoCreate())
1254        this.note = new StringType(); // bb
1255    return this.note;
1256  }
1257
1258  public boolean hasNoteElement() {
1259    return this.note != null && !this.note.isEmpty();
1260  }
1261
1262  public boolean hasNote() {
1263    return this.note != null && !this.note.isEmpty();
1264  }
1265
1266  /**
1267   * @param value {@link #note} (Comments that apply to the overall list.). This
1268   *              is the underlying object with id, value and extensions. The
1269   *              accessor "getNote" gives direct access to the value
1270   */
1271  public List_ setNoteElement(StringType value) {
1272    this.note = value;
1273    return this;
1274  }
1275
1276  /**
1277   * @return Comments that apply to the overall list.
1278   */
1279  public String getNote() {
1280    return this.note == null ? null : this.note.getValue();
1281  }
1282
1283  /**
1284   * @param value Comments that apply to the overall list.
1285   */
1286  public List_ setNote(String value) {
1287    if (Utilities.noString(value))
1288      this.note = null;
1289    else {
1290      if (this.note == null)
1291        this.note = new StringType();
1292      this.note.setValue(value);
1293    }
1294    return this;
1295  }
1296
1297  /**
1298   * @return {@link #entry} (Entries in this list.)
1299   */
1300  public List<ListEntryComponent> getEntry() {
1301    if (this.entry == null)
1302      this.entry = new ArrayList<ListEntryComponent>();
1303    return this.entry;
1304  }
1305
1306  public boolean hasEntry() {
1307    if (this.entry == null)
1308      return false;
1309    for (ListEntryComponent item : this.entry)
1310      if (!item.isEmpty())
1311        return true;
1312    return false;
1313  }
1314
1315  /**
1316   * @return {@link #entry} (Entries in this list.)
1317   */
1318  // syntactic sugar
1319  public ListEntryComponent addEntry() { // 3
1320    ListEntryComponent t = new ListEntryComponent();
1321    if (this.entry == null)
1322      this.entry = new ArrayList<ListEntryComponent>();
1323    this.entry.add(t);
1324    return t;
1325  }
1326
1327  // syntactic sugar
1328  public List_ addEntry(ListEntryComponent t) { // 3
1329    if (t == null)
1330      return this;
1331    if (this.entry == null)
1332      this.entry = new ArrayList<ListEntryComponent>();
1333    this.entry.add(t);
1334    return this;
1335  }
1336
1337  /**
1338   * @return {@link #emptyReason} (If the list is empty, why the list is empty.)
1339   */
1340  public CodeableConcept getEmptyReason() {
1341    if (this.emptyReason == null)
1342      if (Configuration.errorOnAutoCreate())
1343        throw new Error("Attempt to auto-create List_.emptyReason");
1344      else if (Configuration.doAutoCreate())
1345        this.emptyReason = new CodeableConcept(); // cc
1346    return this.emptyReason;
1347  }
1348
1349  public boolean hasEmptyReason() {
1350    return this.emptyReason != null && !this.emptyReason.isEmpty();
1351  }
1352
1353  /**
1354   * @param value {@link #emptyReason} (If the list is empty, why the list is
1355   *              empty.)
1356   */
1357  public List_ setEmptyReason(CodeableConcept value) {
1358    this.emptyReason = value;
1359    return this;
1360  }
1361
1362  protected void listChildren(List<Property> childrenList) {
1363    super.listChildren(childrenList);
1364    childrenList.add(new Property("identifier", "Identifier",
1365        "Identifier for the List assigned for business purposes outside the context of FHIR.", 0,
1366        java.lang.Integer.MAX_VALUE, identifier));
1367    childrenList.add(new Property("title", "string", "A label for the list assigned by the author.", 0,
1368        java.lang.Integer.MAX_VALUE, title));
1369    childrenList.add(new Property("code", "CodeableConcept",
1370        "This code defines the purpose of the list - why it was created.", 0, java.lang.Integer.MAX_VALUE, code));
1371    childrenList.add(new Property("subject", "Reference(Patient|Group|Device|Location)",
1372        "The common subject (or patient) of the resources that are in the list, if there is one.", 0,
1373        java.lang.Integer.MAX_VALUE, subject));
1374    childrenList.add(new Property("source", "Reference(Practitioner|Patient|Device)",
1375        "The entity responsible for deciding what the contents of the list were. Where the list was created by a human, this is the same as the author of the list.",
1376        0, java.lang.Integer.MAX_VALUE, source));
1377    childrenList.add(new Property("encounter", "Reference(Encounter)",
1378        "The encounter that is the context in which this list was created.", 0, java.lang.Integer.MAX_VALUE,
1379        encounter));
1380    childrenList.add(new Property("status", "code", "Indicates the current state of this list.", 0,
1381        java.lang.Integer.MAX_VALUE, status));
1382    childrenList.add(
1383        new Property("date", "dateTime", "The date that the list was prepared.", 0, java.lang.Integer.MAX_VALUE, date));
1384    childrenList.add(new Property("orderedBy", "CodeableConcept", "What order applies to the items in the list.", 0,
1385        java.lang.Integer.MAX_VALUE, orderedBy));
1386    childrenList.add(new Property("mode", "code",
1387        "How this list was prepared - whether it is a working list that is suitable for being maintained on an ongoing basis, or if it represents a snapshot of a list of items from another source, or whether it is a prepared list where items may be marked as added, modified or deleted.",
1388        0, java.lang.Integer.MAX_VALUE, mode));
1389    childrenList.add(new Property("note", "string", "Comments that apply to the overall list.", 0,
1390        java.lang.Integer.MAX_VALUE, note));
1391    childrenList.add(new Property("entry", "", "Entries in this list.", 0, java.lang.Integer.MAX_VALUE, entry));
1392    childrenList.add(new Property("emptyReason", "CodeableConcept", "If the list is empty, why the list is empty.", 0,
1393        java.lang.Integer.MAX_VALUE, emptyReason));
1394  }
1395
1396  @Override
1397  public void setProperty(String name, Base value) throws FHIRException {
1398    if (name.equals("identifier"))
1399      this.getIdentifier().add(castToIdentifier(value));
1400    else if (name.equals("title"))
1401      this.title = castToString(value); // StringType
1402    else if (name.equals("code"))
1403      this.code = castToCodeableConcept(value); // CodeableConcept
1404    else if (name.equals("subject"))
1405      this.subject = castToReference(value); // Reference
1406    else if (name.equals("source"))
1407      this.source = castToReference(value); // Reference
1408    else if (name.equals("encounter"))
1409      this.encounter = castToReference(value); // Reference
1410    else if (name.equals("status"))
1411      this.status = new ListStatusEnumFactory().fromType(value); // Enumeration<ListStatus>
1412    else if (name.equals("date"))
1413      this.date = castToDateTime(value); // DateTimeType
1414    else if (name.equals("orderedBy"))
1415      this.orderedBy = castToCodeableConcept(value); // CodeableConcept
1416    else if (name.equals("mode"))
1417      this.mode = new ListModeEnumFactory().fromType(value); // Enumeration<ListMode>
1418    else if (name.equals("note"))
1419      this.note = castToString(value); // StringType
1420    else if (name.equals("entry"))
1421      this.getEntry().add((ListEntryComponent) value);
1422    else if (name.equals("emptyReason"))
1423      this.emptyReason = castToCodeableConcept(value); // CodeableConcept
1424    else
1425      super.setProperty(name, value);
1426  }
1427
1428  @Override
1429  public Base addChild(String name) throws FHIRException {
1430    if (name.equals("identifier")) {
1431      return addIdentifier();
1432    } else if (name.equals("title")) {
1433      throw new FHIRException("Cannot call addChild on a singleton property List_.title");
1434    } else if (name.equals("code")) {
1435      this.code = new CodeableConcept();
1436      return this.code;
1437    } else if (name.equals("subject")) {
1438      this.subject = new Reference();
1439      return this.subject;
1440    } else if (name.equals("source")) {
1441      this.source = new Reference();
1442      return this.source;
1443    } else if (name.equals("encounter")) {
1444      this.encounter = new Reference();
1445      return this.encounter;
1446    } else if (name.equals("status")) {
1447      throw new FHIRException("Cannot call addChild on a singleton property List_.status");
1448    } else if (name.equals("date")) {
1449      throw new FHIRException("Cannot call addChild on a singleton property List_.date");
1450    } else if (name.equals("orderedBy")) {
1451      this.orderedBy = new CodeableConcept();
1452      return this.orderedBy;
1453    } else if (name.equals("mode")) {
1454      throw new FHIRException("Cannot call addChild on a singleton property List_.mode");
1455    } else if (name.equals("note")) {
1456      throw new FHIRException("Cannot call addChild on a singleton property List_.note");
1457    } else if (name.equals("entry")) {
1458      return addEntry();
1459    } else if (name.equals("emptyReason")) {
1460      this.emptyReason = new CodeableConcept();
1461      return this.emptyReason;
1462    } else
1463      return super.addChild(name);
1464  }
1465
1466  public String fhirType() {
1467    return "List";
1468
1469  }
1470
1471  public List_ copy() {
1472    List_ dst = new List_();
1473    copyValues(dst);
1474    if (identifier != null) {
1475      dst.identifier = new ArrayList<Identifier>();
1476      for (Identifier i : identifier)
1477        dst.identifier.add(i.copy());
1478    }
1479    ;
1480    dst.title = title == null ? null : title.copy();
1481    dst.code = code == null ? null : code.copy();
1482    dst.subject = subject == null ? null : subject.copy();
1483    dst.source = source == null ? null : source.copy();
1484    dst.encounter = encounter == null ? null : encounter.copy();
1485    dst.status = status == null ? null : status.copy();
1486    dst.date = date == null ? null : date.copy();
1487    dst.orderedBy = orderedBy == null ? null : orderedBy.copy();
1488    dst.mode = mode == null ? null : mode.copy();
1489    dst.note = note == null ? null : note.copy();
1490    if (entry != null) {
1491      dst.entry = new ArrayList<ListEntryComponent>();
1492      for (ListEntryComponent i : entry)
1493        dst.entry.add(i.copy());
1494    }
1495    ;
1496    dst.emptyReason = emptyReason == null ? null : emptyReason.copy();
1497    return dst;
1498  }
1499
1500  protected List_ typedCopy() {
1501    return copy();
1502  }
1503
1504  @Override
1505  public boolean equalsDeep(Base other) {
1506    if (!super.equalsDeep(other))
1507      return false;
1508    if (!(other instanceof List_))
1509      return false;
1510    List_ o = (List_) other;
1511    return compareDeep(identifier, o.identifier, true) && compareDeep(title, o.title, true)
1512        && compareDeep(code, o.code, true) && compareDeep(subject, o.subject, true)
1513        && compareDeep(source, o.source, true) && compareDeep(encounter, o.encounter, true)
1514        && compareDeep(status, o.status, true) && compareDeep(date, o.date, true)
1515        && compareDeep(orderedBy, o.orderedBy, true) && compareDeep(mode, o.mode, true)
1516        && compareDeep(note, o.note, true) && compareDeep(entry, o.entry, true)
1517        && compareDeep(emptyReason, o.emptyReason, true);
1518  }
1519
1520  @Override
1521  public boolean equalsShallow(Base other) {
1522    if (!super.equalsShallow(other))
1523      return false;
1524    if (!(other instanceof List_))
1525      return false;
1526    List_ o = (List_) other;
1527    return compareValues(title, o.title, true) && compareValues(status, o.status, true)
1528        && compareValues(date, o.date, true) && compareValues(mode, o.mode, true) && compareValues(note, o.note, true);
1529  }
1530
1531  public boolean isEmpty() {
1532    return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (title == null || title.isEmpty())
1533        && (code == null || code.isEmpty()) && (subject == null || subject.isEmpty())
1534        && (source == null || source.isEmpty()) && (encounter == null || encounter.isEmpty())
1535        && (status == null || status.isEmpty()) && (date == null || date.isEmpty())
1536        && (orderedBy == null || orderedBy.isEmpty()) && (mode == null || mode.isEmpty())
1537        && (note == null || note.isEmpty()) && (entry == null || entry.isEmpty())
1538        && (emptyReason == null || emptyReason.isEmpty());
1539  }
1540
1541  @Override
1542  public ResourceType getResourceType() {
1543    return ResourceType.List;
1544  }
1545
1546  @SearchParamDefinition(name = "date", path = "List.date", description = "When the list was prepared", type = "date")
1547  public static final String SP_DATE = "date";
1548  @SearchParamDefinition(name = "item", path = "List.entry.item", description = "Actual entry", type = "reference")
1549  public static final String SP_ITEM = "item";
1550  @SearchParamDefinition(name = "empty-reason", path = "List.emptyReason", description = "Why list is empty", type = "token")
1551  public static final String SP_EMPTYREASON = "empty-reason";
1552  @SearchParamDefinition(name = "code", path = "List.code", description = "What the purpose of this list is", type = "token")
1553  public static final String SP_CODE = "code";
1554  @SearchParamDefinition(name = "notes", path = "List.note", description = "Comments about the list", type = "string")
1555  public static final String SP_NOTES = "notes";
1556  @SearchParamDefinition(name = "subject", path = "List.subject", description = "If all resources have the same subject", type = "reference")
1557  public static final String SP_SUBJECT = "subject";
1558  @SearchParamDefinition(name = "patient", path = "List.subject", description = "If all resources have the same subject", type = "reference")
1559  public static final String SP_PATIENT = "patient";
1560  @SearchParamDefinition(name = "source", path = "List.source", description = "Who and/or what defined the list contents (aka Author)", type = "reference")
1561  public static final String SP_SOURCE = "source";
1562  @SearchParamDefinition(name = "encounter", path = "List.encounter", description = "Context in which list created", type = "reference")
1563  public static final String SP_ENCOUNTER = "encounter";
1564  @SearchParamDefinition(name = "title", path = "List.title", description = "Descriptive name for the list", type = "string")
1565  public static final String SP_TITLE = "title";
1566  @SearchParamDefinition(name = "status", path = "List.status", description = "current | retired | entered-in-error", type = "token")
1567  public static final String SP_STATUS = "status";
1568
1569}