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