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