
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 * Proxy data for an identified party other than the subject of the record, minimally consisting of human-readable identifier(s), such as name, formal (and possibly computable) identifiers such as NHS number, and an optional link to external data. There must be at least one of name, identifier or external_ref present. Used to describe parties where only identifiers may be known, and there is no entry at all in the demographic system (or even no demographic system). Typically for health care providers, e.g. name and provider number of an institution. Should not be used to include patient identifying information. 050 */ 051@DatatypeDef(name="PARTY_IDENTIFIED") 052public class PARTY_IDENTIFIED extends PARTY_PROXY implements ICompositeType { 053 054 /** 055 * Optional human-readable name (in String form). 056 */ 057 @Child(name = "name", type = {StringType.class}, order=0, min=0, max=1, modifier=false, summary=false) 058 @Description(shortDefinition="Optional human-readable name", formalDefinition="Optional human-readable name (in String form)." ) 059 protected StringType name; 060 061 /** 062 * One or more formal identifiers (possibly computable). 063 */ 064 @Child(name = "identifiers", type = {DV_IDENTIFIER.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 065 @Description(shortDefinition="One or more formal identifiers (possibly computable)", formalDefinition="One or more formal identifiers (possibly computable)." ) 066 protected List<DV_IDENTIFIER> identifiersList; 067 068 private static final long serialVersionUID = 1762655878L; 069 070 /** 071 * Constructor 072 */ 073 public PARTY_IDENTIFIED() { 074 super(); 075 } 076 077 /** 078 * @return {@link #name} (Optional human-readable name (in String form).). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value 079 */ 080 public StringType getNameElement() { 081 if (this.name == null) 082 if (Configuration.errorOnAutoCreate()) 083 throw new Error("Attempt to auto-create PARTY_IDENTIFIED.name"); 084 else if (Configuration.doAutoCreate()) 085 this.name = new StringType(); // bb 086 return this.name; 087 } 088 089 public boolean hasNameElement() { 090 return this.name != null && !this.name.isEmpty(); 091 } 092 093 public boolean hasName() { 094 return this.name != null && !this.name.isEmpty(); 095 } 096 097 /** 098 * @param value {@link #name} (Optional human-readable name (in String form).). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value 099 */ 100 public PARTY_IDENTIFIED setNameElement(StringType value) { 101 this.name = value; 102 return this; 103 } 104 105 /** 106 * @return Optional human-readable name (in String form). 107 */ 108 public String getName() { 109 return this.name == null ? null : this.name.getValue(); 110 } 111 112 /** 113 * @param value Optional human-readable name (in String form). 114 */ 115 public PARTY_IDENTIFIED setName(String value) { 116 if (Utilities.noString(value)) 117 this.name = null; 118 else { 119 if (this.name == null) 120 this.name = new StringType(); 121 this.name.setValue(value); 122 } 123 return this; 124 } 125 126 /** 127 * @return {@link #identifiers} (One or more formal identifiers (possibly computable).) 128 */ 129 public List<DV_IDENTIFIER> getIdentifiersList() { 130 if (this.identifiersList == null) 131 this.identifiersList = new ArrayList<DV_IDENTIFIER>(); 132 return this.identifiersList; 133 } 134 135 /** 136 * @return Returns a reference to <code>this</code> for easy method chaining 137 */ 138 public PARTY_IDENTIFIED setIdentifiersList(List<DV_IDENTIFIER> theIdentifiers) { 139 this.identifiersList = theIdentifiers; 140 return this; 141 } 142 143 public boolean hasIdentifiers() { 144 if (this.identifiersList == null) 145 return false; 146 for (DV_IDENTIFIER item : this.identifiersList) 147 if (!item.isEmpty()) 148 return true; 149 return false; 150 } 151 152 public DV_IDENTIFIER addIdentifiers() { //3a 153 DV_IDENTIFIER t = new DV_IDENTIFIER(); 154 if (this.identifiersList == null) 155 this.identifiersList = new ArrayList<DV_IDENTIFIER>(); 156 this.identifiersList.add(t); 157 return t; 158 } 159 160 public PARTY_IDENTIFIED addIdentifiers(DV_IDENTIFIER t) { //3b 161 if (t == null) 162 return this; 163 if (this.identifiersList == null) 164 this.identifiersList = new ArrayList<DV_IDENTIFIER>(); 165 this.identifiersList.add(t); 166 return this; 167 } 168 169 /** 170 * @return The first repetition of repeating field {@link #identifiers}, creating it if it does not already exist {3} 171 */ 172 public DV_IDENTIFIER getIdentifiersFirstRep() { 173 if (getIdentifiersList().isEmpty()) { 174 addIdentifiers(); 175 } 176 return getIdentifiersList().get(0); 177 } 178 179 protected void listChildren(List<Property> children) { 180 super.listChildren(children); 181 children.add(new Property("name", "string", "Optional human-readable name (in String form).", 0, 1, name)); 182 children.add(new Property("identifiers", "http://openehr.org/fhir/StructureDefinition/DV-IDENTIFIER", "One or more formal identifiers (possibly computable).", 0, java.lang.Integer.MAX_VALUE, identifiersList)); 183 } 184 185 @Override 186 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 187 switch (_hash) { 188 case 3373707: /*name*/ return new Property("name", "string", "Optional human-readable name (in String form).", 0, 1, name); 189 case 1368189162: /*identifiers*/ return new Property("identifiers", "http://openehr.org/fhir/StructureDefinition/DV-IDENTIFIER", "One or more formal identifiers (possibly computable).", 0, java.lang.Integer.MAX_VALUE, identifiersList); 190 default: return super.getNamedProperty(_hash, _name, _checkValid); 191 } 192 193 } 194 195 @Override 196 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 197 switch (hash) { 198 case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // StringType 199 case 1368189162: /*identifiers*/ return this.identifiersList == null ? new Base[0] : this.identifiersList.toArray(new Base[this.identifiersList.size()]); // DV_IDENTIFIER 200 default: return super.getProperty(hash, name, checkValid); 201 } 202 203 } 204 205 @Override 206 public Base setProperty(int hash, String name, Base value) throws FHIRException { 207 switch (hash) { 208 case 3373707: // name 209 this.name = TypeConvertor.castToString(value); // StringType 210 return value; 211 case 1368189162: // identifiers 212 this.getIdentifiersList().add((DV_IDENTIFIER) value); // DV_IDENTIFIER 213 return value; 214 default: return super.setProperty(hash, name, value); 215 } 216 217 } 218 219 @Override 220 public Base setProperty(String name, Base value) throws FHIRException { 221 if (name.equals("name")) { 222 this.name = TypeConvertor.castToString(value); // StringType 223 } else if (name.equals("identifiers")) { 224 this.getIdentifiersList().add((DV_IDENTIFIER) value); // DV_IDENTIFIER 225 } else 226 return super.setProperty(name, value); 227 return value; 228 } 229 230 @Override 231 public Base makeProperty(int hash, String name) throws FHIRException { 232 switch (hash) { 233 case 3373707: return getNameElement(); 234 case 1368189162: return addIdentifiers(); 235 default: return super.makeProperty(hash, name); 236 } 237 238 } 239 240 @Override 241 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 242 switch (hash) { 243 case 3373707: /*name*/ return new String[] {"string"}; 244 case 1368189162: /*identifiers*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-IDENTIFIER"}; 245 default: return super.getTypesForProperty(hash, name); 246 } 247 248 } 249 250 @Override 251 public Base addChild(String name) throws FHIRException { 252 if (name.equals("name")) { 253 throw new FHIRException("Cannot call addChild on a singleton property PARTY_IDENTIFIED.name"); 254 } 255 else if (name.equals("identifiers")) { 256 return addIdentifiers(); 257 } 258 else 259 return super.addChild(name); 260 } 261 262 public String fhirType() { 263 return "PARTY_IDENTIFIED"; 264 265 } 266 267 public PARTY_IDENTIFIED copy() { 268 PARTY_IDENTIFIED dst = new PARTY_IDENTIFIED(); 269 copyValues(dst); 270 return dst; 271 } 272 273 public void copyValues(PARTY_IDENTIFIED dst) { 274 super.copyValues(dst); 275 dst.name = name == null ? null : name.copy(); 276 if (identifiersList != null) { 277 dst.identifiersList = new ArrayList<DV_IDENTIFIER>(); 278 for (DV_IDENTIFIER i : identifiersList) 279 dst.identifiersList.add(i.copy()); 280 }; 281 } 282 283 protected PARTY_IDENTIFIED typedCopy() { 284 return copy(); 285 } 286 287 @Override 288 public boolean equalsDeep(Base other_) { 289 if (!super.equalsDeep(other_)) 290 return false; 291 if (!(other_ instanceof PARTY_IDENTIFIED)) 292 return false; 293 PARTY_IDENTIFIED o = (PARTY_IDENTIFIED) other_; 294 return compareDeep(name, o.name, true) && compareDeep(identifiersList, o.identifiersList, true) 295 ; 296 } 297 298 @Override 299 public boolean equalsShallow(Base other_) { 300 if (!super.equalsShallow(other_)) 301 return false; 302 if (!(other_ instanceof PARTY_IDENTIFIED)) 303 return false; 304 PARTY_IDENTIFIED o = (PARTY_IDENTIFIED) other_; 305 return compareValues(name, o.name, true); 306 } 307 308 public boolean isEmpty() { 309 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(name, identifiersList); 310 } 311 312 313} 314