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