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 * A report of inventory or stock items.
052 */
053@ResourceDef(name="InventoryReport", profile="http://hl7.org/fhir/StructureDefinition/InventoryReport")
054public class InventoryReport extends DomainResource {
055
056    public enum InventoryCountType {
057        /**
058         * The inventory report is a current absolute snapshot, i.e. it represents the quantities at hand.
059         */
060        SNAPSHOT, 
061        /**
062         * The inventory report is about the difference between a previous count and a current count, i.e. it represents the items that have been added/subtracted from inventory.
063         */
064        DIFFERENCE, 
065        /**
066         * added to help the parsers with the generic types
067         */
068        NULL;
069        public static InventoryCountType fromCode(String codeString) throws FHIRException {
070            if (codeString == null || "".equals(codeString))
071                return null;
072        if ("snapshot".equals(codeString))
073          return SNAPSHOT;
074        if ("difference".equals(codeString))
075          return DIFFERENCE;
076        if (Configuration.isAcceptInvalidEnums())
077          return null;
078        else
079          throw new FHIRException("Unknown InventoryCountType code '"+codeString+"'");
080        }
081        public String toCode() {
082          switch (this) {
083            case SNAPSHOT: return "snapshot";
084            case DIFFERENCE: return "difference";
085            case NULL: return null;
086            default: return "?";
087          }
088        }
089        public String getSystem() {
090          switch (this) {
091            case SNAPSHOT: return "http://hl7.org/fhir/inventoryreport-counttype";
092            case DIFFERENCE: return "http://hl7.org/fhir/inventoryreport-counttype";
093            case NULL: return null;
094            default: return "?";
095          }
096        }
097        public String getDefinition() {
098          switch (this) {
099            case SNAPSHOT: return "The inventory report is a current absolute snapshot, i.e. it represents the quantities at hand.";
100            case DIFFERENCE: return "The inventory report is about the difference between a previous count and a current count, i.e. it represents the items that have been added/subtracted from inventory.";
101            case NULL: return null;
102            default: return "?";
103          }
104        }
105        public String getDisplay() {
106          switch (this) {
107            case SNAPSHOT: return "Snapshot";
108            case DIFFERENCE: return "Difference";
109            case NULL: return null;
110            default: return "?";
111          }
112        }
113    }
114
115  public static class InventoryCountTypeEnumFactory implements EnumFactory<InventoryCountType> {
116    public InventoryCountType fromCode(String codeString) throws IllegalArgumentException {
117      if (codeString == null || "".equals(codeString))
118            if (codeString == null || "".equals(codeString))
119                return null;
120        if ("snapshot".equals(codeString))
121          return InventoryCountType.SNAPSHOT;
122        if ("difference".equals(codeString))
123          return InventoryCountType.DIFFERENCE;
124        throw new IllegalArgumentException("Unknown InventoryCountType code '"+codeString+"'");
125        }
126        public Enumeration<InventoryCountType> fromType(PrimitiveType<?> code) throws FHIRException {
127          if (code == null)
128            return null;
129          if (code.isEmpty())
130            return new Enumeration<InventoryCountType>(this, InventoryCountType.NULL, code);
131          String codeString = ((PrimitiveType) code).asStringValue();
132          if (codeString == null || "".equals(codeString))
133            return new Enumeration<InventoryCountType>(this, InventoryCountType.NULL, code);
134        if ("snapshot".equals(codeString))
135          return new Enumeration<InventoryCountType>(this, InventoryCountType.SNAPSHOT, code);
136        if ("difference".equals(codeString))
137          return new Enumeration<InventoryCountType>(this, InventoryCountType.DIFFERENCE, code);
138        throw new FHIRException("Unknown InventoryCountType code '"+codeString+"'");
139        }
140    public String toCode(InventoryCountType code) {
141      if (code == InventoryCountType.SNAPSHOT)
142        return "snapshot";
143      if (code == InventoryCountType.DIFFERENCE)
144        return "difference";
145      return "?";
146      }
147    public String toSystem(InventoryCountType code) {
148      return code.getSystem();
149      }
150    }
151
152    public enum InventoryReportStatus {
153        /**
154         * The existence of the report is registered, but it is still without content or only some preliminary content.
155         */
156        DRAFT, 
157        /**
158         * The inventory report has been requested but there is no data available.
159         */
160        REQUESTED, 
161        /**
162         * This report is submitted as current.
163         */
164        ACTIVE, 
165        /**
166         * The report has been withdrawn following a previous final release.  This electronic record should never have existed, though it is possible that real-world decisions were based on it.
167         */
168        ENTEREDINERROR, 
169        /**
170         * added to help the parsers with the generic types
171         */
172        NULL;
173        public static InventoryReportStatus fromCode(String codeString) throws FHIRException {
174            if (codeString == null || "".equals(codeString))
175                return null;
176        if ("draft".equals(codeString))
177          return DRAFT;
178        if ("requested".equals(codeString))
179          return REQUESTED;
180        if ("active".equals(codeString))
181          return ACTIVE;
182        if ("entered-in-error".equals(codeString))
183          return ENTEREDINERROR;
184        if (Configuration.isAcceptInvalidEnums())
185          return null;
186        else
187          throw new FHIRException("Unknown InventoryReportStatus code '"+codeString+"'");
188        }
189        public String toCode() {
190          switch (this) {
191            case DRAFT: return "draft";
192            case REQUESTED: return "requested";
193            case ACTIVE: return "active";
194            case ENTEREDINERROR: return "entered-in-error";
195            case NULL: return null;
196            default: return "?";
197          }
198        }
199        public String getSystem() {
200          switch (this) {
201            case DRAFT: return "http://hl7.org/fhir/inventoryreport-status";
202            case REQUESTED: return "http://hl7.org/fhir/inventoryreport-status";
203            case ACTIVE: return "http://hl7.org/fhir/inventoryreport-status";
204            case ENTEREDINERROR: return "http://hl7.org/fhir/inventoryreport-status";
205            case NULL: return null;
206            default: return "?";
207          }
208        }
209        public String getDefinition() {
210          switch (this) {
211            case DRAFT: return "The existence of the report is registered, but it is still without content or only some preliminary content.";
212            case REQUESTED: return "The inventory report has been requested but there is no data available.";
213            case ACTIVE: return "This report is submitted as current.";
214            case ENTEREDINERROR: return "The report has been withdrawn following a previous final release.  This electronic record should never have existed, though it is possible that real-world decisions were based on it.";
215            case NULL: return null;
216            default: return "?";
217          }
218        }
219        public String getDisplay() {
220          switch (this) {
221            case DRAFT: return "Draft";
222            case REQUESTED: return "Requested";
223            case ACTIVE: return "Active";
224            case ENTEREDINERROR: return "Entered in Error";
225            case NULL: return null;
226            default: return "?";
227          }
228        }
229    }
230
231  public static class InventoryReportStatusEnumFactory implements EnumFactory<InventoryReportStatus> {
232    public InventoryReportStatus fromCode(String codeString) throws IllegalArgumentException {
233      if (codeString == null || "".equals(codeString))
234            if (codeString == null || "".equals(codeString))
235                return null;
236        if ("draft".equals(codeString))
237          return InventoryReportStatus.DRAFT;
238        if ("requested".equals(codeString))
239          return InventoryReportStatus.REQUESTED;
240        if ("active".equals(codeString))
241          return InventoryReportStatus.ACTIVE;
242        if ("entered-in-error".equals(codeString))
243          return InventoryReportStatus.ENTEREDINERROR;
244        throw new IllegalArgumentException("Unknown InventoryReportStatus code '"+codeString+"'");
245        }
246        public Enumeration<InventoryReportStatus> fromType(PrimitiveType<?> code) throws FHIRException {
247          if (code == null)
248            return null;
249          if (code.isEmpty())
250            return new Enumeration<InventoryReportStatus>(this, InventoryReportStatus.NULL, code);
251          String codeString = ((PrimitiveType) code).asStringValue();
252          if (codeString == null || "".equals(codeString))
253            return new Enumeration<InventoryReportStatus>(this, InventoryReportStatus.NULL, code);
254        if ("draft".equals(codeString))
255          return new Enumeration<InventoryReportStatus>(this, InventoryReportStatus.DRAFT, code);
256        if ("requested".equals(codeString))
257          return new Enumeration<InventoryReportStatus>(this, InventoryReportStatus.REQUESTED, code);
258        if ("active".equals(codeString))
259          return new Enumeration<InventoryReportStatus>(this, InventoryReportStatus.ACTIVE, code);
260        if ("entered-in-error".equals(codeString))
261          return new Enumeration<InventoryReportStatus>(this, InventoryReportStatus.ENTEREDINERROR, code);
262        throw new FHIRException("Unknown InventoryReportStatus code '"+codeString+"'");
263        }
264    public String toCode(InventoryReportStatus code) {
265      if (code == InventoryReportStatus.DRAFT)
266        return "draft";
267      if (code == InventoryReportStatus.REQUESTED)
268        return "requested";
269      if (code == InventoryReportStatus.ACTIVE)
270        return "active";
271      if (code == InventoryReportStatus.ENTEREDINERROR)
272        return "entered-in-error";
273      return "?";
274      }
275    public String toSystem(InventoryReportStatus code) {
276      return code.getSystem();
277      }
278    }
279
280    @Block()
281    public static class InventoryReportInventoryListingComponent extends BackboneElement implements IBaseBackboneElement {
282        /**
283         * Location of the inventory items.
284         */
285        @Child(name = "location", type = {Location.class}, order=1, min=0, max=1, modifier=false, summary=false)
286        @Description(shortDefinition="Location of the inventory items", formalDefinition="Location of the inventory items." )
287        protected Reference location;
288
289        /**
290         * The status of the items.
291         */
292        @Child(name = "itemStatus", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
293        @Description(shortDefinition="The status of the items that are being reported", formalDefinition="The status of the items." )
294        protected CodeableConcept itemStatus;
295
296        /**
297         * The date and time when the items were counted.
298         */
299        @Child(name = "countingDateTime", type = {DateTimeType.class}, order=3, min=0, max=1, modifier=false, summary=false)
300        @Description(shortDefinition="The date and time when the items were counted", formalDefinition="The date and time when the items were counted." )
301        protected DateTimeType countingDateTime;
302
303        /**
304         * The item or items in this listing.
305         */
306        @Child(name = "item", type = {}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
307        @Description(shortDefinition="The item or items in this listing", formalDefinition="The item or items in this listing." )
308        protected List<InventoryReportInventoryListingItemComponent> item;
309
310        private static final long serialVersionUID = 1766136476L;
311
312    /**
313     * Constructor
314     */
315      public InventoryReportInventoryListingComponent() {
316        super();
317      }
318
319        /**
320         * @return {@link #location} (Location of the inventory items.)
321         */
322        public Reference getLocation() { 
323          if (this.location == null)
324            if (Configuration.errorOnAutoCreate())
325              throw new Error("Attempt to auto-create InventoryReportInventoryListingComponent.location");
326            else if (Configuration.doAutoCreate())
327              this.location = new Reference(); // cc
328          return this.location;
329        }
330
331        public boolean hasLocation() { 
332          return this.location != null && !this.location.isEmpty();
333        }
334
335        /**
336         * @param value {@link #location} (Location of the inventory items.)
337         */
338        public InventoryReportInventoryListingComponent setLocation(Reference value) { 
339          this.location = value;
340          return this;
341        }
342
343        /**
344         * @return {@link #itemStatus} (The status of the items.)
345         */
346        public CodeableConcept getItemStatus() { 
347          if (this.itemStatus == null)
348            if (Configuration.errorOnAutoCreate())
349              throw new Error("Attempt to auto-create InventoryReportInventoryListingComponent.itemStatus");
350            else if (Configuration.doAutoCreate())
351              this.itemStatus = new CodeableConcept(); // cc
352          return this.itemStatus;
353        }
354
355        public boolean hasItemStatus() { 
356          return this.itemStatus != null && !this.itemStatus.isEmpty();
357        }
358
359        /**
360         * @param value {@link #itemStatus} (The status of the items.)
361         */
362        public InventoryReportInventoryListingComponent setItemStatus(CodeableConcept value) { 
363          this.itemStatus = value;
364          return this;
365        }
366
367        /**
368         * @return {@link #countingDateTime} (The date and time when the items were counted.). This is the underlying object with id, value and extensions. The accessor "getCountingDateTime" gives direct access to the value
369         */
370        public DateTimeType getCountingDateTimeElement() { 
371          if (this.countingDateTime == null)
372            if (Configuration.errorOnAutoCreate())
373              throw new Error("Attempt to auto-create InventoryReportInventoryListingComponent.countingDateTime");
374            else if (Configuration.doAutoCreate())
375              this.countingDateTime = new DateTimeType(); // bb
376          return this.countingDateTime;
377        }
378
379        public boolean hasCountingDateTimeElement() { 
380          return this.countingDateTime != null && !this.countingDateTime.isEmpty();
381        }
382
383        public boolean hasCountingDateTime() { 
384          return this.countingDateTime != null && !this.countingDateTime.isEmpty();
385        }
386
387        /**
388         * @param value {@link #countingDateTime} (The date and time when the items were counted.). This is the underlying object with id, value and extensions. The accessor "getCountingDateTime" gives direct access to the value
389         */
390        public InventoryReportInventoryListingComponent setCountingDateTimeElement(DateTimeType value) { 
391          this.countingDateTime = value;
392          return this;
393        }
394
395        /**
396         * @return The date and time when the items were counted.
397         */
398        public Date getCountingDateTime() { 
399          return this.countingDateTime == null ? null : this.countingDateTime.getValue();
400        }
401
402        /**
403         * @param value The date and time when the items were counted.
404         */
405        public InventoryReportInventoryListingComponent setCountingDateTime(Date value) { 
406          if (value == null)
407            this.countingDateTime = null;
408          else {
409            if (this.countingDateTime == null)
410              this.countingDateTime = new DateTimeType();
411            this.countingDateTime.setValue(value);
412          }
413          return this;
414        }
415
416        /**
417         * @return {@link #item} (The item or items in this listing.)
418         */
419        public List<InventoryReportInventoryListingItemComponent> getItem() { 
420          if (this.item == null)
421            this.item = new ArrayList<InventoryReportInventoryListingItemComponent>();
422          return this.item;
423        }
424
425        /**
426         * @return Returns a reference to <code>this</code> for easy method chaining
427         */
428        public InventoryReportInventoryListingComponent setItem(List<InventoryReportInventoryListingItemComponent> theItem) { 
429          this.item = theItem;
430          return this;
431        }
432
433        public boolean hasItem() { 
434          if (this.item == null)
435            return false;
436          for (InventoryReportInventoryListingItemComponent item : this.item)
437            if (!item.isEmpty())
438              return true;
439          return false;
440        }
441
442        public InventoryReportInventoryListingItemComponent addItem() { //3
443          InventoryReportInventoryListingItemComponent t = new InventoryReportInventoryListingItemComponent();
444          if (this.item == null)
445            this.item = new ArrayList<InventoryReportInventoryListingItemComponent>();
446          this.item.add(t);
447          return t;
448        }
449
450        public InventoryReportInventoryListingComponent addItem(InventoryReportInventoryListingItemComponent t) { //3
451          if (t == null)
452            return this;
453          if (this.item == null)
454            this.item = new ArrayList<InventoryReportInventoryListingItemComponent>();
455          this.item.add(t);
456          return this;
457        }
458
459        /**
460         * @return The first repetition of repeating field {@link #item}, creating it if it does not already exist {3}
461         */
462        public InventoryReportInventoryListingItemComponent getItemFirstRep() { 
463          if (getItem().isEmpty()) {
464            addItem();
465          }
466          return getItem().get(0);
467        }
468
469        protected void listChildren(List<Property> children) {
470          super.listChildren(children);
471          children.add(new Property("location", "Reference(Location)", "Location of the inventory items.", 0, 1, location));
472          children.add(new Property("itemStatus", "CodeableConcept", "The status of the items.", 0, 1, itemStatus));
473          children.add(new Property("countingDateTime", "dateTime", "The date and time when the items were counted.", 0, 1, countingDateTime));
474          children.add(new Property("item", "", "The item or items in this listing.", 0, java.lang.Integer.MAX_VALUE, item));
475        }
476
477        @Override
478        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
479          switch (_hash) {
480          case 1901043637: /*location*/  return new Property("location", "Reference(Location)", "Location of the inventory items.", 0, 1, location);
481          case 1999789285: /*itemStatus*/  return new Property("itemStatus", "CodeableConcept", "The status of the items.", 0, 1, itemStatus);
482          case -2075203282: /*countingDateTime*/  return new Property("countingDateTime", "dateTime", "The date and time when the items were counted.", 0, 1, countingDateTime);
483          case 3242771: /*item*/  return new Property("item", "", "The item or items in this listing.", 0, java.lang.Integer.MAX_VALUE, item);
484          default: return super.getNamedProperty(_hash, _name, _checkValid);
485          }
486
487        }
488
489      @Override
490      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
491        switch (hash) {
492        case 1901043637: /*location*/ return this.location == null ? new Base[0] : new Base[] {this.location}; // Reference
493        case 1999789285: /*itemStatus*/ return this.itemStatus == null ? new Base[0] : new Base[] {this.itemStatus}; // CodeableConcept
494        case -2075203282: /*countingDateTime*/ return this.countingDateTime == null ? new Base[0] : new Base[] {this.countingDateTime}; // DateTimeType
495        case 3242771: /*item*/ return this.item == null ? new Base[0] : this.item.toArray(new Base[this.item.size()]); // InventoryReportInventoryListingItemComponent
496        default: return super.getProperty(hash, name, checkValid);
497        }
498
499      }
500
501      @Override
502      public Base setProperty(int hash, String name, Base value) throws FHIRException {
503        switch (hash) {
504        case 1901043637: // location
505          this.location = TypeConvertor.castToReference(value); // Reference
506          return value;
507        case 1999789285: // itemStatus
508          this.itemStatus = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
509          return value;
510        case -2075203282: // countingDateTime
511          this.countingDateTime = TypeConvertor.castToDateTime(value); // DateTimeType
512          return value;
513        case 3242771: // item
514          this.getItem().add((InventoryReportInventoryListingItemComponent) value); // InventoryReportInventoryListingItemComponent
515          return value;
516        default: return super.setProperty(hash, name, value);
517        }
518
519      }
520
521      @Override
522      public Base setProperty(String name, Base value) throws FHIRException {
523        if (name.equals("location")) {
524          this.location = TypeConvertor.castToReference(value); // Reference
525        } else if (name.equals("itemStatus")) {
526          this.itemStatus = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
527        } else if (name.equals("countingDateTime")) {
528          this.countingDateTime = TypeConvertor.castToDateTime(value); // DateTimeType
529        } else if (name.equals("item")) {
530          this.getItem().add((InventoryReportInventoryListingItemComponent) value);
531        } else
532          return super.setProperty(name, value);
533        return value;
534      }
535
536      @Override
537      public Base makeProperty(int hash, String name) throws FHIRException {
538        switch (hash) {
539        case 1901043637:  return getLocation();
540        case 1999789285:  return getItemStatus();
541        case -2075203282:  return getCountingDateTimeElement();
542        case 3242771:  return addItem(); 
543        default: return super.makeProperty(hash, name);
544        }
545
546      }
547
548      @Override
549      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
550        switch (hash) {
551        case 1901043637: /*location*/ return new String[] {"Reference"};
552        case 1999789285: /*itemStatus*/ return new String[] {"CodeableConcept"};
553        case -2075203282: /*countingDateTime*/ return new String[] {"dateTime"};
554        case 3242771: /*item*/ return new String[] {};
555        default: return super.getTypesForProperty(hash, name);
556        }
557
558      }
559
560      @Override
561      public Base addChild(String name) throws FHIRException {
562        if (name.equals("location")) {
563          this.location = new Reference();
564          return this.location;
565        }
566        else if (name.equals("itemStatus")) {
567          this.itemStatus = new CodeableConcept();
568          return this.itemStatus;
569        }
570        else if (name.equals("countingDateTime")) {
571          throw new FHIRException("Cannot call addChild on a singleton property InventoryReport.inventoryListing.countingDateTime");
572        }
573        else if (name.equals("item")) {
574          return addItem();
575        }
576        else
577          return super.addChild(name);
578      }
579
580      public InventoryReportInventoryListingComponent copy() {
581        InventoryReportInventoryListingComponent dst = new InventoryReportInventoryListingComponent();
582        copyValues(dst);
583        return dst;
584      }
585
586      public void copyValues(InventoryReportInventoryListingComponent dst) {
587        super.copyValues(dst);
588        dst.location = location == null ? null : location.copy();
589        dst.itemStatus = itemStatus == null ? null : itemStatus.copy();
590        dst.countingDateTime = countingDateTime == null ? null : countingDateTime.copy();
591        if (item != null) {
592          dst.item = new ArrayList<InventoryReportInventoryListingItemComponent>();
593          for (InventoryReportInventoryListingItemComponent i : item)
594            dst.item.add(i.copy());
595        };
596      }
597
598      @Override
599      public boolean equalsDeep(Base other_) {
600        if (!super.equalsDeep(other_))
601          return false;
602        if (!(other_ instanceof InventoryReportInventoryListingComponent))
603          return false;
604        InventoryReportInventoryListingComponent o = (InventoryReportInventoryListingComponent) other_;
605        return compareDeep(location, o.location, true) && compareDeep(itemStatus, o.itemStatus, true) && compareDeep(countingDateTime, o.countingDateTime, true)
606           && compareDeep(item, o.item, true);
607      }
608
609      @Override
610      public boolean equalsShallow(Base other_) {
611        if (!super.equalsShallow(other_))
612          return false;
613        if (!(other_ instanceof InventoryReportInventoryListingComponent))
614          return false;
615        InventoryReportInventoryListingComponent o = (InventoryReportInventoryListingComponent) other_;
616        return compareValues(countingDateTime, o.countingDateTime, true);
617      }
618
619      public boolean isEmpty() {
620        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(location, itemStatus, countingDateTime
621          , item);
622      }
623
624  public String fhirType() {
625    return "InventoryReport.inventoryListing";
626
627  }
628
629  }
630
631    @Block()
632    public static class InventoryReportInventoryListingItemComponent extends BackboneElement implements IBaseBackboneElement {
633        /**
634         * The inventory category or classification of the items being reported. This is meant not for defining the product, but for inventory categories e.g. 'pending recount' or 'damaged'.
635         */
636        @Child(name = "category", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
637        @Description(shortDefinition="The inventory category or classification of the items being reported", formalDefinition="The inventory category or classification of the items being reported. This is meant not for defining the product, but for inventory categories e.g. 'pending recount' or 'damaged'." )
638        protected CodeableConcept category;
639
640        /**
641         * The quantity of the item or items being reported.
642         */
643        @Child(name = "quantity", type = {Quantity.class}, order=2, min=1, max=1, modifier=false, summary=true)
644        @Description(shortDefinition="The quantity of the item or items being reported", formalDefinition="The quantity of the item or items being reported." )
645        protected Quantity quantity;
646
647        /**
648         * The code or reference to the item type.
649         */
650        @Child(name = "item", type = {CodeableReference.class}, order=3, min=1, max=1, modifier=false, summary=true)
651        @Description(shortDefinition="The code or reference to the item type", formalDefinition="The code or reference to the item type." )
652        protected CodeableReference item;
653
654        private static final long serialVersionUID = 566223460L;
655
656    /**
657     * Constructor
658     */
659      public InventoryReportInventoryListingItemComponent() {
660        super();
661      }
662
663    /**
664     * Constructor
665     */
666      public InventoryReportInventoryListingItemComponent(Quantity quantity, CodeableReference item) {
667        super();
668        this.setQuantity(quantity);
669        this.setItem(item);
670      }
671
672        /**
673         * @return {@link #category} (The inventory category or classification of the items being reported. This is meant not for defining the product, but for inventory categories e.g. 'pending recount' or 'damaged'.)
674         */
675        public CodeableConcept getCategory() { 
676          if (this.category == null)
677            if (Configuration.errorOnAutoCreate())
678              throw new Error("Attempt to auto-create InventoryReportInventoryListingItemComponent.category");
679            else if (Configuration.doAutoCreate())
680              this.category = new CodeableConcept(); // cc
681          return this.category;
682        }
683
684        public boolean hasCategory() { 
685          return this.category != null && !this.category.isEmpty();
686        }
687
688        /**
689         * @param value {@link #category} (The inventory category or classification of the items being reported. This is meant not for defining the product, but for inventory categories e.g. 'pending recount' or 'damaged'.)
690         */
691        public InventoryReportInventoryListingItemComponent setCategory(CodeableConcept value) { 
692          this.category = value;
693          return this;
694        }
695
696        /**
697         * @return {@link #quantity} (The quantity of the item or items being reported.)
698         */
699        public Quantity getQuantity() { 
700          if (this.quantity == null)
701            if (Configuration.errorOnAutoCreate())
702              throw new Error("Attempt to auto-create InventoryReportInventoryListingItemComponent.quantity");
703            else if (Configuration.doAutoCreate())
704              this.quantity = new Quantity(); // cc
705          return this.quantity;
706        }
707
708        public boolean hasQuantity() { 
709          return this.quantity != null && !this.quantity.isEmpty();
710        }
711
712        /**
713         * @param value {@link #quantity} (The quantity of the item or items being reported.)
714         */
715        public InventoryReportInventoryListingItemComponent setQuantity(Quantity value) { 
716          this.quantity = value;
717          return this;
718        }
719
720        /**
721         * @return {@link #item} (The code or reference to the item type.)
722         */
723        public CodeableReference getItem() { 
724          if (this.item == null)
725            if (Configuration.errorOnAutoCreate())
726              throw new Error("Attempt to auto-create InventoryReportInventoryListingItemComponent.item");
727            else if (Configuration.doAutoCreate())
728              this.item = new CodeableReference(); // cc
729          return this.item;
730        }
731
732        public boolean hasItem() { 
733          return this.item != null && !this.item.isEmpty();
734        }
735
736        /**
737         * @param value {@link #item} (The code or reference to the item type.)
738         */
739        public InventoryReportInventoryListingItemComponent setItem(CodeableReference value) { 
740          this.item = value;
741          return this;
742        }
743
744        protected void listChildren(List<Property> children) {
745          super.listChildren(children);
746          children.add(new Property("category", "CodeableConcept", "The inventory category or classification of the items being reported. This is meant not for defining the product, but for inventory categories e.g. 'pending recount' or 'damaged'.", 0, 1, category));
747          children.add(new Property("quantity", "Quantity", "The quantity of the item or items being reported.", 0, 1, quantity));
748          children.add(new Property("item", "CodeableReference(Medication|Device|Medication|NutritionProduct|InventoryItem|BiologicallyDerivedProduct|InventoryItem)", "The code or reference to the item type.", 0, 1, item));
749        }
750
751        @Override
752        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
753          switch (_hash) {
754          case 50511102: /*category*/  return new Property("category", "CodeableConcept", "The inventory category or classification of the items being reported. This is meant not for defining the product, but for inventory categories e.g. 'pending recount' or 'damaged'.", 0, 1, category);
755          case -1285004149: /*quantity*/  return new Property("quantity", "Quantity", "The quantity of the item or items being reported.", 0, 1, quantity);
756          case 3242771: /*item*/  return new Property("item", "CodeableReference(Medication|Device|Medication|NutritionProduct|InventoryItem|BiologicallyDerivedProduct|InventoryItem)", "The code or reference to the item type.", 0, 1, item);
757          default: return super.getNamedProperty(_hash, _name, _checkValid);
758          }
759
760        }
761
762      @Override
763      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
764        switch (hash) {
765        case 50511102: /*category*/ return this.category == null ? new Base[0] : new Base[] {this.category}; // CodeableConcept
766        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // Quantity
767        case 3242771: /*item*/ return this.item == null ? new Base[0] : new Base[] {this.item}; // CodeableReference
768        default: return super.getProperty(hash, name, checkValid);
769        }
770
771      }
772
773      @Override
774      public Base setProperty(int hash, String name, Base value) throws FHIRException {
775        switch (hash) {
776        case 50511102: // category
777          this.category = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
778          return value;
779        case -1285004149: // quantity
780          this.quantity = TypeConvertor.castToQuantity(value); // Quantity
781          return value;
782        case 3242771: // item
783          this.item = TypeConvertor.castToCodeableReference(value); // CodeableReference
784          return value;
785        default: return super.setProperty(hash, name, value);
786        }
787
788      }
789
790      @Override
791      public Base setProperty(String name, Base value) throws FHIRException {
792        if (name.equals("category")) {
793          this.category = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
794        } else if (name.equals("quantity")) {
795          this.quantity = TypeConvertor.castToQuantity(value); // Quantity
796        } else if (name.equals("item")) {
797          this.item = TypeConvertor.castToCodeableReference(value); // CodeableReference
798        } else
799          return super.setProperty(name, value);
800        return value;
801      }
802
803      @Override
804      public Base makeProperty(int hash, String name) throws FHIRException {
805        switch (hash) {
806        case 50511102:  return getCategory();
807        case -1285004149:  return getQuantity();
808        case 3242771:  return getItem();
809        default: return super.makeProperty(hash, name);
810        }
811
812      }
813
814      @Override
815      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
816        switch (hash) {
817        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
818        case -1285004149: /*quantity*/ return new String[] {"Quantity"};
819        case 3242771: /*item*/ return new String[] {"CodeableReference"};
820        default: return super.getTypesForProperty(hash, name);
821        }
822
823      }
824
825      @Override
826      public Base addChild(String name) throws FHIRException {
827        if (name.equals("category")) {
828          this.category = new CodeableConcept();
829          return this.category;
830        }
831        else if (name.equals("quantity")) {
832          this.quantity = new Quantity();
833          return this.quantity;
834        }
835        else if (name.equals("item")) {
836          this.item = new CodeableReference();
837          return this.item;
838        }
839        else
840          return super.addChild(name);
841      }
842
843      public InventoryReportInventoryListingItemComponent copy() {
844        InventoryReportInventoryListingItemComponent dst = new InventoryReportInventoryListingItemComponent();
845        copyValues(dst);
846        return dst;
847      }
848
849      public void copyValues(InventoryReportInventoryListingItemComponent dst) {
850        super.copyValues(dst);
851        dst.category = category == null ? null : category.copy();
852        dst.quantity = quantity == null ? null : quantity.copy();
853        dst.item = item == null ? null : item.copy();
854      }
855
856      @Override
857      public boolean equalsDeep(Base other_) {
858        if (!super.equalsDeep(other_))
859          return false;
860        if (!(other_ instanceof InventoryReportInventoryListingItemComponent))
861          return false;
862        InventoryReportInventoryListingItemComponent o = (InventoryReportInventoryListingItemComponent) other_;
863        return compareDeep(category, o.category, true) && compareDeep(quantity, o.quantity, true) && compareDeep(item, o.item, true)
864          ;
865      }
866
867      @Override
868      public boolean equalsShallow(Base other_) {
869        if (!super.equalsShallow(other_))
870          return false;
871        if (!(other_ instanceof InventoryReportInventoryListingItemComponent))
872          return false;
873        InventoryReportInventoryListingItemComponent o = (InventoryReportInventoryListingItemComponent) other_;
874        return true;
875      }
876
877      public boolean isEmpty() {
878        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(category, quantity, item
879          );
880      }
881
882  public String fhirType() {
883    return "InventoryReport.inventoryListing.item";
884
885  }
886
887  }
888
889    /**
890     * Business identifier for the InventoryReport.
891     */
892    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
893    @Description(shortDefinition="Business identifier for the report", formalDefinition="Business identifier for the InventoryReport." )
894    protected List<Identifier> identifier;
895
896    /**
897     * The status of the inventory check or notification - whether this is draft (e.g. the report is still pending some updates) or active.
898     */
899    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
900    @Description(shortDefinition="draft | requested | active | entered-in-error", formalDefinition="The status of the inventory check or notification - whether this is draft (e.g. the report is still pending some updates) or active." )
901    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/inventoryreport-status")
902    protected Enumeration<InventoryReportStatus> status;
903
904    /**
905     * Whether the report is about the current inventory count (snapshot) or a differential change in inventory (change).
906     */
907    @Child(name = "countType", type = {CodeType.class}, order=2, min=1, max=1, modifier=true, summary=true)
908    @Description(shortDefinition="snapshot | difference", formalDefinition="Whether the report is about the current inventory count (snapshot) or a differential change in inventory (change)." )
909    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/inventoryreport-counttype")
910    protected Enumeration<InventoryCountType> countType;
911
912    /**
913     * What type of operation is being performed - addition or subtraction.
914     */
915    @Child(name = "operationType", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
916    @Description(shortDefinition="addition | subtraction", formalDefinition="What type of operation is being performed - addition or subtraction." )
917    protected CodeableConcept operationType;
918
919    /**
920     * The reason for this count - regular count, ad-hoc count, new arrivals, etc.
921     */
922    @Child(name = "operationTypeReason", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=true)
923    @Description(shortDefinition="The reason for this count - regular count, ad-hoc count, new arrivals, etc", formalDefinition="The reason for this count - regular count, ad-hoc count, new arrivals, etc." )
924    protected CodeableConcept operationTypeReason;
925
926    /**
927     * When the report has been submitted.
928     */
929    @Child(name = "reportedDateTime", type = {DateTimeType.class}, order=5, min=1, max=1, modifier=false, summary=true)
930    @Description(shortDefinition="When the report has been submitted", formalDefinition="When the report has been submitted." )
931    protected DateTimeType reportedDateTime;
932
933    /**
934     * Who submits the report.
935     */
936    @Child(name = "reporter", type = {Practitioner.class, Patient.class, RelatedPerson.class, Device.class}, order=6, min=0, max=1, modifier=false, summary=false)
937    @Description(shortDefinition="Who submits the report", formalDefinition="Who submits the report." )
938    protected Reference reporter;
939
940    /**
941     * The period the report refers to.
942     */
943    @Child(name = "reportingPeriod", type = {Period.class}, order=7, min=0, max=1, modifier=false, summary=false)
944    @Description(shortDefinition="The period the report refers to", formalDefinition="The period the report refers to." )
945    protected Period reportingPeriod;
946
947    /**
948     * An inventory listing section (grouped by any of the attributes).
949     */
950    @Child(name = "inventoryListing", type = {}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
951    @Description(shortDefinition="An inventory listing section (grouped by any of the attributes)", formalDefinition="An inventory listing section (grouped by any of the attributes)." )
952    protected List<InventoryReportInventoryListingComponent> inventoryListing;
953
954    /**
955     * A note associated with the InventoryReport.
956     */
957    @Child(name = "note", type = {Annotation.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
958    @Description(shortDefinition="A note associated with the InventoryReport", formalDefinition="A note associated with the InventoryReport." )
959    protected List<Annotation> note;
960
961    private static final long serialVersionUID = 539262671L;
962
963  /**
964   * Constructor
965   */
966    public InventoryReport() {
967      super();
968    }
969
970  /**
971   * Constructor
972   */
973    public InventoryReport(InventoryReportStatus status, InventoryCountType countType, Date reportedDateTime) {
974      super();
975      this.setStatus(status);
976      this.setCountType(countType);
977      this.setReportedDateTime(reportedDateTime);
978    }
979
980    /**
981     * @return {@link #identifier} (Business identifier for the InventoryReport.)
982     */
983    public List<Identifier> getIdentifier() { 
984      if (this.identifier == null)
985        this.identifier = new ArrayList<Identifier>();
986      return this.identifier;
987    }
988
989    /**
990     * @return Returns a reference to <code>this</code> for easy method chaining
991     */
992    public InventoryReport setIdentifier(List<Identifier> theIdentifier) { 
993      this.identifier = theIdentifier;
994      return this;
995    }
996
997    public boolean hasIdentifier() { 
998      if (this.identifier == null)
999        return false;
1000      for (Identifier item : this.identifier)
1001        if (!item.isEmpty())
1002          return true;
1003      return false;
1004    }
1005
1006    public Identifier addIdentifier() { //3
1007      Identifier t = new Identifier();
1008      if (this.identifier == null)
1009        this.identifier = new ArrayList<Identifier>();
1010      this.identifier.add(t);
1011      return t;
1012    }
1013
1014    public InventoryReport addIdentifier(Identifier t) { //3
1015      if (t == null)
1016        return this;
1017      if (this.identifier == null)
1018        this.identifier = new ArrayList<Identifier>();
1019      this.identifier.add(t);
1020      return this;
1021    }
1022
1023    /**
1024     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist {3}
1025     */
1026    public Identifier getIdentifierFirstRep() { 
1027      if (getIdentifier().isEmpty()) {
1028        addIdentifier();
1029      }
1030      return getIdentifier().get(0);
1031    }
1032
1033    /**
1034     * @return {@link #status} (The status of the inventory check or notification - whether this is draft (e.g. the report is still pending some updates) or active.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1035     */
1036    public Enumeration<InventoryReportStatus> getStatusElement() { 
1037      if (this.status == null)
1038        if (Configuration.errorOnAutoCreate())
1039          throw new Error("Attempt to auto-create InventoryReport.status");
1040        else if (Configuration.doAutoCreate())
1041          this.status = new Enumeration<InventoryReportStatus>(new InventoryReportStatusEnumFactory()); // bb
1042      return this.status;
1043    }
1044
1045    public boolean hasStatusElement() { 
1046      return this.status != null && !this.status.isEmpty();
1047    }
1048
1049    public boolean hasStatus() { 
1050      return this.status != null && !this.status.isEmpty();
1051    }
1052
1053    /**
1054     * @param value {@link #status} (The status of the inventory check or notification - whether this is draft (e.g. the report is still pending some updates) or active.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1055     */
1056    public InventoryReport setStatusElement(Enumeration<InventoryReportStatus> value) { 
1057      this.status = value;
1058      return this;
1059    }
1060
1061    /**
1062     * @return The status of the inventory check or notification - whether this is draft (e.g. the report is still pending some updates) or active.
1063     */
1064    public InventoryReportStatus getStatus() { 
1065      return this.status == null ? null : this.status.getValue();
1066    }
1067
1068    /**
1069     * @param value The status of the inventory check or notification - whether this is draft (e.g. the report is still pending some updates) or active.
1070     */
1071    public InventoryReport setStatus(InventoryReportStatus value) { 
1072        if (this.status == null)
1073          this.status = new Enumeration<InventoryReportStatus>(new InventoryReportStatusEnumFactory());
1074        this.status.setValue(value);
1075      return this;
1076    }
1077
1078    /**
1079     * @return {@link #countType} (Whether the report is about the current inventory count (snapshot) or a differential change in inventory (change).). This is the underlying object with id, value and extensions. The accessor "getCountType" gives direct access to the value
1080     */
1081    public Enumeration<InventoryCountType> getCountTypeElement() { 
1082      if (this.countType == null)
1083        if (Configuration.errorOnAutoCreate())
1084          throw new Error("Attempt to auto-create InventoryReport.countType");
1085        else if (Configuration.doAutoCreate())
1086          this.countType = new Enumeration<InventoryCountType>(new InventoryCountTypeEnumFactory()); // bb
1087      return this.countType;
1088    }
1089
1090    public boolean hasCountTypeElement() { 
1091      return this.countType != null && !this.countType.isEmpty();
1092    }
1093
1094    public boolean hasCountType() { 
1095      return this.countType != null && !this.countType.isEmpty();
1096    }
1097
1098    /**
1099     * @param value {@link #countType} (Whether the report is about the current inventory count (snapshot) or a differential change in inventory (change).). This is the underlying object with id, value and extensions. The accessor "getCountType" gives direct access to the value
1100     */
1101    public InventoryReport setCountTypeElement(Enumeration<InventoryCountType> value) { 
1102      this.countType = value;
1103      return this;
1104    }
1105
1106    /**
1107     * @return Whether the report is about the current inventory count (snapshot) or a differential change in inventory (change).
1108     */
1109    public InventoryCountType getCountType() { 
1110      return this.countType == null ? null : this.countType.getValue();
1111    }
1112
1113    /**
1114     * @param value Whether the report is about the current inventory count (snapshot) or a differential change in inventory (change).
1115     */
1116    public InventoryReport setCountType(InventoryCountType value) { 
1117        if (this.countType == null)
1118          this.countType = new Enumeration<InventoryCountType>(new InventoryCountTypeEnumFactory());
1119        this.countType.setValue(value);
1120      return this;
1121    }
1122
1123    /**
1124     * @return {@link #operationType} (What type of operation is being performed - addition or subtraction.)
1125     */
1126    public CodeableConcept getOperationType() { 
1127      if (this.operationType == null)
1128        if (Configuration.errorOnAutoCreate())
1129          throw new Error("Attempt to auto-create InventoryReport.operationType");
1130        else if (Configuration.doAutoCreate())
1131          this.operationType = new CodeableConcept(); // cc
1132      return this.operationType;
1133    }
1134
1135    public boolean hasOperationType() { 
1136      return this.operationType != null && !this.operationType.isEmpty();
1137    }
1138
1139    /**
1140     * @param value {@link #operationType} (What type of operation is being performed - addition or subtraction.)
1141     */
1142    public InventoryReport setOperationType(CodeableConcept value) { 
1143      this.operationType = value;
1144      return this;
1145    }
1146
1147    /**
1148     * @return {@link #operationTypeReason} (The reason for this count - regular count, ad-hoc count, new arrivals, etc.)
1149     */
1150    public CodeableConcept getOperationTypeReason() { 
1151      if (this.operationTypeReason == null)
1152        if (Configuration.errorOnAutoCreate())
1153          throw new Error("Attempt to auto-create InventoryReport.operationTypeReason");
1154        else if (Configuration.doAutoCreate())
1155          this.operationTypeReason = new CodeableConcept(); // cc
1156      return this.operationTypeReason;
1157    }
1158
1159    public boolean hasOperationTypeReason() { 
1160      return this.operationTypeReason != null && !this.operationTypeReason.isEmpty();
1161    }
1162
1163    /**
1164     * @param value {@link #operationTypeReason} (The reason for this count - regular count, ad-hoc count, new arrivals, etc.)
1165     */
1166    public InventoryReport setOperationTypeReason(CodeableConcept value) { 
1167      this.operationTypeReason = value;
1168      return this;
1169    }
1170
1171    /**
1172     * @return {@link #reportedDateTime} (When the report has been submitted.). This is the underlying object with id, value and extensions. The accessor "getReportedDateTime" gives direct access to the value
1173     */
1174    public DateTimeType getReportedDateTimeElement() { 
1175      if (this.reportedDateTime == null)
1176        if (Configuration.errorOnAutoCreate())
1177          throw new Error("Attempt to auto-create InventoryReport.reportedDateTime");
1178        else if (Configuration.doAutoCreate())
1179          this.reportedDateTime = new DateTimeType(); // bb
1180      return this.reportedDateTime;
1181    }
1182
1183    public boolean hasReportedDateTimeElement() { 
1184      return this.reportedDateTime != null && !this.reportedDateTime.isEmpty();
1185    }
1186
1187    public boolean hasReportedDateTime() { 
1188      return this.reportedDateTime != null && !this.reportedDateTime.isEmpty();
1189    }
1190
1191    /**
1192     * @param value {@link #reportedDateTime} (When the report has been submitted.). This is the underlying object with id, value and extensions. The accessor "getReportedDateTime" gives direct access to the value
1193     */
1194    public InventoryReport setReportedDateTimeElement(DateTimeType value) { 
1195      this.reportedDateTime = value;
1196      return this;
1197    }
1198
1199    /**
1200     * @return When the report has been submitted.
1201     */
1202    public Date getReportedDateTime() { 
1203      return this.reportedDateTime == null ? null : this.reportedDateTime.getValue();
1204    }
1205
1206    /**
1207     * @param value When the report has been submitted.
1208     */
1209    public InventoryReport setReportedDateTime(Date value) { 
1210        if (this.reportedDateTime == null)
1211          this.reportedDateTime = new DateTimeType();
1212        this.reportedDateTime.setValue(value);
1213      return this;
1214    }
1215
1216    /**
1217     * @return {@link #reporter} (Who submits the report.)
1218     */
1219    public Reference getReporter() { 
1220      if (this.reporter == null)
1221        if (Configuration.errorOnAutoCreate())
1222          throw new Error("Attempt to auto-create InventoryReport.reporter");
1223        else if (Configuration.doAutoCreate())
1224          this.reporter = new Reference(); // cc
1225      return this.reporter;
1226    }
1227
1228    public boolean hasReporter() { 
1229      return this.reporter != null && !this.reporter.isEmpty();
1230    }
1231
1232    /**
1233     * @param value {@link #reporter} (Who submits the report.)
1234     */
1235    public InventoryReport setReporter(Reference value) { 
1236      this.reporter = value;
1237      return this;
1238    }
1239
1240    /**
1241     * @return {@link #reportingPeriod} (The period the report refers to.)
1242     */
1243    public Period getReportingPeriod() { 
1244      if (this.reportingPeriod == null)
1245        if (Configuration.errorOnAutoCreate())
1246          throw new Error("Attempt to auto-create InventoryReport.reportingPeriod");
1247        else if (Configuration.doAutoCreate())
1248          this.reportingPeriod = new Period(); // cc
1249      return this.reportingPeriod;
1250    }
1251
1252    public boolean hasReportingPeriod() { 
1253      return this.reportingPeriod != null && !this.reportingPeriod.isEmpty();
1254    }
1255
1256    /**
1257     * @param value {@link #reportingPeriod} (The period the report refers to.)
1258     */
1259    public InventoryReport setReportingPeriod(Period value) { 
1260      this.reportingPeriod = value;
1261      return this;
1262    }
1263
1264    /**
1265     * @return {@link #inventoryListing} (An inventory listing section (grouped by any of the attributes).)
1266     */
1267    public List<InventoryReportInventoryListingComponent> getInventoryListing() { 
1268      if (this.inventoryListing == null)
1269        this.inventoryListing = new ArrayList<InventoryReportInventoryListingComponent>();
1270      return this.inventoryListing;
1271    }
1272
1273    /**
1274     * @return Returns a reference to <code>this</code> for easy method chaining
1275     */
1276    public InventoryReport setInventoryListing(List<InventoryReportInventoryListingComponent> theInventoryListing) { 
1277      this.inventoryListing = theInventoryListing;
1278      return this;
1279    }
1280
1281    public boolean hasInventoryListing() { 
1282      if (this.inventoryListing == null)
1283        return false;
1284      for (InventoryReportInventoryListingComponent item : this.inventoryListing)
1285        if (!item.isEmpty())
1286          return true;
1287      return false;
1288    }
1289
1290    public InventoryReportInventoryListingComponent addInventoryListing() { //3
1291      InventoryReportInventoryListingComponent t = new InventoryReportInventoryListingComponent();
1292      if (this.inventoryListing == null)
1293        this.inventoryListing = new ArrayList<InventoryReportInventoryListingComponent>();
1294      this.inventoryListing.add(t);
1295      return t;
1296    }
1297
1298    public InventoryReport addInventoryListing(InventoryReportInventoryListingComponent t) { //3
1299      if (t == null)
1300        return this;
1301      if (this.inventoryListing == null)
1302        this.inventoryListing = new ArrayList<InventoryReportInventoryListingComponent>();
1303      this.inventoryListing.add(t);
1304      return this;
1305    }
1306
1307    /**
1308     * @return The first repetition of repeating field {@link #inventoryListing}, creating it if it does not already exist {3}
1309     */
1310    public InventoryReportInventoryListingComponent getInventoryListingFirstRep() { 
1311      if (getInventoryListing().isEmpty()) {
1312        addInventoryListing();
1313      }
1314      return getInventoryListing().get(0);
1315    }
1316
1317    /**
1318     * @return {@link #note} (A note associated with the InventoryReport.)
1319     */
1320    public List<Annotation> getNote() { 
1321      if (this.note == null)
1322        this.note = new ArrayList<Annotation>();
1323      return this.note;
1324    }
1325
1326    /**
1327     * @return Returns a reference to <code>this</code> for easy method chaining
1328     */
1329    public InventoryReport setNote(List<Annotation> theNote) { 
1330      this.note = theNote;
1331      return this;
1332    }
1333
1334    public boolean hasNote() { 
1335      if (this.note == null)
1336        return false;
1337      for (Annotation item : this.note)
1338        if (!item.isEmpty())
1339          return true;
1340      return false;
1341    }
1342
1343    public Annotation addNote() { //3
1344      Annotation t = new Annotation();
1345      if (this.note == null)
1346        this.note = new ArrayList<Annotation>();
1347      this.note.add(t);
1348      return t;
1349    }
1350
1351    public InventoryReport addNote(Annotation t) { //3
1352      if (t == null)
1353        return this;
1354      if (this.note == null)
1355        this.note = new ArrayList<Annotation>();
1356      this.note.add(t);
1357      return this;
1358    }
1359
1360    /**
1361     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist {3}
1362     */
1363    public Annotation getNoteFirstRep() { 
1364      if (getNote().isEmpty()) {
1365        addNote();
1366      }
1367      return getNote().get(0);
1368    }
1369
1370      protected void listChildren(List<Property> children) {
1371        super.listChildren(children);
1372        children.add(new Property("identifier", "Identifier", "Business identifier for the InventoryReport.", 0, java.lang.Integer.MAX_VALUE, identifier));
1373        children.add(new Property("status", "code", "The status of the inventory check or notification - whether this is draft (e.g. the report is still pending some updates) or active.", 0, 1, status));
1374        children.add(new Property("countType", "code", "Whether the report is about the current inventory count (snapshot) or a differential change in inventory (change).", 0, 1, countType));
1375        children.add(new Property("operationType", "CodeableConcept", "What type of operation is being performed - addition or subtraction.", 0, 1, operationType));
1376        children.add(new Property("operationTypeReason", "CodeableConcept", "The reason for this count - regular count, ad-hoc count, new arrivals, etc.", 0, 1, operationTypeReason));
1377        children.add(new Property("reportedDateTime", "dateTime", "When the report has been submitted.", 0, 1, reportedDateTime));
1378        children.add(new Property("reporter", "Reference(Practitioner|Patient|RelatedPerson|Device)", "Who submits the report.", 0, 1, reporter));
1379        children.add(new Property("reportingPeriod", "Period", "The period the report refers to.", 0, 1, reportingPeriod));
1380        children.add(new Property("inventoryListing", "", "An inventory listing section (grouped by any of the attributes).", 0, java.lang.Integer.MAX_VALUE, inventoryListing));
1381        children.add(new Property("note", "Annotation", "A note associated with the InventoryReport.", 0, java.lang.Integer.MAX_VALUE, note));
1382      }
1383
1384      @Override
1385      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1386        switch (_hash) {
1387        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Business identifier for the InventoryReport.", 0, java.lang.Integer.MAX_VALUE, identifier);
1388        case -892481550: /*status*/  return new Property("status", "code", "The status of the inventory check or notification - whether this is draft (e.g. the report is still pending some updates) or active.", 0, 1, status);
1389        case 1351759081: /*countType*/  return new Property("countType", "code", "Whether the report is about the current inventory count (snapshot) or a differential change in inventory (change).", 0, 1, countType);
1390        case 91999553: /*operationType*/  return new Property("operationType", "CodeableConcept", "What type of operation is being performed - addition or subtraction.", 0, 1, operationType);
1391        case 449681125: /*operationTypeReason*/  return new Property("operationTypeReason", "CodeableConcept", "The reason for this count - regular count, ad-hoc count, new arrivals, etc.", 0, 1, operationTypeReason);
1392        case -1048250994: /*reportedDateTime*/  return new Property("reportedDateTime", "dateTime", "When the report has been submitted.", 0, 1, reportedDateTime);
1393        case -427039519: /*reporter*/  return new Property("reporter", "Reference(Practitioner|Patient|RelatedPerson|Device)", "Who submits the report.", 0, 1, reporter);
1394        case 409685391: /*reportingPeriod*/  return new Property("reportingPeriod", "Period", "The period the report refers to.", 0, 1, reportingPeriod);
1395        case -1764804216: /*inventoryListing*/  return new Property("inventoryListing", "", "An inventory listing section (grouped by any of the attributes).", 0, java.lang.Integer.MAX_VALUE, inventoryListing);
1396        case 3387378: /*note*/  return new Property("note", "Annotation", "A note associated with the InventoryReport.", 0, java.lang.Integer.MAX_VALUE, note);
1397        default: return super.getNamedProperty(_hash, _name, _checkValid);
1398        }
1399
1400      }
1401
1402      @Override
1403      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1404        switch (hash) {
1405        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1406        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<InventoryReportStatus>
1407        case 1351759081: /*countType*/ return this.countType == null ? new Base[0] : new Base[] {this.countType}; // Enumeration<InventoryCountType>
1408        case 91999553: /*operationType*/ return this.operationType == null ? new Base[0] : new Base[] {this.operationType}; // CodeableConcept
1409        case 449681125: /*operationTypeReason*/ return this.operationTypeReason == null ? new Base[0] : new Base[] {this.operationTypeReason}; // CodeableConcept
1410        case -1048250994: /*reportedDateTime*/ return this.reportedDateTime == null ? new Base[0] : new Base[] {this.reportedDateTime}; // DateTimeType
1411        case -427039519: /*reporter*/ return this.reporter == null ? new Base[0] : new Base[] {this.reporter}; // Reference
1412        case 409685391: /*reportingPeriod*/ return this.reportingPeriod == null ? new Base[0] : new Base[] {this.reportingPeriod}; // Period
1413        case -1764804216: /*inventoryListing*/ return this.inventoryListing == null ? new Base[0] : this.inventoryListing.toArray(new Base[this.inventoryListing.size()]); // InventoryReportInventoryListingComponent
1414        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
1415        default: return super.getProperty(hash, name, checkValid);
1416        }
1417
1418      }
1419
1420      @Override
1421      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1422        switch (hash) {
1423        case -1618432855: // identifier
1424          this.getIdentifier().add(TypeConvertor.castToIdentifier(value)); // Identifier
1425          return value;
1426        case -892481550: // status
1427          value = new InventoryReportStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
1428          this.status = (Enumeration) value; // Enumeration<InventoryReportStatus>
1429          return value;
1430        case 1351759081: // countType
1431          value = new InventoryCountTypeEnumFactory().fromType(TypeConvertor.castToCode(value));
1432          this.countType = (Enumeration) value; // Enumeration<InventoryCountType>
1433          return value;
1434        case 91999553: // operationType
1435          this.operationType = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1436          return value;
1437        case 449681125: // operationTypeReason
1438          this.operationTypeReason = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1439          return value;
1440        case -1048250994: // reportedDateTime
1441          this.reportedDateTime = TypeConvertor.castToDateTime(value); // DateTimeType
1442          return value;
1443        case -427039519: // reporter
1444          this.reporter = TypeConvertor.castToReference(value); // Reference
1445          return value;
1446        case 409685391: // reportingPeriod
1447          this.reportingPeriod = TypeConvertor.castToPeriod(value); // Period
1448          return value;
1449        case -1764804216: // inventoryListing
1450          this.getInventoryListing().add((InventoryReportInventoryListingComponent) value); // InventoryReportInventoryListingComponent
1451          return value;
1452        case 3387378: // note
1453          this.getNote().add(TypeConvertor.castToAnnotation(value)); // Annotation
1454          return value;
1455        default: return super.setProperty(hash, name, value);
1456        }
1457
1458      }
1459
1460      @Override
1461      public Base setProperty(String name, Base value) throws FHIRException {
1462        if (name.equals("identifier")) {
1463          this.getIdentifier().add(TypeConvertor.castToIdentifier(value));
1464        } else if (name.equals("status")) {
1465          value = new InventoryReportStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
1466          this.status = (Enumeration) value; // Enumeration<InventoryReportStatus>
1467        } else if (name.equals("countType")) {
1468          value = new InventoryCountTypeEnumFactory().fromType(TypeConvertor.castToCode(value));
1469          this.countType = (Enumeration) value; // Enumeration<InventoryCountType>
1470        } else if (name.equals("operationType")) {
1471          this.operationType = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1472        } else if (name.equals("operationTypeReason")) {
1473          this.operationTypeReason = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1474        } else if (name.equals("reportedDateTime")) {
1475          this.reportedDateTime = TypeConvertor.castToDateTime(value); // DateTimeType
1476        } else if (name.equals("reporter")) {
1477          this.reporter = TypeConvertor.castToReference(value); // Reference
1478        } else if (name.equals("reportingPeriod")) {
1479          this.reportingPeriod = TypeConvertor.castToPeriod(value); // Period
1480        } else if (name.equals("inventoryListing")) {
1481          this.getInventoryListing().add((InventoryReportInventoryListingComponent) value);
1482        } else if (name.equals("note")) {
1483          this.getNote().add(TypeConvertor.castToAnnotation(value));
1484        } else
1485          return super.setProperty(name, value);
1486        return value;
1487      }
1488
1489      @Override
1490      public Base makeProperty(int hash, String name) throws FHIRException {
1491        switch (hash) {
1492        case -1618432855:  return addIdentifier(); 
1493        case -892481550:  return getStatusElement();
1494        case 1351759081:  return getCountTypeElement();
1495        case 91999553:  return getOperationType();
1496        case 449681125:  return getOperationTypeReason();
1497        case -1048250994:  return getReportedDateTimeElement();
1498        case -427039519:  return getReporter();
1499        case 409685391:  return getReportingPeriod();
1500        case -1764804216:  return addInventoryListing(); 
1501        case 3387378:  return addNote(); 
1502        default: return super.makeProperty(hash, name);
1503        }
1504
1505      }
1506
1507      @Override
1508      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1509        switch (hash) {
1510        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1511        case -892481550: /*status*/ return new String[] {"code"};
1512        case 1351759081: /*countType*/ return new String[] {"code"};
1513        case 91999553: /*operationType*/ return new String[] {"CodeableConcept"};
1514        case 449681125: /*operationTypeReason*/ return new String[] {"CodeableConcept"};
1515        case -1048250994: /*reportedDateTime*/ return new String[] {"dateTime"};
1516        case -427039519: /*reporter*/ return new String[] {"Reference"};
1517        case 409685391: /*reportingPeriod*/ return new String[] {"Period"};
1518        case -1764804216: /*inventoryListing*/ return new String[] {};
1519        case 3387378: /*note*/ return new String[] {"Annotation"};
1520        default: return super.getTypesForProperty(hash, name);
1521        }
1522
1523      }
1524
1525      @Override
1526      public Base addChild(String name) throws FHIRException {
1527        if (name.equals("identifier")) {
1528          return addIdentifier();
1529        }
1530        else if (name.equals("status")) {
1531          throw new FHIRException("Cannot call addChild on a singleton property InventoryReport.status");
1532        }
1533        else if (name.equals("countType")) {
1534          throw new FHIRException("Cannot call addChild on a singleton property InventoryReport.countType");
1535        }
1536        else if (name.equals("operationType")) {
1537          this.operationType = new CodeableConcept();
1538          return this.operationType;
1539        }
1540        else if (name.equals("operationTypeReason")) {
1541          this.operationTypeReason = new CodeableConcept();
1542          return this.operationTypeReason;
1543        }
1544        else if (name.equals("reportedDateTime")) {
1545          throw new FHIRException("Cannot call addChild on a singleton property InventoryReport.reportedDateTime");
1546        }
1547        else if (name.equals("reporter")) {
1548          this.reporter = new Reference();
1549          return this.reporter;
1550        }
1551        else if (name.equals("reportingPeriod")) {
1552          this.reportingPeriod = new Period();
1553          return this.reportingPeriod;
1554        }
1555        else if (name.equals("inventoryListing")) {
1556          return addInventoryListing();
1557        }
1558        else if (name.equals("note")) {
1559          return addNote();
1560        }
1561        else
1562          return super.addChild(name);
1563      }
1564
1565  public String fhirType() {
1566    return "InventoryReport";
1567
1568  }
1569
1570      public InventoryReport copy() {
1571        InventoryReport dst = new InventoryReport();
1572        copyValues(dst);
1573        return dst;
1574      }
1575
1576      public void copyValues(InventoryReport dst) {
1577        super.copyValues(dst);
1578        if (identifier != null) {
1579          dst.identifier = new ArrayList<Identifier>();
1580          for (Identifier i : identifier)
1581            dst.identifier.add(i.copy());
1582        };
1583        dst.status = status == null ? null : status.copy();
1584        dst.countType = countType == null ? null : countType.copy();
1585        dst.operationType = operationType == null ? null : operationType.copy();
1586        dst.operationTypeReason = operationTypeReason == null ? null : operationTypeReason.copy();
1587        dst.reportedDateTime = reportedDateTime == null ? null : reportedDateTime.copy();
1588        dst.reporter = reporter == null ? null : reporter.copy();
1589        dst.reportingPeriod = reportingPeriod == null ? null : reportingPeriod.copy();
1590        if (inventoryListing != null) {
1591          dst.inventoryListing = new ArrayList<InventoryReportInventoryListingComponent>();
1592          for (InventoryReportInventoryListingComponent i : inventoryListing)
1593            dst.inventoryListing.add(i.copy());
1594        };
1595        if (note != null) {
1596          dst.note = new ArrayList<Annotation>();
1597          for (Annotation i : note)
1598            dst.note.add(i.copy());
1599        };
1600      }
1601
1602      protected InventoryReport typedCopy() {
1603        return copy();
1604      }
1605
1606      @Override
1607      public boolean equalsDeep(Base other_) {
1608        if (!super.equalsDeep(other_))
1609          return false;
1610        if (!(other_ instanceof InventoryReport))
1611          return false;
1612        InventoryReport o = (InventoryReport) other_;
1613        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(countType, o.countType, true)
1614           && compareDeep(operationType, o.operationType, true) && compareDeep(operationTypeReason, o.operationTypeReason, true)
1615           && compareDeep(reportedDateTime, o.reportedDateTime, true) && compareDeep(reporter, o.reporter, true)
1616           && compareDeep(reportingPeriod, o.reportingPeriod, true) && compareDeep(inventoryListing, o.inventoryListing, true)
1617           && compareDeep(note, o.note, true);
1618      }
1619
1620      @Override
1621      public boolean equalsShallow(Base other_) {
1622        if (!super.equalsShallow(other_))
1623          return false;
1624        if (!(other_ instanceof InventoryReport))
1625          return false;
1626        InventoryReport o = (InventoryReport) other_;
1627        return compareValues(status, o.status, true) && compareValues(countType, o.countType, true) && compareValues(reportedDateTime, o.reportedDateTime, true)
1628          ;
1629      }
1630
1631      public boolean isEmpty() {
1632        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, countType
1633          , operationType, operationTypeReason, reportedDateTime, reporter, reportingPeriod
1634          , inventoryListing, note);
1635      }
1636
1637  @Override
1638  public ResourceType getResourceType() {
1639    return ResourceType.InventoryReport;
1640   }
1641
1642 /**
1643   * Search parameter: <b>identifier</b>
1644   * <p>
1645   * Description: <b>Search by identifier</b><br>
1646   * Type: <b>token</b><br>
1647   * Path: <b>InventoryReport.identifier</b><br>
1648   * </p>
1649   */
1650  @SearchParamDefinition(name="identifier", path="InventoryReport.identifier", description="Search by identifier", type="token" )
1651  public static final String SP_IDENTIFIER = "identifier";
1652 /**
1653   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1654   * <p>
1655   * Description: <b>Search by identifier</b><br>
1656   * Type: <b>token</b><br>
1657   * Path: <b>InventoryReport.identifier</b><br>
1658   * </p>
1659   */
1660  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
1661
1662 /**
1663   * Search parameter: <b>item-reference</b>
1664   * <p>
1665   * Description: <b>Search by items in inventory report</b><br>
1666   * Type: <b>reference</b><br>
1667   * Path: <b>InventoryReport.inventoryListing.item.item.reference</b><br>
1668   * </p>
1669   */
1670  @SearchParamDefinition(name="item-reference", path="InventoryReport.inventoryListing.item.item.reference", description="Search by items in inventory report", type="reference", target={BiologicallyDerivedProduct.class, Device.class, InventoryItem.class, Medication.class, NutritionProduct.class } )
1671  public static final String SP_ITEM_REFERENCE = "item-reference";
1672 /**
1673   * <b>Fluent Client</b> search parameter constant for <b>item-reference</b>
1674   * <p>
1675   * Description: <b>Search by items in inventory report</b><br>
1676   * Type: <b>reference</b><br>
1677   * Path: <b>InventoryReport.inventoryListing.item.item.reference</b><br>
1678   * </p>
1679   */
1680  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ITEM_REFERENCE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ITEM_REFERENCE);
1681
1682/**
1683   * Constant for fluent queries to be used to add include statements. Specifies
1684   * the path value of "<b>InventoryReport:item-reference</b>".
1685   */
1686  public static final ca.uhn.fhir.model.api.Include INCLUDE_ITEM_REFERENCE = new ca.uhn.fhir.model.api.Include("InventoryReport:item-reference").toLocked();
1687
1688 /**
1689   * Search parameter: <b>item</b>
1690   * <p>
1691   * Description: <b>Search by items in inventory report</b><br>
1692   * Type: <b>token</b><br>
1693   * Path: <b>InventoryReport.inventoryListing.item.item.concept</b><br>
1694   * </p>
1695   */
1696  @SearchParamDefinition(name="item", path="InventoryReport.inventoryListing.item.item.concept", description="Search by items in inventory report", type="token" )
1697  public static final String SP_ITEM = "item";
1698 /**
1699   * <b>Fluent Client</b> search parameter constant for <b>item</b>
1700   * <p>
1701   * Description: <b>Search by items in inventory report</b><br>
1702   * Type: <b>token</b><br>
1703   * Path: <b>InventoryReport.inventoryListing.item.item.concept</b><br>
1704   * </p>
1705   */
1706  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ITEM = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_ITEM);
1707
1708 /**
1709   * Search parameter: <b>status</b>
1710   * <p>
1711   * Description: <b>Search by status</b><br>
1712   * Type: <b>token</b><br>
1713   * Path: <b>InventoryReport.status</b><br>
1714   * </p>
1715   */
1716  @SearchParamDefinition(name="status", path="InventoryReport.status", description="Search by status", type="token" )
1717  public static final String SP_STATUS = "status";
1718 /**
1719   * <b>Fluent Client</b> search parameter constant for <b>status</b>
1720   * <p>
1721   * Description: <b>Search by status</b><br>
1722   * Type: <b>token</b><br>
1723   * Path: <b>InventoryReport.status</b><br>
1724   * </p>
1725   */
1726  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
1727
1728
1729}
1730