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 * Ancestor of all Party types, including real world entities and their roles. A Party is any entity which can participate in an activity. The name attribute inherited from LOCATABLE is used to indicate the actual type of party (note that the actual names, i.e. identities of parties are indicated in the identities attribute, not the name attribute).
049 */
050@DatatypeDef(name="PARTY")
051public abstract class PARTY extends LOCATABLE implements ICompositeType {
052
053    /**
054     * Identities used by the party to identify itself, such as legal name, stage names, aliases, nicknames and so on.
055     */
056    @Child(name = "identities", type = {PARTY_IDENTITY.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
057    @Description(shortDefinition="Identities used by the party to identify itself, such as legal name, stage names, aliases, nicknames and so on", formalDefinition="Identities used by the party to identify itself, such as legal name, stage names, aliases, nicknames and so on." )
058    protected List<PARTY_IDENTITY> identitiesList;
059
060    /**
061     * Contacts for this party.
062     */
063    @Child(name = "contacts", type = {CONTACT.class}, order=1, min=0, max=1, modifier=false, summary=false)
064    @Description(shortDefinition="Contacts for this party", formalDefinition="Contacts for this party." )
065    protected CONTACT contacts;
066
067    /**
068     * All other details for this Party.
069     */
070    @Child(name = "details", type = {ITEM_STRUCTURE.class}, order=2, min=0, max=1, modifier=false, summary=false)
071    @Description(shortDefinition="All other details for this Party", formalDefinition="All other details for this Party." )
072    protected ITEM_STRUCTURE details;
073
074    /**
075     * References to relationships in which this Party takes part as target.
076     */
077    @Child(name = "reverse_relationships", type = {LOCATABLE_REF.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
078    @Description(shortDefinition="References to relationships in which this Party takes part as target", formalDefinition="References to relationships in which this Party takes part as target." )
079    protected List<LOCATABLE_REF> reverse_relationshipsList;
080
081    /**
082     * Relationships in which this Party takes part as source.
083     */
084    @Child(name = "relationships", type = {PARTY_RELATIONSHIP.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
085    @Description(shortDefinition="Relationships in which this Party takes part as source", formalDefinition="Relationships in which this Party takes part as source." )
086    protected List<PARTY_RELATIONSHIP> relationshipsList;
087
088    private static final long serialVersionUID = 1369417704L;
089
090  /**
091   * Constructor
092   */
093    public PARTY() {
094      super();
095    }
096
097    /**
098     * @return {@link #identities} (Identities used by the party to identify itself, such as legal name, stage names, aliases, nicknames and so on.)
099     */
100    public List<PARTY_IDENTITY> getIdentitiesList() { 
101      if (this.identitiesList == null)
102        this.identitiesList = new ArrayList<PARTY_IDENTITY>();
103      return this.identitiesList;
104    }
105
106    /**
107     * @return Returns a reference to <code>this</code> for easy method chaining
108     */
109    public PARTY setIdentitiesList(List<PARTY_IDENTITY> theIdentities) { 
110      this.identitiesList = theIdentities;
111      return this;
112    }
113
114    public boolean hasIdentities() { 
115      if (this.identitiesList == null)
116        return false;
117      for (PARTY_IDENTITY item : this.identitiesList)
118        if (!item.isEmpty())
119          return true;
120      return false;
121    }
122
123    public PARTY_IDENTITY addIdentities() { //3a
124      PARTY_IDENTITY t = new PARTY_IDENTITY();
125      if (this.identitiesList == null)
126        this.identitiesList = new ArrayList<PARTY_IDENTITY>();
127      this.identitiesList.add(t);
128      return t;
129    }
130
131    public PARTY addIdentities(PARTY_IDENTITY t) { //3b
132      if (t == null)
133        return this;
134      if (this.identitiesList == null)
135        this.identitiesList = new ArrayList<PARTY_IDENTITY>();
136      this.identitiesList.add(t);
137      return this;
138    }
139
140    /**
141     * @return The first repetition of repeating field {@link #identities}, creating it if it does not already exist {3}
142     */
143    public PARTY_IDENTITY getIdentitiesFirstRep() { 
144      if (getIdentitiesList().isEmpty()) {
145        addIdentities();
146      }
147      return getIdentitiesList().get(0);
148    }
149
150    /**
151     * @return {@link #contacts} (Contacts for this party.)
152     */
153    public CONTACT getContacts() { 
154      if (this.contacts == null)
155        if (Configuration.errorOnAutoCreate())
156          throw new Error("Attempt to auto-create PARTY.contacts");
157        else if (Configuration.doAutoCreate())
158          this.contacts = new CONTACT(); // cc
159      return this.contacts;
160    }
161
162    public boolean hasContacts() { 
163      return this.contacts != null && !this.contacts.isEmpty();
164    }
165
166    /**
167     * @param value {@link #contacts} (Contacts for this party.)
168     */
169    public PARTY setContacts(CONTACT value) { 
170      this.contacts = value;
171      return this;
172    }
173
174    /**
175     * @return {@link #details} (All other details for this Party.)
176     */
177    public ITEM_STRUCTURE getDetails() { 
178      return this.details;
179    }
180
181    public boolean hasDetails() { 
182      return this.details != null && !this.details.isEmpty();
183    }
184
185    /**
186     * @param value {@link #details} (All other details for this Party.)
187     */
188    public PARTY setDetails(ITEM_STRUCTURE value) { 
189      this.details = value;
190      return this;
191    }
192
193    /**
194     * @return {@link #reverse_relationships} (References to relationships in which this Party takes part as target.)
195     */
196    public List<LOCATABLE_REF> getReverse_relationshipsList() { 
197      if (this.reverse_relationshipsList == null)
198        this.reverse_relationshipsList = new ArrayList<LOCATABLE_REF>();
199      return this.reverse_relationshipsList;
200    }
201
202    /**
203     * @return Returns a reference to <code>this</code> for easy method chaining
204     */
205    public PARTY setReverse_relationshipsList(List<LOCATABLE_REF> theReverse_relationships) { 
206      this.reverse_relationshipsList = theReverse_relationships;
207      return this;
208    }
209
210    public boolean hasReverse_relationships() { 
211      if (this.reverse_relationshipsList == null)
212        return false;
213      for (LOCATABLE_REF item : this.reverse_relationshipsList)
214        if (!item.isEmpty())
215          return true;
216      return false;
217    }
218
219    public LOCATABLE_REF addReverse_relationships() { //3a
220      LOCATABLE_REF t = new LOCATABLE_REF();
221      if (this.reverse_relationshipsList == null)
222        this.reverse_relationshipsList = new ArrayList<LOCATABLE_REF>();
223      this.reverse_relationshipsList.add(t);
224      return t;
225    }
226
227    public PARTY addReverse_relationships(LOCATABLE_REF t) { //3b
228      if (t == null)
229        return this;
230      if (this.reverse_relationshipsList == null)
231        this.reverse_relationshipsList = new ArrayList<LOCATABLE_REF>();
232      this.reverse_relationshipsList.add(t);
233      return this;
234    }
235
236    /**
237     * @return The first repetition of repeating field {@link #reverse_relationships}, creating it if it does not already exist {3}
238     */
239    public LOCATABLE_REF getReverse_relationshipsFirstRep() { 
240      if (getReverse_relationshipsList().isEmpty()) {
241        addReverse_relationships();
242      }
243      return getReverse_relationshipsList().get(0);
244    }
245
246    /**
247     * @return {@link #relationships} (Relationships in which this Party takes part as source.)
248     */
249    public List<PARTY_RELATIONSHIP> getRelationshipsList() { 
250      if (this.relationshipsList == null)
251        this.relationshipsList = new ArrayList<PARTY_RELATIONSHIP>();
252      return this.relationshipsList;
253    }
254
255    /**
256     * @return Returns a reference to <code>this</code> for easy method chaining
257     */
258    public PARTY setRelationshipsList(List<PARTY_RELATIONSHIP> theRelationships) { 
259      this.relationshipsList = theRelationships;
260      return this;
261    }
262
263    public boolean hasRelationships() { 
264      if (this.relationshipsList == null)
265        return false;
266      for (PARTY_RELATIONSHIP item : this.relationshipsList)
267        if (!item.isEmpty())
268          return true;
269      return false;
270    }
271
272    public PARTY_RELATIONSHIP addRelationships() { //3a
273      PARTY_RELATIONSHIP t = new PARTY_RELATIONSHIP();
274      if (this.relationshipsList == null)
275        this.relationshipsList = new ArrayList<PARTY_RELATIONSHIP>();
276      this.relationshipsList.add(t);
277      return t;
278    }
279
280    public PARTY addRelationships(PARTY_RELATIONSHIP t) { //3b
281      if (t == null)
282        return this;
283      if (this.relationshipsList == null)
284        this.relationshipsList = new ArrayList<PARTY_RELATIONSHIP>();
285      this.relationshipsList.add(t);
286      return this;
287    }
288
289    /**
290     * @return The first repetition of repeating field {@link #relationships}, creating it if it does not already exist {3}
291     */
292    public PARTY_RELATIONSHIP getRelationshipsFirstRep() { 
293      if (getRelationshipsList().isEmpty()) {
294        addRelationships();
295      }
296      return getRelationshipsList().get(0);
297    }
298
299      protected void listChildren(List<Property> children) {
300        super.listChildren(children);
301        children.add(new Property("identities", "http://openehr.org/fhir/StructureDefinition/PARTY-IDENTITY", "Identities used by the party to identify itself, such as legal name, stage names, aliases, nicknames and so on.", 0, java.lang.Integer.MAX_VALUE, identitiesList));
302        children.add(new Property("contacts", "http://openehr.org/fhir/StructureDefinition/CONTACT", "Contacts for this party.", 0, 1, contacts));
303        children.add(new Property("details", "http://openehr.org/fhir/StructureDefinition/ITEM-STRUCTURE", "All other details for this Party.", 0, 1, details));
304        children.add(new Property("reverse_relationships", "http://openehr.org/fhir/StructureDefinition/LOCATABLE-REF", "References to relationships in which this Party takes part as target.", 0, java.lang.Integer.MAX_VALUE, reverse_relationshipsList));
305        children.add(new Property("relationships", "http://openehr.org/fhir/StructureDefinition/PARTY-RELATIONSHIP", "Relationships in which this Party takes part as source.", 0, java.lang.Integer.MAX_VALUE, relationshipsList));
306      }
307
308      @Override
309      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
310        switch (_hash) {
311        case -1618015780: /*identities*/  return new Property("identities", "http://openehr.org/fhir/StructureDefinition/PARTY-IDENTITY", "Identities used by the party to identify itself, such as legal name, stage names, aliases, nicknames and so on.", 0, java.lang.Integer.MAX_VALUE, identitiesList);
312        case -567451565: /*contacts*/  return new Property("contacts", "http://openehr.org/fhir/StructureDefinition/CONTACT", "Contacts for this party.", 0, 1, contacts);
313        case 1557721666: /*details*/  return new Property("details", "http://openehr.org/fhir/StructureDefinition/ITEM-STRUCTURE", "All other details for this Party.", 0, 1, details);
314        case -96288098: /*reverse_relationships*/  return new Property("reverse_relationships", "http://openehr.org/fhir/StructureDefinition/LOCATABLE-REF", "References to relationships in which this Party takes part as target.", 0, java.lang.Integer.MAX_VALUE, reverse_relationshipsList);
315        case 472535355: /*relationships*/  return new Property("relationships", "http://openehr.org/fhir/StructureDefinition/PARTY-RELATIONSHIP", "Relationships in which this Party takes part as source.", 0, java.lang.Integer.MAX_VALUE, relationshipsList);
316        default: return super.getNamedProperty(_hash, _name, _checkValid);
317        }
318
319      }
320
321      @Override
322      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
323        switch (hash) {
324        case -1618015780: /*identities*/ return this.identitiesList == null ? new Base[0] : this.identitiesList.toArray(new Base[this.identitiesList.size()]); // PARTY_IDENTITY
325        case -567451565: /*contacts*/ return this.contacts == null ? new Base[0] : new Base[] {this.contacts}; // CONTACT
326        case 1557721666: /*details*/ return this.details == null ? new Base[0] : new Base[] {this.details}; // ITEM_STRUCTURE
327        case -96288098: /*reverse_relationships*/ return this.reverse_relationshipsList == null ? new Base[0] : this.reverse_relationshipsList.toArray(new Base[this.reverse_relationshipsList.size()]); // LOCATABLE_REF
328        case 472535355: /*relationships*/ return this.relationshipsList == null ? new Base[0] : this.relationshipsList.toArray(new Base[this.relationshipsList.size()]); // PARTY_RELATIONSHIP
329        default: return super.getProperty(hash, name, checkValid);
330        }
331
332      }
333
334      @Override
335      public Base setProperty(int hash, String name, Base value) throws FHIRException {
336        switch (hash) {
337        case -1618015780: // identities
338          this.getIdentitiesList().add((PARTY_IDENTITY) value); // PARTY_IDENTITY
339          return value;
340        case -567451565: // contacts
341          this.contacts = (CONTACT) value; // CONTACT
342          return value;
343        case 1557721666: // details
344          this.details = (ITEM_STRUCTURE) value; // ITEM_STRUCTURE
345          return value;
346        case -96288098: // reverse_relationships
347          this.getReverse_relationshipsList().add((LOCATABLE_REF) value); // LOCATABLE_REF
348          return value;
349        case 472535355: // relationships
350          this.getRelationshipsList().add((PARTY_RELATIONSHIP) value); // PARTY_RELATIONSHIP
351          return value;
352        default: return super.setProperty(hash, name, value);
353        }
354
355      }
356
357      @Override
358      public Base setProperty(String name, Base value) throws FHIRException {
359        if (name.equals("identities")) {
360          this.getIdentitiesList().add((PARTY_IDENTITY) value); // PARTY_IDENTITY
361        } else if (name.equals("contacts")) {
362          this.contacts = (CONTACT) value; // CONTACT
363        } else if (name.equals("details")) {
364          this.details = (ITEM_STRUCTURE) value; // ITEM_STRUCTURE
365        } else if (name.equals("reverse_relationships")) {
366          this.getReverse_relationshipsList().add((LOCATABLE_REF) value); // LOCATABLE_REF
367        } else if (name.equals("relationships")) {
368          this.getRelationshipsList().add((PARTY_RELATIONSHIP) value); // PARTY_RELATIONSHIP
369        } else
370          return super.setProperty(name, value);
371        return value;
372      }
373
374      @Override
375      public Base makeProperty(int hash, String name) throws FHIRException {
376        switch (hash) {
377        case -1618015780:  return addIdentities(); 
378        case -567451565:  return getContacts();
379        case 1557721666: /*div*/
380          throw new Error("Unable to make an instance of the abstract property 'details'");
381        case -96288098:  return addReverse_relationships(); 
382        case 472535355:  return addRelationships(); 
383        default: return super.makeProperty(hash, name);
384        }
385
386      }
387
388      @Override
389      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
390        switch (hash) {
391        case -1618015780: /*identities*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/PARTY-IDENTITY"};
392        case -567451565: /*contacts*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/CONTACT"};
393        case 1557721666: /*details*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/ITEM-STRUCTURE"};
394        case -96288098: /*reverse_relationships*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/LOCATABLE-REF"};
395        case 472535355: /*relationships*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/PARTY-RELATIONSHIP"};
396        default: return super.getTypesForProperty(hash, name);
397        }
398
399      }
400
401      @Override
402      public Base addChild(String name) throws FHIRException {
403        if (name.equals("identities")) {
404          return addIdentities();
405        }
406        else if (name.equals("contacts")) {
407          this.contacts = new CONTACT();
408          return this.contacts;
409        }
410        else if (name.equals("details")) {
411          throw new FHIRException("Cannot call addChild on an abstract type PARTY.details");
412        }
413        else if (name.equals("reverse_relationships")) {
414          return addReverse_relationships();
415        }
416        else if (name.equals("relationships")) {
417          return addRelationships();
418        }
419        else
420          return super.addChild(name);
421      }
422
423  public String fhirType() {
424    return "PARTY";
425
426  }
427
428      public abstract PARTY copy();
429
430      public void copyValues(PARTY dst) {
431        super.copyValues(dst);
432        if (identitiesList != null) {
433          dst.identitiesList = new ArrayList<PARTY_IDENTITY>();
434          for (PARTY_IDENTITY i : identitiesList)
435            dst.identitiesList.add(i.copy());
436        };
437        dst.contacts = contacts == null ? null : contacts.copy();
438        dst.details = details == null ? null : details.copy();
439        if (reverse_relationshipsList != null) {
440          dst.reverse_relationshipsList = new ArrayList<LOCATABLE_REF>();
441          for (LOCATABLE_REF i : reverse_relationshipsList)
442            dst.reverse_relationshipsList.add(i.copy());
443        };
444        if (relationshipsList != null) {
445          dst.relationshipsList = new ArrayList<PARTY_RELATIONSHIP>();
446          for (PARTY_RELATIONSHIP i : relationshipsList)
447            dst.relationshipsList.add(i.copy());
448        };
449      }
450
451      @Override
452      public boolean equalsDeep(Base other_) {
453        if (!super.equalsDeep(other_))
454          return false;
455        if (!(other_ instanceof PARTY))
456          return false;
457        PARTY o = (PARTY) other_;
458        return compareDeep(identitiesList, o.identitiesList, true) && compareDeep(contacts, o.contacts, true)
459           && compareDeep(details, o.details, true) && compareDeep(reverse_relationshipsList, o.reverse_relationshipsList, true)
460           && compareDeep(relationshipsList, o.relationshipsList, true);
461      }
462
463      @Override
464      public boolean equalsShallow(Base other_) {
465        if (!super.equalsShallow(other_))
466          return false;
467        if (!(other_ instanceof PARTY))
468          return false;
469        PARTY o = (PARTY) other_;
470        return true;
471      }
472
473      public boolean isEmpty() {
474        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identitiesList, contacts, details
475          , reverse_relationshipsList, relationshipsList);
476      }
477
478
479}
480