001package org.hl7.fhir.r4.model;
002
003
004
005/*
006  Copyright (c) 2011+, HL7, Inc.
007  All rights reserved.
008  
009  Redistribution and use in source and binary forms, with or without modification, 
010  are permitted provided that the following conditions are met:
011  
012   * Redistributions of source code must retain the above copyright notice, this 
013     list of conditions and the following disclaimer.
014   * Redistributions in binary form must reproduce the above copyright notice, 
015     this list of conditions and the following disclaimer in the documentation 
016     and/or other materials provided with the distribution.
017   * Neither the name of HL7 nor the names of its contributors may be used to 
018     endorse or promote products derived from this software without specific 
019     prior written permission.
020  
021  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
022  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
023  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
024  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
025  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
026  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
027  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
028  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
029  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
030  POSSIBILITY OF SUCH DAMAGE.
031  
032*/
033
034
035// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
036
037import java.util.*;
038
039import org.hl7.fhir.utilities.Utilities;
040import ca.uhn.fhir.model.api.annotation.ResourceDef;
041import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
042import ca.uhn.fhir.model.api.annotation.Child;
043import ca.uhn.fhir.model.api.annotation.ChildOrder;
044import ca.uhn.fhir.model.api.annotation.Description;
045import ca.uhn.fhir.model.api.annotation.Block;
046import org.hl7.fhir.instance.model.api.*;
047import org.hl7.fhir.exceptions.FHIRException;
048/**
049 * Prospective warnings of potential issues when providing care to the patient.
050 */
051@ResourceDef(name="Flag", profile="http://hl7.org/fhir/StructureDefinition/Flag")
052public class Flag extends DomainResource {
053
054    public enum FlagStatus {
055        /**
056         * A current flag that should be displayed to a user. A system may use the category to determine which user roles should view the flag.
057         */
058        ACTIVE, 
059        /**
060         * The flag no longer needs to be displayed.
061         */
062        INACTIVE, 
063        /**
064         * The flag was added in error and should no longer be displayed.
065         */
066        ENTEREDINERROR, 
067        /**
068         * added to help the parsers with the generic types
069         */
070        NULL;
071        public static FlagStatus fromCode(String codeString) throws FHIRException {
072            if (codeString == null || "".equals(codeString))
073                return null;
074        if ("active".equals(codeString))
075          return ACTIVE;
076        if ("inactive".equals(codeString))
077          return INACTIVE;
078        if ("entered-in-error".equals(codeString))
079          return ENTEREDINERROR;
080        if (Configuration.isAcceptInvalidEnums())
081          return null;
082        else
083          throw new FHIRException("Unknown FlagStatus code '"+codeString+"'");
084        }
085        public String toCode() {
086          switch (this) {
087            case ACTIVE: return "active";
088            case INACTIVE: return "inactive";
089            case ENTEREDINERROR: return "entered-in-error";
090            default: return "?";
091          }
092        }
093        public String getSystem() {
094          switch (this) {
095            case ACTIVE: return "http://hl7.org/fhir/flag-status";
096            case INACTIVE: return "http://hl7.org/fhir/flag-status";
097            case ENTEREDINERROR: return "http://hl7.org/fhir/flag-status";
098            default: return "?";
099          }
100        }
101        public String getDefinition() {
102          switch (this) {
103            case ACTIVE: return "A current flag that should be displayed to a user. A system may use the category to determine which user roles should view the flag.";
104            case INACTIVE: return "The flag no longer needs to be displayed.";
105            case ENTEREDINERROR: return "The flag was added in error and should no longer be displayed.";
106            default: return "?";
107          }
108        }
109        public String getDisplay() {
110          switch (this) {
111            case ACTIVE: return "Active";
112            case INACTIVE: return "Inactive";
113            case ENTEREDINERROR: return "Entered in Error";
114            default: return "?";
115          }
116        }
117    }
118
119  public static class FlagStatusEnumFactory implements EnumFactory<FlagStatus> {
120    public FlagStatus fromCode(String codeString) throws IllegalArgumentException {
121      if (codeString == null || "".equals(codeString))
122            if (codeString == null || "".equals(codeString))
123                return null;
124        if ("active".equals(codeString))
125          return FlagStatus.ACTIVE;
126        if ("inactive".equals(codeString))
127          return FlagStatus.INACTIVE;
128        if ("entered-in-error".equals(codeString))
129          return FlagStatus.ENTEREDINERROR;
130        throw new IllegalArgumentException("Unknown FlagStatus code '"+codeString+"'");
131        }
132        public Enumeration<FlagStatus> fromType(Base code) throws FHIRException {
133          if (code == null)
134            return null;
135          if (code.isEmpty())
136            return new Enumeration<FlagStatus>(this);
137          String codeString = ((PrimitiveType) code).asStringValue();
138          if (codeString == null || "".equals(codeString))
139            return null;
140        if ("active".equals(codeString))
141          return new Enumeration<FlagStatus>(this, FlagStatus.ACTIVE);
142        if ("inactive".equals(codeString))
143          return new Enumeration<FlagStatus>(this, FlagStatus.INACTIVE);
144        if ("entered-in-error".equals(codeString))
145          return new Enumeration<FlagStatus>(this, FlagStatus.ENTEREDINERROR);
146        throw new FHIRException("Unknown FlagStatus code '"+codeString+"'");
147        }
148    public String toCode(FlagStatus code) {
149      if (code == FlagStatus.ACTIVE)
150        return "active";
151      if (code == FlagStatus.INACTIVE)
152        return "inactive";
153      if (code == FlagStatus.ENTEREDINERROR)
154        return "entered-in-error";
155      return "?";
156      }
157    public String toSystem(FlagStatus code) {
158      return code.getSystem();
159      }
160    }
161
162    /**
163     * Business identifiers assigned to this flag by the performer or other systems which remain constant as the resource is updated and propagates from server to server.
164     */
165    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
166    @Description(shortDefinition="Business identifier", formalDefinition="Business identifiers assigned to this flag by the performer or other systems which remain constant as the resource is updated and propagates from server to server." )
167    protected List<Identifier> identifier;
168
169    /**
170     * Supports basic workflow.
171     */
172    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
173    @Description(shortDefinition="active | inactive | entered-in-error", formalDefinition="Supports basic workflow." )
174    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/flag-status")
175    protected Enumeration<FlagStatus> status;
176
177    /**
178     * Allows a flag to be divided into different categories like clinical, administrative etc. Intended to be used as a means of filtering which flags are displayed to particular user or in a given context.
179     */
180    @Child(name = "category", type = {CodeableConcept.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
181    @Description(shortDefinition="Clinical, administrative, etc.", formalDefinition="Allows a flag to be divided into different categories like clinical, administrative etc. Intended to be used as a means of filtering which flags are displayed to particular user or in a given context." )
182    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/flag-category")
183    protected List<CodeableConcept> category;
184
185    /**
186     * The coded value or textual component of the flag to display to the user.
187     */
188    @Child(name = "code", type = {CodeableConcept.class}, order=3, min=1, max=1, modifier=false, summary=true)
189    @Description(shortDefinition="Coded or textual message to display to user", formalDefinition="The coded value or textual component of the flag to display to the user." )
190    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/flag-code")
191    protected CodeableConcept code;
192
193    /**
194     * The patient, location, group, organization, or practitioner etc. this is about record this flag is associated with.
195     */
196    @Child(name = "subject", type = {Patient.class, Location.class, Group.class, Organization.class, Practitioner.class, PlanDefinition.class, Medication.class, Procedure.class}, order=4, min=1, max=1, modifier=false, summary=true)
197    @Description(shortDefinition="Who/What is flag about?", formalDefinition="The patient, location, group, organization, or practitioner etc. this is about record this flag is associated with." )
198    protected Reference subject;
199
200    /**
201     * The actual object that is the target of the reference (The patient, location, group, organization, or practitioner etc. this is about record this flag is associated with.)
202     */
203    protected Resource subjectTarget;
204
205    /**
206     * The period of time from the activation of the flag to inactivation of the flag. If the flag is active, the end of the period should be unspecified.
207     */
208    @Child(name = "period", type = {Period.class}, order=5, min=0, max=1, modifier=false, summary=true)
209    @Description(shortDefinition="Time period when flag is active", formalDefinition="The period of time from the activation of the flag to inactivation of the flag. If the flag is active, the end of the period should be unspecified." )
210    protected Period period;
211
212    /**
213     * This alert is only relevant during the encounter.
214     */
215    @Child(name = "encounter", type = {Encounter.class}, order=6, min=0, max=1, modifier=false, summary=true)
216    @Description(shortDefinition="Alert relevant during encounter", formalDefinition="This alert is only relevant during the encounter." )
217    protected Reference encounter;
218
219    /**
220     * The actual object that is the target of the reference (This alert is only relevant during the encounter.)
221     */
222    protected Encounter encounterTarget;
223
224    /**
225     * The person, organization or device that created the flag.
226     */
227    @Child(name = "author", type = {Device.class, Organization.class, Patient.class, Practitioner.class, PractitionerRole.class}, order=7, min=0, max=1, modifier=false, summary=true)
228    @Description(shortDefinition="Flag creator", formalDefinition="The person, organization or device that created the flag." )
229    protected Reference author;
230
231    /**
232     * The actual object that is the target of the reference (The person, organization or device that created the flag.)
233     */
234    protected Resource authorTarget;
235
236    private static final long serialVersionUID = 163791439L;
237
238  /**
239   * Constructor
240   */
241    public Flag() {
242      super();
243    }
244
245  /**
246   * Constructor
247   */
248    public Flag(Enumeration<FlagStatus> status, CodeableConcept code, Reference subject) {
249      super();
250      this.status = status;
251      this.code = code;
252      this.subject = subject;
253    }
254
255    /**
256     * @return {@link #identifier} (Business identifiers assigned to this flag by the performer or other systems which remain constant as the resource is updated and propagates from server to server.)
257     */
258    public List<Identifier> getIdentifier() { 
259      if (this.identifier == null)
260        this.identifier = new ArrayList<Identifier>();
261      return this.identifier;
262    }
263
264    /**
265     * @return Returns a reference to <code>this</code> for easy method chaining
266     */
267    public Flag setIdentifier(List<Identifier> theIdentifier) { 
268      this.identifier = theIdentifier;
269      return this;
270    }
271
272    public boolean hasIdentifier() { 
273      if (this.identifier == null)
274        return false;
275      for (Identifier item : this.identifier)
276        if (!item.isEmpty())
277          return true;
278      return false;
279    }
280
281    public Identifier addIdentifier() { //3
282      Identifier t = new Identifier();
283      if (this.identifier == null)
284        this.identifier = new ArrayList<Identifier>();
285      this.identifier.add(t);
286      return t;
287    }
288
289    public Flag addIdentifier(Identifier t) { //3
290      if (t == null)
291        return this;
292      if (this.identifier == null)
293        this.identifier = new ArrayList<Identifier>();
294      this.identifier.add(t);
295      return this;
296    }
297
298    /**
299     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
300     */
301    public Identifier getIdentifierFirstRep() { 
302      if (getIdentifier().isEmpty()) {
303        addIdentifier();
304      }
305      return getIdentifier().get(0);
306    }
307
308    /**
309     * @return {@link #status} (Supports basic workflow.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
310     */
311    public Enumeration<FlagStatus> getStatusElement() { 
312      if (this.status == null)
313        if (Configuration.errorOnAutoCreate())
314          throw new Error("Attempt to auto-create Flag.status");
315        else if (Configuration.doAutoCreate())
316          this.status = new Enumeration<FlagStatus>(new FlagStatusEnumFactory()); // bb
317      return this.status;
318    }
319
320    public boolean hasStatusElement() { 
321      return this.status != null && !this.status.isEmpty();
322    }
323
324    public boolean hasStatus() { 
325      return this.status != null && !this.status.isEmpty();
326    }
327
328    /**
329     * @param value {@link #status} (Supports basic workflow.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
330     */
331    public Flag setStatusElement(Enumeration<FlagStatus> value) { 
332      this.status = value;
333      return this;
334    }
335
336    /**
337     * @return Supports basic workflow.
338     */
339    public FlagStatus getStatus() { 
340      return this.status == null ? null : this.status.getValue();
341    }
342
343    /**
344     * @param value Supports basic workflow.
345     */
346    public Flag setStatus(FlagStatus value) { 
347        if (this.status == null)
348          this.status = new Enumeration<FlagStatus>(new FlagStatusEnumFactory());
349        this.status.setValue(value);
350      return this;
351    }
352
353    /**
354     * @return {@link #category} (Allows a flag to be divided into different categories like clinical, administrative etc. Intended to be used as a means of filtering which flags are displayed to particular user or in a given context.)
355     */
356    public List<CodeableConcept> getCategory() { 
357      if (this.category == null)
358        this.category = new ArrayList<CodeableConcept>();
359      return this.category;
360    }
361
362    /**
363     * @return Returns a reference to <code>this</code> for easy method chaining
364     */
365    public Flag setCategory(List<CodeableConcept> theCategory) { 
366      this.category = theCategory;
367      return this;
368    }
369
370    public boolean hasCategory() { 
371      if (this.category == null)
372        return false;
373      for (CodeableConcept item : this.category)
374        if (!item.isEmpty())
375          return true;
376      return false;
377    }
378
379    public CodeableConcept addCategory() { //3
380      CodeableConcept t = new CodeableConcept();
381      if (this.category == null)
382        this.category = new ArrayList<CodeableConcept>();
383      this.category.add(t);
384      return t;
385    }
386
387    public Flag addCategory(CodeableConcept t) { //3
388      if (t == null)
389        return this;
390      if (this.category == null)
391        this.category = new ArrayList<CodeableConcept>();
392      this.category.add(t);
393      return this;
394    }
395
396    /**
397     * @return The first repetition of repeating field {@link #category}, creating it if it does not already exist
398     */
399    public CodeableConcept getCategoryFirstRep() { 
400      if (getCategory().isEmpty()) {
401        addCategory();
402      }
403      return getCategory().get(0);
404    }
405
406    /**
407     * @return {@link #code} (The coded value or textual component of the flag to display to the user.)
408     */
409    public CodeableConcept getCode() { 
410      if (this.code == null)
411        if (Configuration.errorOnAutoCreate())
412          throw new Error("Attempt to auto-create Flag.code");
413        else if (Configuration.doAutoCreate())
414          this.code = new CodeableConcept(); // cc
415      return this.code;
416    }
417
418    public boolean hasCode() { 
419      return this.code != null && !this.code.isEmpty();
420    }
421
422    /**
423     * @param value {@link #code} (The coded value or textual component of the flag to display to the user.)
424     */
425    public Flag setCode(CodeableConcept value) { 
426      this.code = value;
427      return this;
428    }
429
430    /**
431     * @return {@link #subject} (The patient, location, group, organization, or practitioner etc. this is about record this flag is associated with.)
432     */
433    public Reference getSubject() { 
434      if (this.subject == null)
435        if (Configuration.errorOnAutoCreate())
436          throw new Error("Attempt to auto-create Flag.subject");
437        else if (Configuration.doAutoCreate())
438          this.subject = new Reference(); // cc
439      return this.subject;
440    }
441
442    public boolean hasSubject() { 
443      return this.subject != null && !this.subject.isEmpty();
444    }
445
446    /**
447     * @param value {@link #subject} (The patient, location, group, organization, or practitioner etc. this is about record this flag is associated with.)
448     */
449    public Flag setSubject(Reference value) { 
450      this.subject = value;
451      return this;
452    }
453
454    /**
455     * @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 patient, location, group, organization, or practitioner etc. this is about record this flag is associated with.)
456     */
457    public Resource getSubjectTarget() { 
458      return this.subjectTarget;
459    }
460
461    /**
462     * @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 patient, location, group, organization, or practitioner etc. this is about record this flag is associated with.)
463     */
464    public Flag setSubjectTarget(Resource value) { 
465      this.subjectTarget = value;
466      return this;
467    }
468
469    /**
470     * @return {@link #period} (The period of time from the activation of the flag to inactivation of the flag. If the flag is active, the end of the period should be unspecified.)
471     */
472    public Period getPeriod() { 
473      if (this.period == null)
474        if (Configuration.errorOnAutoCreate())
475          throw new Error("Attempt to auto-create Flag.period");
476        else if (Configuration.doAutoCreate())
477          this.period = new Period(); // cc
478      return this.period;
479    }
480
481    public boolean hasPeriod() { 
482      return this.period != null && !this.period.isEmpty();
483    }
484
485    /**
486     * @param value {@link #period} (The period of time from the activation of the flag to inactivation of the flag. If the flag is active, the end of the period should be unspecified.)
487     */
488    public Flag setPeriod(Period value) { 
489      this.period = value;
490      return this;
491    }
492
493    /**
494     * @return {@link #encounter} (This alert is only relevant during the encounter.)
495     */
496    public Reference getEncounter() { 
497      if (this.encounter == null)
498        if (Configuration.errorOnAutoCreate())
499          throw new Error("Attempt to auto-create Flag.encounter");
500        else if (Configuration.doAutoCreate())
501          this.encounter = new Reference(); // cc
502      return this.encounter;
503    }
504
505    public boolean hasEncounter() { 
506      return this.encounter != null && !this.encounter.isEmpty();
507    }
508
509    /**
510     * @param value {@link #encounter} (This alert is only relevant during the encounter.)
511     */
512    public Flag setEncounter(Reference value) { 
513      this.encounter = value;
514      return this;
515    }
516
517    /**
518     * @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. (This alert is only relevant during the encounter.)
519     */
520    public Encounter getEncounterTarget() { 
521      if (this.encounterTarget == null)
522        if (Configuration.errorOnAutoCreate())
523          throw new Error("Attempt to auto-create Flag.encounter");
524        else if (Configuration.doAutoCreate())
525          this.encounterTarget = new Encounter(); // aa
526      return this.encounterTarget;
527    }
528
529    /**
530     * @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. (This alert is only relevant during the encounter.)
531     */
532    public Flag setEncounterTarget(Encounter value) { 
533      this.encounterTarget = value;
534      return this;
535    }
536
537    /**
538     * @return {@link #author} (The person, organization or device that created the flag.)
539     */
540    public Reference getAuthor() { 
541      if (this.author == null)
542        if (Configuration.errorOnAutoCreate())
543          throw new Error("Attempt to auto-create Flag.author");
544        else if (Configuration.doAutoCreate())
545          this.author = new Reference(); // cc
546      return this.author;
547    }
548
549    public boolean hasAuthor() { 
550      return this.author != null && !this.author.isEmpty();
551    }
552
553    /**
554     * @param value {@link #author} (The person, organization or device that created the flag.)
555     */
556    public Flag setAuthor(Reference value) { 
557      this.author = value;
558      return this;
559    }
560
561    /**
562     * @return {@link #author} 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 person, organization or device that created the flag.)
563     */
564    public Resource getAuthorTarget() { 
565      return this.authorTarget;
566    }
567
568    /**
569     * @param value {@link #author} 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 person, organization or device that created the flag.)
570     */
571    public Flag setAuthorTarget(Resource value) { 
572      this.authorTarget = value;
573      return this;
574    }
575
576      protected void listChildren(List<Property> children) {
577        super.listChildren(children);
578        children.add(new Property("identifier", "Identifier", "Business identifiers assigned to this flag by the performer or other systems which remain constant as the resource is updated and propagates from server to server.", 0, java.lang.Integer.MAX_VALUE, identifier));
579        children.add(new Property("status", "code", "Supports basic workflow.", 0, 1, status));
580        children.add(new Property("category", "CodeableConcept", "Allows a flag to be divided into different categories like clinical, administrative etc. Intended to be used as a means of filtering which flags are displayed to particular user or in a given context.", 0, java.lang.Integer.MAX_VALUE, category));
581        children.add(new Property("code", "CodeableConcept", "The coded value or textual component of the flag to display to the user.", 0, 1, code));
582        children.add(new Property("subject", "Reference(Patient|Location|Group|Organization|Practitioner|PlanDefinition|Medication|Procedure)", "The patient, location, group, organization, or practitioner etc. this is about record this flag is associated with.", 0, 1, subject));
583        children.add(new Property("period", "Period", "The period of time from the activation of the flag to inactivation of the flag. If the flag is active, the end of the period should be unspecified.", 0, 1, period));
584        children.add(new Property("encounter", "Reference(Encounter)", "This alert is only relevant during the encounter.", 0, 1, encounter));
585        children.add(new Property("author", "Reference(Device|Organization|Patient|Practitioner|PractitionerRole)", "The person, organization or device that created the flag.", 0, 1, author));
586      }
587
588      @Override
589      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
590        switch (_hash) {
591        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Business identifiers assigned to this flag by the performer or other systems which remain constant as the resource is updated and propagates from server to server.", 0, java.lang.Integer.MAX_VALUE, identifier);
592        case -892481550: /*status*/  return new Property("status", "code", "Supports basic workflow.", 0, 1, status);
593        case 50511102: /*category*/  return new Property("category", "CodeableConcept", "Allows a flag to be divided into different categories like clinical, administrative etc. Intended to be used as a means of filtering which flags are displayed to particular user or in a given context.", 0, java.lang.Integer.MAX_VALUE, category);
594        case 3059181: /*code*/  return new Property("code", "CodeableConcept", "The coded value or textual component of the flag to display to the user.", 0, 1, code);
595        case -1867885268: /*subject*/  return new Property("subject", "Reference(Patient|Location|Group|Organization|Practitioner|PlanDefinition|Medication|Procedure)", "The patient, location, group, organization, or practitioner etc. this is about record this flag is associated with.", 0, 1, subject);
596        case -991726143: /*period*/  return new Property("period", "Period", "The period of time from the activation of the flag to inactivation of the flag. If the flag is active, the end of the period should be unspecified.", 0, 1, period);
597        case 1524132147: /*encounter*/  return new Property("encounter", "Reference(Encounter)", "This alert is only relevant during the encounter.", 0, 1, encounter);
598        case -1406328437: /*author*/  return new Property("author", "Reference(Device|Organization|Patient|Practitioner|PractitionerRole)", "The person, organization or device that created the flag.", 0, 1, author);
599        default: return super.getNamedProperty(_hash, _name, _checkValid);
600        }
601
602      }
603
604      @Override
605      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
606        switch (hash) {
607        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
608        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<FlagStatus>
609        case 50511102: /*category*/ return this.category == null ? new Base[0] : this.category.toArray(new Base[this.category.size()]); // CodeableConcept
610        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
611        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
612        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
613        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : new Base[] {this.encounter}; // Reference
614        case -1406328437: /*author*/ return this.author == null ? new Base[0] : new Base[] {this.author}; // Reference
615        default: return super.getProperty(hash, name, checkValid);
616        }
617
618      }
619
620      @Override
621      public Base setProperty(int hash, String name, Base value) throws FHIRException {
622        switch (hash) {
623        case -1618432855: // identifier
624          this.getIdentifier().add(castToIdentifier(value)); // Identifier
625          return value;
626        case -892481550: // status
627          value = new FlagStatusEnumFactory().fromType(castToCode(value));
628          this.status = (Enumeration) value; // Enumeration<FlagStatus>
629          return value;
630        case 50511102: // category
631          this.getCategory().add(castToCodeableConcept(value)); // CodeableConcept
632          return value;
633        case 3059181: // code
634          this.code = castToCodeableConcept(value); // CodeableConcept
635          return value;
636        case -1867885268: // subject
637          this.subject = castToReference(value); // Reference
638          return value;
639        case -991726143: // period
640          this.period = castToPeriod(value); // Period
641          return value;
642        case 1524132147: // encounter
643          this.encounter = castToReference(value); // Reference
644          return value;
645        case -1406328437: // author
646          this.author = castToReference(value); // Reference
647          return value;
648        default: return super.setProperty(hash, name, value);
649        }
650
651      }
652
653      @Override
654      public Base setProperty(String name, Base value) throws FHIRException {
655        if (name.equals("identifier")) {
656          this.getIdentifier().add(castToIdentifier(value));
657        } else if (name.equals("status")) {
658          value = new FlagStatusEnumFactory().fromType(castToCode(value));
659          this.status = (Enumeration) value; // Enumeration<FlagStatus>
660        } else if (name.equals("category")) {
661          this.getCategory().add(castToCodeableConcept(value));
662        } else if (name.equals("code")) {
663          this.code = castToCodeableConcept(value); // CodeableConcept
664        } else if (name.equals("subject")) {
665          this.subject = castToReference(value); // Reference
666        } else if (name.equals("period")) {
667          this.period = castToPeriod(value); // Period
668        } else if (name.equals("encounter")) {
669          this.encounter = castToReference(value); // Reference
670        } else if (name.equals("author")) {
671          this.author = castToReference(value); // Reference
672        } else
673          return super.setProperty(name, value);
674        return value;
675      }
676
677      @Override
678      public Base makeProperty(int hash, String name) throws FHIRException {
679        switch (hash) {
680        case -1618432855:  return addIdentifier(); 
681        case -892481550:  return getStatusElement();
682        case 50511102:  return addCategory(); 
683        case 3059181:  return getCode(); 
684        case -1867885268:  return getSubject(); 
685        case -991726143:  return getPeriod(); 
686        case 1524132147:  return getEncounter(); 
687        case -1406328437:  return getAuthor(); 
688        default: return super.makeProperty(hash, name);
689        }
690
691      }
692
693      @Override
694      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
695        switch (hash) {
696        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
697        case -892481550: /*status*/ return new String[] {"code"};
698        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
699        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
700        case -1867885268: /*subject*/ return new String[] {"Reference"};
701        case -991726143: /*period*/ return new String[] {"Period"};
702        case 1524132147: /*encounter*/ return new String[] {"Reference"};
703        case -1406328437: /*author*/ return new String[] {"Reference"};
704        default: return super.getTypesForProperty(hash, name);
705        }
706
707      }
708
709      @Override
710      public Base addChild(String name) throws FHIRException {
711        if (name.equals("identifier")) {
712          return addIdentifier();
713        }
714        else if (name.equals("status")) {
715          throw new FHIRException("Cannot call addChild on a primitive type Flag.status");
716        }
717        else if (name.equals("category")) {
718          return addCategory();
719        }
720        else if (name.equals("code")) {
721          this.code = new CodeableConcept();
722          return this.code;
723        }
724        else if (name.equals("subject")) {
725          this.subject = new Reference();
726          return this.subject;
727        }
728        else if (name.equals("period")) {
729          this.period = new Period();
730          return this.period;
731        }
732        else if (name.equals("encounter")) {
733          this.encounter = new Reference();
734          return this.encounter;
735        }
736        else if (name.equals("author")) {
737          this.author = new Reference();
738          return this.author;
739        }
740        else
741          return super.addChild(name);
742      }
743
744  public String fhirType() {
745    return "Flag";
746
747  }
748
749      public Flag copy() {
750        Flag dst = new Flag();
751        copyValues(dst);
752        return dst;
753      }
754
755      public void copyValues(Flag dst) {
756        super.copyValues(dst);
757        if (identifier != null) {
758          dst.identifier = new ArrayList<Identifier>();
759          for (Identifier i : identifier)
760            dst.identifier.add(i.copy());
761        };
762        dst.status = status == null ? null : status.copy();
763        if (category != null) {
764          dst.category = new ArrayList<CodeableConcept>();
765          for (CodeableConcept i : category)
766            dst.category.add(i.copy());
767        };
768        dst.code = code == null ? null : code.copy();
769        dst.subject = subject == null ? null : subject.copy();
770        dst.period = period == null ? null : period.copy();
771        dst.encounter = encounter == null ? null : encounter.copy();
772        dst.author = author == null ? null : author.copy();
773      }
774
775      protected Flag typedCopy() {
776        return copy();
777      }
778
779      @Override
780      public boolean equalsDeep(Base other_) {
781        if (!super.equalsDeep(other_))
782          return false;
783        if (!(other_ instanceof Flag))
784          return false;
785        Flag o = (Flag) other_;
786        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(category, o.category, true)
787           && compareDeep(code, o.code, true) && compareDeep(subject, o.subject, true) && compareDeep(period, o.period, true)
788           && compareDeep(encounter, o.encounter, true) && compareDeep(author, o.author, true);
789      }
790
791      @Override
792      public boolean equalsShallow(Base other_) {
793        if (!super.equalsShallow(other_))
794          return false;
795        if (!(other_ instanceof Flag))
796          return false;
797        Flag o = (Flag) other_;
798        return compareValues(status, o.status, true);
799      }
800
801      public boolean isEmpty() {
802        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, category
803          , code, subject, period, encounter, author);
804      }
805
806  @Override
807  public ResourceType getResourceType() {
808    return ResourceType.Flag;
809   }
810
811 /**
812   * Search parameter: <b>date</b>
813   * <p>
814   * Description: <b>Time period when flag is active</b><br>
815   * Type: <b>date</b><br>
816   * Path: <b>Flag.period</b><br>
817   * </p>
818   */
819  @SearchParamDefinition(name="date", path="Flag.period", description="Time period when flag is active", type="date" )
820  public static final String SP_DATE = "date";
821 /**
822   * <b>Fluent Client</b> search parameter constant for <b>date</b>
823   * <p>
824   * Description: <b>Time period when flag is active</b><br>
825   * Type: <b>date</b><br>
826   * Path: <b>Flag.period</b><br>
827   * </p>
828   */
829  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
830
831 /**
832   * Search parameter: <b>identifier</b>
833   * <p>
834   * Description: <b>Business identifier</b><br>
835   * Type: <b>token</b><br>
836   * Path: <b>Flag.identifier</b><br>
837   * </p>
838   */
839  @SearchParamDefinition(name="identifier", path="Flag.identifier", description="Business identifier", type="token" )
840  public static final String SP_IDENTIFIER = "identifier";
841 /**
842   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
843   * <p>
844   * Description: <b>Business identifier</b><br>
845   * Type: <b>token</b><br>
846   * Path: <b>Flag.identifier</b><br>
847   * </p>
848   */
849  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
850
851 /**
852   * Search parameter: <b>subject</b>
853   * <p>
854   * Description: <b>The identity of a subject to list flags for</b><br>
855   * Type: <b>reference</b><br>
856   * Path: <b>Flag.subject</b><br>
857   * </p>
858   */
859  @SearchParamDefinition(name="subject", path="Flag.subject", description="The identity of a subject to list flags for", type="reference", target={Group.class, Location.class, Medication.class, Organization.class, Patient.class, PlanDefinition.class, Practitioner.class, Procedure.class } )
860  public static final String SP_SUBJECT = "subject";
861 /**
862   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
863   * <p>
864   * Description: <b>The identity of a subject to list flags for</b><br>
865   * Type: <b>reference</b><br>
866   * Path: <b>Flag.subject</b><br>
867   * </p>
868   */
869  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
870
871/**
872   * Constant for fluent queries to be used to add include statements. Specifies
873   * the path value of "<b>Flag:subject</b>".
874   */
875  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("Flag:subject").toLocked();
876
877 /**
878   * Search parameter: <b>patient</b>
879   * <p>
880   * Description: <b>The identity of a subject to list flags for</b><br>
881   * Type: <b>reference</b><br>
882   * Path: <b>Flag.subject</b><br>
883   * </p>
884   */
885  @SearchParamDefinition(name="patient", path="Flag.subject.where(resolve() is Patient)", description="The identity of a subject to list flags for", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Patient.class } )
886  public static final String SP_PATIENT = "patient";
887 /**
888   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
889   * <p>
890   * Description: <b>The identity of a subject to list flags for</b><br>
891   * Type: <b>reference</b><br>
892   * Path: <b>Flag.subject</b><br>
893   * </p>
894   */
895  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
896
897/**
898   * Constant for fluent queries to be used to add include statements. Specifies
899   * the path value of "<b>Flag:patient</b>".
900   */
901  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("Flag:patient").toLocked();
902
903 /**
904   * Search parameter: <b>author</b>
905   * <p>
906   * Description: <b>Flag creator</b><br>
907   * Type: <b>reference</b><br>
908   * Path: <b>Flag.author</b><br>
909   * </p>
910   */
911  @SearchParamDefinition(name="author", path="Flag.author", description="Flag creator", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Device"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={Device.class, Organization.class, Patient.class, Practitioner.class, PractitionerRole.class } )
912  public static final String SP_AUTHOR = "author";
913 /**
914   * <b>Fluent Client</b> search parameter constant for <b>author</b>
915   * <p>
916   * Description: <b>Flag creator</b><br>
917   * Type: <b>reference</b><br>
918   * Path: <b>Flag.author</b><br>
919   * </p>
920   */
921  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam AUTHOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_AUTHOR);
922
923/**
924   * Constant for fluent queries to be used to add include statements. Specifies
925   * the path value of "<b>Flag:author</b>".
926   */
927  public static final ca.uhn.fhir.model.api.Include INCLUDE_AUTHOR = new ca.uhn.fhir.model.api.Include("Flag:author").toLocked();
928
929 /**
930   * Search parameter: <b>encounter</b>
931   * <p>
932   * Description: <b>Alert relevant during encounter</b><br>
933   * Type: <b>reference</b><br>
934   * Path: <b>Flag.encounter</b><br>
935   * </p>
936   */
937  @SearchParamDefinition(name="encounter", path="Flag.encounter", description="Alert relevant during encounter", type="reference", target={Encounter.class } )
938  public static final String SP_ENCOUNTER = "encounter";
939 /**
940   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
941   * <p>
942   * Description: <b>Alert relevant during encounter</b><br>
943   * Type: <b>reference</b><br>
944   * Path: <b>Flag.encounter</b><br>
945   * </p>
946   */
947  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
948
949/**
950   * Constant for fluent queries to be used to add include statements. Specifies
951   * the path value of "<b>Flag:encounter</b>".
952   */
953  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("Flag:encounter").toLocked();
954
955
956}