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 * Record an attestation of a party (the committer) to item(s) of record content. An attestation is an explicit signing by one healthcare agent of particular content for various particular purposes, including:
050
051* for authorisation of a controlled substance or procedure (e.g. sectioning of patient under mental health act);
052* witnessing of content by senior clinical professional;
053* indicating acknowledgement of content by intended recipient, e.g. GP who ordered a test result.
054 */
055@DatatypeDef(name="ATTESTATION")
056public class ATTESTATION extends AUDIT_DETAILS implements ICompositeType {
057
058    /**
059     * Optional visual representation of content attested e.g. screen image.
060     */
061    @Child(name = "attested_view", type = {DV_MULTIMEDIA.class}, order=0, min=0, max=1, modifier=false, summary=false)
062    @Description(shortDefinition="Optional visual representation of content attested e.g. screen image", formalDefinition="Optional visual representation of content attested e.g. screen image." )
063    protected DV_MULTIMEDIA attested_view;
064
065    /**
066     * Proof of attestation.
067     */
068    @Child(name = "proof", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=false)
069    @Description(shortDefinition="Proof of attestation", formalDefinition="Proof of attestation." )
070    protected StringType proof;
071
072    /**
073     * Items attested, expressed as fully qualified runtime paths to the items in question. Although not recommended, these may include fine-grained items which have been attested in some other system. Otherwise it is assumed to be for the entire VERSION with which it is associated.
074     */
075    @Child(name = "items", type = {DV_EHR_URI.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
076    @Description(shortDefinition="Items attested, expressed as fully qualified runtime paths to the items in question", formalDefinition="Items attested, expressed as fully qualified runtime paths to the items in question. Although not recommended, these may include fine-grained items which have been attested in some other system. Otherwise it is assumed to be for the entire VERSION with which it is associated." )
077    protected List<DV_EHR_URI> itemsList;
078
079    /**
080     * Reason of this attestation. Optionally coded by the openEHR Terminology group attestation reason ; includes values like authorisation , witness etc.
081     */
082    @Child(name = "reason", type = {DV_TEXT.class}, order=3, min=1, max=1, modifier=false, summary=false)
083    @Description(shortDefinition="Reason of this attestation", formalDefinition="Reason of this attestation. Optionally coded by the openEHR Terminology group attestation reason ; includes values like authorisation , witness etc." )
084    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="https://specifications.openehr.org/fhir/valueset-attestation_reason")
085    protected DV_TEXT reason;
086
087    /**
088     * True if this attestation is outstanding; False means it has been completed.
089     */
090    @Child(name = "is_pending", type = {BooleanType.class}, order=4, min=1, max=1, modifier=false, summary=false)
091    @Description(shortDefinition="True if this attestation is outstanding; False means it has been completed", formalDefinition="True if this attestation is outstanding; False means it has been completed." )
092    protected BooleanType is_pending;
093
094    private static final long serialVersionUID = 1016314460L;
095
096  /**
097   * Constructor
098   */
099    public ATTESTATION() {
100      super();
101    }
102
103  /**
104   * Constructor
105   */
106    public ATTESTATION(DV_TEXT reason, boolean is_pending) {
107      super();
108      this.setReason(reason);
109      this.setIs_pending(is_pending);
110    }
111
112    /**
113     * @return {@link #attested_view} (Optional visual representation of content attested e.g. screen image.)
114     */
115    public DV_MULTIMEDIA getAttested_view() { 
116      if (this.attested_view == null)
117        if (Configuration.errorOnAutoCreate())
118          throw new Error("Attempt to auto-create ATTESTATION.attested_view");
119        else if (Configuration.doAutoCreate())
120          this.attested_view = new DV_MULTIMEDIA(); // cc
121      return this.attested_view;
122    }
123
124    public boolean hasAttested_view() { 
125      return this.attested_view != null && !this.attested_view.isEmpty();
126    }
127
128    /**
129     * @param value {@link #attested_view} (Optional visual representation of content attested e.g. screen image.)
130     */
131    public ATTESTATION setAttested_view(DV_MULTIMEDIA value) { 
132      this.attested_view = value;
133      return this;
134    }
135
136    /**
137     * @return {@link #proof} (Proof of attestation.). This is the underlying object with id, value and extensions. The accessor "getProof" gives direct access to the value
138     */
139    public StringType getProofElement() { 
140      if (this.proof == null)
141        if (Configuration.errorOnAutoCreate())
142          throw new Error("Attempt to auto-create ATTESTATION.proof");
143        else if (Configuration.doAutoCreate())
144          this.proof = new StringType(); // bb
145      return this.proof;
146    }
147
148    public boolean hasProofElement() { 
149      return this.proof != null && !this.proof.isEmpty();
150    }
151
152    public boolean hasProof() { 
153      return this.proof != null && !this.proof.isEmpty();
154    }
155
156    /**
157     * @param value {@link #proof} (Proof of attestation.). This is the underlying object with id, value and extensions. The accessor "getProof" gives direct access to the value
158     */
159    public ATTESTATION setProofElement(StringType value) { 
160      this.proof = value;
161      return this;
162    }
163
164    /**
165     * @return Proof of attestation.
166     */
167    public String getProof() { 
168      return this.proof == null ? null : this.proof.getValue();
169    }
170
171    /**
172     * @param value Proof of attestation.
173     */
174    public ATTESTATION setProof(String value) { 
175      if (Utilities.noString(value))
176        this.proof = null;
177      else {
178        if (this.proof == null)
179          this.proof = new StringType();
180        this.proof.setValue(value);
181      }
182      return this;
183    }
184
185    /**
186     * @return {@link #items} (Items attested, expressed as fully qualified runtime paths to the items in question. Although not recommended, these may include fine-grained items which have been attested in some other system. Otherwise it is assumed to be for the entire VERSION with which it is associated.)
187     */
188    public List<DV_EHR_URI> getItemsList() { 
189      if (this.itemsList == null)
190        this.itemsList = new ArrayList<DV_EHR_URI>();
191      return this.itemsList;
192    }
193
194    /**
195     * @return Returns a reference to <code>this</code> for easy method chaining
196     */
197    public ATTESTATION setItemsList(List<DV_EHR_URI> theItems) { 
198      this.itemsList = theItems;
199      return this;
200    }
201
202    public boolean hasItems() { 
203      if (this.itemsList == null)
204        return false;
205      for (DV_EHR_URI item : this.itemsList)
206        if (!item.isEmpty())
207          return true;
208      return false;
209    }
210
211    public DV_EHR_URI addItems() { //3a
212      DV_EHR_URI t = new DV_EHR_URI();
213      if (this.itemsList == null)
214        this.itemsList = new ArrayList<DV_EHR_URI>();
215      this.itemsList.add(t);
216      return t;
217    }
218
219    public ATTESTATION addItems(DV_EHR_URI t) { //3b
220      if (t == null)
221        return this;
222      if (this.itemsList == null)
223        this.itemsList = new ArrayList<DV_EHR_URI>();
224      this.itemsList.add(t);
225      return this;
226    }
227
228    /**
229     * @return The first repetition of repeating field {@link #items}, creating it if it does not already exist {3}
230     */
231    public DV_EHR_URI getItemsFirstRep() { 
232      if (getItemsList().isEmpty()) {
233        addItems();
234      }
235      return getItemsList().get(0);
236    }
237
238    /**
239     * @return {@link #reason} (Reason of this attestation. Optionally coded by the openEHR Terminology group attestation reason ; includes values like authorisation , witness etc.)
240     */
241    public DV_TEXT getReason() { 
242      if (this.reason == null)
243        if (Configuration.errorOnAutoCreate())
244          throw new Error("Attempt to auto-create ATTESTATION.reason");
245        else if (Configuration.doAutoCreate())
246          this.reason = new DV_TEXT(); // cc
247      return this.reason;
248    }
249
250    public boolean hasReason() { 
251      return this.reason != null && !this.reason.isEmpty();
252    }
253
254    /**
255     * @param value {@link #reason} (Reason of this attestation. Optionally coded by the openEHR Terminology group attestation reason ; includes values like authorisation , witness etc.)
256     */
257    public ATTESTATION setReason(DV_TEXT value) { 
258      this.reason = value;
259      return this;
260    }
261
262    /**
263     * @return {@link #is_pending} (True if this attestation is outstanding; False means it has been completed.). This is the underlying object with id, value and extensions. The accessor "getIs_pending" gives direct access to the value
264     */
265    public BooleanType getIs_pendingElement() { 
266      if (this.is_pending == null)
267        if (Configuration.errorOnAutoCreate())
268          throw new Error("Attempt to auto-create ATTESTATION.is_pending");
269        else if (Configuration.doAutoCreate())
270          this.is_pending = new BooleanType(); // bb
271      return this.is_pending;
272    }
273
274    public boolean hasIs_pendingElement() { 
275      return this.is_pending != null && !this.is_pending.isEmpty();
276    }
277
278    public boolean hasIs_pending() { 
279      return this.is_pending != null && !this.is_pending.isEmpty();
280    }
281
282    /**
283     * @param value {@link #is_pending} (True if this attestation is outstanding; False means it has been completed.). This is the underlying object with id, value and extensions. The accessor "getIs_pending" gives direct access to the value
284     */
285    public ATTESTATION setIs_pendingElement(BooleanType value) { 
286      this.is_pending = value;
287      return this;
288    }
289
290    /**
291     * @return True if this attestation is outstanding; False means it has been completed.
292     */
293    public boolean getIs_pending() { 
294      return this.is_pending == null || this.is_pending.isEmpty() ? false : this.is_pending.getValue();
295    }
296
297    /**
298     * @param value True if this attestation is outstanding; False means it has been completed.
299     */
300    public ATTESTATION setIs_pending(boolean value) { 
301        if (this.is_pending == null)
302          this.is_pending = new BooleanType();
303        this.is_pending.setValue(value);
304      return this;
305    }
306
307      protected void listChildren(List<Property> children) {
308        super.listChildren(children);
309        children.add(new Property("attested_view", "http://openehr.org/fhir/StructureDefinition/DV-MULTIMEDIA", "Optional visual representation of content attested e.g. screen image.", 0, 1, attested_view));
310        children.add(new Property("proof", "string", "Proof of attestation.", 0, 1, proof));
311        children.add(new Property("items", "http://openehr.org/fhir/StructureDefinition/DV-EHR-URI", "Items attested, expressed as fully qualified runtime paths to the items in question. Although not recommended, these may include fine-grained items which have been attested in some other system. Otherwise it is assumed to be for the entire VERSION with which it is associated.", 0, java.lang.Integer.MAX_VALUE, itemsList));
312        children.add(new Property("reason", "http://openehr.org/fhir/StructureDefinition/DV-TEXT", "Reason of this attestation. Optionally coded by the openEHR Terminology group attestation reason ; includes values like authorisation , witness etc.", 0, 1, reason));
313        children.add(new Property("is_pending", "boolean", "True if this attestation is outstanding; False means it has been completed.", 0, 1, is_pending));
314      }
315
316      @Override
317      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
318        switch (_hash) {
319        case -261018784: /*attested_view*/  return new Property("attested_view", "http://openehr.org/fhir/StructureDefinition/DV-MULTIMEDIA", "Optional visual representation of content attested e.g. screen image.", 0, 1, attested_view);
320        case 106940740: /*proof*/  return new Property("proof", "string", "Proof of attestation.", 0, 1, proof);
321        case 100526016: /*items*/  return new Property("items", "http://openehr.org/fhir/StructureDefinition/DV-EHR-URI", "Items attested, expressed as fully qualified runtime paths to the items in question. Although not recommended, these may include fine-grained items which have been attested in some other system. Otherwise it is assumed to be for the entire VERSION with which it is associated.", 0, java.lang.Integer.MAX_VALUE, itemsList);
322        case -934964668: /*reason*/  return new Property("reason", "http://openehr.org/fhir/StructureDefinition/DV-TEXT", "Reason of this attestation. Optionally coded by the openEHR Terminology group attestation reason ; includes values like authorisation , witness etc.", 0, 1, reason);
323        case 817722242: /*is_pending*/  return new Property("is_pending", "boolean", "True if this attestation is outstanding; False means it has been completed.", 0, 1, is_pending);
324        default: return super.getNamedProperty(_hash, _name, _checkValid);
325        }
326
327      }
328
329      @Override
330      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
331        switch (hash) {
332        case -261018784: /*attested_view*/ return this.attested_view == null ? new Base[0] : new Base[] {this.attested_view}; // DV_MULTIMEDIA
333        case 106940740: /*proof*/ return this.proof == null ? new Base[0] : new Base[] {this.proof}; // StringType
334        case 100526016: /*items*/ return this.itemsList == null ? new Base[0] : this.itemsList.toArray(new Base[this.itemsList.size()]); // DV_EHR_URI
335        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : new Base[] {this.reason}; // DV_TEXT
336        case 817722242: /*is_pending*/ return this.is_pending == null ? new Base[0] : new Base[] {this.is_pending}; // BooleanType
337        default: return super.getProperty(hash, name, checkValid);
338        }
339
340      }
341
342      @Override
343      public Base setProperty(int hash, String name, Base value) throws FHIRException {
344        switch (hash) {
345        case -261018784: // attested_view
346          this.attested_view = (DV_MULTIMEDIA) value; // DV_MULTIMEDIA
347          return value;
348        case 106940740: // proof
349          this.proof = TypeConvertor.castToString(value); // StringType
350          return value;
351        case 100526016: // items
352          this.getItemsList().add((DV_EHR_URI) value); // DV_EHR_URI
353          return value;
354        case -934964668: // reason
355          this.reason = (DV_TEXT) value; // DV_TEXT
356          return value;
357        case 817722242: // is_pending
358          this.is_pending = TypeConvertor.castToBoolean(value); // BooleanType
359          return value;
360        default: return super.setProperty(hash, name, value);
361        }
362
363      }
364
365      @Override
366      public Base setProperty(String name, Base value) throws FHIRException {
367        if (name.equals("attested_view")) {
368          this.attested_view = (DV_MULTIMEDIA) value; // DV_MULTIMEDIA
369        } else if (name.equals("proof")) {
370          this.proof = TypeConvertor.castToString(value); // StringType
371        } else if (name.equals("items")) {
372          this.getItemsList().add((DV_EHR_URI) value); // DV_EHR_URI
373        } else if (name.equals("reason")) {
374          this.reason = (DV_TEXT) value; // DV_TEXT
375        } else if (name.equals("is_pending")) {
376          this.is_pending = TypeConvertor.castToBoolean(value); // BooleanType
377        } else
378          return super.setProperty(name, value);
379        return value;
380      }
381
382      @Override
383      public Base makeProperty(int hash, String name) throws FHIRException {
384        switch (hash) {
385        case -261018784:  return getAttested_view();
386        case 106940740:  return getProofElement();
387        case 100526016:  return addItems(); 
388        case -934964668:  return getReason();
389        case 817722242:  return getIs_pendingElement();
390        default: return super.makeProperty(hash, name);
391        }
392
393      }
394
395      @Override
396      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
397        switch (hash) {
398        case -261018784: /*attested_view*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-MULTIMEDIA"};
399        case 106940740: /*proof*/ return new String[] {"string"};
400        case 100526016: /*items*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-EHR-URI"};
401        case -934964668: /*reason*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-TEXT"};
402        case 817722242: /*is_pending*/ return new String[] {"boolean"};
403        default: return super.getTypesForProperty(hash, name);
404        }
405
406      }
407
408      @Override
409      public Base addChild(String name) throws FHIRException {
410        if (name.equals("attested_view")) {
411          this.attested_view = new DV_MULTIMEDIA();
412          return this.attested_view;
413        }
414        else if (name.equals("proof")) {
415          throw new FHIRException("Cannot call addChild on a singleton property ATTESTATION.proof");
416        }
417        else if (name.equals("items")) {
418          return addItems();
419        }
420        else if (name.equals("reason")) {
421          this.reason = new DV_TEXT();
422          return this.reason;
423        }
424        else if (name.equals("is_pending")) {
425          throw new FHIRException("Cannot call addChild on a singleton property ATTESTATION.is_pending");
426        }
427        else
428          return super.addChild(name);
429      }
430
431  public String fhirType() {
432    return "ATTESTATION";
433
434  }
435
436      public ATTESTATION copy() {
437        ATTESTATION dst = new ATTESTATION();
438        copyValues(dst);
439        return dst;
440      }
441
442      public void copyValues(ATTESTATION dst) {
443        super.copyValues(dst);
444        dst.attested_view = attested_view == null ? null : attested_view.copy();
445        dst.proof = proof == null ? null : proof.copy();
446        if (itemsList != null) {
447          dst.itemsList = new ArrayList<DV_EHR_URI>();
448          for (DV_EHR_URI i : itemsList)
449            dst.itemsList.add(i.copy());
450        };
451        dst.reason = reason == null ? null : reason.copy();
452        dst.is_pending = is_pending == null ? null : is_pending.copy();
453      }
454
455      protected ATTESTATION typedCopy() {
456        return copy();
457      }
458
459      @Override
460      public boolean equalsDeep(Base other_) {
461        if (!super.equalsDeep(other_))
462          return false;
463        if (!(other_ instanceof ATTESTATION))
464          return false;
465        ATTESTATION o = (ATTESTATION) other_;
466        return compareDeep(attested_view, o.attested_view, true) && compareDeep(proof, o.proof, true) && compareDeep(itemsList, o.itemsList, true)
467           && compareDeep(reason, o.reason, true) && compareDeep(is_pending, o.is_pending, true);
468      }
469
470      @Override
471      public boolean equalsShallow(Base other_) {
472        if (!super.equalsShallow(other_))
473          return false;
474        if (!(other_ instanceof ATTESTATION))
475          return false;
476        ATTESTATION o = (ATTESTATION) other_;
477        return compareValues(proof, o.proof, true) && compareValues(is_pending, o.is_pending, true);
478      }
479
480      public boolean isEmpty() {
481        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(attested_view, proof, itemsList
482          , reason, is_pending);
483      }
484
485
486}
487