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 * Proxy type for identifying a party and its relationship to the subject of the record. Use where the relationship between the party and the subject of the record must be known.
049 */
050@DatatypeDef(name="PARTY_RELATED")
051public class PARTY_RELATED extends PARTY_IDENTIFIED implements ICompositeType {
052
053    /**
054     * Relationship of subject of this ENTRY to the subject of the record. May be coded. If it is the patient, coded as self.
055     */
056    @Child(name = "relationship", type = {DV_CODED_TEXT.class}, order=0, min=1, max=1, modifier=false, summary=false)
057    @Description(shortDefinition="Relationship of subject of this ENTRY to the subject of the record. May be coded", formalDefinition="Relationship of subject of this ENTRY to the subject of the record. May be coded. If it is the patient, coded as self." )
058    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="https://specifications.openehr.org/fhir/valueset-subject_relationship")
059    protected DV_CODED_TEXT relationship;
060
061    private static final long serialVersionUID = -391010544L;
062
063  /**
064   * Constructor
065   */
066    public PARTY_RELATED() {
067      super();
068    }
069
070  /**
071   * Constructor
072   */
073    public PARTY_RELATED(DV_CODED_TEXT relationship) {
074      super();
075      this.setRelationship(relationship);
076    }
077
078    /**
079     * @return {@link #relationship} (Relationship of subject of this ENTRY to the subject of the record. May be coded. If it is the patient, coded as self.)
080     */
081    public DV_CODED_TEXT getRelationship() { 
082      if (this.relationship == null)
083        if (Configuration.errorOnAutoCreate())
084          throw new Error("Attempt to auto-create PARTY_RELATED.relationship");
085        else if (Configuration.doAutoCreate())
086          this.relationship = new DV_CODED_TEXT(); // cc
087      return this.relationship;
088    }
089
090    public boolean hasRelationship() { 
091      return this.relationship != null && !this.relationship.isEmpty();
092    }
093
094    /**
095     * @param value {@link #relationship} (Relationship of subject of this ENTRY to the subject of the record. May be coded. If it is the patient, coded as self.)
096     */
097    public PARTY_RELATED setRelationship(DV_CODED_TEXT value) { 
098      this.relationship = value;
099      return this;
100    }
101
102      protected void listChildren(List<Property> children) {
103        super.listChildren(children);
104        children.add(new Property("relationship", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "Relationship of subject of this ENTRY to the subject of the record. May be coded. If it is the patient, coded as self.", 0, 1, relationship));
105      }
106
107      @Override
108      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
109        switch (_hash) {
110        case -261851592: /*relationship*/  return new Property("relationship", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "Relationship of subject of this ENTRY to the subject of the record. May be coded. If it is the patient, coded as self.", 0, 1, relationship);
111        default: return super.getNamedProperty(_hash, _name, _checkValid);
112        }
113
114      }
115
116      @Override
117      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
118        switch (hash) {
119        case -261851592: /*relationship*/ return this.relationship == null ? new Base[0] : new Base[] {this.relationship}; // DV_CODED_TEXT
120        default: return super.getProperty(hash, name, checkValid);
121        }
122
123      }
124
125      @Override
126      public Base setProperty(int hash, String name, Base value) throws FHIRException {
127        switch (hash) {
128        case -261851592: // relationship
129          this.relationship = (DV_CODED_TEXT) value; // DV_CODED_TEXT
130          return value;
131        default: return super.setProperty(hash, name, value);
132        }
133
134      }
135
136      @Override
137      public Base setProperty(String name, Base value) throws FHIRException {
138        if (name.equals("relationship")) {
139          this.relationship = (DV_CODED_TEXT) value; // DV_CODED_TEXT
140        } else
141          return super.setProperty(name, value);
142        return value;
143      }
144
145      @Override
146      public Base makeProperty(int hash, String name) throws FHIRException {
147        switch (hash) {
148        case -261851592:  return getRelationship();
149        default: return super.makeProperty(hash, name);
150        }
151
152      }
153
154      @Override
155      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
156        switch (hash) {
157        case -261851592: /*relationship*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT"};
158        default: return super.getTypesForProperty(hash, name);
159        }
160
161      }
162
163      @Override
164      public Base addChild(String name) throws FHIRException {
165        if (name.equals("relationship")) {
166          this.relationship = new DV_CODED_TEXT();
167          return this.relationship;
168        }
169        else
170          return super.addChild(name);
171      }
172
173  public String fhirType() {
174    return "PARTY_RELATED";
175
176  }
177
178      public PARTY_RELATED copy() {
179        PARTY_RELATED dst = new PARTY_RELATED();
180        copyValues(dst);
181        return dst;
182      }
183
184      public void copyValues(PARTY_RELATED dst) {
185        super.copyValues(dst);
186        dst.relationship = relationship == null ? null : relationship.copy();
187      }
188
189      protected PARTY_RELATED typedCopy() {
190        return copy();
191      }
192
193      @Override
194      public boolean equalsDeep(Base other_) {
195        if (!super.equalsDeep(other_))
196          return false;
197        if (!(other_ instanceof PARTY_RELATED))
198          return false;
199        PARTY_RELATED o = (PARTY_RELATED) other_;
200        return compareDeep(relationship, o.relationship, true);
201      }
202
203      @Override
204      public boolean equalsShallow(Base other_) {
205        if (!super.equalsShallow(other_))
206          return false;
207        if (!(other_ instanceof PARTY_RELATED))
208          return false;
209        PARTY_RELATED o = (PARTY_RELATED) other_;
210        return true;
211      }
212
213      public boolean isEmpty() {
214        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(relationship);
215      }
216
217
218}
219