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.r5.openehr.Enumerations.*;
038import org.hl7.fhir.exceptions.FHIRException;
039import org.hl7.fhir.r5.model.*;
040import org.hl7.fhir.instance.model.api.ICompositeType;
041import ca.uhn.fhir.model.api.annotation.Child;
042import ca.uhn.fhir.model.api.annotation.ChildOrder;
043import ca.uhn.fhir.model.api.annotation.DatatypeDef;
044import ca.uhn.fhir.model.api.annotation.Description;
045import ca.uhn.fhir.model.api.annotation.Block;
046
047/**
048 * Abstract idea of an online resource created by a human author.
049 */
050@DatatypeDef(name="AUTHORED_RESOURCE")
051public abstract class AUTHORED_RESOURCE extends LogicalBase implements ICompositeType {
052
053    /**
054     * Language in which this resource was initially authored. Although there is no language primacy of resources overall, the language of original authoring is required to ensure natural language translations can preserve quality. Language is relevant in both the description and ontology sections.
055     */
056    @Child(name = "original_language", type = {CODE_PHRASE.class}, order=0, min=1, max=1, modifier=false, summary=false)
057    @Description(shortDefinition="Language in which this resource was initially authored", formalDefinition="Language in which this resource was initially authored. Although there is no language primacy of resources overall, the language of original authoring is required to ensure natural language translations can preserve quality. Language is relevant in both the description and ontology sections." )
058    protected CODE_PHRASE original_language;
059
060    /**
061     * True if this resource is under any kind of change control (even file copying), in which case revision history is created.
062     */
063    @Child(name = "is_controlled", type = {BooleanType.class}, order=1, min=0, max=1, modifier=false, summary=false)
064    @Description(shortDefinition="True if this resource is under any kind of change control (even file copying), in which case revision history is created", formalDefinition="True if this resource is under any kind of change control (even file copying), in which case revision history is created." )
065    protected BooleanType is_controlled;
066
067    /**
068     * List of details for each natural-language translation made of this resource, keyed by language. For each translation listed here, there must be corresponding sections in all language-dependent parts of the resource. The original_language does not appear in this list.
069     */
070    @Child(name = "translations", type = {TRANSLATION_DETAILS.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
071    @Description(shortDefinition="List of details for each natural-language translation made of this resource, keyed by language", formalDefinition="List of details for each natural-language translation made of this resource, keyed by language. For each translation listed here, there must be corresponding sections in all language-dependent parts of the resource. The original_language does not appear in this list." )
072    protected List<TRANSLATION_DETAILS> translationsList;
073
074    /**
075     * Description and lifecycle information of the resource.
076     */
077    @Child(name = "description", type = {RESOURCE_DESCRIPTION.class}, order=3, min=0, max=1, modifier=false, summary=false)
078    @Description(shortDefinition="Description and lifecycle information of the resource", formalDefinition="Description and lifecycle information of the resource." )
079    protected RESOURCE_DESCRIPTION description;
080
081    /**
082     * The revision history of the resource. Only required if is_controlled = True (avoids large revision histories for informal or private editing situations).
083     */
084    @Child(name = "revision_history", type = {REVISION_HISTORY.class}, order=4, min=0, max=1, modifier=false, summary=false)
085    @Description(shortDefinition="The revision history of the resource. Only required if is_controlled = True", formalDefinition="The revision history of the resource. Only required if is_controlled = True (avoids large revision histories for informal or private editing situations)." )
086    protected REVISION_HISTORY revision_history;
087
088    private static final long serialVersionUID = 673004665L;
089
090  /**
091   * Constructor
092   */
093    public AUTHORED_RESOURCE() {
094      super();
095    }
096
097  /**
098   * Constructor
099   */
100    public AUTHORED_RESOURCE(CODE_PHRASE original_language) {
101      super();
102      this.setOriginal_language(original_language);
103    }
104
105    /**
106     * @return {@link #original_language} (Language in which this resource was initially authored. Although there is no language primacy of resources overall, the language of original authoring is required to ensure natural language translations can preserve quality. Language is relevant in both the description and ontology sections.)
107     */
108    public CODE_PHRASE getOriginal_language() { 
109      if (this.original_language == null)
110        if (Configuration.errorOnAutoCreate())
111          throw new Error("Attempt to auto-create AUTHORED_RESOURCE.original_language");
112        else if (Configuration.doAutoCreate())
113          this.original_language = new CODE_PHRASE(); // cc
114      return this.original_language;
115    }
116
117    public boolean hasOriginal_language() { 
118      return this.original_language != null && !this.original_language.isEmpty();
119    }
120
121    /**
122     * @param value {@link #original_language} (Language in which this resource was initially authored. Although there is no language primacy of resources overall, the language of original authoring is required to ensure natural language translations can preserve quality. Language is relevant in both the description and ontology sections.)
123     */
124    public AUTHORED_RESOURCE setOriginal_language(CODE_PHRASE value) { 
125      this.original_language = value;
126      return this;
127    }
128
129    /**
130     * @return {@link #is_controlled} (True if this resource is under any kind of change control (even file copying), in which case revision history is created.). This is the underlying object with id, value and extensions. The accessor "getIs_controlled" gives direct access to the value
131     */
132    public BooleanType getIs_controlledElement() { 
133      if (this.is_controlled == null)
134        if (Configuration.errorOnAutoCreate())
135          throw new Error("Attempt to auto-create AUTHORED_RESOURCE.is_controlled");
136        else if (Configuration.doAutoCreate())
137          this.is_controlled = new BooleanType(); // bb
138      return this.is_controlled;
139    }
140
141    public boolean hasIs_controlledElement() { 
142      return this.is_controlled != null && !this.is_controlled.isEmpty();
143    }
144
145    public boolean hasIs_controlled() { 
146      return this.is_controlled != null && !this.is_controlled.isEmpty();
147    }
148
149    /**
150     * @param value {@link #is_controlled} (True if this resource is under any kind of change control (even file copying), in which case revision history is created.). This is the underlying object with id, value and extensions. The accessor "getIs_controlled" gives direct access to the value
151     */
152    public AUTHORED_RESOURCE setIs_controlledElement(BooleanType value) { 
153      this.is_controlled = value;
154      return this;
155    }
156
157    /**
158     * @return True if this resource is under any kind of change control (even file copying), in which case revision history is created.
159     */
160    public boolean getIs_controlled() { 
161      return this.is_controlled == null || this.is_controlled.isEmpty() ? false : this.is_controlled.getValue();
162    }
163
164    /**
165     * @param value True if this resource is under any kind of change control (even file copying), in which case revision history is created.
166     */
167    public AUTHORED_RESOURCE setIs_controlled(boolean value) { 
168        if (this.is_controlled == null)
169          this.is_controlled = new BooleanType();
170        this.is_controlled.setValue(value);
171      return this;
172    }
173
174    /**
175     * @return {@link #translations} (List of details for each natural-language translation made of this resource, keyed by language. For each translation listed here, there must be corresponding sections in all language-dependent parts of the resource. The original_language does not appear in this list.)
176     */
177    public List<TRANSLATION_DETAILS> getTranslationsList() { 
178      if (this.translationsList == null)
179        this.translationsList = new ArrayList<TRANSLATION_DETAILS>();
180      return this.translationsList;
181    }
182
183    /**
184     * @return Returns a reference to <code>this</code> for easy method chaining
185     */
186    public AUTHORED_RESOURCE setTranslationsList(List<TRANSLATION_DETAILS> theTranslations) { 
187      this.translationsList = theTranslations;
188      return this;
189    }
190
191    public boolean hasTranslations() { 
192      if (this.translationsList == null)
193        return false;
194      for (TRANSLATION_DETAILS item : this.translationsList)
195        if (!item.isEmpty())
196          return true;
197      return false;
198    }
199
200    public TRANSLATION_DETAILS addTranslations() { //3a
201      TRANSLATION_DETAILS t = new TRANSLATION_DETAILS();
202      if (this.translationsList == null)
203        this.translationsList = new ArrayList<TRANSLATION_DETAILS>();
204      this.translationsList.add(t);
205      return t;
206    }
207
208    public AUTHORED_RESOURCE addTranslations(TRANSLATION_DETAILS t) { //3b
209      if (t == null)
210        return this;
211      if (this.translationsList == null)
212        this.translationsList = new ArrayList<TRANSLATION_DETAILS>();
213      this.translationsList.add(t);
214      return this;
215    }
216
217    /**
218     * @return The first repetition of repeating field {@link #translations}, creating it if it does not already exist {3}
219     */
220    public TRANSLATION_DETAILS getTranslationsFirstRep() { 
221      if (getTranslationsList().isEmpty()) {
222        addTranslations();
223      }
224      return getTranslationsList().get(0);
225    }
226
227    /**
228     * @return {@link #description} (Description and lifecycle information of the resource.)
229     */
230    public RESOURCE_DESCRIPTION getDescription() { 
231      if (this.description == null)
232        if (Configuration.errorOnAutoCreate())
233          throw new Error("Attempt to auto-create AUTHORED_RESOURCE.description");
234        else if (Configuration.doAutoCreate())
235          this.description = new RESOURCE_DESCRIPTION(); // cc
236      return this.description;
237    }
238
239    public boolean hasDescription() { 
240      return this.description != null && !this.description.isEmpty();
241    }
242
243    /**
244     * @param value {@link #description} (Description and lifecycle information of the resource.)
245     */
246    public AUTHORED_RESOURCE setDescription(RESOURCE_DESCRIPTION value) { 
247      this.description = value;
248      return this;
249    }
250
251    /**
252     * @return {@link #revision_history} (The revision history of the resource. Only required if is_controlled = True (avoids large revision histories for informal or private editing situations).)
253     */
254    public REVISION_HISTORY getRevision_history() { 
255      if (this.revision_history == null)
256        if (Configuration.errorOnAutoCreate())
257          throw new Error("Attempt to auto-create AUTHORED_RESOURCE.revision_history");
258        else if (Configuration.doAutoCreate())
259          this.revision_history = new REVISION_HISTORY(); // cc
260      return this.revision_history;
261    }
262
263    public boolean hasRevision_history() { 
264      return this.revision_history != null && !this.revision_history.isEmpty();
265    }
266
267    /**
268     * @param value {@link #revision_history} (The revision history of the resource. Only required if is_controlled = True (avoids large revision histories for informal or private editing situations).)
269     */
270    public AUTHORED_RESOURCE setRevision_history(REVISION_HISTORY value) { 
271      this.revision_history = value;
272      return this;
273    }
274
275      protected void listChildren(List<Property> children) {
276        super.listChildren(children);
277        children.add(new Property("original_language", "http://openehr.org/fhir/StructureDefinition/CODE-PHRASE", "Language in which this resource was initially authored. Although there is no language primacy of resources overall, the language of original authoring is required to ensure natural language translations can preserve quality. Language is relevant in both the description and ontology sections.", 0, 1, original_language));
278        children.add(new Property("is_controlled", "boolean", "True if this resource is under any kind of change control (even file copying), in which case revision history is created.", 0, 1, is_controlled));
279        children.add(new Property("translations", "http://openehr.org/fhir/StructureDefinition/TRANSLATION-DETAILS", "List of details for each natural-language translation made of this resource, keyed by language. For each translation listed here, there must be corresponding sections in all language-dependent parts of the resource. The original_language does not appear in this list.", 0, java.lang.Integer.MAX_VALUE, translationsList));
280        children.add(new Property("description", "http://openehr.org/fhir/StructureDefinition/RESOURCE-DESCRIPTION", "Description and lifecycle information of the resource.", 0, 1, description));
281        children.add(new Property("revision_history", "http://openehr.org/fhir/StructureDefinition/REVISION-HISTORY", "The revision history of the resource. Only required if is_controlled = True (avoids large revision histories for informal or private editing situations).", 0, 1, revision_history));
282      }
283
284      @Override
285      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
286        switch (_hash) {
287        case 1757722118: /*original_language*/  return new Property("original_language", "http://openehr.org/fhir/StructureDefinition/CODE-PHRASE", "Language in which this resource was initially authored. Although there is no language primacy of resources overall, the language of original authoring is required to ensure natural language translations can preserve quality. Language is relevant in both the description and ontology sections.", 0, 1, original_language);
288        case -1352159805: /*is_controlled*/  return new Property("is_controlled", "boolean", "True if this resource is under any kind of change control (even file copying), in which case revision history is created.", 0, 1, is_controlled);
289        case -1225497630: /*translations*/  return new Property("translations", "http://openehr.org/fhir/StructureDefinition/TRANSLATION-DETAILS", "List of details for each natural-language translation made of this resource, keyed by language. For each translation listed here, there must be corresponding sections in all language-dependent parts of the resource. The original_language does not appear in this list.", 0, java.lang.Integer.MAX_VALUE, translationsList);
290        case -1724546052: /*description*/  return new Property("description", "http://openehr.org/fhir/StructureDefinition/RESOURCE-DESCRIPTION", "Description and lifecycle information of the resource.", 0, 1, description);
291        case -1037551568: /*revision_history*/  return new Property("revision_history", "http://openehr.org/fhir/StructureDefinition/REVISION-HISTORY", "The revision history of the resource. Only required if is_controlled = True (avoids large revision histories for informal or private editing situations).", 0, 1, revision_history);
292        default: return super.getNamedProperty(_hash, _name, _checkValid);
293        }
294
295      }
296
297      @Override
298      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
299        switch (hash) {
300        case 1757722118: /*original_language*/ return this.original_language == null ? new Base[0] : new Base[] {this.original_language}; // CODE_PHRASE
301        case -1352159805: /*is_controlled*/ return this.is_controlled == null ? new Base[0] : new Base[] {this.is_controlled}; // BooleanType
302        case -1225497630: /*translations*/ return this.translationsList == null ? new Base[0] : this.translationsList.toArray(new Base[this.translationsList.size()]); // TRANSLATION_DETAILS
303        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // RESOURCE_DESCRIPTION
304        case -1037551568: /*revision_history*/ return this.revision_history == null ? new Base[0] : new Base[] {this.revision_history}; // REVISION_HISTORY
305        default: return super.getProperty(hash, name, checkValid);
306        }
307
308      }
309
310      @Override
311      public Base setProperty(int hash, String name, Base value) throws FHIRException {
312        switch (hash) {
313        case 1757722118: // original_language
314          this.original_language = (CODE_PHRASE) value; // CODE_PHRASE
315          return value;
316        case -1352159805: // is_controlled
317          this.is_controlled = TypeConvertor.castToBoolean(value); // BooleanType
318          return value;
319        case -1225497630: // translations
320          this.getTranslationsList().add((TRANSLATION_DETAILS) value); // TRANSLATION_DETAILS
321          return value;
322        case -1724546052: // description
323          this.description = (RESOURCE_DESCRIPTION) value; // RESOURCE_DESCRIPTION
324          return value;
325        case -1037551568: // revision_history
326          this.revision_history = (REVISION_HISTORY) value; // REVISION_HISTORY
327          return value;
328        default: return super.setProperty(hash, name, value);
329        }
330
331      }
332
333      @Override
334      public Base setProperty(String name, Base value) throws FHIRException {
335        if (name.equals("original_language")) {
336          this.original_language = (CODE_PHRASE) value; // CODE_PHRASE
337        } else if (name.equals("is_controlled")) {
338          this.is_controlled = TypeConvertor.castToBoolean(value); // BooleanType
339        } else if (name.equals("translations")) {
340          this.getTranslationsList().add((TRANSLATION_DETAILS) value); // TRANSLATION_DETAILS
341        } else if (name.equals("description")) {
342          this.description = (RESOURCE_DESCRIPTION) value; // RESOURCE_DESCRIPTION
343        } else if (name.equals("revision_history")) {
344          this.revision_history = (REVISION_HISTORY) value; // REVISION_HISTORY
345        } else
346          return super.setProperty(name, value);
347        return value;
348      }
349
350      @Override
351      public Base makeProperty(int hash, String name) throws FHIRException {
352        switch (hash) {
353        case 1757722118:  return getOriginal_language();
354        case -1352159805:  return getIs_controlledElement();
355        case -1225497630:  return addTranslations(); 
356        case -1724546052:  return getDescription();
357        case -1037551568:  return getRevision_history();
358        default: return super.makeProperty(hash, name);
359        }
360
361      }
362
363      @Override
364      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
365        switch (hash) {
366        case 1757722118: /*original_language*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/CODE-PHRASE"};
367        case -1352159805: /*is_controlled*/ return new String[] {"boolean"};
368        case -1225497630: /*translations*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/TRANSLATION-DETAILS"};
369        case -1724546052: /*description*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/RESOURCE-DESCRIPTION"};
370        case -1037551568: /*revision_history*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/REVISION-HISTORY"};
371        default: return super.getTypesForProperty(hash, name);
372        }
373
374      }
375
376      @Override
377      public Base addChild(String name) throws FHIRException {
378        if (name.equals("original_language")) {
379          this.original_language = new CODE_PHRASE();
380          return this.original_language;
381        }
382        else if (name.equals("is_controlled")) {
383          throw new FHIRException("Cannot call addChild on a singleton property AUTHORED_RESOURCE.is_controlled");
384        }
385        else if (name.equals("translations")) {
386          return addTranslations();
387        }
388        else if (name.equals("description")) {
389          this.description = new RESOURCE_DESCRIPTION();
390          return this.description;
391        }
392        else if (name.equals("revision_history")) {
393          this.revision_history = new REVISION_HISTORY();
394          return this.revision_history;
395        }
396        else
397          return super.addChild(name);
398      }
399
400  public String fhirType() {
401    return "AUTHORED_RESOURCE";
402
403  }
404
405      public abstract AUTHORED_RESOURCE copy();
406
407      public void copyValues(AUTHORED_RESOURCE dst) {
408        super.copyValues(dst);
409        dst.original_language = original_language == null ? null : original_language.copy();
410        dst.is_controlled = is_controlled == null ? null : is_controlled.copy();
411        if (translationsList != null) {
412          dst.translationsList = new ArrayList<TRANSLATION_DETAILS>();
413          for (TRANSLATION_DETAILS i : translationsList)
414            dst.translationsList.add(i.copy());
415        };
416        dst.description = description == null ? null : description.copy();
417        dst.revision_history = revision_history == null ? null : revision_history.copy();
418      }
419
420      @Override
421      public boolean equalsDeep(Base other_) {
422        if (!super.equalsDeep(other_))
423          return false;
424        if (!(other_ instanceof AUTHORED_RESOURCE))
425          return false;
426        AUTHORED_RESOURCE o = (AUTHORED_RESOURCE) other_;
427        return compareDeep(original_language, o.original_language, true) && compareDeep(is_controlled, o.is_controlled, true)
428           && compareDeep(translationsList, o.translationsList, true) && compareDeep(description, o.description, true)
429           && compareDeep(revision_history, o.revision_history, true);
430      }
431
432      @Override
433      public boolean equalsShallow(Base other_) {
434        if (!super.equalsShallow(other_))
435          return false;
436        if (!(other_ instanceof AUTHORED_RESOURCE))
437          return false;
438        AUTHORED_RESOURCE o = (AUTHORED_RESOURCE) other_;
439        return compareValues(is_controlled, o.is_controlled, true);
440      }
441
442      public boolean isEmpty() {
443        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(original_language, is_controlled
444          , translationsList, description, revision_history);
445      }
446
447
448}
449