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