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 * Items which are truly boolean data, such as true/false or yes/no answers. For such data, it is important to devise the meanings (usually questions in subjective data) carefully, so that the only allowed results are in fact true or false.
050 */
051@DatatypeDef(name="TERM_MAPPING")
052public class TERM_MAPPING extends LogicalBase implements ICompositeType {
053
054    /**
055     * The relative match of the target term with respect to the mapped text item. Result meanings:
056
057* '>': the mapping is to a broader term e.g. orginal text = arbovirus infection , target = viral infection
058* '=': the mapping is to a (supposedly) equivalent to the original item
059* '<': the mapping is to a narrower term. e.g. original text = diabetes , mapping = diabetes mellitus.
060* '?': the kind of mapping is unknown.
061
062The first three values are taken from the ISO standards 2788 ( Guide to Establishment and development of monolingual thesauri) and 5964 (Guide to Establishment and development of multilingual thesauri).
063     */
064    @Child(name = "match", type = {StringType.class}, order=0, min=1, max=1, modifier=false, summary=false)
065    @Description(shortDefinition="> | = | < | ?: The relative match of the target term with respect to the mapped text item", formalDefinition="The relative match of the target term with respect to the mapped text item. Result meanings:\n\n* '>': the mapping is to a broader term e.g. orginal text = arbovirus infection , target = viral infection\n* '=': the mapping is to a (supposedly) equivalent to the original item\n* '<': the mapping is to a narrower term. e.g. original text = diabetes , mapping = diabetes mellitus.\n* '?': the kind of mapping is unknown.\n\nThe first three values are taken from the ISO standards 2788 ( Guide to Establishment and development of monolingual thesauri) and 5964 (Guide to Establishment and development of multilingual thesauri)." )
066    protected StringType match;
067
068    /**
069     * Purpose of the mapping e.g. 'automated data mining', 'billing', 'interoperability'.
070     */
071    @Child(name = "purpose", type = {DV_CODED_TEXT.class}, order=1, min=0, max=1, modifier=false, summary=false)
072    @Description(shortDefinition="Purpose of the mapping", formalDefinition="Purpose of the mapping e.g. 'automated data mining', 'billing', 'interoperability'." )
073    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="https://specifications.openehr.org/fhir/valueset-term_mapping_purpose")
074    protected DV_CODED_TEXT purpose;
075
076    /**
077     * The target term of the mapping.
078     */
079    @Child(name = "target", type = {CODE_PHRASE.class}, order=2, min=1, max=1, modifier=false, summary=false)
080    @Description(shortDefinition="The target term of the mapping", formalDefinition="The target term of the mapping." )
081    protected CODE_PHRASE target;
082
083    private static final long serialVersionUID = -331225696L;
084
085  /**
086   * Constructor
087   */
088    public TERM_MAPPING() {
089      super();
090    }
091
092  /**
093   * Constructor
094   */
095    public TERM_MAPPING(String match, CODE_PHRASE target) {
096      super();
097      this.setMatch(match);
098      this.setTarget(target);
099    }
100
101    /**
102     * @return {@link #match} (The relative match of the target term with respect to the mapped text item. Result meanings:
103
104* '>': the mapping is to a broader term e.g. orginal text = arbovirus infection , target = viral infection
105* '=': the mapping is to a (supposedly) equivalent to the original item
106* '<': the mapping is to a narrower term. e.g. original text = diabetes , mapping = diabetes mellitus.
107* '?': the kind of mapping is unknown.
108
109The first three values are taken from the ISO standards 2788 ( Guide to Establishment and development of monolingual thesauri) and 5964 (Guide to Establishment and development of multilingual thesauri).). This is the underlying object with id, value and extensions. The accessor "getMatch" gives direct access to the value
110     */
111    public StringType getMatchElement() { 
112      if (this.match == null)
113        if (Configuration.errorOnAutoCreate())
114          throw new Error("Attempt to auto-create TERM_MAPPING.match");
115        else if (Configuration.doAutoCreate())
116          this.match = new StringType(); // bb
117      return this.match;
118    }
119
120    public boolean hasMatchElement() { 
121      return this.match != null && !this.match.isEmpty();
122    }
123
124    public boolean hasMatch() { 
125      return this.match != null && !this.match.isEmpty();
126    }
127
128    /**
129     * @param value {@link #match} (The relative match of the target term with respect to the mapped text item. Result meanings:
130
131* '>': the mapping is to a broader term e.g. orginal text = arbovirus infection , target = viral infection
132* '=': the mapping is to a (supposedly) equivalent to the original item
133* '<': the mapping is to a narrower term. e.g. original text = diabetes , mapping = diabetes mellitus.
134* '?': the kind of mapping is unknown.
135
136The first three values are taken from the ISO standards 2788 ( Guide to Establishment and development of monolingual thesauri) and 5964 (Guide to Establishment and development of multilingual thesauri).). This is the underlying object with id, value and extensions. The accessor "getMatch" gives direct access to the value
137     */
138    public TERM_MAPPING setMatchElement(StringType value) { 
139      this.match = value;
140      return this;
141    }
142
143    /**
144     * @return The relative match of the target term with respect to the mapped text item. Result meanings:
145
146* '>': the mapping is to a broader term e.g. orginal text = arbovirus infection , target = viral infection
147* '=': the mapping is to a (supposedly) equivalent to the original item
148* '<': the mapping is to a narrower term. e.g. original text = diabetes , mapping = diabetes mellitus.
149* '?': the kind of mapping is unknown.
150
151The first three values are taken from the ISO standards 2788 ( Guide to Establishment and development of monolingual thesauri) and 5964 (Guide to Establishment and development of multilingual thesauri).
152     */
153    public String getMatch() { 
154      return this.match == null ? null : this.match.getValue();
155    }
156
157    /**
158     * @param value The relative match of the target term with respect to the mapped text item. Result meanings:
159
160* '>': the mapping is to a broader term e.g. orginal text = arbovirus infection , target = viral infection
161* '=': the mapping is to a (supposedly) equivalent to the original item
162* '<': the mapping is to a narrower term. e.g. original text = diabetes , mapping = diabetes mellitus.
163* '?': the kind of mapping is unknown.
164
165The first three values are taken from the ISO standards 2788 ( Guide to Establishment and development of monolingual thesauri) and 5964 (Guide to Establishment and development of multilingual thesauri).
166     */
167    public TERM_MAPPING setMatch(String value) { 
168        if (this.match == null)
169          this.match = new StringType();
170        this.match.setValue(value);
171      return this;
172    }
173
174    /**
175     * @return {@link #purpose} (Purpose of the mapping e.g. 'automated data mining', 'billing', 'interoperability'.)
176     */
177    public DV_CODED_TEXT getPurpose() { 
178      if (this.purpose == null)
179        if (Configuration.errorOnAutoCreate())
180          throw new Error("Attempt to auto-create TERM_MAPPING.purpose");
181        else if (Configuration.doAutoCreate())
182          this.purpose = new DV_CODED_TEXT(); // cc
183      return this.purpose;
184    }
185
186    public boolean hasPurpose() { 
187      return this.purpose != null && !this.purpose.isEmpty();
188    }
189
190    /**
191     * @param value {@link #purpose} (Purpose of the mapping e.g. 'automated data mining', 'billing', 'interoperability'.)
192     */
193    public TERM_MAPPING setPurpose(DV_CODED_TEXT value) { 
194      this.purpose = value;
195      return this;
196    }
197
198    /**
199     * @return {@link #target} (The target term of the mapping.)
200     */
201    public CODE_PHRASE getTarget() { 
202      if (this.target == null)
203        if (Configuration.errorOnAutoCreate())
204          throw new Error("Attempt to auto-create TERM_MAPPING.target");
205        else if (Configuration.doAutoCreate())
206          this.target = new CODE_PHRASE(); // cc
207      return this.target;
208    }
209
210    public boolean hasTarget() { 
211      return this.target != null && !this.target.isEmpty();
212    }
213
214    /**
215     * @param value {@link #target} (The target term of the mapping.)
216     */
217    public TERM_MAPPING setTarget(CODE_PHRASE value) { 
218      this.target = value;
219      return this;
220    }
221
222      protected void listChildren(List<Property> children) {
223        super.listChildren(children);
224        children.add(new Property("match", "string", "The relative match of the target term with respect to the mapped text item. Result meanings:\n\n* '>': the mapping is to a broader term e.g. orginal text = arbovirus infection , target = viral infection\n* '=': the mapping is to a (supposedly) equivalent to the original item\n* '<': the mapping is to a narrower term. e.g. original text = diabetes , mapping = diabetes mellitus.\n* '?': the kind of mapping is unknown.\n\nThe first three values are taken from the ISO standards 2788 ( Guide to Establishment and development of monolingual thesauri) and 5964 (Guide to Establishment and development of multilingual thesauri).", 0, 1, match));
225        children.add(new Property("purpose", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "Purpose of the mapping e.g. 'automated data mining', 'billing', 'interoperability'.", 0, 1, purpose));
226        children.add(new Property("target", "http://openehr.org/fhir/StructureDefinition/CODE-PHRASE", "The target term of the mapping.", 0, 1, target));
227      }
228
229      @Override
230      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
231        switch (_hash) {
232        case 103668165: /*match*/  return new Property("match", "string", "The relative match of the target term with respect to the mapped text item. Result meanings:\n\n* '>': the mapping is to a broader term e.g. orginal text = arbovirus infection , target = viral infection\n* '=': the mapping is to a (supposedly) equivalent to the original item\n* '<': the mapping is to a narrower term. e.g. original text = diabetes , mapping = diabetes mellitus.\n* '?': the kind of mapping is unknown.\n\nThe first three values are taken from the ISO standards 2788 ( Guide to Establishment and development of monolingual thesauri) and 5964 (Guide to Establishment and development of multilingual thesauri).", 0, 1, match);
233        case -220463842: /*purpose*/  return new Property("purpose", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "Purpose of the mapping e.g. 'automated data mining', 'billing', 'interoperability'.", 0, 1, purpose);
234        case -880905839: /*target*/  return new Property("target", "http://openehr.org/fhir/StructureDefinition/CODE-PHRASE", "The target term of the mapping.", 0, 1, target);
235        default: return super.getNamedProperty(_hash, _name, _checkValid);
236        }
237
238      }
239
240      @Override
241      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
242        switch (hash) {
243        case 103668165: /*match*/ return this.match == null ? new Base[0] : new Base[] {this.match}; // StringType
244        case -220463842: /*purpose*/ return this.purpose == null ? new Base[0] : new Base[] {this.purpose}; // DV_CODED_TEXT
245        case -880905839: /*target*/ return this.target == null ? new Base[0] : new Base[] {this.target}; // CODE_PHRASE
246        default: return super.getProperty(hash, name, checkValid);
247        }
248
249      }
250
251      @Override
252      public Base setProperty(int hash, String name, Base value) throws FHIRException {
253        switch (hash) {
254        case 103668165: // match
255          this.match = TypeConvertor.castToString(value); // StringType
256          return value;
257        case -220463842: // purpose
258          this.purpose = (DV_CODED_TEXT) value; // DV_CODED_TEXT
259          return value;
260        case -880905839: // target
261          this.target = (CODE_PHRASE) value; // CODE_PHRASE
262          return value;
263        default: return super.setProperty(hash, name, value);
264        }
265
266      }
267
268      @Override
269      public Base setProperty(String name, Base value) throws FHIRException {
270        if (name.equals("match")) {
271          this.match = TypeConvertor.castToString(value); // StringType
272        } else if (name.equals("purpose")) {
273          this.purpose = (DV_CODED_TEXT) value; // DV_CODED_TEXT
274        } else if (name.equals("target")) {
275          this.target = (CODE_PHRASE) value; // CODE_PHRASE
276        } else
277          return super.setProperty(name, value);
278        return value;
279      }
280
281      @Override
282      public Base makeProperty(int hash, String name) throws FHIRException {
283        switch (hash) {
284        case 103668165:  return getMatchElement();
285        case -220463842:  return getPurpose();
286        case -880905839:  return getTarget();
287        default: return super.makeProperty(hash, name);
288        }
289
290      }
291
292      @Override
293      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
294        switch (hash) {
295        case 103668165: /*match*/ return new String[] {"string"};
296        case -220463842: /*purpose*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT"};
297        case -880905839: /*target*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/CODE-PHRASE"};
298        default: return super.getTypesForProperty(hash, name);
299        }
300
301      }
302
303      @Override
304      public Base addChild(String name) throws FHIRException {
305        if (name.equals("match")) {
306          throw new FHIRException("Cannot call addChild on a singleton property TERM_MAPPING.match");
307        }
308        else if (name.equals("purpose")) {
309          this.purpose = new DV_CODED_TEXT();
310          return this.purpose;
311        }
312        else if (name.equals("target")) {
313          this.target = new CODE_PHRASE();
314          return this.target;
315        }
316        else
317          return super.addChild(name);
318      }
319
320  public String fhirType() {
321    return "TERM_MAPPING";
322
323  }
324
325      public TERM_MAPPING copy() {
326        TERM_MAPPING dst = new TERM_MAPPING();
327        copyValues(dst);
328        return dst;
329      }
330
331      public void copyValues(TERM_MAPPING dst) {
332        super.copyValues(dst);
333        dst.match = match == null ? null : match.copy();
334        dst.purpose = purpose == null ? null : purpose.copy();
335        dst.target = target == null ? null : target.copy();
336      }
337
338      protected TERM_MAPPING typedCopy() {
339        return copy();
340      }
341
342      @Override
343      public boolean equalsDeep(Base other_) {
344        if (!super.equalsDeep(other_))
345          return false;
346        if (!(other_ instanceof TERM_MAPPING))
347          return false;
348        TERM_MAPPING o = (TERM_MAPPING) other_;
349        return compareDeep(match, o.match, true) && compareDeep(purpose, o.purpose, true) && compareDeep(target, o.target, true)
350          ;
351      }
352
353      @Override
354      public boolean equalsShallow(Base other_) {
355        if (!super.equalsShallow(other_))
356          return false;
357        if (!(other_ instanceof TERM_MAPPING))
358          return false;
359        TERM_MAPPING o = (TERM_MAPPING) other_;
360        return compareValues(match, o.match, true);
361      }
362
363      public boolean isEmpty() {
364        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(match, purpose, target);
365      }
366
367
368}
369