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