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, Sep 13, 2018 09:04-0400 for FHIR v3.5.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 system does not know which of the status values currently applies for this request.  Note: This concept is not to be used for "other" - one of the listed statuses is presumed to apply, it's just not known which one.
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 system does not know which of the status values currently applies for this request.  Note: This concept is not to be used for \"other\" - one of the listed statuses is presumed to apply, it's just not known which one.";
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            return null;
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            return null;
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            return null;
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            return null;
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     * Unique identifier for this supply request.
621     */
622    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=1, modifier=false, summary=true)
623    @Description(shortDefinition="Unique identifier", formalDefinition="Unique identifier for this supply request." )
624    protected 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 = -1922364955L;
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} (Unique identifier for this supply request.)
774     */
775    public Identifier getIdentifier() { 
776      if (this.identifier == null)
777        if (Configuration.errorOnAutoCreate())
778          throw new Error("Attempt to auto-create SupplyRequest.identifier");
779        else if (Configuration.doAutoCreate())
780          this.identifier = new Identifier(); // cc
781      return this.identifier;
782    }
783
784    public boolean hasIdentifier() { 
785      return this.identifier != null && !this.identifier.isEmpty();
786    }
787
788    /**
789     * @param value {@link #identifier} (Unique identifier for this supply request.)
790     */
791    public SupplyRequest setIdentifier(Identifier value) { 
792      this.identifier = value;
793      return this;
794    }
795
796    /**
797     * @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
798     */
799    public Enumeration<SupplyRequestStatus> getStatusElement() { 
800      if (this.status == null)
801        if (Configuration.errorOnAutoCreate())
802          throw new Error("Attempt to auto-create SupplyRequest.status");
803        else if (Configuration.doAutoCreate())
804          this.status = new Enumeration<SupplyRequestStatus>(new SupplyRequestStatusEnumFactory()); // bb
805      return this.status;
806    }
807
808    public boolean hasStatusElement() { 
809      return this.status != null && !this.status.isEmpty();
810    }
811
812    public boolean hasStatus() { 
813      return this.status != null && !this.status.isEmpty();
814    }
815
816    /**
817     * @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
818     */
819    public SupplyRequest setStatusElement(Enumeration<SupplyRequestStatus> value) { 
820      this.status = value;
821      return this;
822    }
823
824    /**
825     * @return Status of the supply request.
826     */
827    public SupplyRequestStatus getStatus() { 
828      return this.status == null ? null : this.status.getValue();
829    }
830
831    /**
832     * @param value Status of the supply request.
833     */
834    public SupplyRequest setStatus(SupplyRequestStatus value) { 
835      if (value == null)
836        this.status = null;
837      else {
838        if (this.status == null)
839          this.status = new Enumeration<SupplyRequestStatus>(new SupplyRequestStatusEnumFactory());
840        this.status.setValue(value);
841      }
842      return this;
843    }
844
845    /**
846     * @return {@link #category} (Category of supply, e.g.  central, non-stock, etc. This is used to support work flows associated with the supply process.)
847     */
848    public CodeableConcept getCategory() { 
849      if (this.category == null)
850        if (Configuration.errorOnAutoCreate())
851          throw new Error("Attempt to auto-create SupplyRequest.category");
852        else if (Configuration.doAutoCreate())
853          this.category = new CodeableConcept(); // cc
854      return this.category;
855    }
856
857    public boolean hasCategory() { 
858      return this.category != null && !this.category.isEmpty();
859    }
860
861    /**
862     * @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.)
863     */
864    public SupplyRequest setCategory(CodeableConcept value) { 
865      this.category = value;
866      return this;
867    }
868
869    /**
870     * @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
871     */
872    public Enumeration<RequestPriority> getPriorityElement() { 
873      if (this.priority == null)
874        if (Configuration.errorOnAutoCreate())
875          throw new Error("Attempt to auto-create SupplyRequest.priority");
876        else if (Configuration.doAutoCreate())
877          this.priority = new Enumeration<RequestPriority>(new RequestPriorityEnumFactory()); // bb
878      return this.priority;
879    }
880
881    public boolean hasPriorityElement() { 
882      return this.priority != null && !this.priority.isEmpty();
883    }
884
885    public boolean hasPriority() { 
886      return this.priority != null && !this.priority.isEmpty();
887    }
888
889    /**
890     * @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
891     */
892    public SupplyRequest setPriorityElement(Enumeration<RequestPriority> value) { 
893      this.priority = value;
894      return this;
895    }
896
897    /**
898     * @return Indicates how quickly this SupplyRequest should be addressed with respect to other requests.
899     */
900    public RequestPriority getPriority() { 
901      return this.priority == null ? null : this.priority.getValue();
902    }
903
904    /**
905     * @param value Indicates how quickly this SupplyRequest should be addressed with respect to other requests.
906     */
907    public SupplyRequest setPriority(RequestPriority value) { 
908      if (value == null)
909        this.priority = null;
910      else {
911        if (this.priority == null)
912          this.priority = new Enumeration<RequestPriority>(new RequestPriorityEnumFactory());
913        this.priority.setValue(value);
914      }
915      return this;
916    }
917
918    /**
919     * @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.)
920     */
921    public Type getItem() { 
922      return this.item;
923    }
924
925    /**
926     * @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.)
927     */
928    public CodeableConcept getItemCodeableConcept() throws FHIRException { 
929      if (this.item == null)
930        return null;
931      if (!(this.item instanceof CodeableConcept))
932        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.item.getClass().getName()+" was encountered");
933      return (CodeableConcept) this.item;
934    }
935
936    public boolean hasItemCodeableConcept() { 
937      return this != null && this.item instanceof CodeableConcept;
938    }
939
940    /**
941     * @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.)
942     */
943    public Reference getItemReference() throws FHIRException { 
944      if (this.item == null)
945        return null;
946      if (!(this.item instanceof Reference))
947        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.item.getClass().getName()+" was encountered");
948      return (Reference) this.item;
949    }
950
951    public boolean hasItemReference() { 
952      return this != null && this.item instanceof Reference;
953    }
954
955    public boolean hasItem() { 
956      return this.item != null && !this.item.isEmpty();
957    }
958
959    /**
960     * @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.)
961     */
962    public SupplyRequest setItem(Type value) { 
963      if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
964        throw new Error("Not the right type for SupplyRequest.item[x]: "+value.fhirType());
965      this.item = value;
966      return this;
967    }
968
969    /**
970     * @return {@link #quantity} (The amount that is being ordered of the indicated item.)
971     */
972    public Quantity getQuantity() { 
973      if (this.quantity == null)
974        if (Configuration.errorOnAutoCreate())
975          throw new Error("Attempt to auto-create SupplyRequest.quantity");
976        else if (Configuration.doAutoCreate())
977          this.quantity = new Quantity(); // cc
978      return this.quantity;
979    }
980
981    public boolean hasQuantity() { 
982      return this.quantity != null && !this.quantity.isEmpty();
983    }
984
985    /**
986     * @param value {@link #quantity} (The amount that is being ordered of the indicated item.)
987     */
988    public SupplyRequest setQuantity(Quantity value) { 
989      this.quantity = value;
990      return this;
991    }
992
993    /**
994     * @return {@link #parameter} (Specific parameters for the ordered item.  For example, the size of the indicated item.)
995     */
996    public List<SupplyRequestParameterComponent> getParameter() { 
997      if (this.parameter == null)
998        this.parameter = new ArrayList<SupplyRequestParameterComponent>();
999      return this.parameter;
1000    }
1001
1002    /**
1003     * @return Returns a reference to <code>this</code> for easy method chaining
1004     */
1005    public SupplyRequest setParameter(List<SupplyRequestParameterComponent> theParameter) { 
1006      this.parameter = theParameter;
1007      return this;
1008    }
1009
1010    public boolean hasParameter() { 
1011      if (this.parameter == null)
1012        return false;
1013      for (SupplyRequestParameterComponent item : this.parameter)
1014        if (!item.isEmpty())
1015          return true;
1016      return false;
1017    }
1018
1019    public SupplyRequestParameterComponent addParameter() { //3
1020      SupplyRequestParameterComponent t = new SupplyRequestParameterComponent();
1021      if (this.parameter == null)
1022        this.parameter = new ArrayList<SupplyRequestParameterComponent>();
1023      this.parameter.add(t);
1024      return t;
1025    }
1026
1027    public SupplyRequest addParameter(SupplyRequestParameterComponent t) { //3
1028      if (t == null)
1029        return this;
1030      if (this.parameter == null)
1031        this.parameter = new ArrayList<SupplyRequestParameterComponent>();
1032      this.parameter.add(t);
1033      return this;
1034    }
1035
1036    /**
1037     * @return The first repetition of repeating field {@link #parameter}, creating it if it does not already exist
1038     */
1039    public SupplyRequestParameterComponent getParameterFirstRep() { 
1040      if (getParameter().isEmpty()) {
1041        addParameter();
1042      }
1043      return getParameter().get(0);
1044    }
1045
1046    /**
1047     * @return {@link #occurrence} (When the request should be fulfilled.)
1048     */
1049    public Type getOccurrence() { 
1050      return this.occurrence;
1051    }
1052
1053    /**
1054     * @return {@link #occurrence} (When the request should be fulfilled.)
1055     */
1056    public DateTimeType getOccurrenceDateTimeType() throws FHIRException { 
1057      if (this.occurrence == null)
1058        return null;
1059      if (!(this.occurrence instanceof DateTimeType))
1060        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.occurrence.getClass().getName()+" was encountered");
1061      return (DateTimeType) this.occurrence;
1062    }
1063
1064    public boolean hasOccurrenceDateTimeType() { 
1065      return this != null && this.occurrence instanceof DateTimeType;
1066    }
1067
1068    /**
1069     * @return {@link #occurrence} (When the request should be fulfilled.)
1070     */
1071    public Period getOccurrencePeriod() throws FHIRException { 
1072      if (this.occurrence == null)
1073        return null;
1074      if (!(this.occurrence instanceof Period))
1075        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.occurrence.getClass().getName()+" was encountered");
1076      return (Period) this.occurrence;
1077    }
1078
1079    public boolean hasOccurrencePeriod() { 
1080      return this != null && this.occurrence instanceof Period;
1081    }
1082
1083    /**
1084     * @return {@link #occurrence} (When the request should be fulfilled.)
1085     */
1086    public Timing getOccurrenceTiming() throws FHIRException { 
1087      if (this.occurrence == null)
1088        return null;
1089      if (!(this.occurrence instanceof Timing))
1090        throw new FHIRException("Type mismatch: the type Timing was expected, but "+this.occurrence.getClass().getName()+" was encountered");
1091      return (Timing) this.occurrence;
1092    }
1093
1094    public boolean hasOccurrenceTiming() { 
1095      return this != null && this.occurrence instanceof Timing;
1096    }
1097
1098    public boolean hasOccurrence() { 
1099      return this.occurrence != null && !this.occurrence.isEmpty();
1100    }
1101
1102    /**
1103     * @param value {@link #occurrence} (When the request should be fulfilled.)
1104     */
1105    public SupplyRequest setOccurrence(Type value) { 
1106      if (value != null && !(value instanceof DateTimeType || value instanceof Period || value instanceof Timing))
1107        throw new Error("Not the right type for SupplyRequest.occurrence[x]: "+value.fhirType());
1108      this.occurrence = value;
1109      return this;
1110    }
1111
1112    /**
1113     * @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
1114     */
1115    public DateTimeType getAuthoredOnElement() { 
1116      if (this.authoredOn == null)
1117        if (Configuration.errorOnAutoCreate())
1118          throw new Error("Attempt to auto-create SupplyRequest.authoredOn");
1119        else if (Configuration.doAutoCreate())
1120          this.authoredOn = new DateTimeType(); // bb
1121      return this.authoredOn;
1122    }
1123
1124    public boolean hasAuthoredOnElement() { 
1125      return this.authoredOn != null && !this.authoredOn.isEmpty();
1126    }
1127
1128    public boolean hasAuthoredOn() { 
1129      return this.authoredOn != null && !this.authoredOn.isEmpty();
1130    }
1131
1132    /**
1133     * @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
1134     */
1135    public SupplyRequest setAuthoredOnElement(DateTimeType value) { 
1136      this.authoredOn = value;
1137      return this;
1138    }
1139
1140    /**
1141     * @return When the request was made.
1142     */
1143    public Date getAuthoredOn() { 
1144      return this.authoredOn == null ? null : this.authoredOn.getValue();
1145    }
1146
1147    /**
1148     * @param value When the request was made.
1149     */
1150    public SupplyRequest setAuthoredOn(Date value) { 
1151      if (value == null)
1152        this.authoredOn = null;
1153      else {
1154        if (this.authoredOn == null)
1155          this.authoredOn = new DateTimeType();
1156        this.authoredOn.setValue(value);
1157      }
1158      return this;
1159    }
1160
1161    /**
1162     * @return {@link #requester} (The device, practitioner, etc. who initiated the request.)
1163     */
1164    public Reference getRequester() { 
1165      if (this.requester == null)
1166        if (Configuration.errorOnAutoCreate())
1167          throw new Error("Attempt to auto-create SupplyRequest.requester");
1168        else if (Configuration.doAutoCreate())
1169          this.requester = new Reference(); // cc
1170      return this.requester;
1171    }
1172
1173    public boolean hasRequester() { 
1174      return this.requester != null && !this.requester.isEmpty();
1175    }
1176
1177    /**
1178     * @param value {@link #requester} (The device, practitioner, etc. who initiated the request.)
1179     */
1180    public SupplyRequest setRequester(Reference value) { 
1181      this.requester = value;
1182      return this;
1183    }
1184
1185    /**
1186     * @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.)
1187     */
1188    public Resource getRequesterTarget() { 
1189      return this.requesterTarget;
1190    }
1191
1192    /**
1193     * @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.)
1194     */
1195    public SupplyRequest setRequesterTarget(Resource value) { 
1196      this.requesterTarget = value;
1197      return this;
1198    }
1199
1200    /**
1201     * @return {@link #supplier} (Who is intended to fulfill the request.)
1202     */
1203    public List<Reference> getSupplier() { 
1204      if (this.supplier == null)
1205        this.supplier = new ArrayList<Reference>();
1206      return this.supplier;
1207    }
1208
1209    /**
1210     * @return Returns a reference to <code>this</code> for easy method chaining
1211     */
1212    public SupplyRequest setSupplier(List<Reference> theSupplier) { 
1213      this.supplier = theSupplier;
1214      return this;
1215    }
1216
1217    public boolean hasSupplier() { 
1218      if (this.supplier == null)
1219        return false;
1220      for (Reference item : this.supplier)
1221        if (!item.isEmpty())
1222          return true;
1223      return false;
1224    }
1225
1226    public Reference addSupplier() { //3
1227      Reference t = new Reference();
1228      if (this.supplier == null)
1229        this.supplier = new ArrayList<Reference>();
1230      this.supplier.add(t);
1231      return t;
1232    }
1233
1234    public SupplyRequest addSupplier(Reference t) { //3
1235      if (t == null)
1236        return this;
1237      if (this.supplier == null)
1238        this.supplier = new ArrayList<Reference>();
1239      this.supplier.add(t);
1240      return this;
1241    }
1242
1243    /**
1244     * @return The first repetition of repeating field {@link #supplier}, creating it if it does not already exist
1245     */
1246    public Reference getSupplierFirstRep() { 
1247      if (getSupplier().isEmpty()) {
1248        addSupplier();
1249      }
1250      return getSupplier().get(0);
1251    }
1252
1253    /**
1254     * @deprecated Use Reference#setResource(IBaseResource) instead
1255     */
1256    @Deprecated
1257    public List<Resource> getSupplierTarget() { 
1258      if (this.supplierTarget == null)
1259        this.supplierTarget = new ArrayList<Resource>();
1260      return this.supplierTarget;
1261    }
1262
1263    /**
1264     * @return {@link #reasonCode} (The reason why the supply item was requested.)
1265     */
1266    public List<CodeableConcept> getReasonCode() { 
1267      if (this.reasonCode == null)
1268        this.reasonCode = new ArrayList<CodeableConcept>();
1269      return this.reasonCode;
1270    }
1271
1272    /**
1273     * @return Returns a reference to <code>this</code> for easy method chaining
1274     */
1275    public SupplyRequest setReasonCode(List<CodeableConcept> theReasonCode) { 
1276      this.reasonCode = theReasonCode;
1277      return this;
1278    }
1279
1280    public boolean hasReasonCode() { 
1281      if (this.reasonCode == null)
1282        return false;
1283      for (CodeableConcept item : this.reasonCode)
1284        if (!item.isEmpty())
1285          return true;
1286      return false;
1287    }
1288
1289    public CodeableConcept addReasonCode() { //3
1290      CodeableConcept t = new CodeableConcept();
1291      if (this.reasonCode == null)
1292        this.reasonCode = new ArrayList<CodeableConcept>();
1293      this.reasonCode.add(t);
1294      return t;
1295    }
1296
1297    public SupplyRequest addReasonCode(CodeableConcept t) { //3
1298      if (t == null)
1299        return this;
1300      if (this.reasonCode == null)
1301        this.reasonCode = new ArrayList<CodeableConcept>();
1302      this.reasonCode.add(t);
1303      return this;
1304    }
1305
1306    /**
1307     * @return The first repetition of repeating field {@link #reasonCode}, creating it if it does not already exist
1308     */
1309    public CodeableConcept getReasonCodeFirstRep() { 
1310      if (getReasonCode().isEmpty()) {
1311        addReasonCode();
1312      }
1313      return getReasonCode().get(0);
1314    }
1315
1316    /**
1317     * @return {@link #reasonReference} (The reason why the supply item was requested.)
1318     */
1319    public List<Reference> getReasonReference() { 
1320      if (this.reasonReference == null)
1321        this.reasonReference = new ArrayList<Reference>();
1322      return this.reasonReference;
1323    }
1324
1325    /**
1326     * @return Returns a reference to <code>this</code> for easy method chaining
1327     */
1328    public SupplyRequest setReasonReference(List<Reference> theReasonReference) { 
1329      this.reasonReference = theReasonReference;
1330      return this;
1331    }
1332
1333    public boolean hasReasonReference() { 
1334      if (this.reasonReference == null)
1335        return false;
1336      for (Reference item : this.reasonReference)
1337        if (!item.isEmpty())
1338          return true;
1339      return false;
1340    }
1341
1342    public Reference addReasonReference() { //3
1343      Reference t = new Reference();
1344      if (this.reasonReference == null)
1345        this.reasonReference = new ArrayList<Reference>();
1346      this.reasonReference.add(t);
1347      return t;
1348    }
1349
1350    public SupplyRequest addReasonReference(Reference t) { //3
1351      if (t == null)
1352        return this;
1353      if (this.reasonReference == null)
1354        this.reasonReference = new ArrayList<Reference>();
1355      this.reasonReference.add(t);
1356      return this;
1357    }
1358
1359    /**
1360     * @return The first repetition of repeating field {@link #reasonReference}, creating it if it does not already exist
1361     */
1362    public Reference getReasonReferenceFirstRep() { 
1363      if (getReasonReference().isEmpty()) {
1364        addReasonReference();
1365      }
1366      return getReasonReference().get(0);
1367    }
1368
1369    /**
1370     * @deprecated Use Reference#setResource(IBaseResource) instead
1371     */
1372    @Deprecated
1373    public List<Resource> getReasonReferenceTarget() { 
1374      if (this.reasonReferenceTarget == null)
1375        this.reasonReferenceTarget = new ArrayList<Resource>();
1376      return this.reasonReferenceTarget;
1377    }
1378
1379    /**
1380     * @return {@link #deliverFrom} (Where the supply is expected to come from.)
1381     */
1382    public Reference getDeliverFrom() { 
1383      if (this.deliverFrom == null)
1384        if (Configuration.errorOnAutoCreate())
1385          throw new Error("Attempt to auto-create SupplyRequest.deliverFrom");
1386        else if (Configuration.doAutoCreate())
1387          this.deliverFrom = new Reference(); // cc
1388      return this.deliverFrom;
1389    }
1390
1391    public boolean hasDeliverFrom() { 
1392      return this.deliverFrom != null && !this.deliverFrom.isEmpty();
1393    }
1394
1395    /**
1396     * @param value {@link #deliverFrom} (Where the supply is expected to come from.)
1397     */
1398    public SupplyRequest setDeliverFrom(Reference value) { 
1399      this.deliverFrom = value;
1400      return this;
1401    }
1402
1403    /**
1404     * @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.)
1405     */
1406    public Resource getDeliverFromTarget() { 
1407      return this.deliverFromTarget;
1408    }
1409
1410    /**
1411     * @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.)
1412     */
1413    public SupplyRequest setDeliverFromTarget(Resource value) { 
1414      this.deliverFromTarget = value;
1415      return this;
1416    }
1417
1418    /**
1419     * @return {@link #deliverTo} (Where the supply is destined to go.)
1420     */
1421    public Reference getDeliverTo() { 
1422      if (this.deliverTo == null)
1423        if (Configuration.errorOnAutoCreate())
1424          throw new Error("Attempt to auto-create SupplyRequest.deliverTo");
1425        else if (Configuration.doAutoCreate())
1426          this.deliverTo = new Reference(); // cc
1427      return this.deliverTo;
1428    }
1429
1430    public boolean hasDeliverTo() { 
1431      return this.deliverTo != null && !this.deliverTo.isEmpty();
1432    }
1433
1434    /**
1435     * @param value {@link #deliverTo} (Where the supply is destined to go.)
1436     */
1437    public SupplyRequest setDeliverTo(Reference value) { 
1438      this.deliverTo = value;
1439      return this;
1440    }
1441
1442    /**
1443     * @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.)
1444     */
1445    public Resource getDeliverToTarget() { 
1446      return this.deliverToTarget;
1447    }
1448
1449    /**
1450     * @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.)
1451     */
1452    public SupplyRequest setDeliverToTarget(Resource value) { 
1453      this.deliverToTarget = value;
1454      return this;
1455    }
1456
1457      protected void listChildren(List<Property> children) {
1458        super.listChildren(children);
1459        children.add(new Property("identifier", "Identifier", "Unique identifier for this supply request.", 0, 1, identifier));
1460        children.add(new Property("status", "code", "Status of the supply request.", 0, 1, status));
1461        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));
1462        children.add(new Property("priority", "code", "Indicates how quickly this SupplyRequest should be addressed with respect to other requests.", 0, 1, priority));
1463        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));
1464        children.add(new Property("quantity", "Quantity", "The amount that is being ordered of the indicated item.", 0, 1, quantity));
1465        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));
1466        children.add(new Property("occurrence[x]", "dateTime|Period|Timing", "When the request should be fulfilled.", 0, 1, occurrence));
1467        children.add(new Property("authoredOn", "dateTime", "When the request was made.", 0, 1, authoredOn));
1468        children.add(new Property("requester", "Reference(Practitioner|PractitionerRole|Organization|Patient|RelatedPerson|Device)", "The device, practitioner, etc. who initiated the request.", 0, 1, requester));
1469        children.add(new Property("supplier", "Reference(Organization|HealthcareService)", "Who is intended to fulfill the request.", 0, java.lang.Integer.MAX_VALUE, supplier));
1470        children.add(new Property("reasonCode", "CodeableConcept", "The reason why the supply item was requested.", 0, java.lang.Integer.MAX_VALUE, reasonCode));
1471        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));
1472        children.add(new Property("deliverFrom", "Reference(Organization|Location)", "Where the supply is expected to come from.", 0, 1, deliverFrom));
1473        children.add(new Property("deliverTo", "Reference(Organization|Location|Patient)", "Where the supply is destined to go.", 0, 1, deliverTo));
1474      }
1475
1476      @Override
1477      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1478        switch (_hash) {
1479        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Unique identifier for this supply request.", 0, 1, identifier);
1480        case -892481550: /*status*/  return new Property("status", "code", "Status of the supply request.", 0, 1, status);
1481        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);
1482        case -1165461084: /*priority*/  return new Property("priority", "code", "Indicates how quickly this SupplyRequest should be addressed with respect to other requests.", 0, 1, priority);
1483        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);
1484        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);
1485        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);
1486        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);
1487        case -1285004149: /*quantity*/  return new Property("quantity", "Quantity", "The amount that is being ordered of the indicated item.", 0, 1, quantity);
1488        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);
1489        case -2022646513: /*occurrence[x]*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "When the request should be fulfilled.", 0, 1, occurrence);
1490        case 1687874001: /*occurrence*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "When the request should be fulfilled.", 0, 1, occurrence);
1491        case -298443636: /*occurrenceDateTime*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "When the request should be fulfilled.", 0, 1, occurrence);
1492        case 1397156594: /*occurrencePeriod*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "When the request should be fulfilled.", 0, 1, occurrence);
1493        case 1515218299: /*occurrenceTiming*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "When the request should be fulfilled.", 0, 1, occurrence);
1494        case -1500852503: /*authoredOn*/  return new Property("authoredOn", "dateTime", "When the request was made.", 0, 1, authoredOn);
1495        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);
1496        case -1663305268: /*supplier*/  return new Property("supplier", "Reference(Organization|HealthcareService)", "Who is intended to fulfill the request.", 0, java.lang.Integer.MAX_VALUE, supplier);
1497        case 722137681: /*reasonCode*/  return new Property("reasonCode", "CodeableConcept", "The reason why the supply item was requested.", 0, java.lang.Integer.MAX_VALUE, reasonCode);
1498        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);
1499        case -949323153: /*deliverFrom*/  return new Property("deliverFrom", "Reference(Organization|Location)", "Where the supply is expected to come from.", 0, 1, deliverFrom);
1500        case -242327936: /*deliverTo*/  return new Property("deliverTo", "Reference(Organization|Location|Patient)", "Where the supply is destined to go.", 0, 1, deliverTo);
1501        default: return super.getNamedProperty(_hash, _name, _checkValid);
1502        }
1503
1504      }
1505
1506      @Override
1507      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1508        switch (hash) {
1509        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
1510        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<SupplyRequestStatus>
1511        case 50511102: /*category*/ return this.category == null ? new Base[0] : new Base[] {this.category}; // CodeableConcept
1512        case -1165461084: /*priority*/ return this.priority == null ? new Base[0] : new Base[] {this.priority}; // Enumeration<RequestPriority>
1513        case 3242771: /*item*/ return this.item == null ? new Base[0] : new Base[] {this.item}; // Type
1514        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // Quantity
1515        case 1954460585: /*parameter*/ return this.parameter == null ? new Base[0] : this.parameter.toArray(new Base[this.parameter.size()]); // SupplyRequestParameterComponent
1516        case 1687874001: /*occurrence*/ return this.occurrence == null ? new Base[0] : new Base[] {this.occurrence}; // Type
1517        case -1500852503: /*authoredOn*/ return this.authoredOn == null ? new Base[0] : new Base[] {this.authoredOn}; // DateTimeType
1518        case 693933948: /*requester*/ return this.requester == null ? new Base[0] : new Base[] {this.requester}; // Reference
1519        case -1663305268: /*supplier*/ return this.supplier == null ? new Base[0] : this.supplier.toArray(new Base[this.supplier.size()]); // Reference
1520        case 722137681: /*reasonCode*/ return this.reasonCode == null ? new Base[0] : this.reasonCode.toArray(new Base[this.reasonCode.size()]); // CodeableConcept
1521        case -1146218137: /*reasonReference*/ return this.reasonReference == null ? new Base[0] : this.reasonReference.toArray(new Base[this.reasonReference.size()]); // Reference
1522        case -949323153: /*deliverFrom*/ return this.deliverFrom == null ? new Base[0] : new Base[] {this.deliverFrom}; // Reference
1523        case -242327936: /*deliverTo*/ return this.deliverTo == null ? new Base[0] : new Base[] {this.deliverTo}; // Reference
1524        default: return super.getProperty(hash, name, checkValid);
1525        }
1526
1527      }
1528
1529      @Override
1530      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1531        switch (hash) {
1532        case -1618432855: // identifier
1533          this.identifier = castToIdentifier(value); // Identifier
1534          return value;
1535        case -892481550: // status
1536          value = new SupplyRequestStatusEnumFactory().fromType(castToCode(value));
1537          this.status = (Enumeration) value; // Enumeration<SupplyRequestStatus>
1538          return value;
1539        case 50511102: // category
1540          this.category = castToCodeableConcept(value); // CodeableConcept
1541          return value;
1542        case -1165461084: // priority
1543          value = new RequestPriorityEnumFactory().fromType(castToCode(value));
1544          this.priority = (Enumeration) value; // Enumeration<RequestPriority>
1545          return value;
1546        case 3242771: // item
1547          this.item = castToType(value); // Type
1548          return value;
1549        case -1285004149: // quantity
1550          this.quantity = castToQuantity(value); // Quantity
1551          return value;
1552        case 1954460585: // parameter
1553          this.getParameter().add((SupplyRequestParameterComponent) value); // SupplyRequestParameterComponent
1554          return value;
1555        case 1687874001: // occurrence
1556          this.occurrence = castToType(value); // Type
1557          return value;
1558        case -1500852503: // authoredOn
1559          this.authoredOn = castToDateTime(value); // DateTimeType
1560          return value;
1561        case 693933948: // requester
1562          this.requester = castToReference(value); // Reference
1563          return value;
1564        case -1663305268: // supplier
1565          this.getSupplier().add(castToReference(value)); // Reference
1566          return value;
1567        case 722137681: // reasonCode
1568          this.getReasonCode().add(castToCodeableConcept(value)); // CodeableConcept
1569          return value;
1570        case -1146218137: // reasonReference
1571          this.getReasonReference().add(castToReference(value)); // Reference
1572          return value;
1573        case -949323153: // deliverFrom
1574          this.deliverFrom = castToReference(value); // Reference
1575          return value;
1576        case -242327936: // deliverTo
1577          this.deliverTo = castToReference(value); // Reference
1578          return value;
1579        default: return super.setProperty(hash, name, value);
1580        }
1581
1582      }
1583
1584      @Override
1585      public Base setProperty(String name, Base value) throws FHIRException {
1586        if (name.equals("identifier")) {
1587          this.identifier = castToIdentifier(value); // Identifier
1588        } else if (name.equals("status")) {
1589          value = new SupplyRequestStatusEnumFactory().fromType(castToCode(value));
1590          this.status = (Enumeration) value; // Enumeration<SupplyRequestStatus>
1591        } else if (name.equals("category")) {
1592          this.category = castToCodeableConcept(value); // CodeableConcept
1593        } else if (name.equals("priority")) {
1594          value = new RequestPriorityEnumFactory().fromType(castToCode(value));
1595          this.priority = (Enumeration) value; // Enumeration<RequestPriority>
1596        } else if (name.equals("item[x]")) {
1597          this.item = castToType(value); // Type
1598        } else if (name.equals("quantity")) {
1599          this.quantity = castToQuantity(value); // Quantity
1600        } else if (name.equals("parameter")) {
1601          this.getParameter().add((SupplyRequestParameterComponent) value);
1602        } else if (name.equals("occurrence[x]")) {
1603          this.occurrence = castToType(value); // Type
1604        } else if (name.equals("authoredOn")) {
1605          this.authoredOn = castToDateTime(value); // DateTimeType
1606        } else if (name.equals("requester")) {
1607          this.requester = castToReference(value); // Reference
1608        } else if (name.equals("supplier")) {
1609          this.getSupplier().add(castToReference(value));
1610        } else if (name.equals("reasonCode")) {
1611          this.getReasonCode().add(castToCodeableConcept(value));
1612        } else if (name.equals("reasonReference")) {
1613          this.getReasonReference().add(castToReference(value));
1614        } else if (name.equals("deliverFrom")) {
1615          this.deliverFrom = castToReference(value); // Reference
1616        } else if (name.equals("deliverTo")) {
1617          this.deliverTo = castToReference(value); // Reference
1618        } else
1619          return super.setProperty(name, value);
1620        return value;
1621      }
1622
1623      @Override
1624      public Base makeProperty(int hash, String name) throws FHIRException {
1625        switch (hash) {
1626        case -1618432855:  return getIdentifier(); 
1627        case -892481550:  return getStatusElement();
1628        case 50511102:  return getCategory(); 
1629        case -1165461084:  return getPriorityElement();
1630        case 2116201613:  return getItem(); 
1631        case 3242771:  return getItem(); 
1632        case -1285004149:  return getQuantity(); 
1633        case 1954460585:  return addParameter(); 
1634        case -2022646513:  return getOccurrence(); 
1635        case 1687874001:  return getOccurrence(); 
1636        case -1500852503:  return getAuthoredOnElement();
1637        case 693933948:  return getRequester(); 
1638        case -1663305268:  return addSupplier(); 
1639        case 722137681:  return addReasonCode(); 
1640        case -1146218137:  return addReasonReference(); 
1641        case -949323153:  return getDeliverFrom(); 
1642        case -242327936:  return getDeliverTo(); 
1643        default: return super.makeProperty(hash, name);
1644        }
1645
1646      }
1647
1648      @Override
1649      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1650        switch (hash) {
1651        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1652        case -892481550: /*status*/ return new String[] {"code"};
1653        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
1654        case -1165461084: /*priority*/ return new String[] {"code"};
1655        case 3242771: /*item*/ return new String[] {"CodeableConcept", "Reference"};
1656        case -1285004149: /*quantity*/ return new String[] {"Quantity"};
1657        case 1954460585: /*parameter*/ return new String[] {};
1658        case 1687874001: /*occurrence*/ return new String[] {"dateTime", "Period", "Timing"};
1659        case -1500852503: /*authoredOn*/ return new String[] {"dateTime"};
1660        case 693933948: /*requester*/ return new String[] {"Reference"};
1661        case -1663305268: /*supplier*/ return new String[] {"Reference"};
1662        case 722137681: /*reasonCode*/ return new String[] {"CodeableConcept"};
1663        case -1146218137: /*reasonReference*/ return new String[] {"Reference"};
1664        case -949323153: /*deliverFrom*/ return new String[] {"Reference"};
1665        case -242327936: /*deliverTo*/ return new String[] {"Reference"};
1666        default: return super.getTypesForProperty(hash, name);
1667        }
1668
1669      }
1670
1671      @Override
1672      public Base addChild(String name) throws FHIRException {
1673        if (name.equals("identifier")) {
1674          this.identifier = new Identifier();
1675          return this.identifier;
1676        }
1677        else if (name.equals("status")) {
1678          throw new FHIRException("Cannot call addChild on a primitive type SupplyRequest.status");
1679        }
1680        else if (name.equals("category")) {
1681          this.category = new CodeableConcept();
1682          return this.category;
1683        }
1684        else if (name.equals("priority")) {
1685          throw new FHIRException("Cannot call addChild on a primitive type SupplyRequest.priority");
1686        }
1687        else if (name.equals("itemCodeableConcept")) {
1688          this.item = new CodeableConcept();
1689          return this.item;
1690        }
1691        else if (name.equals("itemReference")) {
1692          this.item = new Reference();
1693          return this.item;
1694        }
1695        else if (name.equals("quantity")) {
1696          this.quantity = new Quantity();
1697          return this.quantity;
1698        }
1699        else if (name.equals("parameter")) {
1700          return addParameter();
1701        }
1702        else if (name.equals("occurrenceDateTime")) {
1703          this.occurrence = new DateTimeType();
1704          return this.occurrence;
1705        }
1706        else if (name.equals("occurrencePeriod")) {
1707          this.occurrence = new Period();
1708          return this.occurrence;
1709        }
1710        else if (name.equals("occurrenceTiming")) {
1711          this.occurrence = new Timing();
1712          return this.occurrence;
1713        }
1714        else if (name.equals("authoredOn")) {
1715          throw new FHIRException("Cannot call addChild on a primitive type SupplyRequest.authoredOn");
1716        }
1717        else if (name.equals("requester")) {
1718          this.requester = new Reference();
1719          return this.requester;
1720        }
1721        else if (name.equals("supplier")) {
1722          return addSupplier();
1723        }
1724        else if (name.equals("reasonCode")) {
1725          return addReasonCode();
1726        }
1727        else if (name.equals("reasonReference")) {
1728          return addReasonReference();
1729        }
1730        else if (name.equals("deliverFrom")) {
1731          this.deliverFrom = new Reference();
1732          return this.deliverFrom;
1733        }
1734        else if (name.equals("deliverTo")) {
1735          this.deliverTo = new Reference();
1736          return this.deliverTo;
1737        }
1738        else
1739          return super.addChild(name);
1740      }
1741
1742  public String fhirType() {
1743    return "SupplyRequest";
1744
1745  }
1746
1747      public SupplyRequest copy() {
1748        SupplyRequest dst = new SupplyRequest();
1749        copyValues(dst);
1750        dst.identifier = identifier == null ? null : identifier.copy();
1751        dst.status = status == null ? null : status.copy();
1752        dst.category = category == null ? null : category.copy();
1753        dst.priority = priority == null ? null : priority.copy();
1754        dst.item = item == null ? null : item.copy();
1755        dst.quantity = quantity == null ? null : quantity.copy();
1756        if (parameter != null) {
1757          dst.parameter = new ArrayList<SupplyRequestParameterComponent>();
1758          for (SupplyRequestParameterComponent i : parameter)
1759            dst.parameter.add(i.copy());
1760        };
1761        dst.occurrence = occurrence == null ? null : occurrence.copy();
1762        dst.authoredOn = authoredOn == null ? null : authoredOn.copy();
1763        dst.requester = requester == null ? null : requester.copy();
1764        if (supplier != null) {
1765          dst.supplier = new ArrayList<Reference>();
1766          for (Reference i : supplier)
1767            dst.supplier.add(i.copy());
1768        };
1769        if (reasonCode != null) {
1770          dst.reasonCode = new ArrayList<CodeableConcept>();
1771          for (CodeableConcept i : reasonCode)
1772            dst.reasonCode.add(i.copy());
1773        };
1774        if (reasonReference != null) {
1775          dst.reasonReference = new ArrayList<Reference>();
1776          for (Reference i : reasonReference)
1777            dst.reasonReference.add(i.copy());
1778        };
1779        dst.deliverFrom = deliverFrom == null ? null : deliverFrom.copy();
1780        dst.deliverTo = deliverTo == null ? null : deliverTo.copy();
1781        return dst;
1782      }
1783
1784      protected SupplyRequest typedCopy() {
1785        return copy();
1786      }
1787
1788      @Override
1789      public boolean equalsDeep(Base other_) {
1790        if (!super.equalsDeep(other_))
1791          return false;
1792        if (!(other_ instanceof SupplyRequest))
1793          return false;
1794        SupplyRequest o = (SupplyRequest) other_;
1795        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(category, o.category, true)
1796           && compareDeep(priority, o.priority, true) && compareDeep(item, o.item, true) && compareDeep(quantity, o.quantity, true)
1797           && compareDeep(parameter, o.parameter, true) && compareDeep(occurrence, o.occurrence, true) && compareDeep(authoredOn, o.authoredOn, true)
1798           && compareDeep(requester, o.requester, true) && compareDeep(supplier, o.supplier, true) && compareDeep(reasonCode, o.reasonCode, true)
1799           && compareDeep(reasonReference, o.reasonReference, true) && compareDeep(deliverFrom, o.deliverFrom, true)
1800           && compareDeep(deliverTo, o.deliverTo, true);
1801      }
1802
1803      @Override
1804      public boolean equalsShallow(Base other_) {
1805        if (!super.equalsShallow(other_))
1806          return false;
1807        if (!(other_ instanceof SupplyRequest))
1808          return false;
1809        SupplyRequest o = (SupplyRequest) other_;
1810        return compareValues(status, o.status, true) && compareValues(priority, o.priority, true) && compareValues(authoredOn, o.authoredOn, true)
1811          ;
1812      }
1813
1814      public boolean isEmpty() {
1815        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, category
1816          , priority, item, quantity, parameter, occurrence, authoredOn, requester, supplier
1817          , reasonCode, reasonReference, deliverFrom, deliverTo);
1818      }
1819
1820  @Override
1821  public ResourceType getResourceType() {
1822    return ResourceType.SupplyRequest;
1823   }
1824
1825 /**
1826   * Search parameter: <b>requester</b>
1827   * <p>
1828   * Description: <b>Individual making the request</b><br>
1829   * Type: <b>reference</b><br>
1830   * Path: <b>SupplyRequest.requester</b><br>
1831   * </p>
1832   */
1833  @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="Patient"), @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 } )
1834  public static final String SP_REQUESTER = "requester";
1835 /**
1836   * <b>Fluent Client</b> search parameter constant for <b>requester</b>
1837   * <p>
1838   * Description: <b>Individual making the request</b><br>
1839   * Type: <b>reference</b><br>
1840   * Path: <b>SupplyRequest.requester</b><br>
1841   * </p>
1842   */
1843  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam REQUESTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_REQUESTER);
1844
1845/**
1846   * Constant for fluent queries to be used to add include statements. Specifies
1847   * the path value of "<b>SupplyRequest:requester</b>".
1848   */
1849  public static final ca.uhn.fhir.model.api.Include INCLUDE_REQUESTER = new ca.uhn.fhir.model.api.Include("SupplyRequest:requester").toLocked();
1850
1851 /**
1852   * Search parameter: <b>date</b>
1853   * <p>
1854   * Description: <b>When the request was made</b><br>
1855   * Type: <b>date</b><br>
1856   * Path: <b>SupplyRequest.authoredOn</b><br>
1857   * </p>
1858   */
1859  @SearchParamDefinition(name="date", path="SupplyRequest.authoredOn", description="When the request was made", type="date" )
1860  public static final String SP_DATE = "date";
1861 /**
1862   * <b>Fluent Client</b> search parameter constant for <b>date</b>
1863   * <p>
1864   * Description: <b>When the request was made</b><br>
1865   * Type: <b>date</b><br>
1866   * Path: <b>SupplyRequest.authoredOn</b><br>
1867   * </p>
1868   */
1869  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
1870
1871 /**
1872   * Search parameter: <b>identifier</b>
1873   * <p>
1874   * Description: <b>Unique identifier</b><br>
1875   * Type: <b>token</b><br>
1876   * Path: <b>SupplyRequest.identifier</b><br>
1877   * </p>
1878   */
1879  @SearchParamDefinition(name="identifier", path="SupplyRequest.identifier", description="Unique identifier", type="token" )
1880  public static final String SP_IDENTIFIER = "identifier";
1881 /**
1882   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1883   * <p>
1884   * Description: <b>Unique identifier</b><br>
1885   * Type: <b>token</b><br>
1886   * Path: <b>SupplyRequest.identifier</b><br>
1887   * </p>
1888   */
1889  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
1890
1891 /**
1892   * Search parameter: <b>supplier</b>
1893   * <p>
1894   * Description: <b>Who is intended to fulfill the request</b><br>
1895   * Type: <b>reference</b><br>
1896   * Path: <b>SupplyRequest.supplier</b><br>
1897   * </p>
1898   */
1899  @SearchParamDefinition(name="supplier", path="SupplyRequest.supplier", description="Who is intended to fulfill the request", type="reference", target={HealthcareService.class, Organization.class } )
1900  public static final String SP_SUPPLIER = "supplier";
1901 /**
1902   * <b>Fluent Client</b> search parameter constant for <b>supplier</b>
1903   * <p>
1904   * Description: <b>Who is intended to fulfill the request</b><br>
1905   * Type: <b>reference</b><br>
1906   * Path: <b>SupplyRequest.supplier</b><br>
1907   * </p>
1908   */
1909  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUPPLIER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUPPLIER);
1910
1911/**
1912   * Constant for fluent queries to be used to add include statements. Specifies
1913   * the path value of "<b>SupplyRequest:supplier</b>".
1914   */
1915  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUPPLIER = new ca.uhn.fhir.model.api.Include("SupplyRequest:supplier").toLocked();
1916
1917 /**
1918   * Search parameter: <b>category</b>
1919   * <p>
1920   * Description: <b>The kind of supply (central, non-stock, etc.)</b><br>
1921   * Type: <b>token</b><br>
1922   * Path: <b>SupplyRequest.category</b><br>
1923   * </p>
1924   */
1925  @SearchParamDefinition(name="category", path="SupplyRequest.category", description="The kind of supply (central, non-stock, etc.)", type="token" )
1926  public static final String SP_CATEGORY = "category";
1927 /**
1928   * <b>Fluent Client</b> search parameter constant for <b>category</b>
1929   * <p>
1930   * Description: <b>The kind of supply (central, non-stock, etc.)</b><br>
1931   * Type: <b>token</b><br>
1932   * Path: <b>SupplyRequest.category</b><br>
1933   * </p>
1934   */
1935  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CATEGORY);
1936
1937 /**
1938   * Search parameter: <b>status</b>
1939   * <p>
1940   * Description: <b>draft | active | suspended +</b><br>
1941   * Type: <b>token</b><br>
1942   * Path: <b>SupplyRequest.status</b><br>
1943   * </p>
1944   */
1945  @SearchParamDefinition(name="status", path="SupplyRequest.status", description="draft | active | suspended +", type="token" )
1946  public static final String SP_STATUS = "status";
1947 /**
1948   * <b>Fluent Client</b> search parameter constant for <b>status</b>
1949   * <p>
1950   * Description: <b>draft | active | suspended +</b><br>
1951   * Type: <b>token</b><br>
1952   * Path: <b>SupplyRequest.status</b><br>
1953   * </p>
1954   */
1955  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
1956
1957
1958}
1959