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 Base makeProperty(int hash, String name) throws FHIRException {
661      switch (hash) {
662      case 3059181:
663        return getCode();
664      case -1410166417:
665        return getValue();
666      case 111972721:
667        return getValue();
668      default:
669        return super.makeProperty(hash, name);
670      }
671
672    }
673
674    @Override
675    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
676      switch (hash) {
677      case 3059181:
678        /* code */ return new String[] { "CodeableConcept" };
679      case 111972721:
680        /* value */ return new String[] { "CodeableConcept", "Quantity", "Range", "boolean" };
681      default:
682        return super.getTypesForProperty(hash, name);
683      }
684
685    }
686
687    @Override
688    public Base addChild(String name) throws FHIRException {
689      if (name.equals("code")) {
690        this.code = new CodeableConcept();
691        return this.code;
692      } else if (name.equals("valueCodeableConcept")) {
693        this.value = new CodeableConcept();
694        return this.value;
695      } else if (name.equals("valueQuantity")) {
696        this.value = new Quantity();
697        return this.value;
698      } else if (name.equals("valueRange")) {
699        this.value = new Range();
700        return this.value;
701      } else if (name.equals("valueBoolean")) {
702        this.value = new BooleanType();
703        return this.value;
704      } else
705        return super.addChild(name);
706    }
707
708    public SupplyRequestParameterComponent copy() {
709      SupplyRequestParameterComponent dst = new SupplyRequestParameterComponent();
710      copyValues(dst);
711      return dst;
712    }
713
714    public void copyValues(SupplyRequestParameterComponent dst) {
715      super.copyValues(dst);
716      dst.code = code == null ? null : code.copy();
717      dst.value = value == null ? null : value.copy();
718    }
719
720    @Override
721    public boolean equalsDeep(Base other_) {
722      if (!super.equalsDeep(other_))
723        return false;
724      if (!(other_ instanceof SupplyRequestParameterComponent))
725        return false;
726      SupplyRequestParameterComponent o = (SupplyRequestParameterComponent) other_;
727      return compareDeep(code, o.code, true) && compareDeep(value, o.value, true);
728    }
729
730    @Override
731    public boolean equalsShallow(Base other_) {
732      if (!super.equalsShallow(other_))
733        return false;
734      if (!(other_ instanceof SupplyRequestParameterComponent))
735        return false;
736      SupplyRequestParameterComponent o = (SupplyRequestParameterComponent) other_;
737      return true;
738    }
739
740    public boolean isEmpty() {
741      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(code, value);
742    }
743
744    public String fhirType() {
745      return "SupplyRequest.parameter";
746
747    }
748
749  }
750
751  /**
752   * Business identifiers assigned to this SupplyRequest by the author and/or
753   * other systems. These identifiers remain constant as the resource is updated
754   * and propagates from server to server.
755   */
756  @Child(name = "identifier", type = {
757      Identifier.class }, order = 0, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
758  @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.")
759  protected List<Identifier> identifier;
760
761  /**
762   * Status of the supply request.
763   */
764  @Child(name = "status", type = { CodeType.class }, order = 1, min = 0, max = 1, modifier = true, summary = true)
765  @Description(shortDefinition = "draft | active | suspended +", formalDefinition = "Status of the supply request.")
766  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/supplyrequest-status")
767  protected Enumeration<SupplyRequestStatus> status;
768
769  /**
770   * Category of supply, e.g. central, non-stock, etc. This is used to support
771   * work flows associated with the supply process.
772   */
773  @Child(name = "category", type = {
774      CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
775  @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.")
776  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/supplyrequest-kind")
777  protected CodeableConcept category;
778
779  /**
780   * Indicates how quickly this SupplyRequest should be addressed with respect to
781   * other requests.
782   */
783  @Child(name = "priority", type = { CodeType.class }, order = 3, min = 0, max = 1, modifier = false, summary = true)
784  @Description(shortDefinition = "routine | urgent | asap | stat", formalDefinition = "Indicates how quickly this SupplyRequest should be addressed with respect to other requests.")
785  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/request-priority")
786  protected Enumeration<RequestPriority> priority;
787
788  /**
789   * The item that is requested to be supplied. This is either a link to a
790   * resource representing the details of the item or a code that identifies the
791   * item from a known list.
792   */
793  @Child(name = "item", type = { CodeableConcept.class, Medication.class, Substance.class,
794      Device.class }, order = 4, min = 1, max = 1, modifier = false, summary = true)
795  @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.")
796  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/supply-item")
797  protected Type item;
798
799  /**
800   * The amount that is being ordered of the indicated item.
801   */
802  @Child(name = "quantity", type = { Quantity.class }, order = 5, min = 1, max = 1, modifier = false, summary = true)
803  @Description(shortDefinition = "The requested amount of the item indicated", formalDefinition = "The amount that is being ordered of the indicated item.")
804  protected Quantity quantity;
805
806  /**
807   * Specific parameters for the ordered item. For example, the size of the
808   * indicated item.
809   */
810  @Child(name = "parameter", type = {}, order = 6, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
811  @Description(shortDefinition = "Ordered item details", formalDefinition = "Specific parameters for the ordered item.  For example, the size of the indicated item.")
812  protected List<SupplyRequestParameterComponent> parameter;
813
814  /**
815   * When the request should be fulfilled.
816   */
817  @Child(name = "occurrence", type = { DateTimeType.class, Period.class,
818      Timing.class }, order = 7, min = 0, max = 1, modifier = false, summary = true)
819  @Description(shortDefinition = "When the request should be fulfilled", formalDefinition = "When the request should be fulfilled.")
820  protected Type occurrence;
821
822  /**
823   * When the request was made.
824   */
825  @Child(name = "authoredOn", type = {
826      DateTimeType.class }, order = 8, min = 0, max = 1, modifier = false, summary = true)
827  @Description(shortDefinition = "When the request was made", formalDefinition = "When the request was made.")
828  protected DateTimeType authoredOn;
829
830  /**
831   * The device, practitioner, etc. who initiated the request.
832   */
833  @Child(name = "requester", type = { Practitioner.class, PractitionerRole.class, Organization.class, Patient.class,
834      RelatedPerson.class, Device.class }, order = 9, min = 0, max = 1, modifier = false, summary = true)
835  @Description(shortDefinition = "Individual making the request", formalDefinition = "The device, practitioner, etc. who initiated the request.")
836  protected Reference requester;
837
838  /**
839   * The actual object that is the target of the reference (The device,
840   * practitioner, etc. who initiated the request.)
841   */
842  protected Resource requesterTarget;
843
844  /**
845   * Who is intended to fulfill the request.
846   */
847  @Child(name = "supplier", type = { Organization.class,
848      HealthcareService.class }, order = 10, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
849  @Description(shortDefinition = "Who is intended to fulfill the request", formalDefinition = "Who is intended to fulfill the request.")
850  protected List<Reference> supplier;
851  /**
852   * The actual objects that are the target of the reference (Who is intended to
853   * fulfill the request.)
854   */
855  protected List<Resource> supplierTarget;
856
857  /**
858   * The reason why the supply item was requested.
859   */
860  @Child(name = "reasonCode", type = {
861      CodeableConcept.class }, order = 11, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
862  @Description(shortDefinition = "The reason why the supply item was requested", formalDefinition = "The reason why the supply item was requested.")
863  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/supplyrequest-reason")
864  protected List<CodeableConcept> reasonCode;
865
866  /**
867   * The reason why the supply item was requested.
868   */
869  @Child(name = "reasonReference", type = { Condition.class, Observation.class, DiagnosticReport.class,
870      DocumentReference.class }, order = 12, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
871  @Description(shortDefinition = "The reason why the supply item was requested", formalDefinition = "The reason why the supply item was requested.")
872  protected List<Reference> reasonReference;
873  /**
874   * The actual objects that are the target of the reference (The reason why the
875   * supply item was requested.)
876   */
877  protected List<Resource> reasonReferenceTarget;
878
879  /**
880   * Where the supply is expected to come from.
881   */
882  @Child(name = "deliverFrom", type = { Organization.class,
883      Location.class }, order = 13, min = 0, max = 1, modifier = false, summary = false)
884  @Description(shortDefinition = "The origin of the supply", formalDefinition = "Where the supply is expected to come from.")
885  protected Reference deliverFrom;
886
887  /**
888   * The actual object that is the target of the reference (Where the supply is
889   * expected to come from.)
890   */
891  protected Resource deliverFromTarget;
892
893  /**
894   * Where the supply is destined to go.
895   */
896  @Child(name = "deliverTo", type = { Organization.class, Location.class,
897      Patient.class }, order = 14, min = 0, max = 1, modifier = false, summary = false)
898  @Description(shortDefinition = "The destination of the supply", formalDefinition = "Where the supply is destined to go.")
899  protected Reference deliverTo;
900
901  /**
902   * The actual object that is the target of the reference (Where the supply is
903   * destined to go.)
904   */
905  protected Resource deliverToTarget;
906
907  private static final long serialVersionUID = 1456312151L;
908
909  /**
910   * Constructor
911   */
912  public SupplyRequest() {
913    super();
914  }
915
916  /**
917   * Constructor
918   */
919  public SupplyRequest(Type item, Quantity quantity) {
920    super();
921    this.item = item;
922    this.quantity = quantity;
923  }
924
925  /**
926   * @return {@link #identifier} (Business identifiers assigned to this
927   *         SupplyRequest by the author and/or other systems. These identifiers
928   *         remain constant as the resource is updated and propagates from server
929   *         to server.)
930   */
931  public List<Identifier> getIdentifier() {
932    if (this.identifier == null)
933      this.identifier = new ArrayList<Identifier>();
934    return this.identifier;
935  }
936
937  /**
938   * @return Returns a reference to <code>this</code> for easy method chaining
939   */
940  public SupplyRequest setIdentifier(List<Identifier> theIdentifier) {
941    this.identifier = theIdentifier;
942    return this;
943  }
944
945  public boolean hasIdentifier() {
946    if (this.identifier == null)
947      return false;
948    for (Identifier item : this.identifier)
949      if (!item.isEmpty())
950        return true;
951    return false;
952  }
953
954  public Identifier addIdentifier() { // 3
955    Identifier t = new Identifier();
956    if (this.identifier == null)
957      this.identifier = new ArrayList<Identifier>();
958    this.identifier.add(t);
959    return t;
960  }
961
962  public SupplyRequest addIdentifier(Identifier t) { // 3
963    if (t == null)
964      return this;
965    if (this.identifier == null)
966      this.identifier = new ArrayList<Identifier>();
967    this.identifier.add(t);
968    return this;
969  }
970
971  /**
972   * @return The first repetition of repeating field {@link #identifier}, creating
973   *         it if it does not already exist
974   */
975  public Identifier getIdentifierFirstRep() {
976    if (getIdentifier().isEmpty()) {
977      addIdentifier();
978    }
979    return getIdentifier().get(0);
980  }
981
982  /**
983   * @return {@link #status} (Status of the supply request.). This is the
984   *         underlying object with id, value and extensions. The accessor
985   *         "getStatus" gives direct access to the value
986   */
987  public Enumeration<SupplyRequestStatus> getStatusElement() {
988    if (this.status == null)
989      if (Configuration.errorOnAutoCreate())
990        throw new Error("Attempt to auto-create SupplyRequest.status");
991      else if (Configuration.doAutoCreate())
992        this.status = new Enumeration<SupplyRequestStatus>(new SupplyRequestStatusEnumFactory()); // bb
993    return this.status;
994  }
995
996  public boolean hasStatusElement() {
997    return this.status != null && !this.status.isEmpty();
998  }
999
1000  public boolean hasStatus() {
1001    return this.status != null && !this.status.isEmpty();
1002  }
1003
1004  /**
1005   * @param value {@link #status} (Status of the supply request.). This is the
1006   *              underlying object with id, value and extensions. The accessor
1007   *              "getStatus" gives direct access to the value
1008   */
1009  public SupplyRequest setStatusElement(Enumeration<SupplyRequestStatus> value) {
1010    this.status = value;
1011    return this;
1012  }
1013
1014  /**
1015   * @return Status of the supply request.
1016   */
1017  public SupplyRequestStatus getStatus() {
1018    return this.status == null ? null : this.status.getValue();
1019  }
1020
1021  /**
1022   * @param value Status of the supply request.
1023   */
1024  public SupplyRequest setStatus(SupplyRequestStatus value) {
1025    if (value == null)
1026      this.status = null;
1027    else {
1028      if (this.status == null)
1029        this.status = new Enumeration<SupplyRequestStatus>(new SupplyRequestStatusEnumFactory());
1030      this.status.setValue(value);
1031    }
1032    return this;
1033  }
1034
1035  /**
1036   * @return {@link #category} (Category of supply, e.g. central, non-stock, etc.
1037   *         This is used to support work flows associated with the supply
1038   *         process.)
1039   */
1040  public CodeableConcept getCategory() {
1041    if (this.category == null)
1042      if (Configuration.errorOnAutoCreate())
1043        throw new Error("Attempt to auto-create SupplyRequest.category");
1044      else if (Configuration.doAutoCreate())
1045        this.category = new CodeableConcept(); // cc
1046    return this.category;
1047  }
1048
1049  public boolean hasCategory() {
1050    return this.category != null && !this.category.isEmpty();
1051  }
1052
1053  /**
1054   * @param value {@link #category} (Category of supply, e.g. central, non-stock,
1055   *              etc. This is used to support work flows associated with the
1056   *              supply process.)
1057   */
1058  public SupplyRequest setCategory(CodeableConcept value) {
1059    this.category = value;
1060    return this;
1061  }
1062
1063  /**
1064   * @return {@link #priority} (Indicates how quickly this SupplyRequest should be
1065   *         addressed with respect to other requests.). This is the underlying
1066   *         object with id, value and extensions. The accessor "getPriority"
1067   *         gives direct access to the value
1068   */
1069  public Enumeration<RequestPriority> getPriorityElement() {
1070    if (this.priority == null)
1071      if (Configuration.errorOnAutoCreate())
1072        throw new Error("Attempt to auto-create SupplyRequest.priority");
1073      else if (Configuration.doAutoCreate())
1074        this.priority = new Enumeration<RequestPriority>(new RequestPriorityEnumFactory()); // bb
1075    return this.priority;
1076  }
1077
1078  public boolean hasPriorityElement() {
1079    return this.priority != null && !this.priority.isEmpty();
1080  }
1081
1082  public boolean hasPriority() {
1083    return this.priority != null && !this.priority.isEmpty();
1084  }
1085
1086  /**
1087   * @param value {@link #priority} (Indicates how quickly this SupplyRequest
1088   *              should be addressed with respect to other requests.). This is
1089   *              the underlying object with id, value and extensions. The
1090   *              accessor "getPriority" gives direct access to the value
1091   */
1092  public SupplyRequest setPriorityElement(Enumeration<RequestPriority> value) {
1093    this.priority = value;
1094    return this;
1095  }
1096
1097  /**
1098   * @return Indicates how quickly this SupplyRequest should be addressed with
1099   *         respect to other requests.
1100   */
1101  public RequestPriority getPriority() {
1102    return this.priority == null ? null : this.priority.getValue();
1103  }
1104
1105  /**
1106   * @param value Indicates how quickly this SupplyRequest should be addressed
1107   *              with respect to other requests.
1108   */
1109  public SupplyRequest setPriority(RequestPriority value) {
1110    if (value == null)
1111      this.priority = null;
1112    else {
1113      if (this.priority == null)
1114        this.priority = new Enumeration<RequestPriority>(new RequestPriorityEnumFactory());
1115      this.priority.setValue(value);
1116    }
1117    return this;
1118  }
1119
1120  /**
1121   * @return {@link #item} (The item that is requested to be supplied. This is
1122   *         either a link to a resource representing the details of the item or a
1123   *         code that identifies the item from a known list.)
1124   */
1125  public Type getItem() {
1126    return this.item;
1127  }
1128
1129  /**
1130   * @return {@link #item} (The item that is requested to be supplied. This is
1131   *         either a link to a resource representing the details of the item or a
1132   *         code that identifies the item from a known list.)
1133   */
1134  public CodeableConcept getItemCodeableConcept() throws FHIRException {
1135    if (this.item == null)
1136      this.item = new CodeableConcept();
1137    if (!(this.item instanceof CodeableConcept))
1138      throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "
1139          + this.item.getClass().getName() + " was encountered");
1140    return (CodeableConcept) this.item;
1141  }
1142
1143  public boolean hasItemCodeableConcept() {
1144    return this != null && this.item instanceof CodeableConcept;
1145  }
1146
1147  /**
1148   * @return {@link #item} (The item that is requested to be supplied. This is
1149   *         either a link to a resource representing the details of the item or a
1150   *         code that identifies the item from a known list.)
1151   */
1152  public Reference getItemReference() throws FHIRException {
1153    if (this.item == null)
1154      this.item = new Reference();
1155    if (!(this.item instanceof Reference))
1156      throw new FHIRException(
1157          "Type mismatch: the type Reference was expected, but " + this.item.getClass().getName() + " was encountered");
1158    return (Reference) this.item;
1159  }
1160
1161  public boolean hasItemReference() {
1162    return this != null && this.item instanceof Reference;
1163  }
1164
1165  public boolean hasItem() {
1166    return this.item != null && !this.item.isEmpty();
1167  }
1168
1169  /**
1170   * @param value {@link #item} (The item that is requested to be supplied. This
1171   *              is either a link to a resource representing the details of the
1172   *              item or a code that identifies the item from a known list.)
1173   */
1174  public SupplyRequest setItem(Type value) {
1175    if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
1176      throw new Error("Not the right type for SupplyRequest.item[x]: " + value.fhirType());
1177    this.item = value;
1178    return this;
1179  }
1180
1181  /**
1182   * @return {@link #quantity} (The amount that is being ordered of the indicated
1183   *         item.)
1184   */
1185  public Quantity getQuantity() {
1186    if (this.quantity == null)
1187      if (Configuration.errorOnAutoCreate())
1188        throw new Error("Attempt to auto-create SupplyRequest.quantity");
1189      else if (Configuration.doAutoCreate())
1190        this.quantity = new Quantity(); // cc
1191    return this.quantity;
1192  }
1193
1194  public boolean hasQuantity() {
1195    return this.quantity != null && !this.quantity.isEmpty();
1196  }
1197
1198  /**
1199   * @param value {@link #quantity} (The amount that is being ordered of the
1200   *              indicated item.)
1201   */
1202  public SupplyRequest setQuantity(Quantity value) {
1203    this.quantity = value;
1204    return this;
1205  }
1206
1207  /**
1208   * @return {@link #parameter} (Specific parameters for the ordered item. For
1209   *         example, the size of the indicated item.)
1210   */
1211  public List<SupplyRequestParameterComponent> getParameter() {
1212    if (this.parameter == null)
1213      this.parameter = new ArrayList<SupplyRequestParameterComponent>();
1214    return this.parameter;
1215  }
1216
1217  /**
1218   * @return Returns a reference to <code>this</code> for easy method chaining
1219   */
1220  public SupplyRequest setParameter(List<SupplyRequestParameterComponent> theParameter) {
1221    this.parameter = theParameter;
1222    return this;
1223  }
1224
1225  public boolean hasParameter() {
1226    if (this.parameter == null)
1227      return false;
1228    for (SupplyRequestParameterComponent item : this.parameter)
1229      if (!item.isEmpty())
1230        return true;
1231    return false;
1232  }
1233
1234  public SupplyRequestParameterComponent addParameter() { // 3
1235    SupplyRequestParameterComponent t = new SupplyRequestParameterComponent();
1236    if (this.parameter == null)
1237      this.parameter = new ArrayList<SupplyRequestParameterComponent>();
1238    this.parameter.add(t);
1239    return t;
1240  }
1241
1242  public SupplyRequest addParameter(SupplyRequestParameterComponent t) { // 3
1243    if (t == null)
1244      return this;
1245    if (this.parameter == null)
1246      this.parameter = new ArrayList<SupplyRequestParameterComponent>();
1247    this.parameter.add(t);
1248    return this;
1249  }
1250
1251  /**
1252   * @return The first repetition of repeating field {@link #parameter}, creating
1253   *         it if it does not already exist
1254   */
1255  public SupplyRequestParameterComponent getParameterFirstRep() {
1256    if (getParameter().isEmpty()) {
1257      addParameter();
1258    }
1259    return getParameter().get(0);
1260  }
1261
1262  /**
1263   * @return {@link #occurrence} (When the request should be fulfilled.)
1264   */
1265  public Type getOccurrence() {
1266    return this.occurrence;
1267  }
1268
1269  /**
1270   * @return {@link #occurrence} (When the request should be fulfilled.)
1271   */
1272  public DateTimeType getOccurrenceDateTimeType() throws FHIRException {
1273    if (this.occurrence == null)
1274      this.occurrence = new DateTimeType();
1275    if (!(this.occurrence instanceof DateTimeType))
1276      throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "
1277          + this.occurrence.getClass().getName() + " was encountered");
1278    return (DateTimeType) this.occurrence;
1279  }
1280
1281  public boolean hasOccurrenceDateTimeType() {
1282    return this != null && this.occurrence instanceof DateTimeType;
1283  }
1284
1285  /**
1286   * @return {@link #occurrence} (When the request should be fulfilled.)
1287   */
1288  public Period getOccurrencePeriod() throws FHIRException {
1289    if (this.occurrence == null)
1290      this.occurrence = new Period();
1291    if (!(this.occurrence instanceof Period))
1292      throw new FHIRException("Type mismatch: the type Period was expected, but " + this.occurrence.getClass().getName()
1293          + " was encountered");
1294    return (Period) this.occurrence;
1295  }
1296
1297  public boolean hasOccurrencePeriod() {
1298    return this != null && this.occurrence instanceof Period;
1299  }
1300
1301  /**
1302   * @return {@link #occurrence} (When the request should be fulfilled.)
1303   */
1304  public Timing getOccurrenceTiming() throws FHIRException {
1305    if (this.occurrence == null)
1306      this.occurrence = new Timing();
1307    if (!(this.occurrence instanceof Timing))
1308      throw new FHIRException("Type mismatch: the type Timing was expected, but " + this.occurrence.getClass().getName()
1309          + " was encountered");
1310    return (Timing) this.occurrence;
1311  }
1312
1313  public boolean hasOccurrenceTiming() {
1314    return this != null && this.occurrence instanceof Timing;
1315  }
1316
1317  public boolean hasOccurrence() {
1318    return this.occurrence != null && !this.occurrence.isEmpty();
1319  }
1320
1321  /**
1322   * @param value {@link #occurrence} (When the request should be fulfilled.)
1323   */
1324  public SupplyRequest setOccurrence(Type value) {
1325    if (value != null && !(value instanceof DateTimeType || value instanceof Period || value instanceof Timing))
1326      throw new Error("Not the right type for SupplyRequest.occurrence[x]: " + value.fhirType());
1327    this.occurrence = value;
1328    return this;
1329  }
1330
1331  /**
1332   * @return {@link #authoredOn} (When the request was made.). This is the
1333   *         underlying object with id, value and extensions. The accessor
1334   *         "getAuthoredOn" gives direct access to the value
1335   */
1336  public DateTimeType getAuthoredOnElement() {
1337    if (this.authoredOn == null)
1338      if (Configuration.errorOnAutoCreate())
1339        throw new Error("Attempt to auto-create SupplyRequest.authoredOn");
1340      else if (Configuration.doAutoCreate())
1341        this.authoredOn = new DateTimeType(); // bb
1342    return this.authoredOn;
1343  }
1344
1345  public boolean hasAuthoredOnElement() {
1346    return this.authoredOn != null && !this.authoredOn.isEmpty();
1347  }
1348
1349  public boolean hasAuthoredOn() {
1350    return this.authoredOn != null && !this.authoredOn.isEmpty();
1351  }
1352
1353  /**
1354   * @param value {@link #authoredOn} (When the request was made.). This is the
1355   *              underlying object with id, value and extensions. The accessor
1356   *              "getAuthoredOn" gives direct access to the value
1357   */
1358  public SupplyRequest setAuthoredOnElement(DateTimeType value) {
1359    this.authoredOn = value;
1360    return this;
1361  }
1362
1363  /**
1364   * @return When the request was made.
1365   */
1366  public Date getAuthoredOn() {
1367    return this.authoredOn == null ? null : this.authoredOn.getValue();
1368  }
1369
1370  /**
1371   * @param value When the request was made.
1372   */
1373  public SupplyRequest setAuthoredOn(Date value) {
1374    if (value == null)
1375      this.authoredOn = null;
1376    else {
1377      if (this.authoredOn == null)
1378        this.authoredOn = new DateTimeType();
1379      this.authoredOn.setValue(value);
1380    }
1381    return this;
1382  }
1383
1384  /**
1385   * @return {@link #requester} (The device, practitioner, etc. who initiated the
1386   *         request.)
1387   */
1388  public Reference getRequester() {
1389    if (this.requester == null)
1390      if (Configuration.errorOnAutoCreate())
1391        throw new Error("Attempt to auto-create SupplyRequest.requester");
1392      else if (Configuration.doAutoCreate())
1393        this.requester = new Reference(); // cc
1394    return this.requester;
1395  }
1396
1397  public boolean hasRequester() {
1398    return this.requester != null && !this.requester.isEmpty();
1399  }
1400
1401  /**
1402   * @param value {@link #requester} (The device, practitioner, etc. who initiated
1403   *              the request.)
1404   */
1405  public SupplyRequest setRequester(Reference value) {
1406    this.requester = value;
1407    return this;
1408  }
1409
1410  /**
1411   * @return {@link #requester} The actual object that is the target of the
1412   *         reference. The reference library doesn't populate this, but you can
1413   *         use it to hold the resource if you resolve it. (The device,
1414   *         practitioner, etc. who initiated the request.)
1415   */
1416  public Resource getRequesterTarget() {
1417    return this.requesterTarget;
1418  }
1419
1420  /**
1421   * @param value {@link #requester} The actual object that is the target of the
1422   *              reference. The reference library doesn't use these, but you can
1423   *              use it to hold the resource if you resolve it. (The device,
1424   *              practitioner, etc. who initiated the request.)
1425   */
1426  public SupplyRequest setRequesterTarget(Resource value) {
1427    this.requesterTarget = value;
1428    return this;
1429  }
1430
1431  /**
1432   * @return {@link #supplier} (Who is intended to fulfill the request.)
1433   */
1434  public List<Reference> getSupplier() {
1435    if (this.supplier == null)
1436      this.supplier = new ArrayList<Reference>();
1437    return this.supplier;
1438  }
1439
1440  /**
1441   * @return Returns a reference to <code>this</code> for easy method chaining
1442   */
1443  public SupplyRequest setSupplier(List<Reference> theSupplier) {
1444    this.supplier = theSupplier;
1445    return this;
1446  }
1447
1448  public boolean hasSupplier() {
1449    if (this.supplier == null)
1450      return false;
1451    for (Reference item : this.supplier)
1452      if (!item.isEmpty())
1453        return true;
1454    return false;
1455  }
1456
1457  public Reference addSupplier() { // 3
1458    Reference t = new Reference();
1459    if (this.supplier == null)
1460      this.supplier = new ArrayList<Reference>();
1461    this.supplier.add(t);
1462    return t;
1463  }
1464
1465  public SupplyRequest addSupplier(Reference t) { // 3
1466    if (t == null)
1467      return this;
1468    if (this.supplier == null)
1469      this.supplier = new ArrayList<Reference>();
1470    this.supplier.add(t);
1471    return this;
1472  }
1473
1474  /**
1475   * @return The first repetition of repeating field {@link #supplier}, creating
1476   *         it if it does not already exist
1477   */
1478  public Reference getSupplierFirstRep() {
1479    if (getSupplier().isEmpty()) {
1480      addSupplier();
1481    }
1482    return getSupplier().get(0);
1483  }
1484
1485  /**
1486   * @deprecated Use Reference#setResource(IBaseResource) instead
1487   */
1488  @Deprecated
1489  public List<Resource> getSupplierTarget() {
1490    if (this.supplierTarget == null)
1491      this.supplierTarget = new ArrayList<Resource>();
1492    return this.supplierTarget;
1493  }
1494
1495  /**
1496   * @return {@link #reasonCode} (The reason why the supply item was requested.)
1497   */
1498  public List<CodeableConcept> getReasonCode() {
1499    if (this.reasonCode == null)
1500      this.reasonCode = new ArrayList<CodeableConcept>();
1501    return this.reasonCode;
1502  }
1503
1504  /**
1505   * @return Returns a reference to <code>this</code> for easy method chaining
1506   */
1507  public SupplyRequest setReasonCode(List<CodeableConcept> theReasonCode) {
1508    this.reasonCode = theReasonCode;
1509    return this;
1510  }
1511
1512  public boolean hasReasonCode() {
1513    if (this.reasonCode == null)
1514      return false;
1515    for (CodeableConcept item : this.reasonCode)
1516      if (!item.isEmpty())
1517        return true;
1518    return false;
1519  }
1520
1521  public CodeableConcept addReasonCode() { // 3
1522    CodeableConcept t = new CodeableConcept();
1523    if (this.reasonCode == null)
1524      this.reasonCode = new ArrayList<CodeableConcept>();
1525    this.reasonCode.add(t);
1526    return t;
1527  }
1528
1529  public SupplyRequest addReasonCode(CodeableConcept t) { // 3
1530    if (t == null)
1531      return this;
1532    if (this.reasonCode == null)
1533      this.reasonCode = new ArrayList<CodeableConcept>();
1534    this.reasonCode.add(t);
1535    return this;
1536  }
1537
1538  /**
1539   * @return The first repetition of repeating field {@link #reasonCode}, creating
1540   *         it if it does not already exist
1541   */
1542  public CodeableConcept getReasonCodeFirstRep() {
1543    if (getReasonCode().isEmpty()) {
1544      addReasonCode();
1545    }
1546    return getReasonCode().get(0);
1547  }
1548
1549  /**
1550   * @return {@link #reasonReference} (The reason why the supply item was
1551   *         requested.)
1552   */
1553  public List<Reference> getReasonReference() {
1554    if (this.reasonReference == null)
1555      this.reasonReference = new ArrayList<Reference>();
1556    return this.reasonReference;
1557  }
1558
1559  /**
1560   * @return Returns a reference to <code>this</code> for easy method chaining
1561   */
1562  public SupplyRequest setReasonReference(List<Reference> theReasonReference) {
1563    this.reasonReference = theReasonReference;
1564    return this;
1565  }
1566
1567  public boolean hasReasonReference() {
1568    if (this.reasonReference == null)
1569      return false;
1570    for (Reference item : this.reasonReference)
1571      if (!item.isEmpty())
1572        return true;
1573    return false;
1574  }
1575
1576  public Reference addReasonReference() { // 3
1577    Reference t = new Reference();
1578    if (this.reasonReference == null)
1579      this.reasonReference = new ArrayList<Reference>();
1580    this.reasonReference.add(t);
1581    return t;
1582  }
1583
1584  public SupplyRequest addReasonReference(Reference t) { // 3
1585    if (t == null)
1586      return this;
1587    if (this.reasonReference == null)
1588      this.reasonReference = new ArrayList<Reference>();
1589    this.reasonReference.add(t);
1590    return this;
1591  }
1592
1593  /**
1594   * @return The first repetition of repeating field {@link #reasonReference},
1595   *         creating it if it does not already exist
1596   */
1597  public Reference getReasonReferenceFirstRep() {
1598    if (getReasonReference().isEmpty()) {
1599      addReasonReference();
1600    }
1601    return getReasonReference().get(0);
1602  }
1603
1604  /**
1605   * @deprecated Use Reference#setResource(IBaseResource) instead
1606   */
1607  @Deprecated
1608  public List<Resource> getReasonReferenceTarget() {
1609    if (this.reasonReferenceTarget == null)
1610      this.reasonReferenceTarget = new ArrayList<Resource>();
1611    return this.reasonReferenceTarget;
1612  }
1613
1614  /**
1615   * @return {@link #deliverFrom} (Where the supply is expected to come from.)
1616   */
1617  public Reference getDeliverFrom() {
1618    if (this.deliverFrom == null)
1619      if (Configuration.errorOnAutoCreate())
1620        throw new Error("Attempt to auto-create SupplyRequest.deliverFrom");
1621      else if (Configuration.doAutoCreate())
1622        this.deliverFrom = new Reference(); // cc
1623    return this.deliverFrom;
1624  }
1625
1626  public boolean hasDeliverFrom() {
1627    return this.deliverFrom != null && !this.deliverFrom.isEmpty();
1628  }
1629
1630  /**
1631   * @param value {@link #deliverFrom} (Where the supply is expected to come
1632   *              from.)
1633   */
1634  public SupplyRequest setDeliverFrom(Reference value) {
1635    this.deliverFrom = value;
1636    return this;
1637  }
1638
1639  /**
1640   * @return {@link #deliverFrom} The actual object that is the target of the
1641   *         reference. The reference library doesn't populate this, but you can
1642   *         use it to hold the resource if you resolve it. (Where the supply is
1643   *         expected to come from.)
1644   */
1645  public Resource getDeliverFromTarget() {
1646    return this.deliverFromTarget;
1647  }
1648
1649  /**
1650   * @param value {@link #deliverFrom} The actual object that is the target of the
1651   *              reference. The reference library doesn't use these, but you can
1652   *              use it to hold the resource if you resolve it. (Where the supply
1653   *              is expected to come from.)
1654   */
1655  public SupplyRequest setDeliverFromTarget(Resource value) {
1656    this.deliverFromTarget = value;
1657    return this;
1658  }
1659
1660  /**
1661   * @return {@link #deliverTo} (Where the supply is destined to go.)
1662   */
1663  public Reference getDeliverTo() {
1664    if (this.deliverTo == null)
1665      if (Configuration.errorOnAutoCreate())
1666        throw new Error("Attempt to auto-create SupplyRequest.deliverTo");
1667      else if (Configuration.doAutoCreate())
1668        this.deliverTo = new Reference(); // cc
1669    return this.deliverTo;
1670  }
1671
1672  public boolean hasDeliverTo() {
1673    return this.deliverTo != null && !this.deliverTo.isEmpty();
1674  }
1675
1676  /**
1677   * @param value {@link #deliverTo} (Where the supply is destined to go.)
1678   */
1679  public SupplyRequest setDeliverTo(Reference value) {
1680    this.deliverTo = value;
1681    return this;
1682  }
1683
1684  /**
1685   * @return {@link #deliverTo} The actual object that is the target of the
1686   *         reference. The reference library doesn't populate this, but you can
1687   *         use it to hold the resource if you resolve it. (Where the supply is
1688   *         destined to go.)
1689   */
1690  public Resource getDeliverToTarget() {
1691    return this.deliverToTarget;
1692  }
1693
1694  /**
1695   * @param value {@link #deliverTo} The actual object that is the target of the
1696   *              reference. The reference library doesn't use these, but you can
1697   *              use it to hold the resource if you resolve it. (Where the supply
1698   *              is destined to go.)
1699   */
1700  public SupplyRequest setDeliverToTarget(Resource value) {
1701    this.deliverToTarget = value;
1702    return this;
1703  }
1704
1705  protected void listChildren(List<Property> children) {
1706    super.listChildren(children);
1707    children.add(new Property("identifier", "Identifier",
1708        "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.",
1709        0, java.lang.Integer.MAX_VALUE, identifier));
1710    children.add(new Property("status", "code", "Status of the supply request.", 0, 1, status));
1711    children.add(new Property("category", "CodeableConcept",
1712        "Category of supply, e.g.  central, non-stock, etc. This is used to support work flows associated with the supply process.",
1713        0, 1, category));
1714    children.add(new Property("priority", "code",
1715        "Indicates how quickly this SupplyRequest should be addressed with respect to other requests.", 0, 1,
1716        priority));
1717    children.add(new Property("item[x]", "CodeableConcept|Reference(Medication|Substance|Device)",
1718        "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.",
1719        0, 1, item));
1720    children.add(new Property("quantity", "Quantity", "The amount that is being ordered of the indicated item.", 0, 1,
1721        quantity));
1722    children.add(new Property("parameter", "",
1723        "Specific parameters for the ordered item.  For example, the size of the indicated item.", 0,
1724        java.lang.Integer.MAX_VALUE, parameter));
1725    children.add(new Property("occurrence[x]", "dateTime|Period|Timing", "When the request should be fulfilled.", 0, 1,
1726        occurrence));
1727    children.add(new Property("authoredOn", "dateTime", "When the request was made.", 0, 1, authoredOn));
1728    children.add(
1729        new Property("requester", "Reference(Practitioner|PractitionerRole|Organization|Patient|RelatedPerson|Device)",
1730            "The device, practitioner, etc. who initiated the request.", 0, 1, requester));
1731    children.add(new Property("supplier", "Reference(Organization|HealthcareService)",
1732        "Who is intended to fulfill the request.", 0, java.lang.Integer.MAX_VALUE, supplier));
1733    children.add(new Property("reasonCode", "CodeableConcept", "The reason why the supply item was requested.", 0,
1734        java.lang.Integer.MAX_VALUE, reasonCode));
1735    children.add(new Property("reasonReference", "Reference(Condition|Observation|DiagnosticReport|DocumentReference)",
1736        "The reason why the supply item was requested.", 0, java.lang.Integer.MAX_VALUE, reasonReference));
1737    children.add(new Property("deliverFrom", "Reference(Organization|Location)",
1738        "Where the supply is expected to come from.", 0, 1, deliverFrom));
1739    children.add(new Property("deliverTo", "Reference(Organization|Location|Patient)",
1740        "Where the supply is destined to go.", 0, 1, deliverTo));
1741  }
1742
1743  @Override
1744  public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1745    switch (_hash) {
1746    case -1618432855:
1747      /* identifier */ return new Property("identifier", "Identifier",
1748          "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.",
1749          0, java.lang.Integer.MAX_VALUE, identifier);
1750    case -892481550:
1751      /* status */ return new Property("status", "code", "Status of the supply request.", 0, 1, status);
1752    case 50511102:
1753      /* category */ return new Property("category", "CodeableConcept",
1754          "Category of supply, e.g.  central, non-stock, etc. This is used to support work flows associated with the supply process.",
1755          0, 1, category);
1756    case -1165461084:
1757      /* priority */ return new Property("priority", "code",
1758          "Indicates how quickly this SupplyRequest should be addressed with respect to other requests.", 0, 1,
1759          priority);
1760    case 2116201613:
1761      /* item[x] */ return new Property("item[x]", "CodeableConcept|Reference(Medication|Substance|Device)",
1762          "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.",
1763          0, 1, item);
1764    case 3242771:
1765      /* item */ return new Property("item[x]", "CodeableConcept|Reference(Medication|Substance|Device)",
1766          "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.",
1767          0, 1, item);
1768    case 106644494:
1769      /* itemCodeableConcept */ return new Property("item[x]", "CodeableConcept|Reference(Medication|Substance|Device)",
1770          "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.",
1771          0, 1, item);
1772    case 1376364920:
1773      /* itemReference */ return new Property("item[x]", "CodeableConcept|Reference(Medication|Substance|Device)",
1774          "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.",
1775          0, 1, item);
1776    case -1285004149:
1777      /* quantity */ return new Property("quantity", "Quantity",
1778          "The amount that is being ordered of the indicated item.", 0, 1, quantity);
1779    case 1954460585:
1780      /* parameter */ return new Property("parameter", "",
1781          "Specific parameters for the ordered item.  For example, the size of the indicated item.", 0,
1782          java.lang.Integer.MAX_VALUE, parameter);
1783    case -2022646513:
1784      /* occurrence[x] */ return new Property("occurrence[x]", "dateTime|Period|Timing",
1785          "When the request should be fulfilled.", 0, 1, occurrence);
1786    case 1687874001:
1787      /* occurrence */ return new Property("occurrence[x]", "dateTime|Period|Timing",
1788          "When the request should be fulfilled.", 0, 1, occurrence);
1789    case -298443636:
1790      /* occurrenceDateTime */ return new Property("occurrence[x]", "dateTime|Period|Timing",
1791          "When the request should be fulfilled.", 0, 1, occurrence);
1792    case 1397156594:
1793      /* occurrencePeriod */ return new Property("occurrence[x]", "dateTime|Period|Timing",
1794          "When the request should be fulfilled.", 0, 1, occurrence);
1795    case 1515218299:
1796      /* occurrenceTiming */ return new Property("occurrence[x]", "dateTime|Period|Timing",
1797          "When the request should be fulfilled.", 0, 1, occurrence);
1798    case -1500852503:
1799      /* authoredOn */ return new Property("authoredOn", "dateTime", "When the request was made.", 0, 1, authoredOn);
1800    case 693933948:
1801      /* requester */ return new Property("requester",
1802          "Reference(Practitioner|PractitionerRole|Organization|Patient|RelatedPerson|Device)",
1803          "The device, practitioner, etc. who initiated the request.", 0, 1, requester);
1804    case -1663305268:
1805      /* supplier */ return new Property("supplier", "Reference(Organization|HealthcareService)",
1806          "Who is intended to fulfill the request.", 0, java.lang.Integer.MAX_VALUE, supplier);
1807    case 722137681:
1808      /* reasonCode */ return new Property("reasonCode", "CodeableConcept",
1809          "The reason why the supply item was requested.", 0, java.lang.Integer.MAX_VALUE, reasonCode);
1810    case -1146218137:
1811      /* reasonReference */ return new Property("reasonReference",
1812          "Reference(Condition|Observation|DiagnosticReport|DocumentReference)",
1813          "The reason why the supply item was requested.", 0, java.lang.Integer.MAX_VALUE, reasonReference);
1814    case -949323153:
1815      /* deliverFrom */ return new Property("deliverFrom", "Reference(Organization|Location)",
1816          "Where the supply is expected to come from.", 0, 1, deliverFrom);
1817    case -242327936:
1818      /* deliverTo */ return new Property("deliverTo", "Reference(Organization|Location|Patient)",
1819          "Where the supply is destined to go.", 0, 1, deliverTo);
1820    default:
1821      return super.getNamedProperty(_hash, _name, _checkValid);
1822    }
1823
1824  }
1825
1826  @Override
1827  public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1828    switch (hash) {
1829    case -1618432855:
1830      /* identifier */ return this.identifier == null ? new Base[0]
1831          : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1832    case -892481550:
1833      /* status */ return this.status == null ? new Base[0] : new Base[] { this.status }; // Enumeration<SupplyRequestStatus>
1834    case 50511102:
1835      /* category */ return this.category == null ? new Base[0] : new Base[] { this.category }; // CodeableConcept
1836    case -1165461084:
1837      /* priority */ return this.priority == null ? new Base[0] : new Base[] { this.priority }; // Enumeration<RequestPriority>
1838    case 3242771:
1839      /* item */ return this.item == null ? new Base[0] : new Base[] { this.item }; // Type
1840    case -1285004149:
1841      /* quantity */ return this.quantity == null ? new Base[0] : new Base[] { this.quantity }; // Quantity
1842    case 1954460585:
1843      /* parameter */ return this.parameter == null ? new Base[0]
1844          : this.parameter.toArray(new Base[this.parameter.size()]); // SupplyRequestParameterComponent
1845    case 1687874001:
1846      /* occurrence */ return this.occurrence == null ? new Base[0] : new Base[] { this.occurrence }; // Type
1847    case -1500852503:
1848      /* authoredOn */ return this.authoredOn == null ? new Base[0] : new Base[] { this.authoredOn }; // DateTimeType
1849    case 693933948:
1850      /* requester */ return this.requester == null ? new Base[0] : new Base[] { this.requester }; // Reference
1851    case -1663305268:
1852      /* supplier */ return this.supplier == null ? new Base[0] : this.supplier.toArray(new Base[this.supplier.size()]); // Reference
1853    case 722137681:
1854      /* reasonCode */ return this.reasonCode == null ? new Base[0]
1855          : this.reasonCode.toArray(new Base[this.reasonCode.size()]); // CodeableConcept
1856    case -1146218137:
1857      /* reasonReference */ return this.reasonReference == null ? new Base[0]
1858          : this.reasonReference.toArray(new Base[this.reasonReference.size()]); // Reference
1859    case -949323153:
1860      /* deliverFrom */ return this.deliverFrom == null ? new Base[0] : new Base[] { this.deliverFrom }; // Reference
1861    case -242327936:
1862      /* deliverTo */ return this.deliverTo == null ? new Base[0] : new Base[] { this.deliverTo }; // Reference
1863    default:
1864      return super.getProperty(hash, name, checkValid);
1865    }
1866
1867  }
1868
1869  @Override
1870  public Base setProperty(int hash, String name, Base value) throws FHIRException {
1871    switch (hash) {
1872    case -1618432855: // identifier
1873      this.getIdentifier().add(castToIdentifier(value)); // Identifier
1874      return value;
1875    case -892481550: // status
1876      value = new SupplyRequestStatusEnumFactory().fromType(castToCode(value));
1877      this.status = (Enumeration) value; // Enumeration<SupplyRequestStatus>
1878      return value;
1879    case 50511102: // category
1880      this.category = castToCodeableConcept(value); // CodeableConcept
1881      return value;
1882    case -1165461084: // priority
1883      value = new RequestPriorityEnumFactory().fromType(castToCode(value));
1884      this.priority = (Enumeration) value; // Enumeration<RequestPriority>
1885      return value;
1886    case 3242771: // item
1887      this.item = castToType(value); // Type
1888      return value;
1889    case -1285004149: // quantity
1890      this.quantity = castToQuantity(value); // Quantity
1891      return value;
1892    case 1954460585: // parameter
1893      this.getParameter().add((SupplyRequestParameterComponent) value); // SupplyRequestParameterComponent
1894      return value;
1895    case 1687874001: // occurrence
1896      this.occurrence = castToType(value); // Type
1897      return value;
1898    case -1500852503: // authoredOn
1899      this.authoredOn = castToDateTime(value); // DateTimeType
1900      return value;
1901    case 693933948: // requester
1902      this.requester = castToReference(value); // Reference
1903      return value;
1904    case -1663305268: // supplier
1905      this.getSupplier().add(castToReference(value)); // Reference
1906      return value;
1907    case 722137681: // reasonCode
1908      this.getReasonCode().add(castToCodeableConcept(value)); // CodeableConcept
1909      return value;
1910    case -1146218137: // reasonReference
1911      this.getReasonReference().add(castToReference(value)); // Reference
1912      return value;
1913    case -949323153: // deliverFrom
1914      this.deliverFrom = castToReference(value); // Reference
1915      return value;
1916    case -242327936: // deliverTo
1917      this.deliverTo = castToReference(value); // Reference
1918      return value;
1919    default:
1920      return super.setProperty(hash, name, value);
1921    }
1922
1923  }
1924
1925  @Override
1926  public Base setProperty(String name, Base value) throws FHIRException {
1927    if (name.equals("identifier")) {
1928      this.getIdentifier().add(castToIdentifier(value));
1929    } else if (name.equals("status")) {
1930      value = new SupplyRequestStatusEnumFactory().fromType(castToCode(value));
1931      this.status = (Enumeration) value; // Enumeration<SupplyRequestStatus>
1932    } else if (name.equals("category")) {
1933      this.category = castToCodeableConcept(value); // CodeableConcept
1934    } else if (name.equals("priority")) {
1935      value = new RequestPriorityEnumFactory().fromType(castToCode(value));
1936      this.priority = (Enumeration) value; // Enumeration<RequestPriority>
1937    } else if (name.equals("item[x]")) {
1938      this.item = castToType(value); // Type
1939    } else if (name.equals("quantity")) {
1940      this.quantity = castToQuantity(value); // Quantity
1941    } else if (name.equals("parameter")) {
1942      this.getParameter().add((SupplyRequestParameterComponent) value);
1943    } else if (name.equals("occurrence[x]")) {
1944      this.occurrence = castToType(value); // Type
1945    } else if (name.equals("authoredOn")) {
1946      this.authoredOn = castToDateTime(value); // DateTimeType
1947    } else if (name.equals("requester")) {
1948      this.requester = castToReference(value); // Reference
1949    } else if (name.equals("supplier")) {
1950      this.getSupplier().add(castToReference(value));
1951    } else if (name.equals("reasonCode")) {
1952      this.getReasonCode().add(castToCodeableConcept(value));
1953    } else if (name.equals("reasonReference")) {
1954      this.getReasonReference().add(castToReference(value));
1955    } else if (name.equals("deliverFrom")) {
1956      this.deliverFrom = castToReference(value); // Reference
1957    } else if (name.equals("deliverTo")) {
1958      this.deliverTo = castToReference(value); // Reference
1959    } else
1960      return super.setProperty(name, value);
1961    return value;
1962  }
1963
1964  @Override
1965  public Base makeProperty(int hash, String name) throws FHIRException {
1966    switch (hash) {
1967    case -1618432855:
1968      return addIdentifier();
1969    case -892481550:
1970      return getStatusElement();
1971    case 50511102:
1972      return getCategory();
1973    case -1165461084:
1974      return getPriorityElement();
1975    case 2116201613:
1976      return getItem();
1977    case 3242771:
1978      return getItem();
1979    case -1285004149:
1980      return getQuantity();
1981    case 1954460585:
1982      return addParameter();
1983    case -2022646513:
1984      return getOccurrence();
1985    case 1687874001:
1986      return getOccurrence();
1987    case -1500852503:
1988      return getAuthoredOnElement();
1989    case 693933948:
1990      return getRequester();
1991    case -1663305268:
1992      return addSupplier();
1993    case 722137681:
1994      return addReasonCode();
1995    case -1146218137:
1996      return addReasonReference();
1997    case -949323153:
1998      return getDeliverFrom();
1999    case -242327936:
2000      return getDeliverTo();
2001    default:
2002      return super.makeProperty(hash, name);
2003    }
2004
2005  }
2006
2007  @Override
2008  public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2009    switch (hash) {
2010    case -1618432855:
2011      /* identifier */ return new String[] { "Identifier" };
2012    case -892481550:
2013      /* status */ return new String[] { "code" };
2014    case 50511102:
2015      /* category */ return new String[] { "CodeableConcept" };
2016    case -1165461084:
2017      /* priority */ return new String[] { "code" };
2018    case 3242771:
2019      /* item */ return new String[] { "CodeableConcept", "Reference" };
2020    case -1285004149:
2021      /* quantity */ return new String[] { "Quantity" };
2022    case 1954460585:
2023      /* parameter */ return new String[] {};
2024    case 1687874001:
2025      /* occurrence */ return new String[] { "dateTime", "Period", "Timing" };
2026    case -1500852503:
2027      /* authoredOn */ return new String[] { "dateTime" };
2028    case 693933948:
2029      /* requester */ return new String[] { "Reference" };
2030    case -1663305268:
2031      /* supplier */ return new String[] { "Reference" };
2032    case 722137681:
2033      /* reasonCode */ return new String[] { "CodeableConcept" };
2034    case -1146218137:
2035      /* reasonReference */ return new String[] { "Reference" };
2036    case -949323153:
2037      /* deliverFrom */ return new String[] { "Reference" };
2038    case -242327936:
2039      /* deliverTo */ return new String[] { "Reference" };
2040    default:
2041      return super.getTypesForProperty(hash, name);
2042    }
2043
2044  }
2045
2046  @Override
2047  public Base addChild(String name) throws FHIRException {
2048    if (name.equals("identifier")) {
2049      return addIdentifier();
2050    } else if (name.equals("status")) {
2051      throw new FHIRException("Cannot call addChild on a singleton property SupplyRequest.status");
2052    } else if (name.equals("category")) {
2053      this.category = new CodeableConcept();
2054      return this.category;
2055    } else if (name.equals("priority")) {
2056      throw new FHIRException("Cannot call addChild on a singleton property SupplyRequest.priority");
2057    } else if (name.equals("itemCodeableConcept")) {
2058      this.item = new CodeableConcept();
2059      return this.item;
2060    } else if (name.equals("itemReference")) {
2061      this.item = new Reference();
2062      return this.item;
2063    } else if (name.equals("quantity")) {
2064      this.quantity = new Quantity();
2065      return this.quantity;
2066    } else if (name.equals("parameter")) {
2067      return addParameter();
2068    } else if (name.equals("occurrenceDateTime")) {
2069      this.occurrence = new DateTimeType();
2070      return this.occurrence;
2071    } else if (name.equals("occurrencePeriod")) {
2072      this.occurrence = new Period();
2073      return this.occurrence;
2074    } else if (name.equals("occurrenceTiming")) {
2075      this.occurrence = new Timing();
2076      return this.occurrence;
2077    } else if (name.equals("authoredOn")) {
2078      throw new FHIRException("Cannot call addChild on a singleton property SupplyRequest.authoredOn");
2079    } else if (name.equals("requester")) {
2080      this.requester = new Reference();
2081      return this.requester;
2082    } else if (name.equals("supplier")) {
2083      return addSupplier();
2084    } else if (name.equals("reasonCode")) {
2085      return addReasonCode();
2086    } else if (name.equals("reasonReference")) {
2087      return addReasonReference();
2088    } else if (name.equals("deliverFrom")) {
2089      this.deliverFrom = new Reference();
2090      return this.deliverFrom;
2091    } else if (name.equals("deliverTo")) {
2092      this.deliverTo = new Reference();
2093      return this.deliverTo;
2094    } else
2095      return super.addChild(name);
2096  }
2097
2098  public String fhirType() {
2099    return "SupplyRequest";
2100
2101  }
2102
2103  public SupplyRequest copy() {
2104    SupplyRequest dst = new SupplyRequest();
2105    copyValues(dst);
2106    return dst;
2107  }
2108
2109  public void copyValues(SupplyRequest dst) {
2110    super.copyValues(dst);
2111    if (identifier != null) {
2112      dst.identifier = new ArrayList<Identifier>();
2113      for (Identifier i : identifier)
2114        dst.identifier.add(i.copy());
2115    }
2116    ;
2117    dst.status = status == null ? null : status.copy();
2118    dst.category = category == null ? null : category.copy();
2119    dst.priority = priority == null ? null : priority.copy();
2120    dst.item = item == null ? null : item.copy();
2121    dst.quantity = quantity == null ? null : quantity.copy();
2122    if (parameter != null) {
2123      dst.parameter = new ArrayList<SupplyRequestParameterComponent>();
2124      for (SupplyRequestParameterComponent i : parameter)
2125        dst.parameter.add(i.copy());
2126    }
2127    ;
2128    dst.occurrence = occurrence == null ? null : occurrence.copy();
2129    dst.authoredOn = authoredOn == null ? null : authoredOn.copy();
2130    dst.requester = requester == null ? null : requester.copy();
2131    if (supplier != null) {
2132      dst.supplier = new ArrayList<Reference>();
2133      for (Reference i : supplier)
2134        dst.supplier.add(i.copy());
2135    }
2136    ;
2137    if (reasonCode != null) {
2138      dst.reasonCode = new ArrayList<CodeableConcept>();
2139      for (CodeableConcept i : reasonCode)
2140        dst.reasonCode.add(i.copy());
2141    }
2142    ;
2143    if (reasonReference != null) {
2144      dst.reasonReference = new ArrayList<Reference>();
2145      for (Reference i : reasonReference)
2146        dst.reasonReference.add(i.copy());
2147    }
2148    ;
2149    dst.deliverFrom = deliverFrom == null ? null : deliverFrom.copy();
2150    dst.deliverTo = deliverTo == null ? null : deliverTo.copy();
2151  }
2152
2153  protected SupplyRequest typedCopy() {
2154    return copy();
2155  }
2156
2157  @Override
2158  public boolean equalsDeep(Base other_) {
2159    if (!super.equalsDeep(other_))
2160      return false;
2161    if (!(other_ instanceof SupplyRequest))
2162      return false;
2163    SupplyRequest o = (SupplyRequest) other_;
2164    return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true)
2165        && compareDeep(category, o.category, true) && compareDeep(priority, o.priority, true)
2166        && compareDeep(item, o.item, true) && compareDeep(quantity, o.quantity, true)
2167        && compareDeep(parameter, o.parameter, true) && compareDeep(occurrence, o.occurrence, true)
2168        && compareDeep(authoredOn, o.authoredOn, true) && compareDeep(requester, o.requester, true)
2169        && compareDeep(supplier, o.supplier, true) && compareDeep(reasonCode, o.reasonCode, true)
2170        && compareDeep(reasonReference, o.reasonReference, true) && compareDeep(deliverFrom, o.deliverFrom, true)
2171        && compareDeep(deliverTo, o.deliverTo, true);
2172  }
2173
2174  @Override
2175  public boolean equalsShallow(Base other_) {
2176    if (!super.equalsShallow(other_))
2177      return false;
2178    if (!(other_ instanceof SupplyRequest))
2179      return false;
2180    SupplyRequest o = (SupplyRequest) other_;
2181    return compareValues(status, o.status, true) && compareValues(priority, o.priority, true)
2182        && compareValues(authoredOn, o.authoredOn, true);
2183  }
2184
2185  public boolean isEmpty() {
2186    return super.isEmpty()
2187        && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, category, priority, item, quantity, parameter,
2188            occurrence, authoredOn, requester, supplier, reasonCode, reasonReference, deliverFrom, deliverTo);
2189  }
2190
2191  @Override
2192  public ResourceType getResourceType() {
2193    return ResourceType.SupplyRequest;
2194  }
2195
2196  /**
2197   * Search parameter: <b>requester</b>
2198   * <p>
2199   * Description: <b>Individual making the request</b><br>
2200   * Type: <b>reference</b><br>
2201   * Path: <b>SupplyRequest.requester</b><br>
2202   * </p>
2203   */
2204  @SearchParamDefinition(name = "requester", path = "SupplyRequest.requester", description = "Individual making the request", type = "reference", providesMembershipIn = {
2205      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Device"),
2206      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Practitioner"),
2207      @ca.uhn.fhir.model.api.annotation.Compartment(name = "RelatedPerson") }, target = { Device.class,
2208          Organization.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class })
2209  public static final String SP_REQUESTER = "requester";
2210  /**
2211   * <b>Fluent Client</b> search parameter constant for <b>requester</b>
2212   * <p>
2213   * Description: <b>Individual making the request</b><br>
2214   * Type: <b>reference</b><br>
2215   * Path: <b>SupplyRequest.requester</b><br>
2216   * </p>
2217   */
2218  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam REQUESTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
2219      SP_REQUESTER);
2220
2221  /**
2222   * Constant for fluent queries to be used to add include statements. Specifies
2223   * the path value of "<b>SupplyRequest:requester</b>".
2224   */
2225  public static final ca.uhn.fhir.model.api.Include INCLUDE_REQUESTER = new ca.uhn.fhir.model.api.Include(
2226      "SupplyRequest:requester").toLocked();
2227
2228  /**
2229   * Search parameter: <b>date</b>
2230   * <p>
2231   * Description: <b>When the request was made</b><br>
2232   * Type: <b>date</b><br>
2233   * Path: <b>SupplyRequest.authoredOn</b><br>
2234   * </p>
2235   */
2236  @SearchParamDefinition(name = "date", path = "SupplyRequest.authoredOn", description = "When the request was made", type = "date")
2237  public static final String SP_DATE = "date";
2238  /**
2239   * <b>Fluent Client</b> search parameter constant for <b>date</b>
2240   * <p>
2241   * Description: <b>When the request was made</b><br>
2242   * Type: <b>date</b><br>
2243   * Path: <b>SupplyRequest.authoredOn</b><br>
2244   * </p>
2245   */
2246  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(
2247      SP_DATE);
2248
2249  /**
2250   * Search parameter: <b>identifier</b>
2251   * <p>
2252   * Description: <b>Business Identifier for SupplyRequest</b><br>
2253   * Type: <b>token</b><br>
2254   * Path: <b>SupplyRequest.identifier</b><br>
2255   * </p>
2256   */
2257  @SearchParamDefinition(name = "identifier", path = "SupplyRequest.identifier", description = "Business Identifier for SupplyRequest", type = "token")
2258  public static final String SP_IDENTIFIER = "identifier";
2259  /**
2260   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2261   * <p>
2262   * Description: <b>Business Identifier for SupplyRequest</b><br>
2263   * Type: <b>token</b><br>
2264   * Path: <b>SupplyRequest.identifier</b><br>
2265   * </p>
2266   */
2267  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(
2268      SP_IDENTIFIER);
2269
2270  /**
2271   * Search parameter: <b>subject</b>
2272   * <p>
2273   * Description: <b>The destination of the supply</b><br>
2274   * Type: <b>reference</b><br>
2275   * Path: <b>SupplyRequest.deliverTo</b><br>
2276   * </p>
2277   */
2278  @SearchParamDefinition(name = "subject", path = "SupplyRequest.deliverTo", description = "The destination of the supply", type = "reference", providesMembershipIn = {
2279      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Patient") }, target = { Location.class, Organization.class,
2280          Patient.class })
2281  public static final String SP_SUBJECT = "subject";
2282  /**
2283   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
2284   * <p>
2285   * Description: <b>The destination of the supply</b><br>
2286   * Type: <b>reference</b><br>
2287   * Path: <b>SupplyRequest.deliverTo</b><br>
2288   * </p>
2289   */
2290  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
2291      SP_SUBJECT);
2292
2293  /**
2294   * Constant for fluent queries to be used to add include statements. Specifies
2295   * the path value of "<b>SupplyRequest:subject</b>".
2296   */
2297  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include(
2298      "SupplyRequest:subject").toLocked();
2299
2300  /**
2301   * Search parameter: <b>supplier</b>
2302   * <p>
2303   * Description: <b>Who is intended to fulfill the request</b><br>
2304   * Type: <b>reference</b><br>
2305   * Path: <b>SupplyRequest.supplier</b><br>
2306   * </p>
2307   */
2308  @SearchParamDefinition(name = "supplier", path = "SupplyRequest.supplier", description = "Who is intended to fulfill the request", type = "reference", target = {
2309      HealthcareService.class, Organization.class })
2310  public static final String SP_SUPPLIER = "supplier";
2311  /**
2312   * <b>Fluent Client</b> search parameter constant for <b>supplier</b>
2313   * <p>
2314   * Description: <b>Who is intended to fulfill the request</b><br>
2315   * Type: <b>reference</b><br>
2316   * Path: <b>SupplyRequest.supplier</b><br>
2317   * </p>
2318   */
2319  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUPPLIER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
2320      SP_SUPPLIER);
2321
2322  /**
2323   * Constant for fluent queries to be used to add include statements. Specifies
2324   * the path value of "<b>SupplyRequest:supplier</b>".
2325   */
2326  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUPPLIER = new ca.uhn.fhir.model.api.Include(
2327      "SupplyRequest:supplier").toLocked();
2328
2329  /**
2330   * Search parameter: <b>category</b>
2331   * <p>
2332   * Description: <b>The kind of supply (central, non-stock, etc.)</b><br>
2333   * Type: <b>token</b><br>
2334   * Path: <b>SupplyRequest.category</b><br>
2335   * </p>
2336   */
2337  @SearchParamDefinition(name = "category", path = "SupplyRequest.category", description = "The kind of supply (central, non-stock, etc.)", type = "token")
2338  public static final String SP_CATEGORY = "category";
2339  /**
2340   * <b>Fluent Client</b> search parameter constant for <b>category</b>
2341   * <p>
2342   * Description: <b>The kind of supply (central, non-stock, etc.)</b><br>
2343   * Type: <b>token</b><br>
2344   * Path: <b>SupplyRequest.category</b><br>
2345   * </p>
2346   */
2347  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(
2348      SP_CATEGORY);
2349
2350  /**
2351   * Search parameter: <b>status</b>
2352   * <p>
2353   * Description: <b>draft | active | suspended +</b><br>
2354   * Type: <b>token</b><br>
2355   * Path: <b>SupplyRequest.status</b><br>
2356   * </p>
2357   */
2358  @SearchParamDefinition(name = "status", path = "SupplyRequest.status", description = "draft | active | suspended +", type = "token")
2359  public static final String SP_STATUS = "status";
2360  /**
2361   * <b>Fluent Client</b> search parameter constant for <b>status</b>
2362   * <p>
2363   * Description: <b>draft | active | suspended +</b><br>
2364   * Type: <b>token</b><br>
2365   * Path: <b>SupplyRequest.status</b><br>
2366   * </p>
2367   */
2368  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(
2369      SP_STATUS);
2370
2371}