001package org.hl7.fhir.r4.model;
002
003
004
005/*
006  Copyright (c) 2011+, HL7, Inc.
007  All rights reserved.
008  
009  Redistribution and use in source and binary forms, with or without modification, 
010  are permitted provided that the following conditions are met:
011  
012   * Redistributions of source code must retain the above copyright notice, this 
013     list of conditions and the following disclaimer.
014   * Redistributions in binary form must reproduce the above copyright notice, 
015     this list of conditions and the following disclaimer in the documentation 
016     and/or other materials provided with the distribution.
017   * Neither the name of HL7 nor the names of its contributors may be used to 
018     endorse or promote products derived from this software without specific 
019     prior written permission.
020  
021  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
022  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
023  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
024  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
025  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
026  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
027  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
028  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
029  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
030  POSSIBILITY OF SUCH DAMAGE.
031  
032*/
033
034
035// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
036
037import java.util.*;
038
039import org.hl7.fhir.utilities.Utilities;
040import ca.uhn.fhir.model.api.annotation.ResourceDef;
041import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
042import ca.uhn.fhir.model.api.annotation.Child;
043import ca.uhn.fhir.model.api.annotation.ChildOrder;
044import ca.uhn.fhir.model.api.annotation.Description;
045import ca.uhn.fhir.model.api.annotation.Block;
046import org.hl7.fhir.instance.model.api.*;
047import org.hl7.fhir.exceptions.FHIRException;
048/**
049 * An order or request for both supply of the medication and the instructions for administration of the medication to a patient. The resource is called "MedicationRequest" rather than "MedicationPrescription" or "MedicationOrder" to generalize the use across inpatient and outpatient settings, including care plans, etc., and to harmonize with workflow patterns.
050 */
051@ResourceDef(name="MedicationRequest", profile="http://hl7.org/fhir/StructureDefinition/MedicationRequest")
052public class MedicationRequest extends DomainResource {
053
054    public enum MedicationRequestStatus {
055        /**
056         * The prescription is 'actionable', but not all actions that are implied by it have occurred yet.
057         */
058        ACTIVE, 
059        /**
060         * Actions implied by the prescription are to be temporarily halted, but are expected to continue later.  May also be called 'suspended'.
061         */
062        ONHOLD, 
063        /**
064         * The prescription has been withdrawn before any administrations have occurred
065         */
066        CANCELLED, 
067        /**
068         * All actions that are implied by the prescription have occurred.
069         */
070        COMPLETED, 
071        /**
072         * 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
073         */
074        ENTEREDINERROR, 
075        /**
076         * 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
077         */
078        STOPPED, 
079        /**
080         * 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.
081         */
082        DRAFT, 
083        /**
084         * 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.
085         */
086        UNKNOWN, 
087        /**
088         * added to help the parsers with the generic types
089         */
090        NULL;
091        public static MedicationRequestStatus fromCode(String codeString) throws FHIRException {
092            if (codeString == null || "".equals(codeString))
093                return null;
094        if ("active".equals(codeString))
095          return ACTIVE;
096        if ("on-hold".equals(codeString))
097          return ONHOLD;
098        if ("cancelled".equals(codeString))
099          return CANCELLED;
100        if ("completed".equals(codeString))
101          return COMPLETED;
102        if ("entered-in-error".equals(codeString))
103          return ENTEREDINERROR;
104        if ("stopped".equals(codeString))
105          return STOPPED;
106        if ("draft".equals(codeString))
107          return DRAFT;
108        if ("unknown".equals(codeString))
109          return UNKNOWN;
110        if (Configuration.isAcceptInvalidEnums())
111          return null;
112        else
113          throw new FHIRException("Unknown MedicationRequestStatus code '"+codeString+"'");
114        }
115        public String toCode() {
116          switch (this) {
117            case ACTIVE: return "active";
118            case ONHOLD: return "on-hold";
119            case CANCELLED: return "cancelled";
120            case COMPLETED: return "completed";
121            case ENTEREDINERROR: return "entered-in-error";
122            case STOPPED: return "stopped";
123            case DRAFT: return "draft";
124            case UNKNOWN: return "unknown";
125            case NULL: return null;
126            default: return "?";
127          }
128        }
129        public String getSystem() {
130          switch (this) {
131            case ACTIVE: return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
132            case ONHOLD: return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
133            case CANCELLED: return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
134            case COMPLETED: return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
135            case ENTEREDINERROR: return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
136            case STOPPED: return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
137            case DRAFT: return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
138            case UNKNOWN: return "http://hl7.org/fhir/CodeSystem/medicationrequest-status";
139            case NULL: return null;
140            default: return "?";
141          }
142        }
143        public String getDefinition() {
144          switch (this) {
145            case ACTIVE: return "The prescription is 'actionable', but not all actions that are implied by it have occurred yet.";
146            case ONHOLD: return "Actions implied by the prescription are to be temporarily halted, but are expected to continue later.  May also be called 'suspended'.";
147            case CANCELLED: return "The prescription has been withdrawn before any administrations have occurred";
148            case COMPLETED: return "All actions that are implied by the prescription have occurred.";
149            case ENTEREDINERROR: 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";
150            case STOPPED: 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";
151            case DRAFT: 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.";
152            case UNKNOWN: return "The authoring/source system does not know which of the status values currently applies for this observation. Note: This concept is not to be used for 'other' - one of the listed statuses is presumed to apply, but the authoring/source system does not know which.";
153            case NULL: return null;
154            default: return "?";
155          }
156        }
157        public String getDisplay() {
158          switch (this) {
159            case ACTIVE: return "Active";
160            case ONHOLD: return "On Hold";
161            case CANCELLED: return "Cancelled";
162            case COMPLETED: return "Completed";
163            case ENTEREDINERROR: return "Entered in Error";
164            case STOPPED: return "Stopped";
165            case DRAFT: return "Draft";
166            case UNKNOWN: return "Unknown";
167            case NULL: return null;
168            default: return "?";
169          }
170        }
171    }
172
173  public static class MedicationRequestStatusEnumFactory implements EnumFactory<MedicationRequestStatus> {
174    public MedicationRequestStatus fromCode(String codeString) throws IllegalArgumentException {
175      if (codeString == null || "".equals(codeString))
176            if (codeString == null || "".equals(codeString))
177                return null;
178        if ("active".equals(codeString))
179          return MedicationRequestStatus.ACTIVE;
180        if ("on-hold".equals(codeString))
181          return MedicationRequestStatus.ONHOLD;
182        if ("cancelled".equals(codeString))
183          return MedicationRequestStatus.CANCELLED;
184        if ("completed".equals(codeString))
185          return MedicationRequestStatus.COMPLETED;
186        if ("entered-in-error".equals(codeString))
187          return MedicationRequestStatus.ENTEREDINERROR;
188        if ("stopped".equals(codeString))
189          return MedicationRequestStatus.STOPPED;
190        if ("draft".equals(codeString))
191          return MedicationRequestStatus.DRAFT;
192        if ("unknown".equals(codeString))
193          return MedicationRequestStatus.UNKNOWN;
194        throw new IllegalArgumentException("Unknown MedicationRequestStatus code '"+codeString+"'");
195        }
196        public Enumeration<MedicationRequestStatus> fromType(Base code) throws FHIRException {
197          if (code == null)
198            return null;
199          if (code.isEmpty())
200            return new Enumeration<MedicationRequestStatus>(this);
201          String codeString = ((PrimitiveType) code).asStringValue();
202          if (codeString == null || "".equals(codeString))
203            return null;
204        if ("active".equals(codeString))
205          return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.ACTIVE);
206        if ("on-hold".equals(codeString))
207          return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.ONHOLD);
208        if ("cancelled".equals(codeString))
209          return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.CANCELLED);
210        if ("completed".equals(codeString))
211          return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.COMPLETED);
212        if ("entered-in-error".equals(codeString))
213          return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.ENTEREDINERROR);
214        if ("stopped".equals(codeString))
215          return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.STOPPED);
216        if ("draft".equals(codeString))
217          return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.DRAFT);
218        if ("unknown".equals(codeString))
219          return new Enumeration<MedicationRequestStatus>(this, MedicationRequestStatus.UNKNOWN);
220        throw new FHIRException("Unknown MedicationRequestStatus code '"+codeString+"'");
221        }
222    public String toCode(MedicationRequestStatus code) {
223      if (code == MedicationRequestStatus.ACTIVE)
224        return "active";
225      if (code == MedicationRequestStatus.ONHOLD)
226        return "on-hold";
227      if (code == MedicationRequestStatus.CANCELLED)
228        return "cancelled";
229      if (code == MedicationRequestStatus.COMPLETED)
230        return "completed";
231      if (code == MedicationRequestStatus.ENTEREDINERROR)
232        return "entered-in-error";
233      if (code == MedicationRequestStatus.STOPPED)
234        return "stopped";
235      if (code == MedicationRequestStatus.DRAFT)
236        return "draft";
237      if (code == MedicationRequestStatus.UNKNOWN)
238        return "unknown";
239      return "?";
240      }
241    public String toSystem(MedicationRequestStatus code) {
242      return code.getSystem();
243      }
244    }
245
246    public enum MedicationRequestIntent {
247        /**
248         * 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
249         */
250        PROPOSAL, 
251        /**
252         * The request represents an intention to ensure something occurs without providing an authorization for others to act.
253         */
254        PLAN, 
255        /**
256         * The request represents a request/demand and authorization for action
257         */
258        ORDER, 
259        /**
260         * The request represents the original authorization for the medication request.
261         */
262        ORIGINALORDER, 
263        /**
264         * 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..
265         */
266        REFLEXORDER, 
267        /**
268         * 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.
269         */
270        FILLERORDER, 
271        /**
272         * The request represents an instance for the particular order, for example a medication administration record.
273         */
274        INSTANCEORDER, 
275        /**
276         * The request represents a component or option for a RequestGroup that establishes timing, conditionality and/or  other constraints among a set of requests.
277         */
278        OPTION, 
279        /**
280         * added to help the parsers with the generic types
281         */
282        NULL;
283        public static MedicationRequestIntent fromCode(String codeString) throws FHIRException {
284            if (codeString == null || "".equals(codeString))
285                return null;
286        if ("proposal".equals(codeString))
287          return PROPOSAL;
288        if ("plan".equals(codeString))
289          return PLAN;
290        if ("order".equals(codeString))
291          return ORDER;
292        if ("original-order".equals(codeString))
293          return ORIGINALORDER;
294        if ("reflex-order".equals(codeString))
295          return REFLEXORDER;
296        if ("filler-order".equals(codeString))
297          return FILLERORDER;
298        if ("instance-order".equals(codeString))
299          return INSTANCEORDER;
300        if ("option".equals(codeString))
301          return OPTION;
302        if (Configuration.isAcceptInvalidEnums())
303          return null;
304        else
305          throw new FHIRException("Unknown MedicationRequestIntent code '"+codeString+"'");
306        }
307        public String toCode() {
308          switch (this) {
309            case PROPOSAL: return "proposal";
310            case PLAN: return "plan";
311            case ORDER: return "order";
312            case ORIGINALORDER: return "original-order";
313            case REFLEXORDER: return "reflex-order";
314            case FILLERORDER: return "filler-order";
315            case INSTANCEORDER: return "instance-order";
316            case OPTION: return "option";
317            case NULL: return null;
318            default: return "?";
319          }
320        }
321        public String getSystem() {
322          switch (this) {
323            case PROPOSAL: return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
324            case PLAN: return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
325            case ORDER: return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
326            case ORIGINALORDER: return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
327            case REFLEXORDER: return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
328            case FILLERORDER: return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
329            case INSTANCEORDER: return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
330            case OPTION: return "http://hl7.org/fhir/CodeSystem/medicationrequest-intent";
331            case NULL: return null;
332            default: return "?";
333          }
334        }
335        public String getDefinition() {
336          switch (this) {
337            case PROPOSAL: 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";
338            case PLAN: return "The request represents an intention to ensure something occurs without providing an authorization for others to act.";
339            case ORDER: return "The request represents a request/demand and authorization for action";
340            case ORIGINALORDER: return "The request represents the original authorization for the medication request.";
341            case REFLEXORDER: 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..";
342            case FILLERORDER: 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.";
343            case INSTANCEORDER: return "The request represents an instance for the particular order, for example a medication administration record.";
344            case OPTION: return "The request represents a component or option for a RequestGroup that establishes timing, conditionality and/or  other constraints among a set of requests.";
345            case NULL: return null;
346            default: return "?";
347          }
348        }
349        public String getDisplay() {
350          switch (this) {
351            case PROPOSAL: return "Proposal";
352            case PLAN: return "Plan";
353            case ORDER: return "Order";
354            case ORIGINALORDER: return "Original Order";
355            case REFLEXORDER: return "Reflex Order";
356            case FILLERORDER: return "Filler Order";
357            case INSTANCEORDER: return "Instance Order";
358            case OPTION: return "Option";
359            case NULL: return null;
360            default: return "?";
361          }
362        }
363    }
364
365  public static class MedicationRequestIntentEnumFactory implements EnumFactory<MedicationRequestIntent> {
366    public MedicationRequestIntent fromCode(String codeString) throws IllegalArgumentException {
367      if (codeString == null || "".equals(codeString))
368            if (codeString == null || "".equals(codeString))
369                return null;
370        if ("proposal".equals(codeString))
371          return MedicationRequestIntent.PROPOSAL;
372        if ("plan".equals(codeString))
373          return MedicationRequestIntent.PLAN;
374        if ("order".equals(codeString))
375          return MedicationRequestIntent.ORDER;
376        if ("original-order".equals(codeString))
377          return MedicationRequestIntent.ORIGINALORDER;
378        if ("reflex-order".equals(codeString))
379          return MedicationRequestIntent.REFLEXORDER;
380        if ("filler-order".equals(codeString))
381          return MedicationRequestIntent.FILLERORDER;
382        if ("instance-order".equals(codeString))
383          return MedicationRequestIntent.INSTANCEORDER;
384        if ("option".equals(codeString))
385          return MedicationRequestIntent.OPTION;
386        throw new IllegalArgumentException("Unknown MedicationRequestIntent code '"+codeString+"'");
387        }
388        public Enumeration<MedicationRequestIntent> fromType(Base code) throws FHIRException {
389          if (code == null)
390            return null;
391          if (code.isEmpty())
392            return new Enumeration<MedicationRequestIntent>(this);
393          String codeString = ((PrimitiveType) code).asStringValue();
394          if (codeString == null || "".equals(codeString))
395            return null;
396        if ("proposal".equals(codeString))
397          return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.PROPOSAL);
398        if ("plan".equals(codeString))
399          return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.PLAN);
400        if ("order".equals(codeString))
401          return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.ORDER);
402        if ("original-order".equals(codeString))
403          return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.ORIGINALORDER);
404        if ("reflex-order".equals(codeString))
405          return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.REFLEXORDER);
406        if ("filler-order".equals(codeString))
407          return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.FILLERORDER);
408        if ("instance-order".equals(codeString))
409          return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.INSTANCEORDER);
410        if ("option".equals(codeString))
411          return new Enumeration<MedicationRequestIntent>(this, MedicationRequestIntent.OPTION);
412        throw new FHIRException("Unknown MedicationRequestIntent code '"+codeString+"'");
413        }
414    public String toCode(MedicationRequestIntent code) {
415      if (code == MedicationRequestIntent.PROPOSAL)
416        return "proposal";
417      if (code == MedicationRequestIntent.PLAN)
418        return "plan";
419      if (code == MedicationRequestIntent.ORDER)
420        return "order";
421      if (code == MedicationRequestIntent.ORIGINALORDER)
422        return "original-order";
423      if (code == MedicationRequestIntent.REFLEXORDER)
424        return "reflex-order";
425      if (code == MedicationRequestIntent.FILLERORDER)
426        return "filler-order";
427      if (code == MedicationRequestIntent.INSTANCEORDER)
428        return "instance-order";
429      if (code == MedicationRequestIntent.OPTION)
430        return "option";
431      return "?";
432      }
433    public String toSystem(MedicationRequestIntent code) {
434      return code.getSystem();
435      }
436    }
437
438    public enum MedicationRequestPriority {
439        /**
440         * The request has normal priority.
441         */
442        ROUTINE, 
443        /**
444         * The request should be actioned promptly - higher priority than routine.
445         */
446        URGENT, 
447        /**
448         * The request should be actioned as soon as possible - higher priority than urgent.
449         */
450        ASAP, 
451        /**
452         * The request should be actioned immediately - highest possible priority.  E.g. an emergency.
453         */
454        STAT, 
455        /**
456         * added to help the parsers with the generic types
457         */
458        NULL;
459        public static MedicationRequestPriority fromCode(String codeString) throws FHIRException {
460            if (codeString == null || "".equals(codeString))
461                return null;
462        if ("routine".equals(codeString))
463          return ROUTINE;
464        if ("urgent".equals(codeString))
465          return URGENT;
466        if ("asap".equals(codeString))
467          return ASAP;
468        if ("stat".equals(codeString))
469          return STAT;
470        if (Configuration.isAcceptInvalidEnums())
471          return null;
472        else
473          throw new FHIRException("Unknown MedicationRequestPriority code '"+codeString+"'");
474        }
475        public String toCode() {
476          switch (this) {
477            case ROUTINE: return "routine";
478            case URGENT: return "urgent";
479            case ASAP: return "asap";
480            case STAT: return "stat";
481            case NULL: return null;
482            default: return "?";
483          }
484        }
485        public String getSystem() {
486          switch (this) {
487            case ROUTINE: return "http://hl7.org/fhir/request-priority";
488            case URGENT: return "http://hl7.org/fhir/request-priority";
489            case ASAP: return "http://hl7.org/fhir/request-priority";
490            case STAT: return "http://hl7.org/fhir/request-priority";
491            case NULL: return null;
492            default: return "?";
493          }
494        }
495        public String getDefinition() {
496          switch (this) {
497            case ROUTINE: return "The request has normal priority.";
498            case URGENT: return "The request should be actioned promptly - higher priority than routine.";
499            case ASAP: return "The request should be actioned as soon as possible - higher priority than urgent.";
500            case STAT: return "The request should be actioned immediately - highest possible priority.  E.g. an emergency.";
501            case NULL: return null;
502            default: return "?";
503          }
504        }
505        public String getDisplay() {
506          switch (this) {
507            case ROUTINE: return "Routine";
508            case URGENT: return "Urgent";
509            case ASAP: return "ASAP";
510            case STAT: return "STAT";
511            case NULL: return null;
512            default: return "?";
513          }
514        }
515    }
516
517  public static class MedicationRequestPriorityEnumFactory implements EnumFactory<MedicationRequestPriority> {
518    public MedicationRequestPriority fromCode(String codeString) throws IllegalArgumentException {
519      if (codeString == null || "".equals(codeString))
520            if (codeString == null || "".equals(codeString))
521                return null;
522        if ("routine".equals(codeString))
523          return MedicationRequestPriority.ROUTINE;
524        if ("urgent".equals(codeString))
525          return MedicationRequestPriority.URGENT;
526        if ("asap".equals(codeString))
527          return MedicationRequestPriority.ASAP;
528        if ("stat".equals(codeString))
529          return MedicationRequestPriority.STAT;
530        throw new IllegalArgumentException("Unknown MedicationRequestPriority code '"+codeString+"'");
531        }
532        public Enumeration<MedicationRequestPriority> fromType(Base code) throws FHIRException {
533          if (code == null)
534            return null;
535          if (code.isEmpty())
536            return new Enumeration<MedicationRequestPriority>(this);
537          String codeString = ((PrimitiveType) code).asStringValue();
538          if (codeString == null || "".equals(codeString))
539            return null;
540        if ("routine".equals(codeString))
541          return new Enumeration<MedicationRequestPriority>(this, MedicationRequestPriority.ROUTINE);
542        if ("urgent".equals(codeString))
543          return new Enumeration<MedicationRequestPriority>(this, MedicationRequestPriority.URGENT);
544        if ("asap".equals(codeString))
545          return new Enumeration<MedicationRequestPriority>(this, MedicationRequestPriority.ASAP);
546        if ("stat".equals(codeString))
547          return new Enumeration<MedicationRequestPriority>(this, MedicationRequestPriority.STAT);
548        throw new FHIRException("Unknown MedicationRequestPriority code '"+codeString+"'");
549        }
550    public String toCode(MedicationRequestPriority code) {
551      if (code == MedicationRequestPriority.ROUTINE)
552        return "routine";
553      if (code == MedicationRequestPriority.URGENT)
554        return "urgent";
555      if (code == MedicationRequestPriority.ASAP)
556        return "asap";
557      if (code == MedicationRequestPriority.STAT)
558        return "stat";
559      return "?";
560      }
561    public String toSystem(MedicationRequestPriority code) {
562      return code.getSystem();
563      }
564    }
565
566    @Block()
567    public static class MedicationRequestDispenseRequestComponent extends BackboneElement implements IBaseBackboneElement {
568        /**
569         * Indicates the quantity or duration for the first dispense of the medication.
570         */
571        @Child(name = "initialFill", type = {}, order=1, min=0, max=1, modifier=false, summary=false)
572        @Description(shortDefinition="First fill details", formalDefinition="Indicates the quantity or duration for the first dispense of the medication." )
573        protected MedicationRequestDispenseRequestInitialFillComponent initialFill;
574
575        /**
576         * The minimum period of time that must occur between dispenses of the medication.
577         */
578        @Child(name = "dispenseInterval", type = {Duration.class}, order=2, min=0, max=1, modifier=false, summary=false)
579        @Description(shortDefinition="Minimum period of time between dispenses", formalDefinition="The minimum period of time that must occur between dispenses of the medication." )
580        protected Duration dispenseInterval;
581
582        /**
583         * This indicates the validity period of a prescription (stale dating the Prescription).
584         */
585        @Child(name = "validityPeriod", type = {Period.class}, order=3, min=0, max=1, modifier=false, summary=false)
586        @Description(shortDefinition="Time period supply is authorized for", formalDefinition="This indicates the validity period of a prescription (stale dating the Prescription)." )
587        protected Period validityPeriod;
588
589        /**
590         * 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.
591         */
592        @Child(name = "numberOfRepeatsAllowed", type = {UnsignedIntType.class}, order=4, min=0, max=1, modifier=false, summary=false)
593        @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." )
594        protected UnsignedIntType numberOfRepeatsAllowed;
595
596        /**
597         * The amount that is to be dispensed for one fill.
598         */
599        @Child(name = "quantity", type = {Quantity.class}, order=5, min=0, max=1, modifier=false, summary=false)
600        @Description(shortDefinition="Amount of medication to supply per dispense", formalDefinition="The amount that is to be dispensed for one fill." )
601        protected Quantity quantity;
602
603        /**
604         * 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.
605         */
606        @Child(name = "expectedSupplyDuration", type = {Duration.class}, order=6, min=0, max=1, modifier=false, summary=false)
607        @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." )
608        protected Duration expectedSupplyDuration;
609
610        /**
611         * Indicates the intended dispensing Organization specified by the prescriber.
612         */
613        @Child(name = "performer", type = {Organization.class}, order=7, min=0, max=1, modifier=false, summary=false)
614        @Description(shortDefinition="Intended dispenser", formalDefinition="Indicates the intended dispensing Organization specified by the prescriber." )
615        protected Reference performer;
616
617        /**
618         * The actual object that is the target of the reference (Indicates the intended dispensing Organization specified by the prescriber.)
619         */
620        protected Organization performerTarget;
621
622        private static final long serialVersionUID = -1680129929L;
623
624    /**
625     * Constructor
626     */
627      public MedicationRequestDispenseRequestComponent() {
628        super();
629      }
630
631        /**
632         * @return {@link #initialFill} (Indicates the quantity or duration for the first dispense of the medication.)
633         */
634        public MedicationRequestDispenseRequestInitialFillComponent getInitialFill() { 
635          if (this.initialFill == null)
636            if (Configuration.errorOnAutoCreate())
637              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.initialFill");
638            else if (Configuration.doAutoCreate())
639              this.initialFill = new MedicationRequestDispenseRequestInitialFillComponent(); // cc
640          return this.initialFill;
641        }
642
643        public boolean hasInitialFill() { 
644          return this.initialFill != null && !this.initialFill.isEmpty();
645        }
646
647        /**
648         * @param value {@link #initialFill} (Indicates the quantity or duration for the first dispense of the medication.)
649         */
650        public MedicationRequestDispenseRequestComponent setInitialFill(MedicationRequestDispenseRequestInitialFillComponent value) { 
651          this.initialFill = value;
652          return this;
653        }
654
655        /**
656         * @return {@link #dispenseInterval} (The minimum period of time that must occur between dispenses of the medication.)
657         */
658        public Duration getDispenseInterval() { 
659          if (this.dispenseInterval == null)
660            if (Configuration.errorOnAutoCreate())
661              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.dispenseInterval");
662            else if (Configuration.doAutoCreate())
663              this.dispenseInterval = new Duration(); // cc
664          return this.dispenseInterval;
665        }
666
667        public boolean hasDispenseInterval() { 
668          return this.dispenseInterval != null && !this.dispenseInterval.isEmpty();
669        }
670
671        /**
672         * @param value {@link #dispenseInterval} (The minimum period of time that must occur between dispenses of the medication.)
673         */
674        public MedicationRequestDispenseRequestComponent setDispenseInterval(Duration value) { 
675          this.dispenseInterval = value;
676          return this;
677        }
678
679        /**
680         * @return {@link #validityPeriod} (This indicates the validity period of a prescription (stale dating the Prescription).)
681         */
682        public Period getValidityPeriod() { 
683          if (this.validityPeriod == null)
684            if (Configuration.errorOnAutoCreate())
685              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.validityPeriod");
686            else if (Configuration.doAutoCreate())
687              this.validityPeriod = new Period(); // cc
688          return this.validityPeriod;
689        }
690
691        public boolean hasValidityPeriod() { 
692          return this.validityPeriod != null && !this.validityPeriod.isEmpty();
693        }
694
695        /**
696         * @param value {@link #validityPeriod} (This indicates the validity period of a prescription (stale dating the Prescription).)
697         */
698        public MedicationRequestDispenseRequestComponent setValidityPeriod(Period value) { 
699          this.validityPeriod = value;
700          return this;
701        }
702
703        /**
704         * @return {@link #numberOfRepeatsAllowed} (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.). This is the underlying object with id, value and extensions. The accessor "getNumberOfRepeatsAllowed" gives direct access to the value
705         */
706        public UnsignedIntType getNumberOfRepeatsAllowedElement() { 
707          if (this.numberOfRepeatsAllowed == null)
708            if (Configuration.errorOnAutoCreate())
709              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.numberOfRepeatsAllowed");
710            else if (Configuration.doAutoCreate())
711              this.numberOfRepeatsAllowed = new UnsignedIntType(); // bb
712          return this.numberOfRepeatsAllowed;
713        }
714
715        public boolean hasNumberOfRepeatsAllowedElement() { 
716          return this.numberOfRepeatsAllowed != null && !this.numberOfRepeatsAllowed.isEmpty();
717        }
718
719        public boolean hasNumberOfRepeatsAllowed() { 
720          return this.numberOfRepeatsAllowed != null && !this.numberOfRepeatsAllowed.isEmpty();
721        }
722
723        /**
724         * @param value {@link #numberOfRepeatsAllowed} (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.). This is the underlying object with id, value and extensions. The accessor "getNumberOfRepeatsAllowed" gives direct access to the value
725         */
726        public MedicationRequestDispenseRequestComponent setNumberOfRepeatsAllowedElement(UnsignedIntType value) { 
727          this.numberOfRepeatsAllowed = value;
728          return this;
729        }
730
731        /**
732         * @return 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.
733         */
734        public int getNumberOfRepeatsAllowed() { 
735          return this.numberOfRepeatsAllowed == null || this.numberOfRepeatsAllowed.isEmpty() ? 0 : this.numberOfRepeatsAllowed.getValue();
736        }
737
738        /**
739         * @param value 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.
740         */
741        public MedicationRequestDispenseRequestComponent setNumberOfRepeatsAllowed(int value) { 
742            if (this.numberOfRepeatsAllowed == null)
743              this.numberOfRepeatsAllowed = new UnsignedIntType();
744            this.numberOfRepeatsAllowed.setValue(value);
745          return this;
746        }
747
748        /**
749         * @return {@link #quantity} (The amount that is to be dispensed for one fill.)
750         */
751        public Quantity getQuantity() { 
752          if (this.quantity == null)
753            if (Configuration.errorOnAutoCreate())
754              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.quantity");
755            else if (Configuration.doAutoCreate())
756              this.quantity = new Quantity(); // cc
757          return this.quantity;
758        }
759
760        public boolean hasQuantity() { 
761          return this.quantity != null && !this.quantity.isEmpty();
762        }
763
764        /**
765         * @param value {@link #quantity} (The amount that is to be dispensed for one fill.)
766         */
767        public MedicationRequestDispenseRequestComponent setQuantity(Quantity value) { 
768          this.quantity = value;
769          return this;
770        }
771
772        /**
773         * @return {@link #expectedSupplyDuration} (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.)
774         */
775        public Duration getExpectedSupplyDuration() { 
776          if (this.expectedSupplyDuration == null)
777            if (Configuration.errorOnAutoCreate())
778              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.expectedSupplyDuration");
779            else if (Configuration.doAutoCreate())
780              this.expectedSupplyDuration = new Duration(); // cc
781          return this.expectedSupplyDuration;
782        }
783
784        public boolean hasExpectedSupplyDuration() { 
785          return this.expectedSupplyDuration != null && !this.expectedSupplyDuration.isEmpty();
786        }
787
788        /**
789         * @param value {@link #expectedSupplyDuration} (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.)
790         */
791        public MedicationRequestDispenseRequestComponent setExpectedSupplyDuration(Duration value) { 
792          this.expectedSupplyDuration = value;
793          return this;
794        }
795
796        /**
797         * @return {@link #performer} (Indicates the intended dispensing Organization specified by the prescriber.)
798         */
799        public Reference getPerformer() { 
800          if (this.performer == null)
801            if (Configuration.errorOnAutoCreate())
802              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.performer");
803            else if (Configuration.doAutoCreate())
804              this.performer = new Reference(); // cc
805          return this.performer;
806        }
807
808        public boolean hasPerformer() { 
809          return this.performer != null && !this.performer.isEmpty();
810        }
811
812        /**
813         * @param value {@link #performer} (Indicates the intended dispensing Organization specified by the prescriber.)
814         */
815        public MedicationRequestDispenseRequestComponent setPerformer(Reference value) { 
816          this.performer = value;
817          return this;
818        }
819
820        /**
821         * @return {@link #performer} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Indicates the intended dispensing Organization specified by the prescriber.)
822         */
823        public Organization getPerformerTarget() { 
824          if (this.performerTarget == null)
825            if (Configuration.errorOnAutoCreate())
826              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.performer");
827            else if (Configuration.doAutoCreate())
828              this.performerTarget = new Organization(); // aa
829          return this.performerTarget;
830        }
831
832        /**
833         * @param value {@link #performer} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Indicates the intended dispensing Organization specified by the prescriber.)
834         */
835        public MedicationRequestDispenseRequestComponent setPerformerTarget(Organization value) { 
836          this.performerTarget = value;
837          return this;
838        }
839
840        protected void listChildren(List<Property> children) {
841          super.listChildren(children);
842          children.add(new Property("initialFill", "", "Indicates the quantity or duration for the first dispense of the medication.", 0, 1, initialFill));
843          children.add(new Property("dispenseInterval", "Duration", "The minimum period of time that must occur between dispenses of the medication.", 0, 1, dispenseInterval));
844          children.add(new Property("validityPeriod", "Period", "This indicates the validity period of a prescription (stale dating the Prescription).", 0, 1, validityPeriod));
845          children.add(new Property("numberOfRepeatsAllowed", "unsignedInt", "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.", 0, 1, numberOfRepeatsAllowed));
846          children.add(new Property("quantity", "SimpleQuantity", "The amount that is to be dispensed for one fill.", 0, 1, quantity));
847          children.add(new Property("expectedSupplyDuration", "Duration", "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.", 0, 1, expectedSupplyDuration));
848          children.add(new Property("performer", "Reference(Organization)", "Indicates the intended dispensing Organization specified by the prescriber.", 0, 1, performer));
849        }
850
851        @Override
852        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
853          switch (_hash) {
854          case 1232961255: /*initialFill*/  return new Property("initialFill", "", "Indicates the quantity or duration for the first dispense of the medication.", 0, 1, initialFill);
855          case 757112130: /*dispenseInterval*/  return new Property("dispenseInterval", "Duration", "The minimum period of time that must occur between dispenses of the medication.", 0, 1, dispenseInterval);
856          case -1434195053: /*validityPeriod*/  return new Property("validityPeriod", "Period", "This indicates the validity period of a prescription (stale dating the Prescription).", 0, 1, validityPeriod);
857          case -239736976: /*numberOfRepeatsAllowed*/  return new Property("numberOfRepeatsAllowed", "unsignedInt", "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.", 0, 1, numberOfRepeatsAllowed);
858          case -1285004149: /*quantity*/  return new Property("quantity", "SimpleQuantity", "The amount that is to be dispensed for one fill.", 0, 1, quantity);
859          case -1910182789: /*expectedSupplyDuration*/  return new Property("expectedSupplyDuration", "Duration", "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.", 0, 1, expectedSupplyDuration);
860          case 481140686: /*performer*/  return new Property("performer", "Reference(Organization)", "Indicates the intended dispensing Organization specified by the prescriber.", 0, 1, performer);
861          default: return super.getNamedProperty(_hash, _name, _checkValid);
862          }
863
864        }
865
866      @Override
867      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
868        switch (hash) {
869        case 1232961255: /*initialFill*/ return this.initialFill == null ? new Base[0] : new Base[] {this.initialFill}; // MedicationRequestDispenseRequestInitialFillComponent
870        case 757112130: /*dispenseInterval*/ return this.dispenseInterval == null ? new Base[0] : new Base[] {this.dispenseInterval}; // Duration
871        case -1434195053: /*validityPeriod*/ return this.validityPeriod == null ? new Base[0] : new Base[] {this.validityPeriod}; // Period
872        case -239736976: /*numberOfRepeatsAllowed*/ return this.numberOfRepeatsAllowed == null ? new Base[0] : new Base[] {this.numberOfRepeatsAllowed}; // UnsignedIntType
873        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // Quantity
874        case -1910182789: /*expectedSupplyDuration*/ return this.expectedSupplyDuration == null ? new Base[0] : new Base[] {this.expectedSupplyDuration}; // Duration
875        case 481140686: /*performer*/ return this.performer == null ? new Base[0] : new Base[] {this.performer}; // Reference
876        default: return super.getProperty(hash, name, checkValid);
877        }
878
879      }
880
881      @Override
882      public Base setProperty(int hash, String name, Base value) throws FHIRException {
883        switch (hash) {
884        case 1232961255: // initialFill
885          this.initialFill = (MedicationRequestDispenseRequestInitialFillComponent) value; // MedicationRequestDispenseRequestInitialFillComponent
886          return value;
887        case 757112130: // dispenseInterval
888          this.dispenseInterval = castToDuration(value); // Duration
889          return value;
890        case -1434195053: // validityPeriod
891          this.validityPeriod = castToPeriod(value); // Period
892          return value;
893        case -239736976: // numberOfRepeatsAllowed
894          this.numberOfRepeatsAllowed = castToUnsignedInt(value); // UnsignedIntType
895          return value;
896        case -1285004149: // quantity
897          this.quantity = castToQuantity(value); // Quantity
898          return value;
899        case -1910182789: // expectedSupplyDuration
900          this.expectedSupplyDuration = castToDuration(value); // Duration
901          return value;
902        case 481140686: // performer
903          this.performer = castToReference(value); // Reference
904          return value;
905        default: return super.setProperty(hash, name, value);
906        }
907
908      }
909
910      @Override
911      public Base setProperty(String name, Base value) throws FHIRException {
912        if (name.equals("initialFill")) {
913          this.initialFill = (MedicationRequestDispenseRequestInitialFillComponent) value; // MedicationRequestDispenseRequestInitialFillComponent
914        } else if (name.equals("dispenseInterval")) {
915          this.dispenseInterval = castToDuration(value); // Duration
916        } else if (name.equals("validityPeriod")) {
917          this.validityPeriod = castToPeriod(value); // Period
918        } else if (name.equals("numberOfRepeatsAllowed")) {
919          this.numberOfRepeatsAllowed = castToUnsignedInt(value); // UnsignedIntType
920        } else if (name.equals("quantity")) {
921          this.quantity = castToQuantity(value); // Quantity
922        } else if (name.equals("expectedSupplyDuration")) {
923          this.expectedSupplyDuration = castToDuration(value); // Duration
924        } else if (name.equals("performer")) {
925          this.performer = castToReference(value); // Reference
926        } else
927          return super.setProperty(name, value);
928        return value;
929      }
930
931      @Override
932      public Base makeProperty(int hash, String name) throws FHIRException {
933        switch (hash) {
934        case 1232961255:  return getInitialFill(); 
935        case 757112130:  return getDispenseInterval(); 
936        case -1434195053:  return getValidityPeriod(); 
937        case -239736976:  return getNumberOfRepeatsAllowedElement();
938        case -1285004149:  return getQuantity(); 
939        case -1910182789:  return getExpectedSupplyDuration(); 
940        case 481140686:  return getPerformer(); 
941        default: return super.makeProperty(hash, name);
942        }
943
944      }
945
946      @Override
947      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
948        switch (hash) {
949        case 1232961255: /*initialFill*/ return new String[] {};
950        case 757112130: /*dispenseInterval*/ return new String[] {"Duration"};
951        case -1434195053: /*validityPeriod*/ return new String[] {"Period"};
952        case -239736976: /*numberOfRepeatsAllowed*/ return new String[] {"unsignedInt"};
953        case -1285004149: /*quantity*/ return new String[] {"SimpleQuantity"};
954        case -1910182789: /*expectedSupplyDuration*/ return new String[] {"Duration"};
955        case 481140686: /*performer*/ return new String[] {"Reference"};
956        default: return super.getTypesForProperty(hash, name);
957        }
958
959      }
960
961      @Override
962      public Base addChild(String name) throws FHIRException {
963        if (name.equals("initialFill")) {
964          this.initialFill = new MedicationRequestDispenseRequestInitialFillComponent();
965          return this.initialFill;
966        }
967        else if (name.equals("dispenseInterval")) {
968          this.dispenseInterval = new Duration();
969          return this.dispenseInterval;
970        }
971        else if (name.equals("validityPeriod")) {
972          this.validityPeriod = new Period();
973          return this.validityPeriod;
974        }
975        else if (name.equals("numberOfRepeatsAllowed")) {
976          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.numberOfRepeatsAllowed");
977        }
978        else if (name.equals("quantity")) {
979          this.quantity = new Quantity();
980          return this.quantity;
981        }
982        else if (name.equals("expectedSupplyDuration")) {
983          this.expectedSupplyDuration = new Duration();
984          return this.expectedSupplyDuration;
985        }
986        else if (name.equals("performer")) {
987          this.performer = new Reference();
988          return this.performer;
989        }
990        else
991          return super.addChild(name);
992      }
993
994      public MedicationRequestDispenseRequestComponent copy() {
995        MedicationRequestDispenseRequestComponent dst = new MedicationRequestDispenseRequestComponent();
996        copyValues(dst);
997        return dst;
998      }
999
1000      public void copyValues(MedicationRequestDispenseRequestComponent dst) {
1001        super.copyValues(dst);
1002        dst.initialFill = initialFill == null ? null : initialFill.copy();
1003        dst.dispenseInterval = dispenseInterval == null ? null : dispenseInterval.copy();
1004        dst.validityPeriod = validityPeriod == null ? null : validityPeriod.copy();
1005        dst.numberOfRepeatsAllowed = numberOfRepeatsAllowed == null ? null : numberOfRepeatsAllowed.copy();
1006        dst.quantity = quantity == null ? null : quantity.copy();
1007        dst.expectedSupplyDuration = expectedSupplyDuration == null ? null : expectedSupplyDuration.copy();
1008        dst.performer = performer == null ? null : performer.copy();
1009      }
1010
1011      @Override
1012      public boolean equalsDeep(Base other_) {
1013        if (!super.equalsDeep(other_))
1014          return false;
1015        if (!(other_ instanceof MedicationRequestDispenseRequestComponent))
1016          return false;
1017        MedicationRequestDispenseRequestComponent o = (MedicationRequestDispenseRequestComponent) other_;
1018        return compareDeep(initialFill, o.initialFill, true) && compareDeep(dispenseInterval, o.dispenseInterval, true)
1019           && compareDeep(validityPeriod, o.validityPeriod, true) && compareDeep(numberOfRepeatsAllowed, o.numberOfRepeatsAllowed, true)
1020           && compareDeep(quantity, o.quantity, true) && compareDeep(expectedSupplyDuration, o.expectedSupplyDuration, true)
1021           && compareDeep(performer, o.performer, true);
1022      }
1023
1024      @Override
1025      public boolean equalsShallow(Base other_) {
1026        if (!super.equalsShallow(other_))
1027          return false;
1028        if (!(other_ instanceof MedicationRequestDispenseRequestComponent))
1029          return false;
1030        MedicationRequestDispenseRequestComponent o = (MedicationRequestDispenseRequestComponent) other_;
1031        return compareValues(numberOfRepeatsAllowed, o.numberOfRepeatsAllowed, true);
1032      }
1033
1034      public boolean isEmpty() {
1035        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(initialFill, dispenseInterval
1036          , validityPeriod, numberOfRepeatsAllowed, quantity, expectedSupplyDuration, performer
1037          );
1038      }
1039
1040  public String fhirType() {
1041    return "MedicationRequest.dispenseRequest";
1042
1043  }
1044
1045  }
1046
1047    @Block()
1048    public static class MedicationRequestDispenseRequestInitialFillComponent extends BackboneElement implements IBaseBackboneElement {
1049        /**
1050         * The amount or quantity to provide as part of the first dispense.
1051         */
1052        @Child(name = "quantity", type = {Quantity.class}, order=1, min=0, max=1, modifier=false, summary=false)
1053        @Description(shortDefinition="First fill quantity", formalDefinition="The amount or quantity to provide as part of the first dispense." )
1054        protected Quantity quantity;
1055
1056        /**
1057         * The length of time that the first dispense is expected to last.
1058         */
1059        @Child(name = "duration", type = {Duration.class}, order=2, min=0, max=1, modifier=false, summary=false)
1060        @Description(shortDefinition="First fill duration", formalDefinition="The length of time that the first dispense is expected to last." )
1061        protected Duration duration;
1062
1063        private static final long serialVersionUID = 1223227956L;
1064
1065    /**
1066     * Constructor
1067     */
1068      public MedicationRequestDispenseRequestInitialFillComponent() {
1069        super();
1070      }
1071
1072        /**
1073         * @return {@link #quantity} (The amount or quantity to provide as part of the first dispense.)
1074         */
1075        public Quantity getQuantity() { 
1076          if (this.quantity == null)
1077            if (Configuration.errorOnAutoCreate())
1078              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestInitialFillComponent.quantity");
1079            else if (Configuration.doAutoCreate())
1080              this.quantity = new Quantity(); // cc
1081          return this.quantity;
1082        }
1083
1084        public boolean hasQuantity() { 
1085          return this.quantity != null && !this.quantity.isEmpty();
1086        }
1087
1088        /**
1089         * @param value {@link #quantity} (The amount or quantity to provide as part of the first dispense.)
1090         */
1091        public MedicationRequestDispenseRequestInitialFillComponent setQuantity(Quantity value) { 
1092          this.quantity = value;
1093          return this;
1094        }
1095
1096        /**
1097         * @return {@link #duration} (The length of time that the first dispense is expected to last.)
1098         */
1099        public Duration getDuration() { 
1100          if (this.duration == null)
1101            if (Configuration.errorOnAutoCreate())
1102              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestInitialFillComponent.duration");
1103            else if (Configuration.doAutoCreate())
1104              this.duration = new Duration(); // cc
1105          return this.duration;
1106        }
1107
1108        public boolean hasDuration() { 
1109          return this.duration != null && !this.duration.isEmpty();
1110        }
1111
1112        /**
1113         * @param value {@link #duration} (The length of time that the first dispense is expected to last.)
1114         */
1115        public MedicationRequestDispenseRequestInitialFillComponent setDuration(Duration value) { 
1116          this.duration = value;
1117          return this;
1118        }
1119
1120        protected void listChildren(List<Property> children) {
1121          super.listChildren(children);
1122          children.add(new Property("quantity", "SimpleQuantity", "The amount or quantity to provide as part of the first dispense.", 0, 1, quantity));
1123          children.add(new Property("duration", "Duration", "The length of time that the first dispense is expected to last.", 0, 1, duration));
1124        }
1125
1126        @Override
1127        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1128          switch (_hash) {
1129          case -1285004149: /*quantity*/  return new Property("quantity", "SimpleQuantity", "The amount or quantity to provide as part of the first dispense.", 0, 1, quantity);
1130          case -1992012396: /*duration*/  return new Property("duration", "Duration", "The length of time that the first dispense is expected to last.", 0, 1, duration);
1131          default: return super.getNamedProperty(_hash, _name, _checkValid);
1132          }
1133
1134        }
1135
1136      @Override
1137      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1138        switch (hash) {
1139        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // Quantity
1140        case -1992012396: /*duration*/ return this.duration == null ? new Base[0] : new Base[] {this.duration}; // Duration
1141        default: return super.getProperty(hash, name, checkValid);
1142        }
1143
1144      }
1145
1146      @Override
1147      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1148        switch (hash) {
1149        case -1285004149: // quantity
1150          this.quantity = castToQuantity(value); // Quantity
1151          return value;
1152        case -1992012396: // duration
1153          this.duration = castToDuration(value); // Duration
1154          return value;
1155        default: return super.setProperty(hash, name, value);
1156        }
1157
1158      }
1159
1160      @Override
1161      public Base setProperty(String name, Base value) throws FHIRException {
1162        if (name.equals("quantity")) {
1163          this.quantity = castToQuantity(value); // Quantity
1164        } else if (name.equals("duration")) {
1165          this.duration = castToDuration(value); // Duration
1166        } else
1167          return super.setProperty(name, value);
1168        return value;
1169      }
1170
1171      @Override
1172      public Base makeProperty(int hash, String name) throws FHIRException {
1173        switch (hash) {
1174        case -1285004149:  return getQuantity(); 
1175        case -1992012396:  return getDuration(); 
1176        default: return super.makeProperty(hash, name);
1177        }
1178
1179      }
1180
1181      @Override
1182      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1183        switch (hash) {
1184        case -1285004149: /*quantity*/ return new String[] {"SimpleQuantity"};
1185        case -1992012396: /*duration*/ return new String[] {"Duration"};
1186        default: return super.getTypesForProperty(hash, name);
1187        }
1188
1189      }
1190
1191      @Override
1192      public Base addChild(String name) throws FHIRException {
1193        if (name.equals("quantity")) {
1194          this.quantity = new Quantity();
1195          return this.quantity;
1196        }
1197        else if (name.equals("duration")) {
1198          this.duration = new Duration();
1199          return this.duration;
1200        }
1201        else
1202          return super.addChild(name);
1203      }
1204
1205      public MedicationRequestDispenseRequestInitialFillComponent copy() {
1206        MedicationRequestDispenseRequestInitialFillComponent dst = new MedicationRequestDispenseRequestInitialFillComponent();
1207        copyValues(dst);
1208        return dst;
1209      }
1210
1211      public void copyValues(MedicationRequestDispenseRequestInitialFillComponent dst) {
1212        super.copyValues(dst);
1213        dst.quantity = quantity == null ? null : quantity.copy();
1214        dst.duration = duration == null ? null : duration.copy();
1215      }
1216
1217      @Override
1218      public boolean equalsDeep(Base other_) {
1219        if (!super.equalsDeep(other_))
1220          return false;
1221        if (!(other_ instanceof MedicationRequestDispenseRequestInitialFillComponent))
1222          return false;
1223        MedicationRequestDispenseRequestInitialFillComponent o = (MedicationRequestDispenseRequestInitialFillComponent) other_;
1224        return compareDeep(quantity, o.quantity, true) && compareDeep(duration, o.duration, true);
1225      }
1226
1227      @Override
1228      public boolean equalsShallow(Base other_) {
1229        if (!super.equalsShallow(other_))
1230          return false;
1231        if (!(other_ instanceof MedicationRequestDispenseRequestInitialFillComponent))
1232          return false;
1233        MedicationRequestDispenseRequestInitialFillComponent o = (MedicationRequestDispenseRequestInitialFillComponent) other_;
1234        return true;
1235      }
1236
1237      public boolean isEmpty() {
1238        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(quantity, duration);
1239      }
1240
1241  public String fhirType() {
1242    return "MedicationRequest.dispenseRequest.initialFill";
1243
1244  }
1245
1246  }
1247
1248    @Block()
1249    public static class MedicationRequestSubstitutionComponent extends BackboneElement implements IBaseBackboneElement {
1250        /**
1251         * True if the prescriber allows a different drug to be dispensed from what was prescribed.
1252         */
1253        @Child(name = "allowed", type = {BooleanType.class, CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=false)
1254        @Description(shortDefinition="Whether substitution is allowed or not", formalDefinition="True if the prescriber allows a different drug to be dispensed from what was prescribed." )
1255        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v3-ActSubstanceAdminSubstitutionCode")
1256        protected Type allowed;
1257
1258        /**
1259         * Indicates the reason for the substitution, or why substitution must or must not be performed.
1260         */
1261        @Child(name = "reason", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
1262        @Description(shortDefinition="Why should (not) substitution be made", formalDefinition="Indicates the reason for the substitution, or why substitution must or must not be performed." )
1263        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v3-SubstanceAdminSubstitutionReason")
1264        protected CodeableConcept reason;
1265
1266        private static final long serialVersionUID = 547265407L;
1267
1268    /**
1269     * Constructor
1270     */
1271      public MedicationRequestSubstitutionComponent() {
1272        super();
1273      }
1274
1275    /**
1276     * Constructor
1277     */
1278      public MedicationRequestSubstitutionComponent(Type allowed) {
1279        super();
1280        this.allowed = allowed;
1281      }
1282
1283        /**
1284         * @return {@link #allowed} (True if the prescriber allows a different drug to be dispensed from what was prescribed.)
1285         */
1286        public Type getAllowed() { 
1287          return this.allowed;
1288        }
1289
1290        /**
1291         * @return {@link #allowed} (True if the prescriber allows a different drug to be dispensed from what was prescribed.)
1292         */
1293        public BooleanType getAllowedBooleanType() throws FHIRException { 
1294          if (this.allowed == null)
1295            this.allowed = new BooleanType();
1296          if (!(this.allowed instanceof BooleanType))
1297            throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.allowed.getClass().getName()+" was encountered");
1298          return (BooleanType) this.allowed;
1299        }
1300
1301        public boolean hasAllowedBooleanType() { 
1302          return this != null && this.allowed instanceof BooleanType;
1303        }
1304
1305        /**
1306         * @return {@link #allowed} (True if the prescriber allows a different drug to be dispensed from what was prescribed.)
1307         */
1308        public CodeableConcept getAllowedCodeableConcept() throws FHIRException { 
1309          if (this.allowed == null)
1310            this.allowed = new CodeableConcept();
1311          if (!(this.allowed instanceof CodeableConcept))
1312            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.allowed.getClass().getName()+" was encountered");
1313          return (CodeableConcept) this.allowed;
1314        }
1315
1316        public boolean hasAllowedCodeableConcept() { 
1317          return this != null && this.allowed instanceof CodeableConcept;
1318        }
1319
1320        public boolean hasAllowed() { 
1321          return this.allowed != null && !this.allowed.isEmpty();
1322        }
1323
1324        /**
1325         * @param value {@link #allowed} (True if the prescriber allows a different drug to be dispensed from what was prescribed.)
1326         */
1327        public MedicationRequestSubstitutionComponent setAllowed(Type value) { 
1328          if (value != null && !(value instanceof BooleanType || value instanceof CodeableConcept))
1329            throw new Error("Not the right type for MedicationRequest.substitution.allowed[x]: "+value.fhirType());
1330          this.allowed = value;
1331          return this;
1332        }
1333
1334        /**
1335         * @return {@link #reason} (Indicates the reason for the substitution, or why substitution must or must not be performed.)
1336         */
1337        public CodeableConcept getReason() { 
1338          if (this.reason == null)
1339            if (Configuration.errorOnAutoCreate())
1340              throw new Error("Attempt to auto-create MedicationRequestSubstitutionComponent.reason");
1341            else if (Configuration.doAutoCreate())
1342              this.reason = new CodeableConcept(); // cc
1343          return this.reason;
1344        }
1345
1346        public boolean hasReason() { 
1347          return this.reason != null && !this.reason.isEmpty();
1348        }
1349
1350        /**
1351         * @param value {@link #reason} (Indicates the reason for the substitution, or why substitution must or must not be performed.)
1352         */
1353        public MedicationRequestSubstitutionComponent setReason(CodeableConcept value) { 
1354          this.reason = value;
1355          return this;
1356        }
1357
1358        protected void listChildren(List<Property> children) {
1359          super.listChildren(children);
1360          children.add(new Property("allowed[x]", "boolean|CodeableConcept", "True if the prescriber allows a different drug to be dispensed from what was prescribed.", 0, 1, allowed));
1361          children.add(new Property("reason", "CodeableConcept", "Indicates the reason for the substitution, or why substitution must or must not be performed.", 0, 1, reason));
1362        }
1363
1364        @Override
1365        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1366          switch (_hash) {
1367          case -1336663592: /*allowed[x]*/  return new Property("allowed[x]", "boolean|CodeableConcept", "True if the prescriber allows a different drug to be dispensed from what was prescribed.", 0, 1, allowed);
1368          case -911343192: /*allowed*/  return new Property("allowed[x]", "boolean|CodeableConcept", "True if the prescriber allows a different drug to be dispensed from what was prescribed.", 0, 1, allowed);
1369          case 177755488: /*allowedBoolean*/  return new Property("allowed[x]", "boolean|CodeableConcept", "True if the prescriber allows a different drug to be dispensed from what was prescribed.", 0, 1, allowed);
1370          case 963125465: /*allowedCodeableConcept*/  return new Property("allowed[x]", "boolean|CodeableConcept", "True if the prescriber allows a different drug to be dispensed from what was prescribed.", 0, 1, allowed);
1371          case -934964668: /*reason*/  return new Property("reason", "CodeableConcept", "Indicates the reason for the substitution, or why substitution must or must not be performed.", 0, 1, reason);
1372          default: return super.getNamedProperty(_hash, _name, _checkValid);
1373          }
1374
1375        }
1376
1377      @Override
1378      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1379        switch (hash) {
1380        case -911343192: /*allowed*/ return this.allowed == null ? new Base[0] : new Base[] {this.allowed}; // Type
1381        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : new Base[] {this.reason}; // CodeableConcept
1382        default: return super.getProperty(hash, name, checkValid);
1383        }
1384
1385      }
1386
1387      @Override
1388      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1389        switch (hash) {
1390        case -911343192: // allowed
1391          this.allowed = castToType(value); // Type
1392          return value;
1393        case -934964668: // reason
1394          this.reason = castToCodeableConcept(value); // CodeableConcept
1395          return value;
1396        default: return super.setProperty(hash, name, value);
1397        }
1398
1399      }
1400
1401      @Override
1402      public Base setProperty(String name, Base value) throws FHIRException {
1403        if (name.equals("allowed[x]")) {
1404          this.allowed = castToType(value); // Type
1405        } else if (name.equals("reason")) {
1406          this.reason = castToCodeableConcept(value); // CodeableConcept
1407        } else
1408          return super.setProperty(name, value);
1409        return value;
1410      }
1411
1412      @Override
1413      public Base makeProperty(int hash, String name) throws FHIRException {
1414        switch (hash) {
1415        case -1336663592:  return getAllowed(); 
1416        case -911343192:  return getAllowed(); 
1417        case -934964668:  return getReason(); 
1418        default: return super.makeProperty(hash, name);
1419        }
1420
1421      }
1422
1423      @Override
1424      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1425        switch (hash) {
1426        case -911343192: /*allowed*/ return new String[] {"boolean", "CodeableConcept"};
1427        case -934964668: /*reason*/ return new String[] {"CodeableConcept"};
1428        default: return super.getTypesForProperty(hash, name);
1429        }
1430
1431      }
1432
1433      @Override
1434      public Base addChild(String name) throws FHIRException {
1435        if (name.equals("allowedBoolean")) {
1436          this.allowed = new BooleanType();
1437          return this.allowed;
1438        }
1439        else if (name.equals("allowedCodeableConcept")) {
1440          this.allowed = new CodeableConcept();
1441          return this.allowed;
1442        }
1443        else if (name.equals("reason")) {
1444          this.reason = new CodeableConcept();
1445          return this.reason;
1446        }
1447        else
1448          return super.addChild(name);
1449      }
1450
1451      public MedicationRequestSubstitutionComponent copy() {
1452        MedicationRequestSubstitutionComponent dst = new MedicationRequestSubstitutionComponent();
1453        copyValues(dst);
1454        return dst;
1455      }
1456
1457      public void copyValues(MedicationRequestSubstitutionComponent dst) {
1458        super.copyValues(dst);
1459        dst.allowed = allowed == null ? null : allowed.copy();
1460        dst.reason = reason == null ? null : reason.copy();
1461      }
1462
1463      @Override
1464      public boolean equalsDeep(Base other_) {
1465        if (!super.equalsDeep(other_))
1466          return false;
1467        if (!(other_ instanceof MedicationRequestSubstitutionComponent))
1468          return false;
1469        MedicationRequestSubstitutionComponent o = (MedicationRequestSubstitutionComponent) other_;
1470        return compareDeep(allowed, o.allowed, true) && compareDeep(reason, o.reason, true);
1471      }
1472
1473      @Override
1474      public boolean equalsShallow(Base other_) {
1475        if (!super.equalsShallow(other_))
1476          return false;
1477        if (!(other_ instanceof MedicationRequestSubstitutionComponent))
1478          return false;
1479        MedicationRequestSubstitutionComponent o = (MedicationRequestSubstitutionComponent) other_;
1480        return true;
1481      }
1482
1483      public boolean isEmpty() {
1484        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(allowed, reason);
1485      }
1486
1487  public String fhirType() {
1488    return "MedicationRequest.substitution";
1489
1490  }
1491
1492  }
1493
1494    /**
1495     * 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.
1496     */
1497    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1498    @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." )
1499    protected List<Identifier> identifier;
1500
1501    /**
1502     * A code specifying the current state of the order.  Generally, this will be active or completed state.
1503     */
1504    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
1505    @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." )
1506    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medicationrequest-status")
1507    protected Enumeration<MedicationRequestStatus> status;
1508
1509    /**
1510     * Captures the reason for the current state of the MedicationRequest.
1511     */
1512    @Child(name = "statusReason", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
1513    @Description(shortDefinition="Reason for current status", formalDefinition="Captures the reason for the current state of the MedicationRequest." )
1514    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medicationrequest-status-reason")
1515    protected CodeableConcept statusReason;
1516
1517    /**
1518     * Whether the request is a proposal, plan, or an original order.
1519     */
1520    @Child(name = "intent", type = {CodeType.class}, order=3, min=1, max=1, modifier=true, summary=true)
1521    @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." )
1522    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medicationrequest-intent")
1523    protected Enumeration<MedicationRequestIntent> intent;
1524
1525    /**
1526     * Indicates the type of medication request (for example, where the medication is expected to be consumed or administered (i.e. inpatient or outpatient)).
1527     */
1528    @Child(name = "category", type = {CodeableConcept.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1529    @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))." )
1530    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medicationrequest-category")
1531    protected List<CodeableConcept> category;
1532
1533    /**
1534     * Indicates how quickly the Medication Request should be addressed with respect to other requests.
1535     */
1536    @Child(name = "priority", type = {CodeType.class}, order=5, min=0, max=1, modifier=false, summary=true)
1537    @Description(shortDefinition="routine | urgent | asap | stat", formalDefinition="Indicates how quickly the Medication Request should be addressed with respect to other requests." )
1538    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/request-priority")
1539    protected Enumeration<MedicationRequestPriority> priority;
1540
1541    /**
1542     * If true indicates that the provider is asking for the medication request not to occur.
1543     */
1544    @Child(name = "doNotPerform", type = {BooleanType.class}, order=6, min=0, max=1, modifier=true, summary=true)
1545    @Description(shortDefinition="True if request is prohibiting action", formalDefinition="If true indicates that the provider is asking for the medication request not to occur." )
1546    protected BooleanType doNotPerform;
1547
1548    /**
1549     * 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.
1550     */
1551    @Child(name = "reported", type = {BooleanType.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class, Organization.class}, order=7, min=0, max=1, modifier=false, summary=true)
1552    @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." )
1553    protected Type reported;
1554
1555    /**
1556     * 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.
1557     */
1558    @Child(name = "medication", type = {CodeableConcept.class, Medication.class}, order=8, min=1, max=1, modifier=false, summary=true)
1559    @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." )
1560    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-codes")
1561    protected Type medication;
1562
1563    /**
1564     * A link to a resource representing the person or set of individuals to whom the medication will be given.
1565     */
1566    @Child(name = "subject", type = {Patient.class, Group.class}, order=9, min=1, max=1, modifier=false, summary=true)
1567    @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." )
1568    protected Reference subject;
1569
1570    /**
1571     * The actual object that is the target of the reference (A link to a resource representing the person or set of individuals to whom the medication will be given.)
1572     */
1573    protected Resource subjectTarget;
1574
1575    /**
1576     * The Encounter during which this [x] was created or to which the creation of this record is tightly associated.
1577     */
1578    @Child(name = "encounter", type = {Encounter.class}, order=10, min=0, max=1, modifier=false, summary=false)
1579    @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." )
1580    protected Reference encounter;
1581
1582    /**
1583     * The actual object that is the target of the reference (The Encounter during which this [x] was created or to which the creation of this record is tightly associated.)
1584     */
1585    protected Encounter encounterTarget;
1586
1587    /**
1588     * Include additional information (for example, patient height and weight) that supports the ordering of the medication.
1589     */
1590    @Child(name = "supportingInformation", type = {Reference.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1591    @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." )
1592    protected List<Reference> supportingInformation;
1593    /**
1594     * The actual objects that are the target of the reference (Include additional information (for example, patient height and weight) that supports the ordering of the medication.)
1595     */
1596    protected List<Resource> supportingInformationTarget;
1597
1598
1599    /**
1600     * The date (and perhaps time) when the prescription was initially written or authored on.
1601     */
1602    @Child(name = "authoredOn", type = {DateTimeType.class}, order=12, min=0, max=1, modifier=false, summary=true)
1603    @Description(shortDefinition="When request was initially authored", formalDefinition="The date (and perhaps time) when the prescription was initially written or authored on." )
1604    protected DateTimeType authoredOn;
1605
1606    /**
1607     * The individual, organization, or device that initiated the request and has responsibility for its activation.
1608     */
1609    @Child(name = "requester", type = {Practitioner.class, PractitionerRole.class, Organization.class, Patient.class, RelatedPerson.class, Device.class}, order=13, min=0, max=1, modifier=false, summary=true)
1610    @Description(shortDefinition="Who/What requested the Request", formalDefinition="The individual, organization, or device that initiated the request and has responsibility for its activation." )
1611    protected Reference requester;
1612
1613    /**
1614     * The actual object that is the target of the reference (The individual, organization, or device that initiated the request and has responsibility for its activation.)
1615     */
1616    protected Resource requesterTarget;
1617
1618    /**
1619     * The specified desired performer of the medication treatment (e.g. the performer of the medication administration).
1620     */
1621    @Child(name = "performer", type = {Practitioner.class, PractitionerRole.class, Organization.class, Patient.class, Device.class, RelatedPerson.class, CareTeam.class}, order=14, min=0, max=1, modifier=false, summary=false)
1622    @Description(shortDefinition="Intended performer of administration", formalDefinition="The specified desired performer of the medication treatment (e.g. the performer of the medication administration)." )
1623    protected Reference performer;
1624
1625    /**
1626     * The actual object that is the target of the reference (The specified desired performer of the medication treatment (e.g. the performer of the medication administration).)
1627     */
1628    protected Resource performerTarget;
1629
1630    /**
1631     * Indicates the type of performer of the administration of the medication.
1632     */
1633    @Child(name = "performerType", type = {CodeableConcept.class}, order=15, min=0, max=1, modifier=false, summary=true)
1634    @Description(shortDefinition="Desired kind of performer of the medication administration", formalDefinition="Indicates the type of performer of the administration of the medication." )
1635    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/performer-role")
1636    protected CodeableConcept performerType;
1637
1638    /**
1639     * The person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.
1640     */
1641    @Child(name = "recorder", type = {Practitioner.class, PractitionerRole.class}, order=16, min=0, max=1, modifier=false, summary=false)
1642    @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." )
1643    protected Reference recorder;
1644
1645    /**
1646     * The actual object that is the target of the reference (The person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.)
1647     */
1648    protected Resource recorderTarget;
1649
1650    /**
1651     * The reason or the indication for ordering or not ordering the medication.
1652     */
1653    @Child(name = "reasonCode", type = {CodeableConcept.class}, order=17, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1654    @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." )
1655    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/condition-code")
1656    protected List<CodeableConcept> reasonCode;
1657
1658    /**
1659     * Condition or observation that supports why the medication was ordered.
1660     */
1661    @Child(name = "reasonReference", type = {Condition.class, Observation.class}, order=18, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1662    @Description(shortDefinition="Condition or observation that supports why the prescription is being written", formalDefinition="Condition or observation that supports why the medication was ordered." )
1663    protected List<Reference> reasonReference;
1664    /**
1665     * The actual objects that are the target of the reference (Condition or observation that supports why the medication was ordered.)
1666     */
1667    protected List<Resource> reasonReferenceTarget;
1668
1669
1670    /**
1671     * The URL pointing to a protocol, guideline, orderset, or other definition that is adhered to in whole or in part by this MedicationRequest.
1672     */
1673    @Child(name = "instantiatesCanonical", type = {CanonicalType.class}, order=19, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1674    @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." )
1675    protected List<CanonicalType> instantiatesCanonical;
1676
1677    /**
1678     * 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.
1679     */
1680    @Child(name = "instantiatesUri", type = {UriType.class}, order=20, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1681    @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." )
1682    protected List<UriType> instantiatesUri;
1683
1684    /**
1685     * A plan or request that is fulfilled in whole or in part by this medication request.
1686     */
1687    @Child(name = "basedOn", type = {CarePlan.class, MedicationRequest.class, ServiceRequest.class, ImmunizationRecommendation.class}, order=21, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1688    @Description(shortDefinition="What request fulfills", formalDefinition="A plan or request that is fulfilled in whole or in part by this medication request." )
1689    protected List<Reference> basedOn;
1690    /**
1691     * The actual objects that are the target of the reference (A plan or request that is fulfilled in whole or in part by this medication request.)
1692     */
1693    protected List<Resource> basedOnTarget;
1694
1695
1696    /**
1697     * 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.
1698     */
1699    @Child(name = "groupIdentifier", type = {Identifier.class}, order=22, min=0, max=1, modifier=false, summary=true)
1700    @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." )
1701    protected Identifier groupIdentifier;
1702
1703    /**
1704     * The description of the overall patte3rn of the administration of the medication to the patient.
1705     */
1706    @Child(name = "courseOfTherapyType", type = {CodeableConcept.class}, order=23, min=0, max=1, modifier=false, summary=false)
1707    @Description(shortDefinition="Overall pattern of medication administration", formalDefinition="The description of the overall patte3rn of the administration of the medication to the patient." )
1708    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medicationrequest-course-of-therapy")
1709    protected CodeableConcept courseOfTherapyType;
1710
1711    /**
1712     * Insurance plans, coverage extensions, pre-authorizations and/or pre-determinations that may be required for delivering the requested service.
1713     */
1714    @Child(name = "insurance", type = {Coverage.class, ClaimResponse.class}, order=24, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1715    @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." )
1716    protected List<Reference> insurance;
1717    /**
1718     * The actual objects that are the target of the reference (Insurance plans, coverage extensions, pre-authorizations and/or pre-determinations that may be required for delivering the requested service.)
1719     */
1720    protected List<Resource> insuranceTarget;
1721
1722
1723    /**
1724     * Extra information about the prescription that could not be conveyed by the other attributes.
1725     */
1726    @Child(name = "note", type = {Annotation.class}, order=25, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1727    @Description(shortDefinition="Information about the prescription", formalDefinition="Extra information about the prescription that could not be conveyed by the other attributes." )
1728    protected List<Annotation> note;
1729
1730    /**
1731     * Indicates how the medication is to be used by the patient.
1732     */
1733    @Child(name = "dosageInstruction", type = {Dosage.class}, order=26, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1734    @Description(shortDefinition="How the medication should be taken", formalDefinition="Indicates how the medication is to be used by the patient." )
1735    protected List<Dosage> dosageInstruction;
1736
1737    /**
1738     * 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.
1739     */
1740    @Child(name = "dispenseRequest", type = {}, order=27, min=0, max=1, modifier=false, summary=false)
1741    @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." )
1742    protected MedicationRequestDispenseRequestComponent dispenseRequest;
1743
1744    /**
1745     * 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.
1746     */
1747    @Child(name = "substitution", type = {}, order=28, min=0, max=1, modifier=false, summary=false)
1748    @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." )
1749    protected MedicationRequestSubstitutionComponent substitution;
1750
1751    /**
1752     * A link to a resource representing an earlier order related order or prescription.
1753     */
1754    @Child(name = "priorPrescription", type = {MedicationRequest.class}, order=29, min=0, max=1, modifier=false, summary=false)
1755    @Description(shortDefinition="An order/prescription that is being replaced", formalDefinition="A link to a resource representing an earlier order related order or prescription." )
1756    protected Reference priorPrescription;
1757
1758    /**
1759     * The actual object that is the target of the reference (A link to a resource representing an earlier order related order or prescription.)
1760     */
1761    protected MedicationRequest priorPrescriptionTarget;
1762
1763    /**
1764     * 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.
1765     */
1766    @Child(name = "detectedIssue", type = {DetectedIssue.class}, order=30, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1767    @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." )
1768    protected List<Reference> detectedIssue;
1769    /**
1770     * The actual objects that are the target of the reference (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.)
1771     */
1772    protected List<DetectedIssue> detectedIssueTarget;
1773
1774
1775    /**
1776     * 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.
1777     */
1778    @Child(name = "eventHistory", type = {Provenance.class}, order=31, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1779    @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." )
1780    protected List<Reference> eventHistory;
1781    /**
1782     * The actual objects that are the target of the reference (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.)
1783     */
1784    protected List<Provenance> eventHistoryTarget;
1785
1786
1787    private static final long serialVersionUID = 1313900480L;
1788
1789  /**
1790   * Constructor
1791   */
1792    public MedicationRequest() {
1793      super();
1794    }
1795
1796  /**
1797   * Constructor
1798   */
1799    public MedicationRequest(Enumeration<MedicationRequestStatus> status, Enumeration<MedicationRequestIntent> intent, Type medication, Reference subject) {
1800      super();
1801      this.status = status;
1802      this.intent = intent;
1803      this.medication = medication;
1804      this.subject = subject;
1805    }
1806
1807    /**
1808     * @return {@link #identifier} (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.)
1809     */
1810    public List<Identifier> getIdentifier() { 
1811      if (this.identifier == null)
1812        this.identifier = new ArrayList<Identifier>();
1813      return this.identifier;
1814    }
1815
1816    /**
1817     * @return Returns a reference to <code>this</code> for easy method chaining
1818     */
1819    public MedicationRequest setIdentifier(List<Identifier> theIdentifier) { 
1820      this.identifier = theIdentifier;
1821      return this;
1822    }
1823
1824    public boolean hasIdentifier() { 
1825      if (this.identifier == null)
1826        return false;
1827      for (Identifier item : this.identifier)
1828        if (!item.isEmpty())
1829          return true;
1830      return false;
1831    }
1832
1833    public Identifier addIdentifier() { //3
1834      Identifier t = new Identifier();
1835      if (this.identifier == null)
1836        this.identifier = new ArrayList<Identifier>();
1837      this.identifier.add(t);
1838      return t;
1839    }
1840
1841    public MedicationRequest addIdentifier(Identifier t) { //3
1842      if (t == null)
1843        return this;
1844      if (this.identifier == null)
1845        this.identifier = new ArrayList<Identifier>();
1846      this.identifier.add(t);
1847      return this;
1848    }
1849
1850    /**
1851     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
1852     */
1853    public Identifier getIdentifierFirstRep() { 
1854      if (getIdentifier().isEmpty()) {
1855        addIdentifier();
1856      }
1857      return getIdentifier().get(0);
1858    }
1859
1860    /**
1861     * @return {@link #status} (A code specifying the current state of the order.  Generally, this will be active or completed state.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1862     */
1863    public Enumeration<MedicationRequestStatus> getStatusElement() { 
1864      if (this.status == null)
1865        if (Configuration.errorOnAutoCreate())
1866          throw new Error("Attempt to auto-create MedicationRequest.status");
1867        else if (Configuration.doAutoCreate())
1868          this.status = new Enumeration<MedicationRequestStatus>(new MedicationRequestStatusEnumFactory()); // bb
1869      return this.status;
1870    }
1871
1872    public boolean hasStatusElement() { 
1873      return this.status != null && !this.status.isEmpty();
1874    }
1875
1876    public boolean hasStatus() { 
1877      return this.status != null && !this.status.isEmpty();
1878    }
1879
1880    /**
1881     * @param value {@link #status} (A code specifying the current state of the order.  Generally, this will be active or completed state.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1882     */
1883    public MedicationRequest setStatusElement(Enumeration<MedicationRequestStatus> value) { 
1884      this.status = value;
1885      return this;
1886    }
1887
1888    /**
1889     * @return A code specifying the current state of the order.  Generally, this will be active or completed state.
1890     */
1891    public MedicationRequestStatus getStatus() { 
1892      return this.status == null ? null : this.status.getValue();
1893    }
1894
1895    /**
1896     * @param value A code specifying the current state of the order.  Generally, this will be active or completed state.
1897     */
1898    public MedicationRequest setStatus(MedicationRequestStatus value) { 
1899        if (this.status == null)
1900          this.status = new Enumeration<MedicationRequestStatus>(new MedicationRequestStatusEnumFactory());
1901        this.status.setValue(value);
1902      return this;
1903    }
1904
1905    /**
1906     * @return {@link #statusReason} (Captures the reason for the current state of the MedicationRequest.)
1907     */
1908    public CodeableConcept getStatusReason() { 
1909      if (this.statusReason == null)
1910        if (Configuration.errorOnAutoCreate())
1911          throw new Error("Attempt to auto-create MedicationRequest.statusReason");
1912        else if (Configuration.doAutoCreate())
1913          this.statusReason = new CodeableConcept(); // cc
1914      return this.statusReason;
1915    }
1916
1917    public boolean hasStatusReason() { 
1918      return this.statusReason != null && !this.statusReason.isEmpty();
1919    }
1920
1921    /**
1922     * @param value {@link #statusReason} (Captures the reason for the current state of the MedicationRequest.)
1923     */
1924    public MedicationRequest setStatusReason(CodeableConcept value) { 
1925      this.statusReason = value;
1926      return this;
1927    }
1928
1929    /**
1930     * @return {@link #intent} (Whether the request is a proposal, plan, or an original order.). This is the underlying object with id, value and extensions. The accessor "getIntent" gives direct access to the value
1931     */
1932    public Enumeration<MedicationRequestIntent> getIntentElement() { 
1933      if (this.intent == null)
1934        if (Configuration.errorOnAutoCreate())
1935          throw new Error("Attempt to auto-create MedicationRequest.intent");
1936        else if (Configuration.doAutoCreate())
1937          this.intent = new Enumeration<MedicationRequestIntent>(new MedicationRequestIntentEnumFactory()); // bb
1938      return this.intent;
1939    }
1940
1941    public boolean hasIntentElement() { 
1942      return this.intent != null && !this.intent.isEmpty();
1943    }
1944
1945    public boolean hasIntent() { 
1946      return this.intent != null && !this.intent.isEmpty();
1947    }
1948
1949    /**
1950     * @param value {@link #intent} (Whether the request is a proposal, plan, or an original order.). This is the underlying object with id, value and extensions. The accessor "getIntent" gives direct access to the value
1951     */
1952    public MedicationRequest setIntentElement(Enumeration<MedicationRequestIntent> value) { 
1953      this.intent = value;
1954      return this;
1955    }
1956
1957    /**
1958     * @return Whether the request is a proposal, plan, or an original order.
1959     */
1960    public MedicationRequestIntent getIntent() { 
1961      return this.intent == null ? null : this.intent.getValue();
1962    }
1963
1964    /**
1965     * @param value Whether the request is a proposal, plan, or an original order.
1966     */
1967    public MedicationRequest setIntent(MedicationRequestIntent value) { 
1968        if (this.intent == null)
1969          this.intent = new Enumeration<MedicationRequestIntent>(new MedicationRequestIntentEnumFactory());
1970        this.intent.setValue(value);
1971      return this;
1972    }
1973
1974    /**
1975     * @return {@link #category} (Indicates the type of medication request (for example, where the medication is expected to be consumed or administered (i.e. inpatient or outpatient)).)
1976     */
1977    public List<CodeableConcept> getCategory() { 
1978      if (this.category == null)
1979        this.category = new ArrayList<CodeableConcept>();
1980      return this.category;
1981    }
1982
1983    /**
1984     * @return Returns a reference to <code>this</code> for easy method chaining
1985     */
1986    public MedicationRequest setCategory(List<CodeableConcept> theCategory) { 
1987      this.category = theCategory;
1988      return this;
1989    }
1990
1991    public boolean hasCategory() { 
1992      if (this.category == null)
1993        return false;
1994      for (CodeableConcept item : this.category)
1995        if (!item.isEmpty())
1996          return true;
1997      return false;
1998    }
1999
2000    public CodeableConcept addCategory() { //3
2001      CodeableConcept t = new CodeableConcept();
2002      if (this.category == null)
2003        this.category = new ArrayList<CodeableConcept>();
2004      this.category.add(t);
2005      return t;
2006    }
2007
2008    public MedicationRequest addCategory(CodeableConcept t) { //3
2009      if (t == null)
2010        return this;
2011      if (this.category == null)
2012        this.category = new ArrayList<CodeableConcept>();
2013      this.category.add(t);
2014      return this;
2015    }
2016
2017    /**
2018     * @return The first repetition of repeating field {@link #category}, creating it if it does not already exist
2019     */
2020    public CodeableConcept getCategoryFirstRep() { 
2021      if (getCategory().isEmpty()) {
2022        addCategory();
2023      }
2024      return getCategory().get(0);
2025    }
2026
2027    /**
2028     * @return {@link #priority} (Indicates how quickly the Medication Request should be addressed with respect to other requests.). This is the underlying object with id, value and extensions. The accessor "getPriority" gives direct access to the value
2029     */
2030    public Enumeration<MedicationRequestPriority> getPriorityElement() { 
2031      if (this.priority == null)
2032        if (Configuration.errorOnAutoCreate())
2033          throw new Error("Attempt to auto-create MedicationRequest.priority");
2034        else if (Configuration.doAutoCreate())
2035          this.priority = new Enumeration<MedicationRequestPriority>(new MedicationRequestPriorityEnumFactory()); // bb
2036      return this.priority;
2037    }
2038
2039    public boolean hasPriorityElement() { 
2040      return this.priority != null && !this.priority.isEmpty();
2041    }
2042
2043    public boolean hasPriority() { 
2044      return this.priority != null && !this.priority.isEmpty();
2045    }
2046
2047    /**
2048     * @param value {@link #priority} (Indicates how quickly the Medication Request should be addressed with respect to other requests.). This is the underlying object with id, value and extensions. The accessor "getPriority" gives direct access to the value
2049     */
2050    public MedicationRequest setPriorityElement(Enumeration<MedicationRequestPriority> value) { 
2051      this.priority = value;
2052      return this;
2053    }
2054
2055    /**
2056     * @return Indicates how quickly the Medication Request should be addressed with respect to other requests.
2057     */
2058    public MedicationRequestPriority getPriority() { 
2059      return this.priority == null ? null : this.priority.getValue();
2060    }
2061
2062    /**
2063     * @param value Indicates how quickly the Medication Request should be addressed with respect to other requests.
2064     */
2065    public MedicationRequest setPriority(MedicationRequestPriority value) { 
2066      if (value == null)
2067        this.priority = null;
2068      else {
2069        if (this.priority == null)
2070          this.priority = new Enumeration<MedicationRequestPriority>(new MedicationRequestPriorityEnumFactory());
2071        this.priority.setValue(value);
2072      }
2073      return this;
2074    }
2075
2076    /**
2077     * @return {@link #doNotPerform} (If true indicates that the provider is asking for the medication request not to occur.). This is the underlying object with id, value and extensions. The accessor "getDoNotPerform" gives direct access to the value
2078     */
2079    public BooleanType getDoNotPerformElement() { 
2080      if (this.doNotPerform == null)
2081        if (Configuration.errorOnAutoCreate())
2082          throw new Error("Attempt to auto-create MedicationRequest.doNotPerform");
2083        else if (Configuration.doAutoCreate())
2084          this.doNotPerform = new BooleanType(); // bb
2085      return this.doNotPerform;
2086    }
2087
2088    public boolean hasDoNotPerformElement() { 
2089      return this.doNotPerform != null && !this.doNotPerform.isEmpty();
2090    }
2091
2092    public boolean hasDoNotPerform() { 
2093      return this.doNotPerform != null && !this.doNotPerform.isEmpty();
2094    }
2095
2096    /**
2097     * @param value {@link #doNotPerform} (If true indicates that the provider is asking for the medication request not to occur.). This is the underlying object with id, value and extensions. The accessor "getDoNotPerform" gives direct access to the value
2098     */
2099    public MedicationRequest setDoNotPerformElement(BooleanType value) { 
2100      this.doNotPerform = value;
2101      return this;
2102    }
2103
2104    /**
2105     * @return If true indicates that the provider is asking for the medication request not to occur.
2106     */
2107    public boolean getDoNotPerform() { 
2108      return this.doNotPerform == null || this.doNotPerform.isEmpty() ? false : this.doNotPerform.getValue();
2109    }
2110
2111    /**
2112     * @param value If true indicates that the provider is asking for the medication request not to occur.
2113     */
2114    public MedicationRequest setDoNotPerform(boolean value) { 
2115        if (this.doNotPerform == null)
2116          this.doNotPerform = new BooleanType();
2117        this.doNotPerform.setValue(value);
2118      return this;
2119    }
2120
2121    /**
2122     * @return {@link #reported} (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.)
2123     */
2124    public Type getReported() { 
2125      return this.reported;
2126    }
2127
2128    /**
2129     * @return {@link #reported} (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.)
2130     */
2131    public BooleanType getReportedBooleanType() throws FHIRException { 
2132      if (this.reported == null)
2133        this.reported = new BooleanType();
2134      if (!(this.reported instanceof BooleanType))
2135        throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.reported.getClass().getName()+" was encountered");
2136      return (BooleanType) this.reported;
2137    }
2138
2139    public boolean hasReportedBooleanType() { 
2140      return this != null && this.reported instanceof BooleanType;
2141    }
2142
2143    /**
2144     * @return {@link #reported} (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.)
2145     */
2146    public Reference getReportedReference() throws FHIRException { 
2147      if (this.reported == null)
2148        this.reported = new Reference();
2149      if (!(this.reported instanceof Reference))
2150        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.reported.getClass().getName()+" was encountered");
2151      return (Reference) this.reported;
2152    }
2153
2154    public boolean hasReportedReference() { 
2155      return this != null && this.reported instanceof Reference;
2156    }
2157
2158    public boolean hasReported() { 
2159      return this.reported != null && !this.reported.isEmpty();
2160    }
2161
2162    /**
2163     * @param value {@link #reported} (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.)
2164     */
2165    public MedicationRequest setReported(Type value) { 
2166      if (value != null && !(value instanceof BooleanType || value instanceof Reference))
2167        throw new Error("Not the right type for MedicationRequest.reported[x]: "+value.fhirType());
2168      this.reported = value;
2169      return this;
2170    }
2171
2172    /**
2173     * @return {@link #medication} (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.)
2174     */
2175    public Type getMedication() { 
2176      return this.medication;
2177    }
2178
2179    /**
2180     * @return {@link #medication} (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.)
2181     */
2182    public CodeableConcept getMedicationCodeableConcept() throws FHIRException { 
2183      if (this.medication == null)
2184        this.medication = new CodeableConcept();
2185      if (!(this.medication instanceof CodeableConcept))
2186        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.medication.getClass().getName()+" was encountered");
2187      return (CodeableConcept) this.medication;
2188    }
2189
2190    public boolean hasMedicationCodeableConcept() { 
2191      return this != null && this.medication instanceof CodeableConcept;
2192    }
2193
2194    /**
2195     * @return {@link #medication} (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.)
2196     */
2197    public Reference getMedicationReference() throws FHIRException { 
2198      if (this.medication == null)
2199        this.medication = new Reference();
2200      if (!(this.medication instanceof Reference))
2201        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.medication.getClass().getName()+" was encountered");
2202      return (Reference) this.medication;
2203    }
2204
2205    public boolean hasMedicationReference() { 
2206      return this != null && this.medication instanceof Reference;
2207    }
2208
2209    public boolean hasMedication() { 
2210      return this.medication != null && !this.medication.isEmpty();
2211    }
2212
2213    /**
2214     * @param value {@link #medication} (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.)
2215     */
2216    public MedicationRequest setMedication(Type value) { 
2217      if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
2218        throw new Error("Not the right type for MedicationRequest.medication[x]: "+value.fhirType());
2219      this.medication = value;
2220      return this;
2221    }
2222
2223    /**
2224     * @return {@link #subject} (A link to a resource representing the person or set of individuals to whom the medication will be given.)
2225     */
2226    public Reference getSubject() { 
2227      if (this.subject == null)
2228        if (Configuration.errorOnAutoCreate())
2229          throw new Error("Attempt to auto-create MedicationRequest.subject");
2230        else if (Configuration.doAutoCreate())
2231          this.subject = new Reference(); // cc
2232      return this.subject;
2233    }
2234
2235    public boolean hasSubject() { 
2236      return this.subject != null && !this.subject.isEmpty();
2237    }
2238
2239    /**
2240     * @param value {@link #subject} (A link to a resource representing the person or set of individuals to whom the medication will be given.)
2241     */
2242    public MedicationRequest setSubject(Reference value) { 
2243      this.subject = value;
2244      return this;
2245    }
2246
2247    /**
2248     * @return {@link #subject} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (A link to a resource representing the person or set of individuals to whom the medication will be given.)
2249     */
2250    public Resource getSubjectTarget() { 
2251      return this.subjectTarget;
2252    }
2253
2254    /**
2255     * @param value {@link #subject} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (A link to a resource representing the person or set of individuals to whom the medication will be given.)
2256     */
2257    public MedicationRequest setSubjectTarget(Resource value) { 
2258      this.subjectTarget = value;
2259      return this;
2260    }
2261
2262    /**
2263     * @return {@link #encounter} (The Encounter during which this [x] was created or to which the creation of this record is tightly associated.)
2264     */
2265    public Reference getEncounter() { 
2266      if (this.encounter == null)
2267        if (Configuration.errorOnAutoCreate())
2268          throw new Error("Attempt to auto-create MedicationRequest.encounter");
2269        else if (Configuration.doAutoCreate())
2270          this.encounter = new Reference(); // cc
2271      return this.encounter;
2272    }
2273
2274    public boolean hasEncounter() { 
2275      return this.encounter != null && !this.encounter.isEmpty();
2276    }
2277
2278    /**
2279     * @param value {@link #encounter} (The Encounter during which this [x] was created or to which the creation of this record is tightly associated.)
2280     */
2281    public MedicationRequest setEncounter(Reference value) { 
2282      this.encounter = value;
2283      return this;
2284    }
2285
2286    /**
2287     * @return {@link #encounter} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The Encounter during which this [x] was created or to which the creation of this record is tightly associated.)
2288     */
2289    public Encounter getEncounterTarget() { 
2290      if (this.encounterTarget == null)
2291        if (Configuration.errorOnAutoCreate())
2292          throw new Error("Attempt to auto-create MedicationRequest.encounter");
2293        else if (Configuration.doAutoCreate())
2294          this.encounterTarget = new Encounter(); // aa
2295      return this.encounterTarget;
2296    }
2297
2298    /**
2299     * @param value {@link #encounter} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The Encounter during which this [x] was created or to which the creation of this record is tightly associated.)
2300     */
2301    public MedicationRequest setEncounterTarget(Encounter value) { 
2302      this.encounterTarget = value;
2303      return this;
2304    }
2305
2306    /**
2307     * @return {@link #supportingInformation} (Include additional information (for example, patient height and weight) that supports the ordering of the medication.)
2308     */
2309    public List<Reference> getSupportingInformation() { 
2310      if (this.supportingInformation == null)
2311        this.supportingInformation = new ArrayList<Reference>();
2312      return this.supportingInformation;
2313    }
2314
2315    /**
2316     * @return Returns a reference to <code>this</code> for easy method chaining
2317     */
2318    public MedicationRequest setSupportingInformation(List<Reference> theSupportingInformation) { 
2319      this.supportingInformation = theSupportingInformation;
2320      return this;
2321    }
2322
2323    public boolean hasSupportingInformation() { 
2324      if (this.supportingInformation == null)
2325        return false;
2326      for (Reference item : this.supportingInformation)
2327        if (!item.isEmpty())
2328          return true;
2329      return false;
2330    }
2331
2332    public Reference addSupportingInformation() { //3
2333      Reference t = new Reference();
2334      if (this.supportingInformation == null)
2335        this.supportingInformation = new ArrayList<Reference>();
2336      this.supportingInformation.add(t);
2337      return t;
2338    }
2339
2340    public MedicationRequest addSupportingInformation(Reference t) { //3
2341      if (t == null)
2342        return this;
2343      if (this.supportingInformation == null)
2344        this.supportingInformation = new ArrayList<Reference>();
2345      this.supportingInformation.add(t);
2346      return this;
2347    }
2348
2349    /**
2350     * @return The first repetition of repeating field {@link #supportingInformation}, creating it if it does not already exist
2351     */
2352    public Reference getSupportingInformationFirstRep() { 
2353      if (getSupportingInformation().isEmpty()) {
2354        addSupportingInformation();
2355      }
2356      return getSupportingInformation().get(0);
2357    }
2358
2359    /**
2360     * @deprecated Use Reference#setResource(IBaseResource) instead
2361     */
2362    @Deprecated
2363    public List<Resource> getSupportingInformationTarget() { 
2364      if (this.supportingInformationTarget == null)
2365        this.supportingInformationTarget = new ArrayList<Resource>();
2366      return this.supportingInformationTarget;
2367    }
2368
2369    /**
2370     * @return {@link #authoredOn} (The date (and perhaps time) when the prescription was initially written or authored on.). This is the underlying object with id, value and extensions. The accessor "getAuthoredOn" gives direct access to the value
2371     */
2372    public DateTimeType getAuthoredOnElement() { 
2373      if (this.authoredOn == null)
2374        if (Configuration.errorOnAutoCreate())
2375          throw new Error("Attempt to auto-create MedicationRequest.authoredOn");
2376        else if (Configuration.doAutoCreate())
2377          this.authoredOn = new DateTimeType(); // bb
2378      return this.authoredOn;
2379    }
2380
2381    public boolean hasAuthoredOnElement() { 
2382      return this.authoredOn != null && !this.authoredOn.isEmpty();
2383    }
2384
2385    public boolean hasAuthoredOn() { 
2386      return this.authoredOn != null && !this.authoredOn.isEmpty();
2387    }
2388
2389    /**
2390     * @param value {@link #authoredOn} (The date (and perhaps time) when the prescription was initially written or authored on.). This is the underlying object with id, value and extensions. The accessor "getAuthoredOn" gives direct access to the value
2391     */
2392    public MedicationRequest setAuthoredOnElement(DateTimeType value) { 
2393      this.authoredOn = value;
2394      return this;
2395    }
2396
2397    /**
2398     * @return The date (and perhaps time) when the prescription was initially written or authored on.
2399     */
2400    public Date getAuthoredOn() { 
2401      return this.authoredOn == null ? null : this.authoredOn.getValue();
2402    }
2403
2404    /**
2405     * @param value The date (and perhaps time) when the prescription was initially written or authored on.
2406     */
2407    public MedicationRequest setAuthoredOn(Date value) { 
2408      if (value == null)
2409        this.authoredOn = null;
2410      else {
2411        if (this.authoredOn == null)
2412          this.authoredOn = new DateTimeType();
2413        this.authoredOn.setValue(value);
2414      }
2415      return this;
2416    }
2417
2418    /**
2419     * @return {@link #requester} (The individual, organization, or device that initiated the request and has responsibility for its activation.)
2420     */
2421    public Reference getRequester() { 
2422      if (this.requester == null)
2423        if (Configuration.errorOnAutoCreate())
2424          throw new Error("Attempt to auto-create MedicationRequest.requester");
2425        else if (Configuration.doAutoCreate())
2426          this.requester = new Reference(); // cc
2427      return this.requester;
2428    }
2429
2430    public boolean hasRequester() { 
2431      return this.requester != null && !this.requester.isEmpty();
2432    }
2433
2434    /**
2435     * @param value {@link #requester} (The individual, organization, or device that initiated the request and has responsibility for its activation.)
2436     */
2437    public MedicationRequest setRequester(Reference value) { 
2438      this.requester = value;
2439      return this;
2440    }
2441
2442    /**
2443     * @return {@link #requester} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The individual, organization, or device that initiated the request and has responsibility for its activation.)
2444     */
2445    public Resource getRequesterTarget() { 
2446      return this.requesterTarget;
2447    }
2448
2449    /**
2450     * @param value {@link #requester} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The individual, organization, or device that initiated the request and has responsibility for its activation.)
2451     */
2452    public MedicationRequest setRequesterTarget(Resource value) { 
2453      this.requesterTarget = value;
2454      return this;
2455    }
2456
2457    /**
2458     * @return {@link #performer} (The specified desired performer of the medication treatment (e.g. the performer of the medication administration).)
2459     */
2460    public Reference getPerformer() { 
2461      if (this.performer == null)
2462        if (Configuration.errorOnAutoCreate())
2463          throw new Error("Attempt to auto-create MedicationRequest.performer");
2464        else if (Configuration.doAutoCreate())
2465          this.performer = new Reference(); // cc
2466      return this.performer;
2467    }
2468
2469    public boolean hasPerformer() { 
2470      return this.performer != null && !this.performer.isEmpty();
2471    }
2472
2473    /**
2474     * @param value {@link #performer} (The specified desired performer of the medication treatment (e.g. the performer of the medication administration).)
2475     */
2476    public MedicationRequest setPerformer(Reference value) { 
2477      this.performer = value;
2478      return this;
2479    }
2480
2481    /**
2482     * @return {@link #performer} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The specified desired performer of the medication treatment (e.g. the performer of the medication administration).)
2483     */
2484    public Resource getPerformerTarget() { 
2485      return this.performerTarget;
2486    }
2487
2488    /**
2489     * @param value {@link #performer} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The specified desired performer of the medication treatment (e.g. the performer of the medication administration).)
2490     */
2491    public MedicationRequest setPerformerTarget(Resource value) { 
2492      this.performerTarget = value;
2493      return this;
2494    }
2495
2496    /**
2497     * @return {@link #performerType} (Indicates the type of performer of the administration of the medication.)
2498     */
2499    public CodeableConcept getPerformerType() { 
2500      if (this.performerType == null)
2501        if (Configuration.errorOnAutoCreate())
2502          throw new Error("Attempt to auto-create MedicationRequest.performerType");
2503        else if (Configuration.doAutoCreate())
2504          this.performerType = new CodeableConcept(); // cc
2505      return this.performerType;
2506    }
2507
2508    public boolean hasPerformerType() { 
2509      return this.performerType != null && !this.performerType.isEmpty();
2510    }
2511
2512    /**
2513     * @param value {@link #performerType} (Indicates the type of performer of the administration of the medication.)
2514     */
2515    public MedicationRequest setPerformerType(CodeableConcept value) { 
2516      this.performerType = value;
2517      return this;
2518    }
2519
2520    /**
2521     * @return {@link #recorder} (The person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.)
2522     */
2523    public Reference getRecorder() { 
2524      if (this.recorder == null)
2525        if (Configuration.errorOnAutoCreate())
2526          throw new Error("Attempt to auto-create MedicationRequest.recorder");
2527        else if (Configuration.doAutoCreate())
2528          this.recorder = new Reference(); // cc
2529      return this.recorder;
2530    }
2531
2532    public boolean hasRecorder() { 
2533      return this.recorder != null && !this.recorder.isEmpty();
2534    }
2535
2536    /**
2537     * @param value {@link #recorder} (The person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.)
2538     */
2539    public MedicationRequest setRecorder(Reference value) { 
2540      this.recorder = value;
2541      return this;
2542    }
2543
2544    /**
2545     * @return {@link #recorder} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.)
2546     */
2547    public Resource getRecorderTarget() { 
2548      return this.recorderTarget;
2549    }
2550
2551    /**
2552     * @param value {@link #recorder} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.)
2553     */
2554    public MedicationRequest setRecorderTarget(Resource value) { 
2555      this.recorderTarget = value;
2556      return this;
2557    }
2558
2559    /**
2560     * @return {@link #reasonCode} (The reason or the indication for ordering or not ordering the medication.)
2561     */
2562    public List<CodeableConcept> getReasonCode() { 
2563      if (this.reasonCode == null)
2564        this.reasonCode = new ArrayList<CodeableConcept>();
2565      return this.reasonCode;
2566    }
2567
2568    /**
2569     * @return Returns a reference to <code>this</code> for easy method chaining
2570     */
2571    public MedicationRequest setReasonCode(List<CodeableConcept> theReasonCode) { 
2572      this.reasonCode = theReasonCode;
2573      return this;
2574    }
2575
2576    public boolean hasReasonCode() { 
2577      if (this.reasonCode == null)
2578        return false;
2579      for (CodeableConcept item : this.reasonCode)
2580        if (!item.isEmpty())
2581          return true;
2582      return false;
2583    }
2584
2585    public CodeableConcept addReasonCode() { //3
2586      CodeableConcept t = new CodeableConcept();
2587      if (this.reasonCode == null)
2588        this.reasonCode = new ArrayList<CodeableConcept>();
2589      this.reasonCode.add(t);
2590      return t;
2591    }
2592
2593    public MedicationRequest addReasonCode(CodeableConcept t) { //3
2594      if (t == null)
2595        return this;
2596      if (this.reasonCode == null)
2597        this.reasonCode = new ArrayList<CodeableConcept>();
2598      this.reasonCode.add(t);
2599      return this;
2600    }
2601
2602    /**
2603     * @return The first repetition of repeating field {@link #reasonCode}, creating it if it does not already exist
2604     */
2605    public CodeableConcept getReasonCodeFirstRep() { 
2606      if (getReasonCode().isEmpty()) {
2607        addReasonCode();
2608      }
2609      return getReasonCode().get(0);
2610    }
2611
2612    /**
2613     * @return {@link #reasonReference} (Condition or observation that supports why the medication was ordered.)
2614     */
2615    public List<Reference> getReasonReference() { 
2616      if (this.reasonReference == null)
2617        this.reasonReference = new ArrayList<Reference>();
2618      return this.reasonReference;
2619    }
2620
2621    /**
2622     * @return Returns a reference to <code>this</code> for easy method chaining
2623     */
2624    public MedicationRequest setReasonReference(List<Reference> theReasonReference) { 
2625      this.reasonReference = theReasonReference;
2626      return this;
2627    }
2628
2629    public boolean hasReasonReference() { 
2630      if (this.reasonReference == null)
2631        return false;
2632      for (Reference item : this.reasonReference)
2633        if (!item.isEmpty())
2634          return true;
2635      return false;
2636    }
2637
2638    public Reference addReasonReference() { //3
2639      Reference t = new Reference();
2640      if (this.reasonReference == null)
2641        this.reasonReference = new ArrayList<Reference>();
2642      this.reasonReference.add(t);
2643      return t;
2644    }
2645
2646    public MedicationRequest addReasonReference(Reference t) { //3
2647      if (t == null)
2648        return this;
2649      if (this.reasonReference == null)
2650        this.reasonReference = new ArrayList<Reference>();
2651      this.reasonReference.add(t);
2652      return this;
2653    }
2654
2655    /**
2656     * @return The first repetition of repeating field {@link #reasonReference}, creating it if it does not already exist
2657     */
2658    public Reference getReasonReferenceFirstRep() { 
2659      if (getReasonReference().isEmpty()) {
2660        addReasonReference();
2661      }
2662      return getReasonReference().get(0);
2663    }
2664
2665    /**
2666     * @deprecated Use Reference#setResource(IBaseResource) instead
2667     */
2668    @Deprecated
2669    public List<Resource> getReasonReferenceTarget() { 
2670      if (this.reasonReferenceTarget == null)
2671        this.reasonReferenceTarget = new ArrayList<Resource>();
2672      return this.reasonReferenceTarget;
2673    }
2674
2675    /**
2676     * @return {@link #instantiatesCanonical} (The URL pointing to a protocol, guideline, orderset, or other definition that is adhered to in whole or in part by this MedicationRequest.)
2677     */
2678    public List<CanonicalType> getInstantiatesCanonical() { 
2679      if (this.instantiatesCanonical == null)
2680        this.instantiatesCanonical = new ArrayList<CanonicalType>();
2681      return this.instantiatesCanonical;
2682    }
2683
2684    /**
2685     * @return Returns a reference to <code>this</code> for easy method chaining
2686     */
2687    public MedicationRequest setInstantiatesCanonical(List<CanonicalType> theInstantiatesCanonical) { 
2688      this.instantiatesCanonical = theInstantiatesCanonical;
2689      return this;
2690    }
2691
2692    public boolean hasInstantiatesCanonical() { 
2693      if (this.instantiatesCanonical == null)
2694        return false;
2695      for (CanonicalType item : this.instantiatesCanonical)
2696        if (!item.isEmpty())
2697          return true;
2698      return false;
2699    }
2700
2701    /**
2702     * @return {@link #instantiatesCanonical} (The URL pointing to a protocol, guideline, orderset, or other definition that is adhered to in whole or in part by this MedicationRequest.)
2703     */
2704    public CanonicalType addInstantiatesCanonicalElement() {//2 
2705      CanonicalType t = new CanonicalType();
2706      if (this.instantiatesCanonical == null)
2707        this.instantiatesCanonical = new ArrayList<CanonicalType>();
2708      this.instantiatesCanonical.add(t);
2709      return t;
2710    }
2711
2712    /**
2713     * @param value {@link #instantiatesCanonical} (The URL pointing to a protocol, guideline, orderset, or other definition that is adhered to in whole or in part by this MedicationRequest.)
2714     */
2715    public MedicationRequest addInstantiatesCanonical(String value) { //1
2716      CanonicalType t = new CanonicalType();
2717      t.setValue(value);
2718      if (this.instantiatesCanonical == null)
2719        this.instantiatesCanonical = new ArrayList<CanonicalType>();
2720      this.instantiatesCanonical.add(t);
2721      return this;
2722    }
2723
2724    /**
2725     * @param value {@link #instantiatesCanonical} (The URL pointing to a protocol, guideline, orderset, or other definition that is adhered to in whole or in part by this MedicationRequest.)
2726     */
2727    public boolean hasInstantiatesCanonical(String value) { 
2728      if (this.instantiatesCanonical == null)
2729        return false;
2730      for (CanonicalType v : this.instantiatesCanonical)
2731        if (v.getValue().equals(value)) // canonical
2732          return true;
2733      return false;
2734    }
2735
2736    /**
2737     * @return {@link #instantiatesUri} (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.)
2738     */
2739    public List<UriType> getInstantiatesUri() { 
2740      if (this.instantiatesUri == null)
2741        this.instantiatesUri = new ArrayList<UriType>();
2742      return this.instantiatesUri;
2743    }
2744
2745    /**
2746     * @return Returns a reference to <code>this</code> for easy method chaining
2747     */
2748    public MedicationRequest setInstantiatesUri(List<UriType> theInstantiatesUri) { 
2749      this.instantiatesUri = theInstantiatesUri;
2750      return this;
2751    }
2752
2753    public boolean hasInstantiatesUri() { 
2754      if (this.instantiatesUri == null)
2755        return false;
2756      for (UriType item : this.instantiatesUri)
2757        if (!item.isEmpty())
2758          return true;
2759      return false;
2760    }
2761
2762    /**
2763     * @return {@link #instantiatesUri} (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.)
2764     */
2765    public UriType addInstantiatesUriElement() {//2 
2766      UriType t = new UriType();
2767      if (this.instantiatesUri == null)
2768        this.instantiatesUri = new ArrayList<UriType>();
2769      this.instantiatesUri.add(t);
2770      return t;
2771    }
2772
2773    /**
2774     * @param value {@link #instantiatesUri} (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.)
2775     */
2776    public MedicationRequest addInstantiatesUri(String value) { //1
2777      UriType t = new UriType();
2778      t.setValue(value);
2779      if (this.instantiatesUri == null)
2780        this.instantiatesUri = new ArrayList<UriType>();
2781      this.instantiatesUri.add(t);
2782      return this;
2783    }
2784
2785    /**
2786     * @param value {@link #instantiatesUri} (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.)
2787     */
2788    public boolean hasInstantiatesUri(String value) { 
2789      if (this.instantiatesUri == null)
2790        return false;
2791      for (UriType v : this.instantiatesUri)
2792        if (v.getValue().equals(value)) // uri
2793          return true;
2794      return false;
2795    }
2796
2797    /**
2798     * @return {@link #basedOn} (A plan or request that is fulfilled in whole or in part by this medication request.)
2799     */
2800    public List<Reference> getBasedOn() { 
2801      if (this.basedOn == null)
2802        this.basedOn = new ArrayList<Reference>();
2803      return this.basedOn;
2804    }
2805
2806    /**
2807     * @return Returns a reference to <code>this</code> for easy method chaining
2808     */
2809    public MedicationRequest setBasedOn(List<Reference> theBasedOn) { 
2810      this.basedOn = theBasedOn;
2811      return this;
2812    }
2813
2814    public boolean hasBasedOn() { 
2815      if (this.basedOn == null)
2816        return false;
2817      for (Reference item : this.basedOn)
2818        if (!item.isEmpty())
2819          return true;
2820      return false;
2821    }
2822
2823    public Reference addBasedOn() { //3
2824      Reference t = new Reference();
2825      if (this.basedOn == null)
2826        this.basedOn = new ArrayList<Reference>();
2827      this.basedOn.add(t);
2828      return t;
2829    }
2830
2831    public MedicationRequest addBasedOn(Reference t) { //3
2832      if (t == null)
2833        return this;
2834      if (this.basedOn == null)
2835        this.basedOn = new ArrayList<Reference>();
2836      this.basedOn.add(t);
2837      return this;
2838    }
2839
2840    /**
2841     * @return The first repetition of repeating field {@link #basedOn}, creating it if it does not already exist
2842     */
2843    public Reference getBasedOnFirstRep() { 
2844      if (getBasedOn().isEmpty()) {
2845        addBasedOn();
2846      }
2847      return getBasedOn().get(0);
2848    }
2849
2850    /**
2851     * @deprecated Use Reference#setResource(IBaseResource) instead
2852     */
2853    @Deprecated
2854    public List<Resource> getBasedOnTarget() { 
2855      if (this.basedOnTarget == null)
2856        this.basedOnTarget = new ArrayList<Resource>();
2857      return this.basedOnTarget;
2858    }
2859
2860    /**
2861     * @return {@link #groupIdentifier} (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.)
2862     */
2863    public Identifier getGroupIdentifier() { 
2864      if (this.groupIdentifier == null)
2865        if (Configuration.errorOnAutoCreate())
2866          throw new Error("Attempt to auto-create MedicationRequest.groupIdentifier");
2867        else if (Configuration.doAutoCreate())
2868          this.groupIdentifier = new Identifier(); // cc
2869      return this.groupIdentifier;
2870    }
2871
2872    public boolean hasGroupIdentifier() { 
2873      return this.groupIdentifier != null && !this.groupIdentifier.isEmpty();
2874    }
2875
2876    /**
2877     * @param value {@link #groupIdentifier} (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.)
2878     */
2879    public MedicationRequest setGroupIdentifier(Identifier value) { 
2880      this.groupIdentifier = value;
2881      return this;
2882    }
2883
2884    /**
2885     * @return {@link #courseOfTherapyType} (The description of the overall patte3rn of the administration of the medication to the patient.)
2886     */
2887    public CodeableConcept getCourseOfTherapyType() { 
2888      if (this.courseOfTherapyType == null)
2889        if (Configuration.errorOnAutoCreate())
2890          throw new Error("Attempt to auto-create MedicationRequest.courseOfTherapyType");
2891        else if (Configuration.doAutoCreate())
2892          this.courseOfTherapyType = new CodeableConcept(); // cc
2893      return this.courseOfTherapyType;
2894    }
2895
2896    public boolean hasCourseOfTherapyType() { 
2897      return this.courseOfTherapyType != null && !this.courseOfTherapyType.isEmpty();
2898    }
2899
2900    /**
2901     * @param value {@link #courseOfTherapyType} (The description of the overall patte3rn of the administration of the medication to the patient.)
2902     */
2903    public MedicationRequest setCourseOfTherapyType(CodeableConcept value) { 
2904      this.courseOfTherapyType = value;
2905      return this;
2906    }
2907
2908    /**
2909     * @return {@link #insurance} (Insurance plans, coverage extensions, pre-authorizations and/or pre-determinations that may be required for delivering the requested service.)
2910     */
2911    public List<Reference> getInsurance() { 
2912      if (this.insurance == null)
2913        this.insurance = new ArrayList<Reference>();
2914      return this.insurance;
2915    }
2916
2917    /**
2918     * @return Returns a reference to <code>this</code> for easy method chaining
2919     */
2920    public MedicationRequest setInsurance(List<Reference> theInsurance) { 
2921      this.insurance = theInsurance;
2922      return this;
2923    }
2924
2925    public boolean hasInsurance() { 
2926      if (this.insurance == null)
2927        return false;
2928      for (Reference item : this.insurance)
2929        if (!item.isEmpty())
2930          return true;
2931      return false;
2932    }
2933
2934    public Reference addInsurance() { //3
2935      Reference t = new Reference();
2936      if (this.insurance == null)
2937        this.insurance = new ArrayList<Reference>();
2938      this.insurance.add(t);
2939      return t;
2940    }
2941
2942    public MedicationRequest addInsurance(Reference t) { //3
2943      if (t == null)
2944        return this;
2945      if (this.insurance == null)
2946        this.insurance = new ArrayList<Reference>();
2947      this.insurance.add(t);
2948      return this;
2949    }
2950
2951    /**
2952     * @return The first repetition of repeating field {@link #insurance}, creating it if it does not already exist
2953     */
2954    public Reference getInsuranceFirstRep() { 
2955      if (getInsurance().isEmpty()) {
2956        addInsurance();
2957      }
2958      return getInsurance().get(0);
2959    }
2960
2961    /**
2962     * @deprecated Use Reference#setResource(IBaseResource) instead
2963     */
2964    @Deprecated
2965    public List<Resource> getInsuranceTarget() { 
2966      if (this.insuranceTarget == null)
2967        this.insuranceTarget = new ArrayList<Resource>();
2968      return this.insuranceTarget;
2969    }
2970
2971    /**
2972     * @return {@link #note} (Extra information about the prescription that could not be conveyed by the other attributes.)
2973     */
2974    public List<Annotation> getNote() { 
2975      if (this.note == null)
2976        this.note = new ArrayList<Annotation>();
2977      return this.note;
2978    }
2979
2980    /**
2981     * @return Returns a reference to <code>this</code> for easy method chaining
2982     */
2983    public MedicationRequest setNote(List<Annotation> theNote) { 
2984      this.note = theNote;
2985      return this;
2986    }
2987
2988    public boolean hasNote() { 
2989      if (this.note == null)
2990        return false;
2991      for (Annotation item : this.note)
2992        if (!item.isEmpty())
2993          return true;
2994      return false;
2995    }
2996
2997    public Annotation addNote() { //3
2998      Annotation t = new Annotation();
2999      if (this.note == null)
3000        this.note = new ArrayList<Annotation>();
3001      this.note.add(t);
3002      return t;
3003    }
3004
3005    public MedicationRequest addNote(Annotation t) { //3
3006      if (t == null)
3007        return this;
3008      if (this.note == null)
3009        this.note = new ArrayList<Annotation>();
3010      this.note.add(t);
3011      return this;
3012    }
3013
3014    /**
3015     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist
3016     */
3017    public Annotation getNoteFirstRep() { 
3018      if (getNote().isEmpty()) {
3019        addNote();
3020      }
3021      return getNote().get(0);
3022    }
3023
3024    /**
3025     * @return {@link #dosageInstruction} (Indicates how the medication is to be used by the patient.)
3026     */
3027    public List<Dosage> getDosageInstruction() { 
3028      if (this.dosageInstruction == null)
3029        this.dosageInstruction = new ArrayList<Dosage>();
3030      return this.dosageInstruction;
3031    }
3032
3033    /**
3034     * @return Returns a reference to <code>this</code> for easy method chaining
3035     */
3036    public MedicationRequest setDosageInstruction(List<Dosage> theDosageInstruction) { 
3037      this.dosageInstruction = theDosageInstruction;
3038      return this;
3039    }
3040
3041    public boolean hasDosageInstruction() { 
3042      if (this.dosageInstruction == null)
3043        return false;
3044      for (Dosage item : this.dosageInstruction)
3045        if (!item.isEmpty())
3046          return true;
3047      return false;
3048    }
3049
3050    public Dosage addDosageInstruction() { //3
3051      Dosage t = new Dosage();
3052      if (this.dosageInstruction == null)
3053        this.dosageInstruction = new ArrayList<Dosage>();
3054      this.dosageInstruction.add(t);
3055      return t;
3056    }
3057
3058    public MedicationRequest addDosageInstruction(Dosage t) { //3
3059      if (t == null)
3060        return this;
3061      if (this.dosageInstruction == null)
3062        this.dosageInstruction = new ArrayList<Dosage>();
3063      this.dosageInstruction.add(t);
3064      return this;
3065    }
3066
3067    /**
3068     * @return The first repetition of repeating field {@link #dosageInstruction}, creating it if it does not already exist
3069     */
3070    public Dosage getDosageInstructionFirstRep() { 
3071      if (getDosageInstruction().isEmpty()) {
3072        addDosageInstruction();
3073      }
3074      return getDosageInstruction().get(0);
3075    }
3076
3077    /**
3078     * @return {@link #dispenseRequest} (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.)
3079     */
3080    public MedicationRequestDispenseRequestComponent getDispenseRequest() { 
3081      if (this.dispenseRequest == null)
3082        if (Configuration.errorOnAutoCreate())
3083          throw new Error("Attempt to auto-create MedicationRequest.dispenseRequest");
3084        else if (Configuration.doAutoCreate())
3085          this.dispenseRequest = new MedicationRequestDispenseRequestComponent(); // cc
3086      return this.dispenseRequest;
3087    }
3088
3089    public boolean hasDispenseRequest() { 
3090      return this.dispenseRequest != null && !this.dispenseRequest.isEmpty();
3091    }
3092
3093    /**
3094     * @param value {@link #dispenseRequest} (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.)
3095     */
3096    public MedicationRequest setDispenseRequest(MedicationRequestDispenseRequestComponent value) { 
3097      this.dispenseRequest = value;
3098      return this;
3099    }
3100
3101    /**
3102     * @return {@link #substitution} (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.)
3103     */
3104    public MedicationRequestSubstitutionComponent getSubstitution() { 
3105      if (this.substitution == null)
3106        if (Configuration.errorOnAutoCreate())
3107          throw new Error("Attempt to auto-create MedicationRequest.substitution");
3108        else if (Configuration.doAutoCreate())
3109          this.substitution = new MedicationRequestSubstitutionComponent(); // cc
3110      return this.substitution;
3111    }
3112
3113    public boolean hasSubstitution() { 
3114      return this.substitution != null && !this.substitution.isEmpty();
3115    }
3116
3117    /**
3118     * @param value {@link #substitution} (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.)
3119     */
3120    public MedicationRequest setSubstitution(MedicationRequestSubstitutionComponent value) { 
3121      this.substitution = value;
3122      return this;
3123    }
3124
3125    /**
3126     * @return {@link #priorPrescription} (A link to a resource representing an earlier order related order or prescription.)
3127     */
3128    public Reference getPriorPrescription() { 
3129      if (this.priorPrescription == null)
3130        if (Configuration.errorOnAutoCreate())
3131          throw new Error("Attempt to auto-create MedicationRequest.priorPrescription");
3132        else if (Configuration.doAutoCreate())
3133          this.priorPrescription = new Reference(); // cc
3134      return this.priorPrescription;
3135    }
3136
3137    public boolean hasPriorPrescription() { 
3138      return this.priorPrescription != null && !this.priorPrescription.isEmpty();
3139    }
3140
3141    /**
3142     * @param value {@link #priorPrescription} (A link to a resource representing an earlier order related order or prescription.)
3143     */
3144    public MedicationRequest setPriorPrescription(Reference value) { 
3145      this.priorPrescription = value;
3146      return this;
3147    }
3148
3149    /**
3150     * @return {@link #priorPrescription} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (A link to a resource representing an earlier order related order or prescription.)
3151     */
3152    public MedicationRequest getPriorPrescriptionTarget() { 
3153      if (this.priorPrescriptionTarget == null)
3154        if (Configuration.errorOnAutoCreate())
3155          throw new Error("Attempt to auto-create MedicationRequest.priorPrescription");
3156        else if (Configuration.doAutoCreate())
3157          this.priorPrescriptionTarget = new MedicationRequest(); // aa
3158      return this.priorPrescriptionTarget;
3159    }
3160
3161    /**
3162     * @param value {@link #priorPrescription} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (A link to a resource representing an earlier order related order or prescription.)
3163     */
3164    public MedicationRequest setPriorPrescriptionTarget(MedicationRequest value) { 
3165      this.priorPrescriptionTarget = value;
3166      return this;
3167    }
3168
3169    /**
3170     * @return {@link #detectedIssue} (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.)
3171     */
3172    public List<Reference> getDetectedIssue() { 
3173      if (this.detectedIssue == null)
3174        this.detectedIssue = new ArrayList<Reference>();
3175      return this.detectedIssue;
3176    }
3177
3178    /**
3179     * @return Returns a reference to <code>this</code> for easy method chaining
3180     */
3181    public MedicationRequest setDetectedIssue(List<Reference> theDetectedIssue) { 
3182      this.detectedIssue = theDetectedIssue;
3183      return this;
3184    }
3185
3186    public boolean hasDetectedIssue() { 
3187      if (this.detectedIssue == null)
3188        return false;
3189      for (Reference item : this.detectedIssue)
3190        if (!item.isEmpty())
3191          return true;
3192      return false;
3193    }
3194
3195    public Reference addDetectedIssue() { //3
3196      Reference t = new Reference();
3197      if (this.detectedIssue == null)
3198        this.detectedIssue = new ArrayList<Reference>();
3199      this.detectedIssue.add(t);
3200      return t;
3201    }
3202
3203    public MedicationRequest addDetectedIssue(Reference t) { //3
3204      if (t == null)
3205        return this;
3206      if (this.detectedIssue == null)
3207        this.detectedIssue = new ArrayList<Reference>();
3208      this.detectedIssue.add(t);
3209      return this;
3210    }
3211
3212    /**
3213     * @return The first repetition of repeating field {@link #detectedIssue}, creating it if it does not already exist
3214     */
3215    public Reference getDetectedIssueFirstRep() { 
3216      if (getDetectedIssue().isEmpty()) {
3217        addDetectedIssue();
3218      }
3219      return getDetectedIssue().get(0);
3220    }
3221
3222    /**
3223     * @deprecated Use Reference#setResource(IBaseResource) instead
3224     */
3225    @Deprecated
3226    public List<DetectedIssue> getDetectedIssueTarget() { 
3227      if (this.detectedIssueTarget == null)
3228        this.detectedIssueTarget = new ArrayList<DetectedIssue>();
3229      return this.detectedIssueTarget;
3230    }
3231
3232    /**
3233     * @deprecated Use Reference#setResource(IBaseResource) instead
3234     */
3235    @Deprecated
3236    public DetectedIssue addDetectedIssueTarget() { 
3237      DetectedIssue r = new DetectedIssue();
3238      if (this.detectedIssueTarget == null)
3239        this.detectedIssueTarget = new ArrayList<DetectedIssue>();
3240      this.detectedIssueTarget.add(r);
3241      return r;
3242    }
3243
3244    /**
3245     * @return {@link #eventHistory} (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.)
3246     */
3247    public List<Reference> getEventHistory() { 
3248      if (this.eventHistory == null)
3249        this.eventHistory = new ArrayList<Reference>();
3250      return this.eventHistory;
3251    }
3252
3253    /**
3254     * @return Returns a reference to <code>this</code> for easy method chaining
3255     */
3256    public MedicationRequest setEventHistory(List<Reference> theEventHistory) { 
3257      this.eventHistory = theEventHistory;
3258      return this;
3259    }
3260
3261    public boolean hasEventHistory() { 
3262      if (this.eventHistory == null)
3263        return false;
3264      for (Reference item : this.eventHistory)
3265        if (!item.isEmpty())
3266          return true;
3267      return false;
3268    }
3269
3270    public Reference addEventHistory() { //3
3271      Reference t = new Reference();
3272      if (this.eventHistory == null)
3273        this.eventHistory = new ArrayList<Reference>();
3274      this.eventHistory.add(t);
3275      return t;
3276    }
3277
3278    public MedicationRequest addEventHistory(Reference t) { //3
3279      if (t == null)
3280        return this;
3281      if (this.eventHistory == null)
3282        this.eventHistory = new ArrayList<Reference>();
3283      this.eventHistory.add(t);
3284      return this;
3285    }
3286
3287    /**
3288     * @return The first repetition of repeating field {@link #eventHistory}, creating it if it does not already exist
3289     */
3290    public Reference getEventHistoryFirstRep() { 
3291      if (getEventHistory().isEmpty()) {
3292        addEventHistory();
3293      }
3294      return getEventHistory().get(0);
3295    }
3296
3297    /**
3298     * @deprecated Use Reference#setResource(IBaseResource) instead
3299     */
3300    @Deprecated
3301    public List<Provenance> getEventHistoryTarget() { 
3302      if (this.eventHistoryTarget == null)
3303        this.eventHistoryTarget = new ArrayList<Provenance>();
3304      return this.eventHistoryTarget;
3305    }
3306
3307    /**
3308     * @deprecated Use Reference#setResource(IBaseResource) instead
3309     */
3310    @Deprecated
3311    public Provenance addEventHistoryTarget() { 
3312      Provenance r = new Provenance();
3313      if (this.eventHistoryTarget == null)
3314        this.eventHistoryTarget = new ArrayList<Provenance>();
3315      this.eventHistoryTarget.add(r);
3316      return r;
3317    }
3318
3319      protected void listChildren(List<Property> children) {
3320        super.listChildren(children);
3321        children.add(new Property("identifier", "Identifier", "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.", 0, java.lang.Integer.MAX_VALUE, identifier));
3322        children.add(new Property("status", "code", "A code specifying the current state of the order.  Generally, this will be active or completed state.", 0, 1, status));
3323        children.add(new Property("statusReason", "CodeableConcept", "Captures the reason for the current state of the MedicationRequest.", 0, 1, statusReason));
3324        children.add(new Property("intent", "code", "Whether the request is a proposal, plan, or an original order.", 0, 1, intent));
3325        children.add(new Property("category", "CodeableConcept", "Indicates the type of medication request (for example, where the medication is expected to be consumed or administered (i.e. inpatient or outpatient)).", 0, java.lang.Integer.MAX_VALUE, category));
3326        children.add(new Property("priority", "code", "Indicates how quickly the Medication Request should be addressed with respect to other requests.", 0, 1, priority));
3327        children.add(new Property("doNotPerform", "boolean", "If true indicates that the provider is asking for the medication request not to occur.", 0, 1, doNotPerform));
3328        children.add(new Property("reported[x]", "boolean|Reference(Patient|Practitioner|PractitionerRole|RelatedPerson|Organization)", "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.", 0, 1, reported));
3329        children.add(new Property("medication[x]", "CodeableConcept|Reference(Medication)", "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.", 0, 1, medication));
3330        children.add(new Property("subject", "Reference(Patient|Group)", "A link to a resource representing the person or set of individuals to whom the medication will be given.", 0, 1, subject));
3331        children.add(new Property("encounter", "Reference(Encounter)", "The Encounter during which this [x] was created or to which the creation of this record is tightly associated.", 0, 1, encounter));
3332        children.add(new Property("supportingInformation", "Reference(Any)", "Include additional information (for example, patient height and weight) that supports the ordering of the medication.", 0, java.lang.Integer.MAX_VALUE, supportingInformation));
3333        children.add(new Property("authoredOn", "dateTime", "The date (and perhaps time) when the prescription was initially written or authored on.", 0, 1, authoredOn));
3334        children.add(new Property("requester", "Reference(Practitioner|PractitionerRole|Organization|Patient|RelatedPerson|Device)", "The individual, organization, or device that initiated the request and has responsibility for its activation.", 0, 1, requester));
3335        children.add(new Property("performer", "Reference(Practitioner|PractitionerRole|Organization|Patient|Device|RelatedPerson|CareTeam)", "The specified desired performer of the medication treatment (e.g. the performer of the medication administration).", 0, 1, performer));
3336        children.add(new Property("performerType", "CodeableConcept", "Indicates the type of performer of the administration of the medication.", 0, 1, performerType));
3337        children.add(new Property("recorder", "Reference(Practitioner|PractitionerRole)", "The person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.", 0, 1, recorder));
3338        children.add(new Property("reasonCode", "CodeableConcept", "The reason or the indication for ordering or not ordering the medication.", 0, java.lang.Integer.MAX_VALUE, reasonCode));
3339        children.add(new Property("reasonReference", "Reference(Condition|Observation)", "Condition or observation that supports why the medication was ordered.", 0, java.lang.Integer.MAX_VALUE, reasonReference));
3340        children.add(new Property("instantiatesCanonical", "canonical", "The URL pointing to a protocol, guideline, orderset, or other definition that is adhered to in whole or in part by this MedicationRequest.", 0, java.lang.Integer.MAX_VALUE, instantiatesCanonical));
3341        children.add(new Property("instantiatesUri", "uri", "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.", 0, java.lang.Integer.MAX_VALUE, instantiatesUri));
3342        children.add(new Property("basedOn", "Reference(CarePlan|MedicationRequest|ServiceRequest|ImmunizationRecommendation)", "A plan or request that is fulfilled in whole or in part by this medication request.", 0, java.lang.Integer.MAX_VALUE, basedOn));
3343        children.add(new Property("groupIdentifier", "Identifier", "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.", 0, 1, groupIdentifier));
3344        children.add(new Property("courseOfTherapyType", "CodeableConcept", "The description of the overall patte3rn of the administration of the medication to the patient.", 0, 1, courseOfTherapyType));
3345        children.add(new Property("insurance", "Reference(Coverage|ClaimResponse)", "Insurance plans, coverage extensions, pre-authorizations and/or pre-determinations that may be required for delivering the requested service.", 0, java.lang.Integer.MAX_VALUE, insurance));
3346        children.add(new Property("note", "Annotation", "Extra information about the prescription that could not be conveyed by the other attributes.", 0, java.lang.Integer.MAX_VALUE, note));
3347        children.add(new Property("dosageInstruction", "Dosage", "Indicates how the medication is to be used by the patient.", 0, java.lang.Integer.MAX_VALUE, dosageInstruction));
3348        children.add(new Property("dispenseRequest", "", "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.", 0, 1, dispenseRequest));
3349        children.add(new Property("substitution", "", "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.", 0, 1, substitution));
3350        children.add(new Property("priorPrescription", "Reference(MedicationRequest)", "A link to a resource representing an earlier order related order or prescription.", 0, 1, priorPrescription));
3351        children.add(new Property("detectedIssue", "Reference(DetectedIssue)", "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.", 0, java.lang.Integer.MAX_VALUE, detectedIssue));
3352        children.add(new Property("eventHistory", "Reference(Provenance)", "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.", 0, java.lang.Integer.MAX_VALUE, eventHistory));
3353      }
3354
3355      @Override
3356      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
3357        switch (_hash) {
3358        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "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.", 0, java.lang.Integer.MAX_VALUE, identifier);
3359        case -892481550: /*status*/  return new Property("status", "code", "A code specifying the current state of the order.  Generally, this will be active or completed state.", 0, 1, status);
3360        case 2051346646: /*statusReason*/  return new Property("statusReason", "CodeableConcept", "Captures the reason for the current state of the MedicationRequest.", 0, 1, statusReason);
3361        case -1183762788: /*intent*/  return new Property("intent", "code", "Whether the request is a proposal, plan, or an original order.", 0, 1, intent);
3362        case 50511102: /*category*/  return new Property("category", "CodeableConcept", "Indicates the type of medication request (for example, where the medication is expected to be consumed or administered (i.e. inpatient or outpatient)).", 0, java.lang.Integer.MAX_VALUE, category);
3363        case -1165461084: /*priority*/  return new Property("priority", "code", "Indicates how quickly the Medication Request should be addressed with respect to other requests.", 0, 1, priority);
3364        case -1788508167: /*doNotPerform*/  return new Property("doNotPerform", "boolean", "If true indicates that the provider is asking for the medication request not to occur.", 0, 1, doNotPerform);
3365        case -241505587: /*reported[x]*/  return new Property("reported[x]", "boolean|Reference(Patient|Practitioner|PractitionerRole|RelatedPerson|Organization)", "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.", 0, 1, reported);
3366        case -427039533: /*reported*/  return new Property("reported[x]", "boolean|Reference(Patient|Practitioner|PractitionerRole|RelatedPerson|Organization)", "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.", 0, 1, reported);
3367        case 1219992533: /*reportedBoolean*/  return new Property("reported[x]", "boolean|Reference(Patient|Practitioner|PractitionerRole|RelatedPerson|Organization)", "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.", 0, 1, reported);
3368        case 1198143416: /*reportedReference*/  return new Property("reported[x]", "boolean|Reference(Patient|Practitioner|PractitionerRole|RelatedPerson|Organization)", "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.", 0, 1, reported);
3369        case 1458402129: /*medication[x]*/  return new Property("medication[x]", "CodeableConcept|Reference(Medication)", "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.", 0, 1, medication);
3370        case 1998965455: /*medication*/  return new Property("medication[x]", "CodeableConcept|Reference(Medication)", "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.", 0, 1, medication);
3371        case -209845038: /*medicationCodeableConcept*/  return new Property("medication[x]", "CodeableConcept|Reference(Medication)", "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.", 0, 1, medication);
3372        case 2104315196: /*medicationReference*/  return new Property("medication[x]", "CodeableConcept|Reference(Medication)", "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.", 0, 1, medication);
3373        case -1867885268: /*subject*/  return new Property("subject", "Reference(Patient|Group)", "A link to a resource representing the person or set of individuals to whom the medication will be given.", 0, 1, subject);
3374        case 1524132147: /*encounter*/  return new Property("encounter", "Reference(Encounter)", "The Encounter during which this [x] was created or to which the creation of this record is tightly associated.", 0, 1, encounter);
3375        case -1248768647: /*supportingInformation*/  return new Property("supportingInformation", "Reference(Any)", "Include additional information (for example, patient height and weight) that supports the ordering of the medication.", 0, java.lang.Integer.MAX_VALUE, supportingInformation);
3376        case -1500852503: /*authoredOn*/  return new Property("authoredOn", "dateTime", "The date (and perhaps time) when the prescription was initially written or authored on.", 0, 1, authoredOn);
3377        case 693933948: /*requester*/  return new Property("requester", "Reference(Practitioner|PractitionerRole|Organization|Patient|RelatedPerson|Device)", "The individual, organization, or device that initiated the request and has responsibility for its activation.", 0, 1, requester);
3378        case 481140686: /*performer*/  return new Property("performer", "Reference(Practitioner|PractitionerRole|Organization|Patient|Device|RelatedPerson|CareTeam)", "The specified desired performer of the medication treatment (e.g. the performer of the medication administration).", 0, 1, performer);
3379        case -901444568: /*performerType*/  return new Property("performerType", "CodeableConcept", "Indicates the type of performer of the administration of the medication.", 0, 1, performerType);
3380        case -799233858: /*recorder*/  return new Property("recorder", "Reference(Practitioner|PractitionerRole)", "The person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.", 0, 1, recorder);
3381        case 722137681: /*reasonCode*/  return new Property("reasonCode", "CodeableConcept", "The reason or the indication for ordering or not ordering the medication.", 0, java.lang.Integer.MAX_VALUE, reasonCode);
3382        case -1146218137: /*reasonReference*/  return new Property("reasonReference", "Reference(Condition|Observation)", "Condition or observation that supports why the medication was ordered.", 0, java.lang.Integer.MAX_VALUE, reasonReference);
3383        case 8911915: /*instantiatesCanonical*/  return new Property("instantiatesCanonical", "canonical", "The URL pointing to a protocol, guideline, orderset, or other definition that is adhered to in whole or in part by this MedicationRequest.", 0, java.lang.Integer.MAX_VALUE, instantiatesCanonical);
3384        case -1926393373: /*instantiatesUri*/  return new Property("instantiatesUri", "uri", "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.", 0, java.lang.Integer.MAX_VALUE, instantiatesUri);
3385        case -332612366: /*basedOn*/  return new Property("basedOn", "Reference(CarePlan|MedicationRequest|ServiceRequest|ImmunizationRecommendation)", "A plan or request that is fulfilled in whole or in part by this medication request.", 0, java.lang.Integer.MAX_VALUE, basedOn);
3386        case -445338488: /*groupIdentifier*/  return new Property("groupIdentifier", "Identifier", "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.", 0, 1, groupIdentifier);
3387        case -447282031: /*courseOfTherapyType*/  return new Property("courseOfTherapyType", "CodeableConcept", "The description of the overall patte3rn of the administration of the medication to the patient.", 0, 1, courseOfTherapyType);
3388        case 73049818: /*insurance*/  return new Property("insurance", "Reference(Coverage|ClaimResponse)", "Insurance plans, coverage extensions, pre-authorizations and/or pre-determinations that may be required for delivering the requested service.", 0, java.lang.Integer.MAX_VALUE, insurance);
3389        case 3387378: /*note*/  return new Property("note", "Annotation", "Extra information about the prescription that could not be conveyed by the other attributes.", 0, java.lang.Integer.MAX_VALUE, note);
3390        case -1201373865: /*dosageInstruction*/  return new Property("dosageInstruction", "Dosage", "Indicates how the medication is to be used by the patient.", 0, java.lang.Integer.MAX_VALUE, dosageInstruction);
3391        case 824620658: /*dispenseRequest*/  return new Property("dispenseRequest", "", "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.", 0, 1, dispenseRequest);
3392        case 826147581: /*substitution*/  return new Property("substitution", "", "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.", 0, 1, substitution);
3393        case -486355964: /*priorPrescription*/  return new Property("priorPrescription", "Reference(MedicationRequest)", "A link to a resource representing an earlier order related order or prescription.", 0, 1, priorPrescription);
3394        case 51602295: /*detectedIssue*/  return new Property("detectedIssue", "Reference(DetectedIssue)", "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.", 0, java.lang.Integer.MAX_VALUE, detectedIssue);
3395        case 1835190426: /*eventHistory*/  return new Property("eventHistory", "Reference(Provenance)", "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.", 0, java.lang.Integer.MAX_VALUE, eventHistory);
3396        default: return super.getNamedProperty(_hash, _name, _checkValid);
3397        }
3398
3399      }
3400
3401      @Override
3402      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
3403        switch (hash) {
3404        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
3405        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<MedicationRequestStatus>
3406        case 2051346646: /*statusReason*/ return this.statusReason == null ? new Base[0] : new Base[] {this.statusReason}; // CodeableConcept
3407        case -1183762788: /*intent*/ return this.intent == null ? new Base[0] : new Base[] {this.intent}; // Enumeration<MedicationRequestIntent>
3408        case 50511102: /*category*/ return this.category == null ? new Base[0] : this.category.toArray(new Base[this.category.size()]); // CodeableConcept
3409        case -1165461084: /*priority*/ return this.priority == null ? new Base[0] : new Base[] {this.priority}; // Enumeration<MedicationRequestPriority>
3410        case -1788508167: /*doNotPerform*/ return this.doNotPerform == null ? new Base[0] : new Base[] {this.doNotPerform}; // BooleanType
3411        case -427039533: /*reported*/ return this.reported == null ? new Base[0] : new Base[] {this.reported}; // Type
3412        case 1998965455: /*medication*/ return this.medication == null ? new Base[0] : new Base[] {this.medication}; // Type
3413        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
3414        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : new Base[] {this.encounter}; // Reference
3415        case -1248768647: /*supportingInformation*/ return this.supportingInformation == null ? new Base[0] : this.supportingInformation.toArray(new Base[this.supportingInformation.size()]); // Reference
3416        case -1500852503: /*authoredOn*/ return this.authoredOn == null ? new Base[0] : new Base[] {this.authoredOn}; // DateTimeType
3417        case 693933948: /*requester*/ return this.requester == null ? new Base[0] : new Base[] {this.requester}; // Reference
3418        case 481140686: /*performer*/ return this.performer == null ? new Base[0] : new Base[] {this.performer}; // Reference
3419        case -901444568: /*performerType*/ return this.performerType == null ? new Base[0] : new Base[] {this.performerType}; // CodeableConcept
3420        case -799233858: /*recorder*/ return this.recorder == null ? new Base[0] : new Base[] {this.recorder}; // Reference
3421        case 722137681: /*reasonCode*/ return this.reasonCode == null ? new Base[0] : this.reasonCode.toArray(new Base[this.reasonCode.size()]); // CodeableConcept
3422        case -1146218137: /*reasonReference*/ return this.reasonReference == null ? new Base[0] : this.reasonReference.toArray(new Base[this.reasonReference.size()]); // Reference
3423        case 8911915: /*instantiatesCanonical*/ return this.instantiatesCanonical == null ? new Base[0] : this.instantiatesCanonical.toArray(new Base[this.instantiatesCanonical.size()]); // CanonicalType
3424        case -1926393373: /*instantiatesUri*/ return this.instantiatesUri == null ? new Base[0] : this.instantiatesUri.toArray(new Base[this.instantiatesUri.size()]); // UriType
3425        case -332612366: /*basedOn*/ return this.basedOn == null ? new Base[0] : this.basedOn.toArray(new Base[this.basedOn.size()]); // Reference
3426        case -445338488: /*groupIdentifier*/ return this.groupIdentifier == null ? new Base[0] : new Base[] {this.groupIdentifier}; // Identifier
3427        case -447282031: /*courseOfTherapyType*/ return this.courseOfTherapyType == null ? new Base[0] : new Base[] {this.courseOfTherapyType}; // CodeableConcept
3428        case 73049818: /*insurance*/ return this.insurance == null ? new Base[0] : this.insurance.toArray(new Base[this.insurance.size()]); // Reference
3429        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
3430        case -1201373865: /*dosageInstruction*/ return this.dosageInstruction == null ? new Base[0] : this.dosageInstruction.toArray(new Base[this.dosageInstruction.size()]); // Dosage
3431        case 824620658: /*dispenseRequest*/ return this.dispenseRequest == null ? new Base[0] : new Base[] {this.dispenseRequest}; // MedicationRequestDispenseRequestComponent
3432        case 826147581: /*substitution*/ return this.substitution == null ? new Base[0] : new Base[] {this.substitution}; // MedicationRequestSubstitutionComponent
3433        case -486355964: /*priorPrescription*/ return this.priorPrescription == null ? new Base[0] : new Base[] {this.priorPrescription}; // Reference
3434        case 51602295: /*detectedIssue*/ return this.detectedIssue == null ? new Base[0] : this.detectedIssue.toArray(new Base[this.detectedIssue.size()]); // Reference
3435        case 1835190426: /*eventHistory*/ return this.eventHistory == null ? new Base[0] : this.eventHistory.toArray(new Base[this.eventHistory.size()]); // Reference
3436        default: return super.getProperty(hash, name, checkValid);
3437        }
3438
3439      }
3440
3441      @Override
3442      public Base setProperty(int hash, String name, Base value) throws FHIRException {
3443        switch (hash) {
3444        case -1618432855: // identifier
3445          this.getIdentifier().add(castToIdentifier(value)); // Identifier
3446          return value;
3447        case -892481550: // status
3448          value = new MedicationRequestStatusEnumFactory().fromType(castToCode(value));
3449          this.status = (Enumeration) value; // Enumeration<MedicationRequestStatus>
3450          return value;
3451        case 2051346646: // statusReason
3452          this.statusReason = castToCodeableConcept(value); // CodeableConcept
3453          return value;
3454        case -1183762788: // intent
3455          value = new MedicationRequestIntentEnumFactory().fromType(castToCode(value));
3456          this.intent = (Enumeration) value; // Enumeration<MedicationRequestIntent>
3457          return value;
3458        case 50511102: // category
3459          this.getCategory().add(castToCodeableConcept(value)); // CodeableConcept
3460          return value;
3461        case -1165461084: // priority
3462          value = new MedicationRequestPriorityEnumFactory().fromType(castToCode(value));
3463          this.priority = (Enumeration) value; // Enumeration<MedicationRequestPriority>
3464          return value;
3465        case -1788508167: // doNotPerform
3466          this.doNotPerform = castToBoolean(value); // BooleanType
3467          return value;
3468        case -427039533: // reported
3469          this.reported = castToType(value); // Type
3470          return value;
3471        case 1998965455: // medication
3472          this.medication = castToType(value); // Type
3473          return value;
3474        case -1867885268: // subject
3475          this.subject = castToReference(value); // Reference
3476          return value;
3477        case 1524132147: // encounter
3478          this.encounter = castToReference(value); // Reference
3479          return value;
3480        case -1248768647: // supportingInformation
3481          this.getSupportingInformation().add(castToReference(value)); // Reference
3482          return value;
3483        case -1500852503: // authoredOn
3484          this.authoredOn = castToDateTime(value); // DateTimeType
3485          return value;
3486        case 693933948: // requester
3487          this.requester = castToReference(value); // Reference
3488          return value;
3489        case 481140686: // performer
3490          this.performer = castToReference(value); // Reference
3491          return value;
3492        case -901444568: // performerType
3493          this.performerType = castToCodeableConcept(value); // CodeableConcept
3494          return value;
3495        case -799233858: // recorder
3496          this.recorder = castToReference(value); // Reference
3497          return value;
3498        case 722137681: // reasonCode
3499          this.getReasonCode().add(castToCodeableConcept(value)); // CodeableConcept
3500          return value;
3501        case -1146218137: // reasonReference
3502          this.getReasonReference().add(castToReference(value)); // Reference
3503          return value;
3504        case 8911915: // instantiatesCanonical
3505          this.getInstantiatesCanonical().add(castToCanonical(value)); // CanonicalType
3506          return value;
3507        case -1926393373: // instantiatesUri
3508          this.getInstantiatesUri().add(castToUri(value)); // UriType
3509          return value;
3510        case -332612366: // basedOn
3511          this.getBasedOn().add(castToReference(value)); // Reference
3512          return value;
3513        case -445338488: // groupIdentifier
3514          this.groupIdentifier = castToIdentifier(value); // Identifier
3515          return value;
3516        case -447282031: // courseOfTherapyType
3517          this.courseOfTherapyType = castToCodeableConcept(value); // CodeableConcept
3518          return value;
3519        case 73049818: // insurance
3520          this.getInsurance().add(castToReference(value)); // Reference
3521          return value;
3522        case 3387378: // note
3523          this.getNote().add(castToAnnotation(value)); // Annotation
3524          return value;
3525        case -1201373865: // dosageInstruction
3526          this.getDosageInstruction().add(castToDosage(value)); // Dosage
3527          return value;
3528        case 824620658: // dispenseRequest
3529          this.dispenseRequest = (MedicationRequestDispenseRequestComponent) value; // MedicationRequestDispenseRequestComponent
3530          return value;
3531        case 826147581: // substitution
3532          this.substitution = (MedicationRequestSubstitutionComponent) value; // MedicationRequestSubstitutionComponent
3533          return value;
3534        case -486355964: // priorPrescription
3535          this.priorPrescription = castToReference(value); // Reference
3536          return value;
3537        case 51602295: // detectedIssue
3538          this.getDetectedIssue().add(castToReference(value)); // Reference
3539          return value;
3540        case 1835190426: // eventHistory
3541          this.getEventHistory().add(castToReference(value)); // Reference
3542          return value;
3543        default: return super.setProperty(hash, name, value);
3544        }
3545
3546      }
3547
3548      @Override
3549      public Base setProperty(String name, Base value) throws FHIRException {
3550        if (name.equals("identifier")) {
3551          this.getIdentifier().add(castToIdentifier(value));
3552        } else if (name.equals("status")) {
3553          value = new MedicationRequestStatusEnumFactory().fromType(castToCode(value));
3554          this.status = (Enumeration) value; // Enumeration<MedicationRequestStatus>
3555        } else if (name.equals("statusReason")) {
3556          this.statusReason = castToCodeableConcept(value); // CodeableConcept
3557        } else if (name.equals("intent")) {
3558          value = new MedicationRequestIntentEnumFactory().fromType(castToCode(value));
3559          this.intent = (Enumeration) value; // Enumeration<MedicationRequestIntent>
3560        } else if (name.equals("category")) {
3561          this.getCategory().add(castToCodeableConcept(value));
3562        } else if (name.equals("priority")) {
3563          value = new MedicationRequestPriorityEnumFactory().fromType(castToCode(value));
3564          this.priority = (Enumeration) value; // Enumeration<MedicationRequestPriority>
3565        } else if (name.equals("doNotPerform")) {
3566          this.doNotPerform = castToBoolean(value); // BooleanType
3567        } else if (name.equals("reported[x]")) {
3568          this.reported = castToType(value); // Type
3569        } else if (name.equals("medication[x]")) {
3570          this.medication = castToType(value); // Type
3571        } else if (name.equals("subject")) {
3572          this.subject = castToReference(value); // Reference
3573        } else if (name.equals("encounter")) {
3574          this.encounter = castToReference(value); // Reference
3575        } else if (name.equals("supportingInformation")) {
3576          this.getSupportingInformation().add(castToReference(value));
3577        } else if (name.equals("authoredOn")) {
3578          this.authoredOn = castToDateTime(value); // DateTimeType
3579        } else if (name.equals("requester")) {
3580          this.requester = castToReference(value); // Reference
3581        } else if (name.equals("performer")) {
3582          this.performer = castToReference(value); // Reference
3583        } else if (name.equals("performerType")) {
3584          this.performerType = castToCodeableConcept(value); // CodeableConcept
3585        } else if (name.equals("recorder")) {
3586          this.recorder = castToReference(value); // Reference
3587        } else if (name.equals("reasonCode")) {
3588          this.getReasonCode().add(castToCodeableConcept(value));
3589        } else if (name.equals("reasonReference")) {
3590          this.getReasonReference().add(castToReference(value));
3591        } else if (name.equals("instantiatesCanonical")) {
3592          this.getInstantiatesCanonical().add(castToCanonical(value));
3593        } else if (name.equals("instantiatesUri")) {
3594          this.getInstantiatesUri().add(castToUri(value));
3595        } else if (name.equals("basedOn")) {
3596          this.getBasedOn().add(castToReference(value));
3597        } else if (name.equals("groupIdentifier")) {
3598          this.groupIdentifier = castToIdentifier(value); // Identifier
3599        } else if (name.equals("courseOfTherapyType")) {
3600          this.courseOfTherapyType = castToCodeableConcept(value); // CodeableConcept
3601        } else if (name.equals("insurance")) {
3602          this.getInsurance().add(castToReference(value));
3603        } else if (name.equals("note")) {
3604          this.getNote().add(castToAnnotation(value));
3605        } else if (name.equals("dosageInstruction")) {
3606          this.getDosageInstruction().add(castToDosage(value));
3607        } else if (name.equals("dispenseRequest")) {
3608          this.dispenseRequest = (MedicationRequestDispenseRequestComponent) value; // MedicationRequestDispenseRequestComponent
3609        } else if (name.equals("substitution")) {
3610          this.substitution = (MedicationRequestSubstitutionComponent) value; // MedicationRequestSubstitutionComponent
3611        } else if (name.equals("priorPrescription")) {
3612          this.priorPrescription = castToReference(value); // Reference
3613        } else if (name.equals("detectedIssue")) {
3614          this.getDetectedIssue().add(castToReference(value));
3615        } else if (name.equals("eventHistory")) {
3616          this.getEventHistory().add(castToReference(value));
3617        } else
3618          return super.setProperty(name, value);
3619        return value;
3620      }
3621
3622      @Override
3623      public Base makeProperty(int hash, String name) throws FHIRException {
3624        switch (hash) {
3625        case -1618432855:  return addIdentifier(); 
3626        case -892481550:  return getStatusElement();
3627        case 2051346646:  return getStatusReason(); 
3628        case -1183762788:  return getIntentElement();
3629        case 50511102:  return addCategory(); 
3630        case -1165461084:  return getPriorityElement();
3631        case -1788508167:  return getDoNotPerformElement();
3632        case -241505587:  return getReported(); 
3633        case -427039533:  return getReported(); 
3634        case 1458402129:  return getMedication(); 
3635        case 1998965455:  return getMedication(); 
3636        case -1867885268:  return getSubject(); 
3637        case 1524132147:  return getEncounter(); 
3638        case -1248768647:  return addSupportingInformation(); 
3639        case -1500852503:  return getAuthoredOnElement();
3640        case 693933948:  return getRequester(); 
3641        case 481140686:  return getPerformer(); 
3642        case -901444568:  return getPerformerType(); 
3643        case -799233858:  return getRecorder(); 
3644        case 722137681:  return addReasonCode(); 
3645        case -1146218137:  return addReasonReference(); 
3646        case 8911915:  return addInstantiatesCanonicalElement();
3647        case -1926393373:  return addInstantiatesUriElement();
3648        case -332612366:  return addBasedOn(); 
3649        case -445338488:  return getGroupIdentifier(); 
3650        case -447282031:  return getCourseOfTherapyType(); 
3651        case 73049818:  return addInsurance(); 
3652        case 3387378:  return addNote(); 
3653        case -1201373865:  return addDosageInstruction(); 
3654        case 824620658:  return getDispenseRequest(); 
3655        case 826147581:  return getSubstitution(); 
3656        case -486355964:  return getPriorPrescription(); 
3657        case 51602295:  return addDetectedIssue(); 
3658        case 1835190426:  return addEventHistory(); 
3659        default: return super.makeProperty(hash, name);
3660        }
3661
3662      }
3663
3664      @Override
3665      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
3666        switch (hash) {
3667        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
3668        case -892481550: /*status*/ return new String[] {"code"};
3669        case 2051346646: /*statusReason*/ return new String[] {"CodeableConcept"};
3670        case -1183762788: /*intent*/ return new String[] {"code"};
3671        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
3672        case -1165461084: /*priority*/ return new String[] {"code"};
3673        case -1788508167: /*doNotPerform*/ return new String[] {"boolean"};
3674        case -427039533: /*reported*/ return new String[] {"boolean", "Reference"};
3675        case 1998965455: /*medication*/ return new String[] {"CodeableConcept", "Reference"};
3676        case -1867885268: /*subject*/ return new String[] {"Reference"};
3677        case 1524132147: /*encounter*/ return new String[] {"Reference"};
3678        case -1248768647: /*supportingInformation*/ return new String[] {"Reference"};
3679        case -1500852503: /*authoredOn*/ return new String[] {"dateTime"};
3680        case 693933948: /*requester*/ return new String[] {"Reference"};
3681        case 481140686: /*performer*/ return new String[] {"Reference"};
3682        case -901444568: /*performerType*/ return new String[] {"CodeableConcept"};
3683        case -799233858: /*recorder*/ return new String[] {"Reference"};
3684        case 722137681: /*reasonCode*/ return new String[] {"CodeableConcept"};
3685        case -1146218137: /*reasonReference*/ return new String[] {"Reference"};
3686        case 8911915: /*instantiatesCanonical*/ return new String[] {"canonical"};
3687        case -1926393373: /*instantiatesUri*/ return new String[] {"uri"};
3688        case -332612366: /*basedOn*/ return new String[] {"Reference"};
3689        case -445338488: /*groupIdentifier*/ return new String[] {"Identifier"};
3690        case -447282031: /*courseOfTherapyType*/ return new String[] {"CodeableConcept"};
3691        case 73049818: /*insurance*/ return new String[] {"Reference"};
3692        case 3387378: /*note*/ return new String[] {"Annotation"};
3693        case -1201373865: /*dosageInstruction*/ return new String[] {"Dosage"};
3694        case 824620658: /*dispenseRequest*/ return new String[] {};
3695        case 826147581: /*substitution*/ return new String[] {};
3696        case -486355964: /*priorPrescription*/ return new String[] {"Reference"};
3697        case 51602295: /*detectedIssue*/ return new String[] {"Reference"};
3698        case 1835190426: /*eventHistory*/ return new String[] {"Reference"};
3699        default: return super.getTypesForProperty(hash, name);
3700        }
3701
3702      }
3703
3704      @Override
3705      public Base addChild(String name) throws FHIRException {
3706        if (name.equals("identifier")) {
3707          return addIdentifier();
3708        }
3709        else if (name.equals("status")) {
3710          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.status");
3711        }
3712        else if (name.equals("statusReason")) {
3713          this.statusReason = new CodeableConcept();
3714          return this.statusReason;
3715        }
3716        else if (name.equals("intent")) {
3717          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.intent");
3718        }
3719        else if (name.equals("category")) {
3720          return addCategory();
3721        }
3722        else if (name.equals("priority")) {
3723          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.priority");
3724        }
3725        else if (name.equals("doNotPerform")) {
3726          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.doNotPerform");
3727        }
3728        else if (name.equals("reportedBoolean")) {
3729          this.reported = new BooleanType();
3730          return this.reported;
3731        }
3732        else if (name.equals("reportedReference")) {
3733          this.reported = new Reference();
3734          return this.reported;
3735        }
3736        else if (name.equals("medicationCodeableConcept")) {
3737          this.medication = new CodeableConcept();
3738          return this.medication;
3739        }
3740        else if (name.equals("medicationReference")) {
3741          this.medication = new Reference();
3742          return this.medication;
3743        }
3744        else if (name.equals("subject")) {
3745          this.subject = new Reference();
3746          return this.subject;
3747        }
3748        else if (name.equals("encounter")) {
3749          this.encounter = new Reference();
3750          return this.encounter;
3751        }
3752        else if (name.equals("supportingInformation")) {
3753          return addSupportingInformation();
3754        }
3755        else if (name.equals("authoredOn")) {
3756          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.authoredOn");
3757        }
3758        else if (name.equals("requester")) {
3759          this.requester = new Reference();
3760          return this.requester;
3761        }
3762        else if (name.equals("performer")) {
3763          this.performer = new Reference();
3764          return this.performer;
3765        }
3766        else if (name.equals("performerType")) {
3767          this.performerType = new CodeableConcept();
3768          return this.performerType;
3769        }
3770        else if (name.equals("recorder")) {
3771          this.recorder = new Reference();
3772          return this.recorder;
3773        }
3774        else if (name.equals("reasonCode")) {
3775          return addReasonCode();
3776        }
3777        else if (name.equals("reasonReference")) {
3778          return addReasonReference();
3779        }
3780        else if (name.equals("instantiatesCanonical")) {
3781          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.instantiatesCanonical");
3782        }
3783        else if (name.equals("instantiatesUri")) {
3784          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.instantiatesUri");
3785        }
3786        else if (name.equals("basedOn")) {
3787          return addBasedOn();
3788        }
3789        else if (name.equals("groupIdentifier")) {
3790          this.groupIdentifier = new Identifier();
3791          return this.groupIdentifier;
3792        }
3793        else if (name.equals("courseOfTherapyType")) {
3794          this.courseOfTherapyType = new CodeableConcept();
3795          return this.courseOfTherapyType;
3796        }
3797        else if (name.equals("insurance")) {
3798          return addInsurance();
3799        }
3800        else if (name.equals("note")) {
3801          return addNote();
3802        }
3803        else if (name.equals("dosageInstruction")) {
3804          return addDosageInstruction();
3805        }
3806        else if (name.equals("dispenseRequest")) {
3807          this.dispenseRequest = new MedicationRequestDispenseRequestComponent();
3808          return this.dispenseRequest;
3809        }
3810        else if (name.equals("substitution")) {
3811          this.substitution = new MedicationRequestSubstitutionComponent();
3812          return this.substitution;
3813        }
3814        else if (name.equals("priorPrescription")) {
3815          this.priorPrescription = new Reference();
3816          return this.priorPrescription;
3817        }
3818        else if (name.equals("detectedIssue")) {
3819          return addDetectedIssue();
3820        }
3821        else if (name.equals("eventHistory")) {
3822          return addEventHistory();
3823        }
3824        else
3825          return super.addChild(name);
3826      }
3827
3828  public String fhirType() {
3829    return "MedicationRequest";
3830
3831  }
3832
3833      public MedicationRequest copy() {
3834        MedicationRequest dst = new MedicationRequest();
3835        copyValues(dst);
3836        return dst;
3837      }
3838
3839      public void copyValues(MedicationRequest dst) {
3840        super.copyValues(dst);
3841        if (identifier != null) {
3842          dst.identifier = new ArrayList<Identifier>();
3843          for (Identifier i : identifier)
3844            dst.identifier.add(i.copy());
3845        };
3846        dst.status = status == null ? null : status.copy();
3847        dst.statusReason = statusReason == null ? null : statusReason.copy();
3848        dst.intent = intent == null ? null : intent.copy();
3849        if (category != null) {
3850          dst.category = new ArrayList<CodeableConcept>();
3851          for (CodeableConcept i : category)
3852            dst.category.add(i.copy());
3853        };
3854        dst.priority = priority == null ? null : priority.copy();
3855        dst.doNotPerform = doNotPerform == null ? null : doNotPerform.copy();
3856        dst.reported = reported == null ? null : reported.copy();
3857        dst.medication = medication == null ? null : medication.copy();
3858        dst.subject = subject == null ? null : subject.copy();
3859        dst.encounter = encounter == null ? null : encounter.copy();
3860        if (supportingInformation != null) {
3861          dst.supportingInformation = new ArrayList<Reference>();
3862          for (Reference i : supportingInformation)
3863            dst.supportingInformation.add(i.copy());
3864        };
3865        dst.authoredOn = authoredOn == null ? null : authoredOn.copy();
3866        dst.requester = requester == null ? null : requester.copy();
3867        dst.performer = performer == null ? null : performer.copy();
3868        dst.performerType = performerType == null ? null : performerType.copy();
3869        dst.recorder = recorder == null ? null : recorder.copy();
3870        if (reasonCode != null) {
3871          dst.reasonCode = new ArrayList<CodeableConcept>();
3872          for (CodeableConcept i : reasonCode)
3873            dst.reasonCode.add(i.copy());
3874        };
3875        if (reasonReference != null) {
3876          dst.reasonReference = new ArrayList<Reference>();
3877          for (Reference i : reasonReference)
3878            dst.reasonReference.add(i.copy());
3879        };
3880        if (instantiatesCanonical != null) {
3881          dst.instantiatesCanonical = new ArrayList<CanonicalType>();
3882          for (CanonicalType i : instantiatesCanonical)
3883            dst.instantiatesCanonical.add(i.copy());
3884        };
3885        if (instantiatesUri != null) {
3886          dst.instantiatesUri = new ArrayList<UriType>();
3887          for (UriType i : instantiatesUri)
3888            dst.instantiatesUri.add(i.copy());
3889        };
3890        if (basedOn != null) {
3891          dst.basedOn = new ArrayList<Reference>();
3892          for (Reference i : basedOn)
3893            dst.basedOn.add(i.copy());
3894        };
3895        dst.groupIdentifier = groupIdentifier == null ? null : groupIdentifier.copy();
3896        dst.courseOfTherapyType = courseOfTherapyType == null ? null : courseOfTherapyType.copy();
3897        if (insurance != null) {
3898          dst.insurance = new ArrayList<Reference>();
3899          for (Reference i : insurance)
3900            dst.insurance.add(i.copy());
3901        };
3902        if (note != null) {
3903          dst.note = new ArrayList<Annotation>();
3904          for (Annotation i : note)
3905            dst.note.add(i.copy());
3906        };
3907        if (dosageInstruction != null) {
3908          dst.dosageInstruction = new ArrayList<Dosage>();
3909          for (Dosage i : dosageInstruction)
3910            dst.dosageInstruction.add(i.copy());
3911        };
3912        dst.dispenseRequest = dispenseRequest == null ? null : dispenseRequest.copy();
3913        dst.substitution = substitution == null ? null : substitution.copy();
3914        dst.priorPrescription = priorPrescription == null ? null : priorPrescription.copy();
3915        if (detectedIssue != null) {
3916          dst.detectedIssue = new ArrayList<Reference>();
3917          for (Reference i : detectedIssue)
3918            dst.detectedIssue.add(i.copy());
3919        };
3920        if (eventHistory != null) {
3921          dst.eventHistory = new ArrayList<Reference>();
3922          for (Reference i : eventHistory)
3923            dst.eventHistory.add(i.copy());
3924        };
3925      }
3926
3927      protected MedicationRequest typedCopy() {
3928        return copy();
3929      }
3930
3931      @Override
3932      public boolean equalsDeep(Base other_) {
3933        if (!super.equalsDeep(other_))
3934          return false;
3935        if (!(other_ instanceof MedicationRequest))
3936          return false;
3937        MedicationRequest o = (MedicationRequest) other_;
3938        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(statusReason, o.statusReason, true)
3939           && compareDeep(intent, o.intent, true) && compareDeep(category, o.category, true) && compareDeep(priority, o.priority, true)
3940           && compareDeep(doNotPerform, o.doNotPerform, true) && compareDeep(reported, o.reported, true) && compareDeep(medication, o.medication, true)
3941           && compareDeep(subject, o.subject, true) && compareDeep(encounter, o.encounter, true) && compareDeep(supportingInformation, o.supportingInformation, true)
3942           && compareDeep(authoredOn, o.authoredOn, true) && compareDeep(requester, o.requester, true) && compareDeep(performer, o.performer, true)
3943           && compareDeep(performerType, o.performerType, true) && compareDeep(recorder, o.recorder, true)
3944           && compareDeep(reasonCode, o.reasonCode, true) && compareDeep(reasonReference, o.reasonReference, true)
3945           && compareDeep(instantiatesCanonical, o.instantiatesCanonical, true) && compareDeep(instantiatesUri, o.instantiatesUri, true)
3946           && compareDeep(basedOn, o.basedOn, true) && compareDeep(groupIdentifier, o.groupIdentifier, true)
3947           && compareDeep(courseOfTherapyType, o.courseOfTherapyType, true) && compareDeep(insurance, o.insurance, true)
3948           && compareDeep(note, o.note, true) && compareDeep(dosageInstruction, o.dosageInstruction, true)
3949           && compareDeep(dispenseRequest, o.dispenseRequest, true) && compareDeep(substitution, o.substitution, true)
3950           && compareDeep(priorPrescription, o.priorPrescription, true) && compareDeep(detectedIssue, o.detectedIssue, true)
3951           && compareDeep(eventHistory, o.eventHistory, true);
3952      }
3953
3954      @Override
3955      public boolean equalsShallow(Base other_) {
3956        if (!super.equalsShallow(other_))
3957          return false;
3958        if (!(other_ instanceof MedicationRequest))
3959          return false;
3960        MedicationRequest o = (MedicationRequest) other_;
3961        return compareValues(status, o.status, true) && compareValues(intent, o.intent, true) && compareValues(priority, o.priority, true)
3962           && compareValues(doNotPerform, o.doNotPerform, true) && compareValues(authoredOn, o.authoredOn, true)
3963           && compareValues(instantiatesCanonical, o.instantiatesCanonical, true) && compareValues(instantiatesUri, o.instantiatesUri, true)
3964          ;
3965      }
3966
3967      public boolean isEmpty() {
3968        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, statusReason
3969          , intent, category, priority, doNotPerform, reported, medication, subject, encounter
3970          , supportingInformation, authoredOn, requester, performer, performerType, recorder
3971          , reasonCode, reasonReference, instantiatesCanonical, instantiatesUri, basedOn, groupIdentifier
3972          , courseOfTherapyType, insurance, note, dosageInstruction, dispenseRequest, substitution
3973          , priorPrescription, detectedIssue, eventHistory);
3974      }
3975
3976  @Override
3977  public ResourceType getResourceType() {
3978    return ResourceType.MedicationRequest;
3979   }
3980
3981 /**
3982   * Search parameter: <b>requester</b>
3983   * <p>
3984   * Description: <b>Returns prescriptions prescribed by this prescriber</b><br>
3985   * Type: <b>reference</b><br>
3986   * Path: <b>MedicationRequest.requester</b><br>
3987   * </p>
3988   */
3989  @SearchParamDefinition(name="requester", path="MedicationRequest.requester", description="Returns prescriptions prescribed by this prescriber", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={Device.class, Organization.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class } )
3990  public static final String SP_REQUESTER = "requester";
3991 /**
3992   * <b>Fluent Client</b> search parameter constant for <b>requester</b>
3993   * <p>
3994   * Description: <b>Returns prescriptions prescribed by this prescriber</b><br>
3995   * Type: <b>reference</b><br>
3996   * Path: <b>MedicationRequest.requester</b><br>
3997   * </p>
3998   */
3999  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam REQUESTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_REQUESTER);
4000
4001/**
4002   * Constant for fluent queries to be used to add include statements. Specifies
4003   * the path value of "<b>MedicationRequest:requester</b>".
4004   */
4005  public static final ca.uhn.fhir.model.api.Include INCLUDE_REQUESTER = new ca.uhn.fhir.model.api.Include("MedicationRequest:requester").toLocked();
4006
4007 /**
4008   * Search parameter: <b>date</b>
4009   * <p>
4010   * Description: <b>Returns medication request to be administered on a specific date</b><br>
4011   * Type: <b>date</b><br>
4012   * Path: <b>MedicationRequest.dosageInstruction.timing.event</b><br>
4013   * </p>
4014   */
4015  @SearchParamDefinition(name="date", path="MedicationRequest.dosageInstruction.timing.event", description="Returns medication request to be administered on a specific date", type="date" )
4016  public static final String SP_DATE = "date";
4017 /**
4018   * <b>Fluent Client</b> search parameter constant for <b>date</b>
4019   * <p>
4020   * Description: <b>Returns medication request to be administered on a specific date</b><br>
4021   * Type: <b>date</b><br>
4022   * Path: <b>MedicationRequest.dosageInstruction.timing.event</b><br>
4023   * </p>
4024   */
4025  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
4026
4027 /**
4028   * Search parameter: <b>identifier</b>
4029   * <p>
4030   * Description: <b>Return prescriptions with this external identifier</b><br>
4031   * Type: <b>token</b><br>
4032   * Path: <b>MedicationRequest.identifier</b><br>
4033   * </p>
4034   */
4035  @SearchParamDefinition(name="identifier", path="MedicationRequest.identifier", description="Return prescriptions with this external identifier", type="token" )
4036  public static final String SP_IDENTIFIER = "identifier";
4037 /**
4038   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
4039   * <p>
4040   * Description: <b>Return prescriptions with this external identifier</b><br>
4041   * Type: <b>token</b><br>
4042   * Path: <b>MedicationRequest.identifier</b><br>
4043   * </p>
4044   */
4045  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
4046
4047 /**
4048   * Search parameter: <b>intended-dispenser</b>
4049   * <p>
4050   * Description: <b>Returns prescriptions intended to be dispensed by this Organization</b><br>
4051   * Type: <b>reference</b><br>
4052   * Path: <b>MedicationRequest.dispenseRequest.performer</b><br>
4053   * </p>
4054   */
4055  @SearchParamDefinition(name="intended-dispenser", path="MedicationRequest.dispenseRequest.performer", description="Returns prescriptions intended to be dispensed by this Organization", type="reference", target={Organization.class } )
4056  public static final String SP_INTENDED_DISPENSER = "intended-dispenser";
4057 /**
4058   * <b>Fluent Client</b> search parameter constant for <b>intended-dispenser</b>
4059   * <p>
4060   * Description: <b>Returns prescriptions intended to be dispensed by this Organization</b><br>
4061   * Type: <b>reference</b><br>
4062   * Path: <b>MedicationRequest.dispenseRequest.performer</b><br>
4063   * </p>
4064   */
4065  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam INTENDED_DISPENSER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_INTENDED_DISPENSER);
4066
4067/**
4068   * Constant for fluent queries to be used to add include statements. Specifies
4069   * the path value of "<b>MedicationRequest:intended-dispenser</b>".
4070   */
4071  public static final ca.uhn.fhir.model.api.Include INCLUDE_INTENDED_DISPENSER = new ca.uhn.fhir.model.api.Include("MedicationRequest:intended-dispenser").toLocked();
4072
4073 /**
4074   * Search parameter: <b>authoredon</b>
4075   * <p>
4076   * Description: <b>Return prescriptions written on this date</b><br>
4077   * Type: <b>date</b><br>
4078   * Path: <b>MedicationRequest.authoredOn</b><br>
4079   * </p>
4080   */
4081  @SearchParamDefinition(name="authoredon", path="MedicationRequest.authoredOn", description="Return prescriptions written on this date", type="date" )
4082  public static final String SP_AUTHOREDON = "authoredon";
4083 /**
4084   * <b>Fluent Client</b> search parameter constant for <b>authoredon</b>
4085   * <p>
4086   * Description: <b>Return prescriptions written on this date</b><br>
4087   * Type: <b>date</b><br>
4088   * Path: <b>MedicationRequest.authoredOn</b><br>
4089   * </p>
4090   */
4091  public static final ca.uhn.fhir.rest.gclient.DateClientParam AUTHOREDON = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_AUTHOREDON);
4092
4093 /**
4094   * Search parameter: <b>code</b>
4095   * <p>
4096   * Description: <b>Return prescriptions of this medication code</b><br>
4097   * Type: <b>token</b><br>
4098   * Path: <b>MedicationRequest.medicationCodeableConcept</b><br>
4099   * </p>
4100   */
4101  @SearchParamDefinition(name="code", path="(MedicationRequest.medication as CodeableConcept)", description="Return prescriptions of this medication code", type="token" )
4102  public static final String SP_CODE = "code";
4103 /**
4104   * <b>Fluent Client</b> search parameter constant for <b>code</b>
4105   * <p>
4106   * Description: <b>Return prescriptions of this medication code</b><br>
4107   * Type: <b>token</b><br>
4108   * Path: <b>MedicationRequest.medicationCodeableConcept</b><br>
4109   * </p>
4110   */
4111  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
4112
4113 /**
4114   * Search parameter: <b>subject</b>
4115   * <p>
4116   * Description: <b>The identity of a patient to list orders  for</b><br>
4117   * Type: <b>reference</b><br>
4118   * Path: <b>MedicationRequest.subject</b><br>
4119   * </p>
4120   */
4121  @SearchParamDefinition(name="subject", path="MedicationRequest.subject", description="The identity of a patient to list orders  for", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Group.class, Patient.class } )
4122  public static final String SP_SUBJECT = "subject";
4123 /**
4124   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
4125   * <p>
4126   * Description: <b>The identity of a patient to list orders  for</b><br>
4127   * Type: <b>reference</b><br>
4128   * Path: <b>MedicationRequest.subject</b><br>
4129   * </p>
4130   */
4131  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
4132
4133/**
4134   * Constant for fluent queries to be used to add include statements. Specifies
4135   * the path value of "<b>MedicationRequest:subject</b>".
4136   */
4137  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("MedicationRequest:subject").toLocked();
4138
4139 /**
4140   * Search parameter: <b>medication</b>
4141   * <p>
4142   * Description: <b>Return prescriptions for this medication reference</b><br>
4143   * Type: <b>reference</b><br>
4144   * Path: <b>MedicationRequest.medicationReference</b><br>
4145   * </p>
4146   */
4147  @SearchParamDefinition(name="medication", path="(MedicationRequest.medication as Reference)", description="Return prescriptions for this medication reference", type="reference", target={Medication.class } )
4148  public static final String SP_MEDICATION = "medication";
4149 /**
4150   * <b>Fluent Client</b> search parameter constant for <b>medication</b>
4151   * <p>
4152   * Description: <b>Return prescriptions for this medication reference</b><br>
4153   * Type: <b>reference</b><br>
4154   * Path: <b>MedicationRequest.medicationReference</b><br>
4155   * </p>
4156   */
4157  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam MEDICATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_MEDICATION);
4158
4159/**
4160   * Constant for fluent queries to be used to add include statements. Specifies
4161   * the path value of "<b>MedicationRequest:medication</b>".
4162   */
4163  public static final ca.uhn.fhir.model.api.Include INCLUDE_MEDICATION = new ca.uhn.fhir.model.api.Include("MedicationRequest:medication").toLocked();
4164
4165 /**
4166   * Search parameter: <b>encounter</b>
4167   * <p>
4168   * Description: <b>Return prescriptions with this encounter identifier</b><br>
4169   * Type: <b>reference</b><br>
4170   * Path: <b>MedicationRequest.encounter</b><br>
4171   * </p>
4172   */
4173  @SearchParamDefinition(name="encounter", path="MedicationRequest.encounter", description="Return prescriptions with this encounter identifier", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Encounter") }, target={Encounter.class } )
4174  public static final String SP_ENCOUNTER = "encounter";
4175 /**
4176   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
4177   * <p>
4178   * Description: <b>Return prescriptions with this encounter identifier</b><br>
4179   * Type: <b>reference</b><br>
4180   * Path: <b>MedicationRequest.encounter</b><br>
4181   * </p>
4182   */
4183  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
4184
4185/**
4186   * Constant for fluent queries to be used to add include statements. Specifies
4187   * the path value of "<b>MedicationRequest:encounter</b>".
4188   */
4189  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("MedicationRequest:encounter").toLocked();
4190
4191 /**
4192   * Search parameter: <b>priority</b>
4193   * <p>
4194   * Description: <b>Returns prescriptions with different priorities</b><br>
4195   * Type: <b>token</b><br>
4196   * Path: <b>MedicationRequest.priority</b><br>
4197   * </p>
4198   */
4199  @SearchParamDefinition(name="priority", path="MedicationRequest.priority", description="Returns prescriptions with different priorities", type="token" )
4200  public static final String SP_PRIORITY = "priority";
4201 /**
4202   * <b>Fluent Client</b> search parameter constant for <b>priority</b>
4203   * <p>
4204   * Description: <b>Returns prescriptions with different priorities</b><br>
4205   * Type: <b>token</b><br>
4206   * Path: <b>MedicationRequest.priority</b><br>
4207   * </p>
4208   */
4209  public static final ca.uhn.fhir.rest.gclient.TokenClientParam PRIORITY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_PRIORITY);
4210
4211 /**
4212   * Search parameter: <b>intent</b>
4213   * <p>
4214   * Description: <b>Returns prescriptions with different intents</b><br>
4215   * Type: <b>token</b><br>
4216   * Path: <b>MedicationRequest.intent</b><br>
4217   * </p>
4218   */
4219  @SearchParamDefinition(name="intent", path="MedicationRequest.intent", description="Returns prescriptions with different intents", type="token" )
4220  public static final String SP_INTENT = "intent";
4221 /**
4222   * <b>Fluent Client</b> search parameter constant for <b>intent</b>
4223   * <p>
4224   * Description: <b>Returns prescriptions with different intents</b><br>
4225   * Type: <b>token</b><br>
4226   * Path: <b>MedicationRequest.intent</b><br>
4227   * </p>
4228   */
4229  public static final ca.uhn.fhir.rest.gclient.TokenClientParam INTENT = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_INTENT);
4230
4231 /**
4232   * Search parameter: <b>patient</b>
4233   * <p>
4234   * Description: <b>Returns prescriptions for a specific patient</b><br>
4235   * Type: <b>reference</b><br>
4236   * Path: <b>MedicationRequest.subject</b><br>
4237   * </p>
4238   */
4239  @SearchParamDefinition(name="patient", path="MedicationRequest.subject.where(resolve() is Patient)", description="Returns prescriptions for a specific patient", type="reference", target={Patient.class } )
4240  public static final String SP_PATIENT = "patient";
4241 /**
4242   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
4243   * <p>
4244   * Description: <b>Returns prescriptions for a specific patient</b><br>
4245   * Type: <b>reference</b><br>
4246   * Path: <b>MedicationRequest.subject</b><br>
4247   * </p>
4248   */
4249  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
4250
4251/**
4252   * Constant for fluent queries to be used to add include statements. Specifies
4253   * the path value of "<b>MedicationRequest:patient</b>".
4254   */
4255  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("MedicationRequest:patient").toLocked();
4256
4257 /**
4258   * Search parameter: <b>intended-performer</b>
4259   * <p>
4260   * Description: <b>Returns the intended performer of the administration of the medication request</b><br>
4261   * Type: <b>reference</b><br>
4262   * Path: <b>MedicationRequest.performer</b><br>
4263   * </p>
4264   */
4265  @SearchParamDefinition(name="intended-performer", path="MedicationRequest.performer", description="Returns the intended performer of the administration of the medication request", type="reference", target={CareTeam.class, Device.class, Organization.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class } )
4266  public static final String SP_INTENDED_PERFORMER = "intended-performer";
4267 /**
4268   * <b>Fluent Client</b> search parameter constant for <b>intended-performer</b>
4269   * <p>
4270   * Description: <b>Returns the intended performer of the administration of the medication request</b><br>
4271   * Type: <b>reference</b><br>
4272   * Path: <b>MedicationRequest.performer</b><br>
4273   * </p>
4274   */
4275  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam INTENDED_PERFORMER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_INTENDED_PERFORMER);
4276
4277/**
4278   * Constant for fluent queries to be used to add include statements. Specifies
4279   * the path value of "<b>MedicationRequest:intended-performer</b>".
4280   */
4281  public static final ca.uhn.fhir.model.api.Include INCLUDE_INTENDED_PERFORMER = new ca.uhn.fhir.model.api.Include("MedicationRequest:intended-performer").toLocked();
4282
4283 /**
4284   * Search parameter: <b>intended-performertype</b>
4285   * <p>
4286   * Description: <b>Returns requests for a specific type of performer</b><br>
4287   * Type: <b>token</b><br>
4288   * Path: <b>MedicationRequest.performerType</b><br>
4289   * </p>
4290   */
4291  @SearchParamDefinition(name="intended-performertype", path="MedicationRequest.performerType", description="Returns requests for a specific type of performer", type="token" )
4292  public static final String SP_INTENDED_PERFORMERTYPE = "intended-performertype";
4293 /**
4294   * <b>Fluent Client</b> search parameter constant for <b>intended-performertype</b>
4295   * <p>
4296   * Description: <b>Returns requests for a specific type of performer</b><br>
4297   * Type: <b>token</b><br>
4298   * Path: <b>MedicationRequest.performerType</b><br>
4299   * </p>
4300   */
4301  public static final ca.uhn.fhir.rest.gclient.TokenClientParam INTENDED_PERFORMERTYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_INTENDED_PERFORMERTYPE);
4302
4303 /**
4304   * Search parameter: <b>category</b>
4305   * <p>
4306   * Description: <b>Returns prescriptions with different categories</b><br>
4307   * Type: <b>token</b><br>
4308   * Path: <b>MedicationRequest.category</b><br>
4309   * </p>
4310   */
4311  @SearchParamDefinition(name="category", path="MedicationRequest.category", description="Returns prescriptions with different categories", type="token" )
4312  public static final String SP_CATEGORY = "category";
4313 /**
4314   * <b>Fluent Client</b> search parameter constant for <b>category</b>
4315   * <p>
4316   * Description: <b>Returns prescriptions with different categories</b><br>
4317   * Type: <b>token</b><br>
4318   * Path: <b>MedicationRequest.category</b><br>
4319   * </p>
4320   */
4321  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CATEGORY);
4322
4323 /**
4324   * Search parameter: <b>status</b>
4325   * <p>
4326   * Description: <b>Status of the prescription</b><br>
4327   * Type: <b>token</b><br>
4328   * Path: <b>MedicationRequest.status</b><br>
4329   * </p>
4330   */
4331  @SearchParamDefinition(name="status", path="MedicationRequest.status", description="Status of the prescription", type="token" )
4332  public static final String SP_STATUS = "status";
4333 /**
4334   * <b>Fluent Client</b> search parameter constant for <b>status</b>
4335   * <p>
4336   * Description: <b>Status of the prescription</b><br>
4337   * Type: <b>token</b><br>
4338   * Path: <b>MedicationRequest.status</b><br>
4339   * </p>
4340   */
4341  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
4342
4343
4344}