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