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 * A tag with optional value that is associated with a target information entity identified by a UID.
050 */
051@DatatypeDef(name="ITEM_TAG")
052public class ITEM_TAG extends LogicalBase implements ICompositeType {
053
054    /**
055     * The tag key. May not be empty or contain leading or trailing whitespace.
056     */
057    @Child(name = "key", type = {StringType.class}, order=0, min=1, max=1, modifier=false, summary=false)
058    @Description(shortDefinition="The tag key. May not be empty or contain leading or trailing whitespace", formalDefinition="The tag key. May not be empty or contain leading or trailing whitespace." )
059    protected StringType key;
060
061    /**
062     * The value. If set, may not be empty.
063     */
064    @Child(name = "value", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=false)
065    @Description(shortDefinition="The value. If set, may not be empty", formalDefinition="The value. If set, may not be empty." )
066    protected StringType value;
067
068    /**
069     * Identifier of target, which may be a VERSIONED_OBJECT<T> or a VERSION<T>.
070     */
071    @Child(name = "target", type = {UID_BASED_ID.class}, order=2, min=1, max=1, modifier=false, summary=false)
072    @Description(shortDefinition="Identifier of target, which may be a VERSIONED_OBJECT<T> or a VERSION<T>", formalDefinition="Identifier of target, which may be a VERSIONED_OBJECT<T> or a VERSION<T>." )
073    protected UID_BASED_ID target;
074
075    /**
076     * Optional archetype (i.e. AQL) or RM path within target, used to tag a fine-grained element.
077     */
078    @Child(name = "target_path", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=false)
079    @Description(shortDefinition="Optional archetype (i.e. AQL) or RM path within target, used to tag a fine-grained element", formalDefinition="Optional archetype (i.e. AQL) or RM path within target, used to tag a fine-grained element." )
080    protected StringType target_path;
081
082    /**
083     * Identifier of owner object, such as EHR.
084     */
085    @Child(name = "owner_id", type = {OBJECT_REF.class}, order=4, min=1, max=1, modifier=false, summary=false)
086    @Description(shortDefinition="Identifier of owner object, such as EHR", formalDefinition="Identifier of owner object, such as EHR." )
087    protected OBJECT_REF owner_id;
088
089    private static final long serialVersionUID = -1845987839L;
090
091  /**
092   * Constructor
093   */
094    public ITEM_TAG() {
095      super();
096    }
097
098  /**
099   * Constructor
100   */
101    public ITEM_TAG(String key, UID_BASED_ID target, OBJECT_REF owner_id) {
102      super();
103      this.setKey(key);
104      this.setTarget(target);
105      this.setOwner_id(owner_id);
106    }
107
108    /**
109     * @return {@link #key} (The tag key. May not be empty or contain leading or trailing whitespace.). This is the underlying object with id, value and extensions. The accessor "getKey" gives direct access to the value
110     */
111    public StringType getKeyElement() { 
112      if (this.key == null)
113        if (Configuration.errorOnAutoCreate())
114          throw new Error("Attempt to auto-create ITEM_TAG.key");
115        else if (Configuration.doAutoCreate())
116          this.key = new StringType(); // bb
117      return this.key;
118    }
119
120    public boolean hasKeyElement() { 
121      return this.key != null && !this.key.isEmpty();
122    }
123
124    public boolean hasKey() { 
125      return this.key != null && !this.key.isEmpty();
126    }
127
128    /**
129     * @param value {@link #key} (The tag key. May not be empty or contain leading or trailing whitespace.). This is the underlying object with id, value and extensions. The accessor "getKey" gives direct access to the value
130     */
131    public ITEM_TAG setKeyElement(StringType value) { 
132      this.key = value;
133      return this;
134    }
135
136    /**
137     * @return The tag key. May not be empty or contain leading or trailing whitespace.
138     */
139    public String getKey() { 
140      return this.key == null ? null : this.key.getValue();
141    }
142
143    /**
144     * @param value The tag key. May not be empty or contain leading or trailing whitespace.
145     */
146    public ITEM_TAG setKey(String value) { 
147        if (this.key == null)
148          this.key = new StringType();
149        this.key.setValue(value);
150      return this;
151    }
152
153    /**
154     * @return {@link #value} (The value. If set, may not be empty.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
155     */
156    public StringType getValueElement() { 
157      if (this.value == null)
158        if (Configuration.errorOnAutoCreate())
159          throw new Error("Attempt to auto-create ITEM_TAG.value");
160        else if (Configuration.doAutoCreate())
161          this.value = new StringType(); // bb
162      return this.value;
163    }
164
165    public boolean hasValueElement() { 
166      return this.value != null && !this.value.isEmpty();
167    }
168
169    public boolean hasValue() { 
170      return this.value != null && !this.value.isEmpty();
171    }
172
173    /**
174     * @param value {@link #value} (The value. If set, may not be empty.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
175     */
176    public ITEM_TAG setValueElement(StringType value) { 
177      this.value = value;
178      return this;
179    }
180
181    /**
182     * @return The value. If set, may not be empty.
183     */
184    public String getValue() { 
185      return this.value == null ? null : this.value.getValue();
186    }
187
188    /**
189     * @param value The value. If set, may not be empty.
190     */
191    public ITEM_TAG setValue(String value) { 
192      if (Utilities.noString(value))
193        this.value = null;
194      else {
195        if (this.value == null)
196          this.value = new StringType();
197        this.value.setValue(value);
198      }
199      return this;
200    }
201
202    /**
203     * @return {@link #target} (Identifier of target, which may be a VERSIONED_OBJECT<T> or a VERSION<T>.)
204     */
205    public UID_BASED_ID getTarget() { 
206      return this.target;
207    }
208
209    public boolean hasTarget() { 
210      return this.target != null && !this.target.isEmpty();
211    }
212
213    /**
214     * @param value {@link #target} (Identifier of target, which may be a VERSIONED_OBJECT<T> or a VERSION<T>.)
215     */
216    public ITEM_TAG setTarget(UID_BASED_ID value) { 
217      this.target = value;
218      return this;
219    }
220
221    /**
222     * @return {@link #target_path} (Optional archetype (i.e. AQL) or RM path within target, used to tag a fine-grained element.). This is the underlying object with id, value and extensions. The accessor "getTarget_path" gives direct access to the value
223     */
224    public StringType getTarget_pathElement() { 
225      if (this.target_path == null)
226        if (Configuration.errorOnAutoCreate())
227          throw new Error("Attempt to auto-create ITEM_TAG.target_path");
228        else if (Configuration.doAutoCreate())
229          this.target_path = new StringType(); // bb
230      return this.target_path;
231    }
232
233    public boolean hasTarget_pathElement() { 
234      return this.target_path != null && !this.target_path.isEmpty();
235    }
236
237    public boolean hasTarget_path() { 
238      return this.target_path != null && !this.target_path.isEmpty();
239    }
240
241    /**
242     * @param value {@link #target_path} (Optional archetype (i.e. AQL) or RM path within target, used to tag a fine-grained element.). This is the underlying object with id, value and extensions. The accessor "getTarget_path" gives direct access to the value
243     */
244    public ITEM_TAG setTarget_pathElement(StringType value) { 
245      this.target_path = value;
246      return this;
247    }
248
249    /**
250     * @return Optional archetype (i.e. AQL) or RM path within target, used to tag a fine-grained element.
251     */
252    public String getTarget_path() { 
253      return this.target_path == null ? null : this.target_path.getValue();
254    }
255
256    /**
257     * @param value Optional archetype (i.e. AQL) or RM path within target, used to tag a fine-grained element.
258     */
259    public ITEM_TAG setTarget_path(String value) { 
260      if (Utilities.noString(value))
261        this.target_path = null;
262      else {
263        if (this.target_path == null)
264          this.target_path = new StringType();
265        this.target_path.setValue(value);
266      }
267      return this;
268    }
269
270    /**
271     * @return {@link #owner_id} (Identifier of owner object, such as EHR.)
272     */
273    public OBJECT_REF getOwner_id() { 
274      if (this.owner_id == null)
275        if (Configuration.errorOnAutoCreate())
276          throw new Error("Attempt to auto-create ITEM_TAG.owner_id");
277        else if (Configuration.doAutoCreate())
278          this.owner_id = new OBJECT_REF(); // cc
279      return this.owner_id;
280    }
281
282    public boolean hasOwner_id() { 
283      return this.owner_id != null && !this.owner_id.isEmpty();
284    }
285
286    /**
287     * @param value {@link #owner_id} (Identifier of owner object, such as EHR.)
288     */
289    public ITEM_TAG setOwner_id(OBJECT_REF value) { 
290      this.owner_id = value;
291      return this;
292    }
293
294      protected void listChildren(List<Property> children) {
295        super.listChildren(children);
296        children.add(new Property("key", "string", "The tag key. May not be empty or contain leading or trailing whitespace.", 0, 1, key));
297        children.add(new Property("value", "string", "The value. If set, may not be empty.", 0, 1, value));
298        children.add(new Property("target", "http://openehr.org/fhir/StructureDefinition/UID-BASED-ID", "Identifier of target, which may be a VERSIONED_OBJECT<T> or a VERSION<T>.", 0, 1, target));
299        children.add(new Property("target_path", "string", "Optional archetype (i.e. AQL) or RM path within target, used to tag a fine-grained element.", 0, 1, target_path));
300        children.add(new Property("owner_id", "http://openehr.org/fhir/StructureDefinition/OBJECT-REF", "Identifier of owner object, such as EHR.", 0, 1, owner_id));
301      }
302
303      @Override
304      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
305        switch (_hash) {
306        case 106079: /*key*/  return new Property("key", "string", "The tag key. May not be empty or contain leading or trailing whitespace.", 0, 1, key);
307        case 111972721: /*value*/  return new Property("value", "string", "The value. If set, may not be empty.", 0, 1, value);
308        case -880905839: /*target*/  return new Property("target", "http://openehr.org/fhir/StructureDefinition/UID-BASED-ID", "Identifier of target, which may be a VERSIONED_OBJECT<T> or a VERSION<T>.", 0, 1, target);
309        case -2084700653: /*target_path*/  return new Property("target_path", "string", "Optional archetype (i.e. AQL) or RM path within target, used to tag a fine-grained element.", 0, 1, target_path);
310        case 1663147559: /*owner_id*/  return new Property("owner_id", "http://openehr.org/fhir/StructureDefinition/OBJECT-REF", "Identifier of owner object, such as EHR.", 0, 1, owner_id);
311        default: return super.getNamedProperty(_hash, _name, _checkValid);
312        }
313
314      }
315
316      @Override
317      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
318        switch (hash) {
319        case 106079: /*key*/ return this.key == null ? new Base[0] : new Base[] {this.key}; // StringType
320        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // StringType
321        case -880905839: /*target*/ return this.target == null ? new Base[0] : new Base[] {this.target}; // UID_BASED_ID
322        case -2084700653: /*target_path*/ return this.target_path == null ? new Base[0] : new Base[] {this.target_path}; // StringType
323        case 1663147559: /*owner_id*/ return this.owner_id == null ? new Base[0] : new Base[] {this.owner_id}; // OBJECT_REF
324        default: return super.getProperty(hash, name, checkValid);
325        }
326
327      }
328
329      @Override
330      public Base setProperty(int hash, String name, Base value) throws FHIRException {
331        switch (hash) {
332        case 106079: // key
333          this.key = TypeConvertor.castToString(value); // StringType
334          return value;
335        case 111972721: // value
336          this.value = TypeConvertor.castToString(value); // StringType
337          return value;
338        case -880905839: // target
339          this.target = (UID_BASED_ID) value; // UID_BASED_ID
340          return value;
341        case -2084700653: // target_path
342          this.target_path = TypeConvertor.castToString(value); // StringType
343          return value;
344        case 1663147559: // owner_id
345          this.owner_id = (OBJECT_REF) value; // OBJECT_REF
346          return value;
347        default: return super.setProperty(hash, name, value);
348        }
349
350      }
351
352      @Override
353      public Base setProperty(String name, Base value) throws FHIRException {
354        if (name.equals("key")) {
355          this.key = TypeConvertor.castToString(value); // StringType
356        } else if (name.equals("value")) {
357          this.value = TypeConvertor.castToString(value); // StringType
358        } else if (name.equals("target")) {
359          this.target = (UID_BASED_ID) value; // UID_BASED_ID
360        } else if (name.equals("target_path")) {
361          this.target_path = TypeConvertor.castToString(value); // StringType
362        } else if (name.equals("owner_id")) {
363          this.owner_id = (OBJECT_REF) value; // OBJECT_REF
364        } else
365          return super.setProperty(name, value);
366        return value;
367      }
368
369      @Override
370      public Base makeProperty(int hash, String name) throws FHIRException {
371        switch (hash) {
372        case 106079:  return getKeyElement();
373        case 111972721:  return getValueElement();
374        case -880905839: /*div*/
375          throw new Error("Unable to make an instance of the abstract property 'target'");
376        case -2084700653:  return getTarget_pathElement();
377        case 1663147559:  return getOwner_id();
378        default: return super.makeProperty(hash, name);
379        }
380
381      }
382
383      @Override
384      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
385        switch (hash) {
386        case 106079: /*key*/ return new String[] {"string"};
387        case 111972721: /*value*/ return new String[] {"string"};
388        case -880905839: /*target*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/UID-BASED-ID"};
389        case -2084700653: /*target_path*/ return new String[] {"string"};
390        case 1663147559: /*owner_id*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/OBJECT-REF"};
391        default: return super.getTypesForProperty(hash, name);
392        }
393
394      }
395
396      @Override
397      public Base addChild(String name) throws FHIRException {
398        if (name.equals("key")) {
399          throw new FHIRException("Cannot call addChild on a singleton property ITEM_TAG.key");
400        }
401        else if (name.equals("value")) {
402          throw new FHIRException("Cannot call addChild on a singleton property ITEM_TAG.value");
403        }
404        else if (name.equals("target")) {
405          throw new FHIRException("Cannot call addChild on an abstract type ITEM_TAG.target");
406        }
407        else if (name.equals("target_path")) {
408          throw new FHIRException("Cannot call addChild on a singleton property ITEM_TAG.target_path");
409        }
410        else if (name.equals("owner_id")) {
411          this.owner_id = new OBJECT_REF();
412          return this.owner_id;
413        }
414        else
415          return super.addChild(name);
416      }
417
418  public String fhirType() {
419    return "ITEM_TAG";
420
421  }
422
423      public ITEM_TAG copy() {
424        ITEM_TAG dst = new ITEM_TAG();
425        copyValues(dst);
426        return dst;
427      }
428
429      public void copyValues(ITEM_TAG dst) {
430        super.copyValues(dst);
431        dst.key = key == null ? null : key.copy();
432        dst.value = value == null ? null : value.copy();
433        dst.target = target == null ? null : target.copy();
434        dst.target_path = target_path == null ? null : target_path.copy();
435        dst.owner_id = owner_id == null ? null : owner_id.copy();
436      }
437
438      protected ITEM_TAG typedCopy() {
439        return copy();
440      }
441
442      @Override
443      public boolean equalsDeep(Base other_) {
444        if (!super.equalsDeep(other_))
445          return false;
446        if (!(other_ instanceof ITEM_TAG))
447          return false;
448        ITEM_TAG o = (ITEM_TAG) other_;
449        return compareDeep(key, o.key, true) && compareDeep(value, o.value, true) && compareDeep(target, o.target, true)
450           && compareDeep(target_path, o.target_path, true) && compareDeep(owner_id, o.owner_id, true);
451      }
452
453      @Override
454      public boolean equalsShallow(Base other_) {
455        if (!super.equalsShallow(other_))
456          return false;
457        if (!(other_ instanceof ITEM_TAG))
458          return false;
459        ITEM_TAG o = (ITEM_TAG) other_;
460        return compareValues(key, o.key, true) && compareValues(value, o.value, true) && compareValues(target_path, o.target_path, true)
461          ;
462      }
463
464      public boolean isEmpty() {
465        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(key, value, target, target_path
466          , owner_id);
467      }
468
469
470}
471