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