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 * The set of attributes required to document the committal of an information item to a repository.
050 */
051@DatatypeDef(name="AUDIT_DETAILS")
052public class AUDIT_DETAILS extends LogicalBase implements ICompositeType {
053
054    /**
055     * Identifier of the logical EHR system where the change was committed. This is almost always owned by the organisation legally responsible for the EHR, and is distinct from any application, or any hosting infrastructure.
056     */
057    @Child(name = "system_id", type = {StringType.class}, order=0, min=1, max=1, modifier=false, summary=false)
058    @Description(shortDefinition="Identifier of the logical EHR system where the change was committed", formalDefinition="Identifier of the logical EHR system where the change was committed. This is almost always owned by the organisation legally responsible for the EHR, and is distinct from any application, or any hosting infrastructure." )
059    protected StringType system_id;
060
061    /**
062     * Time of committal of the item.
063     */
064    @Child(name = "time_committed", type = {DV_DATE_TIME.class}, order=1, min=1, max=1, modifier=false, summary=false)
065    @Description(shortDefinition="Time of committal of the item", formalDefinition="Time of committal of the item." )
066    protected DV_DATE_TIME time_committed;
067
068    /**
069     * Type of change. Coded using the openEHR Terminology audit change type group.
070     */
071    @Child(name = "change_type", type = {DV_CODED_TEXT.class}, order=2, min=1, max=1, modifier=false, summary=false)
072    @Description(shortDefinition="Type of change", formalDefinition="Type of change. Coded using the openEHR Terminology audit change type group." )
073    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="https://specifications.openehr.org/fhir/valueset-audit_change_type")
074    protected DV_CODED_TEXT change_type;
075
076    /**
077     * Reason for committal. This may be used to qualify the value in the change_type field. For example, if the change affects only the EHR directory, this field might be used to indicate 'Folder `episode 2018-02-16` added' or similar.
078     */
079    @Child(name = "description", type = {DV_TEXT.class}, order=3, min=0, max=1, modifier=false, summary=false)
080    @Description(shortDefinition="Reason for committal. This may be used to qualify the value in the change_type field", formalDefinition="Reason for committal. This may be used to qualify the value in the change_type field. For example, if the change affects only the EHR directory, this field might be used to indicate 'Folder `episode 2018-02-16` added' or similar." )
081    protected DV_TEXT description;
082
083    /**
084     * Identity and optional reference into identity management service, of user who committed the item.
085     */
086    @Child(name = "committer", type = {PARTY_PROXY.class}, order=4, min=1, max=1, modifier=false, summary=false)
087    @Description(shortDefinition="Identity and optional reference into identity management service, of user who committed the item", formalDefinition="Identity and optional reference into identity management service, of user who committed the item." )
088    protected PARTY_PROXY committer;
089
090    private static final long serialVersionUID = -1398858817L;
091
092  /**
093   * Constructor
094   */
095    public AUDIT_DETAILS() {
096      super();
097    }
098
099  /**
100   * Constructor
101   */
102    public AUDIT_DETAILS(String system_id, DV_DATE_TIME time_committed, DV_CODED_TEXT change_type, PARTY_PROXY committer) {
103      super();
104      this.setSystem_id(system_id);
105      this.setTime_committed(time_committed);
106      this.setChange_type(change_type);
107      this.setCommitter(committer);
108    }
109
110    /**
111     * @return {@link #system_id} (Identifier of the logical EHR system where the change was committed. This is almost always owned by the organisation legally responsible for the EHR, and is distinct from any application, or any hosting infrastructure.). This is the underlying object with id, value and extensions. The accessor "getSystem_id" gives direct access to the value
112     */
113    public StringType getSystem_idElement() { 
114      if (this.system_id == null)
115        if (Configuration.errorOnAutoCreate())
116          throw new Error("Attempt to auto-create AUDIT_DETAILS.system_id");
117        else if (Configuration.doAutoCreate())
118          this.system_id = new StringType(); // bb
119      return this.system_id;
120    }
121
122    public boolean hasSystem_idElement() { 
123      return this.system_id != null && !this.system_id.isEmpty();
124    }
125
126    public boolean hasSystem_id() { 
127      return this.system_id != null && !this.system_id.isEmpty();
128    }
129
130    /**
131     * @param value {@link #system_id} (Identifier of the logical EHR system where the change was committed. This is almost always owned by the organisation legally responsible for the EHR, and is distinct from any application, or any hosting infrastructure.). This is the underlying object with id, value and extensions. The accessor "getSystem_id" gives direct access to the value
132     */
133    public AUDIT_DETAILS setSystem_idElement(StringType value) { 
134      this.system_id = value;
135      return this;
136    }
137
138    /**
139     * @return Identifier of the logical EHR system where the change was committed. This is almost always owned by the organisation legally responsible for the EHR, and is distinct from any application, or any hosting infrastructure.
140     */
141    public String getSystem_id() { 
142      return this.system_id == null ? null : this.system_id.getValue();
143    }
144
145    /**
146     * @param value Identifier of the logical EHR system where the change was committed. This is almost always owned by the organisation legally responsible for the EHR, and is distinct from any application, or any hosting infrastructure.
147     */
148    public AUDIT_DETAILS setSystem_id(String value) { 
149        if (this.system_id == null)
150          this.system_id = new StringType();
151        this.system_id.setValue(value);
152      return this;
153    }
154
155    /**
156     * @return {@link #time_committed} (Time of committal of the item.)
157     */
158    public DV_DATE_TIME getTime_committed() { 
159      if (this.time_committed == null)
160        if (Configuration.errorOnAutoCreate())
161          throw new Error("Attempt to auto-create AUDIT_DETAILS.time_committed");
162        else if (Configuration.doAutoCreate())
163          this.time_committed = new DV_DATE_TIME(); // cc
164      return this.time_committed;
165    }
166
167    public boolean hasTime_committed() { 
168      return this.time_committed != null && !this.time_committed.isEmpty();
169    }
170
171    /**
172     * @param value {@link #time_committed} (Time of committal of the item.)
173     */
174    public AUDIT_DETAILS setTime_committed(DV_DATE_TIME value) { 
175      this.time_committed = value;
176      return this;
177    }
178
179    /**
180     * @return {@link #change_type} (Type of change. Coded using the openEHR Terminology audit change type group.)
181     */
182    public DV_CODED_TEXT getChange_type() { 
183      if (this.change_type == null)
184        if (Configuration.errorOnAutoCreate())
185          throw new Error("Attempt to auto-create AUDIT_DETAILS.change_type");
186        else if (Configuration.doAutoCreate())
187          this.change_type = new DV_CODED_TEXT(); // cc
188      return this.change_type;
189    }
190
191    public boolean hasChange_type() { 
192      return this.change_type != null && !this.change_type.isEmpty();
193    }
194
195    /**
196     * @param value {@link #change_type} (Type of change. Coded using the openEHR Terminology audit change type group.)
197     */
198    public AUDIT_DETAILS setChange_type(DV_CODED_TEXT value) { 
199      this.change_type = value;
200      return this;
201    }
202
203    /**
204     * @return {@link #description} (Reason for committal. This may be used to qualify the value in the change_type field. For example, if the change affects only the EHR directory, this field might be used to indicate 'Folder `episode 2018-02-16` added' or similar.)
205     */
206    public DV_TEXT getDescription() { 
207      if (this.description == null)
208        if (Configuration.errorOnAutoCreate())
209          throw new Error("Attempt to auto-create AUDIT_DETAILS.description");
210        else if (Configuration.doAutoCreate())
211          this.description = new DV_TEXT(); // cc
212      return this.description;
213    }
214
215    public boolean hasDescription() { 
216      return this.description != null && !this.description.isEmpty();
217    }
218
219    /**
220     * @param value {@link #description} (Reason for committal. This may be used to qualify the value in the change_type field. For example, if the change affects only the EHR directory, this field might be used to indicate 'Folder `episode 2018-02-16` added' or similar.)
221     */
222    public AUDIT_DETAILS setDescription(DV_TEXT value) { 
223      this.description = value;
224      return this;
225    }
226
227    /**
228     * @return {@link #committer} (Identity and optional reference into identity management service, of user who committed the item.)
229     */
230    public PARTY_PROXY getCommitter() { 
231      return this.committer;
232    }
233
234    public boolean hasCommitter() { 
235      return this.committer != null && !this.committer.isEmpty();
236    }
237
238    /**
239     * @param value {@link #committer} (Identity and optional reference into identity management service, of user who committed the item.)
240     */
241    public AUDIT_DETAILS setCommitter(PARTY_PROXY value) { 
242      this.committer = value;
243      return this;
244    }
245
246      protected void listChildren(List<Property> children) {
247        super.listChildren(children);
248        children.add(new Property("system_id", "string", "Identifier of the logical EHR system where the change was committed. This is almost always owned by the organisation legally responsible for the EHR, and is distinct from any application, or any hosting infrastructure.", 0, 1, system_id));
249        children.add(new Property("time_committed", "http://openehr.org/fhir/StructureDefinition/DV-DATE-TIME", "Time of committal of the item.", 0, 1, time_committed));
250        children.add(new Property("change_type", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "Type of change. Coded using the openEHR Terminology audit change type group.", 0, 1, change_type));
251        children.add(new Property("description", "http://openehr.org/fhir/StructureDefinition/DV-TEXT", "Reason for committal. This may be used to qualify the value in the change_type field. For example, if the change affects only the EHR directory, this field might be used to indicate 'Folder `episode 2018-02-16` added' or similar.", 0, 1, description));
252        children.add(new Property("committer", "http://openehr.org/fhir/StructureDefinition/PARTY-PROXY", "Identity and optional reference into identity management service, of user who committed the item.", 0, 1, committer));
253      }
254
255      @Override
256      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
257        switch (_hash) {
258        case 1129127211: /*system_id*/  return new Property("system_id", "string", "Identifier of the logical EHR system where the change was committed. This is almost always owned by the organisation legally responsible for the EHR, and is distinct from any application, or any hosting infrastructure.", 0, 1, system_id);
259        case 2138761354: /*time_committed*/  return new Property("time_committed", "http://openehr.org/fhir/StructureDefinition/DV-DATE-TIME", "Time of committal of the item.", 0, 1, time_committed);
260        case -1654455703: /*change_type*/  return new Property("change_type", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "Type of change. Coded using the openEHR Terminology audit change type group.", 0, 1, change_type);
261        case -1724546052: /*description*/  return new Property("description", "http://openehr.org/fhir/StructureDefinition/DV-TEXT", "Reason for committal. This may be used to qualify the value in the change_type field. For example, if the change affects only the EHR directory, this field might be used to indicate 'Folder `episode 2018-02-16` added' or similar.", 0, 1, description);
262        case -1491142774: /*committer*/  return new Property("committer", "http://openehr.org/fhir/StructureDefinition/PARTY-PROXY", "Identity and optional reference into identity management service, of user who committed the item.", 0, 1, committer);
263        default: return super.getNamedProperty(_hash, _name, _checkValid);
264        }
265
266      }
267
268      @Override
269      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
270        switch (hash) {
271        case 1129127211: /*system_id*/ return this.system_id == null ? new Base[0] : new Base[] {this.system_id}; // StringType
272        case 2138761354: /*time_committed*/ return this.time_committed == null ? new Base[0] : new Base[] {this.time_committed}; // DV_DATE_TIME
273        case -1654455703: /*change_type*/ return this.change_type == null ? new Base[0] : new Base[] {this.change_type}; // DV_CODED_TEXT
274        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // DV_TEXT
275        case -1491142774: /*committer*/ return this.committer == null ? new Base[0] : new Base[] {this.committer}; // PARTY_PROXY
276        default: return super.getProperty(hash, name, checkValid);
277        }
278
279      }
280
281      @Override
282      public Base setProperty(int hash, String name, Base value) throws FHIRException {
283        switch (hash) {
284        case 1129127211: // system_id
285          this.system_id = TypeConvertor.castToString(value); // StringType
286          return value;
287        case 2138761354: // time_committed
288          this.time_committed = (DV_DATE_TIME) value; // DV_DATE_TIME
289          return value;
290        case -1654455703: // change_type
291          this.change_type = (DV_CODED_TEXT) value; // DV_CODED_TEXT
292          return value;
293        case -1724546052: // description
294          this.description = (DV_TEXT) value; // DV_TEXT
295          return value;
296        case -1491142774: // committer
297          this.committer = (PARTY_PROXY) value; // PARTY_PROXY
298          return value;
299        default: return super.setProperty(hash, name, value);
300        }
301
302      }
303
304      @Override
305      public Base setProperty(String name, Base value) throws FHIRException {
306        if (name.equals("system_id")) {
307          this.system_id = TypeConvertor.castToString(value); // StringType
308        } else if (name.equals("time_committed")) {
309          this.time_committed = (DV_DATE_TIME) value; // DV_DATE_TIME
310        } else if (name.equals("change_type")) {
311          this.change_type = (DV_CODED_TEXT) value; // DV_CODED_TEXT
312        } else if (name.equals("description")) {
313          this.description = (DV_TEXT) value; // DV_TEXT
314        } else if (name.equals("committer")) {
315          this.committer = (PARTY_PROXY) value; // PARTY_PROXY
316        } else
317          return super.setProperty(name, value);
318        return value;
319      }
320
321      @Override
322      public Base makeProperty(int hash, String name) throws FHIRException {
323        switch (hash) {
324        case 1129127211:  return getSystem_idElement();
325        case 2138761354:  return getTime_committed();
326        case -1654455703:  return getChange_type();
327        case -1724546052:  return getDescription();
328        case -1491142774: /*div*/
329          throw new Error("Unable to make an instance of the abstract property 'committer'");
330        default: return super.makeProperty(hash, name);
331        }
332
333      }
334
335      @Override
336      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
337        switch (hash) {
338        case 1129127211: /*system_id*/ return new String[] {"string"};
339        case 2138761354: /*time_committed*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-DATE-TIME"};
340        case -1654455703: /*change_type*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT"};
341        case -1724546052: /*description*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-TEXT"};
342        case -1491142774: /*committer*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/PARTY-PROXY"};
343        default: return super.getTypesForProperty(hash, name);
344        }
345
346      }
347
348      @Override
349      public Base addChild(String name) throws FHIRException {
350        if (name.equals("system_id")) {
351          throw new FHIRException("Cannot call addChild on a singleton property AUDIT_DETAILS.system_id");
352        }
353        else if (name.equals("time_committed")) {
354          this.time_committed = new DV_DATE_TIME();
355          return this.time_committed;
356        }
357        else if (name.equals("change_type")) {
358          this.change_type = new DV_CODED_TEXT();
359          return this.change_type;
360        }
361        else if (name.equals("description")) {
362          this.description = new DV_TEXT();
363          return this.description;
364        }
365        else if (name.equals("committer")) {
366          throw new FHIRException("Cannot call addChild on an abstract type AUDIT_DETAILS.committer");
367        }
368        else
369          return super.addChild(name);
370      }
371
372  public String fhirType() {
373    return "AUDIT_DETAILS";
374
375  }
376
377      public AUDIT_DETAILS copy() {
378        AUDIT_DETAILS dst = new AUDIT_DETAILS();
379        copyValues(dst);
380        return dst;
381      }
382
383      public void copyValues(AUDIT_DETAILS dst) {
384        super.copyValues(dst);
385        dst.system_id = system_id == null ? null : system_id.copy();
386        dst.time_committed = time_committed == null ? null : time_committed.copy();
387        dst.change_type = change_type == null ? null : change_type.copy();
388        dst.description = description == null ? null : description.copy();
389        dst.committer = committer == null ? null : committer.copy();
390      }
391
392      protected AUDIT_DETAILS typedCopy() {
393        return copy();
394      }
395
396      @Override
397      public boolean equalsDeep(Base other_) {
398        if (!super.equalsDeep(other_))
399          return false;
400        if (!(other_ instanceof AUDIT_DETAILS))
401          return false;
402        AUDIT_DETAILS o = (AUDIT_DETAILS) other_;
403        return compareDeep(system_id, o.system_id, true) && compareDeep(time_committed, o.time_committed, true)
404           && compareDeep(change_type, o.change_type, true) && compareDeep(description, o.description, true)
405           && compareDeep(committer, o.committer, true);
406      }
407
408      @Override
409      public boolean equalsShallow(Base other_) {
410        if (!super.equalsShallow(other_))
411          return false;
412        if (!(other_ instanceof AUDIT_DETAILS))
413          return false;
414        AUDIT_DETAILS o = (AUDIT_DETAILS) other_;
415        return compareValues(system_id, o.system_id, true);
416      }
417
418      public boolean isEmpty() {
419        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(system_id, time_committed
420          , change_type, description, committer);
421      }
422
423
424}
425