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.utilities.Utilities;
038import org.hl7.fhir.r5.openehr.Enumerations.*;
039import org.hl7.fhir.exceptions.FHIRException;
040import org.hl7.fhir.r5.model.*;
041import org.hl7.fhir.instance.model.api.ICompositeType;
042import ca.uhn.fhir.model.api.annotation.Child;
043import ca.uhn.fhir.model.api.annotation.ChildOrder;
044import ca.uhn.fhir.model.api.annotation.DatatypeDef;
045import ca.uhn.fhir.model.api.annotation.Description;
046import ca.uhn.fhir.model.api.annotation.Block;
047
048/**
049 * Used to specify actions in the future. Enables simple and complex specifications to be expressed, including in a fully-computable workflow form. Used for any actionable statement such as medication and therapeutic orders, monitoring, recall and review. Enough details must be provided for the specification to be directly executed by an actor, either human or machine. Not to be used for plan items which are only specified in general terms.
050 */
051@DatatypeDef(name="ACTIVITY")
052public class ACTIVITY extends LOCATABLE implements ICompositeType {
053
054    /**
055     * Timing of the activity, in the form of a parsable string. If used, the preferred syntax is ISO8601 'R' format, but other formats may be used including HL7 GTS.
056     */
057    @Child(name = "timing", type = {DV_PARSABLE.class}, order=0, min=0, max=1, modifier=false, summary=false)
058    @Description(shortDefinition="Timing of the activity, in the form of a parsable string", formalDefinition="Timing of the activity, in the form of a parsable string. If used, the preferred syntax is ISO8601 'R' format, but other formats may be used including HL7 GTS." )
059    protected DV_PARSABLE timing;
060
061    /**
062     * Perl-compliant regular expression pattern, enclosed in '//' delimiters, indicating the valid identifiers of archetypes for Actions corresponding to this Activity specification. Defaults to /.* /, meaning any archetype.
063     */
064    @Child(name = "action_archetype_id", type = {StringType.class}, order=1, min=1, max=1, modifier=false, summary=false)
065    @Description(shortDefinition="Perl-compliant regular expression pattern indicating the valid identifiers of archetypes for Actions corresponding to this Activity", formalDefinition="Perl-compliant regular expression pattern, enclosed in '//' delimiters, indicating the valid identifiers of archetypes for Actions corresponding to this Activity specification. Defaults to /.*/, meaning any archetype." )
066    protected StringType action_archetype_id;
067
068    /**
069     * Description of the activity, in the form of an archetyped structure.
070     */
071    @Child(name = "description", type = {ITEM_STRUCTURE.class}, order=2, min=1, max=1, modifier=false, summary=false)
072    @Description(shortDefinition="Description of the activity, in the form of an archetyped structure", formalDefinition="Description of the activity, in the form of an archetyped structure." )
073    protected ITEM_STRUCTURE description;
074
075    private static final long serialVersionUID = 1041755607L;
076
077  /**
078   * Constructor
079   */
080    public ACTIVITY() {
081      super();
082    }
083
084  /**
085   * Constructor
086   */
087    public ACTIVITY(String action_archetype_id, ITEM_STRUCTURE description) {
088      super();
089      this.setAction_archetype_id(action_archetype_id);
090      this.setDescription(description);
091    }
092
093    /**
094     * @return {@link #timing} (Timing of the activity, in the form of a parsable string. If used, the preferred syntax is ISO8601 'R' format, but other formats may be used including HL7 GTS.)
095     */
096    public DV_PARSABLE getTiming() { 
097      if (this.timing == null)
098        if (Configuration.errorOnAutoCreate())
099          throw new Error("Attempt to auto-create ACTIVITY.timing");
100        else if (Configuration.doAutoCreate())
101          this.timing = new DV_PARSABLE(); // cc
102      return this.timing;
103    }
104
105    public boolean hasTiming() { 
106      return this.timing != null && !this.timing.isEmpty();
107    }
108
109    /**
110     * @param value {@link #timing} (Timing of the activity, in the form of a parsable string. If used, the preferred syntax is ISO8601 'R' format, but other formats may be used including HL7 GTS.)
111     */
112    public ACTIVITY setTiming(DV_PARSABLE value) { 
113      this.timing = value;
114      return this;
115    }
116
117    /**
118     * @return {@link #action_archetype_id} (Perl-compliant regular expression pattern, enclosed in '//' delimiters, indicating the valid identifiers of archetypes for Actions corresponding to this Activity specification. Defaults to /.* /, meaning any archetype.). This is the underlying object with id, value and extensions. The accessor "getAction_archetype_id" gives direct access to the value
119     */
120    public StringType getAction_archetype_idElement() { 
121      if (this.action_archetype_id == null)
122        if (Configuration.errorOnAutoCreate())
123          throw new Error("Attempt to auto-create ACTIVITY.action_archetype_id");
124        else if (Configuration.doAutoCreate())
125          this.action_archetype_id = new StringType(); // bb
126      return this.action_archetype_id;
127    }
128
129    public boolean hasAction_archetype_idElement() { 
130      return this.action_archetype_id != null && !this.action_archetype_id.isEmpty();
131    }
132
133    public boolean hasAction_archetype_id() { 
134      return this.action_archetype_id != null && !this.action_archetype_id.isEmpty();
135    }
136
137    /**
138     * @param value {@link #action_archetype_id} (Perl-compliant regular expression pattern, enclosed in '//' delimiters, indicating the valid identifiers of archetypes for Actions corresponding to this Activity specification. Defaults to /.* /, meaning any archetype.). This is the underlying object with id, value and extensions. The accessor "getAction_archetype_id" gives direct access to the value
139     */
140    public ACTIVITY setAction_archetype_idElement(StringType value) { 
141      this.action_archetype_id = value;
142      return this;
143    }
144
145    /**
146     * @return Perl-compliant regular expression pattern, enclosed in '//' delimiters, indicating the valid identifiers of archetypes for Actions corresponding to this Activity specification. Defaults to /.* /, meaning any archetype.
147     */
148    public String getAction_archetype_id() { 
149      return this.action_archetype_id == null ? null : this.action_archetype_id.getValue();
150    }
151
152    /**
153     * @param value Perl-compliant regular expression pattern, enclosed in '//' delimiters, indicating the valid identifiers of archetypes for Actions corresponding to this Activity specification. Defaults to /.* /, meaning any archetype.
154     */
155    public ACTIVITY setAction_archetype_id(String value) { 
156        if (this.action_archetype_id == null)
157          this.action_archetype_id = new StringType();
158        this.action_archetype_id.setValue(value);
159      return this;
160    }
161
162    /**
163     * @return {@link #description} (Description of the activity, in the form of an archetyped structure.)
164     */
165    public ITEM_STRUCTURE getDescription() { 
166      return this.description;
167    }
168
169    public boolean hasDescription() { 
170      return this.description != null && !this.description.isEmpty();
171    }
172
173    /**
174     * @param value {@link #description} (Description of the activity, in the form of an archetyped structure.)
175     */
176    public ACTIVITY setDescription(ITEM_STRUCTURE value) { 
177      this.description = value;
178      return this;
179    }
180
181      protected void listChildren(List<Property> children) {
182        super.listChildren(children);
183        children.add(new Property("timing", "http://openehr.org/fhir/StructureDefinition/DV-PARSABLE", "Timing of the activity, in the form of a parsable string. If used, the preferred syntax is ISO8601 'R' format, but other formats may be used including HL7 GTS.", 0, 1, timing));
184        children.add(new Property("action_archetype_id", "string", "Perl-compliant regular expression pattern, enclosed in '//' delimiters, indicating the valid identifiers of archetypes for Actions corresponding to this Activity specification. Defaults to /.*/, meaning any archetype.", 0, 1, action_archetype_id));
185        children.add(new Property("description", "http://openehr.org/fhir/StructureDefinition/ITEM-STRUCTURE", "Description of the activity, in the form of an archetyped structure.", 0, 1, description));
186      }
187
188      @Override
189      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
190        switch (_hash) {
191        case -873664438: /*timing*/  return new Property("timing", "http://openehr.org/fhir/StructureDefinition/DV-PARSABLE", "Timing of the activity, in the form of a parsable string. If used, the preferred syntax is ISO8601 'R' format, but other formats may be used including HL7 GTS.", 0, 1, timing);
192        case 1059971578: /*action_archetype_id*/  return new Property("action_archetype_id", "string", "Perl-compliant regular expression pattern, enclosed in '//' delimiters, indicating the valid identifiers of archetypes for Actions corresponding to this Activity specification. Defaults to /.*/, meaning any archetype.", 0, 1, action_archetype_id);
193        case -1724546052: /*description*/  return new Property("description", "http://openehr.org/fhir/StructureDefinition/ITEM-STRUCTURE", "Description of the activity, in the form of an archetyped structure.", 0, 1, description);
194        default: return super.getNamedProperty(_hash, _name, _checkValid);
195        }
196
197      }
198
199      @Override
200      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
201        switch (hash) {
202        case -873664438: /*timing*/ return this.timing == null ? new Base[0] : new Base[] {this.timing}; // DV_PARSABLE
203        case 1059971578: /*action_archetype_id*/ return this.action_archetype_id == null ? new Base[0] : new Base[] {this.action_archetype_id}; // StringType
204        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // ITEM_STRUCTURE
205        default: return super.getProperty(hash, name, checkValid);
206        }
207
208      }
209
210      @Override
211      public Base setProperty(int hash, String name, Base value) throws FHIRException {
212        switch (hash) {
213        case -873664438: // timing
214          this.timing = (DV_PARSABLE) value; // DV_PARSABLE
215          return value;
216        case 1059971578: // action_archetype_id
217          this.action_archetype_id = TypeConvertor.castToString(value); // StringType
218          return value;
219        case -1724546052: // description
220          this.description = (ITEM_STRUCTURE) value; // ITEM_STRUCTURE
221          return value;
222        default: return super.setProperty(hash, name, value);
223        }
224
225      }
226
227      @Override
228      public Base setProperty(String name, Base value) throws FHIRException {
229        if (name.equals("timing")) {
230          this.timing = (DV_PARSABLE) value; // DV_PARSABLE
231        } else if (name.equals("action_archetype_id")) {
232          this.action_archetype_id = TypeConvertor.castToString(value); // StringType
233        } else if (name.equals("description")) {
234          this.description = (ITEM_STRUCTURE) value; // ITEM_STRUCTURE
235        } else
236          return super.setProperty(name, value);
237        return value;
238      }
239
240      @Override
241      public Base makeProperty(int hash, String name) throws FHIRException {
242        switch (hash) {
243        case -873664438:  return getTiming();
244        case 1059971578:  return getAction_archetype_idElement();
245        case -1724546052: /*div*/
246          throw new Error("Unable to make an instance of the abstract property 'description'");
247        default: return super.makeProperty(hash, name);
248        }
249
250      }
251
252      @Override
253      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
254        switch (hash) {
255        case -873664438: /*timing*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-PARSABLE"};
256        case 1059971578: /*action_archetype_id*/ return new String[] {"string"};
257        case -1724546052: /*description*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/ITEM-STRUCTURE"};
258        default: return super.getTypesForProperty(hash, name);
259        }
260
261      }
262
263      @Override
264      public Base addChild(String name) throws FHIRException {
265        if (name.equals("timing")) {
266          this.timing = new DV_PARSABLE();
267          return this.timing;
268        }
269        else if (name.equals("action_archetype_id")) {
270          throw new FHIRException("Cannot call addChild on a singleton property ACTIVITY.action_archetype_id");
271        }
272        else if (name.equals("description")) {
273          throw new FHIRException("Cannot call addChild on an abstract type ACTIVITY.description");
274        }
275        else
276          return super.addChild(name);
277      }
278
279  public String fhirType() {
280    return "ACTIVITY";
281
282  }
283
284      public ACTIVITY copy() {
285        ACTIVITY dst = new ACTIVITY();
286        copyValues(dst);
287        return dst;
288      }
289
290      public void copyValues(ACTIVITY dst) {
291        super.copyValues(dst);
292        dst.timing = timing == null ? null : timing.copy();
293        dst.action_archetype_id = action_archetype_id == null ? null : action_archetype_id.copy();
294        dst.description = description == null ? null : description.copy();
295      }
296
297      protected ACTIVITY typedCopy() {
298        return copy();
299      }
300
301      @Override
302      public boolean equalsDeep(Base other_) {
303        if (!super.equalsDeep(other_))
304          return false;
305        if (!(other_ instanceof ACTIVITY))
306          return false;
307        ACTIVITY o = (ACTIVITY) other_;
308        return compareDeep(timing, o.timing, true) && compareDeep(action_archetype_id, o.action_archetype_id, true)
309           && compareDeep(description, o.description, true);
310      }
311
312      @Override
313      public boolean equalsShallow(Base other_) {
314        if (!super.equalsShallow(other_))
315          return false;
316        if (!(other_ instanceof ACTIVITY))
317          return false;
318        ACTIVITY o = (ACTIVITY) other_;
319        return compareValues(action_archetype_id, o.action_archetype_id, true);
320      }
321
322      public boolean isEmpty() {
323        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(timing, action_archetype_id
324          , description);
325      }
326
327
328}
329