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 Sun, May 6, 2018 17:51-0400 for FHIR v3.4.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/Profile/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', i.e. it is a work in progress, requires sign-off or verification, and 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', i.e. it is a work in progress, requires sign-off or verification, and 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 intension 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 intension 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         * This indicates the validity period of a prescription (stale dating the Prescription).
523         */
524        @Child(name = "validityPeriod", type = {Period.class}, order=1, min=0, max=1, modifier=false, summary=false)
525        @Description(shortDefinition="Time period supply is authorized for", formalDefinition="This indicates the validity period of a prescription (stale dating the Prescription)." )
526        protected Period validityPeriod;
527
528        /**
529         * 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.
530         */
531        @Child(name = "numberOfRepeatsAllowed", type = {UnsignedIntType.class}, order=2, min=0, max=1, modifier=false, summary=false)
532        @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." )
533        protected UnsignedIntType numberOfRepeatsAllowed;
534
535        /**
536         * The amount that is to be dispensed for one fill.
537         */
538        @Child(name = "quantity", type = {SimpleQuantity.class}, order=3, min=0, max=1, modifier=false, summary=false)
539        @Description(shortDefinition="Amount of medication to supply per dispense", formalDefinition="The amount that is to be dispensed for one fill." )
540        protected SimpleQuantity quantity;
541
542        /**
543         * 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.
544         */
545        @Child(name = "expectedSupplyDuration", type = {Duration.class}, order=4, min=0, max=1, modifier=false, summary=false)
546        @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." )
547        protected Duration expectedSupplyDuration;
548
549        /**
550         * Indicates the intended dispensing Organization specified by the prescriber.
551         */
552        @Child(name = "performer", type = {Organization.class}, order=5, min=0, max=1, modifier=false, summary=false)
553        @Description(shortDefinition="Intended dispenser", formalDefinition="Indicates the intended dispensing Organization specified by the prescriber." )
554        protected Reference performer;
555
556        /**
557         * The actual object that is the target of the reference (Indicates the intended dispensing Organization specified by the prescriber.)
558         */
559        protected Organization performerTarget;
560
561        private static final long serialVersionUID = 1831412722L;
562
563    /**
564     * Constructor
565     */
566      public MedicationRequestDispenseRequestComponent() {
567        super();
568      }
569
570        /**
571         * @return {@link #validityPeriod} (This indicates the validity period of a prescription (stale dating the Prescription).)
572         */
573        public Period getValidityPeriod() { 
574          if (this.validityPeriod == null)
575            if (Configuration.errorOnAutoCreate())
576              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.validityPeriod");
577            else if (Configuration.doAutoCreate())
578              this.validityPeriod = new Period(); // cc
579          return this.validityPeriod;
580        }
581
582        public boolean hasValidityPeriod() { 
583          return this.validityPeriod != null && !this.validityPeriod.isEmpty();
584        }
585
586        /**
587         * @param value {@link #validityPeriod} (This indicates the validity period of a prescription (stale dating the Prescription).)
588         */
589        public MedicationRequestDispenseRequestComponent setValidityPeriod(Period value) { 
590          this.validityPeriod = value;
591          return this;
592        }
593
594        /**
595         * @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
596         */
597        public UnsignedIntType getNumberOfRepeatsAllowedElement() { 
598          if (this.numberOfRepeatsAllowed == null)
599            if (Configuration.errorOnAutoCreate())
600              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.numberOfRepeatsAllowed");
601            else if (Configuration.doAutoCreate())
602              this.numberOfRepeatsAllowed = new UnsignedIntType(); // bb
603          return this.numberOfRepeatsAllowed;
604        }
605
606        public boolean hasNumberOfRepeatsAllowedElement() { 
607          return this.numberOfRepeatsAllowed != null && !this.numberOfRepeatsAllowed.isEmpty();
608        }
609
610        public boolean hasNumberOfRepeatsAllowed() { 
611          return this.numberOfRepeatsAllowed != null && !this.numberOfRepeatsAllowed.isEmpty();
612        }
613
614        /**
615         * @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
616         */
617        public MedicationRequestDispenseRequestComponent setNumberOfRepeatsAllowedElement(UnsignedIntType value) { 
618          this.numberOfRepeatsAllowed = value;
619          return this;
620        }
621
622        /**
623         * @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.
624         */
625        public int getNumberOfRepeatsAllowed() { 
626          return this.numberOfRepeatsAllowed == null || this.numberOfRepeatsAllowed.isEmpty() ? 0 : this.numberOfRepeatsAllowed.getValue();
627        }
628
629        /**
630         * @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.
631         */
632        public MedicationRequestDispenseRequestComponent setNumberOfRepeatsAllowed(int value) { 
633            if (this.numberOfRepeatsAllowed == null)
634              this.numberOfRepeatsAllowed = new UnsignedIntType();
635            this.numberOfRepeatsAllowed.setValue(value);
636          return this;
637        }
638
639        /**
640         * @return {@link #quantity} (The amount that is to be dispensed for one fill.)
641         */
642        public SimpleQuantity getQuantity() { 
643          if (this.quantity == null)
644            if (Configuration.errorOnAutoCreate())
645              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.quantity");
646            else if (Configuration.doAutoCreate())
647              this.quantity = new SimpleQuantity(); // cc
648          return this.quantity;
649        }
650
651        public boolean hasQuantity() { 
652          return this.quantity != null && !this.quantity.isEmpty();
653        }
654
655        /**
656         * @param value {@link #quantity} (The amount that is to be dispensed for one fill.)
657         */
658        public MedicationRequestDispenseRequestComponent setQuantity(SimpleQuantity value) { 
659          this.quantity = value;
660          return this;
661        }
662
663        /**
664         * @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.)
665         */
666        public Duration getExpectedSupplyDuration() { 
667          if (this.expectedSupplyDuration == null)
668            if (Configuration.errorOnAutoCreate())
669              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.expectedSupplyDuration");
670            else if (Configuration.doAutoCreate())
671              this.expectedSupplyDuration = new Duration(); // cc
672          return this.expectedSupplyDuration;
673        }
674
675        public boolean hasExpectedSupplyDuration() { 
676          return this.expectedSupplyDuration != null && !this.expectedSupplyDuration.isEmpty();
677        }
678
679        /**
680         * @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.)
681         */
682        public MedicationRequestDispenseRequestComponent setExpectedSupplyDuration(Duration value) { 
683          this.expectedSupplyDuration = value;
684          return this;
685        }
686
687        /**
688         * @return {@link #performer} (Indicates the intended dispensing Organization specified by the prescriber.)
689         */
690        public Reference getPerformer() { 
691          if (this.performer == null)
692            if (Configuration.errorOnAutoCreate())
693              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.performer");
694            else if (Configuration.doAutoCreate())
695              this.performer = new Reference(); // cc
696          return this.performer;
697        }
698
699        public boolean hasPerformer() { 
700          return this.performer != null && !this.performer.isEmpty();
701        }
702
703        /**
704         * @param value {@link #performer} (Indicates the intended dispensing Organization specified by the prescriber.)
705         */
706        public MedicationRequestDispenseRequestComponent setPerformer(Reference value) { 
707          this.performer = value;
708          return this;
709        }
710
711        /**
712         * @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.)
713         */
714        public Organization getPerformerTarget() { 
715          if (this.performerTarget == null)
716            if (Configuration.errorOnAutoCreate())
717              throw new Error("Attempt to auto-create MedicationRequestDispenseRequestComponent.performer");
718            else if (Configuration.doAutoCreate())
719              this.performerTarget = new Organization(); // aa
720          return this.performerTarget;
721        }
722
723        /**
724         * @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.)
725         */
726        public MedicationRequestDispenseRequestComponent setPerformerTarget(Organization value) { 
727          this.performerTarget = value;
728          return this;
729        }
730
731        protected void listChildren(List<Property> children) {
732          super.listChildren(children);
733          children.add(new Property("validityPeriod", "Period", "This indicates the validity period of a prescription (stale dating the Prescription).", 0, 1, validityPeriod));
734          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));
735          children.add(new Property("quantity", "SimpleQuantity", "The amount that is to be dispensed for one fill.", 0, 1, quantity));
736          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));
737          children.add(new Property("performer", "Reference(Organization)", "Indicates the intended dispensing Organization specified by the prescriber.", 0, 1, performer));
738        }
739
740        @Override
741        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
742          switch (_hash) {
743          case -1434195053: /*validityPeriod*/  return new Property("validityPeriod", "Period", "This indicates the validity period of a prescription (stale dating the Prescription).", 0, 1, validityPeriod);
744          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);
745          case -1285004149: /*quantity*/  return new Property("quantity", "SimpleQuantity", "The amount that is to be dispensed for one fill.", 0, 1, quantity);
746          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);
747          case 481140686: /*performer*/  return new Property("performer", "Reference(Organization)", "Indicates the intended dispensing Organization specified by the prescriber.", 0, 1, performer);
748          default: return super.getNamedProperty(_hash, _name, _checkValid);
749          }
750
751        }
752
753      @Override
754      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
755        switch (hash) {
756        case -1434195053: /*validityPeriod*/ return this.validityPeriod == null ? new Base[0] : new Base[] {this.validityPeriod}; // Period
757        case -239736976: /*numberOfRepeatsAllowed*/ return this.numberOfRepeatsAllowed == null ? new Base[0] : new Base[] {this.numberOfRepeatsAllowed}; // UnsignedIntType
758        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // SimpleQuantity
759        case -1910182789: /*expectedSupplyDuration*/ return this.expectedSupplyDuration == null ? new Base[0] : new Base[] {this.expectedSupplyDuration}; // Duration
760        case 481140686: /*performer*/ return this.performer == null ? new Base[0] : new Base[] {this.performer}; // Reference
761        default: return super.getProperty(hash, name, checkValid);
762        }
763
764      }
765
766      @Override
767      public Base setProperty(int hash, String name, Base value) throws FHIRException {
768        switch (hash) {
769        case -1434195053: // validityPeriod
770          this.validityPeriod = castToPeriod(value); // Period
771          return value;
772        case -239736976: // numberOfRepeatsAllowed
773          this.numberOfRepeatsAllowed = castToUnsignedInt(value); // UnsignedIntType
774          return value;
775        case -1285004149: // quantity
776          this.quantity = castToSimpleQuantity(value); // SimpleQuantity
777          return value;
778        case -1910182789: // expectedSupplyDuration
779          this.expectedSupplyDuration = castToDuration(value); // Duration
780          return value;
781        case 481140686: // performer
782          this.performer = castToReference(value); // Reference
783          return value;
784        default: return super.setProperty(hash, name, value);
785        }
786
787      }
788
789      @Override
790      public Base setProperty(String name, Base value) throws FHIRException {
791        if (name.equals("validityPeriod")) {
792          this.validityPeriod = castToPeriod(value); // Period
793        } else if (name.equals("numberOfRepeatsAllowed")) {
794          this.numberOfRepeatsAllowed = castToUnsignedInt(value); // UnsignedIntType
795        } else if (name.equals("quantity")) {
796          this.quantity = castToSimpleQuantity(value); // SimpleQuantity
797        } else if (name.equals("expectedSupplyDuration")) {
798          this.expectedSupplyDuration = castToDuration(value); // Duration
799        } else if (name.equals("performer")) {
800          this.performer = castToReference(value); // Reference
801        } else
802          return super.setProperty(name, value);
803        return value;
804      }
805
806      @Override
807      public Base makeProperty(int hash, String name) throws FHIRException {
808        switch (hash) {
809        case -1434195053:  return getValidityPeriod(); 
810        case -239736976:  return getNumberOfRepeatsAllowedElement();
811        case -1285004149:  return getQuantity(); 
812        case -1910182789:  return getExpectedSupplyDuration(); 
813        case 481140686:  return getPerformer(); 
814        default: return super.makeProperty(hash, name);
815        }
816
817      }
818
819      @Override
820      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
821        switch (hash) {
822        case -1434195053: /*validityPeriod*/ return new String[] {"Period"};
823        case -239736976: /*numberOfRepeatsAllowed*/ return new String[] {"unsignedInt"};
824        case -1285004149: /*quantity*/ return new String[] {"SimpleQuantity"};
825        case -1910182789: /*expectedSupplyDuration*/ return new String[] {"Duration"};
826        case 481140686: /*performer*/ return new String[] {"Reference"};
827        default: return super.getTypesForProperty(hash, name);
828        }
829
830      }
831
832      @Override
833      public Base addChild(String name) throws FHIRException {
834        if (name.equals("validityPeriod")) {
835          this.validityPeriod = new Period();
836          return this.validityPeriod;
837        }
838        else if (name.equals("numberOfRepeatsAllowed")) {
839          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.numberOfRepeatsAllowed");
840        }
841        else if (name.equals("quantity")) {
842          this.quantity = new SimpleQuantity();
843          return this.quantity;
844        }
845        else if (name.equals("expectedSupplyDuration")) {
846          this.expectedSupplyDuration = new Duration();
847          return this.expectedSupplyDuration;
848        }
849        else if (name.equals("performer")) {
850          this.performer = new Reference();
851          return this.performer;
852        }
853        else
854          return super.addChild(name);
855      }
856
857      public MedicationRequestDispenseRequestComponent copy() {
858        MedicationRequestDispenseRequestComponent dst = new MedicationRequestDispenseRequestComponent();
859        copyValues(dst);
860        dst.validityPeriod = validityPeriod == null ? null : validityPeriod.copy();
861        dst.numberOfRepeatsAllowed = numberOfRepeatsAllowed == null ? null : numberOfRepeatsAllowed.copy();
862        dst.quantity = quantity == null ? null : quantity.copy();
863        dst.expectedSupplyDuration = expectedSupplyDuration == null ? null : expectedSupplyDuration.copy();
864        dst.performer = performer == null ? null : performer.copy();
865        return dst;
866      }
867
868      @Override
869      public boolean equalsDeep(Base other_) {
870        if (!super.equalsDeep(other_))
871          return false;
872        if (!(other_ instanceof MedicationRequestDispenseRequestComponent))
873          return false;
874        MedicationRequestDispenseRequestComponent o = (MedicationRequestDispenseRequestComponent) other_;
875        return compareDeep(validityPeriod, o.validityPeriod, true) && compareDeep(numberOfRepeatsAllowed, o.numberOfRepeatsAllowed, true)
876           && compareDeep(quantity, o.quantity, true) && compareDeep(expectedSupplyDuration, o.expectedSupplyDuration, true)
877           && compareDeep(performer, o.performer, true);
878      }
879
880      @Override
881      public boolean equalsShallow(Base other_) {
882        if (!super.equalsShallow(other_))
883          return false;
884        if (!(other_ instanceof MedicationRequestDispenseRequestComponent))
885          return false;
886        MedicationRequestDispenseRequestComponent o = (MedicationRequestDispenseRequestComponent) other_;
887        return compareValues(numberOfRepeatsAllowed, o.numberOfRepeatsAllowed, true);
888      }
889
890      public boolean isEmpty() {
891        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(validityPeriod, numberOfRepeatsAllowed
892          , quantity, expectedSupplyDuration, performer);
893      }
894
895  public String fhirType() {
896    return "MedicationRequest.dispenseRequest";
897
898  }
899
900  }
901
902    @Block()
903    public static class MedicationRequestSubstitutionComponent extends BackboneElement implements IBaseBackboneElement {
904        /**
905         * True if the prescriber allows a different drug to be dispensed from what was prescribed.
906         */
907        @Child(name = "allowed", type = {BooleanType.class}, order=1, min=1, max=1, modifier=true, summary=false)
908        @Description(shortDefinition="Whether substitution is allowed or not", formalDefinition="True if the prescriber allows a different drug to be dispensed from what was prescribed." )
909        protected BooleanType allowed;
910
911        /**
912         * Indicates the reason for the substitution, or why substitution must or must not be performed.
913         */
914        @Child(name = "reason", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
915        @Description(shortDefinition="Why should (not) substitution be made", formalDefinition="Indicates the reason for the substitution, or why substitution must or must not be performed." )
916        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/v3-SubstanceAdminSubstitutionReason")
917        protected CodeableConcept reason;
918
919        private static final long serialVersionUID = -141547037L;
920
921    /**
922     * Constructor
923     */
924      public MedicationRequestSubstitutionComponent() {
925        super();
926      }
927
928    /**
929     * Constructor
930     */
931      public MedicationRequestSubstitutionComponent(BooleanType allowed) {
932        super();
933        this.allowed = allowed;
934      }
935
936        /**
937         * @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
938         */
939        public BooleanType getAllowedElement() { 
940          if (this.allowed == null)
941            if (Configuration.errorOnAutoCreate())
942              throw new Error("Attempt to auto-create MedicationRequestSubstitutionComponent.allowed");
943            else if (Configuration.doAutoCreate())
944              this.allowed = new BooleanType(); // bb
945          return this.allowed;
946        }
947
948        public boolean hasAllowedElement() { 
949          return this.allowed != null && !this.allowed.isEmpty();
950        }
951
952        public boolean hasAllowed() { 
953          return this.allowed != null && !this.allowed.isEmpty();
954        }
955
956        /**
957         * @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
958         */
959        public MedicationRequestSubstitutionComponent setAllowedElement(BooleanType value) { 
960          this.allowed = value;
961          return this;
962        }
963
964        /**
965         * @return True if the prescriber allows a different drug to be dispensed from what was prescribed.
966         */
967        public boolean getAllowed() { 
968          return this.allowed == null || this.allowed.isEmpty() ? false : this.allowed.getValue();
969        }
970
971        /**
972         * @param value True if the prescriber allows a different drug to be dispensed from what was prescribed.
973         */
974        public MedicationRequestSubstitutionComponent setAllowed(boolean value) { 
975            if (this.allowed == null)
976              this.allowed = new BooleanType();
977            this.allowed.setValue(value);
978          return this;
979        }
980
981        /**
982         * @return {@link #reason} (Indicates the reason for the substitution, or why substitution must or must not be performed.)
983         */
984        public CodeableConcept getReason() { 
985          if (this.reason == null)
986            if (Configuration.errorOnAutoCreate())
987              throw new Error("Attempt to auto-create MedicationRequestSubstitutionComponent.reason");
988            else if (Configuration.doAutoCreate())
989              this.reason = new CodeableConcept(); // cc
990          return this.reason;
991        }
992
993        public boolean hasReason() { 
994          return this.reason != null && !this.reason.isEmpty();
995        }
996
997        /**
998         * @param value {@link #reason} (Indicates the reason for the substitution, or why substitution must or must not be performed.)
999         */
1000        public MedicationRequestSubstitutionComponent setReason(CodeableConcept value) { 
1001          this.reason = value;
1002          return this;
1003        }
1004
1005        protected void listChildren(List<Property> children) {
1006          super.listChildren(children);
1007          children.add(new Property("allowed", "boolean", "True if the prescriber allows a different drug to be dispensed from what was prescribed.", 0, 1, allowed));
1008          children.add(new Property("reason", "CodeableConcept", "Indicates the reason for the substitution, or why substitution must or must not be performed.", 0, 1, reason));
1009        }
1010
1011        @Override
1012        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1013          switch (_hash) {
1014          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);
1015          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);
1016          default: return super.getNamedProperty(_hash, _name, _checkValid);
1017          }
1018
1019        }
1020
1021      @Override
1022      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1023        switch (hash) {
1024        case -911343192: /*allowed*/ return this.allowed == null ? new Base[0] : new Base[] {this.allowed}; // BooleanType
1025        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : new Base[] {this.reason}; // CodeableConcept
1026        default: return super.getProperty(hash, name, checkValid);
1027        }
1028
1029      }
1030
1031      @Override
1032      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1033        switch (hash) {
1034        case -911343192: // allowed
1035          this.allowed = castToBoolean(value); // BooleanType
1036          return value;
1037        case -934964668: // reason
1038          this.reason = castToCodeableConcept(value); // CodeableConcept
1039          return value;
1040        default: return super.setProperty(hash, name, value);
1041        }
1042
1043      }
1044
1045      @Override
1046      public Base setProperty(String name, Base value) throws FHIRException {
1047        if (name.equals("allowed")) {
1048          this.allowed = castToBoolean(value); // BooleanType
1049        } else if (name.equals("reason")) {
1050          this.reason = castToCodeableConcept(value); // CodeableConcept
1051        } else
1052          return super.setProperty(name, value);
1053        return value;
1054      }
1055
1056      @Override
1057      public Base makeProperty(int hash, String name) throws FHIRException {
1058        switch (hash) {
1059        case -911343192:  return getAllowedElement();
1060        case -934964668:  return getReason(); 
1061        default: return super.makeProperty(hash, name);
1062        }
1063
1064      }
1065
1066      @Override
1067      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1068        switch (hash) {
1069        case -911343192: /*allowed*/ return new String[] {"boolean"};
1070        case -934964668: /*reason*/ return new String[] {"CodeableConcept"};
1071        default: return super.getTypesForProperty(hash, name);
1072        }
1073
1074      }
1075
1076      @Override
1077      public Base addChild(String name) throws FHIRException {
1078        if (name.equals("allowed")) {
1079          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.allowed");
1080        }
1081        else if (name.equals("reason")) {
1082          this.reason = new CodeableConcept();
1083          return this.reason;
1084        }
1085        else
1086          return super.addChild(name);
1087      }
1088
1089      public MedicationRequestSubstitutionComponent copy() {
1090        MedicationRequestSubstitutionComponent dst = new MedicationRequestSubstitutionComponent();
1091        copyValues(dst);
1092        dst.allowed = allowed == null ? null : allowed.copy();
1093        dst.reason = reason == null ? null : reason.copy();
1094        return dst;
1095      }
1096
1097      @Override
1098      public boolean equalsDeep(Base other_) {
1099        if (!super.equalsDeep(other_))
1100          return false;
1101        if (!(other_ instanceof MedicationRequestSubstitutionComponent))
1102          return false;
1103        MedicationRequestSubstitutionComponent o = (MedicationRequestSubstitutionComponent) other_;
1104        return compareDeep(allowed, o.allowed, true) && compareDeep(reason, o.reason, true);
1105      }
1106
1107      @Override
1108      public boolean equalsShallow(Base other_) {
1109        if (!super.equalsShallow(other_))
1110          return false;
1111        if (!(other_ instanceof MedicationRequestSubstitutionComponent))
1112          return false;
1113        MedicationRequestSubstitutionComponent o = (MedicationRequestSubstitutionComponent) other_;
1114        return compareValues(allowed, o.allowed, true);
1115      }
1116
1117      public boolean isEmpty() {
1118        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(allowed, reason);
1119      }
1120
1121  public String fhirType() {
1122    return "MedicationRequest.substitution";
1123
1124  }
1125
1126  }
1127
1128    /**
1129     * 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.
1130     */
1131    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1132    @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." )
1133    protected List<Identifier> identifier;
1134
1135    /**
1136     * A code specifying the current state of the order.  Generally, this will be active or completed state.
1137     */
1138    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
1139    @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." )
1140    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-request-status")
1141    protected Enumeration<MedicationRequestStatus> status;
1142
1143    /**
1144     * Whether the request is a proposal, plan, or an original order.
1145     */
1146    @Child(name = "intent", type = {CodeType.class}, order=2, min=1, max=1, modifier=true, summary=true)
1147    @Description(shortDefinition="proposal | plan | order | original-order | instance-order | option", formalDefinition="Whether the request is a proposal, plan, or an original order." )
1148    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-request-intent")
1149    protected Enumeration<MedicationRequestIntent> intent;
1150
1151    /**
1152     * Indicates the type of medication request (for example, where the medication is expected to be consumed or administered (i.e. inpatient or outpatient) or the type of treatment (i.e. chemotherapy or endocrine).
1153     */
1154    @Child(name = "category", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1155    @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) or the type of treatment (i.e. chemotherapy or endocrine)." )
1156    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-request-category")
1157    protected List<CodeableConcept> category;
1158
1159    /**
1160     * Indicates how quickly the Medication Request should be addressed with respect to other requests.
1161     */
1162    @Child(name = "priority", type = {CodeType.class}, order=4, min=0, max=1, modifier=false, summary=true)
1163    @Description(shortDefinition="routine | urgent | asap | stat", formalDefinition="Indicates how quickly the Medication Request should be addressed with respect to other requests." )
1164    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/request-priority")
1165    protected Enumeration<MedicationRequestPriority> priority;
1166
1167    /**
1168     * 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.
1169     */
1170    @Child(name = "medication", type = {CodeableConcept.class, Medication.class}, order=5, min=1, max=1, modifier=false, summary=true)
1171    @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." )
1172    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-codes")
1173    protected Type medication;
1174
1175    /**
1176     * A link to a resource representing the person or set of individuals to whom the medication will be given.
1177     */
1178    @Child(name = "subject", type = {Patient.class, Group.class}, order=6, min=1, max=1, modifier=false, summary=true)
1179    @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." )
1180    protected Reference subject;
1181
1182    /**
1183     * 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.)
1184     */
1185    protected Resource subjectTarget;
1186
1187    /**
1188     * 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.
1189     */
1190    @Child(name = "context", type = {Encounter.class, EpisodeOfCare.class}, order=7, min=0, max=1, modifier=false, summary=false)
1191    @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." )
1192    protected Reference context;
1193
1194    /**
1195     * 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.)
1196     */
1197    protected Resource contextTarget;
1198
1199    /**
1200     * Include additional information (for example, patient height and weight) that supports the ordering of the medication.
1201     */
1202    @Child(name = "supportingInformation", type = {Reference.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1203    @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." )
1204    protected List<Reference> supportingInformation;
1205    /**
1206     * 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.)
1207     */
1208    protected List<Resource> supportingInformationTarget;
1209
1210
1211    /**
1212     * The date (and perhaps time) when the prescription was initially written or authored on.
1213     */
1214    @Child(name = "authoredOn", type = {DateTimeType.class}, order=9, min=0, max=1, modifier=false, summary=true)
1215    @Description(shortDefinition="When request was initially authored", formalDefinition="The date (and perhaps time) when the prescription was initially written or authored on." )
1216    protected DateTimeType authoredOn;
1217
1218    /**
1219     * The individual, organization, or device that initiated the request and has responsibility for its activation.
1220     */
1221    @Child(name = "requester", type = {Practitioner.class, PractitionerRole.class, Organization.class, Patient.class, RelatedPerson.class, Device.class}, order=10, min=0, max=1, modifier=false, summary=true)
1222    @Description(shortDefinition="Who/What requested the Request", formalDefinition="The individual, organization, or device that initiated the request and has responsibility for its activation." )
1223    protected Reference requester;
1224
1225    /**
1226     * 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.)
1227     */
1228    protected Resource requesterTarget;
1229
1230    /**
1231     * The specified desired performer of the medication treatment (e.g. the performer of the medication administration).
1232     */
1233    @Child(name = "performer", type = {Practitioner.class, PractitionerRole.class, Organization.class, Patient.class, Device.class, RelatedPerson.class, CareTeam.class}, order=11, min=0, max=1, modifier=false, summary=false)
1234    @Description(shortDefinition="Intended performer of administration", formalDefinition="The specified desired performer of the medication treatment (e.g. the performer of the medication administration)." )
1235    protected Reference performer;
1236
1237    /**
1238     * 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).)
1239     */
1240    protected Resource performerTarget;
1241
1242    /**
1243     * Indicates the type of performer of the administration of the medication.
1244     */
1245    @Child(name = "performerType", type = {CodeableConcept.class}, order=12, min=0, max=1, modifier=false, summary=true)
1246    @Description(shortDefinition="Desired kind of performer of the medication administration", formalDefinition="Indicates the type of performer of the administration of the medication." )
1247    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/performer-role")
1248    protected CodeableConcept performerType;
1249
1250    /**
1251     * The person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.
1252     */
1253    @Child(name = "recorder", type = {Practitioner.class}, order=13, min=0, max=1, modifier=false, summary=false)
1254    @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." )
1255    protected Reference recorder;
1256
1257    /**
1258     * 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.)
1259     */
1260    protected Practitioner recorderTarget;
1261
1262    /**
1263     * The reason or the indication for ordering the medication.
1264     */
1265    @Child(name = "reasonCode", type = {CodeableConcept.class}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1266    @Description(shortDefinition="Reason or indication for writing the prescription", formalDefinition="The reason or the indication for ordering the medication." )
1267    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/condition-code")
1268    protected List<CodeableConcept> reasonCode;
1269
1270    /**
1271     * Condition or observation that supports why the medication was ordered.
1272     */
1273    @Child(name = "reasonReference", type = {Condition.class, Observation.class}, order=15, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1274    @Description(shortDefinition="Condition or observation that supports why the prescription is being written", formalDefinition="Condition or observation that supports why the medication was ordered." )
1275    protected List<Reference> reasonReference;
1276    /**
1277     * The actual objects that are the target of the reference (Condition or observation that supports why the medication was ordered.)
1278     */
1279    protected List<Resource> reasonReferenceTarget;
1280
1281
1282    /**
1283     * The URL pointing to a protocol, guideline, orderset, or other definition that is adhered to in whole or in part by this MedicationRequest.
1284     */
1285    @Child(name = "instantiates", type = {UriType.class}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1286    @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." )
1287    protected List<UriType> instantiates;
1288
1289    /**
1290     * A plan or request that is fulfilled in whole or in part by this medication request.
1291     */
1292    @Child(name = "basedOn", type = {CarePlan.class, MedicationRequest.class, ServiceRequest.class}, order=17, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1293    @Description(shortDefinition="What request fulfills", formalDefinition="A plan or request that is fulfilled in whole or in part by this medication request." )
1294    protected List<Reference> basedOn;
1295    /**
1296     * 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.)
1297     */
1298    protected List<Resource> basedOnTarget;
1299
1300
1301    /**
1302     * 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.
1303     */
1304    @Child(name = "groupIdentifier", type = {Identifier.class}, order=18, min=0, max=1, modifier=false, summary=true)
1305    @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." )
1306    protected Identifier groupIdentifier;
1307
1308    /**
1309     * Captures the reason for the current state of the MedicationRequest.
1310     */
1311    @Child(name = "statusReason", type = {CodeableConcept.class}, order=19, min=0, max=1, modifier=false, summary=false)
1312    @Description(shortDefinition="Reason for current status", formalDefinition="Captures the reason for the current state of the MedicationRequest." )
1313    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/med-request-status-reason")
1314    protected CodeableConcept statusReason;
1315
1316    /**
1317     * Insurance plans, coverage extensions, pre-authorizations and/or pre-determinations that may be required for delivering the requested service.
1318     */
1319    @Child(name = "insurance", type = {Coverage.class, ClaimResponse.class}, order=20, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1320    @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." )
1321    protected List<Reference> insurance;
1322    /**
1323     * 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.)
1324     */
1325    protected List<Resource> insuranceTarget;
1326
1327
1328    /**
1329     * Extra information about the prescription that could not be conveyed by the other attributes.
1330     */
1331    @Child(name = "note", type = {Annotation.class}, order=21, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1332    @Description(shortDefinition="Information about the prescription", formalDefinition="Extra information about the prescription that could not be conveyed by the other attributes." )
1333    protected List<Annotation> note;
1334
1335    /**
1336     * Indicates how the medication is to be used by the patient.
1337     */
1338    @Child(name = "dosageInstruction", type = {Dosage.class}, order=22, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1339    @Description(shortDefinition="How the medication should be taken", formalDefinition="Indicates how the medication is to be used by the patient." )
1340    protected List<Dosage> dosageInstruction;
1341
1342    /**
1343     * 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.
1344     */
1345    @Child(name = "dispenseRequest", type = {}, order=23, min=0, max=1, modifier=false, summary=false)
1346    @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." )
1347    protected MedicationRequestDispenseRequestComponent dispenseRequest;
1348
1349    /**
1350     * 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.
1351     */
1352    @Child(name = "substitution", type = {}, order=24, min=0, max=1, modifier=false, summary=false)
1353    @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." )
1354    protected MedicationRequestSubstitutionComponent substitution;
1355
1356    /**
1357     * A link to a resource representing an earlier order related order or prescription.
1358     */
1359    @Child(name = "priorPrescription", type = {MedicationRequest.class}, order=25, min=0, max=1, modifier=false, summary=false)
1360    @Description(shortDefinition="An order/prescription that is being replaced", formalDefinition="A link to a resource representing an earlier order related order or prescription." )
1361    protected Reference priorPrescription;
1362
1363    /**
1364     * The actual object that is the target of the reference (A link to a resource representing an earlier order related order or prescription.)
1365     */
1366    protected MedicationRequest priorPrescriptionTarget;
1367
1368    /**
1369     * 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.
1370     */
1371    @Child(name = "detectedIssue", type = {DetectedIssue.class}, order=26, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1372    @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." )
1373    protected List<Reference> detectedIssue;
1374    /**
1375     * 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.)
1376     */
1377    protected List<DetectedIssue> detectedIssueTarget;
1378
1379
1380    /**
1381     * 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.
1382     */
1383    @Child(name = "eventHistory", type = {Provenance.class}, order=27, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1384    @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." )
1385    protected List<Reference> eventHistory;
1386    /**
1387     * 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.)
1388     */
1389    protected List<Provenance> eventHistoryTarget;
1390
1391
1392    private static final long serialVersionUID = 1982909716L;
1393
1394  /**
1395   * Constructor
1396   */
1397    public MedicationRequest() {
1398      super();
1399    }
1400
1401  /**
1402   * Constructor
1403   */
1404    public MedicationRequest(Enumeration<MedicationRequestStatus> status, Enumeration<MedicationRequestIntent> intent, Type medication, Reference subject) {
1405      super();
1406      this.status = status;
1407      this.intent = intent;
1408      this.medication = medication;
1409      this.subject = subject;
1410    }
1411
1412    /**
1413     * @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.)
1414     */
1415    public List<Identifier> getIdentifier() { 
1416      if (this.identifier == null)
1417        this.identifier = new ArrayList<Identifier>();
1418      return this.identifier;
1419    }
1420
1421    /**
1422     * @return Returns a reference to <code>this</code> for easy method chaining
1423     */
1424    public MedicationRequest setIdentifier(List<Identifier> theIdentifier) { 
1425      this.identifier = theIdentifier;
1426      return this;
1427    }
1428
1429    public boolean hasIdentifier() { 
1430      if (this.identifier == null)
1431        return false;
1432      for (Identifier item : this.identifier)
1433        if (!item.isEmpty())
1434          return true;
1435      return false;
1436    }
1437
1438    public Identifier addIdentifier() { //3
1439      Identifier t = new Identifier();
1440      if (this.identifier == null)
1441        this.identifier = new ArrayList<Identifier>();
1442      this.identifier.add(t);
1443      return t;
1444    }
1445
1446    public MedicationRequest addIdentifier(Identifier t) { //3
1447      if (t == null)
1448        return this;
1449      if (this.identifier == null)
1450        this.identifier = new ArrayList<Identifier>();
1451      this.identifier.add(t);
1452      return this;
1453    }
1454
1455    /**
1456     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
1457     */
1458    public Identifier getIdentifierFirstRep() { 
1459      if (getIdentifier().isEmpty()) {
1460        addIdentifier();
1461      }
1462      return getIdentifier().get(0);
1463    }
1464
1465    /**
1466     * @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
1467     */
1468    public Enumeration<MedicationRequestStatus> getStatusElement() { 
1469      if (this.status == null)
1470        if (Configuration.errorOnAutoCreate())
1471          throw new Error("Attempt to auto-create MedicationRequest.status");
1472        else if (Configuration.doAutoCreate())
1473          this.status = new Enumeration<MedicationRequestStatus>(new MedicationRequestStatusEnumFactory()); // bb
1474      return this.status;
1475    }
1476
1477    public boolean hasStatusElement() { 
1478      return this.status != null && !this.status.isEmpty();
1479    }
1480
1481    public boolean hasStatus() { 
1482      return this.status != null && !this.status.isEmpty();
1483    }
1484
1485    /**
1486     * @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
1487     */
1488    public MedicationRequest setStatusElement(Enumeration<MedicationRequestStatus> value) { 
1489      this.status = value;
1490      return this;
1491    }
1492
1493    /**
1494     * @return A code specifying the current state of the order.  Generally, this will be active or completed state.
1495     */
1496    public MedicationRequestStatus getStatus() { 
1497      return this.status == null ? null : this.status.getValue();
1498    }
1499
1500    /**
1501     * @param value A code specifying the current state of the order.  Generally, this will be active or completed state.
1502     */
1503    public MedicationRequest setStatus(MedicationRequestStatus value) { 
1504        if (this.status == null)
1505          this.status = new Enumeration<MedicationRequestStatus>(new MedicationRequestStatusEnumFactory());
1506        this.status.setValue(value);
1507      return this;
1508    }
1509
1510    /**
1511     * @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
1512     */
1513    public Enumeration<MedicationRequestIntent> getIntentElement() { 
1514      if (this.intent == null)
1515        if (Configuration.errorOnAutoCreate())
1516          throw new Error("Attempt to auto-create MedicationRequest.intent");
1517        else if (Configuration.doAutoCreate())
1518          this.intent = new Enumeration<MedicationRequestIntent>(new MedicationRequestIntentEnumFactory()); // bb
1519      return this.intent;
1520    }
1521
1522    public boolean hasIntentElement() { 
1523      return this.intent != null && !this.intent.isEmpty();
1524    }
1525
1526    public boolean hasIntent() { 
1527      return this.intent != null && !this.intent.isEmpty();
1528    }
1529
1530    /**
1531     * @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
1532     */
1533    public MedicationRequest setIntentElement(Enumeration<MedicationRequestIntent> value) { 
1534      this.intent = value;
1535      return this;
1536    }
1537
1538    /**
1539     * @return Whether the request is a proposal, plan, or an original order.
1540     */
1541    public MedicationRequestIntent getIntent() { 
1542      return this.intent == null ? null : this.intent.getValue();
1543    }
1544
1545    /**
1546     * @param value Whether the request is a proposal, plan, or an original order.
1547     */
1548    public MedicationRequest setIntent(MedicationRequestIntent value) { 
1549        if (this.intent == null)
1550          this.intent = new Enumeration<MedicationRequestIntent>(new MedicationRequestIntentEnumFactory());
1551        this.intent.setValue(value);
1552      return this;
1553    }
1554
1555    /**
1556     * @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) or the type of treatment (i.e. chemotherapy or endocrine).)
1557     */
1558    public List<CodeableConcept> getCategory() { 
1559      if (this.category == null)
1560        this.category = new ArrayList<CodeableConcept>();
1561      return this.category;
1562    }
1563
1564    /**
1565     * @return Returns a reference to <code>this</code> for easy method chaining
1566     */
1567    public MedicationRequest setCategory(List<CodeableConcept> theCategory) { 
1568      this.category = theCategory;
1569      return this;
1570    }
1571
1572    public boolean hasCategory() { 
1573      if (this.category == null)
1574        return false;
1575      for (CodeableConcept item : this.category)
1576        if (!item.isEmpty())
1577          return true;
1578      return false;
1579    }
1580
1581    public CodeableConcept addCategory() { //3
1582      CodeableConcept t = new CodeableConcept();
1583      if (this.category == null)
1584        this.category = new ArrayList<CodeableConcept>();
1585      this.category.add(t);
1586      return t;
1587    }
1588
1589    public MedicationRequest addCategory(CodeableConcept t) { //3
1590      if (t == null)
1591        return this;
1592      if (this.category == null)
1593        this.category = new ArrayList<CodeableConcept>();
1594      this.category.add(t);
1595      return this;
1596    }
1597
1598    /**
1599     * @return The first repetition of repeating field {@link #category}, creating it if it does not already exist
1600     */
1601    public CodeableConcept getCategoryFirstRep() { 
1602      if (getCategory().isEmpty()) {
1603        addCategory();
1604      }
1605      return getCategory().get(0);
1606    }
1607
1608    /**
1609     * @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
1610     */
1611    public Enumeration<MedicationRequestPriority> getPriorityElement() { 
1612      if (this.priority == null)
1613        if (Configuration.errorOnAutoCreate())
1614          throw new Error("Attempt to auto-create MedicationRequest.priority");
1615        else if (Configuration.doAutoCreate())
1616          this.priority = new Enumeration<MedicationRequestPriority>(new MedicationRequestPriorityEnumFactory()); // bb
1617      return this.priority;
1618    }
1619
1620    public boolean hasPriorityElement() { 
1621      return this.priority != null && !this.priority.isEmpty();
1622    }
1623
1624    public boolean hasPriority() { 
1625      return this.priority != null && !this.priority.isEmpty();
1626    }
1627
1628    /**
1629     * @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
1630     */
1631    public MedicationRequest setPriorityElement(Enumeration<MedicationRequestPriority> value) { 
1632      this.priority = value;
1633      return this;
1634    }
1635
1636    /**
1637     * @return Indicates how quickly the Medication Request should be addressed with respect to other requests.
1638     */
1639    public MedicationRequestPriority getPriority() { 
1640      return this.priority == null ? null : this.priority.getValue();
1641    }
1642
1643    /**
1644     * @param value Indicates how quickly the Medication Request should be addressed with respect to other requests.
1645     */
1646    public MedicationRequest setPriority(MedicationRequestPriority value) { 
1647      if (value == null)
1648        this.priority = null;
1649      else {
1650        if (this.priority == null)
1651          this.priority = new Enumeration<MedicationRequestPriority>(new MedicationRequestPriorityEnumFactory());
1652        this.priority.setValue(value);
1653      }
1654      return this;
1655    }
1656
1657    /**
1658     * @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.)
1659     */
1660    public Type getMedication() { 
1661      return this.medication;
1662    }
1663
1664    /**
1665     * @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.)
1666     */
1667    public CodeableConcept getMedicationCodeableConcept() throws FHIRException { 
1668      if (this.medication == null)
1669        return null;
1670      if (!(this.medication instanceof CodeableConcept))
1671        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.medication.getClass().getName()+" was encountered");
1672      return (CodeableConcept) this.medication;
1673    }
1674
1675    public boolean hasMedicationCodeableConcept() { 
1676      return this != null && this.medication instanceof CodeableConcept;
1677    }
1678
1679    /**
1680     * @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.)
1681     */
1682    public Reference getMedicationReference() throws FHIRException { 
1683      if (this.medication == null)
1684        return null;
1685      if (!(this.medication instanceof Reference))
1686        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.medication.getClass().getName()+" was encountered");
1687      return (Reference) this.medication;
1688    }
1689
1690    public boolean hasMedicationReference() { 
1691      return this != null && this.medication instanceof Reference;
1692    }
1693
1694    public boolean hasMedication() { 
1695      return this.medication != null && !this.medication.isEmpty();
1696    }
1697
1698    /**
1699     * @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.)
1700     */
1701    public MedicationRequest setMedication(Type value) { 
1702      if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
1703        throw new Error("Not the right type for MedicationRequest.medication[x]: "+value.fhirType());
1704      this.medication = value;
1705      return this;
1706    }
1707
1708    /**
1709     * @return {@link #subject} (A link to a resource representing the person or set of individuals to whom the medication will be given.)
1710     */
1711    public Reference getSubject() { 
1712      if (this.subject == null)
1713        if (Configuration.errorOnAutoCreate())
1714          throw new Error("Attempt to auto-create MedicationRequest.subject");
1715        else if (Configuration.doAutoCreate())
1716          this.subject = new Reference(); // cc
1717      return this.subject;
1718    }
1719
1720    public boolean hasSubject() { 
1721      return this.subject != null && !this.subject.isEmpty();
1722    }
1723
1724    /**
1725     * @param value {@link #subject} (A link to a resource representing the person or set of individuals to whom the medication will be given.)
1726     */
1727    public MedicationRequest setSubject(Reference value) { 
1728      this.subject = value;
1729      return this;
1730    }
1731
1732    /**
1733     * @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.)
1734     */
1735    public Resource getSubjectTarget() { 
1736      return this.subjectTarget;
1737    }
1738
1739    /**
1740     * @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.)
1741     */
1742    public MedicationRequest setSubjectTarget(Resource value) { 
1743      this.subjectTarget = value;
1744      return this;
1745    }
1746
1747    /**
1748     * @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.)
1749     */
1750    public Reference getContext() { 
1751      if (this.context == null)
1752        if (Configuration.errorOnAutoCreate())
1753          throw new Error("Attempt to auto-create MedicationRequest.context");
1754        else if (Configuration.doAutoCreate())
1755          this.context = new Reference(); // cc
1756      return this.context;
1757    }
1758
1759    public boolean hasContext() { 
1760      return this.context != null && !this.context.isEmpty();
1761    }
1762
1763    /**
1764     * @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.)
1765     */
1766    public MedicationRequest setContext(Reference value) { 
1767      this.context = value;
1768      return this;
1769    }
1770
1771    /**
1772     * @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.)
1773     */
1774    public Resource getContextTarget() { 
1775      return this.contextTarget;
1776    }
1777
1778    /**
1779     * @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.)
1780     */
1781    public MedicationRequest setContextTarget(Resource value) { 
1782      this.contextTarget = value;
1783      return this;
1784    }
1785
1786    /**
1787     * @return {@link #supportingInformation} (Include additional information (for example, patient height and weight) that supports the ordering of the medication.)
1788     */
1789    public List<Reference> getSupportingInformation() { 
1790      if (this.supportingInformation == null)
1791        this.supportingInformation = new ArrayList<Reference>();
1792      return this.supportingInformation;
1793    }
1794
1795    /**
1796     * @return Returns a reference to <code>this</code> for easy method chaining
1797     */
1798    public MedicationRequest setSupportingInformation(List<Reference> theSupportingInformation) { 
1799      this.supportingInformation = theSupportingInformation;
1800      return this;
1801    }
1802
1803    public boolean hasSupportingInformation() { 
1804      if (this.supportingInformation == null)
1805        return false;
1806      for (Reference item : this.supportingInformation)
1807        if (!item.isEmpty())
1808          return true;
1809      return false;
1810    }
1811
1812    public Reference addSupportingInformation() { //3
1813      Reference t = new Reference();
1814      if (this.supportingInformation == null)
1815        this.supportingInformation = new ArrayList<Reference>();
1816      this.supportingInformation.add(t);
1817      return t;
1818    }
1819
1820    public MedicationRequest addSupportingInformation(Reference t) { //3
1821      if (t == null)
1822        return this;
1823      if (this.supportingInformation == null)
1824        this.supportingInformation = new ArrayList<Reference>();
1825      this.supportingInformation.add(t);
1826      return this;
1827    }
1828
1829    /**
1830     * @return The first repetition of repeating field {@link #supportingInformation}, creating it if it does not already exist
1831     */
1832    public Reference getSupportingInformationFirstRep() { 
1833      if (getSupportingInformation().isEmpty()) {
1834        addSupportingInformation();
1835      }
1836      return getSupportingInformation().get(0);
1837    }
1838
1839    /**
1840     * @deprecated Use Reference#setResource(IBaseResource) instead
1841     */
1842    @Deprecated
1843    public List<Resource> getSupportingInformationTarget() { 
1844      if (this.supportingInformationTarget == null)
1845        this.supportingInformationTarget = new ArrayList<Resource>();
1846      return this.supportingInformationTarget;
1847    }
1848
1849    /**
1850     * @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
1851     */
1852    public DateTimeType getAuthoredOnElement() { 
1853      if (this.authoredOn == null)
1854        if (Configuration.errorOnAutoCreate())
1855          throw new Error("Attempt to auto-create MedicationRequest.authoredOn");
1856        else if (Configuration.doAutoCreate())
1857          this.authoredOn = new DateTimeType(); // bb
1858      return this.authoredOn;
1859    }
1860
1861    public boolean hasAuthoredOnElement() { 
1862      return this.authoredOn != null && !this.authoredOn.isEmpty();
1863    }
1864
1865    public boolean hasAuthoredOn() { 
1866      return this.authoredOn != null && !this.authoredOn.isEmpty();
1867    }
1868
1869    /**
1870     * @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
1871     */
1872    public MedicationRequest setAuthoredOnElement(DateTimeType value) { 
1873      this.authoredOn = value;
1874      return this;
1875    }
1876
1877    /**
1878     * @return The date (and perhaps time) when the prescription was initially written or authored on.
1879     */
1880    public Date getAuthoredOn() { 
1881      return this.authoredOn == null ? null : this.authoredOn.getValue();
1882    }
1883
1884    /**
1885     * @param value The date (and perhaps time) when the prescription was initially written or authored on.
1886     */
1887    public MedicationRequest setAuthoredOn(Date value) { 
1888      if (value == null)
1889        this.authoredOn = null;
1890      else {
1891        if (this.authoredOn == null)
1892          this.authoredOn = new DateTimeType();
1893        this.authoredOn.setValue(value);
1894      }
1895      return this;
1896    }
1897
1898    /**
1899     * @return {@link #requester} (The individual, organization, or device that initiated the request and has responsibility for its activation.)
1900     */
1901    public Reference getRequester() { 
1902      if (this.requester == null)
1903        if (Configuration.errorOnAutoCreate())
1904          throw new Error("Attempt to auto-create MedicationRequest.requester");
1905        else if (Configuration.doAutoCreate())
1906          this.requester = new Reference(); // cc
1907      return this.requester;
1908    }
1909
1910    public boolean hasRequester() { 
1911      return this.requester != null && !this.requester.isEmpty();
1912    }
1913
1914    /**
1915     * @param value {@link #requester} (The individual, organization, or device that initiated the request and has responsibility for its activation.)
1916     */
1917    public MedicationRequest setRequester(Reference value) { 
1918      this.requester = value;
1919      return this;
1920    }
1921
1922    /**
1923     * @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.)
1924     */
1925    public Resource getRequesterTarget() { 
1926      return this.requesterTarget;
1927    }
1928
1929    /**
1930     * @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.)
1931     */
1932    public MedicationRequest setRequesterTarget(Resource value) { 
1933      this.requesterTarget = value;
1934      return this;
1935    }
1936
1937    /**
1938     * @return {@link #performer} (The specified desired performer of the medication treatment (e.g. the performer of the medication administration).)
1939     */
1940    public Reference getPerformer() { 
1941      if (this.performer == null)
1942        if (Configuration.errorOnAutoCreate())
1943          throw new Error("Attempt to auto-create MedicationRequest.performer");
1944        else if (Configuration.doAutoCreate())
1945          this.performer = new Reference(); // cc
1946      return this.performer;
1947    }
1948
1949    public boolean hasPerformer() { 
1950      return this.performer != null && !this.performer.isEmpty();
1951    }
1952
1953    /**
1954     * @param value {@link #performer} (The specified desired performer of the medication treatment (e.g. the performer of the medication administration).)
1955     */
1956    public MedicationRequest setPerformer(Reference value) { 
1957      this.performer = value;
1958      return this;
1959    }
1960
1961    /**
1962     * @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).)
1963     */
1964    public Resource getPerformerTarget() { 
1965      return this.performerTarget;
1966    }
1967
1968    /**
1969     * @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).)
1970     */
1971    public MedicationRequest setPerformerTarget(Resource value) { 
1972      this.performerTarget = value;
1973      return this;
1974    }
1975
1976    /**
1977     * @return {@link #performerType} (Indicates the type of performer of the administration of the medication.)
1978     */
1979    public CodeableConcept getPerformerType() { 
1980      if (this.performerType == null)
1981        if (Configuration.errorOnAutoCreate())
1982          throw new Error("Attempt to auto-create MedicationRequest.performerType");
1983        else if (Configuration.doAutoCreate())
1984          this.performerType = new CodeableConcept(); // cc
1985      return this.performerType;
1986    }
1987
1988    public boolean hasPerformerType() { 
1989      return this.performerType != null && !this.performerType.isEmpty();
1990    }
1991
1992    /**
1993     * @param value {@link #performerType} (Indicates the type of performer of the administration of the medication.)
1994     */
1995    public MedicationRequest setPerformerType(CodeableConcept value) { 
1996      this.performerType = value;
1997      return this;
1998    }
1999
2000    /**
2001     * @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.)
2002     */
2003    public Reference getRecorder() { 
2004      if (this.recorder == null)
2005        if (Configuration.errorOnAutoCreate())
2006          throw new Error("Attempt to auto-create MedicationRequest.recorder");
2007        else if (Configuration.doAutoCreate())
2008          this.recorder = new Reference(); // cc
2009      return this.recorder;
2010    }
2011
2012    public boolean hasRecorder() { 
2013      return this.recorder != null && !this.recorder.isEmpty();
2014    }
2015
2016    /**
2017     * @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.)
2018     */
2019    public MedicationRequest setRecorder(Reference value) { 
2020      this.recorder = value;
2021      return this;
2022    }
2023
2024    /**
2025     * @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.)
2026     */
2027    public Practitioner getRecorderTarget() { 
2028      if (this.recorderTarget == null)
2029        if (Configuration.errorOnAutoCreate())
2030          throw new Error("Attempt to auto-create MedicationRequest.recorder");
2031        else if (Configuration.doAutoCreate())
2032          this.recorderTarget = new Practitioner(); // aa
2033      return this.recorderTarget;
2034    }
2035
2036    /**
2037     * @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.)
2038     */
2039    public MedicationRequest setRecorderTarget(Practitioner value) { 
2040      this.recorderTarget = value;
2041      return this;
2042    }
2043
2044    /**
2045     * @return {@link #reasonCode} (The reason or the indication for ordering the medication.)
2046     */
2047    public List<CodeableConcept> getReasonCode() { 
2048      if (this.reasonCode == null)
2049        this.reasonCode = new ArrayList<CodeableConcept>();
2050      return this.reasonCode;
2051    }
2052
2053    /**
2054     * @return Returns a reference to <code>this</code> for easy method chaining
2055     */
2056    public MedicationRequest setReasonCode(List<CodeableConcept> theReasonCode) { 
2057      this.reasonCode = theReasonCode;
2058      return this;
2059    }
2060
2061    public boolean hasReasonCode() { 
2062      if (this.reasonCode == null)
2063        return false;
2064      for (CodeableConcept item : this.reasonCode)
2065        if (!item.isEmpty())
2066          return true;
2067      return false;
2068    }
2069
2070    public CodeableConcept addReasonCode() { //3
2071      CodeableConcept t = new CodeableConcept();
2072      if (this.reasonCode == null)
2073        this.reasonCode = new ArrayList<CodeableConcept>();
2074      this.reasonCode.add(t);
2075      return t;
2076    }
2077
2078    public MedicationRequest addReasonCode(CodeableConcept t) { //3
2079      if (t == null)
2080        return this;
2081      if (this.reasonCode == null)
2082        this.reasonCode = new ArrayList<CodeableConcept>();
2083      this.reasonCode.add(t);
2084      return this;
2085    }
2086
2087    /**
2088     * @return The first repetition of repeating field {@link #reasonCode}, creating it if it does not already exist
2089     */
2090    public CodeableConcept getReasonCodeFirstRep() { 
2091      if (getReasonCode().isEmpty()) {
2092        addReasonCode();
2093      }
2094      return getReasonCode().get(0);
2095    }
2096
2097    /**
2098     * @return {@link #reasonReference} (Condition or observation that supports why the medication was ordered.)
2099     */
2100    public List<Reference> getReasonReference() { 
2101      if (this.reasonReference == null)
2102        this.reasonReference = new ArrayList<Reference>();
2103      return this.reasonReference;
2104    }
2105
2106    /**
2107     * @return Returns a reference to <code>this</code> for easy method chaining
2108     */
2109    public MedicationRequest setReasonReference(List<Reference> theReasonReference) { 
2110      this.reasonReference = theReasonReference;
2111      return this;
2112    }
2113
2114    public boolean hasReasonReference() { 
2115      if (this.reasonReference == null)
2116        return false;
2117      for (Reference item : this.reasonReference)
2118        if (!item.isEmpty())
2119          return true;
2120      return false;
2121    }
2122
2123    public Reference addReasonReference() { //3
2124      Reference t = new Reference();
2125      if (this.reasonReference == null)
2126        this.reasonReference = new ArrayList<Reference>();
2127      this.reasonReference.add(t);
2128      return t;
2129    }
2130
2131    public MedicationRequest addReasonReference(Reference t) { //3
2132      if (t == null)
2133        return this;
2134      if (this.reasonReference == null)
2135        this.reasonReference = new ArrayList<Reference>();
2136      this.reasonReference.add(t);
2137      return this;
2138    }
2139
2140    /**
2141     * @return The first repetition of repeating field {@link #reasonReference}, creating it if it does not already exist
2142     */
2143    public Reference getReasonReferenceFirstRep() { 
2144      if (getReasonReference().isEmpty()) {
2145        addReasonReference();
2146      }
2147      return getReasonReference().get(0);
2148    }
2149
2150    /**
2151     * @deprecated Use Reference#setResource(IBaseResource) instead
2152     */
2153    @Deprecated
2154    public List<Resource> getReasonReferenceTarget() { 
2155      if (this.reasonReferenceTarget == null)
2156        this.reasonReferenceTarget = new ArrayList<Resource>();
2157      return this.reasonReferenceTarget;
2158    }
2159
2160    /**
2161     * @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.)
2162     */
2163    public List<UriType> getInstantiates() { 
2164      if (this.instantiates == null)
2165        this.instantiates = new ArrayList<UriType>();
2166      return this.instantiates;
2167    }
2168
2169    /**
2170     * @return Returns a reference to <code>this</code> for easy method chaining
2171     */
2172    public MedicationRequest setInstantiates(List<UriType> theInstantiates) { 
2173      this.instantiates = theInstantiates;
2174      return this;
2175    }
2176
2177    public boolean hasInstantiates() { 
2178      if (this.instantiates == null)
2179        return false;
2180      for (UriType item : this.instantiates)
2181        if (!item.isEmpty())
2182          return true;
2183      return false;
2184    }
2185
2186    /**
2187     * @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.)
2188     */
2189    public UriType addInstantiatesElement() {//2 
2190      UriType t = new UriType();
2191      if (this.instantiates == null)
2192        this.instantiates = new ArrayList<UriType>();
2193      this.instantiates.add(t);
2194      return t;
2195    }
2196
2197    /**
2198     * @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.)
2199     */
2200    public MedicationRequest addInstantiates(String value) { //1
2201      UriType t = new UriType();
2202      t.setValue(value);
2203      if (this.instantiates == null)
2204        this.instantiates = new ArrayList<UriType>();
2205      this.instantiates.add(t);
2206      return this;
2207    }
2208
2209    /**
2210     * @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.)
2211     */
2212    public boolean hasInstantiates(String value) { 
2213      if (this.instantiates == null)
2214        return false;
2215      for (UriType v : this.instantiates)
2216        if (v.getValue().equals(value)) // uri
2217          return true;
2218      return false;
2219    }
2220
2221    /**
2222     * @return {@link #basedOn} (A plan or request that is fulfilled in whole or in part by this medication request.)
2223     */
2224    public List<Reference> getBasedOn() { 
2225      if (this.basedOn == null)
2226        this.basedOn = new ArrayList<Reference>();
2227      return this.basedOn;
2228    }
2229
2230    /**
2231     * @return Returns a reference to <code>this</code> for easy method chaining
2232     */
2233    public MedicationRequest setBasedOn(List<Reference> theBasedOn) { 
2234      this.basedOn = theBasedOn;
2235      return this;
2236    }
2237
2238    public boolean hasBasedOn() { 
2239      if (this.basedOn == null)
2240        return false;
2241      for (Reference item : this.basedOn)
2242        if (!item.isEmpty())
2243          return true;
2244      return false;
2245    }
2246
2247    public Reference addBasedOn() { //3
2248      Reference t = new Reference();
2249      if (this.basedOn == null)
2250        this.basedOn = new ArrayList<Reference>();
2251      this.basedOn.add(t);
2252      return t;
2253    }
2254
2255    public MedicationRequest addBasedOn(Reference t) { //3
2256      if (t == null)
2257        return this;
2258      if (this.basedOn == null)
2259        this.basedOn = new ArrayList<Reference>();
2260      this.basedOn.add(t);
2261      return this;
2262    }
2263
2264    /**
2265     * @return The first repetition of repeating field {@link #basedOn}, creating it if it does not already exist
2266     */
2267    public Reference getBasedOnFirstRep() { 
2268      if (getBasedOn().isEmpty()) {
2269        addBasedOn();
2270      }
2271      return getBasedOn().get(0);
2272    }
2273
2274    /**
2275     * @deprecated Use Reference#setResource(IBaseResource) instead
2276     */
2277    @Deprecated
2278    public List<Resource> getBasedOnTarget() { 
2279      if (this.basedOnTarget == null)
2280        this.basedOnTarget = new ArrayList<Resource>();
2281      return this.basedOnTarget;
2282    }
2283
2284    /**
2285     * @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.)
2286     */
2287    public Identifier getGroupIdentifier() { 
2288      if (this.groupIdentifier == null)
2289        if (Configuration.errorOnAutoCreate())
2290          throw new Error("Attempt to auto-create MedicationRequest.groupIdentifier");
2291        else if (Configuration.doAutoCreate())
2292          this.groupIdentifier = new Identifier(); // cc
2293      return this.groupIdentifier;
2294    }
2295
2296    public boolean hasGroupIdentifier() { 
2297      return this.groupIdentifier != null && !this.groupIdentifier.isEmpty();
2298    }
2299
2300    /**
2301     * @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.)
2302     */
2303    public MedicationRequest setGroupIdentifier(Identifier value) { 
2304      this.groupIdentifier = value;
2305      return this;
2306    }
2307
2308    /**
2309     * @return {@link #statusReason} (Captures the reason for the current state of the MedicationRequest.)
2310     */
2311    public CodeableConcept getStatusReason() { 
2312      if (this.statusReason == null)
2313        if (Configuration.errorOnAutoCreate())
2314          throw new Error("Attempt to auto-create MedicationRequest.statusReason");
2315        else if (Configuration.doAutoCreate())
2316          this.statusReason = new CodeableConcept(); // cc
2317      return this.statusReason;
2318    }
2319
2320    public boolean hasStatusReason() { 
2321      return this.statusReason != null && !this.statusReason.isEmpty();
2322    }
2323
2324    /**
2325     * @param value {@link #statusReason} (Captures the reason for the current state of the MedicationRequest.)
2326     */
2327    public MedicationRequest setStatusReason(CodeableConcept value) { 
2328      this.statusReason = value;
2329      return this;
2330    }
2331
2332    /**
2333     * @return {@link #insurance} (Insurance plans, coverage extensions, pre-authorizations and/or pre-determinations that may be required for delivering the requested service.)
2334     */
2335    public List<Reference> getInsurance() { 
2336      if (this.insurance == null)
2337        this.insurance = new ArrayList<Reference>();
2338      return this.insurance;
2339    }
2340
2341    /**
2342     * @return Returns a reference to <code>this</code> for easy method chaining
2343     */
2344    public MedicationRequest setInsurance(List<Reference> theInsurance) { 
2345      this.insurance = theInsurance;
2346      return this;
2347    }
2348
2349    public boolean hasInsurance() { 
2350      if (this.insurance == null)
2351        return false;
2352      for (Reference item : this.insurance)
2353        if (!item.isEmpty())
2354          return true;
2355      return false;
2356    }
2357
2358    public Reference addInsurance() { //3
2359      Reference t = new Reference();
2360      if (this.insurance == null)
2361        this.insurance = new ArrayList<Reference>();
2362      this.insurance.add(t);
2363      return t;
2364    }
2365
2366    public MedicationRequest addInsurance(Reference t) { //3
2367      if (t == null)
2368        return this;
2369      if (this.insurance == null)
2370        this.insurance = new ArrayList<Reference>();
2371      this.insurance.add(t);
2372      return this;
2373    }
2374
2375    /**
2376     * @return The first repetition of repeating field {@link #insurance}, creating it if it does not already exist
2377     */
2378    public Reference getInsuranceFirstRep() { 
2379      if (getInsurance().isEmpty()) {
2380        addInsurance();
2381      }
2382      return getInsurance().get(0);
2383    }
2384
2385    /**
2386     * @deprecated Use Reference#setResource(IBaseResource) instead
2387     */
2388    @Deprecated
2389    public List<Resource> getInsuranceTarget() { 
2390      if (this.insuranceTarget == null)
2391        this.insuranceTarget = new ArrayList<Resource>();
2392      return this.insuranceTarget;
2393    }
2394
2395    /**
2396     * @return {@link #note} (Extra information about the prescription that could not be conveyed by the other attributes.)
2397     */
2398    public List<Annotation> getNote() { 
2399      if (this.note == null)
2400        this.note = new ArrayList<Annotation>();
2401      return this.note;
2402    }
2403
2404    /**
2405     * @return Returns a reference to <code>this</code> for easy method chaining
2406     */
2407    public MedicationRequest setNote(List<Annotation> theNote) { 
2408      this.note = theNote;
2409      return this;
2410    }
2411
2412    public boolean hasNote() { 
2413      if (this.note == null)
2414        return false;
2415      for (Annotation item : this.note)
2416        if (!item.isEmpty())
2417          return true;
2418      return false;
2419    }
2420
2421    public Annotation addNote() { //3
2422      Annotation t = new Annotation();
2423      if (this.note == null)
2424        this.note = new ArrayList<Annotation>();
2425      this.note.add(t);
2426      return t;
2427    }
2428
2429    public MedicationRequest addNote(Annotation t) { //3
2430      if (t == null)
2431        return this;
2432      if (this.note == null)
2433        this.note = new ArrayList<Annotation>();
2434      this.note.add(t);
2435      return this;
2436    }
2437
2438    /**
2439     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist
2440     */
2441    public Annotation getNoteFirstRep() { 
2442      if (getNote().isEmpty()) {
2443        addNote();
2444      }
2445      return getNote().get(0);
2446    }
2447
2448    /**
2449     * @return {@link #dosageInstruction} (Indicates how the medication is to be used by the patient.)
2450     */
2451    public List<Dosage> getDosageInstruction() { 
2452      if (this.dosageInstruction == null)
2453        this.dosageInstruction = new ArrayList<Dosage>();
2454      return this.dosageInstruction;
2455    }
2456
2457    /**
2458     * @return Returns a reference to <code>this</code> for easy method chaining
2459     */
2460    public MedicationRequest setDosageInstruction(List<Dosage> theDosageInstruction) { 
2461      this.dosageInstruction = theDosageInstruction;
2462      return this;
2463    }
2464
2465    public boolean hasDosageInstruction() { 
2466      if (this.dosageInstruction == null)
2467        return false;
2468      for (Dosage item : this.dosageInstruction)
2469        if (!item.isEmpty())
2470          return true;
2471      return false;
2472    }
2473
2474    public Dosage addDosageInstruction() { //3
2475      Dosage t = new Dosage();
2476      if (this.dosageInstruction == null)
2477        this.dosageInstruction = new ArrayList<Dosage>();
2478      this.dosageInstruction.add(t);
2479      return t;
2480    }
2481
2482    public MedicationRequest addDosageInstruction(Dosage t) { //3
2483      if (t == null)
2484        return this;
2485      if (this.dosageInstruction == null)
2486        this.dosageInstruction = new ArrayList<Dosage>();
2487      this.dosageInstruction.add(t);
2488      return this;
2489    }
2490
2491    /**
2492     * @return The first repetition of repeating field {@link #dosageInstruction}, creating it if it does not already exist
2493     */
2494    public Dosage getDosageInstructionFirstRep() { 
2495      if (getDosageInstruction().isEmpty()) {
2496        addDosageInstruction();
2497      }
2498      return getDosageInstruction().get(0);
2499    }
2500
2501    /**
2502     * @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.)
2503     */
2504    public MedicationRequestDispenseRequestComponent getDispenseRequest() { 
2505      if (this.dispenseRequest == null)
2506        if (Configuration.errorOnAutoCreate())
2507          throw new Error("Attempt to auto-create MedicationRequest.dispenseRequest");
2508        else if (Configuration.doAutoCreate())
2509          this.dispenseRequest = new MedicationRequestDispenseRequestComponent(); // cc
2510      return this.dispenseRequest;
2511    }
2512
2513    public boolean hasDispenseRequest() { 
2514      return this.dispenseRequest != null && !this.dispenseRequest.isEmpty();
2515    }
2516
2517    /**
2518     * @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.)
2519     */
2520    public MedicationRequest setDispenseRequest(MedicationRequestDispenseRequestComponent value) { 
2521      this.dispenseRequest = value;
2522      return this;
2523    }
2524
2525    /**
2526     * @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.)
2527     */
2528    public MedicationRequestSubstitutionComponent getSubstitution() { 
2529      if (this.substitution == null)
2530        if (Configuration.errorOnAutoCreate())
2531          throw new Error("Attempt to auto-create MedicationRequest.substitution");
2532        else if (Configuration.doAutoCreate())
2533          this.substitution = new MedicationRequestSubstitutionComponent(); // cc
2534      return this.substitution;
2535    }
2536
2537    public boolean hasSubstitution() { 
2538      return this.substitution != null && !this.substitution.isEmpty();
2539    }
2540
2541    /**
2542     * @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.)
2543     */
2544    public MedicationRequest setSubstitution(MedicationRequestSubstitutionComponent value) { 
2545      this.substitution = value;
2546      return this;
2547    }
2548
2549    /**
2550     * @return {@link #priorPrescription} (A link to a resource representing an earlier order related order or prescription.)
2551     */
2552    public Reference getPriorPrescription() { 
2553      if (this.priorPrescription == null)
2554        if (Configuration.errorOnAutoCreate())
2555          throw new Error("Attempt to auto-create MedicationRequest.priorPrescription");
2556        else if (Configuration.doAutoCreate())
2557          this.priorPrescription = new Reference(); // cc
2558      return this.priorPrescription;
2559    }
2560
2561    public boolean hasPriorPrescription() { 
2562      return this.priorPrescription != null && !this.priorPrescription.isEmpty();
2563    }
2564
2565    /**
2566     * @param value {@link #priorPrescription} (A link to a resource representing an earlier order related order or prescription.)
2567     */
2568    public MedicationRequest setPriorPrescription(Reference value) { 
2569      this.priorPrescription = value;
2570      return this;
2571    }
2572
2573    /**
2574     * @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.)
2575     */
2576    public MedicationRequest getPriorPrescriptionTarget() { 
2577      if (this.priorPrescriptionTarget == null)
2578        if (Configuration.errorOnAutoCreate())
2579          throw new Error("Attempt to auto-create MedicationRequest.priorPrescription");
2580        else if (Configuration.doAutoCreate())
2581          this.priorPrescriptionTarget = new MedicationRequest(); // aa
2582      return this.priorPrescriptionTarget;
2583    }
2584
2585    /**
2586     * @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.)
2587     */
2588    public MedicationRequest setPriorPrescriptionTarget(MedicationRequest value) { 
2589      this.priorPrescriptionTarget = value;
2590      return this;
2591    }
2592
2593    /**
2594     * @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.)
2595     */
2596    public List<Reference> getDetectedIssue() { 
2597      if (this.detectedIssue == null)
2598        this.detectedIssue = new ArrayList<Reference>();
2599      return this.detectedIssue;
2600    }
2601
2602    /**
2603     * @return Returns a reference to <code>this</code> for easy method chaining
2604     */
2605    public MedicationRequest setDetectedIssue(List<Reference> theDetectedIssue) { 
2606      this.detectedIssue = theDetectedIssue;
2607      return this;
2608    }
2609
2610    public boolean hasDetectedIssue() { 
2611      if (this.detectedIssue == null)
2612        return false;
2613      for (Reference item : this.detectedIssue)
2614        if (!item.isEmpty())
2615          return true;
2616      return false;
2617    }
2618
2619    public Reference addDetectedIssue() { //3
2620      Reference t = new Reference();
2621      if (this.detectedIssue == null)
2622        this.detectedIssue = new ArrayList<Reference>();
2623      this.detectedIssue.add(t);
2624      return t;
2625    }
2626
2627    public MedicationRequest addDetectedIssue(Reference t) { //3
2628      if (t == null)
2629        return this;
2630      if (this.detectedIssue == null)
2631        this.detectedIssue = new ArrayList<Reference>();
2632      this.detectedIssue.add(t);
2633      return this;
2634    }
2635
2636    /**
2637     * @return The first repetition of repeating field {@link #detectedIssue}, creating it if it does not already exist
2638     */
2639    public Reference getDetectedIssueFirstRep() { 
2640      if (getDetectedIssue().isEmpty()) {
2641        addDetectedIssue();
2642      }
2643      return getDetectedIssue().get(0);
2644    }
2645
2646    /**
2647     * @deprecated Use Reference#setResource(IBaseResource) instead
2648     */
2649    @Deprecated
2650    public List<DetectedIssue> getDetectedIssueTarget() { 
2651      if (this.detectedIssueTarget == null)
2652        this.detectedIssueTarget = new ArrayList<DetectedIssue>();
2653      return this.detectedIssueTarget;
2654    }
2655
2656    /**
2657     * @deprecated Use Reference#setResource(IBaseResource) instead
2658     */
2659    @Deprecated
2660    public DetectedIssue addDetectedIssueTarget() { 
2661      DetectedIssue r = new DetectedIssue();
2662      if (this.detectedIssueTarget == null)
2663        this.detectedIssueTarget = new ArrayList<DetectedIssue>();
2664      this.detectedIssueTarget.add(r);
2665      return r;
2666    }
2667
2668    /**
2669     * @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.)
2670     */
2671    public List<Reference> getEventHistory() { 
2672      if (this.eventHistory == null)
2673        this.eventHistory = new ArrayList<Reference>();
2674      return this.eventHistory;
2675    }
2676
2677    /**
2678     * @return Returns a reference to <code>this</code> for easy method chaining
2679     */
2680    public MedicationRequest setEventHistory(List<Reference> theEventHistory) { 
2681      this.eventHistory = theEventHistory;
2682      return this;
2683    }
2684
2685    public boolean hasEventHistory() { 
2686      if (this.eventHistory == null)
2687        return false;
2688      for (Reference item : this.eventHistory)
2689        if (!item.isEmpty())
2690          return true;
2691      return false;
2692    }
2693
2694    public Reference addEventHistory() { //3
2695      Reference t = new Reference();
2696      if (this.eventHistory == null)
2697        this.eventHistory = new ArrayList<Reference>();
2698      this.eventHistory.add(t);
2699      return t;
2700    }
2701
2702    public MedicationRequest addEventHistory(Reference t) { //3
2703      if (t == null)
2704        return this;
2705      if (this.eventHistory == null)
2706        this.eventHistory = new ArrayList<Reference>();
2707      this.eventHistory.add(t);
2708      return this;
2709    }
2710
2711    /**
2712     * @return The first repetition of repeating field {@link #eventHistory}, creating it if it does not already exist
2713     */
2714    public Reference getEventHistoryFirstRep() { 
2715      if (getEventHistory().isEmpty()) {
2716        addEventHistory();
2717      }
2718      return getEventHistory().get(0);
2719    }
2720
2721    /**
2722     * @deprecated Use Reference#setResource(IBaseResource) instead
2723     */
2724    @Deprecated
2725    public List<Provenance> getEventHistoryTarget() { 
2726      if (this.eventHistoryTarget == null)
2727        this.eventHistoryTarget = new ArrayList<Provenance>();
2728      return this.eventHistoryTarget;
2729    }
2730
2731    /**
2732     * @deprecated Use Reference#setResource(IBaseResource) instead
2733     */
2734    @Deprecated
2735    public Provenance addEventHistoryTarget() { 
2736      Provenance r = new Provenance();
2737      if (this.eventHistoryTarget == null)
2738        this.eventHistoryTarget = new ArrayList<Provenance>();
2739      this.eventHistoryTarget.add(r);
2740      return r;
2741    }
2742
2743      protected void listChildren(List<Property> children) {
2744        super.listChildren(children);
2745        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));
2746        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));
2747        children.add(new Property("intent", "code", "Whether the request is a proposal, plan, or an original order.", 0, 1, intent));
2748        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) or the type of treatment (i.e. chemotherapy or endocrine).", 0, java.lang.Integer.MAX_VALUE, category));
2749        children.add(new Property("priority", "code", "Indicates how quickly the Medication Request should be addressed with respect to other requests.", 0, 1, priority));
2750        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));
2751        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));
2752        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));
2753        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));
2754        children.add(new Property("authoredOn", "dateTime", "The date (and perhaps time) when the prescription was initially written or authored on.", 0, 1, authoredOn));
2755        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));
2756        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));
2757        children.add(new Property("performerType", "CodeableConcept", "Indicates the type of performer of the administration of the medication.", 0, 1, performerType));
2758        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));
2759        children.add(new Property("reasonCode", "CodeableConcept", "The reason or the indication for ordering the medication.", 0, java.lang.Integer.MAX_VALUE, reasonCode));
2760        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));
2761        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));
2762        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));
2763        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));
2764        children.add(new Property("statusReason", "CodeableConcept", "Captures the reason for the current state of the MedicationRequest.", 0, 1, statusReason));
2765        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));
2766        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));
2767        children.add(new Property("dosageInstruction", "Dosage", "Indicates how the medication is to be used by the patient.", 0, java.lang.Integer.MAX_VALUE, dosageInstruction));
2768        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));
2769        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));
2770        children.add(new Property("priorPrescription", "Reference(MedicationRequest)", "A link to a resource representing an earlier order related order or prescription.", 0, 1, priorPrescription));
2771        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));
2772        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));
2773      }
2774
2775      @Override
2776      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2777        switch (_hash) {
2778        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);
2779        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);
2780        case -1183762788: /*intent*/  return new Property("intent", "code", "Whether the request is a proposal, plan, or an original order.", 0, 1, intent);
2781        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) or the type of treatment (i.e. chemotherapy or endocrine).", 0, java.lang.Integer.MAX_VALUE, category);
2782        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);
2783        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);
2784        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);
2785        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);
2786        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);
2787        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);
2788        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);
2789        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);
2790        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);
2791        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);
2792        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);
2793        case -901444568: /*performerType*/  return new Property("performerType", "CodeableConcept", "Indicates the type of performer of the administration of the medication.", 0, 1, performerType);
2794        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);
2795        case 722137681: /*reasonCode*/  return new Property("reasonCode", "CodeableConcept", "The reason or the indication for ordering the medication.", 0, java.lang.Integer.MAX_VALUE, reasonCode);
2796        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);
2797        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);
2798        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);
2799        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);
2800        case 2051346646: /*statusReason*/  return new Property("statusReason", "CodeableConcept", "Captures the reason for the current state of the MedicationRequest.", 0, 1, statusReason);
2801        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);
2802        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);
2803        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);
2804        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);
2805        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);
2806        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);
2807        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);
2808        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);
2809        default: return super.getNamedProperty(_hash, _name, _checkValid);
2810        }
2811
2812      }
2813
2814      @Override
2815      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2816        switch (hash) {
2817        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2818        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<MedicationRequestStatus>
2819        case -1183762788: /*intent*/ return this.intent == null ? new Base[0] : new Base[] {this.intent}; // Enumeration<MedicationRequestIntent>
2820        case 50511102: /*category*/ return this.category == null ? new Base[0] : this.category.toArray(new Base[this.category.size()]); // CodeableConcept
2821        case -1165461084: /*priority*/ return this.priority == null ? new Base[0] : new Base[] {this.priority}; // Enumeration<MedicationRequestPriority>
2822        case 1998965455: /*medication*/ return this.medication == null ? new Base[0] : new Base[] {this.medication}; // Type
2823        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
2824        case 951530927: /*context*/ return this.context == null ? new Base[0] : new Base[] {this.context}; // Reference
2825        case -1248768647: /*supportingInformation*/ return this.supportingInformation == null ? new Base[0] : this.supportingInformation.toArray(new Base[this.supportingInformation.size()]); // Reference
2826        case -1500852503: /*authoredOn*/ return this.authoredOn == null ? new Base[0] : new Base[] {this.authoredOn}; // DateTimeType
2827        case 693933948: /*requester*/ return this.requester == null ? new Base[0] : new Base[] {this.requester}; // Reference
2828        case 481140686: /*performer*/ return this.performer == null ? new Base[0] : new Base[] {this.performer}; // Reference
2829        case -901444568: /*performerType*/ return this.performerType == null ? new Base[0] : new Base[] {this.performerType}; // CodeableConcept
2830        case -799233858: /*recorder*/ return this.recorder == null ? new Base[0] : new Base[] {this.recorder}; // Reference
2831        case 722137681: /*reasonCode*/ return this.reasonCode == null ? new Base[0] : this.reasonCode.toArray(new Base[this.reasonCode.size()]); // CodeableConcept
2832        case -1146218137: /*reasonReference*/ return this.reasonReference == null ? new Base[0] : this.reasonReference.toArray(new Base[this.reasonReference.size()]); // Reference
2833        case -246883639: /*instantiates*/ return this.instantiates == null ? new Base[0] : this.instantiates.toArray(new Base[this.instantiates.size()]); // UriType
2834        case -332612366: /*basedOn*/ return this.basedOn == null ? new Base[0] : this.basedOn.toArray(new Base[this.basedOn.size()]); // Reference
2835        case -445338488: /*groupIdentifier*/ return this.groupIdentifier == null ? new Base[0] : new Base[] {this.groupIdentifier}; // Identifier
2836        case 2051346646: /*statusReason*/ return this.statusReason == null ? new Base[0] : new Base[] {this.statusReason}; // CodeableConcept
2837        case 73049818: /*insurance*/ return this.insurance == null ? new Base[0] : this.insurance.toArray(new Base[this.insurance.size()]); // Reference
2838        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
2839        case -1201373865: /*dosageInstruction*/ return this.dosageInstruction == null ? new Base[0] : this.dosageInstruction.toArray(new Base[this.dosageInstruction.size()]); // Dosage
2840        case 824620658: /*dispenseRequest*/ return this.dispenseRequest == null ? new Base[0] : new Base[] {this.dispenseRequest}; // MedicationRequestDispenseRequestComponent
2841        case 826147581: /*substitution*/ return this.substitution == null ? new Base[0] : new Base[] {this.substitution}; // MedicationRequestSubstitutionComponent
2842        case -486355964: /*priorPrescription*/ return this.priorPrescription == null ? new Base[0] : new Base[] {this.priorPrescription}; // Reference
2843        case 51602295: /*detectedIssue*/ return this.detectedIssue == null ? new Base[0] : this.detectedIssue.toArray(new Base[this.detectedIssue.size()]); // Reference
2844        case 1835190426: /*eventHistory*/ return this.eventHistory == null ? new Base[0] : this.eventHistory.toArray(new Base[this.eventHistory.size()]); // Reference
2845        default: return super.getProperty(hash, name, checkValid);
2846        }
2847
2848      }
2849
2850      @Override
2851      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2852        switch (hash) {
2853        case -1618432855: // identifier
2854          this.getIdentifier().add(castToIdentifier(value)); // Identifier
2855          return value;
2856        case -892481550: // status
2857          value = new MedicationRequestStatusEnumFactory().fromType(castToCode(value));
2858          this.status = (Enumeration) value; // Enumeration<MedicationRequestStatus>
2859          return value;
2860        case -1183762788: // intent
2861          value = new MedicationRequestIntentEnumFactory().fromType(castToCode(value));
2862          this.intent = (Enumeration) value; // Enumeration<MedicationRequestIntent>
2863          return value;
2864        case 50511102: // category
2865          this.getCategory().add(castToCodeableConcept(value)); // CodeableConcept
2866          return value;
2867        case -1165461084: // priority
2868          value = new MedicationRequestPriorityEnumFactory().fromType(castToCode(value));
2869          this.priority = (Enumeration) value; // Enumeration<MedicationRequestPriority>
2870          return value;
2871        case 1998965455: // medication
2872          this.medication = castToType(value); // Type
2873          return value;
2874        case -1867885268: // subject
2875          this.subject = castToReference(value); // Reference
2876          return value;
2877        case 951530927: // context
2878          this.context = castToReference(value); // Reference
2879          return value;
2880        case -1248768647: // supportingInformation
2881          this.getSupportingInformation().add(castToReference(value)); // Reference
2882          return value;
2883        case -1500852503: // authoredOn
2884          this.authoredOn = castToDateTime(value); // DateTimeType
2885          return value;
2886        case 693933948: // requester
2887          this.requester = castToReference(value); // Reference
2888          return value;
2889        case 481140686: // performer
2890          this.performer = castToReference(value); // Reference
2891          return value;
2892        case -901444568: // performerType
2893          this.performerType = castToCodeableConcept(value); // CodeableConcept
2894          return value;
2895        case -799233858: // recorder
2896          this.recorder = castToReference(value); // Reference
2897          return value;
2898        case 722137681: // reasonCode
2899          this.getReasonCode().add(castToCodeableConcept(value)); // CodeableConcept
2900          return value;
2901        case -1146218137: // reasonReference
2902          this.getReasonReference().add(castToReference(value)); // Reference
2903          return value;
2904        case -246883639: // instantiates
2905          this.getInstantiates().add(castToUri(value)); // UriType
2906          return value;
2907        case -332612366: // basedOn
2908          this.getBasedOn().add(castToReference(value)); // Reference
2909          return value;
2910        case -445338488: // groupIdentifier
2911          this.groupIdentifier = castToIdentifier(value); // Identifier
2912          return value;
2913        case 2051346646: // statusReason
2914          this.statusReason = castToCodeableConcept(value); // CodeableConcept
2915          return value;
2916        case 73049818: // insurance
2917          this.getInsurance().add(castToReference(value)); // Reference
2918          return value;
2919        case 3387378: // note
2920          this.getNote().add(castToAnnotation(value)); // Annotation
2921          return value;
2922        case -1201373865: // dosageInstruction
2923          this.getDosageInstruction().add(castToDosage(value)); // Dosage
2924          return value;
2925        case 824620658: // dispenseRequest
2926          this.dispenseRequest = (MedicationRequestDispenseRequestComponent) value; // MedicationRequestDispenseRequestComponent
2927          return value;
2928        case 826147581: // substitution
2929          this.substitution = (MedicationRequestSubstitutionComponent) value; // MedicationRequestSubstitutionComponent
2930          return value;
2931        case -486355964: // priorPrescription
2932          this.priorPrescription = castToReference(value); // Reference
2933          return value;
2934        case 51602295: // detectedIssue
2935          this.getDetectedIssue().add(castToReference(value)); // Reference
2936          return value;
2937        case 1835190426: // eventHistory
2938          this.getEventHistory().add(castToReference(value)); // Reference
2939          return value;
2940        default: return super.setProperty(hash, name, value);
2941        }
2942
2943      }
2944
2945      @Override
2946      public Base setProperty(String name, Base value) throws FHIRException {
2947        if (name.equals("identifier")) {
2948          this.getIdentifier().add(castToIdentifier(value));
2949        } else if (name.equals("status")) {
2950          value = new MedicationRequestStatusEnumFactory().fromType(castToCode(value));
2951          this.status = (Enumeration) value; // Enumeration<MedicationRequestStatus>
2952        } else if (name.equals("intent")) {
2953          value = new MedicationRequestIntentEnumFactory().fromType(castToCode(value));
2954          this.intent = (Enumeration) value; // Enumeration<MedicationRequestIntent>
2955        } else if (name.equals("category")) {
2956          this.getCategory().add(castToCodeableConcept(value));
2957        } else if (name.equals("priority")) {
2958          value = new MedicationRequestPriorityEnumFactory().fromType(castToCode(value));
2959          this.priority = (Enumeration) value; // Enumeration<MedicationRequestPriority>
2960        } else if (name.equals("medication[x]")) {
2961          this.medication = castToType(value); // Type
2962        } else if (name.equals("subject")) {
2963          this.subject = castToReference(value); // Reference
2964        } else if (name.equals("context")) {
2965          this.context = castToReference(value); // Reference
2966        } else if (name.equals("supportingInformation")) {
2967          this.getSupportingInformation().add(castToReference(value));
2968        } else if (name.equals("authoredOn")) {
2969          this.authoredOn = castToDateTime(value); // DateTimeType
2970        } else if (name.equals("requester")) {
2971          this.requester = castToReference(value); // Reference
2972        } else if (name.equals("performer")) {
2973          this.performer = castToReference(value); // Reference
2974        } else if (name.equals("performerType")) {
2975          this.performerType = castToCodeableConcept(value); // CodeableConcept
2976        } else if (name.equals("recorder")) {
2977          this.recorder = castToReference(value); // Reference
2978        } else if (name.equals("reasonCode")) {
2979          this.getReasonCode().add(castToCodeableConcept(value));
2980        } else if (name.equals("reasonReference")) {
2981          this.getReasonReference().add(castToReference(value));
2982        } else if (name.equals("instantiates")) {
2983          this.getInstantiates().add(castToUri(value));
2984        } else if (name.equals("basedOn")) {
2985          this.getBasedOn().add(castToReference(value));
2986        } else if (name.equals("groupIdentifier")) {
2987          this.groupIdentifier = castToIdentifier(value); // Identifier
2988        } else if (name.equals("statusReason")) {
2989          this.statusReason = castToCodeableConcept(value); // CodeableConcept
2990        } else if (name.equals("insurance")) {
2991          this.getInsurance().add(castToReference(value));
2992        } else if (name.equals("note")) {
2993          this.getNote().add(castToAnnotation(value));
2994        } else if (name.equals("dosageInstruction")) {
2995          this.getDosageInstruction().add(castToDosage(value));
2996        } else if (name.equals("dispenseRequest")) {
2997          this.dispenseRequest = (MedicationRequestDispenseRequestComponent) value; // MedicationRequestDispenseRequestComponent
2998        } else if (name.equals("substitution")) {
2999          this.substitution = (MedicationRequestSubstitutionComponent) value; // MedicationRequestSubstitutionComponent
3000        } else if (name.equals("priorPrescription")) {
3001          this.priorPrescription = castToReference(value); // Reference
3002        } else if (name.equals("detectedIssue")) {
3003          this.getDetectedIssue().add(castToReference(value));
3004        } else if (name.equals("eventHistory")) {
3005          this.getEventHistory().add(castToReference(value));
3006        } else
3007          return super.setProperty(name, value);
3008        return value;
3009      }
3010
3011      @Override
3012      public Base makeProperty(int hash, String name) throws FHIRException {
3013        switch (hash) {
3014        case -1618432855:  return addIdentifier(); 
3015        case -892481550:  return getStatusElement();
3016        case -1183762788:  return getIntentElement();
3017        case 50511102:  return addCategory(); 
3018        case -1165461084:  return getPriorityElement();
3019        case 1458402129:  return getMedication(); 
3020        case 1998965455:  return getMedication(); 
3021        case -1867885268:  return getSubject(); 
3022        case 951530927:  return getContext(); 
3023        case -1248768647:  return addSupportingInformation(); 
3024        case -1500852503:  return getAuthoredOnElement();
3025        case 693933948:  return getRequester(); 
3026        case 481140686:  return getPerformer(); 
3027        case -901444568:  return getPerformerType(); 
3028        case -799233858:  return getRecorder(); 
3029        case 722137681:  return addReasonCode(); 
3030        case -1146218137:  return addReasonReference(); 
3031        case -246883639:  return addInstantiatesElement();
3032        case -332612366:  return addBasedOn(); 
3033        case -445338488:  return getGroupIdentifier(); 
3034        case 2051346646:  return getStatusReason(); 
3035        case 73049818:  return addInsurance(); 
3036        case 3387378:  return addNote(); 
3037        case -1201373865:  return addDosageInstruction(); 
3038        case 824620658:  return getDispenseRequest(); 
3039        case 826147581:  return getSubstitution(); 
3040        case -486355964:  return getPriorPrescription(); 
3041        case 51602295:  return addDetectedIssue(); 
3042        case 1835190426:  return addEventHistory(); 
3043        default: return super.makeProperty(hash, name);
3044        }
3045
3046      }
3047
3048      @Override
3049      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
3050        switch (hash) {
3051        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
3052        case -892481550: /*status*/ return new String[] {"code"};
3053        case -1183762788: /*intent*/ return new String[] {"code"};
3054        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
3055        case -1165461084: /*priority*/ return new String[] {"code"};
3056        case 1998965455: /*medication*/ return new String[] {"CodeableConcept", "Reference"};
3057        case -1867885268: /*subject*/ return new String[] {"Reference"};
3058        case 951530927: /*context*/ return new String[] {"Reference"};
3059        case -1248768647: /*supportingInformation*/ return new String[] {"Reference"};
3060        case -1500852503: /*authoredOn*/ return new String[] {"dateTime"};
3061        case 693933948: /*requester*/ return new String[] {"Reference"};
3062        case 481140686: /*performer*/ return new String[] {"Reference"};
3063        case -901444568: /*performerType*/ return new String[] {"CodeableConcept"};
3064        case -799233858: /*recorder*/ return new String[] {"Reference"};
3065        case 722137681: /*reasonCode*/ return new String[] {"CodeableConcept"};
3066        case -1146218137: /*reasonReference*/ return new String[] {"Reference"};
3067        case -246883639: /*instantiates*/ return new String[] {"uri"};
3068        case -332612366: /*basedOn*/ return new String[] {"Reference"};
3069        case -445338488: /*groupIdentifier*/ return new String[] {"Identifier"};
3070        case 2051346646: /*statusReason*/ return new String[] {"CodeableConcept"};
3071        case 73049818: /*insurance*/ return new String[] {"Reference"};
3072        case 3387378: /*note*/ return new String[] {"Annotation"};
3073        case -1201373865: /*dosageInstruction*/ return new String[] {"Dosage"};
3074        case 824620658: /*dispenseRequest*/ return new String[] {};
3075        case 826147581: /*substitution*/ return new String[] {};
3076        case -486355964: /*priorPrescription*/ return new String[] {"Reference"};
3077        case 51602295: /*detectedIssue*/ return new String[] {"Reference"};
3078        case 1835190426: /*eventHistory*/ return new String[] {"Reference"};
3079        default: return super.getTypesForProperty(hash, name);
3080        }
3081
3082      }
3083
3084      @Override
3085      public Base addChild(String name) throws FHIRException {
3086        if (name.equals("identifier")) {
3087          return addIdentifier();
3088        }
3089        else if (name.equals("status")) {
3090          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.status");
3091        }
3092        else if (name.equals("intent")) {
3093          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.intent");
3094        }
3095        else if (name.equals("category")) {
3096          return addCategory();
3097        }
3098        else if (name.equals("priority")) {
3099          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.priority");
3100        }
3101        else if (name.equals("medicationCodeableConcept")) {
3102          this.medication = new CodeableConcept();
3103          return this.medication;
3104        }
3105        else if (name.equals("medicationReference")) {
3106          this.medication = new Reference();
3107          return this.medication;
3108        }
3109        else if (name.equals("subject")) {
3110          this.subject = new Reference();
3111          return this.subject;
3112        }
3113        else if (name.equals("context")) {
3114          this.context = new Reference();
3115          return this.context;
3116        }
3117        else if (name.equals("supportingInformation")) {
3118          return addSupportingInformation();
3119        }
3120        else if (name.equals("authoredOn")) {
3121          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.authoredOn");
3122        }
3123        else if (name.equals("requester")) {
3124          this.requester = new Reference();
3125          return this.requester;
3126        }
3127        else if (name.equals("performer")) {
3128          this.performer = new Reference();
3129          return this.performer;
3130        }
3131        else if (name.equals("performerType")) {
3132          this.performerType = new CodeableConcept();
3133          return this.performerType;
3134        }
3135        else if (name.equals("recorder")) {
3136          this.recorder = new Reference();
3137          return this.recorder;
3138        }
3139        else if (name.equals("reasonCode")) {
3140          return addReasonCode();
3141        }
3142        else if (name.equals("reasonReference")) {
3143          return addReasonReference();
3144        }
3145        else if (name.equals("instantiates")) {
3146          throw new FHIRException("Cannot call addChild on a primitive type MedicationRequest.instantiates");
3147        }
3148        else if (name.equals("basedOn")) {
3149          return addBasedOn();
3150        }
3151        else if (name.equals("groupIdentifier")) {
3152          this.groupIdentifier = new Identifier();
3153          return this.groupIdentifier;
3154        }
3155        else if (name.equals("statusReason")) {
3156          this.statusReason = new CodeableConcept();
3157          return this.statusReason;
3158        }
3159        else if (name.equals("insurance")) {
3160          return addInsurance();
3161        }
3162        else if (name.equals("note")) {
3163          return addNote();
3164        }
3165        else if (name.equals("dosageInstruction")) {
3166          return addDosageInstruction();
3167        }
3168        else if (name.equals("dispenseRequest")) {
3169          this.dispenseRequest = new MedicationRequestDispenseRequestComponent();
3170          return this.dispenseRequest;
3171        }
3172        else if (name.equals("substitution")) {
3173          this.substitution = new MedicationRequestSubstitutionComponent();
3174          return this.substitution;
3175        }
3176        else if (name.equals("priorPrescription")) {
3177          this.priorPrescription = new Reference();
3178          return this.priorPrescription;
3179        }
3180        else if (name.equals("detectedIssue")) {
3181          return addDetectedIssue();
3182        }
3183        else if (name.equals("eventHistory")) {
3184          return addEventHistory();
3185        }
3186        else
3187          return super.addChild(name);
3188      }
3189
3190  public String fhirType() {
3191    return "MedicationRequest";
3192
3193  }
3194
3195      public MedicationRequest copy() {
3196        MedicationRequest dst = new MedicationRequest();
3197        copyValues(dst);
3198        if (identifier != null) {
3199          dst.identifier = new ArrayList<Identifier>();
3200          for (Identifier i : identifier)
3201            dst.identifier.add(i.copy());
3202        };
3203        dst.status = status == null ? null : status.copy();
3204        dst.intent = intent == null ? null : intent.copy();
3205        if (category != null) {
3206          dst.category = new ArrayList<CodeableConcept>();
3207          for (CodeableConcept i : category)
3208            dst.category.add(i.copy());
3209        };
3210        dst.priority = priority == null ? null : priority.copy();
3211        dst.medication = medication == null ? null : medication.copy();
3212        dst.subject = subject == null ? null : subject.copy();
3213        dst.context = context == null ? null : context.copy();
3214        if (supportingInformation != null) {
3215          dst.supportingInformation = new ArrayList<Reference>();
3216          for (Reference i : supportingInformation)
3217            dst.supportingInformation.add(i.copy());
3218        };
3219        dst.authoredOn = authoredOn == null ? null : authoredOn.copy();
3220        dst.requester = requester == null ? null : requester.copy();
3221        dst.performer = performer == null ? null : performer.copy();
3222        dst.performerType = performerType == null ? null : performerType.copy();
3223        dst.recorder = recorder == null ? null : recorder.copy();
3224        if (reasonCode != null) {
3225          dst.reasonCode = new ArrayList<CodeableConcept>();
3226          for (CodeableConcept i : reasonCode)
3227            dst.reasonCode.add(i.copy());
3228        };
3229        if (reasonReference != null) {
3230          dst.reasonReference = new ArrayList<Reference>();
3231          for (Reference i : reasonReference)
3232            dst.reasonReference.add(i.copy());
3233        };
3234        if (instantiates != null) {
3235          dst.instantiates = new ArrayList<UriType>();
3236          for (UriType i : instantiates)
3237            dst.instantiates.add(i.copy());
3238        };
3239        if (basedOn != null) {
3240          dst.basedOn = new ArrayList<Reference>();
3241          for (Reference i : basedOn)
3242            dst.basedOn.add(i.copy());
3243        };
3244        dst.groupIdentifier = groupIdentifier == null ? null : groupIdentifier.copy();
3245        dst.statusReason = statusReason == null ? null : statusReason.copy();
3246        if (insurance != null) {
3247          dst.insurance = new ArrayList<Reference>();
3248          for (Reference i : insurance)
3249            dst.insurance.add(i.copy());
3250        };
3251        if (note != null) {
3252          dst.note = new ArrayList<Annotation>();
3253          for (Annotation i : note)
3254            dst.note.add(i.copy());
3255        };
3256        if (dosageInstruction != null) {
3257          dst.dosageInstruction = new ArrayList<Dosage>();
3258          for (Dosage i : dosageInstruction)
3259            dst.dosageInstruction.add(i.copy());
3260        };
3261        dst.dispenseRequest = dispenseRequest == null ? null : dispenseRequest.copy();
3262        dst.substitution = substitution == null ? null : substitution.copy();
3263        dst.priorPrescription = priorPrescription == null ? null : priorPrescription.copy();
3264        if (detectedIssue != null) {
3265          dst.detectedIssue = new ArrayList<Reference>();
3266          for (Reference i : detectedIssue)
3267            dst.detectedIssue.add(i.copy());
3268        };
3269        if (eventHistory != null) {
3270          dst.eventHistory = new ArrayList<Reference>();
3271          for (Reference i : eventHistory)
3272            dst.eventHistory.add(i.copy());
3273        };
3274        return dst;
3275      }
3276
3277      protected MedicationRequest typedCopy() {
3278        return copy();
3279      }
3280
3281      @Override
3282      public boolean equalsDeep(Base other_) {
3283        if (!super.equalsDeep(other_))
3284          return false;
3285        if (!(other_ instanceof MedicationRequest))
3286          return false;
3287        MedicationRequest o = (MedicationRequest) other_;
3288        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(intent, o.intent, true)
3289           && compareDeep(category, o.category, true) && compareDeep(priority, o.priority, true) && compareDeep(medication, o.medication, true)
3290           && compareDeep(subject, o.subject, true) && compareDeep(context, o.context, true) && compareDeep(supportingInformation, o.supportingInformation, true)
3291           && compareDeep(authoredOn, o.authoredOn, true) && compareDeep(requester, o.requester, true) && compareDeep(performer, o.performer, true)
3292           && compareDeep(performerType, o.performerType, true) && compareDeep(recorder, o.recorder, true)
3293           && compareDeep(reasonCode, o.reasonCode, true) && compareDeep(reasonReference, o.reasonReference, true)
3294           && compareDeep(instantiates, o.instantiates, true) && compareDeep(basedOn, o.basedOn, true) && compareDeep(groupIdentifier, o.groupIdentifier, true)
3295           && compareDeep(statusReason, o.statusReason, true) && compareDeep(insurance, o.insurance, true)
3296           && compareDeep(note, o.note, true) && compareDeep(dosageInstruction, o.dosageInstruction, true)
3297           && compareDeep(dispenseRequest, o.dispenseRequest, true) && compareDeep(substitution, o.substitution, true)
3298           && compareDeep(priorPrescription, o.priorPrescription, true) && compareDeep(detectedIssue, o.detectedIssue, true)
3299           && compareDeep(eventHistory, o.eventHistory, true);
3300      }
3301
3302      @Override
3303      public boolean equalsShallow(Base other_) {
3304        if (!super.equalsShallow(other_))
3305          return false;
3306        if (!(other_ instanceof MedicationRequest))
3307          return false;
3308        MedicationRequest o = (MedicationRequest) other_;
3309        return compareValues(status, o.status, true) && compareValues(intent, o.intent, true) && compareValues(priority, o.priority, true)
3310           && compareValues(authoredOn, o.authoredOn, true) && compareValues(instantiates, o.instantiates, true)
3311          ;
3312      }
3313
3314      public boolean isEmpty() {
3315        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, intent
3316          , category, priority, medication, subject, context, supportingInformation, authoredOn
3317          , requester, performer, performerType, recorder, reasonCode, reasonReference, instantiates
3318          , basedOn, groupIdentifier, statusReason, insurance, note, dosageInstruction, dispenseRequest
3319          , substitution, priorPrescription, detectedIssue, eventHistory);
3320      }
3321
3322  @Override
3323  public ResourceType getResourceType() {
3324    return ResourceType.MedicationRequest;
3325   }
3326
3327 /**
3328   * Search parameter: <b>requester</b>
3329   * <p>
3330   * Description: <b>Returns prescriptions prescribed by this prescriber</b><br>
3331   * Type: <b>reference</b><br>
3332   * Path: <b>MedicationRequest.requester</b><br>
3333   * </p>
3334   */
3335  @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 } )
3336  public static final String SP_REQUESTER = "requester";
3337 /**
3338   * <b>Fluent Client</b> search parameter constant for <b>requester</b>
3339   * <p>
3340   * Description: <b>Returns prescriptions prescribed by this prescriber</b><br>
3341   * Type: <b>reference</b><br>
3342   * Path: <b>MedicationRequest.requester</b><br>
3343   * </p>
3344   */
3345  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam REQUESTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_REQUESTER);
3346
3347/**
3348   * Constant for fluent queries to be used to add include statements. Specifies
3349   * the path value of "<b>MedicationRequest:requester</b>".
3350   */
3351  public static final ca.uhn.fhir.model.api.Include INCLUDE_REQUESTER = new ca.uhn.fhir.model.api.Include("MedicationRequest:requester").toLocked();
3352
3353 /**
3354   * Search parameter: <b>date</b>
3355   * <p>
3356   * Description: <b>Returns medication request to be administered on a specific date</b><br>
3357   * Type: <b>date</b><br>
3358   * Path: <b>MedicationRequest.dosageInstruction.timing.event</b><br>
3359   * </p>
3360   */
3361  @SearchParamDefinition(name="date", path="MedicationRequest.dosageInstruction.timing.event", description="Returns medication request to be administered on a specific date", type="date" )
3362  public static final String SP_DATE = "date";
3363 /**
3364   * <b>Fluent Client</b> search parameter constant for <b>date</b>
3365   * <p>
3366   * Description: <b>Returns medication request to be administered on a specific date</b><br>
3367   * Type: <b>date</b><br>
3368   * Path: <b>MedicationRequest.dosageInstruction.timing.event</b><br>
3369   * </p>
3370   */
3371  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
3372
3373 /**
3374   * Search parameter: <b>identifier</b>
3375   * <p>
3376   * Description: <b>Return prescriptions with this external identifier</b><br>
3377   * Type: <b>token</b><br>
3378   * Path: <b>MedicationRequest.identifier</b><br>
3379   * </p>
3380   */
3381  @SearchParamDefinition(name="identifier", path="MedicationRequest.identifier", description="Return prescriptions with this external identifier", type="token" )
3382  public static final String SP_IDENTIFIER = "identifier";
3383 /**
3384   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
3385   * <p>
3386   * Description: <b>Return prescriptions with this external identifier</b><br>
3387   * Type: <b>token</b><br>
3388   * Path: <b>MedicationRequest.identifier</b><br>
3389   * </p>
3390   */
3391  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
3392
3393 /**
3394   * Search parameter: <b>intended-dispenser</b>
3395   * <p>
3396   * Description: <b>Returns prescriptions intended to be dispensed by this Organization</b><br>
3397   * Type: <b>reference</b><br>
3398   * Path: <b>MedicationRequest.dispenseRequest.performer</b><br>
3399   * </p>
3400   */
3401  @SearchParamDefinition(name="intended-dispenser", path="MedicationRequest.dispenseRequest.performer", description="Returns prescriptions intended to be dispensed by this Organization", type="reference", target={Organization.class } )
3402  public static final String SP_INTENDED_DISPENSER = "intended-dispenser";
3403 /**
3404   * <b>Fluent Client</b> search parameter constant for <b>intended-dispenser</b>
3405   * <p>
3406   * Description: <b>Returns prescriptions intended to be dispensed by this Organization</b><br>
3407   * Type: <b>reference</b><br>
3408   * Path: <b>MedicationRequest.dispenseRequest.performer</b><br>
3409   * </p>
3410   */
3411  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam INTENDED_DISPENSER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_INTENDED_DISPENSER);
3412
3413/**
3414   * Constant for fluent queries to be used to add include statements. Specifies
3415   * the path value of "<b>MedicationRequest:intended-dispenser</b>".
3416   */
3417  public static final ca.uhn.fhir.model.api.Include INCLUDE_INTENDED_DISPENSER = new ca.uhn.fhir.model.api.Include("MedicationRequest:intended-dispenser").toLocked();
3418
3419 /**
3420   * Search parameter: <b>authoredon</b>
3421   * <p>
3422   * Description: <b>Return prescriptions written on this date</b><br>
3423   * Type: <b>date</b><br>
3424   * Path: <b>MedicationRequest.authoredOn</b><br>
3425   * </p>
3426   */
3427  @SearchParamDefinition(name="authoredon", path="MedicationRequest.authoredOn", description="Return prescriptions written on this date", type="date" )
3428  public static final String SP_AUTHOREDON = "authoredon";
3429 /**
3430   * <b>Fluent Client</b> search parameter constant for <b>authoredon</b>
3431   * <p>
3432   * Description: <b>Return prescriptions written on this date</b><br>
3433   * Type: <b>date</b><br>
3434   * Path: <b>MedicationRequest.authoredOn</b><br>
3435   * </p>
3436   */
3437  public static final ca.uhn.fhir.rest.gclient.DateClientParam AUTHOREDON = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_AUTHOREDON);
3438
3439 /**
3440   * Search parameter: <b>code</b>
3441   * <p>
3442   * Description: <b>Return prescriptions of this medication code</b><br>
3443   * Type: <b>token</b><br>
3444   * Path: <b>MedicationRequest.medicationCodeableConcept</b><br>
3445   * </p>
3446   */
3447  @SearchParamDefinition(name="code", path="MedicationRequest.medication.as(CodeableConcept)", description="Return prescriptions of this medication code", type="token" )
3448  public static final String SP_CODE = "code";
3449 /**
3450   * <b>Fluent Client</b> search parameter constant for <b>code</b>
3451   * <p>
3452   * Description: <b>Return prescriptions of this medication code</b><br>
3453   * Type: <b>token</b><br>
3454   * Path: <b>MedicationRequest.medicationCodeableConcept</b><br>
3455   * </p>
3456   */
3457  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
3458
3459 /**
3460   * Search parameter: <b>subject</b>
3461   * <p>
3462   * Description: <b>The identity of a patient to list orders  for</b><br>
3463   * Type: <b>reference</b><br>
3464   * Path: <b>MedicationRequest.subject</b><br>
3465   * </p>
3466   */
3467  @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 } )
3468  public static final String SP_SUBJECT = "subject";
3469 /**
3470   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
3471   * <p>
3472   * Description: <b>The identity of a patient to list orders  for</b><br>
3473   * Type: <b>reference</b><br>
3474   * Path: <b>MedicationRequest.subject</b><br>
3475   * </p>
3476   */
3477  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
3478
3479/**
3480   * Constant for fluent queries to be used to add include statements. Specifies
3481   * the path value of "<b>MedicationRequest:subject</b>".
3482   */
3483  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("MedicationRequest:subject").toLocked();
3484
3485 /**
3486   * Search parameter: <b>medication</b>
3487   * <p>
3488   * Description: <b>Return prescriptions for this medication reference</b><br>
3489   * Type: <b>reference</b><br>
3490   * Path: <b>MedicationRequest.medicationReference</b><br>
3491   * </p>
3492   */
3493  @SearchParamDefinition(name="medication", path="MedicationRequest.medication.as(Reference)", description="Return prescriptions for this medication reference", type="reference", target={Medication.class } )
3494  public static final String SP_MEDICATION = "medication";
3495 /**
3496   * <b>Fluent Client</b> search parameter constant for <b>medication</b>
3497   * <p>
3498   * Description: <b>Return prescriptions for this medication reference</b><br>
3499   * Type: <b>reference</b><br>
3500   * Path: <b>MedicationRequest.medicationReference</b><br>
3501   * </p>
3502   */
3503  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam MEDICATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_MEDICATION);
3504
3505/**
3506   * Constant for fluent queries to be used to add include statements. Specifies
3507   * the path value of "<b>MedicationRequest:medication</b>".
3508   */
3509  public static final ca.uhn.fhir.model.api.Include INCLUDE_MEDICATION = new ca.uhn.fhir.model.api.Include("MedicationRequest:medication").toLocked();
3510
3511 /**
3512   * Search parameter: <b>priority</b>
3513   * <p>
3514   * Description: <b>Returns prescriptions with different priorities</b><br>
3515   * Type: <b>token</b><br>
3516   * Path: <b>MedicationRequest.priority</b><br>
3517   * </p>
3518   */
3519  @SearchParamDefinition(name="priority", path="MedicationRequest.priority", description="Returns prescriptions with different priorities", type="token" )
3520  public static final String SP_PRIORITY = "priority";
3521 /**
3522   * <b>Fluent Client</b> search parameter constant for <b>priority</b>
3523   * <p>
3524   * Description: <b>Returns prescriptions with different priorities</b><br>
3525   * Type: <b>token</b><br>
3526   * Path: <b>MedicationRequest.priority</b><br>
3527   * </p>
3528   */
3529  public static final ca.uhn.fhir.rest.gclient.TokenClientParam PRIORITY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_PRIORITY);
3530
3531 /**
3532   * Search parameter: <b>intent</b>
3533   * <p>
3534   * Description: <b>Returns prescriptions with different intents</b><br>
3535   * Type: <b>token</b><br>
3536   * Path: <b>MedicationRequest.intent</b><br>
3537   * </p>
3538   */
3539  @SearchParamDefinition(name="intent", path="MedicationRequest.intent", description="Returns prescriptions with different intents", type="token" )
3540  public static final String SP_INTENT = "intent";
3541 /**
3542   * <b>Fluent Client</b> search parameter constant for <b>intent</b>
3543   * <p>
3544   * Description: <b>Returns prescriptions with different intents</b><br>
3545   * Type: <b>token</b><br>
3546   * Path: <b>MedicationRequest.intent</b><br>
3547   * </p>
3548   */
3549  public static final ca.uhn.fhir.rest.gclient.TokenClientParam INTENT = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_INTENT);
3550
3551 /**
3552   * Search parameter: <b>patient</b>
3553   * <p>
3554   * Description: <b>Returns prescriptions for a specific patient</b><br>
3555   * Type: <b>reference</b><br>
3556   * Path: <b>MedicationRequest.subject</b><br>
3557   * </p>
3558   */
3559  @SearchParamDefinition(name="patient", path="MedicationRequest.subject", description="Returns prescriptions for a specific patient", type="reference", target={Patient.class } )
3560  public static final String SP_PATIENT = "patient";
3561 /**
3562   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
3563   * <p>
3564   * Description: <b>Returns prescriptions for a specific patient</b><br>
3565   * Type: <b>reference</b><br>
3566   * Path: <b>MedicationRequest.subject</b><br>
3567   * </p>
3568   */
3569  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
3570
3571/**
3572   * Constant for fluent queries to be used to add include statements. Specifies
3573   * the path value of "<b>MedicationRequest:patient</b>".
3574   */
3575  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("MedicationRequest:patient").toLocked();
3576
3577 /**
3578   * Search parameter: <b>intended-performer</b>
3579   * <p>
3580   * Description: <b>Returns the intended performer of the administration of the medication request</b><br>
3581   * Type: <b>reference</b><br>
3582   * Path: <b>MedicationRequest.performer</b><br>
3583   * </p>
3584   */
3585  @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 } )
3586  public static final String SP_INTENDED_PERFORMER = "intended-performer";
3587 /**
3588   * <b>Fluent Client</b> search parameter constant for <b>intended-performer</b>
3589   * <p>
3590   * Description: <b>Returns the intended performer of the administration of the medication request</b><br>
3591   * Type: <b>reference</b><br>
3592   * Path: <b>MedicationRequest.performer</b><br>
3593   * </p>
3594   */
3595  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam INTENDED_PERFORMER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_INTENDED_PERFORMER);
3596
3597/**
3598   * Constant for fluent queries to be used to add include statements. Specifies
3599   * the path value of "<b>MedicationRequest:intended-performer</b>".
3600   */
3601  public static final ca.uhn.fhir.model.api.Include INCLUDE_INTENDED_PERFORMER = new ca.uhn.fhir.model.api.Include("MedicationRequest:intended-performer").toLocked();
3602
3603 /**
3604   * Search parameter: <b>context</b>
3605   * <p>
3606   * Description: <b>Return prescriptions with this encounter or episode of care identifier</b><br>
3607   * Type: <b>reference</b><br>
3608   * Path: <b>MedicationRequest.context</b><br>
3609   * </p>
3610   */
3611  @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 } )
3612  public static final String SP_CONTEXT = "context";
3613 /**
3614   * <b>Fluent Client</b> search parameter constant for <b>context</b>
3615   * <p>
3616   * Description: <b>Return prescriptions with this encounter or episode of care identifier</b><br>
3617   * Type: <b>reference</b><br>
3618   * Path: <b>MedicationRequest.context</b><br>
3619   * </p>
3620   */
3621  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam CONTEXT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_CONTEXT);
3622
3623/**
3624   * Constant for fluent queries to be used to add include statements. Specifies
3625   * the path value of "<b>MedicationRequest:context</b>".
3626   */
3627  public static final ca.uhn.fhir.model.api.Include INCLUDE_CONTEXT = new ca.uhn.fhir.model.api.Include("MedicationRequest:context").toLocked();
3628
3629 /**
3630   * Search parameter: <b>intended-performertype</b>
3631   * <p>
3632   * Description: <b>Returns requests for a specific type of performer</b><br>
3633   * Type: <b>token</b><br>
3634   * Path: <b>MedicationRequest.performerType</b><br>
3635   * </p>
3636   */
3637  @SearchParamDefinition(name="intended-performertype", path="MedicationRequest.performerType", description="Returns requests for a specific type of performer", type="token" )
3638  public static final String SP_INTENDED_PERFORMERTYPE = "intended-performertype";
3639 /**
3640   * <b>Fluent Client</b> search parameter constant for <b>intended-performertype</b>
3641   * <p>
3642   * Description: <b>Returns requests for a specific type of performer</b><br>
3643   * Type: <b>token</b><br>
3644   * Path: <b>MedicationRequest.performerType</b><br>
3645   * </p>
3646   */
3647  public static final ca.uhn.fhir.rest.gclient.TokenClientParam INTENDED_PERFORMERTYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_INTENDED_PERFORMERTYPE);
3648
3649 /**
3650   * Search parameter: <b>category</b>
3651   * <p>
3652   * Description: <b>Returns prescriptions with different categories</b><br>
3653   * Type: <b>token</b><br>
3654   * Path: <b>MedicationRequest.category</b><br>
3655   * </p>
3656   */
3657  @SearchParamDefinition(name="category", path="MedicationRequest.category", description="Returns prescriptions with different categories", type="token" )
3658  public static final String SP_CATEGORY = "category";
3659 /**
3660   * <b>Fluent Client</b> search parameter constant for <b>category</b>
3661   * <p>
3662   * Description: <b>Returns prescriptions with different categories</b><br>
3663   * Type: <b>token</b><br>
3664   * Path: <b>MedicationRequest.category</b><br>
3665   * </p>
3666   */
3667  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CATEGORY);
3668
3669 /**
3670   * Search parameter: <b>status</b>
3671   * <p>
3672   * Description: <b>Status of the prescription</b><br>
3673   * Type: <b>token</b><br>
3674   * Path: <b>MedicationRequest.status</b><br>
3675   * </p>
3676   */
3677  @SearchParamDefinition(name="status", path="MedicationRequest.status", description="Status of the prescription", type="token" )
3678  public static final String SP_STATUS = "status";
3679 /**
3680   * <b>Fluent Client</b> search parameter constant for <b>status</b>
3681   * <p>
3682   * Description: <b>Status of the prescription</b><br>
3683   * Type: <b>token</b><br>
3684   * Path: <b>MedicationRequest.status</b><br>
3685   * </p>
3686   */
3687  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
3688
3689
3690}
3691