
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 role performed by an Actor. The role corresponds to a competency of the Party. Roles are used to define the responsibilities undertaken by a Party for a purpose. Roles should have credentials qualifying the performer to perform the role. 049 */ 050@DatatypeDef(name="ROLE") 051public class ROLE extends PARTY implements ICompositeType { 052 053 /** 054 * Identities used by the ROLE to identify itself, such as legal name, stage names, aliases, nicknames and so on. 055 */ 056 @Child(name = "time_validity", type = {DV_INTERVAL.class}, order=0, min=0, max=1, modifier=false, summary=false) 057 @Description(shortDefinition="Identities used by the ROLE to identify itself, such as legal name, stage names, aliases, nicknames and so on", formalDefinition="Identities used by the ROLE to identify itself, such as legal name, stage names, aliases, nicknames and so on." ) 058 protected DV_INTERVAL time_validity; 059 060 /** 061 * Contacts for this ROLE. 062 */ 063 @Child(name = "performer", type = {PARTY_REF.class}, order=1, min=1, max=1, modifier=false, summary=false) 064 @Description(shortDefinition="Contacts for this ROLE", formalDefinition="Contacts for this ROLE." ) 065 protected PARTY_REF performer; 066 067 /** 068 * All other details for this ROLE. 069 */ 070 @Child(name = "capabilities", type = {CAPABILITY.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 071 @Description(shortDefinition="All other details for this ROLE", formalDefinition="All other details for this ROLE." ) 072 protected List<CAPABILITY> capabilitiesList; 073 074 private static final long serialVersionUID = 1286378228L; 075 076 /** 077 * Constructor 078 */ 079 public ROLE() { 080 super(); 081 } 082 083 /** 084 * Constructor 085 */ 086 public ROLE(PARTY_REF performer) { 087 super(); 088 this.setPerformer(performer); 089 } 090 091 /** 092 * @return {@link #time_validity} (Identities used by the ROLE to identify itself, such as legal name, stage names, aliases, nicknames and so on.) 093 */ 094 public DV_INTERVAL getTime_validity() { 095 if (this.time_validity == null) 096 if (Configuration.errorOnAutoCreate()) 097 throw new Error("Attempt to auto-create ROLE.time_validity"); 098 else if (Configuration.doAutoCreate()) 099 this.time_validity = new DV_INTERVAL(); // cc 100 return this.time_validity; 101 } 102 103 public boolean hasTime_validity() { 104 return this.time_validity != null && !this.time_validity.isEmpty(); 105 } 106 107 /** 108 * @param value {@link #time_validity} (Identities used by the ROLE to identify itself, such as legal name, stage names, aliases, nicknames and so on.) 109 */ 110 public ROLE setTime_validity(DV_INTERVAL value) { 111 this.time_validity = value; 112 return this; 113 } 114 115 /** 116 * @return {@link #performer} (Contacts for this ROLE.) 117 */ 118 public PARTY_REF getPerformer() { 119 if (this.performer == null) 120 if (Configuration.errorOnAutoCreate()) 121 throw new Error("Attempt to auto-create ROLE.performer"); 122 else if (Configuration.doAutoCreate()) 123 this.performer = new PARTY_REF(); // cc 124 return this.performer; 125 } 126 127 public boolean hasPerformer() { 128 return this.performer != null && !this.performer.isEmpty(); 129 } 130 131 /** 132 * @param value {@link #performer} (Contacts for this ROLE.) 133 */ 134 public ROLE setPerformer(PARTY_REF value) { 135 this.performer = value; 136 return this; 137 } 138 139 /** 140 * @return {@link #capabilities} (All other details for this ROLE.) 141 */ 142 public List<CAPABILITY> getCapabilitiesList() { 143 if (this.capabilitiesList == null) 144 this.capabilitiesList = new ArrayList<CAPABILITY>(); 145 return this.capabilitiesList; 146 } 147 148 /** 149 * @return Returns a reference to <code>this</code> for easy method chaining 150 */ 151 public ROLE setCapabilitiesList(List<CAPABILITY> theCapabilities) { 152 this.capabilitiesList = theCapabilities; 153 return this; 154 } 155 156 public boolean hasCapabilities() { 157 if (this.capabilitiesList == null) 158 return false; 159 for (CAPABILITY item : this.capabilitiesList) 160 if (!item.isEmpty()) 161 return true; 162 return false; 163 } 164 165 public CAPABILITY addCapabilities() { //3a 166 CAPABILITY t = new CAPABILITY(); 167 if (this.capabilitiesList == null) 168 this.capabilitiesList = new ArrayList<CAPABILITY>(); 169 this.capabilitiesList.add(t); 170 return t; 171 } 172 173 public ROLE addCapabilities(CAPABILITY t) { //3b 174 if (t == null) 175 return this; 176 if (this.capabilitiesList == null) 177 this.capabilitiesList = new ArrayList<CAPABILITY>(); 178 this.capabilitiesList.add(t); 179 return this; 180 } 181 182 /** 183 * @return The first repetition of repeating field {@link #capabilities}, creating it if it does not already exist {3} 184 */ 185 public CAPABILITY getCapabilitiesFirstRep() { 186 if (getCapabilitiesList().isEmpty()) { 187 addCapabilities(); 188 } 189 return getCapabilitiesList().get(0); 190 } 191 192 protected void listChildren(List<Property> children) { 193 super.listChildren(children); 194 children.add(new Property("time_validity", "http://openehr.org/fhir/StructureDefinition/DV-INTERVAL", "Identities used by the ROLE to identify itself, such as legal name, stage names, aliases, nicknames and so on.", 0, 1, time_validity)); 195 children.add(new Property("performer", "http://openehr.org/fhir/StructureDefinition/PARTY-REF", "Contacts for this ROLE.", 0, 1, performer)); 196 children.add(new Property("capabilities", "http://openehr.org/fhir/StructureDefinition/CAPABILITY", "All other details for this ROLE.", 0, java.lang.Integer.MAX_VALUE, capabilitiesList)); 197 } 198 199 @Override 200 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 201 switch (_hash) { 202 case -1304171420: /*time_validity*/ return new Property("time_validity", "http://openehr.org/fhir/StructureDefinition/DV-INTERVAL", "Identities used by the ROLE to identify itself, such as legal name, stage names, aliases, nicknames and so on.", 0, 1, time_validity); 203 case 481140686: /*performer*/ return new Property("performer", "http://openehr.org/fhir/StructureDefinition/PARTY-REF", "Contacts for this ROLE.", 0, 1, performer); 204 case -1487597642: /*capabilities*/ return new Property("capabilities", "http://openehr.org/fhir/StructureDefinition/CAPABILITY", "All other details for this ROLE.", 0, java.lang.Integer.MAX_VALUE, capabilitiesList); 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 -1304171420: /*time_validity*/ return this.time_validity == null ? new Base[0] : new Base[] {this.time_validity}; // DV_INTERVAL 214 case 481140686: /*performer*/ return this.performer == null ? new Base[0] : new Base[] {this.performer}; // PARTY_REF 215 case -1487597642: /*capabilities*/ return this.capabilitiesList == null ? new Base[0] : this.capabilitiesList.toArray(new Base[this.capabilitiesList.size()]); // CAPABILITY 216 default: return super.getProperty(hash, name, checkValid); 217 } 218 219 } 220 221 @Override 222 public Base setProperty(int hash, String name, Base value) throws FHIRException { 223 switch (hash) { 224 case -1304171420: // time_validity 225 this.time_validity = (DV_INTERVAL) value; // DV_INTERVAL 226 return value; 227 case 481140686: // performer 228 this.performer = (PARTY_REF) value; // PARTY_REF 229 return value; 230 case -1487597642: // capabilities 231 this.getCapabilitiesList().add((CAPABILITY) value); // CAPABILITY 232 return value; 233 default: return super.setProperty(hash, name, value); 234 } 235 236 } 237 238 @Override 239 public Base setProperty(String name, Base value) throws FHIRException { 240 if (name.equals("time_validity")) { 241 this.time_validity = (DV_INTERVAL) value; // DV_INTERVAL 242 } else if (name.equals("performer")) { 243 this.performer = (PARTY_REF) value; // PARTY_REF 244 } else if (name.equals("capabilities")) { 245 this.getCapabilitiesList().add((CAPABILITY) value); // CAPABILITY 246 } else 247 return super.setProperty(name, value); 248 return value; 249 } 250 251 @Override 252 public Base makeProperty(int hash, String name) throws FHIRException { 253 switch (hash) { 254 case -1304171420: return getTime_validity(); 255 case 481140686: return getPerformer(); 256 case -1487597642: return addCapabilities(); 257 default: return super.makeProperty(hash, name); 258 } 259 260 } 261 262 @Override 263 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 264 switch (hash) { 265 case -1304171420: /*time_validity*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-INTERVAL"}; 266 case 481140686: /*performer*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/PARTY-REF"}; 267 case -1487597642: /*capabilities*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/CAPABILITY"}; 268 default: return super.getTypesForProperty(hash, name); 269 } 270 271 } 272 273 @Override 274 public Base addChild(String name) throws FHIRException { 275 if (name.equals("time_validity")) { 276 this.time_validity = new DV_INTERVAL(); 277 return this.time_validity; 278 } 279 else if (name.equals("performer")) { 280 this.performer = new PARTY_REF(); 281 return this.performer; 282 } 283 else if (name.equals("capabilities")) { 284 return addCapabilities(); 285 } 286 else 287 return super.addChild(name); 288 } 289 290 public String fhirType() { 291 return "ROLE"; 292 293 } 294 295 public ROLE copy() { 296 ROLE dst = new ROLE(); 297 copyValues(dst); 298 return dst; 299 } 300 301 public void copyValues(ROLE dst) { 302 super.copyValues(dst); 303 dst.time_validity = time_validity == null ? null : time_validity.copy(); 304 dst.performer = performer == null ? null : performer.copy(); 305 if (capabilitiesList != null) { 306 dst.capabilitiesList = new ArrayList<CAPABILITY>(); 307 for (CAPABILITY i : capabilitiesList) 308 dst.capabilitiesList.add(i.copy()); 309 }; 310 } 311 312 protected ROLE typedCopy() { 313 return copy(); 314 } 315 316 @Override 317 public boolean equalsDeep(Base other_) { 318 if (!super.equalsDeep(other_)) 319 return false; 320 if (!(other_ instanceof ROLE)) 321 return false; 322 ROLE o = (ROLE) other_; 323 return compareDeep(time_validity, o.time_validity, true) && compareDeep(performer, o.performer, true) 324 && compareDeep(capabilitiesList, o.capabilitiesList, true); 325 } 326 327 @Override 328 public boolean equalsShallow(Base other_) { 329 if (!super.equalsShallow(other_)) 330 return false; 331 if (!(other_ instanceof ROLE)) 332 return false; 333 ROLE o = (ROLE) other_; 334 return true; 335 } 336 337 public boolean isEmpty() { 338 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(time_validity, performer, capabilitiesList 339 ); 340 } 341 342 343} 344