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 * functional description of an inventory item used in inventory and supply-related workflows.
052 */
053@ResourceDef(name="InventoryItem", profile="http://hl7.org/fhir/StructureDefinition/InventoryItem")
054public class InventoryItem extends DomainResource {
055
056    public enum InventoryItemStatusCodes {
057        /**
058         * The item is active and can be referenced.
059         */
060        ACTIVE, 
061        /**
062         * The item is presently inactive - there may be references to it but the item is not expected to be used.
063         */
064        INACTIVE, 
065        /**
066         * The item record was entered in error.
067         */
068        ENTEREDINERROR, 
069        /**
070         * The item status has not been determined.
071         */
072        UNKNOWN, 
073        /**
074         * added to help the parsers with the generic types
075         */
076        NULL;
077        public static InventoryItemStatusCodes fromCode(String codeString) throws FHIRException {
078            if (codeString == null || "".equals(codeString))
079                return null;
080        if ("active".equals(codeString))
081          return ACTIVE;
082        if ("inactive".equals(codeString))
083          return INACTIVE;
084        if ("entered-in-error".equals(codeString))
085          return ENTEREDINERROR;
086        if ("unknown".equals(codeString))
087          return UNKNOWN;
088        if (Configuration.isAcceptInvalidEnums())
089          return null;
090        else
091          throw new FHIRException("Unknown InventoryItemStatusCodes code '"+codeString+"'");
092        }
093        public String toCode() {
094          switch (this) {
095            case ACTIVE: return "active";
096            case INACTIVE: return "inactive";
097            case ENTEREDINERROR: return "entered-in-error";
098            case UNKNOWN: return "unknown";
099            case NULL: return null;
100            default: return "?";
101          }
102        }
103        public String getSystem() {
104          switch (this) {
105            case ACTIVE: return "http://hl7.org/fhir/inventoryitem-status";
106            case INACTIVE: return "http://hl7.org/fhir/inventoryitem-status";
107            case ENTEREDINERROR: return "http://hl7.org/fhir/inventoryitem-status";
108            case UNKNOWN: return "http://hl7.org/fhir/inventoryitem-status";
109            case NULL: return null;
110            default: return "?";
111          }
112        }
113        public String getDefinition() {
114          switch (this) {
115            case ACTIVE: return "The item is active and can be referenced.";
116            case INACTIVE: return "The item is presently inactive - there may be references to it but the item is not expected to be used.";
117            case ENTEREDINERROR: return "The item record was entered in error.";
118            case UNKNOWN: return "The item status has not been determined.";
119            case NULL: return null;
120            default: return "?";
121          }
122        }
123        public String getDisplay() {
124          switch (this) {
125            case ACTIVE: return "Active";
126            case INACTIVE: return "Inactive";
127            case ENTEREDINERROR: return "Entered in Error";
128            case UNKNOWN: return "Unknown";
129            case NULL: return null;
130            default: return "?";
131          }
132        }
133    }
134
135  public static class InventoryItemStatusCodesEnumFactory implements EnumFactory<InventoryItemStatusCodes> {
136    public InventoryItemStatusCodes fromCode(String codeString) throws IllegalArgumentException {
137      if (codeString == null || "".equals(codeString))
138            if (codeString == null || "".equals(codeString))
139                return null;
140        if ("active".equals(codeString))
141          return InventoryItemStatusCodes.ACTIVE;
142        if ("inactive".equals(codeString))
143          return InventoryItemStatusCodes.INACTIVE;
144        if ("entered-in-error".equals(codeString))
145          return InventoryItemStatusCodes.ENTEREDINERROR;
146        if ("unknown".equals(codeString))
147          return InventoryItemStatusCodes.UNKNOWN;
148        throw new IllegalArgumentException("Unknown InventoryItemStatusCodes code '"+codeString+"'");
149        }
150        public Enumeration<InventoryItemStatusCodes> fromType(PrimitiveType<?> code) throws FHIRException {
151          if (code == null)
152            return null;
153          if (code.isEmpty())
154            return new Enumeration<InventoryItemStatusCodes>(this, InventoryItemStatusCodes.NULL, code);
155          String codeString = ((PrimitiveType) code).asStringValue();
156          if (codeString == null || "".equals(codeString))
157            return new Enumeration<InventoryItemStatusCodes>(this, InventoryItemStatusCodes.NULL, code);
158        if ("active".equals(codeString))
159          return new Enumeration<InventoryItemStatusCodes>(this, InventoryItemStatusCodes.ACTIVE, code);
160        if ("inactive".equals(codeString))
161          return new Enumeration<InventoryItemStatusCodes>(this, InventoryItemStatusCodes.INACTIVE, code);
162        if ("entered-in-error".equals(codeString))
163          return new Enumeration<InventoryItemStatusCodes>(this, InventoryItemStatusCodes.ENTEREDINERROR, code);
164        if ("unknown".equals(codeString))
165          return new Enumeration<InventoryItemStatusCodes>(this, InventoryItemStatusCodes.UNKNOWN, code);
166        throw new FHIRException("Unknown InventoryItemStatusCodes code '"+codeString+"'");
167        }
168    public String toCode(InventoryItemStatusCodes code) {
169      if (code == InventoryItemStatusCodes.ACTIVE)
170        return "active";
171      if (code == InventoryItemStatusCodes.INACTIVE)
172        return "inactive";
173      if (code == InventoryItemStatusCodes.ENTEREDINERROR)
174        return "entered-in-error";
175      if (code == InventoryItemStatusCodes.UNKNOWN)
176        return "unknown";
177      return "?";
178      }
179    public String toSystem(InventoryItemStatusCodes code) {
180      return code.getSystem();
181      }
182    }
183
184    @Block()
185    public static class InventoryItemNameComponent extends BackboneElement implements IBaseBackboneElement {
186        /**
187         * The type of name e.g. 'brand-name', 'functional-name', 'common-name'.
188         */
189        @Child(name = "nameType", type = {Coding.class}, order=1, min=1, max=1, modifier=false, summary=true)
190        @Description(shortDefinition="The type of name e.g. 'brand-name', 'functional-name', 'common-name'", formalDefinition="The type of name e.g. 'brand-name', 'functional-name', 'common-name'." )
191        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/inventoryitem-nametype")
192        protected Coding nameType;
193
194        /**
195         * The language that the item name is expressed in.
196         */
197        @Child(name = "language", type = {CodeType.class}, order=2, min=1, max=1, modifier=false, summary=true)
198        @Description(shortDefinition="The language used to express the item name", formalDefinition="The language that the item name is expressed in." )
199        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/languages")
200        protected Enumeration<CommonLanguages> language;
201
202        /**
203         * The name or designation that the item is given.
204         */
205        @Child(name = "name", type = {StringType.class}, order=3, min=1, max=1, modifier=false, summary=true)
206        @Description(shortDefinition="The name or designation of the item", formalDefinition="The name or designation that the item is given." )
207        protected StringType name;
208
209        private static final long serialVersionUID = 2074178414L;
210
211    /**
212     * Constructor
213     */
214      public InventoryItemNameComponent() {
215        super();
216      }
217
218    /**
219     * Constructor
220     */
221      public InventoryItemNameComponent(Coding nameType, CommonLanguages language, String name) {
222        super();
223        this.setNameType(nameType);
224        this.setLanguage(language);
225        this.setName(name);
226      }
227
228        /**
229         * @return {@link #nameType} (The type of name e.g. 'brand-name', 'functional-name', 'common-name'.)
230         */
231        public Coding getNameType() { 
232          if (this.nameType == null)
233            if (Configuration.errorOnAutoCreate())
234              throw new Error("Attempt to auto-create InventoryItemNameComponent.nameType");
235            else if (Configuration.doAutoCreate())
236              this.nameType = new Coding(); // cc
237          return this.nameType;
238        }
239
240        public boolean hasNameType() { 
241          return this.nameType != null && !this.nameType.isEmpty();
242        }
243
244        /**
245         * @param value {@link #nameType} (The type of name e.g. 'brand-name', 'functional-name', 'common-name'.)
246         */
247        public InventoryItemNameComponent setNameType(Coding value) { 
248          this.nameType = value;
249          return this;
250        }
251
252        /**
253         * @return {@link #language} (The language that the item name is expressed in.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value
254         */
255        public Enumeration<CommonLanguages> getLanguageElement() { 
256          if (this.language == null)
257            if (Configuration.errorOnAutoCreate())
258              throw new Error("Attempt to auto-create InventoryItemNameComponent.language");
259            else if (Configuration.doAutoCreate())
260              this.language = new Enumeration<CommonLanguages>(new CommonLanguagesEnumFactory()); // bb
261          return this.language;
262        }
263
264        public boolean hasLanguageElement() { 
265          return this.language != null && !this.language.isEmpty();
266        }
267
268        public boolean hasLanguage() { 
269          return this.language != null && !this.language.isEmpty();
270        }
271
272        /**
273         * @param value {@link #language} (The language that the item name is expressed in.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value
274         */
275        public InventoryItemNameComponent setLanguageElement(Enumeration<CommonLanguages> value) { 
276          this.language = value;
277          return this;
278        }
279
280        /**
281         * @return The language that the item name is expressed in.
282         */
283        public CommonLanguages getLanguage() { 
284          return this.language == null ? null : this.language.getValue();
285        }
286
287        /**
288         * @param value The language that the item name is expressed in.
289         */
290        public InventoryItemNameComponent setLanguage(CommonLanguages value) { 
291            if (this.language == null)
292              this.language = new Enumeration<CommonLanguages>(new CommonLanguagesEnumFactory());
293            this.language.setValue(value);
294          return this;
295        }
296
297        /**
298         * @return {@link #name} (The name or designation that the item is given.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
299         */
300        public StringType getNameElement() { 
301          if (this.name == null)
302            if (Configuration.errorOnAutoCreate())
303              throw new Error("Attempt to auto-create InventoryItemNameComponent.name");
304            else if (Configuration.doAutoCreate())
305              this.name = new StringType(); // bb
306          return this.name;
307        }
308
309        public boolean hasNameElement() { 
310          return this.name != null && !this.name.isEmpty();
311        }
312
313        public boolean hasName() { 
314          return this.name != null && !this.name.isEmpty();
315        }
316
317        /**
318         * @param value {@link #name} (The name or designation that the item is given.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
319         */
320        public InventoryItemNameComponent setNameElement(StringType value) { 
321          this.name = value;
322          return this;
323        }
324
325        /**
326         * @return The name or designation that the item is given.
327         */
328        public String getName() { 
329          return this.name == null ? null : this.name.getValue();
330        }
331
332        /**
333         * @param value The name or designation that the item is given.
334         */
335        public InventoryItemNameComponent setName(String value) { 
336            if (this.name == null)
337              this.name = new StringType();
338            this.name.setValue(value);
339          return this;
340        }
341
342        protected void listChildren(List<Property> children) {
343          super.listChildren(children);
344          children.add(new Property("nameType", "Coding", "The type of name e.g. 'brand-name', 'functional-name', 'common-name'.", 0, 1, nameType));
345          children.add(new Property("language", "code", "The language that the item name is expressed in.", 0, 1, language));
346          children.add(new Property("name", "string", "The name or designation that the item is given.", 0, 1, name));
347        }
348
349        @Override
350        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
351          switch (_hash) {
352          case 1840595045: /*nameType*/  return new Property("nameType", "Coding", "The type of name e.g. 'brand-name', 'functional-name', 'common-name'.", 0, 1, nameType);
353          case -1613589672: /*language*/  return new Property("language", "code", "The language that the item name is expressed in.", 0, 1, language);
354          case 3373707: /*name*/  return new Property("name", "string", "The name or designation that the item is given.", 0, 1, name);
355          default: return super.getNamedProperty(_hash, _name, _checkValid);
356          }
357
358        }
359
360      @Override
361      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
362        switch (hash) {
363        case 1840595045: /*nameType*/ return this.nameType == null ? new Base[0] : new Base[] {this.nameType}; // Coding
364        case -1613589672: /*language*/ return this.language == null ? new Base[0] : new Base[] {this.language}; // Enumeration<CommonLanguages>
365        case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // StringType
366        default: return super.getProperty(hash, name, checkValid);
367        }
368
369      }
370
371      @Override
372      public Base setProperty(int hash, String name, Base value) throws FHIRException {
373        switch (hash) {
374        case 1840595045: // nameType
375          this.nameType = TypeConvertor.castToCoding(value); // Coding
376          return value;
377        case -1613589672: // language
378          value = new CommonLanguagesEnumFactory().fromType(TypeConvertor.castToCode(value));
379          this.language = (Enumeration) value; // Enumeration<CommonLanguages>
380          return value;
381        case 3373707: // name
382          this.name = TypeConvertor.castToString(value); // StringType
383          return value;
384        default: return super.setProperty(hash, name, value);
385        }
386
387      }
388
389      @Override
390      public Base setProperty(String name, Base value) throws FHIRException {
391        if (name.equals("nameType")) {
392          this.nameType = TypeConvertor.castToCoding(value); // Coding
393        } else if (name.equals("language")) {
394          value = new CommonLanguagesEnumFactory().fromType(TypeConvertor.castToCode(value));
395          this.language = (Enumeration) value; // Enumeration<CommonLanguages>
396        } else if (name.equals("name")) {
397          this.name = TypeConvertor.castToString(value); // StringType
398        } else
399          return super.setProperty(name, value);
400        return value;
401      }
402
403  @Override
404  public void removeChild(String name, Base value) throws FHIRException {
405        if (name.equals("nameType")) {
406          this.nameType = null;
407        } else if (name.equals("language")) {
408          value = new CommonLanguagesEnumFactory().fromType(TypeConvertor.castToCode(value));
409          this.language = (Enumeration) value; // Enumeration<CommonLanguages>
410        } else if (name.equals("name")) {
411          this.name = null;
412        } else
413          super.removeChild(name, value);
414        
415      }
416
417      @Override
418      public Base makeProperty(int hash, String name) throws FHIRException {
419        switch (hash) {
420        case 1840595045:  return getNameType();
421        case -1613589672:  return getLanguageElement();
422        case 3373707:  return getNameElement();
423        default: return super.makeProperty(hash, name);
424        }
425
426      }
427
428      @Override
429      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
430        switch (hash) {
431        case 1840595045: /*nameType*/ return new String[] {"Coding"};
432        case -1613589672: /*language*/ return new String[] {"code"};
433        case 3373707: /*name*/ return new String[] {"string"};
434        default: return super.getTypesForProperty(hash, name);
435        }
436
437      }
438
439      @Override
440      public Base addChild(String name) throws FHIRException {
441        if (name.equals("nameType")) {
442          this.nameType = new Coding();
443          return this.nameType;
444        }
445        else if (name.equals("language")) {
446          throw new FHIRException("Cannot call addChild on a singleton property InventoryItem.name.language");
447        }
448        else if (name.equals("name")) {
449          throw new FHIRException("Cannot call addChild on a singleton property InventoryItem.name.name");
450        }
451        else
452          return super.addChild(name);
453      }
454
455      public InventoryItemNameComponent copy() {
456        InventoryItemNameComponent dst = new InventoryItemNameComponent();
457        copyValues(dst);
458        return dst;
459      }
460
461      public void copyValues(InventoryItemNameComponent dst) {
462        super.copyValues(dst);
463        dst.nameType = nameType == null ? null : nameType.copy();
464        dst.language = language == null ? null : language.copy();
465        dst.name = name == null ? null : name.copy();
466      }
467
468      @Override
469      public boolean equalsDeep(Base other_) {
470        if (!super.equalsDeep(other_))
471          return false;
472        if (!(other_ instanceof InventoryItemNameComponent))
473          return false;
474        InventoryItemNameComponent o = (InventoryItemNameComponent) other_;
475        return compareDeep(nameType, o.nameType, true) && compareDeep(language, o.language, true) && compareDeep(name, o.name, true)
476          ;
477      }
478
479      @Override
480      public boolean equalsShallow(Base other_) {
481        if (!super.equalsShallow(other_))
482          return false;
483        if (!(other_ instanceof InventoryItemNameComponent))
484          return false;
485        InventoryItemNameComponent o = (InventoryItemNameComponent) other_;
486        return compareValues(language, o.language, true) && compareValues(name, o.name, true);
487      }
488
489      public boolean isEmpty() {
490        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(nameType, language, name
491          );
492      }
493
494  public String fhirType() {
495    return "InventoryItem.name";
496
497  }
498
499  }
500
501    @Block()
502    public static class InventoryItemResponsibleOrganizationComponent extends BackboneElement implements IBaseBackboneElement {
503        /**
504         * The role of the organization e.g. manufacturer, distributor, etc.
505         */
506        @Child(name = "role", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=false)
507        @Description(shortDefinition="The role of the organization e.g. manufacturer, distributor, or other", formalDefinition="The role of the organization e.g. manufacturer, distributor, etc." )
508        protected CodeableConcept role;
509
510        /**
511         * An organization that has an association with the item, e.g. manufacturer, distributor, responsible, etc.
512         */
513        @Child(name = "organization", type = {Organization.class}, order=2, min=1, max=1, modifier=false, summary=false)
514        @Description(shortDefinition="An organization that is associated with the item", formalDefinition="An organization that has an association with the item, e.g. manufacturer, distributor, responsible, etc." )
515        protected Reference organization;
516
517        private static final long serialVersionUID = -575091539L;
518
519    /**
520     * Constructor
521     */
522      public InventoryItemResponsibleOrganizationComponent() {
523        super();
524      }
525
526    /**
527     * Constructor
528     */
529      public InventoryItemResponsibleOrganizationComponent(CodeableConcept role, Reference organization) {
530        super();
531        this.setRole(role);
532        this.setOrganization(organization);
533      }
534
535        /**
536         * @return {@link #role} (The role of the organization e.g. manufacturer, distributor, etc.)
537         */
538        public CodeableConcept getRole() { 
539          if (this.role == null)
540            if (Configuration.errorOnAutoCreate())
541              throw new Error("Attempt to auto-create InventoryItemResponsibleOrganizationComponent.role");
542            else if (Configuration.doAutoCreate())
543              this.role = new CodeableConcept(); // cc
544          return this.role;
545        }
546
547        public boolean hasRole() { 
548          return this.role != null && !this.role.isEmpty();
549        }
550
551        /**
552         * @param value {@link #role} (The role of the organization e.g. manufacturer, distributor, etc.)
553         */
554        public InventoryItemResponsibleOrganizationComponent setRole(CodeableConcept value) { 
555          this.role = value;
556          return this;
557        }
558
559        /**
560         * @return {@link #organization} (An organization that has an association with the item, e.g. manufacturer, distributor, responsible, etc.)
561         */
562        public Reference getOrganization() { 
563          if (this.organization == null)
564            if (Configuration.errorOnAutoCreate())
565              throw new Error("Attempt to auto-create InventoryItemResponsibleOrganizationComponent.organization");
566            else if (Configuration.doAutoCreate())
567              this.organization = new Reference(); // cc
568          return this.organization;
569        }
570
571        public boolean hasOrganization() { 
572          return this.organization != null && !this.organization.isEmpty();
573        }
574
575        /**
576         * @param value {@link #organization} (An organization that has an association with the item, e.g. manufacturer, distributor, responsible, etc.)
577         */
578        public InventoryItemResponsibleOrganizationComponent setOrganization(Reference value) { 
579          this.organization = value;
580          return this;
581        }
582
583        protected void listChildren(List<Property> children) {
584          super.listChildren(children);
585          children.add(new Property("role", "CodeableConcept", "The role of the organization e.g. manufacturer, distributor, etc.", 0, 1, role));
586          children.add(new Property("organization", "Reference(Organization)", "An organization that has an association with the item, e.g. manufacturer, distributor, responsible, etc.", 0, 1, organization));
587        }
588
589        @Override
590        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
591          switch (_hash) {
592          case 3506294: /*role*/  return new Property("role", "CodeableConcept", "The role of the organization e.g. manufacturer, distributor, etc.", 0, 1, role);
593          case 1178922291: /*organization*/  return new Property("organization", "Reference(Organization)", "An organization that has an association with the item, e.g. manufacturer, distributor, responsible, etc.", 0, 1, organization);
594          default: return super.getNamedProperty(_hash, _name, _checkValid);
595          }
596
597        }
598
599      @Override
600      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
601        switch (hash) {
602        case 3506294: /*role*/ return this.role == null ? new Base[0] : new Base[] {this.role}; // CodeableConcept
603        case 1178922291: /*organization*/ return this.organization == null ? new Base[0] : new Base[] {this.organization}; // Reference
604        default: return super.getProperty(hash, name, checkValid);
605        }
606
607      }
608
609      @Override
610      public Base setProperty(int hash, String name, Base value) throws FHIRException {
611        switch (hash) {
612        case 3506294: // role
613          this.role = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
614          return value;
615        case 1178922291: // organization
616          this.organization = TypeConvertor.castToReference(value); // Reference
617          return value;
618        default: return super.setProperty(hash, name, value);
619        }
620
621      }
622
623      @Override
624      public Base setProperty(String name, Base value) throws FHIRException {
625        if (name.equals("role")) {
626          this.role = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
627        } else if (name.equals("organization")) {
628          this.organization = TypeConvertor.castToReference(value); // Reference
629        } else
630          return super.setProperty(name, value);
631        return value;
632      }
633
634  @Override
635  public void removeChild(String name, Base value) throws FHIRException {
636        if (name.equals("role")) {
637          this.role = null;
638        } else if (name.equals("organization")) {
639          this.organization = null;
640        } else
641          super.removeChild(name, value);
642        
643      }
644
645      @Override
646      public Base makeProperty(int hash, String name) throws FHIRException {
647        switch (hash) {
648        case 3506294:  return getRole();
649        case 1178922291:  return getOrganization();
650        default: return super.makeProperty(hash, name);
651        }
652
653      }
654
655      @Override
656      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
657        switch (hash) {
658        case 3506294: /*role*/ return new String[] {"CodeableConcept"};
659        case 1178922291: /*organization*/ return new String[] {"Reference"};
660        default: return super.getTypesForProperty(hash, name);
661        }
662
663      }
664
665      @Override
666      public Base addChild(String name) throws FHIRException {
667        if (name.equals("role")) {
668          this.role = new CodeableConcept();
669          return this.role;
670        }
671        else if (name.equals("organization")) {
672          this.organization = new Reference();
673          return this.organization;
674        }
675        else
676          return super.addChild(name);
677      }
678
679      public InventoryItemResponsibleOrganizationComponent copy() {
680        InventoryItemResponsibleOrganizationComponent dst = new InventoryItemResponsibleOrganizationComponent();
681        copyValues(dst);
682        return dst;
683      }
684
685      public void copyValues(InventoryItemResponsibleOrganizationComponent dst) {
686        super.copyValues(dst);
687        dst.role = role == null ? null : role.copy();
688        dst.organization = organization == null ? null : organization.copy();
689      }
690
691      @Override
692      public boolean equalsDeep(Base other_) {
693        if (!super.equalsDeep(other_))
694          return false;
695        if (!(other_ instanceof InventoryItemResponsibleOrganizationComponent))
696          return false;
697        InventoryItemResponsibleOrganizationComponent o = (InventoryItemResponsibleOrganizationComponent) other_;
698        return compareDeep(role, o.role, true) && compareDeep(organization, o.organization, true);
699      }
700
701      @Override
702      public boolean equalsShallow(Base other_) {
703        if (!super.equalsShallow(other_))
704          return false;
705        if (!(other_ instanceof InventoryItemResponsibleOrganizationComponent))
706          return false;
707        InventoryItemResponsibleOrganizationComponent o = (InventoryItemResponsibleOrganizationComponent) other_;
708        return true;
709      }
710
711      public boolean isEmpty() {
712        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(role, organization);
713      }
714
715  public String fhirType() {
716    return "InventoryItem.responsibleOrganization";
717
718  }
719
720  }
721
722    @Block()
723    public static class InventoryItemDescriptionComponent extends BackboneElement implements IBaseBackboneElement {
724        /**
725         * The language for the item description, when an item must be described in different languages and those languages may be authoritative and not translations of a 'main' language.
726         */
727        @Child(name = "language", type = {CodeType.class}, order=1, min=0, max=1, modifier=false, summary=false)
728        @Description(shortDefinition="The language that is used in the item description", formalDefinition="The language for the item description, when an item must be described in different languages and those languages may be authoritative and not translations of a 'main' language." )
729        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/languages")
730        protected Enumeration<CommonLanguages> language;
731
732        /**
733         * Textual description of the item.
734         */
735        @Child(name = "description", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=false)
736        @Description(shortDefinition="Textual description of the item", formalDefinition="Textual description of the item." )
737        protected StringType description;
738
739        private static final long serialVersionUID = -803271414L;
740
741    /**
742     * Constructor
743     */
744      public InventoryItemDescriptionComponent() {
745        super();
746      }
747
748        /**
749         * @return {@link #language} (The language for the item description, when an item must be described in different languages and those languages may be authoritative and not translations of a 'main' language.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value
750         */
751        public Enumeration<CommonLanguages> getLanguageElement() { 
752          if (this.language == null)
753            if (Configuration.errorOnAutoCreate())
754              throw new Error("Attempt to auto-create InventoryItemDescriptionComponent.language");
755            else if (Configuration.doAutoCreate())
756              this.language = new Enumeration<CommonLanguages>(new CommonLanguagesEnumFactory()); // bb
757          return this.language;
758        }
759
760        public boolean hasLanguageElement() { 
761          return this.language != null && !this.language.isEmpty();
762        }
763
764        public boolean hasLanguage() { 
765          return this.language != null && !this.language.isEmpty();
766        }
767
768        /**
769         * @param value {@link #language} (The language for the item description, when an item must be described in different languages and those languages may be authoritative and not translations of a 'main' language.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value
770         */
771        public InventoryItemDescriptionComponent setLanguageElement(Enumeration<CommonLanguages> value) { 
772          this.language = value;
773          return this;
774        }
775
776        /**
777         * @return The language for the item description, when an item must be described in different languages and those languages may be authoritative and not translations of a 'main' language.
778         */
779        public CommonLanguages getLanguage() { 
780          return this.language == null ? null : this.language.getValue();
781        }
782
783        /**
784         * @param value The language for the item description, when an item must be described in different languages and those languages may be authoritative and not translations of a 'main' language.
785         */
786        public InventoryItemDescriptionComponent setLanguage(CommonLanguages value) { 
787          if (value == null)
788            this.language = null;
789          else {
790            if (this.language == null)
791              this.language = new Enumeration<CommonLanguages>(new CommonLanguagesEnumFactory());
792            this.language.setValue(value);
793          }
794          return this;
795        }
796
797        /**
798         * @return {@link #description} (Textual description of the item.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
799         */
800        public StringType getDescriptionElement() { 
801          if (this.description == null)
802            if (Configuration.errorOnAutoCreate())
803              throw new Error("Attempt to auto-create InventoryItemDescriptionComponent.description");
804            else if (Configuration.doAutoCreate())
805              this.description = new StringType(); // bb
806          return this.description;
807        }
808
809        public boolean hasDescriptionElement() { 
810          return this.description != null && !this.description.isEmpty();
811        }
812
813        public boolean hasDescription() { 
814          return this.description != null && !this.description.isEmpty();
815        }
816
817        /**
818         * @param value {@link #description} (Textual description of the item.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
819         */
820        public InventoryItemDescriptionComponent setDescriptionElement(StringType value) { 
821          this.description = value;
822          return this;
823        }
824
825        /**
826         * @return Textual description of the item.
827         */
828        public String getDescription() { 
829          return this.description == null ? null : this.description.getValue();
830        }
831
832        /**
833         * @param value Textual description of the item.
834         */
835        public InventoryItemDescriptionComponent setDescription(String value) { 
836          if (Utilities.noString(value))
837            this.description = null;
838          else {
839            if (this.description == null)
840              this.description = new StringType();
841            this.description.setValue(value);
842          }
843          return this;
844        }
845
846        protected void listChildren(List<Property> children) {
847          super.listChildren(children);
848          children.add(new Property("language", "code", "The language for the item description, when an item must be described in different languages and those languages may be authoritative and not translations of a 'main' language.", 0, 1, language));
849          children.add(new Property("description", "string", "Textual description of the item.", 0, 1, description));
850        }
851
852        @Override
853        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
854          switch (_hash) {
855          case -1613589672: /*language*/  return new Property("language", "code", "The language for the item description, when an item must be described in different languages and those languages may be authoritative and not translations of a 'main' language.", 0, 1, language);
856          case -1724546052: /*description*/  return new Property("description", "string", "Textual description of the item.", 0, 1, description);
857          default: return super.getNamedProperty(_hash, _name, _checkValid);
858          }
859
860        }
861
862      @Override
863      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
864        switch (hash) {
865        case -1613589672: /*language*/ return this.language == null ? new Base[0] : new Base[] {this.language}; // Enumeration<CommonLanguages>
866        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
867        default: return super.getProperty(hash, name, checkValid);
868        }
869
870      }
871
872      @Override
873      public Base setProperty(int hash, String name, Base value) throws FHIRException {
874        switch (hash) {
875        case -1613589672: // language
876          value = new CommonLanguagesEnumFactory().fromType(TypeConvertor.castToCode(value));
877          this.language = (Enumeration) value; // Enumeration<CommonLanguages>
878          return value;
879        case -1724546052: // description
880          this.description = TypeConvertor.castToString(value); // StringType
881          return value;
882        default: return super.setProperty(hash, name, value);
883        }
884
885      }
886
887      @Override
888      public Base setProperty(String name, Base value) throws FHIRException {
889        if (name.equals("language")) {
890          value = new CommonLanguagesEnumFactory().fromType(TypeConvertor.castToCode(value));
891          this.language = (Enumeration) value; // Enumeration<CommonLanguages>
892        } else if (name.equals("description")) {
893          this.description = TypeConvertor.castToString(value); // StringType
894        } else
895          return super.setProperty(name, value);
896        return value;
897      }
898
899  @Override
900  public void removeChild(String name, Base value) throws FHIRException {
901        if (name.equals("language")) {
902          value = new CommonLanguagesEnumFactory().fromType(TypeConvertor.castToCode(value));
903          this.language = (Enumeration) value; // Enumeration<CommonLanguages>
904        } else if (name.equals("description")) {
905          this.description = null;
906        } else
907          super.removeChild(name, value);
908        
909      }
910
911      @Override
912      public Base makeProperty(int hash, String name) throws FHIRException {
913        switch (hash) {
914        case -1613589672:  return getLanguageElement();
915        case -1724546052:  return getDescriptionElement();
916        default: return super.makeProperty(hash, name);
917        }
918
919      }
920
921      @Override
922      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
923        switch (hash) {
924        case -1613589672: /*language*/ return new String[] {"code"};
925        case -1724546052: /*description*/ return new String[] {"string"};
926        default: return super.getTypesForProperty(hash, name);
927        }
928
929      }
930
931      @Override
932      public Base addChild(String name) throws FHIRException {
933        if (name.equals("language")) {
934          throw new FHIRException("Cannot call addChild on a singleton property InventoryItem.description.language");
935        }
936        else if (name.equals("description")) {
937          throw new FHIRException("Cannot call addChild on a singleton property InventoryItem.description.description");
938        }
939        else
940          return super.addChild(name);
941      }
942
943      public InventoryItemDescriptionComponent copy() {
944        InventoryItemDescriptionComponent dst = new InventoryItemDescriptionComponent();
945        copyValues(dst);
946        return dst;
947      }
948
949      public void copyValues(InventoryItemDescriptionComponent dst) {
950        super.copyValues(dst);
951        dst.language = language == null ? null : language.copy();
952        dst.description = description == null ? null : description.copy();
953      }
954
955      @Override
956      public boolean equalsDeep(Base other_) {
957        if (!super.equalsDeep(other_))
958          return false;
959        if (!(other_ instanceof InventoryItemDescriptionComponent))
960          return false;
961        InventoryItemDescriptionComponent o = (InventoryItemDescriptionComponent) other_;
962        return compareDeep(language, o.language, true) && compareDeep(description, o.description, true)
963          ;
964      }
965
966      @Override
967      public boolean equalsShallow(Base other_) {
968        if (!super.equalsShallow(other_))
969          return false;
970        if (!(other_ instanceof InventoryItemDescriptionComponent))
971          return false;
972        InventoryItemDescriptionComponent o = (InventoryItemDescriptionComponent) other_;
973        return compareValues(language, o.language, true) && compareValues(description, o.description, true)
974          ;
975      }
976
977      public boolean isEmpty() {
978        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(language, description);
979      }
980
981  public String fhirType() {
982    return "InventoryItem.description";
983
984  }
985
986  }
987
988    @Block()
989    public static class InventoryItemAssociationComponent extends BackboneElement implements IBaseBackboneElement {
990        /**
991         * This attribute defined the type of association when establishing associations or relations between items, e.g. 'packaged within' or 'used with' or 'to be mixed with.
992         */
993        @Child(name = "associationType", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=true)
994        @Description(shortDefinition="The type of association between the device and the other item", formalDefinition="This attribute defined the type of association when establishing associations or relations between items, e.g. 'packaged within' or 'used with' or 'to be mixed with." )
995        protected CodeableConcept associationType;
996
997        /**
998         * The related item or product.
999         */
1000        @Child(name = "relatedItem", type = {InventoryItem.class, Medication.class, MedicationKnowledge.class, Device.class, DeviceDefinition.class, NutritionProduct.class, BiologicallyDerivedProduct.class}, order=2, min=1, max=1, modifier=false, summary=true)
1001        @Description(shortDefinition="The related item or product", formalDefinition="The related item or product." )
1002        protected Reference relatedItem;
1003
1004        /**
1005         * The quantity of the related product in this product - Numerator is the quantity of the related product. Denominator is the quantity of the present product. For example a value of 20 means that this product contains 20 units of the related product; a value of 1:20 means the inverse - that the contained product contains 20 units of the present product.
1006         */
1007        @Child(name = "quantity", type = {Ratio.class}, order=3, min=1, max=1, modifier=false, summary=true)
1008        @Description(shortDefinition="The quantity of the product in this product", formalDefinition="The quantity of the related product in this product - Numerator is the quantity of the related product. Denominator is the quantity of the present product. For example a value of 20 means that this product contains 20 units of the related product; a value of 1:20 means the inverse - that the contained product contains 20 units of the present product." )
1009        protected Ratio quantity;
1010
1011        private static final long serialVersionUID = -1001386921L;
1012
1013    /**
1014     * Constructor
1015     */
1016      public InventoryItemAssociationComponent() {
1017        super();
1018      }
1019
1020    /**
1021     * Constructor
1022     */
1023      public InventoryItemAssociationComponent(CodeableConcept associationType, Reference relatedItem, Ratio quantity) {
1024        super();
1025        this.setAssociationType(associationType);
1026        this.setRelatedItem(relatedItem);
1027        this.setQuantity(quantity);
1028      }
1029
1030        /**
1031         * @return {@link #associationType} (This attribute defined the type of association when establishing associations or relations between items, e.g. 'packaged within' or 'used with' or 'to be mixed with.)
1032         */
1033        public CodeableConcept getAssociationType() { 
1034          if (this.associationType == null)
1035            if (Configuration.errorOnAutoCreate())
1036              throw new Error("Attempt to auto-create InventoryItemAssociationComponent.associationType");
1037            else if (Configuration.doAutoCreate())
1038              this.associationType = new CodeableConcept(); // cc
1039          return this.associationType;
1040        }
1041
1042        public boolean hasAssociationType() { 
1043          return this.associationType != null && !this.associationType.isEmpty();
1044        }
1045
1046        /**
1047         * @param value {@link #associationType} (This attribute defined the type of association when establishing associations or relations between items, e.g. 'packaged within' or 'used with' or 'to be mixed with.)
1048         */
1049        public InventoryItemAssociationComponent setAssociationType(CodeableConcept value) { 
1050          this.associationType = value;
1051          return this;
1052        }
1053
1054        /**
1055         * @return {@link #relatedItem} (The related item or product.)
1056         */
1057        public Reference getRelatedItem() { 
1058          if (this.relatedItem == null)
1059            if (Configuration.errorOnAutoCreate())
1060              throw new Error("Attempt to auto-create InventoryItemAssociationComponent.relatedItem");
1061            else if (Configuration.doAutoCreate())
1062              this.relatedItem = new Reference(); // cc
1063          return this.relatedItem;
1064        }
1065
1066        public boolean hasRelatedItem() { 
1067          return this.relatedItem != null && !this.relatedItem.isEmpty();
1068        }
1069
1070        /**
1071         * @param value {@link #relatedItem} (The related item or product.)
1072         */
1073        public InventoryItemAssociationComponent setRelatedItem(Reference value) { 
1074          this.relatedItem = value;
1075          return this;
1076        }
1077
1078        /**
1079         * @return {@link #quantity} (The quantity of the related product in this product - Numerator is the quantity of the related product. Denominator is the quantity of the present product. For example a value of 20 means that this product contains 20 units of the related product; a value of 1:20 means the inverse - that the contained product contains 20 units of the present product.)
1080         */
1081        public Ratio getQuantity() { 
1082          if (this.quantity == null)
1083            if (Configuration.errorOnAutoCreate())
1084              throw new Error("Attempt to auto-create InventoryItemAssociationComponent.quantity");
1085            else if (Configuration.doAutoCreate())
1086              this.quantity = new Ratio(); // cc
1087          return this.quantity;
1088        }
1089
1090        public boolean hasQuantity() { 
1091          return this.quantity != null && !this.quantity.isEmpty();
1092        }
1093
1094        /**
1095         * @param value {@link #quantity} (The quantity of the related product in this product - Numerator is the quantity of the related product. Denominator is the quantity of the present product. For example a value of 20 means that this product contains 20 units of the related product; a value of 1:20 means the inverse - that the contained product contains 20 units of the present product.)
1096         */
1097        public InventoryItemAssociationComponent setQuantity(Ratio value) { 
1098          this.quantity = value;
1099          return this;
1100        }
1101
1102        protected void listChildren(List<Property> children) {
1103          super.listChildren(children);
1104          children.add(new Property("associationType", "CodeableConcept", "This attribute defined the type of association when establishing associations or relations between items, e.g. 'packaged within' or 'used with' or 'to be mixed with.", 0, 1, associationType));
1105          children.add(new Property("relatedItem", "Reference(InventoryItem|Medication|MedicationKnowledge|Device|DeviceDefinition|NutritionProduct|BiologicallyDerivedProduct)", "The related item or product.", 0, 1, relatedItem));
1106          children.add(new Property("quantity", "Ratio", "The quantity of the related product in this product - Numerator is the quantity of the related product. Denominator is the quantity of the present product. For example a value of 20 means that this product contains 20 units of the related product; a value of 1:20 means the inverse - that the contained product contains 20 units of the present product.", 0, 1, quantity));
1107        }
1108
1109        @Override
1110        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1111          switch (_hash) {
1112          case 2050799451: /*associationType*/  return new Property("associationType", "CodeableConcept", "This attribute defined the type of association when establishing associations or relations between items, e.g. 'packaged within' or 'used with' or 'to be mixed with.", 0, 1, associationType);
1113          case 1112702430: /*relatedItem*/  return new Property("relatedItem", "Reference(InventoryItem|Medication|MedicationKnowledge|Device|DeviceDefinition|NutritionProduct|BiologicallyDerivedProduct)", "The related item or product.", 0, 1, relatedItem);
1114          case -1285004149: /*quantity*/  return new Property("quantity", "Ratio", "The quantity of the related product in this product - Numerator is the quantity of the related product. Denominator is the quantity of the present product. For example a value of 20 means that this product contains 20 units of the related product; a value of 1:20 means the inverse - that the contained product contains 20 units of the present product.", 0, 1, quantity);
1115          default: return super.getNamedProperty(_hash, _name, _checkValid);
1116          }
1117
1118        }
1119
1120      @Override
1121      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1122        switch (hash) {
1123        case 2050799451: /*associationType*/ return this.associationType == null ? new Base[0] : new Base[] {this.associationType}; // CodeableConcept
1124        case 1112702430: /*relatedItem*/ return this.relatedItem == null ? new Base[0] : new Base[] {this.relatedItem}; // Reference
1125        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // Ratio
1126        default: return super.getProperty(hash, name, checkValid);
1127        }
1128
1129      }
1130
1131      @Override
1132      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1133        switch (hash) {
1134        case 2050799451: // associationType
1135          this.associationType = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1136          return value;
1137        case 1112702430: // relatedItem
1138          this.relatedItem = TypeConvertor.castToReference(value); // Reference
1139          return value;
1140        case -1285004149: // quantity
1141          this.quantity = TypeConvertor.castToRatio(value); // Ratio
1142          return value;
1143        default: return super.setProperty(hash, name, value);
1144        }
1145
1146      }
1147
1148      @Override
1149      public Base setProperty(String name, Base value) throws FHIRException {
1150        if (name.equals("associationType")) {
1151          this.associationType = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1152        } else if (name.equals("relatedItem")) {
1153          this.relatedItem = TypeConvertor.castToReference(value); // Reference
1154        } else if (name.equals("quantity")) {
1155          this.quantity = TypeConvertor.castToRatio(value); // Ratio
1156        } else
1157          return super.setProperty(name, value);
1158        return value;
1159      }
1160
1161  @Override
1162  public void removeChild(String name, Base value) throws FHIRException {
1163        if (name.equals("associationType")) {
1164          this.associationType = null;
1165        } else if (name.equals("relatedItem")) {
1166          this.relatedItem = null;
1167        } else if (name.equals("quantity")) {
1168          this.quantity = null;
1169        } else
1170          super.removeChild(name, value);
1171        
1172      }
1173
1174      @Override
1175      public Base makeProperty(int hash, String name) throws FHIRException {
1176        switch (hash) {
1177        case 2050799451:  return getAssociationType();
1178        case 1112702430:  return getRelatedItem();
1179        case -1285004149:  return getQuantity();
1180        default: return super.makeProperty(hash, name);
1181        }
1182
1183      }
1184
1185      @Override
1186      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1187        switch (hash) {
1188        case 2050799451: /*associationType*/ return new String[] {"CodeableConcept"};
1189        case 1112702430: /*relatedItem*/ return new String[] {"Reference"};
1190        case -1285004149: /*quantity*/ return new String[] {"Ratio"};
1191        default: return super.getTypesForProperty(hash, name);
1192        }
1193
1194      }
1195
1196      @Override
1197      public Base addChild(String name) throws FHIRException {
1198        if (name.equals("associationType")) {
1199          this.associationType = new CodeableConcept();
1200          return this.associationType;
1201        }
1202        else if (name.equals("relatedItem")) {
1203          this.relatedItem = new Reference();
1204          return this.relatedItem;
1205        }
1206        else if (name.equals("quantity")) {
1207          this.quantity = new Ratio();
1208          return this.quantity;
1209        }
1210        else
1211          return super.addChild(name);
1212      }
1213
1214      public InventoryItemAssociationComponent copy() {
1215        InventoryItemAssociationComponent dst = new InventoryItemAssociationComponent();
1216        copyValues(dst);
1217        return dst;
1218      }
1219
1220      public void copyValues(InventoryItemAssociationComponent dst) {
1221        super.copyValues(dst);
1222        dst.associationType = associationType == null ? null : associationType.copy();
1223        dst.relatedItem = relatedItem == null ? null : relatedItem.copy();
1224        dst.quantity = quantity == null ? null : quantity.copy();
1225      }
1226
1227      @Override
1228      public boolean equalsDeep(Base other_) {
1229        if (!super.equalsDeep(other_))
1230          return false;
1231        if (!(other_ instanceof InventoryItemAssociationComponent))
1232          return false;
1233        InventoryItemAssociationComponent o = (InventoryItemAssociationComponent) other_;
1234        return compareDeep(associationType, o.associationType, true) && compareDeep(relatedItem, o.relatedItem, true)
1235           && compareDeep(quantity, o.quantity, true);
1236      }
1237
1238      @Override
1239      public boolean equalsShallow(Base other_) {
1240        if (!super.equalsShallow(other_))
1241          return false;
1242        if (!(other_ instanceof InventoryItemAssociationComponent))
1243          return false;
1244        InventoryItemAssociationComponent o = (InventoryItemAssociationComponent) other_;
1245        return true;
1246      }
1247
1248      public boolean isEmpty() {
1249        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(associationType, relatedItem
1250          , quantity);
1251      }
1252
1253  public String fhirType() {
1254    return "InventoryItem.association";
1255
1256  }
1257
1258  }
1259
1260    @Block()
1261    public static class InventoryItemCharacteristicComponent extends BackboneElement implements IBaseBackboneElement {
1262        /**
1263         * The type of characteristic that is being defined.
1264         */
1265        @Child(name = "characteristicType", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=false)
1266        @Description(shortDefinition="The characteristic that is being defined", formalDefinition="The type of characteristic that is being defined." )
1267        protected CodeableConcept characteristicType;
1268
1269        /**
1270         * The value of the attribute.
1271         */
1272        @Child(name = "value", type = {StringType.class, IntegerType.class, DecimalType.class, BooleanType.class, UrlType.class, DateTimeType.class, Quantity.class, Range.class, Ratio.class, Annotation.class, Address.class, Duration.class, CodeableConcept.class}, order=2, min=1, max=1, modifier=false, summary=false)
1273        @Description(shortDefinition="The value of the attribute", formalDefinition="The value of the attribute." )
1274        protected DataType value;
1275
1276        private static final long serialVersionUID = -642436065L;
1277
1278    /**
1279     * Constructor
1280     */
1281      public InventoryItemCharacteristicComponent() {
1282        super();
1283      }
1284
1285    /**
1286     * Constructor
1287     */
1288      public InventoryItemCharacteristicComponent(CodeableConcept characteristicType, DataType value) {
1289        super();
1290        this.setCharacteristicType(characteristicType);
1291        this.setValue(value);
1292      }
1293
1294        /**
1295         * @return {@link #characteristicType} (The type of characteristic that is being defined.)
1296         */
1297        public CodeableConcept getCharacteristicType() { 
1298          if (this.characteristicType == null)
1299            if (Configuration.errorOnAutoCreate())
1300              throw new Error("Attempt to auto-create InventoryItemCharacteristicComponent.characteristicType");
1301            else if (Configuration.doAutoCreate())
1302              this.characteristicType = new CodeableConcept(); // cc
1303          return this.characteristicType;
1304        }
1305
1306        public boolean hasCharacteristicType() { 
1307          return this.characteristicType != null && !this.characteristicType.isEmpty();
1308        }
1309
1310        /**
1311         * @param value {@link #characteristicType} (The type of characteristic that is being defined.)
1312         */
1313        public InventoryItemCharacteristicComponent setCharacteristicType(CodeableConcept value) { 
1314          this.characteristicType = value;
1315          return this;
1316        }
1317
1318        /**
1319         * @return {@link #value} (The value of the attribute.)
1320         */
1321        public DataType getValue() { 
1322          return this.value;
1323        }
1324
1325        /**
1326         * @return {@link #value} (The value of the attribute.)
1327         */
1328        public StringType getValueStringType() throws FHIRException { 
1329          if (this.value == null)
1330            this.value = new StringType();
1331          if (!(this.value instanceof StringType))
1332            throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.value.getClass().getName()+" was encountered");
1333          return (StringType) this.value;
1334        }
1335
1336        public boolean hasValueStringType() { 
1337          return this != null && this.value instanceof StringType;
1338        }
1339
1340        /**
1341         * @return {@link #value} (The value of the attribute.)
1342         */
1343        public IntegerType getValueIntegerType() throws FHIRException { 
1344          if (this.value == null)
1345            this.value = new IntegerType();
1346          if (!(this.value instanceof IntegerType))
1347            throw new FHIRException("Type mismatch: the type IntegerType was expected, but "+this.value.getClass().getName()+" was encountered");
1348          return (IntegerType) this.value;
1349        }
1350
1351        public boolean hasValueIntegerType() { 
1352          return this != null && this.value instanceof IntegerType;
1353        }
1354
1355        /**
1356         * @return {@link #value} (The value of the attribute.)
1357         */
1358        public DecimalType getValueDecimalType() throws FHIRException { 
1359          if (this.value == null)
1360            this.value = new DecimalType();
1361          if (!(this.value instanceof DecimalType))
1362            throw new FHIRException("Type mismatch: the type DecimalType was expected, but "+this.value.getClass().getName()+" was encountered");
1363          return (DecimalType) this.value;
1364        }
1365
1366        public boolean hasValueDecimalType() { 
1367          return this != null && this.value instanceof DecimalType;
1368        }
1369
1370        /**
1371         * @return {@link #value} (The value of the attribute.)
1372         */
1373        public BooleanType getValueBooleanType() throws FHIRException { 
1374          if (this.value == null)
1375            this.value = new BooleanType();
1376          if (!(this.value instanceof BooleanType))
1377            throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.value.getClass().getName()+" was encountered");
1378          return (BooleanType) this.value;
1379        }
1380
1381        public boolean hasValueBooleanType() { 
1382          return this != null && this.value instanceof BooleanType;
1383        }
1384
1385        /**
1386         * @return {@link #value} (The value of the attribute.)
1387         */
1388        public UrlType getValueUrlType() throws FHIRException { 
1389          if (this.value == null)
1390            this.value = new UrlType();
1391          if (!(this.value instanceof UrlType))
1392            throw new FHIRException("Type mismatch: the type UrlType was expected, but "+this.value.getClass().getName()+" was encountered");
1393          return (UrlType) this.value;
1394        }
1395
1396        public boolean hasValueUrlType() { 
1397          return this != null && this.value instanceof UrlType;
1398        }
1399
1400        /**
1401         * @return {@link #value} (The value of the attribute.)
1402         */
1403        public DateTimeType getValueDateTimeType() throws FHIRException { 
1404          if (this.value == null)
1405            this.value = new DateTimeType();
1406          if (!(this.value instanceof DateTimeType))
1407            throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.value.getClass().getName()+" was encountered");
1408          return (DateTimeType) this.value;
1409        }
1410
1411        public boolean hasValueDateTimeType() { 
1412          return this != null && this.value instanceof DateTimeType;
1413        }
1414
1415        /**
1416         * @return {@link #value} (The value of the attribute.)
1417         */
1418        public Quantity getValueQuantity() throws FHIRException { 
1419          if (this.value == null)
1420            this.value = new Quantity();
1421          if (!(this.value instanceof Quantity))
1422            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.value.getClass().getName()+" was encountered");
1423          return (Quantity) this.value;
1424        }
1425
1426        public boolean hasValueQuantity() { 
1427          return this != null && this.value instanceof Quantity;
1428        }
1429
1430        /**
1431         * @return {@link #value} (The value of the attribute.)
1432         */
1433        public Range getValueRange() throws FHIRException { 
1434          if (this.value == null)
1435            this.value = new Range();
1436          if (!(this.value instanceof Range))
1437            throw new FHIRException("Type mismatch: the type Range was expected, but "+this.value.getClass().getName()+" was encountered");
1438          return (Range) this.value;
1439        }
1440
1441        public boolean hasValueRange() { 
1442          return this != null && this.value instanceof Range;
1443        }
1444
1445        /**
1446         * @return {@link #value} (The value of the attribute.)
1447         */
1448        public Ratio getValueRatio() throws FHIRException { 
1449          if (this.value == null)
1450            this.value = new Ratio();
1451          if (!(this.value instanceof Ratio))
1452            throw new FHIRException("Type mismatch: the type Ratio was expected, but "+this.value.getClass().getName()+" was encountered");
1453          return (Ratio) this.value;
1454        }
1455
1456        public boolean hasValueRatio() { 
1457          return this != null && this.value instanceof Ratio;
1458        }
1459
1460        /**
1461         * @return {@link #value} (The value of the attribute.)
1462         */
1463        public Annotation getValueAnnotation() throws FHIRException { 
1464          if (this.value == null)
1465            this.value = new Annotation();
1466          if (!(this.value instanceof Annotation))
1467            throw new FHIRException("Type mismatch: the type Annotation was expected, but "+this.value.getClass().getName()+" was encountered");
1468          return (Annotation) this.value;
1469        }
1470
1471        public boolean hasValueAnnotation() { 
1472          return this != null && this.value instanceof Annotation;
1473        }
1474
1475        /**
1476         * @return {@link #value} (The value of the attribute.)
1477         */
1478        public Address getValueAddress() throws FHIRException { 
1479          if (this.value == null)
1480            this.value = new Address();
1481          if (!(this.value instanceof Address))
1482            throw new FHIRException("Type mismatch: the type Address was expected, but "+this.value.getClass().getName()+" was encountered");
1483          return (Address) this.value;
1484        }
1485
1486        public boolean hasValueAddress() { 
1487          return this != null && this.value instanceof Address;
1488        }
1489
1490        /**
1491         * @return {@link #value} (The value of the attribute.)
1492         */
1493        public Duration getValueDuration() throws FHIRException { 
1494          if (this.value == null)
1495            this.value = new Duration();
1496          if (!(this.value instanceof Duration))
1497            throw new FHIRException("Type mismatch: the type Duration was expected, but "+this.value.getClass().getName()+" was encountered");
1498          return (Duration) this.value;
1499        }
1500
1501        public boolean hasValueDuration() { 
1502          return this != null && this.value instanceof Duration;
1503        }
1504
1505        /**
1506         * @return {@link #value} (The value of the attribute.)
1507         */
1508        public CodeableConcept getValueCodeableConcept() throws FHIRException { 
1509          if (this.value == null)
1510            this.value = new CodeableConcept();
1511          if (!(this.value instanceof CodeableConcept))
1512            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.value.getClass().getName()+" was encountered");
1513          return (CodeableConcept) this.value;
1514        }
1515
1516        public boolean hasValueCodeableConcept() { 
1517          return this != null && this.value instanceof CodeableConcept;
1518        }
1519
1520        public boolean hasValue() { 
1521          return this.value != null && !this.value.isEmpty();
1522        }
1523
1524        /**
1525         * @param value {@link #value} (The value of the attribute.)
1526         */
1527        public InventoryItemCharacteristicComponent setValue(DataType value) { 
1528          if (value != null && !(value instanceof StringType || value instanceof IntegerType || value instanceof DecimalType || value instanceof BooleanType || value instanceof UrlType || value instanceof DateTimeType || value instanceof Quantity || value instanceof Range || value instanceof Ratio || value instanceof Annotation || value instanceof Address || value instanceof Duration || value instanceof CodeableConcept))
1529            throw new FHIRException("Not the right type for InventoryItem.characteristic.value[x]: "+value.fhirType());
1530          this.value = value;
1531          return this;
1532        }
1533
1534        protected void listChildren(List<Property> children) {
1535          super.listChildren(children);
1536          children.add(new Property("characteristicType", "CodeableConcept", "The type of characteristic that is being defined.", 0, 1, characteristicType));
1537          children.add(new Property("value[x]", "string|integer|decimal|boolean|url|dateTime|Quantity|Range|Ratio|Annotation|Address|Duration|CodeableConcept", "The value of the attribute.", 0, 1, value));
1538        }
1539
1540        @Override
1541        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1542          switch (_hash) {
1543          case 1172127605: /*characteristicType*/  return new Property("characteristicType", "CodeableConcept", "The type of characteristic that is being defined.", 0, 1, characteristicType);
1544          case -1410166417: /*value[x]*/  return new Property("value[x]", "string|integer|decimal|boolean|url|dateTime|Quantity|Range|Ratio|Annotation|Address|Duration|CodeableConcept", "The value of the attribute.", 0, 1, value);
1545          case 111972721: /*value*/  return new Property("value[x]", "string|integer|decimal|boolean|url|dateTime|Quantity|Range|Ratio|Annotation|Address|Duration|CodeableConcept", "The value of the attribute.", 0, 1, value);
1546          case -1424603934: /*valueString*/  return new Property("value[x]", "string", "The value of the attribute.", 0, 1, value);
1547          case -1668204915: /*valueInteger*/  return new Property("value[x]", "integer", "The value of the attribute.", 0, 1, value);
1548          case -2083993440: /*valueDecimal*/  return new Property("value[x]", "decimal", "The value of the attribute.", 0, 1, value);
1549          case 733421943: /*valueBoolean*/  return new Property("value[x]", "boolean", "The value of the attribute.", 0, 1, value);
1550          case -1410172354: /*valueUrl*/  return new Property("value[x]", "url", "The value of the attribute.", 0, 1, value);
1551          case 1047929900: /*valueDateTime*/  return new Property("value[x]", "dateTime", "The value of the attribute.", 0, 1, value);
1552          case -2029823716: /*valueQuantity*/  return new Property("value[x]", "Quantity", "The value of the attribute.", 0, 1, value);
1553          case 2030761548: /*valueRange*/  return new Property("value[x]", "Range", "The value of the attribute.", 0, 1, value);
1554          case 2030767386: /*valueRatio*/  return new Property("value[x]", "Ratio", "The value of the attribute.", 0, 1, value);
1555          case -67108992: /*valueAnnotation*/  return new Property("value[x]", "Annotation", "The value of the attribute.", 0, 1, value);
1556          case -478981821: /*valueAddress*/  return new Property("value[x]", "Address", "The value of the attribute.", 0, 1, value);
1557          case 1558135333: /*valueDuration*/  return new Property("value[x]", "Duration", "The value of the attribute.", 0, 1, value);
1558          case 924902896: /*valueCodeableConcept*/  return new Property("value[x]", "CodeableConcept", "The value of the attribute.", 0, 1, value);
1559          default: return super.getNamedProperty(_hash, _name, _checkValid);
1560          }
1561
1562        }
1563
1564      @Override
1565      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1566        switch (hash) {
1567        case 1172127605: /*characteristicType*/ return this.characteristicType == null ? new Base[0] : new Base[] {this.characteristicType}; // CodeableConcept
1568        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // DataType
1569        default: return super.getProperty(hash, name, checkValid);
1570        }
1571
1572      }
1573
1574      @Override
1575      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1576        switch (hash) {
1577        case 1172127605: // characteristicType
1578          this.characteristicType = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1579          return value;
1580        case 111972721: // value
1581          this.value = TypeConvertor.castToType(value); // DataType
1582          return value;
1583        default: return super.setProperty(hash, name, value);
1584        }
1585
1586      }
1587
1588      @Override
1589      public Base setProperty(String name, Base value) throws FHIRException {
1590        if (name.equals("characteristicType")) {
1591          this.characteristicType = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1592        } else if (name.equals("value[x]")) {
1593          this.value = TypeConvertor.castToType(value); // DataType
1594        } else
1595          return super.setProperty(name, value);
1596        return value;
1597      }
1598
1599  @Override
1600  public void removeChild(String name, Base value) throws FHIRException {
1601        if (name.equals("characteristicType")) {
1602          this.characteristicType = null;
1603        } else if (name.equals("value[x]")) {
1604          this.value = null;
1605        } else
1606          super.removeChild(name, value);
1607        
1608      }
1609
1610      @Override
1611      public Base makeProperty(int hash, String name) throws FHIRException {
1612        switch (hash) {
1613        case 1172127605:  return getCharacteristicType();
1614        case -1410166417:  return getValue();
1615        case 111972721:  return getValue();
1616        default: return super.makeProperty(hash, name);
1617        }
1618
1619      }
1620
1621      @Override
1622      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1623        switch (hash) {
1624        case 1172127605: /*characteristicType*/ return new String[] {"CodeableConcept"};
1625        case 111972721: /*value*/ return new String[] {"string", "integer", "decimal", "boolean", "url", "dateTime", "Quantity", "Range", "Ratio", "Annotation", "Address", "Duration", "CodeableConcept"};
1626        default: return super.getTypesForProperty(hash, name);
1627        }
1628
1629      }
1630
1631      @Override
1632      public Base addChild(String name) throws FHIRException {
1633        if (name.equals("characteristicType")) {
1634          this.characteristicType = new CodeableConcept();
1635          return this.characteristicType;
1636        }
1637        else if (name.equals("valueString")) {
1638          this.value = new StringType();
1639          return this.value;
1640        }
1641        else if (name.equals("valueInteger")) {
1642          this.value = new IntegerType();
1643          return this.value;
1644        }
1645        else if (name.equals("valueDecimal")) {
1646          this.value = new DecimalType();
1647          return this.value;
1648        }
1649        else if (name.equals("valueBoolean")) {
1650          this.value = new BooleanType();
1651          return this.value;
1652        }
1653        else if (name.equals("valueUrl")) {
1654          this.value = new UrlType();
1655          return this.value;
1656        }
1657        else if (name.equals("valueDateTime")) {
1658          this.value = new DateTimeType();
1659          return this.value;
1660        }
1661        else if (name.equals("valueQuantity")) {
1662          this.value = new Quantity();
1663          return this.value;
1664        }
1665        else if (name.equals("valueRange")) {
1666          this.value = new Range();
1667          return this.value;
1668        }
1669        else if (name.equals("valueRatio")) {
1670          this.value = new Ratio();
1671          return this.value;
1672        }
1673        else if (name.equals("valueAnnotation")) {
1674          this.value = new Annotation();
1675          return this.value;
1676        }
1677        else if (name.equals("valueAddress")) {
1678          this.value = new Address();
1679          return this.value;
1680        }
1681        else if (name.equals("valueDuration")) {
1682          this.value = new Duration();
1683          return this.value;
1684        }
1685        else if (name.equals("valueCodeableConcept")) {
1686          this.value = new CodeableConcept();
1687          return this.value;
1688        }
1689        else
1690          return super.addChild(name);
1691      }
1692
1693      public InventoryItemCharacteristicComponent copy() {
1694        InventoryItemCharacteristicComponent dst = new InventoryItemCharacteristicComponent();
1695        copyValues(dst);
1696        return dst;
1697      }
1698
1699      public void copyValues(InventoryItemCharacteristicComponent dst) {
1700        super.copyValues(dst);
1701        dst.characteristicType = characteristicType == null ? null : characteristicType.copy();
1702        dst.value = value == null ? null : value.copy();
1703      }
1704
1705      @Override
1706      public boolean equalsDeep(Base other_) {
1707        if (!super.equalsDeep(other_))
1708          return false;
1709        if (!(other_ instanceof InventoryItemCharacteristicComponent))
1710          return false;
1711        InventoryItemCharacteristicComponent o = (InventoryItemCharacteristicComponent) other_;
1712        return compareDeep(characteristicType, o.characteristicType, true) && compareDeep(value, o.value, true)
1713          ;
1714      }
1715
1716      @Override
1717      public boolean equalsShallow(Base other_) {
1718        if (!super.equalsShallow(other_))
1719          return false;
1720        if (!(other_ instanceof InventoryItemCharacteristicComponent))
1721          return false;
1722        InventoryItemCharacteristicComponent o = (InventoryItemCharacteristicComponent) other_;
1723        return true;
1724      }
1725
1726      public boolean isEmpty() {
1727        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(characteristicType, value
1728          );
1729      }
1730
1731  public String fhirType() {
1732    return "InventoryItem.characteristic";
1733
1734  }
1735
1736  }
1737
1738    @Block()
1739    public static class InventoryItemInstanceComponent extends BackboneElement implements IBaseBackboneElement {
1740        /**
1741         * The identifier for the physical instance, typically a serial number.
1742         */
1743        @Child(name = "identifier", type = {Identifier.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1744        @Description(shortDefinition="The identifier for the physical instance, typically a serial number", formalDefinition="The identifier for the physical instance, typically a serial number." )
1745        protected List<Identifier> identifier;
1746
1747        /**
1748         * The lot or batch number of the item.
1749         */
1750        @Child(name = "lotNumber", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=false)
1751        @Description(shortDefinition="The lot or batch number of the item", formalDefinition="The lot or batch number of the item." )
1752        protected StringType lotNumber;
1753
1754        /**
1755         * The expiry date or date and time for the product.
1756         */
1757        @Child(name = "expiry", type = {DateTimeType.class}, order=3, min=0, max=1, modifier=false, summary=false)
1758        @Description(shortDefinition="The expiry date or date and time for the product", formalDefinition="The expiry date or date and time for the product." )
1759        protected DateTimeType expiry;
1760
1761        /**
1762         * The subject that the item is associated with.
1763         */
1764        @Child(name = "subject", type = {Patient.class, Organization.class}, order=4, min=0, max=1, modifier=false, summary=false)
1765        @Description(shortDefinition="The subject that the item is associated with", formalDefinition="The subject that the item is associated with." )
1766        protected Reference subject;
1767
1768        /**
1769         * The location that the item is associated with.
1770         */
1771        @Child(name = "location", type = {Location.class}, order=5, min=0, max=1, modifier=false, summary=false)
1772        @Description(shortDefinition="The location that the item is associated with", formalDefinition="The location that the item is associated with." )
1773        protected Reference location;
1774
1775        private static final long serialVersionUID = 657936980L;
1776
1777    /**
1778     * Constructor
1779     */
1780      public InventoryItemInstanceComponent() {
1781        super();
1782      }
1783
1784        /**
1785         * @return {@link #identifier} (The identifier for the physical instance, typically a serial number.)
1786         */
1787        public List<Identifier> getIdentifier() { 
1788          if (this.identifier == null)
1789            this.identifier = new ArrayList<Identifier>();
1790          return this.identifier;
1791        }
1792
1793        /**
1794         * @return Returns a reference to <code>this</code> for easy method chaining
1795         */
1796        public InventoryItemInstanceComponent setIdentifier(List<Identifier> theIdentifier) { 
1797          this.identifier = theIdentifier;
1798          return this;
1799        }
1800
1801        public boolean hasIdentifier() { 
1802          if (this.identifier == null)
1803            return false;
1804          for (Identifier item : this.identifier)
1805            if (!item.isEmpty())
1806              return true;
1807          return false;
1808        }
1809
1810        public Identifier addIdentifier() { //3
1811          Identifier t = new Identifier();
1812          if (this.identifier == null)
1813            this.identifier = new ArrayList<Identifier>();
1814          this.identifier.add(t);
1815          return t;
1816        }
1817
1818        public InventoryItemInstanceComponent addIdentifier(Identifier t) { //3
1819          if (t == null)
1820            return this;
1821          if (this.identifier == null)
1822            this.identifier = new ArrayList<Identifier>();
1823          this.identifier.add(t);
1824          return this;
1825        }
1826
1827        /**
1828         * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist {3}
1829         */
1830        public Identifier getIdentifierFirstRep() { 
1831          if (getIdentifier().isEmpty()) {
1832            addIdentifier();
1833          }
1834          return getIdentifier().get(0);
1835        }
1836
1837        /**
1838         * @return {@link #lotNumber} (The lot or batch number of the item.). This is the underlying object with id, value and extensions. The accessor "getLotNumber" gives direct access to the value
1839         */
1840        public StringType getLotNumberElement() { 
1841          if (this.lotNumber == null)
1842            if (Configuration.errorOnAutoCreate())
1843              throw new Error("Attempt to auto-create InventoryItemInstanceComponent.lotNumber");
1844            else if (Configuration.doAutoCreate())
1845              this.lotNumber = new StringType(); // bb
1846          return this.lotNumber;
1847        }
1848
1849        public boolean hasLotNumberElement() { 
1850          return this.lotNumber != null && !this.lotNumber.isEmpty();
1851        }
1852
1853        public boolean hasLotNumber() { 
1854          return this.lotNumber != null && !this.lotNumber.isEmpty();
1855        }
1856
1857        /**
1858         * @param value {@link #lotNumber} (The lot or batch number of the item.). This is the underlying object with id, value and extensions. The accessor "getLotNumber" gives direct access to the value
1859         */
1860        public InventoryItemInstanceComponent setLotNumberElement(StringType value) { 
1861          this.lotNumber = value;
1862          return this;
1863        }
1864
1865        /**
1866         * @return The lot or batch number of the item.
1867         */
1868        public String getLotNumber() { 
1869          return this.lotNumber == null ? null : this.lotNumber.getValue();
1870        }
1871
1872        /**
1873         * @param value The lot or batch number of the item.
1874         */
1875        public InventoryItemInstanceComponent setLotNumber(String value) { 
1876          if (Utilities.noString(value))
1877            this.lotNumber = null;
1878          else {
1879            if (this.lotNumber == null)
1880              this.lotNumber = new StringType();
1881            this.lotNumber.setValue(value);
1882          }
1883          return this;
1884        }
1885
1886        /**
1887         * @return {@link #expiry} (The expiry date or date and time for the product.). This is the underlying object with id, value and extensions. The accessor "getExpiry" gives direct access to the value
1888         */
1889        public DateTimeType getExpiryElement() { 
1890          if (this.expiry == null)
1891            if (Configuration.errorOnAutoCreate())
1892              throw new Error("Attempt to auto-create InventoryItemInstanceComponent.expiry");
1893            else if (Configuration.doAutoCreate())
1894              this.expiry = new DateTimeType(); // bb
1895          return this.expiry;
1896        }
1897
1898        public boolean hasExpiryElement() { 
1899          return this.expiry != null && !this.expiry.isEmpty();
1900        }
1901
1902        public boolean hasExpiry() { 
1903          return this.expiry != null && !this.expiry.isEmpty();
1904        }
1905
1906        /**
1907         * @param value {@link #expiry} (The expiry date or date and time for the product.). This is the underlying object with id, value and extensions. The accessor "getExpiry" gives direct access to the value
1908         */
1909        public InventoryItemInstanceComponent setExpiryElement(DateTimeType value) { 
1910          this.expiry = value;
1911          return this;
1912        }
1913
1914        /**
1915         * @return The expiry date or date and time for the product.
1916         */
1917        public Date getExpiry() { 
1918          return this.expiry == null ? null : this.expiry.getValue();
1919        }
1920
1921        /**
1922         * @param value The expiry date or date and time for the product.
1923         */
1924        public InventoryItemInstanceComponent setExpiry(Date value) { 
1925          if (value == null)
1926            this.expiry = null;
1927          else {
1928            if (this.expiry == null)
1929              this.expiry = new DateTimeType();
1930            this.expiry.setValue(value);
1931          }
1932          return this;
1933        }
1934
1935        /**
1936         * @return {@link #subject} (The subject that the item is associated with.)
1937         */
1938        public Reference getSubject() { 
1939          if (this.subject == null)
1940            if (Configuration.errorOnAutoCreate())
1941              throw new Error("Attempt to auto-create InventoryItemInstanceComponent.subject");
1942            else if (Configuration.doAutoCreate())
1943              this.subject = new Reference(); // cc
1944          return this.subject;
1945        }
1946
1947        public boolean hasSubject() { 
1948          return this.subject != null && !this.subject.isEmpty();
1949        }
1950
1951        /**
1952         * @param value {@link #subject} (The subject that the item is associated with.)
1953         */
1954        public InventoryItemInstanceComponent setSubject(Reference value) { 
1955          this.subject = value;
1956          return this;
1957        }
1958
1959        /**
1960         * @return {@link #location} (The location that the item is associated with.)
1961         */
1962        public Reference getLocation() { 
1963          if (this.location == null)
1964            if (Configuration.errorOnAutoCreate())
1965              throw new Error("Attempt to auto-create InventoryItemInstanceComponent.location");
1966            else if (Configuration.doAutoCreate())
1967              this.location = new Reference(); // cc
1968          return this.location;
1969        }
1970
1971        public boolean hasLocation() { 
1972          return this.location != null && !this.location.isEmpty();
1973        }
1974
1975        /**
1976         * @param value {@link #location} (The location that the item is associated with.)
1977         */
1978        public InventoryItemInstanceComponent setLocation(Reference value) { 
1979          this.location = value;
1980          return this;
1981        }
1982
1983        protected void listChildren(List<Property> children) {
1984          super.listChildren(children);
1985          children.add(new Property("identifier", "Identifier", "The identifier for the physical instance, typically a serial number.", 0, java.lang.Integer.MAX_VALUE, identifier));
1986          children.add(new Property("lotNumber", "string", "The lot or batch number of the item.", 0, 1, lotNumber));
1987          children.add(new Property("expiry", "dateTime", "The expiry date or date and time for the product.", 0, 1, expiry));
1988          children.add(new Property("subject", "Reference(Patient|Organization)", "The subject that the item is associated with.", 0, 1, subject));
1989          children.add(new Property("location", "Reference(Location)", "The location that the item is associated with.", 0, 1, location));
1990        }
1991
1992        @Override
1993        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1994          switch (_hash) {
1995          case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "The identifier for the physical instance, typically a serial number.", 0, java.lang.Integer.MAX_VALUE, identifier);
1996          case 462547450: /*lotNumber*/  return new Property("lotNumber", "string", "The lot or batch number of the item.", 0, 1, lotNumber);
1997          case -1289159373: /*expiry*/  return new Property("expiry", "dateTime", "The expiry date or date and time for the product.", 0, 1, expiry);
1998          case -1867885268: /*subject*/  return new Property("subject", "Reference(Patient|Organization)", "The subject that the item is associated with.", 0, 1, subject);
1999          case 1901043637: /*location*/  return new Property("location", "Reference(Location)", "The location that the item is associated with.", 0, 1, location);
2000          default: return super.getNamedProperty(_hash, _name, _checkValid);
2001          }
2002
2003        }
2004
2005      @Override
2006      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2007        switch (hash) {
2008        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2009        case 462547450: /*lotNumber*/ return this.lotNumber == null ? new Base[0] : new Base[] {this.lotNumber}; // StringType
2010        case -1289159373: /*expiry*/ return this.expiry == null ? new Base[0] : new Base[] {this.expiry}; // DateTimeType
2011        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
2012        case 1901043637: /*location*/ return this.location == null ? new Base[0] : new Base[] {this.location}; // Reference
2013        default: return super.getProperty(hash, name, checkValid);
2014        }
2015
2016      }
2017
2018      @Override
2019      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2020        switch (hash) {
2021        case -1618432855: // identifier
2022          this.getIdentifier().add(TypeConvertor.castToIdentifier(value)); // Identifier
2023          return value;
2024        case 462547450: // lotNumber
2025          this.lotNumber = TypeConvertor.castToString(value); // StringType
2026          return value;
2027        case -1289159373: // expiry
2028          this.expiry = TypeConvertor.castToDateTime(value); // DateTimeType
2029          return value;
2030        case -1867885268: // subject
2031          this.subject = TypeConvertor.castToReference(value); // Reference
2032          return value;
2033        case 1901043637: // location
2034          this.location = TypeConvertor.castToReference(value); // Reference
2035          return value;
2036        default: return super.setProperty(hash, name, value);
2037        }
2038
2039      }
2040
2041      @Override
2042      public Base setProperty(String name, Base value) throws FHIRException {
2043        if (name.equals("identifier")) {
2044          this.getIdentifier().add(TypeConvertor.castToIdentifier(value));
2045        } else if (name.equals("lotNumber")) {
2046          this.lotNumber = TypeConvertor.castToString(value); // StringType
2047        } else if (name.equals("expiry")) {
2048          this.expiry = TypeConvertor.castToDateTime(value); // DateTimeType
2049        } else if (name.equals("subject")) {
2050          this.subject = TypeConvertor.castToReference(value); // Reference
2051        } else if (name.equals("location")) {
2052          this.location = TypeConvertor.castToReference(value); // Reference
2053        } else
2054          return super.setProperty(name, value);
2055        return value;
2056      }
2057
2058  @Override
2059  public void removeChild(String name, Base value) throws FHIRException {
2060        if (name.equals("identifier")) {
2061          this.getIdentifier().remove(value);
2062        } else if (name.equals("lotNumber")) {
2063          this.lotNumber = null;
2064        } else if (name.equals("expiry")) {
2065          this.expiry = null;
2066        } else if (name.equals("subject")) {
2067          this.subject = null;
2068        } else if (name.equals("location")) {
2069          this.location = null;
2070        } else
2071          super.removeChild(name, value);
2072        
2073      }
2074
2075      @Override
2076      public Base makeProperty(int hash, String name) throws FHIRException {
2077        switch (hash) {
2078        case -1618432855:  return addIdentifier(); 
2079        case 462547450:  return getLotNumberElement();
2080        case -1289159373:  return getExpiryElement();
2081        case -1867885268:  return getSubject();
2082        case 1901043637:  return getLocation();
2083        default: return super.makeProperty(hash, name);
2084        }
2085
2086      }
2087
2088      @Override
2089      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2090        switch (hash) {
2091        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2092        case 462547450: /*lotNumber*/ return new String[] {"string"};
2093        case -1289159373: /*expiry*/ return new String[] {"dateTime"};
2094        case -1867885268: /*subject*/ return new String[] {"Reference"};
2095        case 1901043637: /*location*/ return new String[] {"Reference"};
2096        default: return super.getTypesForProperty(hash, name);
2097        }
2098
2099      }
2100
2101      @Override
2102      public Base addChild(String name) throws FHIRException {
2103        if (name.equals("identifier")) {
2104          return addIdentifier();
2105        }
2106        else if (name.equals("lotNumber")) {
2107          throw new FHIRException("Cannot call addChild on a singleton property InventoryItem.instance.lotNumber");
2108        }
2109        else if (name.equals("expiry")) {
2110          throw new FHIRException("Cannot call addChild on a singleton property InventoryItem.instance.expiry");
2111        }
2112        else if (name.equals("subject")) {
2113          this.subject = new Reference();
2114          return this.subject;
2115        }
2116        else if (name.equals("location")) {
2117          this.location = new Reference();
2118          return this.location;
2119        }
2120        else
2121          return super.addChild(name);
2122      }
2123
2124      public InventoryItemInstanceComponent copy() {
2125        InventoryItemInstanceComponent dst = new InventoryItemInstanceComponent();
2126        copyValues(dst);
2127        return dst;
2128      }
2129
2130      public void copyValues(InventoryItemInstanceComponent dst) {
2131        super.copyValues(dst);
2132        if (identifier != null) {
2133          dst.identifier = new ArrayList<Identifier>();
2134          for (Identifier i : identifier)
2135            dst.identifier.add(i.copy());
2136        };
2137        dst.lotNumber = lotNumber == null ? null : lotNumber.copy();
2138        dst.expiry = expiry == null ? null : expiry.copy();
2139        dst.subject = subject == null ? null : subject.copy();
2140        dst.location = location == null ? null : location.copy();
2141      }
2142
2143      @Override
2144      public boolean equalsDeep(Base other_) {
2145        if (!super.equalsDeep(other_))
2146          return false;
2147        if (!(other_ instanceof InventoryItemInstanceComponent))
2148          return false;
2149        InventoryItemInstanceComponent o = (InventoryItemInstanceComponent) other_;
2150        return compareDeep(identifier, o.identifier, true) && compareDeep(lotNumber, o.lotNumber, true)
2151           && compareDeep(expiry, o.expiry, true) && compareDeep(subject, o.subject, true) && compareDeep(location, o.location, true)
2152          ;
2153      }
2154
2155      @Override
2156      public boolean equalsShallow(Base other_) {
2157        if (!super.equalsShallow(other_))
2158          return false;
2159        if (!(other_ instanceof InventoryItemInstanceComponent))
2160          return false;
2161        InventoryItemInstanceComponent o = (InventoryItemInstanceComponent) other_;
2162        return compareValues(lotNumber, o.lotNumber, true) && compareValues(expiry, o.expiry, true);
2163      }
2164
2165      public boolean isEmpty() {
2166        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, lotNumber, expiry
2167          , subject, location);
2168      }
2169
2170  public String fhirType() {
2171    return "InventoryItem.instance";
2172
2173  }
2174
2175  }
2176
2177    /**
2178     * Business identifier for the inventory item.
2179     */
2180    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2181    @Description(shortDefinition="Business identifier for the inventory item", formalDefinition="Business identifier for the inventory item." )
2182    protected List<Identifier> identifier;
2183
2184    /**
2185     * Status of the item entry.
2186     */
2187    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=true)
2188    @Description(shortDefinition="active | inactive | entered-in-error | unknown", formalDefinition="Status of the item entry." )
2189    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/inventoryitem-status")
2190    protected Enumeration<InventoryItemStatusCodes> status;
2191
2192    /**
2193     * Category or class of the item.
2194     */
2195    @Child(name = "category", type = {CodeableConcept.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2196    @Description(shortDefinition="Category or class of the item", formalDefinition="Category or class of the item." )
2197    protected List<CodeableConcept> category;
2198
2199    /**
2200     * Code designating the specific type of item.
2201     */
2202    @Child(name = "code", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2203    @Description(shortDefinition="Code designating the specific type of item", formalDefinition="Code designating the specific type of item." )
2204    protected List<CodeableConcept> code;
2205
2206    /**
2207     * The item name(s) - the brand name, or common name, functional name, generic name.
2208     */
2209    @Child(name = "name", type = {}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2210    @Description(shortDefinition="The item name(s) - the brand name, or common name, functional name, generic name or others", formalDefinition="The item name(s) - the brand name, or common name, functional name, generic name." )
2211    protected List<InventoryItemNameComponent> name;
2212
2213    /**
2214     * Organization(s) responsible for the product.
2215     */
2216    @Child(name = "responsibleOrganization", type = {}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2217    @Description(shortDefinition="Organization(s) responsible for the product", formalDefinition="Organization(s) responsible for the product." )
2218    protected List<InventoryItemResponsibleOrganizationComponent> responsibleOrganization;
2219
2220    /**
2221     * The descriptive characteristics of the inventory item.
2222     */
2223    @Child(name = "description", type = {}, order=6, min=0, max=1, modifier=false, summary=false)
2224    @Description(shortDefinition="Descriptive characteristics of the item", formalDefinition="The descriptive characteristics of the inventory item." )
2225    protected InventoryItemDescriptionComponent description;
2226
2227    /**
2228     * The usage status e.g. recalled, in use, discarded... This can be used to indicate that the items have been taken out of inventory, or are in use, etc.
2229     */
2230    @Child(name = "inventoryStatus", type = {CodeableConcept.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2231    @Description(shortDefinition="The usage status like recalled, in use, discarded", formalDefinition="The usage status e.g. recalled, in use, discarded... This can be used to indicate that the items have been taken out of inventory, or are in use, etc." )
2232    protected List<CodeableConcept> inventoryStatus;
2233
2234    /**
2235     * The base unit of measure - the unit in which the product is used or counted.
2236     */
2237    @Child(name = "baseUnit", type = {CodeableConcept.class}, order=8, min=0, max=1, modifier=false, summary=true)
2238    @Description(shortDefinition="The base unit of measure - the unit in which the product is used or counted", formalDefinition="The base unit of measure - the unit in which the product is used or counted." )
2239    protected CodeableConcept baseUnit;
2240
2241    /**
2242     * Net content or amount present in the item.
2243     */
2244    @Child(name = "netContent", type = {Quantity.class}, order=9, min=0, max=1, modifier=false, summary=true)
2245    @Description(shortDefinition="Net content or amount present in the item", formalDefinition="Net content or amount present in the item." )
2246    protected Quantity netContent;
2247
2248    /**
2249     * Association with other items or products.
2250     */
2251    @Child(name = "association", type = {}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2252    @Description(shortDefinition="Association with other items or products", formalDefinition="Association with other items or products." )
2253    protected List<InventoryItemAssociationComponent> association;
2254
2255    /**
2256     * The descriptive or identifying characteristics of the item.
2257     */
2258    @Child(name = "characteristic", type = {}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2259    @Description(shortDefinition="Characteristic of the item", formalDefinition="The descriptive or identifying characteristics of the item." )
2260    protected List<InventoryItemCharacteristicComponent> characteristic;
2261
2262    /**
2263     * Instances or occurrences of the product.
2264     */
2265    @Child(name = "instance", type = {}, order=12, min=0, max=1, modifier=false, summary=false)
2266    @Description(shortDefinition="Instances or occurrences of the product", formalDefinition="Instances or occurrences of the product." )
2267    protected InventoryItemInstanceComponent instance;
2268
2269    /**
2270     * Link to a product resource used in clinical workflows.
2271     */
2272    @Child(name = "productReference", type = {Medication.class, Device.class, NutritionProduct.class, BiologicallyDerivedProduct.class}, order=13, min=0, max=1, modifier=false, summary=false)
2273    @Description(shortDefinition="Link to a product resource used in clinical workflows", formalDefinition="Link to a product resource used in clinical workflows." )
2274    protected Reference productReference;
2275
2276    private static final long serialVersionUID = 2127201564L;
2277
2278  /**
2279   * Constructor
2280   */
2281    public InventoryItem() {
2282      super();
2283    }
2284
2285  /**
2286   * Constructor
2287   */
2288    public InventoryItem(InventoryItemStatusCodes status) {
2289      super();
2290      this.setStatus(status);
2291    }
2292
2293    /**
2294     * @return {@link #identifier} (Business identifier for the inventory item.)
2295     */
2296    public List<Identifier> getIdentifier() { 
2297      if (this.identifier == null)
2298        this.identifier = new ArrayList<Identifier>();
2299      return this.identifier;
2300    }
2301
2302    /**
2303     * @return Returns a reference to <code>this</code> for easy method chaining
2304     */
2305    public InventoryItem setIdentifier(List<Identifier> theIdentifier) { 
2306      this.identifier = theIdentifier;
2307      return this;
2308    }
2309
2310    public boolean hasIdentifier() { 
2311      if (this.identifier == null)
2312        return false;
2313      for (Identifier item : this.identifier)
2314        if (!item.isEmpty())
2315          return true;
2316      return false;
2317    }
2318
2319    public Identifier addIdentifier() { //3
2320      Identifier t = new Identifier();
2321      if (this.identifier == null)
2322        this.identifier = new ArrayList<Identifier>();
2323      this.identifier.add(t);
2324      return t;
2325    }
2326
2327    public InventoryItem addIdentifier(Identifier t) { //3
2328      if (t == null)
2329        return this;
2330      if (this.identifier == null)
2331        this.identifier = new ArrayList<Identifier>();
2332      this.identifier.add(t);
2333      return this;
2334    }
2335
2336    /**
2337     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist {3}
2338     */
2339    public Identifier getIdentifierFirstRep() { 
2340      if (getIdentifier().isEmpty()) {
2341        addIdentifier();
2342      }
2343      return getIdentifier().get(0);
2344    }
2345
2346    /**
2347     * @return {@link #status} (Status of the item entry.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2348     */
2349    public Enumeration<InventoryItemStatusCodes> getStatusElement() { 
2350      if (this.status == null)
2351        if (Configuration.errorOnAutoCreate())
2352          throw new Error("Attempt to auto-create InventoryItem.status");
2353        else if (Configuration.doAutoCreate())
2354          this.status = new Enumeration<InventoryItemStatusCodes>(new InventoryItemStatusCodesEnumFactory()); // bb
2355      return this.status;
2356    }
2357
2358    public boolean hasStatusElement() { 
2359      return this.status != null && !this.status.isEmpty();
2360    }
2361
2362    public boolean hasStatus() { 
2363      return this.status != null && !this.status.isEmpty();
2364    }
2365
2366    /**
2367     * @param value {@link #status} (Status of the item entry.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2368     */
2369    public InventoryItem setStatusElement(Enumeration<InventoryItemStatusCodes> value) { 
2370      this.status = value;
2371      return this;
2372    }
2373
2374    /**
2375     * @return Status of the item entry.
2376     */
2377    public InventoryItemStatusCodes getStatus() { 
2378      return this.status == null ? null : this.status.getValue();
2379    }
2380
2381    /**
2382     * @param value Status of the item entry.
2383     */
2384    public InventoryItem setStatus(InventoryItemStatusCodes value) { 
2385        if (this.status == null)
2386          this.status = new Enumeration<InventoryItemStatusCodes>(new InventoryItemStatusCodesEnumFactory());
2387        this.status.setValue(value);
2388      return this;
2389    }
2390
2391    /**
2392     * @return {@link #category} (Category or class of the item.)
2393     */
2394    public List<CodeableConcept> getCategory() { 
2395      if (this.category == null)
2396        this.category = new ArrayList<CodeableConcept>();
2397      return this.category;
2398    }
2399
2400    /**
2401     * @return Returns a reference to <code>this</code> for easy method chaining
2402     */
2403    public InventoryItem setCategory(List<CodeableConcept> theCategory) { 
2404      this.category = theCategory;
2405      return this;
2406    }
2407
2408    public boolean hasCategory() { 
2409      if (this.category == null)
2410        return false;
2411      for (CodeableConcept item : this.category)
2412        if (!item.isEmpty())
2413          return true;
2414      return false;
2415    }
2416
2417    public CodeableConcept addCategory() { //3
2418      CodeableConcept t = new CodeableConcept();
2419      if (this.category == null)
2420        this.category = new ArrayList<CodeableConcept>();
2421      this.category.add(t);
2422      return t;
2423    }
2424
2425    public InventoryItem addCategory(CodeableConcept t) { //3
2426      if (t == null)
2427        return this;
2428      if (this.category == null)
2429        this.category = new ArrayList<CodeableConcept>();
2430      this.category.add(t);
2431      return this;
2432    }
2433
2434    /**
2435     * @return The first repetition of repeating field {@link #category}, creating it if it does not already exist {3}
2436     */
2437    public CodeableConcept getCategoryFirstRep() { 
2438      if (getCategory().isEmpty()) {
2439        addCategory();
2440      }
2441      return getCategory().get(0);
2442    }
2443
2444    /**
2445     * @return {@link #code} (Code designating the specific type of item.)
2446     */
2447    public List<CodeableConcept> getCode() { 
2448      if (this.code == null)
2449        this.code = new ArrayList<CodeableConcept>();
2450      return this.code;
2451    }
2452
2453    /**
2454     * @return Returns a reference to <code>this</code> for easy method chaining
2455     */
2456    public InventoryItem setCode(List<CodeableConcept> theCode) { 
2457      this.code = theCode;
2458      return this;
2459    }
2460
2461    public boolean hasCode() { 
2462      if (this.code == null)
2463        return false;
2464      for (CodeableConcept item : this.code)
2465        if (!item.isEmpty())
2466          return true;
2467      return false;
2468    }
2469
2470    public CodeableConcept addCode() { //3
2471      CodeableConcept t = new CodeableConcept();
2472      if (this.code == null)
2473        this.code = new ArrayList<CodeableConcept>();
2474      this.code.add(t);
2475      return t;
2476    }
2477
2478    public InventoryItem addCode(CodeableConcept t) { //3
2479      if (t == null)
2480        return this;
2481      if (this.code == null)
2482        this.code = new ArrayList<CodeableConcept>();
2483      this.code.add(t);
2484      return this;
2485    }
2486
2487    /**
2488     * @return The first repetition of repeating field {@link #code}, creating it if it does not already exist {3}
2489     */
2490    public CodeableConcept getCodeFirstRep() { 
2491      if (getCode().isEmpty()) {
2492        addCode();
2493      }
2494      return getCode().get(0);
2495    }
2496
2497    /**
2498     * @return {@link #name} (The item name(s) - the brand name, or common name, functional name, generic name.)
2499     */
2500    public List<InventoryItemNameComponent> getName() { 
2501      if (this.name == null)
2502        this.name = new ArrayList<InventoryItemNameComponent>();
2503      return this.name;
2504    }
2505
2506    /**
2507     * @return Returns a reference to <code>this</code> for easy method chaining
2508     */
2509    public InventoryItem setName(List<InventoryItemNameComponent> theName) { 
2510      this.name = theName;
2511      return this;
2512    }
2513
2514    public boolean hasName() { 
2515      if (this.name == null)
2516        return false;
2517      for (InventoryItemNameComponent item : this.name)
2518        if (!item.isEmpty())
2519          return true;
2520      return false;
2521    }
2522
2523    public InventoryItemNameComponent addName() { //3
2524      InventoryItemNameComponent t = new InventoryItemNameComponent();
2525      if (this.name == null)
2526        this.name = new ArrayList<InventoryItemNameComponent>();
2527      this.name.add(t);
2528      return t;
2529    }
2530
2531    public InventoryItem addName(InventoryItemNameComponent t) { //3
2532      if (t == null)
2533        return this;
2534      if (this.name == null)
2535        this.name = new ArrayList<InventoryItemNameComponent>();
2536      this.name.add(t);
2537      return this;
2538    }
2539
2540    /**
2541     * @return The first repetition of repeating field {@link #name}, creating it if it does not already exist {3}
2542     */
2543    public InventoryItemNameComponent getNameFirstRep() { 
2544      if (getName().isEmpty()) {
2545        addName();
2546      }
2547      return getName().get(0);
2548    }
2549
2550    /**
2551     * @return {@link #responsibleOrganization} (Organization(s) responsible for the product.)
2552     */
2553    public List<InventoryItemResponsibleOrganizationComponent> getResponsibleOrganization() { 
2554      if (this.responsibleOrganization == null)
2555        this.responsibleOrganization = new ArrayList<InventoryItemResponsibleOrganizationComponent>();
2556      return this.responsibleOrganization;
2557    }
2558
2559    /**
2560     * @return Returns a reference to <code>this</code> for easy method chaining
2561     */
2562    public InventoryItem setResponsibleOrganization(List<InventoryItemResponsibleOrganizationComponent> theResponsibleOrganization) { 
2563      this.responsibleOrganization = theResponsibleOrganization;
2564      return this;
2565    }
2566
2567    public boolean hasResponsibleOrganization() { 
2568      if (this.responsibleOrganization == null)
2569        return false;
2570      for (InventoryItemResponsibleOrganizationComponent item : this.responsibleOrganization)
2571        if (!item.isEmpty())
2572          return true;
2573      return false;
2574    }
2575
2576    public InventoryItemResponsibleOrganizationComponent addResponsibleOrganization() { //3
2577      InventoryItemResponsibleOrganizationComponent t = new InventoryItemResponsibleOrganizationComponent();
2578      if (this.responsibleOrganization == null)
2579        this.responsibleOrganization = new ArrayList<InventoryItemResponsibleOrganizationComponent>();
2580      this.responsibleOrganization.add(t);
2581      return t;
2582    }
2583
2584    public InventoryItem addResponsibleOrganization(InventoryItemResponsibleOrganizationComponent t) { //3
2585      if (t == null)
2586        return this;
2587      if (this.responsibleOrganization == null)
2588        this.responsibleOrganization = new ArrayList<InventoryItemResponsibleOrganizationComponent>();
2589      this.responsibleOrganization.add(t);
2590      return this;
2591    }
2592
2593    /**
2594     * @return The first repetition of repeating field {@link #responsibleOrganization}, creating it if it does not already exist {3}
2595     */
2596    public InventoryItemResponsibleOrganizationComponent getResponsibleOrganizationFirstRep() { 
2597      if (getResponsibleOrganization().isEmpty()) {
2598        addResponsibleOrganization();
2599      }
2600      return getResponsibleOrganization().get(0);
2601    }
2602
2603    /**
2604     * @return {@link #description} (The descriptive characteristics of the inventory item.)
2605     */
2606    public InventoryItemDescriptionComponent getDescription() { 
2607      if (this.description == null)
2608        if (Configuration.errorOnAutoCreate())
2609          throw new Error("Attempt to auto-create InventoryItem.description");
2610        else if (Configuration.doAutoCreate())
2611          this.description = new InventoryItemDescriptionComponent(); // cc
2612      return this.description;
2613    }
2614
2615    public boolean hasDescription() { 
2616      return this.description != null && !this.description.isEmpty();
2617    }
2618
2619    /**
2620     * @param value {@link #description} (The descriptive characteristics of the inventory item.)
2621     */
2622    public InventoryItem setDescription(InventoryItemDescriptionComponent value) { 
2623      this.description = value;
2624      return this;
2625    }
2626
2627    /**
2628     * @return {@link #inventoryStatus} (The usage status e.g. recalled, in use, discarded... This can be used to indicate that the items have been taken out of inventory, or are in use, etc.)
2629     */
2630    public List<CodeableConcept> getInventoryStatus() { 
2631      if (this.inventoryStatus == null)
2632        this.inventoryStatus = new ArrayList<CodeableConcept>();
2633      return this.inventoryStatus;
2634    }
2635
2636    /**
2637     * @return Returns a reference to <code>this</code> for easy method chaining
2638     */
2639    public InventoryItem setInventoryStatus(List<CodeableConcept> theInventoryStatus) { 
2640      this.inventoryStatus = theInventoryStatus;
2641      return this;
2642    }
2643
2644    public boolean hasInventoryStatus() { 
2645      if (this.inventoryStatus == null)
2646        return false;
2647      for (CodeableConcept item : this.inventoryStatus)
2648        if (!item.isEmpty())
2649          return true;
2650      return false;
2651    }
2652
2653    public CodeableConcept addInventoryStatus() { //3
2654      CodeableConcept t = new CodeableConcept();
2655      if (this.inventoryStatus == null)
2656        this.inventoryStatus = new ArrayList<CodeableConcept>();
2657      this.inventoryStatus.add(t);
2658      return t;
2659    }
2660
2661    public InventoryItem addInventoryStatus(CodeableConcept t) { //3
2662      if (t == null)
2663        return this;
2664      if (this.inventoryStatus == null)
2665        this.inventoryStatus = new ArrayList<CodeableConcept>();
2666      this.inventoryStatus.add(t);
2667      return this;
2668    }
2669
2670    /**
2671     * @return The first repetition of repeating field {@link #inventoryStatus}, creating it if it does not already exist {3}
2672     */
2673    public CodeableConcept getInventoryStatusFirstRep() { 
2674      if (getInventoryStatus().isEmpty()) {
2675        addInventoryStatus();
2676      }
2677      return getInventoryStatus().get(0);
2678    }
2679
2680    /**
2681     * @return {@link #baseUnit} (The base unit of measure - the unit in which the product is used or counted.)
2682     */
2683    public CodeableConcept getBaseUnit() { 
2684      if (this.baseUnit == null)
2685        if (Configuration.errorOnAutoCreate())
2686          throw new Error("Attempt to auto-create InventoryItem.baseUnit");
2687        else if (Configuration.doAutoCreate())
2688          this.baseUnit = new CodeableConcept(); // cc
2689      return this.baseUnit;
2690    }
2691
2692    public boolean hasBaseUnit() { 
2693      return this.baseUnit != null && !this.baseUnit.isEmpty();
2694    }
2695
2696    /**
2697     * @param value {@link #baseUnit} (The base unit of measure - the unit in which the product is used or counted.)
2698     */
2699    public InventoryItem setBaseUnit(CodeableConcept value) { 
2700      this.baseUnit = value;
2701      return this;
2702    }
2703
2704    /**
2705     * @return {@link #netContent} (Net content or amount present in the item.)
2706     */
2707    public Quantity getNetContent() { 
2708      if (this.netContent == null)
2709        if (Configuration.errorOnAutoCreate())
2710          throw new Error("Attempt to auto-create InventoryItem.netContent");
2711        else if (Configuration.doAutoCreate())
2712          this.netContent = new Quantity(); // cc
2713      return this.netContent;
2714    }
2715
2716    public boolean hasNetContent() { 
2717      return this.netContent != null && !this.netContent.isEmpty();
2718    }
2719
2720    /**
2721     * @param value {@link #netContent} (Net content or amount present in the item.)
2722     */
2723    public InventoryItem setNetContent(Quantity value) { 
2724      this.netContent = value;
2725      return this;
2726    }
2727
2728    /**
2729     * @return {@link #association} (Association with other items or products.)
2730     */
2731    public List<InventoryItemAssociationComponent> getAssociation() { 
2732      if (this.association == null)
2733        this.association = new ArrayList<InventoryItemAssociationComponent>();
2734      return this.association;
2735    }
2736
2737    /**
2738     * @return Returns a reference to <code>this</code> for easy method chaining
2739     */
2740    public InventoryItem setAssociation(List<InventoryItemAssociationComponent> theAssociation) { 
2741      this.association = theAssociation;
2742      return this;
2743    }
2744
2745    public boolean hasAssociation() { 
2746      if (this.association == null)
2747        return false;
2748      for (InventoryItemAssociationComponent item : this.association)
2749        if (!item.isEmpty())
2750          return true;
2751      return false;
2752    }
2753
2754    public InventoryItemAssociationComponent addAssociation() { //3
2755      InventoryItemAssociationComponent t = new InventoryItemAssociationComponent();
2756      if (this.association == null)
2757        this.association = new ArrayList<InventoryItemAssociationComponent>();
2758      this.association.add(t);
2759      return t;
2760    }
2761
2762    public InventoryItem addAssociation(InventoryItemAssociationComponent t) { //3
2763      if (t == null)
2764        return this;
2765      if (this.association == null)
2766        this.association = new ArrayList<InventoryItemAssociationComponent>();
2767      this.association.add(t);
2768      return this;
2769    }
2770
2771    /**
2772     * @return The first repetition of repeating field {@link #association}, creating it if it does not already exist {3}
2773     */
2774    public InventoryItemAssociationComponent getAssociationFirstRep() { 
2775      if (getAssociation().isEmpty()) {
2776        addAssociation();
2777      }
2778      return getAssociation().get(0);
2779    }
2780
2781    /**
2782     * @return {@link #characteristic} (The descriptive or identifying characteristics of the item.)
2783     */
2784    public List<InventoryItemCharacteristicComponent> getCharacteristic() { 
2785      if (this.characteristic == null)
2786        this.characteristic = new ArrayList<InventoryItemCharacteristicComponent>();
2787      return this.characteristic;
2788    }
2789
2790    /**
2791     * @return Returns a reference to <code>this</code> for easy method chaining
2792     */
2793    public InventoryItem setCharacteristic(List<InventoryItemCharacteristicComponent> theCharacteristic) { 
2794      this.characteristic = theCharacteristic;
2795      return this;
2796    }
2797
2798    public boolean hasCharacteristic() { 
2799      if (this.characteristic == null)
2800        return false;
2801      for (InventoryItemCharacteristicComponent item : this.characteristic)
2802        if (!item.isEmpty())
2803          return true;
2804      return false;
2805    }
2806
2807    public InventoryItemCharacteristicComponent addCharacteristic() { //3
2808      InventoryItemCharacteristicComponent t = new InventoryItemCharacteristicComponent();
2809      if (this.characteristic == null)
2810        this.characteristic = new ArrayList<InventoryItemCharacteristicComponent>();
2811      this.characteristic.add(t);
2812      return t;
2813    }
2814
2815    public InventoryItem addCharacteristic(InventoryItemCharacteristicComponent t) { //3
2816      if (t == null)
2817        return this;
2818      if (this.characteristic == null)
2819        this.characteristic = new ArrayList<InventoryItemCharacteristicComponent>();
2820      this.characteristic.add(t);
2821      return this;
2822    }
2823
2824    /**
2825     * @return The first repetition of repeating field {@link #characteristic}, creating it if it does not already exist {3}
2826     */
2827    public InventoryItemCharacteristicComponent getCharacteristicFirstRep() { 
2828      if (getCharacteristic().isEmpty()) {
2829        addCharacteristic();
2830      }
2831      return getCharacteristic().get(0);
2832    }
2833
2834    /**
2835     * @return {@link #instance} (Instances or occurrences of the product.)
2836     */
2837    public InventoryItemInstanceComponent getInstance() { 
2838      if (this.instance == null)
2839        if (Configuration.errorOnAutoCreate())
2840          throw new Error("Attempt to auto-create InventoryItem.instance");
2841        else if (Configuration.doAutoCreate())
2842          this.instance = new InventoryItemInstanceComponent(); // cc
2843      return this.instance;
2844    }
2845
2846    public boolean hasInstance() { 
2847      return this.instance != null && !this.instance.isEmpty();
2848    }
2849
2850    /**
2851     * @param value {@link #instance} (Instances or occurrences of the product.)
2852     */
2853    public InventoryItem setInstance(InventoryItemInstanceComponent value) { 
2854      this.instance = value;
2855      return this;
2856    }
2857
2858    /**
2859     * @return {@link #productReference} (Link to a product resource used in clinical workflows.)
2860     */
2861    public Reference getProductReference() { 
2862      if (this.productReference == null)
2863        if (Configuration.errorOnAutoCreate())
2864          throw new Error("Attempt to auto-create InventoryItem.productReference");
2865        else if (Configuration.doAutoCreate())
2866          this.productReference = new Reference(); // cc
2867      return this.productReference;
2868    }
2869
2870    public boolean hasProductReference() { 
2871      return this.productReference != null && !this.productReference.isEmpty();
2872    }
2873
2874    /**
2875     * @param value {@link #productReference} (Link to a product resource used in clinical workflows.)
2876     */
2877    public InventoryItem setProductReference(Reference value) { 
2878      this.productReference = value;
2879      return this;
2880    }
2881
2882      protected void listChildren(List<Property> children) {
2883        super.listChildren(children);
2884        children.add(new Property("identifier", "Identifier", "Business identifier for the inventory item.", 0, java.lang.Integer.MAX_VALUE, identifier));
2885        children.add(new Property("status", "code", "Status of the item entry.", 0, 1, status));
2886        children.add(new Property("category", "CodeableConcept", "Category or class of the item.", 0, java.lang.Integer.MAX_VALUE, category));
2887        children.add(new Property("code", "CodeableConcept", "Code designating the specific type of item.", 0, java.lang.Integer.MAX_VALUE, code));
2888        children.add(new Property("name", "", "The item name(s) - the brand name, or common name, functional name, generic name.", 0, java.lang.Integer.MAX_VALUE, name));
2889        children.add(new Property("responsibleOrganization", "", "Organization(s) responsible for the product.", 0, java.lang.Integer.MAX_VALUE, responsibleOrganization));
2890        children.add(new Property("description", "", "The descriptive characteristics of the inventory item.", 0, 1, description));
2891        children.add(new Property("inventoryStatus", "CodeableConcept", "The usage status e.g. recalled, in use, discarded... This can be used to indicate that the items have been taken out of inventory, or are in use, etc.", 0, java.lang.Integer.MAX_VALUE, inventoryStatus));
2892        children.add(new Property("baseUnit", "CodeableConcept", "The base unit of measure - the unit in which the product is used or counted.", 0, 1, baseUnit));
2893        children.add(new Property("netContent", "Quantity", "Net content or amount present in the item.", 0, 1, netContent));
2894        children.add(new Property("association", "", "Association with other items or products.", 0, java.lang.Integer.MAX_VALUE, association));
2895        children.add(new Property("characteristic", "", "The descriptive or identifying characteristics of the item.", 0, java.lang.Integer.MAX_VALUE, characteristic));
2896        children.add(new Property("instance", "", "Instances or occurrences of the product.", 0, 1, instance));
2897        children.add(new Property("productReference", "Reference(Medication|Device|NutritionProduct|BiologicallyDerivedProduct)", "Link to a product resource used in clinical workflows.", 0, 1, productReference));
2898      }
2899
2900      @Override
2901      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2902        switch (_hash) {
2903        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Business identifier for the inventory item.", 0, java.lang.Integer.MAX_VALUE, identifier);
2904        case -892481550: /*status*/  return new Property("status", "code", "Status of the item entry.", 0, 1, status);
2905        case 50511102: /*category*/  return new Property("category", "CodeableConcept", "Category or class of the item.", 0, java.lang.Integer.MAX_VALUE, category);
2906        case 3059181: /*code*/  return new Property("code", "CodeableConcept", "Code designating the specific type of item.", 0, java.lang.Integer.MAX_VALUE, code);
2907        case 3373707: /*name*/  return new Property("name", "", "The item name(s) - the brand name, or common name, functional name, generic name.", 0, java.lang.Integer.MAX_VALUE, name);
2908        case -1704933559: /*responsibleOrganization*/  return new Property("responsibleOrganization", "", "Organization(s) responsible for the product.", 0, java.lang.Integer.MAX_VALUE, responsibleOrganization);
2909        case -1724546052: /*description*/  return new Property("description", "", "The descriptive characteristics of the inventory item.", 0, 1, description);
2910        case -1370922898: /*inventoryStatus*/  return new Property("inventoryStatus", "CodeableConcept", "The usage status e.g. recalled, in use, discarded... This can be used to indicate that the items have been taken out of inventory, or are in use, etc.", 0, java.lang.Integer.MAX_VALUE, inventoryStatus);
2911        case -1721465867: /*baseUnit*/  return new Property("baseUnit", "CodeableConcept", "The base unit of measure - the unit in which the product is used or counted.", 0, 1, baseUnit);
2912        case 612796444: /*netContent*/  return new Property("netContent", "Quantity", "Net content or amount present in the item.", 0, 1, netContent);
2913        case -87499647: /*association*/  return new Property("association", "", "Association with other items or products.", 0, java.lang.Integer.MAX_VALUE, association);
2914        case 366313883: /*characteristic*/  return new Property("characteristic", "", "The descriptive or identifying characteristics of the item.", 0, java.lang.Integer.MAX_VALUE, characteristic);
2915        case 555127957: /*instance*/  return new Property("instance", "", "Instances or occurrences of the product.", 0, 1, instance);
2916        case -669667556: /*productReference*/  return new Property("productReference", "Reference(Medication|Device|NutritionProduct|BiologicallyDerivedProduct)", "Link to a product resource used in clinical workflows.", 0, 1, productReference);
2917        default: return super.getNamedProperty(_hash, _name, _checkValid);
2918        }
2919
2920      }
2921
2922      @Override
2923      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2924        switch (hash) {
2925        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2926        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<InventoryItemStatusCodes>
2927        case 50511102: /*category*/ return this.category == null ? new Base[0] : this.category.toArray(new Base[this.category.size()]); // CodeableConcept
2928        case 3059181: /*code*/ return this.code == null ? new Base[0] : this.code.toArray(new Base[this.code.size()]); // CodeableConcept
2929        case 3373707: /*name*/ return this.name == null ? new Base[0] : this.name.toArray(new Base[this.name.size()]); // InventoryItemNameComponent
2930        case -1704933559: /*responsibleOrganization*/ return this.responsibleOrganization == null ? new Base[0] : this.responsibleOrganization.toArray(new Base[this.responsibleOrganization.size()]); // InventoryItemResponsibleOrganizationComponent
2931        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // InventoryItemDescriptionComponent
2932        case -1370922898: /*inventoryStatus*/ return this.inventoryStatus == null ? new Base[0] : this.inventoryStatus.toArray(new Base[this.inventoryStatus.size()]); // CodeableConcept
2933        case -1721465867: /*baseUnit*/ return this.baseUnit == null ? new Base[0] : new Base[] {this.baseUnit}; // CodeableConcept
2934        case 612796444: /*netContent*/ return this.netContent == null ? new Base[0] : new Base[] {this.netContent}; // Quantity
2935        case -87499647: /*association*/ return this.association == null ? new Base[0] : this.association.toArray(new Base[this.association.size()]); // InventoryItemAssociationComponent
2936        case 366313883: /*characteristic*/ return this.characteristic == null ? new Base[0] : this.characteristic.toArray(new Base[this.characteristic.size()]); // InventoryItemCharacteristicComponent
2937        case 555127957: /*instance*/ return this.instance == null ? new Base[0] : new Base[] {this.instance}; // InventoryItemInstanceComponent
2938        case -669667556: /*productReference*/ return this.productReference == null ? new Base[0] : new Base[] {this.productReference}; // Reference
2939        default: return super.getProperty(hash, name, checkValid);
2940        }
2941
2942      }
2943
2944      @Override
2945      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2946        switch (hash) {
2947        case -1618432855: // identifier
2948          this.getIdentifier().add(TypeConvertor.castToIdentifier(value)); // Identifier
2949          return value;
2950        case -892481550: // status
2951          value = new InventoryItemStatusCodesEnumFactory().fromType(TypeConvertor.castToCode(value));
2952          this.status = (Enumeration) value; // Enumeration<InventoryItemStatusCodes>
2953          return value;
2954        case 50511102: // category
2955          this.getCategory().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
2956          return value;
2957        case 3059181: // code
2958          this.getCode().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
2959          return value;
2960        case 3373707: // name
2961          this.getName().add((InventoryItemNameComponent) value); // InventoryItemNameComponent
2962          return value;
2963        case -1704933559: // responsibleOrganization
2964          this.getResponsibleOrganization().add((InventoryItemResponsibleOrganizationComponent) value); // InventoryItemResponsibleOrganizationComponent
2965          return value;
2966        case -1724546052: // description
2967          this.description = (InventoryItemDescriptionComponent) value; // InventoryItemDescriptionComponent
2968          return value;
2969        case -1370922898: // inventoryStatus
2970          this.getInventoryStatus().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
2971          return value;
2972        case -1721465867: // baseUnit
2973          this.baseUnit = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2974          return value;
2975        case 612796444: // netContent
2976          this.netContent = TypeConvertor.castToQuantity(value); // Quantity
2977          return value;
2978        case -87499647: // association
2979          this.getAssociation().add((InventoryItemAssociationComponent) value); // InventoryItemAssociationComponent
2980          return value;
2981        case 366313883: // characteristic
2982          this.getCharacteristic().add((InventoryItemCharacteristicComponent) value); // InventoryItemCharacteristicComponent
2983          return value;
2984        case 555127957: // instance
2985          this.instance = (InventoryItemInstanceComponent) value; // InventoryItemInstanceComponent
2986          return value;
2987        case -669667556: // productReference
2988          this.productReference = TypeConvertor.castToReference(value); // Reference
2989          return value;
2990        default: return super.setProperty(hash, name, value);
2991        }
2992
2993      }
2994
2995      @Override
2996      public Base setProperty(String name, Base value) throws FHIRException {
2997        if (name.equals("identifier")) {
2998          this.getIdentifier().add(TypeConvertor.castToIdentifier(value));
2999        } else if (name.equals("status")) {
3000          value = new InventoryItemStatusCodesEnumFactory().fromType(TypeConvertor.castToCode(value));
3001          this.status = (Enumeration) value; // Enumeration<InventoryItemStatusCodes>
3002        } else if (name.equals("category")) {
3003          this.getCategory().add(TypeConvertor.castToCodeableConcept(value));
3004        } else if (name.equals("code")) {
3005          this.getCode().add(TypeConvertor.castToCodeableConcept(value));
3006        } else if (name.equals("name")) {
3007          this.getName().add((InventoryItemNameComponent) value);
3008        } else if (name.equals("responsibleOrganization")) {
3009          this.getResponsibleOrganization().add((InventoryItemResponsibleOrganizationComponent) value);
3010        } else if (name.equals("description")) {
3011          this.description = (InventoryItemDescriptionComponent) value; // InventoryItemDescriptionComponent
3012        } else if (name.equals("inventoryStatus")) {
3013          this.getInventoryStatus().add(TypeConvertor.castToCodeableConcept(value));
3014        } else if (name.equals("baseUnit")) {
3015          this.baseUnit = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3016        } else if (name.equals("netContent")) {
3017          this.netContent = TypeConvertor.castToQuantity(value); // Quantity
3018        } else if (name.equals("association")) {
3019          this.getAssociation().add((InventoryItemAssociationComponent) value);
3020        } else if (name.equals("characteristic")) {
3021          this.getCharacteristic().add((InventoryItemCharacteristicComponent) value);
3022        } else if (name.equals("instance")) {
3023          this.instance = (InventoryItemInstanceComponent) value; // InventoryItemInstanceComponent
3024        } else if (name.equals("productReference")) {
3025          this.productReference = TypeConvertor.castToReference(value); // Reference
3026        } else
3027          return super.setProperty(name, value);
3028        return value;
3029      }
3030
3031  @Override
3032  public void removeChild(String name, Base value) throws FHIRException {
3033        if (name.equals("identifier")) {
3034          this.getIdentifier().remove(value);
3035        } else if (name.equals("status")) {
3036          value = new InventoryItemStatusCodesEnumFactory().fromType(TypeConvertor.castToCode(value));
3037          this.status = (Enumeration) value; // Enumeration<InventoryItemStatusCodes>
3038        } else if (name.equals("category")) {
3039          this.getCategory().remove(value);
3040        } else if (name.equals("code")) {
3041          this.getCode().remove(value);
3042        } else if (name.equals("name")) {
3043          this.getName().remove((InventoryItemNameComponent) value);
3044        } else if (name.equals("responsibleOrganization")) {
3045          this.getResponsibleOrganization().remove((InventoryItemResponsibleOrganizationComponent) value);
3046        } else if (name.equals("description")) {
3047          this.description = (InventoryItemDescriptionComponent) value; // InventoryItemDescriptionComponent
3048        } else if (name.equals("inventoryStatus")) {
3049          this.getInventoryStatus().remove(value);
3050        } else if (name.equals("baseUnit")) {
3051          this.baseUnit = null;
3052        } else if (name.equals("netContent")) {
3053          this.netContent = null;
3054        } else if (name.equals("association")) {
3055          this.getAssociation().remove((InventoryItemAssociationComponent) value);
3056        } else if (name.equals("characteristic")) {
3057          this.getCharacteristic().remove((InventoryItemCharacteristicComponent) value);
3058        } else if (name.equals("instance")) {
3059          this.instance = (InventoryItemInstanceComponent) value; // InventoryItemInstanceComponent
3060        } else if (name.equals("productReference")) {
3061          this.productReference = null;
3062        } else
3063          super.removeChild(name, value);
3064        
3065      }
3066
3067      @Override
3068      public Base makeProperty(int hash, String name) throws FHIRException {
3069        switch (hash) {
3070        case -1618432855:  return addIdentifier(); 
3071        case -892481550:  return getStatusElement();
3072        case 50511102:  return addCategory(); 
3073        case 3059181:  return addCode(); 
3074        case 3373707:  return addName(); 
3075        case -1704933559:  return addResponsibleOrganization(); 
3076        case -1724546052:  return getDescription();
3077        case -1370922898:  return addInventoryStatus(); 
3078        case -1721465867:  return getBaseUnit();
3079        case 612796444:  return getNetContent();
3080        case -87499647:  return addAssociation(); 
3081        case 366313883:  return addCharacteristic(); 
3082        case 555127957:  return getInstance();
3083        case -669667556:  return getProductReference();
3084        default: return super.makeProperty(hash, name);
3085        }
3086
3087      }
3088
3089      @Override
3090      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
3091        switch (hash) {
3092        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
3093        case -892481550: /*status*/ return new String[] {"code"};
3094        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
3095        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
3096        case 3373707: /*name*/ return new String[] {};
3097        case -1704933559: /*responsibleOrganization*/ return new String[] {};
3098        case -1724546052: /*description*/ return new String[] {};
3099        case -1370922898: /*inventoryStatus*/ return new String[] {"CodeableConcept"};
3100        case -1721465867: /*baseUnit*/ return new String[] {"CodeableConcept"};
3101        case 612796444: /*netContent*/ return new String[] {"Quantity"};
3102        case -87499647: /*association*/ return new String[] {};
3103        case 366313883: /*characteristic*/ return new String[] {};
3104        case 555127957: /*instance*/ return new String[] {};
3105        case -669667556: /*productReference*/ return new String[] {"Reference"};
3106        default: return super.getTypesForProperty(hash, name);
3107        }
3108
3109      }
3110
3111      @Override
3112      public Base addChild(String name) throws FHIRException {
3113        if (name.equals("identifier")) {
3114          return addIdentifier();
3115        }
3116        else if (name.equals("status")) {
3117          throw new FHIRException("Cannot call addChild on a singleton property InventoryItem.status");
3118        }
3119        else if (name.equals("category")) {
3120          return addCategory();
3121        }
3122        else if (name.equals("code")) {
3123          return addCode();
3124        }
3125        else if (name.equals("name")) {
3126          return addName();
3127        }
3128        else if (name.equals("responsibleOrganization")) {
3129          return addResponsibleOrganization();
3130        }
3131        else if (name.equals("description")) {
3132          this.description = new InventoryItemDescriptionComponent();
3133          return this.description;
3134        }
3135        else if (name.equals("inventoryStatus")) {
3136          return addInventoryStatus();
3137        }
3138        else if (name.equals("baseUnit")) {
3139          this.baseUnit = new CodeableConcept();
3140          return this.baseUnit;
3141        }
3142        else if (name.equals("netContent")) {
3143          this.netContent = new Quantity();
3144          return this.netContent;
3145        }
3146        else if (name.equals("association")) {
3147          return addAssociation();
3148        }
3149        else if (name.equals("characteristic")) {
3150          return addCharacteristic();
3151        }
3152        else if (name.equals("instance")) {
3153          this.instance = new InventoryItemInstanceComponent();
3154          return this.instance;
3155        }
3156        else if (name.equals("productReference")) {
3157          this.productReference = new Reference();
3158          return this.productReference;
3159        }
3160        else
3161          return super.addChild(name);
3162      }
3163
3164  public String fhirType() {
3165    return "InventoryItem";
3166
3167  }
3168
3169      public InventoryItem copy() {
3170        InventoryItem dst = new InventoryItem();
3171        copyValues(dst);
3172        return dst;
3173      }
3174
3175      public void copyValues(InventoryItem dst) {
3176        super.copyValues(dst);
3177        if (identifier != null) {
3178          dst.identifier = new ArrayList<Identifier>();
3179          for (Identifier i : identifier)
3180            dst.identifier.add(i.copy());
3181        };
3182        dst.status = status == null ? null : status.copy();
3183        if (category != null) {
3184          dst.category = new ArrayList<CodeableConcept>();
3185          for (CodeableConcept i : category)
3186            dst.category.add(i.copy());
3187        };
3188        if (code != null) {
3189          dst.code = new ArrayList<CodeableConcept>();
3190          for (CodeableConcept i : code)
3191            dst.code.add(i.copy());
3192        };
3193        if (name != null) {
3194          dst.name = new ArrayList<InventoryItemNameComponent>();
3195          for (InventoryItemNameComponent i : name)
3196            dst.name.add(i.copy());
3197        };
3198        if (responsibleOrganization != null) {
3199          dst.responsibleOrganization = new ArrayList<InventoryItemResponsibleOrganizationComponent>();
3200          for (InventoryItemResponsibleOrganizationComponent i : responsibleOrganization)
3201            dst.responsibleOrganization.add(i.copy());
3202        };
3203        dst.description = description == null ? null : description.copy();
3204        if (inventoryStatus != null) {
3205          dst.inventoryStatus = new ArrayList<CodeableConcept>();
3206          for (CodeableConcept i : inventoryStatus)
3207            dst.inventoryStatus.add(i.copy());
3208        };
3209        dst.baseUnit = baseUnit == null ? null : baseUnit.copy();
3210        dst.netContent = netContent == null ? null : netContent.copy();
3211        if (association != null) {
3212          dst.association = new ArrayList<InventoryItemAssociationComponent>();
3213          for (InventoryItemAssociationComponent i : association)
3214            dst.association.add(i.copy());
3215        };
3216        if (characteristic != null) {
3217          dst.characteristic = new ArrayList<InventoryItemCharacteristicComponent>();
3218          for (InventoryItemCharacteristicComponent i : characteristic)
3219            dst.characteristic.add(i.copy());
3220        };
3221        dst.instance = instance == null ? null : instance.copy();
3222        dst.productReference = productReference == null ? null : productReference.copy();
3223      }
3224
3225      protected InventoryItem typedCopy() {
3226        return copy();
3227      }
3228
3229      @Override
3230      public boolean equalsDeep(Base other_) {
3231        if (!super.equalsDeep(other_))
3232          return false;
3233        if (!(other_ instanceof InventoryItem))
3234          return false;
3235        InventoryItem o = (InventoryItem) other_;
3236        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(category, o.category, true)
3237           && compareDeep(code, o.code, true) && compareDeep(name, o.name, true) && compareDeep(responsibleOrganization, o.responsibleOrganization, true)
3238           && compareDeep(description, o.description, true) && compareDeep(inventoryStatus, o.inventoryStatus, true)
3239           && compareDeep(baseUnit, o.baseUnit, true) && compareDeep(netContent, o.netContent, true) && compareDeep(association, o.association, true)
3240           && compareDeep(characteristic, o.characteristic, true) && compareDeep(instance, o.instance, true)
3241           && compareDeep(productReference, o.productReference, true);
3242      }
3243
3244      @Override
3245      public boolean equalsShallow(Base other_) {
3246        if (!super.equalsShallow(other_))
3247          return false;
3248        if (!(other_ instanceof InventoryItem))
3249          return false;
3250        InventoryItem o = (InventoryItem) other_;
3251        return compareValues(status, o.status, true);
3252      }
3253
3254      public boolean isEmpty() {
3255        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, category
3256          , code, name, responsibleOrganization, description, inventoryStatus, baseUnit, netContent
3257          , association, characteristic, instance, productReference);
3258      }
3259
3260  @Override
3261  public ResourceType getResourceType() {
3262    return ResourceType.InventoryItem;
3263   }
3264
3265 /**
3266   * Search parameter: <b>code</b>
3267   * <p>
3268   * Description: <b>Search for products that match this code</b><br>
3269   * Type: <b>token</b><br>
3270   * Path: <b>InventoryItem.code</b><br>
3271   * </p>
3272   */
3273  @SearchParamDefinition(name="code", path="InventoryItem.code", description="Search for products that match this code", type="token" )
3274  public static final String SP_CODE = "code";
3275 /**
3276   * <b>Fluent Client</b> search parameter constant for <b>code</b>
3277   * <p>
3278   * Description: <b>Search for products that match this code</b><br>
3279   * Type: <b>token</b><br>
3280   * Path: <b>InventoryItem.code</b><br>
3281   * </p>
3282   */
3283  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
3284
3285 /**
3286   * Search parameter: <b>identifier</b>
3287   * <p>
3288   * Description: <b>The identifier of the item</b><br>
3289   * Type: <b>token</b><br>
3290   * Path: <b>InventoryItem.identifier</b><br>
3291   * </p>
3292   */
3293  @SearchParamDefinition(name="identifier", path="InventoryItem.identifier", description="The identifier of the item", type="token" )
3294  public static final String SP_IDENTIFIER = "identifier";
3295 /**
3296   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
3297   * <p>
3298   * Description: <b>The identifier of the item</b><br>
3299   * Type: <b>token</b><br>
3300   * Path: <b>InventoryItem.identifier</b><br>
3301   * </p>
3302   */
3303  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
3304
3305 /**
3306   * Search parameter: <b>status</b>
3307   * <p>
3308   * Description: <b>The status of the item</b><br>
3309   * Type: <b>token</b><br>
3310   * Path: <b>InventoryItem.status</b><br>
3311   * </p>
3312   */
3313  @SearchParamDefinition(name="status", path="InventoryItem.status", description="The status of the item", type="token" )
3314  public static final String SP_STATUS = "status";
3315 /**
3316   * <b>Fluent Client</b> search parameter constant for <b>status</b>
3317   * <p>
3318   * Description: <b>The status of the item</b><br>
3319   * Type: <b>token</b><br>
3320   * Path: <b>InventoryItem.status</b><br>
3321   * </p>
3322   */
3323  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
3324
3325 /**
3326   * Search parameter: <b>subject</b>
3327   * <p>
3328   * Description: <b>The identity of a patient for whom to list associations</b><br>
3329   * Type: <b>reference</b><br>
3330   * Path: <b>InventoryItem.instance.subject</b><br>
3331   * </p>
3332   */
3333  @SearchParamDefinition(name="subject", path="InventoryItem.instance.subject", description="The identity of a patient for whom to list associations", type="reference", target={Organization.class, Patient.class } )
3334  public static final String SP_SUBJECT = "subject";
3335 /**
3336   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
3337   * <p>
3338   * Description: <b>The identity of a patient for whom to list associations</b><br>
3339   * Type: <b>reference</b><br>
3340   * Path: <b>InventoryItem.instance.subject</b><br>
3341   * </p>
3342   */
3343  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
3344
3345/**
3346   * Constant for fluent queries to be used to add include statements. Specifies
3347   * the path value of "<b>InventoryItem:subject</b>".
3348   */
3349  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("InventoryItem:subject").toLocked();
3350
3351
3352}
3353