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