
001package org.hl7.fhir.r5.model; 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.model.Enumerations.*; 039import org.hl7.fhir.instance.model.api.IBaseBackboneElement; 040import org.hl7.fhir.exceptions.FHIRException; 041import org.hl7.fhir.instance.model.api.ICompositeType; 042import ca.uhn.fhir.model.api.annotation.ResourceDef; 043import ca.uhn.fhir.model.api.annotation.SearchParamDefinition; 044import org.hl7.fhir.instance.model.api.IBaseBackboneElement; 045import ca.uhn.fhir.model.api.annotation.Child; 046import ca.uhn.fhir.model.api.annotation.ChildOrder; 047import ca.uhn.fhir.model.api.annotation.Description; 048import ca.uhn.fhir.model.api.annotation.Block; 049 050/** 051 * This resource describes a product or service that is available through a program and includes the conditions and constraints of availability. All of the information in this resource is specific to the inclusion of the item in the formulary and is not inherent to the item itself. 052 */ 053@ResourceDef(name="FormularyItem", profile="http://hl7.org/fhir/StructureDefinition/FormularyItem") 054public class FormularyItem extends DomainResource { 055 056 public enum FormularyItemStatusCodes { 057 /** 058 * The service or product referred to by this FormularyItem is in active use within the drug database or inventory system. 059 */ 060 ACTIVE, 061 /** 062 * The service or product referred to by this FormularyItem was entered in error within the drug database or inventory system. 063 */ 064 ENTEREDINERROR, 065 /** 066 * The service or product referred to by this FormularyItem is not in active use within the drug database or inventory system. 067 */ 068 INACTIVE, 069 /** 070 * added to help the parsers with the generic types 071 */ 072 NULL; 073 public static FormularyItemStatusCodes fromCode(String codeString) throws FHIRException { 074 if (codeString == null || "".equals(codeString)) 075 return null; 076 if ("active".equals(codeString)) 077 return ACTIVE; 078 if ("entered-in-error".equals(codeString)) 079 return ENTEREDINERROR; 080 if ("inactive".equals(codeString)) 081 return INACTIVE; 082 if (Configuration.isAcceptInvalidEnums()) 083 return null; 084 else 085 throw new FHIRException("Unknown FormularyItemStatusCodes code '"+codeString+"'"); 086 } 087 public String toCode() { 088 switch (this) { 089 case ACTIVE: return "active"; 090 case ENTEREDINERROR: return "entered-in-error"; 091 case INACTIVE: return "inactive"; 092 case NULL: return null; 093 default: return "?"; 094 } 095 } 096 public String getSystem() { 097 switch (this) { 098 case ACTIVE: return "http://hl7.org/fhir/CodeSystem/formularyitem-status"; 099 case ENTEREDINERROR: return "http://hl7.org/fhir/CodeSystem/formularyitem-status"; 100 case INACTIVE: return "http://hl7.org/fhir/CodeSystem/formularyitem-status"; 101 case NULL: return null; 102 default: return "?"; 103 } 104 } 105 public String getDefinition() { 106 switch (this) { 107 case ACTIVE: return "The service or product referred to by this FormularyItem is in active use within the drug database or inventory system."; 108 case ENTEREDINERROR: return "The service or product referred to by this FormularyItem was entered in error within the drug database or inventory system."; 109 case INACTIVE: return "The service or product referred to by this FormularyItem is not in active use within the drug database or inventory system."; 110 case NULL: return null; 111 default: return "?"; 112 } 113 } 114 public String getDisplay() { 115 switch (this) { 116 case ACTIVE: return "Active"; 117 case ENTEREDINERROR: return "Entered in Error"; 118 case INACTIVE: return "Inactive"; 119 case NULL: return null; 120 default: return "?"; 121 } 122 } 123 } 124 125 public static class FormularyItemStatusCodesEnumFactory implements EnumFactory<FormularyItemStatusCodes> { 126 public FormularyItemStatusCodes fromCode(String codeString) throws IllegalArgumentException { 127 if (codeString == null || "".equals(codeString)) 128 if (codeString == null || "".equals(codeString)) 129 return null; 130 if ("active".equals(codeString)) 131 return FormularyItemStatusCodes.ACTIVE; 132 if ("entered-in-error".equals(codeString)) 133 return FormularyItemStatusCodes.ENTEREDINERROR; 134 if ("inactive".equals(codeString)) 135 return FormularyItemStatusCodes.INACTIVE; 136 throw new IllegalArgumentException("Unknown FormularyItemStatusCodes code '"+codeString+"'"); 137 } 138 public Enumeration<FormularyItemStatusCodes> fromType(PrimitiveType<?> code) throws FHIRException { 139 if (code == null) 140 return null; 141 if (code.isEmpty()) 142 return new Enumeration<FormularyItemStatusCodes>(this, FormularyItemStatusCodes.NULL, code); 143 String codeString = ((PrimitiveType) code).asStringValue(); 144 if (codeString == null || "".equals(codeString)) 145 return new Enumeration<FormularyItemStatusCodes>(this, FormularyItemStatusCodes.NULL, code); 146 if ("active".equals(codeString)) 147 return new Enumeration<FormularyItemStatusCodes>(this, FormularyItemStatusCodes.ACTIVE, code); 148 if ("entered-in-error".equals(codeString)) 149 return new Enumeration<FormularyItemStatusCodes>(this, FormularyItemStatusCodes.ENTEREDINERROR, code); 150 if ("inactive".equals(codeString)) 151 return new Enumeration<FormularyItemStatusCodes>(this, FormularyItemStatusCodes.INACTIVE, code); 152 throw new FHIRException("Unknown FormularyItemStatusCodes code '"+codeString+"'"); 153 } 154 public String toCode(FormularyItemStatusCodes code) { 155 if (code == FormularyItemStatusCodes.ACTIVE) 156 return "active"; 157 if (code == FormularyItemStatusCodes.ENTEREDINERROR) 158 return "entered-in-error"; 159 if (code == FormularyItemStatusCodes.INACTIVE) 160 return "inactive"; 161 return "?"; 162 } 163 public String toSystem(FormularyItemStatusCodes code) { 164 return code.getSystem(); 165 } 166 } 167 168 /** 169 * Business identifier for this formulary item. 170 */ 171 @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 172 @Description(shortDefinition="Business identifier for this formulary item", formalDefinition="Business identifier for this formulary item." ) 173 protected List<Identifier> identifier; 174 175 /** 176 * A code (or set of codes) that specify the product or service that is identified by this formulary item. 177 */ 178 @Child(name = "code", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true) 179 @Description(shortDefinition="Codes that identify this formulary item", formalDefinition="A code (or set of codes) that specify the product or service that is identified by this formulary item." ) 180 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-codes") 181 protected CodeableConcept code; 182 183 /** 184 * The validity about the information of the formulary item and not of the underlying product or service itself. 185 */ 186 @Child(name = "status", type = {CodeType.class}, order=2, min=0, max=1, modifier=true, summary=true) 187 @Description(shortDefinition="active | entered-in-error | inactive", formalDefinition="The validity about the information of the formulary item and not of the underlying product or service itself." ) 188 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/formularyitem-status") 189 protected Enumeration<FormularyItemStatusCodes> status; 190 191 private static final long serialVersionUID = 601026823L; 192 193 /** 194 * Constructor 195 */ 196 public FormularyItem() { 197 super(); 198 } 199 200 /** 201 * @return {@link #identifier} (Business identifier for this formulary item.) 202 */ 203 public List<Identifier> getIdentifier() { 204 if (this.identifier == null) 205 this.identifier = new ArrayList<Identifier>(); 206 return this.identifier; 207 } 208 209 /** 210 * @return Returns a reference to <code>this</code> for easy method chaining 211 */ 212 public FormularyItem setIdentifier(List<Identifier> theIdentifier) { 213 this.identifier = theIdentifier; 214 return this; 215 } 216 217 public boolean hasIdentifier() { 218 if (this.identifier == null) 219 return false; 220 for (Identifier item : this.identifier) 221 if (!item.isEmpty()) 222 return true; 223 return false; 224 } 225 226 public Identifier addIdentifier() { //3 227 Identifier t = new Identifier(); 228 if (this.identifier == null) 229 this.identifier = new ArrayList<Identifier>(); 230 this.identifier.add(t); 231 return t; 232 } 233 234 public FormularyItem addIdentifier(Identifier t) { //3 235 if (t == null) 236 return this; 237 if (this.identifier == null) 238 this.identifier = new ArrayList<Identifier>(); 239 this.identifier.add(t); 240 return this; 241 } 242 243 /** 244 * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist {3} 245 */ 246 public Identifier getIdentifierFirstRep() { 247 if (getIdentifier().isEmpty()) { 248 addIdentifier(); 249 } 250 return getIdentifier().get(0); 251 } 252 253 /** 254 * @return {@link #code} (A code (or set of codes) that specify the product or service that is identified by this formulary item.) 255 */ 256 public CodeableConcept getCode() { 257 if (this.code == null) 258 if (Configuration.errorOnAutoCreate()) 259 throw new Error("Attempt to auto-create FormularyItem.code"); 260 else if (Configuration.doAutoCreate()) 261 this.code = new CodeableConcept(); // cc 262 return this.code; 263 } 264 265 public boolean hasCode() { 266 return this.code != null && !this.code.isEmpty(); 267 } 268 269 /** 270 * @param value {@link #code} (A code (or set of codes) that specify the product or service that is identified by this formulary item.) 271 */ 272 public FormularyItem setCode(CodeableConcept value) { 273 this.code = value; 274 return this; 275 } 276 277 /** 278 * @return {@link #status} (The validity about the information of the formulary item and not of the underlying product or service itself.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value 279 */ 280 public Enumeration<FormularyItemStatusCodes> getStatusElement() { 281 if (this.status == null) 282 if (Configuration.errorOnAutoCreate()) 283 throw new Error("Attempt to auto-create FormularyItem.status"); 284 else if (Configuration.doAutoCreate()) 285 this.status = new Enumeration<FormularyItemStatusCodes>(new FormularyItemStatusCodesEnumFactory()); // bb 286 return this.status; 287 } 288 289 public boolean hasStatusElement() { 290 return this.status != null && !this.status.isEmpty(); 291 } 292 293 public boolean hasStatus() { 294 return this.status != null && !this.status.isEmpty(); 295 } 296 297 /** 298 * @param value {@link #status} (The validity about the information of the formulary item and not of the underlying product or service itself.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value 299 */ 300 public FormularyItem setStatusElement(Enumeration<FormularyItemStatusCodes> value) { 301 this.status = value; 302 return this; 303 } 304 305 /** 306 * @return The validity about the information of the formulary item and not of the underlying product or service itself. 307 */ 308 public FormularyItemStatusCodes getStatus() { 309 return this.status == null ? null : this.status.getValue(); 310 } 311 312 /** 313 * @param value The validity about the information of the formulary item and not of the underlying product or service itself. 314 */ 315 public FormularyItem setStatus(FormularyItemStatusCodes value) { 316 if (value == null) 317 this.status = null; 318 else { 319 if (this.status == null) 320 this.status = new Enumeration<FormularyItemStatusCodes>(new FormularyItemStatusCodesEnumFactory()); 321 this.status.setValue(value); 322 } 323 return this; 324 } 325 326 protected void listChildren(List<Property> children) { 327 super.listChildren(children); 328 children.add(new Property("identifier", "Identifier", "Business identifier for this formulary item.", 0, java.lang.Integer.MAX_VALUE, identifier)); 329 children.add(new Property("code", "CodeableConcept", "A code (or set of codes) that specify the product or service that is identified by this formulary item.", 0, 1, code)); 330 children.add(new Property("status", "code", "The validity about the information of the formulary item and not of the underlying product or service itself.", 0, 1, status)); 331 } 332 333 @Override 334 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 335 switch (_hash) { 336 case -1618432855: /*identifier*/ return new Property("identifier", "Identifier", "Business identifier for this formulary item.", 0, java.lang.Integer.MAX_VALUE, identifier); 337 case 3059181: /*code*/ return new Property("code", "CodeableConcept", "A code (or set of codes) that specify the product or service that is identified by this formulary item.", 0, 1, code); 338 case -892481550: /*status*/ return new Property("status", "code", "The validity about the information of the formulary item and not of the underlying product or service itself.", 0, 1, status); 339 default: return super.getNamedProperty(_hash, _name, _checkValid); 340 } 341 342 } 343 344 @Override 345 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 346 switch (hash) { 347 case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier 348 case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept 349 case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<FormularyItemStatusCodes> 350 default: return super.getProperty(hash, name, checkValid); 351 } 352 353 } 354 355 @Override 356 public Base setProperty(int hash, String name, Base value) throws FHIRException { 357 switch (hash) { 358 case -1618432855: // identifier 359 this.getIdentifier().add(TypeConvertor.castToIdentifier(value)); // Identifier 360 return value; 361 case 3059181: // code 362 this.code = TypeConvertor.castToCodeableConcept(value); // CodeableConcept 363 return value; 364 case -892481550: // status 365 value = new FormularyItemStatusCodesEnumFactory().fromType(TypeConvertor.castToCode(value)); 366 this.status = (Enumeration) value; // Enumeration<FormularyItemStatusCodes> 367 return value; 368 default: return super.setProperty(hash, name, value); 369 } 370 371 } 372 373 @Override 374 public Base setProperty(String name, Base value) throws FHIRException { 375 if (name.equals("identifier")) { 376 this.getIdentifier().add(TypeConvertor.castToIdentifier(value)); 377 } else if (name.equals("code")) { 378 this.code = TypeConvertor.castToCodeableConcept(value); // CodeableConcept 379 } else if (name.equals("status")) { 380 value = new FormularyItemStatusCodesEnumFactory().fromType(TypeConvertor.castToCode(value)); 381 this.status = (Enumeration) value; // Enumeration<FormularyItemStatusCodes> 382 } else 383 return super.setProperty(name, value); 384 return value; 385 } 386 387 @Override 388 public Base makeProperty(int hash, String name) throws FHIRException { 389 switch (hash) { 390 case -1618432855: return addIdentifier(); 391 case 3059181: return getCode(); 392 case -892481550: return getStatusElement(); 393 default: return super.makeProperty(hash, name); 394 } 395 396 } 397 398 @Override 399 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 400 switch (hash) { 401 case -1618432855: /*identifier*/ return new String[] {"Identifier"}; 402 case 3059181: /*code*/ return new String[] {"CodeableConcept"}; 403 case -892481550: /*status*/ return new String[] {"code"}; 404 default: return super.getTypesForProperty(hash, name); 405 } 406 407 } 408 409 @Override 410 public Base addChild(String name) throws FHIRException { 411 if (name.equals("identifier")) { 412 return addIdentifier(); 413 } 414 else if (name.equals("code")) { 415 this.code = new CodeableConcept(); 416 return this.code; 417 } 418 else if (name.equals("status")) { 419 throw new FHIRException("Cannot call addChild on a singleton property FormularyItem.status"); 420 } 421 else 422 return super.addChild(name); 423 } 424 425 public String fhirType() { 426 return "FormularyItem"; 427 428 } 429 430 public FormularyItem copy() { 431 FormularyItem dst = new FormularyItem(); 432 copyValues(dst); 433 return dst; 434 } 435 436 public void copyValues(FormularyItem dst) { 437 super.copyValues(dst); 438 if (identifier != null) { 439 dst.identifier = new ArrayList<Identifier>(); 440 for (Identifier i : identifier) 441 dst.identifier.add(i.copy()); 442 }; 443 dst.code = code == null ? null : code.copy(); 444 dst.status = status == null ? null : status.copy(); 445 } 446 447 protected FormularyItem typedCopy() { 448 return copy(); 449 } 450 451 @Override 452 public boolean equalsDeep(Base other_) { 453 if (!super.equalsDeep(other_)) 454 return false; 455 if (!(other_ instanceof FormularyItem)) 456 return false; 457 FormularyItem o = (FormularyItem) other_; 458 return compareDeep(identifier, o.identifier, true) && compareDeep(code, o.code, true) && compareDeep(status, o.status, true) 459 ; 460 } 461 462 @Override 463 public boolean equalsShallow(Base other_) { 464 if (!super.equalsShallow(other_)) 465 return false; 466 if (!(other_ instanceof FormularyItem)) 467 return false; 468 FormularyItem o = (FormularyItem) other_; 469 return compareValues(status, o.status, true); 470 } 471 472 public boolean isEmpty() { 473 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, code, status 474 ); 475 } 476 477 @Override 478 public ResourceType getResourceType() { 479 return ResourceType.FormularyItem; 480 } 481 482 /** 483 * Search parameter: <b>code</b> 484 * <p> 485 * Description: <b>Returns formulary items for a specific code</b><br> 486 * Type: <b>token</b><br> 487 * Path: <b>FormularyItem.code</b><br> 488 * </p> 489 */ 490 @SearchParamDefinition(name="code", path="FormularyItem.code", description="Returns formulary items for a specific code", type="token" ) 491 public static final String SP_CODE = "code"; 492 /** 493 * <b>Fluent Client</b> search parameter constant for <b>code</b> 494 * <p> 495 * Description: <b>Returns formulary items for a specific code</b><br> 496 * Type: <b>token</b><br> 497 * Path: <b>FormularyItem.code</b><br> 498 * </p> 499 */ 500 public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE); 501 502 /** 503 * Search parameter: <b>identifier</b> 504 * <p> 505 * Description: <b>Returns formulary items with this external identifier</b><br> 506 * Type: <b>token</b><br> 507 * Path: <b>FormularyItem.identifier</b><br> 508 * </p> 509 */ 510 @SearchParamDefinition(name="identifier", path="FormularyItem.identifier", description="Returns formulary items with this external identifier", type="token" ) 511 public static final String SP_IDENTIFIER = "identifier"; 512 /** 513 * <b>Fluent Client</b> search parameter constant for <b>identifier</b> 514 * <p> 515 * Description: <b>Returns formulary items with this external identifier</b><br> 516 * Type: <b>token</b><br> 517 * Path: <b>FormularyItem.identifier</b><br> 518 * </p> 519 */ 520 public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER); 521 522 523} 524