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