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