001package org.hl7.fhir.r4.model;
002
003
004
005/*
006  Copyright (c) 2011+, HL7, Inc.
007  All rights reserved.
008  
009  Redistribution and use in source and binary forms, with or without modification, 
010  are permitted provided that the following conditions are met:
011  
012   * Redistributions of source code must retain the above copyright notice, this 
013     list of conditions and the following disclaimer.
014   * Redistributions in binary form must reproduce the above copyright notice, 
015     this list of conditions and the following disclaimer in the documentation 
016     and/or other materials provided with the distribution.
017   * Neither the name of HL7 nor the names of its contributors may be used to 
018     endorse or promote products derived from this software without specific 
019     prior written permission.
020  
021  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
022  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
023  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
024  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
025  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
026  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
027  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
028  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
029  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
030  POSSIBILITY OF SUCH DAMAGE.
031  
032*/
033
034
035// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
036
037import java.util.*;
038
039import org.hl7.fhir.utilities.Utilities;
040import ca.uhn.fhir.model.api.annotation.ResourceDef;
041import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
042import ca.uhn.fhir.model.api.annotation.Child;
043import ca.uhn.fhir.model.api.annotation.ChildOrder;
044import ca.uhn.fhir.model.api.annotation.Description;
045import ca.uhn.fhir.model.api.annotation.Block;
046import org.hl7.fhir.instance.model.api.*;
047import org.hl7.fhir.exceptions.FHIRException;
048/**
049 * A record of a request for a medication, substance or device used in the healthcare setting.
050 */
051@ResourceDef(name="SupplyRequest", profile="http://hl7.org/fhir/StructureDefinition/SupplyRequest")
052public class SupplyRequest extends DomainResource {
053
054    public enum SupplyRequestStatus {
055        /**
056         * The request has been created but is not yet complete or ready for action.
057         */
058        DRAFT, 
059        /**
060         * The request is ready to be acted upon.
061         */
062        ACTIVE, 
063        /**
064         * The authorization/request to act has been temporarily withdrawn but is expected to resume in the future.
065         */
066        SUSPENDED, 
067        /**
068         * The authorization/request to act has been terminated prior to the full completion of the intended actions.  No further activity should occur.
069         */
070        CANCELLED, 
071        /**
072         * Activity against the request has been sufficiently completed to the satisfaction of the requester.
073         */
074        COMPLETED, 
075        /**
076         * This electronic record should never have existed, though it is possible that real-world decisions were based on it.  (If real-world activity has occurred, the status should be "cancelled" rather than "entered-in-error".).
077         */
078        ENTEREDINERROR, 
079        /**
080         * The authoring/source system does not know which of the status values currently applies for this observation. Note: This concept is not to be used for "other" - one of the listed statuses is presumed to apply, but the authoring/source system does not know which.
081         */
082        UNKNOWN, 
083        /**
084         * added to help the parsers with the generic types
085         */
086        NULL;
087        public static SupplyRequestStatus fromCode(String codeString) throws FHIRException {
088            if (codeString == null || "".equals(codeString))
089                return null;
090        if ("draft".equals(codeString))
091          return DRAFT;
092        if ("active".equals(codeString))
093          return ACTIVE;
094        if ("suspended".equals(codeString))
095          return SUSPENDED;
096        if ("cancelled".equals(codeString))
097          return CANCELLED;
098        if ("completed".equals(codeString))
099          return COMPLETED;
100        if ("entered-in-error".equals(codeString))
101          return ENTEREDINERROR;
102        if ("unknown".equals(codeString))
103          return UNKNOWN;
104        if (Configuration.isAcceptInvalidEnums())
105          return null;
106        else
107          throw new FHIRException("Unknown SupplyRequestStatus code '"+codeString+"'");
108        }
109        public String toCode() {
110          switch (this) {
111            case DRAFT: return "draft";
112            case ACTIVE: return "active";
113            case SUSPENDED: return "suspended";
114            case CANCELLED: return "cancelled";
115            case COMPLETED: return "completed";
116            case ENTEREDINERROR: return "entered-in-error";
117            case UNKNOWN: return "unknown";
118            default: return "?";
119          }
120        }
121        public String getSystem() {
122          switch (this) {
123            case DRAFT: return "http://hl7.org/fhir/supplyrequest-status";
124            case ACTIVE: return "http://hl7.org/fhir/supplyrequest-status";
125            case SUSPENDED: return "http://hl7.org/fhir/supplyrequest-status";
126            case CANCELLED: return "http://hl7.org/fhir/supplyrequest-status";
127            case COMPLETED: return "http://hl7.org/fhir/supplyrequest-status";
128            case ENTEREDINERROR: return "http://hl7.org/fhir/supplyrequest-status";
129            case UNKNOWN: return "http://hl7.org/fhir/supplyrequest-status";
130            default: return "?";
131          }
132        }
133        public String getDefinition() {
134          switch (this) {
135            case DRAFT: return "The request has been created but is not yet complete or ready for action.";
136            case ACTIVE: return "The request is ready to be acted upon.";
137            case SUSPENDED: return "The authorization/request to act has been temporarily withdrawn but is expected to resume in the future.";
138            case CANCELLED: return "The authorization/request to act has been terminated prior to the full completion of the intended actions.  No further activity should occur.";
139            case COMPLETED: return "Activity against the request has been sufficiently completed to the satisfaction of the requester.";
140            case ENTEREDINERROR: return "This electronic record should never have existed, though it is possible that real-world decisions were based on it.  (If real-world activity has occurred, the status should be \"cancelled\" rather than \"entered-in-error\".).";
141            case UNKNOWN: return "The authoring/source system does not know which of the status values currently applies for this observation. Note: This concept is not to be used for \"other\" - one of the listed statuses is presumed to apply, but the authoring/source system does not know which.";
142            default: return "?";
143          }
144        }
145        public String getDisplay() {
146          switch (this) {
147            case DRAFT: return "Draft";
148            case ACTIVE: return "Active";
149            case SUSPENDED: return "Suspended";
150            case CANCELLED: return "Cancelled";
151            case COMPLETED: return "Completed";
152            case ENTEREDINERROR: return "Entered in Error";
153            case UNKNOWN: return "Unknown";
154            default: return "?";
155          }
156        }
157    }
158
159  public static class SupplyRequestStatusEnumFactory implements EnumFactory<SupplyRequestStatus> {
160    public SupplyRequestStatus fromCode(String codeString) throws IllegalArgumentException {
161      if (codeString == null || "".equals(codeString))
162            if (codeString == null || "".equals(codeString))
163                return null;
164        if ("draft".equals(codeString))
165          return SupplyRequestStatus.DRAFT;
166        if ("active".equals(codeString))
167          return SupplyRequestStatus.ACTIVE;
168        if ("suspended".equals(codeString))
169          return SupplyRequestStatus.SUSPENDED;
170        if ("cancelled".equals(codeString))
171          return SupplyRequestStatus.CANCELLED;
172        if ("completed".equals(codeString))
173          return SupplyRequestStatus.COMPLETED;
174        if ("entered-in-error".equals(codeString))
175          return SupplyRequestStatus.ENTEREDINERROR;
176        if ("unknown".equals(codeString))
177          return SupplyRequestStatus.UNKNOWN;
178        throw new IllegalArgumentException("Unknown SupplyRequestStatus code '"+codeString+"'");
179        }
180        public Enumeration<SupplyRequestStatus> fromType(Base code) throws FHIRException {
181          if (code == null)
182            return null;
183          if (code.isEmpty())
184            return new Enumeration<SupplyRequestStatus>(this);
185          String codeString = ((PrimitiveType) code).asStringValue();
186          if (codeString == null || "".equals(codeString))
187            return null;
188        if ("draft".equals(codeString))
189          return new Enumeration<SupplyRequestStatus>(this, SupplyRequestStatus.DRAFT);
190        if ("active".equals(codeString))
191          return new Enumeration<SupplyRequestStatus>(this, SupplyRequestStatus.ACTIVE);
192        if ("suspended".equals(codeString))
193          return new Enumeration<SupplyRequestStatus>(this, SupplyRequestStatus.SUSPENDED);
194        if ("cancelled".equals(codeString))
195          return new Enumeration<SupplyRequestStatus>(this, SupplyRequestStatus.CANCELLED);
196        if ("completed".equals(codeString))
197          return new Enumeration<SupplyRequestStatus>(this, SupplyRequestStatus.COMPLETED);
198        if ("entered-in-error".equals(codeString))
199          return new Enumeration<SupplyRequestStatus>(this, SupplyRequestStatus.ENTEREDINERROR);
200        if ("unknown".equals(codeString))
201          return new Enumeration<SupplyRequestStatus>(this, SupplyRequestStatus.UNKNOWN);
202        throw new FHIRException("Unknown SupplyRequestStatus code '"+codeString+"'");
203        }
204    public String toCode(SupplyRequestStatus code) {
205      if (code == SupplyRequestStatus.DRAFT)
206        return "draft";
207      if (code == SupplyRequestStatus.ACTIVE)
208        return "active";
209      if (code == SupplyRequestStatus.SUSPENDED)
210        return "suspended";
211      if (code == SupplyRequestStatus.CANCELLED)
212        return "cancelled";
213      if (code == SupplyRequestStatus.COMPLETED)
214        return "completed";
215      if (code == SupplyRequestStatus.ENTEREDINERROR)
216        return "entered-in-error";
217      if (code == SupplyRequestStatus.UNKNOWN)
218        return "unknown";
219      return "?";
220      }
221    public String toSystem(SupplyRequestStatus code) {
222      return code.getSystem();
223      }
224    }
225
226    public enum RequestPriority {
227        /**
228         * The request has normal priority.
229         */
230        ROUTINE, 
231        /**
232         * The request should be actioned promptly - higher priority than routine.
233         */
234        URGENT, 
235        /**
236         * The request should be actioned as soon as possible - higher priority than urgent.
237         */
238        ASAP, 
239        /**
240         * The request should be actioned immediately - highest possible priority.  E.g. an emergency.
241         */
242        STAT, 
243        /**
244         * added to help the parsers with the generic types
245         */
246        NULL;
247        public static RequestPriority fromCode(String codeString) throws FHIRException {
248            if (codeString == null || "".equals(codeString))
249                return null;
250        if ("routine".equals(codeString))
251          return ROUTINE;
252        if ("urgent".equals(codeString))
253          return URGENT;
254        if ("asap".equals(codeString))
255          return ASAP;
256        if ("stat".equals(codeString))
257          return STAT;
258        if (Configuration.isAcceptInvalidEnums())
259          return null;
260        else
261          throw new FHIRException("Unknown RequestPriority code '"+codeString+"'");
262        }
263        public String toCode() {
264          switch (this) {
265            case ROUTINE: return "routine";
266            case URGENT: return "urgent";
267            case ASAP: return "asap";
268            case STAT: return "stat";
269            default: return "?";
270          }
271        }
272        public String getSystem() {
273          switch (this) {
274            case ROUTINE: return "http://hl7.org/fhir/request-priority";
275            case URGENT: return "http://hl7.org/fhir/request-priority";
276            case ASAP: return "http://hl7.org/fhir/request-priority";
277            case STAT: return "http://hl7.org/fhir/request-priority";
278            default: return "?";
279          }
280        }
281        public String getDefinition() {
282          switch (this) {
283            case ROUTINE: return "The request has normal priority.";
284            case URGENT: return "The request should be actioned promptly - higher priority than routine.";
285            case ASAP: return "The request should be actioned as soon as possible - higher priority than urgent.";
286            case STAT: return "The request should be actioned immediately - highest possible priority.  E.g. an emergency.";
287            default: return "?";
288          }
289        }
290        public String getDisplay() {
291          switch (this) {
292            case ROUTINE: return "Routine";
293            case URGENT: return "Urgent";
294            case ASAP: return "ASAP";
295            case STAT: return "STAT";
296            default: return "?";
297          }
298        }
299    }
300
301  public static class RequestPriorityEnumFactory implements EnumFactory<RequestPriority> {
302    public RequestPriority fromCode(String codeString) throws IllegalArgumentException {
303      if (codeString == null || "".equals(codeString))
304            if (codeString == null || "".equals(codeString))
305                return null;
306        if ("routine".equals(codeString))
307          return RequestPriority.ROUTINE;
308        if ("urgent".equals(codeString))
309          return RequestPriority.URGENT;
310        if ("asap".equals(codeString))
311          return RequestPriority.ASAP;
312        if ("stat".equals(codeString))
313          return RequestPriority.STAT;
314        throw new IllegalArgumentException("Unknown RequestPriority code '"+codeString+"'");
315        }
316        public Enumeration<RequestPriority> fromType(Base code) throws FHIRException {
317          if (code == null)
318            return null;
319          if (code.isEmpty())
320            return new Enumeration<RequestPriority>(this);
321          String codeString = ((PrimitiveType) code).asStringValue();
322          if (codeString == null || "".equals(codeString))
323            return null;
324        if ("routine".equals(codeString))
325          return new Enumeration<RequestPriority>(this, RequestPriority.ROUTINE);
326        if ("urgent".equals(codeString))
327          return new Enumeration<RequestPriority>(this, RequestPriority.URGENT);
328        if ("asap".equals(codeString))
329          return new Enumeration<RequestPriority>(this, RequestPriority.ASAP);
330        if ("stat".equals(codeString))
331          return new Enumeration<RequestPriority>(this, RequestPriority.STAT);
332        throw new FHIRException("Unknown RequestPriority code '"+codeString+"'");
333        }
334    public String toCode(RequestPriority code) {
335      if (code == RequestPriority.ROUTINE)
336        return "routine";
337      if (code == RequestPriority.URGENT)
338        return "urgent";
339      if (code == RequestPriority.ASAP)
340        return "asap";
341      if (code == RequestPriority.STAT)
342        return "stat";
343      return "?";
344      }
345    public String toSystem(RequestPriority code) {
346      return code.getSystem();
347      }
348    }
349
350    @Block()
351    public static class SupplyRequestParameterComponent extends BackboneElement implements IBaseBackboneElement {
352        /**
353         * A code or string that identifies the device detail being asserted.
354         */
355        @Child(name = "code", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
356        @Description(shortDefinition="Item detail", formalDefinition="A code or string that identifies the device detail being asserted." )
357        protected CodeableConcept code;
358
359        /**
360         * The value of the device detail.
361         */
362        @Child(name = "value", type = {CodeableConcept.class, Quantity.class, Range.class, BooleanType.class}, order=2, min=0, max=1, modifier=false, summary=false)
363        @Description(shortDefinition="Value of detail", formalDefinition="The value of the device detail." )
364        protected Type value;
365
366        private static final long serialVersionUID = 884525025L;
367
368    /**
369     * Constructor
370     */
371      public SupplyRequestParameterComponent() {
372        super();
373      }
374
375        /**
376         * @return {@link #code} (A code or string that identifies the device detail being asserted.)
377         */
378        public CodeableConcept getCode() { 
379          if (this.code == null)
380            if (Configuration.errorOnAutoCreate())
381              throw new Error("Attempt to auto-create SupplyRequestParameterComponent.code");
382            else if (Configuration.doAutoCreate())
383              this.code = new CodeableConcept(); // cc
384          return this.code;
385        }
386
387        public boolean hasCode() { 
388          return this.code != null && !this.code.isEmpty();
389        }
390
391        /**
392         * @param value {@link #code} (A code or string that identifies the device detail being asserted.)
393         */
394        public SupplyRequestParameterComponent setCode(CodeableConcept value) { 
395          this.code = value;
396          return this;
397        }
398
399        /**
400         * @return {@link #value} (The value of the device detail.)
401         */
402        public Type getValue() { 
403          return this.value;
404        }
405
406        /**
407         * @return {@link #value} (The value of the device detail.)
408         */
409        public CodeableConcept getValueCodeableConcept() throws FHIRException { 
410          if (this.value == null)
411            this.value = new CodeableConcept();
412          if (!(this.value instanceof CodeableConcept))
413            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.value.getClass().getName()+" was encountered");
414          return (CodeableConcept) this.value;
415        }
416
417        public boolean hasValueCodeableConcept() { 
418          return this != null && this.value instanceof CodeableConcept;
419        }
420
421        /**
422         * @return {@link #value} (The value of the device detail.)
423         */
424        public Quantity getValueQuantity() throws FHIRException { 
425          if (this.value == null)
426            this.value = new Quantity();
427          if (!(this.value instanceof Quantity))
428            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.value.getClass().getName()+" was encountered");
429          return (Quantity) this.value;
430        }
431
432        public boolean hasValueQuantity() { 
433          return this != null && this.value instanceof Quantity;
434        }
435
436        /**
437         * @return {@link #value} (The value of the device detail.)
438         */
439        public Range getValueRange() throws FHIRException { 
440          if (this.value == null)
441            this.value = new Range();
442          if (!(this.value instanceof Range))
443            throw new FHIRException("Type mismatch: the type Range was expected, but "+this.value.getClass().getName()+" was encountered");
444          return (Range) this.value;
445        }
446
447        public boolean hasValueRange() { 
448          return this != null && this.value instanceof Range;
449        }
450
451        /**
452         * @return {@link #value} (The value of the device detail.)
453         */
454        public BooleanType getValueBooleanType() throws FHIRException { 
455          if (this.value == null)
456            this.value = new BooleanType();
457          if (!(this.value instanceof BooleanType))
458            throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.value.getClass().getName()+" was encountered");
459          return (BooleanType) this.value;
460        }
461
462        public boolean hasValueBooleanType() { 
463          return this != null && this.value instanceof BooleanType;
464        }
465
466        public boolean hasValue() { 
467          return this.value != null && !this.value.isEmpty();
468        }
469
470        /**
471         * @param value {@link #value} (The value of the device detail.)
472         */
473        public SupplyRequestParameterComponent setValue(Type value) { 
474          if (value != null && !(value instanceof CodeableConcept || value instanceof Quantity || value instanceof Range || value instanceof BooleanType))
475            throw new Error("Not the right type for SupplyRequest.parameter.value[x]: "+value.fhirType());
476          this.value = value;
477          return this;
478        }
479
480        protected void listChildren(List<Property> children) {
481          super.listChildren(children);
482          children.add(new Property("code", "CodeableConcept", "A code or string that identifies the device detail being asserted.", 0, 1, code));
483          children.add(new Property("value[x]", "CodeableConcept|Quantity|Range|boolean", "The value of the device detail.", 0, 1, value));
484        }
485
486        @Override
487        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
488          switch (_hash) {
489          case 3059181: /*code*/  return new Property("code", "CodeableConcept", "A code or string that identifies the device detail being asserted.", 0, 1, code);
490          case -1410166417: /*value[x]*/  return new Property("value[x]", "CodeableConcept|Quantity|Range|boolean", "The value of the device detail.", 0, 1, value);
491          case 111972721: /*value*/  return new Property("value[x]", "CodeableConcept|Quantity|Range|boolean", "The value of the device detail.", 0, 1, value);
492          case 924902896: /*valueCodeableConcept*/  return new Property("value[x]", "CodeableConcept|Quantity|Range|boolean", "The value of the device detail.", 0, 1, value);
493          case -2029823716: /*valueQuantity*/  return new Property("value[x]", "CodeableConcept|Quantity|Range|boolean", "The value of the device detail.", 0, 1, value);
494          case 2030761548: /*valueRange*/  return new Property("value[x]", "CodeableConcept|Quantity|Range|boolean", "The value of the device detail.", 0, 1, value);
495          case 733421943: /*valueBoolean*/  return new Property("value[x]", "CodeableConcept|Quantity|Range|boolean", "The value of the device detail.", 0, 1, value);
496          default: return super.getNamedProperty(_hash, _name, _checkValid);
497          }
498
499        }
500
501      @Override
502      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
503        switch (hash) {
504        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
505        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // Type
506        default: return super.getProperty(hash, name, checkValid);
507        }
508
509      }
510
511      @Override
512      public Base setProperty(int hash, String name, Base value) throws FHIRException {
513        switch (hash) {
514        case 3059181: // code
515          this.code = castToCodeableConcept(value); // CodeableConcept
516          return value;
517        case 111972721: // value
518          this.value = castToType(value); // Type
519          return value;
520        default: return super.setProperty(hash, name, value);
521        }
522
523      }
524
525      @Override
526      public Base setProperty(String name, Base value) throws FHIRException {
527        if (name.equals("code")) {
528          this.code = castToCodeableConcept(value); // CodeableConcept
529        } else if (name.equals("value[x]")) {
530          this.value = castToType(value); // Type
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 3059181:  return getCode(); 
540        case -1410166417:  return getValue(); 
541        case 111972721:  return getValue(); 
542        default: return super.makeProperty(hash, name);
543        }
544
545      }
546
547      @Override
548      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
549        switch (hash) {
550        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
551        case 111972721: /*value*/ return new String[] {"CodeableConcept", "Quantity", "Range", "boolean"};
552        default: return super.getTypesForProperty(hash, name);
553        }
554
555      }
556
557      @Override
558      public Base addChild(String name) throws FHIRException {
559        if (name.equals("code")) {
560          this.code = new CodeableConcept();
561          return this.code;
562        }
563        else if (name.equals("valueCodeableConcept")) {
564          this.value = new CodeableConcept();
565          return this.value;
566        }
567        else if (name.equals("valueQuantity")) {
568          this.value = new Quantity();
569          return this.value;
570        }
571        else if (name.equals("valueRange")) {
572          this.value = new Range();
573          return this.value;
574        }
575        else if (name.equals("valueBoolean")) {
576          this.value = new BooleanType();
577          return this.value;
578        }
579        else
580          return super.addChild(name);
581      }
582
583      public SupplyRequestParameterComponent copy() {
584        SupplyRequestParameterComponent dst = new SupplyRequestParameterComponent();
585        copyValues(dst);
586        return dst;
587      }
588
589      public void copyValues(SupplyRequestParameterComponent dst) {
590        super.copyValues(dst);
591        dst.code = code == null ? null : code.copy();
592        dst.value = value == null ? null : value.copy();
593      }
594
595      @Override
596      public boolean equalsDeep(Base other_) {
597        if (!super.equalsDeep(other_))
598          return false;
599        if (!(other_ instanceof SupplyRequestParameterComponent))
600          return false;
601        SupplyRequestParameterComponent o = (SupplyRequestParameterComponent) other_;
602        return compareDeep(code, o.code, true) && compareDeep(value, o.value, true);
603      }
604
605      @Override
606      public boolean equalsShallow(Base other_) {
607        if (!super.equalsShallow(other_))
608          return false;
609        if (!(other_ instanceof SupplyRequestParameterComponent))
610          return false;
611        SupplyRequestParameterComponent o = (SupplyRequestParameterComponent) other_;
612        return true;
613      }
614
615      public boolean isEmpty() {
616        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(code, value);
617      }
618
619  public String fhirType() {
620    return "SupplyRequest.parameter";
621
622  }
623
624  }
625
626    /**
627     * Business identifiers assigned to this SupplyRequest by the author and/or other systems. These identifiers remain constant as the resource is updated and propagates from server to server.
628     */
629    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
630    @Description(shortDefinition="Business Identifier for SupplyRequest", formalDefinition="Business identifiers assigned to this SupplyRequest by the author and/or other systems. These identifiers remain constant as the resource is updated and propagates from server to server." )
631    protected List<Identifier> identifier;
632
633    /**
634     * Status of the supply request.
635     */
636    @Child(name = "status", type = {CodeType.class}, order=1, min=0, max=1, modifier=true, summary=true)
637    @Description(shortDefinition="draft | active | suspended +", formalDefinition="Status of the supply request." )
638    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/supplyrequest-status")
639    protected Enumeration<SupplyRequestStatus> status;
640
641    /**
642     * Category of supply, e.g.  central, non-stock, etc. This is used to support work flows associated with the supply process.
643     */
644    @Child(name = "category", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
645    @Description(shortDefinition="The kind of supply (central, non-stock, etc.)", formalDefinition="Category of supply, e.g.  central, non-stock, etc. This is used to support work flows associated with the supply process." )
646    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/supplyrequest-kind")
647    protected CodeableConcept category;
648
649    /**
650     * Indicates how quickly this SupplyRequest should be addressed with respect to other requests.
651     */
652    @Child(name = "priority", type = {CodeType.class}, order=3, min=0, max=1, modifier=false, summary=true)
653    @Description(shortDefinition="routine | urgent | asap | stat", formalDefinition="Indicates how quickly this SupplyRequest should be addressed with respect to other requests." )
654    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/request-priority")
655    protected Enumeration<RequestPriority> priority;
656
657    /**
658     * The item that is requested to be supplied. This is either a link to a resource representing the details of the item or a code that identifies the item from a known list.
659     */
660    @Child(name = "item", type = {CodeableConcept.class, Medication.class, Substance.class, Device.class}, order=4, min=1, max=1, modifier=false, summary=true)
661    @Description(shortDefinition="Medication, Substance, or Device requested to be supplied", formalDefinition="The item that is requested to be supplied. This is either a link to a resource representing the details of the item or a code that identifies the item from a known list." )
662    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/supply-item")
663    protected Type item;
664
665    /**
666     * The amount that is being ordered of the indicated item.
667     */
668    @Child(name = "quantity", type = {Quantity.class}, order=5, min=1, max=1, modifier=false, summary=true)
669    @Description(shortDefinition="The requested amount of the item indicated", formalDefinition="The amount that is being ordered of the indicated item." )
670    protected Quantity quantity;
671
672    /**
673     * Specific parameters for the ordered item.  For example, the size of the indicated item.
674     */
675    @Child(name = "parameter", type = {}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
676    @Description(shortDefinition="Ordered item details", formalDefinition="Specific parameters for the ordered item.  For example, the size of the indicated item." )
677    protected List<SupplyRequestParameterComponent> parameter;
678
679    /**
680     * When the request should be fulfilled.
681     */
682    @Child(name = "occurrence", type = {DateTimeType.class, Period.class, Timing.class}, order=7, min=0, max=1, modifier=false, summary=true)
683    @Description(shortDefinition="When the request should be fulfilled", formalDefinition="When the request should be fulfilled." )
684    protected Type occurrence;
685
686    /**
687     * When the request was made.
688     */
689    @Child(name = "authoredOn", type = {DateTimeType.class}, order=8, min=0, max=1, modifier=false, summary=true)
690    @Description(shortDefinition="When the request was made", formalDefinition="When the request was made." )
691    protected DateTimeType authoredOn;
692
693    /**
694     * The device, practitioner, etc. who initiated the request.
695     */
696    @Child(name = "requester", type = {Practitioner.class, PractitionerRole.class, Organization.class, Patient.class, RelatedPerson.class, Device.class}, order=9, min=0, max=1, modifier=false, summary=true)
697    @Description(shortDefinition="Individual making the request", formalDefinition="The device, practitioner, etc. who initiated the request." )
698    protected Reference requester;
699
700    /**
701     * The actual object that is the target of the reference (The device, practitioner, etc. who initiated the request.)
702     */
703    protected Resource requesterTarget;
704
705    /**
706     * Who is intended to fulfill the request.
707     */
708    @Child(name = "supplier", type = {Organization.class, HealthcareService.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
709    @Description(shortDefinition="Who is intended to fulfill the request", formalDefinition="Who is intended to fulfill the request." )
710    protected List<Reference> supplier;
711    /**
712     * The actual objects that are the target of the reference (Who is intended to fulfill the request.)
713     */
714    protected List<Resource> supplierTarget;
715
716
717    /**
718     * The reason why the supply item was requested.
719     */
720    @Child(name = "reasonCode", type = {CodeableConcept.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
721    @Description(shortDefinition="The reason why the supply item was requested", formalDefinition="The reason why the supply item was requested." )
722    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/supplyrequest-reason")
723    protected List<CodeableConcept> reasonCode;
724
725    /**
726     * The reason why the supply item was requested.
727     */
728    @Child(name = "reasonReference", type = {Condition.class, Observation.class, DiagnosticReport.class, DocumentReference.class}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
729    @Description(shortDefinition="The reason why the supply item was requested", formalDefinition="The reason why the supply item was requested." )
730    protected List<Reference> reasonReference;
731    /**
732     * The actual objects that are the target of the reference (The reason why the supply item was requested.)
733     */
734    protected List<Resource> reasonReferenceTarget;
735
736
737    /**
738     * Where the supply is expected to come from.
739     */
740    @Child(name = "deliverFrom", type = {Organization.class, Location.class}, order=13, min=0, max=1, modifier=false, summary=false)
741    @Description(shortDefinition="The origin of the supply", formalDefinition="Where the supply is expected to come from." )
742    protected Reference deliverFrom;
743
744    /**
745     * The actual object that is the target of the reference (Where the supply is expected to come from.)
746     */
747    protected Resource deliverFromTarget;
748
749    /**
750     * Where the supply is destined to go.
751     */
752    @Child(name = "deliverTo", type = {Organization.class, Location.class, Patient.class}, order=14, min=0, max=1, modifier=false, summary=false)
753    @Description(shortDefinition="The destination of the supply", formalDefinition="Where the supply is destined to go." )
754    protected Reference deliverTo;
755
756    /**
757     * The actual object that is the target of the reference (Where the supply is destined to go.)
758     */
759    protected Resource deliverToTarget;
760
761    private static final long serialVersionUID = 1456312151L;
762
763  /**
764   * Constructor
765   */
766    public SupplyRequest() {
767      super();
768    }
769
770  /**
771   * Constructor
772   */
773    public SupplyRequest(Type item, Quantity quantity) {
774      super();
775      this.item = item;
776      this.quantity = quantity;
777    }
778
779    /**
780     * @return {@link #identifier} (Business identifiers assigned to this SupplyRequest by the author and/or other systems. These identifiers remain constant as the resource is updated and propagates from server to server.)
781     */
782    public List<Identifier> getIdentifier() { 
783      if (this.identifier == null)
784        this.identifier = new ArrayList<Identifier>();
785      return this.identifier;
786    }
787
788    /**
789     * @return Returns a reference to <code>this</code> for easy method chaining
790     */
791    public SupplyRequest setIdentifier(List<Identifier> theIdentifier) { 
792      this.identifier = theIdentifier;
793      return this;
794    }
795
796    public boolean hasIdentifier() { 
797      if (this.identifier == null)
798        return false;
799      for (Identifier item : this.identifier)
800        if (!item.isEmpty())
801          return true;
802      return false;
803    }
804
805    public Identifier addIdentifier() { //3
806      Identifier t = new Identifier();
807      if (this.identifier == null)
808        this.identifier = new ArrayList<Identifier>();
809      this.identifier.add(t);
810      return t;
811    }
812
813    public SupplyRequest addIdentifier(Identifier t) { //3
814      if (t == null)
815        return this;
816      if (this.identifier == null)
817        this.identifier = new ArrayList<Identifier>();
818      this.identifier.add(t);
819      return this;
820    }
821
822    /**
823     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
824     */
825    public Identifier getIdentifierFirstRep() { 
826      if (getIdentifier().isEmpty()) {
827        addIdentifier();
828      }
829      return getIdentifier().get(0);
830    }
831
832    /**
833     * @return {@link #status} (Status of the supply request.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
834     */
835    public Enumeration<SupplyRequestStatus> getStatusElement() { 
836      if (this.status == null)
837        if (Configuration.errorOnAutoCreate())
838          throw new Error("Attempt to auto-create SupplyRequest.status");
839        else if (Configuration.doAutoCreate())
840          this.status = new Enumeration<SupplyRequestStatus>(new SupplyRequestStatusEnumFactory()); // bb
841      return this.status;
842    }
843
844    public boolean hasStatusElement() { 
845      return this.status != null && !this.status.isEmpty();
846    }
847
848    public boolean hasStatus() { 
849      return this.status != null && !this.status.isEmpty();
850    }
851
852    /**
853     * @param value {@link #status} (Status of the supply request.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
854     */
855    public SupplyRequest setStatusElement(Enumeration<SupplyRequestStatus> value) { 
856      this.status = value;
857      return this;
858    }
859
860    /**
861     * @return Status of the supply request.
862     */
863    public SupplyRequestStatus getStatus() { 
864      return this.status == null ? null : this.status.getValue();
865    }
866
867    /**
868     * @param value Status of the supply request.
869     */
870    public SupplyRequest setStatus(SupplyRequestStatus value) { 
871      if (value == null)
872        this.status = null;
873      else {
874        if (this.status == null)
875          this.status = new Enumeration<SupplyRequestStatus>(new SupplyRequestStatusEnumFactory());
876        this.status.setValue(value);
877      }
878      return this;
879    }
880
881    /**
882     * @return {@link #category} (Category of supply, e.g.  central, non-stock, etc. This is used to support work flows associated with the supply process.)
883     */
884    public CodeableConcept getCategory() { 
885      if (this.category == null)
886        if (Configuration.errorOnAutoCreate())
887          throw new Error("Attempt to auto-create SupplyRequest.category");
888        else if (Configuration.doAutoCreate())
889          this.category = new CodeableConcept(); // cc
890      return this.category;
891    }
892
893    public boolean hasCategory() { 
894      return this.category != null && !this.category.isEmpty();
895    }
896
897    /**
898     * @param value {@link #category} (Category of supply, e.g.  central, non-stock, etc. This is used to support work flows associated with the supply process.)
899     */
900    public SupplyRequest setCategory(CodeableConcept value) { 
901      this.category = value;
902      return this;
903    }
904
905    /**
906     * @return {@link #priority} (Indicates how quickly this SupplyRequest should be addressed with respect to other requests.). This is the underlying object with id, value and extensions. The accessor "getPriority" gives direct access to the value
907     */
908    public Enumeration<RequestPriority> getPriorityElement() { 
909      if (this.priority == null)
910        if (Configuration.errorOnAutoCreate())
911          throw new Error("Attempt to auto-create SupplyRequest.priority");
912        else if (Configuration.doAutoCreate())
913          this.priority = new Enumeration<RequestPriority>(new RequestPriorityEnumFactory()); // bb
914      return this.priority;
915    }
916
917    public boolean hasPriorityElement() { 
918      return this.priority != null && !this.priority.isEmpty();
919    }
920
921    public boolean hasPriority() { 
922      return this.priority != null && !this.priority.isEmpty();
923    }
924
925    /**
926     * @param value {@link #priority} (Indicates how quickly this SupplyRequest should be addressed with respect to other requests.). This is the underlying object with id, value and extensions. The accessor "getPriority" gives direct access to the value
927     */
928    public SupplyRequest setPriorityElement(Enumeration<RequestPriority> value) { 
929      this.priority = value;
930      return this;
931    }
932
933    /**
934     * @return Indicates how quickly this SupplyRequest should be addressed with respect to other requests.
935     */
936    public RequestPriority getPriority() { 
937      return this.priority == null ? null : this.priority.getValue();
938    }
939
940    /**
941     * @param value Indicates how quickly this SupplyRequest should be addressed with respect to other requests.
942     */
943    public SupplyRequest setPriority(RequestPriority value) { 
944      if (value == null)
945        this.priority = null;
946      else {
947        if (this.priority == null)
948          this.priority = new Enumeration<RequestPriority>(new RequestPriorityEnumFactory());
949        this.priority.setValue(value);
950      }
951      return this;
952    }
953
954    /**
955     * @return {@link #item} (The item that is requested to be supplied. This is either a link to a resource representing the details of the item or a code that identifies the item from a known list.)
956     */
957    public Type getItem() { 
958      return this.item;
959    }
960
961    /**
962     * @return {@link #item} (The item that is requested to be supplied. This is either a link to a resource representing the details of the item or a code that identifies the item from a known list.)
963     */
964    public CodeableConcept getItemCodeableConcept() throws FHIRException { 
965      if (this.item == null)
966        this.item = new CodeableConcept();
967      if (!(this.item instanceof CodeableConcept))
968        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.item.getClass().getName()+" was encountered");
969      return (CodeableConcept) this.item;
970    }
971
972    public boolean hasItemCodeableConcept() { 
973      return this != null && this.item instanceof CodeableConcept;
974    }
975
976    /**
977     * @return {@link #item} (The item that is requested to be supplied. This is either a link to a resource representing the details of the item or a code that identifies the item from a known list.)
978     */
979    public Reference getItemReference() throws FHIRException { 
980      if (this.item == null)
981        this.item = new Reference();
982      if (!(this.item instanceof Reference))
983        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.item.getClass().getName()+" was encountered");
984      return (Reference) this.item;
985    }
986
987    public boolean hasItemReference() { 
988      return this != null && this.item instanceof Reference;
989    }
990
991    public boolean hasItem() { 
992      return this.item != null && !this.item.isEmpty();
993    }
994
995    /**
996     * @param value {@link #item} (The item that is requested to be supplied. This is either a link to a resource representing the details of the item or a code that identifies the item from a known list.)
997     */
998    public SupplyRequest setItem(Type value) { 
999      if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
1000        throw new Error("Not the right type for SupplyRequest.item[x]: "+value.fhirType());
1001      this.item = value;
1002      return this;
1003    }
1004
1005    /**
1006     * @return {@link #quantity} (The amount that is being ordered of the indicated item.)
1007     */
1008    public Quantity getQuantity() { 
1009      if (this.quantity == null)
1010        if (Configuration.errorOnAutoCreate())
1011          throw new Error("Attempt to auto-create SupplyRequest.quantity");
1012        else if (Configuration.doAutoCreate())
1013          this.quantity = new Quantity(); // cc
1014      return this.quantity;
1015    }
1016
1017    public boolean hasQuantity() { 
1018      return this.quantity != null && !this.quantity.isEmpty();
1019    }
1020
1021    /**
1022     * @param value {@link #quantity} (The amount that is being ordered of the indicated item.)
1023     */
1024    public SupplyRequest setQuantity(Quantity value) { 
1025      this.quantity = value;
1026      return this;
1027    }
1028
1029    /**
1030     * @return {@link #parameter} (Specific parameters for the ordered item.  For example, the size of the indicated item.)
1031     */
1032    public List<SupplyRequestParameterComponent> getParameter() { 
1033      if (this.parameter == null)
1034        this.parameter = new ArrayList<SupplyRequestParameterComponent>();
1035      return this.parameter;
1036    }
1037
1038    /**
1039     * @return Returns a reference to <code>this</code> for easy method chaining
1040     */
1041    public SupplyRequest setParameter(List<SupplyRequestParameterComponent> theParameter) { 
1042      this.parameter = theParameter;
1043      return this;
1044    }
1045
1046    public boolean hasParameter() { 
1047      if (this.parameter == null)
1048        return false;
1049      for (SupplyRequestParameterComponent item : this.parameter)
1050        if (!item.isEmpty())
1051          return true;
1052      return false;
1053    }
1054
1055    public SupplyRequestParameterComponent addParameter() { //3
1056      SupplyRequestParameterComponent t = new SupplyRequestParameterComponent();
1057      if (this.parameter == null)
1058        this.parameter = new ArrayList<SupplyRequestParameterComponent>();
1059      this.parameter.add(t);
1060      return t;
1061    }
1062
1063    public SupplyRequest addParameter(SupplyRequestParameterComponent t) { //3
1064      if (t == null)
1065        return this;
1066      if (this.parameter == null)
1067        this.parameter = new ArrayList<SupplyRequestParameterComponent>();
1068      this.parameter.add(t);
1069      return this;
1070    }
1071
1072    /**
1073     * @return The first repetition of repeating field {@link #parameter}, creating it if it does not already exist
1074     */
1075    public SupplyRequestParameterComponent getParameterFirstRep() { 
1076      if (getParameter().isEmpty()) {
1077        addParameter();
1078      }
1079      return getParameter().get(0);
1080    }
1081
1082    /**
1083     * @return {@link #occurrence} (When the request should be fulfilled.)
1084     */
1085    public Type getOccurrence() { 
1086      return this.occurrence;
1087    }
1088
1089    /**
1090     * @return {@link #occurrence} (When the request should be fulfilled.)
1091     */
1092    public DateTimeType getOccurrenceDateTimeType() throws FHIRException { 
1093      if (this.occurrence == null)
1094        this.occurrence = new DateTimeType();
1095      if (!(this.occurrence instanceof DateTimeType))
1096        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.occurrence.getClass().getName()+" was encountered");
1097      return (DateTimeType) this.occurrence;
1098    }
1099
1100    public boolean hasOccurrenceDateTimeType() { 
1101      return this != null && this.occurrence instanceof DateTimeType;
1102    }
1103
1104    /**
1105     * @return {@link #occurrence} (When the request should be fulfilled.)
1106     */
1107    public Period getOccurrencePeriod() throws FHIRException { 
1108      if (this.occurrence == null)
1109        this.occurrence = new Period();
1110      if (!(this.occurrence instanceof Period))
1111        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.occurrence.getClass().getName()+" was encountered");
1112      return (Period) this.occurrence;
1113    }
1114
1115    public boolean hasOccurrencePeriod() { 
1116      return this != null && this.occurrence instanceof Period;
1117    }
1118
1119    /**
1120     * @return {@link #occurrence} (When the request should be fulfilled.)
1121     */
1122    public Timing getOccurrenceTiming() throws FHIRException { 
1123      if (this.occurrence == null)
1124        this.occurrence = new Timing();
1125      if (!(this.occurrence instanceof Timing))
1126        throw new FHIRException("Type mismatch: the type Timing was expected, but "+this.occurrence.getClass().getName()+" was encountered");
1127      return (Timing) this.occurrence;
1128    }
1129
1130    public boolean hasOccurrenceTiming() { 
1131      return this != null && this.occurrence instanceof Timing;
1132    }
1133
1134    public boolean hasOccurrence() { 
1135      return this.occurrence != null && !this.occurrence.isEmpty();
1136    }
1137
1138    /**
1139     * @param value {@link #occurrence} (When the request should be fulfilled.)
1140     */
1141    public SupplyRequest setOccurrence(Type value) { 
1142      if (value != null && !(value instanceof DateTimeType || value instanceof Period || value instanceof Timing))
1143        throw new Error("Not the right type for SupplyRequest.occurrence[x]: "+value.fhirType());
1144      this.occurrence = value;
1145      return this;
1146    }
1147
1148    /**
1149     * @return {@link #authoredOn} (When the request was made.). This is the underlying object with id, value and extensions. The accessor "getAuthoredOn" gives direct access to the value
1150     */
1151    public DateTimeType getAuthoredOnElement() { 
1152      if (this.authoredOn == null)
1153        if (Configuration.errorOnAutoCreate())
1154          throw new Error("Attempt to auto-create SupplyRequest.authoredOn");
1155        else if (Configuration.doAutoCreate())
1156          this.authoredOn = new DateTimeType(); // bb
1157      return this.authoredOn;
1158    }
1159
1160    public boolean hasAuthoredOnElement() { 
1161      return this.authoredOn != null && !this.authoredOn.isEmpty();
1162    }
1163
1164    public boolean hasAuthoredOn() { 
1165      return this.authoredOn != null && !this.authoredOn.isEmpty();
1166    }
1167
1168    /**
1169     * @param value {@link #authoredOn} (When the request was made.). This is the underlying object with id, value and extensions. The accessor "getAuthoredOn" gives direct access to the value
1170     */
1171    public SupplyRequest setAuthoredOnElement(DateTimeType value) { 
1172      this.authoredOn = value;
1173      return this;
1174    }
1175
1176    /**
1177     * @return When the request was made.
1178     */
1179    public Date getAuthoredOn() { 
1180      return this.authoredOn == null ? null : this.authoredOn.getValue();
1181    }
1182
1183    /**
1184     * @param value When the request was made.
1185     */
1186    public SupplyRequest setAuthoredOn(Date value) { 
1187      if (value == null)
1188        this.authoredOn = null;
1189      else {
1190        if (this.authoredOn == null)
1191          this.authoredOn = new DateTimeType();
1192        this.authoredOn.setValue(value);
1193      }
1194      return this;
1195    }
1196
1197    /**
1198     * @return {@link #requester} (The device, practitioner, etc. who initiated the request.)
1199     */
1200    public Reference getRequester() { 
1201      if (this.requester == null)
1202        if (Configuration.errorOnAutoCreate())
1203          throw new Error("Attempt to auto-create SupplyRequest.requester");
1204        else if (Configuration.doAutoCreate())
1205          this.requester = new Reference(); // cc
1206      return this.requester;
1207    }
1208
1209    public boolean hasRequester() { 
1210      return this.requester != null && !this.requester.isEmpty();
1211    }
1212
1213    /**
1214     * @param value {@link #requester} (The device, practitioner, etc. who initiated the request.)
1215     */
1216    public SupplyRequest setRequester(Reference value) { 
1217      this.requester = value;
1218      return this;
1219    }
1220
1221    /**
1222     * @return {@link #requester} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The device, practitioner, etc. who initiated the request.)
1223     */
1224    public Resource getRequesterTarget() { 
1225      return this.requesterTarget;
1226    }
1227
1228    /**
1229     * @param value {@link #requester} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The device, practitioner, etc. who initiated the request.)
1230     */
1231    public SupplyRequest setRequesterTarget(Resource value) { 
1232      this.requesterTarget = value;
1233      return this;
1234    }
1235
1236    /**
1237     * @return {@link #supplier} (Who is intended to fulfill the request.)
1238     */
1239    public List<Reference> getSupplier() { 
1240      if (this.supplier == null)
1241        this.supplier = new ArrayList<Reference>();
1242      return this.supplier;
1243    }
1244
1245    /**
1246     * @return Returns a reference to <code>this</code> for easy method chaining
1247     */
1248    public SupplyRequest setSupplier(List<Reference> theSupplier) { 
1249      this.supplier = theSupplier;
1250      return this;
1251    }
1252
1253    public boolean hasSupplier() { 
1254      if (this.supplier == null)
1255        return false;
1256      for (Reference item : this.supplier)
1257        if (!item.isEmpty())
1258          return true;
1259      return false;
1260    }
1261
1262    public Reference addSupplier() { //3
1263      Reference t = new Reference();
1264      if (this.supplier == null)
1265        this.supplier = new ArrayList<Reference>();
1266      this.supplier.add(t);
1267      return t;
1268    }
1269
1270    public SupplyRequest addSupplier(Reference t) { //3
1271      if (t == null)
1272        return this;
1273      if (this.supplier == null)
1274        this.supplier = new ArrayList<Reference>();
1275      this.supplier.add(t);
1276      return this;
1277    }
1278
1279    /**
1280     * @return The first repetition of repeating field {@link #supplier}, creating it if it does not already exist
1281     */
1282    public Reference getSupplierFirstRep() { 
1283      if (getSupplier().isEmpty()) {
1284        addSupplier();
1285      }
1286      return getSupplier().get(0);
1287    }
1288
1289    /**
1290     * @deprecated Use Reference#setResource(IBaseResource) instead
1291     */
1292    @Deprecated
1293    public List<Resource> getSupplierTarget() { 
1294      if (this.supplierTarget == null)
1295        this.supplierTarget = new ArrayList<Resource>();
1296      return this.supplierTarget;
1297    }
1298
1299    /**
1300     * @return {@link #reasonCode} (The reason why the supply item was requested.)
1301     */
1302    public List<CodeableConcept> getReasonCode() { 
1303      if (this.reasonCode == null)
1304        this.reasonCode = new ArrayList<CodeableConcept>();
1305      return this.reasonCode;
1306    }
1307
1308    /**
1309     * @return Returns a reference to <code>this</code> for easy method chaining
1310     */
1311    public SupplyRequest setReasonCode(List<CodeableConcept> theReasonCode) { 
1312      this.reasonCode = theReasonCode;
1313      return this;
1314    }
1315
1316    public boolean hasReasonCode() { 
1317      if (this.reasonCode == null)
1318        return false;
1319      for (CodeableConcept item : this.reasonCode)
1320        if (!item.isEmpty())
1321          return true;
1322      return false;
1323    }
1324
1325    public CodeableConcept addReasonCode() { //3
1326      CodeableConcept t = new CodeableConcept();
1327      if (this.reasonCode == null)
1328        this.reasonCode = new ArrayList<CodeableConcept>();
1329      this.reasonCode.add(t);
1330      return t;
1331    }
1332
1333    public SupplyRequest addReasonCode(CodeableConcept t) { //3
1334      if (t == null)
1335        return this;
1336      if (this.reasonCode == null)
1337        this.reasonCode = new ArrayList<CodeableConcept>();
1338      this.reasonCode.add(t);
1339      return this;
1340    }
1341
1342    /**
1343     * @return The first repetition of repeating field {@link #reasonCode}, creating it if it does not already exist
1344     */
1345    public CodeableConcept getReasonCodeFirstRep() { 
1346      if (getReasonCode().isEmpty()) {
1347        addReasonCode();
1348      }
1349      return getReasonCode().get(0);
1350    }
1351
1352    /**
1353     * @return {@link #reasonReference} (The reason why the supply item was requested.)
1354     */
1355    public List<Reference> getReasonReference() { 
1356      if (this.reasonReference == null)
1357        this.reasonReference = new ArrayList<Reference>();
1358      return this.reasonReference;
1359    }
1360
1361    /**
1362     * @return Returns a reference to <code>this</code> for easy method chaining
1363     */
1364    public SupplyRequest setReasonReference(List<Reference> theReasonReference) { 
1365      this.reasonReference = theReasonReference;
1366      return this;
1367    }
1368
1369    public boolean hasReasonReference() { 
1370      if (this.reasonReference == null)
1371        return false;
1372      for (Reference item : this.reasonReference)
1373        if (!item.isEmpty())
1374          return true;
1375      return false;
1376    }
1377
1378    public Reference addReasonReference() { //3
1379      Reference t = new Reference();
1380      if (this.reasonReference == null)
1381        this.reasonReference = new ArrayList<Reference>();
1382      this.reasonReference.add(t);
1383      return t;
1384    }
1385
1386    public SupplyRequest addReasonReference(Reference t) { //3
1387      if (t == null)
1388        return this;
1389      if (this.reasonReference == null)
1390        this.reasonReference = new ArrayList<Reference>();
1391      this.reasonReference.add(t);
1392      return this;
1393    }
1394
1395    /**
1396     * @return The first repetition of repeating field {@link #reasonReference}, creating it if it does not already exist
1397     */
1398    public Reference getReasonReferenceFirstRep() { 
1399      if (getReasonReference().isEmpty()) {
1400        addReasonReference();
1401      }
1402      return getReasonReference().get(0);
1403    }
1404
1405    /**
1406     * @deprecated Use Reference#setResource(IBaseResource) instead
1407     */
1408    @Deprecated
1409    public List<Resource> getReasonReferenceTarget() { 
1410      if (this.reasonReferenceTarget == null)
1411        this.reasonReferenceTarget = new ArrayList<Resource>();
1412      return this.reasonReferenceTarget;
1413    }
1414
1415    /**
1416     * @return {@link #deliverFrom} (Where the supply is expected to come from.)
1417     */
1418    public Reference getDeliverFrom() { 
1419      if (this.deliverFrom == null)
1420        if (Configuration.errorOnAutoCreate())
1421          throw new Error("Attempt to auto-create SupplyRequest.deliverFrom");
1422        else if (Configuration.doAutoCreate())
1423          this.deliverFrom = new Reference(); // cc
1424      return this.deliverFrom;
1425    }
1426
1427    public boolean hasDeliverFrom() { 
1428      return this.deliverFrom != null && !this.deliverFrom.isEmpty();
1429    }
1430
1431    /**
1432     * @param value {@link #deliverFrom} (Where the supply is expected to come from.)
1433     */
1434    public SupplyRequest setDeliverFrom(Reference value) { 
1435      this.deliverFrom = value;
1436      return this;
1437    }
1438
1439    /**
1440     * @return {@link #deliverFrom} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Where the supply is expected to come from.)
1441     */
1442    public Resource getDeliverFromTarget() { 
1443      return this.deliverFromTarget;
1444    }
1445
1446    /**
1447     * @param value {@link #deliverFrom} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Where the supply is expected to come from.)
1448     */
1449    public SupplyRequest setDeliverFromTarget(Resource value) { 
1450      this.deliverFromTarget = value;
1451      return this;
1452    }
1453
1454    /**
1455     * @return {@link #deliverTo} (Where the supply is destined to go.)
1456     */
1457    public Reference getDeliverTo() { 
1458      if (this.deliverTo == null)
1459        if (Configuration.errorOnAutoCreate())
1460          throw new Error("Attempt to auto-create SupplyRequest.deliverTo");
1461        else if (Configuration.doAutoCreate())
1462          this.deliverTo = new Reference(); // cc
1463      return this.deliverTo;
1464    }
1465
1466    public boolean hasDeliverTo() { 
1467      return this.deliverTo != null && !this.deliverTo.isEmpty();
1468    }
1469
1470    /**
1471     * @param value {@link #deliverTo} (Where the supply is destined to go.)
1472     */
1473    public SupplyRequest setDeliverTo(Reference value) { 
1474      this.deliverTo = value;
1475      return this;
1476    }
1477
1478    /**
1479     * @return {@link #deliverTo} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Where the supply is destined to go.)
1480     */
1481    public Resource getDeliverToTarget() { 
1482      return this.deliverToTarget;
1483    }
1484
1485    /**
1486     * @param value {@link #deliverTo} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Where the supply is destined to go.)
1487     */
1488    public SupplyRequest setDeliverToTarget(Resource value) { 
1489      this.deliverToTarget = value;
1490      return this;
1491    }
1492
1493      protected void listChildren(List<Property> children) {
1494        super.listChildren(children);
1495        children.add(new Property("identifier", "Identifier", "Business identifiers assigned to this SupplyRequest by the author and/or other systems. These identifiers remain constant as the resource is updated and propagates from server to server.", 0, java.lang.Integer.MAX_VALUE, identifier));
1496        children.add(new Property("status", "code", "Status of the supply request.", 0, 1, status));
1497        children.add(new Property("category", "CodeableConcept", "Category of supply, e.g.  central, non-stock, etc. This is used to support work flows associated with the supply process.", 0, 1, category));
1498        children.add(new Property("priority", "code", "Indicates how quickly this SupplyRequest should be addressed with respect to other requests.", 0, 1, priority));
1499        children.add(new Property("item[x]", "CodeableConcept|Reference(Medication|Substance|Device)", "The item that is requested to be supplied. This is either a link to a resource representing the details of the item or a code that identifies the item from a known list.", 0, 1, item));
1500        children.add(new Property("quantity", "Quantity", "The amount that is being ordered of the indicated item.", 0, 1, quantity));
1501        children.add(new Property("parameter", "", "Specific parameters for the ordered item.  For example, the size of the indicated item.", 0, java.lang.Integer.MAX_VALUE, parameter));
1502        children.add(new Property("occurrence[x]", "dateTime|Period|Timing", "When the request should be fulfilled.", 0, 1, occurrence));
1503        children.add(new Property("authoredOn", "dateTime", "When the request was made.", 0, 1, authoredOn));
1504        children.add(new Property("requester", "Reference(Practitioner|PractitionerRole|Organization|Patient|RelatedPerson|Device)", "The device, practitioner, etc. who initiated the request.", 0, 1, requester));
1505        children.add(new Property("supplier", "Reference(Organization|HealthcareService)", "Who is intended to fulfill the request.", 0, java.lang.Integer.MAX_VALUE, supplier));
1506        children.add(new Property("reasonCode", "CodeableConcept", "The reason why the supply item was requested.", 0, java.lang.Integer.MAX_VALUE, reasonCode));
1507        children.add(new Property("reasonReference", "Reference(Condition|Observation|DiagnosticReport|DocumentReference)", "The reason why the supply item was requested.", 0, java.lang.Integer.MAX_VALUE, reasonReference));
1508        children.add(new Property("deliverFrom", "Reference(Organization|Location)", "Where the supply is expected to come from.", 0, 1, deliverFrom));
1509        children.add(new Property("deliverTo", "Reference(Organization|Location|Patient)", "Where the supply is destined to go.", 0, 1, deliverTo));
1510      }
1511
1512      @Override
1513      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1514        switch (_hash) {
1515        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Business identifiers assigned to this SupplyRequest by the author and/or other systems. These identifiers remain constant as the resource is updated and propagates from server to server.", 0, java.lang.Integer.MAX_VALUE, identifier);
1516        case -892481550: /*status*/  return new Property("status", "code", "Status of the supply request.", 0, 1, status);
1517        case 50511102: /*category*/  return new Property("category", "CodeableConcept", "Category of supply, e.g.  central, non-stock, etc. This is used to support work flows associated with the supply process.", 0, 1, category);
1518        case -1165461084: /*priority*/  return new Property("priority", "code", "Indicates how quickly this SupplyRequest should be addressed with respect to other requests.", 0, 1, priority);
1519        case 2116201613: /*item[x]*/  return new Property("item[x]", "CodeableConcept|Reference(Medication|Substance|Device)", "The item that is requested to be supplied. This is either a link to a resource representing the details of the item or a code that identifies the item from a known list.", 0, 1, item);
1520        case 3242771: /*item*/  return new Property("item[x]", "CodeableConcept|Reference(Medication|Substance|Device)", "The item that is requested to be supplied. This is either a link to a resource representing the details of the item or a code that identifies the item from a known list.", 0, 1, item);
1521        case 106644494: /*itemCodeableConcept*/  return new Property("item[x]", "CodeableConcept|Reference(Medication|Substance|Device)", "The item that is requested to be supplied. This is either a link to a resource representing the details of the item or a code that identifies the item from a known list.", 0, 1, item);
1522        case 1376364920: /*itemReference*/  return new Property("item[x]", "CodeableConcept|Reference(Medication|Substance|Device)", "The item that is requested to be supplied. This is either a link to a resource representing the details of the item or a code that identifies the item from a known list.", 0, 1, item);
1523        case -1285004149: /*quantity*/  return new Property("quantity", "Quantity", "The amount that is being ordered of the indicated item.", 0, 1, quantity);
1524        case 1954460585: /*parameter*/  return new Property("parameter", "", "Specific parameters for the ordered item.  For example, the size of the indicated item.", 0, java.lang.Integer.MAX_VALUE, parameter);
1525        case -2022646513: /*occurrence[x]*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "When the request should be fulfilled.", 0, 1, occurrence);
1526        case 1687874001: /*occurrence*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "When the request should be fulfilled.", 0, 1, occurrence);
1527        case -298443636: /*occurrenceDateTime*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "When the request should be fulfilled.", 0, 1, occurrence);
1528        case 1397156594: /*occurrencePeriod*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "When the request should be fulfilled.", 0, 1, occurrence);
1529        case 1515218299: /*occurrenceTiming*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "When the request should be fulfilled.", 0, 1, occurrence);
1530        case -1500852503: /*authoredOn*/  return new Property("authoredOn", "dateTime", "When the request was made.", 0, 1, authoredOn);
1531        case 693933948: /*requester*/  return new Property("requester", "Reference(Practitioner|PractitionerRole|Organization|Patient|RelatedPerson|Device)", "The device, practitioner, etc. who initiated the request.", 0, 1, requester);
1532        case -1663305268: /*supplier*/  return new Property("supplier", "Reference(Organization|HealthcareService)", "Who is intended to fulfill the request.", 0, java.lang.Integer.MAX_VALUE, supplier);
1533        case 722137681: /*reasonCode*/  return new Property("reasonCode", "CodeableConcept", "The reason why the supply item was requested.", 0, java.lang.Integer.MAX_VALUE, reasonCode);
1534        case -1146218137: /*reasonReference*/  return new Property("reasonReference", "Reference(Condition|Observation|DiagnosticReport|DocumentReference)", "The reason why the supply item was requested.", 0, java.lang.Integer.MAX_VALUE, reasonReference);
1535        case -949323153: /*deliverFrom*/  return new Property("deliverFrom", "Reference(Organization|Location)", "Where the supply is expected to come from.", 0, 1, deliverFrom);
1536        case -242327936: /*deliverTo*/  return new Property("deliverTo", "Reference(Organization|Location|Patient)", "Where the supply is destined to go.", 0, 1, deliverTo);
1537        default: return super.getNamedProperty(_hash, _name, _checkValid);
1538        }
1539
1540      }
1541
1542      @Override
1543      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1544        switch (hash) {
1545        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1546        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<SupplyRequestStatus>
1547        case 50511102: /*category*/ return this.category == null ? new Base[0] : new Base[] {this.category}; // CodeableConcept
1548        case -1165461084: /*priority*/ return this.priority == null ? new Base[0] : new Base[] {this.priority}; // Enumeration<RequestPriority>
1549        case 3242771: /*item*/ return this.item == null ? new Base[0] : new Base[] {this.item}; // Type
1550        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // Quantity
1551        case 1954460585: /*parameter*/ return this.parameter == null ? new Base[0] : this.parameter.toArray(new Base[this.parameter.size()]); // SupplyRequestParameterComponent
1552        case 1687874001: /*occurrence*/ return this.occurrence == null ? new Base[0] : new Base[] {this.occurrence}; // Type
1553        case -1500852503: /*authoredOn*/ return this.authoredOn == null ? new Base[0] : new Base[] {this.authoredOn}; // DateTimeType
1554        case 693933948: /*requester*/ return this.requester == null ? new Base[0] : new Base[] {this.requester}; // Reference
1555        case -1663305268: /*supplier*/ return this.supplier == null ? new Base[0] : this.supplier.toArray(new Base[this.supplier.size()]); // Reference
1556        case 722137681: /*reasonCode*/ return this.reasonCode == null ? new Base[0] : this.reasonCode.toArray(new Base[this.reasonCode.size()]); // CodeableConcept
1557        case -1146218137: /*reasonReference*/ return this.reasonReference == null ? new Base[0] : this.reasonReference.toArray(new Base[this.reasonReference.size()]); // Reference
1558        case -949323153: /*deliverFrom*/ return this.deliverFrom == null ? new Base[0] : new Base[] {this.deliverFrom}; // Reference
1559        case -242327936: /*deliverTo*/ return this.deliverTo == null ? new Base[0] : new Base[] {this.deliverTo}; // Reference
1560        default: return super.getProperty(hash, name, checkValid);
1561        }
1562
1563      }
1564
1565      @Override
1566      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1567        switch (hash) {
1568        case -1618432855: // identifier
1569          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1570          return value;
1571        case -892481550: // status
1572          value = new SupplyRequestStatusEnumFactory().fromType(castToCode(value));
1573          this.status = (Enumeration) value; // Enumeration<SupplyRequestStatus>
1574          return value;
1575        case 50511102: // category
1576          this.category = castToCodeableConcept(value); // CodeableConcept
1577          return value;
1578        case -1165461084: // priority
1579          value = new RequestPriorityEnumFactory().fromType(castToCode(value));
1580          this.priority = (Enumeration) value; // Enumeration<RequestPriority>
1581          return value;
1582        case 3242771: // item
1583          this.item = castToType(value); // Type
1584          return value;
1585        case -1285004149: // quantity
1586          this.quantity = castToQuantity(value); // Quantity
1587          return value;
1588        case 1954460585: // parameter
1589          this.getParameter().add((SupplyRequestParameterComponent) value); // SupplyRequestParameterComponent
1590          return value;
1591        case 1687874001: // occurrence
1592          this.occurrence = castToType(value); // Type
1593          return value;
1594        case -1500852503: // authoredOn
1595          this.authoredOn = castToDateTime(value); // DateTimeType
1596          return value;
1597        case 693933948: // requester
1598          this.requester = castToReference(value); // Reference
1599          return value;
1600        case -1663305268: // supplier
1601          this.getSupplier().add(castToReference(value)); // Reference
1602          return value;
1603        case 722137681: // reasonCode
1604          this.getReasonCode().add(castToCodeableConcept(value)); // CodeableConcept
1605          return value;
1606        case -1146218137: // reasonReference
1607          this.getReasonReference().add(castToReference(value)); // Reference
1608          return value;
1609        case -949323153: // deliverFrom
1610          this.deliverFrom = castToReference(value); // Reference
1611          return value;
1612        case -242327936: // deliverTo
1613          this.deliverTo = castToReference(value); // Reference
1614          return value;
1615        default: return super.setProperty(hash, name, value);
1616        }
1617
1618      }
1619
1620      @Override
1621      public Base setProperty(String name, Base value) throws FHIRException {
1622        if (name.equals("identifier")) {
1623          this.getIdentifier().add(castToIdentifier(value));
1624        } else if (name.equals("status")) {
1625          value = new SupplyRequestStatusEnumFactory().fromType(castToCode(value));
1626          this.status = (Enumeration) value; // Enumeration<SupplyRequestStatus>
1627        } else if (name.equals("category")) {
1628          this.category = castToCodeableConcept(value); // CodeableConcept
1629        } else if (name.equals("priority")) {
1630          value = new RequestPriorityEnumFactory().fromType(castToCode(value));
1631          this.priority = (Enumeration) value; // Enumeration<RequestPriority>
1632        } else if (name.equals("item[x]")) {
1633          this.item = castToType(value); // Type
1634        } else if (name.equals("quantity")) {
1635          this.quantity = castToQuantity(value); // Quantity
1636        } else if (name.equals("parameter")) {
1637          this.getParameter().add((SupplyRequestParameterComponent) value);
1638        } else if (name.equals("occurrence[x]")) {
1639          this.occurrence = castToType(value); // Type
1640        } else if (name.equals("authoredOn")) {
1641          this.authoredOn = castToDateTime(value); // DateTimeType
1642        } else if (name.equals("requester")) {
1643          this.requester = castToReference(value); // Reference
1644        } else if (name.equals("supplier")) {
1645          this.getSupplier().add(castToReference(value));
1646        } else if (name.equals("reasonCode")) {
1647          this.getReasonCode().add(castToCodeableConcept(value));
1648        } else if (name.equals("reasonReference")) {
1649          this.getReasonReference().add(castToReference(value));
1650        } else if (name.equals("deliverFrom")) {
1651          this.deliverFrom = castToReference(value); // Reference
1652        } else if (name.equals("deliverTo")) {
1653          this.deliverTo = castToReference(value); // Reference
1654        } else
1655          return super.setProperty(name, value);
1656        return value;
1657      }
1658
1659      @Override
1660      public Base makeProperty(int hash, String name) throws FHIRException {
1661        switch (hash) {
1662        case -1618432855:  return addIdentifier(); 
1663        case -892481550:  return getStatusElement();
1664        case 50511102:  return getCategory(); 
1665        case -1165461084:  return getPriorityElement();
1666        case 2116201613:  return getItem(); 
1667        case 3242771:  return getItem(); 
1668        case -1285004149:  return getQuantity(); 
1669        case 1954460585:  return addParameter(); 
1670        case -2022646513:  return getOccurrence(); 
1671        case 1687874001:  return getOccurrence(); 
1672        case -1500852503:  return getAuthoredOnElement();
1673        case 693933948:  return getRequester(); 
1674        case -1663305268:  return addSupplier(); 
1675        case 722137681:  return addReasonCode(); 
1676        case -1146218137:  return addReasonReference(); 
1677        case -949323153:  return getDeliverFrom(); 
1678        case -242327936:  return getDeliverTo(); 
1679        default: return super.makeProperty(hash, name);
1680        }
1681
1682      }
1683
1684      @Override
1685      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1686        switch (hash) {
1687        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1688        case -892481550: /*status*/ return new String[] {"code"};
1689        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
1690        case -1165461084: /*priority*/ return new String[] {"code"};
1691        case 3242771: /*item*/ return new String[] {"CodeableConcept", "Reference"};
1692        case -1285004149: /*quantity*/ return new String[] {"Quantity"};
1693        case 1954460585: /*parameter*/ return new String[] {};
1694        case 1687874001: /*occurrence*/ return new String[] {"dateTime", "Period", "Timing"};
1695        case -1500852503: /*authoredOn*/ return new String[] {"dateTime"};
1696        case 693933948: /*requester*/ return new String[] {"Reference"};
1697        case -1663305268: /*supplier*/ return new String[] {"Reference"};
1698        case 722137681: /*reasonCode*/ return new String[] {"CodeableConcept"};
1699        case -1146218137: /*reasonReference*/ return new String[] {"Reference"};
1700        case -949323153: /*deliverFrom*/ return new String[] {"Reference"};
1701        case -242327936: /*deliverTo*/ return new String[] {"Reference"};
1702        default: return super.getTypesForProperty(hash, name);
1703        }
1704
1705      }
1706
1707      @Override
1708      public Base addChild(String name) throws FHIRException {
1709        if (name.equals("identifier")) {
1710          return addIdentifier();
1711        }
1712        else if (name.equals("status")) {
1713          throw new FHIRException("Cannot call addChild on a primitive type SupplyRequest.status");
1714        }
1715        else if (name.equals("category")) {
1716          this.category = new CodeableConcept();
1717          return this.category;
1718        }
1719        else if (name.equals("priority")) {
1720          throw new FHIRException("Cannot call addChild on a primitive type SupplyRequest.priority");
1721        }
1722        else if (name.equals("itemCodeableConcept")) {
1723          this.item = new CodeableConcept();
1724          return this.item;
1725        }
1726        else if (name.equals("itemReference")) {
1727          this.item = new Reference();
1728          return this.item;
1729        }
1730        else if (name.equals("quantity")) {
1731          this.quantity = new Quantity();
1732          return this.quantity;
1733        }
1734        else if (name.equals("parameter")) {
1735          return addParameter();
1736        }
1737        else if (name.equals("occurrenceDateTime")) {
1738          this.occurrence = new DateTimeType();
1739          return this.occurrence;
1740        }
1741        else if (name.equals("occurrencePeriod")) {
1742          this.occurrence = new Period();
1743          return this.occurrence;
1744        }
1745        else if (name.equals("occurrenceTiming")) {
1746          this.occurrence = new Timing();
1747          return this.occurrence;
1748        }
1749        else if (name.equals("authoredOn")) {
1750          throw new FHIRException("Cannot call addChild on a primitive type SupplyRequest.authoredOn");
1751        }
1752        else if (name.equals("requester")) {
1753          this.requester = new Reference();
1754          return this.requester;
1755        }
1756        else if (name.equals("supplier")) {
1757          return addSupplier();
1758        }
1759        else if (name.equals("reasonCode")) {
1760          return addReasonCode();
1761        }
1762        else if (name.equals("reasonReference")) {
1763          return addReasonReference();
1764        }
1765        else if (name.equals("deliverFrom")) {
1766          this.deliverFrom = new Reference();
1767          return this.deliverFrom;
1768        }
1769        else if (name.equals("deliverTo")) {
1770          this.deliverTo = new Reference();
1771          return this.deliverTo;
1772        }
1773        else
1774          return super.addChild(name);
1775      }
1776
1777  public String fhirType() {
1778    return "SupplyRequest";
1779
1780  }
1781
1782      public SupplyRequest copy() {
1783        SupplyRequest dst = new SupplyRequest();
1784        copyValues(dst);
1785        return dst;
1786      }
1787
1788      public void copyValues(SupplyRequest dst) {
1789        super.copyValues(dst);
1790        if (identifier != null) {
1791          dst.identifier = new ArrayList<Identifier>();
1792          for (Identifier i : identifier)
1793            dst.identifier.add(i.copy());
1794        };
1795        dst.status = status == null ? null : status.copy();
1796        dst.category = category == null ? null : category.copy();
1797        dst.priority = priority == null ? null : priority.copy();
1798        dst.item = item == null ? null : item.copy();
1799        dst.quantity = quantity == null ? null : quantity.copy();
1800        if (parameter != null) {
1801          dst.parameter = new ArrayList<SupplyRequestParameterComponent>();
1802          for (SupplyRequestParameterComponent i : parameter)
1803            dst.parameter.add(i.copy());
1804        };
1805        dst.occurrence = occurrence == null ? null : occurrence.copy();
1806        dst.authoredOn = authoredOn == null ? null : authoredOn.copy();
1807        dst.requester = requester == null ? null : requester.copy();
1808        if (supplier != null) {
1809          dst.supplier = new ArrayList<Reference>();
1810          for (Reference i : supplier)
1811            dst.supplier.add(i.copy());
1812        };
1813        if (reasonCode != null) {
1814          dst.reasonCode = new ArrayList<CodeableConcept>();
1815          for (CodeableConcept i : reasonCode)
1816            dst.reasonCode.add(i.copy());
1817        };
1818        if (reasonReference != null) {
1819          dst.reasonReference = new ArrayList<Reference>();
1820          for (Reference i : reasonReference)
1821            dst.reasonReference.add(i.copy());
1822        };
1823        dst.deliverFrom = deliverFrom == null ? null : deliverFrom.copy();
1824        dst.deliverTo = deliverTo == null ? null : deliverTo.copy();
1825      }
1826
1827      protected SupplyRequest typedCopy() {
1828        return copy();
1829      }
1830
1831      @Override
1832      public boolean equalsDeep(Base other_) {
1833        if (!super.equalsDeep(other_))
1834          return false;
1835        if (!(other_ instanceof SupplyRequest))
1836          return false;
1837        SupplyRequest o = (SupplyRequest) other_;
1838        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(category, o.category, true)
1839           && compareDeep(priority, o.priority, true) && compareDeep(item, o.item, true) && compareDeep(quantity, o.quantity, true)
1840           && compareDeep(parameter, o.parameter, true) && compareDeep(occurrence, o.occurrence, true) && compareDeep(authoredOn, o.authoredOn, true)
1841           && compareDeep(requester, o.requester, true) && compareDeep(supplier, o.supplier, true) && compareDeep(reasonCode, o.reasonCode, true)
1842           && compareDeep(reasonReference, o.reasonReference, true) && compareDeep(deliverFrom, o.deliverFrom, true)
1843           && compareDeep(deliverTo, o.deliverTo, true);
1844      }
1845
1846      @Override
1847      public boolean equalsShallow(Base other_) {
1848        if (!super.equalsShallow(other_))
1849          return false;
1850        if (!(other_ instanceof SupplyRequest))
1851          return false;
1852        SupplyRequest o = (SupplyRequest) other_;
1853        return compareValues(status, o.status, true) && compareValues(priority, o.priority, true) && compareValues(authoredOn, o.authoredOn, true)
1854          ;
1855      }
1856
1857      public boolean isEmpty() {
1858        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, category
1859          , priority, item, quantity, parameter, occurrence, authoredOn, requester, supplier
1860          , reasonCode, reasonReference, deliverFrom, deliverTo);
1861      }
1862
1863  @Override
1864  public ResourceType getResourceType() {
1865    return ResourceType.SupplyRequest;
1866   }
1867
1868 /**
1869   * Search parameter: <b>requester</b>
1870   * <p>
1871   * Description: <b>Individual making the request</b><br>
1872   * Type: <b>reference</b><br>
1873   * Path: <b>SupplyRequest.requester</b><br>
1874   * </p>
1875   */
1876  @SearchParamDefinition(name="requester", path="SupplyRequest.requester", description="Individual making the request", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Device"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner"), @ca.uhn.fhir.model.api.annotation.Compartment(name="RelatedPerson") }, target={Device.class, Organization.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class } )
1877  public static final String SP_REQUESTER = "requester";
1878 /**
1879   * <b>Fluent Client</b> search parameter constant for <b>requester</b>
1880   * <p>
1881   * Description: <b>Individual making the request</b><br>
1882   * Type: <b>reference</b><br>
1883   * Path: <b>SupplyRequest.requester</b><br>
1884   * </p>
1885   */
1886  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam REQUESTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_REQUESTER);
1887
1888/**
1889   * Constant for fluent queries to be used to add include statements. Specifies
1890   * the path value of "<b>SupplyRequest:requester</b>".
1891   */
1892  public static final ca.uhn.fhir.model.api.Include INCLUDE_REQUESTER = new ca.uhn.fhir.model.api.Include("SupplyRequest:requester").toLocked();
1893
1894 /**
1895   * Search parameter: <b>date</b>
1896   * <p>
1897   * Description: <b>When the request was made</b><br>
1898   * Type: <b>date</b><br>
1899   * Path: <b>SupplyRequest.authoredOn</b><br>
1900   * </p>
1901   */
1902  @SearchParamDefinition(name="date", path="SupplyRequest.authoredOn", description="When the request was made", type="date" )
1903  public static final String SP_DATE = "date";
1904 /**
1905   * <b>Fluent Client</b> search parameter constant for <b>date</b>
1906   * <p>
1907   * Description: <b>When the request was made</b><br>
1908   * Type: <b>date</b><br>
1909   * Path: <b>SupplyRequest.authoredOn</b><br>
1910   * </p>
1911   */
1912  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
1913
1914 /**
1915   * Search parameter: <b>identifier</b>
1916   * <p>
1917   * Description: <b>Business Identifier for SupplyRequest</b><br>
1918   * Type: <b>token</b><br>
1919   * Path: <b>SupplyRequest.identifier</b><br>
1920   * </p>
1921   */
1922  @SearchParamDefinition(name="identifier", path="SupplyRequest.identifier", description="Business Identifier for SupplyRequest", type="token" )
1923  public static final String SP_IDENTIFIER = "identifier";
1924 /**
1925   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1926   * <p>
1927   * Description: <b>Business Identifier for SupplyRequest</b><br>
1928   * Type: <b>token</b><br>
1929   * Path: <b>SupplyRequest.identifier</b><br>
1930   * </p>
1931   */
1932  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
1933
1934 /**
1935   * Search parameter: <b>subject</b>
1936   * <p>
1937   * Description: <b>The destination of the supply</b><br>
1938   * Type: <b>reference</b><br>
1939   * Path: <b>SupplyRequest.deliverTo</b><br>
1940   * </p>
1941   */
1942  @SearchParamDefinition(name="subject", path="SupplyRequest.deliverTo", description="The destination of the supply", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Location.class, Organization.class, Patient.class } )
1943  public static final String SP_SUBJECT = "subject";
1944 /**
1945   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
1946   * <p>
1947   * Description: <b>The destination of the supply</b><br>
1948   * Type: <b>reference</b><br>
1949   * Path: <b>SupplyRequest.deliverTo</b><br>
1950   * </p>
1951   */
1952  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
1953
1954/**
1955   * Constant for fluent queries to be used to add include statements. Specifies
1956   * the path value of "<b>SupplyRequest:subject</b>".
1957   */
1958  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("SupplyRequest:subject").toLocked();
1959
1960 /**
1961   * Search parameter: <b>supplier</b>
1962   * <p>
1963   * Description: <b>Who is intended to fulfill the request</b><br>
1964   * Type: <b>reference</b><br>
1965   * Path: <b>SupplyRequest.supplier</b><br>
1966   * </p>
1967   */
1968  @SearchParamDefinition(name="supplier", path="SupplyRequest.supplier", description="Who is intended to fulfill the request", type="reference", target={HealthcareService.class, Organization.class } )
1969  public static final String SP_SUPPLIER = "supplier";
1970 /**
1971   * <b>Fluent Client</b> search parameter constant for <b>supplier</b>
1972   * <p>
1973   * Description: <b>Who is intended to fulfill the request</b><br>
1974   * Type: <b>reference</b><br>
1975   * Path: <b>SupplyRequest.supplier</b><br>
1976   * </p>
1977   */
1978  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUPPLIER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUPPLIER);
1979
1980/**
1981   * Constant for fluent queries to be used to add include statements. Specifies
1982   * the path value of "<b>SupplyRequest:supplier</b>".
1983   */
1984  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUPPLIER = new ca.uhn.fhir.model.api.Include("SupplyRequest:supplier").toLocked();
1985
1986 /**
1987   * Search parameter: <b>category</b>
1988   * <p>
1989   * Description: <b>The kind of supply (central, non-stock, etc.)</b><br>
1990   * Type: <b>token</b><br>
1991   * Path: <b>SupplyRequest.category</b><br>
1992   * </p>
1993   */
1994  @SearchParamDefinition(name="category", path="SupplyRequest.category", description="The kind of supply (central, non-stock, etc.)", type="token" )
1995  public static final String SP_CATEGORY = "category";
1996 /**
1997   * <b>Fluent Client</b> search parameter constant for <b>category</b>
1998   * <p>
1999   * Description: <b>The kind of supply (central, non-stock, etc.)</b><br>
2000   * Type: <b>token</b><br>
2001   * Path: <b>SupplyRequest.category</b><br>
2002   * </p>
2003   */
2004  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CATEGORY);
2005
2006 /**
2007   * Search parameter: <b>status</b>
2008   * <p>
2009   * Description: <b>draft | active | suspended +</b><br>
2010   * Type: <b>token</b><br>
2011   * Path: <b>SupplyRequest.status</b><br>
2012   * </p>
2013   */
2014  @SearchParamDefinition(name="status", path="SupplyRequest.status", description="draft | active | suspended +", type="token" )
2015  public static final String SP_STATUS = "status";
2016 /**
2017   * <b>Fluent Client</b> search parameter constant for <b>status</b>
2018   * <p>
2019   * Description: <b>draft | active | suspended +</b><br>
2020   * Type: <b>token</b><br>
2021   * Path: <b>SupplyRequest.status</b><br>
2022   * </p>
2023   */
2024  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
2025
2026
2027}