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