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 * An order or request for both supply of the medication and the instructions
048 * for administration of the medication to a patient. The resource is called
049 * "MedicationRequest" rather than "MedicationPrescription" or "MedicationOrder"
050 * to generalize the use across inpatient and outpatient settings, including
051 * care plans, etc., and to harmonize with workflow patterns.
052 */
053@ResourceDef(name = "MedicationRequest", profile = "http://hl7.org/fhir/StructureDefinition/MedicationRequest")
054public class MedicationRequest extends DomainResource {
055
056  public enum MedicationRequestStatus {
057    /**
058     * The prescription is 'actionable', but not all actions that are implied by it
059     * have occurred yet.
060     */
061    ACTIVE,
062    /**
063     * Actions implied by the prescription are to be temporarily halted, but are
064     * expected to continue later. May also be called 'suspended'.
065     */
066    ONHOLD,
067    /**
068     * The prescription has been withdrawn before any administrations have occurred
069     */
070    CANCELLED,
071    /**
072     * All actions that are implied by the prescription have occurred.
073     */
074    COMPLETED,
075    /**
076     * Some of the actions that are implied by the medication request may have
077     * occurred. For example, the medication may have been dispensed and the patient
078     * may have taken some of the medication. Clinical decision support systems
079     * should take this status into account
080     */
081    ENTEREDINERROR,
082    /**
083     * Actions implied by the prescription are to be permanently halted, before all
084     * of the administrations occurred. This should not be used if the original
085     * order was entered in error
086     */
087    STOPPED,
088    /**
089     * The prescription is not yet 'actionable', e.g. it is a work in progress,
090     * requires sign-off, verification or needs to be run through decision support
091     * process.
092     */
093    DRAFT,
094    /**
095     * The authoring/source system does not know which of the status values
096     * currently applies for this observation. Note: This concept is not to be used
097     * for 'other' - one of the listed statuses is presumed to apply, but the
098     * authoring/source system does not know which.
099     */
100    UNKNOWN,
101    /**
102     * added to help the parsers with the generic types
103     */
104    NULL;
105
106    public static MedicationRequestStatus fromCode(String codeString) throws FHIRException {
107      if (codeString == null || "".equals(codeString))
108        return null;
109      if ("active".equals(codeString))
110        return ACTIVE;
111      if ("on-hold".equals(codeString))
112        return ONHOLD;
113      if ("cancelled".equals(codeString))
114        return CANCELLED;
115      if ("completed".equals(codeString))
116        return COMPLETED;
117      if ("entered-in-error".equals(codeString))
118        return ENTEREDINERROR;
119      if ("stopped".equals(codeString))
120        return STOPPED;
121      if ("draft".equals(codeString))
122        return DRAFT;
123      if ("unknown".equals(codeString))
124        return UNKNOWN;
125      if (Configuration.isAcceptInvalidEnums())
126        return null;
127      else
128        throw new FHIRException("Unknown MedicationRequestStatus code '" + codeString + "'");
129    }
130
131    public String toCode() {
132      switch (this) {
133      case ACTIVE:
134        return "active";
135      case ONHOLD:
136        return "on-hold";
137      case CANCELLED:
138        return "cancelled";
139      case COMPLETED:
140        return "completed";
141      case ENTEREDINERROR:
142        return "entered-in-error";
143      case STOPPED:
144        return "stopped";
145      case DRAFT:
146        return "draft";
147      case UNKNOWN:
148        return "unknown";
149      case NULL:
150        return null;
151      default:
152        return "?";
153      }
154    }
155
156    public String getSystem() {
157      switch (this) {
158      case ACTIVE:
159        return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
160      case ONHOLD:
161        return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
162      case CANCELLED:
163        return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
164      case COMPLETED:
165        return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
166      case ENTEREDINERROR:
167        return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
168      case STOPPED:
169        return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
170      case DRAFT:
171        return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
172      case UNKNOWN:
173        return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
174      case NULL:
175        return null;
176      default:
177        return "?";
178      }
179    }
180
181    public String getDefinition() {
182      switch (this) {
183      case ACTIVE:
184        return "The prescription is 'actionable', but not all actions that are implied by it have occurred yet.";
185      case ONHOLD:
186        return "Actions implied by the prescription are to be temporarily halted, but are expected to continue later.  May also be called 'suspended'.";
187      case CANCELLED:
188        return "The prescription has been withdrawn before any administrations have occurred";
189      case COMPLETED:
190        return "All actions that are implied by the prescription have occurred.";
191      case ENTEREDINERROR:
192        return "Some of the actions that are implied by the medication request may have occurred.  For example, the medication may have been dispensed and the patient may have taken some of the medication.  Clinical decision support systems should take this status into account";
193      case STOPPED:
194        return "Actions implied by the prescription are to be permanently halted, before all of the administrations occurred. This should not be used if the original order was entered in error";
195      case DRAFT:
196        return "The prescription is not yet 'actionable', e.g. it is a work in progress, requires sign-off, verification or needs to be run through decision support process.";
197      case UNKNOWN:
198        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.";
199      case NULL:
200        return null;
201      default:
202        return "?";
203      }
204    }
205
206    public String getDisplay() {
207      switch (this) {
208      case ACTIVE:
209        return "Active";
210      case ONHOLD:
211        return "On Hold";
212      case CANCELLED:
213        return "Cancelled";
214      case COMPLETED:
215        return "Completed";
216      case ENTEREDINERROR:
217        return "Entered in Error";
218      case STOPPED:
219        return "Stopped";
220      case DRAFT:
221        return "Draft";
222      case UNKNOWN:
223        return "Unknown";
224      case NULL:
225        return null;
226      default:
227        return "?";
228      }
229    }
230  }
231
232  public static class MedicationRequestStatusEnumFactory implements EnumFactory<MedicationRequestStatus> {
233    public MedicationRequestStatus fromCode(String codeString) throws IllegalArgumentException {
234      if (codeString == null || "".equals(codeString))
235        if (codeString == null || "".equals(codeString))
236          return null;
237      if ("active".equals(codeString))
238        return MedicationRequestStatus.ACTIVE;
239      if ("on-hold".equals(codeString))
240        return MedicationRequestStatus.ONHOLD;
241      if ("cancelled".equals(codeString))
242        return MedicationRequestStatus.CANCELLED;
243      if ("completed".equals(codeString))
244        return MedicationRequestStatus.COMPLETED;
245      if ("entered-in-error".equals(codeString))
246        return MedicationRequestStatus.ENTEREDINERROR;
247      if ("stopped".equals(codeString))
248        return MedicationRequestStatus.STOPPED;
249      if ("draft".equals(codeString))
250        return MedicationRequestStatus.DRAFT;
251      if ("unknown".equals(codeString))
252        return MedicationRequestStatus.UNKNOWN;
253      throw new IllegalArgumentException("Unknown MedicationRequestStatus code '" + codeString + "'");
254    }
255
256    public Enumeration<MedicationRequestStatus> fromType(PrimitiveType<?> code) throws FHIRException {
257      if (code == null)
258        return null;
259      if (code.isEmpty())
260        return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.NULL, code);
261      String codeString = code.asStringValue();
262      if (codeString == null || "".equals(codeString))
263        return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.NULL, code);
264      if ("active".equals(codeString))
265        return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.ACTIVE, code);
266      if ("on-hold".equals(codeString))
267        return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.ONHOLD, code);
268      if ("cancelled".equals(codeString))
269        return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.CANCELLED, code);
270      if ("completed".equals(codeString))
271        return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.COMPLETED, code);
272      if ("entered-in-error".equals(codeString))
273        return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.ENTEREDINERROR, code);
274      if ("stopped".equals(codeString))
275        return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.STOPPED, code);
276      if ("draft".equals(codeString))
277        return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.DRAFT, code);
278      if ("unknown".equals(codeString))
279        return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.UNKNOWN, code);
280      throw new FHIRException("Unknown MedicationRequestStatus code '" + codeString + "'");
281    }
282
283    public String toCode(MedicationRequestStatus code) {
284       if (code == MedicationRequestStatus.NULL)
285           return null;
286       if (code == MedicationRequestStatus.ACTIVE)
287        return "active";
288      if (code == MedicationRequestStatus.ONHOLD)
289        return "on-hold";
290      if (code == MedicationRequestStatus.CANCELLED)
291        return "cancelled";
292      if (code == MedicationRequestStatus.COMPLETED)
293        return "completed";
294      if (code == MedicationRequestStatus.ENTEREDINERROR)
295        return "entered-in-error";
296      if (code == MedicationRequestStatus.STOPPED)
297        return "stopped";
298      if (code == MedicationRequestStatus.DRAFT)
299        return "draft";
300      if (code == MedicationRequestStatus.UNKNOWN)
301        return "unknown";
302      return "?";
303   }
304
305    public String toSystem(MedicationRequestStatus code) {
306      return code.getSystem();
307    }
308  }
309
310  public enum MedicationRequestIntent {
311    /**
312     * The request is a suggestion made by someone/something that doesn't have an
313     * intention to ensure it occurs and without providing an authorization to act
314     */
315    PROPOSAL,
316    /**
317     * The request represents an intention to ensure something occurs without
318     * providing an authorization for others to act.
319     */
320    PLAN,
321    /**
322     * The request represents a request/demand and authorization for action
323     */
324    ORDER,
325    /**
326     * The request represents the original authorization for the medication request.
327     */
328    ORIGINALORDER,
329    /**
330     * The request represents an automatically generated supplemental authorization
331     * for action based on a parent authorization together with initial results of
332     * the action taken against that parent authorization..
333     */
334    REFLEXORDER,
335    /**
336     * The request represents the view of an authorization instantiated by a
337     * fulfilling system representing the details of the fulfiller's intention to
338     * act upon a submitted order.
339     */
340    FILLERORDER,
341    /**
342     * The request represents an instance for the particular order, for example a
343     * medication administration record.
344     */
345    INSTANCEORDER,
346    /**
347     * The request represents a component or option for a RequestGroup that
348     * establishes timing, conditionality and/or other constraints among a set of
349     * requests.
350     */
351    OPTION,
352    /**
353     * added to help the parsers with the generic types
354     */
355    NULL;
356
357    public static MedicationRequestIntent fromCode(String codeString) throws FHIRException {
358      if (codeString == null || "".equals(codeString))
359        return null;
360      if ("proposal".equals(codeString))
361        return PROPOSAL;
362      if ("plan".equals(codeString))
363        return PLAN;
364      if ("order".equals(codeString))
365        return ORDER;
366      if ("original-order".equals(codeString))
367        return ORIGINALORDER;
368      if ("reflex-order".equals(codeString))
369        return REFLEXORDER;
370      if ("filler-order".equals(codeString))
371        return FILLERORDER;
372      if ("instance-order".equals(codeString))
373        return INSTANCEORDER;
374      if ("option".equals(codeString))
375        return OPTION;
376      if (Configuration.isAcceptInvalidEnums())
377        return null;
378      else
379        throw new FHIRException("Unknown MedicationRequestIntent code '" + codeString + "'");
380    }
381
382    public String toCode() {
383      switch (this) {
384      case PROPOSAL:
385        return "proposal";
386      case PLAN:
387        return "plan";
388      case ORDER:
389        return "order";
390      case ORIGINALORDER:
391        return "original-order";
392      case REFLEXORDER:
393        return "reflex-order";
394      case FILLERORDER:
395        return "filler-order";
396      case INSTANCEORDER:
397        return "instance-order";
398      case OPTION:
399        return "option";
400      case NULL:
401        return null;
402      default:
403        return "?";
404      }
405    }
406
407    public String getSystem() {
408      switch (this) {
409      case PROPOSAL:
410        return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
411      case PLAN:
412        return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
413      case ORDER:
414        return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
415      case ORIGINALORDER:
416        return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
417      case REFLEXORDER:
418        return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
419      case FILLERORDER:
420        return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
421      case INSTANCEORDER:
422        return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
423      case OPTION:
424        return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
425      case NULL:
426        return null;
427      default:
428        return "?";
429      }
430    }
431
432    public String getDefinition() {
433      switch (this) {
434      case PROPOSAL:
435        return "The request is a suggestion made by someone/something that doesn't have an intention to ensure it occurs and without providing an authorization to act";
436      case PLAN:
437        return "The request represents an intention to ensure something occurs without providing an authorization for others to act.";
438      case ORDER:
439        return "The request represents a request/demand and authorization for action";
440      case ORIGINALORDER:
441        return "The request represents the original authorization for the medication request.";
442      case REFLEXORDER:
443        return "The request represents an automatically generated supplemental authorization for action based on a parent authorization together with initial results of the action taken against that parent authorization..";
444      case FILLERORDER:
445        return "The request represents the view of an authorization instantiated by a fulfilling system representing the details of the fulfiller's intention to act upon a submitted order.";
446      case INSTANCEORDER:
447        return "The request represents an instance for the particular order, for example a medication administration record.";
448      case OPTION:
449        return "The request represents a component or option for a RequestGroup that establishes timing, conditionality and/or  other constraints among a set of requests.";
450      case NULL:
451        return null;
452      default:
453        return "?";
454      }
455    }
456
457    public String getDisplay() {
458      switch (this) {
459      case PROPOSAL:
460        return "Proposal";
461      case PLAN:
462        return "Plan";
463      case ORDER:
464        return "Order";
465      case ORIGINALORDER:
466        return "Original Order";
467      case REFLEXORDER:
468        return "Reflex Order";
469      case FILLERORDER:
470        return "Filler Order";
471      case INSTANCEORDER:
472        return "Instance Order";
473      case OPTION:
474        return "Option";
475      case NULL:
476        return null;
477      default:
478        return "?";
479      }
480    }
481  }
482
483  public static class MedicationRequestIntentEnumFactory implements EnumFactory<MedicationRequestIntent> {
484    public MedicationRequestIntent fromCode(String codeString) throws IllegalArgumentException {
485      if (codeString == null || "".equals(codeString))
486        if (codeString == null || "".equals(codeString))
487          return null;
488      if ("proposal".equals(codeString))
489        return MedicationRequestIntent.PROPOSAL;
490      if ("plan".equals(codeString))
491        return MedicationRequestIntent.PLAN;
492      if ("order".equals(codeString))
493        return MedicationRequestIntent.ORDER;
494      if ("original-order".equals(codeString))
495        return MedicationRequestIntent.ORIGINALORDER;
496      if ("reflex-order".equals(codeString))
497        return MedicationRequestIntent.REFLEXORDER;
498      if ("filler-order".equals(codeString))
499        return MedicationRequestIntent.FILLERORDER;
500      if ("instance-order".equals(codeString))
501        return MedicationRequestIntent.INSTANCEORDER;
502      if ("option".equals(codeString))
503        return MedicationRequestIntent.OPTION;
504      throw new IllegalArgumentException("Unknown MedicationRequestIntent code '" + codeString + "'");
505    }
506
507    public Enumeration<MedicationRequestIntent> fromType(PrimitiveType<?> code) throws FHIRException {
508      if (code == null)
509        return null;
510      if (code.isEmpty())
511        return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.NULL, code);
512      String codeString = code.asStringValue();
513      if (codeString == null || "".equals(codeString))
514        return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.NULL, code);
515      if ("proposal".equals(codeString))
516        return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.PROPOSAL, code);
517      if ("plan".equals(codeString))
518        return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.PLAN, code);
519      if ("order".equals(codeString))
520        return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.ORDER, code);
521      if ("original-order".equals(codeString))
522        return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.ORIGINALORDER, code);
523      if ("reflex-order".equals(codeString))
524        return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.REFLEXORDER, code);
525      if ("filler-order".equals(codeString))
526        return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.FILLERORDER, code);
527      if ("instance-order".equals(codeString))
528        return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.INSTANCEORDER, code);
529      if ("option".equals(codeString))
530        return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.OPTION, code);
531      throw new FHIRException("Unknown MedicationRequestIntent code '" + codeString + "'");
532    }
533
534    public String toCode(MedicationRequestIntent code) {
535       if (code == MedicationRequestIntent.NULL)
536           return null;
537       if (code == MedicationRequestIntent.PROPOSAL)
538        return "proposal";
539      if (code == MedicationRequestIntent.PLAN)
540        return "plan";
541      if (code == MedicationRequestIntent.ORDER)
542        return "order";
543      if (code == MedicationRequestIntent.ORIGINALORDER)
544        return "original-order";
545      if (code == MedicationRequestIntent.REFLEXORDER)
546        return "reflex-order";
547      if (code == MedicationRequestIntent.FILLERORDER)
548        return "filler-order";
549      if (code == MedicationRequestIntent.INSTANCEORDER)
550        return "instance-order";
551      if (code == MedicationRequestIntent.OPTION)
552        return "option";
553      return "?";
554   }
555
556    public String toSystem(MedicationRequestIntent code) {
557      return code.getSystem();
558    }
559  }
560
561  public enum MedicationRequestPriority {
562    /**
563     * The request has normal priority.
564     */
565    ROUTINE,
566    /**
567     * The request should be actioned promptly - higher priority than routine.
568     */
569    URGENT,
570    /**
571     * The request should be actioned as soon as possible - higher priority than
572     * urgent.
573     */
574    ASAP,
575    /**
576     * The request should be actioned immediately - highest possible priority. E.g.
577     * an emergency.
578     */
579    STAT,
580    /**
581     * added to help the parsers with the generic types
582     */
583    NULL;
584
585    public static MedicationRequestPriority fromCode(String codeString) throws FHIRException {
586      if (codeString == null || "".equals(codeString))
587        return null;
588      if ("routine".equals(codeString))
589        return ROUTINE;
590      if ("urgent".equals(codeString))
591        return URGENT;
592      if ("asap".equals(codeString))
593        return ASAP;
594      if ("stat".equals(codeString))
595        return STAT;
596      if (Configuration.isAcceptInvalidEnums())
597        return null;
598      else
599        throw new FHIRException("Unknown MedicationRequestPriority code '" + codeString + "'");
600    }
601
602    public String toCode() {
603      switch (this) {
604      case ROUTINE:
605        return "routine";
606      case URGENT:
607        return "urgent";
608      case ASAP:
609        return "asap";
610      case STAT:
611        return "stat";
612      case NULL:
613        return null;
614      default:
615        return "?";
616      }
617    }
618
619    public String getSystem() {
620      switch (this) {
621      case ROUTINE:
622        return "http://hl7.org/fhir/request-priority";
623      case URGENT:
624        return "http://hl7.org/fhir/request-priority";
625      case ASAP:
626        return "http://hl7.org/fhir/request-priority";
627      case STAT:
628        return "http://hl7.org/fhir/request-priority";
629      case NULL:
630        return null;
631      default:
632        return "?";
633      }
634    }
635
636    public String getDefinition() {
637      switch (this) {
638      case ROUTINE:
639        return "The request has normal priority.";
640      case URGENT:
641        return "The request should be actioned promptly - higher priority than routine.";
642      case ASAP:
643        return "The request should be actioned as soon as possible - higher priority than urgent.";
644      case STAT:
645        return "The request should be actioned immediately - highest possible priority.  E.g. an emergency.";
646      case NULL:
647        return null;
648      default:
649        return "?";
650      }
651    }
652
653    public String getDisplay() {
654      switch (this) {
655      case ROUTINE:
656        return "Routine";
657      case URGENT:
658        return "Urgent";
659      case ASAP:
660        return "ASAP";
661      case STAT:
662        return "STAT";
663      case NULL:
664        return null;
665      default:
666        return "?";
667      }
668    }
669  }
670
671  public static class MedicationRequestPriorityEnumFactory implements EnumFactory<MedicationRequestPriority> {
672    public MedicationRequestPriority fromCode(String codeString) throws IllegalArgumentException {
673      if (codeString == null || "".equals(codeString))
674        if (codeString == null || "".equals(codeString))
675          return null;
676      if ("routine".equals(codeString))
677        return MedicationRequestPriority.ROUTINE;
678      if ("urgent".equals(codeString))
679        return MedicationRequestPriority.URGENT;
680      if ("asap".equals(codeString))
681        return MedicationRequestPriority.ASAP;
682      if ("stat".equals(codeString))
683        return MedicationRequestPriority.STAT;
684      throw new IllegalArgumentException("Unknown MedicationRequestPriority code '" + codeString + "'");
685    }
686
687    public Enumeration<MedicationRequestPriority> fromType(PrimitiveType<?> code) throws FHIRException {
688      if (code == null)
689        return null;
690      if (code.isEmpty())
691        return new Enumeration<MedicationRequestPriority>(this, MedicationRequestPriority.NULL, code);
692      String codeString = code.asStringValue();
693      if (codeString == null || "".equals(codeString))
694        return new Enumeration<MedicationRequestPriority>(this, MedicationRequestPriority.NULL, code);
695      if ("routine".equals(codeString))
696        return new Enumeration<MedicationRequestPriority>(this, MedicationRequestPriority.ROUTINE, code);
697      if ("urgent".equals(codeString))
698        return new Enumeration<MedicationRequestPriority>(this, MedicationRequestPriority.URGENT, code);
699      if ("asap".equals(codeString))
700        return new Enumeration<MedicationRequestPriority>(this, MedicationRequestPriority.ASAP, code);
701      if ("stat".equals(codeString))
702        return new Enumeration<MedicationRequestPriority>(this, MedicationRequestPriority.STAT, code);
703      throw new FHIRException("Unknown MedicationRequestPriority code '" + codeString + "'");
704    }
705
706    public String toCode(MedicationRequestPriority code) {
707       if (code == MedicationRequestPriority.NULL)
708           return null;
709       if (code == MedicationRequestPriority.ROUTINE)
710        return "routine";
711      if (code == MedicationRequestPriority.URGENT)
712        return "urgent";
713      if (code == MedicationRequestPriority.ASAP)
714        return "asap";
715      if (code == MedicationRequestPriority.STAT)
716        return "stat";
717      return "?";
718   }
719
720    public String toSystem(MedicationRequestPriority code) {
721      return code.getSystem();
722    }
723  }
724
725  @Block()
726  public static class MedicationRequestDispenseRequestComponent extends BackboneElement
727      implements IBaseBackboneElement {
728    /**
729     * Indicates the quantity or duration for the first dispense of the medication.
730     */
731    @Child(name = "initialFill", type = {}, order = 1, min = 0, max = 1, modifier = false, summary = false)
732    @Description(shortDefinition = "First fill details", formalDefinition = "Indicates the quantity or duration for the first dispense of the medication.")
733    protected MedicationRequestDispenseRequestInitialFillComponent initialFill;
734
735    /**
736     * The minimum period of time that must occur between dispenses of the
737     * medication.
738     */
739    @Child(name = "dispenseInterval", type = {
740        Duration.class }, order = 2, min = 0, max = 1, modifier = false, summary = false)
741    @Description(shortDefinition = "Minimum period of time between dispenses", formalDefinition = "The minimum period of time that must occur between dispenses of the medication.")
742    protected Duration dispenseInterval;
743
744    /**
745     * This indicates the validity period of a prescription (stale dating the
746     * Prescription).
747     */
748    @Child(name = "validityPeriod", type = {
749        Period.class }, order = 3, min = 0, max = 1, modifier = false, summary = false)
750    @Description(shortDefinition = "Time period supply is authorized for", formalDefinition = "This indicates the validity period of a prescription (stale dating the Prescription).")
751    protected Period validityPeriod;
752
753    /**
754     * An integer indicating the number of times, in addition to the original
755     * dispense, (aka refills or repeats) that the patient can receive the
756     * prescribed medication. Usage Notes: This integer does not include the
757     * original order dispense. This means that if an order indicates dispense 30
758     * tablets plus "3 repeats", then the order can be dispensed a total of 4 times
759     * and the patient can receive a total of 120 tablets. A prescriber may
760     * explicitly say that zero refills are permitted after the initial dispense.
761     */
762    @Child(name = "numberOfRepeatsAllowed", type = {
763        UnsignedIntType.class }, order = 4, min = 0, max = 1, modifier = false, summary = false)
764    @Description(shortDefinition = "Number of refills authorized", formalDefinition = "An integer indicating the number of times, in addition to the original dispense, (aka refills or repeats) that the patient can receive the prescribed medication. Usage Notes: This integer does not include the original order dispense. This means that if an order indicates dispense 30 tablets plus \"3 repeats\", then the order can be dispensed a total of 4 times and the patient can receive a total of 120 tablets.  A prescriber may explicitly say that zero refills are permitted after the initial dispense.")
765    protected UnsignedIntType numberOfRepeatsAllowed;
766
767    /**
768     * The amount that is to be dispensed for one fill.
769     */
770    @Child(name = "quantity", type = { Quantity.class }, order = 5, min = 0, max = 1, modifier = false, summary = false)
771    @Description(shortDefinition = "Amount of medication to supply per dispense", formalDefinition = "The amount that is to be dispensed for one fill.")
772    protected Quantity quantity;
773
774    /**
775     * Identifies the period time over which the supplied product is expected to be
776     * used, or the length of time the dispense is expected to last.
777     */
778    @Child(name = "expectedSupplyDuration", type = {
779        Duration.class }, order = 6, min = 0, max = 1, modifier = false, summary = false)
780    @Description(shortDefinition = "Number of days supply per dispense", formalDefinition = "Identifies the period time over which the supplied product is expected to be used, or the length of time the dispense is expected to last.")
781    protected Duration expectedSupplyDuration;
782
783    /**
784     * Indicates the intended dispensing Organization specified by the prescriber.
785     */
786    @Child(name = "performer", type = {
787        Organization.class }, order = 7, min = 0, max = 1, modifier = false, summary = false)
788    @Description(shortDefinition = "Intended dispenser", formalDefinition = "Indicates the intended dispensing Organization specified by the prescriber.")
789    protected Reference performer;
790
791    /**
792     * The actual object that is the target of the reference (Indicates the intended
793     * dispensing Organization specified by the prescriber.)
794     */
795    protected Organization performerTarget;
796
797    private static final long serialVersionUID = -1680129929L;
798
799    /**
800     * Constructor
801     */
802    public MedicationRequestDispenseRequestComponent() {
803      super();
804    }
805
806    /**
807     * @return {@link #initialFill} (Indicates the quantity or duration for the
808     *         first dispense of the medication.)
809     */
810    public MedicationRequestDispenseRequestInitialFillComponent getInitialFill() {
811      if (this.initialFill == null)
812        if (Configuration.errorOnAutoCreate())
813          throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.initialFill");
814        else if (Configuration.doAutoCreate())
815          this.initialFill = new MedicationRequestDispenseRequestInitialFillComponent(); // cc
816      return this.initialFill;
817    }
818
819    public boolean hasInitialFill() {
820      return this.initialFill != null && !this.initialFill.isEmpty();
821    }
822
823    /**
824     * @param value {@link #initialFill} (Indicates the quantity or duration for the
825     *              first dispense of the medication.)
826     */
827    public MedicationRequestDispenseRequestComponent setInitialFill(
828        MedicationRequestDispenseRequestInitialFillComponent value) {
829      this.initialFill = value;
830      return this;
831    }
832
833    /**
834     * @return {@link #dispenseInterval} (The minimum period of time that must occur
835     *         between dispenses of the medication.)
836     */
837    public Duration getDispenseInterval() {
838      if (this.dispenseInterval == null)
839        if (Configuration.errorOnAutoCreate())
840          throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.dispenseInterval");
841        else if (Configuration.doAutoCreate())
842          this.dispenseInterval = new Duration(); // cc
843      return this.dispenseInterval;
844    }
845
846    public boolean hasDispenseInterval() {
847      return this.dispenseInterval != null && !this.dispenseInterval.isEmpty();
848    }
849
850    /**
851     * @param value {@link #dispenseInterval} (The minimum period of time that must
852     *              occur between dispenses of the medication.)
853     */
854    public MedicationRequestDispenseRequestComponent setDispenseInterval(Duration value) {
855      this.dispenseInterval = value;
856      return this;
857    }
858
859    /**
860     * @return {@link #validityPeriod} (This indicates the validity period of a
861     *         prescription (stale dating the Prescription).)
862     */
863    public Period getValidityPeriod() {
864      if (this.validityPeriod == null)
865        if (Configuration.errorOnAutoCreate())
866          throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.validityPeriod");
867        else if (Configuration.doAutoCreate())
868          this.validityPeriod = new Period(); // cc
869      return this.validityPeriod;
870    }
871
872    public boolean hasValidityPeriod() {
873      return this.validityPeriod != null && !this.validityPeriod.isEmpty();
874    }
875
876    /**
877     * @param value {@link #validityPeriod} (This indicates the validity period of a
878     *              prescription (stale dating the Prescription).)
879     */
880    public MedicationRequestDispenseRequestComponent setValidityPeriod(Period value) {
881      this.validityPeriod = value;
882      return this;
883    }
884
885    /**
886     * @return {@link #numberOfRepeatsAllowed} (An integer indicating the number of
887     *         times, in addition to the original dispense, (aka refills or repeats)
888     *         that the patient can receive the prescribed medication. Usage Notes:
889     *         This integer does not include the original order dispense. This means
890     *         that if an order indicates dispense 30 tablets plus "3 repeats", then
891     *         the order can be dispensed a total of 4 times and the patient can
892     *         receive a total of 120 tablets. A prescriber may explicitly say that
893     *         zero refills are permitted after the initial dispense.). This is the
894     *         underlying object with id, value and extensions. The accessor
895     *         "getNumberOfRepeatsAllowed" gives direct access to the value
896     */
897    public UnsignedIntType getNumberOfRepeatsAllowedElement() {
898      if (this.numberOfRepeatsAllowed == null)
899        if (Configuration.errorOnAutoCreate())
900          throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.numberOfRepeatsAllowed");
901        else if (Configuration.doAutoCreate())
902          this.numberOfRepeatsAllowed = new UnsignedIntType(); // bb
903      return this.numberOfRepeatsAllowed;
904    }
905
906    public boolean hasNumberOfRepeatsAllowedElement() {
907      return this.numberOfRepeatsAllowed != null && !this.numberOfRepeatsAllowed.isEmpty();
908    }
909
910    public boolean hasNumberOfRepeatsAllowed() {
911      return this.numberOfRepeatsAllowed != null && !this.numberOfRepeatsAllowed.isEmpty();
912    }
913
914    /**
915     * @param value {@link #numberOfRepeatsAllowed} (An integer indicating the
916     *              number of times, in addition to the original dispense, (aka
917     *              refills or repeats) that the patient can receive the prescribed
918     *              medication. Usage Notes: This integer does not include the
919     *              original order dispense. This means that if an order indicates
920     *              dispense 30 tablets plus "3 repeats", then the order can be
921     *              dispensed a total of 4 times and the patient can receive a total
922     *              of 120 tablets. A prescriber may explicitly say that zero
923     *              refills are permitted after the initial dispense.). This is the
924     *              underlying object with id, value and extensions. The accessor
925     *              "getNumberOfRepeatsAllowed" gives direct access to the value
926     */
927    public MedicationRequestDispenseRequestComponent setNumberOfRepeatsAllowedElement(UnsignedIntType value) {
928      this.numberOfRepeatsAllowed = value;
929      return this;
930    }
931
932    /**
933     * @return An integer indicating the number of times, in addition to the
934     *         original dispense, (aka refills or repeats) that the patient can
935     *         receive the prescribed medication. Usage Notes: This integer does not
936     *         include the original order dispense. This means that if an order
937     *         indicates dispense 30 tablets plus "3 repeats", then the order can be
938     *         dispensed a total of 4 times and the patient can receive a total of
939     *         120 tablets. A prescriber may explicitly say that zero refills are
940     *         permitted after the initial dispense.
941     */
942    public int getNumberOfRepeatsAllowed() {
943      return this.numberOfRepeatsAllowed == null || this.numberOfRepeatsAllowed.isEmpty() ? 0
944          : this.numberOfRepeatsAllowed.getValue();
945    }
946
947    /**
948     * @param value An integer indicating the number of times, in addition to the
949     *              original dispense, (aka refills or repeats) that the patient can
950     *              receive the prescribed medication. Usage Notes: This integer
951     *              does not include the original order dispense. This means that if
952     *              an order indicates dispense 30 tablets plus "3 repeats", then
953     *              the order can be dispensed a total of 4 times and the patient
954     *              can receive a total of 120 tablets. A prescriber may explicitly
955     *              say that zero refills are permitted after the initial dispense.
956     */
957    public MedicationRequestDispenseRequestComponent setNumberOfRepeatsAllowed(int value) {
958      if (this.numberOfRepeatsAllowed == null)
959        this.numberOfRepeatsAllowed = new UnsignedIntType();
960      this.numberOfRepeatsAllowed.setValue(value);
961      return this;
962    }
963
964    /**
965     * @return {@link #quantity} (The amount that is to be dispensed for one fill.)
966     */
967    public Quantity getQuantity() {
968      if (this.quantity == null)
969        if (Configuration.errorOnAutoCreate())
970          throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.quantity");
971        else if (Configuration.doAutoCreate())
972          this.quantity = new Quantity(); // cc
973      return this.quantity;
974    }
975
976    public boolean hasQuantity() {
977      return this.quantity != null && !this.quantity.isEmpty();
978    }
979
980    /**
981     * @param value {@link #quantity} (The amount that is to be dispensed for one
982     *              fill.)
983     */
984    public MedicationRequestDispenseRequestComponent setQuantity(Quantity value) {
985      this.quantity = value;
986      return this;
987    }
988
989    /**
990     * @return {@link #expectedSupplyDuration} (Identifies the period time over
991     *         which the supplied product is expected to be used, or the length of
992     *         time the dispense is expected to last.)
993     */
994    public Duration getExpectedSupplyDuration() {
995      if (this.expectedSupplyDuration == null)
996        if (Configuration.errorOnAutoCreate())
997          throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.expectedSupplyDuration");
998        else if (Configuration.doAutoCreate())
999          this.expectedSupplyDuration = new Duration(); // cc
1000      return this.expectedSupplyDuration;
1001    }
1002
1003    public boolean hasExpectedSupplyDuration() {
1004      return this.expectedSupplyDuration != null && !this.expectedSupplyDuration.isEmpty();
1005    }
1006
1007    /**
1008     * @param value {@link #expectedSupplyDuration} (Identifies the period time over
1009     *              which the supplied product is expected to be used, or the length
1010     *              of time the dispense is expected to last.)
1011     */
1012    public MedicationRequestDispenseRequestComponent setExpectedSupplyDuration(Duration value) {
1013      this.expectedSupplyDuration = value;
1014      return this;
1015    }
1016
1017    /**
1018     * @return {@link #performer} (Indicates the intended dispensing Organization
1019     *         specified by the prescriber.)
1020     */
1021    public Reference getPerformer() {
1022      if (this.performer == null)
1023        if (Configuration.errorOnAutoCreate())
1024          throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.performer");
1025        else if (Configuration.doAutoCreate())
1026          this.performer = new Reference(); // cc
1027      return this.performer;
1028    }
1029
1030    public boolean hasPerformer() {
1031      return this.performer != null && !this.performer.isEmpty();
1032    }
1033
1034    /**
1035     * @param value {@link #performer} (Indicates the intended dispensing
1036     *              Organization specified by the prescriber.)
1037     */
1038    public MedicationRequestDispenseRequestComponent setPerformer(Reference value) {
1039      this.performer = value;
1040      return this;
1041    }
1042
1043    /**
1044     * @return {@link #performer} The actual object that is the target of the
1045     *         reference. The reference library doesn't populate this, but you can
1046     *         use it to hold the resource if you resolve it. (Indicates the
1047     *         intended dispensing Organization specified by the prescriber.)
1048     */
1049    public Organization getPerformerTarget() {
1050      if (this.performerTarget == null)
1051        if (Configuration.errorOnAutoCreate())
1052          throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.performer");
1053        else if (Configuration.doAutoCreate())
1054          this.performerTarget = new Organization(); // aa
1055      return this.performerTarget;
1056    }
1057
1058    /**
1059     * @param value {@link #performer} The actual object that is the target of the
1060     *              reference. The reference library doesn't use these, but you can
1061     *              use it to hold the resource if you resolve it. (Indicates the
1062     *              intended dispensing Organization specified by the prescriber.)
1063     */
1064    public MedicationRequestDispenseRequestComponent setPerformerTarget(Organization value) {
1065      this.performerTarget = value;
1066      return this;
1067    }
1068
1069    protected void listChildren(List<Property> children) {
1070      super.listChildren(children);
1071      children.add(new Property("initialFill", "",
1072          "Indicates the quantity or duration for the first dispense of the medication.", 0, 1, initialFill));
1073      children.add(new Property("dispenseInterval", "Duration",
1074          "The minimum period of time that must occur between dispenses of the medication.", 0, 1, dispenseInterval));
1075      children.add(new Property("validityPeriod", "Period",
1076          "This indicates the validity period of a prescription (stale dating the Prescription).", 0, 1,
1077          validityPeriod));
1078      children.add(new Property("numberOfRepeatsAllowed", "unsignedInt",
1079          "An integer indicating the number of times, in addition to the original dispense, (aka refills or repeats) that the patient can receive the prescribed medication. Usage Notes: This integer does not include the original order dispense. This means that if an order indicates dispense 30 tablets plus \"3 repeats\", then the order can be dispensed a total of 4 times and the patient can receive a total of 120 tablets.  A prescriber may explicitly say that zero refills are permitted after the initial dispense.",
1080          0, 1, numberOfRepeatsAllowed));
1081      children.add(new Property("quantity", "SimpleQuantity", "The amount that is to be dispensed for one fill.", 0, 1,
1082          quantity));
1083      children.add(new Property("expectedSupplyDuration", "Duration",
1084          "Identifies the period time over which the supplied product is expected to be used, or the length of time the dispense is expected to last.",
1085          0, 1, expectedSupplyDuration));
1086      children.add(new Property("performer", "Reference(Organization)",
1087          "Indicates the intended dispensing Organization specified by the prescriber.", 0, 1, performer));
1088    }
1089
1090    @Override
1091    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1092      switch (_hash) {
1093      case 1232961255:
1094        /* initialFill */ return new Property("initialFill", "",
1095            "Indicates the quantity or duration for the first dispense of the medication.", 0, 1, initialFill);
1096      case 757112130:
1097        /* dispenseInterval */ return new Property("dispenseInterval", "Duration",
1098            "The minimum period of time that must occur between dispenses of the medication.", 0, 1, dispenseInterval);
1099      case -1434195053:
1100        /* validityPeriod */ return new Property("validityPeriod", "Period",
1101            "This indicates the validity period of a prescription (stale dating the Prescription).", 0, 1,
1102            validityPeriod);
1103      case -239736976:
1104        /* numberOfRepeatsAllowed */ return new Property("numberOfRepeatsAllowed", "unsignedInt",
1105            "An integer indicating the number of times, in addition to the original dispense, (aka refills or repeats) that the patient can receive the prescribed medication. Usage Notes: This integer does not include the original order dispense. This means that if an order indicates dispense 30 tablets plus \"3 repeats\", then the order can be dispensed a total of 4 times and the patient can receive a total of 120 tablets.  A prescriber may explicitly say that zero refills are permitted after the initial dispense.",
1106            0, 1, numberOfRepeatsAllowed);
1107      case -1285004149:
1108        /* quantity */ return new Property("quantity", "SimpleQuantity",
1109            "The amount that is to be dispensed for one fill.", 0, 1, quantity);
1110      case -1910182789:
1111        /* expectedSupplyDuration */ return new Property("expectedSupplyDuration", "Duration",
1112            "Identifies the period time over which the supplied product is expected to be used, or the length of time the dispense is expected to last.",
1113            0, 1, expectedSupplyDuration);
1114      case 481140686:
1115        /* performer */ return new Property("performer", "Reference(Organization)",
1116            "Indicates the intended dispensing Organization specified by the prescriber.", 0, 1, performer);
1117      default:
1118        return super.getNamedProperty(_hash, _name, _checkValid);
1119      }
1120
1121    }
1122
1123    @Override
1124    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1125      switch (hash) {
1126      case 1232961255:
1127        /* initialFill */ return this.initialFill == null ? new Base[0] : new Base[] { this.initialFill }; // MedicationRequestDispenseRequestInitialFillComponent
1128      case 757112130:
1129        /* dispenseInterval */ return this.dispenseInterval == null ? new Base[0]
1130            : new Base[] { this.dispenseInterval }; // Duration
1131      case -1434195053:
1132        /* validityPeriod */ return this.validityPeriod == null ? new Base[0] : new Base[] { this.validityPeriod }; // Period
1133      case -239736976:
1134        /* numberOfRepeatsAllowed */ return this.numberOfRepeatsAllowed == null ? new Base[0]
1135            : new Base[] { this.numberOfRepeatsAllowed }; // UnsignedIntType
1136      case -1285004149:
1137        /* quantity */ return this.quantity == null ? new Base[0] : new Base[] { this.quantity }; // Quantity
1138      case -1910182789:
1139        /* expectedSupplyDuration */ return this.expectedSupplyDuration == null ? new Base[0]
1140            : new Base[] { this.expectedSupplyDuration }; // Duration
1141      case 481140686:
1142        /* performer */ return this.performer == null ? new Base[0] : new Base[] { this.performer }; // Reference
1143      default:
1144        return super.getProperty(hash, name, checkValid);
1145      }
1146
1147    }
1148
1149    @Override
1150    public Base setProperty(int hash, String name, Base value) throws FHIRException {
1151      switch (hash) {
1152      case 1232961255: // initialFill
1153        this.initialFill = (MedicationRequestDispenseRequestInitialFillComponent) value; // MedicationRequestDispenseRequestInitialFillComponent
1154        return value;
1155      case 757112130: // dispenseInterval
1156        this.dispenseInterval = castToDuration(value); // Duration
1157        return value;
1158      case -1434195053: // validityPeriod
1159        this.validityPeriod = castToPeriod(value); // Period
1160        return value;
1161      case -239736976: // numberOfRepeatsAllowed
1162        this.numberOfRepeatsAllowed = castToUnsignedInt(value); // UnsignedIntType
1163        return value;
1164      case -1285004149: // quantity
1165        this.quantity = castToQuantity(value); // Quantity
1166        return value;
1167      case -1910182789: // expectedSupplyDuration
1168        this.expectedSupplyDuration = castToDuration(value); // Duration
1169        return value;
1170      case 481140686: // performer
1171        this.performer = castToReference(value); // Reference
1172        return value;
1173      default:
1174        return super.setProperty(hash, name, value);
1175      }
1176
1177    }
1178
1179    @Override
1180    public Base setProperty(String name, Base value) throws FHIRException {
1181      if (name.equals("initialFill")) {
1182        this.initialFill = (MedicationRequestDispenseRequestInitialFillComponent) value; // MedicationRequestDispenseRequestInitialFillComponent
1183      } else if (name.equals("dispenseInterval")) {
1184        this.dispenseInterval = castToDuration(value); // Duration
1185      } else if (name.equals("validityPeriod")) {
1186        this.validityPeriod = castToPeriod(value); // Period
1187      } else if (name.equals("numberOfRepeatsAllowed")) {
1188        this.numberOfRepeatsAllowed = castToUnsignedInt(value); // UnsignedIntType
1189      } else if (name.equals("quantity")) {
1190        this.quantity = castToQuantity(value); // Quantity
1191      } else if (name.equals("expectedSupplyDuration")) {
1192        this.expectedSupplyDuration = castToDuration(value); // Duration
1193      } else if (name.equals("performer")) {
1194        this.performer = castToReference(value); // Reference
1195      } else
1196        return super.setProperty(name, value);
1197      return value;
1198    }
1199
1200  @Override
1201  public void removeChild(String name, Base value) throws FHIRException {
1202      if (name.equals("initialFill")) {
1203        this.initialFill = (MedicationRequestDispenseRequestInitialFillComponent) value; // MedicationRequestDispenseRequestInitialFillComponent
1204      } else if (name.equals("dispenseInterval")) {
1205        this.dispenseInterval = null;
1206      } else if (name.equals("validityPeriod")) {
1207        this.validityPeriod = null;
1208      } else if (name.equals("numberOfRepeatsAllowed")) {
1209        this.numberOfRepeatsAllowed = null;
1210      } else if (name.equals("quantity")) {
1211        this.quantity = null;
1212      } else if (name.equals("expectedSupplyDuration")) {
1213        this.expectedSupplyDuration = null;
1214      } else if (name.equals("performer")) {
1215        this.performer = null;
1216      } else
1217        super.removeChild(name, value);
1218      
1219    }
1220
1221    @Override
1222    public Base makeProperty(int hash, String name) throws FHIRException {
1223      switch (hash) {
1224      case 1232961255:
1225        return getInitialFill();
1226      case 757112130:
1227        return getDispenseInterval();
1228      case -1434195053:
1229        return getValidityPeriod();
1230      case -239736976:
1231        return getNumberOfRepeatsAllowedElement();
1232      case -1285004149:
1233        return getQuantity();
1234      case -1910182789:
1235        return getExpectedSupplyDuration();
1236      case 481140686:
1237        return getPerformer();
1238      default:
1239        return super.makeProperty(hash, name);
1240      }
1241
1242    }
1243
1244    @Override
1245    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1246      switch (hash) {
1247      case 1232961255:
1248        /* initialFill */ return new String[] {};
1249      case 757112130:
1250        /* dispenseInterval */ return new String[] { "Duration" };
1251      case -1434195053:
1252        /* validityPeriod */ return new String[] { "Period" };
1253      case -239736976:
1254        /* numberOfRepeatsAllowed */ return new String[] { "unsignedInt" };
1255      case -1285004149:
1256        /* quantity */ return new String[] { "SimpleQuantity" };
1257      case -1910182789:
1258        /* expectedSupplyDuration */ return new String[] { "Duration" };
1259      case 481140686:
1260        /* performer */ return new String[] { "Reference" };
1261      default:
1262        return super.getTypesForProperty(hash, name);
1263      }
1264
1265    }
1266
1267    @Override
1268    public Base addChild(String name) throws FHIRException {
1269      if (name.equals("initialFill")) {
1270        this.initialFill = new MedicationRequestDispenseRequestInitialFillComponent();
1271        return this.initialFill;
1272      } else if (name.equals("dispenseInterval")) {
1273        this.dispenseInterval = new Duration();
1274        return this.dispenseInterval;
1275      } else if (name.equals("validityPeriod")) {
1276        this.validityPeriod = new Period();
1277        return this.validityPeriod;
1278      } else if (name.equals("numberOfRepeatsAllowed")) {
1279        throw new FHIRException("Cannot call addChild on a singleton property MedicationRequest.numberOfRepeatsAllowed");
1280      } else if (name.equals("quantity")) {
1281        this.quantity = new Quantity();
1282        return this.quantity;
1283      } else if (name.equals("expectedSupplyDuration")) {
1284        this.expectedSupplyDuration = new Duration();
1285        return this.expectedSupplyDuration;
1286      } else if (name.equals("performer")) {
1287        this.performer = new Reference();
1288        return this.performer;
1289      } else
1290        return super.addChild(name);
1291    }
1292
1293    public MedicationRequestDispenseRequestComponent copy() {
1294      MedicationRequestDispenseRequestComponent dst = new MedicationRequestDispenseRequestComponent();
1295      copyValues(dst);
1296      return dst;
1297    }
1298
1299    public void copyValues(MedicationRequestDispenseRequestComponent dst) {
1300      super.copyValues(dst);
1301      dst.initialFill = initialFill == null ? null : initialFill.copy();
1302      dst.dispenseInterval = dispenseInterval == null ? null : dispenseInterval.copy();
1303      dst.validityPeriod = validityPeriod == null ? null : validityPeriod.copy();
1304      dst.numberOfRepeatsAllowed = numberOfRepeatsAllowed == null ? null : numberOfRepeatsAllowed.copy();
1305      dst.quantity = quantity == null ? null : quantity.copy();
1306      dst.expectedSupplyDuration = expectedSupplyDuration == null ? null : expectedSupplyDuration.copy();
1307      dst.performer = performer == null ? null : performer.copy();
1308    }
1309
1310    @Override
1311    public boolean equalsDeep(Base other_) {
1312      if (!super.equalsDeep(other_))
1313        return false;
1314      if (!(other_ instanceof MedicationRequestDispenseRequestComponent))
1315        return false;
1316      MedicationRequestDispenseRequestComponent o = (MedicationRequestDispenseRequestComponent) other_;
1317      return compareDeep(initialFill, o.initialFill, true) && compareDeep(dispenseInterval, o.dispenseInterval, true)
1318          && compareDeep(validityPeriod, o.validityPeriod, true)
1319          && compareDeep(numberOfRepeatsAllowed, o.numberOfRepeatsAllowed, true)
1320          && compareDeep(quantity, o.quantity, true)
1321          && compareDeep(expectedSupplyDuration, o.expectedSupplyDuration, true)
1322          && compareDeep(performer, o.performer, true);
1323    }
1324
1325    @Override
1326    public boolean equalsShallow(Base other_) {
1327      if (!super.equalsShallow(other_))
1328        return false;
1329      if (!(other_ instanceof MedicationRequestDispenseRequestComponent))
1330        return false;
1331      MedicationRequestDispenseRequestComponent o = (MedicationRequestDispenseRequestComponent) other_;
1332      return compareValues(numberOfRepeatsAllowed, o.numberOfRepeatsAllowed, true);
1333    }
1334
1335    public boolean isEmpty() {
1336      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(initialFill, dispenseInterval, validityPeriod,
1337          numberOfRepeatsAllowed, quantity, expectedSupplyDuration, performer);
1338    }
1339
1340    public String fhirType() {
1341      return "MedicationRequest.dispenseRequest";
1342
1343    }
1344
1345  }
1346
1347  @Block()
1348  public static class MedicationRequestDispenseRequestInitialFillComponent extends BackboneElement
1349      implements IBaseBackboneElement {
1350    /**
1351     * The amount or quantity to provide as part of the first dispense.
1352     */
1353    @Child(name = "quantity", type = { Quantity.class }, order = 1, min = 0, max = 1, modifier = false, summary = false)
1354    @Description(shortDefinition = "First fill quantity", formalDefinition = "The amount or quantity to provide as part of the first dispense.")
1355    protected Quantity quantity;
1356
1357    /**
1358     * The length of time that the first dispense is expected to last.
1359     */
1360    @Child(name = "duration", type = { Duration.class }, order = 2, min = 0, max = 1, modifier = false, summary = false)
1361    @Description(shortDefinition = "First fill duration", formalDefinition = "The length of time that the first dispense is expected to last.")
1362    protected Duration duration;
1363
1364    private static final long serialVersionUID = 1223227956L;
1365
1366    /**
1367     * Constructor
1368     */
1369    public MedicationRequestDispenseRequestInitialFillComponent() {
1370      super();
1371    }
1372
1373    /**
1374     * @return {@link #quantity} (The amount or quantity to provide as part of the
1375     *         first dispense.)
1376     */
1377    public Quantity getQuantity() {
1378      if (this.quantity == null)
1379        if (Configuration.errorOnAutoCreate())
1380          throw new Error("Attempt to auto-create MedicationRequestDispenseRequestInitialFillComponent.quantity");
1381        else if (Configuration.doAutoCreate())
1382          this.quantity = new Quantity(); // cc
1383      return this.quantity;
1384    }
1385
1386    public boolean hasQuantity() {
1387      return this.quantity != null && !this.quantity.isEmpty();
1388    }
1389
1390    /**
1391     * @param value {@link #quantity} (The amount or quantity to provide as part of
1392     *              the first dispense.)
1393     */
1394    public MedicationRequestDispenseRequestInitialFillComponent setQuantity(Quantity value) {
1395      this.quantity = value;
1396      return this;
1397    }
1398
1399    /**
1400     * @return {@link #duration} (The length of time that the first dispense is
1401     *         expected to last.)
1402     */
1403    public Duration getDuration() {
1404      if (this.duration == null)
1405        if (Configuration.errorOnAutoCreate())
1406          throw new Error("Attempt to auto-create MedicationRequestDispenseRequestInitialFillComponent.duration");
1407        else if (Configuration.doAutoCreate())
1408          this.duration = new Duration(); // cc
1409      return this.duration;
1410    }
1411
1412    public boolean hasDuration() {
1413      return this.duration != null && !this.duration.isEmpty();
1414    }
1415
1416    /**
1417     * @param value {@link #duration} (The length of time that the first dispense is
1418     *              expected to last.)
1419     */
1420    public MedicationRequestDispenseRequestInitialFillComponent setDuration(Duration value) {
1421      this.duration = value;
1422      return this;
1423    }
1424
1425    protected void listChildren(List<Property> children) {
1426      super.listChildren(children);
1427      children.add(new Property("quantity", "SimpleQuantity",
1428          "The amount or quantity to provide as part of the first dispense.", 0, 1, quantity));
1429      children.add(new Property("duration", "Duration",
1430          "The length of time that the first dispense is expected to last.", 0, 1, duration));
1431    }
1432
1433    @Override
1434    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1435      switch (_hash) {
1436      case -1285004149:
1437        /* quantity */ return new Property("quantity", "SimpleQuantity",
1438            "The amount or quantity to provide as part of the first dispense.", 0, 1, quantity);
1439      case -1992012396:
1440        /* duration */ return new Property("duration", "Duration",
1441            "The length of time that the first dispense is expected to last.", 0, 1, duration);
1442      default:
1443        return super.getNamedProperty(_hash, _name, _checkValid);
1444      }
1445
1446    }
1447
1448    @Override
1449    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1450      switch (hash) {
1451      case -1285004149:
1452        /* quantity */ return this.quantity == null ? new Base[0] : new Base[] { this.quantity }; // Quantity
1453      case -1992012396:
1454        /* duration */ return this.duration == null ? new Base[0] : new Base[] { this.duration }; // Duration
1455      default:
1456        return super.getProperty(hash, name, checkValid);
1457      }
1458
1459    }
1460
1461    @Override
1462    public Base setProperty(int hash, String name, Base value) throws FHIRException {
1463      switch (hash) {
1464      case -1285004149: // quantity
1465        this.quantity = castToQuantity(value); // Quantity
1466        return value;
1467      case -1992012396: // duration
1468        this.duration = castToDuration(value); // Duration
1469        return value;
1470      default:
1471        return super.setProperty(hash, name, value);
1472      }
1473
1474    }
1475
1476    @Override
1477    public Base setProperty(String name, Base value) throws FHIRException {
1478      if (name.equals("quantity")) {
1479        this.quantity = castToQuantity(value); // Quantity
1480      } else if (name.equals("duration")) {
1481        this.duration = castToDuration(value); // Duration
1482      } else
1483        return super.setProperty(name, value);
1484      return value;
1485    }
1486
1487  @Override
1488  public void removeChild(String name, Base value) throws FHIRException {
1489      if (name.equals("quantity")) {
1490        this.quantity = null;
1491      } else if (name.equals("duration")) {
1492        this.duration = null;
1493      } else
1494        super.removeChild(name, value);
1495      
1496    }
1497
1498    @Override
1499    public Base makeProperty(int hash, String name) throws FHIRException {
1500      switch (hash) {
1501      case -1285004149:
1502        return getQuantity();
1503      case -1992012396:
1504        return getDuration();
1505      default:
1506        return super.makeProperty(hash, name);
1507      }
1508
1509    }
1510
1511    @Override
1512    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1513      switch (hash) {
1514      case -1285004149:
1515        /* quantity */ return new String[] { "SimpleQuantity" };
1516      case -1992012396:
1517        /* duration */ return new String[] { "Duration" };
1518      default:
1519        return super.getTypesForProperty(hash, name);
1520      }
1521
1522    }
1523
1524    @Override
1525    public Base addChild(String name) throws FHIRException {
1526      if (name.equals("quantity")) {
1527        this.quantity = new Quantity();
1528        return this.quantity;
1529      } else if (name.equals("duration")) {
1530        this.duration = new Duration();
1531        return this.duration;
1532      } else
1533        return super.addChild(name);
1534    }
1535
1536    public MedicationRequestDispenseRequestInitialFillComponent copy() {
1537      MedicationRequestDispenseRequestInitialFillComponent dst = new MedicationRequestDispenseRequestInitialFillComponent();
1538      copyValues(dst);
1539      return dst;
1540    }
1541
1542    public void copyValues(MedicationRequestDispenseRequestInitialFillComponent dst) {
1543      super.copyValues(dst);
1544      dst.quantity = quantity == null ? null : quantity.copy();
1545      dst.duration = duration == null ? null : duration.copy();
1546    }
1547
1548    @Override
1549    public boolean equalsDeep(Base other_) {
1550      if (!super.equalsDeep(other_))
1551        return false;
1552      if (!(other_ instanceof MedicationRequestDispenseRequestInitialFillComponent))
1553        return false;
1554      MedicationRequestDispenseRequestInitialFillComponent o = (MedicationRequestDispenseRequestInitialFillComponent) other_;
1555      return compareDeep(quantity, o.quantity, true) && compareDeep(duration, o.duration, true);
1556    }
1557
1558    @Override
1559    public boolean equalsShallow(Base other_) {
1560      if (!super.equalsShallow(other_))
1561        return false;
1562      if (!(other_ instanceof MedicationRequestDispenseRequestInitialFillComponent))
1563        return false;
1564      MedicationRequestDispenseRequestInitialFillComponent o = (MedicationRequestDispenseRequestInitialFillComponent) other_;
1565      return true;
1566    }
1567
1568    public boolean isEmpty() {
1569      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(quantity, duration);
1570    }
1571
1572    public String fhirType() {
1573      return "MedicationRequest.dispenseRequest.initialFill";
1574
1575    }
1576
1577  }
1578
1579  @Block()
1580  public static class MedicationRequestSubstitutionComponent extends BackboneElement implements IBaseBackboneElement {
1581    /**
1582     * True if the prescriber allows a different drug to be dispensed from what was
1583     * prescribed.
1584     */
1585    @Child(name = "allowed", type = { BooleanType.class,
1586        CodeableConcept.class }, order = 1, min = 1, max = 1, modifier = false, summary = false)
1587    @Description(shortDefinition = "Whether substitution is allowed or not", formalDefinition = "True if the prescriber allows a different drug to be dispensed from what was prescribed.")
1588    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://terminology.hl7.org/ValueSet/v3-ActSubstanceAdminSubstitutionCode")
1589    protected Type allowed;
1590
1591    /**
1592     * Indicates the reason for the substitution, or why substitution must or must
1593     * not be performed.
1594     */
1595    @Child(name = "reason", type = {
1596        CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = false)
1597    @Description(shortDefinition = "Why should (not) substitution be made", formalDefinition = "Indicates the reason for the substitution, or why substitution must or must not be performed.")
1598    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://terminology.hl7.org/ValueSet/v3-SubstanceAdminSubstitutionReason")
1599    protected CodeableConcept reason;
1600
1601    private static final long serialVersionUID = 547265407L;
1602
1603    /**
1604     * Constructor
1605     */
1606    public MedicationRequestSubstitutionComponent() {
1607      super();
1608    }
1609
1610    /**
1611     * Constructor
1612     */
1613    public MedicationRequestSubstitutionComponent(Type allowed) {
1614      super();
1615      this.allowed = allowed;
1616    }
1617
1618    /**
1619     * @return {@link #allowed} (True if the prescriber allows a different drug to
1620     *         be dispensed from what was prescribed.)
1621     */
1622    public Type getAllowed() {
1623      return this.allowed;
1624    }
1625
1626    /**
1627     * @return {@link #allowed} (True if the prescriber allows a different drug to
1628     *         be dispensed from what was prescribed.)
1629     */
1630    public BooleanType getAllowedBooleanType() throws FHIRException {
1631      if (this.allowed == null)
1632        this.allowed = new BooleanType();
1633      if (!(this.allowed instanceof BooleanType))
1634        throw new FHIRException("Type mismatch: the type BooleanType was expected, but "
1635            + this.allowed.getClass().getName() + " was encountered");
1636      return (BooleanType) this.allowed;
1637    }
1638
1639    public boolean hasAllowedBooleanType() {
1640      return this != null && this.allowed instanceof BooleanType;
1641    }
1642
1643    /**
1644     * @return {@link #allowed} (True if the prescriber allows a different drug to
1645     *         be dispensed from what was prescribed.)
1646     */
1647    public CodeableConcept getAllowedCodeableConcept() throws FHIRException {
1648      if (this.allowed == null)
1649        this.allowed = new CodeableConcept();
1650      if (!(this.allowed instanceof CodeableConcept))
1651        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "
1652            + this.allowed.getClass().getName() + " was encountered");
1653      return (CodeableConcept) this.allowed;
1654    }
1655
1656    public boolean hasAllowedCodeableConcept() {
1657      return this != null && this.allowed instanceof CodeableConcept;
1658    }
1659
1660    public boolean hasAllowed() {
1661      return this.allowed != null && !this.allowed.isEmpty();
1662    }
1663
1664    /**
1665     * @param value {@link #allowed} (True if the prescriber allows a different drug
1666     *              to be dispensed from what was prescribed.)
1667     */
1668    public MedicationRequestSubstitutionComponent setAllowed(Type value) {
1669      if (value != null && !(value instanceof BooleanType || value instanceof CodeableConcept))
1670        throw new Error("Not the right type for MedicationRequest.substitution.allowed[x]: " + value.fhirType());
1671      this.allowed = value;
1672      return this;
1673    }
1674
1675    /**
1676     * @return {@link #reason} (Indicates the reason for the substitution, or why
1677     *         substitution must or must not be performed.)
1678     */
1679    public CodeableConcept getReason() {
1680      if (this.reason == null)
1681        if (Configuration.errorOnAutoCreate())
1682          throw new Error("Attempt to auto-create MedicationRequestSubstitutionComponent.reason");
1683        else if (Configuration.doAutoCreate())
1684          this.reason = new CodeableConcept(); // cc
1685      return this.reason;
1686    }
1687
1688    public boolean hasReason() {
1689      return this.reason != null && !this.reason.isEmpty();
1690    }
1691
1692    /**
1693     * @param value {@link #reason} (Indicates the reason for the substitution, or
1694     *              why substitution must or must not be performed.)
1695     */
1696    public MedicationRequestSubstitutionComponent setReason(CodeableConcept value) {
1697      this.reason = value;
1698      return this;
1699    }
1700
1701    protected void listChildren(List<Property> children) {
1702      super.listChildren(children);
1703      children.add(new Property("allowed[x]", "boolean|CodeableConcept",
1704          "True if the prescriber allows a different drug to be dispensed from what was prescribed.", 0, 1, allowed));
1705      children.add(new Property("reason", "CodeableConcept",
1706          "Indicates the reason for the substitution, or why substitution must or must not be performed.", 0, 1,
1707          reason));
1708    }
1709
1710    @Override
1711    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1712      switch (_hash) {
1713      case -1336663592:
1714        /* allowed[x] */ return new Property("allowed[x]", "boolean|CodeableConcept",
1715            "True if the prescriber allows a different drug to be dispensed from what was prescribed.", 0, 1, allowed);
1716      case -911343192:
1717        /* allowed */ return new Property("allowed[x]", "boolean|CodeableConcept",
1718            "True if the prescriber allows a different drug to be dispensed from what was prescribed.", 0, 1, allowed);
1719      case 177755488:
1720        /* allowedBoolean */ return new Property("allowed[x]", "boolean|CodeableConcept",
1721            "True if the prescriber allows a different drug to be dispensed from what was prescribed.", 0, 1, allowed);
1722      case 963125465:
1723        /* allowedCodeableConcept */ return new Property("allowed[x]", "boolean|CodeableConcept",
1724            "True if the prescriber allows a different drug to be dispensed from what was prescribed.", 0, 1, allowed);
1725      case -934964668:
1726        /* reason */ return new Property("reason", "CodeableConcept",
1727            "Indicates the reason for the substitution, or why substitution must or must not be performed.", 0, 1,
1728            reason);
1729      default:
1730        return super.getNamedProperty(_hash, _name, _checkValid);
1731      }
1732
1733    }
1734
1735    @Override
1736    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1737      switch (hash) {
1738      case -911343192:
1739        /* allowed */ return this.allowed == null ? new Base[0] : new Base[] { this.allowed }; // Type
1740      case -934964668:
1741        /* reason */ return this.reason == null ? new Base[0] : new Base[] { this.reason }; // CodeableConcept
1742      default:
1743        return super.getProperty(hash, name, checkValid);
1744      }
1745
1746    }
1747
1748    @Override
1749    public Base setProperty(int hash, String name, Base value) throws FHIRException {
1750      switch (hash) {
1751      case -911343192: // allowed
1752        this.allowed = castToType(value); // Type
1753        return value;
1754      case -934964668: // reason
1755        this.reason = castToCodeableConcept(value); // CodeableConcept
1756        return value;
1757      default:
1758        return super.setProperty(hash, name, value);
1759      }
1760
1761    }
1762
1763    @Override
1764    public Base setProperty(String name, Base value) throws FHIRException {
1765      if (name.equals("allowed[x]")) {
1766        this.allowed = castToType(value); // Type
1767      } else if (name.equals("reason")) {
1768        this.reason = castToCodeableConcept(value); // CodeableConcept
1769      } else
1770        return super.setProperty(name, value);
1771      return value;
1772    }
1773
1774  @Override
1775  public void removeChild(String name, Base value) throws FHIRException {
1776      if (name.equals("allowed[x]")) {
1777        this.allowed = null;
1778      } else if (name.equals("reason")) {
1779        this.reason = null;
1780      } else
1781        super.removeChild(name, value);
1782      
1783    }
1784
1785    @Override
1786    public Base makeProperty(int hash, String name) throws FHIRException {
1787      switch (hash) {
1788      case -1336663592:
1789        return getAllowed();
1790      case -911343192:
1791        return getAllowed();
1792      case -934964668:
1793        return getReason();
1794      default:
1795        return super.makeProperty(hash, name);
1796      }
1797
1798    }
1799
1800    @Override
1801    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1802      switch (hash) {
1803      case -911343192:
1804        /* allowed */ return new String[] { "boolean", "CodeableConcept" };
1805      case -934964668:
1806        /* reason */ return new String[] { "CodeableConcept" };
1807      default:
1808        return super.getTypesForProperty(hash, name);
1809      }
1810
1811    }
1812
1813    @Override
1814    public Base addChild(String name) throws FHIRException {
1815      if (name.equals("allowedBoolean")) {
1816        this.allowed = new BooleanType();
1817        return this.allowed;
1818      } else if (name.equals("allowedCodeableConcept")) {
1819        this.allowed = new CodeableConcept();
1820        return this.allowed;
1821      } else if (name.equals("reason")) {
1822        this.reason = new CodeableConcept();
1823        return this.reason;
1824      } else
1825        return super.addChild(name);
1826    }
1827
1828    public MedicationRequestSubstitutionComponent copy() {
1829      MedicationRequestSubstitutionComponent dst = new MedicationRequestSubstitutionComponent();
1830      copyValues(dst);
1831      return dst;
1832    }
1833
1834    public void copyValues(MedicationRequestSubstitutionComponent dst) {
1835      super.copyValues(dst);
1836      dst.allowed = allowed == null ? null : allowed.copy();
1837      dst.reason = reason == null ? null : reason.copy();
1838    }
1839
1840    @Override
1841    public boolean equalsDeep(Base other_) {
1842      if (!super.equalsDeep(other_))
1843        return false;
1844      if (!(other_ instanceof MedicationRequestSubstitutionComponent))
1845        return false;
1846      MedicationRequestSubstitutionComponent o = (MedicationRequestSubstitutionComponent) other_;
1847      return compareDeep(allowed, o.allowed, true) && compareDeep(reason, o.reason, true);
1848    }
1849
1850    @Override
1851    public boolean equalsShallow(Base other_) {
1852      if (!super.equalsShallow(other_))
1853        return false;
1854      if (!(other_ instanceof MedicationRequestSubstitutionComponent))
1855        return false;
1856      MedicationRequestSubstitutionComponent o = (MedicationRequestSubstitutionComponent) other_;
1857      return true;
1858    }
1859
1860    public boolean isEmpty() {
1861      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(allowed, reason);
1862    }
1863
1864    public String fhirType() {
1865      return "MedicationRequest.substitution";
1866
1867    }
1868
1869  }
1870
1871  /**
1872   * Identifiers associated with this medication request that are defined by
1873   * business processes and/or used to refer to it when a direct URL reference to
1874   * the resource itself is not appropriate. They are business identifiers
1875   * assigned to this resource by the performer or other systems and remain
1876   * constant as the resource is updated and propagates from server to server.
1877   */
1878  @Child(name = "identifier", type = {
1879      Identifier.class }, order = 0, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1880  @Description(shortDefinition = "External ids for this request", formalDefinition = "Identifiers associated with this medication request that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate. They are business identifiers assigned to this resource by the performer or other systems and remain constant as the resource is updated and propagates from server to server.")
1881  protected List<Identifier> identifier;
1882
1883  /**
1884   * A code specifying the current state of the order. Generally, this will be
1885   * active or completed state.
1886   */
1887  @Child(name = "status", type = { CodeType.class }, order = 1, min = 1, max = 1, modifier = true, summary = true)
1888  @Description(shortDefinition = "active | on-hold | cancelled | completed | entered-in-error | stopped | draft | unknown", formalDefinition = "A code specifying the current state of the order.  Generally, this will be active or completed state.")
1889  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/medicationrequest-status")
1890  protected Enumeration<MedicationRequestStatus> status;
1891
1892  /**
1893   * Captures the reason for the current state of the MedicationRequest.
1894   */
1895  @Child(name = "statusReason", type = {
1896      CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = false)
1897  @Description(shortDefinition = "Reason for current status", formalDefinition = "Captures the reason for the current state of the MedicationRequest.")
1898  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/medicationrequest-status-reason")
1899  protected CodeableConcept statusReason;
1900
1901  /**
1902   * Whether the request is a proposal, plan, or an original order.
1903   */
1904  @Child(name = "intent", type = { CodeType.class }, order = 3, min = 1, max = 1, modifier = true, summary = true)
1905  @Description(shortDefinition = "proposal | plan | order | original-order | reflex-order | filler-order | instance-order | option", formalDefinition = "Whether the request is a proposal, plan, or an original order.")
1906  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/medicationrequest-intent")
1907  protected Enumeration<MedicationRequestIntent> intent;
1908
1909  /**
1910   * Indicates the type of medication request (for example, where the medication
1911   * is expected to be consumed or administered (i.e. inpatient or outpatient)).
1912   */
1913  @Child(name = "category", type = {
1914      CodeableConcept.class }, order = 4, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1915  @Description(shortDefinition = "Type of medication usage", formalDefinition = "Indicates the type of medication request (for example, where the medication is expected to be consumed or administered (i.e. inpatient or outpatient)).")
1916  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/medicationrequest-category")
1917  protected List<CodeableConcept> category;
1918
1919  /**
1920   * Indicates how quickly the Medication Request should be addressed with respect
1921   * to other requests.
1922   */
1923  @Child(name = "priority", type = { CodeType.class }, order = 5, min = 0, max = 1, modifier = false, summary = true)
1924  @Description(shortDefinition = "routine | urgent | asap | stat", formalDefinition = "Indicates how quickly the Medication Request should be addressed with respect to other requests.")
1925  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/request-priority")
1926  protected Enumeration<MedicationRequestPriority> priority;
1927
1928  /**
1929   * If true indicates that the provider is asking for the medication request not
1930   * to occur.
1931   */
1932  @Child(name = "doNotPerform", type = {
1933      BooleanType.class }, order = 6, min = 0, max = 1, modifier = true, summary = true)
1934  @Description(shortDefinition = "True if request is prohibiting action", formalDefinition = "If true indicates that the provider is asking for the medication request not to occur.")
1935  protected BooleanType doNotPerform;
1936
1937  /**
1938   * Indicates if this record was captured as a secondary 'reported' record rather
1939   * than as an original primary source-of-truth record. It may also indicate the
1940   * source of the report.
1941   */
1942  @Child(name = "reported", type = { BooleanType.class, Patient.class, Practitioner.class, PractitionerRole.class,
1943      RelatedPerson.class, Organization.class }, order = 7, min = 0, max = 1, modifier = false, summary = true)
1944  @Description(shortDefinition = "Reported rather than primary record", formalDefinition = "Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.")
1945  protected Type reported;
1946
1947  /**
1948   * Identifies the medication being requested. This is a link to a resource that
1949   * represents the medication which may be the details of the medication or
1950   * simply an attribute carrying a code that identifies the medication from a
1951   * known list of medications.
1952   */
1953  @Child(name = "medication", type = { CodeableConcept.class,
1954      Medication.class }, order = 8, min = 1, max = 1, modifier = false, summary = true)
1955  @Description(shortDefinition = "Medication to be taken", formalDefinition = "Identifies the medication being requested. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications.")
1956  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/medication-codes")
1957  protected Type medication;
1958
1959  /**
1960   * A link to a resource representing the person or set of individuals to whom
1961   * the medication will be given.
1962   */
1963  @Child(name = "subject", type = { Patient.class,
1964      Group.class }, order = 9, min = 1, max = 1, modifier = false, summary = true)
1965  @Description(shortDefinition = "Who or group medication request is for", formalDefinition = "A link to a resource representing the person or set of individuals to whom the medication will be given.")
1966  protected Reference subject;
1967
1968  /**
1969   * The actual object that is the target of the reference (A link to a resource
1970   * representing the person or set of individuals to whom the medication will be
1971   * given.)
1972   */
1973  protected Resource subjectTarget;
1974
1975  /**
1976   * The Encounter during which this [x] was created or to which the creation of
1977   * this record is tightly associated.
1978   */
1979  @Child(name = "encounter", type = {
1980      Encounter.class }, order = 10, min = 0, max = 1, modifier = false, summary = false)
1981  @Description(shortDefinition = "Encounter created as part of encounter/admission/stay", formalDefinition = "The Encounter during which this [x] was created or to which the creation of this record is tightly associated.")
1982  protected Reference encounter;
1983
1984  /**
1985   * The actual object that is the target of the reference (The Encounter during
1986   * which this [x] was created or to which the creation of this record is tightly
1987   * associated.)
1988   */
1989  protected Encounter encounterTarget;
1990
1991  /**
1992   * Include additional information (for example, patient height and weight) that
1993   * supports the ordering of the medication.
1994   */
1995  @Child(name = "supportingInformation", type = {
1996      Reference.class }, order = 11, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1997  @Description(shortDefinition = "Information to support ordering of the medication", formalDefinition = "Include additional information (for example, patient height and weight) that supports the ordering of the medication.")
1998  protected List<Reference> supportingInformation;
1999  /**
2000   * The actual objects that are the target of the reference (Include additional
2001   * information (for example, patient height and weight) that supports the
2002   * ordering of the medication.)
2003   */
2004  protected List<Resource> supportingInformationTarget;
2005
2006  /**
2007   * The date (and perhaps time) when the prescription was initially written or
2008   * authored on.
2009   */
2010  @Child(name = "authoredOn", type = {
2011      DateTimeType.class }, order = 12, min = 0, max = 1, modifier = false, summary = true)
2012  @Description(shortDefinition = "When request was initially authored", formalDefinition = "The date (and perhaps time) when the prescription was initially written or authored on.")
2013  protected DateTimeType authoredOn;
2014
2015  /**
2016   * The individual, organization, or device that initiated the request and has
2017   * responsibility for its activation.
2018   */
2019  @Child(name = "requester", type = { Practitioner.class, PractitionerRole.class, Organization.class, Patient.class,
2020      RelatedPerson.class, Device.class }, order = 13, min = 0, max = 1, modifier = false, summary = true)
2021  @Description(shortDefinition = "Who/What requested the Request", formalDefinition = "The individual, organization, or device that initiated the request and has responsibility for its activation.")
2022  protected Reference requester;
2023
2024  /**
2025   * The actual object that is the target of the reference (The individual,
2026   * organization, or device that initiated the request and has responsibility for
2027   * its activation.)
2028   */
2029  protected Resource requesterTarget;
2030
2031  /**
2032   * The specified desired performer of the medication treatment (e.g. the
2033   * performer of the medication administration).
2034   */
2035  @Child(name = "performer", type = { Practitioner.class, PractitionerRole.class, Organization.class, Patient.class,
2036      Device.class, RelatedPerson.class,
2037      CareTeam.class }, order = 14, min = 0, max = 1, modifier = false, summary = false)
2038  @Description(shortDefinition = "Intended performer of administration", formalDefinition = "The specified desired performer of the medication treatment (e.g. the performer of the medication administration).")
2039  protected Reference performer;
2040
2041  /**
2042   * The actual object that is the target of the reference (The specified desired
2043   * performer of the medication treatment (e.g. the performer of the medication
2044   * administration).)
2045   */
2046  protected Resource performerTarget;
2047
2048  /**
2049   * Indicates the type of performer of the administration of the medication.
2050   */
2051  @Child(name = "performerType", type = {
2052      CodeableConcept.class }, order = 15, min = 0, max = 1, modifier = false, summary = true)
2053  @Description(shortDefinition = "Desired kind of performer of the medication administration", formalDefinition = "Indicates the type of performer of the administration of the medication.")
2054  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/performer-role")
2055  protected CodeableConcept performerType;
2056
2057  /**
2058   * The person who entered the order on behalf of another individual for example
2059   * in the case of a verbal or a telephone order.
2060   */
2061  @Child(name = "recorder", type = { Practitioner.class,
2062      PractitionerRole.class }, order = 16, min = 0, max = 1, modifier = false, summary = false)
2063  @Description(shortDefinition = "Person who entered the request", formalDefinition = "The person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.")
2064  protected Reference recorder;
2065
2066  /**
2067   * The actual object that is the target of the reference (The person who entered
2068   * the order on behalf of another individual for example in the case of a verbal
2069   * or a telephone order.)
2070   */
2071  protected Resource recorderTarget;
2072
2073  /**
2074   * The reason or the indication for ordering or not ordering the medication.
2075   */
2076  @Child(name = "reasonCode", type = {
2077      CodeableConcept.class }, order = 17, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
2078  @Description(shortDefinition = "Reason or indication for ordering or not ordering the medication", formalDefinition = "The reason or the indication for ordering or not ordering the medication.")
2079  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/condition-code")
2080  protected List<CodeableConcept> reasonCode;
2081
2082  /**
2083   * Condition or observation that supports why the medication was ordered.
2084   */
2085  @Child(name = "reasonReference", type = { Condition.class,
2086      Observation.class }, order = 18, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
2087  @Description(shortDefinition = "Condition or observation that supports why the prescription is being written", formalDefinition = "Condition or observation that supports why the medication was ordered.")
2088  protected List<Reference> reasonReference;
2089  /**
2090   * The actual objects that are the target of the reference (Condition or
2091   * observation that supports why the medication was ordered.)
2092   */
2093  protected List<Resource> reasonReferenceTarget;
2094
2095  /**
2096   * The URL pointing to a protocol, guideline, orderset, or other definition that
2097   * is adhered to in whole or in part by this MedicationRequest.
2098   */
2099  @Child(name = "instantiatesCanonical", type = {
2100      CanonicalType.class }, order = 19, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
2101  @Description(shortDefinition = "Instantiates FHIR protocol or definition", formalDefinition = "The URL pointing to a protocol, guideline, orderset, or other definition that is adhered to in whole or in part by this MedicationRequest.")
2102  protected List<CanonicalType> instantiatesCanonical;
2103
2104  /**
2105   * The URL pointing to an externally maintained protocol, guideline, orderset or
2106   * other definition that is adhered to in whole or in part by this
2107   * MedicationRequest.
2108   */
2109  @Child(name = "instantiatesUri", type = {
2110      UriType.class }, order = 20, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
2111  @Description(shortDefinition = "Instantiates external protocol or definition", formalDefinition = "The URL pointing to an externally maintained protocol, guideline, orderset or other definition that is adhered to in whole or in part by this MedicationRequest.")
2112  protected List<UriType> instantiatesUri;
2113
2114  /**
2115   * A plan or request that is fulfilled in whole or in part by this medication
2116   * request.
2117   */
2118  @Child(name = "basedOn", type = { CarePlan.class, MedicationRequest.class, ServiceRequest.class,
2119      ImmunizationRecommendation.class }, order = 21, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
2120  @Description(shortDefinition = "What request fulfills", formalDefinition = "A plan or request that is fulfilled in whole or in part by this medication request.")
2121  protected List<Reference> basedOn;
2122  /**
2123   * The actual objects that are the target of the reference (A plan or request
2124   * that is fulfilled in whole or in part by this medication request.)
2125   */
2126  protected List<Resource> basedOnTarget;
2127
2128  /**
2129   * A shared identifier common to all requests that were authorized more or less
2130   * simultaneously by a single author, representing the identifier of the
2131   * requisition or prescription.
2132   */
2133  @Child(name = "groupIdentifier", type = {
2134      Identifier.class }, order = 22, min = 0, max = 1, modifier = false, summary = true)
2135  @Description(shortDefinition = "Composite request this is part of", formalDefinition = "A shared identifier common to all requests that were authorized more or less simultaneously by a single author, representing the identifier of the requisition or prescription.")
2136  protected Identifier groupIdentifier;
2137
2138  /**
2139   * The description of the overall patte3rn of the administration of the
2140   * medication to the patient.
2141   */
2142  @Child(name = "courseOfTherapyType", type = {
2143      CodeableConcept.class }, order = 23, min = 0, max = 1, modifier = false, summary = false)
2144  @Description(shortDefinition = "Overall pattern of medication administration", formalDefinition = "The description of the overall patte3rn of the administration of the medication to the patient.")
2145  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/medicationrequest-course-of-therapy")
2146  protected CodeableConcept courseOfTherapyType;
2147
2148  /**
2149   * Insurance plans, coverage extensions, pre-authorizations and/or
2150   * pre-determinations that may be required for delivering the requested service.
2151   */
2152  @Child(name = "insurance", type = { Coverage.class,
2153      ClaimResponse.class }, order = 24, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
2154  @Description(shortDefinition = "Associated insurance coverage", formalDefinition = "Insurance plans, coverage extensions, pre-authorizations and/or pre-determinations that may be required for delivering the requested service.")
2155  protected List<Reference> insurance;
2156  /**
2157   * The actual objects that are the target of the reference (Insurance plans,
2158   * coverage extensions, pre-authorizations and/or pre-determinations that may be
2159   * required for delivering the requested service.)
2160   */
2161  protected List<Resource> insuranceTarget;
2162
2163  /**
2164   * Extra information about the prescription that could not be conveyed by the
2165   * other attributes.
2166   */
2167  @Child(name = "note", type = {
2168      Annotation.class }, order = 25, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
2169  @Description(shortDefinition = "Information about the prescription", formalDefinition = "Extra information about the prescription that could not be conveyed by the other attributes.")
2170  protected List<Annotation> note;
2171
2172  /**
2173   * Indicates how the medication is to be used by the patient.
2174   */
2175  @Child(name = "dosageInstruction", type = {
2176      Dosage.class }, order = 26, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
2177  @Description(shortDefinition = "How the medication should be taken", formalDefinition = "Indicates how the medication is to be used by the patient.")
2178  protected List<Dosage> dosageInstruction;
2179
2180  /**
2181   * Indicates the specific details for the dispense or medication supply part of
2182   * a medication request (also known as a Medication Prescription or Medication
2183   * Order). Note that this information is not always sent with the order. There
2184   * may be in some settings (e.g. hospitals) institutional or system support for
2185   * completing the dispense details in the pharmacy department.
2186   */
2187  @Child(name = "dispenseRequest", type = {}, order = 27, min = 0, max = 1, modifier = false, summary = false)
2188  @Description(shortDefinition = "Medication supply authorization", formalDefinition = "Indicates the specific details for the dispense or medication supply part of a medication request (also known as a Medication Prescription or Medication Order).  Note that this information is not always sent with the order.  There may be in some settings (e.g. hospitals) institutional or system support for completing the dispense details in the pharmacy department.")
2189  protected MedicationRequestDispenseRequestComponent dispenseRequest;
2190
2191  /**
2192   * Indicates whether or not substitution can or should be part of the dispense.
2193   * In some cases, substitution must happen, in other cases substitution must not
2194   * happen. This block explains the prescriber's intent. If nothing is specified
2195   * substitution may be done.
2196   */
2197  @Child(name = "substitution", type = {}, order = 28, min = 0, max = 1, modifier = false, summary = false)
2198  @Description(shortDefinition = "Any restrictions on medication substitution", formalDefinition = "Indicates whether or not substitution can or should be part of the dispense. In some cases, substitution must happen, in other cases substitution must not happen. This block explains the prescriber's intent. If nothing is specified substitution may be done.")
2199  protected MedicationRequestSubstitutionComponent substitution;
2200
2201  /**
2202   * A link to a resource representing an earlier order related order or
2203   * prescription.
2204   */
2205  @Child(name = "priorPrescription", type = {
2206      MedicationRequest.class }, order = 29, min = 0, max = 1, modifier = false, summary = false)
2207  @Description(shortDefinition = "An order/prescription that is being replaced", formalDefinition = "A link to a resource representing an earlier order related order or prescription.")
2208  protected Reference priorPrescription;
2209
2210  /**
2211   * The actual object that is the target of the reference (A link to a resource
2212   * representing an earlier order related order or prescription.)
2213   */
2214  protected MedicationRequest priorPrescriptionTarget;
2215
2216  /**
2217   * Indicates an actual or potential clinical issue with or between one or more
2218   * active or proposed clinical actions for a patient; e.g. Drug-drug
2219   * interaction, duplicate therapy, dosage alert etc.
2220   */
2221  @Child(name = "detectedIssue", type = {
2222      DetectedIssue.class }, order = 30, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
2223  @Description(shortDefinition = "Clinical Issue with action", formalDefinition = "Indicates an actual or potential clinical issue with or between one or more active or proposed clinical actions for a patient; e.g. Drug-drug interaction, duplicate therapy, dosage alert etc.")
2224  protected List<Reference> detectedIssue;
2225  /**
2226   * The actual objects that are the target of the reference (Indicates an actual
2227   * or potential clinical issue with or between one or more active or proposed
2228   * clinical actions for a patient; e.g. Drug-drug interaction, duplicate
2229   * therapy, dosage alert etc.)
2230   */
2231  protected List<DetectedIssue> detectedIssueTarget;
2232
2233  /**
2234   * Links to Provenance records for past versions of this resource or fulfilling
2235   * request or event resources that identify key state transitions or updates
2236   * that are likely to be relevant to a user looking at the current version of
2237   * the resource.
2238   */
2239  @Child(name = "eventHistory", type = {
2240      Provenance.class }, order = 31, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
2241  @Description(shortDefinition = "A list of events of interest in the lifecycle", formalDefinition = "Links to Provenance records for past versions of this resource or fulfilling request or event resources that identify key state transitions or updates that are likely to be relevant to a user looking at the current version of the resource.")
2242  protected List<Reference> eventHistory;
2243  /**
2244   * The actual objects that are the target of the reference (Links to Provenance
2245   * records for past versions of this resource or fulfilling request or event
2246   * resources that identify key state transitions or updates that are likely to
2247   * be relevant to a user looking at the current version of the resource.)
2248   */
2249  protected List<Provenance> eventHistoryTarget;
2250
2251  private static final long serialVersionUID = 1313900480L;
2252
2253  /**
2254   * Constructor
2255   */
2256  public MedicationRequest() {
2257    super();
2258  }
2259
2260  /**
2261   * Constructor
2262   */
2263  public MedicationRequest(Enumeration<MedicationRequestStatus> status, Enumeration<MedicationRequestIntent> intent,
2264      Type medication, Reference subject) {
2265    super();
2266    this.status = status;
2267    this.intent = intent;
2268    this.medication = medication;
2269    this.subject = subject;
2270  }
2271
2272  /**
2273   * @return {@link #identifier} (Identifiers associated with this medication
2274   *         request that are defined by business processes and/or used to refer
2275   *         to it when a direct URL reference to the resource itself is not
2276   *         appropriate. They are business identifiers assigned to this resource
2277   *         by the performer or other systems and remain constant as the resource
2278   *         is updated and propagates from server to server.)
2279   */
2280  public List<Identifier> getIdentifier() {
2281    if (this.identifier == null)
2282      this.identifier = new ArrayList<Identifier>();
2283    return this.identifier;
2284  }
2285
2286  /**
2287   * @return Returns a reference to <code>this</code> for easy method chaining
2288   */
2289  public MedicationRequest setIdentifier(List<Identifier> theIdentifier) {
2290    this.identifier = theIdentifier;
2291    return this;
2292  }
2293
2294  public boolean hasIdentifier() {
2295    if (this.identifier == null)
2296      return false;
2297    for (Identifier item : this.identifier)
2298      if (!item.isEmpty())
2299        return true;
2300    return false;
2301  }
2302
2303  public Identifier addIdentifier() { // 3
2304    Identifier t = new Identifier();
2305    if (this.identifier == null)
2306      this.identifier = new ArrayList<Identifier>();
2307    this.identifier.add(t);
2308    return t;
2309  }
2310
2311  public MedicationRequest addIdentifier(Identifier t) { // 3
2312    if (t == null)
2313      return this;
2314    if (this.identifier == null)
2315      this.identifier = new ArrayList<Identifier>();
2316    this.identifier.add(t);
2317    return this;
2318  }
2319
2320  /**
2321   * @return The first repetition of repeating field {@link #identifier}, creating
2322   *         it if it does not already exist
2323   */
2324  public Identifier getIdentifierFirstRep() {
2325    if (getIdentifier().isEmpty()) {
2326      addIdentifier();
2327    }
2328    return getIdentifier().get(0);
2329  }
2330
2331  /**
2332   * @return {@link #status} (A code specifying the current state of the order.
2333   *         Generally, this will be active or completed state.). This is the
2334   *         underlying object with id, value and extensions. The accessor
2335   *         "getStatus" gives direct access to the value
2336   */
2337  public Enumeration<MedicationRequestStatus> getStatusElement() {
2338    if (this.status == null)
2339      if (Configuration.errorOnAutoCreate())
2340        throw new Error("Attempt to auto-create MedicationRequest.status");
2341      else if (Configuration.doAutoCreate())
2342        this.status = new Enumeration<MedicationRequestStatus>(new MedicationRequestStatusEnumFactory()); // bb
2343    return this.status;
2344  }
2345
2346  public boolean hasStatusElement() {
2347    return this.status != null && !this.status.isEmpty();
2348  }
2349
2350  public boolean hasStatus() {
2351    return this.status != null && !this.status.isEmpty();
2352  }
2353
2354  /**
2355   * @param value {@link #status} (A code specifying the current state of the
2356   *              order. Generally, this will be active or completed state.). This
2357   *              is the underlying object with id, value and extensions. The
2358   *              accessor "getStatus" gives direct access to the value
2359   */
2360  public MedicationRequest setStatusElement(Enumeration<MedicationRequestStatus> value) {
2361    this.status = value;
2362    return this;
2363  }
2364
2365  /**
2366   * @return A code specifying the current state of the order. Generally, this
2367   *         will be active or completed state.
2368   */
2369  public MedicationRequestStatus getStatus() {
2370    return this.status == null ? null : this.status.getValue();
2371  }
2372
2373  /**
2374   * @param value A code specifying the current state of the order. Generally,
2375   *              this will be active or completed state.
2376   */
2377  public MedicationRequest setStatus(MedicationRequestStatus value) {
2378    if (this.status == null)
2379      this.status = new Enumeration<MedicationRequestStatus>(new MedicationRequestStatusEnumFactory());
2380    this.status.setValue(value);
2381    return this;
2382  }
2383
2384  /**
2385   * @return {@link #statusReason} (Captures the reason for the current state of
2386   *         the MedicationRequest.)
2387   */
2388  public CodeableConcept getStatusReason() {
2389    if (this.statusReason == null)
2390      if (Configuration.errorOnAutoCreate())
2391        throw new Error("Attempt to auto-create MedicationRequest.statusReason");
2392      else if (Configuration.doAutoCreate())
2393        this.statusReason = new CodeableConcept(); // cc
2394    return this.statusReason;
2395  }
2396
2397  public boolean hasStatusReason() {
2398    return this.statusReason != null && !this.statusReason.isEmpty();
2399  }
2400
2401  /**
2402   * @param value {@link #statusReason} (Captures the reason for the current state
2403   *              of the MedicationRequest.)
2404   */
2405  public MedicationRequest setStatusReason(CodeableConcept value) {
2406    this.statusReason = value;
2407    return this;
2408  }
2409
2410  /**
2411   * @return {@link #intent} (Whether the request is a proposal, plan, or an
2412   *         original order.). This is the underlying object with id, value and
2413   *         extensions. The accessor "getIntent" gives direct access to the value
2414   */
2415  public Enumeration<MedicationRequestIntent> getIntentElement() {
2416    if (this.intent == null)
2417      if (Configuration.errorOnAutoCreate())
2418        throw new Error("Attempt to auto-create MedicationRequest.intent");
2419      else if (Configuration.doAutoCreate())
2420        this.intent = new Enumeration<MedicationRequestIntent>(new MedicationRequestIntentEnumFactory()); // bb
2421    return this.intent;
2422  }
2423
2424  public boolean hasIntentElement() {
2425    return this.intent != null && !this.intent.isEmpty();
2426  }
2427
2428  public boolean hasIntent() {
2429    return this.intent != null && !this.intent.isEmpty();
2430  }
2431
2432  /**
2433   * @param value {@link #intent} (Whether the request is a proposal, plan, or an
2434   *              original order.). This is the underlying object with id, value
2435   *              and extensions. The accessor "getIntent" gives direct access to
2436   *              the value
2437   */
2438  public MedicationRequest setIntentElement(Enumeration<MedicationRequestIntent> value) {
2439    this.intent = value;
2440    return this;
2441  }
2442
2443  /**
2444   * @return Whether the request is a proposal, plan, or an original order.
2445   */
2446  public MedicationRequestIntent getIntent() {
2447    return this.intent == null ? null : this.intent.getValue();
2448  }
2449
2450  /**
2451   * @param value Whether the request is a proposal, plan, or an original order.
2452   */
2453  public MedicationRequest setIntent(MedicationRequestIntent value) {
2454    if (this.intent == null)
2455      this.intent = new Enumeration<MedicationRequestIntent>(new MedicationRequestIntentEnumFactory());
2456    this.intent.setValue(value);
2457    return this;
2458  }
2459
2460  /**
2461   * @return {@link #category} (Indicates the type of medication request (for
2462   *         example, where the medication is expected to be consumed or
2463   *         administered (i.e. inpatient or outpatient)).)
2464   */
2465  public List<CodeableConcept> getCategory() {
2466    if (this.category == null)
2467      this.category = new ArrayList<CodeableConcept>();
2468    return this.category;
2469  }
2470
2471  /**
2472   * @return Returns a reference to <code>this</code> for easy method chaining
2473   */
2474  public MedicationRequest setCategory(List<CodeableConcept> theCategory) {
2475    this.category = theCategory;
2476    return this;
2477  }
2478
2479  public boolean hasCategory() {
2480    if (this.category == null)
2481      return false;
2482    for (CodeableConcept item : this.category)
2483      if (!item.isEmpty())
2484        return true;
2485    return false;
2486  }
2487
2488  public CodeableConcept addCategory() { // 3
2489    CodeableConcept t = new CodeableConcept();
2490    if (this.category == null)
2491      this.category = new ArrayList<CodeableConcept>();
2492    this.category.add(t);
2493    return t;
2494  }
2495
2496  public MedicationRequest addCategory(CodeableConcept t) { // 3
2497    if (t == null)
2498      return this;
2499    if (this.category == null)
2500      this.category = new ArrayList<CodeableConcept>();
2501    this.category.add(t);
2502    return this;
2503  }
2504
2505  /**
2506   * @return The first repetition of repeating field {@link #category}, creating
2507   *         it if it does not already exist
2508   */
2509  public CodeableConcept getCategoryFirstRep() {
2510    if (getCategory().isEmpty()) {
2511      addCategory();
2512    }
2513    return getCategory().get(0);
2514  }
2515
2516  /**
2517   * @return {@link #priority} (Indicates how quickly the Medication Request
2518   *         should be addressed with respect to other requests.). This is the
2519   *         underlying object with id, value and extensions. The accessor
2520   *         "getPriority" gives direct access to the value
2521   */
2522  public Enumeration<MedicationRequestPriority> getPriorityElement() {
2523    if (this.priority == null)
2524      if (Configuration.errorOnAutoCreate())
2525        throw new Error("Attempt to auto-create MedicationRequest.priority");
2526      else if (Configuration.doAutoCreate())
2527        this.priority = new Enumeration<MedicationRequestPriority>(new MedicationRequestPriorityEnumFactory()); // bb
2528    return this.priority;
2529  }
2530
2531  public boolean hasPriorityElement() {
2532    return this.priority != null && !this.priority.isEmpty();
2533  }
2534
2535  public boolean hasPriority() {
2536    return this.priority != null && !this.priority.isEmpty();
2537  }
2538
2539  /**
2540   * @param value {@link #priority} (Indicates how quickly the Medication Request
2541   *              should be addressed with respect to other requests.). This is
2542   *              the underlying object with id, value and extensions. The
2543   *              accessor "getPriority" gives direct access to the value
2544   */
2545  public MedicationRequest setPriorityElement(Enumeration<MedicationRequestPriority> value) {
2546    this.priority = value;
2547    return this;
2548  }
2549
2550  /**
2551   * @return Indicates how quickly the Medication Request should be addressed with
2552   *         respect to other requests.
2553   */
2554  public MedicationRequestPriority getPriority() {
2555    return this.priority == null ? null : this.priority.getValue();
2556  }
2557
2558  /**
2559   * @param value Indicates how quickly the Medication Request should be addressed
2560   *              with respect to other requests.
2561   */
2562  public MedicationRequest setPriority(MedicationRequestPriority value) {
2563    if (value == null)
2564      this.priority = null;
2565    else {
2566      if (this.priority == null)
2567        this.priority = new Enumeration<MedicationRequestPriority>(new MedicationRequestPriorityEnumFactory());
2568      this.priority.setValue(value);
2569    }
2570    return this;
2571  }
2572
2573  /**
2574   * @return {@link #doNotPerform} (If true indicates that the provider is asking
2575   *         for the medication request not to occur.). This is the underlying
2576   *         object with id, value and extensions. The accessor "getDoNotPerform"
2577   *         gives direct access to the value
2578   */
2579  public BooleanType getDoNotPerformElement() {
2580    if (this.doNotPerform == null)
2581      if (Configuration.errorOnAutoCreate())
2582        throw new Error("Attempt to auto-create MedicationRequest.doNotPerform");
2583      else if (Configuration.doAutoCreate())
2584        this.doNotPerform = new BooleanType(); // bb
2585    return this.doNotPerform;
2586  }
2587
2588  public boolean hasDoNotPerformElement() {
2589    return this.doNotPerform != null && !this.doNotPerform.isEmpty();
2590  }
2591
2592  public boolean hasDoNotPerform() {
2593    return this.doNotPerform != null && !this.doNotPerform.isEmpty();
2594  }
2595
2596  /**
2597   * @param value {@link #doNotPerform} (If true indicates that the provider is
2598   *              asking for the medication request not to occur.). This is the
2599   *              underlying object with id, value and extensions. The accessor
2600   *              "getDoNotPerform" gives direct access to the value
2601   */
2602  public MedicationRequest setDoNotPerformElement(BooleanType value) {
2603    this.doNotPerform = value;
2604    return this;
2605  }
2606
2607  /**
2608   * @return If true indicates that the provider is asking for the medication
2609   *         request not to occur.
2610   */
2611  public boolean getDoNotPerform() {
2612    return this.doNotPerform == null || this.doNotPerform.isEmpty() ? false : this.doNotPerform.getValue();
2613  }
2614
2615  /**
2616   * @param value If true indicates that the provider is asking for the medication
2617   *              request not to occur.
2618   */
2619  public MedicationRequest setDoNotPerform(boolean value) {
2620    if (this.doNotPerform == null)
2621      this.doNotPerform = new BooleanType();
2622    this.doNotPerform.setValue(value);
2623    return this;
2624  }
2625
2626  /**
2627   * @return {@link #reported} (Indicates if this record was captured as a
2628   *         secondary 'reported' record rather than as an original primary
2629   *         source-of-truth record. It may also indicate the source of the
2630   *         report.)
2631   */
2632  public Type getReported() {
2633    return this.reported;
2634  }
2635
2636  /**
2637   * @return {@link #reported} (Indicates if this record was captured as a
2638   *         secondary 'reported' record rather than as an original primary
2639   *         source-of-truth record. It may also indicate the source of the
2640   *         report.)
2641   */
2642  public BooleanType getReportedBooleanType() throws FHIRException {
2643    if (this.reported == null)
2644      this.reported = new BooleanType();
2645    if (!(this.reported instanceof BooleanType))
2646      throw new FHIRException("Type mismatch: the type BooleanType was expected, but "
2647          + this.reported.getClass().getName() + " was encountered");
2648    return (BooleanType) this.reported;
2649  }
2650
2651  public boolean hasReportedBooleanType() {
2652    return this != null && this.reported instanceof BooleanType;
2653  }
2654
2655  /**
2656   * @return {@link #reported} (Indicates if this record was captured as a
2657   *         secondary 'reported' record rather than as an original primary
2658   *         source-of-truth record. It may also indicate the source of the
2659   *         report.)
2660   */
2661  public Reference getReportedReference() throws FHIRException {
2662    if (this.reported == null)
2663      this.reported = new Reference();
2664    if (!(this.reported instanceof Reference))
2665      throw new FHIRException("Type mismatch: the type Reference was expected, but "
2666          + this.reported.getClass().getName() + " was encountered");
2667    return (Reference) this.reported;
2668  }
2669
2670  public boolean hasReportedReference() {
2671    return this != null && this.reported instanceof Reference;
2672  }
2673
2674  public boolean hasReported() {
2675    return this.reported != null && !this.reported.isEmpty();
2676  }
2677
2678  /**
2679   * @param value {@link #reported} (Indicates if this record was captured as a
2680   *              secondary 'reported' record rather than as an original primary
2681   *              source-of-truth record. It may also indicate the source of the
2682   *              report.)
2683   */
2684  public MedicationRequest setReported(Type value) {
2685    if (value != null && !(value instanceof BooleanType || value instanceof Reference))
2686      throw new Error("Not the right type for MedicationRequest.reported[x]: " + value.fhirType());
2687    this.reported = value;
2688    return this;
2689  }
2690
2691  /**
2692   * @return {@link #medication} (Identifies the medication being requested. This
2693   *         is a link to a resource that represents the medication which may be
2694   *         the details of the medication or simply an attribute carrying a code
2695   *         that identifies the medication from a known list of medications.)
2696   */
2697  public Type getMedication() {
2698    return this.medication;
2699  }
2700
2701  /**
2702   * @return {@link #medication} (Identifies the medication being requested. This
2703   *         is a link to a resource that represents the medication which may be
2704   *         the details of the medication or simply an attribute carrying a code
2705   *         that identifies the medication from a known list of medications.)
2706   */
2707  public CodeableConcept getMedicationCodeableConcept() throws FHIRException {
2708    if (this.medication == null)
2709      this.medication = new CodeableConcept();
2710    if (!(this.medication instanceof CodeableConcept))
2711      throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "
2712          + this.medication.getClass().getName() + " was encountered");
2713    return (CodeableConcept) this.medication;
2714  }
2715
2716  public boolean hasMedicationCodeableConcept() {
2717    return this != null && this.medication instanceof CodeableConcept;
2718  }
2719
2720  /**
2721   * @return {@link #medication} (Identifies the medication being requested. This
2722   *         is a link to a resource that represents the medication which may be
2723   *         the details of the medication or simply an attribute carrying a code
2724   *         that identifies the medication from a known list of medications.)
2725   */
2726  public Reference getMedicationReference() throws FHIRException {
2727    if (this.medication == null)
2728      this.medication = new Reference();
2729    if (!(this.medication instanceof Reference))
2730      throw new FHIRException("Type mismatch: the type Reference was expected, but "
2731          + this.medication.getClass().getName() + " was encountered");
2732    return (Reference) this.medication;
2733  }
2734
2735  public boolean hasMedicationReference() {
2736    return this != null && this.medication instanceof Reference;
2737  }
2738
2739  public boolean hasMedication() {
2740    return this.medication != null && !this.medication.isEmpty();
2741  }
2742
2743  /**
2744   * @param value {@link #medication} (Identifies the medication being requested.
2745   *              This is a link to a resource that represents the medication
2746   *              which may be the details of the medication or simply an
2747   *              attribute carrying a code that identifies the medication from a
2748   *              known list of medications.)
2749   */
2750  public MedicationRequest setMedication(Type value) {
2751    if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
2752      throw new Error("Not the right type for MedicationRequest.medication[x]: " + value.fhirType());
2753    this.medication = value;
2754    return this;
2755  }
2756
2757  /**
2758   * @return {@link #subject} (A link to a resource representing the person or set
2759   *         of individuals to whom the medication will be given.)
2760   */
2761  public Reference getSubject() {
2762    if (this.subject == null)
2763      if (Configuration.errorOnAutoCreate())
2764        throw new Error("Attempt to auto-create MedicationRequest.subject");
2765      else if (Configuration.doAutoCreate())
2766        this.subject = new Reference(); // cc
2767    return this.subject;
2768  }
2769
2770  public boolean hasSubject() {
2771    return this.subject != null && !this.subject.isEmpty();
2772  }
2773
2774  /**
2775   * @param value {@link #subject} (A link to a resource representing the person
2776   *              or set of individuals to whom the medication will be given.)
2777   */
2778  public MedicationRequest setSubject(Reference value) {
2779    this.subject = value;
2780    return this;
2781  }
2782
2783  /**
2784   * @return {@link #subject} The actual object that is the target of the
2785   *         reference. The reference library doesn't populate this, but you can
2786   *         use it to hold the resource if you resolve it. (A link to a resource
2787   *         representing the person or set of individuals to whom the medication
2788   *         will be given.)
2789   */
2790  public Resource getSubjectTarget() {
2791    return this.subjectTarget;
2792  }
2793
2794  /**
2795   * @param value {@link #subject} The actual object that is the target of the
2796   *              reference. The reference library doesn't use these, but you can
2797   *              use it to hold the resource if you resolve it. (A link to a
2798   *              resource representing the person or set of individuals to whom
2799   *              the medication will be given.)
2800   */
2801  public MedicationRequest setSubjectTarget(Resource value) {
2802    this.subjectTarget = value;
2803    return this;
2804  }
2805
2806  /**
2807   * @return {@link #encounter} (The Encounter during which this [x] was created
2808   *         or to which the creation of this record is tightly associated.)
2809   */
2810  public Reference getEncounter() {
2811    if (this.encounter == null)
2812      if (Configuration.errorOnAutoCreate())
2813        throw new Error("Attempt to auto-create MedicationRequest.encounter");
2814      else if (Configuration.doAutoCreate())
2815        this.encounter = new Reference(); // cc
2816    return this.encounter;
2817  }
2818
2819  public boolean hasEncounter() {
2820    return this.encounter != null && !this.encounter.isEmpty();
2821  }
2822
2823  /**
2824   * @param value {@link #encounter} (The Encounter during which this [x] was
2825   *              created or to which the creation of this record is tightly
2826   *              associated.)
2827   */
2828  public MedicationRequest setEncounter(Reference value) {
2829    this.encounter = value;
2830    return this;
2831  }
2832
2833  /**
2834   * @return {@link #encounter} The actual object that is the target of the
2835   *         reference. The reference library doesn't populate this, but you can
2836   *         use it to hold the resource if you resolve it. (The Encounter during
2837   *         which this [x] was created or to which the creation of this record is
2838   *         tightly associated.)
2839   */
2840  public Encounter getEncounterTarget() {
2841    if (this.encounterTarget == null)
2842      if (Configuration.errorOnAutoCreate())
2843        throw new Error("Attempt to auto-create MedicationRequest.encounter");
2844      else if (Configuration.doAutoCreate())
2845        this.encounterTarget = new Encounter(); // aa
2846    return this.encounterTarget;
2847  }
2848
2849  /**
2850   * @param value {@link #encounter} The actual object that is the target of the
2851   *              reference. The reference library doesn't use these, but you can
2852   *              use it to hold the resource if you resolve it. (The Encounter
2853   *              during which this [x] was created or to which the creation of
2854   *              this record is tightly associated.)
2855   */
2856  public MedicationRequest setEncounterTarget(Encounter value) {
2857    this.encounterTarget = value;
2858    return this;
2859  }
2860
2861  /**
2862   * @return {@link #supportingInformation} (Include additional information (for
2863   *         example, patient height and weight) that supports the ordering of the
2864   *         medication.)
2865   */
2866  public List<Reference> getSupportingInformation() {
2867    if (this.supportingInformation == null)
2868      this.supportingInformation = new ArrayList<Reference>();
2869    return this.supportingInformation;
2870  }
2871
2872  /**
2873   * @return Returns a reference to <code>this</code> for easy method chaining
2874   */
2875  public MedicationRequest setSupportingInformation(List<Reference> theSupportingInformation) {
2876    this.supportingInformation = theSupportingInformation;
2877    return this;
2878  }
2879
2880  public boolean hasSupportingInformation() {
2881    if (this.supportingInformation == null)
2882      return false;
2883    for (Reference item : this.supportingInformation)
2884      if (!item.isEmpty())
2885        return true;
2886    return false;
2887  }
2888
2889  public Reference addSupportingInformation() { // 3
2890    Reference t = new Reference();
2891    if (this.supportingInformation == null)
2892      this.supportingInformation = new ArrayList<Reference>();
2893    this.supportingInformation.add(t);
2894    return t;
2895  }
2896
2897  public MedicationRequest addSupportingInformation(Reference t) { // 3
2898    if (t == null)
2899      return this;
2900    if (this.supportingInformation == null)
2901      this.supportingInformation = new ArrayList<Reference>();
2902    this.supportingInformation.add(t);
2903    return this;
2904  }
2905
2906  /**
2907   * @return The first repetition of repeating field
2908   *         {@link #supportingInformation}, creating it if it does not already
2909   *         exist
2910   */
2911  public Reference getSupportingInformationFirstRep() {
2912    if (getSupportingInformation().isEmpty()) {
2913      addSupportingInformation();
2914    }
2915    return getSupportingInformation().get(0);
2916  }
2917
2918  /**
2919   * @deprecated Use Reference#setResource(IBaseResource) instead
2920   */
2921  @Deprecated
2922  public List<Resource> getSupportingInformationTarget() {
2923    if (this.supportingInformationTarget == null)
2924      this.supportingInformationTarget = new ArrayList<Resource>();
2925    return this.supportingInformationTarget;
2926  }
2927
2928  /**
2929   * @return {@link #authoredOn} (The date (and perhaps time) when the
2930   *         prescription was initially written or authored on.). This is the
2931   *         underlying object with id, value and extensions. The accessor
2932   *         "getAuthoredOn" gives direct access to the value
2933   */
2934  public DateTimeType getAuthoredOnElement() {
2935    if (this.authoredOn == null)
2936      if (Configuration.errorOnAutoCreate())
2937        throw new Error("Attempt to auto-create MedicationRequest.authoredOn");
2938      else if (Configuration.doAutoCreate())
2939        this.authoredOn = new DateTimeType(); // bb
2940    return this.authoredOn;
2941  }
2942
2943  public boolean hasAuthoredOnElement() {
2944    return this.authoredOn != null && !this.authoredOn.isEmpty();
2945  }
2946
2947  public boolean hasAuthoredOn() {
2948    return this.authoredOn != null && !this.authoredOn.isEmpty();
2949  }
2950
2951  /**
2952   * @param value {@link #authoredOn} (The date (and perhaps time) when the
2953   *              prescription was initially written or authored on.). This is the
2954   *              underlying object with id, value and extensions. The accessor
2955   *              "getAuthoredOn" gives direct access to the value
2956   */
2957  public MedicationRequest setAuthoredOnElement(DateTimeType value) {
2958    this.authoredOn = value;
2959    return this;
2960  }
2961
2962  /**
2963   * @return The date (and perhaps time) when the prescription was initially
2964   *         written or authored on.
2965   */
2966  public Date getAuthoredOn() {
2967    return this.authoredOn == null ? null : this.authoredOn.getValue();
2968  }
2969
2970  /**
2971   * @param value The date (and perhaps time) when the prescription was initially
2972   *              written or authored on.
2973   */
2974  public MedicationRequest setAuthoredOn(Date value) {
2975    if (value == null)
2976      this.authoredOn = null;
2977    else {
2978      if (this.authoredOn == null)
2979        this.authoredOn = new DateTimeType();
2980      this.authoredOn.setValue(value);
2981    }
2982    return this;
2983  }
2984
2985  /**
2986   * @return {@link #requester} (The individual, organization, or device that
2987   *         initiated the request and has responsibility for its activation.)
2988   */
2989  public Reference getRequester() {
2990    if (this.requester == null)
2991      if (Configuration.errorOnAutoCreate())
2992        throw new Error("Attempt to auto-create MedicationRequest.requester");
2993      else if (Configuration.doAutoCreate())
2994        this.requester = new Reference(); // cc
2995    return this.requester;
2996  }
2997
2998  public boolean hasRequester() {
2999    return this.requester != null && !this.requester.isEmpty();
3000  }
3001
3002  /**
3003   * @param value {@link #requester} (The individual, organization, or device that
3004   *              initiated the request and has responsibility for its
3005   *              activation.)
3006   */
3007  public MedicationRequest setRequester(Reference value) {
3008    this.requester = value;
3009    return this;
3010  }
3011
3012  /**
3013   * @return {@link #requester} The actual object that is the target of the
3014   *         reference. The reference library doesn't populate this, but you can
3015   *         use it to hold the resource if you resolve it. (The individual,
3016   *         organization, or device that initiated the request and has
3017   *         responsibility for its activation.)
3018   */
3019  public Resource getRequesterTarget() {
3020    return this.requesterTarget;
3021  }
3022
3023  /**
3024   * @param value {@link #requester} The actual object that is the target of the
3025   *              reference. The reference library doesn't use these, but you can
3026   *              use it to hold the resource if you resolve it. (The individual,
3027   *              organization, or device that initiated the request and has
3028   *              responsibility for its activation.)
3029   */
3030  public MedicationRequest setRequesterTarget(Resource value) {
3031    this.requesterTarget = value;
3032    return this;
3033  }
3034
3035  /**
3036   * @return {@link #performer} (The specified desired performer of the medication
3037   *         treatment (e.g. the performer of the medication administration).)
3038   */
3039  public Reference getPerformer() {
3040    if (this.performer == null)
3041      if (Configuration.errorOnAutoCreate())
3042        throw new Error("Attempt to auto-create MedicationRequest.performer");
3043      else if (Configuration.doAutoCreate())
3044        this.performer = new Reference(); // cc
3045    return this.performer;
3046  }
3047
3048  public boolean hasPerformer() {
3049    return this.performer != null && !this.performer.isEmpty();
3050  }
3051
3052  /**
3053   * @param value {@link #performer} (The specified desired performer of the
3054   *              medication treatment (e.g. the performer of the medication
3055   *              administration).)
3056   */
3057  public MedicationRequest setPerformer(Reference value) {
3058    this.performer = value;
3059    return this;
3060  }
3061
3062  /**
3063   * @return {@link #performer} The actual object that is the target of the
3064   *         reference. The reference library doesn't populate this, but you can
3065   *         use it to hold the resource if you resolve it. (The specified desired
3066   *         performer of the medication treatment (e.g. the performer of the
3067   *         medication administration).)
3068   */
3069  public Resource getPerformerTarget() {
3070    return this.performerTarget;
3071  }
3072
3073  /**
3074   * @param value {@link #performer} The actual object that is the target of the
3075   *              reference. The reference library doesn't use these, but you can
3076   *              use it to hold the resource if you resolve it. (The specified
3077   *              desired performer of the medication treatment (e.g. the
3078   *              performer of the medication administration).)
3079   */
3080  public MedicationRequest setPerformerTarget(Resource value) {
3081    this.performerTarget = value;
3082    return this;
3083  }
3084
3085  /**
3086   * @return {@link #performerType} (Indicates the type of performer of the
3087   *         administration of the medication.)
3088   */
3089  public CodeableConcept getPerformerType() {
3090    if (this.performerType == null)
3091      if (Configuration.errorOnAutoCreate())
3092        throw new Error("Attempt to auto-create MedicationRequest.performerType");
3093      else if (Configuration.doAutoCreate())
3094        this.performerType = new CodeableConcept(); // cc
3095    return this.performerType;
3096  }
3097
3098  public boolean hasPerformerType() {
3099    return this.performerType != null && !this.performerType.isEmpty();
3100  }
3101
3102  /**
3103   * @param value {@link #performerType} (Indicates the type of performer of the
3104   *              administration of the medication.)
3105   */
3106  public MedicationRequest setPerformerType(CodeableConcept value) {
3107    this.performerType = value;
3108    return this;
3109  }
3110
3111  /**
3112   * @return {@link #recorder} (The person who entered the order on behalf of
3113   *         another individual for example in the case of a verbal or a telephone
3114   *         order.)
3115   */
3116  public Reference getRecorder() {
3117    if (this.recorder == null)
3118      if (Configuration.errorOnAutoCreate())
3119        throw new Error("Attempt to auto-create MedicationRequest.recorder");
3120      else if (Configuration.doAutoCreate())
3121        this.recorder = new Reference(); // cc
3122    return this.recorder;
3123  }
3124
3125  public boolean hasRecorder() {
3126    return this.recorder != null && !this.recorder.isEmpty();
3127  }
3128
3129  /**
3130   * @param value {@link #recorder} (The person who entered the order on behalf of
3131   *              another individual for example in the case of a verbal or a
3132   *              telephone order.)
3133   */
3134  public MedicationRequest setRecorder(Reference value) {
3135    this.recorder = value;
3136    return this;
3137  }
3138
3139  /**
3140   * @return {@link #recorder} The actual object that is the target of the
3141   *         reference. The reference library doesn't populate this, but you can
3142   *         use it to hold the resource if you resolve it. (The person who
3143   *         entered the order on behalf of another individual for example in the
3144   *         case of a verbal or a telephone order.)
3145   */
3146  public Resource getRecorderTarget() {
3147    return this.recorderTarget;
3148  }
3149
3150  /**
3151   * @param value {@link #recorder} The actual object that is the target of the
3152   *              reference. The reference library doesn't use these, but you can
3153   *              use it to hold the resource if you resolve it. (The person who
3154   *              entered the order on behalf of another individual for example in
3155   *              the case of a verbal or a telephone order.)
3156   */
3157  public MedicationRequest setRecorderTarget(Resource value) {
3158    this.recorderTarget = value;
3159    return this;
3160  }
3161
3162  /**
3163   * @return {@link #reasonCode} (The reason or the indication for ordering or not
3164   *         ordering the medication.)
3165   */
3166  public List<CodeableConcept> getReasonCode() {
3167    if (this.reasonCode == null)
3168      this.reasonCode = new ArrayList<CodeableConcept>();
3169    return this.reasonCode;
3170  }
3171
3172  /**
3173   * @return Returns a reference to <code>this</code> for easy method chaining
3174   */
3175  public MedicationRequest setReasonCode(List<CodeableConcept> theReasonCode) {
3176    this.reasonCode = theReasonCode;
3177    return this;
3178  }
3179
3180  public boolean hasReasonCode() {
3181    if (this.reasonCode == null)
3182      return false;
3183    for (CodeableConcept item : this.reasonCode)
3184      if (!item.isEmpty())
3185        return true;
3186    return false;
3187  }
3188
3189  public CodeableConcept addReasonCode() { // 3
3190    CodeableConcept t = new CodeableConcept();
3191    if (this.reasonCode == null)
3192      this.reasonCode = new ArrayList<CodeableConcept>();
3193    this.reasonCode.add(t);
3194    return t;
3195  }
3196
3197  public MedicationRequest addReasonCode(CodeableConcept t) { // 3
3198    if (t == null)
3199      return this;
3200    if (this.reasonCode == null)
3201      this.reasonCode = new ArrayList<CodeableConcept>();
3202    this.reasonCode.add(t);
3203    return this;
3204  }
3205
3206  /**
3207   * @return The first repetition of repeating field {@link #reasonCode}, creating
3208   *         it if it does not already exist
3209   */
3210  public CodeableConcept getReasonCodeFirstRep() {
3211    if (getReasonCode().isEmpty()) {
3212      addReasonCode();
3213    }
3214    return getReasonCode().get(0);
3215  }
3216
3217  /**
3218   * @return {@link #reasonReference} (Condition or observation that supports why
3219   *         the medication was ordered.)
3220   */
3221  public List<Reference> getReasonReference() {
3222    if (this.reasonReference == null)
3223      this.reasonReference = new ArrayList<Reference>();
3224    return this.reasonReference;
3225  }
3226
3227  /**
3228   * @return Returns a reference to <code>this</code> for easy method chaining
3229   */
3230  public MedicationRequest setReasonReference(List<Reference> theReasonReference) {
3231    this.reasonReference = theReasonReference;
3232    return this;
3233  }
3234
3235  public boolean hasReasonReference() {
3236    if (this.reasonReference == null)
3237      return false;
3238    for (Reference item : this.reasonReference)
3239      if (!item.isEmpty())
3240        return true;
3241    return false;
3242  }
3243
3244  public Reference addReasonReference() { // 3
3245    Reference t = new Reference();
3246    if (this.reasonReference == null)
3247      this.reasonReference = new ArrayList<Reference>();
3248    this.reasonReference.add(t);
3249    return t;
3250  }
3251
3252  public MedicationRequest addReasonReference(Reference t) { // 3
3253    if (t == null)
3254      return this;
3255    if (this.reasonReference == null)
3256      this.reasonReference = new ArrayList<Reference>();
3257    this.reasonReference.add(t);
3258    return this;
3259  }
3260
3261  /**
3262   * @return The first repetition of repeating field {@link #reasonReference},
3263   *         creating it if it does not already exist
3264   */
3265  public Reference getReasonReferenceFirstRep() {
3266    if (getReasonReference().isEmpty()) {
3267      addReasonReference();
3268    }
3269    return getReasonReference().get(0);
3270  }
3271
3272  /**
3273   * @deprecated Use Reference#setResource(IBaseResource) instead
3274   */
3275  @Deprecated
3276  public List<Resource> getReasonReferenceTarget() {
3277    if (this.reasonReferenceTarget == null)
3278      this.reasonReferenceTarget = new ArrayList<Resource>();
3279    return this.reasonReferenceTarget;
3280  }
3281
3282  /**
3283   * @return {@link #instantiatesCanonical} (The URL pointing to a protocol,
3284   *         guideline, orderset, or other definition that is adhered to in whole
3285   *         or in part by this MedicationRequest.)
3286   */
3287  public List<CanonicalType> getInstantiatesCanonical() {
3288    if (this.instantiatesCanonical == null)
3289      this.instantiatesCanonical = new ArrayList<CanonicalType>();
3290    return this.instantiatesCanonical;
3291  }
3292
3293  /**
3294   * @return Returns a reference to <code>this</code> for easy method chaining
3295   */
3296  public MedicationRequest setInstantiatesCanonical(List<CanonicalType> theInstantiatesCanonical) {
3297    this.instantiatesCanonical = theInstantiatesCanonical;
3298    return this;
3299  }
3300
3301  public boolean hasInstantiatesCanonical() {
3302    if (this.instantiatesCanonical == null)
3303      return false;
3304    for (CanonicalType item : this.instantiatesCanonical)
3305      if (!item.isEmpty())
3306        return true;
3307    return false;
3308  }
3309
3310  /**
3311   * @return {@link #instantiatesCanonical} (The URL pointing to a protocol,
3312   *         guideline, orderset, or other definition that is adhered to in whole
3313   *         or in part by this MedicationRequest.)
3314   */
3315  public CanonicalType addInstantiatesCanonicalElement() {// 2
3316    CanonicalType t = new CanonicalType();
3317    if (this.instantiatesCanonical == null)
3318      this.instantiatesCanonical = new ArrayList<CanonicalType>();
3319    this.instantiatesCanonical.add(t);
3320    return t;
3321  }
3322
3323  /**
3324   * @param value {@link #instantiatesCanonical} (The URL pointing to a protocol,
3325   *              guideline, orderset, or other definition that is adhered to in
3326   *              whole or in part by this MedicationRequest.)
3327   */
3328  public MedicationRequest addInstantiatesCanonical(String value) { // 1
3329    CanonicalType t = new CanonicalType();
3330    t.setValue(value);
3331    if (this.instantiatesCanonical == null)
3332      this.instantiatesCanonical = new ArrayList<CanonicalType>();
3333    this.instantiatesCanonical.add(t);
3334    return this;
3335  }
3336
3337  /**
3338   * @param value {@link #instantiatesCanonical} (The URL pointing to a protocol,
3339   *              guideline, orderset, or other definition that is adhered to in
3340   *              whole or in part by this MedicationRequest.)
3341   */
3342  public boolean hasInstantiatesCanonical(String value) {
3343    if (this.instantiatesCanonical == null)
3344      return false;
3345    for (CanonicalType v : this.instantiatesCanonical)
3346      if (v.getValue().equals(value)) // canonical
3347        return true;
3348    return false;
3349  }
3350
3351  /**
3352   * @return {@link #instantiatesUri} (The URL pointing to an externally
3353   *         maintained protocol, guideline, orderset or other definition that is
3354   *         adhered to in whole or in part by this MedicationRequest.)
3355   */
3356  public List<UriType> getInstantiatesUri() {
3357    if (this.instantiatesUri == null)
3358      this.instantiatesUri = new ArrayList<UriType>();
3359    return this.instantiatesUri;
3360  }
3361
3362  /**
3363   * @return Returns a reference to <code>this</code> for easy method chaining
3364   */
3365  public MedicationRequest setInstantiatesUri(List<UriType> theInstantiatesUri) {
3366    this.instantiatesUri = theInstantiatesUri;
3367    return this;
3368  }
3369
3370  public boolean hasInstantiatesUri() {
3371    if (this.instantiatesUri == null)
3372      return false;
3373    for (UriType item : this.instantiatesUri)
3374      if (!item.isEmpty())
3375        return true;
3376    return false;
3377  }
3378
3379  /**
3380   * @return {@link #instantiatesUri} (The URL pointing to an externally
3381   *         maintained protocol, guideline, orderset or other definition that is
3382   *         adhered to in whole or in part by this MedicationRequest.)
3383   */
3384  public UriType addInstantiatesUriElement() {// 2
3385    UriType t = new UriType();
3386    if (this.instantiatesUri == null)
3387      this.instantiatesUri = new ArrayList<UriType>();
3388    this.instantiatesUri.add(t);
3389    return t;
3390  }
3391
3392  /**
3393   * @param value {@link #instantiatesUri} (The URL pointing to an externally
3394   *              maintained protocol, guideline, orderset or other definition
3395   *              that is adhered to in whole or in part by this
3396   *              MedicationRequest.)
3397   */
3398  public MedicationRequest addInstantiatesUri(String value) { // 1
3399    UriType t = new UriType();
3400    t.setValue(value);
3401    if (this.instantiatesUri == null)
3402      this.instantiatesUri = new ArrayList<UriType>();
3403    this.instantiatesUri.add(t);
3404    return this;
3405  }
3406
3407  /**
3408   * @param value {@link #instantiatesUri} (The URL pointing to an externally
3409   *              maintained protocol, guideline, orderset or other definition
3410   *              that is adhered to in whole or in part by this
3411   *              MedicationRequest.)
3412   */
3413  public boolean hasInstantiatesUri(String value) {
3414    if (this.instantiatesUri == null)
3415      return false;
3416    for (UriType v : this.instantiatesUri)
3417      if (v.getValue().equals(value)) // uri
3418        return true;
3419    return false;
3420  }
3421
3422  /**
3423   * @return {@link #basedOn} (A plan or request that is fulfilled in whole or in
3424   *         part by this medication request.)
3425   */
3426  public List<Reference> getBasedOn() {
3427    if (this.basedOn == null)
3428      this.basedOn = new ArrayList<Reference>();
3429    return this.basedOn;
3430  }
3431
3432  /**
3433   * @return Returns a reference to <code>this</code> for easy method chaining
3434   */
3435  public MedicationRequest setBasedOn(List<Reference> theBasedOn) {
3436    this.basedOn = theBasedOn;
3437    return this;
3438  }
3439
3440  public boolean hasBasedOn() {
3441    if (this.basedOn == null)
3442      return false;
3443    for (Reference item : this.basedOn)
3444      if (!item.isEmpty())
3445        return true;
3446    return false;
3447  }
3448
3449  public Reference addBasedOn() { // 3
3450    Reference t = new Reference();
3451    if (this.basedOn == null)
3452      this.basedOn = new ArrayList<Reference>();
3453    this.basedOn.add(t);
3454    return t;
3455  }
3456
3457  public MedicationRequest addBasedOn(Reference t) { // 3
3458    if (t == null)
3459      return this;
3460    if (this.basedOn == null)
3461      this.basedOn = new ArrayList<Reference>();
3462    this.basedOn.add(t);
3463    return this;
3464  }
3465
3466  /**
3467   * @return The first repetition of repeating field {@link #basedOn}, creating it
3468   *         if it does not already exist
3469   */
3470  public Reference getBasedOnFirstRep() {
3471    if (getBasedOn().isEmpty()) {
3472      addBasedOn();
3473    }
3474    return getBasedOn().get(0);
3475  }
3476
3477  /**
3478   * @deprecated Use Reference#setResource(IBaseResource) instead
3479   */
3480  @Deprecated
3481  public List<Resource> getBasedOnTarget() {
3482    if (this.basedOnTarget == null)
3483      this.basedOnTarget = new ArrayList<Resource>();
3484    return this.basedOnTarget;
3485  }
3486
3487  /**
3488   * @return {@link #groupIdentifier} (A shared identifier common to all requests
3489   *         that were authorized more or less simultaneously by a single author,
3490   *         representing the identifier of the requisition or prescription.)
3491   */
3492  public Identifier getGroupIdentifier() {
3493    if (this.groupIdentifier == null)
3494      if (Configuration.errorOnAutoCreate())
3495        throw new Error("Attempt to auto-create MedicationRequest.groupIdentifier");
3496      else if (Configuration.doAutoCreate())
3497        this.groupIdentifier = new Identifier(); // cc
3498    return this.groupIdentifier;
3499  }
3500
3501  public boolean hasGroupIdentifier() {
3502    return this.groupIdentifier != null && !this.groupIdentifier.isEmpty();
3503  }
3504
3505  /**
3506   * @param value {@link #groupIdentifier} (A shared identifier common to all
3507   *              requests that were authorized more or less simultaneously by a
3508   *              single author, representing the identifier of the requisition or
3509   *              prescription.)
3510   */
3511  public MedicationRequest setGroupIdentifier(Identifier value) {
3512    this.groupIdentifier = value;
3513    return this;
3514  }
3515
3516  /**
3517   * @return {@link #courseOfTherapyType} (The description of the overall patte3rn
3518   *         of the administration of the medication to the patient.)
3519   */
3520  public CodeableConcept getCourseOfTherapyType() {
3521    if (this.courseOfTherapyType == null)
3522      if (Configuration.errorOnAutoCreate())
3523        throw new Error("Attempt to auto-create MedicationRequest.courseOfTherapyType");
3524      else if (Configuration.doAutoCreate())
3525        this.courseOfTherapyType = new CodeableConcept(); // cc
3526    return this.courseOfTherapyType;
3527  }
3528
3529  public boolean hasCourseOfTherapyType() {
3530    return this.courseOfTherapyType != null && !this.courseOfTherapyType.isEmpty();
3531  }
3532
3533  /**
3534   * @param value {@link #courseOfTherapyType} (The description of the overall
3535   *              patte3rn of the administration of the medication to the
3536   *              patient.)
3537   */
3538  public MedicationRequest setCourseOfTherapyType(CodeableConcept value) {
3539    this.courseOfTherapyType = value;
3540    return this;
3541  }
3542
3543  /**
3544   * @return {@link #insurance} (Insurance plans, coverage extensions,
3545   *         pre-authorizations and/or pre-determinations that may be required for
3546   *         delivering the requested service.)
3547   */
3548  public List<Reference> getInsurance() {
3549    if (this.insurance == null)
3550      this.insurance = new ArrayList<Reference>();
3551    return this.insurance;
3552  }
3553
3554  /**
3555   * @return Returns a reference to <code>this</code> for easy method chaining
3556   */
3557  public MedicationRequest setInsurance(List<Reference> theInsurance) {
3558    this.insurance = theInsurance;
3559    return this;
3560  }
3561
3562  public boolean hasInsurance() {
3563    if (this.insurance == null)
3564      return false;
3565    for (Reference item : this.insurance)
3566      if (!item.isEmpty())
3567        return true;
3568    return false;
3569  }
3570
3571  public Reference addInsurance() { // 3
3572    Reference t = new Reference();
3573    if (this.insurance == null)
3574      this.insurance = new ArrayList<Reference>();
3575    this.insurance.add(t);
3576    return t;
3577  }
3578
3579  public MedicationRequest addInsurance(Reference t) { // 3
3580    if (t == null)
3581      return this;
3582    if (this.insurance == null)
3583      this.insurance = new ArrayList<Reference>();
3584    this.insurance.add(t);
3585    return this;
3586  }
3587
3588  /**
3589   * @return The first repetition of repeating field {@link #insurance}, creating
3590   *         it if it does not already exist
3591   */
3592  public Reference getInsuranceFirstRep() {
3593    if (getInsurance().isEmpty()) {
3594      addInsurance();
3595    }
3596    return getInsurance().get(0);
3597  }
3598
3599  /**
3600   * @deprecated Use Reference#setResource(IBaseResource) instead
3601   */
3602  @Deprecated
3603  public List<Resource> getInsuranceTarget() {
3604    if (this.insuranceTarget == null)
3605      this.insuranceTarget = new ArrayList<Resource>();
3606    return this.insuranceTarget;
3607  }
3608
3609  /**
3610   * @return {@link #note} (Extra information about the prescription that could
3611   *         not be conveyed by the other attributes.)
3612   */
3613  public List<Annotation> getNote() {
3614    if (this.note == null)
3615      this.note = new ArrayList<Annotation>();
3616    return this.note;
3617  }
3618
3619  /**
3620   * @return Returns a reference to <code>this</code> for easy method chaining
3621   */
3622  public MedicationRequest setNote(List<Annotation> theNote) {
3623    this.note = theNote;
3624    return this;
3625  }
3626
3627  public boolean hasNote() {
3628    if (this.note == null)
3629      return false;
3630    for (Annotation item : this.note)
3631      if (!item.isEmpty())
3632        return true;
3633    return false;
3634  }
3635
3636  public Annotation addNote() { // 3
3637    Annotation t = new Annotation();
3638    if (this.note == null)
3639      this.note = new ArrayList<Annotation>();
3640    this.note.add(t);
3641    return t;
3642  }
3643
3644  public MedicationRequest addNote(Annotation t) { // 3
3645    if (t == null)
3646      return this;
3647    if (this.note == null)
3648      this.note = new ArrayList<Annotation>();
3649    this.note.add(t);
3650    return this;
3651  }
3652
3653  /**
3654   * @return The first repetition of repeating field {@link #note}, creating it if
3655   *         it does not already exist
3656   */
3657  public Annotation getNoteFirstRep() {
3658    if (getNote().isEmpty()) {
3659      addNote();
3660    }
3661    return getNote().get(0);
3662  }
3663
3664  /**
3665   * @return {@link #dosageInstruction} (Indicates how the medication is to be
3666   *         used by the patient.)
3667   */
3668  public List<Dosage> getDosageInstruction() {
3669    if (this.dosageInstruction == null)
3670      this.dosageInstruction = new ArrayList<Dosage>();
3671    return this.dosageInstruction;
3672  }
3673
3674  /**
3675   * @return Returns a reference to <code>this</code> for easy method chaining
3676   */
3677  public MedicationRequest setDosageInstruction(List<Dosage> theDosageInstruction) {
3678    this.dosageInstruction = theDosageInstruction;
3679    return this;
3680  }
3681
3682  public boolean hasDosageInstruction() {
3683    if (this.dosageInstruction == null)
3684      return false;
3685    for (Dosage item : this.dosageInstruction)
3686      if (!item.isEmpty())
3687        return true;
3688    return false;
3689  }
3690
3691  public Dosage addDosageInstruction() { // 3
3692    Dosage t = new Dosage();
3693    if (this.dosageInstruction == null)
3694      this.dosageInstruction = new ArrayList<Dosage>();
3695    this.dosageInstruction.add(t);
3696    return t;
3697  }
3698
3699  public MedicationRequest addDosageInstruction(Dosage t) { // 3
3700    if (t == null)
3701      return this;
3702    if (this.dosageInstruction == null)
3703      this.dosageInstruction = new ArrayList<Dosage>();
3704    this.dosageInstruction.add(t);
3705    return this;
3706  }
3707
3708  /**
3709   * @return The first repetition of repeating field {@link #dosageInstruction},
3710   *         creating it if it does not already exist
3711   */
3712  public Dosage getDosageInstructionFirstRep() {
3713    if (getDosageInstruction().isEmpty()) {
3714      addDosageInstruction();
3715    }
3716    return getDosageInstruction().get(0);
3717  }
3718
3719  /**
3720   * @return {@link #dispenseRequest} (Indicates the specific details for the
3721   *         dispense or medication supply part of a medication request (also
3722   *         known as a Medication Prescription or Medication Order). Note that
3723   *         this information is not always sent with the order. There may be in
3724   *         some settings (e.g. hospitals) institutional or system support for
3725   *         completing the dispense details in the pharmacy department.)
3726   */
3727  public MedicationRequestDispenseRequestComponent getDispenseRequest() {
3728    if (this.dispenseRequest == null)
3729      if (Configuration.errorOnAutoCreate())
3730        throw new Error("Attempt to auto-create MedicationRequest.dispenseRequest");
3731      else if (Configuration.doAutoCreate())
3732        this.dispenseRequest = new MedicationRequestDispenseRequestComponent(); // cc
3733    return this.dispenseRequest;
3734  }
3735
3736  public boolean hasDispenseRequest() {
3737    return this.dispenseRequest != null && !this.dispenseRequest.isEmpty();
3738  }
3739
3740  /**
3741   * @param value {@link #dispenseRequest} (Indicates the specific details for the
3742   *              dispense or medication supply part of a medication request (also
3743   *              known as a Medication Prescription or Medication Order). Note
3744   *              that this information is not always sent with the order. There
3745   *              may be in some settings (e.g. hospitals) institutional or system
3746   *              support for completing the dispense details in the pharmacy
3747   *              department.)
3748   */
3749  public MedicationRequest setDispenseRequest(MedicationRequestDispenseRequestComponent value) {
3750    this.dispenseRequest = value;
3751    return this;
3752  }
3753
3754  /**
3755   * @return {@link #substitution} (Indicates whether or not substitution can or
3756   *         should be part of the dispense. In some cases, substitution must
3757   *         happen, in other cases substitution must not happen. This block
3758   *         explains the prescriber's intent. If nothing is specified
3759   *         substitution may be done.)
3760   */
3761  public MedicationRequestSubstitutionComponent getSubstitution() {
3762    if (this.substitution == null)
3763      if (Configuration.errorOnAutoCreate())
3764        throw new Error("Attempt to auto-create MedicationRequest.substitution");
3765      else if (Configuration.doAutoCreate())
3766        this.substitution = new MedicationRequestSubstitutionComponent(); // cc
3767    return this.substitution;
3768  }
3769
3770  public boolean hasSubstitution() {
3771    return this.substitution != null && !this.substitution.isEmpty();
3772  }
3773
3774  /**
3775   * @param value {@link #substitution} (Indicates whether or not substitution can
3776   *              or should be part of the dispense. In some cases, substitution
3777   *              must happen, in other cases substitution must not happen. This
3778   *              block explains the prescriber's intent. If nothing is specified
3779   *              substitution may be done.)
3780   */
3781  public MedicationRequest setSubstitution(MedicationRequestSubstitutionComponent value) {
3782    this.substitution = value;
3783    return this;
3784  }
3785
3786  /**
3787   * @return {@link #priorPrescription} (A link to a resource representing an
3788   *         earlier order related order or prescription.)
3789   */
3790  public Reference getPriorPrescription() {
3791    if (this.priorPrescription == null)
3792      if (Configuration.errorOnAutoCreate())
3793        throw new Error("Attempt to auto-create MedicationRequest.priorPrescription");
3794      else if (Configuration.doAutoCreate())
3795        this.priorPrescription = new Reference(); // cc
3796    return this.priorPrescription;
3797  }
3798
3799  public boolean hasPriorPrescription() {
3800    return this.priorPrescription != null && !this.priorPrescription.isEmpty();
3801  }
3802
3803  /**
3804   * @param value {@link #priorPrescription} (A link to a resource representing an
3805   *              earlier order related order or prescription.)
3806   */
3807  public MedicationRequest setPriorPrescription(Reference value) {
3808    this.priorPrescription = value;
3809    return this;
3810  }
3811
3812  /**
3813   * @return {@link #priorPrescription} The actual object that is the target of
3814   *         the reference. The reference library doesn't populate this, but you
3815   *         can use it to hold the resource if you resolve it. (A link to a
3816   *         resource representing an earlier order related order or
3817   *         prescription.)
3818   */
3819  public MedicationRequest getPriorPrescriptionTarget() {
3820    if (this.priorPrescriptionTarget == null)
3821      if (Configuration.errorOnAutoCreate())
3822        throw new Error("Attempt to auto-create MedicationRequest.priorPrescription");
3823      else if (Configuration.doAutoCreate())
3824        this.priorPrescriptionTarget = new MedicationRequest(); // aa
3825    return this.priorPrescriptionTarget;
3826  }
3827
3828  /**
3829   * @param value {@link #priorPrescription} The actual object that is the target
3830   *              of the reference. The reference library doesn't use these, but
3831   *              you can use it to hold the resource if you resolve it. (A link
3832   *              to a resource representing an earlier order related order or
3833   *              prescription.)
3834   */
3835  public MedicationRequest setPriorPrescriptionTarget(MedicationRequest value) {
3836    this.priorPrescriptionTarget = value;
3837    return this;
3838  }
3839
3840  /**
3841   * @return {@link #detectedIssue} (Indicates an actual or potential clinical
3842   *         issue with or between one or more active or proposed clinical actions
3843   *         for a patient; e.g. Drug-drug interaction, duplicate therapy, dosage
3844   *         alert etc.)
3845   */
3846  public List<Reference> getDetectedIssue() {
3847    if (this.detectedIssue == null)
3848      this.detectedIssue = new ArrayList<Reference>();
3849    return this.detectedIssue;
3850  }
3851
3852  /**
3853   * @return Returns a reference to <code>this</code> for easy method chaining
3854   */
3855  public MedicationRequest setDetectedIssue(List<Reference> theDetectedIssue) {
3856    this.detectedIssue = theDetectedIssue;
3857    return this;
3858  }
3859
3860  public boolean hasDetectedIssue() {
3861    if (this.detectedIssue == null)
3862      return false;
3863    for (Reference item : this.detectedIssue)
3864      if (!item.isEmpty())
3865        return true;
3866    return false;
3867  }
3868
3869  public Reference addDetectedIssue() { // 3
3870    Reference t = new Reference();
3871    if (this.detectedIssue == null)
3872      this.detectedIssue = new ArrayList<Reference>();
3873    this.detectedIssue.add(t);
3874    return t;
3875  }
3876
3877  public MedicationRequest addDetectedIssue(Reference t) { // 3
3878    if (t == null)
3879      return this;
3880    if (this.detectedIssue == null)
3881      this.detectedIssue = new ArrayList<Reference>();
3882    this.detectedIssue.add(t);
3883    return this;
3884  }
3885
3886  /**
3887   * @return The first repetition of repeating field {@link #detectedIssue},
3888   *         creating it if it does not already exist
3889   */
3890  public Reference getDetectedIssueFirstRep() {
3891    if (getDetectedIssue().isEmpty()) {
3892      addDetectedIssue();
3893    }
3894    return getDetectedIssue().get(0);
3895  }
3896
3897  /**
3898   * @deprecated Use Reference#setResource(IBaseResource) instead
3899   */
3900  @Deprecated
3901  public List<DetectedIssue> getDetectedIssueTarget() {
3902    if (this.detectedIssueTarget == null)
3903      this.detectedIssueTarget = new ArrayList<DetectedIssue>();
3904    return this.detectedIssueTarget;
3905  }
3906
3907  /**
3908   * @deprecated Use Reference#setResource(IBaseResource) instead
3909   */
3910  @Deprecated
3911  public DetectedIssue addDetectedIssueTarget() {
3912    DetectedIssue r = new DetectedIssue();
3913    if (this.detectedIssueTarget == null)
3914      this.detectedIssueTarget = new ArrayList<DetectedIssue>();
3915    this.detectedIssueTarget.add(r);
3916    return r;
3917  }
3918
3919  /**
3920   * @return {@link #eventHistory} (Links to Provenance records for past versions
3921   *         of this resource or fulfilling request or event resources that
3922   *         identify key state transitions or updates that are likely to be
3923   *         relevant to a user looking at the current version of the resource.)
3924   */
3925  public List<Reference> getEventHistory() {
3926    if (this.eventHistory == null)
3927      this.eventHistory = new ArrayList<Reference>();
3928    return this.eventHistory;
3929  }
3930
3931  /**
3932   * @return Returns a reference to <code>this</code> for easy method chaining
3933   */
3934  public MedicationRequest setEventHistory(List<Reference> theEventHistory) {
3935    this.eventHistory = theEventHistory;
3936    return this;
3937  }
3938
3939  public boolean hasEventHistory() {
3940    if (this.eventHistory == null)
3941      return false;
3942    for (Reference item : this.eventHistory)
3943      if (!item.isEmpty())
3944        return true;
3945    return false;
3946  }
3947
3948  public Reference addEventHistory() { // 3
3949    Reference t = new Reference();
3950    if (this.eventHistory == null)
3951      this.eventHistory = new ArrayList<Reference>();
3952    this.eventHistory.add(t);
3953    return t;
3954  }
3955
3956  public MedicationRequest addEventHistory(Reference t) { // 3
3957    if (t == null)
3958      return this;
3959    if (this.eventHistory == null)
3960      this.eventHistory = new ArrayList<Reference>();
3961    this.eventHistory.add(t);
3962    return this;
3963  }
3964
3965  /**
3966   * @return The first repetition of repeating field {@link #eventHistory},
3967   *         creating it if it does not already exist
3968   */
3969  public Reference getEventHistoryFirstRep() {
3970    if (getEventHistory().isEmpty()) {
3971      addEventHistory();
3972    }
3973    return getEventHistory().get(0);
3974  }
3975
3976  /**
3977   * @deprecated Use Reference#setResource(IBaseResource) instead
3978   */
3979  @Deprecated
3980  public List<Provenance> getEventHistoryTarget() {
3981    if (this.eventHistoryTarget == null)
3982      this.eventHistoryTarget = new ArrayList<Provenance>();
3983    return this.eventHistoryTarget;
3984  }
3985
3986  /**
3987   * @deprecated Use Reference#setResource(IBaseResource) instead
3988   */
3989  @Deprecated
3990  public Provenance addEventHistoryTarget() {
3991    Provenance r = new Provenance();
3992    if (this.eventHistoryTarget == null)
3993      this.eventHistoryTarget = new ArrayList<Provenance>();
3994    this.eventHistoryTarget.add(r);
3995    return r;
3996  }
3997
3998  protected void listChildren(List<Property> children) {
3999    super.listChildren(children);
4000    children.add(new Property("identifier", "Identifier",
4001        "Identifiers associated with this medication request that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate. They are business identifiers assigned to this resource by the performer or other systems and remain constant as the resource is updated and propagates from server to server.",
4002        0, java.lang.Integer.MAX_VALUE, identifier));
4003    children.add(new Property("status", "code",
4004        "A code specifying the current state of the order.  Generally, this will be active or completed state.", 0, 1,
4005        status));
4006    children.add(new Property("statusReason", "CodeableConcept",
4007        "Captures the reason for the current state of the MedicationRequest.", 0, 1, statusReason));
4008    children.add(
4009        new Property("intent", "code", "Whether the request is a proposal, plan, or an original order.", 0, 1, intent));
4010    children.add(new Property("category", "CodeableConcept",
4011        "Indicates the type of medication request (for example, where the medication is expected to be consumed or administered (i.e. inpatient or outpatient)).",
4012        0, java.lang.Integer.MAX_VALUE, category));
4013    children.add(new Property("priority", "code",
4014        "Indicates how quickly the Medication Request should be addressed with respect to other requests.", 0, 1,
4015        priority));
4016    children.add(new Property("doNotPerform", "boolean",
4017        "If true indicates that the provider is asking for the medication request not to occur.", 0, 1, doNotPerform));
4018    children.add(new Property("reported[x]",
4019        "boolean|Reference(Patient|Practitioner|PractitionerRole|RelatedPerson|Organization)",
4020        "Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.",
4021        0, 1, reported));
4022    children.add(new Property("medication[x]", "CodeableConcept|Reference(Medication)",
4023        "Identifies the medication being requested. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications.",
4024        0, 1, medication));
4025    children.add(new Property("subject", "Reference(Patient|Group)",
4026        "A link to a resource representing the person or set of individuals to whom the medication will be given.", 0,
4027        1, subject));
4028    children.add(new Property("encounter", "Reference(Encounter)",
4029        "The Encounter during which this [x] was created or to which the creation of this record is tightly associated.",
4030        0, 1, encounter));
4031    children.add(new Property("supportingInformation", "Reference(Any)",
4032        "Include additional information (for example, patient height and weight) that supports the ordering of the medication.",
4033        0, java.lang.Integer.MAX_VALUE, supportingInformation));
4034    children.add(new Property("authoredOn", "dateTime",
4035        "The date (and perhaps time) when the prescription was initially written or authored on.", 0, 1, authoredOn));
4036    children.add(new Property("requester",
4037        "Reference(Practitioner|PractitionerRole|Organization|Patient|RelatedPerson|Device)",
4038        "The individual, organization, or device that initiated the request and has responsibility for its activation.",
4039        0, 1, requester));
4040    children.add(new Property("performer",
4041        "Reference(Practitioner|PractitionerRole|Organization|Patient|Device|RelatedPerson|CareTeam)",
4042        "The specified desired performer of the medication treatment (e.g. the performer of the medication administration).",
4043        0, 1, performer));
4044    children.add(new Property("performerType", "CodeableConcept",
4045        "Indicates the type of performer of the administration of the medication.", 0, 1, performerType));
4046    children.add(new Property("recorder", "Reference(Practitioner|PractitionerRole)",
4047        "The person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.",
4048        0, 1, recorder));
4049    children.add(new Property("reasonCode", "CodeableConcept",
4050        "The reason or the indication for ordering or not ordering the medication.", 0, java.lang.Integer.MAX_VALUE,
4051        reasonCode));
4052    children.add(new Property("reasonReference", "Reference(Condition|Observation)",
4053        "Condition or observation that supports why the medication was ordered.", 0, java.lang.Integer.MAX_VALUE,
4054        reasonReference));
4055    children.add(new Property("instantiatesCanonical", "canonical",
4056        "The URL pointing to a protocol, guideline, orderset, or other definition that is adhered to in whole or in part by this MedicationRequest.",
4057        0, java.lang.Integer.MAX_VALUE, instantiatesCanonical));
4058    children.add(new Property("instantiatesUri", "uri",
4059        "The URL pointing to an externally maintained protocol, guideline, orderset or other definition that is adhered to in whole or in part by this MedicationRequest.",
4060        0, java.lang.Integer.MAX_VALUE, instantiatesUri));
4061    children
4062        .add(new Property("basedOn", "Reference(CarePlan|MedicationRequest|ServiceRequest|ImmunizationRecommendation)",
4063            "A plan or request that is fulfilled in whole or in part by this medication request.", 0,
4064            java.lang.Integer.MAX_VALUE, basedOn));
4065    children.add(new Property("groupIdentifier", "Identifier",
4066        "A shared identifier common to all requests that were authorized more or less simultaneously by a single author, representing the identifier of the requisition or prescription.",
4067        0, 1, groupIdentifier));
4068    children.add(new Property("courseOfTherapyType", "CodeableConcept",
4069        "The description of the overall patte3rn of the administration of the medication to the patient.", 0, 1,
4070        courseOfTherapyType));
4071    children.add(new Property("insurance", "Reference(Coverage|ClaimResponse)",
4072        "Insurance plans, coverage extensions, pre-authorizations and/or pre-determinations that may be required for delivering the requested service.",
4073        0, java.lang.Integer.MAX_VALUE, insurance));
4074    children.add(new Property("note", "Annotation",
4075        "Extra information about the prescription that could not be conveyed by the other attributes.", 0,
4076        java.lang.Integer.MAX_VALUE, note));
4077    children
4078        .add(new Property("dosageInstruction", "Dosage", "Indicates how the medication is to be used by the patient.",
4079            0, java.lang.Integer.MAX_VALUE, dosageInstruction));
4080    children.add(new Property("dispenseRequest", "",
4081        "Indicates the specific details for the dispense or medication supply part of a medication request (also known as a Medication Prescription or Medication Order).  Note that this information is not always sent with the order.  There may be in some settings (e.g. hospitals) institutional or system support for completing the dispense details in the pharmacy department.",
4082        0, 1, dispenseRequest));
4083    children.add(new Property("substitution", "",
4084        "Indicates whether or not substitution can or should be part of the dispense. In some cases, substitution must happen, in other cases substitution must not happen. This block explains the prescriber's intent. If nothing is specified substitution may be done.",
4085        0, 1, substitution));
4086    children.add(new Property("priorPrescription", "Reference(MedicationRequest)",
4087        "A link to a resource representing an earlier order related order or prescription.", 0, 1, priorPrescription));
4088    children.add(new Property("detectedIssue", "Reference(DetectedIssue)",
4089        "Indicates an actual or potential clinical issue with or between one or more active or proposed clinical actions for a patient; e.g. Drug-drug interaction, duplicate therapy, dosage alert etc.",
4090        0, java.lang.Integer.MAX_VALUE, detectedIssue));
4091    children.add(new Property("eventHistory", "Reference(Provenance)",
4092        "Links to Provenance records for past versions of this resource or fulfilling request or event resources that identify key state transitions or updates that are likely to be relevant to a user looking at the current version of the resource.",
4093        0, java.lang.Integer.MAX_VALUE, eventHistory));
4094  }
4095
4096  @Override
4097  public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
4098    switch (_hash) {
4099    case -1618432855:
4100      /* identifier */ return new Property("identifier", "Identifier",
4101          "Identifiers associated with this medication request that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate. They are business identifiers assigned to this resource by the performer or other systems and remain constant as the resource is updated and propagates from server to server.",
4102          0, java.lang.Integer.MAX_VALUE, identifier);
4103    case -892481550:
4104      /* status */ return new Property("status", "code",
4105          "A code specifying the current state of the order.  Generally, this will be active or completed state.", 0, 1,
4106          status);
4107    case 2051346646:
4108      /* statusReason */ return new Property("statusReason", "CodeableConcept",
4109          "Captures the reason for the current state of the MedicationRequest.", 0, 1, statusReason);
4110    case -1183762788:
4111      /* intent */ return new Property("intent", "code",
4112          "Whether the request is a proposal, plan, or an original order.", 0, 1, intent);
4113    case 50511102:
4114      /* category */ return new Property("category", "CodeableConcept",
4115          "Indicates the type of medication request (for example, where the medication is expected to be consumed or administered (i.e. inpatient or outpatient)).",
4116          0, java.lang.Integer.MAX_VALUE, category);
4117    case -1165461084:
4118      /* priority */ return new Property("priority", "code",
4119          "Indicates how quickly the Medication Request should be addressed with respect to other requests.", 0, 1,
4120          priority);
4121    case -1788508167:
4122      /* doNotPerform */ return new Property("doNotPerform", "boolean",
4123          "If true indicates that the provider is asking for the medication request not to occur.", 0, 1, doNotPerform);
4124    case -241505587:
4125      /* reported[x] */ return new Property("reported[x]",
4126          "boolean|Reference(Patient|Practitioner|PractitionerRole|RelatedPerson|Organization)",
4127          "Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.",
4128          0, 1, reported);
4129    case -427039533:
4130      /* reported */ return new Property("reported[x]",
4131          "boolean|Reference(Patient|Practitioner|PractitionerRole|RelatedPerson|Organization)",
4132          "Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.",
4133          0, 1, reported);
4134    case 1219992533:
4135      /* reportedBoolean */ return new Property("reported[x]",
4136          "boolean|Reference(Patient|Practitioner|PractitionerRole|RelatedPerson|Organization)",
4137          "Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.",
4138          0, 1, reported);
4139    case 1198143416:
4140      /* reportedReference */ return new Property("reported[x]",
4141          "boolean|Reference(Patient|Practitioner|PractitionerRole|RelatedPerson|Organization)",
4142          "Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.",
4143          0, 1, reported);
4144    case 1458402129:
4145      /* medication[x] */ return new Property("medication[x]", "CodeableConcept|Reference(Medication)",
4146          "Identifies the medication being requested. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications.",
4147          0, 1, medication);
4148    case 1998965455:
4149      /* medication */ return new Property("medication[x]", "CodeableConcept|Reference(Medication)",
4150          "Identifies the medication being requested. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications.",
4151          0, 1, medication);
4152    case -209845038:
4153      /* medicationCodeableConcept */ return new Property("medication[x]", "CodeableConcept|Reference(Medication)",
4154          "Identifies the medication being requested. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications.",
4155          0, 1, medication);
4156    case 2104315196:
4157      /* medicationReference */ return new Property("medication[x]", "CodeableConcept|Reference(Medication)",
4158          "Identifies the medication being requested. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications.",
4159          0, 1, medication);
4160    case -1867885268:
4161      /* subject */ return new Property("subject", "Reference(Patient|Group)",
4162          "A link to a resource representing the person or set of individuals to whom the medication will be given.", 0,
4163          1, subject);
4164    case 1524132147:
4165      /* encounter */ return new Property("encounter", "Reference(Encounter)",
4166          "The Encounter during which this [x] was created or to which the creation of this record is tightly associated.",
4167          0, 1, encounter);
4168    case -1248768647:
4169      /* supportingInformation */ return new Property("supportingInformation", "Reference(Any)",
4170          "Include additional information (for example, patient height and weight) that supports the ordering of the medication.",
4171          0, java.lang.Integer.MAX_VALUE, supportingInformation);
4172    case -1500852503:
4173      /* authoredOn */ return new Property("authoredOn", "dateTime",
4174          "The date (and perhaps time) when the prescription was initially written or authored on.", 0, 1, authoredOn);
4175    case 693933948:
4176      /* requester */ return new Property("requester",
4177          "Reference(Practitioner|PractitionerRole|Organization|Patient|RelatedPerson|Device)",
4178          "The individual, organization, or device that initiated the request and has responsibility for its activation.",
4179          0, 1, requester);
4180    case 481140686:
4181      /* performer */ return new Property("performer",
4182          "Reference(Practitioner|PractitionerRole|Organization|Patient|Device|RelatedPerson|CareTeam)",
4183          "The specified desired performer of the medication treatment (e.g. the performer of the medication administration).",
4184          0, 1, performer);
4185    case -901444568:
4186      /* performerType */ return new Property("performerType", "CodeableConcept",
4187          "Indicates the type of performer of the administration of the medication.", 0, 1, performerType);
4188    case -799233858:
4189      /* recorder */ return new Property("recorder", "Reference(Practitioner|PractitionerRole)",
4190          "The person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.",
4191          0, 1, recorder);
4192    case 722137681:
4193      /* reasonCode */ return new Property("reasonCode", "CodeableConcept",
4194          "The reason or the indication for ordering or not ordering the medication.", 0, java.lang.Integer.MAX_VALUE,
4195          reasonCode);
4196    case -1146218137:
4197      /* reasonReference */ return new Property("reasonReference", "Reference(Condition|Observation)",
4198          "Condition or observation that supports why the medication was ordered.", 0, java.lang.Integer.MAX_VALUE,
4199          reasonReference);
4200    case 8911915:
4201      /* instantiatesCanonical */ return new Property("instantiatesCanonical", "canonical",
4202          "The URL pointing to a protocol, guideline, orderset, or other definition that is adhered to in whole or in part by this MedicationRequest.",
4203          0, java.lang.Integer.MAX_VALUE, instantiatesCanonical);
4204    case -1926393373:
4205      /* instantiatesUri */ return new Property("instantiatesUri", "uri",
4206          "The URL pointing to an externally maintained protocol, guideline, orderset or other definition that is adhered to in whole or in part by this MedicationRequest.",
4207          0, java.lang.Integer.MAX_VALUE, instantiatesUri);
4208    case -332612366:
4209      /* basedOn */ return new Property("basedOn",
4210          "Reference(CarePlan|MedicationRequest|ServiceRequest|ImmunizationRecommendation)",
4211          "A plan or request that is fulfilled in whole or in part by this medication request.", 0,
4212          java.lang.Integer.MAX_VALUE, basedOn);
4213    case -445338488:
4214      /* groupIdentifier */ return new Property("groupIdentifier", "Identifier",
4215          "A shared identifier common to all requests that were authorized more or less simultaneously by a single author, representing the identifier of the requisition or prescription.",
4216          0, 1, groupIdentifier);
4217    case -447282031:
4218      /* courseOfTherapyType */ return new Property("courseOfTherapyType", "CodeableConcept",
4219          "The description of the overall patte3rn of the administration of the medication to the patient.", 0, 1,
4220          courseOfTherapyType);
4221    case 73049818:
4222      /* insurance */ return new Property("insurance", "Reference(Coverage|ClaimResponse)",
4223          "Insurance plans, coverage extensions, pre-authorizations and/or pre-determinations that may be required for delivering the requested service.",
4224          0, java.lang.Integer.MAX_VALUE, insurance);
4225    case 3387378:
4226      /* note */ return new Property("note", "Annotation",
4227          "Extra information about the prescription that could not be conveyed by the other attributes.", 0,
4228          java.lang.Integer.MAX_VALUE, note);
4229    case -1201373865:
4230      /* dosageInstruction */ return new Property("dosageInstruction", "Dosage",
4231          "Indicates how the medication is to be used by the patient.", 0, java.lang.Integer.MAX_VALUE,
4232          dosageInstruction);
4233    case 824620658:
4234      /* dispenseRequest */ return new Property("dispenseRequest", "",
4235          "Indicates the specific details for the dispense or medication supply part of a medication request (also known as a Medication Prescription or Medication Order).  Note that this information is not always sent with the order.  There may be in some settings (e.g. hospitals) institutional or system support for completing the dispense details in the pharmacy department.",
4236          0, 1, dispenseRequest);
4237    case 826147581:
4238      /* substitution */ return new Property("substitution", "",
4239          "Indicates whether or not substitution can or should be part of the dispense. In some cases, substitution must happen, in other cases substitution must not happen. This block explains the prescriber's intent. If nothing is specified substitution may be done.",
4240          0, 1, substitution);
4241    case -486355964:
4242      /* priorPrescription */ return new Property("priorPrescription", "Reference(MedicationRequest)",
4243          "A link to a resource representing an earlier order related order or prescription.", 0, 1, priorPrescription);
4244    case 51602295:
4245      /* detectedIssue */ return new Property("detectedIssue", "Reference(DetectedIssue)",
4246          "Indicates an actual or potential clinical issue with or between one or more active or proposed clinical actions for a patient; e.g. Drug-drug interaction, duplicate therapy, dosage alert etc.",
4247          0, java.lang.Integer.MAX_VALUE, detectedIssue);
4248    case 1835190426:
4249      /* eventHistory */ return new Property("eventHistory", "Reference(Provenance)",
4250          "Links to Provenance records for past versions of this resource or fulfilling request or event resources that identify key state transitions or updates that are likely to be relevant to a user looking at the current version of the resource.",
4251          0, java.lang.Integer.MAX_VALUE, eventHistory);
4252    default:
4253      return super.getNamedProperty(_hash, _name, _checkValid);
4254    }
4255
4256  }
4257
4258  @Override
4259  public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
4260    switch (hash) {
4261    case -1618432855:
4262      /* identifier */ return this.identifier == null ? new Base[0]
4263          : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
4264    case -892481550:
4265      /* status */ return this.status == null ? new Base[0] : new Base[] { this.status }; // Enumeration<MedicationRequestStatus>
4266    case 2051346646:
4267      /* statusReason */ return this.statusReason == null ? new Base[0] : new Base[] { this.statusReason }; // CodeableConcept
4268    case -1183762788:
4269      /* intent */ return this.intent == null ? new Base[0] : new Base[] { this.intent }; // Enumeration<MedicationRequestIntent>
4270    case 50511102:
4271      /* category */ return this.category == null ? new Base[0] : this.category.toArray(new Base[this.category.size()]); // CodeableConcept
4272    case -1165461084:
4273      /* priority */ return this.priority == null ? new Base[0] : new Base[] { this.priority }; // Enumeration<MedicationRequestPriority>
4274    case -1788508167:
4275      /* doNotPerform */ return this.doNotPerform == null ? new Base[0] : new Base[] { this.doNotPerform }; // BooleanType
4276    case -427039533:
4277      /* reported */ return this.reported == null ? new Base[0] : new Base[] { this.reported }; // Type
4278    case 1998965455:
4279      /* medication */ return this.medication == null ? new Base[0] : new Base[] { this.medication }; // Type
4280    case -1867885268:
4281      /* subject */ return this.subject == null ? new Base[0] : new Base[] { this.subject }; // Reference
4282    case 1524132147:
4283      /* encounter */ return this.encounter == null ? new Base[0] : new Base[] { this.encounter }; // Reference
4284    case -1248768647:
4285      /* supportingInformation */ return this.supportingInformation == null ? new Base[0]
4286          : this.supportingInformation.toArray(new Base[this.supportingInformation.size()]); // Reference
4287    case -1500852503:
4288      /* authoredOn */ return this.authoredOn == null ? new Base[0] : new Base[] { this.authoredOn }; // DateTimeType
4289    case 693933948:
4290      /* requester */ return this.requester == null ? new Base[0] : new Base[] { this.requester }; // Reference
4291    case 481140686:
4292      /* performer */ return this.performer == null ? new Base[0] : new Base[] { this.performer }; // Reference
4293    case -901444568:
4294      /* performerType */ return this.performerType == null ? new Base[0] : new Base[] { this.performerType }; // CodeableConcept
4295    case -799233858:
4296      /* recorder */ return this.recorder == null ? new Base[0] : new Base[] { this.recorder }; // Reference
4297    case 722137681:
4298      /* reasonCode */ return this.reasonCode == null ? new Base[0]
4299          : this.reasonCode.toArray(new Base[this.reasonCode.size()]); // CodeableConcept
4300    case -1146218137:
4301      /* reasonReference */ return this.reasonReference == null ? new Base[0]
4302          : this.reasonReference.toArray(new Base[this.reasonReference.size()]); // Reference
4303    case 8911915:
4304      /* instantiatesCanonical */ return this.instantiatesCanonical == null ? new Base[0]
4305          : this.instantiatesCanonical.toArray(new Base[this.instantiatesCanonical.size()]); // CanonicalType
4306    case -1926393373:
4307      /* instantiatesUri */ return this.instantiatesUri == null ? new Base[0]
4308          : this.instantiatesUri.toArray(new Base[this.instantiatesUri.size()]); // UriType
4309    case -332612366:
4310      /* basedOn */ return this.basedOn == null ? new Base[0] : this.basedOn.toArray(new Base[this.basedOn.size()]); // Reference
4311    case -445338488:
4312      /* groupIdentifier */ return this.groupIdentifier == null ? new Base[0] : new Base[] { this.groupIdentifier }; // Identifier
4313    case -447282031:
4314      /* courseOfTherapyType */ return this.courseOfTherapyType == null ? new Base[0]
4315          : new Base[] { this.courseOfTherapyType }; // CodeableConcept
4316    case 73049818:
4317      /* insurance */ return this.insurance == null ? new Base[0]
4318          : this.insurance.toArray(new Base[this.insurance.size()]); // Reference
4319    case 3387378:
4320      /* note */ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
4321    case -1201373865:
4322      /* dosageInstruction */ return this.dosageInstruction == null ? new Base[0]
4323          : this.dosageInstruction.toArray(new Base[this.dosageInstruction.size()]); // Dosage
4324    case 824620658:
4325      /* dispenseRequest */ return this.dispenseRequest == null ? new Base[0] : new Base[] { this.dispenseRequest }; // MedicationRequestDispenseRequestComponent
4326    case 826147581:
4327      /* substitution */ return this.substitution == null ? new Base[0] : new Base[] { this.substitution }; // MedicationRequestSubstitutionComponent
4328    case -486355964:
4329      /* priorPrescription */ return this.priorPrescription == null ? new Base[0]
4330          : new Base[] { this.priorPrescription }; // Reference
4331    case 51602295:
4332      /* detectedIssue */ return this.detectedIssue == null ? new Base[0]
4333          : this.detectedIssue.toArray(new Base[this.detectedIssue.size()]); // Reference
4334    case 1835190426:
4335      /* eventHistory */ return this.eventHistory == null ? new Base[0]
4336          : this.eventHistory.toArray(new Base[this.eventHistory.size()]); // Reference
4337    default:
4338      return super.getProperty(hash, name, checkValid);
4339    }
4340
4341  }
4342
4343  @Override
4344  public Base setProperty(int hash, String name, Base value) throws FHIRException {
4345    switch (hash) {
4346    case -1618432855: // identifier
4347      this.getIdentifier().add(castToIdentifier(value)); // Identifier
4348      return value;
4349    case -892481550: // status
4350      value = new MedicationRequestStatusEnumFactory().fromType(castToCode(value));
4351      this.status = (Enumeration) value; // Enumeration<MedicationRequestStatus>
4352      return value;
4353    case 2051346646: // statusReason
4354      this.statusReason = castToCodeableConcept(value); // CodeableConcept
4355      return value;
4356    case -1183762788: // intent
4357      value = new MedicationRequestIntentEnumFactory().fromType(castToCode(value));
4358      this.intent = (Enumeration) value; // Enumeration<MedicationRequestIntent>
4359      return value;
4360    case 50511102: // category
4361      this.getCategory().add(castToCodeableConcept(value)); // CodeableConcept
4362      return value;
4363    case -1165461084: // priority
4364      value = new MedicationRequestPriorityEnumFactory().fromType(castToCode(value));
4365      this.priority = (Enumeration) value; // Enumeration<MedicationRequestPriority>
4366      return value;
4367    case -1788508167: // doNotPerform
4368      this.doNotPerform = castToBoolean(value); // BooleanType
4369      return value;
4370    case -427039533: // reported
4371      this.reported = castToType(value); // Type
4372      return value;
4373    case 1998965455: // medication
4374      this.medication = castToType(value); // Type
4375      return value;
4376    case -1867885268: // subject
4377      this.subject = castToReference(value); // Reference
4378      return value;
4379    case 1524132147: // encounter
4380      this.encounter = castToReference(value); // Reference
4381      return value;
4382    case -1248768647: // supportingInformation
4383      this.getSupportingInformation().add(castToReference(value)); // Reference
4384      return value;
4385    case -1500852503: // authoredOn
4386      this.authoredOn = castToDateTime(value); // DateTimeType
4387      return value;
4388    case 693933948: // requester
4389      this.requester = castToReference(value); // Reference
4390      return value;
4391    case 481140686: // performer
4392      this.performer = castToReference(value); // Reference
4393      return value;
4394    case -901444568: // performerType
4395      this.performerType = castToCodeableConcept(value); // CodeableConcept
4396      return value;
4397    case -799233858: // recorder
4398      this.recorder = castToReference(value); // Reference
4399      return value;
4400    case 722137681: // reasonCode
4401      this.getReasonCode().add(castToCodeableConcept(value)); // CodeableConcept
4402      return value;
4403    case -1146218137: // reasonReference
4404      this.getReasonReference().add(castToReference(value)); // Reference
4405      return value;
4406    case 8911915: // instantiatesCanonical
4407      this.getInstantiatesCanonical().add(castToCanonical(value)); // CanonicalType
4408      return value;
4409    case -1926393373: // instantiatesUri
4410      this.getInstantiatesUri().add(castToUri(value)); // UriType
4411      return value;
4412    case -332612366: // basedOn
4413      this.getBasedOn().add(castToReference(value)); // Reference
4414      return value;
4415    case -445338488: // groupIdentifier
4416      this.groupIdentifier = castToIdentifier(value); // Identifier
4417      return value;
4418    case -447282031: // courseOfTherapyType
4419      this.courseOfTherapyType = castToCodeableConcept(value); // CodeableConcept
4420      return value;
4421    case 73049818: // insurance
4422      this.getInsurance().add(castToReference(value)); // Reference
4423      return value;
4424    case 3387378: // note
4425      this.getNote().add(castToAnnotation(value)); // Annotation
4426      return value;
4427    case -1201373865: // dosageInstruction
4428      this.getDosageInstruction().add(castToDosage(value)); // Dosage
4429      return value;
4430    case 824620658: // dispenseRequest
4431      this.dispenseRequest = (MedicationRequestDispenseRequestComponent) value; // MedicationRequestDispenseRequestComponent
4432      return value;
4433    case 826147581: // substitution
4434      this.substitution = (MedicationRequestSubstitutionComponent) value; // MedicationRequestSubstitutionComponent
4435      return value;
4436    case -486355964: // priorPrescription
4437      this.priorPrescription = castToReference(value); // Reference
4438      return value;
4439    case 51602295: // detectedIssue
4440      this.getDetectedIssue().add(castToReference(value)); // Reference
4441      return value;
4442    case 1835190426: // eventHistory
4443      this.getEventHistory().add(castToReference(value)); // Reference
4444      return value;
4445    default:
4446      return super.setProperty(hash, name, value);
4447    }
4448
4449  }
4450
4451  @Override
4452  public Base setProperty(String name, Base value) throws FHIRException {
4453    if (name.equals("identifier")) {
4454      this.getIdentifier().add(castToIdentifier(value));
4455    } else if (name.equals("status")) {
4456      value = new MedicationRequestStatusEnumFactory().fromType(castToCode(value));
4457      this.status = (Enumeration) value; // Enumeration<MedicationRequestStatus>
4458    } else if (name.equals("statusReason")) {
4459      this.statusReason = castToCodeableConcept(value); // CodeableConcept
4460    } else if (name.equals("intent")) {
4461      value = new MedicationRequestIntentEnumFactory().fromType(castToCode(value));
4462      this.intent = (Enumeration) value; // Enumeration<MedicationRequestIntent>
4463    } else if (name.equals("category")) {
4464      this.getCategory().add(castToCodeableConcept(value));
4465    } else if (name.equals("priority")) {
4466      value = new MedicationRequestPriorityEnumFactory().fromType(castToCode(value));
4467      this.priority = (Enumeration) value; // Enumeration<MedicationRequestPriority>
4468    } else if (name.equals("doNotPerform")) {
4469      this.doNotPerform = castToBoolean(value); // BooleanType
4470    } else if (name.equals("reported[x]")) {
4471      this.reported = castToType(value); // Type
4472    } else if (name.equals("medication[x]")) {
4473      this.medication = castToType(value); // Type
4474    } else if (name.equals("subject")) {
4475      this.subject = castToReference(value); // Reference
4476    } else if (name.equals("encounter")) {
4477      this.encounter = castToReference(value); // Reference
4478    } else if (name.equals("supportingInformation")) {
4479      this.getSupportingInformation().add(castToReference(value));
4480    } else if (name.equals("authoredOn")) {
4481      this.authoredOn = castToDateTime(value); // DateTimeType
4482    } else if (name.equals("requester")) {
4483      this.requester = castToReference(value); // Reference
4484    } else if (name.equals("performer")) {
4485      this.performer = castToReference(value); // Reference
4486    } else if (name.equals("performerType")) {
4487      this.performerType = castToCodeableConcept(value); // CodeableConcept
4488    } else if (name.equals("recorder")) {
4489      this.recorder = castToReference(value); // Reference
4490    } else if (name.equals("reasonCode")) {
4491      this.getReasonCode().add(castToCodeableConcept(value));
4492    } else if (name.equals("reasonReference")) {
4493      this.getReasonReference().add(castToReference(value));
4494    } else if (name.equals("instantiatesCanonical")) {
4495      this.getInstantiatesCanonical().add(castToCanonical(value));
4496    } else if (name.equals("instantiatesUri")) {
4497      this.getInstantiatesUri().add(castToUri(value));
4498    } else if (name.equals("basedOn")) {
4499      this.getBasedOn().add(castToReference(value));
4500    } else if (name.equals("groupIdentifier")) {
4501      this.groupIdentifier = castToIdentifier(value); // Identifier
4502    } else if (name.equals("courseOfTherapyType")) {
4503      this.courseOfTherapyType = castToCodeableConcept(value); // CodeableConcept
4504    } else if (name.equals("insurance")) {
4505      this.getInsurance().add(castToReference(value));
4506    } else if (name.equals("note")) {
4507      this.getNote().add(castToAnnotation(value));
4508    } else if (name.equals("dosageInstruction")) {
4509      this.getDosageInstruction().add(castToDosage(value));
4510    } else if (name.equals("dispenseRequest")) {
4511      this.dispenseRequest = (MedicationRequestDispenseRequestComponent) value; // MedicationRequestDispenseRequestComponent
4512    } else if (name.equals("substitution")) {
4513      this.substitution = (MedicationRequestSubstitutionComponent) value; // MedicationRequestSubstitutionComponent
4514    } else if (name.equals("priorPrescription")) {
4515      this.priorPrescription = castToReference(value); // Reference
4516    } else if (name.equals("detectedIssue")) {
4517      this.getDetectedIssue().add(castToReference(value));
4518    } else if (name.equals("eventHistory")) {
4519      this.getEventHistory().add(castToReference(value));
4520    } else
4521      return super.setProperty(name, value);
4522    return value;
4523  }
4524
4525  @Override
4526  public void removeChild(String name, Base value) throws FHIRException {
4527    if (name.equals("identifier")) {
4528      this.getIdentifier().remove(castToIdentifier(value));
4529    } else if (name.equals("status")) {
4530      this.status = null;
4531    } else if (name.equals("statusReason")) {
4532      this.statusReason = null;
4533    } else if (name.equals("intent")) {
4534      this.intent = null;
4535    } else if (name.equals("category")) {
4536      this.getCategory().remove(castToCodeableConcept(value));
4537    } else if (name.equals("priority")) {
4538      this.priority = null;
4539    } else if (name.equals("doNotPerform")) {
4540      this.doNotPerform = null;
4541    } else if (name.equals("reported[x]")) {
4542      this.reported = null;
4543    } else if (name.equals("medication[x]")) {
4544      this.medication = null;
4545    } else if (name.equals("subject")) {
4546      this.subject = null;
4547    } else if (name.equals("encounter")) {
4548      this.encounter = null;
4549    } else if (name.equals("supportingInformation")) {
4550      this.getSupportingInformation().remove(castToReference(value));
4551    } else if (name.equals("authoredOn")) {
4552      this.authoredOn = null;
4553    } else if (name.equals("requester")) {
4554      this.requester = null;
4555    } else if (name.equals("performer")) {
4556      this.performer = null;
4557    } else if (name.equals("performerType")) {
4558      this.performerType = null;
4559    } else if (name.equals("recorder")) {
4560      this.recorder = null;
4561    } else if (name.equals("reasonCode")) {
4562      this.getReasonCode().remove(castToCodeableConcept(value));
4563    } else if (name.equals("reasonReference")) {
4564      this.getReasonReference().remove(castToReference(value));
4565    } else if (name.equals("instantiatesCanonical")) {
4566      this.getInstantiatesCanonical().remove(castToCanonical(value));
4567    } else if (name.equals("instantiatesUri")) {
4568      this.getInstantiatesUri().remove(castToUri(value));
4569    } else if (name.equals("basedOn")) {
4570      this.getBasedOn().remove(castToReference(value));
4571    } else if (name.equals("groupIdentifier")) {
4572      this.groupIdentifier = null;
4573    } else if (name.equals("courseOfTherapyType")) {
4574      this.courseOfTherapyType = null;
4575    } else if (name.equals("insurance")) {
4576      this.getInsurance().remove(castToReference(value));
4577    } else if (name.equals("note")) {
4578      this.getNote().remove(castToAnnotation(value));
4579    } else if (name.equals("dosageInstruction")) {
4580      this.getDosageInstruction().remove(castToDosage(value));
4581    } else if (name.equals("dispenseRequest")) {
4582      this.dispenseRequest = (MedicationRequestDispenseRequestComponent) value; // MedicationRequestDispenseRequestComponent
4583    } else if (name.equals("substitution")) {
4584      this.substitution = (MedicationRequestSubstitutionComponent) value; // MedicationRequestSubstitutionComponent
4585    } else if (name.equals("priorPrescription")) {
4586      this.priorPrescription = null;
4587    } else if (name.equals("detectedIssue")) {
4588      this.getDetectedIssue().remove(castToReference(value));
4589    } else if (name.equals("eventHistory")) {
4590      this.getEventHistory().remove(castToReference(value));
4591    } else
4592      super.removeChild(name, value);
4593    
4594  }
4595
4596  @Override
4597  public Base makeProperty(int hash, String name) throws FHIRException {
4598    switch (hash) {
4599    case -1618432855:
4600      return addIdentifier();
4601    case -892481550:
4602      return getStatusElement();
4603    case 2051346646:
4604      return getStatusReason();
4605    case -1183762788:
4606      return getIntentElement();
4607    case 50511102:
4608      return addCategory();
4609    case -1165461084:
4610      return getPriorityElement();
4611    case -1788508167:
4612      return getDoNotPerformElement();
4613    case -241505587:
4614      return getReported();
4615    case -427039533:
4616      return getReported();
4617    case 1458402129:
4618      return getMedication();
4619    case 1998965455:
4620      return getMedication();
4621    case -1867885268:
4622      return getSubject();
4623    case 1524132147:
4624      return getEncounter();
4625    case -1248768647:
4626      return addSupportingInformation();
4627    case -1500852503:
4628      return getAuthoredOnElement();
4629    case 693933948:
4630      return getRequester();
4631    case 481140686:
4632      return getPerformer();
4633    case -901444568:
4634      return getPerformerType();
4635    case -799233858:
4636      return getRecorder();
4637    case 722137681:
4638      return addReasonCode();
4639    case -1146218137:
4640      return addReasonReference();
4641    case 8911915:
4642      return addInstantiatesCanonicalElement();
4643    case -1926393373:
4644      return addInstantiatesUriElement();
4645    case -332612366:
4646      return addBasedOn();
4647    case -445338488:
4648      return getGroupIdentifier();
4649    case -447282031:
4650      return getCourseOfTherapyType();
4651    case 73049818:
4652      return addInsurance();
4653    case 3387378:
4654      return addNote();
4655    case -1201373865:
4656      return addDosageInstruction();
4657    case 824620658:
4658      return getDispenseRequest();
4659    case 826147581:
4660      return getSubstitution();
4661    case -486355964:
4662      return getPriorPrescription();
4663    case 51602295:
4664      return addDetectedIssue();
4665    case 1835190426:
4666      return addEventHistory();
4667    default:
4668      return super.makeProperty(hash, name);
4669    }
4670
4671  }
4672
4673  @Override
4674  public String[] getTypesForProperty(int hash, String name) throws FHIRException {
4675    switch (hash) {
4676    case -1618432855:
4677      /* identifier */ return new String[] { "Identifier" };
4678    case -892481550:
4679      /* status */ return new String[] { "code" };
4680    case 2051346646:
4681      /* statusReason */ return new String[] { "CodeableConcept" };
4682    case -1183762788:
4683      /* intent */ return new String[] { "code" };
4684    case 50511102:
4685      /* category */ return new String[] { "CodeableConcept" };
4686    case -1165461084:
4687      /* priority */ return new String[] { "code" };
4688    case -1788508167:
4689      /* doNotPerform */ return new String[] { "boolean" };
4690    case -427039533:
4691      /* reported */ return new String[] { "boolean", "Reference" };
4692    case 1998965455:
4693      /* medication */ return new String[] { "CodeableConcept", "Reference" };
4694    case -1867885268:
4695      /* subject */ return new String[] { "Reference" };
4696    case 1524132147:
4697      /* encounter */ return new String[] { "Reference" };
4698    case -1248768647:
4699      /* supportingInformation */ return new String[] { "Reference" };
4700    case -1500852503:
4701      /* authoredOn */ return new String[] { "dateTime" };
4702    case 693933948:
4703      /* requester */ return new String[] { "Reference" };
4704    case 481140686:
4705      /* performer */ return new String[] { "Reference" };
4706    case -901444568:
4707      /* performerType */ return new String[] { "CodeableConcept" };
4708    case -799233858:
4709      /* recorder */ return new String[] { "Reference" };
4710    case 722137681:
4711      /* reasonCode */ return new String[] { "CodeableConcept" };
4712    case -1146218137:
4713      /* reasonReference */ return new String[] { "Reference" };
4714    case 8911915:
4715      /* instantiatesCanonical */ return new String[] { "canonical" };
4716    case -1926393373:
4717      /* instantiatesUri */ return new String[] { "uri" };
4718    case -332612366:
4719      /* basedOn */ return new String[] { "Reference" };
4720    case -445338488:
4721      /* groupIdentifier */ return new String[] { "Identifier" };
4722    case -447282031:
4723      /* courseOfTherapyType */ return new String[] { "CodeableConcept" };
4724    case 73049818:
4725      /* insurance */ return new String[] { "Reference" };
4726    case 3387378:
4727      /* note */ return new String[] { "Annotation" };
4728    case -1201373865:
4729      /* dosageInstruction */ return new String[] { "Dosage" };
4730    case 824620658:
4731      /* dispenseRequest */ return new String[] {};
4732    case 826147581:
4733      /* substitution */ return new String[] {};
4734    case -486355964:
4735      /* priorPrescription */ return new String[] { "Reference" };
4736    case 51602295:
4737      /* detectedIssue */ return new String[] { "Reference" };
4738    case 1835190426:
4739      /* eventHistory */ return new String[] { "Reference" };
4740    default:
4741      return super.getTypesForProperty(hash, name);
4742    }
4743
4744  }
4745
4746  @Override
4747  public Base addChild(String name) throws FHIRException {
4748    if (name.equals("identifier")) {
4749      return addIdentifier();
4750    } else if (name.equals("status")) {
4751      throw new FHIRException("Cannot call addChild on a singleton property MedicationRequest.status");
4752    } else if (name.equals("statusReason")) {
4753      this.statusReason = new CodeableConcept();
4754      return this.statusReason;
4755    } else if (name.equals("intent")) {
4756      throw new FHIRException("Cannot call addChild on a singleton property MedicationRequest.intent");
4757    } else if (name.equals("category")) {
4758      return addCategory();
4759    } else if (name.equals("priority")) {
4760      throw new FHIRException("Cannot call addChild on a singleton property MedicationRequest.priority");
4761    } else if (name.equals("doNotPerform")) {
4762      throw new FHIRException("Cannot call addChild on a singleton property MedicationRequest.doNotPerform");
4763    } else if (name.equals("reportedBoolean")) {
4764      this.reported = new BooleanType();
4765      return this.reported;
4766    } else if (name.equals("reportedReference")) {
4767      this.reported = new Reference();
4768      return this.reported;
4769    } else if (name.equals("medicationCodeableConcept")) {
4770      this.medication = new CodeableConcept();
4771      return this.medication;
4772    } else if (name.equals("medicationReference")) {
4773      this.medication = new Reference();
4774      return this.medication;
4775    } else if (name.equals("subject")) {
4776      this.subject = new Reference();
4777      return this.subject;
4778    } else if (name.equals("encounter")) {
4779      this.encounter = new Reference();
4780      return this.encounter;
4781    } else if (name.equals("supportingInformation")) {
4782      return addSupportingInformation();
4783    } else if (name.equals("authoredOn")) {
4784      throw new FHIRException("Cannot call addChild on a singleton property MedicationRequest.authoredOn");
4785    } else if (name.equals("requester")) {
4786      this.requester = new Reference();
4787      return this.requester;
4788    } else if (name.equals("performer")) {
4789      this.performer = new Reference();
4790      return this.performer;
4791    } else if (name.equals("performerType")) {
4792      this.performerType = new CodeableConcept();
4793      return this.performerType;
4794    } else if (name.equals("recorder")) {
4795      this.recorder = new Reference();
4796      return this.recorder;
4797    } else if (name.equals("reasonCode")) {
4798      return addReasonCode();
4799    } else if (name.equals("reasonReference")) {
4800      return addReasonReference();
4801    } else if (name.equals("instantiatesCanonical")) {
4802      throw new FHIRException("Cannot call addChild on a singleton property MedicationRequest.instantiatesCanonical");
4803    } else if (name.equals("instantiatesUri")) {
4804      throw new FHIRException("Cannot call addChild on a singleton property MedicationRequest.instantiatesUri");
4805    } else if (name.equals("basedOn")) {
4806      return addBasedOn();
4807    } else if (name.equals("groupIdentifier")) {
4808      this.groupIdentifier = new Identifier();
4809      return this.groupIdentifier;
4810    } else if (name.equals("courseOfTherapyType")) {
4811      this.courseOfTherapyType = new CodeableConcept();
4812      return this.courseOfTherapyType;
4813    } else if (name.equals("insurance")) {
4814      return addInsurance();
4815    } else if (name.equals("note")) {
4816      return addNote();
4817    } else if (name.equals("dosageInstruction")) {
4818      return addDosageInstruction();
4819    } else if (name.equals("dispenseRequest")) {
4820      this.dispenseRequest = new MedicationRequestDispenseRequestComponent();
4821      return this.dispenseRequest;
4822    } else if (name.equals("substitution")) {
4823      this.substitution = new MedicationRequestSubstitutionComponent();
4824      return this.substitution;
4825    } else if (name.equals("priorPrescription")) {
4826      this.priorPrescription = new Reference();
4827      return this.priorPrescription;
4828    } else if (name.equals("detectedIssue")) {
4829      return addDetectedIssue();
4830    } else if (name.equals("eventHistory")) {
4831      return addEventHistory();
4832    } else
4833      return super.addChild(name);
4834  }
4835
4836  public String fhirType() {
4837    return "MedicationRequest";
4838
4839  }
4840
4841  public MedicationRequest copy() {
4842    MedicationRequest dst = new MedicationRequest();
4843    copyValues(dst);
4844    return dst;
4845  }
4846
4847  public void copyValues(MedicationRequest dst) {
4848    super.copyValues(dst);
4849    if (identifier != null) {
4850      dst.identifier = new ArrayList<Identifier>();
4851      for (Identifier i : identifier)
4852        dst.identifier.add(i.copy());
4853    }
4854    ;
4855    dst.status = status == null ? null : status.copy();
4856    dst.statusReason = statusReason == null ? null : statusReason.copy();
4857    dst.intent = intent == null ? null : intent.copy();
4858    if (category != null) {
4859      dst.category = new ArrayList<CodeableConcept>();
4860      for (CodeableConcept i : category)
4861        dst.category.add(i.copy());
4862    }
4863    ;
4864    dst.priority = priority == null ? null : priority.copy();
4865    dst.doNotPerform = doNotPerform == null ? null : doNotPerform.copy();
4866    dst.reported = reported == null ? null : reported.copy();
4867    dst.medication = medication == null ? null : medication.copy();
4868    dst.subject = subject == null ? null : subject.copy();
4869    dst.encounter = encounter == null ? null : encounter.copy();
4870    if (supportingInformation != null) {
4871      dst.supportingInformation = new ArrayList<Reference>();
4872      for (Reference i : supportingInformation)
4873        dst.supportingInformation.add(i.copy());
4874    }
4875    ;
4876    dst.authoredOn = authoredOn == null ? null : authoredOn.copy();
4877    dst.requester = requester == null ? null : requester.copy();
4878    dst.performer = performer == null ? null : performer.copy();
4879    dst.performerType = performerType == null ? null : performerType.copy();
4880    dst.recorder = recorder == null ? null : recorder.copy();
4881    if (reasonCode != null) {
4882      dst.reasonCode = new ArrayList<CodeableConcept>();
4883      for (CodeableConcept i : reasonCode)
4884        dst.reasonCode.add(i.copy());
4885    }
4886    ;
4887    if (reasonReference != null) {
4888      dst.reasonReference = new ArrayList<Reference>();
4889      for (Reference i : reasonReference)
4890        dst.reasonReference.add(i.copy());
4891    }
4892    ;
4893    if (instantiatesCanonical != null) {
4894      dst.instantiatesCanonical = new ArrayList<CanonicalType>();
4895      for (CanonicalType i : instantiatesCanonical)
4896        dst.instantiatesCanonical.add(i.copy());
4897    }
4898    ;
4899    if (instantiatesUri != null) {
4900      dst.instantiatesUri = new ArrayList<UriType>();
4901      for (UriType i : instantiatesUri)
4902        dst.instantiatesUri.add(i.copy());
4903    }
4904    ;
4905    if (basedOn != null) {
4906      dst.basedOn = new ArrayList<Reference>();
4907      for (Reference i : basedOn)
4908        dst.basedOn.add(i.copy());
4909    }
4910    ;
4911    dst.groupIdentifier = groupIdentifier == null ? null : groupIdentifier.copy();
4912    dst.courseOfTherapyType = courseOfTherapyType == null ? null : courseOfTherapyType.copy();
4913    if (insurance != null) {
4914      dst.insurance = new ArrayList<Reference>();
4915      for (Reference i : insurance)
4916        dst.insurance.add(i.copy());
4917    }
4918    ;
4919    if (note != null) {
4920      dst.note = new ArrayList<Annotation>();
4921      for (Annotation i : note)
4922        dst.note.add(i.copy());
4923    }
4924    ;
4925    if (dosageInstruction != null) {
4926      dst.dosageInstruction = new ArrayList<Dosage>();
4927      for (Dosage i : dosageInstruction)
4928        dst.dosageInstruction.add(i.copy());
4929    }
4930    ;
4931    dst.dispenseRequest = dispenseRequest == null ? null : dispenseRequest.copy();
4932    dst.substitution = substitution == null ? null : substitution.copy();
4933    dst.priorPrescription = priorPrescription == null ? null : priorPrescription.copy();
4934    if (detectedIssue != null) {
4935      dst.detectedIssue = new ArrayList<Reference>();
4936      for (Reference i : detectedIssue)
4937        dst.detectedIssue.add(i.copy());
4938    }
4939    ;
4940    if (eventHistory != null) {
4941      dst.eventHistory = new ArrayList<Reference>();
4942      for (Reference i : eventHistory)
4943        dst.eventHistory.add(i.copy());
4944    }
4945    ;
4946  }
4947
4948  protected MedicationRequest typedCopy() {
4949    return copy();
4950  }
4951
4952  @Override
4953  public boolean equalsDeep(Base other_) {
4954    if (!super.equalsDeep(other_))
4955      return false;
4956    if (!(other_ instanceof MedicationRequest))
4957      return false;
4958    MedicationRequest o = (MedicationRequest) other_;
4959    return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true)
4960        && compareDeep(statusReason, o.statusReason, true) && compareDeep(intent, o.intent, true)
4961        && compareDeep(category, o.category, true) && compareDeep(priority, o.priority, true)
4962        && compareDeep(doNotPerform, o.doNotPerform, true) && compareDeep(reported, o.reported, true)
4963        && compareDeep(medication, o.medication, true) && compareDeep(subject, o.subject, true)
4964        && compareDeep(encounter, o.encounter, true)
4965        && compareDeep(supportingInformation, o.supportingInformation, true)
4966        && compareDeep(authoredOn, o.authoredOn, true) && compareDeep(requester, o.requester, true)
4967        && compareDeep(performer, o.performer, true) && compareDeep(performerType, o.performerType, true)
4968        && compareDeep(recorder, o.recorder, true) && compareDeep(reasonCode, o.reasonCode, true)
4969        && compareDeep(reasonReference, o.reasonReference, true)
4970        && compareDeep(instantiatesCanonical, o.instantiatesCanonical, true)
4971        && compareDeep(instantiatesUri, o.instantiatesUri, true) && compareDeep(basedOn, o.basedOn, true)
4972        && compareDeep(groupIdentifier, o.groupIdentifier, true)
4973        && compareDeep(courseOfTherapyType, o.courseOfTherapyType, true) && compareDeep(insurance, o.insurance, true)
4974        && compareDeep(note, o.note, true) && compareDeep(dosageInstruction, o.dosageInstruction, true)
4975        && compareDeep(dispenseRequest, o.dispenseRequest, true) && compareDeep(substitution, o.substitution, true)
4976        && compareDeep(priorPrescription, o.priorPrescription, true)
4977        && compareDeep(detectedIssue, o.detectedIssue, true) && compareDeep(eventHistory, o.eventHistory, true);
4978  }
4979
4980  @Override
4981  public boolean equalsShallow(Base other_) {
4982    if (!super.equalsShallow(other_))
4983      return false;
4984    if (!(other_ instanceof MedicationRequest))
4985      return false;
4986    MedicationRequest o = (MedicationRequest) other_;
4987    return compareValues(status, o.status, true) && compareValues(intent, o.intent, true)
4988        && compareValues(priority, o.priority, true) && compareValues(doNotPerform, o.doNotPerform, true)
4989        && compareValues(authoredOn, o.authoredOn, true)
4990        && compareValues(instantiatesCanonical, o.instantiatesCanonical, true)
4991        && compareValues(instantiatesUri, o.instantiatesUri, true);
4992  }
4993
4994  public boolean isEmpty() {
4995    return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, statusReason, intent, category,
4996        priority, doNotPerform, reported, medication, subject, encounter, supportingInformation, authoredOn, requester,
4997        performer, performerType, recorder, reasonCode, reasonReference, instantiatesCanonical, instantiatesUri,
4998        basedOn, groupIdentifier, courseOfTherapyType, insurance, note, dosageInstruction, dispenseRequest,
4999        substitution, priorPrescription, detectedIssue, eventHistory);
5000  }
5001
5002  @Override
5003  public ResourceType getResourceType() {
5004    return ResourceType.MedicationRequest;
5005  }
5006
5007  /**
5008   * Search parameter: <b>requester</b>
5009   * <p>
5010   * Description: <b>Returns prescriptions prescribed by this prescriber</b><br>
5011   * Type: <b>reference</b><br>
5012   * Path: <b>MedicationRequest.requester</b><br>
5013   * </p>
5014   */
5015  @SearchParamDefinition(name = "requester", path = "MedicationRequest.requester", description = "Returns prescriptions prescribed by this prescriber", type = "reference", providesMembershipIn = {
5016      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Practitioner") }, target = { Device.class,
5017          Organization.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class })
5018  public static final String SP_REQUESTER = "requester";
5019  /**
5020   * <b>Fluent Client</b> search parameter constant for <b>requester</b>
5021   * <p>
5022   * Description: <b>Returns prescriptions prescribed by this prescriber</b><br>
5023   * Type: <b>reference</b><br>
5024   * Path: <b>MedicationRequest.requester</b><br>
5025   * </p>
5026   */
5027  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam REQUESTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
5028      SP_REQUESTER);
5029
5030  /**
5031   * Constant for fluent queries to be used to add include statements. Specifies
5032   * the path value of "<b>MedicationRequest:requester</b>".
5033   */
5034  public static final ca.uhn.fhir.model.api.Include INCLUDE_REQUESTER = new ca.uhn.fhir.model.api.Include(
5035      "MedicationRequest:requester").toLocked();
5036
5037  /**
5038   * Search parameter: <b>date</b>
5039   * <p>
5040   * Description: <b>Returns medication request to be administered on a specific
5041   * date</b><br>
5042   * Type: <b>date</b><br>
5043   * Path: <b>MedicationRequest.dosageInstruction.timing.event</b><br>
5044   * </p>
5045   */
5046  @SearchParamDefinition(name = "date", path = "MedicationRequest.dosageInstruction.timing.event", description = "Returns medication request to be administered on a specific date", type = "date")
5047  public static final String SP_DATE = "date";
5048  /**
5049   * <b>Fluent Client</b> search parameter constant for <b>date</b>
5050   * <p>
5051   * Description: <b>Returns medication request to be administered on a specific
5052   * date</b><br>
5053   * Type: <b>date</b><br>
5054   * Path: <b>MedicationRequest.dosageInstruction.timing.event</b><br>
5055   * </p>
5056   */
5057  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(
5058      SP_DATE);
5059
5060  /**
5061   * Search parameter: <b>identifier</b>
5062   * <p>
5063   * Description: <b>Return prescriptions with this external identifier</b><br>
5064   * Type: <b>token</b><br>
5065   * Path: <b>MedicationRequest.identifier</b><br>
5066   * </p>
5067   */
5068  @SearchParamDefinition(name = "identifier", path = "MedicationRequest.identifier", description = "Return prescriptions with this external identifier", type = "token")
5069  public static final String SP_IDENTIFIER = "identifier";
5070  /**
5071   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
5072   * <p>
5073   * Description: <b>Return prescriptions with this external identifier</b><br>
5074   * Type: <b>token</b><br>
5075   * Path: <b>MedicationRequest.identifier</b><br>
5076   * </p>
5077   */
5078  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(
5079      SP_IDENTIFIER);
5080
5081  /**
5082   * Search parameter: <b>intended-dispenser</b>
5083   * <p>
5084   * Description: <b>Returns prescriptions intended to be dispensed by this
5085   * Organization</b><br>
5086   * Type: <b>reference</b><br>
5087   * Path: <b>MedicationRequest.dispenseRequest.performer</b><br>
5088   * </p>
5089   */
5090  @SearchParamDefinition(name = "intended-dispenser", path = "MedicationRequest.dispenseRequest.performer", description = "Returns prescriptions intended to be dispensed by this Organization", type = "reference", target = {
5091      Organization.class })
5092  public static final String SP_INTENDED_DISPENSER = "intended-dispenser";
5093  /**
5094   * <b>Fluent Client</b> search parameter constant for <b>intended-dispenser</b>
5095   * <p>
5096   * Description: <b>Returns prescriptions intended to be dispensed by this
5097   * Organization</b><br>
5098   * Type: <b>reference</b><br>
5099   * Path: <b>MedicationRequest.dispenseRequest.performer</b><br>
5100   * </p>
5101   */
5102  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam INTENDED_DISPENSER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
5103      SP_INTENDED_DISPENSER);
5104
5105  /**
5106   * Constant for fluent queries to be used to add include statements. Specifies
5107   * the path value of "<b>MedicationRequest:intended-dispenser</b>".
5108   */
5109  public static final ca.uhn.fhir.model.api.Include INCLUDE_INTENDED_DISPENSER = new ca.uhn.fhir.model.api.Include(
5110      "MedicationRequest:intended-dispenser").toLocked();
5111
5112  /**
5113   * Search parameter: <b>authoredon</b>
5114   * <p>
5115   * Description: <b>Return prescriptions written on this date</b><br>
5116   * Type: <b>date</b><br>
5117   * Path: <b>MedicationRequest.authoredOn</b><br>
5118   * </p>
5119   */
5120  @SearchParamDefinition(name = "authoredon", path = "MedicationRequest.authoredOn", description = "Return prescriptions written on this date", type = "date")
5121  public static final String SP_AUTHOREDON = "authoredon";
5122  /**
5123   * <b>Fluent Client</b> search parameter constant for <b>authoredon</b>
5124   * <p>
5125   * Description: <b>Return prescriptions written on this date</b><br>
5126   * Type: <b>date</b><br>
5127   * Path: <b>MedicationRequest.authoredOn</b><br>
5128   * </p>
5129   */
5130  public static final ca.uhn.fhir.rest.gclient.DateClientParam AUTHOREDON = new ca.uhn.fhir.rest.gclient.DateClientParam(
5131      SP_AUTHOREDON);
5132
5133  /**
5134   * Search parameter: <b>code</b>
5135   * <p>
5136   * Description: <b>Return prescriptions of this medication code</b><br>
5137   * Type: <b>token</b><br>
5138   * Path: <b>MedicationRequest.medicationCodeableConcept</b><br>
5139   * </p>
5140   */
5141  @SearchParamDefinition(name = "code", path = "(MedicationRequest.medication as CodeableConcept)", description = "Return prescriptions of this medication code", type = "token")
5142  public static final String SP_CODE = "code";
5143  /**
5144   * <b>Fluent Client</b> search parameter constant for <b>code</b>
5145   * <p>
5146   * Description: <b>Return prescriptions of this medication code</b><br>
5147   * Type: <b>token</b><br>
5148   * Path: <b>MedicationRequest.medicationCodeableConcept</b><br>
5149   * </p>
5150   */
5151  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(
5152      SP_CODE);
5153
5154  /**
5155   * Search parameter: <b>subject</b>
5156   * <p>
5157   * Description: <b>The identity of a patient to list orders for</b><br>
5158   * Type: <b>reference</b><br>
5159   * Path: <b>MedicationRequest.subject</b><br>
5160   * </p>
5161   */
5162  @SearchParamDefinition(name = "subject", path = "MedicationRequest.subject", description = "The identity of a patient to list orders  for", type = "reference", providesMembershipIn = {
5163      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Patient") }, target = { Group.class, Patient.class })
5164  public static final String SP_SUBJECT = "subject";
5165  /**
5166   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
5167   * <p>
5168   * Description: <b>The identity of a patient to list orders for</b><br>
5169   * Type: <b>reference</b><br>
5170   * Path: <b>MedicationRequest.subject</b><br>
5171   * </p>
5172   */
5173  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
5174      SP_SUBJECT);
5175
5176  /**
5177   * Constant for fluent queries to be used to add include statements. Specifies
5178   * the path value of "<b>MedicationRequest:subject</b>".
5179   */
5180  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include(
5181      "MedicationRequest:subject").toLocked();
5182
5183  /**
5184   * Search parameter: <b>medication</b>
5185   * <p>
5186   * Description: <b>Return prescriptions for this medication reference</b><br>
5187   * Type: <b>reference</b><br>
5188   * Path: <b>MedicationRequest.medicationReference</b><br>
5189   * </p>
5190   */
5191  @SearchParamDefinition(name = "medication", path = "(MedicationRequest.medication as Reference)", description = "Return prescriptions for this medication reference", type = "reference", target = {
5192      Medication.class })
5193  public static final String SP_MEDICATION = "medication";
5194  /**
5195   * <b>Fluent Client</b> search parameter constant for <b>medication</b>
5196   * <p>
5197   * Description: <b>Return prescriptions for this medication reference</b><br>
5198   * Type: <b>reference</b><br>
5199   * Path: <b>MedicationRequest.medicationReference</b><br>
5200   * </p>
5201   */
5202  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam MEDICATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
5203      SP_MEDICATION);
5204
5205  /**
5206   * Constant for fluent queries to be used to add include statements. Specifies
5207   * the path value of "<b>MedicationRequest:medication</b>".
5208   */
5209  public static final ca.uhn.fhir.model.api.Include INCLUDE_MEDICATION = new ca.uhn.fhir.model.api.Include(
5210      "MedicationRequest:medication").toLocked();
5211
5212  /**
5213   * Search parameter: <b>encounter</b>
5214   * <p>
5215   * Description: <b>Return prescriptions with this encounter identifier</b><br>
5216   * Type: <b>reference</b><br>
5217   * Path: <b>MedicationRequest.encounter</b><br>
5218   * </p>
5219   */
5220  @SearchParamDefinition(name = "encounter", path = "MedicationRequest.encounter", description = "Return prescriptions with this encounter identifier", type = "reference", providesMembershipIn = {
5221      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Encounter") }, target = { Encounter.class })
5222  public static final String SP_ENCOUNTER = "encounter";
5223  /**
5224   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
5225   * <p>
5226   * Description: <b>Return prescriptions with this encounter identifier</b><br>
5227   * Type: <b>reference</b><br>
5228   * Path: <b>MedicationRequest.encounter</b><br>
5229   * </p>
5230   */
5231  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
5232      SP_ENCOUNTER);
5233
5234  /**
5235   * Constant for fluent queries to be used to add include statements. Specifies
5236   * the path value of "<b>MedicationRequest:encounter</b>".
5237   */
5238  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include(
5239      "MedicationRequest:encounter").toLocked();
5240
5241  /**
5242   * Search parameter: <b>priority</b>
5243   * <p>
5244   * Description: <b>Returns prescriptions with different priorities</b><br>
5245   * Type: <b>token</b><br>
5246   * Path: <b>MedicationRequest.priority</b><br>
5247   * </p>
5248   */
5249  @SearchParamDefinition(name = "priority", path = "MedicationRequest.priority", description = "Returns prescriptions with different priorities", type = "token")
5250  public static final String SP_PRIORITY = "priority";
5251  /**
5252   * <b>Fluent Client</b> search parameter constant for <b>priority</b>
5253   * <p>
5254   * Description: <b>Returns prescriptions with different priorities</b><br>
5255   * Type: <b>token</b><br>
5256   * Path: <b>MedicationRequest.priority</b><br>
5257   * </p>
5258   */
5259  public static final ca.uhn.fhir.rest.gclient.TokenClientParam PRIORITY = new ca.uhn.fhir.rest.gclient.TokenClientParam(
5260      SP_PRIORITY);
5261
5262  /**
5263   * Search parameter: <b>intent</b>
5264   * <p>
5265   * Description: <b>Returns prescriptions with different intents</b><br>
5266   * Type: <b>token</b><br>
5267   * Path: <b>MedicationRequest.intent</b><br>
5268   * </p>
5269   */
5270  @SearchParamDefinition(name = "intent", path = "MedicationRequest.intent", description = "Returns prescriptions with different intents", type = "token")
5271  public static final String SP_INTENT = "intent";
5272  /**
5273   * <b>Fluent Client</b> search parameter constant for <b>intent</b>
5274   * <p>
5275   * Description: <b>Returns prescriptions with different intents</b><br>
5276   * Type: <b>token</b><br>
5277   * Path: <b>MedicationRequest.intent</b><br>
5278   * </p>
5279   */
5280  public static final ca.uhn.fhir.rest.gclient.TokenClientParam INTENT = new ca.uhn.fhir.rest.gclient.TokenClientParam(
5281      SP_INTENT);
5282
5283  /**
5284   * Search parameter: <b>patient</b>
5285   * <p>
5286   * Description: <b>Returns prescriptions for a specific patient</b><br>
5287   * Type: <b>reference</b><br>
5288   * Path: <b>MedicationRequest.subject</b><br>
5289   * </p>
5290   */
5291  @SearchParamDefinition(name = "patient", path = "MedicationRequest.subject.where(resolve() is Patient)", description = "Returns prescriptions for a specific patient", type = "reference", target = {
5292      Patient.class })
5293  public static final String SP_PATIENT = "patient";
5294  /**
5295   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
5296   * <p>
5297   * Description: <b>Returns prescriptions for a specific patient</b><br>
5298   * Type: <b>reference</b><br>
5299   * Path: <b>MedicationRequest.subject</b><br>
5300   * </p>
5301   */
5302  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
5303      SP_PATIENT);
5304
5305  /**
5306   * Constant for fluent queries to be used to add include statements. Specifies
5307   * the path value of "<b>MedicationRequest:patient</b>".
5308   */
5309  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include(
5310      "MedicationRequest:patient").toLocked();
5311
5312  /**
5313   * Search parameter: <b>intended-performer</b>
5314   * <p>
5315   * Description: <b>Returns the intended performer of the administration of the
5316   * medication request</b><br>
5317   * Type: <b>reference</b><br>
5318   * Path: <b>MedicationRequest.performer</b><br>
5319   * </p>
5320   */
5321  @SearchParamDefinition(name = "intended-performer", path = "MedicationRequest.performer", description = "Returns the intended performer of the administration of the medication request", type = "reference", target = {
5322      CareTeam.class, Device.class, Organization.class, Patient.class, Practitioner.class, PractitionerRole.class,
5323      RelatedPerson.class })
5324  public static final String SP_INTENDED_PERFORMER = "intended-performer";
5325  /**
5326   * <b>Fluent Client</b> search parameter constant for <b>intended-performer</b>
5327   * <p>
5328   * Description: <b>Returns the intended performer of the administration of the
5329   * medication request</b><br>
5330   * Type: <b>reference</b><br>
5331   * Path: <b>MedicationRequest.performer</b><br>
5332   * </p>
5333   */
5334  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam INTENDED_PERFORMER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
5335      SP_INTENDED_PERFORMER);
5336
5337  /**
5338   * Constant for fluent queries to be used to add include statements. Specifies
5339   * the path value of "<b>MedicationRequest:intended-performer</b>".
5340   */
5341  public static final ca.uhn.fhir.model.api.Include INCLUDE_INTENDED_PERFORMER = new ca.uhn.fhir.model.api.Include(
5342      "MedicationRequest:intended-performer").toLocked();
5343
5344  /**
5345   * Search parameter: <b>intended-performertype</b>
5346   * <p>
5347   * Description: <b>Returns requests for a specific type of performer</b><br>
5348   * Type: <b>token</b><br>
5349   * Path: <b>MedicationRequest.performerType</b><br>
5350   * </p>
5351   */
5352  @SearchParamDefinition(name = "intended-performertype", path = "MedicationRequest.performerType", description = "Returns requests for a specific type of performer", type = "token")
5353  public static final String SP_INTENDED_PERFORMERTYPE = "intended-performertype";
5354  /**
5355   * <b>Fluent Client</b> search parameter constant for
5356   * <b>intended-performertype</b>
5357   * <p>
5358   * Description: <b>Returns requests for a specific type of performer</b><br>
5359   * Type: <b>token</b><br>
5360   * Path: <b>MedicationRequest.performerType</b><br>
5361   * </p>
5362   */
5363  public static final ca.uhn.fhir.rest.gclient.TokenClientParam INTENDED_PERFORMERTYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(
5364      SP_INTENDED_PERFORMERTYPE);
5365
5366  /**
5367   * Search parameter: <b>category</b>
5368   * <p>
5369   * Description: <b>Returns prescriptions with different categories</b><br>
5370   * Type: <b>token</b><br>
5371   * Path: <b>MedicationRequest.category</b><br>
5372   * </p>
5373   */
5374  @SearchParamDefinition(name = "category", path = "MedicationRequest.category", description = "Returns prescriptions with different categories", type = "token")
5375  public static final String SP_CATEGORY = "category";
5376  /**
5377   * <b>Fluent Client</b> search parameter constant for <b>category</b>
5378   * <p>
5379   * Description: <b>Returns prescriptions with different categories</b><br>
5380   * Type: <b>token</b><br>
5381   * Path: <b>MedicationRequest.category</b><br>
5382   * </p>
5383   */
5384  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(
5385      SP_CATEGORY);
5386
5387  /**
5388   * Search parameter: <b>status</b>
5389   * <p>
5390   * Description: <b>Status of the prescription</b><br>
5391   * Type: <b>token</b><br>
5392   * Path: <b>MedicationRequest.status</b><br>
5393   * </p>
5394   */
5395  @SearchParamDefinition(name = "status", path = "MedicationRequest.status", description = "Status of the prescription", type = "token")
5396  public static final String SP_STATUS = "status";
5397  /**
5398   * <b>Fluent Client</b> search parameter constant for <b>status</b>
5399   * <p>
5400   * Description: <b>Status of the prescription</b><br>
5401   * Type: <b>token</b><br>
5402   * Path: <b>MedicationRequest.status</b><br>
5403   * </p>
5404   */
5405  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(
5406      SP_STATUS);
5407
5408}