001package org.hl7.fhir.r5.openehr;
002
003
004/*
005  Copyright (c) 2011+, HL7, Inc.
006  All rights reserved.
007  
008  Redistribution and use in source and binary forms, with or without modification, \
009  are permitted provided that the following conditions are met:
010  
011   * Redistributions of source code must retain the above copyright notice, this \
012     list of conditions and the following disclaimer.
013   * Redistributions in binary form must reproduce the above copyright notice, \
014     this list of conditions and the following disclaimer in the documentation \
015     and/or other materials provided with the distribution.
016   * Neither the name of HL7 nor the names of its contributors may be used to 
017     endorse or promote products derived from this software without specific 
018     prior written permission.
019  
020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
021  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
022  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
023  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
024  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
025  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
026  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
027  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
028  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
029  POSSIBILITY OF SUCH DAMAGE.
030  */
031
032// Generated on Thu, Mar 23, 2023 19:59+1100 for FHIR v5.0.0
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import org.hl7.fhir.r5.openehr.Enumerations.*;
038import org.hl7.fhir.exceptions.FHIRException;
039import org.hl7.fhir.r5.model.*;
040import org.hl7.fhir.instance.model.api.ICompositeType;
041import ca.uhn.fhir.model.api.annotation.Child;
042import ca.uhn.fhir.model.api.annotation.ChildOrder;
043import ca.uhn.fhir.model.api.annotation.DatatypeDef;
044import ca.uhn.fhir.model.api.annotation.Description;
045import ca.uhn.fhir.model.api.annotation.Block;
046
047/**
048 * Model of a participation of a Party (any Actor or Role) in an activity. Used to represent any participation of a Party in some activity, which is not explicitly in the model, e.g. assisting nurse. Can be used to record past or future participations. Should not be used in place of more permanent relationships between demographic entities.
049 */
050@DatatypeDef(name="PARTICIPATION")
051public class PARTICIPATION extends LOCATABLE implements ICompositeType {
052
053    /**
054     * Optional reference to more detailed demographic or identification information for this party, in an external system.
055     */
056    @Child(name = "function", type = {DV_TEXT.class}, order=0, min=1, max=1, modifier=false, summary=false)
057    @Description(shortDefinition="Reference to more detailed demographic or identification information for this party", formalDefinition="Optional reference to more detailed demographic or identification information for this party, in an external system." )
058    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="https://specifications.openehr.org/fhir/valueset-participation_function")
059    protected DV_TEXT function;
060
061    /**
062     * Optional reference to more detailed demographic or identification information for this party, in an external system.
063     */
064    @Child(name = "mode", type = {DV_CODED_TEXT.class}, order=1, min=0, max=1, modifier=false, summary=false)
065    @Description(shortDefinition="Reference to more detailed demographic or identification information for this party", formalDefinition="Optional reference to more detailed demographic or identification information for this party, in an external system." )
066    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="https://specifications.openehr.org/fhir/valueset-participation_mode")
067    protected DV_CODED_TEXT mode;
068
069    /**
070     * Optional reference to more detailed demographic or identification information for this party, in an external system.
071     */
072    @Child(name = "performer", type = {PARTY_PROXY.class}, order=2, min=1, max=1, modifier=false, summary=false)
073    @Description(shortDefinition="Reference to more detailed demographic or identification information for this party", formalDefinition="Optional reference to more detailed demographic or identification information for this party, in an external system." )
074    protected PARTY_PROXY performer;
075
076    /**
077     * Optional reference to more detailed demographic or identification information for this party, in an external system.
078     */
079    @Child(name = "time", type = {DV_INTERVAL.class}, order=3, min=0, max=1, modifier=false, summary=false)
080    @Description(shortDefinition="Reference to more detailed demographic or identification information for this party", formalDefinition="Optional reference to more detailed demographic or identification information for this party, in an external system." )
081    protected DV_INTERVAL time;
082
083    private static final long serialVersionUID = -595665945L;
084
085  /**
086   * Constructor
087   */
088    public PARTICIPATION() {
089      super();
090    }
091
092  /**
093   * Constructor
094   */
095    public PARTICIPATION(DV_TEXT function, PARTY_PROXY performer) {
096      super();
097      this.setFunction(function);
098      this.setPerformer(performer);
099    }
100
101    /**
102     * @return {@link #function} (Optional reference to more detailed demographic or identification information for this party, in an external system.)
103     */
104    public DV_TEXT getFunction() { 
105      if (this.function == null)
106        if (Configuration.errorOnAutoCreate())
107          throw new Error("Attempt to auto-create PARTICIPATION.function");
108        else if (Configuration.doAutoCreate())
109          this.function = new DV_TEXT(); // cc
110      return this.function;
111    }
112
113    public boolean hasFunction() { 
114      return this.function != null && !this.function.isEmpty();
115    }
116
117    /**
118     * @param value {@link #function} (Optional reference to more detailed demographic or identification information for this party, in an external system.)
119     */
120    public PARTICIPATION setFunction(DV_TEXT value) { 
121      this.function = value;
122      return this;
123    }
124
125    /**
126     * @return {@link #mode} (Optional reference to more detailed demographic or identification information for this party, in an external system.)
127     */
128    public DV_CODED_TEXT getMode() { 
129      if (this.mode == null)
130        if (Configuration.errorOnAutoCreate())
131          throw new Error("Attempt to auto-create PARTICIPATION.mode");
132        else if (Configuration.doAutoCreate())
133          this.mode = new DV_CODED_TEXT(); // cc
134      return this.mode;
135    }
136
137    public boolean hasMode() { 
138      return this.mode != null && !this.mode.isEmpty();
139    }
140
141    /**
142     * @param value {@link #mode} (Optional reference to more detailed demographic or identification information for this party, in an external system.)
143     */
144    public PARTICIPATION setMode(DV_CODED_TEXT value) { 
145      this.mode = value;
146      return this;
147    }
148
149    /**
150     * @return {@link #performer} (Optional reference to more detailed demographic or identification information for this party, in an external system.)
151     */
152    public PARTY_PROXY getPerformer() { 
153      return this.performer;
154    }
155
156    public boolean hasPerformer() { 
157      return this.performer != null && !this.performer.isEmpty();
158    }
159
160    /**
161     * @param value {@link #performer} (Optional reference to more detailed demographic or identification information for this party, in an external system.)
162     */
163    public PARTICIPATION setPerformer(PARTY_PROXY value) { 
164      this.performer = value;
165      return this;
166    }
167
168    /**
169     * @return {@link #time} (Optional reference to more detailed demographic or identification information for this party, in an external system.)
170     */
171    public DV_INTERVAL getTime() { 
172      if (this.time == null)
173        if (Configuration.errorOnAutoCreate())
174          throw new Error("Attempt to auto-create PARTICIPATION.time");
175        else if (Configuration.doAutoCreate())
176          this.time = new DV_INTERVAL(); // cc
177      return this.time;
178    }
179
180    public boolean hasTime() { 
181      return this.time != null && !this.time.isEmpty();
182    }
183
184    /**
185     * @param value {@link #time} (Optional reference to more detailed demographic or identification information for this party, in an external system.)
186     */
187    public PARTICIPATION setTime(DV_INTERVAL value) { 
188      this.time = value;
189      return this;
190    }
191
192      protected void listChildren(List<Property> children) {
193        super.listChildren(children);
194        children.add(new Property("function", "http://openehr.org/fhir/StructureDefinition/DV-TEXT", "Optional reference to more detailed demographic or identification information for this party, in an external system.", 0, 1, function));
195        children.add(new Property("mode", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "Optional reference to more detailed demographic or identification information for this party, in an external system.", 0, 1, mode));
196        children.add(new Property("performer", "http://openehr.org/fhir/StructureDefinition/PARTY-PROXY", "Optional reference to more detailed demographic or identification information for this party, in an external system.", 0, 1, performer));
197        children.add(new Property("time", "http://openehr.org/fhir/StructureDefinition/DV-INTERVAL", "Optional reference to more detailed demographic or identification information for this party, in an external system.", 0, 1, time));
198      }
199
200      @Override
201      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
202        switch (_hash) {
203        case 1380938712: /*function*/  return new Property("function", "http://openehr.org/fhir/StructureDefinition/DV-TEXT", "Optional reference to more detailed demographic or identification information for this party, in an external system.", 0, 1, function);
204        case 3357091: /*mode*/  return new Property("mode", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "Optional reference to more detailed demographic or identification information for this party, in an external system.", 0, 1, mode);
205        case 481140686: /*performer*/  return new Property("performer", "http://openehr.org/fhir/StructureDefinition/PARTY-PROXY", "Optional reference to more detailed demographic or identification information for this party, in an external system.", 0, 1, performer);
206        case 3560141: /*time*/  return new Property("time", "http://openehr.org/fhir/StructureDefinition/DV-INTERVAL", "Optional reference to more detailed demographic or identification information for this party, in an external system.", 0, 1, time);
207        default: return super.getNamedProperty(_hash, _name, _checkValid);
208        }
209
210      }
211
212      @Override
213      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
214        switch (hash) {
215        case 1380938712: /*function*/ return this.function == null ? new Base[0] : new Base[] {this.function}; // DV_TEXT
216        case 3357091: /*mode*/ return this.mode == null ? new Base[0] : new Base[] {this.mode}; // DV_CODED_TEXT
217        case 481140686: /*performer*/ return this.performer == null ? new Base[0] : new Base[] {this.performer}; // PARTY_PROXY
218        case 3560141: /*time*/ return this.time == null ? new Base[0] : new Base[] {this.time}; // DV_INTERVAL
219        default: return super.getProperty(hash, name, checkValid);
220        }
221
222      }
223
224      @Override
225      public Base setProperty(int hash, String name, Base value) throws FHIRException {
226        switch (hash) {
227        case 1380938712: // function
228          this.function = (DV_TEXT) value; // DV_TEXT
229          return value;
230        case 3357091: // mode
231          this.mode = (DV_CODED_TEXT) value; // DV_CODED_TEXT
232          return value;
233        case 481140686: // performer
234          this.performer = (PARTY_PROXY) value; // PARTY_PROXY
235          return value;
236        case 3560141: // time
237          this.time = (DV_INTERVAL) value; // DV_INTERVAL
238          return value;
239        default: return super.setProperty(hash, name, value);
240        }
241
242      }
243
244      @Override
245      public Base setProperty(String name, Base value) throws FHIRException {
246        if (name.equals("function")) {
247          this.function = (DV_TEXT) value; // DV_TEXT
248        } else if (name.equals("mode")) {
249          this.mode = (DV_CODED_TEXT) value; // DV_CODED_TEXT
250        } else if (name.equals("performer")) {
251          this.performer = (PARTY_PROXY) value; // PARTY_PROXY
252        } else if (name.equals("time")) {
253          this.time = (DV_INTERVAL) value; // DV_INTERVAL
254        } else
255          return super.setProperty(name, value);
256        return value;
257      }
258
259      @Override
260      public Base makeProperty(int hash, String name) throws FHIRException {
261        switch (hash) {
262        case 1380938712:  return getFunction();
263        case 3357091:  return getMode();
264        case 481140686: /*div*/
265          throw new Error("Unable to make an instance of the abstract property 'performer'");
266        case 3560141:  return getTime();
267        default: return super.makeProperty(hash, name);
268        }
269
270      }
271
272      @Override
273      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
274        switch (hash) {
275        case 1380938712: /*function*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-TEXT"};
276        case 3357091: /*mode*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT"};
277        case 481140686: /*performer*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/PARTY-PROXY"};
278        case 3560141: /*time*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-INTERVAL"};
279        default: return super.getTypesForProperty(hash, name);
280        }
281
282      }
283
284      @Override
285      public Base addChild(String name) throws FHIRException {
286        if (name.equals("function")) {
287          this.function = new DV_TEXT();
288          return this.function;
289        }
290        else if (name.equals("mode")) {
291          this.mode = new DV_CODED_TEXT();
292          return this.mode;
293        }
294        else if (name.equals("performer")) {
295          throw new FHIRException("Cannot call addChild on an abstract type PARTICIPATION.performer");
296        }
297        else if (name.equals("time")) {
298          this.time = new DV_INTERVAL();
299          return this.time;
300        }
301        else
302          return super.addChild(name);
303      }
304
305  public String fhirType() {
306    return "PARTICIPATION";
307
308  }
309
310      public PARTICIPATION copy() {
311        PARTICIPATION dst = new PARTICIPATION();
312        copyValues(dst);
313        return dst;
314      }
315
316      public void copyValues(PARTICIPATION dst) {
317        super.copyValues(dst);
318        dst.function = function == null ? null : function.copy();
319        dst.mode = mode == null ? null : mode.copy();
320        dst.performer = performer == null ? null : performer.copy();
321        dst.time = time == null ? null : time.copy();
322      }
323
324      protected PARTICIPATION typedCopy() {
325        return copy();
326      }
327
328      @Override
329      public boolean equalsDeep(Base other_) {
330        if (!super.equalsDeep(other_))
331          return false;
332        if (!(other_ instanceof PARTICIPATION))
333          return false;
334        PARTICIPATION o = (PARTICIPATION) other_;
335        return compareDeep(function, o.function, true) && compareDeep(mode, o.mode, true) && compareDeep(performer, o.performer, true)
336           && compareDeep(time, o.time, true);
337      }
338
339      @Override
340      public boolean equalsShallow(Base other_) {
341        if (!super.equalsShallow(other_))
342          return false;
343        if (!(other_ instanceof PARTICIPATION))
344          return false;
345        PARTICIPATION o = (PARTICIPATION) other_;
346        return true;
347      }
348
349      public boolean isEmpty() {
350        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(function, mode, performer
351          , time);
352      }
353
354
355}
356