
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 * Class describing a reference to another object, which may exist locally or be maintained outside the current namespace, e.g. in another service. Services are usually external, e.g. available in a LAN (including on the same host) or the internet via Corba, SOAP, or some other distributed protocol. However, in small systems they may be part of the same executable as the data containing the Id. 050 */ 051@DatatypeDef(name="OBJECT_REF") 052public class OBJECT_REF extends LogicalBase implements ICompositeType { 053 054 /** 055 * Namespace to which this identifier belongs in the local system context (and possibly in any other openEHR compliant environment) e.g. terminology , demographic . These names are not yet standardised. Legal values for namespace are: 'local', 'unknown', or a string matching the standard regex [a-zA-Z][a-zA-Z0-9_.:/&?=+-]*. Note that the first two are just special values of the regex, and will be matched by it. 056 */ 057 @Child(name = "namespace", type = {StringType.class}, order=0, min=1, max=1, modifier=false, summary=false) 058 @Description(shortDefinition="Namespace to which this identifier belongs in the local system context (and possibly in any other openEHR compliant environment)", formalDefinition="Namespace to which this identifier belongs in the local system context (and possibly in any other openEHR compliant environment) e.g. terminology , demographic . These names are not yet standardised. Legal values for namespace are: 'local', 'unknown', or a string matching the standard regex [a-zA-Z][a-zA-Z0-9_.:/&?=+-]*. Note that the first two are just special values of the regex, and will be matched by it." ) 059 protected StringType namespace; 060 061 /** 062 * Name of the class (concrete or abstract) of object to which this identifier type refers, e.g. PARTY, PERSON, GUIDELINE etc. These class names are from the relevant reference model. The type name ANY can be used to indicate that any type is accepted (e.g. if the type is unknown). 063 */ 064 @Child(name = "type", type = {StringType.class}, order=1, min=1, max=1, modifier=false, summary=false) 065 @Description(shortDefinition="Name of the class (concrete or abstract) of object to which this identifier type refers. These class names are from the relevant reference model", formalDefinition="Name of the class (concrete or abstract) of object to which this identifier type refers, e.g. PARTY, PERSON, GUIDELINE etc. These class names are from the relevant reference model. The type name ANY can be used to indicate that any type is accepted (e.g. if the type is unknown)." ) 066 protected StringType type; 067 068 /** 069 * Globally unique id of an object, regardless of where it is stored. 070 */ 071 @Child(name = "id", type = {OBJECT_ID.class}, order=2, min=1, max=1, modifier=false, summary=false) 072 @Description(shortDefinition="Globally unique id of an object, regardless of where it is stored", formalDefinition="Globally unique id of an object, regardless of where it is stored." ) 073 protected OBJECT_ID id; 074 075 private static final long serialVersionUID = 1415979947L; 076 077 /** 078 * Constructor 079 */ 080 public OBJECT_REF() { 081 super(); 082 } 083 084 /** 085 * Constructor 086 */ 087 public OBJECT_REF(String namespace, String type, OBJECT_ID id) { 088 super(); 089 this.setNamespace(namespace); 090 this.setType(type); 091 this.setId(id); 092 } 093 094 /** 095 * @return {@link #namespace} (Namespace to which this identifier belongs in the local system context (and possibly in any other openEHR compliant environment) e.g. terminology , demographic . These names are not yet standardised. Legal values for namespace are: 'local', 'unknown', or a string matching the standard regex [a-zA-Z][a-zA-Z0-9_.:/&?=+-]*. Note that the first two are just special values of the regex, and will be matched by it.). This is the underlying object with id, value and extensions. The accessor "getNamespace" gives direct access to the value 096 */ 097 public StringType getNamespaceElement() { 098 if (this.namespace == null) 099 if (Configuration.errorOnAutoCreate()) 100 throw new Error("Attempt to auto-create OBJECT_REF.namespace"); 101 else if (Configuration.doAutoCreate()) 102 this.namespace = new StringType(); // bb 103 return this.namespace; 104 } 105 106 public boolean hasNamespaceElement() { 107 return this.namespace != null && !this.namespace.isEmpty(); 108 } 109 110 public boolean hasNamespace() { 111 return this.namespace != null && !this.namespace.isEmpty(); 112 } 113 114 /** 115 * @param value {@link #namespace} (Namespace to which this identifier belongs in the local system context (and possibly in any other openEHR compliant environment) e.g. terminology , demographic . These names are not yet standardised. Legal values for namespace are: 'local', 'unknown', or a string matching the standard regex [a-zA-Z][a-zA-Z0-9_.:/&?=+-]*. Note that the first two are just special values of the regex, and will be matched by it.). This is the underlying object with id, value and extensions. The accessor "getNamespace" gives direct access to the value 116 */ 117 public OBJECT_REF setNamespaceElement(StringType value) { 118 this.namespace = value; 119 return this; 120 } 121 122 /** 123 * @return Namespace to which this identifier belongs in the local system context (and possibly in any other openEHR compliant environment) e.g. terminology , demographic . These names are not yet standardised. Legal values for namespace are: 'local', 'unknown', or a string matching the standard regex [a-zA-Z][a-zA-Z0-9_.:/&?=+-]*. Note that the first two are just special values of the regex, and will be matched by it. 124 */ 125 public String getNamespace() { 126 return this.namespace == null ? null : this.namespace.getValue(); 127 } 128 129 /** 130 * @param value Namespace to which this identifier belongs in the local system context (and possibly in any other openEHR compliant environment) e.g. terminology , demographic . These names are not yet standardised. Legal values for namespace are: 'local', 'unknown', or a string matching the standard regex [a-zA-Z][a-zA-Z0-9_.:/&?=+-]*. Note that the first two are just special values of the regex, and will be matched by it. 131 */ 132 public OBJECT_REF setNamespace(String value) { 133 if (this.namespace == null) 134 this.namespace = new StringType(); 135 this.namespace.setValue(value); 136 return this; 137 } 138 139 /** 140 * @return {@link #type} (Name of the class (concrete or abstract) of object to which this identifier type refers, e.g. PARTY, PERSON, GUIDELINE etc. These class names are from the relevant reference model. The type name ANY can be used to indicate that any type is accepted (e.g. if the type is unknown).). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value 141 */ 142 public StringType getTypeElement() { 143 if (this.type == null) 144 if (Configuration.errorOnAutoCreate()) 145 throw new Error("Attempt to auto-create OBJECT_REF.type"); 146 else if (Configuration.doAutoCreate()) 147 this.type = new StringType(); // bb 148 return this.type; 149 } 150 151 public boolean hasTypeElement() { 152 return this.type != null && !this.type.isEmpty(); 153 } 154 155 public boolean hasType() { 156 return this.type != null && !this.type.isEmpty(); 157 } 158 159 /** 160 * @param value {@link #type} (Name of the class (concrete or abstract) of object to which this identifier type refers, e.g. PARTY, PERSON, GUIDELINE etc. These class names are from the relevant reference model. The type name ANY can be used to indicate that any type is accepted (e.g. if the type is unknown).). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value 161 */ 162 public OBJECT_REF setTypeElement(StringType value) { 163 this.type = value; 164 return this; 165 } 166 167 /** 168 * @return Name of the class (concrete or abstract) of object to which this identifier type refers, e.g. PARTY, PERSON, GUIDELINE etc. These class names are from the relevant reference model. The type name ANY can be used to indicate that any type is accepted (e.g. if the type is unknown). 169 */ 170 public String getType() { 171 return this.type == null ? null : this.type.getValue(); 172 } 173 174 /** 175 * @param value Name of the class (concrete or abstract) of object to which this identifier type refers, e.g. PARTY, PERSON, GUIDELINE etc. These class names are from the relevant reference model. The type name ANY can be used to indicate that any type is accepted (e.g. if the type is unknown). 176 */ 177 public OBJECT_REF setType(String value) { 178 if (this.type == null) 179 this.type = new StringType(); 180 this.type.setValue(value); 181 return this; 182 } 183 184 /** 185 * @return {@link #id} (Globally unique id of an object, regardless of where it is stored.) 186 */ 187 public OBJECT_ID getId() { 188 return this.id; 189 } 190 191 public boolean hasId() { 192 return this.id != null && !this.id.isEmpty(); 193 } 194 195 /** 196 * @param value {@link #id} (Globally unique id of an object, regardless of where it is stored.) 197 */ 198 public OBJECT_REF setId(OBJECT_ID value) { 199 this.id = value; 200 return this; 201 } 202 203 protected void listChildren(List<Property> children) { 204 super.listChildren(children); 205 children.add(new Property("namespace", "string", "Namespace to which this identifier belongs in the local system context (and possibly in any other openEHR compliant environment) e.g. terminology , demographic . These names are not yet standardised. Legal values for namespace are: 'local', 'unknown', or a string matching the standard regex [a-zA-Z][a-zA-Z0-9_.:/&?=+-]*. Note that the first two are just special values of the regex, and will be matched by it.", 0, 1, namespace)); 206 children.add(new Property("type", "string", "Name of the class (concrete or abstract) of object to which this identifier type refers, e.g. PARTY, PERSON, GUIDELINE etc. These class names are from the relevant reference model. The type name ANY can be used to indicate that any type is accepted (e.g. if the type is unknown).", 0, 1, type)); 207 children.add(new Property("id", "http://openehr.org/fhir/StructureDefinition/OBJECT-ID", "Globally unique id of an object, regardless of where it is stored.", 0, 1, id)); 208 } 209 210 @Override 211 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 212 switch (_hash) { 213 case 1252218203: /*namespace*/ return new Property("namespace", "string", "Namespace to which this identifier belongs in the local system context (and possibly in any other openEHR compliant environment) e.g. terminology , demographic . These names are not yet standardised. Legal values for namespace are: 'local', 'unknown', or a string matching the standard regex [a-zA-Z][a-zA-Z0-9_.:/&?=+-]*. Note that the first two are just special values of the regex, and will be matched by it.", 0, 1, namespace); 214 case 3575610: /*type*/ return new Property("type", "string", "Name of the class (concrete or abstract) of object to which this identifier type refers, e.g. PARTY, PERSON, GUIDELINE etc. These class names are from the relevant reference model. The type name ANY can be used to indicate that any type is accepted (e.g. if the type is unknown).", 0, 1, type); 215 case 3355: /*id*/ return new Property("id", "http://openehr.org/fhir/StructureDefinition/OBJECT-ID", "Globally unique id of an object, regardless of where it is stored.", 0, 1, id); 216 default: return super.getNamedProperty(_hash, _name, _checkValid); 217 } 218 219 } 220 221 @Override 222 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 223 switch (hash) { 224 case 1252218203: /*namespace*/ return this.namespace == null ? new Base[0] : new Base[] {this.namespace}; // StringType 225 case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // StringType 226 case 3355: /*id*/ return this.id == null ? new Base[0] : new Base[] {this.id}; // OBJECT_ID 227 default: return super.getProperty(hash, name, checkValid); 228 } 229 230 } 231 232 @Override 233 public Base setProperty(int hash, String name, Base value) throws FHIRException { 234 switch (hash) { 235 case 1252218203: // namespace 236 this.namespace = TypeConvertor.castToString(value); // StringType 237 return value; 238 case 3575610: // type 239 this.type = TypeConvertor.castToString(value); // StringType 240 return value; 241 case 3355: // id 242 this.id = (OBJECT_ID) value; // OBJECT_ID 243 return value; 244 default: return super.setProperty(hash, name, value); 245 } 246 247 } 248 249 @Override 250 public Base setProperty(String name, Base value) throws FHIRException { 251 if (name.equals("namespace")) { 252 this.namespace = TypeConvertor.castToString(value); // StringType 253 } else if (name.equals("type")) { 254 this.type = TypeConvertor.castToString(value); // StringType 255 } else if (name.equals("id")) { 256 this.id = (OBJECT_ID) value; // OBJECT_ID 257 } else 258 return super.setProperty(name, value); 259 return value; 260 } 261 262 @Override 263 public Base makeProperty(int hash, String name) throws FHIRException { 264 switch (hash) { 265 case 1252218203: return getNamespaceElement(); 266 case 3575610: return getTypeElement(); 267 case 3355: /*div*/ 268 throw new Error("Unable to make an instance of the abstract property 'id'"); 269 default: return super.makeProperty(hash, name); 270 } 271 272 } 273 274 @Override 275 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 276 switch (hash) { 277 case 1252218203: /*namespace*/ return new String[] {"string"}; 278 case 3575610: /*type*/ return new String[] {"string"}; 279 case 3355: /*id*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/OBJECT-ID"}; 280 default: return super.getTypesForProperty(hash, name); 281 } 282 283 } 284 285 @Override 286 public Base addChild(String name) throws FHIRException { 287 if (name.equals("namespace")) { 288 throw new FHIRException("Cannot call addChild on a singleton property OBJECT_REF.namespace"); 289 } 290 else if (name.equals("type")) { 291 throw new FHIRException("Cannot call addChild on a singleton property OBJECT_REF.type"); 292 } 293 else if (name.equals("id")) { 294 throw new FHIRException("Cannot call addChild on an abstract type OBJECT_REF.id"); 295 } 296 else 297 return super.addChild(name); 298 } 299 300 public String fhirType() { 301 return "OBJECT_REF"; 302 303 } 304 305 public OBJECT_REF copy() { 306 OBJECT_REF dst = new OBJECT_REF(); 307 copyValues(dst); 308 return dst; 309 } 310 311 public void copyValues(OBJECT_REF dst) { 312 super.copyValues(dst); 313 dst.namespace = namespace == null ? null : namespace.copy(); 314 dst.type = type == null ? null : type.copy(); 315 dst.id = id == null ? null : id.copy(); 316 } 317 318 protected OBJECT_REF typedCopy() { 319 return copy(); 320 } 321 322 @Override 323 public boolean equalsDeep(Base other_) { 324 if (!super.equalsDeep(other_)) 325 return false; 326 if (!(other_ instanceof OBJECT_REF)) 327 return false; 328 OBJECT_REF o = (OBJECT_REF) other_; 329 return compareDeep(namespace, o.namespace, true) && compareDeep(type, o.type, true) && compareDeep(id, o.id, true) 330 ; 331 } 332 333 @Override 334 public boolean equalsShallow(Base other_) { 335 if (!super.equalsShallow(other_)) 336 return false; 337 if (!(other_ instanceof OBJECT_REF)) 338 return false; 339 OBJECT_REF o = (OBJECT_REF) other_; 340 return compareValues(namespace, o.namespace, true) && compareValues(type, o.type, true); 341 } 342 343 public boolean isEmpty() { 344 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(namespace, type, id); 345 } 346 347 348} 349