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