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 * Single object per EHR containing various EHR-wide status flags and settings, including whether this EHR can be queried, modified etc. This object is always modifiable, in order to change the status of the EHR as a whole.
049 */
050@DatatypeDef(name="EHR_STATUS")
051public class EHR_STATUS extends LOCATABLE implements ICompositeType {
052
053    /**
054     * The subject of this EHR. The external_ref attribute can be used to contain a direct reference to the subject in a demographic or identity service. Alternatively, the association between patients and their records may be done elsewhere for security reasons.
055     */
056    @Child(name = "subject", type = {PARTY_SELF.class}, order=0, min=1, max=1, modifier=false, summary=false)
057    @Description(shortDefinition="The subject of this EHR. The external_ref attribute can be used to contain a direct reference to the subject in a demographic or identity service. Alternatively, the association between patients and their records may be done elsewhere for security reasons", formalDefinition="The subject of this EHR. The external_ref attribute can be used to contain a direct reference to the subject in a demographic or identity service. Alternatively, the association between patients and their records may be done elsewhere for security reasons." )
058    protected PARTY_SELF subject;
059
060    /**
061     * True if this EHR should be included in population queries, i.e. if this EHR is considered active in the population.
062     */
063    @Child(name = "is_queryable", type = {BooleanType.class}, order=1, min=1, max=1, modifier=false, summary=false)
064    @Description(shortDefinition="True if this EHR should be included in population queries, i.e. if this EHR is considered active in the population", formalDefinition="True if this EHR should be included in population queries, i.e. if this EHR is considered active in the population." )
065    protected BooleanType is_queryable;
066
067    /**
068     * True if the EHR, other than the EHR_STATUS object, is allowed to be written to. The EHR_STATUS object itself can always be written to.
069     */
070    @Child(name = "is_modifiable", type = {BooleanType.class}, order=2, min=1, max=1, modifier=false, summary=false)
071    @Description(shortDefinition="True if the EHR, other than the EHR_STATUS object, is allowed to be written to. The EHR_STATUS object itself can always be written to", formalDefinition="True if the EHR, other than the EHR_STATUS object, is allowed to be written to. The EHR_STATUS object itself can always be written to." )
072    protected BooleanType is_modifiable;
073
074    /**
075     * Any other details of the EHR summary object, in the form of an archetyped ITEM_STRUCTURE.
076     */
077    @Child(name = "other_details", type = {ITEM_STRUCTURE.class}, order=3, min=0, max=1, modifier=false, summary=false)
078    @Description(shortDefinition="Any other details of the EHR summary object, in the form of an archetyped ITEM_STRUCTURE", formalDefinition="Any other details of the EHR summary object, in the form of an archetyped ITEM_STRUCTURE." )
079    protected ITEM_STRUCTURE other_details;
080
081    private static final long serialVersionUID = -1523453193L;
082
083  /**
084   * Constructor
085   */
086    public EHR_STATUS() {
087      super();
088    }
089
090  /**
091   * Constructor
092   */
093    public EHR_STATUS(PARTY_SELF subject, boolean is_queryable, boolean is_modifiable) {
094      super();
095      this.setSubject(subject);
096      this.setIs_queryable(is_queryable);
097      this.setIs_modifiable(is_modifiable);
098    }
099
100    /**
101     * @return {@link #subject} (The subject of this EHR. The external_ref attribute can be used to contain a direct reference to the subject in a demographic or identity service. Alternatively, the association between patients and their records may be done elsewhere for security reasons.)
102     */
103    public PARTY_SELF getSubject() { 
104      if (this.subject == null)
105        if (Configuration.errorOnAutoCreate())
106          throw new Error("Attempt to auto-create EHR_STATUS.subject");
107        else if (Configuration.doAutoCreate())
108          this.subject = new PARTY_SELF(); // cc
109      return this.subject;
110    }
111
112    public boolean hasSubject() { 
113      return this.subject != null && !this.subject.isEmpty();
114    }
115
116    /**
117     * @param value {@link #subject} (The subject of this EHR. The external_ref attribute can be used to contain a direct reference to the subject in a demographic or identity service. Alternatively, the association between patients and their records may be done elsewhere for security reasons.)
118     */
119    public EHR_STATUS setSubject(PARTY_SELF value) { 
120      this.subject = value;
121      return this;
122    }
123
124    /**
125     * @return {@link #is_queryable} (True if this EHR should be included in population queries, i.e. if this EHR is considered active in the population.). This is the underlying object with id, value and extensions. The accessor "getIs_queryable" gives direct access to the value
126     */
127    public BooleanType getIs_queryableElement() { 
128      if (this.is_queryable == null)
129        if (Configuration.errorOnAutoCreate())
130          throw new Error("Attempt to auto-create EHR_STATUS.is_queryable");
131        else if (Configuration.doAutoCreate())
132          this.is_queryable = new BooleanType(); // bb
133      return this.is_queryable;
134    }
135
136    public boolean hasIs_queryableElement() { 
137      return this.is_queryable != null && !this.is_queryable.isEmpty();
138    }
139
140    public boolean hasIs_queryable() { 
141      return this.is_queryable != null && !this.is_queryable.isEmpty();
142    }
143
144    /**
145     * @param value {@link #is_queryable} (True if this EHR should be included in population queries, i.e. if this EHR is considered active in the population.). This is the underlying object with id, value and extensions. The accessor "getIs_queryable" gives direct access to the value
146     */
147    public EHR_STATUS setIs_queryableElement(BooleanType value) { 
148      this.is_queryable = value;
149      return this;
150    }
151
152    /**
153     * @return True if this EHR should be included in population queries, i.e. if this EHR is considered active in the population.
154     */
155    public boolean getIs_queryable() { 
156      return this.is_queryable == null || this.is_queryable.isEmpty() ? false : this.is_queryable.getValue();
157    }
158
159    /**
160     * @param value True if this EHR should be included in population queries, i.e. if this EHR is considered active in the population.
161     */
162    public EHR_STATUS setIs_queryable(boolean value) { 
163        if (this.is_queryable == null)
164          this.is_queryable = new BooleanType();
165        this.is_queryable.setValue(value);
166      return this;
167    }
168
169    /**
170     * @return {@link #is_modifiable} (True if the EHR, other than the EHR_STATUS object, is allowed to be written to. The EHR_STATUS object itself can always be written to.). This is the underlying object with id, value and extensions. The accessor "getIs_modifiable" gives direct access to the value
171     */
172    public BooleanType getIs_modifiableElement() { 
173      if (this.is_modifiable == null)
174        if (Configuration.errorOnAutoCreate())
175          throw new Error("Attempt to auto-create EHR_STATUS.is_modifiable");
176        else if (Configuration.doAutoCreate())
177          this.is_modifiable = new BooleanType(); // bb
178      return this.is_modifiable;
179    }
180
181    public boolean hasIs_modifiableElement() { 
182      return this.is_modifiable != null && !this.is_modifiable.isEmpty();
183    }
184
185    public boolean hasIs_modifiable() { 
186      return this.is_modifiable != null && !this.is_modifiable.isEmpty();
187    }
188
189    /**
190     * @param value {@link #is_modifiable} (True if the EHR, other than the EHR_STATUS object, is allowed to be written to. The EHR_STATUS object itself can always be written to.). This is the underlying object with id, value and extensions. The accessor "getIs_modifiable" gives direct access to the value
191     */
192    public EHR_STATUS setIs_modifiableElement(BooleanType value) { 
193      this.is_modifiable = value;
194      return this;
195    }
196
197    /**
198     * @return True if the EHR, other than the EHR_STATUS object, is allowed to be written to. The EHR_STATUS object itself can always be written to.
199     */
200    public boolean getIs_modifiable() { 
201      return this.is_modifiable == null || this.is_modifiable.isEmpty() ? false : this.is_modifiable.getValue();
202    }
203
204    /**
205     * @param value True if the EHR, other than the EHR_STATUS object, is allowed to be written to. The EHR_STATUS object itself can always be written to.
206     */
207    public EHR_STATUS setIs_modifiable(boolean value) { 
208        if (this.is_modifiable == null)
209          this.is_modifiable = new BooleanType();
210        this.is_modifiable.setValue(value);
211      return this;
212    }
213
214    /**
215     * @return {@link #other_details} (Any other details of the EHR summary object, in the form of an archetyped ITEM_STRUCTURE.)
216     */
217    public ITEM_STRUCTURE getOther_details() { 
218      return this.other_details;
219    }
220
221    public boolean hasOther_details() { 
222      return this.other_details != null && !this.other_details.isEmpty();
223    }
224
225    /**
226     * @param value {@link #other_details} (Any other details of the EHR summary object, in the form of an archetyped ITEM_STRUCTURE.)
227     */
228    public EHR_STATUS setOther_details(ITEM_STRUCTURE value) { 
229      this.other_details = value;
230      return this;
231    }
232
233      protected void listChildren(List<Property> children) {
234        super.listChildren(children);
235        children.add(new Property("subject", "http://openehr.org/fhir/StructureDefinition/PARTY-SELF", "The subject of this EHR. The external_ref attribute can be used to contain a direct reference to the subject in a demographic or identity service. Alternatively, the association between patients and their records may be done elsewhere for security reasons.", 0, 1, subject));
236        children.add(new Property("is_queryable", "boolean", "True if this EHR should be included in population queries, i.e. if this EHR is considered active in the population.", 0, 1, is_queryable));
237        children.add(new Property("is_modifiable", "boolean", "True if the EHR, other than the EHR_STATUS object, is allowed to be written to. The EHR_STATUS object itself can always be written to.", 0, 1, is_modifiable));
238        children.add(new Property("other_details", "http://openehr.org/fhir/StructureDefinition/ITEM-STRUCTURE", "Any other details of the EHR summary object, in the form of an archetyped ITEM_STRUCTURE.", 0, 1, other_details));
239      }
240
241      @Override
242      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
243        switch (_hash) {
244        case -1867885268: /*subject*/  return new Property("subject", "http://openehr.org/fhir/StructureDefinition/PARTY-SELF", "The subject of this EHR. The external_ref attribute can be used to contain a direct reference to the subject in a demographic or identity service. Alternatively, the association between patients and their records may be done elsewhere for security reasons.", 0, 1, subject);
245        case 1177363789: /*is_queryable*/  return new Property("is_queryable", "boolean", "True if this EHR should be included in population queries, i.e. if this EHR is considered active in the population.", 0, 1, is_queryable);
246        case -792595655: /*is_modifiable*/  return new Property("is_modifiable", "boolean", "True if the EHR, other than the EHR_STATUS object, is allowed to be written to. The EHR_STATUS object itself can always be written to.", 0, 1, is_modifiable);
247        case -1257043949: /*other_details*/  return new Property("other_details", "http://openehr.org/fhir/StructureDefinition/ITEM-STRUCTURE", "Any other details of the EHR summary object, in the form of an archetyped ITEM_STRUCTURE.", 0, 1, other_details);
248        default: return super.getNamedProperty(_hash, _name, _checkValid);
249        }
250
251      }
252
253      @Override
254      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
255        switch (hash) {
256        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // PARTY_SELF
257        case 1177363789: /*is_queryable*/ return this.is_queryable == null ? new Base[0] : new Base[] {this.is_queryable}; // BooleanType
258        case -792595655: /*is_modifiable*/ return this.is_modifiable == null ? new Base[0] : new Base[] {this.is_modifiable}; // BooleanType
259        case -1257043949: /*other_details*/ return this.other_details == null ? new Base[0] : new Base[] {this.other_details}; // ITEM_STRUCTURE
260        default: return super.getProperty(hash, name, checkValid);
261        }
262
263      }
264
265      @Override
266      public Base setProperty(int hash, String name, Base value) throws FHIRException {
267        switch (hash) {
268        case -1867885268: // subject
269          this.subject = (PARTY_SELF) value; // PARTY_SELF
270          return value;
271        case 1177363789: // is_queryable
272          this.is_queryable = TypeConvertor.castToBoolean(value); // BooleanType
273          return value;
274        case -792595655: // is_modifiable
275          this.is_modifiable = TypeConvertor.castToBoolean(value); // BooleanType
276          return value;
277        case -1257043949: // other_details
278          this.other_details = (ITEM_STRUCTURE) value; // ITEM_STRUCTURE
279          return value;
280        default: return super.setProperty(hash, name, value);
281        }
282
283      }
284
285      @Override
286      public Base setProperty(String name, Base value) throws FHIRException {
287        if (name.equals("subject")) {
288          this.subject = (PARTY_SELF) value; // PARTY_SELF
289        } else if (name.equals("is_queryable")) {
290          this.is_queryable = TypeConvertor.castToBoolean(value); // BooleanType
291        } else if (name.equals("is_modifiable")) {
292          this.is_modifiable = TypeConvertor.castToBoolean(value); // BooleanType
293        } else if (name.equals("other_details")) {
294          this.other_details = (ITEM_STRUCTURE) value; // ITEM_STRUCTURE
295        } else
296          return super.setProperty(name, value);
297        return value;
298      }
299
300      @Override
301      public Base makeProperty(int hash, String name) throws FHIRException {
302        switch (hash) {
303        case -1867885268:  return getSubject();
304        case 1177363789:  return getIs_queryableElement();
305        case -792595655:  return getIs_modifiableElement();
306        case -1257043949: /*div*/
307          throw new Error("Unable to make an instance of the abstract property 'other_details'");
308        default: return super.makeProperty(hash, name);
309        }
310
311      }
312
313      @Override
314      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
315        switch (hash) {
316        case -1867885268: /*subject*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/PARTY-SELF"};
317        case 1177363789: /*is_queryable*/ return new String[] {"boolean"};
318        case -792595655: /*is_modifiable*/ return new String[] {"boolean"};
319        case -1257043949: /*other_details*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/ITEM-STRUCTURE"};
320        default: return super.getTypesForProperty(hash, name);
321        }
322
323      }
324
325      @Override
326      public Base addChild(String name) throws FHIRException {
327        if (name.equals("subject")) {
328          this.subject = new PARTY_SELF();
329          return this.subject;
330        }
331        else if (name.equals("is_queryable")) {
332          throw new FHIRException("Cannot call addChild on a singleton property EHR_STATUS.is_queryable");
333        }
334        else if (name.equals("is_modifiable")) {
335          throw new FHIRException("Cannot call addChild on a singleton property EHR_STATUS.is_modifiable");
336        }
337        else if (name.equals("other_details")) {
338          throw new FHIRException("Cannot call addChild on an abstract type EHR_STATUS.other_details");
339        }
340        else
341          return super.addChild(name);
342      }
343
344  public String fhirType() {
345    return "EHR_STATUS";
346
347  }
348
349      public EHR_STATUS copy() {
350        EHR_STATUS dst = new EHR_STATUS();
351        copyValues(dst);
352        return dst;
353      }
354
355      public void copyValues(EHR_STATUS dst) {
356        super.copyValues(dst);
357        dst.subject = subject == null ? null : subject.copy();
358        dst.is_queryable = is_queryable == null ? null : is_queryable.copy();
359        dst.is_modifiable = is_modifiable == null ? null : is_modifiable.copy();
360        dst.other_details = other_details == null ? null : other_details.copy();
361      }
362
363      protected EHR_STATUS typedCopy() {
364        return copy();
365      }
366
367      @Override
368      public boolean equalsDeep(Base other_) {
369        if (!super.equalsDeep(other_))
370          return false;
371        if (!(other_ instanceof EHR_STATUS))
372          return false;
373        EHR_STATUS o = (EHR_STATUS) other_;
374        return compareDeep(subject, o.subject, true) && compareDeep(is_queryable, o.is_queryable, true)
375           && compareDeep(is_modifiable, o.is_modifiable, true) && compareDeep(other_details, o.other_details, true)
376          ;
377      }
378
379      @Override
380      public boolean equalsShallow(Base other_) {
381        if (!super.equalsShallow(other_))
382          return false;
383        if (!(other_ instanceof EHR_STATUS))
384          return false;
385        EHR_STATUS o = (EHR_STATUS) other_;
386        return compareValues(is_queryable, o.is_queryable, true) && compareValues(is_modifiable, o.is_modifiable, true)
387          ;
388      }
389
390      public boolean isEmpty() {
391        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(subject, is_queryable, is_modifiable
392          , other_details);
393      }
394
395
396}
397