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 * Generic description of a relationship between parties.
049 */
050@DatatypeDef(name="PARTY_RELATIONSHIP")
051public class PARTY_RELATIONSHIP extends LOCATABLE implements ICompositeType {
052
053    /**
054     * The detailed description of the relationship.
055     */
056    @Child(name = "details", type = {ITEM_STRUCTURE.class}, order=0, min=0, max=1, modifier=false, summary=false)
057    @Description(shortDefinition="The detailed description of the relationship", formalDefinition="The detailed description of the relationship." )
058    protected ITEM_STRUCTURE details;
059
060    /**
061     * Target of relationship.
062     */
063    @Child(name = "target", type = {PARTY_REF.class}, order=1, min=1, max=1, modifier=false, summary=false)
064    @Description(shortDefinition="Target of relationship", formalDefinition="Target of relationship." )
065    protected PARTY_REF target;
066
067    /**
068     * Valid time interval for this relationship.
069     */
070    @Child(name = "time_validity", type = {DV_INTERVAL.class}, order=2, min=0, max=1, modifier=false, summary=false)
071    @Description(shortDefinition="Valid time interval for this relationship", formalDefinition="Valid time interval for this relationship." )
072    protected DV_INTERVAL time_validity;
073
074    /**
075     * Source of relationship.
076     */
077    @Child(name = "source", type = {PARTY_REF.class}, order=3, min=1, max=1, modifier=false, summary=false)
078    @Description(shortDefinition="Source of relationship", formalDefinition="Source of relationship." )
079    protected PARTY_REF source;
080
081    private static final long serialVersionUID = -1906999521L;
082
083  /**
084   * Constructor
085   */
086    public PARTY_RELATIONSHIP() {
087      super();
088    }
089
090  /**
091   * Constructor
092   */
093    public PARTY_RELATIONSHIP(PARTY_REF target, PARTY_REF source) {
094      super();
095      this.setTarget(target);
096      this.setSource(source);
097    }
098
099    /**
100     * @return {@link #details} (The detailed description of the relationship.)
101     */
102    public ITEM_STRUCTURE getDetails() { 
103      return this.details;
104    }
105
106    public boolean hasDetails() { 
107      return this.details != null && !this.details.isEmpty();
108    }
109
110    /**
111     * @param value {@link #details} (The detailed description of the relationship.)
112     */
113    public PARTY_RELATIONSHIP setDetails(ITEM_STRUCTURE value) { 
114      this.details = value;
115      return this;
116    }
117
118    /**
119     * @return {@link #target} (Target of relationship.)
120     */
121    public PARTY_REF getTarget() { 
122      if (this.target == null)
123        if (Configuration.errorOnAutoCreate())
124          throw new Error("Attempt to auto-create PARTY_RELATIONSHIP.target");
125        else if (Configuration.doAutoCreate())
126          this.target = new PARTY_REF(); // cc
127      return this.target;
128    }
129
130    public boolean hasTarget() { 
131      return this.target != null && !this.target.isEmpty();
132    }
133
134    /**
135     * @param value {@link #target} (Target of relationship.)
136     */
137    public PARTY_RELATIONSHIP setTarget(PARTY_REF value) { 
138      this.target = value;
139      return this;
140    }
141
142    /**
143     * @return {@link #time_validity} (Valid time interval for this relationship.)
144     */
145    public DV_INTERVAL getTime_validity() { 
146      if (this.time_validity == null)
147        if (Configuration.errorOnAutoCreate())
148          throw new Error("Attempt to auto-create PARTY_RELATIONSHIP.time_validity");
149        else if (Configuration.doAutoCreate())
150          this.time_validity = new DV_INTERVAL(); // cc
151      return this.time_validity;
152    }
153
154    public boolean hasTime_validity() { 
155      return this.time_validity != null && !this.time_validity.isEmpty();
156    }
157
158    /**
159     * @param value {@link #time_validity} (Valid time interval for this relationship.)
160     */
161    public PARTY_RELATIONSHIP setTime_validity(DV_INTERVAL value) { 
162      this.time_validity = value;
163      return this;
164    }
165
166    /**
167     * @return {@link #source} (Source of relationship.)
168     */
169    public PARTY_REF getSource() { 
170      if (this.source == null)
171        if (Configuration.errorOnAutoCreate())
172          throw new Error("Attempt to auto-create PARTY_RELATIONSHIP.source");
173        else if (Configuration.doAutoCreate())
174          this.source = new PARTY_REF(); // cc
175      return this.source;
176    }
177
178    public boolean hasSource() { 
179      return this.source != null && !this.source.isEmpty();
180    }
181
182    /**
183     * @param value {@link #source} (Source of relationship.)
184     */
185    public PARTY_RELATIONSHIP setSource(PARTY_REF value) { 
186      this.source = value;
187      return this;
188    }
189
190      protected void listChildren(List<Property> children) {
191        super.listChildren(children);
192        children.add(new Property("details", "http://openehr.org/fhir/StructureDefinition/ITEM-STRUCTURE", "The detailed description of the relationship.", 0, 1, details));
193        children.add(new Property("target", "http://openehr.org/fhir/StructureDefinition/PARTY-REF", "Target of relationship.", 0, 1, target));
194        children.add(new Property("time_validity", "http://openehr.org/fhir/StructureDefinition/DV-INTERVAL", "Valid time interval for this relationship.", 0, 1, time_validity));
195        children.add(new Property("source", "http://openehr.org/fhir/StructureDefinition/PARTY-REF", "Source of relationship.", 0, 1, source));
196      }
197
198      @Override
199      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
200        switch (_hash) {
201        case 1557721666: /*details*/  return new Property("details", "http://openehr.org/fhir/StructureDefinition/ITEM-STRUCTURE", "The detailed description of the relationship.", 0, 1, details);
202        case -880905839: /*target*/  return new Property("target", "http://openehr.org/fhir/StructureDefinition/PARTY-REF", "Target of relationship.", 0, 1, target);
203        case -1304171420: /*time_validity*/  return new Property("time_validity", "http://openehr.org/fhir/StructureDefinition/DV-INTERVAL", "Valid time interval for this relationship.", 0, 1, time_validity);
204        case -896505829: /*source*/  return new Property("source", "http://openehr.org/fhir/StructureDefinition/PARTY-REF", "Source of relationship.", 0, 1, source);
205        default: return super.getNamedProperty(_hash, _name, _checkValid);
206        }
207
208      }
209
210      @Override
211      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
212        switch (hash) {
213        case 1557721666: /*details*/ return this.details == null ? new Base[0] : new Base[] {this.details}; // ITEM_STRUCTURE
214        case -880905839: /*target*/ return this.target == null ? new Base[0] : new Base[] {this.target}; // PARTY_REF
215        case -1304171420: /*time_validity*/ return this.time_validity == null ? new Base[0] : new Base[] {this.time_validity}; // DV_INTERVAL
216        case -896505829: /*source*/ return this.source == null ? new Base[0] : new Base[] {this.source}; // PARTY_REF
217        default: return super.getProperty(hash, name, checkValid);
218        }
219
220      }
221
222      @Override
223      public Base setProperty(int hash, String name, Base value) throws FHIRException {
224        switch (hash) {
225        case 1557721666: // details
226          this.details = (ITEM_STRUCTURE) value; // ITEM_STRUCTURE
227          return value;
228        case -880905839: // target
229          this.target = (PARTY_REF) value; // PARTY_REF
230          return value;
231        case -1304171420: // time_validity
232          this.time_validity = (DV_INTERVAL) value; // DV_INTERVAL
233          return value;
234        case -896505829: // source
235          this.source = (PARTY_REF) value; // PARTY_REF
236          return value;
237        default: return super.setProperty(hash, name, value);
238        }
239
240      }
241
242      @Override
243      public Base setProperty(String name, Base value) throws FHIRException {
244        if (name.equals("details")) {
245          this.details = (ITEM_STRUCTURE) value; // ITEM_STRUCTURE
246        } else if (name.equals("target")) {
247          this.target = (PARTY_REF) value; // PARTY_REF
248        } else if (name.equals("time_validity")) {
249          this.time_validity = (DV_INTERVAL) value; // DV_INTERVAL
250        } else if (name.equals("source")) {
251          this.source = (PARTY_REF) value; // PARTY_REF
252        } else
253          return super.setProperty(name, value);
254        return value;
255      }
256
257      @Override
258      public Base makeProperty(int hash, String name) throws FHIRException {
259        switch (hash) {
260        case 1557721666: /*div*/
261          throw new Error("Unable to make an instance of the abstract property 'details'");
262        case -880905839:  return getTarget();
263        case -1304171420:  return getTime_validity();
264        case -896505829:  return getSource();
265        default: return super.makeProperty(hash, name);
266        }
267
268      }
269
270      @Override
271      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
272        switch (hash) {
273        case 1557721666: /*details*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/ITEM-STRUCTURE"};
274        case -880905839: /*target*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/PARTY-REF"};
275        case -1304171420: /*time_validity*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-INTERVAL"};
276        case -896505829: /*source*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/PARTY-REF"};
277        default: return super.getTypesForProperty(hash, name);
278        }
279
280      }
281
282      @Override
283      public Base addChild(String name) throws FHIRException {
284        if (name.equals("details")) {
285          throw new FHIRException("Cannot call addChild on an abstract type PARTY_RELATIONSHIP.details");
286        }
287        else if (name.equals("target")) {
288          this.target = new PARTY_REF();
289          return this.target;
290        }
291        else if (name.equals("time_validity")) {
292          this.time_validity = new DV_INTERVAL();
293          return this.time_validity;
294        }
295        else if (name.equals("source")) {
296          this.source = new PARTY_REF();
297          return this.source;
298        }
299        else
300          return super.addChild(name);
301      }
302
303  public String fhirType() {
304    return "PARTY_RELATIONSHIP";
305
306  }
307
308      public PARTY_RELATIONSHIP copy() {
309        PARTY_RELATIONSHIP dst = new PARTY_RELATIONSHIP();
310        copyValues(dst);
311        return dst;
312      }
313
314      public void copyValues(PARTY_RELATIONSHIP dst) {
315        super.copyValues(dst);
316        dst.details = details == null ? null : details.copy();
317        dst.target = target == null ? null : target.copy();
318        dst.time_validity = time_validity == null ? null : time_validity.copy();
319        dst.source = source == null ? null : source.copy();
320      }
321
322      protected PARTY_RELATIONSHIP typedCopy() {
323        return copy();
324      }
325
326      @Override
327      public boolean equalsDeep(Base other_) {
328        if (!super.equalsDeep(other_))
329          return false;
330        if (!(other_ instanceof PARTY_RELATIONSHIP))
331          return false;
332        PARTY_RELATIONSHIP o = (PARTY_RELATIONSHIP) other_;
333        return compareDeep(details, o.details, true) && compareDeep(target, o.target, true) && compareDeep(time_validity, o.time_validity, true)
334           && compareDeep(source, o.source, true);
335      }
336
337      @Override
338      public boolean equalsShallow(Base other_) {
339        if (!super.equalsShallow(other_))
340          return false;
341        if (!(other_ instanceof PARTY_RELATIONSHIP))
342          return false;
343        PARTY_RELATIONSHIP o = (PARTY_RELATIONSHIP) other_;
344        return true;
345      }
346
347      public boolean isEmpty() {
348        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(details, target, time_validity
349          , source);
350      }
351
352
353}
354