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