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