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