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 fully coordinated (i.e. all coordination has been performed) term from a terminology service (as distinct from a particular terminology).
050 */
051@DatatypeDef(name="CODE_PHRASE")
052public class CODE_PHRASE extends LogicalBase implements ICompositeType {
053
054    /**
055     * Identifier of the distinct terminology from which the code_string (or its elements) was extracted.
056     */
057    @Child(name = "terminology_id", type = {TERMINOLOGY_ID.class}, order=0, min=1, max=1, modifier=false, summary=false)
058    @Description(shortDefinition="Identifier of the distinct terminology from which the code_string was extracted", formalDefinition="Identifier of the distinct terminology from which the code_string (or its elements) was extracted." )
059    protected TERMINOLOGY_ID terminology_id;
060
061    /**
062     * The key used by the terminology service to identify a concept or coordination of concepts. This string is most likely parsable inside the terminology service, but nothing can be assumed about its syntax outside that context.
063     */
064    @Child(name = "code_string", type = {StringType.class}, order=1, min=1, max=1, modifier=false, summary=false)
065    @Description(shortDefinition="The key used by the terminology service to identify a concept or coordination of concepts", formalDefinition="The key used by the terminology service to identify a concept or coordination of concepts. This string is most likely parsable inside the terminology service, but nothing can be assumed about its syntax outside that context." )
066    protected StringType code_string;
067
068    /**
069     * Optional attribute to carry preferred term corresponding to the code or expression in code_string. Typical use in integration situations which create mappings, and representing data for which both a (non-preferred) actual term and a preferred term are both required.
070     */
071    @Child(name = "preferred_term", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=false)
072    @Description(shortDefinition="Optional attribute to carry preferred term corresponding to the code or expression in code_string", formalDefinition="Optional attribute to carry preferred term corresponding to the code or expression in code_string. Typical use in integration situations which create mappings, and representing data for which both a (non-preferred) actual term and a preferred term are both required." )
073    protected StringType preferred_term;
074
075    private static final long serialVersionUID = -380890311L;
076
077  /**
078   * Constructor
079   */
080    public CODE_PHRASE() {
081      super();
082    }
083
084  /**
085   * Constructor
086   */
087    public CODE_PHRASE(TERMINOLOGY_ID terminology_id, String code_string) {
088      super();
089      this.setTerminology_id(terminology_id);
090      this.setCode_string(code_string);
091    }
092
093    /**
094     * @return {@link #terminology_id} (Identifier of the distinct terminology from which the code_string (or its elements) was extracted.)
095     */
096    public TERMINOLOGY_ID getTerminology_id() { 
097      if (this.terminology_id == null)
098        if (Configuration.errorOnAutoCreate())
099          throw new Error("Attempt to auto-create CODE_PHRASE.terminology_id");
100        else if (Configuration.doAutoCreate())
101          this.terminology_id = new TERMINOLOGY_ID(); // cc
102      return this.terminology_id;
103    }
104
105    public boolean hasTerminology_id() { 
106      return this.terminology_id != null && !this.terminology_id.isEmpty();
107    }
108
109    /**
110     * @param value {@link #terminology_id} (Identifier of the distinct terminology from which the code_string (or its elements) was extracted.)
111     */
112    public CODE_PHRASE setTerminology_id(TERMINOLOGY_ID value) { 
113      this.terminology_id = value;
114      return this;
115    }
116
117    /**
118     * @return {@link #code_string} (The key used by the terminology service to identify a concept or coordination of concepts. This string is most likely parsable inside the terminology service, but nothing can be assumed about its syntax outside that context.). This is the underlying object with id, value and extensions. The accessor "getCode_string" gives direct access to the value
119     */
120    public StringType getCode_stringElement() { 
121      if (this.code_string == null)
122        if (Configuration.errorOnAutoCreate())
123          throw new Error("Attempt to auto-create CODE_PHRASE.code_string");
124        else if (Configuration.doAutoCreate())
125          this.code_string = new StringType(); // bb
126      return this.code_string;
127    }
128
129    public boolean hasCode_stringElement() { 
130      return this.code_string != null && !this.code_string.isEmpty();
131    }
132
133    public boolean hasCode_string() { 
134      return this.code_string != null && !this.code_string.isEmpty();
135    }
136
137    /**
138     * @param value {@link #code_string} (The key used by the terminology service to identify a concept or coordination of concepts. This string is most likely parsable inside the terminology service, but nothing can be assumed about its syntax outside that context.). This is the underlying object with id, value and extensions. The accessor "getCode_string" gives direct access to the value
139     */
140    public CODE_PHRASE setCode_stringElement(StringType value) { 
141      this.code_string = value;
142      return this;
143    }
144
145    /**
146     * @return The key used by the terminology service to identify a concept or coordination of concepts. This string is most likely parsable inside the terminology service, but nothing can be assumed about its syntax outside that context.
147     */
148    public String getCode_string() { 
149      return this.code_string == null ? null : this.code_string.getValue();
150    }
151
152    /**
153     * @param value The key used by the terminology service to identify a concept or coordination of concepts. This string is most likely parsable inside the terminology service, but nothing can be assumed about its syntax outside that context.
154     */
155    public CODE_PHRASE setCode_string(String value) { 
156        if (this.code_string == null)
157          this.code_string = new StringType();
158        this.code_string.setValue(value);
159      return this;
160    }
161
162    /**
163     * @return {@link #preferred_term} (Optional attribute to carry preferred term corresponding to the code or expression in code_string. Typical use in integration situations which create mappings, and representing data for which both a (non-preferred) actual term and a preferred term are both required.). This is the underlying object with id, value and extensions. The accessor "getPreferred_term" gives direct access to the value
164     */
165    public StringType getPreferred_termElement() { 
166      if (this.preferred_term == null)
167        if (Configuration.errorOnAutoCreate())
168          throw new Error("Attempt to auto-create CODE_PHRASE.preferred_term");
169        else if (Configuration.doAutoCreate())
170          this.preferred_term = new StringType(); // bb
171      return this.preferred_term;
172    }
173
174    public boolean hasPreferred_termElement() { 
175      return this.preferred_term != null && !this.preferred_term.isEmpty();
176    }
177
178    public boolean hasPreferred_term() { 
179      return this.preferred_term != null && !this.preferred_term.isEmpty();
180    }
181
182    /**
183     * @param value {@link #preferred_term} (Optional attribute to carry preferred term corresponding to the code or expression in code_string. Typical use in integration situations which create mappings, and representing data for which both a (non-preferred) actual term and a preferred term are both required.). This is the underlying object with id, value and extensions. The accessor "getPreferred_term" gives direct access to the value
184     */
185    public CODE_PHRASE setPreferred_termElement(StringType value) { 
186      this.preferred_term = value;
187      return this;
188    }
189
190    /**
191     * @return Optional attribute to carry preferred term corresponding to the code or expression in code_string. Typical use in integration situations which create mappings, and representing data for which both a (non-preferred) actual term and a preferred term are both required.
192     */
193    public String getPreferred_term() { 
194      return this.preferred_term == null ? null : this.preferred_term.getValue();
195    }
196
197    /**
198     * @param value Optional attribute to carry preferred term corresponding to the code or expression in code_string. Typical use in integration situations which create mappings, and representing data for which both a (non-preferred) actual term and a preferred term are both required.
199     */
200    public CODE_PHRASE setPreferred_term(String value) { 
201      if (Utilities.noString(value))
202        this.preferred_term = null;
203      else {
204        if (this.preferred_term == null)
205          this.preferred_term = new StringType();
206        this.preferred_term.setValue(value);
207      }
208      return this;
209    }
210
211      protected void listChildren(List<Property> children) {
212        super.listChildren(children);
213        children.add(new Property("terminology_id", "http://openehr.org/fhir/StructureDefinition/TERMINOLOGY-ID", "Identifier of the distinct terminology from which the code_string (or its elements) was extracted.", 0, 1, terminology_id));
214        children.add(new Property("code_string", "string", "The key used by the terminology service to identify a concept or coordination of concepts. This string is most likely parsable inside the terminology service, but nothing can be assumed about its syntax outside that context.", 0, 1, code_string));
215        children.add(new Property("preferred_term", "string", "Optional attribute to carry preferred term corresponding to the code or expression in code_string. Typical use in integration situations which create mappings, and representing data for which both a (non-preferred) actual term and a preferred term are both required.", 0, 1, preferred_term));
216      }
217
218      @Override
219      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
220        switch (_hash) {
221        case 1262816807: /*terminology_id*/  return new Property("terminology_id", "http://openehr.org/fhir/StructureDefinition/TERMINOLOGY-ID", "Identifier of the distinct terminology from which the code_string (or its elements) was extracted.", 0, 1, terminology_id);
222        case -752837981: /*code_string*/  return new Property("code_string", "string", "The key used by the terminology service to identify a concept or coordination of concepts. This string is most likely parsable inside the terminology service, but nothing can be assumed about its syntax outside that context.", 0, 1, code_string);
223        case -1673881238: /*preferred_term*/  return new Property("preferred_term", "string", "Optional attribute to carry preferred term corresponding to the code or expression in code_string. Typical use in integration situations which create mappings, and representing data for which both a (non-preferred) actual term and a preferred term are both required.", 0, 1, preferred_term);
224        default: return super.getNamedProperty(_hash, _name, _checkValid);
225        }
226
227      }
228
229      @Override
230      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
231        switch (hash) {
232        case 1262816807: /*terminology_id*/ return this.terminology_id == null ? new Base[0] : new Base[] {this.terminology_id}; // TERMINOLOGY_ID
233        case -752837981: /*code_string*/ return this.code_string == null ? new Base[0] : new Base[] {this.code_string}; // StringType
234        case -1673881238: /*preferred_term*/ return this.preferred_term == null ? new Base[0] : new Base[] {this.preferred_term}; // StringType
235        default: return super.getProperty(hash, name, checkValid);
236        }
237
238      }
239
240      @Override
241      public Base setProperty(int hash, String name, Base value) throws FHIRException {
242        switch (hash) {
243        case 1262816807: // terminology_id
244          this.terminology_id = (TERMINOLOGY_ID) value; // TERMINOLOGY_ID
245          return value;
246        case -752837981: // code_string
247          this.code_string = TypeConvertor.castToString(value); // StringType
248          return value;
249        case -1673881238: // preferred_term
250          this.preferred_term = TypeConvertor.castToString(value); // StringType
251          return value;
252        default: return super.setProperty(hash, name, value);
253        }
254
255      }
256
257      @Override
258      public Base setProperty(String name, Base value) throws FHIRException {
259        if (name.equals("terminology_id")) {
260          this.terminology_id = (TERMINOLOGY_ID) value; // TERMINOLOGY_ID
261        } else if (name.equals("code_string")) {
262          this.code_string = TypeConvertor.castToString(value); // StringType
263        } else if (name.equals("preferred_term")) {
264          this.preferred_term = TypeConvertor.castToString(value); // StringType
265        } else
266          return super.setProperty(name, value);
267        return value;
268      }
269
270      @Override
271      public Base makeProperty(int hash, String name) throws FHIRException {
272        switch (hash) {
273        case 1262816807:  return getTerminology_id();
274        case -752837981:  return getCode_stringElement();
275        case -1673881238:  return getPreferred_termElement();
276        default: return super.makeProperty(hash, name);
277        }
278
279      }
280
281      @Override
282      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
283        switch (hash) {
284        case 1262816807: /*terminology_id*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/TERMINOLOGY-ID"};
285        case -752837981: /*code_string*/ return new String[] {"string"};
286        case -1673881238: /*preferred_term*/ return new String[] {"string"};
287        default: return super.getTypesForProperty(hash, name);
288        }
289
290      }
291
292      @Override
293      public Base addChild(String name) throws FHIRException {
294        if (name.equals("terminology_id")) {
295          this.terminology_id = new TERMINOLOGY_ID();
296          return this.terminology_id;
297        }
298        else if (name.equals("code_string")) {
299          throw new FHIRException("Cannot call addChild on a singleton property CODE_PHRASE.code_string");
300        }
301        else if (name.equals("preferred_term")) {
302          throw new FHIRException("Cannot call addChild on a singleton property CODE_PHRASE.preferred_term");
303        }
304        else
305          return super.addChild(name);
306      }
307
308  public String fhirType() {
309    return "CODE_PHRASE";
310
311  }
312
313      public CODE_PHRASE copy() {
314        CODE_PHRASE dst = new CODE_PHRASE();
315        copyValues(dst);
316        return dst;
317      }
318
319      public void copyValues(CODE_PHRASE dst) {
320        super.copyValues(dst);
321        dst.terminology_id = terminology_id == null ? null : terminology_id.copy();
322        dst.code_string = code_string == null ? null : code_string.copy();
323        dst.preferred_term = preferred_term == null ? null : preferred_term.copy();
324      }
325
326      protected CODE_PHRASE typedCopy() {
327        return copy();
328      }
329
330      @Override
331      public boolean equalsDeep(Base other_) {
332        if (!super.equalsDeep(other_))
333          return false;
334        if (!(other_ instanceof CODE_PHRASE))
335          return false;
336        CODE_PHRASE o = (CODE_PHRASE) other_;
337        return compareDeep(terminology_id, o.terminology_id, true) && compareDeep(code_string, o.code_string, true)
338           && compareDeep(preferred_term, o.preferred_term, true);
339      }
340
341      @Override
342      public boolean equalsShallow(Base other_) {
343        if (!super.equalsShallow(other_))
344          return false;
345        if (!(other_ instanceof CODE_PHRASE))
346          return false;
347        CODE_PHRASE o = (CODE_PHRASE) other_;
348        return compareValues(code_string, o.code_string, true) && compareValues(preferred_term, o.preferred_term, true)
349          ;
350      }
351
352      public boolean isEmpty() {
353        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(terminology_id, code_string
354          , preferred_term);
355      }
356
357
358}
359