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 * Class providing details of a natural language translation.
050 */
051@DatatypeDef(name="TRANSLATION_DETAILS")
052public class TRANSLATION_DETAILS extends LogicalBase implements ICompositeType {
053
054    /**
055     * Language of the translation.
056     */
057    @Child(name = "language", type = {CODE_PHRASE.class}, order=0, min=1, max=1, modifier=false, summary=false)
058    @Description(shortDefinition="Language of the translation", formalDefinition="Language of the translation." )
059    protected CODE_PHRASE language;
060
061    /**
062     * Translator name and other demographic details.
063     */
064    @Child(name = "author", type = {StringType.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
065    @Description(shortDefinition="Translator name and other demographic details", formalDefinition="Translator name and other demographic details." )
066    protected List<StringType> authorList;
067
068    /**
069     * Accreditation of translator, usually a national translator?s registration or association membership id.
070     */
071    @Child(name = "accreditation", type = {StringType.class}, order=2, min=1, max=1, modifier=false, summary=false)
072    @Description(shortDefinition="Accreditation of translator, usually a national translator?s registration or association membership id", formalDefinition="Accreditation of translator, usually a national translator?s registration or association membership id." )
073    protected StringType accreditation;
074
075    /**
076     * Any other meta-data.
077     */
078    @Child(name = "other_details", type = {StringType.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
079    @Description(shortDefinition="Any other meta-data", formalDefinition="Any other meta-data." )
080    protected List<StringType> other_detailsList;
081
082    private static final long serialVersionUID = -1093734482L;
083
084  /**
085   * Constructor
086   */
087    public TRANSLATION_DETAILS() {
088      super();
089    }
090
091  /**
092   * Constructor
093   */
094    public TRANSLATION_DETAILS(CODE_PHRASE language, String accreditation) {
095      super();
096      this.setLanguage(language);
097      this.setAccreditation(accreditation);
098    }
099
100    /**
101     * @return {@link #language} (Language of the translation.)
102     */
103    public CODE_PHRASE getLanguage() { 
104      if (this.language == null)
105        if (Configuration.errorOnAutoCreate())
106          throw new Error("Attempt to auto-create TRANSLATION_DETAILS.language");
107        else if (Configuration.doAutoCreate())
108          this.language = new CODE_PHRASE(); // cc
109      return this.language;
110    }
111
112    public boolean hasLanguage() { 
113      return this.language != null && !this.language.isEmpty();
114    }
115
116    /**
117     * @param value {@link #language} (Language of the translation.)
118     */
119    public TRANSLATION_DETAILS setLanguage(CODE_PHRASE value) { 
120      this.language = value;
121      return this;
122    }
123
124    /**
125     * @return {@link #author} (Translator name and other demographic details.)
126     */
127    public List<StringType> getAuthorList() { 
128      if (this.authorList == null)
129        this.authorList = new ArrayList<StringType>();
130      return this.authorList;
131    }
132
133    /**
134     * @return Returns a reference to <code>this</code> for easy method chaining
135     */
136    public TRANSLATION_DETAILS setAuthorList(List<StringType> theAuthor) { 
137      this.authorList = theAuthor;
138      return this;
139    }
140
141    public boolean hasAuthor() { 
142      if (this.authorList == null)
143        return false;
144      for (StringType item : this.authorList)
145        if (!item.isEmpty())
146          return true;
147      return false;
148    }
149
150    /**
151     * @return {@link #author} (Translator name and other demographic details.)
152     */
153    public StringType addAuthorElement() {//2 
154      StringType t = new StringType();
155      if (this.authorList == null)
156        this.authorList = new ArrayList<StringType>();
157      this.authorList.add(t);
158      return t;
159    }
160
161    /**
162     * @param value {@link #author} (Translator name and other demographic details.)
163     */
164    public TRANSLATION_DETAILS addAuthor(String value) { //1
165      StringType t = new StringType();
166      t.setValue(value);
167      if (this.authorList == null)
168        this.authorList = new ArrayList<StringType>();
169      this.authorList.add(t);
170      return this;
171    }
172
173    /**
174     * @param value {@link #author} (Translator name and other demographic details.)
175     */
176    public boolean hasAuthor(String value) { 
177      if (this.authorList == null)
178        return false;
179      for (StringType v : this.authorList)
180        if (v.getValue().equals(value)) // string
181          return true;
182      return false;
183    }
184
185    /**
186     * @return {@link #accreditation} (Accreditation of translator, usually a national translator?s registration or association membership id.). This is the underlying object with id, value and extensions. The accessor "getAccreditation" gives direct access to the value
187     */
188    public StringType getAccreditationElement() { 
189      if (this.accreditation == null)
190        if (Configuration.errorOnAutoCreate())
191          throw new Error("Attempt to auto-create TRANSLATION_DETAILS.accreditation");
192        else if (Configuration.doAutoCreate())
193          this.accreditation = new StringType(); // bb
194      return this.accreditation;
195    }
196
197    public boolean hasAccreditationElement() { 
198      return this.accreditation != null && !this.accreditation.isEmpty();
199    }
200
201    public boolean hasAccreditation() { 
202      return this.accreditation != null && !this.accreditation.isEmpty();
203    }
204
205    /**
206     * @param value {@link #accreditation} (Accreditation of translator, usually a national translator?s registration or association membership id.). This is the underlying object with id, value and extensions. The accessor "getAccreditation" gives direct access to the value
207     */
208    public TRANSLATION_DETAILS setAccreditationElement(StringType value) { 
209      this.accreditation = value;
210      return this;
211    }
212
213    /**
214     * @return Accreditation of translator, usually a national translator?s registration or association membership id.
215     */
216    public String getAccreditation() { 
217      return this.accreditation == null ? null : this.accreditation.getValue();
218    }
219
220    /**
221     * @param value Accreditation of translator, usually a national translator?s registration or association membership id.
222     */
223    public TRANSLATION_DETAILS setAccreditation(String value) { 
224        if (this.accreditation == null)
225          this.accreditation = new StringType();
226        this.accreditation.setValue(value);
227      return this;
228    }
229
230    /**
231     * @return {@link #other_details} (Any other meta-data.)
232     */
233    public List<StringType> getOther_detailsList() { 
234      if (this.other_detailsList == null)
235        this.other_detailsList = new ArrayList<StringType>();
236      return this.other_detailsList;
237    }
238
239    /**
240     * @return Returns a reference to <code>this</code> for easy method chaining
241     */
242    public TRANSLATION_DETAILS setOther_detailsList(List<StringType> theOther_details) { 
243      this.other_detailsList = theOther_details;
244      return this;
245    }
246
247    public boolean hasOther_details() { 
248      if (this.other_detailsList == null)
249        return false;
250      for (StringType item : this.other_detailsList)
251        if (!item.isEmpty())
252          return true;
253      return false;
254    }
255
256    /**
257     * @return {@link #other_details} (Any other meta-data.)
258     */
259    public StringType addOther_detailsElement() {//2 
260      StringType t = new StringType();
261      if (this.other_detailsList == null)
262        this.other_detailsList = new ArrayList<StringType>();
263      this.other_detailsList.add(t);
264      return t;
265    }
266
267    /**
268     * @param value {@link #other_details} (Any other meta-data.)
269     */
270    public TRANSLATION_DETAILS addOther_details(String value) { //1
271      StringType t = new StringType();
272      t.setValue(value);
273      if (this.other_detailsList == null)
274        this.other_detailsList = new ArrayList<StringType>();
275      this.other_detailsList.add(t);
276      return this;
277    }
278
279    /**
280     * @param value {@link #other_details} (Any other meta-data.)
281     */
282    public boolean hasOther_details(String value) { 
283      if (this.other_detailsList == null)
284        return false;
285      for (StringType v : this.other_detailsList)
286        if (v.getValue().equals(value)) // string
287          return true;
288      return false;
289    }
290
291      protected void listChildren(List<Property> children) {
292        super.listChildren(children);
293        children.add(new Property("language", "http://openehr.org/fhir/StructureDefinition/CODE-PHRASE", "Language of the translation.", 0, 1, language));
294        children.add(new Property("author", "string", "Translator name and other demographic details.", 0, java.lang.Integer.MAX_VALUE, authorList));
295        children.add(new Property("accreditation", "string", "Accreditation of translator, usually a national translator?s registration or association membership id.", 0, 1, accreditation));
296        children.add(new Property("other_details", "string", "Any other meta-data.", 0, java.lang.Integer.MAX_VALUE, other_detailsList));
297      }
298
299      @Override
300      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
301        switch (_hash) {
302        case -1613589672: /*language*/  return new Property("language", "http://openehr.org/fhir/StructureDefinition/CODE-PHRASE", "Language of the translation.", 0, 1, language);
303        case -1406328437: /*author*/  return new Property("author", "string", "Translator name and other demographic details.", 0, java.lang.Integer.MAX_VALUE, authorList);
304        case 1197534778: /*accreditation*/  return new Property("accreditation", "string", "Accreditation of translator, usually a national translator?s registration or association membership id.", 0, 1, accreditation);
305        case -1257043949: /*other_details*/  return new Property("other_details", "string", "Any other meta-data.", 0, java.lang.Integer.MAX_VALUE, other_detailsList);
306        default: return super.getNamedProperty(_hash, _name, _checkValid);
307        }
308
309      }
310
311      @Override
312      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
313        switch (hash) {
314        case -1613589672: /*language*/ return this.language == null ? new Base[0] : new Base[] {this.language}; // CODE_PHRASE
315        case -1406328437: /*author*/ return this.authorList == null ? new Base[0] : this.authorList.toArray(new Base[this.authorList.size()]); // StringType
316        case 1197534778: /*accreditation*/ return this.accreditation == null ? new Base[0] : new Base[] {this.accreditation}; // StringType
317        case -1257043949: /*other_details*/ return this.other_detailsList == null ? new Base[0] : this.other_detailsList.toArray(new Base[this.other_detailsList.size()]); // StringType
318        default: return super.getProperty(hash, name, checkValid);
319        }
320
321      }
322
323      @Override
324      public Base setProperty(int hash, String name, Base value) throws FHIRException {
325        switch (hash) {
326        case -1613589672: // language
327          this.language = (CODE_PHRASE) value; // CODE_PHRASE
328          return value;
329        case -1406328437: // author
330          this.getAuthorList().add(TypeConvertor.castToString(value)); // StringType
331          return value;
332        case 1197534778: // accreditation
333          this.accreditation = TypeConvertor.castToString(value); // StringType
334          return value;
335        case -1257043949: // other_details
336          this.getOther_detailsList().add(TypeConvertor.castToString(value)); // StringType
337          return value;
338        default: return super.setProperty(hash, name, value);
339        }
340
341      }
342
343      @Override
344      public Base setProperty(String name, Base value) throws FHIRException {
345        if (name.equals("language")) {
346          this.language = (CODE_PHRASE) value; // CODE_PHRASE
347        } else if (name.equals("author")) {
348          this.getAuthorList().add(TypeConvertor.castToString(value)); // StringType
349        } else if (name.equals("accreditation")) {
350          this.accreditation = TypeConvertor.castToString(value); // StringType
351        } else if (name.equals("other_details")) {
352          this.getOther_detailsList().add(TypeConvertor.castToString(value)); // StringType
353        } else
354          return super.setProperty(name, value);
355        return value;
356      }
357
358      @Override
359      public Base makeProperty(int hash, String name) throws FHIRException {
360        switch (hash) {
361        case -1613589672:  return getLanguage();
362        case -1406328437:  return addAuthorElement();
363        case 1197534778:  return getAccreditationElement();
364        case -1257043949:  return addOther_detailsElement();
365        default: return super.makeProperty(hash, name);
366        }
367
368      }
369
370      @Override
371      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
372        switch (hash) {
373        case -1613589672: /*language*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/CODE-PHRASE"};
374        case -1406328437: /*author*/ return new String[] {"string"};
375        case 1197534778: /*accreditation*/ return new String[] {"string"};
376        case -1257043949: /*other_details*/ return new String[] {"string"};
377        default: return super.getTypesForProperty(hash, name);
378        }
379
380      }
381
382      @Override
383      public Base addChild(String name) throws FHIRException {
384        if (name.equals("language")) {
385          this.language = new CODE_PHRASE();
386          return this.language;
387        }
388        else if (name.equals("author")) {
389          throw new FHIRException("Cannot call addChild on a singleton property TRANSLATION_DETAILS.author");
390        }
391        else if (name.equals("accreditation")) {
392          throw new FHIRException("Cannot call addChild on a singleton property TRANSLATION_DETAILS.accreditation");
393        }
394        else if (name.equals("other_details")) {
395          throw new FHIRException("Cannot call addChild on a singleton property TRANSLATION_DETAILS.other_details");
396        }
397        else
398          return super.addChild(name);
399      }
400
401  public String fhirType() {
402    return "TRANSLATION_DETAILS";
403
404  }
405
406      public TRANSLATION_DETAILS copy() {
407        TRANSLATION_DETAILS dst = new TRANSLATION_DETAILS();
408        copyValues(dst);
409        return dst;
410      }
411
412      public void copyValues(TRANSLATION_DETAILS dst) {
413        super.copyValues(dst);
414        dst.language = language == null ? null : language.copy();
415        if (authorList != null) {
416          dst.authorList = new ArrayList<StringType>();
417          for (StringType i : authorList)
418            dst.authorList.add(i.copy());
419        };
420        dst.accreditation = accreditation == null ? null : accreditation.copy();
421        if (other_detailsList != null) {
422          dst.other_detailsList = new ArrayList<StringType>();
423          for (StringType i : other_detailsList)
424            dst.other_detailsList.add(i.copy());
425        };
426      }
427
428      protected TRANSLATION_DETAILS typedCopy() {
429        return copy();
430      }
431
432      @Override
433      public boolean equalsDeep(Base other_) {
434        if (!super.equalsDeep(other_))
435          return false;
436        if (!(other_ instanceof TRANSLATION_DETAILS))
437          return false;
438        TRANSLATION_DETAILS o = (TRANSLATION_DETAILS) other_;
439        return compareDeep(language, o.language, true) && compareDeep(authorList, o.authorList, true) && compareDeep(accreditation, o.accreditation, true)
440           && compareDeep(other_detailsList, o.other_detailsList, true);
441      }
442
443      @Override
444      public boolean equalsShallow(Base other_) {
445        if (!super.equalsShallow(other_))
446          return false;
447        if (!(other_ instanceof TRANSLATION_DETAILS))
448          return false;
449        TRANSLATION_DETAILS o = (TRANSLATION_DETAILS) other_;
450        return compareValues(authorList, o.authorList, true) && compareValues(accreditation, o.accreditation, true)
451           && compareValues(other_detailsList, o.other_detailsList, true);
452      }
453
454      public boolean isEmpty() {
455        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(language, authorList, accreditation
456          , other_detailsList);
457      }
458
459
460}
461